summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto')
-rw-r--r--src/lib/libcrypto/Makefile.ssl214
-rw-r--r--src/lib/libcrypto/aes/Makefile.ssl103
-rw-r--r--src/lib/libcrypto/aes/aes.h9
-rw-r--r--src/lib/libcrypto/aes/aes_cbc.c58
-rw-r--r--src/lib/libcrypto/aes/aes_cfb.c6
-rw-r--r--src/lib/libcrypto/aes/aes_core.c12
-rw-r--r--src/lib/libcrypto/aes/aes_ctr.c21
-rw-r--r--src/lib/libcrypto/aes/aes_ecb.c6
-rw-r--r--src/lib/libcrypto/aes/aes_locl.h2
-rw-r--r--src/lib/libcrypto/aes/aes_ofb.c6
-rw-r--r--src/lib/libcrypto/asn1/Makefile.ssl1151
-rw-r--r--src/lib/libcrypto/asn1/a_bitstr.c4
-rw-r--r--src/lib/libcrypto/asn1/a_bytes.c2
-rw-r--r--src/lib/libcrypto/asn1/a_d2i_fp.c24
-rw-r--r--src/lib/libcrypto/asn1/a_gentm.c240
-rw-r--r--src/lib/libcrypto/asn1/a_hdr.c119
-rw-r--r--src/lib/libcrypto/asn1/a_mbstr.c4
-rw-r--r--src/lib/libcrypto/asn1/a_meth.c84
-rw-r--r--src/lib/libcrypto/asn1/a_object.c4
-rw-r--r--src/lib/libcrypto/asn1/a_sign.c8
-rw-r--r--src/lib/libcrypto/asn1/a_strex.c14
-rw-r--r--src/lib/libcrypto/asn1/a_strnid.c35
-rw-r--r--src/lib/libcrypto/asn1/a_time.c12
-rw-r--r--src/lib/libcrypto/asn1/a_type.c2
-rw-r--r--src/lib/libcrypto/asn1/a_utctm.c298
-rw-r--r--src/lib/libcrypto/asn1/a_verify.c4
-rw-r--r--src/lib/libcrypto/asn1/asn1.h5
-rw-r--r--src/lib/libcrypto/asn1/asn1_err.c4
-rw-r--r--src/lib/libcrypto/asn1/asn1_lib.c4
-rw-r--r--src/lib/libcrypto/asn1/asn1_par.c13
-rw-r--r--src/lib/libcrypto/asn1/f.c80
-rw-r--r--src/lib/libcrypto/asn1/f_int.c3
-rw-r--r--src/lib/libcrypto/asn1/n_pkey.c6
-rw-r--r--src/lib/libcrypto/asn1/p8_key.c131
-rw-r--r--src/lib/libcrypto/asn1/p8_pkey.c4
-rw-r--r--src/lib/libcrypto/asn1/t_crl.c7
-rw-r--r--src/lib/libcrypto/asn1/t_pkey.c36
-rw-r--r--src/lib/libcrypto/asn1/t_req.c19
-rw-r--r--src/lib/libcrypto/asn1/t_x509.c9
-rw-r--r--src/lib/libcrypto/asn1/t_x509a.c4
-rw-r--r--src/lib/libcrypto/asn1/tasn_dec.c4
-rw-r--r--src/lib/libcrypto/asn1/tasn_fre.c5
-rw-r--r--src/lib/libcrypto/asn1/tasn_new.c5
-rw-r--r--src/lib/libcrypto/asn1/tasn_prn.c2
-rw-r--r--src/lib/libcrypto/asn1/x_cinf.c201
-rw-r--r--src/lib/libcrypto/asn1/x_long.c10
-rw-r--r--src/lib/libcrypto/bf/Makefile.ssl120
-rw-r--r--src/lib/libcrypto/bf/asm/bf-686.pl127
-rw-r--r--src/lib/libcrypto/bf/asm/readme10
-rw-r--r--src/lib/libcrypto/bf/bf_opts.c328
-rw-r--r--src/lib/libcrypto/bf/bfs.cpp67
-rw-r--r--src/lib/libcrypto/bf/bfspeed.c274
-rw-r--r--src/lib/libcrypto/bf/bftest.c534
-rw-r--r--src/lib/libcrypto/bio/Makefile.ssl216
-rw-r--r--src/lib/libcrypto/bio/b_dump.c32
-rw-r--r--src/lib/libcrypto/bio/b_print.c29
-rw-r--r--src/lib/libcrypto/bio/b_sock.c28
-rw-r--r--src/lib/libcrypto/bio/bf_buff.c2
-rw-r--r--src/lib/libcrypto/bio/bio.h7
-rw-r--r--src/lib/libcrypto/bio/bio_cb.c36
-rw-r--r--src/lib/libcrypto/bio/bio_lib.c15
-rw-r--r--src/lib/libcrypto/bio/bss_bio.c3
-rw-r--r--src/lib/libcrypto/bio/bss_conn.c10
-rw-r--r--src/lib/libcrypto/bio/bss_file.c12
-rw-r--r--src/lib/libcrypto/bio/bss_log.c13
-rw-r--r--src/lib/libcrypto/bio/bss_mem.c8
-rw-r--r--src/lib/libcrypto/bio/bss_rtcp.c294
-rw-r--r--src/lib/libcrypto/bio/bss_sock.c6
-rw-r--r--src/lib/libcrypto/bn/Makefile.ssl339
-rw-r--r--src/lib/libcrypto/bn/asm/README27
-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-alpha.pl571
-rw-r--r--src/lib/libcrypto/bn/asm/ca.pl33
-rw-r--r--src/lib/libcrypto/bn/asm/co-alpha.pl116
-rw-r--r--src/lib/libcrypto/bn/asm/ia64.S235
-rw-r--r--src/lib/libcrypto/bn/asm/mips1.s539
-rw-r--r--src/lib/libcrypto/bn/asm/mips3.s2201
-rw-r--r--src/lib/libcrypto/bn/asm/pa-risc.s710
-rw-r--r--src/lib/libcrypto/bn/asm/pa-risc2.s36
-rw-r--r--src/lib/libcrypto/bn/asm/r3000.s646
-rw-r--r--src/lib/libcrypto/bn/asm/vms.mar6412
-rw-r--r--src/lib/libcrypto/bn/asm/x86/f3
-rw-r--r--src/lib/libcrypto/bn/bn.h2
-rw-r--r--src/lib/libcrypto/bn/bn.mul19
-rw-r--r--src/lib/libcrypto/bn/bn_div.c28
-rw-r--r--src/lib/libcrypto/bn/bn_lcl.h26
-rw-r--r--src/lib/libcrypto/bn/bn_lib.c8
-rw-r--r--src/lib/libcrypto/bn/bn_mul.c529
-rw-r--r--src/lib/libcrypto/bn/bn_prime.c2
-rw-r--r--src/lib/libcrypto/bn/bn_print.c5
-rw-r--r--src/lib/libcrypto/bn/bn_rand.c2
-rw-r--r--src/lib/libcrypto/bn/bn_word.c5
-rw-r--r--src/lib/libcrypto/bn/bnspeed.c233
-rw-r--r--src/lib/libcrypto/bn/bntest.c1243
-rw-r--r--src/lib/libcrypto/bn/divtest.c41
-rw-r--r--src/lib/libcrypto/bn/exp.c62
-rw-r--r--src/lib/libcrypto/bn/expspeed.c353
-rw-r--r--src/lib/libcrypto/bn/exptest.c187
-rw-r--r--src/lib/libcrypto/bn/todo3
-rw-r--r--src/lib/libcrypto/bn/vms-helper.c68
-rw-r--r--src/lib/libcrypto/buffer/Makefile.ssl94
-rw-r--r--src/lib/libcrypto/buffer/buffer.c57
-rw-r--r--src/lib/libcrypto/buffer/buffer.h9
-rw-r--r--src/lib/libcrypto/cast/Makefile.ssl125
-rw-r--r--src/lib/libcrypto/cast/asm/readme7
-rw-r--r--src/lib/libcrypto/cast/cast_spd.c275
-rw-r--r--src/lib/libcrypto/cast/castopts.c339
-rw-r--r--src/lib/libcrypto/cast/casts.cpp70
-rw-r--r--src/lib/libcrypto/cast/casttest.c230
-rw-r--r--src/lib/libcrypto/comp/Makefile.ssl114
-rw-r--r--src/lib/libcrypto/comp/c_zlib.c4
-rw-r--r--src/lib/libcrypto/conf/Makefile.ssl183
-rw-r--r--src/lib/libcrypto/conf/cnf_save.c106
-rw-r--r--src/lib/libcrypto/conf/conf_def.c24
-rw-r--r--src/lib/libcrypto/conf/conf_mall.c4
-rw-r--r--src/lib/libcrypto/conf/conf_mod.c8
-rw-r--r--src/lib/libcrypto/conf/conf_sap.c4
-rw-r--r--src/lib/libcrypto/conf/test.c98
-rw-r--r--src/lib/libcrypto/cryptlib.c40
-rw-r--r--src/lib/libcrypto/cryptlib.h6
-rw-r--r--src/lib/libcrypto/crypto-lib.com1512
-rw-r--r--src/lib/libcrypto/crypto.h65
-rw-r--r--src/lib/libcrypto/cversion.c8
-rw-r--r--src/lib/libcrypto/des/DES.pm19
-rw-r--r--src/lib/libcrypto/des/DES.xs268
-rw-r--r--src/lib/libcrypto/des/FILES96
-rw-r--r--src/lib/libcrypto/des/INSTALL69
-rw-r--r--src/lib/libcrypto/des/Imakefile35
-rw-r--r--src/lib/libcrypto/des/KERBEROS41
-rw-r--r--src/lib/libcrypto/des/Makefile.ssl325
-rw-r--r--src/lib/libcrypto/des/README54
-rw-r--r--src/lib/libcrypto/des/VERSION412
-rw-r--r--src/lib/libcrypto/des/asm/crypt586.pl46
-rw-r--r--src/lib/libcrypto/des/asm/des-586.pl50
-rw-r--r--src/lib/libcrypto/des/asm/des686.pl230
-rw-r--r--src/lib/libcrypto/des/asm/readme131
-rw-r--r--src/lib/libcrypto/des/cbc3_enc.c99
-rw-r--r--src/lib/libcrypto/des/cbc_cksm.c9
-rw-r--r--src/lib/libcrypto/des/des-lib.com1003
-rw-r--r--src/lib/libcrypto/des/des.c932
-rw-r--r--src/lib/libcrypto/des/des.h6
-rw-r--r--src/lib/libcrypto/des/des.pod217
-rw-r--r--src/lib/libcrypto/des/des3s.cpp67
-rw-r--r--src/lib/libcrypto/des/des_locl.h13
-rw-r--r--src/lib/libcrypto/des/des_old.c271
-rw-r--r--src/lib/libcrypto/des/des_old.h439
-rw-r--r--src/lib/libcrypto/des/des_old2.c82
-rw-r--r--src/lib/libcrypto/des/des_opts.c604
-rw-r--r--src/lib/libcrypto/des/des_ver.h67
-rw-r--r--src/lib/libcrypto/des/dess.cpp67
-rw-r--r--src/lib/libcrypto/des/destest.c946
-rw-r--r--src/lib/libcrypto/des/ecb_enc.c3
-rw-r--r--src/lib/libcrypto/des/makefile.bc50
-rw-r--r--src/lib/libcrypto/des/options.txt39
-rw-r--r--src/lib/libcrypto/des/read2pwd.c139
-rw-r--r--src/lib/libcrypto/des/read_pwd.c511
-rw-r--r--src/lib/libcrypto/des/rpc_des.h131
-rw-r--r--src/lib/libcrypto/des/rpc_enc.c98
-rw-r--r--src/lib/libcrypto/des/rpw.c99
-rw-r--r--src/lib/libcrypto/des/speed.c310
-rw-r--r--src/lib/libcrypto/des/str2key.c4
-rw-r--r--src/lib/libcrypto/des/t/test27
-rw-r--r--src/lib/libcrypto/des/times/486-50.sol16
-rw-r--r--src/lib/libcrypto/des/times/586-100.lnx20
-rw-r--r--src/lib/libcrypto/des/times/686-200.fre18
-rw-r--r--src/lib/libcrypto/des/times/aix.cc26
-rw-r--r--src/lib/libcrypto/des/times/alpha.cc18
-rw-r--r--src/lib/libcrypto/des/times/hpux.cc17
-rw-r--r--src/lib/libcrypto/des/times/sparc.gcc17
-rw-r--r--src/lib/libcrypto/des/times/usparc.cc31
-rw-r--r--src/lib/libcrypto/des/typemap34
-rw-r--r--src/lib/libcrypto/dh/Makefile.ssl136
-rw-r--r--src/lib/libcrypto/dh/dh.h2
-rw-r--r--src/lib/libcrypto/dh/dh1024.pem5
-rw-r--r--src/lib/libcrypto/dh/dh192.pem3
-rw-r--r--src/lib/libcrypto/dh/dh2048.pem16
-rw-r--r--src/lib/libcrypto/dh/dh4096.pem14
-rw-r--r--src/lib/libcrypto/dh/dh512.pem4
-rw-r--r--src/lib/libcrypto/dh/dh_key.c1
-rw-r--r--src/lib/libcrypto/dh/dh_lib.c10
-rw-r--r--src/lib/libcrypto/dh/dhtest.c216
-rw-r--r--src/lib/libcrypto/dh/example50
-rw-r--r--src/lib/libcrypto/dh/generate65
-rw-r--r--src/lib/libcrypto/dh/p1024.c92
-rw-r--r--src/lib/libcrypto/dh/p192.c80
-rw-r--r--src/lib/libcrypto/dh/p512.c85
-rw-r--r--src/lib/libcrypto/doc/DH_generate_parameters.pod3
-rw-r--r--src/lib/libcrypto/doc/DSA_SIG_new.pod3
-rw-r--r--src/lib/libcrypto/doc/DSA_generate_key.pod3
-rw-r--r--src/lib/libcrypto/doc/ERR_get_error.pod2
-rw-r--r--src/lib/libcrypto/doc/EVP_DigestInit.pod6
-rw-r--r--src/lib/libcrypto/doc/EVP_EncryptInit.pod2
-rw-r--r--src/lib/libcrypto/doc/EVP_SealInit.pod26
-rw-r--r--src/lib/libcrypto/doc/EVP_SignInit.pod8
-rw-r--r--src/lib/libcrypto/doc/OpenSSL_add_all_algorithms.pod2
-rw-r--r--src/lib/libcrypto/doc/RAND_bytes.pod3
-rw-r--r--src/lib/libcrypto/doc/RSA_generate_key.pod3
-rw-r--r--src/lib/libcrypto/doc/RSA_print.pod8
-rw-r--r--src/lib/libcrypto/doc/RSA_private_encrypt.pod4
-rw-r--r--src/lib/libcrypto/doc/RSA_public_encrypt.pod3
-rw-r--r--src/lib/libcrypto/doc/RSA_set_method.pod13
-rw-r--r--src/lib/libcrypto/doc/RSA_sign_ASN1_OCTET_STRING.pod4
-rw-r--r--src/lib/libcrypto/doc/d2i_DHparams.pod14
-rw-r--r--src/lib/libcrypto/doc/d2i_RSAPublicKey.pod39
-rw-r--r--src/lib/libcrypto/doc/dsa.pod3
-rw-r--r--src/lib/libcrypto/dsa/Makefile.ssl177
-rw-r--r--src/lib/libcrypto/dsa/README4
-rw-r--r--src/lib/libcrypto/dsa/dsa_lib.c15
-rw-r--r--src/lib/libcrypto/dsa/dsa_ossl.c14
-rw-r--r--src/lib/libcrypto/dsa/dsa_sign.c1
-rw-r--r--src/lib/libcrypto/dsa/dsa_vrf.c1
-rw-r--r--src/lib/libcrypto/dsa/dsagen.c111
-rw-r--r--src/lib/libcrypto/dsa/dsatest.c237
-rw-r--r--src/lib/libcrypto/dsa/fips186a.txt122
-rw-r--r--src/lib/libcrypto/dso/Makefile.ssl142
-rw-r--r--src/lib/libcrypto/dso/README22
-rw-r--r--src/lib/libcrypto/dso/dso_dl.c284
-rw-r--r--src/lib/libcrypto/dso/dso_lib.c4
-rw-r--r--src/lib/libcrypto/dso/dso_vms.c379
-rw-r--r--src/lib/libcrypto/dso/dso_win32.c279
-rw-r--r--src/lib/libcrypto/ebcdic.c218
-rw-r--r--src/lib/libcrypto/ebcdic.h19
-rw-r--r--src/lib/libcrypto/ec/Makefile.ssl128
-rw-r--r--src/lib/libcrypto/ec/ec.h2
-rw-r--r--src/lib/libcrypto/ec/ec_err.c2
-rw-r--r--src/lib/libcrypto/ec/ec_lib.c8
-rw-r--r--src/lib/libcrypto/ec/ec_mult.c11
-rw-r--r--src/lib/libcrypto/ec/ecp_recp.c133
-rw-r--r--src/lib/libcrypto/ec/ectest.c634
-rw-r--r--src/lib/libcrypto/engine/Makefile.ssl556
-rw-r--r--src/lib/libcrypto/engine/eng_all.c18
-rw-r--r--src/lib/libcrypto/engine/eng_ctrl.c10
-rw-r--r--src/lib/libcrypto/engine/eng_err.c3
-rw-r--r--src/lib/libcrypto/engine/eng_fat.c8
-rw-r--r--src/lib/libcrypto/engine/eng_list.c33
-rw-r--r--src/lib/libcrypto/engine/eng_openssl.c18
-rw-r--r--src/lib/libcrypto/engine/engine.h13
-rw-r--r--src/lib/libcrypto/engine/enginetest.c274
-rw-r--r--src/lib/libcrypto/engine/hw.ec8
-rw-r--r--src/lib/libcrypto/engine/hw_4758_cca.c967
-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.c1119
-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.c592
-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_cryptodev.c1106
-rw-r--r--src/lib/libcrypto/engine/hw_cswift.c924
-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.c1342
-rw-r--r--src/lib/libcrypto/engine/hw_ncipher_err.c156
-rw-r--r--src/lib/libcrypto/engine/hw_ncipher_err.h100
-rw-r--r--src/lib/libcrypto/engine/hw_nuron.c416
-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_openbsd_dev_crypto.c594
-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.c1059
-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/tb_cipher.c4
-rw-r--r--src/lib/libcrypto/engine/tb_dh.c4
-rw-r--r--src/lib/libcrypto/engine/tb_digest.c4
-rw-r--r--src/lib/libcrypto/engine/tb_dsa.c4
-rw-r--r--src/lib/libcrypto/engine/tb_rand.c4
-rw-r--r--src/lib/libcrypto/engine/tb_rsa.c4
-rw-r--r--src/lib/libcrypto/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/err/Makefile.ssl119
-rw-r--r--src/lib/libcrypto/err/err.c4
-rw-r--r--src/lib/libcrypto/err/err_all.c4
-rw-r--r--src/lib/libcrypto/err/err_prn.c1
-rw-r--r--src/lib/libcrypto/evp/Makefile.ssl1060
-rw-r--r--src/lib/libcrypto/evp/bio_b64.c1
-rw-r--r--src/lib/libcrypto/evp/bio_enc.c9
-rw-r--r--src/lib/libcrypto/evp/bio_ok.c575
-rw-r--r--src/lib/libcrypto/evp/c_all.c6
-rw-r--r--src/lib/libcrypto/evp/c_allc.c180
-rw-r--r--src/lib/libcrypto/evp/c_alld.c103
-rw-r--r--src/lib/libcrypto/evp/digest.c17
-rw-r--r--src/lib/libcrypto/evp/e_aes.c1
-rw-r--r--src/lib/libcrypto/evp/e_dsa.c71
-rw-r--r--src/lib/libcrypto/evp/e_idea.c2
-rw-r--r--src/lib/libcrypto/evp/e_rc2.c1
-rw-r--r--src/lib/libcrypto/evp/e_rc4.c5
-rw-r--r--src/lib/libcrypto/evp/e_rc5.c125
-rw-r--r--src/lib/libcrypto/evp/encode.c2
-rw-r--r--src/lib/libcrypto/evp/evp.h54
-rw-r--r--src/lib/libcrypto/evp/evp_acnf.c74
-rw-r--r--src/lib/libcrypto/evp/evp_enc.c30
-rw-r--r--src/lib/libcrypto/evp/evp_key.c6
-rw-r--r--src/lib/libcrypto/evp/evp_lib.c2
-rw-r--r--src/lib/libcrypto/evp/evp_pbe.c4
-rw-r--r--src/lib/libcrypto/evp/evp_pkey.c2
-rw-r--r--src/lib/libcrypto/evp/evp_test.c386
-rw-r--r--src/lib/libcrypto/evp/evptests.txt183
-rw-r--r--src/lib/libcrypto/evp/m_md2.c96
-rw-r--r--src/lib/libcrypto/evp/m_mdc2.c96
-rw-r--r--src/lib/libcrypto/evp/m_sha.c95
-rw-r--r--src/lib/libcrypto/evp/openbsd_hw.c446
-rw-r--r--src/lib/libcrypto/evp/p5_crpt.c8
-rw-r--r--src/lib/libcrypto/evp/p5_crpt2.c3
-rw-r--r--src/lib/libcrypto/evp/p_open.c2
-rw-r--r--src/lib/libcrypto/hmac/Makefile.ssl99
-rw-r--r--src/lib/libcrypto/hmac/hmac.c3
-rw-r--r--src/lib/libcrypto/hmac/hmactest.c160
-rw-r--r--src/lib/libcrypto/idea/Makefile.ssl91
-rw-r--r--src/lib/libcrypto/install.com138
-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.c101
-rw-r--r--src/lib/libcrypto/lhash/lh_test.c88
-rw-r--r--src/lib/libcrypto/lhash/num.pl17
-rw-r--r--src/lib/libcrypto/md2/Makefile.ssl90
-rw-r--r--src/lib/libcrypto/md2/md2.c124
-rw-r--r--src/lib/libcrypto/md2/md2.h91
-rw-r--r--src/lib/libcrypto/md2/md2_dgst.c226
-rw-r--r--src/lib/libcrypto/md2/md2_one.c93
-rw-r--r--src/lib/libcrypto/md2/md2test.c138
-rw-r--r--src/lib/libcrypto/md32_common.h38
-rw-r--r--src/lib/libcrypto/md4/Makefile.ssl88
-rw-r--r--src/lib/libcrypto/md4/md4.c127
-rw-r--r--src/lib/libcrypto/md4/md4_dgst.c36
-rw-r--r--src/lib/libcrypto/md4/md4_one.c3
-rw-r--r--src/lib/libcrypto/md4/md4s.cpp78
-rw-r--r--src/lib/libcrypto/md4/md4test.c134
-rw-r--r--src/lib/libcrypto/md5/Makefile.ssl135
-rw-r--r--src/lib/libcrypto/md5/asm/md5-sparcv9.S1029
-rw-r--r--src/lib/libcrypto/md5/md5.c127
-rw-r--r--src/lib/libcrypto/md5/md5.h4
-rw-r--r--src/lib/libcrypto/md5/md5_dgst.c36
-rw-r--r--src/lib/libcrypto/md5/md5_locl.h2
-rw-r--r--src/lib/libcrypto/md5/md5_one.c3
-rw-r--r--src/lib/libcrypto/md5/md5s.cpp78
-rw-r--r--src/lib/libcrypto/md5/md5test.c134
-rw-r--r--src/lib/libcrypto/mdc2/Makefile.ssl98
-rw-r--r--src/lib/libcrypto/mdc2/mdc2.h95
-rw-r--r--src/lib/libcrypto/mem.c358
-rw-r--r--src/lib/libcrypto/mem_dbg.c41
-rw-r--r--src/lib/libcrypto/o_time.c3
-rw-r--r--src/lib/libcrypto/objects/Makefile.ssl123
-rw-r--r--src/lib/libcrypto/objects/obj_dat.c11
-rw-r--r--src/lib/libcrypto/objects/obj_dat.pl4
-rw-r--r--src/lib/libcrypto/objects/obj_mac.num2
-rw-r--r--src/lib/libcrypto/objects/objects.pl13
-rw-r--r--src/lib/libcrypto/objects/objects.txt6
-rw-r--r--src/lib/libcrypto/ocsp/Makefile.ssl293
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_asn.c2
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_ht.c19
-rw-r--r--src/lib/libcrypto/opensslconf.h.in158
-rw-r--r--src/lib/libcrypto/opensslv.h4
-rw-r--r--src/lib/libcrypto/ossl_typ.h2
-rw-r--r--src/lib/libcrypto/pem/Makefile.ssl336
-rw-r--r--src/lib/libcrypto/pem/pem.h8
-rw-r--r--src/lib/libcrypto/pem/pem_info.c5
-rw-r--r--src/lib/libcrypto/pem/pem_lib.c40
-rw-r--r--src/lib/libcrypto/pem/pem_pk8.c2
-rw-r--r--src/lib/libcrypto/pem/pem_seal.c2
-rw-r--r--src/lib/libcrypto/perlasm/alpha.pl434
-rw-r--r--src/lib/libcrypto/perlasm/cbc.pl41
-rw-r--r--src/lib/libcrypto/perlasm/x86asm.pl9
-rw-r--r--src/lib/libcrypto/perlasm/x86ms.pl365
-rw-r--r--src/lib/libcrypto/perlasm/x86nasm.pl342
-rw-r--r--src/lib/libcrypto/perlasm/x86unix.pl544
-rw-r--r--src/lib/libcrypto/pkcs12/Makefile.ssl417
-rw-r--r--src/lib/libcrypto/pkcs12/p12_crpt.c4
-rw-r--r--src/lib/libcrypto/pkcs12/p12_decr.c4
-rw-r--r--src/lib/libcrypto/pkcs12/p12_key.c2
-rw-r--r--src/lib/libcrypto/pkcs12/p12_npas.c2
-rw-r--r--src/lib/libcrypto/pkcs7/Makefile.ssl243
-rw-r--r--src/lib/libcrypto/pkcs7/bio_ber.c466
-rw-r--r--src/lib/libcrypto/pkcs7/dec.c248
-rw-r--r--src/lib/libcrypto/pkcs7/des.pem15
-rw-r--r--src/lib/libcrypto/pkcs7/doc24
-rw-r--r--src/lib/libcrypto/pkcs7/enc.c174
-rw-r--r--src/lib/libcrypto/pkcs7/es1.pem66
-rw-r--r--src/lib/libcrypto/pkcs7/example.c329
-rw-r--r--src/lib/libcrypto/pkcs7/example.h57
-rw-r--r--src/lib/libcrypto/pkcs7/info.pem57
-rw-r--r--src/lib/libcrypto/pkcs7/infokey.pem9
-rw-r--r--src/lib/libcrypto/pkcs7/p7/a12
-rw-r--r--src/lib/libcrypto/pkcs7/p7/a21
-rw-r--r--src/lib/libcrypto/pkcs7/p7/cert.p7cbin0 -> 1728 bytes
-rw-r--r--src/lib/libcrypto/pkcs7/p7/smime.p7mbin0 -> 4894 bytes
-rw-r--r--src/lib/libcrypto/pkcs7/p7/smime.p7sbin0 -> 2625 bytes
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_dgst.c66
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_doit.c6
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_enc.c76
-rw-r--r--src/lib/libcrypto/pkcs7/server.pem24
-rw-r--r--src/lib/libcrypto/pkcs7/sign.c154
-rw-r--r--src/lib/libcrypto/pkcs7/t/3des.pem16
-rw-r--r--src/lib/libcrypto/pkcs7/t/3dess.pem32
-rw-r--r--src/lib/libcrypto/pkcs7/t/c.pem48
-rw-r--r--src/lib/libcrypto/pkcs7/t/ff32
-rw-r--r--src/lib/libcrypto/pkcs7/t/msie-e20
-rw-r--r--src/lib/libcrypto/pkcs7/t/msie-e.pem22
-rw-r--r--src/lib/libcrypto/pkcs7/t/msie-enc-0162
-rw-r--r--src/lib/libcrypto/pkcs7/t/msie-enc-01.pem66
-rw-r--r--src/lib/libcrypto/pkcs7/t/msie-enc-0290
-rw-r--r--src/lib/libcrypto/pkcs7/t/msie-enc-02.pem106
-rw-r--r--src/lib/libcrypto/pkcs7/t/msie-s-a-e91
-rw-r--r--src/lib/libcrypto/pkcs7/t/msie-s-a-e.pem106
-rw-r--r--src/lib/libcrypto/pkcs7/t/nav-smime157
-rw-r--r--src/lib/libcrypto/pkcs7/t/s.pem57
-rw-r--r--src/lib/libcrypto/pkcs7/t/server.pem57
-rw-r--r--src/lib/libcrypto/pkcs7/verify.c263
-rw-r--r--src/lib/libcrypto/rand/Makefile.ssl194
-rw-r--r--src/lib/libcrypto/rand/md_rand.c572
-rw-r--r--src/lib/libcrypto/rand/rand.h2
-rw-r--r--src/lib/libcrypto/rand/rand_egd.c298
-rw-r--r--src/lib/libcrypto/rand/rand_lcl.h158
-rw-r--r--src/lib/libcrypto/rand/rand_lib.c10
-rw-r--r--src/lib/libcrypto/rand/rand_os2.c147
-rw-r--r--src/lib/libcrypto/rand/rand_unix.c257
-rw-r--r--src/lib/libcrypto/rand/rand_vms.c135
-rw-r--r--src/lib/libcrypto/rand/rand_win.c693
-rw-r--r--src/lib/libcrypto/rand/randfile.c71
-rw-r--r--src/lib/libcrypto/rand/randtest.c214
-rw-r--r--src/lib/libcrypto/rc2/Makefile.ssl91
-rw-r--r--src/lib/libcrypto/rc2/rc2speed.c274
-rw-r--r--src/lib/libcrypto/rc2/rc2test.c269
-rw-r--r--src/lib/libcrypto/rc2/tab.c86
-rw-r--r--src/lib/libcrypto/rc4/Makefile.ssl115
-rw-r--r--src/lib/libcrypto/rc4/rc4.c192
-rw-r--r--src/lib/libcrypto/rc4/rc4s.cpp73
-rw-r--r--src/lib/libcrypto/rc4/rc4speed.c250
-rw-r--r--src/lib/libcrypto/rc4/rc4test.c201
-rw-r--r--src/lib/libcrypto/rc4/rrc4.doc278
-rw-r--r--src/lib/libcrypto/rc5/Makefile.ssl113
-rw-r--r--src/lib/libcrypto/rc5/rc5.h116
-rw-r--r--src/lib/libcrypto/rijndael/Makefile.ssl89
-rw-r--r--src/lib/libcrypto/rijndael/README80
-rw-r--r--src/lib/libcrypto/rijndael/rd_fst.c1400
-rw-r--r--src/lib/libcrypto/rijndael/rd_fst.h42
-rw-r--r--src/lib/libcrypto/rijndael/rijndael.h7
-rw-r--r--src/lib/libcrypto/ripemd/Makefile.ssl110
-rw-r--r--src/lib/libcrypto/ripemd/asm/rips.cpp82
-rw-r--r--src/lib/libcrypto/ripemd/rmd160.c127
-rw-r--r--src/lib/libcrypto/ripemd/rmd_dgst.c12
-rw-r--r--src/lib/libcrypto/ripemd/rmd_one.c3
-rw-r--r--src/lib/libcrypto/ripemd/rmdtest.c143
-rw-r--r--src/lib/libcrypto/rsa/Makefile.ssl243
-rw-r--r--src/lib/libcrypto/rsa/rsa.h9
-rw-r--r--src/lib/libcrypto/rsa/rsa_eay.c131
-rw-r--r--src/lib/libcrypto/rsa/rsa_lib.c43
-rw-r--r--src/lib/libcrypto/rsa/rsa_null.c150
-rw-r--r--src/lib/libcrypto/rsa/rsa_pk1.c2
-rw-r--r--src/lib/libcrypto/rsa/rsa_saos.c6
-rw-r--r--src/lib/libcrypto/rsa/rsa_sign.c25
-rw-r--r--src/lib/libcrypto/rsa/rsa_test.c318
-rw-r--r--src/lib/libcrypto/sha/Makefile.ssl115
-rw-r--r--src/lib/libcrypto/sha/asm/README1
-rw-r--r--src/lib/libcrypto/sha/sha.c124
-rw-r--r--src/lib/libcrypto/sha/sha1.c127
-rw-r--r--src/lib/libcrypto/sha/sha1_one.c3
-rw-r--r--src/lib/libcrypto/sha/sha1s.cpp82
-rw-r--r--src/lib/libcrypto/sha/sha1test.c172
-rw-r--r--src/lib/libcrypto/sha/sha_dgst.c73
-rw-r--r--src/lib/libcrypto/sha/sha_locl.h12
-rw-r--r--src/lib/libcrypto/sha/sha_one.c76
-rw-r--r--src/lib/libcrypto/sha/shatest.c172
-rw-r--r--src/lib/libcrypto/stack/Makefile.ssl88
-rw-r--r--src/lib/libcrypto/symhacks.h275
-rw-r--r--src/lib/libcrypto/threads/README14
-rw-r--r--src/lib/libcrypto/threads/mttest.c1101
-rw-r--r--src/lib/libcrypto/threads/profile.sh4
-rw-r--r--src/lib/libcrypto/threads/ptest.bat4
-rw-r--r--src/lib/libcrypto/threads/pthread.sh9
-rw-r--r--src/lib/libcrypto/threads/pthread2.sh7
-rw-r--r--src/lib/libcrypto/threads/pthreads-vms.com9
-rw-r--r--src/lib/libcrypto/threads/purify.sh4
-rw-r--r--src/lib/libcrypto/threads/solaris.sh4
-rw-r--r--src/lib/libcrypto/threads/th-lock.c387
-rw-r--r--src/lib/libcrypto/threads/win32.bat4
-rw-r--r--src/lib/libcrypto/tmdiff.c241
-rw-r--r--src/lib/libcrypto/tmdiff.h81
-rw-r--r--src/lib/libcrypto/txt_db/Makefile.ssl88
-rw-r--r--src/lib/libcrypto/txt_db/txt_db.c4
-rw-r--r--src/lib/libcrypto/ui/Makefile.ssl117
-rw-r--r--src/lib/libcrypto/ui/ui_compat.c67
-rw-r--r--src/lib/libcrypto/ui/ui_lib.c23
-rw-r--r--src/lib/libcrypto/ui/ui_openssl.c26
-rw-r--r--src/lib/libcrypto/ui/ui_util.c8
-rw-r--r--src/lib/libcrypto/uid.c89
-rw-r--r--src/lib/libcrypto/util/FreeBSD.sh6
-rw-r--r--src/lib/libcrypto/util/add_cr.pl123
-rw-r--r--src/lib/libcrypto/util/bat.sh132
-rw-r--r--src/lib/libcrypto/util/ck_errf.pl45
-rw-r--r--src/lib/libcrypto/util/clean-depend.pl54
-rw-r--r--src/lib/libcrypto/util/cygwin.sh125
-rw-r--r--src/lib/libcrypto/util/deleof.pl7
-rw-r--r--src/lib/libcrypto/util/dirname.pl18
-rw-r--r--src/lib/libcrypto/util/do_ms.sh19
-rw-r--r--src/lib/libcrypto/util/domd29
-rw-r--r--src/lib/libcrypto/util/err-ins.pl33
-rw-r--r--src/lib/libcrypto/util/files.pl61
-rw-r--r--src/lib/libcrypto/util/fixNT.sh14
-rw-r--r--src/lib/libcrypto/util/install.sh108
-rw-r--r--src/lib/libcrypto/util/libeay.num2795
-rw-r--r--src/lib/libcrypto/util/mk1mf.pl907
-rw-r--r--src/lib/libcrypto/util/mkcerts.sh220
-rw-r--r--src/lib/libcrypto/util/mkdef.pl1360
-rw-r--r--src/lib/libcrypto/util/mkdir-p.pl33
-rw-r--r--src/lib/libcrypto/util/mkerr.pl16
-rw-r--r--src/lib/libcrypto/util/mkfiles.pl117
-rw-r--r--src/lib/libcrypto/util/mklink.pl69
-rw-r--r--src/lib/libcrypto/util/perlpath.pl35
-rw-r--r--src/lib/libcrypto/util/pl/BC-16.pl146
-rw-r--r--src/lib/libcrypto/util/pl/BC-32.pl135
-rw-r--r--src/lib/libcrypto/util/pl/Mingw32.pl104
-rw-r--r--src/lib/libcrypto/util/pl/Mingw32f.pl73
-rw-r--r--src/lib/libcrypto/util/pl/OS2-EMX.pl117
-rw-r--r--src/lib/libcrypto/util/pl/VC-16.pl172
-rw-r--r--src/lib/libcrypto/util/pl/VC-32.pl140
-rw-r--r--src/lib/libcrypto/util/pl/linux.pl104
-rw-r--r--src/lib/libcrypto/util/pl/ultrix.pl38
-rw-r--r--src/lib/libcrypto/util/pl/unix.pl96
-rw-r--r--src/lib/libcrypto/util/pod2man.pl1183
-rw-r--r--src/lib/libcrypto/util/pod2mantest58
-rw-r--r--src/lib/libcrypto/util/pod2mantest.pod15
-rw-r--r--src/lib/libcrypto/util/point.sh10
-rw-r--r--src/lib/libcrypto/util/selftest.pl195
-rw-r--r--src/lib/libcrypto/util/sp-diff.pl80
-rw-r--r--src/lib/libcrypto/util/speed.sh39
-rw-r--r--src/lib/libcrypto/util/src-dep.pl147
-rw-r--r--src/lib/libcrypto/util/ssleay.num217
-rw-r--r--src/lib/libcrypto/util/tab_num.pl17
-rw-r--r--src/lib/libcrypto/util/x86asm.sh42
-rw-r--r--src/lib/libcrypto/x509/Makefile.ssl594
-rw-r--r--src/lib/libcrypto/x509/by_dir.c4
-rw-r--r--src/lib/libcrypto/x509/by_file.c20
-rw-r--r--src/lib/libcrypto/x509/x509.h3
-rw-r--r--src/lib/libcrypto/x509/x509_cmp.c119
-rw-r--r--src/lib/libcrypto/x509/x509_txt.c2
-rw-r--r--src/lib/libcrypto/x509/x509_v3.c2
-rw-r--r--src/lib/libcrypto/x509/x509_vfy.c2
-rw-r--r--src/lib/libcrypto/x509v3/Makefile.ssl603
-rw-r--r--src/lib/libcrypto/x509v3/ext_dat.h6
-rw-r--r--src/lib/libcrypto/x509v3/tabtest.c88
-rw-r--r--src/lib/libcrypto/x509v3/v3_alt.c3
-rw-r--r--src/lib/libcrypto/x509v3/v3_info.c13
-rw-r--r--src/lib/libcrypto/x509v3/v3_ocsp.c3
-rw-r--r--src/lib/libcrypto/x509v3/v3_prn.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3_purp.c4
-rw-r--r--src/lib/libcrypto/x509v3/v3_utl.c2
-rw-r--r--src/lib/libcrypto/x509v3/v3conf.c127
-rw-r--r--src/lib/libcrypto/x509v3/v3prin.c99
-rw-r--r--src/lib/libcrypto/x509v3/x509v3.h1
577 files changed, 88751 insertions, 1917 deletions
diff --git a/src/lib/libcrypto/Makefile.ssl b/src/lib/libcrypto/Makefile.ssl
new file mode 100644
index 0000000000..db8baf385e
--- /dev/null
+++ b/src/lib/libcrypto/Makefile.ssl
@@ -0,0 +1,214 @@
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_dbg.c cversion.c ex_data.c tmdiff.c cpt_err.c ebcdic.c uid.c o_time.c
40LIBOBJ= cryptlib.o mem.o mem_dbg.o cversion.o ex_data.o tmdiff.o cpt_err.o ebcdic.o uid.o o_time.o
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: buildinf.h lib subdirs 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:
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}' 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_dbg.o: ../e_os.h ../include/openssl/bio.h ../include/openssl/buffer.h
197mem_dbg.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
198mem_dbg.o: ../include/openssl/err.h ../include/openssl/lhash.h
199mem_dbg.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
200mem_dbg.o: ../include/openssl/safestack.h ../include/openssl/stack.h
201mem_dbg.o: ../include/openssl/symhacks.h cryptlib.h mem_dbg.c
202o_time.o: ../include/openssl/e_os2.h ../include/openssl/opensslconf.h o_time.c
203o_time.o: o_time.h
204tmdiff.o: ../e_os.h ../include/openssl/bio.h ../include/openssl/buffer.h
205tmdiff.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
206tmdiff.o: ../include/openssl/err.h ../include/openssl/lhash.h
207tmdiff.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
208tmdiff.o: ../include/openssl/safestack.h ../include/openssl/stack.h
209tmdiff.o: ../include/openssl/symhacks.h ../include/openssl/tmdiff.h cryptlib.h
210tmdiff.o: tmdiff.c
211uid.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
212uid.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
213uid.o: ../include/openssl/safestack.h ../include/openssl/stack.h
214uid.o: ../include/openssl/symhacks.h uid.c
diff --git a/src/lib/libcrypto/aes/Makefile.ssl b/src/lib/libcrypto/aes/Makefile.ssl
new file mode 100644
index 0000000000..9358802a2e
--- /dev/null
+++ b/src/lib/libcrypto/aes/Makefile.ssl
@@ -0,0 +1,103 @@
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 8294a41a3a..e8da921ec5 100644
--- a/src/lib/libcrypto/aes/aes.h
+++ b/src/lib/libcrypto/aes/aes.h
@@ -56,9 +56,8 @@
56#error AES is disabled. 56#error AES is disabled.
57#endif 57#endif
58 58
59#define AES_ENCRYPT 1 59static const int AES_DECRYPT = 0;
60#define AES_DECRYPT 0 60static const int AES_ENCRYPT = 1;
61
62/* Because array size can't be a const in C, the following two are macros. 61/* Because array size can't be a const in C, the following two are macros.
63 Both sizes are in bytes. */ 62 Both sizes are in bytes. */
64#define AES_MAXNR 14 63#define AES_MAXNR 14
@@ -100,9 +99,7 @@ void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out,
100 unsigned char *ivec, int *num); 99 unsigned char *ivec, int *num);
101void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out, 100void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out,
102 const unsigned long length, const AES_KEY *key, 101 const unsigned long length, const AES_KEY *key,
103 unsigned char counter[AES_BLOCK_SIZE], 102 unsigned char *counter, unsigned int *num);
104 unsigned char ecount_buf[AES_BLOCK_SIZE],
105 unsigned int *num);
106 103
107 104
108#ifdef __cplusplus 105#ifdef __cplusplus
diff --git a/src/lib/libcrypto/aes/aes_cbc.c b/src/lib/libcrypto/aes/aes_cbc.c
index de438306b1..3dfd7aba2a 100644
--- a/src/lib/libcrypto/aes/aes_cbc.c
+++ b/src/lib/libcrypto/aes/aes_cbc.c
@@ -49,13 +49,7 @@
49 * 49 *
50 */ 50 */
51 51
52#ifndef AES_DEBUG
53# ifndef NDEBUG
54# define NDEBUG
55# endif
56#endif
57#include <assert.h> 52#include <assert.h>
58
59#include <openssl/aes.h> 53#include <openssl/aes.h>
60#include "aes_locl.h" 54#include "aes_locl.h"
61 55
@@ -63,49 +57,33 @@ void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
63 const unsigned long length, const AES_KEY *key, 57 const unsigned long length, const AES_KEY *key,
64 unsigned char *ivec, const int enc) { 58 unsigned char *ivec, const int enc) {
65 59
66 unsigned long n; 60 int n;
67 unsigned long len = length; 61 unsigned long len = length;
68 unsigned char tmp[AES_BLOCK_SIZE]; 62 unsigned char tmp[16];
69 63
70 assert(in && out && key && ivec); 64 assert(in && out && key && ivec);
65 assert(length % AES_BLOCK_SIZE == 0);
71 assert((AES_ENCRYPT == enc)||(AES_DECRYPT == enc)); 66 assert((AES_ENCRYPT == enc)||(AES_DECRYPT == enc));
72 67
73 if (AES_ENCRYPT == enc) { 68 if (AES_ENCRYPT == enc)
74 while (len >= AES_BLOCK_SIZE) { 69 while (len > 0) {
75 for(n=0; n < sizeof tmp; ++n) 70 for(n=0; n < 16; ++n)
76 tmp[n] = in[n] ^ ivec[n]; 71 tmp[n] = in[n] ^ ivec[n];
77 AES_encrypt(tmp, out, key); 72 AES_encrypt(tmp, out, key);
78 memcpy(ivec, out, AES_BLOCK_SIZE); 73 memcpy(ivec, out, 16);
79 len -= AES_BLOCK_SIZE; 74 len -= 16;
80 in += AES_BLOCK_SIZE; 75 in += 16;
81 out += AES_BLOCK_SIZE; 76 out += 16;
82 } 77 }
83 if (len) { 78 else
84 for(n=0; n < len; ++n) 79 while (len > 0) {
85 tmp[n] = in[n] ^ ivec[n]; 80 memcpy(tmp, in, 16);
86 for(n=len; n < AES_BLOCK_SIZE; ++n)
87 tmp[n] = ivec[n];
88 AES_encrypt(tmp, tmp, key);
89 memcpy(out, tmp, len);
90 memcpy(ivec, tmp, sizeof tmp);
91 }
92 } else {
93 while (len >= AES_BLOCK_SIZE) {
94 memcpy(tmp, in, sizeof tmp);
95 AES_decrypt(in, out, key); 81 AES_decrypt(in, out, key);
96 for(n=0; n < AES_BLOCK_SIZE; ++n) 82 for(n=0; n < 16; ++n)
97 out[n] ^= ivec[n]; 83 out[n] ^= ivec[n];
98 memcpy(ivec, tmp, AES_BLOCK_SIZE); 84 memcpy(ivec, tmp, 16);
99 len -= AES_BLOCK_SIZE; 85 len -= 16;
100 in += AES_BLOCK_SIZE; 86 in += 16;
101 out += AES_BLOCK_SIZE; 87 out += 16;
102 } 88 }
103 if (len) {
104 memcpy(tmp, in, sizeof tmp);
105 AES_decrypt(tmp, tmp, key);
106 for(n=0; n < len; ++n)
107 out[n] ^= ivec[n];
108 memcpy(ivec, tmp, sizeof tmp);
109 }
110 }
111} 89}
diff --git a/src/lib/libcrypto/aes/aes_cfb.c b/src/lib/libcrypto/aes/aes_cfb.c
index 9b569dda90..41c2a5ec3d 100644
--- a/src/lib/libcrypto/aes/aes_cfb.c
+++ b/src/lib/libcrypto/aes/aes_cfb.c
@@ -105,13 +105,7 @@
105 * [including the GNU Public Licence.] 105 * [including the GNU Public Licence.]
106 */ 106 */
107 107
108#ifndef AES_DEBUG
109# ifndef NDEBUG
110# define NDEBUG
111# endif
112#endif
113#include <assert.h> 108#include <assert.h>
114
115#include <openssl/aes.h> 109#include <openssl/aes.h>
116#include "aes_locl.h" 110#include "aes_locl.h"
117 111
diff --git a/src/lib/libcrypto/aes/aes_core.c b/src/lib/libcrypto/aes/aes_core.c
index 2f41a825f8..937988dd8c 100644
--- a/src/lib/libcrypto/aes/aes_core.c
+++ b/src/lib/libcrypto/aes/aes_core.c
@@ -28,13 +28,7 @@
28/* Note: rewritten a little bit to provide error control and an OpenSSL- 28/* Note: rewritten a little bit to provide error control and an OpenSSL-
29 compatible API */ 29 compatible API */
30 30
31#ifndef AES_DEBUG
32# ifndef NDEBUG
33# define NDEBUG
34# endif
35#endif
36#include <assert.h> 31#include <assert.h>
37
38#include <stdlib.h> 32#include <stdlib.h>
39#include <openssl/aes.h> 33#include <openssl/aes.h>
40#include "aes_locl.h" 34#include "aes_locl.h"
@@ -750,7 +744,7 @@ int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
750 rk[2] = GETU32(userKey + 8); 744 rk[2] = GETU32(userKey + 8);
751 rk[3] = GETU32(userKey + 12); 745 rk[3] = GETU32(userKey + 12);
752 if (bits == 128) { 746 if (bits == 128) {
753 while (1) { 747 for (;;) {
754 temp = rk[3]; 748 temp = rk[3];
755 rk[4] = rk[0] ^ 749 rk[4] = rk[0] ^
756 (Te4[(temp >> 16) & 0xff] & 0xff000000) ^ 750 (Te4[(temp >> 16) & 0xff] & 0xff000000) ^
@@ -770,7 +764,7 @@ int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
770 rk[4] = GETU32(userKey + 16); 764 rk[4] = GETU32(userKey + 16);
771 rk[5] = GETU32(userKey + 20); 765 rk[5] = GETU32(userKey + 20);
772 if (bits == 192) { 766 if (bits == 192) {
773 while (1) { 767 for (;;) {
774 temp = rk[ 5]; 768 temp = rk[ 5];
775 rk[ 6] = rk[ 0] ^ 769 rk[ 6] = rk[ 0] ^
776 (Te4[(temp >> 16) & 0xff] & 0xff000000) ^ 770 (Te4[(temp >> 16) & 0xff] & 0xff000000) ^
@@ -792,7 +786,7 @@ int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
792 rk[6] = GETU32(userKey + 24); 786 rk[6] = GETU32(userKey + 24);
793 rk[7] = GETU32(userKey + 28); 787 rk[7] = GETU32(userKey + 28);
794 if (bits == 256) { 788 if (bits == 256) {
795 while (1) { 789 for (;;) {
796 temp = rk[ 7]; 790 temp = rk[ 7];
797 rk[ 8] = rk[ 0] ^ 791 rk[ 8] = rk[ 0] ^
798 (Te4[(temp >> 16) & 0xff] & 0xff000000) ^ 792 (Te4[(temp >> 16) & 0xff] & 0xff000000) ^
diff --git a/src/lib/libcrypto/aes/aes_ctr.c b/src/lib/libcrypto/aes/aes_ctr.c
index 59088499a0..aea3db2092 100644
--- a/src/lib/libcrypto/aes/aes_ctr.c
+++ b/src/lib/libcrypto/aes/aes_ctr.c
@@ -49,13 +49,7 @@
49 * 49 *
50 */ 50 */
51 51
52#ifndef AES_DEBUG
53# ifndef NDEBUG
54# define NDEBUG
55# endif
56#endif
57#include <assert.h> 52#include <assert.h>
58
59#include <openssl/aes.h> 53#include <openssl/aes.h>
60#include "aes_locl.h" 54#include "aes_locl.h"
61 55
@@ -96,31 +90,26 @@ static void AES_ctr128_inc(unsigned char *counter) {
96 90
97/* The input encrypted as though 128bit counter mode is being 91/* The input encrypted as though 128bit counter mode is being
98 * used. The extra state information to record how much of the 92 * used. The extra state information to record how much of the
99 * 128bit block we have used is contained in *num, and the 93 * 128bit block we have used is contained in *num;
100 * encrypted counter is kept in ecount_buf. Both *num and
101 * ecount_buf must be initialised with zeros before the first
102 * call to AES_ctr128_encrypt().
103 */ 94 */
104void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out, 95void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out,
105 const unsigned long length, const AES_KEY *key, 96 const unsigned long length, const AES_KEY *key,
106 unsigned char counter[AES_BLOCK_SIZE], 97 unsigned char *counter, unsigned int *num) {
107 unsigned char ecount_buf[AES_BLOCK_SIZE],
108 unsigned int *num) {
109 98
110 unsigned int n; 99 unsigned int n;
111 unsigned long l=length; 100 unsigned long l=length;
101 unsigned char tmp[AES_BLOCK_SIZE];
112 102
113 assert(in && out && key && counter && num); 103 assert(in && out && key && counter && num);
114 assert(*num < AES_BLOCK_SIZE);
115 104
116 n = *num; 105 n = *num;
117 106
118 while (l--) { 107 while (l--) {
119 if (n == 0) { 108 if (n == 0) {
120 AES_encrypt(counter, ecount_buf, key); 109 AES_encrypt(counter, tmp, key);
121 AES_ctr128_inc(counter); 110 AES_ctr128_inc(counter);
122 } 111 }
123 *(out++) = *(in++) ^ ecount_buf[n]; 112 *(out++) = *(in++) ^ tmp[n];
124 n = (n+1) % AES_BLOCK_SIZE; 113 n = (n+1) % AES_BLOCK_SIZE;
125 } 114 }
126 115
diff --git a/src/lib/libcrypto/aes/aes_ecb.c b/src/lib/libcrypto/aes/aes_ecb.c
index 28aa561c2d..1cb2e07d3d 100644
--- a/src/lib/libcrypto/aes/aes_ecb.c
+++ b/src/lib/libcrypto/aes/aes_ecb.c
@@ -49,13 +49,7 @@
49 * 49 *
50 */ 50 */
51 51
52#ifndef AES_DEBUG
53# ifndef NDEBUG
54# define NDEBUG
55# endif
56#endif
57#include <assert.h> 52#include <assert.h>
58
59#include <openssl/aes.h> 53#include <openssl/aes.h>
60#include "aes_locl.h" 54#include "aes_locl.h"
61 55
diff --git a/src/lib/libcrypto/aes/aes_locl.h b/src/lib/libcrypto/aes/aes_locl.h
index f290946058..18fc2d0747 100644
--- a/src/lib/libcrypto/aes/aes_locl.h
+++ b/src/lib/libcrypto/aes/aes_locl.h
@@ -62,7 +62,7 @@
62#include <stdlib.h> 62#include <stdlib.h>
63#include <string.h> 63#include <string.h>
64 64
65#if defined(_MSC_VER) && !defined(OPENSSL_SYS_WINCE) 65#ifdef _MSC_VER
66# define SWAP(x) (_lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00) 66# define SWAP(x) (_lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00)
67# define GETU32(p) SWAP(*((u32 *)(p))) 67# define GETU32(p) SWAP(*((u32 *)(p)))
68# define PUTU32(ct, st) { *((u32 *)(ct)) = SWAP((st)); } 68# define PUTU32(ct, st) { *((u32 *)(ct)) = SWAP((st)); }
diff --git a/src/lib/libcrypto/aes/aes_ofb.c b/src/lib/libcrypto/aes/aes_ofb.c
index f358bb39e2..e33bdaea28 100644
--- a/src/lib/libcrypto/aes/aes_ofb.c
+++ b/src/lib/libcrypto/aes/aes_ofb.c
@@ -105,13 +105,7 @@
105 * [including the GNU Public Licence.] 105 * [including the GNU Public Licence.]
106 */ 106 */
107 107
108#ifndef AES_DEBUG
109# ifndef NDEBUG
110# define NDEBUG
111# endif
112#endif
113#include <assert.h> 108#include <assert.h>
114
115#include <openssl/aes.h> 109#include <openssl/aes.h>
116#include "aes_locl.h" 110#include "aes_locl.h"
117 111
diff --git a/src/lib/libcrypto/asn1/Makefile.ssl b/src/lib/libcrypto/asn1/Makefile.ssl
new file mode 100644
index 0000000000..b5a186c904
--- /dev/null
+++ b/src/lib/libcrypto/asn1/Makefile.ssl
@@ -0,0 +1,1151 @@
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: ../../include/openssl/aes.h ../../include/openssl/asn1.h
290a_strex.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
291a_strex.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
292a_strex.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
293a_strex.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
294a_strex.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
295a_strex.o: ../../include/openssl/e_os2.h ../../include/openssl/evp.h
296a_strex.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
297a_strex.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
298a_strex.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
299a_strex.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
300a_strex.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
301a_strex.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
302a_strex.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
303a_strex.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
304a_strex.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
305a_strex.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
306a_strex.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
307a_strex.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
308a_strex.o: ../../include/openssl/x509_vfy.h a_strex.c charmap.h
309a_strnid.o: ../../e_os.h ../../include/openssl/asn1.h
310a_strnid.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
311a_strnid.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
312a_strnid.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
313a_strnid.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
314a_strnid.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
315a_strnid.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
316a_strnid.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
317a_strnid.o: ../../include/openssl/symhacks.h ../cryptlib.h a_strnid.c
318a_time.o: ../../e_os.h ../../include/openssl/asn1.h
319a_time.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
320a_time.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
321a_time.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
322a_time.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
323a_time.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
324a_time.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
325a_time.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
326a_time.o: ../cryptlib.h ../o_time.h a_time.c
327a_type.o: ../../e_os.h ../../include/openssl/asn1.h
328a_type.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
329a_type.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
330a_type.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
331a_type.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
332a_type.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
333a_type.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
334a_type.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
335a_type.o: ../cryptlib.h a_type.c
336a_utctm.o: ../../e_os.h ../../include/openssl/asn1.h
337a_utctm.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
338a_utctm.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
339a_utctm.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
340a_utctm.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
341a_utctm.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
342a_utctm.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
343a_utctm.o: ../../include/openssl/symhacks.h ../cryptlib.h ../o_time.h a_utctm.c
344a_utf8.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
345a_utf8.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
346a_utf8.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
347a_utf8.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
348a_utf8.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
349a_utf8.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
350a_utf8.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
351a_utf8.o: ../cryptlib.h a_utf8.c
352a_verify.o: ../../e_os.h ../../include/openssl/aes.h
353a_verify.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
354a_verify.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
355a_verify.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
356a_verify.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
357a_verify.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
358a_verify.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
359a_verify.o: ../../include/openssl/err.h ../../include/openssl/evp.h
360a_verify.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
361a_verify.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
362a_verify.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
363a_verify.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
364a_verify.o: ../../include/openssl/opensslconf.h
365a_verify.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
366a_verify.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
367a_verify.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
368a_verify.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
369a_verify.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
370a_verify.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
371a_verify.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
372a_verify.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
373a_verify.o: ../cryptlib.h a_verify.c
374asn1_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
375asn1_err.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
376asn1_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
377asn1_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
378asn1_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
379asn1_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
380asn1_err.o: ../../include/openssl/symhacks.h asn1_err.c
381asn1_lib.o: ../../e_os.h ../../include/openssl/asn1.h
382asn1_lib.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h
383asn1_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
384asn1_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
385asn1_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
386asn1_lib.o: ../../include/openssl/opensslconf.h
387asn1_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
388asn1_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
389asn1_lib.o: ../../include/openssl/symhacks.h ../cryptlib.h asn1_lib.c
390asn1_par.o: ../../e_os.h ../../include/openssl/asn1.h
391asn1_par.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
392asn1_par.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
393asn1_par.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
394asn1_par.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
395asn1_par.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
396asn1_par.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
397asn1_par.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
398asn1_par.o: ../../include/openssl/symhacks.h ../cryptlib.h asn1_par.c
399asn_moid.o: ../../e_os.h ../../include/openssl/aes.h
400asn_moid.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
401asn_moid.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
402asn_moid.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
403asn_moid.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
404asn_moid.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
405asn_moid.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
406asn_moid.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
407asn_moid.o: ../../include/openssl/err.h ../../include/openssl/evp.h
408asn_moid.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
409asn_moid.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
410asn_moid.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
411asn_moid.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
412asn_moid.o: ../../include/openssl/opensslconf.h
413asn_moid.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
414asn_moid.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
415asn_moid.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
416asn_moid.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
417asn_moid.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
418asn_moid.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
419asn_moid.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
420asn_moid.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
421asn_moid.o: ../cryptlib.h asn_moid.c
422asn_pack.o: ../../e_os.h ../../include/openssl/asn1.h
423asn_pack.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
424asn_pack.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
425asn_pack.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
426asn_pack.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
427asn_pack.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
428asn_pack.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
429asn_pack.o: ../../include/openssl/symhacks.h ../cryptlib.h asn_pack.c
430d2i_pr.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
431d2i_pr.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
432d2i_pr.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
433d2i_pr.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
434d2i_pr.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
435d2i_pr.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
436d2i_pr.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
437d2i_pr.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
438d2i_pr.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
439d2i_pr.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
440d2i_pr.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
441d2i_pr.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
442d2i_pr.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
443d2i_pr.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
444d2i_pr.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
445d2i_pr.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
446d2i_pr.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
447d2i_pr.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
448d2i_pr.o: ../../include/openssl/ui_compat.h ../cryptlib.h d2i_pr.c
449d2i_pu.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
450d2i_pu.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
451d2i_pu.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
452d2i_pu.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
453d2i_pu.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
454d2i_pu.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
455d2i_pu.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
456d2i_pu.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
457d2i_pu.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
458d2i_pu.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
459d2i_pu.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
460d2i_pu.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
461d2i_pu.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
462d2i_pu.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
463d2i_pu.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
464d2i_pu.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
465d2i_pu.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
466d2i_pu.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
467d2i_pu.o: ../../include/openssl/ui_compat.h ../cryptlib.h d2i_pu.c
468evp_asn1.o: ../../e_os.h ../../include/openssl/asn1.h
469evp_asn1.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h
470evp_asn1.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
471evp_asn1.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
472evp_asn1.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
473evp_asn1.o: ../../include/openssl/opensslconf.h
474evp_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
475evp_asn1.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
476evp_asn1.o: ../../include/openssl/symhacks.h ../cryptlib.h evp_asn1.c
477f_enum.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
478f_enum.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
479f_enum.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
480f_enum.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
481f_enum.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
482f_enum.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
483f_enum.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
484f_enum.o: ../cryptlib.h f_enum.c
485f_int.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
486f_int.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
487f_int.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
488f_int.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
489f_int.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
490f_int.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
491f_int.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
492f_int.o: ../cryptlib.h f_int.c
493f_string.o: ../../e_os.h ../../include/openssl/asn1.h
494f_string.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
495f_string.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
496f_string.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
497f_string.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
498f_string.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
499f_string.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
500f_string.o: ../../include/openssl/symhacks.h ../cryptlib.h f_string.c
501i2d_pr.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
502i2d_pr.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
503i2d_pr.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
504i2d_pr.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
505i2d_pr.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
506i2d_pr.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
507i2d_pr.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
508i2d_pr.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
509i2d_pr.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
510i2d_pr.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
511i2d_pr.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
512i2d_pr.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
513i2d_pr.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
514i2d_pr.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
515i2d_pr.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
516i2d_pr.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
517i2d_pr.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
518i2d_pr.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
519i2d_pr.o: ../../include/openssl/ui_compat.h ../cryptlib.h i2d_pr.c
520i2d_pu.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
521i2d_pu.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
522i2d_pu.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
523i2d_pu.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
524i2d_pu.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
525i2d_pu.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
526i2d_pu.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
527i2d_pu.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
528i2d_pu.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
529i2d_pu.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
530i2d_pu.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
531i2d_pu.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
532i2d_pu.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
533i2d_pu.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
534i2d_pu.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
535i2d_pu.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
536i2d_pu.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
537i2d_pu.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
538i2d_pu.o: ../../include/openssl/ui_compat.h ../cryptlib.h i2d_pu.c
539n_pkey.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
540n_pkey.o: ../../include/openssl/asn1_mac.h ../../include/openssl/asn1t.h
541n_pkey.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
542n_pkey.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
543n_pkey.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
544n_pkey.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
545n_pkey.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
546n_pkey.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
547n_pkey.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
548n_pkey.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
549n_pkey.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
550n_pkey.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
551n_pkey.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
552n_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
553n_pkey.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
554n_pkey.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
555n_pkey.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
556n_pkey.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
557n_pkey.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
558n_pkey.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
559n_pkey.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
560n_pkey.o: ../cryptlib.h n_pkey.c
561nsseq.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
562nsseq.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
563nsseq.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
564nsseq.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
565nsseq.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
566nsseq.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
567nsseq.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
568nsseq.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
569nsseq.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
570nsseq.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
571nsseq.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
572nsseq.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
573nsseq.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
574nsseq.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
575nsseq.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
576nsseq.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
577nsseq.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
578nsseq.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
579nsseq.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
580nsseq.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h nsseq.c
581p5_pbe.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
582p5_pbe.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
583p5_pbe.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
584p5_pbe.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
585p5_pbe.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
586p5_pbe.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
587p5_pbe.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
588p5_pbe.o: ../../include/openssl/err.h ../../include/openssl/evp.h
589p5_pbe.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
590p5_pbe.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
591p5_pbe.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
592p5_pbe.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
593p5_pbe.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
594p5_pbe.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
595p5_pbe.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
596p5_pbe.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
597p5_pbe.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
598p5_pbe.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
599p5_pbe.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
600p5_pbe.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
601p5_pbe.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
602p5_pbe.o: ../cryptlib.h p5_pbe.c
603p5_pbev2.o: ../../e_os.h ../../include/openssl/aes.h
604p5_pbev2.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
605p5_pbev2.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
606p5_pbev2.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
607p5_pbev2.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
608p5_pbev2.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
609p5_pbev2.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
610p5_pbev2.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
611p5_pbev2.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
612p5_pbev2.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
613p5_pbev2.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
614p5_pbev2.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
615p5_pbev2.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
616p5_pbev2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
617p5_pbev2.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
618p5_pbev2.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
619p5_pbev2.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
620p5_pbev2.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
621p5_pbev2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
622p5_pbev2.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
623p5_pbev2.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
624p5_pbev2.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p5_pbev2.c
625p8_pkey.o: ../../e_os.h ../../include/openssl/aes.h
626p8_pkey.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
627p8_pkey.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
628p8_pkey.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
629p8_pkey.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
630p8_pkey.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
631p8_pkey.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
632p8_pkey.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
633p8_pkey.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
634p8_pkey.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
635p8_pkey.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
636p8_pkey.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
637p8_pkey.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
638p8_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
639p8_pkey.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
640p8_pkey.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
641p8_pkey.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
642p8_pkey.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
643p8_pkey.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
644p8_pkey.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
645p8_pkey.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
646p8_pkey.o: ../cryptlib.h p8_pkey.c
647t_bitst.o: ../../e_os.h ../../include/openssl/aes.h
648t_bitst.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
649t_bitst.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
650t_bitst.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
651t_bitst.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
652t_bitst.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
653t_bitst.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
654t_bitst.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
655t_bitst.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
656t_bitst.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
657t_bitst.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
658t_bitst.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
659t_bitst.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
660t_bitst.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
661t_bitst.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
662t_bitst.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
663t_bitst.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
664t_bitst.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
665t_bitst.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
666t_bitst.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
667t_bitst.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
668t_bitst.o: ../../include/openssl/x509v3.h ../cryptlib.h t_bitst.c
669t_crl.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
670t_crl.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
671t_crl.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
672t_crl.o: ../../include/openssl/cast.h ../../include/openssl/conf.h
673t_crl.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
674t_crl.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
675t_crl.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
676t_crl.o: ../../include/openssl/err.h ../../include/openssl/evp.h
677t_crl.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
678t_crl.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
679t_crl.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
680t_crl.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
681t_crl.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
682t_crl.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
683t_crl.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
684t_crl.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
685t_crl.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
686t_crl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
687t_crl.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
688t_crl.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
689t_crl.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
690t_crl.o: ../cryptlib.h t_crl.c
691t_pkey.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
692t_pkey.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
693t_pkey.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
694t_pkey.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
695t_pkey.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
696t_pkey.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
697t_pkey.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rsa.h
698t_pkey.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
699t_pkey.o: ../../include/openssl/symhacks.h ../cryptlib.h t_pkey.c
700t_req.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
701t_req.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
702t_req.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
703t_req.o: ../../include/openssl/cast.h ../../include/openssl/conf.h
704t_req.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
705t_req.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
706t_req.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
707t_req.o: ../../include/openssl/err.h ../../include/openssl/evp.h
708t_req.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
709t_req.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
710t_req.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
711t_req.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
712t_req.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
713t_req.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
714t_req.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
715t_req.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
716t_req.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
717t_req.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
718t_req.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
719t_req.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
720t_req.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
721t_req.o: ../cryptlib.h t_req.c
722t_spki.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
723t_spki.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
724t_spki.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
725t_spki.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
726t_spki.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
727t_spki.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
728t_spki.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
729t_spki.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
730t_spki.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
731t_spki.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
732t_spki.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
733t_spki.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
734t_spki.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
735t_spki.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
736t_spki.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
737t_spki.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
738t_spki.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
739t_spki.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
740t_spki.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
741t_spki.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
742t_spki.o: ../cryptlib.h t_spki.c
743t_x509.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
744t_x509.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
745t_x509.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
746t_x509.o: ../../include/openssl/cast.h ../../include/openssl/conf.h
747t_x509.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
748t_x509.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
749t_x509.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
750t_x509.o: ../../include/openssl/err.h ../../include/openssl/evp.h
751t_x509.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
752t_x509.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
753t_x509.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
754t_x509.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
755t_x509.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
756t_x509.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
757t_x509.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
758t_x509.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
759t_x509.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
760t_x509.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
761t_x509.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
762t_x509.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
763t_x509.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
764t_x509.o: ../cryptlib.h t_x509.c
765t_x509a.o: ../../e_os.h ../../include/openssl/aes.h
766t_x509a.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
767t_x509a.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
768t_x509a.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
769t_x509a.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
770t_x509a.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
771t_x509a.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
772t_x509a.o: ../../include/openssl/err.h ../../include/openssl/evp.h
773t_x509a.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
774t_x509a.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
775t_x509a.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
776t_x509a.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
777t_x509a.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
778t_x509a.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
779t_x509a.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
780t_x509a.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
781t_x509a.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
782t_x509a.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
783t_x509a.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
784t_x509a.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
785t_x509a.o: ../../include/openssl/x509_vfy.h ../cryptlib.h t_x509a.c
786tasn_dec.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
787tasn_dec.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
788tasn_dec.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
789tasn_dec.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
790tasn_dec.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
791tasn_dec.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
792tasn_dec.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
793tasn_dec.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
794tasn_dec.o: ../../include/openssl/symhacks.h tasn_dec.c
795tasn_enc.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
796tasn_enc.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
797tasn_enc.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
798tasn_enc.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
799tasn_enc.o: ../../include/openssl/opensslconf.h
800tasn_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
801tasn_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
802tasn_enc.o: ../../include/openssl/symhacks.h tasn_enc.c
803tasn_fre.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
804tasn_fre.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
805tasn_fre.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
806tasn_fre.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
807tasn_fre.o: ../../include/openssl/opensslconf.h
808tasn_fre.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
809tasn_fre.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
810tasn_fre.o: ../../include/openssl/symhacks.h tasn_fre.c
811tasn_new.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
812tasn_new.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
813tasn_new.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
814tasn_new.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
815tasn_new.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
816tasn_new.o: ../../include/openssl/opensslconf.h
817tasn_new.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
818tasn_new.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
819tasn_new.o: ../../include/openssl/symhacks.h tasn_new.c
820tasn_typ.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
821tasn_typ.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
822tasn_typ.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
823tasn_typ.o: ../../include/openssl/opensslconf.h
824tasn_typ.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
825tasn_typ.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
826tasn_typ.o: ../../include/openssl/symhacks.h tasn_typ.c
827tasn_utl.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
828tasn_utl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
829tasn_utl.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
830tasn_utl.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
831tasn_utl.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
832tasn_utl.o: ../../include/openssl/opensslconf.h
833tasn_utl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
834tasn_utl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
835tasn_utl.o: ../../include/openssl/symhacks.h tasn_utl.c
836x_algor.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
837x_algor.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
838x_algor.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
839x_algor.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
840x_algor.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
841x_algor.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
842x_algor.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
843x_algor.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
844x_algor.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
845x_algor.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
846x_algor.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
847x_algor.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
848x_algor.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
849x_algor.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
850x_algor.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
851x_algor.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
852x_algor.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
853x_algor.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
854x_algor.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
855x_algor.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
856x_algor.o: x_algor.c
857x_attrib.o: ../../e_os.h ../../include/openssl/aes.h
858x_attrib.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
859x_attrib.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
860x_attrib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
861x_attrib.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
862x_attrib.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
863x_attrib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
864x_attrib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
865x_attrib.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
866x_attrib.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
867x_attrib.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
868x_attrib.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
869x_attrib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
870x_attrib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
871x_attrib.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
872x_attrib.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
873x_attrib.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
874x_attrib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
875x_attrib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
876x_attrib.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
877x_attrib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
878x_attrib.o: ../cryptlib.h x_attrib.c
879x_bignum.o: ../../e_os.h ../../include/openssl/asn1.h
880x_bignum.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
881x_bignum.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
882x_bignum.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
883x_bignum.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
884x_bignum.o: ../../include/openssl/opensslconf.h
885x_bignum.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
886x_bignum.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
887x_bignum.o: ../../include/openssl/symhacks.h ../cryptlib.h x_bignum.c
888x_crl.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
889x_crl.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
890x_crl.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
891x_crl.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
892x_crl.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
893x_crl.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
894x_crl.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
895x_crl.o: ../../include/openssl/err.h ../../include/openssl/evp.h
896x_crl.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
897x_crl.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
898x_crl.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
899x_crl.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
900x_crl.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
901x_crl.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
902x_crl.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
903x_crl.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
904x_crl.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
905x_crl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
906x_crl.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
907x_crl.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
908x_crl.o: ../../include/openssl/x509_vfy.h ../cryptlib.h x_crl.c
909x_exten.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
910x_exten.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
911x_exten.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
912x_exten.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
913x_exten.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
914x_exten.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
915x_exten.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
916x_exten.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
917x_exten.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
918x_exten.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
919x_exten.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
920x_exten.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
921x_exten.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
922x_exten.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
923x_exten.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
924x_exten.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
925x_exten.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
926x_exten.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
927x_exten.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
928x_exten.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
929x_exten.o: x_exten.c
930x_info.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
931x_info.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
932x_info.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
933x_info.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
934x_info.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
935x_info.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
936x_info.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
937x_info.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
938x_info.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
939x_info.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
940x_info.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
941x_info.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
942x_info.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
943x_info.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
944x_info.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
945x_info.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
946x_info.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
947x_info.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
948x_info.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
949x_info.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
950x_info.o: ../cryptlib.h x_info.c
951x_long.o: ../../e_os.h ../../include/openssl/asn1.h
952x_long.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
953x_long.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
954x_long.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
955x_long.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
956x_long.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
957x_long.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
958x_long.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
959x_long.o: ../cryptlib.h x_long.c
960x_name.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
961x_name.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
962x_name.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
963x_name.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
964x_name.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
965x_name.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
966x_name.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
967x_name.o: ../../include/openssl/err.h ../../include/openssl/evp.h
968x_name.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
969x_name.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
970x_name.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
971x_name.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
972x_name.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
973x_name.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
974x_name.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
975x_name.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
976x_name.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
977x_name.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
978x_name.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
979x_name.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
980x_name.o: ../../include/openssl/x509_vfy.h ../cryptlib.h x_name.c
981x_pkey.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
982x_pkey.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h
983x_pkey.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
984x_pkey.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
985x_pkey.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
986x_pkey.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
987x_pkey.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
988x_pkey.o: ../../include/openssl/err.h ../../include/openssl/evp.h
989x_pkey.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
990x_pkey.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
991x_pkey.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
992x_pkey.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
993x_pkey.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
994x_pkey.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
995x_pkey.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
996x_pkey.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
997x_pkey.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
998x_pkey.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
999x_pkey.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
1000x_pkey.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
1001x_pkey.o: ../../include/openssl/x509_vfy.h ../cryptlib.h x_pkey.c
1002x_pubkey.o: ../../e_os.h ../../include/openssl/aes.h
1003x_pubkey.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
1004x_pubkey.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
1005x_pubkey.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
1006x_pubkey.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
1007x_pubkey.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
1008x_pubkey.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
1009x_pubkey.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
1010x_pubkey.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
1011x_pubkey.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
1012x_pubkey.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
1013x_pubkey.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
1014x_pubkey.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
1015x_pubkey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
1016x_pubkey.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
1017x_pubkey.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
1018x_pubkey.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
1019x_pubkey.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
1020x_pubkey.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
1021x_pubkey.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
1022x_pubkey.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
1023x_pubkey.o: ../cryptlib.h x_pubkey.c
1024x_req.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
1025x_req.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
1026x_req.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
1027x_req.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
1028x_req.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
1029x_req.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
1030x_req.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
1031x_req.o: ../../include/openssl/err.h ../../include/openssl/evp.h
1032x_req.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
1033x_req.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
1034x_req.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
1035x_req.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
1036x_req.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
1037x_req.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
1038x_req.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
1039x_req.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
1040x_req.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
1041x_req.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
1042x_req.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
1043x_req.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
1044x_req.o: ../../include/openssl/x509_vfy.h ../cryptlib.h x_req.c
1045x_sig.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
1046x_sig.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
1047x_sig.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
1048x_sig.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
1049x_sig.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
1050x_sig.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
1051x_sig.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
1052x_sig.o: ../../include/openssl/err.h ../../include/openssl/evp.h
1053x_sig.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
1054x_sig.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
1055x_sig.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
1056x_sig.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
1057x_sig.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
1058x_sig.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
1059x_sig.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
1060x_sig.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
1061x_sig.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
1062x_sig.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
1063x_sig.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
1064x_sig.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
1065x_sig.o: ../../include/openssl/x509_vfy.h ../cryptlib.h x_sig.c
1066x_spki.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
1067x_spki.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
1068x_spki.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
1069x_spki.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
1070x_spki.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
1071x_spki.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
1072x_spki.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
1073x_spki.o: ../../include/openssl/err.h ../../include/openssl/evp.h
1074x_spki.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
1075x_spki.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
1076x_spki.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
1077x_spki.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
1078x_spki.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
1079x_spki.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
1080x_spki.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
1081x_spki.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
1082x_spki.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
1083x_spki.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
1084x_spki.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
1085x_spki.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
1086x_spki.o: ../../include/openssl/x509_vfy.h ../cryptlib.h x_spki.c
1087x_val.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
1088x_val.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
1089x_val.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
1090x_val.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
1091x_val.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
1092x_val.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
1093x_val.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
1094x_val.o: ../../include/openssl/err.h ../../include/openssl/evp.h
1095x_val.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
1096x_val.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
1097x_val.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
1098x_val.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
1099x_val.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
1100x_val.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
1101x_val.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
1102x_val.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
1103x_val.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
1104x_val.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
1105x_val.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
1106x_val.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
1107x_val.o: ../../include/openssl/x509_vfy.h ../cryptlib.h x_val.c
1108x_x509.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
1109x_x509.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
1110x_x509.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
1111x_x509.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
1112x_x509.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
1113x_x509.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
1114x_x509.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
1115x_x509.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
1116x_x509.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
1117x_x509.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
1118x_x509.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
1119x_x509.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
1120x_x509.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
1121x_x509.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
1122x_x509.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
1123x_x509.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
1124x_x509.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
1125x_x509.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
1126x_x509.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
1127x_x509.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
1128x_x509.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
1129x_x509.o: ../../include/openssl/x509v3.h ../cryptlib.h x_x509.c
1130x_x509a.o: ../../e_os.h ../../include/openssl/aes.h
1131x_x509a.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
1132x_x509a.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
1133x_x509a.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
1134x_x509a.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
1135x_x509a.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
1136x_x509a.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
1137x_x509a.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
1138x_x509a.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
1139x_x509a.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
1140x_x509a.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
1141x_x509a.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
1142x_x509a.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
1143x_x509a.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
1144x_x509a.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
1145x_x509a.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
1146x_x509a.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
1147x_x509a.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
1148x_x509a.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
1149x_x509a.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
1150x_x509a.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
1151x_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 f4ea96cd54..e0265f69d2 100644
--- a/src/lib/libcrypto/asn1/a_bitstr.c
+++ b/src/lib/libcrypto/asn1/a_bitstr.c
@@ -191,9 +191,7 @@ int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value)
191 if (a->data == NULL) 191 if (a->data == NULL)
192 c=(unsigned char *)OPENSSL_malloc(w+1); 192 c=(unsigned char *)OPENSSL_malloc(w+1);
193 else 193 else
194 c=(unsigned char *)OPENSSL_realloc_clean(a->data, 194 c=(unsigned char *)OPENSSL_realloc(a->data,w+1);
195 a->length,
196 w+1);
197 if (c == NULL) return(0); 195 if (c == NULL) return(0);
198 if (w+1-a->length > 0) memset(c+a->length, 0, w+1-a->length); 196 if (w+1-a->length > 0) memset(c+a->length, 0, w+1-a->length);
199 a->data=c; 197 a->data=c;
diff --git a/src/lib/libcrypto/asn1/a_bytes.c b/src/lib/libcrypto/asn1/a_bytes.c
index afd27b80e1..bb88660f58 100644
--- a/src/lib/libcrypto/asn1/a_bytes.c
+++ b/src/lib/libcrypto/asn1/a_bytes.c
@@ -285,7 +285,7 @@ static int asn1_collate_primitive(ASN1_STRING *a, ASN1_CTX *c)
285 goto err; 285 goto err;
286 } 286 }
287 287
288 if (!BUF_MEM_grow_clean(&b,num+os->length)) 288 if (!BUF_MEM_grow(&b,num+os->length))
289 { 289 {
290 c->error=ERR_R_BUF_LIB; 290 c->error=ERR_R_BUF_LIB;
291 goto err; 291 goto err;
diff --git a/src/lib/libcrypto/asn1/a_d2i_fp.c b/src/lib/libcrypto/asn1/a_d2i_fp.c
index b67b75e7c2..a80fbe9ff7 100644
--- a/src/lib/libcrypto/asn1/a_d2i_fp.c
+++ b/src/lib/libcrypto/asn1/a_d2i_fp.c
@@ -149,12 +149,7 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
149 ASN1_CTX c; 149 ASN1_CTX c;
150 int want=HEADER_SIZE; 150 int want=HEADER_SIZE;
151 int eos=0; 151 int eos=0;
152#if defined(__GNUC__) && defined(__ia64)
153 /* pathetic compiler bug in all known versions as of Nov. 2002 */
154 long off=0;
155#else
156 int off=0; 152 int off=0;
157#endif
158 int len=0; 153 int len=0;
159 154
160 b=BUF_MEM_new(); 155 b=BUF_MEM_new();
@@ -171,7 +166,7 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
171 { 166 {
172 want-=(len-off); 167 want-=(len-off);
173 168
174 if (!BUF_MEM_grow_clean(b,len+want)) 169 if (!BUF_MEM_grow(b,len+want))
175 { 170 {
176 ASN1err(ASN1_F_ASN1_D2I_BIO,ERR_R_MALLOC_FAILURE); 171 ASN1err(ASN1_F_ASN1_D2I_BIO,ERR_R_MALLOC_FAILURE);
177 goto err; 172 goto err;
@@ -226,23 +221,18 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
226 if (want > (len-off)) 221 if (want > (len-off))
227 { 222 {
228 want-=(len-off); 223 want-=(len-off);
229 if (!BUF_MEM_grow_clean(b,len+want)) 224 if (!BUF_MEM_grow(b,len+want))
230 { 225 {
231 ASN1err(ASN1_F_ASN1_D2I_BIO,ERR_R_MALLOC_FAILURE); 226 ASN1err(ASN1_F_ASN1_D2I_BIO,ERR_R_MALLOC_FAILURE);
232 goto err; 227 goto err;
233 } 228 }
234 while (want > 0) 229 i=BIO_read(in,&(b->data[len]),want);
230 if (i <= 0)
235 { 231 {
236 i=BIO_read(in,&(b->data[len]),want); 232 ASN1err(ASN1_F_ASN1_D2I_BIO,ASN1_R_NOT_ENOUGH_DATA);
237 if (i <= 0) 233 goto err;
238 {
239 ASN1err(ASN1_F_ASN1_D2I_BIO,
240 ASN1_R_NOT_ENOUGH_DATA);
241 goto err;
242 }
243 len+=i;
244 want -= i;
245 } 234 }
235 len+=i;
246 } 236 }
247 off+=(int)c.slen; 237 off+=(int)c.slen;
248 if (eos <= 0) 238 if (eos <= 0)
diff --git a/src/lib/libcrypto/asn1/a_gentm.c b/src/lib/libcrypto/asn1/a_gentm.c
new file mode 100644
index 0000000000..48b923de1f
--- /dev/null
+++ b/src/lib/libcrypto/asn1/a_gentm.c
@@ -0,0 +1,240 @@
1/* crypto/asn1/a_gentm.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/* GENERALIZEDTIME implementation, written by Steve Henson. Based on UTCTIME */
60
61#include <stdio.h>
62#include <time.h>
63#include "cryptlib.h"
64#include "o_time.h"
65#include <openssl/asn1.h>
66
67#if 0
68
69int i2d_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME *a, unsigned char **pp)
70 {
71#ifdef CHARSET_EBCDIC
72 /* KLUDGE! We convert to ascii before writing DER */
73 int len;
74 char tmp[24];
75 ASN1_STRING tmpstr = *(ASN1_STRING *)a;
76
77 len = tmpstr.length;
78 ebcdic2ascii(tmp, tmpstr.data, (len >= sizeof tmp) ? sizeof tmp : len);
79 tmpstr.data = tmp;
80
81 a = (ASN1_GENERALIZEDTIME *) &tmpstr;
82#endif
83 return(i2d_ASN1_bytes((ASN1_STRING *)a,pp,
84 V_ASN1_GENERALIZEDTIME,V_ASN1_UNIVERSAL));
85 }
86
87
88ASN1_GENERALIZEDTIME *d2i_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME **a,
89 unsigned char **pp, long length)
90 {
91 ASN1_GENERALIZEDTIME *ret=NULL;
92
93 ret=(ASN1_GENERALIZEDTIME *)d2i_ASN1_bytes((ASN1_STRING **)a,pp,length,
94 V_ASN1_GENERALIZEDTIME,V_ASN1_UNIVERSAL);
95 if (ret == NULL)
96 {
97 ASN1err(ASN1_F_D2I_ASN1_GENERALIZEDTIME,ERR_R_NESTED_ASN1_ERROR);
98 return(NULL);
99 }
100#ifdef CHARSET_EBCDIC
101 ascii2ebcdic(ret->data, ret->data, ret->length);
102#endif
103 if (!ASN1_GENERALIZEDTIME_check(ret))
104 {
105 ASN1err(ASN1_F_D2I_ASN1_GENERALIZEDTIME,ASN1_R_INVALID_TIME_FORMAT);
106 goto err;
107 }
108
109 return(ret);
110err:
111 if ((ret != NULL) && ((a == NULL) || (*a != ret)))
112 M_ASN1_GENERALIZEDTIME_free(ret);
113 return(NULL);
114 }
115
116#endif
117
118int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *d)
119 {
120 static 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};
122 char *a;
123 int n,i,l,o;
124
125 if (d->type != V_ASN1_GENERALIZEDTIME) return(0);
126 l=d->length;
127 a=(char *)d->data;
128 o=0;
129 /* GENERALIZEDTIME is similar to UTCTIME except the year is
130 * represented as YYYY. This stuff treats everything as a two digit
131 * field so make first two fields 00 to 99
132 */
133 if (l < 13) goto err;
134 for (i=0; i<7; i++)
135 {
136 if ((i == 6) && ((a[o] == 'Z') ||
137 (a[o] == '+') || (a[o] == '-')))
138 { i++; break; }
139 if ((a[o] < '0') || (a[o] > '9')) goto err;
140 n= a[o]-'0';
141 if (++o > l) goto err;
142
143 if ((a[o] < '0') || (a[o] > '9')) goto err;
144 n=(n*10)+ a[o]-'0';
145 if (++o > l) goto err;
146
147 if ((n < min[i]) || (n > max[i])) goto err;
148 }
149 /* Optional fractional seconds: decimal point followed by one
150 * or more digits.
151 */
152 if (a[o] == '.')
153 {
154 if (++o > l) goto err;
155 i = o;
156 while ((a[o] >= '0') && (a[o] <= '9') && (o <= l))
157 o++;
158 /* Must have at least one digit after decimal point */
159 if (i == o) goto err;
160 }
161
162 if (a[o] == 'Z')
163 o++;
164 else if ((a[o] == '+') || (a[o] == '-'))
165 {
166 o++;
167 if (o+4 > l) goto err;
168 for (i=7; i<9; i++)
169 {
170 if ((a[o] < '0') || (a[o] > '9')) goto err;
171 n= a[o]-'0';
172 o++;
173 if ((a[o] < '0') || (a[o] > '9')) goto err;
174 n=(n*10)+ a[o]-'0';
175 if ((n < min[i]) || (n > max[i])) goto err;
176 o++;
177 }
178 }
179 return(o == l);
180err:
181 return(0);
182 }
183
184int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, char *str)
185 {
186 ASN1_GENERALIZEDTIME t;
187
188 t.type=V_ASN1_GENERALIZEDTIME;
189 t.length=strlen(str);
190 t.data=(unsigned char *)str;
191 if (ASN1_GENERALIZEDTIME_check(&t))
192 {
193 if (s != NULL)
194 {
195 ASN1_STRING_set((ASN1_STRING *)s,
196 (unsigned char *)str,t.length);
197 s->type=V_ASN1_GENERALIZEDTIME;
198 }
199 return(1);
200 }
201 else
202 return(0);
203 }
204
205ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,
206 time_t t)
207 {
208 char *p;
209 struct tm *ts;
210 struct tm data;
211 size_t len = 20;
212
213 if (s == NULL)
214 s=M_ASN1_GENERALIZEDTIME_new();
215 if (s == NULL)
216 return(NULL);
217
218 ts=OPENSSL_gmtime(&t, &data);
219 if (ts == NULL)
220 return(NULL);
221
222 p=(char *)s->data;
223 if ((p == NULL) || (s->length < len))
224 {
225 p=OPENSSL_malloc(len);
226 if (p == NULL) return(NULL);
227 if (s->data != NULL)
228 OPENSSL_free(s->data);
229 s->data=(unsigned char *)p;
230 }
231
232 snprintf(p,len,"%04d%02d%02d%02d%02d%02dZ",ts->tm_year + 1900,
233 ts->tm_mon+1,ts->tm_mday,ts->tm_hour,ts->tm_min,ts->tm_sec);
234 s->length=strlen(p);
235 s->type=V_ASN1_GENERALIZEDTIME;
236#ifdef CHARSET_EBCDIC_not
237 ebcdic2ascii(s->data, s->data, s->length);
238#endif
239 return(s);
240 }
diff --git a/src/lib/libcrypto/asn1/a_hdr.c b/src/lib/libcrypto/asn1/a_hdr.c
new file mode 100644
index 0000000000..b1aad81f77
--- /dev/null
+++ b/src/lib/libcrypto/asn1/a_hdr.c
@@ -0,0 +1,119 @@
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, 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(ret->header,d2i_ASN1_OCTET_STRING);
87 if (ret->meth != NULL)
88 {
89 M_ASN1_D2I_get(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_mbstr.c b/src/lib/libcrypto/asn1/a_mbstr.c
index 5d981c6553..58b437bc84 100644
--- a/src/lib/libcrypto/asn1/a_mbstr.c
+++ b/src/lib/libcrypto/asn1/a_mbstr.c
@@ -145,14 +145,14 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
145 145
146 if((minsize > 0) && (nchar < minsize)) { 146 if((minsize > 0) && (nchar < minsize)) {
147 ASN1err(ASN1_F_ASN1_MBSTRING_COPY, ASN1_R_STRING_TOO_SHORT); 147 ASN1err(ASN1_F_ASN1_MBSTRING_COPY, ASN1_R_STRING_TOO_SHORT);
148 sprintf(strbuf, "%ld", minsize); 148 snprintf(strbuf, sizeof strbuf, "%ld", minsize);
149 ERR_add_error_data(2, "minsize=", strbuf); 149 ERR_add_error_data(2, "minsize=", strbuf);
150 return -1; 150 return -1;
151 } 151 }
152 152
153 if((maxsize > 0) && (nchar > maxsize)) { 153 if((maxsize > 0) && (nchar > maxsize)) {
154 ASN1err(ASN1_F_ASN1_MBSTRING_COPY, ASN1_R_STRING_TOO_LONG); 154 ASN1err(ASN1_F_ASN1_MBSTRING_COPY, ASN1_R_STRING_TOO_LONG);
155 sprintf(strbuf, "%ld", maxsize); 155 snprintf(strbuf, sizeof strbuf, "%ld", maxsize);
156 ERR_add_error_data(2, "maxsize=", strbuf); 156 ERR_add_error_data(2, "maxsize=", strbuf);
157 return -1; 157 return -1;
158 } 158 }
diff --git a/src/lib/libcrypto/asn1/a_meth.c b/src/lib/libcrypto/asn1/a_meth.c
new file mode 100644
index 0000000000..63158e9cab
--- /dev/null
+++ b/src/lib/libcrypto/asn1/a_meth.c
@@ -0,0 +1,84 @@
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 (int (*)()) i2d_ASN1_IA5STRING,
66 (char *(*)()) d2i_ASN1_IA5STRING,
67 (char *(*)()) ASN1_STRING_new,
68 (void (*)()) ASN1_STRING_free};
69
70static ASN1_METHOD bit_string_meth={
71 (int (*)()) i2d_ASN1_BIT_STRING,
72 (char *(*)()) d2i_ASN1_BIT_STRING,
73 (char *(*)()) ASN1_STRING_new,
74 (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 0a8e6c287c..71ce7c3896 100644
--- a/src/lib/libcrypto/asn1/a_object.c
+++ b/src/lib/libcrypto/asn1/a_object.c
@@ -183,8 +183,8 @@ int i2a_ASN1_OBJECT(BIO *bp, ASN1_OBJECT *a)
183 183
184 if ((a == NULL) || (a->data == NULL)) 184 if ((a == NULL) || (a->data == NULL))
185 return(BIO_write(bp,"NULL",4)); 185 return(BIO_write(bp,"NULL",4));
186 i=i2t_ASN1_OBJECT(buf,sizeof buf,a); 186 i=i2t_ASN1_OBJECT(buf,80,a);
187 if (i > sizeof buf) i=sizeof buf; 187 if (i > 80) i=80;
188 BIO_write(bp,buf,i); 188 BIO_write(bp,buf,i);
189 return(i); 189 return(i);
190 } 190 }
diff --git a/src/lib/libcrypto/asn1/a_sign.c b/src/lib/libcrypto/asn1/a_sign.c
index 52ce7e3974..de53b44144 100644
--- a/src/lib/libcrypto/asn1/a_sign.c
+++ b/src/lib/libcrypto/asn1/a_sign.c
@@ -204,9 +204,9 @@ int ASN1_sign(int (*i2d)(), X509_ALGOR *algor1, X509_ALGOR *algor2,
204err: 204err:
205 EVP_MD_CTX_cleanup(&ctx); 205 EVP_MD_CTX_cleanup(&ctx);
206 if (buf_in != NULL) 206 if (buf_in != NULL)
207 { OPENSSL_cleanse((char *)buf_in,(unsigned int)inl); OPENSSL_free(buf_in); } 207 { memset((char *)buf_in,0,(unsigned int)inl); OPENSSL_free(buf_in); }
208 if (buf_out != NULL) 208 if (buf_out != NULL)
209 { OPENSSL_cleanse((char *)buf_out,outll); OPENSSL_free(buf_out); } 209 { memset((char *)buf_out,0,outll); OPENSSL_free(buf_out); }
210 return(outl); 210 return(outl);
211 } 211 }
212 212
@@ -287,8 +287,8 @@ int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2,
287err: 287err:
288 EVP_MD_CTX_cleanup(&ctx); 288 EVP_MD_CTX_cleanup(&ctx);
289 if (buf_in != NULL) 289 if (buf_in != NULL)
290 { OPENSSL_cleanse((char *)buf_in,(unsigned int)inl); OPENSSL_free(buf_in); } 290 { memset((char *)buf_in,0,(unsigned int)inl); OPENSSL_free(buf_in); }
291 if (buf_out != NULL) 291 if (buf_out != NULL)
292 { OPENSSL_cleanse((char *)buf_out,outll); OPENSSL_free(buf_out); } 292 { memset((char *)buf_out,0,outll); OPENSSL_free(buf_out); }
293 return(outl); 293 return(outl);
294 } 294 }
diff --git a/src/lib/libcrypto/asn1/a_strex.c b/src/lib/libcrypto/asn1/a_strex.c
index 1def6c6549..7ddb7662f1 100644
--- a/src/lib/libcrypto/asn1/a_strex.c
+++ b/src/lib/libcrypto/asn1/a_strex.c
@@ -63,7 +63,6 @@
63#include <openssl/asn1.h> 63#include <openssl/asn1.h>
64 64
65#include "charmap.h" 65#include "charmap.h"
66#include "cryptlib.h"
67 66
68/* ASN1_STRING_print_ex() and X509_NAME_print_ex(). 67/* ASN1_STRING_print_ex() and X509_NAME_print_ex().
69 * Enhanced string and name printing routines handling 68 * Enhanced string and name printing routines handling
@@ -115,17 +114,14 @@ typedef int char_io(void *arg, const void *buf, int len);
115static int do_esc_char(unsigned long c, unsigned char flags, char *do_quotes, char_io *io_ch, void *arg) 114static int do_esc_char(unsigned long c, unsigned char flags, char *do_quotes, char_io *io_ch, void *arg)
116{ 115{
117 unsigned char chflgs, chtmp; 116 unsigned char chflgs, chtmp;
118 char tmphex[HEX_SIZE(long)+3]; 117 char tmphex[11];
119
120 if(c > 0xffffffffL)
121 return -1;
122 if(c > 0xffff) { 118 if(c > 0xffff) {
123 BIO_snprintf(tmphex, sizeof tmphex, "\\W%08lX", c); 119 BIO_snprintf(tmphex, 11, "\\W%08lX", c);
124 if(!io_ch(arg, tmphex, 10)) return -1; 120 if(!io_ch(arg, tmphex, 10)) return -1;
125 return 10; 121 return 10;
126 } 122 }
127 if(c > 0xff) { 123 if(c > 0xff) {
128 BIO_snprintf(tmphex, sizeof tmphex, "\\U%04lX", c); 124 BIO_snprintf(tmphex, 11, "\\U%04lX", c);
129 if(!io_ch(arg, tmphex, 6)) return -1; 125 if(!io_ch(arg, tmphex, 6)) return -1;
130 return 6; 126 return 6;
131 } 127 }
@@ -199,7 +195,7 @@ static int do_buf(unsigned char *buf, int buflen,
199 if(type & BUF_TYPE_CONVUTF8) { 195 if(type & BUF_TYPE_CONVUTF8) {
200 unsigned char utfbuf[6]; 196 unsigned char utfbuf[6];
201 int utflen; 197 int utflen;
202 utflen = UTF8_putc(utfbuf, sizeof utfbuf, c); 198 utflen = UTF8_putc(utfbuf, 6, c);
203 for(i = 0; i < utflen; i++) { 199 for(i = 0; i < utflen; i++) {
204 /* We don't need to worry about setting orflags correctly 200 /* We don't need to worry about setting orflags correctly
205 * because if utflen==1 its value will be correct anyway 201 * because if utflen==1 its value will be correct anyway
@@ -465,7 +461,7 @@ static int do_name_ex(char_io *io_ch, void *arg, X509_NAME *n,
465 if(fn_opt != XN_FLAG_FN_NONE) { 461 if(fn_opt != XN_FLAG_FN_NONE) {
466 int objlen, fld_len; 462 int objlen, fld_len;
467 if((fn_opt == XN_FLAG_FN_OID) || (fn_nid==NID_undef) ) { 463 if((fn_opt == XN_FLAG_FN_OID) || (fn_nid==NID_undef) ) {
468 OBJ_obj2txt(objtmp, sizeof objtmp, fn, 1); 464 OBJ_obj2txt(objtmp, 80, fn, 1);
469 fld_len = 0; /* XXX: what should this be? */ 465 fld_len = 0; /* XXX: what should this be? */
470 objbuf = objtmp; 466 objbuf = objtmp;
471 } else { 467 } else {
diff --git a/src/lib/libcrypto/asn1/a_strnid.c b/src/lib/libcrypto/asn1/a_strnid.c
index aa49e9d7d0..04789d1c63 100644
--- a/src/lib/libcrypto/asn1/a_strnid.c
+++ b/src/lib/libcrypto/asn1/a_strnid.c
@@ -173,7 +173,6 @@ static ASN1_STRING_TABLE tbl_standard[] = {
173{NID_friendlyName, -1, -1, B_ASN1_BMPSTRING, STABLE_NO_MASK}, 173{NID_friendlyName, -1, -1, B_ASN1_BMPSTRING, STABLE_NO_MASK},
174{NID_name, 1, ub_name, DIRSTRING_TYPE, 0}, 174{NID_name, 1, ub_name, DIRSTRING_TYPE, 0},
175{NID_dnQualifier, -1, -1, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK}, 175{NID_dnQualifier, -1, -1, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK},
176{NID_domainComponent, 1, -1, B_ASN1_IA5STRING, STABLE_NO_MASK},
177{NID_ms_csp_name, -1, -1, B_ASN1_BMPSTRING, STABLE_NO_MASK} 176{NID_ms_csp_name, -1, -1, B_ASN1_BMPSTRING, STABLE_NO_MASK}
178}; 177};
179 178
@@ -250,38 +249,4 @@ static void st_free(ASN1_STRING_TABLE *tbl)
250 if(tbl->flags & STABLE_FLAGS_MALLOC) OPENSSL_free(tbl); 249 if(tbl->flags & STABLE_FLAGS_MALLOC) OPENSSL_free(tbl);
251} 250}
252 251
253
254IMPLEMENT_STACK_OF(ASN1_STRING_TABLE) 252IMPLEMENT_STACK_OF(ASN1_STRING_TABLE)
255
256#ifdef STRING_TABLE_TEST
257
258main()
259{
260 ASN1_STRING_TABLE *tmp;
261 int i, last_nid = -1;
262
263 for (tmp = tbl_standard, i = 0;
264 i < sizeof(tbl_standard)/sizeof(ASN1_STRING_TABLE); i++, tmp++)
265 {
266 if (tmp->nid < last_nid)
267 {
268 last_nid = 0;
269 break;
270 }
271 last_nid = tmp->nid;
272 }
273
274 if (last_nid != 0)
275 {
276 printf("Table order OK\n");
277 exit(0);
278 }
279
280 for (tmp = tbl_standard, i = 0;
281 i < sizeof(tbl_standard)/sizeof(ASN1_STRING_TABLE); i++, tmp++)
282 printf("Index %d, NID %d, Name=%s\n", i, tmp->nid,
283 OBJ_nid2ln(tmp->nid));
284
285}
286
287#endif
diff --git a/src/lib/libcrypto/asn1/a_time.c b/src/lib/libcrypto/asn1/a_time.c
index 7348da9457..8216783aa8 100644
--- a/src/lib/libcrypto/asn1/a_time.c
+++ b/src/lib/libcrypto/asn1/a_time.c
@@ -105,10 +105,7 @@ ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t)
105 105
106 ts=OPENSSL_gmtime(&t,&data); 106 ts=OPENSSL_gmtime(&t,&data);
107 if (ts == NULL) 107 if (ts == NULL)
108 {
109 ASN1err(ASN1_F_ASN1_TIME_SET, ASN1_R_ERROR_GETTING_TIME);
110 return NULL; 108 return NULL;
111 }
112 if((ts->tm_year >= 50) && (ts->tm_year < 150)) 109 if((ts->tm_year >= 50) && (ts->tm_year < 150))
113 return ASN1_UTCTIME_set(s, t); 110 return ASN1_UTCTIME_set(s, t);
114 return ASN1_GENERALIZEDTIME_set(s,t); 111 return ASN1_GENERALIZEDTIME_set(s,t);
@@ -128,6 +125,7 @@ ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZE
128 { 125 {
129 ASN1_GENERALIZEDTIME *ret; 126 ASN1_GENERALIZEDTIME *ret;
130 char *str; 127 char *str;
128 int newlen;
131 129
132 if (!ASN1_TIME_check(t)) return NULL; 130 if (!ASN1_TIME_check(t)) return NULL;
133 131
@@ -150,12 +148,14 @@ ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZE
150 /* grow the string */ 148 /* grow the string */
151 if (!ASN1_STRING_set(ret, NULL, t->length + 2)) 149 if (!ASN1_STRING_set(ret, NULL, t->length + 2))
152 return NULL; 150 return NULL;
151 /* ASN1_STRING_set() allocated 'len + 1' bytes. */
152 newlen = t->length + 2 + 1;
153 str = (char *)ret->data; 153 str = (char *)ret->data;
154 /* Work out the century and prepend */ 154 /* Work out the century and prepend */
155 if (t->data[0] >= '5') strcpy(str, "19"); 155 if (t->data[0] >= '5') strlcpy(str, "19", newlen);
156 else strcpy(str, "20"); 156 else strlcpy(str, "20", newlen);
157 157
158 BUF_strlcat(str, (char *)t->data, t->length+3); /* Include space for a '\0' */ 158 strlcat(str, (char *)t->data, newlen);
159 159
160 return ret; 160 return ret;
161 } 161 }
diff --git a/src/lib/libcrypto/asn1/a_type.c b/src/lib/libcrypto/asn1/a_type.c
index fe3fcd40b0..96e111cf23 100644
--- a/src/lib/libcrypto/asn1/a_type.c
+++ b/src/lib/libcrypto/asn1/a_type.c
@@ -62,7 +62,7 @@
62 62
63int ASN1_TYPE_get(ASN1_TYPE *a) 63int ASN1_TYPE_get(ASN1_TYPE *a)
64 { 64 {
65 if ((a->value.ptr != NULL) || (a->type == V_ASN1_NULL)) 65 if (a->value.ptr != NULL)
66 return(a->type); 66 return(a->type);
67 else 67 else
68 return(0); 68 return(0);
diff --git a/src/lib/libcrypto/asn1/a_utctm.c b/src/lib/libcrypto/asn1/a_utctm.c
new file mode 100644
index 0000000000..41f6d421bb
--- /dev/null
+++ b/src/lib/libcrypto/asn1/a_utctm.c
@@ -0,0 +1,298 @@
1/* crypto/asn1/a_utctm.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 "o_time.h"
63#include <openssl/asn1.h>
64
65#if 0
66int i2d_ASN1_UTCTIME(ASN1_UTCTIME *a, unsigned char **pp)
67 {
68#ifndef CHARSET_EBCDIC
69 return(i2d_ASN1_bytes((ASN1_STRING *)a,pp,
70 V_ASN1_UTCTIME,V_ASN1_UNIVERSAL));
71#else
72 /* KLUDGE! We convert to ascii before writing DER */
73 int len;
74 char tmp[24];
75 ASN1_STRING x = *(ASN1_STRING *)a;
76
77 len = x.length;
78 ebcdic2ascii(tmp, x.data, (len >= sizeof tmp) ? sizeof tmp : len);
79 x.data = tmp;
80 return i2d_ASN1_bytes(&x, pp, V_ASN1_UTCTIME,V_ASN1_UNIVERSAL);
81#endif
82 }
83
84
85ASN1_UTCTIME *d2i_ASN1_UTCTIME(ASN1_UTCTIME **a, unsigned char **pp,
86 long length)
87 {
88 ASN1_UTCTIME *ret=NULL;
89
90 ret=(ASN1_UTCTIME *)d2i_ASN1_bytes((ASN1_STRING **)a,pp,length,
91 V_ASN1_UTCTIME,V_ASN1_UNIVERSAL);
92 if (ret == NULL)
93 {
94 ASN1err(ASN1_F_D2I_ASN1_UTCTIME,ERR_R_NESTED_ASN1_ERROR);
95 return(NULL);
96 }
97#ifdef CHARSET_EBCDIC
98 ascii2ebcdic(ret->data, ret->data, ret->length);
99#endif
100 if (!ASN1_UTCTIME_check(ret))
101 {
102 ASN1err(ASN1_F_D2I_ASN1_UTCTIME,ASN1_R_INVALID_TIME_FORMAT);
103 goto err;
104 }
105
106 return(ret);
107err:
108 if ((ret != NULL) && ((a == NULL) || (*a != ret)))
109 M_ASN1_UTCTIME_free(ret);
110 return(NULL);
111 }
112
113#endif
114
115int ASN1_UTCTIME_check(ASN1_UTCTIME *d)
116 {
117 static int min[8]={ 0, 1, 1, 0, 0, 0, 0, 0};
118 static int max[8]={99,12,31,23,59,59,12,59};
119 char *a;
120 int n,i,l,o;
121
122 if (d->type != V_ASN1_UTCTIME) return(0);
123 l=d->length;
124 a=(char *)d->data;
125 o=0;
126
127 if (l < 11) goto err;
128 for (i=0; i<6; i++)
129 {
130 if ((i == 5) && ((a[o] == 'Z') ||
131 (a[o] == '+') || (a[o] == '-')))
132 { i++; break; }
133 if ((a[o] < '0') || (a[o] > '9')) goto err;
134 n= a[o]-'0';
135 if (++o > l) goto err;
136
137 if ((a[o] < '0') || (a[o] > '9')) goto err;
138 n=(n*10)+ a[o]-'0';
139 if (++o > l) goto err;
140
141 if ((n < min[i]) || (n > max[i])) goto err;
142 }
143 if (a[o] == 'Z')
144 o++;
145 else if ((a[o] == '+') || (a[o] == '-'))
146 {
147 o++;
148 if (o+4 > l) goto err;
149 for (i=6; i<8; i++)
150 {
151 if ((a[o] < '0') || (a[o] > '9')) goto err;
152 n= a[o]-'0';
153 o++;
154 if ((a[o] < '0') || (a[o] > '9')) goto err;
155 n=(n*10)+ a[o]-'0';
156 if ((n < min[i]) || (n > max[i])) goto err;
157 o++;
158 }
159 }
160 return(o == l);
161err:
162 return(0);
163 }
164
165int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, char *str)
166 {
167 ASN1_UTCTIME t;
168
169 t.type=V_ASN1_UTCTIME;
170 t.length=strlen(str);
171 t.data=(unsigned char *)str;
172 if (ASN1_UTCTIME_check(&t))
173 {
174 if (s != NULL)
175 {
176 ASN1_STRING_set((ASN1_STRING *)s,
177 (unsigned char *)str,t.length);
178 s->type = V_ASN1_UTCTIME;
179 }
180 return(1);
181 }
182 else
183 return(0);
184 }
185
186ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t)
187 {
188 char *p;
189 struct tm *ts;
190 struct tm data;
191 size_t len = 20;
192
193 if (s == NULL)
194 s=M_ASN1_UTCTIME_new();
195 if (s == NULL)
196 return(NULL);
197
198 ts=OPENSSL_gmtime(&t, &data);
199 if (ts == NULL)
200 return(NULL);
201
202 p=(char *)s->data;
203 if ((p == NULL) || (s->length < len))
204 {
205 p=OPENSSL_malloc(len);
206 if (p == NULL) return(NULL);
207 if (s->data != NULL)
208 OPENSSL_free(s->data);
209 s->data=(unsigned char *)p;
210 }
211
212 snprintf(p,len,"%02d%02d%02d%02d%02d%02dZ",ts->tm_year%100,
213 ts->tm_mon+1,ts->tm_mday,ts->tm_hour,ts->tm_min,ts->tm_sec);
214 s->length=strlen(p);
215 s->type=V_ASN1_UTCTIME;
216#ifdef CHARSET_EBCDIC_not
217 ebcdic2ascii(s->data, s->data, s->length);
218#endif
219 return(s);
220 }
221
222
223int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t)
224 {
225 struct tm *tm;
226 struct tm data;
227 int offset;
228 int year;
229
230#define g2(p) (((p)[0]-'0')*10+(p)[1]-'0')
231
232 if (s->data[12] == 'Z')
233 offset=0;
234 else
235 {
236 offset = g2(s->data+13)*60+g2(s->data+15);
237 if (s->data[12] == '-')
238 offset = -offset;
239 }
240
241 t -= offset*60; /* FIXME: may overflow in extreme cases */
242
243 tm = OPENSSL_gmtime(&t, &data);
244
245#define return_cmp(a,b) if ((a)<(b)) return -1; else if ((a)>(b)) return 1
246 year = g2(s->data);
247 if (year < 50)
248 year += 100;
249 return_cmp(year, tm->tm_year);
250 return_cmp(g2(s->data+2) - 1, tm->tm_mon);
251 return_cmp(g2(s->data+4), tm->tm_mday);
252 return_cmp(g2(s->data+6), tm->tm_hour);
253 return_cmp(g2(s->data+8), tm->tm_min);
254 return_cmp(g2(s->data+10), tm->tm_sec);
255#undef g2
256#undef return_cmp
257
258 return 0;
259 }
260
261
262#if 0
263time_t ASN1_UTCTIME_get(const ASN1_UTCTIME *s)
264 {
265 struct tm tm;
266 int offset;
267
268 memset(&tm,'\0',sizeof tm);
269
270#define g2(p) (((p)[0]-'0')*10+(p)[1]-'0')
271 tm.tm_year=g2(s->data);
272 if(tm.tm_year < 50)
273 tm.tm_year+=100;
274 tm.tm_mon=g2(s->data+2)-1;
275 tm.tm_mday=g2(s->data+4);
276 tm.tm_hour=g2(s->data+6);
277 tm.tm_min=g2(s->data+8);
278 tm.tm_sec=g2(s->data+10);
279 if(s->data[12] == 'Z')
280 offset=0;
281 else
282 {
283 offset=g2(s->data+13)*60+g2(s->data+15);
284 if(s->data[12] == '-')
285 offset= -offset;
286 }
287#undef g2
288
289 return mktime(&tm)-offset*60; /* FIXME: mktime assumes the current timezone
290 * instead of UTC, and unless we rewrite OpenSSL
291 * in Lisp we cannot locally change the timezone
292 * without possibly interfering with other parts
293 * of the program. timegm, which uses UTC, is
294 * non-standard.
295 * Also time_t is inappropriate for general
296 * UTC times because it may a 32 bit type. */
297 }
298#endif
diff --git a/src/lib/libcrypto/asn1/a_verify.c b/src/lib/libcrypto/asn1/a_verify.c
index da2a0a6d69..bf41de5146 100644
--- a/src/lib/libcrypto/asn1/a_verify.c
+++ b/src/lib/libcrypto/asn1/a_verify.c
@@ -103,7 +103,7 @@ int ASN1_verify(int (*i2d)(), X509_ALGOR *a, ASN1_BIT_STRING *signature,
103 EVP_VerifyInit_ex(&ctx,type, NULL); 103 EVP_VerifyInit_ex(&ctx,type, NULL);
104 EVP_VerifyUpdate(&ctx,(unsigned char *)buf_in,inl); 104 EVP_VerifyUpdate(&ctx,(unsigned char *)buf_in,inl);
105 105
106 OPENSSL_cleanse(buf_in,(unsigned int)inl); 106 memset(buf_in,0,(unsigned int)inl);
107 OPENSSL_free(buf_in); 107 OPENSSL_free(buf_in);
108 108
109 if (EVP_VerifyFinal(&ctx,(unsigned char *)signature->data, 109 if (EVP_VerifyFinal(&ctx,(unsigned char *)signature->data,
@@ -153,7 +153,7 @@ int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *a, ASN1_BIT_STRING *signat
153 EVP_VerifyInit_ex(&ctx,type, NULL); 153 EVP_VerifyInit_ex(&ctx,type, NULL);
154 EVP_VerifyUpdate(&ctx,(unsigned char *)buf_in,inl); 154 EVP_VerifyUpdate(&ctx,(unsigned char *)buf_in,inl);
155 155
156 OPENSSL_cleanse(buf_in,(unsigned int)inl); 156 memset(buf_in,0,(unsigned int)inl);
157 OPENSSL_free(buf_in); 157 OPENSSL_free(buf_in);
158 158
159 if (EVP_VerifyFinal(&ctx,(unsigned char *)signature->data, 159 if (EVP_VerifyFinal(&ctx,(unsigned char *)signature->data,
diff --git a/src/lib/libcrypto/asn1/asn1.h b/src/lib/libcrypto/asn1/asn1.h
index 3414509f1b..dbb30f4f22 100644
--- a/src/lib/libcrypto/asn1/asn1.h
+++ b/src/lib/libcrypto/asn1/asn1.h
@@ -70,6 +70,7 @@
70 70
71#include <openssl/symhacks.h> 71#include <openssl/symhacks.h>
72 72
73#include <openssl/e_os2.h>
73#include <openssl/ossl_typ.h> 74#include <openssl/ossl_typ.h>
74 75
75#ifdef OPENSSL_BUILD_SHLIBCRYPTO 76#ifdef OPENSSL_BUILD_SHLIBCRYPTO
@@ -132,7 +133,7 @@ extern "C" {
132#define B_ASN1_NUMERICSTRING 0x0001 133#define B_ASN1_NUMERICSTRING 0x0001
133#define B_ASN1_PRINTABLESTRING 0x0002 134#define B_ASN1_PRINTABLESTRING 0x0002
134#define B_ASN1_T61STRING 0x0004 135#define B_ASN1_T61STRING 0x0004
135#define B_ASN1_TELETEXSTRING 0x0004 136#define B_ASN1_TELETEXSTRING 0x0008
136#define B_ASN1_VIDEOTEXSTRING 0x0008 137#define B_ASN1_VIDEOTEXSTRING 0x0008
137#define B_ASN1_IA5STRING 0x0010 138#define B_ASN1_IA5STRING 0x0010
138#define B_ASN1_GRAPHICSTRING 0x0020 139#define B_ASN1_GRAPHICSTRING 0x0020
@@ -980,7 +981,6 @@ void ERR_load_ASN1_strings(void);
980#define ASN1_F_ASN1_TEMPLATE_D2I 131 981#define ASN1_F_ASN1_TEMPLATE_D2I 131
981#define ASN1_F_ASN1_TEMPLATE_EX_D2I 132 982#define ASN1_F_ASN1_TEMPLATE_EX_D2I 132
982#define ASN1_F_ASN1_TEMPLATE_NEW 133 983#define ASN1_F_ASN1_TEMPLATE_NEW 133
983#define ASN1_F_ASN1_TIME_SET 175
984#define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 134 984#define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 134
985#define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 135 985#define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 135
986#define ASN1_F_ASN1_UNPACK_STRING 136 986#define ASN1_F_ASN1_UNPACK_STRING 136
@@ -1038,7 +1038,6 @@ void ERR_load_ASN1_strings(void);
1038#define ASN1_R_DECODE_ERROR 110 1038#define ASN1_R_DECODE_ERROR 110
1039#define ASN1_R_DECODING_ERROR 111 1039#define ASN1_R_DECODING_ERROR 111
1040#define ASN1_R_ENCODE_ERROR 112 1040#define ASN1_R_ENCODE_ERROR 112
1041#define ASN1_R_ERROR_GETTING_TIME 173
1042#define ASN1_R_ERROR_LOADING_SECTION 172 1041#define ASN1_R_ERROR_LOADING_SECTION 172
1043#define ASN1_R_ERROR_PARSING_SET_ELEMENT 113 1042#define ASN1_R_ERROR_PARSING_SET_ELEMENT 113
1044#define ASN1_R_ERROR_SETTING_CIPHER_PARAMS 114 1043#define ASN1_R_ERROR_SETTING_CIPHER_PARAMS 114
diff --git a/src/lib/libcrypto/asn1/asn1_err.c b/src/lib/libcrypto/asn1/asn1_err.c
index 094ec06fda..c4c3d2a91d 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-2002 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
@@ -100,7 +100,6 @@ static ERR_STRING_DATA ASN1_str_functs[]=
100{ERR_PACK(0,ASN1_F_ASN1_TEMPLATE_D2I,0), "ASN1_TEMPLATE_D2I"}, 100{ERR_PACK(0,ASN1_F_ASN1_TEMPLATE_D2I,0), "ASN1_TEMPLATE_D2I"},
101{ERR_PACK(0,ASN1_F_ASN1_TEMPLATE_EX_D2I,0), "ASN1_TEMPLATE_EX_D2I"}, 101{ERR_PACK(0,ASN1_F_ASN1_TEMPLATE_EX_D2I,0), "ASN1_TEMPLATE_EX_D2I"},
102{ERR_PACK(0,ASN1_F_ASN1_TEMPLATE_NEW,0), "ASN1_TEMPLATE_NEW"}, 102{ERR_PACK(0,ASN1_F_ASN1_TEMPLATE_NEW,0), "ASN1_TEMPLATE_NEW"},
103{ERR_PACK(0,ASN1_F_ASN1_TIME_SET,0), "ASN1_TIME_set"},
104{ERR_PACK(0,ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING,0), "ASN1_TYPE_get_int_octetstring"}, 103{ERR_PACK(0,ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING,0), "ASN1_TYPE_get_int_octetstring"},
105{ERR_PACK(0,ASN1_F_ASN1_TYPE_GET_OCTETSTRING,0), "ASN1_TYPE_get_octetstring"}, 104{ERR_PACK(0,ASN1_F_ASN1_TYPE_GET_OCTETSTRING,0), "ASN1_TYPE_get_octetstring"},
106{ERR_PACK(0,ASN1_F_ASN1_UNPACK_STRING,0), "ASN1_unpack_string"}, 105{ERR_PACK(0,ASN1_F_ASN1_UNPACK_STRING,0), "ASN1_unpack_string"},
@@ -161,7 +160,6 @@ static ERR_STRING_DATA ASN1_str_reasons[]=
161{ASN1_R_DECODE_ERROR ,"decode error"}, 160{ASN1_R_DECODE_ERROR ,"decode error"},
162{ASN1_R_DECODING_ERROR ,"decoding error"}, 161{ASN1_R_DECODING_ERROR ,"decoding error"},
163{ASN1_R_ENCODE_ERROR ,"encode error"}, 162{ASN1_R_ENCODE_ERROR ,"encode error"},
164{ASN1_R_ERROR_GETTING_TIME ,"error getting time"},
165{ASN1_R_ERROR_LOADING_SECTION ,"error loading section"}, 163{ASN1_R_ERROR_LOADING_SECTION ,"error loading section"},
166{ASN1_R_ERROR_PARSING_SET_ELEMENT ,"error parsing set element"}, 164{ASN1_R_ERROR_PARSING_SET_ELEMENT ,"error parsing set element"},
167{ASN1_R_ERROR_SETTING_CIPHER_PARAMS ,"error setting cipher params"}, 165{ASN1_R_ERROR_SETTING_CIPHER_PARAMS ,"error setting cipher params"},
diff --git a/src/lib/libcrypto/asn1/asn1_lib.c b/src/lib/libcrypto/asn1/asn1_lib.c
index 0638870ab7..60f36bb958 100644
--- a/src/lib/libcrypto/asn1/asn1_lib.c
+++ b/src/lib/libcrypto/asn1/asn1_lib.c
@@ -412,8 +412,8 @@ void asn1_add_error(unsigned char *address, int offset)
412 { 412 {
413 char buf1[DECIMAL_SIZE(address)+1],buf2[DECIMAL_SIZE(offset)+1]; 413 char buf1[DECIMAL_SIZE(address)+1],buf2[DECIMAL_SIZE(offset)+1];
414 414
415 sprintf(buf1,"%lu",(unsigned long)address); 415 snprintf(buf1,sizeof buf1,"%lu",(unsigned long)address);
416 sprintf(buf2,"%d",offset); 416 snprintf(buf2,sizeof buf2,"%d",offset);
417 ERR_add_error_data(4,"address=",buf1," offset=",buf2); 417 ERR_add_error_data(4,"address=",buf1," offset=",buf2);
418 } 418 }
419 419
diff --git a/src/lib/libcrypto/asn1/asn1_par.c b/src/lib/libcrypto/asn1/asn1_par.c
index e48532a24d..4223c9ae45 100644
--- a/src/lib/libcrypto/asn1/asn1_par.c
+++ b/src/lib/libcrypto/asn1/asn1_par.c
@@ -79,15 +79,20 @@ static int asn1_print_info(BIO *bp, int tag, int xclass, int constructed,
79 else 79 else
80 p="prim: "; 80 p="prim: ";
81 if (BIO_write(bp,p,6) < 6) goto err; 81 if (BIO_write(bp,p,6) < 6) goto err;
82 BIO_indent(bp,indent,128); 82 if (indent)
83 {
84 if (indent > 128) indent=128;
85 memset(str,' ',indent);
86 if (BIO_write(bp,str,indent) < indent) goto err;
87 }
83 88
84 p=str; 89 p=str;
85 if ((xclass & V_ASN1_PRIVATE) == V_ASN1_PRIVATE) 90 if ((xclass & V_ASN1_PRIVATE) == V_ASN1_PRIVATE)
86 sprintf(str,"priv [ %d ] ",tag); 91 snprintf(str,sizeof str,"priv [ %d ] ",tag);
87 else if ((xclass & V_ASN1_CONTEXT_SPECIFIC) == V_ASN1_CONTEXT_SPECIFIC) 92 else if ((xclass & V_ASN1_CONTEXT_SPECIFIC) == V_ASN1_CONTEXT_SPECIFIC)
88 sprintf(str,"cont [ %d ]",tag); 93 snprintf(str,sizeof str,"cont [ %d ]",tag);
89 else if ((xclass & V_ASN1_APPLICATION) == V_ASN1_APPLICATION) 94 else if ((xclass & V_ASN1_APPLICATION) == V_ASN1_APPLICATION)
90 sprintf(str,"appl [ %d ]",tag); 95 snprintf(str,sizeof str,"appl [ %d ]",tag);
91 else p = ASN1_tag2str(tag); 96 else p = ASN1_tag2str(tag);
92 97
93 if (p2 != NULL) 98 if (p2 != NULL)
diff --git a/src/lib/libcrypto/asn1/f.c b/src/lib/libcrypto/asn1/f.c
new file mode 100644
index 0000000000..82bccdfd51
--- /dev/null
+++ b/src/lib/libcrypto/asn1/f.c
@@ -0,0 +1,80 @@
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/f_int.c b/src/lib/libcrypto/asn1/f_int.c
index 9494e597ab..48cc3bfb90 100644
--- a/src/lib/libcrypto/asn1/f_int.c
+++ b/src/lib/libcrypto/asn1/f_int.c
@@ -169,7 +169,8 @@ int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size)
169 sp=(unsigned char *)OPENSSL_malloc( 169 sp=(unsigned char *)OPENSSL_malloc(
170 (unsigned int)num+i*2); 170 (unsigned int)num+i*2);
171 else 171 else
172 sp=OPENSSL_realloc_clean(s,slen,num+i*2); 172 sp=(unsigned char *)OPENSSL_realloc(s,
173 (unsigned int)num+i*2);
173 if (sp == NULL) 174 if (sp == NULL)
174 { 175 {
175 ASN1err(ASN1_F_A2I_ASN1_INTEGER,ERR_R_MALLOC_FAILURE); 176 ASN1err(ASN1_F_A2I_ASN1_INTEGER,ERR_R_MALLOC_FAILURE);
diff --git a/src/lib/libcrypto/asn1/n_pkey.c b/src/lib/libcrypto/asn1/n_pkey.c
index 766b51c538..9146ee02c9 100644
--- a/src/lib/libcrypto/asn1/n_pkey.c
+++ b/src/lib/libcrypto/asn1/n_pkey.c
@@ -187,7 +187,7 @@ int i2d_RSA_NET(const RSA *a, unsigned char **pp, int (*cb)(), int sgckey)
187 i2d_NETSCAPE_PKEY(pkey,&zz); 187 i2d_NETSCAPE_PKEY(pkey,&zz);
188 188
189 /* Wipe the private key encoding */ 189 /* Wipe the private key encoding */
190 OPENSSL_cleanse(pkey->private_key->data, rsalen); 190 memset(pkey->private_key->data, 0, rsalen);
191 191
192 if (cb == NULL) 192 if (cb == NULL)
193 cb=EVP_read_pw_string; 193 cb=EVP_read_pw_string;
@@ -206,7 +206,7 @@ int i2d_RSA_NET(const RSA *a, unsigned char **pp, int (*cb)(), int sgckey)
206 } 206 }
207 207
208 EVP_BytesToKey(EVP_rc4(),EVP_md5(),NULL,buf,i,1,key,NULL); 208 EVP_BytesToKey(EVP_rc4(),EVP_md5(),NULL,buf,i,1,key,NULL);
209 OPENSSL_cleanse(buf,256); 209 memset(buf,0,256);
210 210
211 /* Encrypt private key in place */ 211 /* Encrypt private key in place */
212 zz = enckey->enckey->digest->data; 212 zz = enckey->enckey->digest->data;
@@ -294,7 +294,7 @@ static RSA *d2i_RSA_NET_2(RSA **a, ASN1_OCTET_STRING *os,
294 } 294 }
295 295
296 EVP_BytesToKey(EVP_rc4(),EVP_md5(),NULL,buf,i,1,key,NULL); 296 EVP_BytesToKey(EVP_rc4(),EVP_md5(),NULL,buf,i,1,key,NULL);
297 OPENSSL_cleanse(buf,256); 297 memset(buf,0,256);
298 298
299 EVP_CIPHER_CTX_init(&ctx); 299 EVP_CIPHER_CTX_init(&ctx);
300 EVP_DecryptInit_ex(&ctx,EVP_rc4(),NULL, key,NULL); 300 EVP_DecryptInit_ex(&ctx,EVP_rc4(),NULL, key,NULL);
diff --git a/src/lib/libcrypto/asn1/p8_key.c b/src/lib/libcrypto/asn1/p8_key.c
new file mode 100644
index 0000000000..3a31248e14
--- /dev/null
+++ b/src/lib/libcrypto/asn1/p8_key.c
@@ -0,0 +1,131 @@
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 24b409132f..b634d5bc85 100644
--- a/src/lib/libcrypto/asn1/p8_pkey.c
+++ b/src/lib/libcrypto/asn1/p8_pkey.c
@@ -68,8 +68,8 @@ static int pkey_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it)
68 if(operation == ASN1_OP_FREE_PRE) { 68 if(operation == ASN1_OP_FREE_PRE) {
69 PKCS8_PRIV_KEY_INFO *key = (PKCS8_PRIV_KEY_INFO *)*pval; 69 PKCS8_PRIV_KEY_INFO *key = (PKCS8_PRIV_KEY_INFO *)*pval;
70 if (key->pkey->value.octet_string) 70 if (key->pkey->value.octet_string)
71 OPENSSL_cleanse(key->pkey->value.octet_string->data, 71 memset(key->pkey->value.octet_string->data,
72 key->pkey->value.octet_string->length); 72 0, key->pkey->value.octet_string->length);
73 } 73 }
74 return 1; 74 return 1;
75} 75}
diff --git a/src/lib/libcrypto/asn1/t_crl.c b/src/lib/libcrypto/asn1/t_crl.c
index 757c148df8..60db305756 100644
--- a/src/lib/libcrypto/asn1/t_crl.c
+++ b/src/lib/libcrypto/asn1/t_crl.c
@@ -84,11 +84,11 @@ int X509_CRL_print_fp(FILE *fp, X509_CRL *x)
84 84
85int X509_CRL_print(BIO *out, X509_CRL *x) 85int X509_CRL_print(BIO *out, X509_CRL *x)
86{ 86{
87 char buf[256];
87 STACK_OF(X509_REVOKED) *rev; 88 STACK_OF(X509_REVOKED) *rev;
88 X509_REVOKED *r; 89 X509_REVOKED *r;
89 long l; 90 long l;
90 int i, n; 91 int i, n;
91 char *p;
92 92
93 BIO_printf(out, "Certificate Revocation List (CRL):\n"); 93 BIO_printf(out, "Certificate Revocation List (CRL):\n");
94 l = X509_CRL_get_version(x); 94 l = X509_CRL_get_version(x);
@@ -96,9 +96,8 @@ int X509_CRL_print(BIO *out, X509_CRL *x)
96 i = OBJ_obj2nid(x->sig_alg->algorithm); 96 i = OBJ_obj2nid(x->sig_alg->algorithm);
97 BIO_printf(out, "%8sSignature Algorithm: %s\n", "", 97 BIO_printf(out, "%8sSignature Algorithm: %s\n", "",
98 (i == NID_undef) ? "NONE" : OBJ_nid2ln(i)); 98 (i == NID_undef) ? "NONE" : OBJ_nid2ln(i));
99 p=X509_NAME_oneline(X509_CRL_get_issuer(x),NULL,0); 99 X509_NAME_oneline(X509_CRL_get_issuer(x),buf,256);
100 BIO_printf(out,"%8sIssuer: %s\n","",p); 100 BIO_printf(out,"%8sIssuer: %s\n","",buf);
101 OPENSSL_free(p);
102 BIO_printf(out,"%8sLast Update: ",""); 101 BIO_printf(out,"%8sLast Update: ","");
103 ASN1_TIME_print(out,X509_CRL_get_lastUpdate(x)); 102 ASN1_TIME_print(out,X509_CRL_get_lastUpdate(x));
104 BIO_printf(out,"\n%8sNext Update: ",""); 103 BIO_printf(out,"\n%8sNext Update: ","");
diff --git a/src/lib/libcrypto/asn1/t_pkey.c b/src/lib/libcrypto/asn1/t_pkey.c
index 4e09c9e44e..b3f8364012 100644
--- a/src/lib/libcrypto/asn1/t_pkey.c
+++ b/src/lib/libcrypto/asn1/t_pkey.c
@@ -130,18 +130,22 @@ int RSA_print(BIO *bp, const RSA *x, int off)
130 goto err; 130 goto err;
131 } 131 }
132 132
133 if (off)
134 {
135 if (off > 128) off=128;
136 memset(str,' ',off);
137 }
133 if (x->d != NULL) 138 if (x->d != NULL)
134 { 139 {
135 if(!BIO_indent(bp,off,128)) 140 if (off && (BIO_write(bp,str,off) <= 0)) goto err;
136 goto err;
137 if (BIO_printf(bp,"Private-Key: (%d bit)\n",BN_num_bits(x->n)) 141 if (BIO_printf(bp,"Private-Key: (%d bit)\n",BN_num_bits(x->n))
138 <= 0) goto err; 142 <= 0) goto err;
139 } 143 }
140 144
141 if (x->d == NULL) 145 if (x->d == NULL)
142 sprintf(str,"Modulus (%d bit):",BN_num_bits(x->n)); 146 snprintf(str,sizeof str,"Modulus (%d bit):",BN_num_bits(x->n));
143 else 147 else
144 strcpy(str,"modulus:"); 148 strlcpy(str,"modulus:",sizeof str);
145 if (!print(bp,str,x->n,m,off)) goto err; 149 if (!print(bp,str,x->n,m,off)) goto err;
146 s=(x->d == NULL)?"Exponent:":"publicExponent:"; 150 s=(x->d == NULL)?"Exponent:":"publicExponent:";
147 if (!print(bp,s,x->e,m,off)) goto err; 151 if (!print(bp,s,x->e,m,off)) goto err;
@@ -179,6 +183,7 @@ int DSA_print_fp(FILE *fp, const DSA *x, int off)
179 183
180int DSA_print(BIO *bp, const DSA *x, int off) 184int DSA_print(BIO *bp, const DSA *x, int off)
181 { 185 {
186 char str[128];
182 unsigned char *m=NULL; 187 unsigned char *m=NULL;
183 int ret=0; 188 int ret=0;
184 size_t buf_len=0,i; 189 size_t buf_len=0,i;
@@ -205,10 +210,14 @@ int DSA_print(BIO *bp, const DSA *x, int off)
205 goto err; 210 goto err;
206 } 211 }
207 212
213 if (off)
214 {
215 if (off > 128) off=128;
216 memset(str,' ',off);
217 }
208 if (x->priv_key != NULL) 218 if (x->priv_key != NULL)
209 { 219 {
210 if(!BIO_indent(bp,off,128)) 220 if (off && (BIO_write(bp,str,off) <= 0)) goto err;
211 goto err;
212 if (BIO_printf(bp,"Private-Key: (%d bit)\n",BN_num_bits(x->p)) 221 if (BIO_printf(bp,"Private-Key: (%d bit)\n",BN_num_bits(x->p))
213 <= 0) goto err; 222 <= 0) goto err;
214 } 223 }
@@ -231,12 +240,17 @@ static int print(BIO *bp, const char *number, BIGNUM *num, unsigned char *buf,
231 int off) 240 int off)
232 { 241 {
233 int n,i; 242 int n,i;
243 char str[128];
234 const char *neg; 244 const char *neg;
235 245
236 if (num == NULL) return(1); 246 if (num == NULL) return(1);
237 neg=(num->neg)?"-":""; 247 neg=(num->neg)?"-":"";
238 if(!BIO_indent(bp,off,128)) 248 if (off)
239 return 0; 249 {
250 if (off > 128) off=128;
251 memset(str,' ',off);
252 if (BIO_write(bp,str,off) <= 0) return(0);
253 }
240 254
241 if (BN_num_bytes(num) <= BN_BYTES) 255 if (BN_num_bytes(num) <= BN_BYTES)
242 { 256 {
@@ -260,9 +274,9 @@ static int print(BIO *bp, const char *number, BIGNUM *num, unsigned char *buf,
260 { 274 {
261 if ((i%15) == 0) 275 if ((i%15) == 0)
262 { 276 {
263 if(BIO_puts(bp,"\n") <= 0 277 str[0]='\n';
264 || !BIO_indent(bp,off+4,128)) 278 memset(&(str[1]),' ',off+4);
265 return 0; 279 if (BIO_write(bp,str,off+1+4) <= 0) return(0);
266 } 280 }
267 if (BIO_printf(bp,"%02x%s",buf[i],((i+1) == n)?"":":") 281 if (BIO_printf(bp,"%02x%s",buf[i],((i+1) == n)?"":":")
268 <= 0) return(0); 282 <= 0) return(0);
diff --git a/src/lib/libcrypto/asn1/t_req.c b/src/lib/libcrypto/asn1/t_req.c
index 740cee80c0..eca97e00cb 100644
--- a/src/lib/libcrypto/asn1/t_req.c
+++ b/src/lib/libcrypto/asn1/t_req.c
@@ -91,6 +91,7 @@ int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags, unsigned long
91 EVP_PKEY *pkey; 91 EVP_PKEY *pkey;
92 STACK_OF(X509_ATTRIBUTE) *sk; 92 STACK_OF(X509_ATTRIBUTE) *sk;
93 STACK_OF(X509_EXTENSION) *exts; 93 STACK_OF(X509_EXTENSION) *exts;
94 char str[128];
94 char mlch = ' '; 95 char mlch = ' ';
95 int nmindent = 0; 96 int nmindent = 0;
96 97
@@ -115,9 +116,9 @@ int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags, unsigned long
115 l=0; 116 l=0;
116 for (i=0; i<ri->version->length; i++) 117 for (i=0; i<ri->version->length; i++)
117 { l<<=8; l+=ri->version->data[i]; } 118 { l<<=8; l+=ri->version->data[i]; }
118 if(BIO_printf(bp,"%8sVersion: %s%lu (%s0x%lx)\n","",neg,l,neg, 119 snprintf(str,sizeof str,"%8sVersion: %s%lu (%s0x%lx)\n","",neg,
119 l) <= 0) 120 l,neg,l);
120 goto err; 121 if (BIO_puts(bp,str) <= 0) goto err;
121 } 122 }
122 if(!(cflag & X509_FLAG_NO_SUBJECT)) 123 if(!(cflag & X509_FLAG_NO_SUBJECT))
123 { 124 {
@@ -168,14 +169,14 @@ int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags, unsigned long
168 if(!(cflag & X509_FLAG_NO_ATTRIBUTES)) 169 if(!(cflag & X509_FLAG_NO_ATTRIBUTES))
169 { 170 {
170 /* may not be */ 171 /* may not be */
171 if(BIO_printf(bp,"%8sAttributes:\n","") <= 0) 172 snprintf(str,sizeof str,"%8sAttributes:\n","");
172 goto err; 173 if (BIO_puts(bp,str) <= 0) goto err;
173 174
174 sk=x->req_info->attributes; 175 sk=x->req_info->attributes;
175 if (sk_X509_ATTRIBUTE_num(sk) == 0) 176 if (sk_X509_ATTRIBUTE_num(sk) == 0)
176 { 177 {
177 if(BIO_printf(bp,"%12sa0:00\n","") <= 0) 178 snprintf(str,sizeof str,"%12sa0:00\n","");
178 goto err; 179 if (BIO_puts(bp,str) <= 0) goto err;
179 } 180 }
180 else 181 else
181 { 182 {
@@ -190,8 +191,8 @@ int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags, unsigned long
190 a=sk_X509_ATTRIBUTE_value(sk,i); 191 a=sk_X509_ATTRIBUTE_value(sk,i);
191 if(X509_REQ_extension_nid(OBJ_obj2nid(a->object))) 192 if(X509_REQ_extension_nid(OBJ_obj2nid(a->object)))
192 continue; 193 continue;
193 if(BIO_printf(bp,"%12s","") <= 0) 194 snprintf(str,sizeof str,"%12s","");
194 goto err; 195 if (BIO_puts(bp,str) <= 0) goto err;
195 if ((j=i2a_ASN1_OBJECT(bp,a->object)) > 0) 196 if ((j=i2a_ASN1_OBJECT(bp,a->object)) > 0)
196 { 197 {
197 if (a->single) 198 if (a->single)
diff --git a/src/lib/libcrypto/asn1/t_x509.c b/src/lib/libcrypto/asn1/t_x509.c
index d1034c47f8..5de4833ed0 100644
--- a/src/lib/libcrypto/asn1/t_x509.c
+++ b/src/lib/libcrypto/asn1/t_x509.c
@@ -433,17 +433,15 @@ err:
433 433
434int X509_NAME_print(BIO *bp, X509_NAME *name, int obase) 434int X509_NAME_print(BIO *bp, X509_NAME *name, int obase)
435 { 435 {
436 char *s,*c,*b; 436 char *s,*c;
437 int ret=0,l,ll,i,first=1; 437 int ret=0,l,ll,i,first=1;
438 char buf[256];
438 439
439 ll=80-2-obase; 440 ll=80-2-obase;
440 441
441 b=s=X509_NAME_oneline(name,NULL,0); 442 s=X509_NAME_oneline(name,buf,256);
442 if (!*s) 443 if (!*s)
443 {
444 OPENSSL_free(b);
445 return 1; 444 return 1;
446 }
447 s++; /* skip the first slash */ 445 s++; /* skip the first slash */
448 446
449 l=ll; 447 l=ll;
@@ -499,7 +497,6 @@ int X509_NAME_print(BIO *bp, X509_NAME *name, int obase)
499err: 497err:
500 X509err(X509_F_X509_NAME_PRINT,ERR_R_BUF_LIB); 498 X509err(X509_F_X509_NAME_PRINT,ERR_R_BUF_LIB);
501 } 499 }
502 OPENSSL_free(b);
503 return(ret); 500 return(ret);
504 } 501 }
505 502
diff --git a/src/lib/libcrypto/asn1/t_x509a.c b/src/lib/libcrypto/asn1/t_x509a.c
index ffbbfb51f4..7d4a6e6084 100644
--- a/src/lib/libcrypto/asn1/t_x509a.c
+++ b/src/lib/libcrypto/asn1/t_x509a.c
@@ -77,7 +77,7 @@ int X509_CERT_AUX_print(BIO *out, X509_CERT_AUX *aux, int indent)
77 for(i = 0; i < sk_ASN1_OBJECT_num(aux->trust); i++) { 77 for(i = 0; i < sk_ASN1_OBJECT_num(aux->trust); i++) {
78 if(!first) BIO_puts(out, ", "); 78 if(!first) BIO_puts(out, ", ");
79 else first = 0; 79 else first = 0;
80 OBJ_obj2txt(oidstr, sizeof oidstr, 80 OBJ_obj2txt(oidstr, 80,
81 sk_ASN1_OBJECT_value(aux->trust, i), 0); 81 sk_ASN1_OBJECT_value(aux->trust, i), 0);
82 BIO_puts(out, oidstr); 82 BIO_puts(out, oidstr);
83 } 83 }
@@ -90,7 +90,7 @@ int X509_CERT_AUX_print(BIO *out, X509_CERT_AUX *aux, int indent)
90 for(i = 0; i < sk_ASN1_OBJECT_num(aux->reject); i++) { 90 for(i = 0; i < sk_ASN1_OBJECT_num(aux->reject); i++) {
91 if(!first) BIO_puts(out, ", "); 91 if(!first) BIO_puts(out, ", ");
92 else first = 0; 92 else first = 0;
93 OBJ_obj2txt(oidstr, sizeof oidstr, 93 OBJ_obj2txt(oidstr, 80,
94 sk_ASN1_OBJECT_value(aux->reject, i), 0); 94 sk_ASN1_OBJECT_value(aux->reject, i), 0);
95 BIO_puts(out, oidstr); 95 BIO_puts(out, oidstr);
96 } 96 }
diff --git a/src/lib/libcrypto/asn1/tasn_dec.c b/src/lib/libcrypto/asn1/tasn_dec.c
index 76fc023230..f87c08793a 100644
--- a/src/lib/libcrypto/asn1/tasn_dec.c
+++ b/src/lib/libcrypto/asn1/tasn_dec.c
@@ -664,7 +664,7 @@ static int asn1_d2i_ex_primitive(ASN1_VALUE **pval, unsigned char **in, long inl
664 if(!asn1_collect(&buf, &p, plen, inf, -1, V_ASN1_UNIVERSAL)) goto err; 664 if(!asn1_collect(&buf, &p, plen, inf, -1, V_ASN1_UNIVERSAL)) goto err;
665 len = buf.length; 665 len = buf.length;
666 /* Append a final null to string */ 666 /* Append a final null to string */
667 if(!BUF_MEM_grow_clean(&buf, len + 1)) { 667 if(!BUF_MEM_grow(&buf, len + 1)) {
668 ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ERR_R_MALLOC_FAILURE); 668 ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ERR_R_MALLOC_FAILURE);
669 return 0; 669 return 0;
670 } 670 }
@@ -857,7 +857,7 @@ static int collect_data(BUF_MEM *buf, unsigned char **p, long plen)
857 int len; 857 int len;
858 if(buf) { 858 if(buf) {
859 len = buf->length; 859 len = buf->length;
860 if(!BUF_MEM_grow_clean(buf, len + plen)) { 860 if(!BUF_MEM_grow(buf, len + plen)) {
861 ASN1err(ASN1_F_COLLECT_DATA, ERR_R_MALLOC_FAILURE); 861 ASN1err(ASN1_F_COLLECT_DATA, ERR_R_MALLOC_FAILURE);
862 return 0; 862 return 0;
863 } 863 }
diff --git a/src/lib/libcrypto/asn1/tasn_fre.c b/src/lib/libcrypto/asn1/tasn_fre.c
index 2dd844159e..c7610776f2 100644
--- a/src/lib/libcrypto/asn1/tasn_fre.c
+++ b/src/lib/libcrypto/asn1/tasn_fre.c
@@ -206,10 +206,7 @@ void ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
206 break; 206 break;
207 207
208 case V_ASN1_BOOLEAN: 208 case V_ASN1_BOOLEAN:
209 if (it) 209 *(ASN1_BOOLEAN *)pval = it->size;
210 *(ASN1_BOOLEAN *)pval = it->size;
211 else
212 *(ASN1_BOOLEAN *)pval = -1;
213 return; 210 return;
214 211
215 case V_ASN1_NULL: 212 case V_ASN1_NULL:
diff --git a/src/lib/libcrypto/asn1/tasn_new.c b/src/lib/libcrypto/asn1/tasn_new.c
index a0e3db574f..e33861f864 100644
--- a/src/lib/libcrypto/asn1/tasn_new.c
+++ b/src/lib/libcrypto/asn1/tasn_new.c
@@ -305,10 +305,7 @@ int ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it)
305 return 1; 305 return 1;
306 306
307 case V_ASN1_BOOLEAN: 307 case V_ASN1_BOOLEAN:
308 if (it) 308 *(ASN1_BOOLEAN *)pval = it->size;
309 *(ASN1_BOOLEAN *)pval = it->size;
310 else
311 *(ASN1_BOOLEAN *)pval = -1;
312 return 1; 309 return 1;
313 310
314 case V_ASN1_NULL: 311 case V_ASN1_NULL:
diff --git a/src/lib/libcrypto/asn1/tasn_prn.c b/src/lib/libcrypto/asn1/tasn_prn.c
index 719639b511..fab67ae5ac 100644
--- a/src/lib/libcrypto/asn1/tasn_prn.c
+++ b/src/lib/libcrypto/asn1/tasn_prn.c
@@ -186,7 +186,7 @@ if(*bool == -1) printf("BOOL MISSING\n");
186 char objbuf[80], *ln; 186 char objbuf[80], *ln;
187 ln = OBJ_nid2ln(OBJ_obj2nid(fld)); 187 ln = OBJ_nid2ln(OBJ_obj2nid(fld));
188 if(!ln) ln = ""; 188 if(!ln) ln = "";
189 OBJ_obj2txt(objbuf, sizeof objbuf, fld, 1); 189 OBJ_obj2txt(objbuf, 80, fld, 1);
190 BIO_printf(out, "%*s%s:%s (%s)", indent, "", "OBJECT", ln, objbuf); 190 BIO_printf(out, "%*s%s:%s (%s)", indent, "", "OBJECT", ln, objbuf);
191 } else { 191 } else {
192 BIO_printf(out, "%*s%s:", indent, "", name); 192 BIO_printf(out, "%*s%s:", indent, "", name);
diff --git a/src/lib/libcrypto/asn1/x_cinf.c b/src/lib/libcrypto/asn1/x_cinf.c
new file mode 100644
index 0000000000..339a110eef
--- /dev/null
+++ b/src/lib/libcrypto/asn1/x_cinf.c
@@ -0,0 +1,201 @@
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_long.c b/src/lib/libcrypto/asn1/x_long.c
index c04b192794..c5f25956cb 100644
--- a/src/lib/libcrypto/asn1/x_long.c
+++ b/src/lib/libcrypto/asn1/x_long.c
@@ -104,7 +104,12 @@ static int long_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const A
104 long ltmp; 104 long ltmp;
105 unsigned long utmp; 105 unsigned long utmp;
106 int clen, pad, i; 106 int clen, pad, i;
107 ltmp = *(long *)pval; 107 /* this exists to bypass broken gcc optimization */
108 char *cp = (char *)pval;
109
110 /* use memcpy, because we may not be long aligned */
111 memcpy(&ltmp, cp, sizeof(long));
112
108 if(ltmp == it->size) return -1; 113 if(ltmp == it->size) return -1;
109 /* Convert the long to positive: we subtract one if negative so 114 /* Convert the long to positive: we subtract one if negative so
110 * we can cleanly handle the padding if only the MSB of the leading 115 * we can cleanly handle the padding if only the MSB of the leading
@@ -136,6 +141,7 @@ static int long_c2i(ASN1_VALUE **pval, unsigned char *cont, int len, int utype,
136 int neg, i; 141 int neg, i;
137 long ltmp; 142 long ltmp;
138 unsigned long utmp = 0; 143 unsigned long utmp = 0;
144 char *cp = (char *)pval;
139 if(len > sizeof(long)) { 145 if(len > sizeof(long)) {
140 ASN1err(ASN1_F_LONG_C2I, ASN1_R_INTEGER_TOO_LARGE_FOR_LONG); 146 ASN1err(ASN1_F_LONG_C2I, ASN1_R_INTEGER_TOO_LARGE_FOR_LONG);
141 return 0; 147 return 0;
@@ -158,6 +164,6 @@ static int long_c2i(ASN1_VALUE **pval, unsigned char *cont, int len, int utype,
158 ASN1err(ASN1_F_LONG_C2I, ASN1_R_INTEGER_TOO_LARGE_FOR_LONG); 164 ASN1err(ASN1_F_LONG_C2I, ASN1_R_INTEGER_TOO_LARGE_FOR_LONG);
159 return 0; 165 return 0;
160 } 166 }
161 *(long *)pval = ltmp; 167 memcpy(cp, &ltmp, sizeof(long));
162 return 1; 168 return 1;
163} 169}
diff --git a/src/lib/libcrypto/bf/Makefile.ssl b/src/lib/libcrypto/bf/Makefile.ssl
new file mode 100644
index 0000000000..079f7e860c
--- /dev/null
+++ b/src/lib/libcrypto/bf/Makefile.ssl
@@ -0,0 +1,120 @@
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)
25
26GENERAL=Makefile
27TEST=bftest.c
28APPS=
29
30LIB=$(TOP)/libcrypto.a
31LIBSRC=bf_skey.c bf_ecb.c bf_enc.c bf_cfb64.c bf_ofb64.c
32LIBOBJ=bf_skey.o bf_ecb.o $(BF_ENC) bf_cfb64.o bf_ofb64.o
33
34SRC= $(LIBSRC)
35
36EXHEADER= blowfish.h
37HEADER= bf_pi.h bf_locl.h $(EXHEADER)
38
39ALL= $(GENERAL) $(SRC) $(HEADER)
40
41top:
42 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
43
44all: lib
45
46lib: $(LIBOBJ)
47 $(AR) $(LIB) $(LIBOBJ)
48 $(RANLIB) $(LIB) || echo Never mind.
49 @touch lib
50
51# elf
52asm/bx86-elf.o: asm/bx86unix.cpp
53 $(CPP) -DELF -x c asm/bx86unix.cpp | as -o asm/bx86-elf.o
54
55# solaris
56asm/bx86-sol.o: asm/bx86unix.cpp
57 $(CC) -E -DSOL asm/bx86unix.cpp | sed 's/^#.*//' > asm/bx86-sol.s
58 as -o asm/bx86-sol.o asm/bx86-sol.s
59 rm -f asm/bx86-sol.s
60
61# a.out
62asm/bx86-out.o: asm/bx86unix.cpp
63 $(CPP) -DOUT asm/bx86unix.cpp | as -o asm/bx86-out.o
64
65# bsdi
66asm/bx86bsdi.o: asm/bx86unix.cpp
67 $(CPP) -DBSDI asm/bx86unix.cpp | sed 's/ :/:/' | as -o asm/bx86bsdi.o
68
69asm/bx86unix.cpp: asm/bf-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl
70 (cd asm; $(PERL) bf-586.pl cpp $(PROCESSOR) >bx86unix.cpp)
71
72files:
73 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
74
75links:
76 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
77 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
78 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
79 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
80
81install: installs
82
83installs:
84 @for i in $(EXHEADER) ; \
85 do \
86 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
87 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
88 done;
89
90tags:
91 ctags $(SRC)
92
93tests:
94
95lint:
96 lint -DLINT $(INCLUDES) $(SRC)>fluff
97
98depend:
99 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC)
100
101dclean:
102 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
103 mv -f Makefile.new $(MAKEFILE)
104
105clean:
106 rm -f asm/bx86unix.cpp *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
107
108# DO NOT DELETE THIS LINE -- make depend depends on it.
109
110bf_cfb64.o: ../../include/openssl/blowfish.h ../../include/openssl/e_os2.h
111bf_cfb64.o: ../../include/openssl/opensslconf.h bf_cfb64.c bf_locl.h
112bf_ecb.o: ../../include/openssl/blowfish.h ../../include/openssl/e_os2.h
113bf_ecb.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
114bf_ecb.o: bf_ecb.c bf_locl.h
115bf_enc.o: ../../include/openssl/blowfish.h ../../include/openssl/e_os2.h
116bf_enc.o: ../../include/openssl/opensslconf.h bf_enc.c bf_locl.h
117bf_ofb64.o: ../../include/openssl/blowfish.h ../../include/openssl/e_os2.h
118bf_ofb64.o: ../../include/openssl/opensslconf.h bf_locl.h bf_ofb64.c
119bf_skey.o: ../../include/openssl/blowfish.h ../../include/openssl/e_os2.h
120bf_skey.o: ../../include/openssl/opensslconf.h bf_locl.h bf_pi.h bf_skey.c
diff --git a/src/lib/libcrypto/bf/asm/bf-686.pl b/src/lib/libcrypto/bf/asm/bf-686.pl
new file mode 100644
index 0000000000..8e4c25f598
--- /dev/null
+++ b/src/lib/libcrypto/bf/asm/bf-686.pl
@@ -0,0 +1,127 @@
1#!/usr/local/bin/perl
2
3push(@INC,"perlasm","../../perlasm");
4require "x86asm.pl";
5require "cbc.pl";
6
7&asm_init($ARGV[0],"bf-686.pl");
8
9$BF_ROUNDS=16;
10$BF_OFF=($BF_ROUNDS+2)*4;
11$L="ecx";
12$R="edx";
13$P="edi";
14$tot="esi";
15$tmp1="eax";
16$tmp2="ebx";
17$tmp3="ebp";
18
19&des_encrypt("BF_encrypt",1);
20&des_encrypt("BF_decrypt",0);
21&cbc("BF_cbc_encrypt","BF_encrypt","BF_decrypt",1,4,5,3,-1,-1);
22
23&asm_finish();
24
25&file_end();
26
27sub des_encrypt
28 {
29 local($name,$enc)=@_;
30
31 &function_begin($name,"");
32
33 &comment("");
34 &comment("Load the 2 words");
35 &mov("eax",&wparam(0));
36 &mov($L,&DWP(0,"eax","",0));
37 &mov($R,&DWP(4,"eax","",0));
38
39 &comment("");
40 &comment("P pointer, s and enc flag");
41 &mov($P,&wparam(1));
42
43 &xor( $tmp1, $tmp1);
44 &xor( $tmp2, $tmp2);
45
46 # encrypting part
47
48 if ($enc)
49 {
50 &xor($L,&DWP(0,$P,"",0));
51 for ($i=0; $i<$BF_ROUNDS; $i+=2)
52 {
53 &comment("");
54 &comment("Round $i");
55 &BF_ENCRYPT($i+1,$R,$L,$P,$tot,$tmp1,$tmp2,$tmp3);
56
57 &comment("");
58 &comment("Round ".sprintf("%d",$i+1));
59 &BF_ENCRYPT($i+2,$L,$R,$P,$tot,$tmp1,$tmp2,$tmp3);
60 }
61 &xor($R,&DWP(($BF_ROUNDS+1)*4,$P,"",0));
62
63 &mov("eax",&wparam(0));
64 &mov(&DWP(0,"eax","",0),$R);
65 &mov(&DWP(4,"eax","",0),$L);
66 &function_end_A($name);
67 }
68 else
69 {
70 &xor($L,&DWP(($BF_ROUNDS+1)*4,$P,"",0));
71 for ($i=$BF_ROUNDS; $i>0; $i-=2)
72 {
73 &comment("");
74 &comment("Round $i");
75 &BF_ENCRYPT($i,$R,$L,$P,$tot,$tmp1,$tmp2,$tmp3);
76 &comment("");
77 &comment("Round ".sprintf("%d",$i-1));
78 &BF_ENCRYPT($i-1,$L,$R,$P,$tot,$tmp1,$tmp2,$tmp3);
79 }
80 &xor($R,&DWP(0,$P,"",0));
81
82 &mov("eax",&wparam(0));
83 &mov(&DWP(0,"eax","",0),$R);
84 &mov(&DWP(4,"eax","",0),$L);
85 &function_end_A($name);
86 }
87
88 &function_end_B($name);
89 }
90
91sub BF_ENCRYPT
92 {
93 local($i,$L,$R,$P,$tot,$tmp1,$tmp2,$tmp3)=@_;
94
95 &rotr( $R, 16);
96 &mov( $tot, &DWP(&n2a($i*4),$P,"",0));
97
98 &movb( &LB($tmp1), &HB($R));
99 &movb( &LB($tmp2), &LB($R));
100
101 &rotr( $R, 16);
102 &xor( $L, $tot);
103
104 &mov( $tot, &DWP(&n2a($BF_OFF+0x0000),$P,$tmp1,4));
105 &mov( $tmp3, &DWP(&n2a($BF_OFF+0x0400),$P,$tmp2,4));
106
107 &movb( &LB($tmp1), &HB($R));
108 &movb( &LB($tmp2), &LB($R));
109
110 &add( $tot, $tmp3);
111 &mov( $tmp1, &DWP(&n2a($BF_OFF+0x0800),$P,$tmp1,4)); # delay
112
113 &xor( $tot, $tmp1);
114 &mov( $tmp3, &DWP(&n2a($BF_OFF+0x0C00),$P,$tmp2,4));
115
116 &add( $tot, $tmp3);
117 &xor( $tmp1, $tmp1);
118
119 &xor( $L, $tot);
120 # delay
121 }
122
123sub n2a
124 {
125 sprintf("%d",$_[0]);
126 }
127
diff --git a/src/lib/libcrypto/bf/asm/readme b/src/lib/libcrypto/bf/asm/readme
new file mode 100644
index 0000000000..2385fa3812
--- /dev/null
+++ b/src/lib/libcrypto/bf/asm/readme
@@ -0,0 +1,10 @@
1There are blowfish assembler generation scripts.
2bf-586.pl version is for the pentium and
3bf-686.pl is my original version, which is faster on the pentium pro.
4
5When using a bf-586.pl, the pentium pro/II is %8 slower than using
6bf-686.pl. When using a bf-686.pl, the pentium is %16 slower
7than bf-586.pl
8
9So the default is bf-586.pl
10
diff --git a/src/lib/libcrypto/bf/bf_opts.c b/src/lib/libcrypto/bf/bf_opts.c
new file mode 100644
index 0000000000..171dada2ca
--- /dev/null
+++ b/src/lib/libcrypto/bf/bf_opts.c
@@ -0,0 +1,328 @@
1/* crypto/bf/bf_opts.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/* define PART1, PART2, PART3 or PART4 to build only with a few of the options.
60 * This is for machines with 64k code segment size restrictions. */
61
62#if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX)
63#define TIMES
64#endif
65
66#include <stdio.h>
67
68#include <openssl/e_os2.h>
69#include OPENSSL_UNISTD_IO
70OPENSSL_DECLARE_EXIT
71
72#include <signal.h>
73#ifndef _IRIX
74#include <time.h>
75#endif
76#ifdef TIMES
77#include <sys/types.h>
78#include <sys/times.h>
79#endif
80
81/* Depending on the VMS version, the tms structure is perhaps defined.
82 The __TMS macro will show if it was. If it wasn't defined, we should
83 undefine TIMES, since that tells the rest of the program how things
84 should be handled. -- Richard Levitte */
85#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
86#undef TIMES
87#endif
88
89#ifndef TIMES
90#include <sys/timeb.h>
91#endif
92
93#if defined(sun) || defined(__ultrix)
94#define _POSIX_SOURCE
95#include <limits.h>
96#include <sys/param.h>
97#endif
98
99#include <openssl/blowfish.h>
100
101#define BF_DEFAULT_OPTIONS
102
103#undef BF_ENC
104#define BF_encrypt BF_encrypt_normal
105#undef HEADER_BF_LOCL_H
106#include "bf_enc.c"
107
108#define BF_PTR
109#undef BF_PTR2
110#undef BF_ENC
111#undef BF_encrypt
112#define BF_encrypt BF_encrypt_ptr
113#undef HEADER_BF_LOCL_H
114#include "bf_enc.c"
115
116#undef BF_PTR
117#define BF_PTR2
118#undef BF_ENC
119#undef BF_encrypt
120#define BF_encrypt BF_encrypt_ptr2
121#undef HEADER_BF_LOCL_H
122#include "bf_enc.c"
123
124/* The following if from times(3) man page. It may need to be changed */
125#ifndef HZ
126# ifndef CLK_TCK
127# ifndef _BSD_CLK_TCK_ /* FreeBSD fix */
128# define HZ 100.0
129# else /* _BSD_CLK_TCK_ */
130# define HZ ((double)_BSD_CLK_TCK_)
131# endif
132# else /* CLK_TCK */
133# define HZ ((double)CLK_TCK)
134# endif
135#endif
136
137#define BUFSIZE ((long)1024)
138long run=0;
139
140double Time_F(int s);
141#ifdef SIGALRM
142#if defined(__STDC__) || defined(sgi)
143#define SIGRETTYPE void
144#else
145#define SIGRETTYPE int
146#endif
147
148SIGRETTYPE sig_done(int sig);
149SIGRETTYPE sig_done(int sig)
150 {
151 signal(SIGALRM,sig_done);
152 run=0;
153#ifdef LINT
154 sig=sig;
155#endif
156 }
157#endif
158
159#define START 0
160#define STOP 1
161
162double Time_F(int s)
163 {
164 double ret;
165#ifdef TIMES
166 static struct tms tstart,tend;
167
168 if (s == START)
169 {
170 times(&tstart);
171 return(0);
172 }
173 else
174 {
175 times(&tend);
176 ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
177 return((ret == 0.0)?1e-6:ret);
178 }
179#else /* !times() */
180 static struct timeb tstart,tend;
181 long i;
182
183 if (s == START)
184 {
185 ftime(&tstart);
186 return(0);
187 }
188 else
189 {
190 ftime(&tend);
191 i=(long)tend.millitm-(long)tstart.millitm;
192 ret=((double)(tend.time-tstart.time))+((double)i)/1000.0;
193 return((ret == 0.0)?1e-6:ret);
194 }
195#endif
196 }
197
198#ifdef SIGALRM
199#define print_name(name) fprintf(stderr,"Doing %s's for 10 seconds\n",name); alarm(10);
200#else
201#define print_name(name) fprintf(stderr,"Doing %s %ld times\n",name,cb);
202#endif
203
204#define time_it(func,name,index) \
205 print_name(name); \
206 Time_F(START); \
207 for (count=0,run=1; COND(cb); count+=4) \
208 { \
209 unsigned long d[2]; \
210 func(d,&sch); \
211 func(d,&sch); \
212 func(d,&sch); \
213 func(d,&sch); \
214 } \
215 tm[index]=Time_F(STOP); \
216 fprintf(stderr,"%ld %s's in %.2f second\n",count,name,tm[index]); \
217 tm[index]=((double)COUNT(cb))/tm[index];
218
219#define print_it(name,index) \
220 fprintf(stderr,"%s bytes per sec = %12.2f (%5.1fuS)\n",name, \
221 tm[index]*8,1.0e6/tm[index]);
222
223int main(int argc, char **argv)
224 {
225 long count;
226 static unsigned char buf[BUFSIZE];
227 static char key[16]={ 0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
228 0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0};
229 BF_KEY sch;
230 double d,tm[16],max=0;
231 int rank[16];
232 char *str[16];
233 int max_idx=0,i,num=0,j;
234#ifndef SIGALARM
235 long ca,cb,cc,cd,ce;
236#endif
237
238 for (i=0; i<12; i++)
239 {
240 tm[i]=0.0;
241 rank[i]=0;
242 }
243
244#ifndef TIMES
245 fprintf(stderr,"To get the most accurate results, try to run this\n");
246 fprintf(stderr,"program when this computer is idle.\n");
247#endif
248
249 BF_set_key(&sch,16,key);
250
251#ifndef SIGALRM
252 fprintf(stderr,"First we calculate the approximate speed ...\n");
253 count=10;
254 do {
255 long i;
256 unsigned long data[2];
257
258 count*=2;
259 Time_F(START);
260 for (i=count; i; i--)
261 BF_encrypt(data,&sch);
262 d=Time_F(STOP);
263 } while (d < 3.0);
264 ca=count;
265 cb=count*3;
266 cc=count*3*8/BUFSIZE+1;
267 cd=count*8/BUFSIZE+1;
268
269 ce=count/20+1;
270#define COND(d) (count != (d))
271#define COUNT(d) (d)
272#else
273#define COND(c) (run)
274#define COUNT(d) (count)
275 signal(SIGALRM,sig_done);
276 alarm(10);
277#endif
278
279 time_it(BF_encrypt_normal, "BF_encrypt_normal ", 0);
280 time_it(BF_encrypt_ptr, "BF_encrypt_ptr ", 1);
281 time_it(BF_encrypt_ptr2, "BF_encrypt_ptr2 ", 2);
282 num+=3;
283
284 str[0]="<nothing>";
285 print_it("BF_encrypt_normal ",0);
286 max=tm[0];
287 max_idx=0;
288 str[1]="ptr ";
289 print_it("BF_encrypt_ptr ",1);
290 if (max < tm[1]) { max=tm[1]; max_idx=1; }
291 str[2]="ptr2 ";
292 print_it("BF_encrypt_ptr2 ",2);
293 if (max < tm[2]) { max=tm[2]; max_idx=2; }
294
295 printf("options BF ecb/s\n");
296 printf("%s %12.2f 100.0%%\n",str[max_idx],tm[max_idx]);
297 d=tm[max_idx];
298 tm[max_idx]= -2.0;
299 max= -1.0;
300 for (;;)
301 {
302 for (i=0; i<3; i++)
303 {
304 if (max < tm[i]) { max=tm[i]; j=i; }
305 }
306 if (max < 0.0) break;
307 printf("%s %12.2f %4.1f%%\n",str[j],tm[j],tm[j]/d*100.0);
308 tm[j]= -2.0;
309 max= -1.0;
310 }
311
312 switch (max_idx)
313 {
314 case 0:
315 printf("-DBF_DEFAULT_OPTIONS\n");
316 break;
317 case 1:
318 printf("-DBF_PTR\n");
319 break;
320 case 2:
321 printf("-DBF_PTR2\n");
322 break;
323 }
324 exit(0);
325#if defined(LINT) || defined(OPENSSL_SYS_MSDOS)
326 return(0);
327#endif
328 }
diff --git a/src/lib/libcrypto/bf/bfs.cpp b/src/lib/libcrypto/bf/bfs.cpp
new file mode 100644
index 0000000000..d74c457760
--- /dev/null
+++ b/src/lib/libcrypto/bf/bfs.cpp
@@ -0,0 +1,67 @@
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/blowfish.h>
36
37void main(int argc,char *argv[])
38 {
39 BF_KEY key;
40 unsigned long s1,s2,e1,e2;
41 unsigned long data[2];
42 int i,j;
43
44 for (j=0; j<6; j++)
45 {
46 for (i=0; i<1000; i++) /**/
47 {
48 BF_encrypt(&data[0],&key);
49 GetTSC(s1);
50 BF_encrypt(&data[0],&key);
51 BF_encrypt(&data[0],&key);
52 BF_encrypt(&data[0],&key);
53 GetTSC(e1);
54 GetTSC(s2);
55 BF_encrypt(&data[0],&key);
56 BF_encrypt(&data[0],&key);
57 BF_encrypt(&data[0],&key);
58 BF_encrypt(&data[0],&key);
59 GetTSC(e2);
60 BF_encrypt(&data[0],&key);
61 }
62
63 printf("blowfish %d %d (%d)\n",
64 e1-s1,e2-s2,((e2-s2)-(e1-s1)));
65 }
66 }
67
diff --git a/src/lib/libcrypto/bf/bfspeed.c b/src/lib/libcrypto/bf/bfspeed.c
new file mode 100644
index 0000000000..f346af64f3
--- /dev/null
+++ b/src/lib/libcrypto/bf/bfspeed.c
@@ -0,0 +1,274 @@
1/* crypto/bf/bfspeed.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/* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */
60/* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */
61
62#if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX)
63#define TIMES
64#endif
65
66#include <stdio.h>
67
68#include <openssl/e_os2.h>
69#include OPENSSL_UNISTD_IO
70OPENSSL_DECLARE_EXIT
71
72#include <signal.h>
73#ifndef _IRIX
74#include <time.h>
75#endif
76#ifdef TIMES
77#include <sys/types.h>
78#include <sys/times.h>
79#endif
80
81/* Depending on the VMS version, the tms structure is perhaps defined.
82 The __TMS macro will show if it was. If it wasn't defined, we should
83 undefine TIMES, since that tells the rest of the program how things
84 should be handled. -- Richard Levitte */
85#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
86#undef TIMES
87#endif
88
89#ifndef TIMES
90#include <sys/timeb.h>
91#endif
92
93#if defined(sun) || defined(__ultrix)
94#define _POSIX_SOURCE
95#include <limits.h>
96#include <sys/param.h>
97#endif
98
99#include <openssl/blowfish.h>
100
101/* The following if from times(3) man page. It may need to be changed */
102#ifndef HZ
103#ifndef CLK_TCK
104#define HZ 100.0
105#else /* CLK_TCK */
106#define HZ ((double)CLK_TCK)
107#endif
108#endif
109
110#define BUFSIZE ((long)1024)
111long run=0;
112
113double Time_F(int s);
114#ifdef SIGALRM
115#if defined(__STDC__) || defined(sgi) || defined(_AIX)
116#define SIGRETTYPE void
117#else
118#define SIGRETTYPE int
119#endif
120
121SIGRETTYPE sig_done(int sig);
122SIGRETTYPE sig_done(int sig)
123 {
124 signal(SIGALRM,sig_done);
125 run=0;
126#ifdef LINT
127 sig=sig;
128#endif
129 }
130#endif
131
132#define START 0
133#define STOP 1
134
135double Time_F(int s)
136 {
137 double ret;
138#ifdef TIMES
139 static struct tms tstart,tend;
140
141 if (s == START)
142 {
143 times(&tstart);
144 return(0);
145 }
146 else
147 {
148 times(&tend);
149 ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
150 return((ret == 0.0)?1e-6:ret);
151 }
152#else /* !times() */
153 static struct timeb tstart,tend;
154 long i;
155
156 if (s == START)
157 {
158 ftime(&tstart);
159 return(0);
160 }
161 else
162 {
163 ftime(&tend);
164 i=(long)tend.millitm-(long)tstart.millitm;
165 ret=((double)(tend.time-tstart.time))+((double)i)/1e3;
166 return((ret == 0.0)?1e-6:ret);
167 }
168#endif
169 }
170
171int main(int argc, char **argv)
172 {
173 long count;
174 static unsigned char buf[BUFSIZE];
175 static unsigned char key[] ={
176 0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
177 0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10,
178 };
179 BF_KEY sch;
180 double a,b,c,d;
181#ifndef SIGALRM
182 long ca,cb,cc;
183#endif
184
185#ifndef TIMES
186 printf("To get the most accurate results, try to run this\n");
187 printf("program when this computer is idle.\n");
188#endif
189
190#ifndef SIGALRM
191 printf("First we calculate the approximate speed ...\n");
192 BF_set_key(&sch,16,key);
193 count=10;
194 do {
195 long i;
196 BF_LONG data[2];
197
198 count*=2;
199 Time_F(START);
200 for (i=count; i; i--)
201 BF_encrypt(data,&sch);
202 d=Time_F(STOP);
203 } while (d < 3.0);
204 ca=count/512;
205 cb=count;
206 cc=count*8/BUFSIZE+1;
207 printf("Doing BF_set_key %ld times\n",ca);
208#define COND(d) (count != (d))
209#define COUNT(d) (d)
210#else
211#define COND(c) (run)
212#define COUNT(d) (count)
213 signal(SIGALRM,sig_done);
214 printf("Doing BF_set_key for 10 seconds\n");
215 alarm(10);
216#endif
217
218 Time_F(START);
219 for (count=0,run=1; COND(ca); count+=4)
220 {
221 BF_set_key(&sch,16,key);
222 BF_set_key(&sch,16,key);
223 BF_set_key(&sch,16,key);
224 BF_set_key(&sch,16,key);
225 }
226 d=Time_F(STOP);
227 printf("%ld BF_set_key's in %.2f seconds\n",count,d);
228 a=((double)COUNT(ca))/d;
229
230#ifdef SIGALRM
231 printf("Doing BF_encrypt's for 10 seconds\n");
232 alarm(10);
233#else
234 printf("Doing BF_encrypt %ld times\n",cb);
235#endif
236 Time_F(START);
237 for (count=0,run=1; COND(cb); count+=4)
238 {
239 BF_LONG data[2];
240
241 BF_encrypt(data,&sch);
242 BF_encrypt(data,&sch);
243 BF_encrypt(data,&sch);
244 BF_encrypt(data,&sch);
245 }
246 d=Time_F(STOP);
247 printf("%ld BF_encrypt's in %.2f second\n",count,d);
248 b=((double)COUNT(cb)*8)/d;
249
250#ifdef SIGALRM
251 printf("Doing BF_cbc_encrypt on %ld byte blocks for 10 seconds\n",
252 BUFSIZE);
253 alarm(10);
254#else
255 printf("Doing BF_cbc_encrypt %ld times on %ld byte blocks\n",cc,
256 BUFSIZE);
257#endif
258 Time_F(START);
259 for (count=0,run=1; COND(cc); count++)
260 BF_cbc_encrypt(buf,buf,BUFSIZE,&sch,
261 &(key[0]),BF_ENCRYPT);
262 d=Time_F(STOP);
263 printf("%ld BF_cbc_encrypt's of %ld byte blocks in %.2f second\n",
264 count,BUFSIZE,d);
265 c=((double)COUNT(cc)*BUFSIZE)/d;
266
267 printf("Blowfish set_key per sec = %12.3f (%9.3fuS)\n",a,1.0e6/a);
268 printf("Blowfish raw ecb bytes per sec = %12.3f (%9.3fuS)\n",b,8.0e6/b);
269 printf("Blowfish cbc bytes per sec = %12.3f (%9.3fuS)\n",c,8.0e6/c);
270 exit(0);
271#if defined(LINT) || defined(OPENSSL_SYS_MSDOS)
272 return(0);
273#endif
274 }
diff --git a/src/lib/libcrypto/bf/bftest.c b/src/lib/libcrypto/bf/bftest.c
new file mode 100644
index 0000000000..09895f2542
--- /dev/null
+++ b/src/lib/libcrypto/bf/bftest.c
@@ -0,0 +1,534 @@
1/* crypto/bf/bftest.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/* This has been a quickly hacked 'ideatest.c'. When I add tests for other
60 * RC2 modes, more of the code will be uncommented. */
61
62#include <stdio.h>
63#include <string.h>
64#include <stdlib.h>
65
66#ifdef OPENSSL_NO_BF
67int main(int argc, char *argv[])
68{
69 printf("No BF support\n");
70 return(0);
71}
72#else
73#include <openssl/blowfish.h>
74
75#ifdef CHARSET_EBCDIC
76#include <openssl/ebcdic.h>
77#endif
78
79static char *bf_key[2]={
80 "abcdefghijklmnopqrstuvwxyz",
81 "Who is John Galt?"
82 };
83
84/* big endian */
85static BF_LONG bf_plain[2][2]={
86 {0x424c4f57L,0x46495348L},
87 {0xfedcba98L,0x76543210L}
88 };
89
90static BF_LONG bf_cipher[2][2]={
91 {0x324ed0feL,0xf413a203L},
92 {0xcc91732bL,0x8022f684L}
93 };
94/************/
95
96/* Lets use the DES test vectors :-) */
97#define NUM_TESTS 34
98static unsigned char ecb_data[NUM_TESTS][8]={
99 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
100 {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},
101 {0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
102 {0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11},
103 {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF},
104 {0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11},
105 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
106 {0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10},
107 {0x7C,0xA1,0x10,0x45,0x4A,0x1A,0x6E,0x57},
108 {0x01,0x31,0xD9,0x61,0x9D,0xC1,0x37,0x6E},
109 {0x07,0xA1,0x13,0x3E,0x4A,0x0B,0x26,0x86},
110 {0x38,0x49,0x67,0x4C,0x26,0x02,0x31,0x9E},
111 {0x04,0xB9,0x15,0xBA,0x43,0xFE,0xB5,0xB6},
112 {0x01,0x13,0xB9,0x70,0xFD,0x34,0xF2,0xCE},
113 {0x01,0x70,0xF1,0x75,0x46,0x8F,0xB5,0xE6},
114 {0x43,0x29,0x7F,0xAD,0x38,0xE3,0x73,0xFE},
115 {0x07,0xA7,0x13,0x70,0x45,0xDA,0x2A,0x16},
116 {0x04,0x68,0x91,0x04,0xC2,0xFD,0x3B,0x2F},
117 {0x37,0xD0,0x6B,0xB5,0x16,0xCB,0x75,0x46},
118 {0x1F,0x08,0x26,0x0D,0x1A,0xC2,0x46,0x5E},
119 {0x58,0x40,0x23,0x64,0x1A,0xBA,0x61,0x76},
120 {0x02,0x58,0x16,0x16,0x46,0x29,0xB0,0x07},
121 {0x49,0x79,0x3E,0xBC,0x79,0xB3,0x25,0x8F},
122 {0x4F,0xB0,0x5E,0x15,0x15,0xAB,0x73,0xA7},
123 {0x49,0xE9,0x5D,0x6D,0x4C,0xA2,0x29,0xBF},
124 {0x01,0x83,0x10,0xDC,0x40,0x9B,0x26,0xD6},
125 {0x1C,0x58,0x7F,0x1C,0x13,0x92,0x4F,0xEF},
126 {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01},
127 {0x1F,0x1F,0x1F,0x1F,0x0E,0x0E,0x0E,0x0E},
128 {0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1,0xFE},
129 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
130 {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},
131 {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF},
132 {0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10}};
133
134static unsigned char plain_data[NUM_TESTS][8]={
135 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
136 {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},
137 {0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x01},
138 {0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11},
139 {0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11},
140 {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF},
141 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
142 {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF},
143 {0x01,0xA1,0xD6,0xD0,0x39,0x77,0x67,0x42},
144 {0x5C,0xD5,0x4C,0xA8,0x3D,0xEF,0x57,0xDA},
145 {0x02,0x48,0xD4,0x38,0x06,0xF6,0x71,0x72},
146 {0x51,0x45,0x4B,0x58,0x2D,0xDF,0x44,0x0A},
147 {0x42,0xFD,0x44,0x30,0x59,0x57,0x7F,0xA2},
148 {0x05,0x9B,0x5E,0x08,0x51,0xCF,0x14,0x3A},
149 {0x07,0x56,0xD8,0xE0,0x77,0x47,0x61,0xD2},
150 {0x76,0x25,0x14,0xB8,0x29,0xBF,0x48,0x6A},
151 {0x3B,0xDD,0x11,0x90,0x49,0x37,0x28,0x02},
152 {0x26,0x95,0x5F,0x68,0x35,0xAF,0x60,0x9A},
153 {0x16,0x4D,0x5E,0x40,0x4F,0x27,0x52,0x32},
154 {0x6B,0x05,0x6E,0x18,0x75,0x9F,0x5C,0xCA},
155 {0x00,0x4B,0xD6,0xEF,0x09,0x17,0x60,0x62},
156 {0x48,0x0D,0x39,0x00,0x6E,0xE7,0x62,0xF2},
157 {0x43,0x75,0x40,0xC8,0x69,0x8F,0x3C,0xFA},
158 {0x07,0x2D,0x43,0xA0,0x77,0x07,0x52,0x92},
159 {0x02,0xFE,0x55,0x77,0x81,0x17,0xF1,0x2A},
160 {0x1D,0x9D,0x5C,0x50,0x18,0xF7,0x28,0xC2},
161 {0x30,0x55,0x32,0x28,0x6D,0x6F,0x29,0x5A},
162 {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF},
163 {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF},
164 {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF},
165 {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},
166 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
167 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
168 {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}};
169
170static unsigned char cipher_data[NUM_TESTS][8]={
171 {0x4E,0xF9,0x97,0x45,0x61,0x98,0xDD,0x78},
172 {0x51,0x86,0x6F,0xD5,0xB8,0x5E,0xCB,0x8A},
173 {0x7D,0x85,0x6F,0x9A,0x61,0x30,0x63,0xF2},
174 {0x24,0x66,0xDD,0x87,0x8B,0x96,0x3C,0x9D},
175 {0x61,0xF9,0xC3,0x80,0x22,0x81,0xB0,0x96},
176 {0x7D,0x0C,0xC6,0x30,0xAF,0xDA,0x1E,0xC7},
177 {0x4E,0xF9,0x97,0x45,0x61,0x98,0xDD,0x78},
178 {0x0A,0xCE,0xAB,0x0F,0xC6,0xA0,0xA2,0x8D},
179 {0x59,0xC6,0x82,0x45,0xEB,0x05,0x28,0x2B},
180 {0xB1,0xB8,0xCC,0x0B,0x25,0x0F,0x09,0xA0},
181 {0x17,0x30,0xE5,0x77,0x8B,0xEA,0x1D,0xA4},
182 {0xA2,0x5E,0x78,0x56,0xCF,0x26,0x51,0xEB},
183 {0x35,0x38,0x82,0xB1,0x09,0xCE,0x8F,0x1A},
184 {0x48,0xF4,0xD0,0x88,0x4C,0x37,0x99,0x18},
185 {0x43,0x21,0x93,0xB7,0x89,0x51,0xFC,0x98},
186 {0x13,0xF0,0x41,0x54,0xD6,0x9D,0x1A,0xE5},
187 {0x2E,0xED,0xDA,0x93,0xFF,0xD3,0x9C,0x79},
188 {0xD8,0x87,0xE0,0x39,0x3C,0x2D,0xA6,0xE3},
189 {0x5F,0x99,0xD0,0x4F,0x5B,0x16,0x39,0x69},
190 {0x4A,0x05,0x7A,0x3B,0x24,0xD3,0x97,0x7B},
191 {0x45,0x20,0x31,0xC1,0xE4,0xFA,0xDA,0x8E},
192 {0x75,0x55,0xAE,0x39,0xF5,0x9B,0x87,0xBD},
193 {0x53,0xC5,0x5F,0x9C,0xB4,0x9F,0xC0,0x19},
194 {0x7A,0x8E,0x7B,0xFA,0x93,0x7E,0x89,0xA3},
195 {0xCF,0x9C,0x5D,0x7A,0x49,0x86,0xAD,0xB5},
196 {0xD1,0xAB,0xB2,0x90,0x65,0x8B,0xC7,0x78},
197 {0x55,0xCB,0x37,0x74,0xD1,0x3E,0xF2,0x01},
198 {0xFA,0x34,0xEC,0x48,0x47,0xB2,0x68,0xB2},
199 {0xA7,0x90,0x79,0x51,0x08,0xEA,0x3C,0xAE},
200 {0xC3,0x9E,0x07,0x2D,0x9F,0xAC,0x63,0x1D},
201 {0x01,0x49,0x33,0xE0,0xCD,0xAF,0xF6,0xE4},
202 {0xF2,0x1E,0x9A,0x77,0xB7,0x1C,0x49,0xBC},
203 {0x24,0x59,0x46,0x88,0x57,0x54,0x36,0x9A},
204 {0x6B,0x5C,0x5A,0x9C,0x5D,0x9E,0x0A,0x5A},
205 };
206
207static unsigned char cbc_key [16]={
208 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,
209 0xf0,0xe1,0xd2,0xc3,0xb4,0xa5,0x96,0x87};
210static unsigned char cbc_iv [8]={0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10};
211static char cbc_data[40]="7654321 Now is the time for ";
212static unsigned char cbc_ok[32]={
213 0x6B,0x77,0xB4,0xD6,0x30,0x06,0xDE,0xE6,
214 0x05,0xB1,0x56,0xE2,0x74,0x03,0x97,0x93,
215 0x58,0xDE,0xB9,0xE7,0x15,0x46,0x16,0xD9,
216 0x59,0xF1,0x65,0x2B,0xD5,0xFF,0x92,0xCC};
217
218static unsigned char cfb64_ok[]={
219 0xE7,0x32,0x14,0xA2,0x82,0x21,0x39,0xCA,
220 0xF2,0x6E,0xCF,0x6D,0x2E,0xB9,0xE7,0x6E,
221 0x3D,0xA3,0xDE,0x04,0xD1,0x51,0x72,0x00,
222 0x51,0x9D,0x57,0xA6,0xC3};
223
224static unsigned char ofb64_ok[]={
225 0xE7,0x32,0x14,0xA2,0x82,0x21,0x39,0xCA,
226 0x62,0xB3,0x43,0xCC,0x5B,0x65,0x58,0x73,
227 0x10,0xDD,0x90,0x8D,0x0C,0x24,0x1B,0x22,
228 0x63,0xC2,0xCF,0x80,0xDA};
229
230#define KEY_TEST_NUM 25
231static unsigned char key_test[KEY_TEST_NUM]={
232 0xf0,0xe1,0xd2,0xc3,0xb4,0xa5,0x96,0x87,
233 0x78,0x69,0x5a,0x4b,0x3c,0x2d,0x1e,0x0f,
234 0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,
235 0x88};
236
237static unsigned char key_data[8]=
238 {0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10};
239
240static unsigned char key_out[KEY_TEST_NUM][8]={
241 {0xF9,0xAD,0x59,0x7C,0x49,0xDB,0x00,0x5E},
242 {0xE9,0x1D,0x21,0xC1,0xD9,0x61,0xA6,0xD6},
243 {0xE9,0xC2,0xB7,0x0A,0x1B,0xC6,0x5C,0xF3},
244 {0xBE,0x1E,0x63,0x94,0x08,0x64,0x0F,0x05},
245 {0xB3,0x9E,0x44,0x48,0x1B,0xDB,0x1E,0x6E},
246 {0x94,0x57,0xAA,0x83,0xB1,0x92,0x8C,0x0D},
247 {0x8B,0xB7,0x70,0x32,0xF9,0x60,0x62,0x9D},
248 {0xE8,0x7A,0x24,0x4E,0x2C,0xC8,0x5E,0x82},
249 {0x15,0x75,0x0E,0x7A,0x4F,0x4E,0xC5,0x77},
250 {0x12,0x2B,0xA7,0x0B,0x3A,0xB6,0x4A,0xE0},
251 {0x3A,0x83,0x3C,0x9A,0xFF,0xC5,0x37,0xF6},
252 {0x94,0x09,0xDA,0x87,0xA9,0x0F,0x6B,0xF2},
253 {0x88,0x4F,0x80,0x62,0x50,0x60,0xB8,0xB4},
254 {0x1F,0x85,0x03,0x1C,0x19,0xE1,0x19,0x68},
255 {0x79,0xD9,0x37,0x3A,0x71,0x4C,0xA3,0x4F},
256 {0x93,0x14,0x28,0x87,0xEE,0x3B,0xE1,0x5C},
257 {0x03,0x42,0x9E,0x83,0x8C,0xE2,0xD1,0x4B},
258 {0xA4,0x29,0x9E,0x27,0x46,0x9F,0xF6,0x7B},
259 {0xAF,0xD5,0xAE,0xD1,0xC1,0xBC,0x96,0xA8},
260 {0x10,0x85,0x1C,0x0E,0x38,0x58,0xDA,0x9F},
261 {0xE6,0xF5,0x1E,0xD7,0x9B,0x9D,0xB2,0x1F},
262 {0x64,0xA6,0xE1,0x4A,0xFD,0x36,0xB4,0x6F},
263 {0x80,0xC7,0xD7,0xD4,0x5A,0x54,0x79,0xAD},
264 {0x05,0x04,0x4B,0x62,0xFA,0x52,0xD0,0x80},
265 };
266
267static int test(void );
268static int print_test_data(void );
269int main(int argc, char *argv[])
270 {
271 int ret;
272
273 if (argc > 1)
274 ret=print_test_data();
275 else
276 ret=test();
277
278 exit(ret);
279 return(0);
280 }
281
282static int print_test_data(void)
283 {
284 unsigned int i,j;
285
286 printf("ecb test data\n");
287 printf("key bytes\t\tclear bytes\t\tcipher bytes\n");
288 for (i=0; i<NUM_TESTS; i++)
289 {
290 for (j=0; j<8; j++)
291 printf("%02X",ecb_data[i][j]);
292 printf("\t");
293 for (j=0; j<8; j++)
294 printf("%02X",plain_data[i][j]);
295 printf("\t");
296 for (j=0; j<8; j++)
297 printf("%02X",cipher_data[i][j]);
298 printf("\n");
299 }
300
301 printf("set_key test data\n");
302 printf("data[8]= ");
303 for (j=0; j<8; j++)
304 printf("%02X",key_data[j]);
305 printf("\n");
306 for (i=0; i<KEY_TEST_NUM-1; i++)
307 {
308 printf("c=");
309 for (j=0; j<8; j++)
310 printf("%02X",key_out[i][j]);
311 printf(" k[%2u]=",i+1);
312 for (j=0; j<i+1; j++)
313 printf("%02X",key_test[j]);
314 printf("\n");
315 }
316
317 printf("\nchaining mode test data\n");
318 printf("key[16] = ");
319 for (j=0; j<16; j++)
320 printf("%02X",cbc_key[j]);
321 printf("\niv[8] = ");
322 for (j=0; j<8; j++)
323 printf("%02X",cbc_iv[j]);
324 printf("\ndata[%d] = '%s'",(int)strlen(cbc_data)+1,cbc_data);
325 printf("\ndata[%d] = ",(int)strlen(cbc_data)+1);
326 for (j=0; j<strlen(cbc_data)+1; j++)
327 printf("%02X",cbc_data[j]);
328 printf("\n");
329 printf("cbc cipher text\n");
330 printf("cipher[%d]= ",32);
331 for (j=0; j<32; j++)
332 printf("%02X",cbc_ok[j]);
333 printf("\n");
334
335 printf("cfb64 cipher text\n");
336 printf("cipher[%d]= ",(int)strlen(cbc_data)+1);
337 for (j=0; j<strlen(cbc_data)+1; j++)
338 printf("%02X",cfb64_ok[j]);
339 printf("\n");
340
341 printf("ofb64 cipher text\n");
342 printf("cipher[%d]= ",(int)strlen(cbc_data)+1);
343 for (j=0; j<strlen(cbc_data)+1; j++)
344 printf("%02X",ofb64_ok[j]);
345 printf("\n");
346 return(0);
347 }
348
349static int test(void)
350 {
351 unsigned char cbc_in[40],cbc_out[40],iv[8];
352 int i,n,err=0;
353 BF_KEY key;
354 BF_LONG data[2];
355 unsigned char out[8];
356 BF_LONG len;
357
358#ifdef CHARSET_EBCDIC
359 ebcdic2ascii(cbc_data, cbc_data, strlen(cbc_data));
360#endif
361
362 printf("testing blowfish in raw ecb mode\n");
363 for (n=0; n<2; n++)
364 {
365#ifdef CHARSET_EBCDIC
366 ebcdic2ascii(bf_key[n], bf_key[n], strlen(bf_key[n]));
367#endif
368 BF_set_key(&key,strlen(bf_key[n]),(unsigned char *)bf_key[n]);
369
370 data[0]=bf_plain[n][0];
371 data[1]=bf_plain[n][1];
372 BF_encrypt(data,&key);
373 if (memcmp(&(bf_cipher[n][0]),&(data[0]),8) != 0)
374 {
375 printf("BF_encrypt error encrypting\n");
376 printf("got :");
377 for (i=0; i<2; i++)
378 printf("%08lX ",(unsigned long)data[i]);
379 printf("\n");
380 printf("expected:");
381 for (i=0; i<2; i++)
382 printf("%08lX ",(unsigned long)bf_cipher[n][i]);
383 err=1;
384 printf("\n");
385 }
386
387 BF_decrypt(&(data[0]),&key);
388 if (memcmp(&(bf_plain[n][0]),&(data[0]),8) != 0)
389 {
390 printf("BF_encrypt error decrypting\n");
391 printf("got :");
392 for (i=0; i<2; i++)
393 printf("%08lX ",(unsigned long)data[i]);
394 printf("\n");
395 printf("expected:");
396 for (i=0; i<2; i++)
397 printf("%08lX ",(unsigned long)bf_plain[n][i]);
398 printf("\n");
399 err=1;
400 }
401 }
402
403 printf("testing blowfish in ecb mode\n");
404
405 for (n=0; n<NUM_TESTS; n++)
406 {
407 BF_set_key(&key,8,ecb_data[n]);
408
409 BF_ecb_encrypt(&(plain_data[n][0]),out,&key,BF_ENCRYPT);
410 if (memcmp(&(cipher_data[n][0]),out,8) != 0)
411 {
412 printf("BF_ecb_encrypt blowfish error encrypting\n");
413 printf("got :");
414 for (i=0; i<8; i++)
415 printf("%02X ",out[i]);
416 printf("\n");
417 printf("expected:");
418 for (i=0; i<8; i++)
419 printf("%02X ",cipher_data[n][i]);
420 err=1;
421 printf("\n");
422 }
423
424 BF_ecb_encrypt(out,out,&key,BF_DECRYPT);
425 if (memcmp(&(plain_data[n][0]),out,8) != 0)
426 {
427 printf("BF_ecb_encrypt error decrypting\n");
428 printf("got :");
429 for (i=0; i<8; i++)
430 printf("%02X ",out[i]);
431 printf("\n");
432 printf("expected:");
433 for (i=0; i<8; i++)
434 printf("%02X ",plain_data[n][i]);
435 printf("\n");
436 err=1;
437 }
438 }
439
440 printf("testing blowfish set_key\n");
441 for (n=1; n<KEY_TEST_NUM; n++)
442 {
443 BF_set_key(&key,n,key_test);
444 BF_ecb_encrypt(key_data,out,&key,BF_ENCRYPT);
445 /* mips-sgi-irix6.5-gcc vv -mabi=64 bug workaround */
446 if (memcmp(out,&(key_out[i=n-1][0]),8) != 0)
447 {
448 printf("blowfish setkey error\n");
449 err=1;
450 }
451 }
452
453 printf("testing blowfish in cbc mode\n");
454 len=strlen(cbc_data)+1;
455
456 BF_set_key(&key,16,cbc_key);
457 memset(cbc_in,0,40);
458 memset(cbc_out,0,40);
459 memcpy(iv,cbc_iv,8);
460 BF_cbc_encrypt((unsigned char *)cbc_data,cbc_out,len,
461 &key,iv,BF_ENCRYPT);
462 if (memcmp(cbc_out,cbc_ok,32) != 0)
463 {
464 err=1;
465 printf("BF_cbc_encrypt encrypt error\n");
466 for (i=0; i<32; i++) printf("0x%02X,",cbc_out[i]);
467 }
468 memcpy(iv,cbc_iv,8);
469 BF_cbc_encrypt(cbc_out,cbc_in,len,
470 &key,iv,BF_DECRYPT);
471 if (memcmp(cbc_in,cbc_data,strlen(cbc_data)+1) != 0)
472 {
473 printf("BF_cbc_encrypt decrypt error\n");
474 err=1;
475 }
476
477 printf("testing blowfish in cfb64 mode\n");
478
479 BF_set_key(&key,16,cbc_key);
480 memset(cbc_in,0,40);
481 memset(cbc_out,0,40);
482 memcpy(iv,cbc_iv,8);
483 n=0;
484 BF_cfb64_encrypt((unsigned char *)cbc_data,cbc_out,(long)13,
485 &key,iv,&n,BF_ENCRYPT);
486 BF_cfb64_encrypt((unsigned char *)&(cbc_data[13]),&(cbc_out[13]),len-13,
487 &key,iv,&n,BF_ENCRYPT);
488 if (memcmp(cbc_out,cfb64_ok,(int)len) != 0)
489 {
490 err=1;
491 printf("BF_cfb64_encrypt encrypt error\n");
492 for (i=0; i<(int)len; i++) printf("0x%02X,",cbc_out[i]);
493 }
494 n=0;
495 memcpy(iv,cbc_iv,8);
496 BF_cfb64_encrypt(cbc_out,cbc_in,17,
497 &key,iv,&n,BF_DECRYPT);
498 BF_cfb64_encrypt(&(cbc_out[17]),&(cbc_in[17]),len-17,
499 &key,iv,&n,BF_DECRYPT);
500 if (memcmp(cbc_in,cbc_data,(int)len) != 0)
501 {
502 printf("BF_cfb64_encrypt decrypt error\n");
503 err=1;
504 }
505
506 printf("testing blowfish in ofb64\n");
507
508 BF_set_key(&key,16,cbc_key);
509 memset(cbc_in,0,40);
510 memset(cbc_out,0,40);
511 memcpy(iv,cbc_iv,8);
512 n=0;
513 BF_ofb64_encrypt((unsigned char *)cbc_data,cbc_out,(long)13,&key,iv,&n);
514 BF_ofb64_encrypt((unsigned char *)&(cbc_data[13]),
515 &(cbc_out[13]),len-13,&key,iv,&n);
516 if (memcmp(cbc_out,ofb64_ok,(int)len) != 0)
517 {
518 err=1;
519 printf("BF_ofb64_encrypt encrypt error\n");
520 for (i=0; i<(int)len; i++) printf("0x%02X,",cbc_out[i]);
521 }
522 n=0;
523 memcpy(iv,cbc_iv,8);
524 BF_ofb64_encrypt(cbc_out,cbc_in,17,&key,iv,&n);
525 BF_ofb64_encrypt(&(cbc_out[17]),&(cbc_in[17]),len-17,&key,iv,&n);
526 if (memcmp(cbc_in,cbc_data,(int)len) != 0)
527 {
528 printf("BF_ofb64_encrypt decrypt error\n");
529 err=1;
530 }
531
532 return(err);
533 }
534#endif
diff --git a/src/lib/libcrypto/bio/Makefile.ssl b/src/lib/libcrypto/bio/Makefile.ssl
new file mode 100644
index 0000000000..dfcee03448
--- /dev/null
+++ b/src/lib/libcrypto/bio/Makefile.ssl
@@ -0,0 +1,216 @@
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_dump.c b/src/lib/libcrypto/bio/b_dump.c
index 8397cfab6a..983604fb49 100644
--- a/src/lib/libcrypto/bio/b_dump.c
+++ b/src/lib/libcrypto/bio/b_dump.c
@@ -104,38 +104,41 @@ int BIO_dump_indent(BIO *bio, const char *s, int len, int indent)
104 for(i=0;i<rows;i++) 104 for(i=0;i<rows;i++)
105 { 105 {
106 buf[0]='\0'; /* start with empty string */ 106 buf[0]='\0'; /* start with empty string */
107 strcpy(buf,str); 107 strlcpy(buf,str,sizeof buf);
108 sprintf(tmp,"%04x - ",i*dump_width); 108 snprintf(tmp,sizeof tmp,"%04x - ",i*dump_width);
109 strcat(buf,tmp); 109 strlcat(buf,tmp,sizeof buf);
110 for(j=0;j<dump_width;j++) 110 for(j=0;j<dump_width;j++)
111 { 111 {
112 if (((i*dump_width)+j)>=len) 112 if (((i*dump_width)+j)>=len)
113 { 113 {
114 strcat(buf," "); 114 strlcat(buf," ",sizeof buf);
115 } 115 }
116 else 116 else
117 { 117 {
118 ch=((unsigned char)*(s+i*dump_width+j)) & 0xff; 118 ch=((unsigned char)*(s+i*dump_width+j)) & 0xff;
119 sprintf(tmp,"%02x%c",ch,j==7?'-':' '); 119 snprintf(tmp,sizeof tmp,"%02x%c",ch,
120 strcat(buf,tmp); 120 j==7?'-':' ');
121 strlcat(buf,tmp,sizeof buf);
121 } 122 }
122 } 123 }
123 strcat(buf," "); 124 strlcat(buf," ",sizeof buf);
124 for(j=0;j<dump_width;j++) 125 for(j=0;j<dump_width;j++)
125 { 126 {
126 if (((i*dump_width)+j)>=len) 127 if (((i*dump_width)+j)>=len)
127 break; 128 break;
128 ch=((unsigned char)*(s+i*dump_width+j)) & 0xff; 129 ch=((unsigned char)*(s+i*dump_width+j)) & 0xff;
129#ifndef CHARSET_EBCDIC 130#ifndef CHARSET_EBCDIC
130 sprintf(tmp,"%c",((ch>=' ')&&(ch<='~'))?ch:'.'); 131 snprintf(tmp,sizeof tmp,"%c",
132 ((ch>=' ')&&(ch<='~'))?ch:'.');
131#else 133#else
132 sprintf(tmp,"%c",((ch>=os_toascii[' '])&&(ch<=os_toascii['~'])) 134 snprintf(tmp,sizeof tmp,"%c",
133 ? os_toebcdic[ch] 135 ((ch>=os_toascii[' '])&&(ch<=os_toascii['~']))
134 : '.'); 136 ? os_toebcdic[ch]
137 : '.');
135#endif 138#endif
136 strcat(buf,tmp); 139 strlcat(buf,tmp,sizeof buf);
137 } 140 }
138 strcat(buf,"\n"); 141 strlcat(buf,"\n",sizeof buf);
139 /* if this is the last call then update the ddt_dump thing so that 142 /* if this is the last call then update the ddt_dump thing so that
140 * we will move the selection point in the debug window 143 * we will move the selection point in the debug window
141 */ 144 */
@@ -144,7 +147,8 @@ int BIO_dump_indent(BIO *bio, const char *s, int len, int indent)
144#ifdef TRUNCATE 147#ifdef TRUNCATE
145 if (trunc > 0) 148 if (trunc > 0)
146 { 149 {
147 sprintf(buf,"%s%04x - <SPACES/NULS>\n",str,len+trunc); 150 snprintf(buf,sizeof buf,"%s%04x - <SPACES/NULS>\n",str,
151 len+trunc);
148 ret+=BIO_write(bio,(char *)buf,strlen(buf)); 152 ret+=BIO_write(bio,(char *)buf,strlen(buf));
149 } 153 }
150#endif 154#endif
diff --git a/src/lib/libcrypto/bio/b_print.c b/src/lib/libcrypto/bio/b_print.c
index a9e552f245..80c9cb69db 100644
--- a/src/lib/libcrypto/bio/b_print.c
+++ b/src/lib/libcrypto/bio/b_print.c
@@ -378,7 +378,7 @@ _dopr(
378 case 'p': 378 case 'p':
379 value = (long)va_arg(args, void *); 379 value = (long)va_arg(args, void *);
380 fmtint(sbuffer, buffer, &currlen, maxlen, 380 fmtint(sbuffer, buffer, &currlen, maxlen,
381 value, 16, min, max, flags|DP_F_NUM); 381 value, 16, min, max, flags);
382 break; 382 break;
383 case 'n': /* XXX */ 383 case 'n': /* XXX */
384 if (cflags == DP_C_SHORT) { 384 if (cflags == DP_C_SHORT) {
@@ -482,9 +482,8 @@ fmtint(
482 int flags) 482 int flags)
483{ 483{
484 int signvalue = 0; 484 int signvalue = 0;
485 char *prefix = "";
486 unsigned LLONG uvalue; 485 unsigned LLONG uvalue;
487 char convert[DECIMAL_SIZE(value)+3]; 486 char convert[20];
488 int place = 0; 487 int place = 0;
489 int spadlen = 0; 488 int spadlen = 0;
490 int zpadlen = 0; 489 int zpadlen = 0;
@@ -502,10 +501,6 @@ fmtint(
502 else if (flags & DP_F_SPACE) 501 else if (flags & DP_F_SPACE)
503 signvalue = ' '; 502 signvalue = ' ';
504 } 503 }
505 if (flags & DP_F_NUM) {
506 if (base == 8) prefix = "0";
507 if (base == 16) prefix = "0x";
508 }
509 if (flags & DP_F_UP) 504 if (flags & DP_F_UP)
510 caps = 1; 505 caps = 1;
511 do { 506 do {
@@ -513,13 +508,13 @@ fmtint(
513 (caps ? "0123456789ABCDEF" : "0123456789abcdef") 508 (caps ? "0123456789ABCDEF" : "0123456789abcdef")
514 [uvalue % (unsigned) base]; 509 [uvalue % (unsigned) base];
515 uvalue = (uvalue / (unsigned) base); 510 uvalue = (uvalue / (unsigned) base);
516 } while (uvalue && (place < sizeof convert)); 511 } while (uvalue && (place < 20));
517 if (place == sizeof convert) 512 if (place == 20)
518 place--; 513 place--;
519 convert[place] = 0; 514 convert[place] = 0;
520 515
521 zpadlen = max - place; 516 zpadlen = max - place;
522 spadlen = min - OSSL_MAX(max, place) - (signvalue ? 1 : 0) - strlen(prefix); 517 spadlen = min - OSSL_MAX(max, place) - (signvalue ? 1 : 0);
523 if (zpadlen < 0) 518 if (zpadlen < 0)
524 zpadlen = 0; 519 zpadlen = 0;
525 if (spadlen < 0) 520 if (spadlen < 0)
@@ -541,12 +536,6 @@ fmtint(
541 if (signvalue) 536 if (signvalue)
542 doapr_outch(sbuffer, buffer, currlen, maxlen, signvalue); 537 doapr_outch(sbuffer, buffer, currlen, maxlen, signvalue);
543 538
544 /* prefix */
545 while (*prefix) {
546 doapr_outch(sbuffer, buffer, currlen, maxlen, *prefix);
547 prefix++;
548 }
549
550 /* zeros */ 539 /* zeros */
551 if (zpadlen > 0) { 540 if (zpadlen > 0) {
552 while (zpadlen > 0) { 541 while (zpadlen > 0) {
@@ -652,8 +641,8 @@ fmtfp(
652 (caps ? "0123456789ABCDEF" 641 (caps ? "0123456789ABCDEF"
653 : "0123456789abcdef")[intpart % 10]; 642 : "0123456789abcdef")[intpart % 10];
654 intpart = (intpart / 10); 643 intpart = (intpart / 10);
655 } while (intpart && (iplace < sizeof iplace)); 644 } while (intpart && (iplace < 20));
656 if (iplace == sizeof iplace) 645 if (iplace == 20)
657 iplace--; 646 iplace--;
658 iconvert[iplace] = 0; 647 iconvert[iplace] = 0;
659 648
@@ -664,7 +653,7 @@ fmtfp(
664 : "0123456789abcdef")[fracpart % 10]; 653 : "0123456789abcdef")[fracpart % 10];
665 fracpart = (fracpart / 10); 654 fracpart = (fracpart / 10);
666 } while (fplace < max); 655 } while (fplace < max);
667 if (fplace == sizeof fplace) 656 if (fplace == 20)
668 fplace--; 657 fplace--;
669 fconvert[fplace] = 0; 658 fconvert[fplace] = 0;
670 659
@@ -703,7 +692,7 @@ fmtfp(
703 * Decimal point. This should probably use locale to find the correct 692 * Decimal point. This should probably use locale to find the correct
704 * char to print out. 693 * char to print out.
705 */ 694 */
706 if (max > 0 || (flags & DP_F_NUM)) { 695 if (max > 0) {
707 doapr_outch(sbuffer, buffer, currlen, maxlen, '.'); 696 doapr_outch(sbuffer, buffer, currlen, maxlen, '.');
708 697
709 while (fplace > 0) 698 while (fplace > 0)
diff --git a/src/lib/libcrypto/bio/b_sock.c b/src/lib/libcrypto/bio/b_sock.c
index 601a14f37c..7632c2d85e 100644
--- a/src/lib/libcrypto/bio/b_sock.c
+++ b/src/lib/libcrypto/bio/b_sock.c
@@ -83,7 +83,6 @@
83static int wsa_init_done=0; 83static int wsa_init_done=0;
84#endif 84#endif
85 85
86#if 0
87static unsigned long BIO_ghbn_hits=0L; 86static unsigned long BIO_ghbn_hits=0L;
88static unsigned long BIO_ghbn_miss=0L; 87static unsigned long BIO_ghbn_miss=0L;
89 88
@@ -94,7 +93,6 @@ static struct ghbn_cache_st
94 struct hostent *ent; 93 struct hostent *ent;
95 unsigned long order; 94 unsigned long order;
96 } ghbn_cache[GHBN_NUM]; 95 } ghbn_cache[GHBN_NUM];
97#endif
98 96
99static int get_ip(const char *str,unsigned char *ip); 97static int get_ip(const char *str,unsigned char *ip);
100#if 0 98#if 0
@@ -232,7 +230,6 @@ int BIO_sock_error(int sock)
232 return(j); 230 return(j);
233 } 231 }
234 232
235#if 0
236long BIO_ghbn_ctrl(int cmd, int iarg, char *parg) 233long BIO_ghbn_ctrl(int cmd, int iarg, char *parg)
237 { 234 {
238 int i; 235 int i;
@@ -270,7 +267,6 @@ long BIO_ghbn_ctrl(int cmd, int iarg, char *parg)
270 } 267 }
271 return(1); 268 return(1);
272 } 269 }
273#endif
274 270
275#if 0 271#if 0
276static struct hostent *ghbn_dup(struct hostent *a) 272static struct hostent *ghbn_dup(struct hostent *a)
@@ -467,12 +463,6 @@ int BIO_sock_init(void)
467 } 463 }
468 } 464 }
469#endif /* OPENSSL_SYS_WINDOWS */ 465#endif /* OPENSSL_SYS_WINDOWS */
470#ifdef WATT32
471 extern int _watt_do_exit;
472 _watt_do_exit = 0; /* don't make sock_init() call exit() */
473 if (sock_init())
474 return (-1);
475#endif
476 return(1); 466 return(1);
477 } 467 }
478 468
@@ -482,9 +472,7 @@ void BIO_sock_cleanup(void)
482 if (wsa_init_done) 472 if (wsa_init_done)
483 { 473 {
484 wsa_init_done=0; 474 wsa_init_done=0;
485#ifndef OPENSSL_SYS_WINCE
486 WSACancelBlockingCall(); 475 WSACancelBlockingCall();
487#endif
488 WSACleanup(); 476 WSACleanup();
489 } 477 }
490#endif 478#endif
@@ -492,7 +480,7 @@ void BIO_sock_cleanup(void)
492 480
493#if !defined(OPENSSL_SYS_VMS) || __VMS_VER >= 70000000 481#if !defined(OPENSSL_SYS_VMS) || __VMS_VER >= 70000000
494 482
495int BIO_socket_ioctl(int fd, long type, void *arg) 483int BIO_socket_ioctl(int fd, long type, unsigned long *arg)
496 { 484 {
497 int i; 485 int i;
498 486
@@ -709,12 +697,12 @@ int BIO_accept(int sock, char **addr)
709 } 697 }
710 *addr=p; 698 *addr=p;
711 } 699 }
712 sprintf(*addr,"%d.%d.%d.%d:%d", 700 snprintf(*addr,24,"%d.%d.%d.%d:%d",
713 (unsigned char)(l>>24L)&0xff, 701 (unsigned char)(l>>24L)&0xff,
714 (unsigned char)(l>>16L)&0xff, 702 (unsigned char)(l>>16L)&0xff,
715 (unsigned char)(l>> 8L)&0xff, 703 (unsigned char)(l>> 8L)&0xff,
716 (unsigned char)(l )&0xff, 704 (unsigned char)(l )&0xff,
717 port); 705 port);
718end: 706end:
719 return(ret); 707 return(ret);
720 } 708 }
@@ -742,7 +730,7 @@ int BIO_set_tcp_ndelay(int s, int on)
742int BIO_socket_nbio(int s, int mode) 730int BIO_socket_nbio(int s, int mode)
743 { 731 {
744 int ret= -1; 732 int ret= -1;
745 int l; 733 unsigned long l;
746 734
747 l=mode; 735 l=mode;
748#ifdef FIONBIO 736#ifdef FIONBIO
diff --git a/src/lib/libcrypto/bio/bf_buff.c b/src/lib/libcrypto/bio/bf_buff.c
index 1cecd70579..6ccda06596 100644
--- a/src/lib/libcrypto/bio/bf_buff.c
+++ b/src/lib/libcrypto/bio/bf_buff.c
@@ -482,7 +482,7 @@ static int buffer_gets(BIO *b, char *buf, int size)
482 size-=i; 482 size-=i;
483 ctx->ibuf_len-=i; 483 ctx->ibuf_len-=i;
484 ctx->ibuf_off+=i; 484 ctx->ibuf_off+=i;
485 if (flag || size == 0) 485 if ((flag) || (i == size))
486 { 486 {
487 *buf='\0'; 487 *buf='\0';
488 return(num); 488 return(num);
diff --git a/src/lib/libcrypto/bio/bio.h b/src/lib/libcrypto/bio/bio.h
index fbbc16d00c..c5caf253c9 100644
--- a/src/lib/libcrypto/bio/bio.h
+++ b/src/lib/libcrypto/bio/bio.h
@@ -244,7 +244,7 @@ typedef struct bio_method_st
244 long (_far *ctrl)(); 244 long (_far *ctrl)();
245 int (_far *create)(); 245 int (_far *create)();
246 int (_far *destroy)(); 246 int (_far *destroy)();
247 long (_far *callback_ctrl)(); 247 long (_fat *callback_ctrl)();
248 } BIO_METHOD; 248 } BIO_METHOD;
249#endif 249#endif
250 250
@@ -522,7 +522,6 @@ int BIO_read(BIO *b, void *data, int len);
522int BIO_gets(BIO *bp,char *buf, int size); 522int BIO_gets(BIO *bp,char *buf, int size);
523int BIO_write(BIO *b, const void *data, int len); 523int BIO_write(BIO *b, const void *data, int len);
524int BIO_puts(BIO *bp,const char *buf); 524int BIO_puts(BIO *bp,const char *buf);
525int BIO_indent(BIO *b,int indent,int max);
526long BIO_ctrl(BIO *bp,int cmd,long larg,void *parg); 525long BIO_ctrl(BIO *bp,int cmd,long larg,void *parg);
527long BIO_callback_ctrl(BIO *b, int cmd, void (*fp)(struct bio_st *, int, const char *, int, long, long)); 526long BIO_callback_ctrl(BIO *b, int cmd, void (*fp)(struct bio_st *, int, const char *, int, long, long));
528char * BIO_ptr_ctrl(BIO *bp,int cmd,long larg); 527char * BIO_ptr_ctrl(BIO *bp,int cmd,long larg);
@@ -585,7 +584,7 @@ struct hostent *BIO_gethostbyname(const char *name);
585 * and an appropriate error code is set). 584 * and an appropriate error code is set).
586 */ 585 */
587int BIO_sock_error(int sock); 586int BIO_sock_error(int sock);
588int BIO_socket_ioctl(int fd, long type, void *arg); 587int BIO_socket_ioctl(int fd, long type, unsigned long *arg);
589int BIO_socket_nbio(int fd,int mode); 588int BIO_socket_nbio(int fd,int mode);
590int BIO_get_port(const char *str, unsigned short *port_ptr); 589int BIO_get_port(const char *str, unsigned short *port_ptr);
591int BIO_get_host_ip(const char *str, unsigned char *ip); 590int BIO_get_host_ip(const char *str, unsigned char *ip);
@@ -609,7 +608,7 @@ int BIO_new_bio_pair(BIO **bio1, size_t writebuf1,
609 608
610void BIO_copy_next_retry(BIO *b); 609void BIO_copy_next_retry(BIO *b);
611 610
612/*long BIO_ghbn_ctrl(int cmd,int iarg,char *parg);*/ 611long BIO_ghbn_ctrl(int cmd,int iarg,char *parg);
613 612
614int BIO_printf(BIO *bio, const char *format, ...); 613int BIO_printf(BIO *bio, const char *format, ...);
615int BIO_vprintf(BIO *bio, const char *format, va_list args); 614int BIO_vprintf(BIO *bio, const char *format, va_list args);
diff --git a/src/lib/libcrypto/bio/bio_cb.c b/src/lib/libcrypto/bio/bio_cb.c
index 0ffa4d2136..ee9159ebd8 100644
--- a/src/lib/libcrypto/bio/bio_cb.c
+++ b/src/lib/libcrypto/bio/bio_cb.c
@@ -70,55 +70,61 @@ long MS_CALLBACK BIO_debug_callback(BIO *bio, int cmd, const char *argp,
70 MS_STATIC char buf[256]; 70 MS_STATIC char buf[256];
71 char *p; 71 char *p;
72 long r=1; 72 long r=1;
73 size_t p_maxlen;
73 74
74 if (BIO_CB_RETURN & cmd) 75 if (BIO_CB_RETURN & cmd)
75 r=ret; 76 r=ret;
76 77
77 sprintf(buf,"BIO[%08lX]:",(unsigned long)bio); 78 snprintf(buf,sizeof buf,"BIO[%08lX]:",(unsigned long)bio);
78 p= &(buf[14]); 79 p= &(buf[14]);
80 p_maxlen = sizeof buf - 14;
79 switch (cmd) 81 switch (cmd)
80 { 82 {
81 case BIO_CB_FREE: 83 case BIO_CB_FREE:
82 sprintf(p,"Free - %s\n",bio->method->name); 84 snprintf(p,p_maxlen,"Free - %s\n",bio->method->name);
83 break; 85 break;
84 case BIO_CB_READ: 86 case BIO_CB_READ:
85 if (bio->method->type & BIO_TYPE_DESCRIPTOR) 87 if (bio->method->type & BIO_TYPE_DESCRIPTOR)
86 sprintf(p,"read(%d,%d) - %s fd=%d\n",bio->num,argi,bio->method->name,bio->num); 88 snprintf(p,p_maxlen,"read(%d,%d) - %s fd=%d\n",
89 bio->num,argi,bio->method->name,bio->num);
87 else 90 else
88 sprintf(p,"read(%d,%d) - %s\n",bio->num,argi,bio->method->name); 91 snprintf(p,p_maxlen,"read(%d,%d) - %s\n",
92 bio->num,argi,bio->method->name);
89 break; 93 break;
90 case BIO_CB_WRITE: 94 case BIO_CB_WRITE:
91 if (bio->method->type & BIO_TYPE_DESCRIPTOR) 95 if (bio->method->type & BIO_TYPE_DESCRIPTOR)
92 sprintf(p,"write(%d,%d) - %s fd=%d\n",bio->num,argi,bio->method->name,bio->num); 96 snprintf(p,p_maxlen,"write(%d,%d) - %s fd=%d\n",
97 bio->num,argi,bio->method->name,bio->num);
93 else 98 else
94 sprintf(p,"write(%d,%d) - %s\n",bio->num,argi,bio->method->name); 99 snprintf(p,p_maxlen,"write(%d,%d) - %s\n",
100 bio->num,argi,bio->method->name);
95 break; 101 break;
96 case BIO_CB_PUTS: 102 case BIO_CB_PUTS:
97 sprintf(p,"puts() - %s\n",bio->method->name); 103 snprintf(p,p_maxlen,"puts() - %s\n",bio->method->name);
98 break; 104 break;
99 case BIO_CB_GETS: 105 case BIO_CB_GETS:
100 sprintf(p,"gets(%d) - %s\n",argi,bio->method->name); 106 snprintf(p,p_maxlen,"gets(%d) - %s\n",argi,bio->method->name);
101 break; 107 break;
102 case BIO_CB_CTRL: 108 case BIO_CB_CTRL:
103 sprintf(p,"ctrl(%d) - %s\n",argi,bio->method->name); 109 snprintf(p,p_maxlen,"ctrl(%d) - %s\n",argi,bio->method->name);
104 break; 110 break;
105 case BIO_CB_RETURN|BIO_CB_READ: 111 case BIO_CB_RETURN|BIO_CB_READ:
106 sprintf(p,"read return %ld\n",ret); 112 snprintf(p,p_maxlen,"read return %ld\n",ret);
107 break; 113 break;
108 case BIO_CB_RETURN|BIO_CB_WRITE: 114 case BIO_CB_RETURN|BIO_CB_WRITE:
109 sprintf(p,"write return %ld\n",ret); 115 snprintf(p,p_maxlen,"write return %ld\n",ret);
110 break; 116 break;
111 case BIO_CB_RETURN|BIO_CB_GETS: 117 case BIO_CB_RETURN|BIO_CB_GETS:
112 sprintf(p,"gets return %ld\n",ret); 118 snprintf(p,p_maxlen,"gets return %ld\n",ret);
113 break; 119 break;
114 case BIO_CB_RETURN|BIO_CB_PUTS: 120 case BIO_CB_RETURN|BIO_CB_PUTS:
115 sprintf(p,"puts return %ld\n",ret); 121 snprintf(p,p_maxlen,"puts return %ld\n",ret);
116 break; 122 break;
117 case BIO_CB_RETURN|BIO_CB_CTRL: 123 case BIO_CB_RETURN|BIO_CB_CTRL:
118 sprintf(p,"ctrl return %ld\n",ret); 124 snprintf(p,p_maxlen,"ctrl return %ld\n",ret);
119 break; 125 break;
120 default: 126 default:
121 sprintf(p,"bio callback - unknown type (%d)\n",cmd); 127 snprintf(p,p_maxlen,"bio callback - unknown type (%d)\n",cmd);
122 break; 128 break;
123 } 129 }
124 130
diff --git a/src/lib/libcrypto/bio/bio_lib.c b/src/lib/libcrypto/bio/bio_lib.c
index 692c8fb5c6..50df2238fa 100644
--- a/src/lib/libcrypto/bio/bio_lib.c
+++ b/src/lib/libcrypto/bio/bio_lib.c
@@ -272,18 +272,6 @@ int BIO_gets(BIO *b, char *in, int inl)
272 return(i); 272 return(i);
273 } 273 }
274 274
275int BIO_indent(BIO *b,int indent,int max)
276 {
277 if(indent < 0)
278 indent=0;
279 if(indent > max)
280 indent=max;
281 while(indent--)
282 if(BIO_puts(b," ") != 1)
283 return 0;
284 return 1;
285 }
286
287long BIO_int_ctrl(BIO *b, int cmd, long larg, int iarg) 275long BIO_int_ctrl(BIO *b, int cmd, long larg, int iarg)
288 { 276 {
289 int i; 277 int i;
@@ -395,8 +383,6 @@ BIO *BIO_pop(BIO *b)
395 if (b == NULL) return(NULL); 383 if (b == NULL) return(NULL);
396 ret=b->next_bio; 384 ret=b->next_bio;
397 385
398 BIO_ctrl(b,BIO_CTRL_POP,0,NULL);
399
400 if (b->prev_bio != NULL) 386 if (b->prev_bio != NULL)
401 b->prev_bio->next_bio=b->next_bio; 387 b->prev_bio->next_bio=b->next_bio;
402 if (b->next_bio != NULL) 388 if (b->next_bio != NULL)
@@ -404,6 +390,7 @@ BIO *BIO_pop(BIO *b)
404 390
405 b->next_bio=NULL; 391 b->next_bio=NULL;
406 b->prev_bio=NULL; 392 b->prev_bio=NULL;
393 BIO_ctrl(b,BIO_CTRL_POP,0,NULL);
407 return(ret); 394 return(ret);
408 } 395 }
409 396
diff --git a/src/lib/libcrypto/bio/bss_bio.c b/src/lib/libcrypto/bio/bss_bio.c
index aa58dab046..1c485a4479 100644
--- a/src/lib/libcrypto/bio/bss_bio.c
+++ b/src/lib/libcrypto/bio/bss_bio.c
@@ -28,12 +28,13 @@
28 28
29#include <openssl/bio.h> 29#include <openssl/bio.h>
30#include <openssl/err.h> 30#include <openssl/err.h>
31#include <openssl/err.h>
31#include <openssl/crypto.h> 32#include <openssl/crypto.h>
32 33
33#include "e_os.h" 34#include "e_os.h"
34 35
35/* VxWorks defines SSIZE_MAX with an empty value causing compile errors */ 36/* VxWorks defines SSIZE_MAX with an empty value causing compile errors */
36#if defined(OPENSSL_SYS_VXWORKS) 37#if defined(OPENSSL_SYS_VSWORKS)
37# undef SSIZE_MAX 38# undef SSIZE_MAX
38#endif 39#endif
39#ifndef SSIZE_MAX 40#ifndef SSIZE_MAX
diff --git a/src/lib/libcrypto/bio/bss_conn.c b/src/lib/libcrypto/bio/bss_conn.c
index 743db6ff94..81f27dba4c 100644
--- a/src/lib/libcrypto/bio/bss_conn.c
+++ b/src/lib/libcrypto/bio/bss_conn.c
@@ -519,10 +519,10 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
519 else if (num == 2) 519 else if (num == 2)
520 { 520 {
521 char buf[16]; 521 char buf[16];
522 unsigned char *p = ptr; 522 char *p = ptr;
523 523
524 sprintf(buf,"%d.%d.%d.%d", 524 snprintf(buf,sizeof buf,"%d.%d.%d.%d",
525 p[0],p[1],p[2],p[3]); 525 p[0],p[1],p[2],p[3]);
526 if (data->param_hostname != NULL) 526 if (data->param_hostname != NULL)
527 OPENSSL_free(data->param_hostname); 527 OPENSSL_free(data->param_hostname);
528 data->param_hostname=BUF_strdup(buf); 528 data->param_hostname=BUF_strdup(buf);
@@ -530,9 +530,9 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
530 } 530 }
531 else if (num == 3) 531 else if (num == 3)
532 { 532 {
533 char buf[DECIMAL_SIZE(int)+1]; 533 char buf[16];
534 534
535 sprintf(buf,"%d",*(int *)ptr); 535 snprintf(buf,sizeof buf,"%d",*(int *)ptr);
536 if (data->param_port != NULL) 536 if (data->param_port != NULL)
537 OPENSSL_free(data->param_port); 537 OPENSSL_free(data->param_port);
538 data->param_port=BUF_strdup(buf); 538 data->param_port=BUF_strdup(buf);
diff --git a/src/lib/libcrypto/bio/bss_file.c b/src/lib/libcrypto/bio/bss_file.c
index a66600c1a3..18e7bb86e6 100644
--- a/src/lib/libcrypto/bio/bss_file.c
+++ b/src/lib/libcrypto/bio/bss_file.c
@@ -232,22 +232,22 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr)
232 if (num & BIO_FP_APPEND) 232 if (num & BIO_FP_APPEND)
233 { 233 {
234 if (num & BIO_FP_READ) 234 if (num & BIO_FP_READ)
235 strcpy(p,"a+"); 235 strlcpy(p,"a+",sizeof p);
236 else strcpy(p,"a"); 236 else strlcpy(p,"a",sizeof p);
237 } 237 }
238 else if ((num & BIO_FP_READ) && (num & BIO_FP_WRITE)) 238 else if ((num & BIO_FP_READ) && (num & BIO_FP_WRITE))
239 strcpy(p,"r+"); 239 strlcpy(p,"r+",sizeof p);
240 else if (num & BIO_FP_WRITE) 240 else if (num & BIO_FP_WRITE)
241 strcpy(p,"w"); 241 strlcpy(p,"w",sizeof p);
242 else if (num & BIO_FP_READ) 242 else if (num & BIO_FP_READ)
243 strcpy(p,"r"); 243 strlcpy(p,"r",sizeof p);
244 else 244 else
245 { 245 {
246 BIOerr(BIO_F_FILE_CTRL,BIO_R_BAD_FOPEN_MODE); 246 BIOerr(BIO_F_FILE_CTRL,BIO_R_BAD_FOPEN_MODE);
247 ret=0; 247 ret=0;
248 break; 248 break;
249 } 249 }
250#if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_OS2) 250#if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS)
251 if (!(num & BIO_FP_TEXT)) 251 if (!(num & BIO_FP_TEXT))
252 strcat(p,"b"); 252 strcat(p,"b");
253 else 253 else
diff --git a/src/lib/libcrypto/bio/bss_log.c b/src/lib/libcrypto/bio/bss_log.c
index 1eb678cac0..a39d95297c 100644
--- a/src/lib/libcrypto/bio/bss_log.c
+++ b/src/lib/libcrypto/bio/bss_log.c
@@ -68,8 +68,7 @@
68 68
69#include "cryptlib.h" 69#include "cryptlib.h"
70 70
71#if defined(OPENSSL_SYS_WINCE) 71#if defined(OPENSSL_SYS_WIN32)
72#elif defined(OPENSSL_SYS_WIN32)
73# include <process.h> 72# include <process.h>
74#elif defined(OPENSSL_SYS_VMS) 73#elif defined(OPENSSL_SYS_VMS)
75# include <opcdef.h> 74# include <opcdef.h>
@@ -78,7 +77,7 @@
78# include <starlet.h> 77# include <starlet.h>
79#elif defined(__ultrix) 78#elif defined(__ultrix)
80# include <sys/syslog.h> 79# include <sys/syslog.h>
81#elif (!defined(MSDOS) || defined(WATT32)) && !defined(OPENSSL_SYS_VXWORKS) && !defined(NO_SYSLOG) 80#elif !defined(MSDOS) && !defined(OPENSSL_SYS_VXWORKS) && !defined(NO_SYSLOG) /* Unix */
82# include <syslog.h> 81# include <syslog.h>
83#endif 82#endif
84 83
@@ -275,7 +274,7 @@ static void xsyslog(BIO *bp, int priority, const char *string)
275 LPCSTR lpszStrings[2]; 274 LPCSTR lpszStrings[2];
276 WORD evtype= EVENTLOG_ERROR_TYPE; 275 WORD evtype= EVENTLOG_ERROR_TYPE;
277 int pid = _getpid(); 276 int pid = _getpid();
278 char pidbuf[DECIMAL_SIZE(pid)+4]; 277 char pidbuf[20];
279 278
280 switch (priority) 279 switch (priority)
281 { 280 {
@@ -374,15 +373,11 @@ static void xcloselog(BIO* bp)
374{ 373{
375} 374}
376 375
377#else /* Unix/Watt32 */ 376#else /* Unix */
378 377
379static void xopenlog(BIO* bp, char* name, int level) 378static void xopenlog(BIO* bp, char* name, int level)
380{ 379{
381#ifdef WATT32 /* djgpp/DOS */
382 openlog(name, LOG_PID|LOG_CONS|LOG_NDELAY, level);
383#else
384 openlog(name, LOG_PID|LOG_CONS, level); 380 openlog(name, LOG_PID|LOG_CONS, level);
385#endif
386} 381}
387 382
388static void xsyslog(BIO *bp, int priority, const char *string) 383static void xsyslog(BIO *bp, int priority, const char *string)
diff --git a/src/lib/libcrypto/bio/bss_mem.c b/src/lib/libcrypto/bio/bss_mem.c
index a4edb711ae..28ff7582bf 100644
--- a/src/lib/libcrypto/bio/bss_mem.c
+++ b/src/lib/libcrypto/bio/bss_mem.c
@@ -190,7 +190,7 @@ static int mem_write(BIO *b, const char *in, int inl)
190 190
191 BIO_clear_retry_flags(b); 191 BIO_clear_retry_flags(b);
192 blen=bm->length; 192 blen=bm->length;
193 if (BUF_MEM_grow_clean(bm,blen+inl) != (blen+inl)) 193 if (BUF_MEM_grow(bm,blen+inl) != (blen+inl))
194 goto end; 194 goto end;
195 memcpy(&(bm->data[blen]),in,inl); 195 memcpy(&(bm->data[blen]),in,inl);
196 ret=inl; 196 ret=inl;
@@ -284,11 +284,7 @@ static int mem_gets(BIO *bp, char *buf, int size)
284 284
285 BIO_clear_retry_flags(bp); 285 BIO_clear_retry_flags(bp);
286 j=bm->length; 286 j=bm->length;
287 if (j <= 0) 287 if (j <= 0) return(0);
288 {
289 *buf='\0';
290 return 0;
291 }
292 p=bm->data; 288 p=bm->data;
293 for (i=0; i<j; i++) 289 for (i=0; i<j; i++)
294 { 290 {
diff --git a/src/lib/libcrypto/bio/bss_rtcp.c b/src/lib/libcrypto/bio/bss_rtcp.c
new file mode 100644
index 0000000000..7dae485564
--- /dev/null
+++ b/src/lib/libcrypto/bio/bss_rtcp.c
@@ -0,0 +1,294 @@
1/* crypto/bio/bss_rtcp.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/* Written by David L. Jones <jonesd@kcgl1.eng.ohio-state.edu>
60 * Date: 22-JUL-1996
61 * Revised: 25-SEP-1997 Update for 0.8.1, BIO_CTRL_SET -> BIO_C_SET_FD
62 */
63/* VMS */
64#include <stdio.h>
65#include <stdlib.h>
66#include <string.h>
67#include <errno.h>
68#include "cryptlib.h"
69#include <openssl/bio.h>
70
71#include <iodef.h> /* VMS IO$_ definitions */
72#include <starlet.h>
73
74typedef unsigned short io_channel;
75/*************************************************************************/
76struct io_status { short status, count; long flags; };
77
78struct rpc_msg { /* Should have member alignment inhibited */
79 char channel; /* 'A'-app data. 'R'-remote client 'G'-global */
80 char function; /* 'G'-get, 'P'-put, 'C'-confirm, 'X'-close */
81 unsigned short int length; /* Amount of data returned or max to return */
82 char data[4092]; /* variable data */
83};
84#define RPC_HDR_SIZE (sizeof(struct rpc_msg) - 4092)
85
86struct rpc_ctx {
87 int filled, pos;
88 struct rpc_msg msg;
89};
90
91static int rtcp_write(BIO *h,const char *buf,int num);
92static int rtcp_read(BIO *h,char *buf,int size);
93static int rtcp_puts(BIO *h,const char *str);
94static int rtcp_gets(BIO *h,char *str,int size);
95static long rtcp_ctrl(BIO *h,int cmd,long arg1,void *arg2);
96static int rtcp_new(BIO *h);
97static int rtcp_free(BIO *data);
98
99static BIO_METHOD rtcp_method=
100 {
101 BIO_TYPE_FD,
102 "RTCP",
103 rtcp_write,
104 rtcp_read,
105 rtcp_puts,
106 rtcp_gets,
107 rtcp_ctrl,
108 rtcp_new,
109 rtcp_free,
110 NULL,
111 };
112
113BIO_METHOD *BIO_s_rtcp(void)
114 {
115 return(&rtcp_method);
116 }
117/*****************************************************************************/
118/* Decnet I/O routines.
119 */
120
121#ifdef __DECC
122#pragma message save
123#pragma message disable DOLLARID
124#endif
125
126static int get ( io_channel chan, char *buffer, int maxlen, int *length )
127{
128 int status;
129 struct io_status iosb;
130 status = sys$qiow ( 0, chan, IO$_READVBLK, &iosb, 0, 0,
131 buffer, maxlen, 0, 0, 0, 0 );
132 if ( (status&1) == 1 ) status = iosb.status;
133 if ( (status&1) == 1 ) *length = iosb.count;
134 return status;
135}
136
137static int put ( io_channel chan, char *buffer, int length )
138{
139 int status;
140 struct io_status iosb;
141 status = sys$qiow ( 0, chan, IO$_WRITEVBLK, &iosb, 0, 0,
142 buffer, length, 0, 0, 0, 0 );
143 if ( (status&1) == 1 ) status = iosb.status;
144 return status;
145}
146
147#ifdef __DECC
148#pragma message restore
149#endif
150
151/***************************************************************************/
152
153static int rtcp_new(BIO *bi)
154{
155 struct rpc_ctx *ctx;
156 bi->init=1;
157 bi->num=0;
158 bi->flags = 0;
159 bi->ptr=OPENSSL_malloc(sizeof(struct rpc_ctx));
160 ctx = (struct rpc_ctx *) bi->ptr;
161 ctx->filled = 0;
162 ctx->pos = 0;
163 return(1);
164}
165
166static int rtcp_free(BIO *a)
167{
168 if (a == NULL) return(0);
169 if ( a->ptr ) OPENSSL_free ( a->ptr );
170 a->ptr = NULL;
171 return(1);
172}
173
174static int rtcp_read(BIO *b, char *out, int outl)
175{
176 int status, length;
177 struct rpc_ctx *ctx;
178 /*
179 * read data, return existing.
180 */
181 ctx = (struct rpc_ctx *) b->ptr;
182 if ( ctx->pos < ctx->filled ) {
183 length = ctx->filled - ctx->pos;
184 if ( length > outl ) length = outl;
185 memmove ( out, &ctx->msg.data[ctx->pos], length );
186 ctx->pos += length;
187 return length;
188 }
189 /*
190 * Requst more data from R channel.
191 */
192 ctx->msg.channel = 'R';
193 ctx->msg.function = 'G';
194 ctx->msg.length = sizeof(ctx->msg.data);
195 status = put ( b->num, (char *) &ctx->msg, RPC_HDR_SIZE );
196 if ( (status&1) == 0 ) {
197 return -1;
198 }
199 /*
200 * Read.
201 */
202 ctx->pos = ctx->filled = 0;
203 status = get ( b->num, (char *) &ctx->msg, sizeof(ctx->msg), &length );
204 if ( (status&1) == 0 ) length = -1;
205 if ( ctx->msg.channel != 'R' || ctx->msg.function != 'C' ) {
206 length = -1;
207 }
208 ctx->filled = length - RPC_HDR_SIZE;
209
210 if ( ctx->pos < ctx->filled ) {
211 length = ctx->filled - ctx->pos;
212 if ( length > outl ) length = outl;
213 memmove ( out, ctx->msg.data, length );
214 ctx->pos += length;
215 return length;
216 }
217
218 return length;
219}
220
221static int rtcp_write(BIO *b, const char *in, int inl)
222{
223 int status, i, segment, length;
224 struct rpc_ctx *ctx;
225 /*
226 * Output data, send in chunks no larger that sizeof(ctx->msg.data).
227 */
228 ctx = (struct rpc_ctx *) b->ptr;
229 for ( i = 0; i < inl; i += segment ) {
230 segment = inl - i;
231 if ( segment > sizeof(ctx->msg.data) ) segment = sizeof(ctx->msg.data);
232 ctx->msg.channel = 'R';
233 ctx->msg.function = 'P';
234 ctx->msg.length = segment;
235 memmove ( ctx->msg.data, &in[i], segment );
236 status = put ( b->num, (char *) &ctx->msg, segment + RPC_HDR_SIZE );
237 if ((status&1) == 0 ) { i = -1; break; }
238
239 status = get ( b->num, (char *) &ctx->msg, sizeof(ctx->msg), &length );
240 if ( ((status&1) == 0) || (length < RPC_HDR_SIZE) ) { i = -1; break; }
241 if ( (ctx->msg.channel != 'R') || (ctx->msg.function != 'C') ) {
242 printf("unexpected response when confirming put %c %c\n",
243 ctx->msg.channel, ctx->msg.function );
244
245 }
246 }
247 return(i);
248}
249
250static long rtcp_ctrl(BIO *b, int cmd, long num, void *ptr)
251 {
252 long ret=1;
253
254 switch (cmd)
255 {
256 case BIO_CTRL_RESET:
257 case BIO_CTRL_EOF:
258 ret = 1;
259 break;
260 case BIO_C_SET_FD:
261 b->num = num;
262 ret = 1;
263 break;
264 case BIO_CTRL_SET_CLOSE:
265 case BIO_CTRL_FLUSH:
266 case BIO_CTRL_DUP:
267 ret=1;
268 break;
269 case BIO_CTRL_GET_CLOSE:
270 case BIO_CTRL_INFO:
271 case BIO_CTRL_GET:
272 case BIO_CTRL_PENDING:
273 case BIO_CTRL_WPENDING:
274 default:
275 ret=0;
276 break;
277 }
278 return(ret);
279 }
280
281static int rtcp_gets(BIO *bp, char *buf, int size)
282 {
283 return(0);
284 }
285
286static int rtcp_puts(BIO *bp, const char *str)
287{
288 int length;
289 if (str == NULL) return(0);
290 length = strlen ( str );
291 if ( length == 0 ) return (0);
292 return rtcp_write ( bp,str, length );
293}
294
diff --git a/src/lib/libcrypto/bio/bss_sock.c b/src/lib/libcrypto/bio/bss_sock.c
index 2c1c405ec7..fdabd16d7e 100644
--- a/src/lib/libcrypto/bio/bss_sock.c
+++ b/src/lib/libcrypto/bio/bss_sock.c
@@ -64,12 +64,6 @@
64#include "cryptlib.h" 64#include "cryptlib.h"
65#include <openssl/bio.h> 65#include <openssl/bio.h>
66 66
67#ifdef WATT32
68#define sock_write SockWrite /* Watt-32 uses same names */
69#define sock_read SockRead
70#define sock_puts SockPuts
71#endif
72
73static int sock_write(BIO *h, const char *buf, int num); 67static int sock_write(BIO *h, const char *buf, int num);
74static int sock_read(BIO *h, char *buf, int size); 68static int sock_read(BIO *h, char *buf, int size);
75static int sock_puts(BIO *h, const char *str); 69static int sock_puts(BIO *h, const char *str);
diff --git a/src/lib/libcrypto/bn/Makefile.ssl b/src/lib/libcrypto/bn/Makefile.ssl
new file mode 100644
index 0000000000..6a479726c4
--- /dev/null
+++ b/src/lib/libcrypto/bn/Makefile.ssl
@@ -0,0 +1,339 @@
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)
25
26# We let the C compiler driver to take care of .s files. This is done in
27# order to be excused from maintaining a separate set of architecture
28# dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
29# gcc, then the driver will automatically translate it to -xarch=v8plus
30# and pass it down to assembler.
31AS=$(CC) -c
32ASFLAGS=$(CFLAGS)
33
34GENERAL=Makefile
35TEST=bntest.c exptest.c
36APPS=
37
38LIB=$(TOP)/libcrypto.a
39LIBSRC= bn_add.c bn_div.c bn_exp.c bn_lib.c bn_ctx.c bn_mul.c bn_mod.c \
40 bn_print.c bn_rand.c bn_shift.c bn_word.c bn_blind.c \
41 bn_kron.c bn_sqrt.c bn_gcd.c bn_prime.c bn_err.c bn_sqr.c bn_asm.c \
42 bn_recp.c bn_mont.c bn_mpi.c bn_exp2.c
43
44LIBOBJ= bn_add.o bn_div.o bn_exp.o bn_lib.o bn_ctx.o bn_mul.o bn_mod.o \
45 bn_print.o bn_rand.o bn_shift.o bn_word.o bn_blind.o \
46 bn_kron.o bn_sqrt.o bn_gcd.o bn_prime.o bn_err.o bn_sqr.o $(BN_ASM) \
47 bn_recp.o bn_mont.o bn_mpi.o bn_exp2.o
48
49SRC= $(LIBSRC)
50
51EXHEADER= bn.h
52HEADER= bn_lcl.h bn_prime.h $(EXHEADER)
53
54ALL= $(GENERAL) $(SRC) $(HEADER)
55
56top:
57 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
58
59all: lib
60
61bn_prime.h: bn_prime.pl
62 $(PERL) bn_prime.pl >bn_prime.h
63
64divtest: divtest.c ../../libcrypto.a
65 cc -I../../include divtest.c -o divtest ../../libcrypto.a
66
67bnbug: bnbug.c ../../libcrypto.a top
68 cc -g -I../../include bnbug.c -o bnbug ../../libcrypto.a
69
70lib: $(LIBOBJ)
71 $(AR) $(LIB) $(LIBOBJ)
72 $(RANLIB) $(LIB) || echo Never mind.
73 @touch lib
74
75# elf
76asm/bn86-elf.o: asm/bn86unix.cpp
77 $(CPP) -DELF -x c asm/bn86unix.cpp | as -o asm/bn86-elf.o
78
79asm/co86-elf.o: asm/co86unix.cpp
80 $(CPP) -DELF -x c asm/co86unix.cpp | as -o asm/co86-elf.o
81
82# solaris
83asm/bn86-sol.o: asm/bn86unix.cpp
84 $(CC) -E -DSOL asm/bn86unix.cpp | sed 's/^#.*//' > asm/bn86-sol.s
85 as -o asm/bn86-sol.o asm/bn86-sol.s
86 rm -f asm/bn86-sol.s
87
88asm/co86-sol.o: asm/co86unix.cpp
89 $(CC) -E -DSOL asm/co86unix.cpp | sed 's/^#.*//' > asm/co86-sol.s
90 as -o asm/co86-sol.o asm/co86-sol.s
91 rm -f asm/co86-sol.s
92
93# a.out
94asm/bn86-out.o: asm/bn86unix.cpp
95 $(CPP) -DOUT asm/bn86unix.cpp | as -o asm/bn86-out.o
96
97asm/co86-out.o: asm/co86unix.cpp
98 $(CPP) -DOUT asm/co86unix.cpp | as -o asm/co86-out.o
99
100# bsdi
101asm/bn86bsdi.o: asm/bn86unix.cpp
102 $(CPP) -DBSDI asm/bn86unix.cpp | sed 's/ :/:/' | as -o asm/bn86bsdi.o
103
104asm/co86bsdi.o: asm/co86unix.cpp
105 $(CPP) -DBSDI asm/co86unix.cpp | sed 's/ :/:/' | as -o asm/co86bsdi.o
106
107asm/bn86unix.cpp: asm/bn-586.pl ../perlasm/x86asm.pl
108 (cd asm; $(PERL) bn-586.pl cpp >bn86unix.cpp )
109
110asm/co86unix.cpp: asm/co-586.pl ../perlasm/x86asm.pl
111 (cd asm; $(PERL) co-586.pl cpp >co86unix.cpp )
112
113asm/sparcv8.o: asm/sparcv8.S
114
115asm/sparcv8plus.o: asm/sparcv8plus.S
116
117# Old GNU assembler doesn't understand V9 instructions, so we
118# hire /usr/ccs/bin/as to do the job. Note that option is called
119# *-gcc27, but even gcc 2>=8 users may experience similar problem
120# if they didn't bother to upgrade GNU assembler. Such users should
121# not choose this option, but be adviced to *remove* GNU assembler
122# or upgrade it.
123asm/sparcv8plus-gcc27.o: asm/sparcv8plus.S
124 $(CC) $(ASFLAGS) -E asm/sparcv8plus.S | \
125 /usr/ccs/bin/as -xarch=v8plus - -o asm/sparcv8plus-gcc27.o
126
127
128asm/ia64.o: asm/ia64.S
129
130# Some compiler drivers (most notably HP-UX and Intel C++) don't
131# understand .S extension:-( I wish I could pipe output from cc -E,
132# but it's too compiler driver/ABI dependent to cover with a single
133# rule... <appro@fy.chalmers.se>
134asm/ia64-cpp.o: asm/ia64.S
135 $(CC) $(ASFLAGS) -E asm/ia64.S > /tmp/ia64.$$$$.s && \
136 $(CC) $(ASFLAGS) -c -o asm/ia64-cpp.o /tmp/ia64.$$$$.s; \
137 rm -f /tmp/ia64.$$$$.s
138
139files:
140 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
141
142links:
143 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
144 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
145 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
146 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
147
148install:
149 @for i in $(EXHEADER) ; \
150 do \
151 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
152 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
153 done;
154
155exptest:
156 rm -f exptest
157 gcc -I../../include -g2 -ggdb -o exptest exptest.c ../../libcrypto.a
158
159div:
160 rm -f a.out
161 gcc -I.. -g div.c ../../libcrypto.a
162
163tags:
164 ctags $(SRC)
165
166tests:
167
168lint:
169 lint -DLINT $(INCLUDES) $(SRC)>fluff
170
171depend:
172 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC)
173
174dclean:
175 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
176 mv -f Makefile.new $(MAKEFILE)
177
178clean:
179 rm -f asm/co86unix.cpp asm/bn86unix.cpp *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff bn_asm.s
180
181# DO NOT DELETE THIS LINE -- make depend depends on it.
182
183bn_add.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
184bn_add.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
185bn_add.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
186bn_add.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
187bn_add.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
188bn_add.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
189bn_add.o: ../cryptlib.h bn_add.c bn_lcl.h
190bn_asm.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
191bn_asm.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
192bn_asm.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
193bn_asm.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
194bn_asm.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
195bn_asm.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
196bn_asm.o: ../cryptlib.h bn_asm.c bn_lcl.h
197bn_blind.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
198bn_blind.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
199bn_blind.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
200bn_blind.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
201bn_blind.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
202bn_blind.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
203bn_blind.o: ../cryptlib.h bn_blind.c bn_lcl.h
204bn_ctx.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
205bn_ctx.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
206bn_ctx.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
207bn_ctx.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
208bn_ctx.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
209bn_ctx.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
210bn_ctx.o: ../cryptlib.h bn_ctx.c bn_lcl.h
211bn_div.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
212bn_div.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
213bn_div.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
214bn_div.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
215bn_div.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
216bn_div.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
217bn_div.o: ../cryptlib.h bn_div.c bn_lcl.h
218bn_err.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
219bn_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
220bn_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
221bn_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
222bn_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
223bn_err.o: ../../include/openssl/symhacks.h bn_err.c
224bn_exp.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
225bn_exp.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
226bn_exp.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
227bn_exp.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
228bn_exp.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
229bn_exp.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
230bn_exp.o: ../cryptlib.h bn_exp.c bn_lcl.h
231bn_exp2.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
232bn_exp2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
233bn_exp2.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
234bn_exp2.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
235bn_exp2.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
236bn_exp2.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
237bn_exp2.o: ../cryptlib.h bn_exp2.c bn_lcl.h
238bn_gcd.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
239bn_gcd.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
240bn_gcd.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
241bn_gcd.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
242bn_gcd.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
243bn_gcd.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
244bn_gcd.o: ../cryptlib.h bn_gcd.c bn_lcl.h
245bn_kron.o: ../../include/openssl/bn.h ../../include/openssl/e_os2.h
246bn_kron.o: ../../include/openssl/opensslconf.h bn_kron.c bn_lcl.h
247bn_lib.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
248bn_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
249bn_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
250bn_lib.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
251bn_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
252bn_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
253bn_lib.o: ../cryptlib.h bn_lcl.h bn_lib.c
254bn_mod.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
255bn_mod.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
256bn_mod.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
257bn_mod.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
258bn_mod.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
259bn_mod.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
260bn_mod.o: ../cryptlib.h bn_lcl.h bn_mod.c
261bn_mont.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
262bn_mont.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
263bn_mont.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
264bn_mont.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
265bn_mont.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
266bn_mont.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
267bn_mont.o: ../cryptlib.h bn_lcl.h bn_mont.c
268bn_mpi.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
269bn_mpi.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
270bn_mpi.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
271bn_mpi.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
272bn_mpi.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
273bn_mpi.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
274bn_mpi.o: ../cryptlib.h bn_lcl.h bn_mpi.c
275bn_mul.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
276bn_mul.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
277bn_mul.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
278bn_mul.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
279bn_mul.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
280bn_mul.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
281bn_mul.o: ../cryptlib.h bn_lcl.h bn_mul.c
282bn_prime.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
283bn_prime.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
284bn_prime.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
285bn_prime.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
286bn_prime.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
287bn_prime.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
288bn_prime.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
289bn_prime.o: ../cryptlib.h bn_lcl.h bn_prime.c bn_prime.h
290bn_print.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
291bn_print.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
292bn_print.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
293bn_print.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
294bn_print.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
295bn_print.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
296bn_print.o: ../cryptlib.h bn_lcl.h bn_print.c
297bn_rand.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
298bn_rand.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
299bn_rand.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
300bn_rand.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
301bn_rand.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
302bn_rand.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
303bn_rand.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
304bn_rand.o: ../cryptlib.h bn_lcl.h bn_rand.c
305bn_recp.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
306bn_recp.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
307bn_recp.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
308bn_recp.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
309bn_recp.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
310bn_recp.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
311bn_recp.o: ../cryptlib.h bn_lcl.h bn_recp.c
312bn_shift.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
313bn_shift.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
314bn_shift.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
315bn_shift.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
316bn_shift.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
317bn_shift.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
318bn_shift.o: ../cryptlib.h bn_lcl.h bn_shift.c
319bn_sqr.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
320bn_sqr.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
321bn_sqr.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
322bn_sqr.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
323bn_sqr.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
324bn_sqr.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
325bn_sqr.o: ../cryptlib.h bn_lcl.h bn_sqr.c
326bn_sqrt.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
327bn_sqrt.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
328bn_sqrt.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
329bn_sqrt.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
330bn_sqrt.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
331bn_sqrt.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
332bn_sqrt.o: ../cryptlib.h bn_lcl.h bn_sqrt.c
333bn_word.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
334bn_word.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
335bn_word.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
336bn_word.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
337bn_word.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
338bn_word.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
339bn_word.o: ../cryptlib.h bn_lcl.h bn_word.c
diff --git a/src/lib/libcrypto/bn/asm/README b/src/lib/libcrypto/bn/asm/README
new file mode 100644
index 0000000000..b0f3a68a06
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/README
@@ -0,0 +1,27 @@
1<OBSOLETE>
2
3All assember in this directory are just version of the file
4crypto/bn/bn_asm.c.
5
6Quite a few of these files are just the assember output from gcc since on
7quite a few machines they are 2 times faster than the system compiler.
8
9For the x86, I have hand written assember because of the bad job all
10compilers seem to do on it. This normally gives a 2 time speed up in the RSA
11routines.
12
13For the DEC alpha, I also hand wrote the assember (except the division which
14is just the output from the C compiler pasted on the end of the file).
15On the 2 alpha C compilers I had access to, it was not possible to do
1664b x 64b -> 128b calculations (both long and the long long data types
17were 64 bits). So the hand assember gives access to the 128 bit result and
18a 2 times speedup :-).
19
20There are 3 versions of assember for the HP PA-RISC.
21
22pa-risc.s is the origional one which works fine and generated using gcc :-)
23
24pa-risc2W.s and pa-risc2.s are 64 and 32-bit PA-RISC 2.0 implementations
25by Chris Ruemmler from HP (with some help from the HP C compiler).
26
27</OBSOLETE>
diff --git a/src/lib/libcrypto/bn/asm/alpha.s b/src/lib/libcrypto/bn/asm/alpha.s
new file mode 100644
index 0000000000..555ff0b92d
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/alpha.s
@@ -0,0 +1,3199 @@
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
new file mode 100644
index 0000000000..ee6c587809
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/alpha.s.works
@@ -0,0 +1,533 @@
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
new file mode 100644
index 0000000000..4dc76e6b69
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/alpha.works/add.pl
@@ -0,0 +1,119 @@
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
new file mode 100644
index 0000000000..7ec144377f
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/alpha.works/div.pl
@@ -0,0 +1,144 @@
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
new file mode 100644
index 0000000000..b182bae452
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/alpha.works/mul.pl
@@ -0,0 +1,116 @@
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
new file mode 100644
index 0000000000..e37f6315fb
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/alpha.works/mul_add.pl
@@ -0,0 +1,120 @@
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
new file mode 100644
index 0000000000..5efd201281
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/alpha.works/mul_c4.pl
@@ -0,0 +1,213 @@
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
new file mode 100644
index 0000000000..79d86dd25c
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/alpha.works/mul_c4.works.pl
@@ -0,0 +1,98 @@
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
new file mode 100644
index 0000000000..525ca7494b
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/alpha.works/mul_c8.pl
@@ -0,0 +1,177 @@
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
new file mode 100644
index 0000000000..a55b696906
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/alpha.works/sqr.pl
@@ -0,0 +1,113 @@
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
new file mode 100644
index 0000000000..bf33f5b503
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/alpha.works/sqr_c4.pl
@@ -0,0 +1,109 @@
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
new file mode 100644
index 0000000000..b4afe085f1
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/alpha.works/sqr_c8.pl
@@ -0,0 +1,132 @@
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
new file mode 100644
index 0000000000..d998da5c21
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/alpha.works/sub.pl
@@ -0,0 +1,108 @@
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
new file mode 100644
index 0000000000..13bf516428
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/alpha/add.pl
@@ -0,0 +1,118 @@
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
new file mode 100644
index 0000000000..e9e680897a
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/alpha/div.pl
@@ -0,0 +1,144 @@
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
new file mode 100644
index 0000000000..76c926566c
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/alpha/mul.pl
@@ -0,0 +1,104 @@
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
new file mode 100644
index 0000000000..0d6df69bc4
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/alpha/mul_add.pl
@@ -0,0 +1,123 @@
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
new file mode 100644
index 0000000000..9cc876ded4
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/alpha/mul_c4.pl
@@ -0,0 +1,215 @@
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
new file mode 100644
index 0000000000..79d86dd25c
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/alpha/mul_c4.works.pl
@@ -0,0 +1,98 @@
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
new file mode 100644
index 0000000000..525ca7494b
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/alpha/mul_c8.pl
@@ -0,0 +1,177 @@
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
new file mode 100644
index 0000000000..a55b696906
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/alpha/sqr.pl
@@ -0,0 +1,113 @@
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
new file mode 100644
index 0000000000..bf33f5b503
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/alpha/sqr_c4.pl
@@ -0,0 +1,109 @@
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
new file mode 100644
index 0000000000..b4afe085f1
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/alpha/sqr_c8.pl
@@ -0,0 +1,132 @@
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
new file mode 100644
index 0000000000..d998da5c21
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/alpha/sub.pl
@@ -0,0 +1,108 @@
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-alpha.pl b/src/lib/libcrypto/bn/asm/bn-alpha.pl
new file mode 100644
index 0000000000..302edf2376
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/bn-alpha.pl
@@ -0,0 +1,571 @@
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
new file mode 100644
index 0000000000..c1ce67a6b4
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/ca.pl
@@ -0,0 +1,33 @@
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-alpha.pl b/src/lib/libcrypto/bn/asm/co-alpha.pl
new file mode 100644
index 0000000000..67dad3e3d5
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/co-alpha.pl
@@ -0,0 +1,116 @@
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/ia64.S b/src/lib/libcrypto/bn/asm/ia64.S
index 7dfda85566..ae56066310 100644
--- a/src/lib/libcrypto/bn/asm/ia64.S
+++ b/src/lib/libcrypto/bn/asm/ia64.S
@@ -1,6 +1,6 @@
1.explicit 1.explicit
2.text 2.text
3.ident "ia64.S, Version 2.0" 3.ident "ia64.S, Version 1.1"
4.ident "IA-64 ISA artwork by Andy Polyakov <appro@fy.chalmers.se>" 4.ident "IA-64 ISA artwork by Andy Polyakov <appro@fy.chalmers.se>"
5 5
6// 6//
@@ -13,35 +13,6 @@
13// disclaimed. 13// disclaimed.
14// ==================================================================== 14// ====================================================================
15// 15//
16// Version 2.x is Itanium2 re-tune. Few words about how Itanum2 is
17// different from Itanium to this module viewpoint. Most notably, is it
18// "wider" than Itanium? Can you experience loop scalability as
19// discussed in commentary sections? Not really:-( Itanium2 has 6
20// integer ALU ports, i.e. it's 2 ports wider, but it's not enough to
21// spin twice as fast, as I need 8 IALU ports. Amount of floating point
22// ports is the same, i.e. 2, while I need 4. In other words, to this
23// module Itanium2 remains effectively as "wide" as Itanium. Yet it's
24// essentially different in respect to this module, and a re-tune was
25// required. Well, because some intruction latencies has changed. Most
26// noticeably those intensively used:
27//
28// Itanium Itanium2
29// ldf8 9 6 L2 hit
30// ld8 2 1 L1 hit
31// getf 2 5
32// xma[->getf] 7[+1] 4[+0]
33// add[->st8] 1[+1] 1[+0]
34//
35// What does it mean? You might ratiocinate that the original code
36// should run just faster... Because sum of latencies is smaller...
37// Wrong! Note that getf latency increased. This means that if a loop is
38// scheduled for lower latency (and they are), then it will suffer from
39// stall condition and the code will therefore turn anti-scalable, e.g.
40// original bn_mul_words spun at 5*n or 2.5 times slower than expected
41// on Itanium2! What to do? Reschedule loops for Itanium2? But then
42// Itanium would exhibit anti-scalability. So I've chosen to reschedule
43// for worst latency for every instruction aiming for best *all-round*
44// performance.
45 16
46// Q. How much faster does it get? 17// Q. How much faster does it get?
47// A. Here is the output from 'openssl speed rsa dsa' for vanilla 18// A. Here is the output from 'openssl speed rsa dsa' for vanilla
@@ -178,27 +149,12 @@ bn_add_words:
178 brp.loop.imp .L_bn_add_words_ctop,.L_bn_add_words_cend-16 149 brp.loop.imp .L_bn_add_words_ctop,.L_bn_add_words_cend-16
179 } 150 }
180 .body 151 .body
181{ .mib; 152{ .mib; mov r14=r32 // rp
182#if defined(_HPUX_SOURCE) && defined(_ILP32)
183 addp4 r14=0,r32 // rp
184#else
185 mov r14=r32 // rp
186#endif
187 mov r9=pr };; 153 mov r9=pr };;
188{ .mii; 154{ .mii; mov r15=r33 // ap
189#if defined(_HPUX_SOURCE) && defined(_ILP32)
190 addp4 r15=0,r33 // ap
191#else
192 mov r15=r33 // ap
193#endif
194 mov ar.lc=r10 155 mov ar.lc=r10
195 mov ar.ec=6 } 156 mov ar.ec=6 }
196{ .mib; 157{ .mib; mov r16=r34 // bp
197#if defined(_HPUX_SOURCE) && defined(_ILP32)
198 addp4 r16=0,r34 // bp
199#else
200 mov r16=r34 // bp
201#endif
202 mov pr.rot=1<<16 };; 158 mov pr.rot=1<<16 };;
203 159
204.L_bn_add_words_ctop: 160.L_bn_add_words_ctop:
@@ -218,7 +174,7 @@ bn_add_words:
218 174
219{ .mii; 175{ .mii;
220(p59) add r8=1,r8 // return value 176(p59) add r8=1,r8 // return value
221 mov pr=r9,0x1ffff 177 mov pr=r9,-1
222 mov ar.lc=r3 } 178 mov ar.lc=r3 }
223{ .mbb; nop.b 0x0 179{ .mbb; nop.b 0x0
224 br.ret.sptk.many b0 };; 180 br.ret.sptk.many b0 };;
@@ -246,27 +202,12 @@ bn_sub_words:
246 brp.loop.imp .L_bn_sub_words_ctop,.L_bn_sub_words_cend-16 202 brp.loop.imp .L_bn_sub_words_ctop,.L_bn_sub_words_cend-16
247 } 203 }
248 .body 204 .body
249{ .mib; 205{ .mib; mov r14=r32 // rp
250#if defined(_HPUX_SOURCE) && defined(_ILP32)
251 addp4 r14=0,r32 // rp
252#else
253 mov r14=r32 // rp
254#endif
255 mov r9=pr };; 206 mov r9=pr };;
256{ .mii; 207{ .mii; mov r15=r33 // ap
257#if defined(_HPUX_SOURCE) && defined(_ILP32)
258 addp4 r15=0,r33 // ap
259#else
260 mov r15=r33 // ap
261#endif
262 mov ar.lc=r10 208 mov ar.lc=r10
263 mov ar.ec=6 } 209 mov ar.ec=6 }
264{ .mib; 210{ .mib; mov r16=r34 // bp
265#if defined(_HPUX_SOURCE) && defined(_ILP32)
266 addp4 r16=0,r34 // bp
267#else
268 mov r16=r34 // bp
269#endif
270 mov pr.rot=1<<16 };; 211 mov pr.rot=1<<16 };;
271 212
272.L_bn_sub_words_ctop: 213.L_bn_sub_words_ctop:
@@ -286,7 +227,7 @@ bn_sub_words:
286 227
287{ .mii; 228{ .mii;
288(p59) add r8=1,r8 // return value 229(p59) add r8=1,r8 // return value
289 mov pr=r9,0x1ffff 230 mov pr=r9,-1
290 mov ar.lc=r3 } 231 mov ar.lc=r3 }
291{ .mbb; nop.b 0x0 232{ .mbb; nop.b 0x0
292 br.ret.sptk.many b0 };; 233 br.ret.sptk.many b0 };;
@@ -312,7 +253,7 @@ bn_mul_words:
312#ifdef XMA_TEMPTATION 253#ifdef XMA_TEMPTATION
313{ .mfi; alloc r2=ar.pfs,4,0,0,0 };; 254{ .mfi; alloc r2=ar.pfs,4,0,0,0 };;
314#else 255#else
315{ .mfi; alloc r2=ar.pfs,4,12,0,16 };; 256{ .mfi; alloc r2=ar.pfs,4,4,0,8 };;
316#endif 257#endif
317{ .mib; mov r8=r0 // return value 258{ .mib; mov r8=r0 // return value
318 cmp4.le p6,p0=r34,r0 259 cmp4.le p6,p0=r34,r0
@@ -325,30 +266,24 @@ bn_mul_words:
325 266
326 .body 267 .body
327{ .mib; setf.sig f8=r35 // w 268{ .mib; setf.sig f8=r35 // w
328 mov pr.rot=0x800001<<16 269 mov pr.rot=0x400001<<16
329 // ------^----- serves as (p50) at first (p27) 270 // ------^----- serves as (p48) at first (p26)
330 brp.loop.imp .L_bn_mul_words_ctop,.L_bn_mul_words_cend-16 271 brp.loop.imp .L_bn_mul_words_ctop,.L_bn_mul_words_cend-16
331 } 272 }
332 273
333#ifndef XMA_TEMPTATION 274#ifndef XMA_TEMPTATION
334 275
335{ .mii; 276{ .mii; mov r14=r32 // rp
336#if defined(_HPUX_SOURCE) && defined(_ILP32) 277 mov r15=r33 // ap
337 addp4 r14=0,r32 // rp
338 addp4 r15=0,r33 // ap
339#else
340 mov r14=r32 // rp
341 mov r15=r33 // ap
342#endif
343 mov ar.lc=r10 } 278 mov ar.lc=r10 }
344{ .mii; mov r40=0 // serves as r35 at first (p27) 279{ .mii; mov r39=0 // serves as r33 at first (p26)
345 mov ar.ec=13 };; 280 mov ar.ec=12 };;
346 281
347// This loop spins in 2*(n+12) ticks. It's scheduled for data in Itanium 282// This loop spins in 2*(n+11) ticks. It's scheduled for data in L2
348// L2 cache (i.e. 9 ticks away) as floating point load/store instructions 283// cache (i.e. 9 ticks away) as floating point load/store instructions
349// bypass L1 cache and L2 latency is actually best-case scenario for 284// bypass L1 cache and L2 latency is actually best-case scenario for
350// ldf8. The loop is not scalable and shall run in 2*(n+12) even on 285// ldf8. The loop is not scalable and shall run in 2*(n+11) even on
351// "wider" IA-64 implementations. It's a trade-off here. n+24 loop 286// "wider" IA-64 implementations. It's a trade-off here. n+22 loop
352// would give us ~5% in *overall* performance improvement on "wider" 287// would give us ~5% in *overall* performance improvement on "wider"
353// IA-64, but would hurt Itanium for about same because of longer 288// IA-64, but would hurt Itanium for about same because of longer
354// epilogue. As it's a matter of few percents in either case I've 289// epilogue. As it's a matter of few percents in either case I've
@@ -356,25 +291,25 @@ bn_mul_words:
356// this very instruction sequence in bn_mul_add_words loop which in 291// this very instruction sequence in bn_mul_add_words loop which in
357// turn is scalable). 292// turn is scalable).
358.L_bn_mul_words_ctop: 293.L_bn_mul_words_ctop:
359{ .mfi; (p25) getf.sig r36=f52 // low 294{ .mfi; (p25) getf.sig r36=f49 // low
360 (p21) xmpy.lu f48=f37,f8 295 (p21) xmpy.lu f45=f37,f8
361 (p28) cmp.ltu p54,p50=r41,r39 } 296 (p27) cmp.ltu p52,p48=r39,r38 }
362{ .mfi; (p16) ldf8 f32=[r15],8 297{ .mfi; (p16) ldf8 f32=[r15],8
363 (p21) xmpy.hu f40=f37,f8 298 (p21) xmpy.hu f38=f37,f8
364 (p0) nop.i 0x0 };; 299 (p0) nop.i 0x0 };;
365{ .mii; (p25) getf.sig r32=f44 // high 300{ .mii; (p26) getf.sig r32=f43 // high
366 .pred.rel "mutex",p50,p54 301 .pred.rel "mutex",p48,p52
367 (p50) add r40=r38,r35 // (p27) 302 (p48) add r38=r37,r33 // (p26)
368 (p54) add r40=r38,r35,1 } // (p27) 303 (p52) add r38=r37,r33,1 } // (p26)
369{ .mfb; (p28) st8 [r14]=r41,8 304{ .mfb; (p27) st8 [r14]=r39,8
370 (p0) nop.f 0x0 305 (p0) nop.f 0x0
371 br.ctop.sptk .L_bn_mul_words_ctop };; 306 br.ctop.sptk .L_bn_mul_words_ctop };;
372.L_bn_mul_words_cend: 307.L_bn_mul_words_cend:
373 308
374{ .mii; nop.m 0x0 309{ .mii; nop.m 0x0
375.pred.rel "mutex",p51,p55 310.pred.rel "mutex",p49,p53
376(p51) add r8=r36,r0 311(p49) add r8=r34,r0
377(p55) add r8=r36,r0,1 } 312(p53) add r8=r34,r0,1 }
378{ .mfb; nop.m 0x0 313{ .mfb; nop.m 0x0
379 nop.f 0x0 314 nop.f 0x0
380 nop.b 0x0 } 315 nop.b 0x0 }
@@ -409,7 +344,7 @@ bn_mul_words:
409#endif // XMA_TEMPTATION 344#endif // XMA_TEMPTATION
410 345
411{ .mii; nop.m 0x0 346{ .mii; nop.m 0x0
412 mov pr=r9,0x1ffff 347 mov pr=r9,-1
413 mov ar.lc=r3 } 348 mov ar.lc=r3 }
414{ .mfb; rum 1<<5 // clear um.mfh 349{ .mfb; rum 1<<5 // clear um.mfh
415 nop.f 0x0 350 nop.f 0x0
@@ -441,69 +376,59 @@ bn_mul_add_words:
441 376
442 .body 377 .body
443{ .mib; setf.sig f8=r35 // w 378{ .mib; setf.sig f8=r35 // w
444 mov pr.rot=0x800001<<16 379 mov pr.rot=0x400001<<16
445 // ------^----- serves as (p50) at first (p27) 380 // ------^----- serves as (p48) at first (p26)
446 brp.loop.imp .L_bn_mul_add_words_ctop,.L_bn_mul_add_words_cend-16 381 brp.loop.imp .L_bn_mul_add_words_ctop,.L_bn_mul_add_words_cend-16
447 } 382 }
448{ .mii; 383{ .mii; mov r14=r32 // rp
449#if defined(_HPUX_SOURCE) && defined(_ILP32) 384 mov r15=r33 // ap
450 addp4 r14=0,r32 // rp
451 addp4 r15=0,r33 // ap
452#else
453 mov r14=r32 // rp
454 mov r15=r33 // ap
455#endif
456 mov ar.lc=r10 } 385 mov ar.lc=r10 }
457{ .mii; mov r40=0 // serves as r35 at first (p27) 386{ .mii; mov r39=0 // serves as r33 at first (p26)
458#if defined(_HPUX_SOURCE) && defined(_ILP32) 387 mov r18=r32 // rp copy
459 addp4 r18=0,r32 // rp copy 388 mov ar.ec=14 };;
460#else
461 mov r18=r32 // rp copy
462#endif
463 mov ar.ec=15 };;
464 389
465// This loop spins in 3*(n+14) ticks on Itanium and should spin in 390// This loop spins in 3*(n+13) ticks on Itanium and should spin in
466// 2*(n+14) on "wider" IA-64 implementations (to be verified with new 391// 2*(n+13) on "wider" IA-64 implementations (to be verified with new
467// µ-architecture manuals as they become available). As usual it's 392// µ-architecture manuals as they become available). As usual it's
468// possible to compress the epilogue, down to 10 in this case, at the 393// possible to compress the epilogue, down to 10 in this case, at the
469// cost of scalability. Compressed (and therefore non-scalable) loop 394// cost of scalability. Compressed (and therefore non-scalable) loop
470// running at 3*(n+11) would buy you ~10% on Itanium but take ~35% 395// running at 3*(n+10) would buy you ~10% on Itanium but take ~35%
471// from "wider" IA-64 so let it be scalable! Special attention was 396// from "wider" IA-64 so let it be scalable! Special attention was
472// paid for having the loop body split at 64-byte boundary. ld8 is 397// paid for having the loop body split at 64-byte boundary. ld8 is
473// scheduled for L1 cache as the data is more than likely there. 398// scheduled for L1 cache as the data is more than likely there.
474// Indeed, bn_mul_words has put it there a moment ago:-) 399// Indeed, bn_mul_words has put it there a moment ago:-)
475.L_bn_mul_add_words_ctop: 400.L_bn_mul_add_words_ctop:
476{ .mfi; (p25) getf.sig r36=f52 // low 401{ .mfi; (p25) getf.sig r36=f49 // low
477 (p21) xmpy.lu f48=f37,f8 402 (p21) xmpy.lu f45=f37,f8
478 (p28) cmp.ltu p54,p50=r41,r39 } 403 (p27) cmp.ltu p52,p48=r39,r38 }
479{ .mfi; (p16) ldf8 f32=[r15],8 404{ .mfi; (p16) ldf8 f32=[r15],8
480 (p21) xmpy.hu f40=f37,f8 405 (p21) xmpy.hu f38=f37,f8
481 (p28) add r45=r45,r41 };; 406 (p27) add r43=r43,r39 };;
482{ .mii; (p25) getf.sig r32=f44 // high 407{ .mii; (p26) getf.sig r32=f43 // high
483 .pred.rel "mutex",p50,p54 408 .pred.rel "mutex",p48,p52
484 (p50) add r40=r38,r35 // (p27) 409 (p48) add r38=r37,r33 // (p26)
485 (p54) add r40=r38,r35,1 } // (p27) 410 (p52) add r38=r37,r33,1 } // (p26)
486{ .mfb; (p28) cmp.ltu.unc p60,p0=r45,r41 411{ .mfb; (p27) cmp.ltu.unc p56,p0=r43,r39
487 (p0) nop.f 0x0 412 (p0) nop.f 0x0
488 (p0) nop.b 0x0 } 413 (p0) nop.b 0x0 }
489{ .mii; (p27) ld8 r44=[r18],8 414{ .mii; (p26) ld8 r42=[r18],8
490 (p62) cmp.eq.or p61,p0=-1,r46 415 (p58) cmp.eq.or p57,p0=-1,r44
491 (p62) add r46=1,r46 } 416 (p58) add r44=1,r44 }
492{ .mfb; (p30) st8 [r14]=r47,8 417{ .mfb; (p29) st8 [r14]=r45,8
493 (p0) nop.f 0x0 418 (p0) nop.f 0x0
494 br.ctop.sptk .L_bn_mul_add_words_ctop};; 419 br.ctop.sptk .L_bn_mul_add_words_ctop};;
495.L_bn_mul_add_words_cend: 420.L_bn_mul_add_words_cend:
496 421
497{ .mii; nop.m 0x0 422{ .mii; nop.m 0x0
498.pred.rel "mutex",p53,p57 423.pred.rel "mutex",p51,p55
499(p53) add r8=r38,r0 424(p51) add r8=r36,r0
500(p57) add r8=r38,r0,1 } 425(p55) add r8=r36,r0,1 }
501{ .mfb; nop.m 0x0 426{ .mfb; nop.m 0x0
502 nop.f 0x0 427 nop.f 0x0
503 nop.b 0x0 };; 428 nop.b 0x0 };;
504{ .mii; 429{ .mii;
505(p63) add r8=1,r8 430(p59) add r8=1,r8
506 mov pr=r9,0x1ffff 431 mov pr=r9,-1
507 mov ar.lc=r3 } 432 mov ar.lc=r3 }
508{ .mfb; rum 1<<5 // clear um.mfh 433{ .mfb; rum 1<<5 // clear um.mfh
509 nop.f 0x0 434 nop.f 0x0
@@ -536,10 +461,6 @@ bn_sqr_words:
536 mov r9=pr };; 461 mov r9=pr };;
537 462
538 .body 463 .body
539#if defined(_HPUX_SOURCE) && defined(_ILP32)
540{ .mii; addp4 r32=0,r32
541 addp4 r33=0,r33 };;
542#endif
543{ .mib; 464{ .mib;
544 mov pr.rot=1<<16 465 mov pr.rot=1<<16
545 brp.loop.imp .L_bn_sqr_words_ctop,.L_bn_sqr_words_cend-16 466 brp.loop.imp .L_bn_sqr_words_ctop,.L_bn_sqr_words_cend-16
@@ -571,7 +492,7 @@ bn_sqr_words:
571.L_bn_sqr_words_cend: 492.L_bn_sqr_words_cend:
572 493
573{ .mii; nop.m 0x0 494{ .mii; nop.m 0x0
574 mov pr=r9,0x1ffff 495 mov pr=r9,-1
575 mov ar.lc=r3 } 496 mov ar.lc=r3 }
576{ .mfb; rum 1<<5 // clear um.mfh 497{ .mfb; rum 1<<5 // clear um.mfh
577 nop.f 0x0 498 nop.f 0x0
@@ -605,14 +526,7 @@ bn_sqr_comba8:
605 .prologue 526 .prologue
606 .fframe 0 527 .fframe 0
607 .save ar.pfs,r2 528 .save ar.pfs,r2
608#if defined(_HPUX_SOURCE) && defined(_ILP32)
609{ .mii; alloc r2=ar.pfs,2,1,0,0 529{ .mii; alloc r2=ar.pfs,2,1,0,0
610 addp4 r33=0,r33
611 addp4 r32=0,r32 };;
612{ .mii;
613#else
614{ .mii; alloc r2=ar.pfs,2,1,0,0
615#endif
616 mov r34=r33 530 mov r34=r33
617 add r14=8,r33 };; 531 add r14=8,r33 };;
618 .body 532 .body
@@ -673,14 +587,7 @@ bn_mul_comba8:
673 .prologue 587 .prologue
674 .fframe 0 588 .fframe 0
675 .save ar.pfs,r2 589 .save ar.pfs,r2
676#if defined(_HPUX_SOURCE) && defined(_ILP32)
677{ .mii; alloc r2=ar.pfs,3,0,0,0 590{ .mii; alloc r2=ar.pfs,3,0,0,0
678 addp4 r33=0,r33
679 addp4 r34=0,r34 };;
680{ .mii; addp4 r32=0,r32
681#else
682{ .mii; alloc r2=ar.pfs,3,0,0,0
683#endif
684 add r14=8,r33 591 add r14=8,r33
685 add r17=8,r34 } 592 add r17=8,r34 }
686 .body 593 .body
@@ -1231,14 +1138,7 @@ bn_sqr_comba4:
1231 .prologue 1138 .prologue
1232 .fframe 0 1139 .fframe 0
1233 .save ar.pfs,r2 1140 .save ar.pfs,r2
1234#if defined(_HPUX_SOURCE) && defined(_ILP32)
1235{ .mii; alloc r2=ar.pfs,2,1,0,0
1236 addp4 r32=0,r32
1237 addp4 r33=0,r33 };;
1238{ .mii;
1239#else
1240{ .mii; alloc r2=ar.pfs,2,1,0,0 1141{ .mii; alloc r2=ar.pfs,2,1,0,0
1241#endif
1242 mov r34=r33 1142 mov r34=r33
1243 add r14=8,r33 };; 1143 add r14=8,r33 };;
1244 .body 1144 .body
@@ -1264,14 +1164,7 @@ bn_mul_comba4:
1264 .prologue 1164 .prologue
1265 .fframe 0 1165 .fframe 0
1266 .save ar.pfs,r2 1166 .save ar.pfs,r2
1267#if defined(_HPUX_SOURCE) && defined(_ILP32)
1268{ .mii; alloc r2=ar.pfs,3,0,0,0
1269 addp4 r33=0,r33
1270 addp4 r34=0,r34 };;
1271{ .mii; addp4 r32=0,r32
1272#else
1273{ .mii; alloc r2=ar.pfs,3,0,0,0 1167{ .mii; alloc r2=ar.pfs,3,0,0,0
1274#endif
1275 add r14=8,r33 1168 add r14=8,r33
1276 add r17=8,r34 } 1169 add r17=8,r34 }
1277 .body 1170 .body
@@ -1571,7 +1464,7 @@ bn_div_words:
1571 or r8=r8,r33 1464 or r8=r8,r33
1572 mov ar.pfs=r2 };; 1465 mov ar.pfs=r2 };;
1573{ .mii; shr.u r9=H,I // remainder if anybody wants it 1466{ .mii; shr.u r9=H,I // remainder if anybody wants it
1574 mov pr=r10,0x1ffff } 1467 mov pr=r10,-1 }
1575{ .mfb; br.ret.sptk.many b0 };; 1468{ .mfb; br.ret.sptk.many b0 };;
1576 1469
1577// Unsigned 64 by 32 (well, by 64 for the moment) bit integer division 1470// Unsigned 64 by 32 (well, by 64 for the moment) bit integer division
diff --git a/src/lib/libcrypto/bn/asm/mips1.s b/src/lib/libcrypto/bn/asm/mips1.s
new file mode 100644
index 0000000000..44fa1254c7
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/mips1.s
@@ -0,0 +1,539 @@
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/mips3.s b/src/lib/libcrypto/bn/asm/mips3.s
new file mode 100644
index 0000000000..dca4105c7d
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/mips3.s
@@ -0,0 +1,2201 @@
1.rdata
2.asciiz "mips3.s, Version 1.1"
3.asciiz "MIPS III/IV ISA artwork by Andy Polyakov <appro@fy.chalmers.se>"
4
5/*
6 * ====================================================================
7 * Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL
8 * project.
9 *
10 * Rights for redistribution and usage in source and binary forms are
11 * granted according to the OpenSSL license. Warranty of any kind is
12 * disclaimed.
13 * ====================================================================
14 */
15
16/*
17 * This is my modest contributon to the OpenSSL project (see
18 * http://www.openssl.org/ for more information about it) and is
19 * a drop-in MIPS III/IV ISA replacement for crypto/bn/bn_asm.c
20 * module. For updates see http://fy.chalmers.se/~appro/hpe/.
21 *
22 * The module is designed to work with either of the "new" MIPS ABI(5),
23 * namely N32 or N64, offered by IRIX 6.x. It's not ment to work under
24 * IRIX 5.x not only because it doesn't support new ABIs but also
25 * because 5.x kernels put R4x00 CPU into 32-bit mode and all those
26 * 64-bit instructions (daddu, dmultu, etc.) found below gonna only
27 * cause illegal instruction exception:-(
28 *
29 * In addition the code depends on preprocessor flags set up by MIPSpro
30 * compiler driver (either as or cc) and therefore (probably?) can't be
31 * compiled by the GNU assembler. GNU C driver manages fine though...
32 * I mean as long as -mmips-as is specified or is the default option,
33 * because then it simply invokes /usr/bin/as which in turn takes
34 * perfect care of the preprocessor definitions. Another neat feature
35 * offered by the MIPSpro assembler is an optimization pass. This gave
36 * me the opportunity to have the code looking more regular as all those
37 * architecture dependent instruction rescheduling details were left to
38 * the assembler. Cool, huh?
39 *
40 * Performance improvement is astonishing! 'apps/openssl speed rsa dsa'
41 * goes way over 3 times faster!
42 *
43 * <appro@fy.chalmers.se>
44 */
45#include <asm.h>
46#include <regdef.h>
47
48#if _MIPS_ISA>=4
49#define MOVNZ(cond,dst,src) \
50 movn dst,src,cond
51#else
52#define MOVNZ(cond,dst,src) \
53 .set noreorder; \
54 bnezl cond,.+8; \
55 move dst,src; \
56 .set reorder
57#endif
58
59.text
60
61.set noat
62.set reorder
63
64#define MINUS4 v1
65
66.align 5
67LEAF(bn_mul_add_words)
68 .set noreorder
69 bgtzl a2,.L_bn_mul_add_words_proceed
70 ld t0,0(a1)
71 jr ra
72 move v0,zero
73 .set reorder
74
75.L_bn_mul_add_words_proceed:
76 li MINUS4,-4
77 and ta0,a2,MINUS4
78 move v0,zero
79 beqz ta0,.L_bn_mul_add_words_tail
80
81.L_bn_mul_add_words_loop:
82 dmultu t0,a3
83 ld t1,0(a0)
84 ld t2,8(a1)
85 ld t3,8(a0)
86 ld ta0,16(a1)
87 ld ta1,16(a0)
88 daddu t1,v0
89 sltu v0,t1,v0 /* All manuals say it "compares 32-bit
90 * values", but it seems to work fine
91 * even on 64-bit registers. */
92 mflo AT
93 mfhi t0
94 daddu t1,AT
95 daddu v0,t0
96 sltu AT,t1,AT
97 sd t1,0(a0)
98 daddu v0,AT
99
100 dmultu t2,a3
101 ld ta2,24(a1)
102 ld ta3,24(a0)
103 daddu t3,v0
104 sltu v0,t3,v0
105 mflo AT
106 mfhi t2
107 daddu t3,AT
108 daddu v0,t2
109 sltu AT,t3,AT
110 sd t3,8(a0)
111 daddu v0,AT
112
113 dmultu ta0,a3
114 subu a2,4
115 PTR_ADD a0,32
116 PTR_ADD a1,32
117 daddu ta1,v0
118 sltu v0,ta1,v0
119 mflo AT
120 mfhi ta0
121 daddu ta1,AT
122 daddu v0,ta0
123 sltu AT,ta1,AT
124 sd ta1,-16(a0)
125 daddu v0,AT
126
127
128 dmultu ta2,a3
129 and ta0,a2,MINUS4
130 daddu ta3,v0
131 sltu v0,ta3,v0
132 mflo AT
133 mfhi ta2
134 daddu ta3,AT
135 daddu v0,ta2
136 sltu AT,ta3,AT
137 sd ta3,-8(a0)
138 daddu v0,AT
139 .set noreorder
140 bgtzl ta0,.L_bn_mul_add_words_loop
141 ld t0,0(a1)
142
143 bnezl a2,.L_bn_mul_add_words_tail
144 ld t0,0(a1)
145 .set reorder
146
147.L_bn_mul_add_words_return:
148 jr ra
149
150.L_bn_mul_add_words_tail:
151 dmultu t0,a3
152 ld t1,0(a0)
153 subu a2,1
154 daddu t1,v0
155 sltu v0,t1,v0
156 mflo AT
157 mfhi t0
158 daddu t1,AT
159 daddu v0,t0
160 sltu AT,t1,AT
161 sd t1,0(a0)
162 daddu v0,AT
163 beqz a2,.L_bn_mul_add_words_return
164
165 ld t0,8(a1)
166 dmultu t0,a3
167 ld t1,8(a0)
168 subu a2,1
169 daddu t1,v0
170 sltu v0,t1,v0
171 mflo AT
172 mfhi t0
173 daddu t1,AT
174 daddu v0,t0
175 sltu AT,t1,AT
176 sd t1,8(a0)
177 daddu v0,AT
178 beqz a2,.L_bn_mul_add_words_return
179
180 ld t0,16(a1)
181 dmultu t0,a3
182 ld t1,16(a0)
183 daddu t1,v0
184 sltu v0,t1,v0
185 mflo AT
186 mfhi t0
187 daddu t1,AT
188 daddu v0,t0
189 sltu AT,t1,AT
190 sd t1,16(a0)
191 daddu v0,AT
192 jr ra
193END(bn_mul_add_words)
194
195.align 5
196LEAF(bn_mul_words)
197 .set noreorder
198 bgtzl a2,.L_bn_mul_words_proceed
199 ld t0,0(a1)
200 jr ra
201 move v0,zero
202 .set reorder
203
204.L_bn_mul_words_proceed:
205 li MINUS4,-4
206 and ta0,a2,MINUS4
207 move v0,zero
208 beqz ta0,.L_bn_mul_words_tail
209
210.L_bn_mul_words_loop:
211 dmultu t0,a3
212 ld t2,8(a1)
213 ld ta0,16(a1)
214 ld ta2,24(a1)
215 mflo AT
216 mfhi t0
217 daddu v0,AT
218 sltu t1,v0,AT
219 sd v0,0(a0)
220 daddu v0,t1,t0
221
222 dmultu t2,a3
223 subu a2,4
224 PTR_ADD a0,32
225 PTR_ADD a1,32
226 mflo AT
227 mfhi t2
228 daddu v0,AT
229 sltu t3,v0,AT
230 sd v0,-24(a0)
231 daddu v0,t3,t2
232
233 dmultu ta0,a3
234 mflo AT
235 mfhi ta0
236 daddu v0,AT
237 sltu ta1,v0,AT
238 sd v0,-16(a0)
239 daddu v0,ta1,ta0
240
241
242 dmultu ta2,a3
243 and ta0,a2,MINUS4
244 mflo AT
245 mfhi ta2
246 daddu v0,AT
247 sltu ta3,v0,AT
248 sd v0,-8(a0)
249 daddu v0,ta3,ta2
250 .set noreorder
251 bgtzl ta0,.L_bn_mul_words_loop
252 ld t0,0(a1)
253
254 bnezl a2,.L_bn_mul_words_tail
255 ld t0,0(a1)
256 .set reorder
257
258.L_bn_mul_words_return:
259 jr ra
260
261.L_bn_mul_words_tail:
262 dmultu t0,a3
263 subu a2,1
264 mflo AT
265 mfhi t0
266 daddu v0,AT
267 sltu t1,v0,AT
268 sd v0,0(a0)
269 daddu v0,t1,t0
270 beqz a2,.L_bn_mul_words_return
271
272 ld t0,8(a1)
273 dmultu t0,a3
274 subu a2,1
275 mflo AT
276 mfhi t0
277 daddu v0,AT
278 sltu t1,v0,AT
279 sd v0,8(a0)
280 daddu v0,t1,t0
281 beqz a2,.L_bn_mul_words_return
282
283 ld t0,16(a1)
284 dmultu t0,a3
285 mflo AT
286 mfhi t0
287 daddu v0,AT
288 sltu t1,v0,AT
289 sd v0,16(a0)
290 daddu v0,t1,t0
291 jr ra
292END(bn_mul_words)
293
294.align 5
295LEAF(bn_sqr_words)
296 .set noreorder
297 bgtzl a2,.L_bn_sqr_words_proceed
298 ld t0,0(a1)
299 jr ra
300 move v0,zero
301 .set reorder
302
303.L_bn_sqr_words_proceed:
304 li MINUS4,-4
305 and ta0,a2,MINUS4
306 move v0,zero
307 beqz ta0,.L_bn_sqr_words_tail
308
309.L_bn_sqr_words_loop:
310 dmultu t0,t0
311 ld t2,8(a1)
312 ld ta0,16(a1)
313 ld ta2,24(a1)
314 mflo t1
315 mfhi t0
316 sd t1,0(a0)
317 sd t0,8(a0)
318
319 dmultu t2,t2
320 subu a2,4
321 PTR_ADD a0,64
322 PTR_ADD a1,32
323 mflo t3
324 mfhi t2
325 sd t3,-48(a0)
326 sd t2,-40(a0)
327
328 dmultu ta0,ta0
329 mflo ta1
330 mfhi ta0
331 sd ta1,-32(a0)
332 sd ta0,-24(a0)
333
334
335 dmultu ta2,ta2
336 and ta0,a2,MINUS4
337 mflo ta3
338 mfhi ta2
339 sd ta3,-16(a0)
340 sd ta2,-8(a0)
341
342 .set noreorder
343 bgtzl ta0,.L_bn_sqr_words_loop
344 ld t0,0(a1)
345
346 bnezl a2,.L_bn_sqr_words_tail
347 ld t0,0(a1)
348 .set reorder
349
350.L_bn_sqr_words_return:
351 move v0,zero
352 jr ra
353
354.L_bn_sqr_words_tail:
355 dmultu t0,t0
356 subu a2,1
357 mflo t1
358 mfhi t0
359 sd t1,0(a0)
360 sd t0,8(a0)
361 beqz a2,.L_bn_sqr_words_return
362
363 ld t0,8(a1)
364 dmultu t0,t0
365 subu a2,1
366 mflo t1
367 mfhi t0
368 sd t1,16(a0)
369 sd t0,24(a0)
370 beqz a2,.L_bn_sqr_words_return
371
372 ld t0,16(a1)
373 dmultu t0,t0
374 mflo t1
375 mfhi t0
376 sd t1,32(a0)
377 sd t0,40(a0)
378 jr ra
379END(bn_sqr_words)
380
381.align 5
382LEAF(bn_add_words)
383 .set noreorder
384 bgtzl a3,.L_bn_add_words_proceed
385 ld t0,0(a1)
386 jr ra
387 move v0,zero
388 .set reorder
389
390.L_bn_add_words_proceed:
391 li MINUS4,-4
392 and AT,a3,MINUS4
393 move v0,zero
394 beqz AT,.L_bn_add_words_tail
395
396.L_bn_add_words_loop:
397 ld ta0,0(a2)
398 subu a3,4
399 ld t1,8(a1)
400 and AT,a3,MINUS4
401 ld t2,16(a1)
402 PTR_ADD a2,32
403 ld t3,24(a1)
404 PTR_ADD a0,32
405 ld ta1,-24(a2)
406 PTR_ADD a1,32
407 ld ta2,-16(a2)
408 ld ta3,-8(a2)
409 daddu ta0,t0
410 sltu t8,ta0,t0
411 daddu t0,ta0,v0
412 sltu v0,t0,ta0
413 sd t0,-32(a0)
414 daddu v0,t8
415
416 daddu ta1,t1
417 sltu t9,ta1,t1
418 daddu t1,ta1,v0
419 sltu v0,t1,ta1
420 sd t1,-24(a0)
421 daddu v0,t9
422
423 daddu ta2,t2
424 sltu t8,ta2,t2
425 daddu t2,ta2,v0
426 sltu v0,t2,ta2
427 sd t2,-16(a0)
428 daddu v0,t8
429
430 daddu ta3,t3
431 sltu t9,ta3,t3
432 daddu t3,ta3,v0
433 sltu v0,t3,ta3
434 sd t3,-8(a0)
435 daddu v0,t9
436
437 .set noreorder
438 bgtzl AT,.L_bn_add_words_loop
439 ld t0,0(a1)
440
441 bnezl a3,.L_bn_add_words_tail
442 ld t0,0(a1)
443 .set reorder
444
445.L_bn_add_words_return:
446 jr ra
447
448.L_bn_add_words_tail:
449 ld ta0,0(a2)
450 daddu ta0,t0
451 subu a3,1
452 sltu t8,ta0,t0
453 daddu t0,ta0,v0
454 sltu v0,t0,ta0
455 sd t0,0(a0)
456 daddu v0,t8
457 beqz a3,.L_bn_add_words_return
458
459 ld t1,8(a1)
460 ld ta1,8(a2)
461 daddu ta1,t1
462 subu a3,1
463 sltu t9,ta1,t1
464 daddu t1,ta1,v0
465 sltu v0,t1,ta1
466 sd t1,8(a0)
467 daddu v0,t9
468 beqz a3,.L_bn_add_words_return
469
470 ld t2,16(a1)
471 ld ta2,16(a2)
472 daddu ta2,t2
473 sltu t8,ta2,t2
474 daddu t2,ta2,v0
475 sltu v0,t2,ta2
476 sd t2,16(a0)
477 daddu v0,t8
478 jr ra
479END(bn_add_words)
480
481.align 5
482LEAF(bn_sub_words)
483 .set noreorder
484 bgtzl a3,.L_bn_sub_words_proceed
485 ld t0,0(a1)
486 jr ra
487 move v0,zero
488 .set reorder
489
490.L_bn_sub_words_proceed:
491 li MINUS4,-4
492 and AT,a3,MINUS4
493 move v0,zero
494 beqz AT,.L_bn_sub_words_tail
495
496.L_bn_sub_words_loop:
497 ld ta0,0(a2)
498 subu a3,4
499 ld t1,8(a1)
500 and AT,a3,MINUS4
501 ld t2,16(a1)
502 PTR_ADD a2,32
503 ld t3,24(a1)
504 PTR_ADD a0,32
505 ld ta1,-24(a2)
506 PTR_ADD a1,32
507 ld ta2,-16(a2)
508 ld ta3,-8(a2)
509 sltu t8,t0,ta0
510 dsubu t0,ta0
511 dsubu ta0,t0,v0
512 sd ta0,-32(a0)
513 MOVNZ (t0,v0,t8)
514
515 sltu t9,t1,ta1
516 dsubu t1,ta1
517 dsubu ta1,t1,v0
518 sd ta1,-24(a0)
519 MOVNZ (t1,v0,t9)
520
521
522 sltu t8,t2,ta2
523 dsubu t2,ta2
524 dsubu ta2,t2,v0
525 sd ta2,-16(a0)
526 MOVNZ (t2,v0,t8)
527
528 sltu t9,t3,ta3
529 dsubu t3,ta3
530 dsubu ta3,t3,v0
531 sd ta3,-8(a0)
532 MOVNZ (t3,v0,t9)
533
534 .set noreorder
535 bgtzl AT,.L_bn_sub_words_loop
536 ld t0,0(a1)
537
538 bnezl a3,.L_bn_sub_words_tail
539 ld t0,0(a1)
540 .set reorder
541
542.L_bn_sub_words_return:
543 jr ra
544
545.L_bn_sub_words_tail:
546 ld ta0,0(a2)
547 subu a3,1
548 sltu t8,t0,ta0
549 dsubu t0,ta0
550 dsubu ta0,t0,v0
551 MOVNZ (t0,v0,t8)
552 sd ta0,0(a0)
553 beqz a3,.L_bn_sub_words_return
554
555 ld t1,8(a1)
556 subu a3,1
557 ld ta1,8(a2)
558 sltu t9,t1,ta1
559 dsubu t1,ta1
560 dsubu ta1,t1,v0
561 MOVNZ (t1,v0,t9)
562 sd ta1,8(a0)
563 beqz a3,.L_bn_sub_words_return
564
565 ld t2,16(a1)
566 ld ta2,16(a2)
567 sltu t8,t2,ta2
568 dsubu t2,ta2
569 dsubu ta2,t2,v0
570 MOVNZ (t2,v0,t8)
571 sd ta2,16(a0)
572 jr ra
573END(bn_sub_words)
574
575#undef MINUS4
576
577.align 5
578LEAF(bn_div_3_words)
579 .set reorder
580 move a3,a0 /* we know that bn_div_words doesn't
581 * touch a3, ta2, ta3 and preserves a2
582 * so that we can save two arguments
583 * and return address in registers
584 * instead of stack:-)
585 */
586 ld a0,(a3)
587 move ta2,a1
588 ld a1,-8(a3)
589 bne a0,a2,.L_bn_div_3_words_proceed
590 li v0,-1
591 jr ra
592.L_bn_div_3_words_proceed:
593 move ta3,ra
594 bal bn_div_words
595 move ra,ta3
596 dmultu ta2,v0
597 ld t2,-16(a3)
598 move ta0,zero
599 mfhi t1
600 mflo t0
601 sltu t8,t1,v1
602.L_bn_div_3_words_inner_loop:
603 bnez t8,.L_bn_div_3_words_inner_loop_done
604 sgeu AT,t2,t0
605 seq t9,t1,v1
606 and AT,t9
607 sltu t3,t0,ta2
608 daddu v1,a2
609 dsubu t1,t3
610 dsubu t0,ta2
611 sltu t8,t1,v1
612 sltu ta0,v1,a2
613 or t8,ta0
614 .set noreorder
615 beqzl AT,.L_bn_div_3_words_inner_loop
616 dsubu v0,1
617 .set reorder
618.L_bn_div_3_words_inner_loop_done:
619 jr ra
620END(bn_div_3_words)
621
622.align 5
623LEAF(bn_div_words)
624 .set noreorder
625 bnezl a2,.L_bn_div_words_proceed
626 move v1,zero
627 jr ra
628 li v0,-1 /* I'd rather signal div-by-zero
629 * which can be done with 'break 7' */
630
631.L_bn_div_words_proceed:
632 bltz a2,.L_bn_div_words_body
633 move t9,v1
634 dsll a2,1
635 bgtz a2,.-4
636 addu t9,1
637
638 .set reorder
639 negu t1,t9
640 li t2,-1
641 dsll t2,t1
642 and t2,a0
643 dsrl AT,a1,t1
644 .set noreorder
645 bnezl t2,.+8
646 break 6 /* signal overflow */
647 .set reorder
648 dsll a0,t9
649 dsll a1,t9
650 or a0,AT
651
652#define QT ta0
653#define HH ta1
654#define DH v1
655.L_bn_div_words_body:
656 dsrl DH,a2,32
657 sgeu AT,a0,a2
658 .set noreorder
659 bnezl AT,.+8
660 dsubu a0,a2
661 .set reorder
662
663 li QT,-1
664 dsrl HH,a0,32
665 dsrl QT,32 /* q=0xffffffff */
666 beq DH,HH,.L_bn_div_words_skip_div1
667 ddivu zero,a0,DH
668 mflo QT
669.L_bn_div_words_skip_div1:
670 dmultu a2,QT
671 dsll t3,a0,32
672 dsrl AT,a1,32
673 or t3,AT
674 mflo t0
675 mfhi t1
676.L_bn_div_words_inner_loop1:
677 sltu t2,t3,t0
678 seq t8,HH,t1
679 sltu AT,HH,t1
680 and t2,t8
681 sltu v0,t0,a2
682 or AT,t2
683 .set noreorder
684 beqz AT,.L_bn_div_words_inner_loop1_done
685 dsubu t1,v0
686 dsubu t0,a2
687 b .L_bn_div_words_inner_loop1
688 dsubu QT,1
689 .set reorder
690.L_bn_div_words_inner_loop1_done:
691
692 dsll a1,32
693 dsubu a0,t3,t0
694 dsll v0,QT,32
695
696 li QT,-1
697 dsrl HH,a0,32
698 dsrl QT,32 /* q=0xffffffff */
699 beq DH,HH,.L_bn_div_words_skip_div2
700 ddivu zero,a0,DH
701 mflo QT
702.L_bn_div_words_skip_div2:
703#undef DH
704 dmultu a2,QT
705 dsll t3,a0,32
706 dsrl AT,a1,32
707 or t3,AT
708 mflo t0
709 mfhi t1
710.L_bn_div_words_inner_loop2:
711 sltu t2,t3,t0
712 seq t8,HH,t1
713 sltu AT,HH,t1
714 and t2,t8
715 sltu v1,t0,a2
716 or AT,t2
717 .set noreorder
718 beqz AT,.L_bn_div_words_inner_loop2_done
719 dsubu t1,v1
720 dsubu t0,a2
721 b .L_bn_div_words_inner_loop2
722 dsubu QT,1
723 .set reorder
724.L_bn_div_words_inner_loop2_done:
725#undef HH
726
727 dsubu a0,t3,t0
728 or v0,QT
729 dsrl v1,a0,t9 /* v1 contains remainder if anybody wants it */
730 dsrl a2,t9 /* restore a2 */
731 jr ra
732#undef QT
733END(bn_div_words)
734
735#define a_0 t0
736#define a_1 t1
737#define a_2 t2
738#define a_3 t3
739#define b_0 ta0
740#define b_1 ta1
741#define b_2 ta2
742#define b_3 ta3
743
744#define a_4 s0
745#define a_5 s2
746#define a_6 s4
747#define a_7 a1 /* once we load a[7] we don't need a anymore */
748#define b_4 s1
749#define b_5 s3
750#define b_6 s5
751#define b_7 a2 /* once we load b[7] we don't need b anymore */
752
753#define t_1 t8
754#define t_2 t9
755
756#define c_1 v0
757#define c_2 v1
758#define c_3 a3
759
760#define FRAME_SIZE 48
761
762.align 5
763LEAF(bn_mul_comba8)
764 .set noreorder
765 PTR_SUB sp,FRAME_SIZE
766 .frame sp,64,ra
767 .set reorder
768 ld a_0,0(a1) /* If compiled with -mips3 option on
769 * R5000 box assembler barks on this
770 * line with "shouldn't have mult/div
771 * as last instruction in bb (R10K
772 * bug)" warning. If anybody out there
773 * has a clue about how to circumvent
774 * this do send me a note.
775 * <appro@fy.chalmers.se>
776 */
777 ld b_0,0(a2)
778 ld a_1,8(a1)
779 ld a_2,16(a1)
780 ld a_3,24(a1)
781 ld b_1,8(a2)
782 ld b_2,16(a2)
783 ld b_3,24(a2)
784 dmultu a_0,b_0 /* mul_add_c(a[0],b[0],c1,c2,c3); */
785 sd s0,0(sp)
786 sd s1,8(sp)
787 sd s2,16(sp)
788 sd s3,24(sp)
789 sd s4,32(sp)
790 sd s5,40(sp)
791 mflo c_1
792 mfhi c_2
793
794 dmultu a_0,b_1 /* mul_add_c(a[0],b[1],c2,c3,c1); */
795 ld a_4,32(a1)
796 ld a_5,40(a1)
797 ld a_6,48(a1)
798 ld a_7,56(a1)
799 ld b_4,32(a2)
800 ld b_5,40(a2)
801 mflo t_1
802 mfhi t_2
803 daddu c_2,t_1
804 sltu AT,c_2,t_1
805 daddu c_3,t_2,AT
806 dmultu a_1,b_0 /* mul_add_c(a[1],b[0],c2,c3,c1); */
807 ld b_6,48(a2)
808 ld b_7,56(a2)
809 sd c_1,0(a0) /* r[0]=c1; */
810 mflo t_1
811 mfhi t_2
812 daddu c_2,t_1
813 sltu AT,c_2,t_1
814 daddu t_2,AT
815 daddu c_3,t_2
816 sltu c_1,c_3,t_2
817 sd c_2,8(a0) /* r[1]=c2; */
818
819 dmultu a_2,b_0 /* mul_add_c(a[2],b[0],c3,c1,c2); */
820 mflo t_1
821 mfhi t_2
822 daddu c_3,t_1
823 sltu AT,c_3,t_1
824 daddu t_2,AT
825 daddu c_1,t_2
826 dmultu a_1,b_1 /* mul_add_c(a[1],b[1],c3,c1,c2); */
827 mflo t_1
828 mfhi t_2
829 daddu c_3,t_1
830 sltu AT,c_3,t_1
831 daddu t_2,AT
832 daddu c_1,t_2
833 sltu c_2,c_1,t_2
834 dmultu a_0,b_2 /* mul_add_c(a[0],b[2],c3,c1,c2); */
835 mflo t_1
836 mfhi t_2
837 daddu c_3,t_1
838 sltu AT,c_3,t_1
839 daddu t_2,AT
840 daddu c_1,t_2
841 sltu AT,c_1,t_2
842 daddu c_2,AT
843 sd c_3,16(a0) /* r[2]=c3; */
844
845 dmultu a_0,b_3 /* mul_add_c(a[0],b[3],c1,c2,c3); */
846 mflo t_1
847 mfhi t_2
848 daddu c_1,t_1
849 sltu AT,c_1,t_1
850 daddu t_2,AT
851 daddu c_2,t_2
852 sltu c_3,c_2,t_2
853 dmultu a_1,b_2 /* mul_add_c(a[1],b[2],c1,c2,c3); */
854 mflo t_1
855 mfhi t_2
856 daddu c_1,t_1
857 sltu AT,c_1,t_1
858 daddu t_2,AT
859 daddu c_2,t_2
860 sltu AT,c_2,t_2
861 daddu c_3,AT
862 dmultu a_2,b_1 /* mul_add_c(a[2],b[1],c1,c2,c3); */
863 mflo t_1
864 mfhi t_2
865 daddu c_1,t_1
866 sltu AT,c_1,t_1
867 daddu t_2,AT
868 daddu c_2,t_2
869 sltu AT,c_2,t_2
870 daddu c_3,AT
871 dmultu a_3,b_0 /* mul_add_c(a[3],b[0],c1,c2,c3); */
872 mflo t_1
873 mfhi t_2
874 daddu c_1,t_1
875 sltu AT,c_1,t_1
876 daddu t_2,AT
877 daddu c_2,t_2
878 sltu AT,c_2,t_2
879 daddu c_3,AT
880 sd c_1,24(a0) /* r[3]=c1; */
881
882 dmultu a_4,b_0 /* mul_add_c(a[4],b[0],c2,c3,c1); */
883 mflo t_1
884 mfhi t_2
885 daddu c_2,t_1
886 sltu AT,c_2,t_1
887 daddu t_2,AT
888 daddu c_3,t_2
889 sltu c_1,c_3,t_2
890 dmultu a_3,b_1 /* mul_add_c(a[3],b[1],c2,c3,c1); */
891 mflo t_1
892 mfhi t_2
893 daddu c_2,t_1
894 sltu AT,c_2,t_1
895 daddu t_2,AT
896 daddu c_3,t_2
897 sltu AT,c_3,t_2
898 daddu c_1,AT
899 dmultu a_2,b_2 /* mul_add_c(a[2],b[2],c2,c3,c1); */
900 mflo t_1
901 mfhi t_2
902 daddu c_2,t_1
903 sltu AT,c_2,t_1
904 daddu t_2,AT
905 daddu c_3,t_2
906 sltu AT,c_3,t_2
907 daddu c_1,AT
908 dmultu a_1,b_3 /* mul_add_c(a[1],b[3],c2,c3,c1); */
909 mflo t_1
910 mfhi t_2
911 daddu c_2,t_1
912 sltu AT,c_2,t_1
913 daddu t_2,AT
914 daddu c_3,t_2
915 sltu AT,c_3,t_2
916 daddu c_1,AT
917 dmultu a_0,b_4 /* mul_add_c(a[0],b[4],c2,c3,c1); */
918 mflo t_1
919 mfhi t_2
920 daddu c_2,t_1
921 sltu AT,c_2,t_1
922 daddu t_2,AT
923 daddu c_3,t_2
924 sltu AT,c_3,t_2
925 daddu c_1,AT
926 sd c_2,32(a0) /* r[4]=c2; */
927
928 dmultu a_0,b_5 /* mul_add_c(a[0],b[5],c3,c1,c2); */
929 mflo t_1
930 mfhi t_2
931 daddu c_3,t_1
932 sltu AT,c_3,t_1
933 daddu t_2,AT
934 daddu c_1,t_2
935 sltu c_2,c_1,t_2
936 dmultu a_1,b_4 /* mul_add_c(a[1],b[4],c3,c1,c2); */
937 mflo t_1
938 mfhi t_2
939 daddu c_3,t_1
940 sltu AT,c_3,t_1
941 daddu t_2,AT
942 daddu c_1,t_2
943 sltu AT,c_1,t_2
944 daddu c_2,AT
945 dmultu a_2,b_3 /* mul_add_c(a[2],b[3],c3,c1,c2); */
946 mflo t_1
947 mfhi t_2
948 daddu c_3,t_1
949 sltu AT,c_3,t_1
950 daddu t_2,AT
951 daddu c_1,t_2
952 sltu AT,c_1,t_2
953 daddu c_2,AT
954 dmultu a_3,b_2 /* mul_add_c(a[3],b[2],c3,c1,c2); */
955 mflo t_1
956 mfhi t_2
957 daddu c_3,t_1
958 sltu AT,c_3,t_1
959 daddu t_2,AT
960 daddu c_1,t_2
961 sltu AT,c_1,t_2
962 daddu c_2,AT
963 dmultu a_4,b_1 /* mul_add_c(a[4],b[1],c3,c1,c2); */
964 mflo t_1
965 mfhi t_2
966 daddu c_3,t_1
967 sltu AT,c_3,t_1
968 daddu t_2,AT
969 daddu c_1,t_2
970 sltu AT,c_1,t_2
971 daddu c_2,AT
972 dmultu a_5,b_0 /* mul_add_c(a[5],b[0],c3,c1,c2); */
973 mflo t_1
974 mfhi t_2
975 daddu c_3,t_1
976 sltu AT,c_3,t_1
977 daddu t_2,AT
978 daddu c_1,t_2
979 sltu AT,c_1,t_2
980 daddu c_2,AT
981 sd c_3,40(a0) /* r[5]=c3; */
982
983 dmultu a_6,b_0 /* mul_add_c(a[6],b[0],c1,c2,c3); */
984 mflo t_1
985 mfhi t_2
986 daddu c_1,t_1
987 sltu AT,c_1,t_1
988 daddu t_2,AT
989 daddu c_2,t_2
990 sltu c_3,c_2,t_2
991 dmultu a_5,b_1 /* mul_add_c(a[5],b[1],c1,c2,c3); */
992 mflo t_1
993 mfhi t_2
994 daddu c_1,t_1
995 sltu AT,c_1,t_1
996 daddu t_2,AT
997 daddu c_2,t_2
998 sltu AT,c_2,t_2
999 daddu c_3,AT
1000 dmultu a_4,b_2 /* mul_add_c(a[4],b[2],c1,c2,c3); */
1001 mflo t_1
1002 mfhi t_2
1003 daddu c_1,t_1
1004 sltu AT,c_1,t_1
1005 daddu t_2,AT
1006 daddu c_2,t_2
1007 sltu AT,c_2,t_2
1008 daddu c_3,AT
1009 dmultu a_3,b_3 /* mul_add_c(a[3],b[3],c1,c2,c3); */
1010 mflo t_1
1011 mfhi t_2
1012 daddu c_1,t_1
1013 sltu AT,c_1,t_1
1014 daddu t_2,AT
1015 daddu c_2,t_2
1016 sltu AT,c_2,t_2
1017 daddu c_3,AT
1018 dmultu a_2,b_4 /* mul_add_c(a[2],b[4],c1,c2,c3); */
1019 mflo t_1
1020 mfhi t_2
1021 daddu c_1,t_1
1022 sltu AT,c_1,t_1
1023 daddu t_2,AT
1024 daddu c_2,t_2
1025 sltu AT,c_2,t_2
1026 daddu c_3,AT
1027 dmultu a_1,b_5 /* mul_add_c(a[1],b[5],c1,c2,c3); */
1028 mflo t_1
1029 mfhi t_2
1030 daddu c_1,t_1
1031 sltu AT,c_1,t_1
1032 daddu t_2,AT
1033 daddu c_2,t_2
1034 sltu AT,c_2,t_2
1035 daddu c_3,AT
1036 dmultu a_0,b_6 /* mul_add_c(a[0],b[6],c1,c2,c3); */
1037 mflo t_1
1038 mfhi t_2
1039 daddu c_1,t_1
1040 sltu AT,c_1,t_1
1041 daddu t_2,AT
1042 daddu c_2,t_2
1043 sltu AT,c_2,t_2
1044 daddu c_3,AT
1045 sd c_1,48(a0) /* r[6]=c1; */
1046
1047 dmultu a_0,b_7 /* mul_add_c(a[0],b[7],c2,c3,c1); */
1048 mflo t_1
1049 mfhi t_2
1050 daddu c_2,t_1
1051 sltu AT,c_2,t_1
1052 daddu t_2,AT
1053 daddu c_3,t_2
1054 sltu c_1,c_3,t_2
1055 dmultu a_1,b_6 /* mul_add_c(a[1],b[6],c2,c3,c1); */
1056 mflo t_1
1057 mfhi t_2
1058 daddu c_2,t_1
1059 sltu AT,c_2,t_1
1060 daddu t_2,AT
1061 daddu c_3,t_2
1062 sltu AT,c_3,t_2
1063 daddu c_1,AT
1064 dmultu a_2,b_5 /* mul_add_c(a[2],b[5],c2,c3,c1); */
1065 mflo t_1
1066 mfhi t_2
1067 daddu c_2,t_1
1068 sltu AT,c_2,t_1
1069 daddu t_2,AT
1070 daddu c_3,t_2
1071 sltu AT,c_3,t_2
1072 daddu c_1,AT
1073 dmultu a_3,b_4 /* mul_add_c(a[3],b[4],c2,c3,c1); */
1074 mflo t_1
1075 mfhi t_2
1076 daddu c_2,t_1
1077 sltu AT,c_2,t_1
1078 daddu t_2,AT
1079 daddu c_3,t_2
1080 sltu AT,c_3,t_2
1081 daddu c_1,AT
1082 dmultu a_4,b_3 /* mul_add_c(a[4],b[3],c2,c3,c1); */
1083 mflo t_1
1084 mfhi t_2
1085 daddu c_2,t_1
1086 sltu AT,c_2,t_1
1087 daddu t_2,AT
1088 daddu c_3,t_2
1089 sltu AT,c_3,t_2
1090 daddu c_1,AT
1091 dmultu a_5,b_2 /* mul_add_c(a[5],b[2],c2,c3,c1); */
1092 mflo t_1
1093 mfhi t_2
1094 daddu c_2,t_1
1095 sltu AT,c_2,t_1
1096 daddu t_2,AT
1097 daddu c_3,t_2
1098 sltu AT,c_3,t_2
1099 daddu c_1,AT
1100 dmultu a_6,b_1 /* mul_add_c(a[6],b[1],c2,c3,c1); */
1101 mflo t_1
1102 mfhi t_2
1103 daddu c_2,t_1
1104 sltu AT,c_2,t_1
1105 daddu t_2,AT
1106 daddu c_3,t_2
1107 sltu AT,c_3,t_2
1108 daddu c_1,AT
1109 dmultu a_7,b_0 /* mul_add_c(a[7],b[0],c2,c3,c1); */
1110 mflo t_1
1111 mfhi t_2
1112 daddu c_2,t_1
1113 sltu AT,c_2,t_1
1114 daddu t_2,AT
1115 daddu c_3,t_2
1116 sltu AT,c_3,t_2
1117 daddu c_1,AT
1118 sd c_2,56(a0) /* r[7]=c2; */
1119
1120 dmultu a_7,b_1 /* mul_add_c(a[7],b[1],c3,c1,c2); */
1121 mflo t_1
1122 mfhi t_2
1123 daddu c_3,t_1
1124 sltu AT,c_3,t_1
1125 daddu t_2,AT
1126 daddu c_1,t_2
1127 sltu c_2,c_1,t_2
1128 dmultu a_6,b_2 /* mul_add_c(a[6],b[2],c3,c1,c2); */
1129 mflo t_1
1130 mfhi t_2
1131 daddu c_3,t_1
1132 sltu AT,c_3,t_1
1133 daddu t_2,AT
1134 daddu c_1,t_2
1135 sltu AT,c_1,t_2
1136 daddu c_2,AT
1137 dmultu a_5,b_3 /* mul_add_c(a[5],b[3],c3,c1,c2); */
1138 mflo t_1
1139 mfhi t_2
1140 daddu c_3,t_1
1141 sltu AT,c_3,t_1
1142 daddu t_2,AT
1143 daddu c_1,t_2
1144 sltu AT,c_1,t_2
1145 daddu c_2,AT
1146 dmultu a_4,b_4 /* mul_add_c(a[4],b[4],c3,c1,c2); */
1147 mflo t_1
1148 mfhi t_2
1149 daddu c_3,t_1
1150 sltu AT,c_3,t_1
1151 daddu t_2,AT
1152 daddu c_1,t_2
1153 sltu AT,c_1,t_2
1154 daddu c_2,AT
1155 dmultu a_3,b_5 /* mul_add_c(a[3],b[5],c3,c1,c2); */
1156 mflo t_1
1157 mfhi t_2
1158 daddu c_3,t_1
1159 sltu AT,c_3,t_1
1160 daddu t_2,AT
1161 daddu c_1,t_2
1162 sltu AT,c_1,t_2
1163 daddu c_2,AT
1164 dmultu a_2,b_6 /* mul_add_c(a[2],b[6],c3,c1,c2); */
1165 mflo t_1
1166 mfhi t_2
1167 daddu c_3,t_1
1168 sltu AT,c_3,t_1
1169 daddu t_2,AT
1170 daddu c_1,t_2
1171 sltu AT,c_1,t_2
1172 daddu c_2,AT
1173 dmultu a_1,b_7 /* mul_add_c(a[1],b[7],c3,c1,c2); */
1174 mflo t_1
1175 mfhi t_2
1176 daddu c_3,t_1
1177 sltu AT,c_3,t_1
1178 daddu t_2,AT
1179 daddu c_1,t_2
1180 sltu AT,c_1,t_2
1181 daddu c_2,AT
1182 sd c_3,64(a0) /* r[8]=c3; */
1183
1184 dmultu a_2,b_7 /* mul_add_c(a[2],b[7],c1,c2,c3); */
1185 mflo t_1
1186 mfhi t_2
1187 daddu c_1,t_1
1188 sltu AT,c_1,t_1
1189 daddu t_2,AT
1190 daddu c_2,t_2
1191 sltu c_3,c_2,t_2
1192 dmultu a_3,b_6 /* mul_add_c(a[3],b[6],c1,c2,c3); */
1193 mflo t_1
1194 mfhi t_2
1195 daddu c_1,t_1
1196 sltu AT,c_1,t_1
1197 daddu t_2,AT
1198 daddu c_2,t_2
1199 sltu AT,c_2,t_2
1200 daddu c_3,AT
1201 dmultu a_4,b_5 /* mul_add_c(a[4],b[5],c1,c2,c3); */
1202 mflo t_1
1203 mfhi t_2
1204 daddu c_1,t_1
1205 sltu AT,c_1,t_1
1206 daddu t_2,AT
1207 daddu c_2,t_2
1208 sltu AT,c_2,t_2
1209 daddu c_3,AT
1210 dmultu a_5,b_4 /* mul_add_c(a[5],b[4],c1,c2,c3); */
1211 mflo t_1
1212 mfhi t_2
1213 daddu c_1,t_1
1214 sltu AT,c_1,t_1
1215 daddu t_2,AT
1216 daddu c_2,t_2
1217 sltu AT,c_2,t_2
1218 daddu c_3,AT
1219 dmultu a_6,b_3 /* mul_add_c(a[6],b[3],c1,c2,c3); */
1220 mflo t_1
1221 mfhi t_2
1222 daddu c_1,t_1
1223 sltu AT,c_1,t_1
1224 daddu t_2,AT
1225 daddu c_2,t_2
1226 sltu AT,c_2,t_2
1227 daddu c_3,AT
1228 dmultu a_7,b_2 /* mul_add_c(a[7],b[2],c1,c2,c3); */
1229 mflo t_1
1230 mfhi t_2
1231 daddu c_1,t_1
1232 sltu AT,c_1,t_1
1233 daddu t_2,AT
1234 daddu c_2,t_2
1235 sltu AT,c_2,t_2
1236 daddu c_3,AT
1237 sd c_1,72(a0) /* r[9]=c1; */
1238
1239 dmultu a_7,b_3 /* mul_add_c(a[7],b[3],c2,c3,c1); */
1240 mflo t_1
1241 mfhi t_2
1242 daddu c_2,t_1
1243 sltu AT,c_2,t_1
1244 daddu t_2,AT
1245 daddu c_3,t_2
1246 sltu c_1,c_3,t_2
1247 dmultu a_6,b_4 /* mul_add_c(a[6],b[4],c2,c3,c1); */
1248 mflo t_1
1249 mfhi t_2
1250 daddu c_2,t_1
1251 sltu AT,c_2,t_1
1252 daddu t_2,AT
1253 daddu c_3,t_2
1254 sltu AT,c_3,t_2
1255 daddu c_1,AT
1256 dmultu a_5,b_5 /* mul_add_c(a[5],b[5],c2,c3,c1); */
1257 mflo t_1
1258 mfhi t_2
1259 daddu c_2,t_1
1260 sltu AT,c_2,t_1
1261 daddu t_2,AT
1262 daddu c_3,t_2
1263 sltu AT,c_3,t_2
1264 daddu c_1,AT
1265 dmultu a_4,b_6 /* mul_add_c(a[4],b[6],c2,c3,c1); */
1266 mflo t_1
1267 mfhi t_2
1268 daddu c_2,t_1
1269 sltu AT,c_2,t_1
1270 daddu t_2,AT
1271 daddu c_3,t_2
1272 sltu AT,c_3,t_2
1273 daddu c_1,AT
1274 dmultu a_3,b_7 /* mul_add_c(a[3],b[7],c2,c3,c1); */
1275 mflo t_1
1276 mfhi t_2
1277 daddu c_2,t_1
1278 sltu AT,c_2,t_1
1279 daddu t_2,AT
1280 daddu c_3,t_2
1281 sltu AT,c_3,t_2
1282 daddu c_1,AT
1283 sd c_2,80(a0) /* r[10]=c2; */
1284
1285 dmultu a_4,b_7 /* mul_add_c(a[4],b[7],c3,c1,c2); */
1286 mflo t_1
1287 mfhi t_2
1288 daddu c_3,t_1
1289 sltu AT,c_3,t_1
1290 daddu t_2,AT
1291 daddu c_1,t_2
1292 sltu c_2,c_1,t_2
1293 dmultu a_5,b_6 /* mul_add_c(a[5],b[6],c3,c1,c2); */
1294 mflo t_1
1295 mfhi t_2
1296 daddu c_3,t_1
1297 sltu AT,c_3,t_1
1298 daddu t_2,AT
1299 daddu c_1,t_2
1300 sltu AT,c_1,t_2
1301 daddu c_2,AT
1302 dmultu a_6,b_5 /* mul_add_c(a[6],b[5],c3,c1,c2); */
1303 mflo t_1
1304 mfhi t_2
1305 daddu c_3,t_1
1306 sltu AT,c_3,t_1
1307 daddu t_2,AT
1308 daddu c_1,t_2
1309 sltu AT,c_1,t_2
1310 daddu c_2,AT
1311 dmultu a_7,b_4 /* mul_add_c(a[7],b[4],c3,c1,c2); */
1312 mflo t_1
1313 mfhi t_2
1314 daddu c_3,t_1
1315 sltu AT,c_3,t_1
1316 daddu t_2,AT
1317 daddu c_1,t_2
1318 sltu AT,c_1,t_2
1319 daddu c_2,AT
1320 sd c_3,88(a0) /* r[11]=c3; */
1321
1322 dmultu a_7,b_5 /* mul_add_c(a[7],b[5],c1,c2,c3); */
1323 mflo t_1
1324 mfhi t_2
1325 daddu c_1,t_1
1326 sltu AT,c_1,t_1
1327 daddu t_2,AT
1328 daddu c_2,t_2
1329 sltu c_3,c_2,t_2
1330 dmultu a_6,b_6 /* mul_add_c(a[6],b[6],c1,c2,c3); */
1331 mflo t_1
1332 mfhi t_2
1333 daddu c_1,t_1
1334 sltu AT,c_1,t_1
1335 daddu t_2,AT
1336 daddu c_2,t_2
1337 sltu AT,c_2,t_2
1338 daddu c_3,AT
1339 dmultu a_5,b_7 /* mul_add_c(a[5],b[7],c1,c2,c3); */
1340 mflo t_1
1341 mfhi t_2
1342 daddu c_1,t_1
1343 sltu AT,c_1,t_1
1344 daddu t_2,AT
1345 daddu c_2,t_2
1346 sltu AT,c_2,t_2
1347 daddu c_3,AT
1348 sd c_1,96(a0) /* r[12]=c1; */
1349
1350 dmultu a_6,b_7 /* mul_add_c(a[6],b[7],c2,c3,c1); */
1351 mflo t_1
1352 mfhi t_2
1353 daddu c_2,t_1
1354 sltu AT,c_2,t_1
1355 daddu t_2,AT
1356 daddu c_3,t_2
1357 sltu c_1,c_3,t_2
1358 dmultu a_7,b_6 /* mul_add_c(a[7],b[6],c2,c3,c1); */
1359 mflo t_1
1360 mfhi t_2
1361 daddu c_2,t_1
1362 sltu AT,c_2,t_1
1363 daddu t_2,AT
1364 daddu c_3,t_2
1365 sltu AT,c_3,t_2
1366 daddu c_1,AT
1367 sd c_2,104(a0) /* r[13]=c2; */
1368
1369 dmultu a_7,b_7 /* mul_add_c(a[7],b[7],c3,c1,c2); */
1370 ld s0,0(sp)
1371 ld s1,8(sp)
1372 ld s2,16(sp)
1373 ld s3,24(sp)
1374 ld s4,32(sp)
1375 ld s5,40(sp)
1376 mflo t_1
1377 mfhi t_2
1378 daddu c_3,t_1
1379 sltu AT,c_3,t_1
1380 daddu t_2,AT
1381 daddu c_1,t_2
1382 sd c_3,112(a0) /* r[14]=c3; */
1383 sd c_1,120(a0) /* r[15]=c1; */
1384
1385 PTR_ADD sp,FRAME_SIZE
1386
1387 jr ra
1388END(bn_mul_comba8)
1389
1390.align 5
1391LEAF(bn_mul_comba4)
1392 .set reorder
1393 ld a_0,0(a1)
1394 ld b_0,0(a2)
1395 ld a_1,8(a1)
1396 ld a_2,16(a1)
1397 dmultu a_0,b_0 /* mul_add_c(a[0],b[0],c1,c2,c3); */
1398 ld a_3,24(a1)
1399 ld b_1,8(a2)
1400 ld b_2,16(a2)
1401 ld b_3,24(a2)
1402 mflo c_1
1403 mfhi c_2
1404 sd c_1,0(a0)
1405
1406 dmultu a_0,b_1 /* mul_add_c(a[0],b[1],c2,c3,c1); */
1407 mflo t_1
1408 mfhi t_2
1409 daddu c_2,t_1
1410 sltu AT,c_2,t_1
1411 daddu c_3,t_2,AT
1412 dmultu a_1,b_0 /* mul_add_c(a[1],b[0],c2,c3,c1); */
1413 mflo t_1
1414 mfhi t_2
1415 daddu c_2,t_1
1416 sltu AT,c_2,t_1
1417 daddu t_2,AT
1418 daddu c_3,t_2
1419 sltu c_1,c_3,t_2
1420 sd c_2,8(a0)
1421
1422 dmultu a_2,b_0 /* mul_add_c(a[2],b[0],c3,c1,c2); */
1423 mflo t_1
1424 mfhi t_2
1425 daddu c_3,t_1
1426 sltu AT,c_3,t_1
1427 daddu t_2,AT
1428 daddu c_1,t_2
1429 dmultu a_1,b_1 /* mul_add_c(a[1],b[1],c3,c1,c2); */
1430 mflo t_1
1431 mfhi t_2
1432 daddu c_3,t_1
1433 sltu AT,c_3,t_1
1434 daddu t_2,AT
1435 daddu c_1,t_2
1436 sltu c_2,c_1,t_2
1437 dmultu a_0,b_2 /* mul_add_c(a[0],b[2],c3,c1,c2); */
1438 mflo t_1
1439 mfhi t_2
1440 daddu c_3,t_1
1441 sltu AT,c_3,t_1
1442 daddu t_2,AT
1443 daddu c_1,t_2
1444 sltu AT,c_1,t_2
1445 daddu c_2,AT
1446 sd c_3,16(a0)
1447
1448 dmultu a_0,b_3 /* mul_add_c(a[0],b[3],c1,c2,c3); */
1449 mflo t_1
1450 mfhi t_2
1451 daddu c_1,t_1
1452 sltu AT,c_1,t_1
1453 daddu t_2,AT
1454 daddu c_2,t_2
1455 sltu c_3,c_2,t_2
1456 dmultu a_1,b_2 /* mul_add_c(a[1],b[2],c1,c2,c3); */
1457 mflo t_1
1458 mfhi t_2
1459 daddu c_1,t_1
1460 sltu AT,c_1,t_1
1461 daddu t_2,AT
1462 daddu c_2,t_2
1463 sltu AT,c_2,t_2
1464 daddu c_3,AT
1465 dmultu a_2,b_1 /* mul_add_c(a[2],b[1],c1,c2,c3); */
1466 mflo t_1
1467 mfhi t_2
1468 daddu c_1,t_1
1469 sltu AT,c_1,t_1
1470 daddu t_2,AT
1471 daddu c_2,t_2
1472 sltu AT,c_2,t_2
1473 daddu c_3,AT
1474 dmultu a_3,b_0 /* mul_add_c(a[3],b[0],c1,c2,c3); */
1475 mflo t_1
1476 mfhi t_2
1477 daddu c_1,t_1
1478 sltu AT,c_1,t_1
1479 daddu t_2,AT
1480 daddu c_2,t_2
1481 sltu AT,c_2,t_2
1482 daddu c_3,AT
1483 sd c_1,24(a0)
1484
1485 dmultu a_3,b_1 /* mul_add_c(a[3],b[1],c2,c3,c1); */
1486 mflo t_1
1487 mfhi t_2
1488 daddu c_2,t_1
1489 sltu AT,c_2,t_1
1490 daddu t_2,AT
1491 daddu c_3,t_2
1492 sltu c_1,c_3,t_2
1493 dmultu a_2,b_2 /* mul_add_c(a[2],b[2],c2,c3,c1); */
1494 mflo t_1
1495 mfhi t_2
1496 daddu c_2,t_1
1497 sltu AT,c_2,t_1
1498 daddu t_2,AT
1499 daddu c_3,t_2
1500 sltu AT,c_3,t_2
1501 daddu c_1,AT
1502 dmultu a_1,b_3 /* mul_add_c(a[1],b[3],c2,c3,c1); */
1503 mflo t_1
1504 mfhi t_2
1505 daddu c_2,t_1
1506 sltu AT,c_2,t_1
1507 daddu t_2,AT
1508 daddu c_3,t_2
1509 sltu AT,c_3,t_2
1510 daddu c_1,AT
1511 sd c_2,32(a0)
1512
1513 dmultu a_2,b_3 /* mul_add_c(a[2],b[3],c3,c1,c2); */
1514 mflo t_1
1515 mfhi t_2
1516 daddu c_3,t_1
1517 sltu AT,c_3,t_1
1518 daddu t_2,AT
1519 daddu c_1,t_2
1520 sltu c_2,c_1,t_2
1521 dmultu a_3,b_2 /* mul_add_c(a[3],b[2],c3,c1,c2); */
1522 mflo t_1
1523 mfhi t_2
1524 daddu c_3,t_1
1525 sltu AT,c_3,t_1
1526 daddu t_2,AT
1527 daddu c_1,t_2
1528 sltu AT,c_1,t_2
1529 daddu c_2,AT
1530 sd c_3,40(a0)
1531
1532 dmultu a_3,b_3 /* mul_add_c(a[3],b[3],c1,c2,c3); */
1533 mflo t_1
1534 mfhi t_2
1535 daddu c_1,t_1
1536 sltu AT,c_1,t_1
1537 daddu t_2,AT
1538 daddu c_2,t_2
1539 sd c_1,48(a0)
1540 sd c_2,56(a0)
1541
1542 jr ra
1543END(bn_mul_comba4)
1544
1545#undef a_4
1546#undef a_5
1547#undef a_6
1548#undef a_7
1549#define a_4 b_0
1550#define a_5 b_1
1551#define a_6 b_2
1552#define a_7 b_3
1553
1554.align 5
1555LEAF(bn_sqr_comba8)
1556 .set reorder
1557 ld a_0,0(a1)
1558 ld a_1,8(a1)
1559 ld a_2,16(a1)
1560 ld a_3,24(a1)
1561
1562 dmultu a_0,a_0 /* mul_add_c(a[0],b[0],c1,c2,c3); */
1563 ld a_4,32(a1)
1564 ld a_5,40(a1)
1565 ld a_6,48(a1)
1566 ld a_7,56(a1)
1567 mflo c_1
1568 mfhi c_2
1569 sd c_1,0(a0)
1570
1571 dmultu a_0,a_1 /* mul_add_c2(a[0],b[1],c2,c3,c1); */
1572 mflo t_1
1573 mfhi t_2
1574 slt c_1,t_2,zero
1575 dsll t_2,1
1576 slt a2,t_1,zero
1577 daddu t_2,a2
1578 dsll t_1,1
1579 daddu c_2,t_1
1580 sltu AT,c_2,t_1
1581 daddu c_3,t_2,AT
1582 sd c_2,8(a0)
1583
1584 dmultu a_2,a_0 /* mul_add_c2(a[2],b[0],c3,c1,c2); */
1585 mflo t_1
1586 mfhi t_2
1587 slt c_2,t_2,zero
1588 dsll t_2,1
1589 slt a2,t_1,zero
1590 daddu t_2,a2
1591 dsll t_1,1
1592 daddu c_3,t_1
1593 sltu AT,c_3,t_1
1594 daddu t_2,AT
1595 daddu c_1,t_2
1596 sltu AT,c_1,t_2
1597 daddu c_2,AT
1598 dmultu a_1,a_1 /* mul_add_c(a[1],b[1],c3,c1,c2); */
1599 mflo t_1
1600 mfhi t_2
1601 daddu c_3,t_1
1602 sltu AT,c_3,t_1
1603 daddu t_2,AT
1604 daddu c_1,t_2
1605 sltu AT,c_1,t_2
1606 daddu c_2,AT
1607 sd c_3,16(a0)
1608
1609 dmultu a_0,a_3 /* mul_add_c2(a[0],b[3],c1,c2,c3); */
1610 mflo t_1
1611 mfhi t_2
1612 slt c_3,t_2,zero
1613 dsll t_2,1
1614 slt a2,t_1,zero
1615 daddu t_2,a2
1616 dsll t_1,1
1617 daddu c_1,t_1
1618 sltu AT,c_1,t_1
1619 daddu t_2,AT
1620 daddu c_2,t_2
1621 sltu AT,c_2,t_2
1622 daddu c_3,AT
1623 dmultu a_1,a_2 /* mul_add_c2(a[1],b[2],c1,c2,c3); */
1624 mflo t_1
1625 mfhi t_2
1626 slt AT,t_2,zero
1627 daddu c_3,AT
1628 dsll t_2,1
1629 slt a2,t_1,zero
1630 daddu t_2,a2
1631 dsll t_1,1
1632 daddu c_1,t_1
1633 sltu AT,c_1,t_1
1634 daddu t_2,AT
1635 daddu c_2,t_2
1636 sltu AT,c_2,t_2
1637 daddu c_3,AT
1638 sd c_1,24(a0)
1639
1640 dmultu a_4,a_0 /* mul_add_c2(a[4],b[0],c2,c3,c1); */
1641 mflo t_1
1642 mfhi t_2
1643 slt c_1,t_2,zero
1644 dsll t_2,1
1645 slt a2,t_1,zero
1646 daddu t_2,a2
1647 dsll t_1,1
1648 daddu c_2,t_1
1649 sltu AT,c_2,t_1
1650 daddu t_2,AT
1651 daddu c_3,t_2
1652 sltu AT,c_3,t_2
1653 daddu c_1,AT
1654 dmultu a_3,a_1 /* mul_add_c2(a[3],b[1],c2,c3,c1); */
1655 mflo t_1
1656 mfhi t_2
1657 slt AT,t_2,zero
1658 daddu c_1,AT
1659 dsll t_2,1
1660 slt a2,t_1,zero
1661 daddu t_2,a2
1662 dsll t_1,1
1663 daddu c_2,t_1
1664 sltu AT,c_2,t_1
1665 daddu t_2,AT
1666 daddu c_3,t_2
1667 sltu AT,c_3,t_2
1668 daddu c_1,AT
1669 dmultu a_2,a_2 /* mul_add_c(a[2],b[2],c2,c3,c1); */
1670 mflo t_1
1671 mfhi t_2
1672 daddu c_2,t_1
1673 sltu AT,c_2,t_1
1674 daddu t_2,AT
1675 daddu c_3,t_2
1676 sltu AT,c_3,t_2
1677 daddu c_1,AT
1678 sd c_2,32(a0)
1679
1680 dmultu a_0,a_5 /* mul_add_c2(a[0],b[5],c3,c1,c2); */
1681 mflo t_1
1682 mfhi t_2
1683 slt c_2,t_2,zero
1684 dsll t_2,1
1685 slt a2,t_1,zero
1686 daddu t_2,a2
1687 dsll t_1,1
1688 daddu c_3,t_1
1689 sltu AT,c_3,t_1
1690 daddu t_2,AT
1691 daddu c_1,t_2
1692 sltu AT,c_1,t_2
1693 daddu c_2,AT
1694 dmultu a_1,a_4 /* mul_add_c2(a[1],b[4],c3,c1,c2); */
1695 mflo t_1
1696 mfhi t_2
1697 slt AT,t_2,zero
1698 daddu c_2,AT
1699 dsll t_2,1
1700 slt a2,t_1,zero
1701 daddu t_2,a2
1702 dsll t_1,1
1703 daddu c_3,t_1
1704 sltu AT,c_3,t_1
1705 daddu t_2,AT
1706 daddu c_1,t_2
1707 sltu AT,c_1,t_2
1708 daddu c_2,AT
1709 dmultu a_2,a_3 /* mul_add_c2(a[2],b[3],c3,c1,c2); */
1710 mflo t_1
1711 mfhi t_2
1712 slt AT,t_2,zero
1713 daddu c_2,AT
1714 dsll t_2,1
1715 slt a2,t_1,zero
1716 daddu t_2,a2
1717 dsll t_1,1
1718 daddu c_3,t_1
1719 sltu AT,c_3,t_1
1720 daddu t_2,AT
1721 daddu c_1,t_2
1722 sltu AT,c_1,t_2
1723 daddu c_2,AT
1724 sd c_3,40(a0)
1725
1726 dmultu a_6,a_0 /* mul_add_c2(a[6],b[0],c1,c2,c3); */
1727 mflo t_1
1728 mfhi t_2
1729 slt c_3,t_2,zero
1730 dsll t_2,1
1731 slt a2,t_1,zero
1732 daddu t_2,a2
1733 dsll t_1,1
1734 daddu c_1,t_1
1735 sltu AT,c_1,t_1
1736 daddu t_2,AT
1737 daddu c_2,t_2
1738 sltu AT,c_2,t_2
1739 daddu c_3,AT
1740 dmultu a_5,a_1 /* mul_add_c2(a[5],b[1],c1,c2,c3); */
1741 mflo t_1
1742 mfhi t_2
1743 slt AT,t_2,zero
1744 daddu c_3,AT
1745 dsll t_2,1
1746 slt a2,t_1,zero
1747 daddu t_2,a2
1748 dsll t_1,1
1749 daddu c_1,t_1
1750 sltu AT,c_1,t_1
1751 daddu t_2,AT
1752 daddu c_2,t_2
1753 sltu AT,c_2,t_2
1754 daddu c_3,AT
1755 dmultu a_4,a_2 /* mul_add_c2(a[4],b[2],c1,c2,c3); */
1756 mflo t_1
1757 mfhi t_2
1758 slt AT,t_2,zero
1759 daddu c_3,AT
1760 dsll t_2,1
1761 slt a2,t_1,zero
1762 daddu t_2,a2
1763 dsll t_1,1
1764 daddu c_1,t_1
1765 sltu AT,c_1,t_1
1766 daddu t_2,AT
1767 daddu c_2,t_2
1768 sltu AT,c_2,t_2
1769 daddu c_3,AT
1770 dmultu a_3,a_3 /* mul_add_c(a[3],b[3],c1,c2,c3); */
1771 mflo t_1
1772 mfhi t_2
1773 daddu c_1,t_1
1774 sltu AT,c_1,t_1
1775 daddu t_2,AT
1776 daddu c_2,t_2
1777 sltu AT,c_2,t_2
1778 daddu c_3,AT
1779 sd c_1,48(a0)
1780
1781 dmultu a_0,a_7 /* mul_add_c2(a[0],b[7],c2,c3,c1); */
1782 mflo t_1
1783 mfhi t_2
1784 slt c_1,t_2,zero
1785 dsll t_2,1
1786 slt a2,t_1,zero
1787 daddu t_2,a2
1788 dsll t_1,1
1789 daddu c_2,t_1
1790 sltu AT,c_2,t_1
1791 daddu t_2,AT
1792 daddu c_3,t_2
1793 sltu AT,c_3,t_2
1794 daddu c_1,AT
1795 dmultu a_1,a_6 /* mul_add_c2(a[1],b[6],c2,c3,c1); */
1796 mflo t_1
1797 mfhi t_2
1798 slt AT,t_2,zero
1799 daddu c_1,AT
1800 dsll t_2,1
1801 slt a2,t_1,zero
1802 daddu t_2,a2
1803 dsll t_1,1
1804 daddu c_2,t_1
1805 sltu AT,c_2,t_1
1806 daddu t_2,AT
1807 daddu c_3,t_2
1808 sltu AT,c_3,t_2
1809 daddu c_1,AT
1810 dmultu a_2,a_5 /* mul_add_c2(a[2],b[5],c2,c3,c1); */
1811 mflo t_1
1812 mfhi t_2
1813 slt AT,t_2,zero
1814 daddu c_1,AT
1815 dsll t_2,1
1816 slt a2,t_1,zero
1817 daddu t_2,a2
1818 dsll t_1,1
1819 daddu c_2,t_1
1820 sltu AT,c_2,t_1
1821 daddu t_2,AT
1822 daddu c_3,t_2
1823 sltu AT,c_3,t_2
1824 daddu c_1,AT
1825 dmultu a_3,a_4 /* mul_add_c2(a[3],b[4],c2,c3,c1); */
1826 mflo t_1
1827 mfhi t_2
1828 slt AT,t_2,zero
1829 daddu c_1,AT
1830 dsll t_2,1
1831 slt a2,t_1,zero
1832 daddu t_2,a2
1833 dsll t_1,1
1834 daddu c_2,t_1
1835 sltu AT,c_2,t_1
1836 daddu t_2,AT
1837 daddu c_3,t_2
1838 sltu AT,c_3,t_2
1839 daddu c_1,AT
1840 sd c_2,56(a0)
1841
1842 dmultu a_7,a_1 /* mul_add_c2(a[7],b[1],c3,c1,c2); */
1843 mflo t_1
1844 mfhi t_2
1845 slt c_2,t_2,zero
1846 dsll t_2,1
1847 slt a2,t_1,zero
1848 daddu t_2,a2
1849 dsll t_1,1
1850 daddu c_3,t_1
1851 sltu AT,c_3,t_1
1852 daddu t_2,AT
1853 daddu c_1,t_2
1854 sltu AT,c_1,t_2
1855 daddu c_2,AT
1856 dmultu a_6,a_2 /* mul_add_c2(a[6],b[2],c3,c1,c2); */
1857 mflo t_1
1858 mfhi t_2
1859 slt AT,t_2,zero
1860 daddu c_2,AT
1861 dsll t_2,1
1862 slt a2,t_1,zero
1863 daddu t_2,a2
1864 dsll t_1,1
1865 daddu c_3,t_1
1866 sltu AT,c_3,t_1
1867 daddu t_2,AT
1868 daddu c_1,t_2
1869 sltu AT,c_1,t_2
1870 daddu c_2,AT
1871 dmultu a_5,a_3 /* mul_add_c2(a[5],b[3],c3,c1,c2); */
1872 mflo t_1
1873 mfhi t_2
1874 slt AT,t_2,zero
1875 daddu c_2,AT
1876 dsll t_2,1
1877 slt a2,t_1,zero
1878 daddu t_2,a2
1879 dsll t_1,1
1880 daddu c_3,t_1
1881 sltu AT,c_3,t_1
1882 daddu t_2,AT
1883 daddu c_1,t_2
1884 sltu AT,c_1,t_2
1885 daddu c_2,AT
1886 dmultu a_4,a_4 /* mul_add_c(a[4],b[4],c3,c1,c2); */
1887 mflo t_1
1888 mfhi t_2
1889 daddu c_3,t_1
1890 sltu AT,c_3,t_1
1891 daddu t_2,AT
1892 daddu c_1,t_2
1893 sltu AT,c_1,t_2
1894 daddu c_2,AT
1895 sd c_3,64(a0)
1896
1897 dmultu a_2,a_7 /* mul_add_c2(a[2],b[7],c1,c2,c3); */
1898 mflo t_1
1899 mfhi t_2
1900 slt c_3,t_2,zero
1901 dsll t_2,1
1902 slt a2,t_1,zero
1903 daddu t_2,a2
1904 dsll t_1,1
1905 daddu c_1,t_1
1906 sltu AT,c_1,t_1
1907 daddu t_2,AT
1908 daddu c_2,t_2
1909 sltu AT,c_2,t_2
1910 daddu c_3,AT
1911 dmultu a_3,a_6 /* mul_add_c2(a[3],b[6],c1,c2,c3); */
1912 mflo t_1
1913 mfhi t_2
1914 slt AT,t_2,zero
1915 daddu c_3,AT
1916 dsll t_2,1
1917 slt a2,t_1,zero
1918 daddu t_2,a2
1919 dsll t_1,1
1920 daddu c_1,t_1
1921 sltu AT,c_1,t_1
1922 daddu t_2,AT
1923 daddu c_2,t_2
1924 sltu AT,c_2,t_2
1925 daddu c_3,AT
1926 dmultu a_4,a_5 /* mul_add_c2(a[4],b[5],c1,c2,c3); */
1927 mflo t_1
1928 mfhi t_2
1929 slt AT,t_2,zero
1930 daddu c_3,AT
1931 dsll t_2,1
1932 slt a2,t_1,zero
1933 daddu t_2,a2
1934 dsll t_1,1
1935 daddu c_1,t_1
1936 sltu AT,c_1,t_1
1937 daddu t_2,AT
1938 daddu c_2,t_2
1939 sltu AT,c_2,t_2
1940 daddu c_3,AT
1941 sd c_1,72(a0)
1942
1943 dmultu a_7,a_3 /* mul_add_c2(a[7],b[3],c2,c3,c1); */
1944 mflo t_1
1945 mfhi t_2
1946 slt c_1,t_2,zero
1947 dsll t_2,1
1948 slt a2,t_1,zero
1949 daddu t_2,a2
1950 dsll t_1,1
1951 daddu c_2,t_1
1952 sltu AT,c_2,t_1
1953 daddu t_2,AT
1954 daddu c_3,t_2
1955 sltu AT,c_3,t_2
1956 daddu c_1,AT
1957 dmultu a_6,a_4 /* mul_add_c2(a[6],b[4],c2,c3,c1); */
1958 mflo t_1
1959 mfhi t_2
1960 slt AT,t_2,zero
1961 daddu c_1,AT
1962 dsll t_2,1
1963 slt a2,t_1,zero
1964 daddu t_2,a2
1965 dsll t_1,1
1966 daddu c_2,t_1
1967 sltu AT,c_2,t_1
1968 daddu t_2,AT
1969 daddu c_3,t_2
1970 sltu AT,c_3,t_2
1971 daddu c_1,AT
1972 dmultu a_5,a_5 /* mul_add_c(a[5],b[5],c2,c3,c1); */
1973 mflo t_1
1974 mfhi t_2
1975 daddu c_2,t_1
1976 sltu AT,c_2,t_1
1977 daddu t_2,AT
1978 daddu c_3,t_2
1979 sltu AT,c_3,t_2
1980 daddu c_1,AT
1981 sd c_2,80(a0)
1982
1983 dmultu a_4,a_7 /* mul_add_c2(a[4],b[7],c3,c1,c2); */
1984 mflo t_1
1985 mfhi t_2
1986 slt c_2,t_2,zero
1987 dsll t_2,1
1988 slt a2,t_1,zero
1989 daddu t_2,a2
1990 dsll t_1,1
1991 daddu c_3,t_1
1992 sltu AT,c_3,t_1
1993 daddu t_2,AT
1994 daddu c_1,t_2
1995 sltu AT,c_1,t_2
1996 daddu c_2,AT
1997 dmultu a_5,a_6 /* mul_add_c2(a[5],b[6],c3,c1,c2); */
1998 mflo t_1
1999 mfhi t_2
2000 slt AT,t_2,zero
2001 daddu c_2,AT
2002 dsll t_2,1
2003 slt a2,t_1,zero
2004 daddu t_2,a2
2005 dsll t_1,1
2006 daddu c_3,t_1
2007 sltu AT,c_3,t_1
2008 daddu t_2,AT
2009 daddu c_1,t_2
2010 sltu AT,c_1,t_2
2011 daddu c_2,AT
2012 sd c_3,88(a0)
2013
2014 dmultu a_7,a_5 /* mul_add_c2(a[7],b[5],c1,c2,c3); */
2015 mflo t_1
2016 mfhi t_2
2017 slt c_3,t_2,zero
2018 dsll t_2,1
2019 slt a2,t_1,zero
2020 daddu t_2,a2
2021 dsll t_1,1
2022 daddu c_1,t_1
2023 sltu AT,c_1,t_1
2024 daddu t_2,AT
2025 daddu c_2,t_2
2026 sltu AT,c_2,t_2
2027 daddu c_3,AT
2028 dmultu a_6,a_6 /* mul_add_c(a[6],b[6],c1,c2,c3); */
2029 mflo t_1
2030 mfhi t_2
2031 daddu c_1,t_1
2032 sltu AT,c_1,t_1
2033 daddu t_2,AT
2034 daddu c_2,t_2
2035 sltu AT,c_2,t_2
2036 daddu c_3,AT
2037 sd c_1,96(a0)
2038
2039 dmultu a_6,a_7 /* mul_add_c2(a[6],b[7],c2,c3,c1); */
2040 mflo t_1
2041 mfhi t_2
2042 slt c_1,t_2,zero
2043 dsll t_2,1
2044 slt a2,t_1,zero
2045 daddu t_2,a2
2046 dsll t_1,1
2047 daddu c_2,t_1
2048 sltu AT,c_2,t_1
2049 daddu t_2,AT
2050 daddu c_3,t_2
2051 sltu AT,c_3,t_2
2052 daddu c_1,AT
2053 sd c_2,104(a0)
2054
2055 dmultu a_7,a_7 /* mul_add_c(a[7],b[7],c3,c1,c2); */
2056 mflo t_1
2057 mfhi t_2
2058 daddu c_3,t_1
2059 sltu AT,c_3,t_1
2060 daddu t_2,AT
2061 daddu c_1,t_2
2062 sd c_3,112(a0)
2063 sd c_1,120(a0)
2064
2065 jr ra
2066END(bn_sqr_comba8)
2067
2068.align 5
2069LEAF(bn_sqr_comba4)
2070 .set reorder
2071 ld a_0,0(a1)
2072 ld a_1,8(a1)
2073 ld a_2,16(a1)
2074 ld a_3,24(a1)
2075 dmultu a_0,a_0 /* mul_add_c(a[0],b[0],c1,c2,c3); */
2076 mflo c_1
2077 mfhi c_2
2078 sd c_1,0(a0)
2079
2080 dmultu a_0,a_1 /* mul_add_c2(a[0],b[1],c2,c3,c1); */
2081 mflo t_1
2082 mfhi t_2
2083 slt c_1,t_2,zero
2084 dsll t_2,1
2085 slt a2,t_1,zero
2086 daddu t_2,a2
2087 dsll t_1,1
2088 daddu c_2,t_1
2089 sltu AT,c_2,t_1
2090 daddu c_3,t_2,AT
2091 sd c_2,8(a0)
2092
2093 dmultu a_2,a_0 /* mul_add_c2(a[2],b[0],c3,c1,c2); */
2094 mflo t_1
2095 mfhi t_2
2096 slt c_2,t_2,zero
2097 dsll t_2,1
2098 slt a2,t_1,zero
2099 daddu t_2,a2
2100 dsll t_1,1
2101 daddu c_3,t_1
2102 sltu AT,c_3,t_1
2103 daddu t_2,AT
2104 daddu c_1,t_2
2105 sltu AT,c_1,t_2
2106 daddu c_2,AT
2107 dmultu a_1,a_1 /* mul_add_c(a[1],b[1],c3,c1,c2); */
2108 mflo t_1
2109 mfhi t_2
2110 daddu c_3,t_1
2111 sltu AT,c_3,t_1
2112 daddu t_2,AT
2113 daddu c_1,t_2
2114 sltu AT,c_1,t_2
2115 daddu c_2,AT
2116 sd c_3,16(a0)
2117
2118 dmultu a_0,a_3 /* mul_add_c2(a[0],b[3],c1,c2,c3); */
2119 mflo t_1
2120 mfhi t_2
2121 slt c_3,t_2,zero
2122 dsll t_2,1
2123 slt a2,t_1,zero
2124 daddu t_2,a2
2125 dsll t_1,1
2126 daddu c_1,t_1
2127 sltu AT,c_1,t_1
2128 daddu t_2,AT
2129 daddu c_2,t_2
2130 sltu AT,c_2,t_2
2131 daddu c_3,AT
2132 dmultu a_1,a_2 /* mul_add_c(a2[1],b[2],c1,c2,c3); */
2133 mflo t_1
2134 mfhi t_2
2135 slt AT,t_2,zero
2136 daddu c_3,AT
2137 dsll t_2,1
2138 slt a2,t_1,zero
2139 daddu t_2,a2
2140 dsll t_1,1
2141 daddu c_1,t_1
2142 sltu AT,c_1,t_1
2143 daddu t_2,AT
2144 daddu c_2,t_2
2145 sltu AT,c_2,t_2
2146 daddu c_3,AT
2147 sd c_1,24(a0)
2148
2149 dmultu a_3,a_1 /* mul_add_c2(a[3],b[1],c2,c3,c1); */
2150 mflo t_1
2151 mfhi t_2
2152 slt c_1,t_2,zero
2153 dsll t_2,1
2154 slt a2,t_1,zero
2155 daddu t_2,a2
2156 dsll t_1,1
2157 daddu c_2,t_1
2158 sltu AT,c_2,t_1
2159 daddu t_2,AT
2160 daddu c_3,t_2
2161 sltu AT,c_3,t_2
2162 daddu c_1,AT
2163 dmultu a_2,a_2 /* mul_add_c(a[2],b[2],c2,c3,c1); */
2164 mflo t_1
2165 mfhi t_2
2166 daddu c_2,t_1
2167 sltu AT,c_2,t_1
2168 daddu t_2,AT
2169 daddu c_3,t_2
2170 sltu AT,c_3,t_2
2171 daddu c_1,AT
2172 sd c_2,32(a0)
2173
2174 dmultu a_2,a_3 /* mul_add_c2(a[2],b[3],c3,c1,c2); */
2175 mflo t_1
2176 mfhi t_2
2177 slt c_2,t_2,zero
2178 dsll t_2,1
2179 slt a2,t_1,zero
2180 daddu t_2,a2
2181 dsll t_1,1
2182 daddu c_3,t_1
2183 sltu AT,c_3,t_1
2184 daddu t_2,AT
2185 daddu c_1,t_2
2186 sltu AT,c_1,t_2
2187 daddu c_2,AT
2188 sd c_3,40(a0)
2189
2190 dmultu a_3,a_3 /* mul_add_c(a[3],b[3],c1,c2,c3); */
2191 mflo t_1
2192 mfhi t_2
2193 daddu c_1,t_1
2194 sltu AT,c_1,t_1
2195 daddu t_2,AT
2196 daddu c_2,t_2
2197 sd c_1,48(a0)
2198 sd c_2,56(a0)
2199
2200 jr ra
2201END(bn_sqr_comba4)
diff --git a/src/lib/libcrypto/bn/asm/pa-risc.s b/src/lib/libcrypto/bn/asm/pa-risc.s
new file mode 100644
index 0000000000..775130a191
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/pa-risc.s
@@ -0,0 +1,710 @@
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/pa-risc2.s b/src/lib/libcrypto/bn/asm/pa-risc2.s
index f3b16290eb..af9730d062 100644
--- a/src/lib/libcrypto/bn/asm/pa-risc2.s
+++ b/src/lib/libcrypto/bn/asm/pa-risc2.s
@@ -747,8 +747,8 @@ bn_div_words
747 .PROC 747 .PROC
748 .EXPORT bn_div_words,ENTRY,PRIV_LEV=3,ARGW0=GR,ARGW1=GR,ARGW2=GR,ARGW3=GR,RTNVAL=GR,LONG_RETURN 748 .EXPORT bn_div_words,ENTRY,PRIV_LEV=3,ARGW0=GR,ARGW1=GR,ARGW2=GR,ARGW3=GR,RTNVAL=GR,LONG_RETURN
749 .IMPORT BN_num_bits_word,CODE 749 .IMPORT BN_num_bits_word,CODE
750 ;--- not PIC .IMPORT __iob,DATA 750 .IMPORT __iob,DATA
751 ;--- not PIC .IMPORT fprintf,CODE 751 .IMPORT fprintf,CODE
752 .IMPORT abort,CODE 752 .IMPORT abort,CODE
753 .IMPORT $$div2U,MILLICODE 753 .IMPORT $$div2U,MILLICODE
754 .CALLINFO CALLER,FRAME=144,ENTRY_GR=%r9,SAVE_RP,ARGS_SAVED,ORDERING_AWARE 754 .CALLINFO CALLER,FRAME=144,ENTRY_GR=%r9,SAVE_RP,ARGS_SAVED,ORDERING_AWARE
@@ -844,12 +844,12 @@ $0006001A
844 MOVIB,TR 2,%r8,$0006001C ;offset 0xa18 844 MOVIB,TR 2,%r8,$0006001C ;offset 0xa18
845 EXTRD,U %r3,63,32,%r7 ;offset 0xa1c 845 EXTRD,U %r3,63,32,%r7 ;offset 0xa1c
846$D2 846$D2
847 ;--- not PIC ADDIL LR'__iob-$global$,%r27,%r1 ;offset 0xa20 847 ADDIL LR'__iob-$global$,%r27,%r1 ;offset 0xa20
848 ;--- not PIC LDIL LR'C$7,%r21 ;offset 0xa24 848 LDIL LR'C$7,%r21 ;offset 0xa24
849 ;--- not PIC LDO RR'__iob-$global$+32(%r1),%r26 ;offset 0xa28 849 LDO RR'__iob-$global$+32(%r1),%r26 ;offset 0xa28
850 ;--- not PIC .CALL ARGW0=GR,ARGW1=GR,ARGW2=GR,RTNVAL=GR ;in=24,25,26;out=28; 850 .CALL ARGW0=GR,ARGW1=GR,ARGW2=GR,RTNVAL=GR ;in=24,25,26;out=28;
851 ;--- not PIC B,L fprintf,%r2 ;offset 0xa2c 851 B,L fprintf,%r2 ;offset 0xa2c
852 ;--- not PIC LDO RR'C$7(%r21),%r25 ;offset 0xa30 852 LDO RR'C$7(%r21),%r25 ;offset 0xa30
853 .CALL ; 853 .CALL ;
854 B,L abort,%r2 ;offset 0xa34 854 B,L abort,%r2 ;offset 0xa34
855 NOP ;offset 0xa38 855 NOP ;offset 0xa38
@@ -1605,14 +1605,14 @@ bn_mul_comba4
1605 .PROCEND 1605 .PROCEND
1606 1606
1607 1607
1608;--- not PIC .SPACE $TEXT$ 1608 .SPACE $TEXT$
1609;--- not PIC .SUBSPA $CODE$ 1609 .SUBSPA $CODE$
1610;--- not PIC .SPACE $PRIVATE$,SORT=16 1610 .SPACE $PRIVATE$,SORT=16
1611;--- not PIC .IMPORT $global$,DATA 1611 .IMPORT $global$,DATA
1612;--- not PIC .SPACE $TEXT$ 1612 .SPACE $TEXT$
1613;--- not PIC .SUBSPA $CODE$ 1613 .SUBSPA $CODE$
1614;--- not PIC .SUBSPA $LIT$,ACCESS=0x2c 1614 .SUBSPA $LIT$,ACCESS=0x2c
1615;--- not PIC C$7 1615C$7
1616;--- not PIC .ALIGN 8 1616 .ALIGN 8
1617;--- not PIC .STRINGZ "Division would overflow (%d)\n" 1617 .STRINGZ "Division would overflow (%d)\n"
1618 .END 1618 .END
diff --git a/src/lib/libcrypto/bn/asm/r3000.s b/src/lib/libcrypto/bn/asm/r3000.s
new file mode 100644
index 0000000000..e95269afa3
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/r3000.s
@@ -0,0 +1,646 @@
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/vms.mar b/src/lib/libcrypto/bn/asm/vms.mar
new file mode 100644
index 0000000000..465f2774b6
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/vms.mar
@@ -0,0 +1,6412 @@
1 .title vax_bn_mul_add_word unsigned multiply & add, 32*32+32+32=>64
2;
3; w.j.m. 15-jan-1999
4;
5; it's magic ...
6;
7; ULONG bn_mul_add_words(ULONG r[],ULONG a[],int n,ULONG w) {
8; ULONG c = 0;
9; int i;
10; for(i = 0; i < n; i++) <c,r[i]> := r[i] + c + a[i] * w ;
11; return c;
12; }
13
14r=4 ;(AP)
15a=8 ;(AP)
16n=12 ;(AP) n by value (input)
17w=16 ;(AP) w by value (input)
18
19
20 .psect code,nowrt
21
22.entry bn_mul_add_words,^m<r2,r3,r4,r5,r6>
23
24 moval @r(ap),r2
25 moval @a(ap),r3
26 movl n(ap),r4 ; assumed >0 by C code
27 movl w(ap),r5
28 clrl r6 ; c
29
300$:
31 emul r5,(r3),(r2),r0 ; w, a[], r[] considered signed
32
33 ; fixup for "negative" r[]
34 tstl (r2)
35 bgeq 10$
36 incl r1
3710$:
38
39 ; add in c
40 addl2 r6,r0
41 adwc #0,r1
42
43 ; combined fixup for "negative" w, a[]
44 tstl r5
45 bgeq 20$
46 addl2 (r3),r1
4720$:
48 tstl (r3)
49 bgeq 30$
50 addl2 r5,r1
5130$:
52
53 movl r0,(r2)+ ; store lo result in r[] & advance
54 addl #4,r3 ; advance a[]
55 movl r1,r6 ; store hi result => c
56
57 sobgtr r4,0$
58
59 movl r6,r0 ; return c
60 ret
61
62 .title vax_bn_mul_word unsigned multiply & add, 32*32+32=>64
63;
64; w.j.m. 15-jan-1999
65;
66; it's magic ...
67;
68; ULONG bn_mul_words(ULONG r[],ULONG a[],int n,ULONG w) {
69; ULONG c = 0;
70; int i;
71; for(i = 0; i < num; i++) <c,r[i]> := a[i] * w + c ;
72; return(c);
73; }
74
75r=4 ;(AP)
76a=8 ;(AP)
77n=12 ;(AP) n by value (input)
78w=16 ;(AP) w by value (input)
79
80
81 .psect code,nowrt
82
83.entry bn_mul_words,^m<r2,r3,r4,r5,r6>
84
85 moval @r(ap),r2 ; r2 -> r[]
86 moval @a(ap),r3 ; r3 -> a[]
87 movl n(ap),r4 ; r4 = loop count (assumed >0 by C code)
88 movl w(ap),r5 ; r5 = w
89 clrl r6 ; r6 = c
90
910$:
92 ; <r1,r0> := w * a[] + c
93 emul r5,(r3),r6,r0 ; w, a[], c considered signed
94
95 ; fixup for "negative" c
96 tstl r6 ; c
97 bgeq 10$
98 incl r1
9910$:
100
101 ; combined fixup for "negative" w, a[]
102 tstl r5 ; w
103 bgeq 20$
104 addl2 (r3),r1 ; a[]
10520$:
106 tstl (r3) ; a[]
107 bgeq 30$
108 addl2 r5,r1 ; w
10930$:
110
111 movl r0,(r2)+ ; store lo result in r[] & advance
112 addl #4,r3 ; advance a[]
113 movl r1,r6 ; store hi result => c
114
115 sobgtr r4,0$
116
117 movl r6,r0 ; return c
118 ret
119
120 .title vax_bn_sqr_words unsigned square, 32*32=>64
121;
122; w.j.m. 15-jan-1999
123;
124; it's magic ...
125;
126; void bn_sqr_words(ULONG r[],ULONG a[],int n) {
127; int i;
128; for(i = 0; i < n; i++) <r[2*i+1],r[2*i]> := a[i] * a[i] ;
129; }
130
131r=4 ;(AP)
132a=8 ;(AP)
133n=12 ;(AP) n by value (input)
134
135
136 .psect code,nowrt
137
138.entry bn_sqr_words,^m<r2,r3,r4,r5>
139
140 moval @r(ap),r2 ; r2 -> r[]
141 moval @a(ap),r3 ; r3 -> a[]
142 movl n(ap),r4 ; r4 = n (assumed >0 by C code)
143
1440$:
145 movl (r3)+,r5 ; r5 = a[] & advance
146
147 ; <r1,r0> := a[] * a[]
148 emul r5,r5,#0,r0 ; a[] considered signed
149
150 ; fixup for "negative" a[]
151 tstl r5 ; a[]
152 bgeq 30$
153 addl2 r5,r1 ; a[]
154 addl2 r5,r1 ; a[]
15530$:
156
157 movl r0,(r2)+ ; store lo result in r[] & advance
158 movl r1,(r2)+ ; store hi result in r[] & advance
159
160 sobgtr r4,0$
161
162 movl #1,r0 ; return SS$_NORMAL
163 ret
164
165 .title vax_bn_div_words unsigned divide
166;
167; Richard Levitte 20-Nov-2000
168;
169; ULONG bn_div_words(ULONG h, ULONG l, ULONG d)
170; {
171; return ((ULONG)((((ULLONG)h)<<32)|l) / (ULLONG)d);
172; }
173;
174; Using EDIV would be very easy, if it didn't do signed calculations.
175; Therefore, som extra things have to happen around it. The way to
176; handle that is to shift all operands right one step (basically dividing
177; them by 2) and handle the different cases depending on what the lowest
178; bit of each operand was.
179;
180; To start with, let's define the following:
181;
182; a' = l & 1
183; a2 = <h,l> >> 1 # UNSIGNED shift!
184; b' = d & 1
185; b2 = d >> 1 # UNSIGNED shift!
186;
187; Now, use EDIV to calculate a quotient and a remainder:
188;
189; q'' = a2/b2
190; r'' = a2 - q''*b2
191;
192; If b' is 0, the quotient is already correct, we just need to adjust the
193; remainder:
194;
195; if (b' == 0)
196; {
197; r = 2*r'' + a'
198; q = q''
199; }
200;
201; If b' is 1, we need to do other adjustements. The first thought is the
202; following (note that r' will not always have the right value, but an
203; adjustement follows further down):
204;
205; if (b' == 1)
206; {
207; q' = q''
208; r' = a - q'*b
209;
210; However, one can note the folowing relationship:
211;
212; r'' = a2 - q''*b2
213; => 2*r'' = 2*a2 - 2*q''*b2
214; = { a = 2*a2 + a', b = 2*b2 + b' = 2*b2 + 1,
215; q' = q'' }
216; = a - a' - q'*(b - 1)
217; = a - q'*b - a' + q'
218; = r' - a' + q'
219; => r' = 2*r'' - q' + a'
220;
221; This enables us to use r'' instead of discarding and calculating another
222; modulo:
223;
224; if (b' == 1)
225; {
226; q' = q''
227; r' = (r'' << 1) - q' + a'
228;
229; Now, all we have to do is adjust r', because it might be < 0:
230;
231; while (r' < 0)
232; {
233; r' = r' + b
234; q' = q' - 1
235; }
236; }
237;
238; return q'
239
240h=4 ;(AP) h by value (input)
241l=8 ;(AP) l by value (input)
242d=12 ;(AP) d by value (input)
243
244;aprim=r5
245;a2=r6
246;a20=r6
247;a21=r7
248;bprim=r8
249;b2=r9
250;qprim=r10 ; initially used as q''
251;rprim=r11 ; initially used as r''
252
253
254 .psect code,nowrt
255
256.entry bn_div_words,^m<r2,r3,r4,r5,r6,r7,r8,r9,r10,r11>
257 movl l(ap),r2
258 movl h(ap),r3
259 movl d(ap),r4
260
261 movl #0,r5
262 movl #0,r8
263 movl #0,r0
264; movl #0,r1
265
266 rotl #-1,r2,r6 ; a20 = l >> 1 (almost)
267 rotl #-1,r3,r7 ; a21 = h >> 1 (almost)
268 rotl #-1,r4,r9 ; b2 = d >> 1 (almost)
269
270 tstl r6
271 bgeq 1$
272 xorl2 #^X80000000,r6 ; fixup a20 so highest bit is 0
273 incl r5 ; a' = 1
2741$:
275 tstl r7
276 bgeq 2$
277 xorl2 #^X80000000,r6 ; fixup a20 so highest bit is 1,
278 ; since that's what was lowest in a21
279 xorl2 #^X80000000,r7 ; fixup a21 so highest bit is 1
2802$:
281 tstl r9
282 beql 666$ ; Uh-oh, the divisor is 0...
283 bgtr 3$
284 xorl2 #^X80000000,r9 ; fixup b2 so highest bit is 0
285 incl r8 ; b' = 1
2863$:
287 tstl r9
288 bneq 4$ ; if b2 is 0, we know that b' is 1
289 tstl r3
290 bneq 666$ ; if higher half isn't 0, we overflow
291 movl r2,r10 ; otherwise, we have our result
292 brb 42$ ; This is a success, really.
2934$:
294 ediv r9,r6,r10,r11
295
296 tstl r8
297 bneq 5$ ; If b' != 0, go to the other part
298; addl3 r11,r11,r1
299; addl2 r5,r1
300 brb 42$
3015$:
302 ashl #1,r11,r11
303 subl2 r10,r11
304 addl2 r5,r11
305 bgeq 7$
3066$:
307 decl r10
308 addl2 r4,r11
309 blss 6$
3107$:
311; movl r11,r1
31242$:
313 movl r10,r0
314666$:
315 ret
316
317 .title vax_bn_add_words unsigned add of two arrays
318;
319; Richard Levitte 20-Nov-2000
320;
321; ULONG bn_add_words(ULONG r[], ULONG a[], ULONG b[], int n) {
322; ULONG c = 0;
323; int i;
324; for (i = 0; i < n; i++) <c,r[i]> = a[i] + b[i] + c;
325; return(c);
326; }
327
328r=4 ;(AP) r by reference (output)
329a=8 ;(AP) a by reference (input)
330b=12 ;(AP) b by reference (input)
331n=16 ;(AP) n by value (input)
332
333
334 .psect code,nowrt
335
336.entry bn_add_words,^m<r2,r3,r4,r5,r6>
337
338 moval @r(ap),r2
339 moval @a(ap),r3
340 moval @b(ap),r4
341 movl n(ap),r5 ; assumed >0 by C code
342 clrl r0 ; c
343
344 tstl r5 ; carry = 0
345 bleq 666$
346
3470$:
348 movl (r3)+,r6 ; carry untouched
349 adwc (r4)+,r6 ; carry used and touched
350 movl r6,(r2)+ ; carry untouched
351 sobgtr r5,0$ ; carry untouched
352
353 adwc #0,r0
354666$:
355 ret
356
357 .title vax_bn_sub_words unsigned add of two arrays
358;
359; Richard Levitte 20-Nov-2000
360;
361; ULONG bn_sub_words(ULONG r[], ULONG a[], ULONG b[], int n) {
362; ULONG c = 0;
363; int i;
364; for (i = 0; i < n; i++) <c,r[i]> = a[i] - b[i] - c;
365; return(c);
366; }
367
368r=4 ;(AP) r by reference (output)
369a=8 ;(AP) a by reference (input)
370b=12 ;(AP) b by reference (input)
371n=16 ;(AP) n by value (input)
372
373
374 .psect code,nowrt
375
376.entry bn_sub_words,^m<r2,r3,r4,r5,r6>
377
378 moval @r(ap),r2
379 moval @a(ap),r3
380 moval @b(ap),r4
381 movl n(ap),r5 ; assumed >0 by C code
382 clrl r0 ; c
383
384 tstl r5 ; carry = 0
385 bleq 666$
386
3870$:
388 movl (r3)+,r6 ; carry untouched
389 sbwc (r4)+,r6 ; carry used and touched
390 movl r6,(r2)+ ; carry untouched
391 sobgtr r5,0$ ; carry untouched
392
393 adwc #0,r0
394666$:
395 ret
396
397
398;r=4 ;(AP)
399;a=8 ;(AP)
400;b=12 ;(AP)
401;n=16 ;(AP) n by value (input)
402
403 .psect code,nowrt
404
405.entry BN_MUL_COMBA8,^m<r2,r3,r4,r5,r6,r7,r8,r9,r10,r11>
406 movab -924(sp),sp
407 clrq r8
408
409 clrl r10
410
411 movl 8(ap),r6
412 movzwl 2(r6),r3
413 movl 12(ap),r7
414 bicl3 #-65536,(r7),r2
415 movzwl 2(r7),r0
416 bicl2 #-65536,r0
417 bicl3 #-65536,(r6),-12(fp)
418 bicl3 #-65536,r3,-16(fp)
419 mull3 r0,-12(fp),-4(fp)
420 mull2 r2,-12(fp)
421 mull3 r2,-16(fp),-8(fp)
422 mull2 r0,-16(fp)
423 addl3 -4(fp),-8(fp),r0
424 bicl3 #0,r0,-4(fp)
425 cmpl -4(fp),-8(fp)
426 bgequ noname.45
427 addl2 #65536,-16(fp)
428noname.45:
429 movzwl -2(fp),r0
430 bicl2 #-65536,r0
431 addl2 r0,-16(fp)
432 bicl3 #-65536,-4(fp),r0
433 ashl #16,r0,-8(fp)
434 addl3 -8(fp),-12(fp),r0
435 bicl3 #0,r0,-12(fp)
436 cmpl -12(fp),-8(fp)
437 bgequ noname.46
438 incl -16(fp)
439noname.46:
440 movl -12(fp),r1
441 movl -16(fp),r2
442 addl2 r1,r9
443 bicl2 #0,r9
444 cmpl r9,r1
445 bgequ noname.47
446 incl r2
447noname.47:
448 addl2 r2,r8
449 bicl2 #0,r8
450 cmpl r8,r2
451 bgequ noname.48
452 incl r10
453noname.48:
454
455 movl 4(ap),r11
456 movl r9,(r11)
457
458 clrl r9
459
460 movzwl 2(r6),r2
461 bicl3 #-65536,4(r7),r3
462 movzwl 6(r7),r0
463 bicl2 #-65536,r0
464 bicl3 #-65536,(r6),-28(fp)
465 bicl3 #-65536,r2,-32(fp)
466 mull3 r0,-28(fp),-20(fp)
467 mull2 r3,-28(fp)
468 mull3 r3,-32(fp),-24(fp)
469 mull2 r0,-32(fp)
470 addl3 -20(fp),-24(fp),r0
471 bicl3 #0,r0,-20(fp)
472 cmpl -20(fp),-24(fp)
473 bgequ noname.49
474 addl2 #65536,-32(fp)
475noname.49:
476 movzwl -18(fp),r0
477 bicl2 #-65536,r0
478 addl2 r0,-32(fp)
479 bicl3 #-65536,-20(fp),r0
480 ashl #16,r0,-24(fp)
481 addl3 -24(fp),-28(fp),r0
482 bicl3 #0,r0,-28(fp)
483 cmpl -28(fp),-24(fp)
484 bgequ noname.50
485 incl -32(fp)
486noname.50:
487 movl -28(fp),r1
488 movl -32(fp),r2
489 addl2 r1,r8
490 bicl2 #0,r8
491 cmpl r8,r1
492 bgequ noname.51
493 incl r2
494noname.51:
495 addl2 r2,r10
496 bicl2 #0,r10
497 cmpl r10,r2
498 bgequ noname.52
499 incl r9
500noname.52:
501
502 movzwl 6(r6),r2
503 bicl3 #-65536,(r7),r3
504 movzwl 2(r7),r0
505 bicl2 #-65536,r0
506 bicl3 #-65536,4(r6),-44(fp)
507 bicl3 #-65536,r2,-48(fp)
508 mull3 r0,-44(fp),-36(fp)
509 mull2 r3,-44(fp)
510 mull3 r3,-48(fp),-40(fp)
511 mull2 r0,-48(fp)
512 addl3 -36(fp),-40(fp),r0
513 bicl3 #0,r0,-36(fp)
514 cmpl -36(fp),-40(fp)
515 bgequ noname.53
516 addl2 #65536,-48(fp)
517noname.53:
518 movzwl -34(fp),r0
519 bicl2 #-65536,r0
520 addl2 r0,-48(fp)
521 bicl3 #-65536,-36(fp),r0
522 ashl #16,r0,-40(fp)
523 addl3 -40(fp),-44(fp),r0
524 bicl3 #0,r0,-44(fp)
525 cmpl -44(fp),-40(fp)
526 bgequ noname.54
527 incl -48(fp)
528noname.54:
529 movl -44(fp),r1
530 movl -48(fp),r2
531 addl2 r1,r8
532 bicl2 #0,r8
533 cmpl r8,r1
534 bgequ noname.55
535 incl r2
536noname.55:
537 addl2 r2,r10
538 bicl2 #0,r10
539 cmpl r10,r2
540 bgequ noname.56
541 incl r9
542noname.56:
543
544 movl r8,4(r11)
545
546 clrl r8
547
548 movzwl 10(r6),r2
549 bicl3 #-65536,(r7),r3
550 movzwl 2(r7),r0
551 bicl2 #-65536,r0
552 bicl3 #-65536,8(r6),-60(fp)
553 bicl3 #-65536,r2,-64(fp)
554 mull3 r0,-60(fp),-52(fp)
555 mull2 r3,-60(fp)
556 mull3 r3,-64(fp),-56(fp)
557 mull2 r0,-64(fp)
558 addl3 -52(fp),-56(fp),r0
559 bicl3 #0,r0,-52(fp)
560 cmpl -52(fp),-56(fp)
561 bgequ noname.57
562 addl2 #65536,-64(fp)
563noname.57:
564 movzwl -50(fp),r0
565 bicl2 #-65536,r0
566 addl2 r0,-64(fp)
567 bicl3 #-65536,-52(fp),r0
568 ashl #16,r0,-56(fp)
569 addl3 -56(fp),-60(fp),r0
570 bicl3 #0,r0,-60(fp)
571 cmpl -60(fp),-56(fp)
572 bgequ noname.58
573 incl -64(fp)
574noname.58:
575 movl -60(fp),r1
576 movl -64(fp),r2
577 addl2 r1,r10
578 bicl2 #0,r10
579 cmpl r10,r1
580 bgequ noname.59
581 incl r2
582noname.59:
583 addl2 r2,r9
584 bicl2 #0,r9
585 cmpl r9,r2
586 bgequ noname.60
587 incl r8
588noname.60:
589
590 movzwl 6(r6),r2
591 bicl3 #-65536,4(r7),r3
592 movzwl 6(r7),r0
593 bicl2 #-65536,r0
594 bicl3 #-65536,4(r6),-76(fp)
595 bicl3 #-65536,r2,-80(fp)
596 mull3 r0,-76(fp),-68(fp)
597 mull2 r3,-76(fp)
598 mull3 r3,-80(fp),-72(fp)
599 mull2 r0,-80(fp)
600 addl3 -68(fp),-72(fp),r0
601 bicl3 #0,r0,-68(fp)
602 cmpl -68(fp),-72(fp)
603 bgequ noname.61
604 addl2 #65536,-80(fp)
605noname.61:
606 movzwl -66(fp),r0
607 bicl2 #-65536,r0
608 addl2 r0,-80(fp)
609 bicl3 #-65536,-68(fp),r0
610 ashl #16,r0,-72(fp)
611 addl3 -72(fp),-76(fp),r0
612 bicl3 #0,r0,-76(fp)
613 cmpl -76(fp),-72(fp)
614 bgequ noname.62
615 incl -80(fp)
616noname.62:
617 movl -76(fp),r1
618 movl -80(fp),r2
619 addl2 r1,r10
620 bicl2 #0,r10
621 cmpl r10,r1
622 bgequ noname.63
623 incl r2
624noname.63:
625 addl2 r2,r9
626 bicl2 #0,r9
627 cmpl r9,r2
628 bgequ noname.64
629 incl r8
630noname.64:
631
632 movzwl 2(r6),r2
633 bicl3 #-65536,8(r7),r3
634 movzwl 10(r7),r0
635 bicl2 #-65536,r0
636 bicl3 #-65536,(r6),-92(fp)
637 bicl3 #-65536,r2,-96(fp)
638 mull3 r0,-92(fp),-84(fp)
639 mull2 r3,-92(fp)
640 mull3 r3,-96(fp),-88(fp)
641 mull2 r0,-96(fp)
642 addl3 -84(fp),-88(fp),r0
643 bicl3 #0,r0,-84(fp)
644 cmpl -84(fp),-88(fp)
645 bgequ noname.65
646 addl2 #65536,-96(fp)
647noname.65:
648 movzwl -82(fp),r0
649 bicl2 #-65536,r0
650 addl2 r0,-96(fp)
651 bicl3 #-65536,-84(fp),r0
652 ashl #16,r0,-88(fp)
653 addl3 -88(fp),-92(fp),r0
654 bicl3 #0,r0,-92(fp)
655 cmpl -92(fp),-88(fp)
656 bgequ noname.66
657 incl -96(fp)
658noname.66:
659 movl -92(fp),r1
660 movl -96(fp),r2
661 addl2 r1,r10
662 bicl2 #0,r10
663 cmpl r10,r1
664 bgequ noname.67
665 incl r2
666noname.67:
667 addl2 r2,r9
668 bicl2 #0,r9
669 cmpl r9,r2
670 bgequ noname.68
671 incl r8
672noname.68:
673
674 movl r10,8(r11)
675
676 clrl r10
677
678 movzwl 2(r6),r2
679 bicl3 #-65536,12(r7),r3
680 movzwl 14(r7),r0
681 bicl2 #-65536,r0
682 bicl3 #-65536,(r6),-108(fp)
683 bicl3 #-65536,r2,-112(fp)
684 mull3 r0,-108(fp),-100(fp)
685 mull2 r3,-108(fp)
686 mull3 r3,-112(fp),-104(fp)
687 mull2 r0,-112(fp)
688 addl3 -100(fp),-104(fp),r0
689 bicl3 #0,r0,-100(fp)
690 cmpl -100(fp),-104(fp)
691 bgequ noname.69
692 addl2 #65536,-112(fp)
693noname.69:
694 movzwl -98(fp),r0
695 bicl2 #-65536,r0
696 addl2 r0,-112(fp)
697 bicl3 #-65536,-100(fp),r0
698 ashl #16,r0,-104(fp)
699 addl3 -104(fp),-108(fp),r0
700 bicl3 #0,r0,-108(fp)
701 cmpl -108(fp),-104(fp)
702 bgequ noname.70
703 incl -112(fp)
704noname.70:
705 movl -108(fp),r1
706 movl -112(fp),r2
707 addl2 r1,r9
708 bicl2 #0,r9
709 cmpl r9,r1
710 bgequ noname.71
711 incl r2
712noname.71:
713 addl2 r2,r8
714 bicl2 #0,r8
715 cmpl r8,r2
716 bgequ noname.72
717 incl r10
718noname.72:
719
720 movzwl 6(r6),r2
721 bicl3 #-65536,8(r7),r3
722 movzwl 10(r7),r0
723 bicl2 #-65536,r0
724 bicl3 #-65536,4(r6),-124(fp)
725 bicl3 #-65536,r2,-128(fp)
726 mull3 r0,-124(fp),-116(fp)
727 mull2 r3,-124(fp)
728 mull3 r3,-128(fp),-120(fp)
729 mull2 r0,-128(fp)
730 addl3 -116(fp),-120(fp),r0
731 bicl3 #0,r0,-116(fp)
732 cmpl -116(fp),-120(fp)
733 bgequ noname.73
734 addl2 #65536,-128(fp)
735noname.73:
736 movzwl -114(fp),r0
737 bicl2 #-65536,r0
738 addl2 r0,-128(fp)
739 bicl3 #-65536,-116(fp),r0
740 ashl #16,r0,-120(fp)
741 addl3 -120(fp),-124(fp),r0
742 bicl3 #0,r0,-124(fp)
743 cmpl -124(fp),-120(fp)
744 bgequ noname.74
745 incl -128(fp)
746noname.74:
747 movl -124(fp),r1
748 movl -128(fp),r2
749 addl2 r1,r9
750 bicl2 #0,r9
751 cmpl r9,r1
752 bgequ noname.75
753 incl r2
754noname.75:
755 addl2 r2,r8
756 bicl2 #0,r8
757 cmpl r8,r2
758 bgequ noname.76
759 incl r10
760noname.76:
761
762 movzwl 10(r6),r2
763 bicl3 #-65536,4(r7),r3
764 movzwl 6(r7),r0
765 bicl2 #-65536,r0
766 bicl3 #-65536,8(r6),-140(fp)
767 bicl3 #-65536,r2,-144(fp)
768 mull3 r0,-140(fp),-132(fp)
769 mull2 r3,-140(fp)
770 mull3 r3,-144(fp),-136(fp)
771 mull2 r0,-144(fp)
772 addl3 -132(fp),-136(fp),r0
773 bicl3 #0,r0,-132(fp)
774 cmpl -132(fp),-136(fp)
775 bgequ noname.77
776 addl2 #65536,-144(fp)
777noname.77:
778 movzwl -130(fp),r0
779 bicl2 #-65536,r0
780 addl2 r0,-144(fp)
781 bicl3 #-65536,-132(fp),r0
782 ashl #16,r0,-136(fp)
783 addl3 -136(fp),-140(fp),r0
784 bicl3 #0,r0,-140(fp)
785 cmpl -140(fp),-136(fp)
786 bgequ noname.78
787 incl -144(fp)
788noname.78:
789 movl -140(fp),r1
790 movl -144(fp),r2
791 addl2 r1,r9
792 bicl2 #0,r9
793 cmpl r9,r1
794 bgequ noname.79
795 incl r2
796noname.79:
797 addl2 r2,r8
798 bicl2 #0,r8
799 cmpl r8,r2
800 bgequ noname.80
801 incl r10
802noname.80:
803
804 movzwl 14(r6),r2
805 bicl3 #-65536,(r7),r3
806 movzwl 2(r7),r0
807 bicl2 #-65536,r0
808 bicl3 #-65536,12(r6),-156(fp)
809 bicl3 #-65536,r2,-160(fp)
810 mull3 r0,-156(fp),-148(fp)
811 mull2 r3,-156(fp)
812 mull3 r3,-160(fp),-152(fp)
813 mull2 r0,-160(fp)
814 addl3 -148(fp),-152(fp),r0
815 bicl3 #0,r0,-148(fp)
816 cmpl -148(fp),-152(fp)
817 bgequ noname.81
818 addl2 #65536,-160(fp)
819noname.81:
820 movzwl -146(fp),r0
821 bicl2 #-65536,r0
822 addl2 r0,-160(fp)
823 bicl3 #-65536,-148(fp),r0
824 ashl #16,r0,-152(fp)
825 addl3 -152(fp),-156(fp),r0
826 bicl3 #0,r0,-156(fp)
827 cmpl -156(fp),-152(fp)
828 bgequ noname.82
829 incl -160(fp)
830noname.82:
831 movl -156(fp),r1
832 movl -160(fp),r2
833 addl2 r1,r9
834 bicl2 #0,r9
835 cmpl r9,r1
836 bgequ noname.83
837 incl r2
838noname.83:
839 addl2 r2,r8
840 bicl2 #0,r8
841 cmpl r8,r2
842 bgequ noname.84
843 incl r10
844noname.84:
845
846 movl r9,12(r11)
847
848 clrl r9
849
850 movzwl 18(r6),r2
851 bicl3 #-65536,(r7),r3
852 movzwl 2(r7),r0
853 bicl2 #-65536,r0
854 bicl3 #-65536,16(r6),-172(fp)
855 bicl3 #-65536,r2,-176(fp)
856 mull3 r0,-172(fp),-164(fp)
857 mull2 r3,-172(fp)
858 mull3 r3,-176(fp),-168(fp)
859 mull2 r0,-176(fp)
860 addl3 -164(fp),-168(fp),r0
861 bicl3 #0,r0,-164(fp)
862 cmpl -164(fp),-168(fp)
863 bgequ noname.85
864 addl2 #65536,-176(fp)
865noname.85:
866 movzwl -162(fp),r0
867 bicl2 #-65536,r0
868 addl2 r0,-176(fp)
869 bicl3 #-65536,-164(fp),r0
870 ashl #16,r0,-168(fp)
871 addl3 -168(fp),-172(fp),r0
872 bicl3 #0,r0,-172(fp)
873 cmpl -172(fp),-168(fp)
874 bgequ noname.86
875 incl -176(fp)
876noname.86:
877 movl -172(fp),r1
878 movl -176(fp),r2
879 addl2 r1,r8
880 bicl2 #0,r8
881 cmpl r8,r1
882 bgequ noname.87
883 incl r2
884noname.87:
885 addl2 r2,r10
886 bicl2 #0,r10
887 cmpl r10,r2
888 bgequ noname.88
889 incl r9
890noname.88:
891
892 movzwl 14(r6),r2
893 bicl3 #-65536,4(r7),r3
894 movzwl 6(r7),r0
895 bicl2 #-65536,r0
896 bicl3 #-65536,12(r6),-188(fp)
897 bicl3 #-65536,r2,-192(fp)
898 mull3 r0,-188(fp),-180(fp)
899 mull2 r3,-188(fp)
900 mull3 r3,-192(fp),-184(fp)
901 mull2 r0,-192(fp)
902 addl3 -180(fp),-184(fp),r0
903 bicl3 #0,r0,-180(fp)
904 cmpl -180(fp),-184(fp)
905 bgequ noname.89
906 addl2 #65536,-192(fp)
907noname.89:
908 movzwl -178(fp),r0
909 bicl2 #-65536,r0
910 addl2 r0,-192(fp)
911 bicl3 #-65536,-180(fp),r0
912 ashl #16,r0,-184(fp)
913 addl3 -184(fp),-188(fp),r0
914 bicl3 #0,r0,-188(fp)
915 cmpl -188(fp),-184(fp)
916 bgequ noname.90
917 incl -192(fp)
918noname.90:
919 movl -188(fp),r1
920 movl -192(fp),r2
921 addl2 r1,r8
922 bicl2 #0,r8
923 cmpl r8,r1
924 bgequ noname.91
925 incl r2
926noname.91:
927 addl2 r2,r10
928 bicl2 #0,r10
929 cmpl r10,r2
930 bgequ noname.92
931 incl r9
932noname.92:
933
934 movzwl 10(r6),r2
935 bicl3 #-65536,8(r7),r3
936 movzwl 10(r7),r0
937 bicl2 #-65536,r0
938 bicl3 #-65536,8(r6),-204(fp)
939 bicl3 #-65536,r2,-208(fp)
940 mull3 r0,-204(fp),-196(fp)
941 mull2 r3,-204(fp)
942 mull3 r3,-208(fp),-200(fp)
943 mull2 r0,-208(fp)
944 addl3 -196(fp),-200(fp),r0
945 bicl3 #0,r0,-196(fp)
946 cmpl -196(fp),-200(fp)
947 bgequ noname.93
948 addl2 #65536,-208(fp)
949noname.93:
950 movzwl -194(fp),r0
951 bicl2 #-65536,r0
952 addl2 r0,-208(fp)
953 bicl3 #-65536,-196(fp),r0
954 ashl #16,r0,-200(fp)
955 addl3 -200(fp),-204(fp),r0
956 bicl3 #0,r0,-204(fp)
957 cmpl -204(fp),-200(fp)
958 bgequ noname.94
959 incl -208(fp)
960noname.94:
961 movl -204(fp),r1
962 movl -208(fp),r2
963 addl2 r1,r8
964 bicl2 #0,r8
965 cmpl r8,r1
966 bgequ noname.95
967 incl r2
968noname.95:
969 addl2 r2,r10
970 bicl2 #0,r10
971 cmpl r10,r2
972 bgequ noname.96
973 incl r9
974noname.96:
975
976 movzwl 6(r6),r2
977 bicl3 #-65536,12(r7),r3
978 movzwl 14(r7),r0
979 bicl2 #-65536,r0
980 bicl3 #-65536,4(r6),-220(fp)
981 bicl3 #-65536,r2,-224(fp)
982 mull3 r0,-220(fp),-212(fp)
983 mull2 r3,-220(fp)
984 mull3 r3,-224(fp),-216(fp)
985 mull2 r0,-224(fp)
986 addl3 -212(fp),-216(fp),r0
987 bicl3 #0,r0,-212(fp)
988 cmpl -212(fp),-216(fp)
989 bgequ noname.97
990 addl2 #65536,-224(fp)
991noname.97:
992 movzwl -210(fp),r0
993 bicl2 #-65536,r0
994 addl2 r0,-224(fp)
995 bicl3 #-65536,-212(fp),r0
996 ashl #16,r0,-216(fp)
997 addl3 -216(fp),-220(fp),r0
998 bicl3 #0,r0,-220(fp)
999 cmpl -220(fp),-216(fp)
1000 bgequ noname.98
1001 incl -224(fp)
1002noname.98:
1003 movl -220(fp),r1
1004 movl -224(fp),r2
1005 addl2 r1,r8
1006 bicl2 #0,r8
1007 cmpl r8,r1
1008 bgequ noname.99
1009 incl r2
1010noname.99:
1011 addl2 r2,r10
1012 bicl2 #0,r10
1013 cmpl r10,r2
1014 bgequ noname.100
1015 incl r9
1016noname.100:
1017
1018 movzwl 2(r6),r2
1019 bicl3 #-65536,16(r7),r3
1020 movzwl 18(r7),r0
1021 bicl2 #-65536,r0
1022 bicl3 #-65536,(r6),-236(fp)
1023 bicl3 #-65536,r2,-240(fp)
1024 mull3 r0,-236(fp),-228(fp)
1025 mull2 r3,-236(fp)
1026 mull3 r3,-240(fp),-232(fp)
1027 mull2 r0,-240(fp)
1028 addl3 -228(fp),-232(fp),r0
1029 bicl3 #0,r0,-228(fp)
1030 cmpl -228(fp),-232(fp)
1031 bgequ noname.101
1032 addl2 #65536,-240(fp)
1033noname.101:
1034 movzwl -226(fp),r0
1035 bicl2 #-65536,r0
1036 addl2 r0,-240(fp)
1037 bicl3 #-65536,-228(fp),r0
1038 ashl #16,r0,-232(fp)
1039 addl3 -232(fp),-236(fp),r0
1040 bicl3 #0,r0,-236(fp)
1041 cmpl -236(fp),-232(fp)
1042 bgequ noname.102
1043 incl -240(fp)
1044noname.102:
1045 movl -236(fp),r1
1046 movl -240(fp),r2
1047 addl2 r1,r8
1048 bicl2 #0,r8
1049 cmpl r8,r1
1050 bgequ noname.103
1051 incl r2
1052noname.103:
1053 addl2 r2,r10
1054 bicl2 #0,r10
1055 cmpl r10,r2
1056 bgequ noname.104
1057 incl r9
1058noname.104:
1059
1060 movl r8,16(r11)
1061
1062 clrl r8
1063
1064 movzwl 2(r6),r2
1065 bicl3 #-65536,20(r7),r3
1066 movzwl 22(r7),r0
1067 bicl2 #-65536,r0
1068 bicl3 #-65536,(r6),-252(fp)
1069 bicl3 #-65536,r2,-256(fp)
1070 mull3 r0,-252(fp),-244(fp)
1071 mull2 r3,-252(fp)
1072 mull3 r3,-256(fp),-248(fp)
1073 mull2 r0,-256(fp)
1074 addl3 -244(fp),-248(fp),r0
1075 bicl3 #0,r0,-244(fp)
1076 cmpl -244(fp),-248(fp)
1077 bgequ noname.105
1078 addl2 #65536,-256(fp)
1079noname.105:
1080 movzwl -242(fp),r0
1081 bicl2 #-65536,r0
1082 addl2 r0,-256(fp)
1083 bicl3 #-65536,-244(fp),r0
1084 ashl #16,r0,-248(fp)
1085 addl3 -248(fp),-252(fp),r0
1086 bicl3 #0,r0,-252(fp)
1087 cmpl -252(fp),-248(fp)
1088 bgequ noname.106
1089 incl -256(fp)
1090noname.106:
1091 movl -252(fp),r1
1092 movl -256(fp),r2
1093 addl2 r1,r10
1094 bicl2 #0,r10
1095 cmpl r10,r1
1096 bgequ noname.107
1097 incl r2
1098noname.107:
1099 addl2 r2,r9
1100 bicl2 #0,r9
1101 cmpl r9,r2
1102 bgequ noname.108
1103 incl r8
1104noname.108:
1105
1106 movzwl 6(r6),r2
1107 bicl3 #-65536,16(r7),r3
1108 movzwl 18(r7),r0
1109 bicl2 #-65536,r0
1110 bicl3 #-65536,4(r6),-268(fp)
1111 bicl3 #-65536,r2,-272(fp)
1112 mull3 r0,-268(fp),-260(fp)
1113 mull2 r3,-268(fp)
1114 mull3 r3,-272(fp),-264(fp)
1115 mull2 r0,-272(fp)
1116 addl3 -260(fp),-264(fp),r0
1117 bicl3 #0,r0,-260(fp)
1118 cmpl -260(fp),-264(fp)
1119 bgequ noname.109
1120 addl2 #65536,-272(fp)
1121noname.109:
1122 movzwl -258(fp),r0
1123 bicl2 #-65536,r0
1124 addl2 r0,-272(fp)
1125 bicl3 #-65536,-260(fp),r0
1126 ashl #16,r0,-264(fp)
1127 addl3 -264(fp),-268(fp),r0
1128 bicl3 #0,r0,-268(fp)
1129 cmpl -268(fp),-264(fp)
1130 bgequ noname.110
1131 incl -272(fp)
1132noname.110:
1133 movl -268(fp),r1
1134 movl -272(fp),r2
1135 addl2 r1,r10
1136 bicl2 #0,r10
1137 cmpl r10,r1
1138 bgequ noname.111
1139 incl r2
1140noname.111:
1141 addl2 r2,r9
1142 bicl2 #0,r9
1143 cmpl r9,r2
1144 bgequ noname.112
1145 incl r8
1146noname.112:
1147
1148 movzwl 10(r6),r2
1149 bicl3 #-65536,12(r7),r3
1150 movzwl 14(r7),r0
1151 bicl2 #-65536,r0
1152 bicl3 #-65536,8(r6),-284(fp)
1153 bicl3 #-65536,r2,-288(fp)
1154 mull3 r0,-284(fp),-276(fp)
1155 mull2 r3,-284(fp)
1156 mull3 r3,-288(fp),-280(fp)
1157 mull2 r0,-288(fp)
1158 addl3 -276(fp),-280(fp),r0
1159 bicl3 #0,r0,-276(fp)
1160 cmpl -276(fp),-280(fp)
1161 bgequ noname.113
1162 addl2 #65536,-288(fp)
1163noname.113:
1164 movzwl -274(fp),r0
1165 bicl2 #-65536,r0
1166 addl2 r0,-288(fp)
1167 bicl3 #-65536,-276(fp),r0
1168 ashl #16,r0,-280(fp)
1169 addl3 -280(fp),-284(fp),r0
1170 bicl3 #0,r0,-284(fp)
1171 cmpl -284(fp),-280(fp)
1172 bgequ noname.114
1173 incl -288(fp)
1174noname.114:
1175 movl -284(fp),r1
1176 movl -288(fp),r2
1177 addl2 r1,r10
1178 bicl2 #0,r10
1179 cmpl r10,r1
1180 bgequ noname.115
1181 incl r2
1182noname.115:
1183 addl2 r2,r9
1184 bicl2 #0,r9
1185 cmpl r9,r2
1186 bgequ noname.116
1187 incl r8
1188noname.116:
1189
1190 movzwl 14(r6),r2
1191 bicl3 #-65536,8(r7),r3
1192 movzwl 10(r7),r0
1193 bicl2 #-65536,r0
1194 bicl3 #-65536,12(r6),-300(fp)
1195 bicl3 #-65536,r2,-304(fp)
1196 mull3 r0,-300(fp),-292(fp)
1197 mull2 r3,-300(fp)
1198 mull3 r3,-304(fp),-296(fp)
1199 mull2 r0,-304(fp)
1200 addl3 -292(fp),-296(fp),r0
1201 bicl3 #0,r0,-292(fp)
1202 cmpl -292(fp),-296(fp)
1203 bgequ noname.117
1204 addl2 #65536,-304(fp)
1205noname.117:
1206 movzwl -290(fp),r0
1207 bicl2 #-65536,r0
1208 addl2 r0,-304(fp)
1209 bicl3 #-65536,-292(fp),r0
1210 ashl #16,r0,-296(fp)
1211 addl3 -296(fp),-300(fp),r0
1212 bicl3 #0,r0,-300(fp)
1213 cmpl -300(fp),-296(fp)
1214 bgequ noname.118
1215 incl -304(fp)
1216noname.118:
1217 movl -300(fp),r1
1218 movl -304(fp),r2
1219 addl2 r1,r10
1220 bicl2 #0,r10
1221 cmpl r10,r1
1222 bgequ noname.119
1223 incl r2
1224noname.119:
1225 addl2 r2,r9
1226 bicl2 #0,r9
1227 cmpl r9,r2
1228 bgequ noname.120
1229 incl r8
1230noname.120:
1231
1232 movzwl 18(r6),r2
1233 bicl3 #-65536,4(r7),r3
1234 movzwl 6(r7),r0
1235 bicl2 #-65536,r0
1236 bicl3 #-65536,16(r6),-316(fp)
1237 bicl3 #-65536,r2,-320(fp)
1238 mull3 r0,-316(fp),-308(fp)
1239 mull2 r3,-316(fp)
1240 mull3 r3,-320(fp),-312(fp)
1241 mull2 r0,-320(fp)
1242 addl3 -308(fp),-312(fp),r0
1243 bicl3 #0,r0,-308(fp)
1244 cmpl -308(fp),-312(fp)
1245 bgequ noname.121
1246 addl2 #65536,-320(fp)
1247noname.121:
1248 movzwl -306(fp),r0
1249 bicl2 #-65536,r0
1250 addl2 r0,-320(fp)
1251 bicl3 #-65536,-308(fp),r0
1252 ashl #16,r0,-312(fp)
1253 addl3 -312(fp),-316(fp),r0
1254 bicl3 #0,r0,-316(fp)
1255 cmpl -316(fp),-312(fp)
1256 bgequ noname.122
1257 incl -320(fp)
1258noname.122:
1259 movl -316(fp),r1
1260 movl -320(fp),r2
1261 addl2 r1,r10
1262 bicl2 #0,r10
1263 cmpl r10,r1
1264 bgequ noname.123
1265 incl r2
1266
1267noname.123:
1268 addl2 r2,r9
1269 bicl2 #0,r9
1270 cmpl r9,r2
1271 bgequ noname.124
1272 incl r8
1273noname.124:
1274
1275 movzwl 22(r6),r2
1276 bicl3 #-65536,(r7),r3
1277 movzwl 2(r7),r0
1278 bicl2 #-65536,r0
1279 bicl3 #-65536,20(r6),-332(fp)
1280 bicl3 #-65536,r2,-336(fp)
1281 mull3 r0,-332(fp),-324(fp)
1282 mull2 r3,-332(fp)
1283 mull3 r3,-336(fp),-328(fp)
1284 mull2 r0,-336(fp)
1285 addl3 -324(fp),-328(fp),r0
1286 bicl3 #0,r0,-324(fp)
1287 cmpl -324(fp),-328(fp)
1288 bgequ noname.125
1289 addl2 #65536,-336(fp)
1290noname.125:
1291 movzwl -322(fp),r0
1292 bicl2 #-65536,r0
1293 addl2 r0,-336(fp)
1294 bicl3 #-65536,-324(fp),r0
1295 ashl #16,r0,-328(fp)
1296 addl3 -328(fp),-332(fp),r0
1297 bicl3 #0,r0,-332(fp)
1298 cmpl -332(fp),-328(fp)
1299 bgequ noname.126
1300 incl -336(fp)
1301noname.126:
1302 movl -332(fp),r1
1303 movl -336(fp),r2
1304 addl2 r1,r10
1305 bicl2 #0,r10
1306 cmpl r10,r1
1307 bgequ noname.127
1308 incl r2
1309noname.127:
1310 addl2 r2,r9
1311 bicl2 #0,r9
1312 cmpl r9,r2
1313 bgequ noname.128
1314 incl r8
1315noname.128:
1316
1317 movl r10,20(r11)
1318
1319 clrl r10
1320
1321 movzwl 26(r6),r2
1322 bicl3 #-65536,(r7),r3
1323 movzwl 2(r7),r0
1324 bicl2 #-65536,r0
1325 bicl3 #-65536,24(r6),-348(fp)
1326 bicl3 #-65536,r2,-352(fp)
1327 mull3 r0,-348(fp),-340(fp)
1328 mull2 r3,-348(fp)
1329 mull3 r3,-352(fp),-344(fp)
1330 mull2 r0,-352(fp)
1331 addl3 -340(fp),-344(fp),r0
1332 bicl3 #0,r0,-340(fp)
1333 cmpl -340(fp),-344(fp)
1334 bgequ noname.129
1335 addl2 #65536,-352(fp)
1336noname.129:
1337 movzwl -338(fp),r0
1338 bicl2 #-65536,r0
1339 addl2 r0,-352(fp)
1340 bicl3 #-65536,-340(fp),r0
1341 ashl #16,r0,-344(fp)
1342 addl3 -344(fp),-348(fp),r0
1343 bicl3 #0,r0,-348(fp)
1344 cmpl -348(fp),-344(fp)
1345 bgequ noname.130
1346 incl -352(fp)
1347noname.130:
1348 movl -348(fp),r1
1349 movl -352(fp),r2
1350 addl2 r1,r9
1351 bicl2 #0,r9
1352 cmpl r9,r1
1353 bgequ noname.131
1354 incl r2
1355noname.131:
1356 addl2 r2,r8
1357 bicl2 #0,r8
1358 cmpl r8,r2
1359 bgequ noname.132
1360 incl r10
1361noname.132:
1362
1363 movzwl 22(r6),r2
1364 bicl3 #-65536,4(r7),r3
1365 movzwl 6(r7),r0
1366 bicl2 #-65536,r0
1367 bicl3 #-65536,20(r6),-364(fp)
1368 bicl3 #-65536,r2,-368(fp)
1369 mull3 r0,-364(fp),-356(fp)
1370 mull2 r3,-364(fp)
1371 mull3 r3,-368(fp),-360(fp)
1372 mull2 r0,-368(fp)
1373 addl3 -356(fp),-360(fp),r0
1374 bicl3 #0,r0,-356(fp)
1375 cmpl -356(fp),-360(fp)
1376 bgequ noname.133
1377 addl2 #65536,-368(fp)
1378noname.133:
1379 movzwl -354(fp),r0
1380 bicl2 #-65536,r0
1381 addl2 r0,-368(fp)
1382 bicl3 #-65536,-356(fp),r0
1383 ashl #16,r0,-360(fp)
1384 addl3 -360(fp),-364(fp),r0
1385 bicl3 #0,r0,-364(fp)
1386 cmpl -364(fp),-360(fp)
1387 bgequ noname.134
1388 incl -368(fp)
1389noname.134:
1390 movl -364(fp),r1
1391 movl -368(fp),r2
1392 addl2 r1,r9
1393 bicl2 #0,r9
1394 cmpl r9,r1
1395 bgequ noname.135
1396 incl r2
1397noname.135:
1398 addl2 r2,r8
1399 bicl2 #0,r8
1400 cmpl r8,r2
1401 bgequ noname.136
1402 incl r10
1403noname.136:
1404
1405 movzwl 18(r6),r2
1406 bicl3 #-65536,8(r7),r3
1407 movzwl 10(r7),r0
1408 bicl2 #-65536,r0
1409 bicl3 #-65536,16(r6),-380(fp)
1410 bicl3 #-65536,r2,-384(fp)
1411 mull3 r0,-380(fp),-372(fp)
1412 mull2 r3,-380(fp)
1413 mull3 r3,-384(fp),-376(fp)
1414 mull2 r0,-384(fp)
1415 addl3 -372(fp),-376(fp),r0
1416 bicl3 #0,r0,-372(fp)
1417 cmpl -372(fp),-376(fp)
1418 bgequ noname.137
1419 addl2 #65536,-384(fp)
1420noname.137:
1421 movzwl -370(fp),r0
1422 bicl2 #-65536,r0
1423 addl2 r0,-384(fp)
1424 bicl3 #-65536,-372(fp),r0
1425 ashl #16,r0,-376(fp)
1426 addl3 -376(fp),-380(fp),r0
1427 bicl3 #0,r0,-380(fp)
1428 cmpl -380(fp),-376(fp)
1429 bgequ noname.138
1430 incl -384(fp)
1431noname.138:
1432 movl -380(fp),r1
1433 movl -384(fp),r2
1434 addl2 r1,r9
1435 bicl2 #0,r9
1436 cmpl r9,r1
1437 bgequ noname.139
1438 incl r2
1439noname.139:
1440 addl2 r2,r8
1441 bicl2 #0,r8
1442 cmpl r8,r2
1443 bgequ noname.140
1444 incl r10
1445noname.140:
1446
1447 movzwl 14(r6),r2
1448 bicl3 #-65536,12(r7),r3
1449 movzwl 14(r7),r0
1450 bicl2 #-65536,r0
1451 bicl3 #-65536,12(r6),-396(fp)
1452 bicl3 #-65536,r2,-400(fp)
1453 mull3 r0,-396(fp),-388(fp)
1454 mull2 r3,-396(fp)
1455 mull3 r3,-400(fp),-392(fp)
1456 mull2 r0,-400(fp)
1457 addl3 -388(fp),-392(fp),r0
1458 bicl3 #0,r0,-388(fp)
1459 cmpl -388(fp),-392(fp)
1460 bgequ noname.141
1461 addl2 #65536,-400(fp)
1462noname.141:
1463 movzwl -386(fp),r0
1464 bicl2 #-65536,r0
1465 addl2 r0,-400(fp)
1466 bicl3 #-65536,-388(fp),r0
1467 ashl #16,r0,-392(fp)
1468 addl3 -392(fp),-396(fp),r0
1469 bicl3 #0,r0,-396(fp)
1470 cmpl -396(fp),-392(fp)
1471 bgequ noname.142
1472 incl -400(fp)
1473noname.142:
1474 movl -396(fp),r1
1475 movl -400(fp),r2
1476 addl2 r1,r9
1477 bicl2 #0,r9
1478 cmpl r9,r1
1479 bgequ noname.143
1480 incl r2
1481noname.143:
1482 addl2 r2,r8
1483 bicl2 #0,r8
1484 cmpl r8,r2
1485 bgequ noname.144
1486 incl r10
1487noname.144:
1488
1489 movzwl 10(r6),r2
1490 bicl3 #-65536,16(r7),r3
1491 movzwl 18(r7),r0
1492 bicl2 #-65536,r0
1493 bicl3 #-65536,8(r6),-412(fp)
1494 bicl3 #-65536,r2,-416(fp)
1495 mull3 r0,-412(fp),-404(fp)
1496 mull2 r3,-412(fp)
1497 mull3 r3,-416(fp),-408(fp)
1498 mull2 r0,-416(fp)
1499 addl3 -404(fp),-408(fp),r0
1500 bicl3 #0,r0,-404(fp)
1501 cmpl -404(fp),-408(fp)
1502 bgequ noname.145
1503 addl2 #65536,-416(fp)
1504noname.145:
1505 movzwl -402(fp),r0
1506 bicl2 #-65536,r0
1507 addl2 r0,-416(fp)
1508 bicl3 #-65536,-404(fp),r0
1509 ashl #16,r0,-408(fp)
1510 addl3 -408(fp),-412(fp),r0
1511 bicl3 #0,r0,-412(fp)
1512 cmpl -412(fp),-408(fp)
1513 bgequ noname.146
1514 incl -416(fp)
1515noname.146:
1516 movl -412(fp),r1
1517 movl -416(fp),r2
1518 addl2 r1,r9
1519 bicl2 #0,r9
1520 cmpl r9,r1
1521 bgequ noname.147
1522 incl r2
1523noname.147:
1524 addl2 r2,r8
1525 bicl2 #0,r8
1526 cmpl r8,r2
1527 bgequ noname.148
1528 incl r10
1529noname.148:
1530
1531 movzwl 6(r6),r2
1532 bicl3 #-65536,20(r7),r3
1533 movzwl 22(r7),r0
1534 bicl2 #-65536,r0
1535 bicl3 #-65536,4(r6),-428(fp)
1536 bicl3 #-65536,r2,-432(fp)
1537 mull3 r0,-428(fp),-420(fp)
1538 mull2 r3,-428(fp)
1539 mull3 r3,-432(fp),-424(fp)
1540 mull2 r0,-432(fp)
1541 addl3 -420(fp),-424(fp),r0
1542 bicl3 #0,r0,-420(fp)
1543 cmpl -420(fp),-424(fp)
1544 bgequ noname.149
1545 addl2 #65536,-432(fp)
1546noname.149:
1547 movzwl -418(fp),r0
1548 bicl2 #-65536,r0
1549 addl2 r0,-432(fp)
1550 bicl3 #-65536,-420(fp),r0
1551 ashl #16,r0,-424(fp)
1552 addl3 -424(fp),-428(fp),r0
1553 bicl3 #0,r0,-428(fp)
1554 cmpl -428(fp),-424(fp)
1555 bgequ noname.150
1556 incl -432(fp)
1557noname.150:
1558 movl -428(fp),r1
1559 movl -432(fp),r2
1560 addl2 r1,r9
1561 bicl2 #0,r9
1562 cmpl r9,r1
1563 bgequ noname.151
1564 incl r2
1565noname.151:
1566 addl2 r2,r8
1567 bicl2 #0,r8
1568 cmpl r8,r2
1569 bgequ noname.152
1570 incl r10
1571noname.152:
1572
1573 movzwl 2(r6),r2
1574 bicl3 #-65536,24(r7),r3
1575 movzwl 26(r7),r0
1576 bicl2 #-65536,r0
1577 bicl3 #-65536,(r6),-444(fp)
1578 bicl3 #-65536,r2,-448(fp)
1579 mull3 r0,-444(fp),-436(fp)
1580 mull2 r3,-444(fp)
1581 mull3 r3,-448(fp),-440(fp)
1582 mull2 r0,-448(fp)
1583 addl3 -436(fp),-440(fp),r0
1584 bicl3 #0,r0,-436(fp)
1585 cmpl -436(fp),-440(fp)
1586 bgequ noname.153
1587 addl2 #65536,-448(fp)
1588noname.153:
1589 movzwl -434(fp),r0
1590 bicl2 #-65536,r0
1591 addl2 r0,-448(fp)
1592 bicl3 #-65536,-436(fp),r0
1593 ashl #16,r0,-440(fp)
1594 addl3 -440(fp),-444(fp),r0
1595 bicl3 #0,r0,-444(fp)
1596 cmpl -444(fp),-440(fp)
1597 bgequ noname.154
1598 incl -448(fp)
1599noname.154:
1600 movl -444(fp),r1
1601 movl -448(fp),r2
1602 addl2 r1,r9
1603 bicl2 #0,r9
1604 cmpl r9,r1
1605 bgequ noname.155
1606 incl r2
1607noname.155:
1608 addl2 r2,r8
1609 bicl2 #0,r8
1610 cmpl r8,r2
1611 bgequ noname.156
1612 incl r10
1613noname.156:
1614
1615 movl r9,24(r11)
1616
1617 clrl r9
1618
1619 movzwl 2(r6),r2
1620 bicl3 #-65536,28(r7),r3
1621 movzwl 30(r7),r0
1622 bicl2 #-65536,r0
1623 bicl3 #-65536,(r6),-460(fp)
1624 bicl3 #-65536,r2,-464(fp)
1625 mull3 r0,-460(fp),-452(fp)
1626 mull2 r3,-460(fp)
1627 mull3 r3,-464(fp),-456(fp)
1628 mull2 r0,-464(fp)
1629 addl3 -452(fp),-456(fp),r0
1630 bicl3 #0,r0,-452(fp)
1631 cmpl -452(fp),-456(fp)
1632 bgequ noname.157
1633 addl2 #65536,-464(fp)
1634noname.157:
1635 movzwl -450(fp),r0
1636 bicl2 #-65536,r0
1637 addl2 r0,-464(fp)
1638 bicl3 #-65536,-452(fp),r0
1639 ashl #16,r0,-456(fp)
1640 addl3 -456(fp),-460(fp),r0
1641 bicl3 #0,r0,-460(fp)
1642 cmpl -460(fp),-456(fp)
1643 bgequ noname.158
1644 incl -464(fp)
1645noname.158:
1646 movl -460(fp),r1
1647 movl -464(fp),r2
1648 addl2 r1,r8
1649 bicl2 #0,r8
1650 cmpl r8,r1
1651 bgequ noname.159
1652 incl r2
1653noname.159:
1654 addl2 r2,r10
1655 bicl2 #0,r10
1656 cmpl r10,r2
1657 bgequ noname.160
1658 incl r9
1659noname.160:
1660
1661 movzwl 6(r6),r2
1662 bicl3 #-65536,24(r7),r3
1663 movzwl 26(r7),r0
1664 bicl2 #-65536,r0
1665 bicl3 #-65536,4(r6),-476(fp)
1666 bicl3 #-65536,r2,-480(fp)
1667 mull3 r0,-476(fp),-468(fp)
1668 mull2 r3,-476(fp)
1669 mull3 r3,-480(fp),-472(fp)
1670 mull2 r0,-480(fp)
1671 addl3 -468(fp),-472(fp),r0
1672 bicl3 #0,r0,-468(fp)
1673 cmpl -468(fp),-472(fp)
1674 bgequ noname.161
1675 addl2 #65536,-480(fp)
1676noname.161:
1677 movzwl -466(fp),r0
1678 bicl2 #-65536,r0
1679 addl2 r0,-480(fp)
1680 bicl3 #-65536,-468(fp),r0
1681 ashl #16,r0,-472(fp)
1682 addl3 -472(fp),-476(fp),r0
1683 bicl3 #0,r0,-476(fp)
1684 cmpl -476(fp),-472(fp)
1685 bgequ noname.162
1686 incl -480(fp)
1687noname.162:
1688 movl -476(fp),r1
1689 movl -480(fp),r2
1690 addl2 r1,r8
1691 bicl2 #0,r8
1692 cmpl r8,r1
1693 bgequ noname.163
1694 incl r2
1695noname.163:
1696 addl2 r2,r10
1697 bicl2 #0,r10
1698 cmpl r10,r2
1699 bgequ noname.164
1700 incl r9
1701noname.164:
1702
1703 movzwl 10(r6),r2
1704 bicl3 #-65536,20(r7),r3
1705 movzwl 22(r7),r0
1706 bicl2 #-65536,r0
1707 bicl3 #-65536,8(r6),-492(fp)
1708 bicl3 #-65536,r2,-496(fp)
1709 mull3 r0,-492(fp),-484(fp)
1710 mull2 r3,-492(fp)
1711 mull3 r3,-496(fp),-488(fp)
1712 mull2 r0,-496(fp)
1713 addl3 -484(fp),-488(fp),r0
1714 bicl3 #0,r0,-484(fp)
1715 cmpl -484(fp),-488(fp)
1716 bgequ noname.165
1717 addl2 #65536,-496(fp)
1718noname.165:
1719 movzwl -482(fp),r0
1720 bicl2 #-65536,r0
1721 addl2 r0,-496(fp)
1722 bicl3 #-65536,-484(fp),r0
1723 ashl #16,r0,-488(fp)
1724 addl3 -488(fp),-492(fp),r0
1725 bicl3 #0,r0,-492(fp)
1726 cmpl -492(fp),-488(fp)
1727 bgequ noname.166
1728 incl -496(fp)
1729noname.166:
1730 movl -492(fp),r1
1731 movl -496(fp),r2
1732 addl2 r1,r8
1733 bicl2 #0,r8
1734 cmpl r8,r1
1735 bgequ noname.167
1736 incl r2
1737noname.167:
1738 addl2 r2,r10
1739 bicl2 #0,r10
1740 cmpl r10,r2
1741 bgequ noname.168
1742 incl r9
1743noname.168:
1744
1745 movzwl 14(r6),r2
1746 bicl3 #-65536,16(r7),r3
1747 movzwl 18(r7),r0
1748 bicl2 #-65536,r0
1749 bicl3 #-65536,12(r6),-508(fp)
1750 bicl3 #-65536,r2,-512(fp)
1751 mull3 r0,-508(fp),-500(fp)
1752 mull2 r3,-508(fp)
1753 mull3 r3,-512(fp),-504(fp)
1754 mull2 r0,-512(fp)
1755 addl3 -500(fp),-504(fp),r0
1756 bicl3 #0,r0,-500(fp)
1757 cmpl -500(fp),-504(fp)
1758 bgequ noname.169
1759 addl2 #65536,-512(fp)
1760noname.169:
1761 movzwl -498(fp),r0
1762 bicl2 #-65536,r0
1763 addl2 r0,-512(fp)
1764 bicl3 #-65536,-500(fp),r0
1765 ashl #16,r0,-504(fp)
1766 addl3 -504(fp),-508(fp),r0
1767 bicl3 #0,r0,-508(fp)
1768 cmpl -508(fp),-504(fp)
1769 bgequ noname.170
1770 incl -512(fp)
1771noname.170:
1772 movl -508(fp),r1
1773 movl -512(fp),r2
1774 addl2 r1,r8
1775 bicl2 #0,r8
1776 cmpl r8,r1
1777 bgequ noname.171
1778 incl r2
1779noname.171:
1780 addl2 r2,r10
1781 bicl2 #0,r10
1782 cmpl r10,r2
1783 bgequ noname.172
1784 incl r9
1785noname.172:
1786
1787 movzwl 18(r6),r2
1788 bicl3 #-65536,12(r7),r3
1789 movzwl 14(r7),r0
1790 bicl2 #-65536,r0
1791 bicl3 #-65536,16(r6),-524(fp)
1792 bicl3 #-65536,r2,-528(fp)
1793 mull3 r0,-524(fp),-516(fp)
1794 mull2 r3,-524(fp)
1795 mull3 r3,-528(fp),-520(fp)
1796 mull2 r0,-528(fp)
1797 addl3 -516(fp),-520(fp),r0
1798 bicl3 #0,r0,-516(fp)
1799 cmpl -516(fp),-520(fp)
1800 bgequ noname.173
1801 addl2 #65536,-528(fp)
1802noname.173:
1803 movzwl -514(fp),r0
1804 bicl2 #-65536,r0
1805 addl2 r0,-528(fp)
1806 bicl3 #-65536,-516(fp),r0
1807 ashl #16,r0,-520(fp)
1808 addl3 -520(fp),-524(fp),r0
1809 bicl3 #0,r0,-524(fp)
1810 cmpl -524(fp),-520(fp)
1811 bgequ noname.174
1812 incl -528(fp)
1813noname.174:
1814 movl -524(fp),r1
1815 movl -528(fp),r2
1816 addl2 r1,r8
1817 bicl2 #0,r8
1818 cmpl r8,r1
1819 bgequ noname.175
1820 incl r2
1821noname.175:
1822 addl2 r2,r10
1823 bicl2 #0,r10
1824 cmpl r10,r2
1825 bgequ noname.176
1826 incl r9
1827noname.176:
1828
1829 movzwl 22(r6),r2
1830 bicl3 #-65536,8(r7),r3
1831 movzwl 10(r7),r0
1832 bicl2 #-65536,r0
1833 bicl3 #-65536,20(r6),-540(fp)
1834 bicl3 #-65536,r2,-544(fp)
1835 mull3 r0,-540(fp),-532(fp)
1836 mull2 r3,-540(fp)
1837 mull3 r3,-544(fp),-536(fp)
1838 mull2 r0,-544(fp)
1839 addl3 -532(fp),-536(fp),r0
1840 bicl3 #0,r0,-532(fp)
1841 cmpl -532(fp),-536(fp)
1842 bgequ noname.177
1843 addl2 #65536,-544(fp)
1844noname.177:
1845 movzwl -530(fp),r0
1846 bicl2 #-65536,r0
1847 addl2 r0,-544(fp)
1848 bicl3 #-65536,-532(fp),r0
1849 ashl #16,r0,-536(fp)
1850 addl3 -536(fp),-540(fp),r0
1851 bicl3 #0,r0,-540(fp)
1852 cmpl -540(fp),-536(fp)
1853 bgequ noname.178
1854 incl -544(fp)
1855noname.178:
1856 movl -540(fp),r1
1857 movl -544(fp),r2
1858 addl2 r1,r8
1859 bicl2 #0,r8
1860 cmpl r8,r1
1861 bgequ noname.179
1862 incl r2
1863noname.179:
1864 addl2 r2,r10
1865 bicl2 #0,r10
1866 cmpl r10,r2
1867 bgequ noname.180
1868 incl r9
1869noname.180:
1870
1871 movzwl 26(r6),r2
1872 bicl3 #-65536,4(r7),r3
1873 movzwl 6(r7),r0
1874 bicl2 #-65536,r0
1875 bicl3 #-65536,24(r6),-556(fp)
1876 bicl3 #-65536,r2,-560(fp)
1877 mull3 r0,-556(fp),-548(fp)
1878 mull2 r3,-556(fp)
1879 mull3 r3,-560(fp),-552(fp)
1880 mull2 r0,-560(fp)
1881 addl3 -548(fp),-552(fp),r0
1882 bicl3 #0,r0,-548(fp)
1883 cmpl -548(fp),-552(fp)
1884 bgequ noname.181
1885 addl2 #65536,-560(fp)
1886noname.181:
1887 movzwl -546(fp),r0
1888 bicl2 #-65536,r0
1889 addl2 r0,-560(fp)
1890 bicl3 #-65536,-548(fp),r0
1891 ashl #16,r0,-552(fp)
1892 addl3 -552(fp),-556(fp),r0
1893 bicl3 #0,r0,-556(fp)
1894 cmpl -556(fp),-552(fp)
1895 bgequ noname.182
1896 incl -560(fp)
1897noname.182:
1898 movl -556(fp),r1
1899 movl -560(fp),r2
1900 addl2 r1,r8
1901 bicl2 #0,r8
1902 cmpl r8,r1
1903 bgequ noname.183
1904 incl r2
1905noname.183:
1906 addl2 r2,r10
1907 bicl2 #0,r10
1908 cmpl r10,r2
1909 bgequ noname.184
1910 incl r9
1911noname.184:
1912
1913 movzwl 30(r6),r2
1914 bicl3 #-65536,(r7),r3
1915 movzwl 2(r7),r0
1916 bicl2 #-65536,r0
1917 bicl3 #-65536,28(r6),-572(fp)
1918 bicl3 #-65536,r2,-576(fp)
1919 mull3 r0,-572(fp),-564(fp)
1920 mull2 r3,-572(fp)
1921 mull3 r3,-576(fp),-568(fp)
1922 mull2 r0,-576(fp)
1923 addl3 -564(fp),-568(fp),r0
1924 bicl3 #0,r0,-564(fp)
1925 cmpl -564(fp),-568(fp)
1926 bgequ noname.185
1927 addl2 #65536,-576(fp)
1928noname.185:
1929 movzwl -562(fp),r0
1930 bicl2 #-65536,r0
1931 addl2 r0,-576(fp)
1932 bicl3 #-65536,-564(fp),r0
1933 ashl #16,r0,-568(fp)
1934 addl3 -568(fp),-572(fp),r0
1935 bicl3 #0,r0,-572(fp)
1936 cmpl -572(fp),-568(fp)
1937 bgequ noname.186
1938 incl -576(fp)
1939noname.186:
1940 movl -572(fp),r1
1941 movl -576(fp),r2
1942 addl2 r1,r8
1943 bicl2 #0,r8
1944 cmpl r8,r1
1945 bgequ noname.187
1946 incl r2
1947noname.187:
1948 addl2 r2,r10
1949 bicl2 #0,r10
1950 cmpl r10,r2
1951 bgequ noname.188
1952 incl r9
1953noname.188:
1954
1955 movl r8,28(r11)
1956
1957 clrl r8
1958
1959 movzwl 30(r6),r2
1960 bicl3 #-65536,4(r7),r3
1961 movzwl 6(r7),r0
1962 bicl2 #-65536,r0
1963 bicl3 #-65536,28(r6),-588(fp)
1964 bicl3 #-65536,r2,-592(fp)
1965 mull3 r0,-588(fp),-580(fp)
1966 mull2 r3,-588(fp)
1967 mull3 r3,-592(fp),-584(fp)
1968 mull2 r0,-592(fp)
1969 addl3 -580(fp),-584(fp),r0
1970 bicl3 #0,r0,-580(fp)
1971 cmpl -580(fp),-584(fp)
1972 bgequ noname.189
1973 addl2 #65536,-592(fp)
1974noname.189:
1975 movzwl -578(fp),r0
1976 bicl2 #-65536,r0
1977 addl2 r0,-592(fp)
1978 bicl3 #-65536,-580(fp),r0
1979 ashl #16,r0,-584(fp)
1980 addl3 -584(fp),-588(fp),r0
1981 bicl3 #0,r0,-588(fp)
1982 cmpl -588(fp),-584(fp)
1983 bgequ noname.190
1984 incl -592(fp)
1985noname.190:
1986 movl -588(fp),r1
1987 movl -592(fp),r2
1988 addl2 r1,r10
1989 bicl2 #0,r10
1990 cmpl r10,r1
1991 bgequ noname.191
1992 incl r2
1993noname.191:
1994 addl2 r2,r9
1995 bicl2 #0,r9
1996 cmpl r9,r2
1997 bgequ noname.192
1998 incl r8
1999noname.192:
2000
2001 movzwl 26(r6),r2
2002 bicl3 #-65536,8(r7),r3
2003 movzwl 10(r7),r0
2004 bicl2 #-65536,r0
2005 bicl3 #-65536,24(r6),-604(fp)
2006 bicl3 #-65536,r2,-608(fp)
2007 mull3 r0,-604(fp),-596(fp)
2008 mull2 r3,-604(fp)
2009 mull3 r3,-608(fp),-600(fp)
2010 mull2 r0,-608(fp)
2011 addl3 -596(fp),-600(fp),r0
2012 bicl3 #0,r0,-596(fp)
2013 cmpl -596(fp),-600(fp)
2014 bgequ noname.193
2015 addl2 #65536,-608(fp)
2016noname.193:
2017 movzwl -594(fp),r0
2018 bicl2 #-65536,r0
2019 addl2 r0,-608(fp)
2020 bicl3 #-65536,-596(fp),r0
2021 ashl #16,r0,-600(fp)
2022 addl3 -600(fp),-604(fp),r0
2023 bicl3 #0,r0,-604(fp)
2024 cmpl -604(fp),-600(fp)
2025 bgequ noname.194
2026 incl -608(fp)
2027noname.194:
2028 movl -604(fp),r1
2029 movl -608(fp),r2
2030 addl2 r1,r10
2031 bicl2 #0,r10
2032 cmpl r10,r1
2033 bgequ noname.195
2034 incl r2
2035noname.195:
2036 addl2 r2,r9
2037 bicl2 #0,r9
2038 cmpl r9,r2
2039 bgequ noname.196
2040 incl r8
2041noname.196:
2042
2043 movzwl 22(r6),r2
2044 bicl3 #-65536,12(r7),r3
2045 movzwl 14(r7),r0
2046 bicl2 #-65536,r0
2047 bicl3 #-65536,20(r6),-620(fp)
2048 bicl3 #-65536,r2,-624(fp)
2049 mull3 r0,-620(fp),-612(fp)
2050 mull2 r3,-620(fp)
2051 mull3 r3,-624(fp),-616(fp)
2052 mull2 r0,-624(fp)
2053 addl3 -612(fp),-616(fp),r0
2054 bicl3 #0,r0,-612(fp)
2055 cmpl -612(fp),-616(fp)
2056 bgequ noname.197
2057 addl2 #65536,-624(fp)
2058noname.197:
2059 movzwl -610(fp),r0
2060 bicl2 #-65536,r0
2061 addl2 r0,-624(fp)
2062 bicl3 #-65536,-612(fp),r0
2063 ashl #16,r0,-616(fp)
2064 addl3 -616(fp),-620(fp),r0
2065 bicl3 #0,r0,-620(fp)
2066 cmpl -620(fp),-616(fp)
2067 bgequ noname.198
2068 incl -624(fp)
2069noname.198:
2070 movl -620(fp),r1
2071 movl -624(fp),r2
2072 addl2 r1,r10
2073 bicl2 #0,r10
2074 cmpl r10,r1
2075 bgequ noname.199
2076 incl r2
2077noname.199:
2078 addl2 r2,r9
2079 bicl2 #0,r9
2080 cmpl r9,r2
2081 bgequ noname.200
2082 incl r8
2083noname.200:
2084
2085 movzwl 18(r6),r2
2086 bicl3 #-65536,16(r7),r3
2087 movzwl 18(r7),r0
2088 bicl2 #-65536,r0
2089 bicl3 #-65536,16(r6),-636(fp)
2090 bicl3 #-65536,r2,-640(fp)
2091 mull3 r0,-636(fp),-628(fp)
2092 mull2 r3,-636(fp)
2093 mull3 r3,-640(fp),-632(fp)
2094 mull2 r0,-640(fp)
2095 addl3 -628(fp),-632(fp),r0
2096 bicl3 #0,r0,-628(fp)
2097 cmpl -628(fp),-632(fp)
2098 bgequ noname.201
2099 addl2 #65536,-640(fp)
2100noname.201:
2101 movzwl -626(fp),r0
2102 bicl2 #-65536,r0
2103 addl2 r0,-640(fp)
2104 bicl3 #-65536,-628(fp),r0
2105 ashl #16,r0,-632(fp)
2106 addl3 -632(fp),-636(fp),r0
2107 bicl3 #0,r0,-636(fp)
2108 cmpl -636(fp),-632(fp)
2109 bgequ noname.202
2110 incl -640(fp)
2111noname.202:
2112 movl -636(fp),r1
2113 movl -640(fp),r2
2114 addl2 r1,r10
2115 bicl2 #0,r10
2116 cmpl r10,r1
2117 bgequ noname.203
2118 incl r2
2119noname.203:
2120 addl2 r2,r9
2121 bicl2 #0,r9
2122 cmpl r9,r2
2123 bgequ noname.204
2124 incl r8
2125noname.204:
2126
2127 movzwl 14(r6),r2
2128 bicl3 #-65536,20(r7),r3
2129 movzwl 22(r7),r0
2130 bicl2 #-65536,r0
2131 bicl3 #-65536,12(r6),-652(fp)
2132 bicl3 #-65536,r2,-656(fp)
2133 mull3 r0,-652(fp),-644(fp)
2134 mull2 r3,-652(fp)
2135 mull3 r3,-656(fp),-648(fp)
2136 mull2 r0,-656(fp)
2137 addl3 -644(fp),-648(fp),r0
2138 bicl3 #0,r0,-644(fp)
2139 cmpl -644(fp),-648(fp)
2140 bgequ noname.205
2141 addl2 #65536,-656(fp)
2142noname.205:
2143 movzwl -642(fp),r0
2144 bicl2 #-65536,r0
2145 addl2 r0,-656(fp)
2146 bicl3 #-65536,-644(fp),r0
2147 ashl #16,r0,-648(fp)
2148 addl3 -648(fp),-652(fp),r0
2149 bicl3 #0,r0,-652(fp)
2150 cmpl -652(fp),-648(fp)
2151 bgequ noname.206
2152 incl -656(fp)
2153noname.206:
2154 movl -652(fp),r1
2155 movl -656(fp),r2
2156 addl2 r1,r10
2157 bicl2 #0,r10
2158 cmpl r10,r1
2159 bgequ noname.207
2160 incl r2
2161noname.207:
2162 addl2 r2,r9
2163 bicl2 #0,r9
2164 cmpl r9,r2
2165 bgequ noname.208
2166 incl r8
2167noname.208:
2168
2169 movzwl 10(r6),r2
2170 bicl3 #-65536,24(r7),r3
2171 movzwl 26(r7),r0
2172 bicl2 #-65536,r0
2173 bicl3 #-65536,8(r6),-668(fp)
2174 bicl3 #-65536,r2,-672(fp)
2175 mull3 r0,-668(fp),-660(fp)
2176 mull2 r3,-668(fp)
2177 mull3 r3,-672(fp),-664(fp)
2178 mull2 r0,-672(fp)
2179 addl3 -660(fp),-664(fp),r0
2180 bicl3 #0,r0,-660(fp)
2181 cmpl -660(fp),-664(fp)
2182 bgequ noname.209
2183 addl2 #65536,-672(fp)
2184noname.209:
2185 movzwl -658(fp),r0
2186 bicl2 #-65536,r0
2187 addl2 r0,-672(fp)
2188 bicl3 #-65536,-660(fp),r0
2189 ashl #16,r0,-664(fp)
2190 addl3 -664(fp),-668(fp),r0
2191 bicl3 #0,r0,-668(fp)
2192 cmpl -668(fp),-664(fp)
2193 bgequ noname.210
2194 incl -672(fp)
2195noname.210:
2196 movl -668(fp),r1
2197 movl -672(fp),r2
2198 addl2 r1,r10
2199 bicl2 #0,r10
2200 cmpl r10,r1
2201 bgequ noname.211
2202 incl r2
2203noname.211:
2204 addl2 r2,r9
2205 bicl2 #0,r9
2206 cmpl r9,r2
2207 bgequ noname.212
2208 incl r8
2209noname.212:
2210
2211 movzwl 6(r6),r2
2212 bicl3 #-65536,28(r7),r3
2213 movzwl 30(r7),r0
2214 bicl2 #-65536,r0
2215 bicl3 #-65536,4(r6),-684(fp)
2216 bicl3 #-65536,r2,-688(fp)
2217 mull3 r0,-684(fp),-676(fp)
2218 mull2 r3,-684(fp)
2219 mull3 r3,-688(fp),-680(fp)
2220 mull2 r0,-688(fp)
2221 addl3 -676(fp),-680(fp),r0
2222 bicl3 #0,r0,-676(fp)
2223 cmpl -676(fp),-680(fp)
2224 bgequ noname.213
2225 addl2 #65536,-688(fp)
2226noname.213:
2227 movzwl -674(fp),r0
2228 bicl2 #-65536,r0
2229 addl2 r0,-688(fp)
2230 bicl3 #-65536,-676(fp),r0
2231 ashl #16,r0,-680(fp)
2232 addl3 -680(fp),-684(fp),r0
2233 bicl3 #0,r0,-684(fp)
2234 cmpl -684(fp),-680(fp)
2235 bgequ noname.214
2236 incl -688(fp)
2237noname.214:
2238 movl -684(fp),r1
2239 movl -688(fp),r2
2240 addl2 r1,r10
2241 bicl2 #0,r10
2242 cmpl r10,r1
2243 bgequ noname.215
2244 incl r2
2245noname.215:
2246 addl2 r2,r9
2247 bicl2 #0,r9
2248 cmpl r9,r2
2249 bgequ noname.216
2250 incl r8
2251noname.216:
2252
2253 movl r10,32(r11)
2254
2255 clrl r10
2256
2257 movzwl 10(r6),r2
2258 bicl3 #-65536,28(r7),r3
2259 movzwl 30(r7),r0
2260 bicl2 #-65536,r0
2261 bicl3 #-65536,8(r6),-700(fp)
2262 bicl3 #-65536,r2,-704(fp)
2263 mull3 r0,-700(fp),-692(fp)
2264 mull2 r3,-700(fp)
2265 mull3 r3,-704(fp),-696(fp)
2266 mull2 r0,-704(fp)
2267 addl3 -692(fp),-696(fp),r0
2268 bicl3 #0,r0,-692(fp)
2269 cmpl -692(fp),-696(fp)
2270 bgequ noname.217
2271 addl2 #65536,-704(fp)
2272noname.217:
2273 movzwl -690(fp),r0
2274 bicl2 #-65536,r0
2275 addl2 r0,-704(fp)
2276 bicl3 #-65536,-692(fp),r0
2277 ashl #16,r0,-696(fp)
2278 addl3 -696(fp),-700(fp),r0
2279 bicl3 #0,r0,-700(fp)
2280 cmpl -700(fp),-696(fp)
2281 bgequ noname.218
2282 incl -704(fp)
2283noname.218:
2284 movl -700(fp),r1
2285 movl -704(fp),r2
2286 addl2 r1,r9
2287 bicl2 #0,r9
2288 cmpl r9,r1
2289 bgequ noname.219
2290 incl r2
2291noname.219:
2292 addl2 r2,r8
2293 bicl2 #0,r8
2294 cmpl r8,r2
2295 bgequ noname.220
2296 incl r10
2297noname.220:
2298
2299 movzwl 14(r6),r2
2300 bicl3 #-65536,24(r7),r3
2301 movzwl 26(r7),r0
2302 bicl2 #-65536,r0
2303 bicl3 #-65536,12(r6),-716(fp)
2304 bicl3 #-65536,r2,-720(fp)
2305 mull3 r0,-716(fp),-708(fp)
2306 mull2 r3,-716(fp)
2307 mull3 r3,-720(fp),-712(fp)
2308 mull2 r0,-720(fp)
2309 addl3 -708(fp),-712(fp),r0
2310 bicl3 #0,r0,-708(fp)
2311 cmpl -708(fp),-712(fp)
2312 bgequ noname.221
2313 addl2 #65536,-720(fp)
2314noname.221:
2315 movzwl -706(fp),r0
2316 bicl2 #-65536,r0
2317 addl2 r0,-720(fp)
2318 bicl3 #-65536,-708(fp),r0
2319 ashl #16,r0,-712(fp)
2320 addl3 -712(fp),-716(fp),r0
2321 bicl3 #0,r0,-716(fp)
2322 cmpl -716(fp),-712(fp)
2323 bgequ noname.222
2324 incl -720(fp)
2325noname.222:
2326 movl -716(fp),r1
2327 movl -720(fp),r2
2328 addl2 r1,r9
2329 bicl2 #0,r9
2330 cmpl r9,r1
2331 bgequ noname.223
2332 incl r2
2333noname.223:
2334 addl2 r2,r8
2335 bicl2 #0,r8
2336 cmpl r8,r2
2337 bgequ noname.224
2338 incl r10
2339noname.224:
2340
2341 movzwl 18(r6),r2
2342 bicl3 #-65536,20(r7),r3
2343 movzwl 22(r7),r0
2344 bicl2 #-65536,r0
2345 bicl3 #-65536,16(r6),-732(fp)
2346 bicl3 #-65536,r2,-736(fp)
2347 mull3 r0,-732(fp),-724(fp)
2348 mull2 r3,-732(fp)
2349 mull3 r3,-736(fp),-728(fp)
2350 mull2 r0,-736(fp)
2351 addl3 -724(fp),-728(fp),r0
2352 bicl3 #0,r0,-724(fp)
2353 cmpl -724(fp),-728(fp)
2354 bgequ noname.225
2355 addl2 #65536,-736(fp)
2356noname.225:
2357 movzwl -722(fp),r0
2358 bicl2 #-65536,r0
2359 addl2 r0,-736(fp)
2360 bicl3 #-65536,-724(fp),r0
2361 ashl #16,r0,-728(fp)
2362 addl3 -728(fp),-732(fp),r0
2363 bicl3 #0,r0,-732(fp)
2364 cmpl -732(fp),-728(fp)
2365 bgequ noname.226
2366 incl -736(fp)
2367noname.226:
2368 movl -732(fp),r1
2369 movl -736(fp),r2
2370 addl2 r1,r9
2371 bicl2 #0,r9
2372 cmpl r9,r1
2373 bgequ noname.227
2374 incl r2
2375noname.227:
2376 addl2 r2,r8
2377 bicl2 #0,r8
2378 cmpl r8,r2
2379 bgequ noname.228
2380 incl r10
2381noname.228:
2382
2383 movzwl 22(r6),r2
2384 bicl3 #-65536,16(r7),r3
2385 movzwl 18(r7),r0
2386 bicl2 #-65536,r0
2387 bicl3 #-65536,20(r6),-748(fp)
2388 bicl3 #-65536,r2,-752(fp)
2389 mull3 r0,-748(fp),-740(fp)
2390 mull2 r3,-748(fp)
2391 mull3 r3,-752(fp),-744(fp)
2392 mull2 r0,-752(fp)
2393 addl3 -740(fp),-744(fp),r0
2394 bicl3 #0,r0,-740(fp)
2395 cmpl -740(fp),-744(fp)
2396 bgequ noname.229
2397 addl2 #65536,-752(fp)
2398noname.229:
2399 movzwl -738(fp),r0
2400 bicl2 #-65536,r0
2401 addl2 r0,-752(fp)
2402 bicl3 #-65536,-740(fp),r0
2403 ashl #16,r0,-744(fp)
2404 addl3 -744(fp),-748(fp),r0
2405 bicl3 #0,r0,-748(fp)
2406 cmpl -748(fp),-744(fp)
2407 bgequ noname.230
2408 incl -752(fp)
2409noname.230:
2410 movl -748(fp),r1
2411 movl -752(fp),r2
2412 addl2 r1,r9
2413 bicl2 #0,r9
2414 cmpl r9,r1
2415 bgequ noname.231
2416 incl r2
2417noname.231:
2418 addl2 r2,r8
2419 bicl2 #0,r8
2420 cmpl r8,r2
2421 bgequ noname.232
2422 incl r10
2423noname.232:
2424
2425 movzwl 26(r6),r2
2426 bicl3 #-65536,12(r7),r3
2427 movzwl 14(r7),r0
2428 bicl2 #-65536,r0
2429 bicl3 #-65536,24(r6),-764(fp)
2430 bicl3 #-65536,r2,-768(fp)
2431 mull3 r0,-764(fp),-756(fp)
2432 mull2 r3,-764(fp)
2433 mull3 r3,-768(fp),-760(fp)
2434 mull2 r0,-768(fp)
2435 addl3 -756(fp),-760(fp),r0
2436 bicl3 #0,r0,-756(fp)
2437 cmpl -756(fp),-760(fp)
2438 bgequ noname.233
2439 addl2 #65536,-768(fp)
2440noname.233:
2441 movzwl -754(fp),r0
2442 bicl2 #-65536,r0
2443 addl2 r0,-768(fp)
2444 bicl3 #-65536,-756(fp),r0
2445 ashl #16,r0,-760(fp)
2446 addl3 -760(fp),-764(fp),r0
2447 bicl3 #0,r0,-764(fp)
2448 cmpl -764(fp),-760(fp)
2449 bgequ noname.234
2450 incl -768(fp)
2451noname.234:
2452 movl -764(fp),r1
2453 movl -768(fp),r2
2454 addl2 r1,r9
2455 bicl2 #0,r9
2456 cmpl r9,r1
2457 bgequ noname.235
2458 incl r2
2459noname.235:
2460 addl2 r2,r8
2461 bicl2 #0,r8
2462 cmpl r8,r2
2463 bgequ noname.236
2464 incl r10
2465noname.236:
2466
2467 bicl3 #-65536,28(r6),r3
2468 movzwl 30(r6),r1
2469 bicl2 #-65536,r1
2470 bicl3 #-65536,8(r7),r2
2471 movzwl 10(r7),r0
2472 bicl2 #-65536,r0
2473 movl r3,r5
2474 movl r1,r4
2475 mull3 r0,r5,-772(fp)
2476 mull2 r2,r5
2477 mull3 r2,r4,-776(fp)
2478 mull2 r0,r4
2479 addl3 -772(fp),-776(fp),r0
2480 bicl3 #0,r0,-772(fp)
2481 cmpl -772(fp),-776(fp)
2482 bgequ noname.237
2483 addl2 #65536,r4
2484noname.237:
2485 movzwl -770(fp),r0
2486 bicl2 #-65536,r0
2487 addl2 r0,r4
2488 bicl3 #-65536,-772(fp),r0
2489 ashl #16,r0,-776(fp)
2490 addl2 -776(fp),r5
2491 bicl2 #0,r5
2492 cmpl r5,-776(fp)
2493 bgequ noname.238
2494 incl r4
2495noname.238:
2496 movl r5,r1
2497 movl r4,r2
2498 addl2 r1,r9
2499 bicl2 #0,r9
2500 cmpl r9,r1
2501 bgequ noname.239
2502 incl r2
2503noname.239:
2504 addl2 r2,r8
2505 bicl2 #0,r8
2506 cmpl r8,r2
2507 bgequ noname.240
2508 incl r10
2509noname.240:
2510
2511 movl r9,36(r11)
2512
2513 clrl r9
2514
2515 bicl3 #-65536,28(r6),r3
2516 movzwl 30(r6),r1
2517 bicl2 #-65536,r1
2518 bicl3 #-65536,12(r7),r2
2519 movzwl 14(r7),r0
2520 bicl2 #-65536,r0
2521 movl r3,r5
2522 movl r1,r4
2523 mull3 r0,r5,-780(fp)
2524 mull2 r2,r5
2525 mull3 r2,r4,-784(fp)
2526 mull2 r0,r4
2527 addl3 -780(fp),-784(fp),r0
2528 bicl3 #0,r0,-780(fp)
2529 cmpl -780(fp),-784(fp)
2530 bgequ noname.241
2531 addl2 #65536,r4
2532noname.241:
2533 movzwl -778(fp),r0
2534 bicl2 #-65536,r0
2535 addl2 r0,r4
2536 bicl3 #-65536,-780(fp),r0
2537 ashl #16,r0,-784(fp)
2538 addl2 -784(fp),r5
2539 bicl2 #0,r5
2540 cmpl r5,-784(fp)
2541 bgequ noname.242
2542 incl r4
2543noname.242:
2544 movl r5,r1
2545 movl r4,r2
2546 addl2 r1,r8
2547 bicl2 #0,r8
2548 cmpl r8,r1
2549 bgequ noname.243
2550 incl r2
2551noname.243:
2552 addl2 r2,r10
2553 bicl2 #0,r10
2554 cmpl r10,r2
2555 bgequ noname.244
2556 incl r9
2557noname.244:
2558
2559 bicl3 #-65536,24(r6),r3
2560 movzwl 26(r6),r1
2561 bicl2 #-65536,r1
2562 bicl3 #-65536,16(r7),r2
2563 movzwl 18(r7),r0
2564 bicl2 #-65536,r0
2565 movl r3,r5
2566 movl r1,r4
2567 mull3 r0,r5,-788(fp)
2568 mull2 r2,r5
2569 mull3 r2,r4,-792(fp)
2570 mull2 r0,r4
2571 addl3 -788(fp),-792(fp),r0
2572 bicl3 #0,r0,-788(fp)
2573 cmpl -788(fp),-792(fp)
2574 bgequ noname.245
2575 addl2 #65536,r4
2576noname.245:
2577 movzwl -786(fp),r0
2578 bicl2 #-65536,r0
2579 addl2 r0,r4
2580 bicl3 #-65536,-788(fp),r0
2581 ashl #16,r0,-792(fp)
2582 addl2 -792(fp),r5
2583 bicl2 #0,r5
2584 cmpl r5,-792(fp)
2585 bgequ noname.246
2586 incl r4
2587noname.246:
2588 movl r5,r1
2589 movl r4,r2
2590 addl2 r1,r8
2591 bicl2 #0,r8
2592 cmpl r8,r1
2593 bgequ noname.247
2594 incl r2
2595noname.247:
2596 addl2 r2,r10
2597 bicl2 #0,r10
2598 cmpl r10,r2
2599 bgequ noname.248
2600 incl r9
2601noname.248:
2602
2603 bicl3 #-65536,20(r6),r3
2604 movzwl 22(r6),r1
2605 bicl2 #-65536,r1
2606 bicl3 #-65536,20(r7),r2
2607 movzwl 22(r7),r0
2608 bicl2 #-65536,r0
2609 movl r3,r5
2610 movl r1,r4
2611 mull3 r0,r5,-796(fp)
2612 mull2 r2,r5
2613 mull3 r2,r4,-800(fp)
2614 mull2 r0,r4
2615 addl3 -796(fp),-800(fp),r0
2616 bicl3 #0,r0,-796(fp)
2617 cmpl -796(fp),-800(fp)
2618 bgequ noname.249
2619 addl2 #65536,r4
2620noname.249:
2621 movzwl -794(fp),r0
2622 bicl2 #-65536,r0
2623 addl2 r0,r4
2624 bicl3 #-65536,-796(fp),r0
2625 ashl #16,r0,-800(fp)
2626 addl2 -800(fp),r5
2627 bicl2 #0,r5
2628 cmpl r5,-800(fp)
2629 bgequ noname.250
2630 incl r4
2631noname.250:
2632 movl r5,r1
2633 movl r4,r2
2634 addl2 r1,r8
2635 bicl2 #0,r8
2636 cmpl r8,r1
2637 bgequ noname.251
2638 incl r2
2639noname.251:
2640 addl2 r2,r10
2641 bicl2 #0,r10
2642 cmpl r10,r2
2643 bgequ noname.252
2644 incl r9
2645noname.252:
2646
2647 bicl3 #-65536,16(r6),r3
2648 movzwl 18(r6),r1
2649 bicl2 #-65536,r1
2650 bicl3 #-65536,24(r7),r2
2651 movzwl 26(r7),r0
2652 bicl2 #-65536,r0
2653 movl r3,r5
2654 movl r1,r4
2655 mull3 r0,r5,-804(fp)
2656 mull2 r2,r5
2657 mull3 r2,r4,-808(fp)
2658 mull2 r0,r4
2659 addl3 -804(fp),-808(fp),r0
2660 bicl3 #0,r0,-804(fp)
2661 cmpl -804(fp),-808(fp)
2662 bgequ noname.253
2663 addl2 #65536,r4
2664noname.253:
2665 movzwl -802(fp),r0
2666 bicl2 #-65536,r0
2667 addl2 r0,r4
2668 bicl3 #-65536,-804(fp),r0
2669 ashl #16,r0,-808(fp)
2670 addl2 -808(fp),r5
2671 bicl2 #0,r5
2672 cmpl r5,-808(fp)
2673 bgequ noname.254
2674 incl r4
2675noname.254:
2676 movl r5,r1
2677 movl r4,r2
2678 addl2 r1,r8
2679 bicl2 #0,r8
2680 cmpl r8,r1
2681 bgequ noname.255
2682 incl r2
2683noname.255:
2684 addl2 r2,r10
2685 bicl2 #0,r10
2686 cmpl r10,r2
2687 bgequ noname.256
2688 incl r9
2689noname.256:
2690
2691 bicl3 #-65536,12(r6),r3
2692 movzwl 14(r6),r1
2693 bicl2 #-65536,r1
2694 bicl3 #-65536,28(r7),r2
2695 movzwl 30(r7),r0
2696 bicl2 #-65536,r0
2697 movl r3,r5
2698 movl r1,r4
2699 mull3 r0,r5,-812(fp)
2700 mull2 r2,r5
2701 mull3 r2,r4,-816(fp)
2702 mull2 r0,r4
2703 addl3 -812(fp),-816(fp),r0
2704 bicl3 #0,r0,-812(fp)
2705 cmpl -812(fp),-816(fp)
2706 bgequ noname.257
2707 addl2 #65536,r4
2708noname.257:
2709 movzwl -810(fp),r0
2710 bicl2 #-65536,r0
2711 addl2 r0,r4
2712 bicl3 #-65536,-812(fp),r0
2713 ashl #16,r0,-816(fp)
2714 addl2 -816(fp),r5
2715 bicl2 #0,r5
2716 cmpl r5,-816(fp)
2717 bgequ noname.258
2718 incl r4
2719noname.258:
2720 movl r5,r1
2721 movl r4,r2
2722 addl2 r1,r8
2723 bicl2 #0,r8
2724 cmpl r8,r1
2725 bgequ noname.259
2726 incl r2
2727noname.259:
2728 addl2 r2,r10
2729 bicl2 #0,r10
2730 cmpl r10,r2
2731 bgequ noname.260
2732 incl r9
2733noname.260:
2734
2735 movl r8,40(r11)
2736
2737 clrl r8
2738
2739 bicl3 #-65536,16(r6),r3
2740 movzwl 18(r6),r2
2741 bicl3 #-65536,28(r7),r1
2742 movzwl 30(r7),r0
2743 bicl2 #-65536,r0
2744 movl r3,r4
2745 bicl3 #-65536,r2,-828(fp)
2746 mull3 r0,r4,-820(fp)
2747 mull2 r1,r4
2748 mull3 r1,-828(fp),-824(fp)
2749 mull2 r0,-828(fp)
2750 addl3 -820(fp),-824(fp),r0
2751 bicl3 #0,r0,-820(fp)
2752 cmpl -820(fp),-824(fp)
2753 bgequ noname.261
2754 addl2 #65536,-828(fp)
2755noname.261:
2756 movzwl -818(fp),r0
2757 bicl2 #-65536,r0
2758 addl2 r0,-828(fp)
2759 bicl3 #-65536,-820(fp),r0
2760 ashl #16,r0,-824(fp)
2761 addl2 -824(fp),r4
2762 bicl2 #0,r4
2763 cmpl r4,-824(fp)
2764 bgequ noname.262
2765 incl -828(fp)
2766noname.262:
2767 movl r4,r1
2768 movl -828(fp),r2
2769 addl2 r1,r10
2770 bicl2 #0,r10
2771 cmpl r10,r1
2772 bgequ noname.263
2773 incl r2
2774noname.263:
2775 addl2 r2,r9
2776 bicl2 #0,r9
2777 cmpl r9,r2
2778 bgequ noname.264
2779 incl r8
2780noname.264:
2781
2782 movzwl 22(r6),r2
2783 bicl3 #-65536,24(r7),r3
2784 movzwl 26(r7),r0
2785 bicl2 #-65536,r0
2786 bicl3 #-65536,20(r6),-840(fp)
2787 bicl3 #-65536,r2,-844(fp)
2788 mull3 r0,-840(fp),-832(fp)
2789 mull2 r3,-840(fp)
2790 mull3 r3,-844(fp),-836(fp)
2791 mull2 r0,-844(fp)
2792 addl3 -832(fp),-836(fp),r0
2793 bicl3 #0,r0,-832(fp)
2794 cmpl -832(fp),-836(fp)
2795 bgequ noname.265
2796 addl2 #65536,-844(fp)
2797noname.265:
2798 movzwl -830(fp),r0
2799 bicl2 #-65536,r0
2800 addl2 r0,-844(fp)
2801 bicl3 #-65536,-832(fp),r0
2802 ashl #16,r0,-836(fp)
2803 addl3 -836(fp),-840(fp),r0
2804 bicl3 #0,r0,-840(fp)
2805 cmpl -840(fp),-836(fp)
2806 bgequ noname.266
2807 incl -844(fp)
2808noname.266:
2809 movl -840(fp),r1
2810 movl -844(fp),r2
2811 addl2 r1,r10
2812 bicl2 #0,r10
2813 cmpl r10,r1
2814 bgequ noname.267
2815 incl r2
2816noname.267:
2817 addl2 r2,r9
2818 bicl2 #0,r9
2819 cmpl r9,r2
2820 bgequ noname.268
2821 incl r8
2822noname.268:
2823
2824 bicl3 #-65536,24(r6),r3
2825 movzwl 26(r6),r1
2826 bicl2 #-65536,r1
2827 bicl3 #-65536,20(r7),r2
2828 movzwl 22(r7),r0
2829 bicl2 #-65536,r0
2830 movl r3,r5
2831 movl r1,r4
2832 mull3 r0,r5,-848(fp)
2833 mull2 r2,r5
2834 mull3 r2,r4,-852(fp)
2835 mull2 r0,r4
2836 addl3 -848(fp),-852(fp),r0
2837 bicl3 #0,r0,-848(fp)
2838 cmpl -848(fp),-852(fp)
2839 bgequ noname.269
2840 addl2 #65536,r4
2841noname.269:
2842 movzwl -846(fp),r0
2843 bicl2 #-65536,r0
2844 addl2 r0,r4
2845 bicl3 #-65536,-848(fp),r0
2846 ashl #16,r0,-852(fp)
2847 addl2 -852(fp),r5
2848 bicl2 #0,r5
2849 cmpl r5,-852(fp)
2850 bgequ noname.270
2851 incl r4
2852noname.270:
2853 movl r5,r1
2854 movl r4,r2
2855 addl2 r1,r10
2856 bicl2 #0,r10
2857 cmpl r10,r1
2858 bgequ noname.271
2859 incl r2
2860noname.271:
2861 addl2 r2,r9
2862 bicl2 #0,r9
2863 cmpl r9,r2
2864 bgequ noname.272
2865 incl r8
2866noname.272:
2867
2868 bicl3 #-65536,28(r6),r3
2869 movzwl 30(r6),r1
2870 bicl2 #-65536,r1
2871 bicl3 #-65536,16(r7),r2
2872 movzwl 18(r7),r0
2873 bicl2 #-65536,r0
2874 movl r3,r5
2875 movl r1,r4
2876 mull3 r0,r5,-856(fp)
2877 mull2 r2,r5
2878 mull3 r2,r4,-860(fp)
2879 mull2 r0,r4
2880 addl3 -856(fp),-860(fp),r0
2881 bicl3 #0,r0,-856(fp)
2882 cmpl -856(fp),-860(fp)
2883 bgequ noname.273
2884 addl2 #65536,r4
2885noname.273:
2886 movzwl -854(fp),r0
2887 bicl2 #-65536,r0
2888 addl2 r0,r4
2889 bicl3 #-65536,-856(fp),r0
2890 ashl #16,r0,-860(fp)
2891 addl2 -860(fp),r5
2892 bicl2 #0,r5
2893 cmpl r5,-860(fp)
2894 bgequ noname.274
2895 incl r4
2896noname.274:
2897 movl r5,r1
2898 movl r4,r2
2899 addl2 r1,r10
2900 bicl2 #0,r10
2901 cmpl r10,r1
2902 bgequ noname.275
2903 incl r2
2904noname.275:
2905 addl2 r2,r9
2906 bicl2 #0,r9
2907 cmpl r9,r2
2908 bgequ noname.276
2909 incl r8
2910noname.276:
2911
2912 movl r10,44(r11)
2913
2914 clrl r10
2915
2916 bicl3 #-65536,28(r6),r3
2917 movzwl 30(r6),r1
2918 bicl2 #-65536,r1
2919 bicl3 #-65536,20(r7),r2
2920 movzwl 22(r7),r0
2921 bicl2 #-65536,r0
2922 movl r3,r5
2923 movl r1,r4
2924 mull3 r0,r5,-864(fp)
2925 mull2 r2,r5
2926 mull3 r2,r4,-868(fp)
2927 mull2 r0,r4
2928 addl3 -864(fp),-868(fp),r0
2929 bicl3 #0,r0,-864(fp)
2930 cmpl -864(fp),-868(fp)
2931 bgequ noname.277
2932 addl2 #65536,r4
2933noname.277:
2934 movzwl -862(fp),r0
2935 bicl2 #-65536,r0
2936 addl2 r0,r4
2937 bicl3 #-65536,-864(fp),r0
2938 ashl #16,r0,-868(fp)
2939 addl2 -868(fp),r5
2940 bicl2 #0,r5
2941 cmpl r5,-868(fp)
2942 bgequ noname.278
2943 incl r4
2944noname.278:
2945 movl r5,r1
2946 movl r4,r2
2947 addl2 r1,r9
2948 bicl2 #0,r9
2949 cmpl r9,r1
2950 bgequ noname.279
2951 incl r2
2952noname.279:
2953 addl2 r2,r8
2954 bicl2 #0,r8
2955 cmpl r8,r2
2956 bgequ noname.280
2957 incl r10
2958noname.280:
2959
2960 bicl3 #-65536,24(r6),r3
2961 movzwl 26(r6),r1
2962 bicl2 #-65536,r1
2963 bicl3 #-65536,24(r7),r2
2964 movzwl 26(r7),r0
2965 bicl2 #-65536,r0
2966 movl r3,r5
2967 movl r1,r4
2968 mull3 r0,r5,-872(fp)
2969 mull2 r2,r5
2970 mull3 r2,r4,-876(fp)
2971 mull2 r0,r4
2972 addl3 -872(fp),-876(fp),r0
2973 bicl3 #0,r0,-872(fp)
2974 cmpl -872(fp),-876(fp)
2975 bgequ noname.281
2976 addl2 #65536,r4
2977noname.281:
2978 movzwl -870(fp),r0
2979 bicl2 #-65536,r0
2980 addl2 r0,r4
2981 bicl3 #-65536,-872(fp),r0
2982 ashl #16,r0,-876(fp)
2983 addl2 -876(fp),r5
2984 bicl2 #0,r5
2985 cmpl r5,-876(fp)
2986 bgequ noname.282
2987 incl r4
2988noname.282:
2989 movl r5,r1
2990 movl r4,r2
2991 addl2 r1,r9
2992 bicl2 #0,r9
2993 cmpl r9,r1
2994 bgequ noname.283
2995 incl r2
2996noname.283:
2997 addl2 r2,r8
2998 bicl2 #0,r8
2999 cmpl r8,r2
3000 bgequ noname.284
3001 incl r10
3002noname.284:
3003
3004 bicl3 #-65536,20(r6),r3
3005 movzwl 22(r6),r1
3006 bicl2 #-65536,r1
3007 bicl3 #-65536,28(r7),r2
3008 movzwl 30(r7),r0
3009 bicl2 #-65536,r0
3010 movl r3,r5
3011 movl r1,r4
3012 mull3 r0,r5,-880(fp)
3013 mull2 r2,r5
3014 mull3 r2,r4,-884(fp)
3015 mull2 r0,r4
3016 addl3 -880(fp),-884(fp),r0
3017 bicl3 #0,r0,-880(fp)
3018 cmpl -880(fp),-884(fp)
3019 bgequ noname.285
3020 addl2 #65536,r4
3021noname.285:
3022 movzwl -878(fp),r0
3023 bicl2 #-65536,r0
3024 addl2 r0,r4
3025 bicl3 #-65536,-880(fp),r0
3026 ashl #16,r0,-884(fp)
3027 addl2 -884(fp),r5
3028 bicl2 #0,r5
3029 cmpl r5,-884(fp)
3030 bgequ noname.286
3031 incl r4
3032noname.286:
3033 movl r5,r1
3034 movl r4,r2
3035 addl2 r1,r9
3036 bicl2 #0,r9
3037 cmpl r9,r1
3038 bgequ noname.287
3039 incl r2
3040noname.287:
3041 addl2 r2,r8
3042 bicl2 #0,r8
3043 cmpl r8,r2
3044 bgequ noname.288
3045 incl r10
3046noname.288:
3047
3048 movl r9,48(r11)
3049
3050 clrl r9
3051
3052 bicl3 #-65536,24(r6),r3
3053 movzwl 26(r6),r1
3054 bicl2 #-65536,r1
3055 bicl3 #-65536,28(r7),r2
3056 movzwl 30(r7),r0
3057 bicl2 #-65536,r0
3058 movl r3,r5
3059 movl r1,r4
3060 mull3 r0,r5,-888(fp)
3061 mull2 r2,r5
3062 mull3 r2,r4,-892(fp)
3063 mull2 r0,r4
3064 addl3 -888(fp),-892(fp),r0
3065 bicl3 #0,r0,-888(fp)
3066 cmpl -888(fp),-892(fp)
3067 bgequ noname.289
3068 addl2 #65536,r4
3069noname.289:
3070 movzwl -886(fp),r0
3071 bicl2 #-65536,r0
3072 addl2 r0,r4
3073 bicl3 #-65536,-888(fp),r0
3074 ashl #16,r0,-892(fp)
3075 addl2 -892(fp),r5
3076 bicl2 #0,r5
3077 cmpl r5,-892(fp)
3078 bgequ noname.290
3079 incl r4
3080noname.290:
3081 movl r5,r1
3082 movl r4,r2
3083 addl2 r1,r8
3084 bicl2 #0,r8
3085 cmpl r8,r1
3086 bgequ noname.291
3087 incl r2
3088noname.291:
3089 addl2 r2,r10
3090 bicl2 #0,r10
3091 cmpl r10,r2
3092 bgequ noname.292
3093 incl r9
3094noname.292:
3095
3096 movzwl 30(r6),r2
3097 bicl3 #-65536,24(r7),r3
3098 movzwl 26(r7),r0
3099 bicl2 #-65536,r0
3100 bicl3 #-65536,28(r6),-904(fp)
3101 bicl3 #-65536,r2,-908(fp)
3102 mull3 r0,-904(fp),-896(fp)
3103 mull2 r3,-904(fp)
3104 mull3 r3,-908(fp),-900(fp)
3105 mull2 r0,-908(fp)
3106 addl3 -896(fp),-900(fp),r0
3107 bicl3 #0,r0,-896(fp)
3108 cmpl -896(fp),-900(fp)
3109 bgequ noname.293
3110 addl2 #65536,-908(fp)
3111noname.293:
3112 movzwl -894(fp),r0
3113 bicl2 #-65536,r0
3114 addl2 r0,-908(fp)
3115 bicl3 #-65536,-896(fp),r0
3116 ashl #16,r0,-900(fp)
3117 addl3 -900(fp),-904(fp),r0
3118 bicl3 #0,r0,-904(fp)
3119 cmpl -904(fp),-900(fp)
3120 bgequ noname.294
3121 incl -908(fp)
3122noname.294:
3123 movl -904(fp),r1
3124 movl -908(fp),r2
3125 addl2 r1,r8
3126 bicl2 #0,r8
3127 cmpl r8,r1
3128 bgequ noname.295
3129 incl r2
3130noname.295:
3131 addl2 r2,r10
3132 bicl2 #0,r10
3133 cmpl r10,r2
3134 bgequ noname.296
3135 incl r9
3136noname.296:
3137
3138 movl r8,52(r11)
3139
3140 clrl r8
3141
3142 movzwl 30(r6),r2
3143 bicl3 #-65536,28(r7),r3
3144 movzwl 30(r7),r0
3145 bicl2 #-65536,r0
3146 bicl3 #-65536,28(r6),-920(fp)
3147 bicl3 #-65536,r2,-924(fp)
3148 mull3 r0,-920(fp),-912(fp)
3149 mull2 r3,-920(fp)
3150 mull3 r3,-924(fp),-916(fp)
3151 mull2 r0,-924(fp)
3152 addl3 -912(fp),-916(fp),r0
3153 bicl3 #0,r0,-912(fp)
3154 cmpl -912(fp),-916(fp)
3155 bgequ noname.297
3156 addl2 #65536,-924(fp)
3157noname.297:
3158 movzwl -910(fp),r0
3159 bicl2 #-65536,r0
3160 addl2 r0,-924(fp)
3161 bicl3 #-65536,-912(fp),r0
3162 ashl #16,r0,-916(fp)
3163 addl3 -916(fp),-920(fp),r0
3164 bicl3 #0,r0,-920(fp)
3165 cmpl -920(fp),-916(fp)
3166 bgequ noname.298
3167 incl -924(fp)
3168noname.298:
3169 movl -920(fp),r1
3170 movl -924(fp),r2
3171 addl2 r1,r10
3172 bicl2 #0,r10
3173 cmpl r10,r1
3174 bgequ noname.299
3175 incl r2
3176noname.299:
3177 addl2 r2,r9
3178 bicl2 #0,r9
3179 cmpl r9,r2
3180 bgequ noname.300
3181 incl r8
3182noname.300:
3183
3184 movl r10,56(r11)
3185
3186 movl r9,60(r11)
3187
3188 ret
3189
3190
3191
3192;r=4 ;(AP)
3193;a=8 ;(AP)
3194;b=12 ;(AP)
3195;n=16 ;(AP) n by value (input)
3196
3197 .psect code,nowrt
3198
3199.entry BN_MUL_COMBA4,^m<r2,r3,r4,r5,r6,r7,r8,r9,r10,r11>
3200 movab -156(sp),sp
3201
3202 clrq r9
3203
3204 clrl r8
3205
3206 movl 8(ap),r6
3207 bicl3 #-65536,(r6),r3
3208 movzwl 2(r6),r2
3209 bicl2 #-65536,r2
3210 movl 12(ap),r7
3211 bicl3 #-65536,(r7),r1
3212 movzwl 2(r7),r0
3213 bicl2 #-65536,r0
3214 movl r3,r5
3215 movl r2,r4
3216 mull3 r0,r5,-4(fp)
3217 mull2 r1,r5
3218 mull3 r1,r4,-8(fp)
3219 mull2 r0,r4
3220 addl3 -4(fp),-8(fp),r0
3221 bicl3 #0,r0,-4(fp)
3222 cmpl -4(fp),-8(fp)
3223 bgequ noname.303
3224 addl2 #65536,r4
3225noname.303:
3226 movzwl -2(fp),r0
3227 bicl2 #-65536,r0
3228 addl2 r0,r4
3229 bicl3 #-65536,-4(fp),r0
3230 ashl #16,r0,-8(fp)
3231 addl2 -8(fp),r5
3232 bicl2 #0,r5
3233 cmpl r5,-8(fp)
3234 bgequ noname.304
3235 incl r4
3236noname.304:
3237 movl r5,r1
3238 movl r4,r2
3239 addl2 r1,r10
3240 bicl2 #0,r10
3241 cmpl r10,r1
3242 bgequ noname.305
3243 incl r2
3244noname.305:
3245 addl2 r2,r9
3246 bicl2 #0,r9
3247 cmpl r9,r2
3248 bgequ noname.306
3249 incl r8
3250noname.306:
3251
3252 movl 4(ap),r11
3253 movl r10,(r11)
3254
3255 clrl r10
3256
3257 bicl3 #-65536,(r6),r3
3258 movzwl 2(r6),r1
3259 bicl2 #-65536,r1
3260 bicl3 #-65536,4(r7),r2
3261 movzwl 6(r7),r0
3262 bicl2 #-65536,r0
3263 movl r3,r5
3264 movl r1,r4
3265 mull3 r0,r5,-12(fp)
3266 mull2 r2,r5
3267 mull3 r2,r4,-16(fp)
3268 mull2 r0,r4
3269 addl3 -12(fp),-16(fp),r0
3270 bicl3 #0,r0,-12(fp)
3271 cmpl -12(fp),-16(fp)
3272 bgequ noname.307
3273 addl2 #65536,r4
3274noname.307:
3275 movzwl -10(fp),r0
3276 bicl2 #-65536,r0
3277 addl2 r0,r4
3278 bicl3 #-65536,-12(fp),r0
3279 ashl #16,r0,-16(fp)
3280 addl2 -16(fp),r5
3281 bicl2 #0,r5
3282 cmpl r5,-16(fp)
3283 bgequ noname.308
3284 incl r4
3285noname.308:
3286 movl r5,r1
3287 movl r4,r2
3288 addl2 r1,r9
3289 bicl2 #0,r9
3290 cmpl r9,r1
3291 bgequ noname.309
3292 incl r2
3293noname.309:
3294 addl2 r2,r8
3295 bicl2 #0,r8
3296 cmpl r8,r2
3297 bgequ noname.310
3298 incl r10
3299noname.310:
3300
3301 bicl3 #-65536,4(r6),r3
3302 movzwl 6(r6),r1
3303 bicl2 #-65536,r1
3304 bicl3 #-65536,(r7),r2
3305 movzwl 2(r7),r0
3306 bicl2 #-65536,r0
3307 movl r3,r5
3308 movl r1,r4
3309 mull3 r0,r5,-20(fp)
3310 mull2 r2,r5
3311 mull3 r2,r4,-24(fp)
3312 mull2 r0,r4
3313 addl3 -20(fp),-24(fp),r0
3314 bicl3 #0,r0,-20(fp)
3315 cmpl -20(fp),-24(fp)
3316 bgequ noname.311
3317 addl2 #65536,r4
3318noname.311:
3319 movzwl -18(fp),r0
3320 bicl2 #-65536,r0
3321 addl2 r0,r4
3322 bicl3 #-65536,-20(fp),r0
3323 ashl #16,r0,-24(fp)
3324 addl2 -24(fp),r5
3325 bicl2 #0,r5
3326 cmpl r5,-24(fp)
3327 bgequ noname.312
3328 incl r4
3329noname.312:
3330 movl r5,r1
3331 movl r4,r2
3332 addl2 r1,r9
3333 bicl2 #0,r9
3334 cmpl r9,r1
3335 bgequ noname.313
3336 incl r2
3337noname.313:
3338 addl2 r2,r8
3339 bicl2 #0,r8
3340 cmpl r8,r2
3341 bgequ noname.314
3342 incl r10
3343noname.314:
3344
3345 movl r9,4(r11)
3346
3347 clrl r9
3348
3349 bicl3 #-65536,8(r6),r3
3350 movzwl 10(r6),r1
3351 bicl2 #-65536,r1
3352 bicl3 #-65536,(r7),r2
3353 movzwl 2(r7),r0
3354 bicl2 #-65536,r0
3355 movl r3,r5
3356 movl r1,r4
3357 mull3 r0,r5,-28(fp)
3358 mull2 r2,r5
3359 mull3 r2,r4,-32(fp)
3360 mull2 r0,r4
3361 addl3 -28(fp),-32(fp),r0
3362 bicl3 #0,r0,-28(fp)
3363 cmpl -28(fp),-32(fp)
3364 bgequ noname.315
3365 addl2 #65536,r4
3366noname.315:
3367 movzwl -26(fp),r0
3368 bicl2 #-65536,r0
3369 addl2 r0,r4
3370 bicl3 #-65536,-28(fp),r0
3371 ashl #16,r0,-32(fp)
3372 addl2 -32(fp),r5
3373 bicl2 #0,r5
3374 cmpl r5,-32(fp)
3375 bgequ noname.316
3376 incl r4
3377noname.316:
3378 movl r5,r1
3379 movl r4,r2
3380 addl2 r1,r8
3381 bicl2 #0,r8
3382 cmpl r8,r1
3383 bgequ noname.317
3384 incl r2
3385noname.317:
3386 addl2 r2,r10
3387 bicl2 #0,r10
3388 cmpl r10,r2
3389 bgequ noname.318
3390 incl r9
3391noname.318:
3392
3393 bicl3 #-65536,4(r6),r3
3394 movzwl 6(r6),r1
3395 bicl2 #-65536,r1
3396 bicl3 #-65536,4(r7),r2
3397 movzwl 6(r7),r0
3398 bicl2 #-65536,r0
3399 movl r3,r5
3400 movl r1,r4
3401 mull3 r0,r5,-36(fp)
3402 mull2 r2,r5
3403 mull3 r2,r4,-40(fp)
3404 mull2 r0,r4
3405 addl3 -36(fp),-40(fp),r0
3406 bicl3 #0,r0,-36(fp)
3407 cmpl -36(fp),-40(fp)
3408 bgequ noname.319
3409 addl2 #65536,r4
3410noname.319:
3411 movzwl -34(fp),r0
3412 bicl2 #-65536,r0
3413 addl2 r0,r4
3414 bicl3 #-65536,-36(fp),r0
3415 ashl #16,r0,-40(fp)
3416 addl2 -40(fp),r5
3417 bicl2 #0,r5
3418 cmpl r5,-40(fp)
3419 bgequ noname.320
3420 incl r4
3421noname.320:
3422 movl r5,r1
3423 movl r4,r2
3424 addl2 r1,r8
3425 bicl2 #0,r8
3426 cmpl r8,r1
3427 bgequ noname.321
3428 incl r2
3429noname.321:
3430 addl2 r2,r10
3431 bicl2 #0,r10
3432 cmpl r10,r2
3433 bgequ noname.322
3434 incl r9
3435noname.322:
3436
3437 bicl3 #-65536,(r6),r3
3438 movzwl 2(r6),r1
3439 bicl2 #-65536,r1
3440 bicl3 #-65536,8(r7),r2
3441 movzwl 10(r7),r0
3442 bicl2 #-65536,r0
3443 movl r3,r5
3444 movl r1,r4
3445 mull3 r0,r5,-44(fp)
3446 mull2 r2,r5
3447 mull3 r2,r4,-48(fp)
3448 mull2 r0,r4
3449 addl3 -44(fp),-48(fp),r0
3450 bicl3 #0,r0,-44(fp)
3451 cmpl -44(fp),-48(fp)
3452 bgequ noname.323
3453 addl2 #65536,r4
3454noname.323:
3455 movzwl -42(fp),r0
3456 bicl2 #-65536,r0
3457 addl2 r0,r4
3458 bicl3 #-65536,-44(fp),r0
3459 ashl #16,r0,-48(fp)
3460 addl2 -48(fp),r5
3461 bicl2 #0,r5
3462 cmpl r5,-48(fp)
3463 bgequ noname.324
3464 incl r4
3465noname.324:
3466 movl r5,r1
3467 movl r4,r2
3468 addl2 r1,r8
3469 bicl2 #0,r8
3470 cmpl r8,r1
3471 bgequ noname.325
3472 incl r2
3473noname.325:
3474 addl2 r2,r10
3475 bicl2 #0,r10
3476 cmpl r10,r2
3477 bgequ noname.326
3478 incl r9
3479noname.326:
3480
3481 movl r8,8(r11)
3482
3483 clrl r8
3484
3485 bicl3 #-65536,(r6),r3
3486 movzwl 2(r6),r2
3487 bicl3 #-65536,12(r7),r1
3488 movzwl 14(r7),r0
3489 bicl2 #-65536,r0
3490 movl r3,r4
3491 bicl3 #-65536,r2,-60(fp)
3492 mull3 r0,r4,-52(fp)
3493 mull2 r1,r4
3494 mull3 r1,-60(fp),-56(fp)
3495 mull2 r0,-60(fp)
3496 addl3 -52(fp),-56(fp),r0
3497 bicl3 #0,r0,-52(fp)
3498 cmpl -52(fp),-56(fp)
3499 bgequ noname.327
3500 addl2 #65536,-60(fp)
3501noname.327:
3502 movzwl -50(fp),r0
3503 bicl2 #-65536,r0
3504 addl2 r0,-60(fp)
3505 bicl3 #-65536,-52(fp),r0
3506 ashl #16,r0,-56(fp)
3507 addl2 -56(fp),r4
3508 bicl2 #0,r4
3509 cmpl r4,-56(fp)
3510 bgequ noname.328
3511 incl -60(fp)
3512noname.328:
3513 movl r4,r1
3514 movl -60(fp),r2
3515 addl2 r1,r10
3516 bicl2 #0,r10
3517 cmpl r10,r1
3518 bgequ noname.329
3519 incl r2
3520noname.329:
3521 addl2 r2,r9
3522 bicl2 #0,r9
3523 cmpl r9,r2
3524 bgequ noname.330
3525 incl r8
3526noname.330:
3527
3528 movzwl 6(r6),r2
3529 bicl3 #-65536,8(r7),r3
3530 movzwl 10(r7),r0
3531 bicl2 #-65536,r0
3532 bicl3 #-65536,4(r6),-72(fp)
3533 bicl3 #-65536,r2,-76(fp)
3534 mull3 r0,-72(fp),-64(fp)
3535 mull2 r3,-72(fp)
3536 mull3 r3,-76(fp),-68(fp)
3537 mull2 r0,-76(fp)
3538 addl3 -64(fp),-68(fp),r0
3539 bicl3 #0,r0,-64(fp)
3540 cmpl -64(fp),-68(fp)
3541 bgequ noname.331
3542 addl2 #65536,-76(fp)
3543noname.331:
3544 movzwl -62(fp),r0
3545 bicl2 #-65536,r0
3546 addl2 r0,-76(fp)
3547 bicl3 #-65536,-64(fp),r0
3548 ashl #16,r0,-68(fp)
3549 addl3 -68(fp),-72(fp),r0
3550 bicl3 #0,r0,-72(fp)
3551 cmpl -72(fp),-68(fp)
3552 bgequ noname.332
3553 incl -76(fp)
3554noname.332:
3555 movl -72(fp),r1
3556 movl -76(fp),r2
3557 addl2 r1,r10
3558 bicl2 #0,r10
3559 cmpl r10,r1
3560 bgequ noname.333
3561 incl r2
3562noname.333:
3563 addl2 r2,r9
3564 bicl2 #0,r9
3565 cmpl r9,r2
3566 bgequ noname.334
3567 incl r8
3568noname.334:
3569
3570 bicl3 #-65536,8(r6),r3
3571 movzwl 10(r6),r1
3572 bicl2 #-65536,r1
3573 bicl3 #-65536,4(r7),r2
3574 movzwl 6(r7),r0
3575 bicl2 #-65536,r0
3576 movl r3,r5
3577 movl r1,r4
3578 mull3 r0,r5,-80(fp)
3579 mull2 r2,r5
3580 mull3 r2,r4,-84(fp)
3581 mull2 r0,r4
3582 addl3 -80(fp),-84(fp),r0
3583 bicl3 #0,r0,-80(fp)
3584 cmpl -80(fp),-84(fp)
3585 bgequ noname.335
3586 addl2 #65536,r4
3587noname.335:
3588 movzwl -78(fp),r0
3589 bicl2 #-65536,r0
3590 addl2 r0,r4
3591 bicl3 #-65536,-80(fp),r0
3592 ashl #16,r0,-84(fp)
3593 addl2 -84(fp),r5
3594 bicl2 #0,r5
3595 cmpl r5,-84(fp)
3596 bgequ noname.336
3597 incl r4
3598noname.336:
3599 movl r5,r1
3600 movl r4,r2
3601 addl2 r1,r10
3602 bicl2 #0,r10
3603 cmpl r10,r1
3604 bgequ noname.337
3605 incl r2
3606noname.337:
3607 addl2 r2,r9
3608 bicl2 #0,r9
3609 cmpl r9,r2
3610 bgequ noname.338
3611 incl r8
3612noname.338:
3613
3614 bicl3 #-65536,12(r6),r3
3615 movzwl 14(r6),r1
3616 bicl2 #-65536,r1
3617 bicl3 #-65536,(r7),r2
3618 movzwl 2(r7),r0
3619 bicl2 #-65536,r0
3620 movl r3,r5
3621 movl r1,r4
3622 mull3 r0,r5,-88(fp)
3623 mull2 r2,r5
3624 mull3 r2,r4,-92(fp)
3625 mull2 r0,r4
3626 addl3 -88(fp),-92(fp),r0
3627 bicl3 #0,r0,-88(fp)
3628 cmpl -88(fp),-92(fp)
3629 bgequ noname.339
3630 addl2 #65536,r4
3631noname.339:
3632 movzwl -86(fp),r0
3633 bicl2 #-65536,r0
3634 addl2 r0,r4
3635 bicl3 #-65536,-88(fp),r0
3636 ashl #16,r0,-92(fp)
3637 addl2 -92(fp),r5
3638 bicl2 #0,r5
3639 cmpl r5,-92(fp)
3640 bgequ noname.340
3641 incl r4
3642noname.340:
3643 movl r5,r1
3644 movl r4,r2
3645 addl2 r1,r10
3646 bicl2 #0,r10
3647 cmpl r10,r1
3648 bgequ noname.341
3649 incl r2
3650noname.341:
3651 addl2 r2,r9
3652 bicl2 #0,r9
3653 cmpl r9,r2
3654 bgequ noname.342
3655 incl r8
3656noname.342:
3657
3658 movl r10,12(r11)
3659
3660 clrl r10
3661
3662 bicl3 #-65536,12(r6),r3
3663 movzwl 14(r6),r1
3664 bicl2 #-65536,r1
3665 bicl3 #-65536,4(r7),r2
3666 movzwl 6(r7),r0
3667 bicl2 #-65536,r0
3668 movl r3,r5
3669 movl r1,r4
3670 mull3 r0,r5,-96(fp)
3671 mull2 r2,r5
3672 mull3 r2,r4,-100(fp)
3673 mull2 r0,r4
3674 addl3 -96(fp),-100(fp),r0
3675 bicl3 #0,r0,-96(fp)
3676 cmpl -96(fp),-100(fp)
3677 bgequ noname.343
3678 addl2 #65536,r4
3679noname.343:
3680 movzwl -94(fp),r0
3681 bicl2 #-65536,r0
3682 addl2 r0,r4
3683 bicl3 #-65536,-96(fp),r0
3684 ashl #16,r0,-100(fp)
3685 addl2 -100(fp),r5
3686 bicl2 #0,r5
3687 cmpl r5,-100(fp)
3688 bgequ noname.344
3689 incl r4
3690noname.344:
3691 movl r5,r1
3692 movl r4,r2
3693 addl2 r1,r9
3694 bicl2 #0,r9
3695 cmpl r9,r1
3696 bgequ noname.345
3697 incl r2
3698noname.345:
3699 addl2 r2,r8
3700 bicl2 #0,r8
3701 cmpl r8,r2
3702 bgequ noname.346
3703 incl r10
3704noname.346:
3705
3706 bicl3 #-65536,8(r6),r3
3707 movzwl 10(r6),r1
3708 bicl2 #-65536,r1
3709 bicl3 #-65536,8(r7),r2
3710 movzwl 10(r7),r0
3711 bicl2 #-65536,r0
3712 movl r3,r5
3713 movl r1,r4
3714 mull3 r0,r5,-104(fp)
3715 mull2 r2,r5
3716 mull3 r2,r4,-108(fp)
3717 mull2 r0,r4
3718 addl3 -104(fp),-108(fp),r0
3719 bicl3 #0,r0,-104(fp)
3720 cmpl -104(fp),-108(fp)
3721 bgequ noname.347
3722 addl2 #65536,r4
3723noname.347:
3724 movzwl -102(fp),r0
3725 bicl2 #-65536,r0
3726 addl2 r0,r4
3727 bicl3 #-65536,-104(fp),r0
3728 ashl #16,r0,-108(fp)
3729 addl2 -108(fp),r5
3730 bicl2 #0,r5
3731 cmpl r5,-108(fp)
3732 bgequ noname.348
3733 incl r4
3734noname.348:
3735 movl r5,r1
3736 movl r4,r2
3737 addl2 r1,r9
3738 bicl2 #0,r9
3739 cmpl r9,r1
3740 bgequ noname.349
3741 incl r2
3742noname.349:
3743 addl2 r2,r8
3744 bicl2 #0,r8
3745 cmpl r8,r2
3746 bgequ noname.350
3747 incl r10
3748noname.350:
3749
3750 bicl3 #-65536,4(r6),r3
3751 movzwl 6(r6),r1
3752 bicl2 #-65536,r1
3753 bicl3 #-65536,12(r7),r2
3754 movzwl 14(r7),r0
3755 bicl2 #-65536,r0
3756 movl r3,r5
3757 movl r1,r4
3758 mull3 r0,r5,-112(fp)
3759 mull2 r2,r5
3760 mull3 r2,r4,-116(fp)
3761 mull2 r0,r4
3762 addl3 -112(fp),-116(fp),r0
3763 bicl3 #0,r0,-112(fp)
3764 cmpl -112(fp),-116(fp)
3765 bgequ noname.351
3766 addl2 #65536,r4
3767noname.351:
3768 movzwl -110(fp),r0
3769 bicl2 #-65536,r0
3770 addl2 r0,r4
3771 bicl3 #-65536,-112(fp),r0
3772 ashl #16,r0,-116(fp)
3773 addl2 -116(fp),r5
3774 bicl2 #0,r5
3775 cmpl r5,-116(fp)
3776 bgequ noname.352
3777 incl r4
3778noname.352:
3779 movl r5,r1
3780 movl r4,r2
3781 addl2 r1,r9
3782 bicl2 #0,r9
3783 cmpl r9,r1
3784 bgequ noname.353
3785 incl r2
3786noname.353:
3787 addl2 r2,r8
3788 bicl2 #0,r8
3789 cmpl r8,r2
3790 bgequ noname.354
3791 incl r10
3792noname.354:
3793
3794 movl r9,16(r11)
3795
3796 clrl r9
3797
3798 bicl3 #-65536,8(r6),r3
3799 movzwl 10(r6),r1
3800 bicl2 #-65536,r1
3801 bicl3 #-65536,12(r7),r2
3802 movzwl 14(r7),r0
3803 bicl2 #-65536,r0
3804 movl r3,r5
3805 movl r1,r4
3806 mull3 r0,r5,-120(fp)
3807 mull2 r2,r5
3808 mull3 r2,r4,-124(fp)
3809 mull2 r0,r4
3810 addl3 -120(fp),-124(fp),r0
3811 bicl3 #0,r0,-120(fp)
3812 cmpl -120(fp),-124(fp)
3813 bgequ noname.355
3814 addl2 #65536,r4
3815noname.355:
3816 movzwl -118(fp),r0
3817 bicl2 #-65536,r0
3818 addl2 r0,r4
3819 bicl3 #-65536,-120(fp),r0
3820 ashl #16,r0,-124(fp)
3821 addl2 -124(fp),r5
3822 bicl2 #0,r5
3823 cmpl r5,-124(fp)
3824 bgequ noname.356
3825 incl r4
3826noname.356:
3827 movl r5,r1
3828 movl r4,r2
3829 addl2 r1,r8
3830 bicl2 #0,r8
3831 cmpl r8,r1
3832 bgequ noname.357
3833 incl r2
3834noname.357:
3835 addl2 r2,r10
3836 bicl2 #0,r10
3837 cmpl r10,r2
3838 bgequ noname.358
3839 incl r9
3840noname.358:
3841
3842 movzwl 14(r6),r2
3843 bicl3 #-65536,8(r7),r3
3844 movzwl 10(r7),r0
3845 bicl2 #-65536,r0
3846 bicl3 #-65536,12(r6),-136(fp)
3847 bicl3 #-65536,r2,-140(fp)
3848 mull3 r0,-136(fp),-128(fp)
3849 mull2 r3,-136(fp)
3850 mull3 r3,-140(fp),-132(fp)
3851 mull2 r0,-140(fp)
3852 addl3 -128(fp),-132(fp),r0
3853 bicl3 #0,r0,-128(fp)
3854 cmpl -128(fp),-132(fp)
3855 bgequ noname.359
3856 addl2 #65536,-140(fp)
3857noname.359:
3858 movzwl -126(fp),r0
3859 bicl2 #-65536,r0
3860 addl2 r0,-140(fp)
3861 bicl3 #-65536,-128(fp),r0
3862 ashl #16,r0,-132(fp)
3863 addl3 -132(fp),-136(fp),r0
3864 bicl3 #0,r0,-136(fp)
3865 cmpl -136(fp),-132(fp)
3866 bgequ noname.360
3867 incl -140(fp)
3868noname.360:
3869 movl -136(fp),r1
3870 movl -140(fp),r2
3871 addl2 r1,r8
3872 bicl2 #0,r8
3873 cmpl r8,r1
3874 bgequ noname.361
3875 incl r2
3876noname.361:
3877 addl2 r2,r10
3878 bicl2 #0,r10
3879 cmpl r10,r2
3880 bgequ noname.362
3881 incl r9
3882noname.362:
3883
3884 movl r8,20(r11)
3885
3886 clrl r8
3887
3888 movzwl 14(r6),r2
3889 bicl3 #-65536,12(r7),r3
3890 movzwl 14(r7),r0
3891 bicl2 #-65536,r0
3892 bicl3 #-65536,12(r6),-152(fp)
3893 bicl3 #-65536,r2,-156(fp)
3894 mull3 r0,-152(fp),-144(fp)
3895 mull2 r3,-152(fp)
3896 mull3 r3,-156(fp),-148(fp)
3897 mull2 r0,-156(fp)
3898 addl3 -144(fp),-148(fp),r0
3899 bicl3 #0,r0,-144(fp)
3900 cmpl -144(fp),-148(fp)
3901 bgequ noname.363
3902 addl2 #65536,-156(fp)
3903noname.363:
3904 movzwl -142(fp),r0
3905 bicl2 #-65536,r0
3906 addl2 r0,-156(fp)
3907 bicl3 #-65536,-144(fp),r0
3908 ashl #16,r0,-148(fp)
3909 addl3 -148(fp),-152(fp),r0
3910 bicl3 #0,r0,-152(fp)
3911 cmpl -152(fp),-148(fp)
3912 bgequ noname.364
3913 incl -156(fp)
3914noname.364:
3915 movl -152(fp),r1
3916 movl -156(fp),r2
3917 addl2 r1,r10
3918 bicl2 #0,r10
3919 cmpl r10,r1
3920 bgequ noname.365
3921 incl r2
3922noname.365:
3923 addl2 r2,r9
3924 bicl2 #0,r9
3925 cmpl r9,r2
3926 bgequ noname.366
3927 incl r8
3928noname.366:
3929
3930 movl r10,24(r11)
3931
3932 movl r9,28(r11)
3933
3934 ret
3935
3936
3937
3938;r=4 ;(AP)
3939;a=8 ;(AP)
3940;b=12 ;(AP)
3941;n=16 ;(AP) n by value (input)
3942
3943 .psect code,nowrt
3944
3945.entry BN_SQR_COMBA8,^m<r2,r3,r4,r5,r6,r7,r8,r9>
3946 movab -444(sp),sp
3947
3948 clrq r8
3949
3950 clrl r7
3951
3952 movl 8(ap),r4
3953 movl (r4),r3
3954 bicl3 #-65536,r3,-4(fp)
3955 extzv #16,#16,r3,r0
3956 bicl3 #-65536,r0,r3
3957 movl -4(fp),r0
3958 mull3 r0,r3,-8(fp)
3959 mull3 r0,r0,-4(fp)
3960 mull2 r3,r3
3961 bicl3 #32767,-8(fp),r0
3962 extzv #15,#17,r0,r0
3963 addl2 r0,r3
3964 bicl3 #-65536,-8(fp),r0
3965 ashl #17,r0,-8(fp)
3966 addl3 -4(fp),-8(fp),r0
3967 bicl3 #0,r0,-4(fp)
3968 cmpl -4(fp),-8(fp)
3969 bgequ noname.369
3970 incl r3
3971noname.369:
3972 movl -4(fp),r1
3973 movl r3,r2
3974 addl2 r1,r9
3975 bicl2 #0,r9
3976 cmpl r9,r1
3977 bgequ noname.370
3978 incl r2
3979noname.370:
3980 addl2 r2,r8
3981 bicl2 #0,r8
3982 cmpl r8,r2
3983 bgequ noname.371
3984 incl r7
3985noname.371:
3986
3987 movl r9,@4(ap)
3988
3989 clrl r9
3990
3991 movzwl 6(r4),r2
3992 bicl3 #-65536,(r4),r3
3993 movzwl 2(r4),r0
3994 bicl2 #-65536,r0
3995 bicl3 #-65536,4(r4),-20(fp)
3996 bicl3 #-65536,r2,-24(fp)
3997 mull3 r0,-20(fp),-12(fp)
3998 mull2 r3,-20(fp)
3999 mull3 r3,-24(fp),-16(fp)
4000 mull2 r0,-24(fp)
4001 addl3 -12(fp),-16(fp),r0
4002 bicl3 #0,r0,-12(fp)
4003 cmpl -12(fp),-16(fp)
4004 bgequ noname.372
4005 addl2 #65536,-24(fp)
4006noname.372:
4007 movzwl -10(fp),r0
4008 bicl2 #-65536,r0
4009 addl2 r0,-24(fp)
4010 bicl3 #-65536,-12(fp),r0
4011 ashl #16,r0,-16(fp)
4012 addl3 -16(fp),-20(fp),r0
4013 bicl3 #0,r0,-20(fp)
4014 cmpl -20(fp),-16(fp)
4015 bgequ noname.373
4016 incl -24(fp)
4017noname.373:
4018 movl -20(fp),r3
4019 movl -24(fp),r2
4020 bbc #31,r2,noname.374
4021 incl r9
4022noname.374:
4023 addl2 r2,r2
4024 bicl2 #0,r2
4025 bbc #31,r3,noname.375
4026 incl r2
4027noname.375:
4028 addl2 r3,r3
4029 bicl2 #0,r3
4030 addl2 r3,r8
4031 bicl2 #0,r8
4032 cmpl r8,r3
4033 bgequ noname.376
4034 incl r2
4035 bicl3 #0,r2,r0
4036 bneq noname.376
4037 incl r9
4038noname.376:
4039 addl2 r2,r7
4040 bicl2 #0,r7
4041 cmpl r7,r2
4042 bgequ noname.377
4043 incl r9
4044noname.377:
4045
4046 movl 4(ap),r0
4047 movl r8,4(r0)
4048
4049 clrl r8
4050
4051 movl 8(ap),r4
4052 movl 4(r4),r3
4053 bicl3 #-65536,r3,-28(fp)
4054 extzv #16,#16,r3,r0
4055 bicl3 #-65536,r0,r3
4056 movl -28(fp),r0
4057 mull3 r0,r3,-32(fp)
4058 mull3 r0,r0,-28(fp)
4059 mull2 r3,r3
4060 bicl3 #32767,-32(fp),r0
4061 extzv #15,#17,r0,r0
4062 addl2 r0,r3
4063 bicl3 #-65536,-32(fp),r0
4064 ashl #17,r0,-32(fp)
4065 addl3 -28(fp),-32(fp),r0
4066 bicl3 #0,r0,-28(fp)
4067 cmpl -28(fp),-32(fp)
4068 bgequ noname.378
4069 incl r3
4070noname.378:
4071 movl -28(fp),r1
4072 movl r3,r2
4073 addl2 r1,r7
4074 bicl2 #0,r7
4075 cmpl r7,r1
4076 bgequ noname.379
4077 incl r2
4078noname.379:
4079 addl2 r2,r9
4080 bicl2 #0,r9
4081 cmpl r9,r2
4082 bgequ noname.380
4083 incl r8
4084noname.380:
4085
4086 movzwl 10(r4),r2
4087 bicl3 #-65536,(r4),r3
4088 movzwl 2(r4),r0
4089 bicl2 #-65536,r0
4090 bicl3 #-65536,8(r4),-44(fp)
4091 bicl3 #-65536,r2,-48(fp)
4092 mull3 r0,-44(fp),-36(fp)
4093 mull2 r3,-44(fp)
4094 mull3 r3,-48(fp),-40(fp)
4095 mull2 r0,-48(fp)
4096 addl3 -36(fp),-40(fp),r0
4097 bicl3 #0,r0,-36(fp)
4098 cmpl -36(fp),-40(fp)
4099 bgequ noname.381
4100 addl2 #65536,-48(fp)
4101noname.381:
4102 movzwl -34(fp),r0
4103 bicl2 #-65536,r0
4104 addl2 r0,-48(fp)
4105 bicl3 #-65536,-36(fp),r0
4106 ashl #16,r0,-40(fp)
4107 addl3 -40(fp),-44(fp),r0
4108 bicl3 #0,r0,-44(fp)
4109 cmpl -44(fp),-40(fp)
4110 bgequ noname.382
4111 incl -48(fp)
4112noname.382:
4113 movl -44(fp),r3
4114 movl -48(fp),r2
4115 bbc #31,r2,noname.383
4116 incl r8
4117noname.383:
4118 addl2 r2,r2
4119 bicl2 #0,r2
4120 bbc #31,r3,noname.384
4121 incl r2
4122noname.384:
4123 addl2 r3,r3
4124 bicl2 #0,r3
4125 addl2 r3,r7
4126 bicl2 #0,r7
4127 cmpl r7,r3
4128 bgequ noname.385
4129 incl r2
4130 bicl3 #0,r2,r0
4131 bneq noname.385
4132 incl r8
4133noname.385:
4134 addl2 r2,r9
4135 bicl2 #0,r9
4136 cmpl r9,r2
4137 bgequ noname.386
4138 incl r8
4139noname.386:
4140
4141 movl 4(ap),r0
4142 movl r7,8(r0)
4143
4144 clrl r7
4145
4146 movl 8(ap),r0
4147 movzwl 14(r0),r2
4148 bicl3 #-65536,(r0),r3
4149 movzwl 2(r0),r1
4150 bicl2 #-65536,r1
4151 bicl3 #-65536,12(r0),-60(fp)
4152 bicl3 #-65536,r2,-64(fp)
4153 mull3 r1,-60(fp),-52(fp)
4154 mull2 r3,-60(fp)
4155 mull3 r3,-64(fp),-56(fp)
4156 mull2 r1,-64(fp)
4157 addl3 -52(fp),-56(fp),r0
4158 bicl3 #0,r0,-52(fp)
4159 cmpl -52(fp),-56(fp)
4160 bgequ noname.387
4161 addl2 #65536,-64(fp)
4162noname.387:
4163 movzwl -50(fp),r0
4164 bicl2 #-65536,r0
4165 addl2 r0,-64(fp)
4166 bicl3 #-65536,-52(fp),r0
4167 ashl #16,r0,-56(fp)
4168 addl3 -56(fp),-60(fp),r0
4169 bicl3 #0,r0,-60(fp)
4170 cmpl -60(fp),-56(fp)
4171 bgequ noname.388
4172 incl -64(fp)
4173noname.388:
4174 movl -60(fp),r3
4175 movl -64(fp),r2
4176 bbc #31,r2,noname.389
4177 incl r7
4178noname.389:
4179 addl2 r2,r2
4180 bicl2 #0,r2
4181 bbc #31,r3,noname.390
4182 incl r2
4183noname.390:
4184 addl2 r3,r3
4185 bicl2 #0,r3
4186 addl2 r3,r9
4187 bicl2 #0,r9
4188 cmpl r9,r3
4189 bgequ noname.391
4190 incl r2
4191 bicl3 #0,r2,r0
4192 bneq noname.391
4193 incl r7
4194noname.391:
4195 addl2 r2,r8
4196 bicl2 #0,r8
4197 cmpl r8,r2
4198 bgequ noname.392
4199 incl r7
4200noname.392:
4201
4202 movl 8(ap),r0
4203 movzwl 10(r0),r2
4204 bicl3 #-65536,4(r0),r3
4205 movzwl 6(r0),r1
4206 bicl2 #-65536,r1
4207 bicl3 #-65536,8(r0),-76(fp)
4208 bicl3 #-65536,r2,-80(fp)
4209 mull3 r1,-76(fp),-68(fp)
4210 mull2 r3,-76(fp)
4211 mull3 r3,-80(fp),-72(fp)
4212 mull2 r1,-80(fp)
4213 addl3 -68(fp),-72(fp),r0
4214 bicl3 #0,r0,-68(fp)
4215 cmpl -68(fp),-72(fp)
4216 bgequ noname.393
4217 addl2 #65536,-80(fp)
4218noname.393:
4219 movzwl -66(fp),r0
4220 bicl2 #-65536,r0
4221 addl2 r0,-80(fp)
4222 bicl3 #-65536,-68(fp),r0
4223 ashl #16,r0,-72(fp)
4224 addl3 -72(fp),-76(fp),r0
4225 bicl3 #0,r0,-76(fp)
4226 cmpl -76(fp),-72(fp)
4227 bgequ noname.394
4228 incl -80(fp)
4229noname.394:
4230 movl -76(fp),r3
4231 movl -80(fp),r2
4232 bbc #31,r2,noname.395
4233 incl r7
4234noname.395:
4235 addl2 r2,r2
4236 bicl2 #0,r2
4237 bbc #31,r3,noname.396
4238 incl r2
4239noname.396:
4240 addl2 r3,r3
4241 bicl2 #0,r3
4242 addl2 r3,r9
4243 bicl2 #0,r9
4244 cmpl r9,r3
4245 bgequ noname.397
4246 incl r2
4247 bicl3 #0,r2,r0
4248 bneq noname.397
4249 incl r7
4250noname.397:
4251 addl2 r2,r8
4252 bicl2 #0,r8
4253 cmpl r8,r2
4254 bgequ noname.398
4255 incl r7
4256noname.398:
4257
4258 movl 4(ap),r0
4259 movl r9,12(r0)
4260
4261 clrl r9
4262
4263 movl 8(ap),r2
4264 movl 8(r2),r4
4265 bicl3 #-65536,r4,-84(fp)
4266 extzv #16,#16,r4,r0
4267 bicl3 #-65536,r0,r4
4268 movl -84(fp),r0
4269 mull3 r0,r4,-88(fp)
4270 mull3 r0,r0,-84(fp)
4271 mull2 r4,r4
4272 bicl3 #32767,-88(fp),r0
4273 extzv #15,#17,r0,r0
4274 addl2 r0,r4
4275 bicl3 #-65536,-88(fp),r0
4276 ashl #17,r0,-88(fp)
4277 addl3 -84(fp),-88(fp),r0
4278 bicl3 #0,r0,-84(fp)
4279 cmpl -84(fp),-88(fp)
4280 bgequ noname.399
4281 incl r4
4282noname.399:
4283 movl -84(fp),r1
4284 movl r4,r3
4285 addl2 r1,r8
4286 bicl2 #0,r8
4287 cmpl r8,r1
4288 bgequ noname.400
4289 incl r3
4290noname.400:
4291 addl2 r3,r7
4292 bicl2 #0,r7
4293 cmpl r7,r3
4294 bgequ noname.401
4295 incl r9
4296noname.401:
4297
4298 movzwl 14(r2),r3
4299 bicl3 #-65536,4(r2),r1
4300 movzwl 6(r2),r0
4301 bicl2 #-65536,r0
4302 bicl3 #-65536,12(r2),-100(fp)
4303 bicl3 #-65536,r3,-104(fp)
4304 mull3 r0,-100(fp),-92(fp)
4305 mull2 r1,-100(fp)
4306 mull3 r1,-104(fp),-96(fp)
4307 mull2 r0,-104(fp)
4308 addl3 -92(fp),-96(fp),r0
4309 bicl3 #0,r0,-92(fp)
4310 cmpl -92(fp),-96(fp)
4311 bgequ noname.402
4312 addl2 #65536,-104(fp)
4313noname.402:
4314 movzwl -90(fp),r0
4315 bicl2 #-65536,r0
4316 addl2 r0,-104(fp)
4317 bicl3 #-65536,-92(fp),r0
4318 ashl #16,r0,-96(fp)
4319 addl3 -96(fp),-100(fp),r0
4320 bicl3 #0,r0,-100(fp)
4321 cmpl -100(fp),-96(fp)
4322 bgequ noname.403
4323 incl -104(fp)
4324noname.403:
4325 movl -100(fp),r3
4326 movl -104(fp),r2
4327 bbc #31,r2,noname.404
4328 incl r9
4329noname.404:
4330 addl2 r2,r2
4331 bicl2 #0,r2
4332 bbc #31,r3,noname.405
4333 incl r2
4334noname.405:
4335 addl2 r3,r3
4336 bicl2 #0,r3
4337 addl2 r3,r8
4338 bicl2 #0,r8
4339 cmpl r8,r3
4340 bgequ noname.406
4341 incl r2
4342 bicl3 #0,r2,r0
4343 bneq noname.406
4344 incl r9
4345noname.406:
4346 addl2 r2,r7
4347 bicl2 #0,r7
4348 cmpl r7,r2
4349 bgequ noname.407
4350 incl r9
4351noname.407:
4352
4353 movl 8(ap),r0
4354 movzwl 18(r0),r2
4355 bicl3 #-65536,(r0),r3
4356 movzwl 2(r0),r1
4357 bicl2 #-65536,r1
4358 bicl3 #-65536,16(r0),-116(fp)
4359 bicl3 #-65536,r2,-120(fp)
4360 mull3 r1,-116(fp),-108(fp)
4361 mull2 r3,-116(fp)
4362 mull3 r3,-120(fp),-112(fp)
4363 mull2 r1,-120(fp)
4364 addl3 -108(fp),-112(fp),r0
4365 bicl3 #0,r0,-108(fp)
4366 cmpl -108(fp),-112(fp)
4367 bgequ noname.408
4368 addl2 #65536,-120(fp)
4369noname.408:
4370 movzwl -106(fp),r0
4371 bicl2 #-65536,r0
4372 addl2 r0,-120(fp)
4373 bicl3 #-65536,-108(fp),r0
4374 ashl #16,r0,-112(fp)
4375 addl3 -112(fp),-116(fp),r0
4376 bicl3 #0,r0,-116(fp)
4377 cmpl -116(fp),-112(fp)
4378 bgequ noname.409
4379 incl -120(fp)
4380noname.409:
4381 movl -116(fp),r3
4382 movl -120(fp),r2
4383 bbc #31,r2,noname.410
4384 incl r9
4385noname.410:
4386 addl2 r2,r2
4387 bicl2 #0,r2
4388 bbc #31,r3,noname.411
4389 incl r2
4390noname.411:
4391 addl2 r3,r3
4392 bicl2 #0,r3
4393 addl2 r3,r8
4394 bicl2 #0,r8
4395 cmpl r8,r3
4396 bgequ noname.412
4397 incl r2
4398 bicl3 #0,r2,r0
4399 bneq noname.412
4400 incl r9
4401noname.412:
4402 addl2 r2,r7
4403 bicl2 #0,r7
4404 cmpl r7,r2
4405 bgequ noname.413
4406 incl r9
4407noname.413:
4408
4409 movl 4(ap),r0
4410 movl r8,16(r0)
4411
4412 clrl r8
4413
4414 movl 8(ap),r0
4415 movzwl 22(r0),r2
4416 bicl3 #-65536,(r0),r3
4417 movzwl 2(r0),r1
4418 bicl2 #-65536,r1
4419 bicl3 #-65536,20(r0),-132(fp)
4420 bicl3 #-65536,r2,-136(fp)
4421 mull3 r1,-132(fp),-124(fp)
4422 mull2 r3,-132(fp)
4423 mull3 r3,-136(fp),-128(fp)
4424 mull2 r1,-136(fp)
4425 addl3 -124(fp),-128(fp),r0
4426 bicl3 #0,r0,-124(fp)
4427 cmpl -124(fp),-128(fp)
4428 bgequ noname.414
4429 addl2 #65536,-136(fp)
4430noname.414:
4431 movzwl -122(fp),r0
4432 bicl2 #-65536,r0
4433 addl2 r0,-136(fp)
4434 bicl3 #-65536,-124(fp),r0
4435 ashl #16,r0,-128(fp)
4436 addl3 -128(fp),-132(fp),r0
4437 bicl3 #0,r0,-132(fp)
4438 cmpl -132(fp),-128(fp)
4439 bgequ noname.415
4440 incl -136(fp)
4441noname.415:
4442 movl -132(fp),r3
4443 movl -136(fp),r2
4444 bbc #31,r2,noname.416
4445 incl r8
4446noname.416:
4447 addl2 r2,r2
4448 bicl2 #0,r2
4449 bbc #31,r3,noname.417
4450 incl r2
4451noname.417:
4452 addl2 r3,r3
4453 bicl2 #0,r3
4454 addl2 r3,r7
4455 bicl2 #0,r7
4456 cmpl r7,r3
4457 bgequ noname.418
4458 incl r2
4459 bicl3 #0,r2,r0
4460 bneq noname.418
4461 incl r8
4462noname.418:
4463 addl2 r2,r9
4464 bicl2 #0,r9
4465 cmpl r9,r2
4466 bgequ noname.419
4467 incl r8
4468noname.419:
4469
4470 movl 8(ap),r0
4471 movzwl 18(r0),r2
4472 bicl3 #-65536,4(r0),r3
4473 movzwl 6(r0),r1
4474 bicl2 #-65536,r1
4475 bicl3 #-65536,16(r0),-148(fp)
4476 bicl3 #-65536,r2,-152(fp)
4477 mull3 r1,-148(fp),-140(fp)
4478 mull2 r3,-148(fp)
4479 mull3 r3,-152(fp),-144(fp)
4480 mull2 r1,-152(fp)
4481 addl3 -140(fp),-144(fp),r0
4482 bicl3 #0,r0,-140(fp)
4483 cmpl -140(fp),-144(fp)
4484 bgequ noname.420
4485 addl2 #65536,-152(fp)
4486noname.420:
4487 movzwl -138(fp),r0
4488 bicl2 #-65536,r0
4489 addl2 r0,-152(fp)
4490 bicl3 #-65536,-140(fp),r0
4491 ashl #16,r0,-144(fp)
4492 addl3 -144(fp),-148(fp),r0
4493 bicl3 #0,r0,-148(fp)
4494 cmpl -148(fp),-144(fp)
4495 bgequ noname.421
4496 incl -152(fp)
4497noname.421:
4498 movl -148(fp),r3
4499 movl -152(fp),r2
4500 bbc #31,r2,noname.422
4501 incl r8
4502noname.422:
4503 addl2 r2,r2
4504 bicl2 #0,r2
4505 bbc #31,r3,noname.423
4506 incl r2
4507noname.423:
4508 addl2 r3,r3
4509 bicl2 #0,r3
4510 addl2 r3,r7
4511 bicl2 #0,r7
4512 cmpl r7,r3
4513 bgequ noname.424
4514 incl r2
4515 bicl3 #0,r2,r0
4516 bneq noname.424
4517 incl r8
4518noname.424:
4519 addl2 r2,r9
4520 bicl2 #0,r9
4521 cmpl r9,r2
4522 bgequ noname.425
4523 incl r8
4524noname.425:
4525
4526 movl 8(ap),r0
4527 movzwl 14(r0),r2
4528 bicl3 #-65536,8(r0),r3
4529 movzwl 10(r0),r1
4530 bicl2 #-65536,r1
4531 bicl3 #-65536,12(r0),-164(fp)
4532 bicl3 #-65536,r2,-168(fp)
4533 mull3 r1,-164(fp),-156(fp)
4534 mull2 r3,-164(fp)
4535 mull3 r3,-168(fp),-160(fp)
4536 mull2 r1,-168(fp)
4537 addl3 -156(fp),-160(fp),r0
4538 bicl3 #0,r0,-156(fp)
4539 cmpl -156(fp),-160(fp)
4540 bgequ noname.426
4541 addl2 #65536,-168(fp)
4542noname.426:
4543 movzwl -154(fp),r0
4544 bicl2 #-65536,r0
4545 addl2 r0,-168(fp)
4546 bicl3 #-65536,-156(fp),r0
4547 ashl #16,r0,-160(fp)
4548 addl3 -160(fp),-164(fp),r0
4549 bicl3 #0,r0,-164(fp)
4550 cmpl -164(fp),-160(fp)
4551 bgequ noname.427
4552 incl -168(fp)
4553noname.427:
4554 movl -164(fp),r3
4555 movl -168(fp),r2
4556 bbc #31,r2,noname.428
4557 incl r8
4558noname.428:
4559 addl2 r2,r2
4560 bicl2 #0,r2
4561 bbc #31,r3,noname.429
4562 incl r2
4563noname.429:
4564 addl2 r3,r3
4565 bicl2 #0,r3
4566 addl2 r3,r7
4567 bicl2 #0,r7
4568 cmpl r7,r3
4569 bgequ noname.430
4570 incl r2
4571 bicl3 #0,r2,r0
4572 bneq noname.430
4573 incl r8
4574noname.430:
4575 addl2 r2,r9
4576 bicl2 #0,r9
4577 cmpl r9,r2
4578 bgequ noname.431
4579 incl r8
4580noname.431:
4581
4582 movl 4(ap),r0
4583 movl r7,20(r0)
4584
4585 clrl r7
4586
4587 movl 8(ap),r2
4588 movl 12(r2),r4
4589 bicl3 #-65536,r4,-172(fp)
4590 extzv #16,#16,r4,r0
4591 bicl3 #-65536,r0,r4
4592 movl -172(fp),r0
4593 mull3 r0,r4,-176(fp)
4594 mull3 r0,r0,-172(fp)
4595 mull2 r4,r4
4596 bicl3 #32767,-176(fp),r0
4597 extzv #15,#17,r0,r0
4598 addl2 r0,r4
4599 bicl3 #-65536,-176(fp),r0
4600 ashl #17,r0,-176(fp)
4601 addl3 -172(fp),-176(fp),r0
4602 bicl3 #0,r0,-172(fp)
4603 cmpl -172(fp),-176(fp)
4604 bgequ noname.432
4605 incl r4
4606noname.432:
4607 movl -172(fp),r1
4608 movl r4,r3
4609 addl2 r1,r9
4610 bicl2 #0,r9
4611 cmpl r9,r1
4612 bgequ noname.433
4613 incl r3
4614noname.433:
4615 addl2 r3,r8
4616 bicl2 #0,r8
4617 cmpl r8,r3
4618 bgequ noname.434
4619 incl r7
4620noname.434:
4621
4622 movzwl 18(r2),r3
4623 bicl3 #-65536,8(r2),r1
4624 movzwl 10(r2),r0
4625 bicl2 #-65536,r0
4626 bicl3 #-65536,16(r2),-188(fp)
4627 bicl3 #-65536,r3,-192(fp)
4628 mull3 r0,-188(fp),-180(fp)
4629 mull2 r1,-188(fp)
4630 mull3 r1,-192(fp),-184(fp)
4631 mull2 r0,-192(fp)
4632 addl3 -180(fp),-184(fp),r0
4633 bicl3 #0,r0,-180(fp)
4634 cmpl -180(fp),-184(fp)
4635 bgequ noname.435
4636 addl2 #65536,-192(fp)
4637noname.435:
4638 movzwl -178(fp),r0
4639 bicl2 #-65536,r0
4640 addl2 r0,-192(fp)
4641 bicl3 #-65536,-180(fp),r0
4642 ashl #16,r0,-184(fp)
4643 addl3 -184(fp),-188(fp),r0
4644 bicl3 #0,r0,-188(fp)
4645 cmpl -188(fp),-184(fp)
4646 bgequ noname.436
4647 incl -192(fp)
4648noname.436:
4649 movl -188(fp),r3
4650 movl -192(fp),r2
4651 bbc #31,r2,noname.437
4652 incl r7
4653noname.437:
4654 addl2 r2,r2
4655 bicl2 #0,r2
4656 bbc #31,r3,noname.438
4657 incl r2
4658noname.438:
4659 addl2 r3,r3
4660 bicl2 #0,r3
4661 addl2 r3,r9
4662 bicl2 #0,r9
4663 cmpl r9,r3
4664 bgequ noname.439
4665 incl r2
4666 bicl3 #0,r2,r0
4667 bneq noname.439
4668 incl r7
4669noname.439:
4670 addl2 r2,r8
4671 bicl2 #0,r8
4672 cmpl r8,r2
4673 bgequ noname.440
4674 incl r7
4675noname.440:
4676
4677 movl 8(ap),r0
4678 movzwl 22(r0),r2
4679 bicl3 #-65536,4(r0),r3
4680 movzwl 6(r0),r1
4681 bicl2 #-65536,r1
4682 bicl3 #-65536,20(r0),-204(fp)
4683 bicl3 #-65536,r2,-208(fp)
4684 mull3 r1,-204(fp),-196(fp)
4685 mull2 r3,-204(fp)
4686 mull3 r3,-208(fp),-200(fp)
4687 mull2 r1,-208(fp)
4688 addl3 -196(fp),-200(fp),r0
4689 bicl3 #0,r0,-196(fp)
4690 cmpl -196(fp),-200(fp)
4691 bgequ noname.441
4692 addl2 #65536,-208(fp)
4693noname.441:
4694 movzwl -194(fp),r0
4695 bicl2 #-65536,r0
4696 addl2 r0,-208(fp)
4697 bicl3 #-65536,-196(fp),r0
4698 ashl #16,r0,-200(fp)
4699 addl3 -200(fp),-204(fp),r0
4700 bicl3 #0,r0,-204(fp)
4701 cmpl -204(fp),-200(fp)
4702 bgequ noname.442
4703 incl -208(fp)
4704noname.442:
4705 movl -204(fp),r3
4706 movl -208(fp),r2
4707 bbc #31,r2,noname.443
4708 incl r7
4709noname.443:
4710 addl2 r2,r2
4711 bicl2 #0,r2
4712 bbc #31,r3,noname.444
4713 incl r2
4714noname.444:
4715 addl2 r3,r3
4716 bicl2 #0,r3
4717 addl2 r3,r9
4718 bicl2 #0,r9
4719 cmpl r9,r3
4720 bgequ noname.445
4721 incl r2
4722 bicl3 #0,r2,r0
4723 bneq noname.445
4724 incl r7
4725noname.445:
4726 addl2 r2,r8
4727 bicl2 #0,r8
4728 cmpl r8,r2
4729 bgequ noname.446
4730 incl r7
4731noname.446:
4732
4733 movl 8(ap),r0
4734 movzwl 26(r0),r2
4735 bicl3 #-65536,(r0),r3
4736 movzwl 2(r0),r1
4737 bicl2 #-65536,r1
4738 bicl3 #-65536,24(r0),-220(fp)
4739 bicl3 #-65536,r2,-224(fp)
4740 mull3 r1,-220(fp),-212(fp)
4741 mull2 r3,-220(fp)
4742 mull3 r3,-224(fp),-216(fp)
4743 mull2 r1,-224(fp)
4744 addl3 -212(fp),-216(fp),r0
4745 bicl3 #0,r0,-212(fp)
4746 cmpl -212(fp),-216(fp)
4747 bgequ noname.447
4748 addl2 #65536,-224(fp)
4749noname.447:
4750 movzwl -210(fp),r0
4751 bicl2 #-65536,r0
4752 addl2 r0,-224(fp)
4753 bicl3 #-65536,-212(fp),r0
4754 ashl #16,r0,-216(fp)
4755 addl3 -216(fp),-220(fp),r0
4756 bicl3 #0,r0,-220(fp)
4757 cmpl -220(fp),-216(fp)
4758 bgequ noname.448
4759 incl -224(fp)
4760noname.448:
4761 movl -220(fp),r3
4762 movl -224(fp),r2
4763 bbc #31,r2,noname.449
4764 incl r7
4765noname.449:
4766 addl2 r2,r2
4767 bicl2 #0,r2
4768 bbc #31,r3,noname.450
4769 incl r2
4770noname.450:
4771 addl2 r3,r3
4772 bicl2 #0,r3
4773 addl2 r3,r9
4774 bicl2 #0,r9
4775 cmpl r9,r3
4776 bgequ noname.451
4777 incl r2
4778 bicl3 #0,r2,r0
4779 bneq noname.451
4780 incl r7
4781noname.451:
4782 addl2 r2,r8
4783 bicl2 #0,r8
4784 cmpl r8,r2
4785 bgequ noname.452
4786 incl r7
4787noname.452:
4788
4789 movl 4(ap),r0
4790 movl r9,24(r0)
4791
4792 clrl r9
4793
4794 movl 8(ap),r0
4795 movzwl 30(r0),r2
4796 bicl3 #-65536,(r0),r3
4797 movzwl 2(r0),r1
4798 bicl2 #-65536,r1
4799 bicl3 #-65536,28(r0),-236(fp)
4800 bicl3 #-65536,r2,-240(fp)
4801 mull3 r1,-236(fp),-228(fp)
4802 mull2 r3,-236(fp)
4803 mull3 r3,-240(fp),-232(fp)
4804 mull2 r1,-240(fp)
4805 addl3 -228(fp),-232(fp),r0
4806 bicl3 #0,r0,-228(fp)
4807 cmpl -228(fp),-232(fp)
4808 bgequ noname.453
4809 addl2 #65536,-240(fp)
4810noname.453:
4811 movzwl -226(fp),r0
4812 bicl2 #-65536,r0
4813 addl2 r0,-240(fp)
4814 bicl3 #-65536,-228(fp),r0
4815 ashl #16,r0,-232(fp)
4816 addl3 -232(fp),-236(fp),r0
4817 bicl3 #0,r0,-236(fp)
4818 cmpl -236(fp),-232(fp)
4819 bgequ noname.454
4820 incl -240(fp)
4821noname.454:
4822 movl -236(fp),r3
4823 movl -240(fp),r2
4824 bbc #31,r2,noname.455
4825 incl r9
4826noname.455:
4827 addl2 r2,r2
4828 bicl2 #0,r2
4829 bbc #31,r3,noname.456
4830 incl r2
4831noname.456:
4832 addl2 r3,r3
4833 bicl2 #0,r3
4834 addl2 r3,r8
4835 bicl2 #0,r8
4836 cmpl r8,r3
4837 bgequ noname.457
4838 incl r2
4839 bicl3 #0,r2,r0
4840 bneq noname.457
4841 incl r9
4842noname.457:
4843 addl2 r2,r7
4844 bicl2 #0,r7
4845 cmpl r7,r2
4846 bgequ noname.458
4847 incl r9
4848noname.458:
4849
4850 movl 8(ap),r0
4851 movzwl 26(r0),r2
4852 bicl3 #-65536,4(r0),r3
4853 movzwl 6(r0),r1
4854 bicl2 #-65536,r1
4855 bicl3 #-65536,24(r0),-252(fp)
4856 bicl3 #-65536,r2,-256(fp)
4857 mull3 r1,-252(fp),-244(fp)
4858 mull2 r3,-252(fp)
4859 mull3 r3,-256(fp),-248(fp)
4860 mull2 r1,-256(fp)
4861 addl3 -244(fp),-248(fp),r0
4862 bicl3 #0,r0,-244(fp)
4863 cmpl -244(fp),-248(fp)
4864 bgequ noname.459
4865 addl2 #65536,-256(fp)
4866noname.459:
4867 movzwl -242(fp),r0
4868 bicl2 #-65536,r0
4869 addl2 r0,-256(fp)
4870 bicl3 #-65536,-244(fp),r0
4871 ashl #16,r0,-248(fp)
4872 addl3 -248(fp),-252(fp),r0
4873 bicl3 #0,r0,-252(fp)
4874 cmpl -252(fp),-248(fp)
4875 bgequ noname.460
4876 incl -256(fp)
4877noname.460:
4878 movl -252(fp),r3
4879 movl -256(fp),r2
4880 bbc #31,r2,noname.461
4881 incl r9
4882noname.461:
4883 addl2 r2,r2
4884 bicl2 #0,r2
4885 bbc #31,r3,noname.462
4886 incl r2
4887noname.462:
4888 addl2 r3,r3
4889 bicl2 #0,r3
4890 addl2 r3,r8
4891 bicl2 #0,r8
4892 cmpl r8,r3
4893 bgequ noname.463
4894 incl r2
4895 bicl3 #0,r2,r0
4896 bneq noname.463
4897 incl r9
4898noname.463:
4899 addl2 r2,r7
4900 bicl2 #0,r7
4901 cmpl r7,r2
4902 bgequ noname.464
4903 incl r9
4904noname.464:
4905
4906 movl 8(ap),r0
4907 movzwl 22(r0),r2
4908 bicl3 #-65536,8(r0),r3
4909 movzwl 10(r0),r1
4910 bicl2 #-65536,r1
4911 bicl3 #-65536,20(r0),-268(fp)
4912 bicl3 #-65536,r2,-272(fp)
4913 mull3 r1,-268(fp),-260(fp)
4914 mull2 r3,-268(fp)
4915 mull3 r3,-272(fp),-264(fp)
4916 mull2 r1,-272(fp)
4917 addl3 -260(fp),-264(fp),r0
4918 bicl3 #0,r0,-260(fp)
4919 cmpl -260(fp),-264(fp)
4920 bgequ noname.465
4921 addl2 #65536,-272(fp)
4922noname.465:
4923 movzwl -258(fp),r0
4924 bicl2 #-65536,r0
4925 addl2 r0,-272(fp)
4926 bicl3 #-65536,-260(fp),r0
4927 ashl #16,r0,-264(fp)
4928 addl3 -264(fp),-268(fp),r0
4929 bicl3 #0,r0,-268(fp)
4930 cmpl -268(fp),-264(fp)
4931 bgequ noname.466
4932 incl -272(fp)
4933noname.466:
4934 movl -268(fp),r3
4935 movl -272(fp),r2
4936 bbc #31,r2,noname.467
4937 incl r9
4938noname.467:
4939 addl2 r2,r2
4940 bicl2 #0,r2
4941 bbc #31,r3,noname.468
4942 incl r2
4943noname.468:
4944 addl2 r3,r3
4945 bicl2 #0,r3
4946 addl2 r3,r8
4947 bicl2 #0,r8
4948 cmpl r8,r3
4949 bgequ noname.469
4950 incl r2
4951 bicl3 #0,r2,r0
4952 bneq noname.469
4953 incl r9
4954noname.469:
4955 addl2 r2,r7
4956 bicl2 #0,r7
4957 cmpl r7,r2
4958 bgequ noname.470
4959 incl r9
4960noname.470:
4961
4962 movl 8(ap),r0
4963 movzwl 18(r0),r2
4964 bicl3 #-65536,12(r0),r3
4965 movzwl 14(r0),r1
4966 bicl2 #-65536,r1
4967 bicl3 #-65536,16(r0),-284(fp)
4968 bicl3 #-65536,r2,-288(fp)
4969 mull3 r1,-284(fp),-276(fp)
4970 mull2 r3,-284(fp)
4971 mull3 r3,-288(fp),-280(fp)
4972 mull2 r1,-288(fp)
4973 addl3 -276(fp),-280(fp),r0
4974 bicl3 #0,r0,-276(fp)
4975 cmpl -276(fp),-280(fp)
4976 bgequ noname.471
4977 addl2 #65536,-288(fp)
4978noname.471:
4979 movzwl -274(fp),r0
4980 bicl2 #-65536,r0
4981 addl2 r0,-288(fp)
4982 bicl3 #-65536,-276(fp),r0
4983 ashl #16,r0,-280(fp)
4984 addl3 -280(fp),-284(fp),r0
4985 bicl3 #0,r0,-284(fp)
4986 cmpl -284(fp),-280(fp)
4987 bgequ noname.472
4988 incl -288(fp)
4989noname.472:
4990 movl -284(fp),r3
4991 movl -288(fp),r2
4992 bbc #31,r2,noname.473
4993 incl r9
4994noname.473:
4995 addl2 r2,r2
4996 bicl2 #0,r2
4997 bbc #31,r3,noname.474
4998 incl r2
4999noname.474:
5000 addl2 r3,r3
5001 bicl2 #0,r3
5002 addl2 r3,r8
5003 bicl2 #0,r8
5004 cmpl r8,r3
5005 bgequ noname.475
5006 incl r2
5007 bicl3 #0,r2,r0
5008 bneq noname.475
5009 incl r9
5010noname.475:
5011 addl2 r2,r7
5012 bicl2 #0,r7
5013 cmpl r7,r2
5014 bgequ noname.476
5015 incl r9
5016noname.476:
5017
5018 movl 4(ap),r0
5019 movl r8,28(r0)
5020
5021 clrl r8
5022
5023 movl 8(ap),r3
5024 movl 16(r3),r4
5025 bicl3 #-65536,r4,r5
5026 extzv #16,#16,r4,r0
5027 bicl3 #-65536,r0,r4
5028 mull3 r5,r4,-292(fp)
5029 mull2 r5,r5
5030 mull2 r4,r4
5031 bicl3 #32767,-292(fp),r0
5032 extzv #15,#17,r0,r0
5033 addl2 r0,r4
5034 bicl3 #-65536,-292(fp),r0
5035 ashl #17,r0,-292(fp)
5036 addl2 -292(fp),r5
5037 bicl2 #0,r5
5038 cmpl r5,-292(fp)
5039 bgequ noname.477
5040 incl r4
5041noname.477:
5042 movl r5,r1
5043 movl r4,r2
5044 addl2 r1,r7
5045 bicl2 #0,r7
5046 cmpl r7,r1
5047 bgequ noname.478
5048 incl r2
5049noname.478:
5050 addl2 r2,r9
5051 bicl2 #0,r9
5052 cmpl r9,r2
5053 bgequ noname.479
5054 incl r8
5055noname.479:
5056
5057 bicl3 #-65536,20(r3),r4
5058 movzwl 22(r3),r1
5059 bicl2 #-65536,r1
5060 bicl3 #-65536,12(r3),r2
5061 movzwl 14(r3),r0
5062 bicl2 #-65536,r0
5063 movl r4,r6
5064 movl r1,r5
5065 mull3 r0,r6,-296(fp)
5066 mull2 r2,r6
5067 mull3 r2,r5,-300(fp)
5068 mull2 r0,r5
5069 addl3 -296(fp),-300(fp),r0
5070 bicl3 #0,r0,-296(fp)
5071 cmpl -296(fp),-300(fp)
5072 bgequ noname.480
5073 addl2 #65536,r5
5074noname.480:
5075 movzwl -294(fp),r0
5076 bicl2 #-65536,r0
5077 addl2 r0,r5
5078 bicl3 #-65536,-296(fp),r0
5079 ashl #16,r0,-300(fp)
5080 addl2 -300(fp),r6
5081 bicl2 #0,r6
5082 cmpl r6,-300(fp)
5083 bgequ noname.481
5084 incl r5
5085noname.481:
5086 movl r6,r3
5087 movl r5,r2
5088 bbc #31,r2,noname.482
5089 incl r8
5090noname.482:
5091 addl2 r2,r2
5092 bicl2 #0,r2
5093 bbc #31,r3,noname.483
5094 incl r2
5095noname.483:
5096 addl2 r3,r3
5097 bicl2 #0,r3
5098 addl2 r3,r7
5099 bicl2 #0,r7
5100 cmpl r7,r3
5101 bgequ noname.484
5102 incl r2
5103 bicl3 #0,r2,r0
5104 bneq noname.484
5105 incl r8
5106noname.484:
5107 addl2 r2,r9
5108 bicl2 #0,r9
5109 cmpl r9,r2
5110 bgequ noname.485
5111 incl r8
5112noname.485:
5113
5114 movl 8(ap),r0
5115 bicl3 #-65536,24(r0),r3
5116 movzwl 26(r0),r1
5117 bicl2 #-65536,r1
5118 bicl3 #-65536,8(r0),r2
5119 movzwl 10(r0),r0
5120 bicl2 #-65536,r0
5121 movl r3,r5
5122 movl r1,r4
5123 mull3 r0,r5,-304(fp)
5124 mull2 r2,r5
5125 mull3 r2,r4,-308(fp)
5126 mull2 r0,r4
5127 addl3 -304(fp),-308(fp),r0
5128 bicl3 #0,r0,-304(fp)
5129 cmpl -304(fp),-308(fp)
5130 bgequ noname.486
5131 addl2 #65536,r4
5132noname.486:
5133 movzwl -302(fp),r0
5134 bicl2 #-65536,r0
5135 addl2 r0,r4
5136 bicl3 #-65536,-304(fp),r0
5137 ashl #16,r0,-308(fp)
5138 addl2 -308(fp),r5
5139 bicl2 #0,r5
5140 cmpl r5,-308(fp)
5141 bgequ noname.487
5142 incl r4
5143noname.487:
5144 movl r5,r3
5145 movl r4,r2
5146 bbc #31,r2,noname.488
5147 incl r8
5148noname.488:
5149 addl2 r2,r2
5150 bicl2 #0,r2
5151 bbc #31,r3,noname.489
5152 incl r2
5153noname.489:
5154 addl2 r3,r3
5155 bicl2 #0,r3
5156 addl2 r3,r7
5157 bicl2 #0,r7
5158 cmpl r7,r3
5159 bgequ noname.490
5160 incl r2
5161 bicl3 #0,r2,r0
5162 bneq noname.490
5163 incl r8
5164noname.490:
5165 addl2 r2,r9
5166 bicl2 #0,r9
5167 cmpl r9,r2
5168 bgequ noname.491
5169 incl r8
5170noname.491:
5171
5172 movl 8(ap),r0
5173 bicl3 #-65536,28(r0),r3
5174 movzwl 30(r0),r1
5175 bicl2 #-65536,r1
5176 bicl3 #-65536,4(r0),r2
5177 movzwl 6(r0),r0
5178 bicl2 #-65536,r0
5179 movl r3,r5
5180 movl r1,r4
5181 mull3 r0,r5,-312(fp)
5182 mull2 r2,r5
5183 mull3 r2,r4,-316(fp)
5184 mull2 r0,r4
5185 addl3 -312(fp),-316(fp),r0
5186 bicl3 #0,r0,-312(fp)
5187 cmpl -312(fp),-316(fp)
5188 bgequ noname.492
5189 addl2 #65536,r4
5190noname.492:
5191 movzwl -310(fp),r0
5192 bicl2 #-65536,r0
5193 addl2 r0,r4
5194 bicl3 #-65536,-312(fp),r0
5195 ashl #16,r0,-316(fp)
5196 addl2 -316(fp),r5
5197 bicl2 #0,r5
5198 cmpl r5,-316(fp)
5199 bgequ noname.493
5200 incl r4
5201noname.493:
5202 movl r5,r3
5203 movl r4,r2
5204 bbc #31,r2,noname.494
5205 incl r8
5206noname.494:
5207 addl2 r2,r2
5208 bicl2 #0,r2
5209 bbc #31,r3,noname.495
5210 incl r2
5211noname.495:
5212 addl2 r3,r3
5213 bicl2 #0,r3
5214 addl2 r3,r7
5215 bicl2 #0,r7
5216 cmpl r7,r3
5217 bgequ noname.496
5218 incl r2
5219 bicl3 #0,r2,r0
5220 bneq noname.496
5221 incl r8
5222noname.496:
5223 addl2 r2,r9
5224 bicl2 #0,r9
5225 cmpl r9,r2
5226 bgequ noname.497
5227 incl r8
5228noname.497:
5229
5230 movl 4(ap),r0
5231 movl r7,32(r0)
5232
5233 clrl r7
5234
5235 movl 8(ap),r0
5236 bicl3 #-65536,28(r0),r3
5237 movzwl 30(r0),r2
5238 bicl3 #-65536,8(r0),r1
5239 movzwl 10(r0),r0
5240 bicl2 #-65536,r0
5241 movl r3,r4
5242 bicl3 #-65536,r2,-328(fp)
5243 mull3 r0,r4,-320(fp)
5244 mull2 r1,r4
5245 mull3 r1,-328(fp),-324(fp)
5246 mull2 r0,-328(fp)
5247 addl3 -320(fp),-324(fp),r0
5248 bicl3 #0,r0,-320(fp)
5249 cmpl -320(fp),-324(fp)
5250 bgequ noname.498
5251 addl2 #65536,-328(fp)
5252noname.498:
5253 movzwl -318(fp),r0
5254 bicl2 #-65536,r0
5255 addl2 r0,-328(fp)
5256 bicl3 #-65536,-320(fp),r0
5257 ashl #16,r0,-324(fp)
5258 addl2 -324(fp),r4
5259 bicl2 #0,r4
5260 cmpl r4,-324(fp)
5261 bgequ noname.499
5262 incl -328(fp)
5263noname.499:
5264 movl r4,r3
5265 movl -328(fp),r2
5266 bbc #31,r2,noname.500
5267 incl r7
5268noname.500:
5269 addl2 r2,r2
5270 bicl2 #0,r2
5271 bbc #31,r3,noname.501
5272 incl r2
5273noname.501:
5274 addl2 r3,r3
5275 bicl2 #0,r3
5276 addl2 r3,r9
5277 bicl2 #0,r9
5278 cmpl r9,r3
5279 bgequ noname.502
5280 incl r2
5281 bicl3 #0,r2,r0
5282 bneq noname.502
5283 incl r7
5284noname.502:
5285 addl2 r2,r8
5286 bicl2 #0,r8
5287 cmpl r8,r2
5288 bgequ noname.503
5289 incl r7
5290noname.503:
5291
5292 movl 8(ap),r0
5293 movzwl 26(r0),r2
5294 bicl3 #-65536,12(r0),r3
5295 movzwl 14(r0),r1
5296 bicl2 #-65536,r1
5297 bicl3 #-65536,24(r0),-340(fp)
5298 bicl3 #-65536,r2,-344(fp)
5299 mull3 r1,-340(fp),-332(fp)
5300 mull2 r3,-340(fp)
5301 mull3 r3,-344(fp),-336(fp)
5302 mull2 r1,-344(fp)
5303 addl3 -332(fp),-336(fp),r0
5304 bicl3 #0,r0,-332(fp)
5305 cmpl -332(fp),-336(fp)
5306 bgequ noname.504
5307 addl2 #65536,-344(fp)
5308noname.504:
5309 movzwl -330(fp),r0
5310 bicl2 #-65536,r0
5311 addl2 r0,-344(fp)
5312 bicl3 #-65536,-332(fp),r0
5313 ashl #16,r0,-336(fp)
5314 addl3 -336(fp),-340(fp),r0
5315 bicl3 #0,r0,-340(fp)
5316 cmpl -340(fp),-336(fp)
5317 bgequ noname.505
5318 incl -344(fp)
5319noname.505:
5320 movl -340(fp),r3
5321 movl -344(fp),r2
5322 bbc #31,r2,noname.506
5323 incl r7
5324noname.506:
5325 addl2 r2,r2
5326 bicl2 #0,r2
5327 bbc #31,r3,noname.507
5328 incl r2
5329noname.507:
5330 addl2 r3,r3
5331 bicl2 #0,r3
5332 addl2 r3,r9
5333 bicl2 #0,r9
5334 cmpl r9,r3
5335 bgequ noname.508
5336 incl r2
5337 bicl3 #0,r2,r0
5338 bneq noname.508
5339 incl r7
5340noname.508:
5341 addl2 r2,r8
5342 bicl2 #0,r8
5343 cmpl r8,r2
5344 bgequ noname.509
5345 incl r7
5346noname.509:
5347
5348 movl 8(ap),r0
5349 movzwl 22(r0),r2
5350 bicl3 #-65536,16(r0),r3
5351 movzwl 18(r0),r1
5352 bicl2 #-65536,r1
5353 bicl3 #-65536,20(r0),-356(fp)
5354 bicl3 #-65536,r2,-360(fp)
5355 mull3 r1,-356(fp),-348(fp)
5356 mull2 r3,-356(fp)
5357 mull3 r3,-360(fp),-352(fp)
5358 mull2 r1,-360(fp)
5359 addl3 -348(fp),-352(fp),r0
5360 bicl3 #0,r0,-348(fp)
5361 cmpl -348(fp),-352(fp)
5362 bgequ noname.510
5363 addl2 #65536,-360(fp)
5364noname.510:
5365 movzwl -346(fp),r0
5366 bicl2 #-65536,r0
5367 addl2 r0,-360(fp)
5368 bicl3 #-65536,-348(fp),r0
5369 ashl #16,r0,-352(fp)
5370 addl3 -352(fp),-356(fp),r0
5371 bicl3 #0,r0,-356(fp)
5372 cmpl -356(fp),-352(fp)
5373 bgequ noname.511
5374 incl -360(fp)
5375noname.511:
5376 movl -356(fp),r3
5377 movl -360(fp),r2
5378 bbc #31,r2,noname.512
5379 incl r7
5380noname.512:
5381 addl2 r2,r2
5382 bicl2 #0,r2
5383 bbc #31,r3,noname.513
5384 incl r2
5385noname.513:
5386 addl2 r3,r3
5387 bicl2 #0,r3
5388 addl2 r3,r9
5389 bicl2 #0,r9
5390 cmpl r9,r3
5391 bgequ noname.514
5392 incl r2
5393 bicl3 #0,r2,r0
5394 bneq noname.514
5395 incl r7
5396noname.514:
5397 addl2 r2,r8
5398 bicl2 #0,r8
5399 cmpl r8,r2
5400 bgequ noname.515
5401 incl r7
5402noname.515:
5403
5404 movl 4(ap),r0
5405 movl r9,36(r0)
5406
5407 clrl r9
5408
5409 movl 8(ap),r3
5410 movl 20(r3),r4
5411 bicl3 #-65536,r4,-364(fp)
5412 extzv #16,#16,r4,r0
5413 bicl3 #-65536,r0,r4
5414 movl -364(fp),r0
5415 mull3 r0,r4,-368(fp)
5416 mull3 r0,r0,-364(fp)
5417 mull2 r4,r4
5418 bicl3 #32767,-368(fp),r0
5419 extzv #15,#17,r0,r0
5420 addl2 r0,r4
5421 bicl3 #-65536,-368(fp),r0
5422 ashl #17,r0,-368(fp)
5423 addl3 -364(fp),-368(fp),r0
5424 bicl3 #0,r0,-364(fp)
5425 cmpl -364(fp),-368(fp)
5426 bgequ noname.516
5427 incl r4
5428noname.516:
5429 movl -364(fp),r1
5430 movl r4,r2
5431 addl2 r1,r8
5432 bicl2 #0,r8
5433 cmpl r8,r1
5434 bgequ noname.517
5435 incl r2
5436noname.517:
5437 addl2 r2,r7
5438 bicl2 #0,r7
5439 cmpl r7,r2
5440 bgequ noname.518
5441 incl r9
5442noname.518:
5443
5444 bicl3 #-65536,24(r3),r4
5445 movzwl 26(r3),r1
5446 bicl2 #-65536,r1
5447 bicl3 #-65536,16(r3),r2
5448 movzwl 18(r3),r0
5449 bicl2 #-65536,r0
5450 movl r4,r6
5451 movl r1,r5
5452 mull3 r0,r6,-372(fp)
5453 mull2 r2,r6
5454 mull3 r2,r5,-376(fp)
5455 mull2 r0,r5
5456 addl3 -372(fp),-376(fp),r0
5457 bicl3 #0,r0,-372(fp)
5458 cmpl -372(fp),-376(fp)
5459 bgequ noname.519
5460 addl2 #65536,r5
5461noname.519:
5462 movzwl -370(fp),r0
5463 bicl2 #-65536,r0
5464 addl2 r0,r5
5465 bicl3 #-65536,-372(fp),r0
5466 ashl #16,r0,-376(fp)
5467 addl2 -376(fp),r6
5468 bicl2 #0,r6
5469 cmpl r6,-376(fp)
5470 bgequ noname.520
5471 incl r5
5472noname.520:
5473 movl r6,r3
5474 movl r5,r2
5475 bbc #31,r2,noname.521
5476 incl r9
5477noname.521:
5478 addl2 r2,r2
5479 bicl2 #0,r2
5480 bbc #31,r3,noname.522
5481 incl r2
5482noname.522:
5483 addl2 r3,r3
5484 bicl2 #0,r3
5485 addl2 r3,r8
5486 bicl2 #0,r8
5487 cmpl r8,r3
5488 bgequ noname.523
5489 incl r2
5490 bicl3 #0,r2,r0
5491 bneq noname.523
5492 incl r9
5493noname.523:
5494 addl2 r2,r7
5495 bicl2 #0,r7
5496 cmpl r7,r2
5497 bgequ noname.524
5498 incl r9
5499noname.524:
5500
5501 movl 8(ap),r0
5502 bicl3 #-65536,28(r0),r3
5503 movzwl 30(r0),r1
5504 bicl2 #-65536,r1
5505 bicl3 #-65536,12(r0),r2
5506 movzwl 14(r0),r0
5507 bicl2 #-65536,r0
5508 movl r3,r5
5509 movl r1,r4
5510 mull3 r0,r5,-380(fp)
5511 mull2 r2,r5
5512 mull3 r2,r4,-384(fp)
5513 mull2 r0,r4
5514 addl3 -380(fp),-384(fp),r0
5515 bicl3 #0,r0,-380(fp)
5516 cmpl -380(fp),-384(fp)
5517 bgequ noname.525
5518 addl2 #65536,r4
5519noname.525:
5520 movzwl -378(fp),r0
5521 bicl2 #-65536,r0
5522 addl2 r0,r4
5523 bicl3 #-65536,-380(fp),r0
5524 ashl #16,r0,-384(fp)
5525 addl2 -384(fp),r5
5526 bicl2 #0,r5
5527 cmpl r5,-384(fp)
5528 bgequ noname.526
5529 incl r4
5530noname.526:
5531 movl r5,r3
5532 movl r4,r2
5533 bbc #31,r2,noname.527
5534 incl r9
5535noname.527:
5536 addl2 r2,r2
5537 bicl2 #0,r2
5538 bbc #31,r3,noname.528
5539 incl r2
5540noname.528:
5541 addl2 r3,r3
5542 bicl2 #0,r3
5543 addl2 r3,r8
5544 bicl2 #0,r8
5545 cmpl r8,r3
5546 bgequ noname.529
5547 incl r2
5548 bicl3 #0,r2,r0
5549 bneq noname.529
5550 incl r9
5551noname.529:
5552 addl2 r2,r7
5553 bicl2 #0,r7
5554 cmpl r7,r2
5555 bgequ noname.530
5556 incl r9
5557noname.530:
5558 movl 4(ap),r0
5559 movl r8,40(r0)
5560
5561 clrl r8
5562
5563 movl 8(ap),r0
5564 bicl3 #-65536,28(r0),r3
5565 movzwl 30(r0),r1
5566 bicl2 #-65536,r1
5567 bicl3 #-65536,16(r0),r2
5568 movzwl 18(r0),r0
5569 bicl2 #-65536,r0
5570 movl r3,r5
5571 movl r1,r4
5572 mull3 r0,r5,-388(fp)
5573 mull2 r2,r5
5574 mull3 r2,r4,-392(fp)
5575 mull2 r0,r4
5576 addl3 -388(fp),-392(fp),r0
5577 bicl3 #0,r0,-388(fp)
5578 cmpl -388(fp),-392(fp)
5579 bgequ noname.531
5580 addl2 #65536,r4
5581noname.531:
5582 movzwl -386(fp),r0
5583 bicl2 #-65536,r0
5584 addl2 r0,r4
5585 bicl3 #-65536,-388(fp),r0
5586 ashl #16,r0,-392(fp)
5587 addl2 -392(fp),r5
5588 bicl2 #0,r5
5589 cmpl r5,-392(fp)
5590 bgequ noname.532
5591 incl r4
5592noname.532:
5593 movl r5,r3
5594 movl r4,r2
5595 bbc #31,r2,noname.533
5596 incl r8
5597noname.533:
5598 addl2 r2,r2
5599 bicl2 #0,r2
5600 bbc #31,r3,noname.534
5601 incl r2
5602noname.534:
5603 addl2 r3,r3
5604 bicl2 #0,r3
5605 addl2 r3,r7
5606 bicl2 #0,r7
5607 cmpl r7,r3
5608 bgequ noname.535
5609 incl r2
5610 bicl3 #0,r2,r0
5611 bneq noname.535
5612 incl r8
5613noname.535:
5614 addl2 r2,r9
5615 bicl2 #0,r9
5616 cmpl r9,r2
5617 bgequ noname.536
5618 incl r8
5619noname.536:
5620
5621 movl 8(ap),r0
5622 bicl3 #-65536,24(r0),r3
5623 movzwl 26(r0),r1
5624 bicl2 #-65536,r1
5625 bicl3 #-65536,20(r0),r2
5626 movzwl 22(r0),r0
5627 bicl2 #-65536,r0
5628 movl r3,r5
5629 movl r1,r4
5630 mull3 r0,r5,-396(fp)
5631 mull2 r2,r5
5632 mull3 r2,r4,-400(fp)
5633 mull2 r0,r4
5634 addl3 -396(fp),-400(fp),r0
5635 bicl3 #0,r0,-396(fp)
5636 cmpl -396(fp),-400(fp)
5637 bgequ noname.537
5638 addl2 #65536,r4
5639noname.537:
5640 movzwl -394(fp),r0
5641 bicl2 #-65536,r0
5642 addl2 r0,r4
5643 bicl3 #-65536,-396(fp),r0
5644 ashl #16,r0,-400(fp)
5645 addl2 -400(fp),r5
5646 bicl2 #0,r5
5647 cmpl r5,-400(fp)
5648 bgequ noname.538
5649 incl r4
5650noname.538:
5651 movl r5,r3
5652 movl r4,r2
5653 bbc #31,r2,noname.539
5654 incl r8
5655noname.539:
5656 addl2 r2,r2
5657 bicl2 #0,r2
5658 bbc #31,r3,noname.540
5659 incl r2
5660noname.540:
5661 addl2 r3,r3
5662 bicl2 #0,r3
5663 addl2 r3,r7
5664 bicl2 #0,r7
5665 cmpl r7,r3
5666 bgequ noname.541
5667 incl r2
5668 bicl3 #0,r2,r0
5669 bneq noname.541
5670 incl r8
5671noname.541:
5672 addl2 r2,r9
5673 bicl2 #0,r9
5674 cmpl r9,r2
5675 bgequ noname.542
5676 incl r8
5677noname.542:
5678
5679 movl 4(ap),r0
5680 movl r7,44(r0)
5681
5682 clrl r7
5683
5684 movl 8(ap),r3
5685 movl 24(r3),r4
5686 bicl3 #-65536,r4,r5
5687 extzv #16,#16,r4,r0
5688 bicl3 #-65536,r0,r4
5689 mull3 r5,r4,-404(fp)
5690 mull2 r5,r5
5691 mull2 r4,r4
5692 bicl3 #32767,-404(fp),r0
5693 extzv #15,#17,r0,r0
5694 addl2 r0,r4
5695 bicl3 #-65536,-404(fp),r0
5696 ashl #17,r0,-404(fp)
5697 addl2 -404(fp),r5
5698 bicl2 #0,r5
5699 cmpl r5,-404(fp)
5700 bgequ noname.543
5701 incl r4
5702noname.543:
5703 movl r5,r1
5704 movl r4,r2
5705 addl2 r1,r9
5706 bicl2 #0,r9
5707 cmpl r9,r1
5708 bgequ noname.544
5709 incl r2
5710noname.544:
5711 addl2 r2,r8
5712 bicl2 #0,r8
5713 cmpl r8,r2
5714 bgequ noname.545
5715 incl r7
5716noname.545:
5717
5718 movzwl 30(r3),r2
5719 bicl3 #-65536,20(r3),r1
5720 movzwl 22(r3),r0
5721 bicl2 #-65536,r0
5722 bicl3 #-65536,28(r3),-416(fp)
5723 bicl3 #-65536,r2,-420(fp)
5724 mull3 r0,-416(fp),-408(fp)
5725 mull2 r1,-416(fp)
5726 mull3 r1,-420(fp),-412(fp)
5727 mull2 r0,-420(fp)
5728 addl3 -408(fp),-412(fp),r0
5729 bicl3 #0,r0,-408(fp)
5730 cmpl -408(fp),-412(fp)
5731 bgequ noname.546
5732 addl2 #65536,-420(fp)
5733noname.546:
5734 movzwl -406(fp),r0
5735 bicl2 #-65536,r0
5736 addl2 r0,-420(fp)
5737 bicl3 #-65536,-408(fp),r0
5738 ashl #16,r0,-412(fp)
5739 addl3 -412(fp),-416(fp),r0
5740 bicl3 #0,r0,-416(fp)
5741 cmpl -416(fp),-412(fp)
5742 bgequ noname.547
5743 incl -420(fp)
5744noname.547:
5745 movl -416(fp),r3
5746 movl -420(fp),r2
5747 bbc #31,r2,noname.548
5748 incl r7
5749noname.548:
5750 addl2 r2,r2
5751 bicl2 #0,r2
5752 bbc #31,r3,noname.549
5753 incl r2
5754noname.549:
5755 addl2 r3,r3
5756 bicl2 #0,r3
5757 addl2 r3,r9
5758 bicl2 #0,r9
5759 cmpl r9,r3
5760 bgequ noname.550
5761 incl r2
5762 bicl3 #0,r2,r0
5763 bneq noname.550
5764 incl r7
5765noname.550:
5766 addl2 r2,r8
5767 bicl2 #0,r8
5768 cmpl r8,r2
5769 bgequ noname.551
5770 incl r7
5771noname.551:
5772
5773 movl 4(ap),r0
5774 movl r9,48(r0)
5775
5776 clrl r9
5777
5778 movl 8(ap),r0
5779 movzwl 30(r0),r2
5780 bicl3 #-65536,24(r0),r3
5781 movzwl 26(r0),r1
5782 bicl2 #-65536,r1
5783 bicl3 #-65536,28(r0),-432(fp)
5784 bicl3 #-65536,r2,-436(fp)
5785 mull3 r1,-432(fp),-424(fp)
5786 mull2 r3,-432(fp)
5787 mull3 r3,-436(fp),-428(fp)
5788 mull2 r1,-436(fp)
5789 addl3 -424(fp),-428(fp),r0
5790 bicl3 #0,r0,-424(fp)
5791 cmpl -424(fp),-428(fp)
5792 bgequ noname.552
5793 addl2 #65536,-436(fp)
5794noname.552:
5795 movzwl -422(fp),r0
5796 bicl2 #-65536,r0
5797 addl2 r0,-436(fp)
5798 bicl3 #-65536,-424(fp),r0
5799 ashl #16,r0,-428(fp)
5800 addl3 -428(fp),-432(fp),r0
5801 bicl3 #0,r0,-432(fp)
5802 cmpl -432(fp),-428(fp)
5803 bgequ noname.553
5804 incl -436(fp)
5805noname.553:
5806 movl -432(fp),r3
5807 movl -436(fp),r2
5808 bbc #31,r2,noname.554
5809 incl r9
5810noname.554:
5811 addl2 r2,r2
5812 bicl2 #0,r2
5813 bbc #31,r3,noname.555
5814 incl r2
5815noname.555:
5816 addl2 r3,r3
5817 bicl2 #0,r3
5818 addl2 r3,r8
5819 bicl2 #0,r8
5820 cmpl r8,r3
5821 bgequ noname.556
5822 incl r2
5823 bicl3 #0,r2,r0
5824 bneq noname.556
5825 incl r9
5826noname.556:
5827 addl2 r2,r7
5828 bicl2 #0,r7
5829 cmpl r7,r2
5830 bgequ noname.557
5831 incl r9
5832noname.557:
5833
5834 movl 4(ap),r4
5835 movl r8,52(r4)
5836
5837 clrl r8
5838
5839 movl 8(ap),r0
5840 movl 28(r0),r3
5841 bicl3 #-65536,r3,-440(fp)
5842 extzv #16,#16,r3,r0
5843 bicl3 #-65536,r0,r3
5844 movl -440(fp),r0
5845 mull3 r0,r3,-444(fp)
5846 mull3 r0,r0,-440(fp)
5847 mull2 r3,r3
5848 bicl3 #32767,-444(fp),r0
5849 extzv #15,#17,r0,r0
5850 addl2 r0,r3
5851 bicl3 #-65536,-444(fp),r0
5852 ashl #17,r0,-444(fp)
5853 addl3 -440(fp),-444(fp),r0
5854 bicl3 #0,r0,-440(fp)
5855 cmpl -440(fp),-444(fp)
5856 bgequ noname.558
5857 incl r3
5858noname.558:
5859 movl -440(fp),r1
5860 movl r3,r2
5861 addl2 r1,r7
5862 bicl2 #0,r7
5863 cmpl r7,r1
5864 bgequ noname.559
5865 incl r2
5866noname.559:
5867 addl2 r2,r9
5868 bicl2 #0,r9
5869 cmpl r9,r2
5870 bgequ noname.560
5871 incl r8
5872noname.560:
5873
5874 movl r7,56(r4)
5875
5876 movl r9,60(r4)
5877
5878 ret
5879
5880
5881
5882;r=4 ;(AP)
5883;a=8 ;(AP)
5884;b=12 ;(AP)
5885;n=16 ;(AP) n by value (input)
5886
5887 .psect code,nowrt
5888
5889.entry BN_SQR_COMBA4,^m<r2,r3,r4,r5,r6,r7,r8,r9,r10>
5890 subl2 #44,sp
5891
5892 clrq r8
5893
5894 clrl r10
5895
5896 movl 8(ap),r5
5897 movl (r5),r3
5898 bicl3 #-65536,r3,r4
5899 extzv #16,#16,r3,r0
5900 bicl3 #-65536,r0,r3
5901 mull3 r4,r3,-4(fp)
5902 mull2 r4,r4
5903 mull2 r3,r3
5904 bicl3 #32767,-4(fp),r0
5905 extzv #15,#17,r0,r0
5906 addl2 r0,r3
5907 bicl3 #-65536,-4(fp),r0
5908 ashl #17,r0,-4(fp)
5909 addl2 -4(fp),r4
5910 bicl2 #0,r4
5911 cmpl r4,-4(fp)
5912 bgequ noname.563
5913 incl r3
5914noname.563:
5915 movl r4,r1
5916 movl r3,r2
5917 addl2 r1,r9
5918 bicl2 #0,r9
5919 cmpl r9,r1
5920 bgequ noname.564
5921 incl r2
5922noname.564:
5923 addl2 r2,r8
5924 bicl2 #0,r8
5925 cmpl r8,r2
5926 bgequ noname.565
5927 incl r10
5928noname.565:
5929
5930 movl r9,@4(ap)
5931
5932 clrl r9
5933
5934 bicl3 #-65536,4(r5),r3
5935 movzwl 6(r5),r1
5936 bicl2 #-65536,r1
5937 bicl3 #-65536,(r5),r2
5938 movzwl 2(r5),r0
5939 bicl2 #-65536,r0
5940 movl r3,r6
5941 movl r1,r4
5942 mull3 r0,r6,-8(fp)
5943 mull2 r2,r6
5944 mull2 r4,r2
5945 mull2 r0,r4
5946 addl3 -8(fp),r2,r0
5947 bicl3 #0,r0,-8(fp)
5948 cmpl -8(fp),r2
5949 bgequ noname.566
5950 addl2 #65536,r4
5951noname.566:
5952 movzwl -6(fp),r0
5953 bicl2 #-65536,r0
5954 addl2 r0,r4
5955 bicl3 #-65536,-8(fp),r0
5956 ashl #16,r0,r1
5957 addl2 r1,r6
5958 bicl2 #0,r6
5959 cmpl r6,r1
5960 bgequ noname.567
5961 incl r4
5962noname.567:
5963 movl r6,r3
5964 movl r4,r2
5965 bbc #31,r2,noname.568
5966 incl r9
5967noname.568:
5968 addl2 r2,r2
5969 bicl2 #0,r2
5970 bbc #31,r3,noname.569
5971 incl r2
5972noname.569:
5973 addl2 r3,r3
5974 bicl2 #0,r3
5975 addl2 r3,r8
5976 bicl2 #0,r8
5977 cmpl r8,r3
5978 bgequ noname.570
5979 incl r2
5980 bicl3 #0,r2,r0
5981 bneq noname.570
5982 incl r9
5983noname.570:
5984 addl2 r2,r10
5985 bicl2 #0,r10
5986 cmpl r10,r2
5987 bgequ noname.571
5988 incl r9
5989noname.571:
5990
5991 movl 4(ap),r0
5992 movl r8,4(r0)
5993
5994 clrl r8
5995
5996 movl 8(ap),r4
5997 movl 4(r4),r3
5998 bicl3 #-65536,r3,r5
5999 extzv #16,#16,r3,r0
6000 bicl3 #-65536,r0,r3
6001 mull3 r5,r3,r1
6002 mull2 r5,r5
6003 mull2 r3,r3
6004 bicl3 #32767,r1,r0
6005 extzv #15,#17,r0,r0
6006 addl2 r0,r3
6007 bicl2 #-65536,r1
6008 ashl #17,r1,r1
6009 addl2 r1,r5
6010 bicl2 #0,r5
6011 cmpl r5,r1
6012 bgequ noname.572
6013 incl r3
6014noname.572:
6015 movl r5,r1
6016 movl r3,r2
6017 addl2 r1,r10
6018 bicl2 #0,r10
6019 cmpl r10,r1
6020 bgequ noname.573
6021 incl r2
6022noname.573:
6023 addl2 r2,r9
6024 bicl2 #0,r9
6025 cmpl r9,r2
6026 bgequ noname.574
6027 incl r8
6028noname.574:
6029
6030 bicl3 #-65536,8(r4),r3
6031 movzwl 10(r4),r1
6032 bicl2 #-65536,r1
6033 bicl3 #-65536,(r4),r2
6034 movzwl 2(r4),r0
6035 bicl2 #-65536,r0
6036 movl r3,r6
6037 movl r1,r5
6038 mull3 r0,r6,r7
6039 mull2 r2,r6
6040 mull2 r5,r2
6041 mull2 r0,r5
6042 addl2 r2,r7
6043 bicl2 #0,r7
6044 cmpl r7,r2
6045 bgequ noname.575
6046 addl2 #65536,r5
6047noname.575:
6048 extzv #16,#16,r7,r0
6049 bicl2 #-65536,r0
6050 addl2 r0,r5
6051 bicl3 #-65536,r7,r0
6052 ashl #16,r0,r1
6053 addl2 r1,r6
6054 bicl2 #0,r6
6055 cmpl r6,r1
6056 bgequ noname.576
6057 incl r5
6058noname.576:
6059 movl r6,r3
6060 movl r5,r2
6061 bbc #31,r2,noname.577
6062 incl r8
6063noname.577:
6064 addl2 r2,r2
6065 bicl2 #0,r2
6066 bbc #31,r3,noname.578
6067 incl r2
6068noname.578:
6069 addl2 r3,r3
6070 bicl2 #0,r3
6071 addl2 r3,r10
6072 bicl2 #0,r10
6073 cmpl r10,r3
6074 bgequ noname.579
6075 incl r2
6076 bicl3 #0,r2,r0
6077 bneq noname.579
6078 incl r8
6079noname.579:
6080 addl2 r2,r9
6081 bicl2 #0,r9
6082 cmpl r9,r2
6083 bgequ noname.580
6084 incl r8
6085noname.580:
6086
6087 movl 4(ap),r0
6088 movl r10,8(r0)
6089
6090 clrl r10
6091
6092 movl 8(ap),r0
6093 bicl3 #-65536,12(r0),r3
6094 movzwl 14(r0),r1
6095 bicl2 #-65536,r1
6096 bicl3 #-65536,(r0),r2
6097 movzwl 2(r0),r0
6098 bicl2 #-65536,r0
6099 movl r3,r5
6100 movl r1,r4
6101 mull3 r0,r5,r6
6102 mull2 r2,r5
6103 mull3 r2,r4,-12(fp)
6104 mull2 r0,r4
6105 addl2 -12(fp),r6
6106 bicl2 #0,r6
6107 cmpl r6,-12(fp)
6108 bgequ noname.581
6109 addl2 #65536,r4
6110noname.581:
6111 extzv #16,#16,r6,r0
6112 bicl2 #-65536,r0
6113 addl2 r0,r4
6114 bicl3 #-65536,r6,r0
6115 ashl #16,r0,-12(fp)
6116 addl2 -12(fp),r5
6117 bicl2 #0,r5
6118 cmpl r5,-12(fp)
6119 bgequ noname.582
6120 incl r4
6121noname.582:
6122 movl r5,r3
6123 movl r4,r2
6124 bbc #31,r2,noname.583
6125 incl r10
6126noname.583:
6127 addl2 r2,r2
6128 bicl2 #0,r2
6129 bbc #31,r3,noname.584
6130 incl r2
6131noname.584:
6132 addl2 r3,r3
6133 bicl2 #0,r3
6134 addl2 r3,r9
6135 bicl2 #0,r9
6136 cmpl r9,r3
6137 bgequ noname.585
6138 incl r2
6139 bicl3 #0,r2,r0
6140 bneq noname.585
6141 incl r10
6142noname.585:
6143 addl2 r2,r8
6144 bicl2 #0,r8
6145 cmpl r8,r2
6146 bgequ noname.586
6147 incl r10
6148noname.586:
6149
6150 movl 8(ap),r0
6151 bicl3 #-65536,8(r0),r3
6152 movzwl 10(r0),r1
6153 bicl2 #-65536,r1
6154 bicl3 #-65536,4(r0),r2
6155 movzwl 6(r0),r0
6156 bicl2 #-65536,r0
6157 movl r3,r5
6158 movl r1,r4
6159 mull3 r0,r5,-16(fp)
6160 mull2 r2,r5
6161 mull3 r2,r4,-20(fp)
6162 mull2 r0,r4
6163 addl3 -16(fp),-20(fp),r0
6164 bicl3 #0,r0,-16(fp)
6165 cmpl -16(fp),-20(fp)
6166 bgequ noname.587
6167 addl2 #65536,r4
6168noname.587:
6169 movzwl -14(fp),r0
6170 bicl2 #-65536,r0
6171 addl2 r0,r4
6172 bicl3 #-65536,-16(fp),r0
6173 ashl #16,r0,-20(fp)
6174 addl2 -20(fp),r5
6175 bicl2 #0,r5
6176 cmpl r5,-20(fp)
6177 bgequ noname.588
6178 incl r4
6179noname.588:
6180 movl r5,r3
6181 movl r4,r2
6182 bbc #31,r2,noname.589
6183 incl r10
6184noname.589:
6185 addl2 r2,r2
6186 bicl2 #0,r2
6187 bbc #31,r3,noname.590
6188 incl r2
6189noname.590:
6190 addl2 r3,r3
6191 bicl2 #0,r3
6192 addl2 r3,r9
6193 bicl2 #0,r9
6194 cmpl r9,r3
6195 bgequ noname.591
6196 incl r2
6197 bicl3 #0,r2,r0
6198 bneq noname.591
6199 incl r10
6200noname.591:
6201 addl2 r2,r8
6202 bicl2 #0,r8
6203 cmpl r8,r2
6204 bgequ noname.592
6205 incl r10
6206noname.592:
6207 movl 4(ap),r0
6208 movl r9,12(r0)
6209
6210 clrl r9
6211
6212 movl 8(ap),r3
6213 movl 8(r3),r4
6214 bicl3 #-65536,r4,r5
6215 extzv #16,#16,r4,r0
6216 bicl3 #-65536,r0,r4
6217 mull3 r5,r4,-24(fp)
6218 mull2 r5,r5
6219 mull2 r4,r4
6220 bicl3 #32767,-24(fp),r0
6221 extzv #15,#17,r0,r0
6222 addl2 r0,r4
6223 bicl3 #-65536,-24(fp),r0
6224 ashl #17,r0,-24(fp)
6225 addl2 -24(fp),r5
6226 bicl2 #0,r5
6227 cmpl r5,-24(fp)
6228 bgequ noname.593
6229 incl r4
6230noname.593:
6231 movl r5,r1
6232 movl r4,r2
6233 addl2 r1,r8
6234 bicl2 #0,r8
6235 cmpl r8,r1
6236 bgequ noname.594
6237 incl r2
6238noname.594:
6239 addl2 r2,r10
6240 bicl2 #0,r10
6241 cmpl r10,r2
6242 bgequ noname.595
6243 incl r9
6244noname.595:
6245
6246 bicl3 #-65536,12(r3),r4
6247 movzwl 14(r3),r1
6248 bicl2 #-65536,r1
6249 bicl3 #-65536,4(r3),r2
6250 movzwl 6(r3),r0
6251 bicl2 #-65536,r0
6252 movl r4,r6
6253 movl r1,r5
6254 mull3 r0,r6,-28(fp)
6255 mull2 r2,r6
6256 mull3 r2,r5,-32(fp)
6257 mull2 r0,r5
6258 addl3 -28(fp),-32(fp),r0
6259 bicl3 #0,r0,-28(fp)
6260 cmpl -28(fp),-32(fp)
6261 bgequ noname.596
6262 addl2 #65536,r5
6263noname.596:
6264 movzwl -26(fp),r0
6265 bicl2 #-65536,r0
6266 addl2 r0,r5
6267 bicl3 #-65536,-28(fp),r0
6268 ashl #16,r0,-32(fp)
6269 addl2 -32(fp),r6
6270 bicl2 #0,r6
6271 cmpl r6,-32(fp)
6272 bgequ noname.597
6273 incl r5
6274noname.597:
6275 movl r6,r3
6276 movl r5,r2
6277 bbc #31,r2,noname.598
6278 incl r9
6279noname.598:
6280 addl2 r2,r2
6281 bicl2 #0,r2
6282 bbc #31,r3,noname.599
6283 incl r2
6284noname.599:
6285 addl2 r3,r3
6286 bicl2 #0,r3
6287 addl2 r3,r8
6288 bicl2 #0,r8
6289 cmpl r8,r3
6290 bgequ noname.600
6291 incl r2
6292 bicl3 #0,r2,r0
6293 bneq noname.600
6294 incl r9
6295noname.600:
6296 addl2 r2,r10
6297 bicl2 #0,r10
6298 cmpl r10,r2
6299 bgequ noname.601
6300 incl r9
6301noname.601:
6302
6303 movl 4(ap),r0
6304 movl r8,16(r0)
6305
6306 clrl r8
6307
6308 movl 8(ap),r0
6309 bicl3 #-65536,12(r0),r3
6310 movzwl 14(r0),r1
6311 bicl2 #-65536,r1
6312 bicl3 #-65536,8(r0),r2
6313 movzwl 10(r0),r0
6314 bicl2 #-65536,r0
6315 movl r3,r5
6316 movl r1,r4
6317 mull3 r0,r5,-36(fp)
6318 mull2 r2,r5
6319 mull3 r2,r4,-40(fp)
6320 mull2 r0,r4
6321 addl3 -36(fp),-40(fp),r0
6322 bicl3 #0,r0,-36(fp)
6323 cmpl -36(fp),-40(fp)
6324 bgequ noname.602
6325 addl2 #65536,r4
6326noname.602:
6327 movzwl -34(fp),r0
6328 bicl2 #-65536,r0
6329 addl2 r0,r4
6330 bicl3 #-65536,-36(fp),r0
6331 ashl #16,r0,-40(fp)
6332 addl2 -40(fp),r5
6333 bicl2 #0,r5
6334 cmpl r5,-40(fp)
6335 bgequ noname.603
6336 incl r4
6337noname.603:
6338 movl r5,r3
6339 movl r4,r2
6340 bbc #31,r2,noname.604
6341 incl r8
6342noname.604:
6343 addl2 r2,r2
6344 bicl2 #0,r2
6345 bbc #31,r3,noname.605
6346 incl r2
6347noname.605:
6348 addl2 r3,r3
6349 bicl2 #0,r3
6350 addl2 r3,r10
6351 bicl2 #0,r10
6352 cmpl r10,r3
6353 bgequ noname.606
6354 incl r2
6355 bicl3 #0,r2,r0
6356 bneq noname.606
6357 incl r8
6358noname.606:
6359 addl2 r2,r9
6360 bicl2 #0,r9
6361 cmpl r9,r2
6362 bgequ noname.607
6363 incl r8
6364noname.607:
6365
6366 movl 4(ap),r4
6367 movl r10,20(r4)
6368
6369 clrl r10
6370
6371 movl 8(ap),r0
6372 movl 12(r0),r3
6373 bicl3 #-65536,r3,r5
6374 extzv #16,#16,r3,r0
6375 bicl3 #-65536,r0,r3
6376 mull3 r5,r3,-44(fp)
6377 mull2 r5,r5
6378 mull2 r3,r3
6379 bicl3 #32767,-44(fp),r0
6380 extzv #15,#17,r0,r0
6381 addl2 r0,r3
6382 bicl3 #-65536,-44(fp),r0
6383 ashl #17,r0,-44(fp)
6384 addl2 -44(fp),r5
6385 bicl2 #0,r5
6386 cmpl r5,-44(fp)
6387 bgequ noname.608
6388 incl r3
6389noname.608:
6390 movl r5,r1
6391 movl r3,r2
6392 addl2 r1,r9
6393 bicl2 #0,r9
6394 cmpl r9,r1
6395 bgequ noname.609
6396 incl r2
6397noname.609:
6398 addl2 r2,r8
6399 bicl2 #0,r8
6400 cmpl r8,r2
6401 bgequ noname.610
6402 incl r10
6403noname.610:
6404
6405 movl r9,24(r4)
6406
6407 movl r8,28(r4)
6408
6409 ret
6410
6411; For now, the code below doesn't work, so I end this prematurely.
6412.end
diff --git a/src/lib/libcrypto/bn/asm/x86/f b/src/lib/libcrypto/bn/asm/x86/f
new file mode 100644
index 0000000000..22e4112224
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/x86/f
@@ -0,0 +1,3 @@
1#!/usr/local/bin/perl
2# x86 assember
3
diff --git a/src/lib/libcrypto/bn/bn.h b/src/lib/libcrypto/bn/bn.h
index 3da6d8ced9..b40682f831 100644
--- a/src/lib/libcrypto/bn/bn.h
+++ b/src/lib/libcrypto/bn/bn.h
@@ -248,8 +248,6 @@ typedef struct bn_blinding_st
248 BIGNUM *A; 248 BIGNUM *A;
249 BIGNUM *Ai; 249 BIGNUM *Ai;
250 BIGNUM *mod; /* just a reference */ 250 BIGNUM *mod; /* just a reference */
251 unsigned long thread_id; /* added in OpenSSL 0.9.6j and 0.9.7b;
252 * used only by crypto/rsa/rsa_eay.c, rsa_lib.c */
253 } BN_BLINDING; 251 } BN_BLINDING;
254 252
255/* Used for montgomery multiplication */ 253/* Used for montgomery multiplication */
diff --git a/src/lib/libcrypto/bn/bn.mul b/src/lib/libcrypto/bn/bn.mul
new file mode 100644
index 0000000000..9728870d38
--- /dev/null
+++ b/src/lib/libcrypto/bn/bn.mul
@@ -0,0 +1,19 @@
1We need
2
3* bn_mul_comba8
4* bn_mul_comba4
5* bn_mul_normal
6* bn_mul_recursive
7
8* bn_sqr_comba8
9* bn_sqr_comba4
10bn_sqr_normal -> BN_sqr
11* bn_sqr_recursive
12
13* bn_mul_low_recursive
14* bn_mul_low_normal
15* bn_mul_high
16
17* bn_mul_part_recursive # symetric but not power of 2
18
19bn_mul_asymetric_recursive # uneven, but do the chop up.
diff --git a/src/lib/libcrypto/bn/bn_div.c b/src/lib/libcrypto/bn/bn_div.c
index 580d1201bc..f9a095e3b3 100644
--- a/src/lib/libcrypto/bn/bn_div.c
+++ b/src/lib/libcrypto/bn/bn_div.c
@@ -150,20 +150,6 @@ int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,
150 q; \ 150 q; \
151 }) 151 })
152# define REMAINDER_IS_ALREADY_CALCULATED 152# define REMAINDER_IS_ALREADY_CALCULATED
153# elif defined(__x86_64) && defined(SIXTY_FOUR_BIT_LONG)
154 /*
155 * Same story here, but it's 128-bit by 64-bit division. Wow!
156 * <appro@fy.chalmers.se>
157 */
158# define bn_div_words(n0,n1,d0) \
159 ({ asm volatile ( \
160 "divq %4" \
161 : "=a"(q), "=d"(rem) \
162 : "a"(n1), "d"(n0), "g"(d0) \
163 : "cc"); \
164 q; \
165 })
166# define REMAINDER_IS_ALREADY_CALCULATED
167# endif /* __<cpu> */ 153# endif /* __<cpu> */
168# endif /* __GNUC__ */ 154# endif /* __GNUC__ */
169#endif /* OPENSSL_NO_ASM */ 155#endif /* OPENSSL_NO_ASM */
@@ -282,11 +268,6 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
282 q=(BN_ULONG)(((((BN_ULLONG)n0)<<BN_BITS2)|n1)/d0); 268 q=(BN_ULONG)(((((BN_ULLONG)n0)<<BN_BITS2)|n1)/d0);
283#else 269#else
284 q=bn_div_words(n0,n1,d0); 270 q=bn_div_words(n0,n1,d0);
285#ifdef BN_DEBUG_LEVITTE
286 fprintf(stderr,"DEBUG: bn_div_words(0x%08X,0x%08X,0x%08\
287X) -> 0x%08X\n",
288 n0, n1, d0, q);
289#endif
290#endif 271#endif
291 272
292#ifndef REMAINDER_IS_ALREADY_CALCULATED 273#ifndef REMAINDER_IS_ALREADY_CALCULATED
@@ -311,18 +292,11 @@ X) -> 0x%08X\n",
311 BN_ULONG t2l,t2h,ql,qh; 292 BN_ULONG t2l,t2h,ql,qh;
312 293
313 q=bn_div_words(n0,n1,d0); 294 q=bn_div_words(n0,n1,d0);
314#ifdef BN_DEBUG_LEVITTE
315 fprintf(stderr,"DEBUG: bn_div_words(0x%08X,0x%08X,0x%08\
316X) -> 0x%08X\n",
317 n0, n1, d0, q);
318#endif
319#ifndef REMAINDER_IS_ALREADY_CALCULATED 295#ifndef REMAINDER_IS_ALREADY_CALCULATED
320 rem=(n1-q*d0)&BN_MASK2; 296 rem=(n1-q*d0)&BN_MASK2;
321#endif 297#endif
322 298
323#if defined(BN_UMULT_LOHI) 299#ifdef BN_UMULT_HIGH
324 BN_UMULT_LOHI(t2l,t2h,d1,q);
325#elif defined(BN_UMULT_HIGH)
326 t2l = d1 * q; 300 t2l = d1 * q;
327 t2h = BN_UMULT_HIGH(d1,q); 301 t2h = BN_UMULT_HIGH(d1,q);
328#else 302#else
diff --git a/src/lib/libcrypto/bn/bn_lcl.h b/src/lib/libcrypto/bn/bn_lcl.h
index 5614bc6164..8a4dba375a 100644
--- a/src/lib/libcrypto/bn/bn_lcl.h
+++ b/src/lib/libcrypto/bn/bn_lcl.h
@@ -230,21 +230,6 @@ struct bignum_ctx
230 : "r"(a), "r"(b)); \ 230 : "r"(a), "r"(b)); \
231 ret; }) 231 ret; })
232# endif /* compiler */ 232# endif /* compiler */
233# elif defined(__x86_64) && defined(SIXTY_FOUR_BIT_LONG)
234# if defined(__GNUC__)
235# define BN_UMULT_HIGH(a,b) ({ \
236 register BN_ULONG ret,discard; \
237 asm ("mulq %3" \
238 : "=a"(discard),"=d"(ret) \
239 : "a"(a), "g"(b) \
240 : "cc"); \
241 ret; })
242# define BN_UMULT_LOHI(low,high,a,b) \
243 asm ("mulq %3" \
244 : "=a"(low),"=d"(high) \
245 : "a"(a),"g"(b) \
246 : "cc");
247# endif
248# endif /* cpu */ 233# endif /* cpu */
249#endif /* OPENSSL_NO_ASM */ 234#endif /* OPENSSL_NO_ASM */
250 235
@@ -352,7 +337,7 @@ struct bignum_ctx
352 337
353#define LBITS(a) ((a)&BN_MASK2l) 338#define LBITS(a) ((a)&BN_MASK2l)
354#define HBITS(a) (((a)>>BN_BITS4)&BN_MASK2l) 339#define HBITS(a) (((a)>>BN_BITS4)&BN_MASK2l)
355#define L2HBITS(a) (((a)<<BN_BITS4)&BN_MASK2) 340#define L2HBITS(a) ((BN_ULONG)((a)&BN_MASK2l)<<BN_BITS4)
356 341
357#define LLBITS(a) ((a)&BN_MASKl) 342#define LLBITS(a) ((a)&BN_MASKl)
358#define LHBITS(a) (((a)>>BN_BITS2)&BN_MASKl) 343#define LHBITS(a) (((a)>>BN_BITS2)&BN_MASKl)
@@ -368,7 +353,7 @@ struct bignum_ctx
368 lt=(bl)*(lt); \ 353 lt=(bl)*(lt); \
369 m1=(bl)*(ht); \ 354 m1=(bl)*(ht); \
370 ht =(bh)*(ht); \ 355 ht =(bh)*(ht); \
371 m=(m+m1)&BN_MASK2; if (m < m1) ht+=L2HBITS((BN_ULONG)1); \ 356 m=(m+m1)&BN_MASK2; if (m < m1) ht+=L2HBITS(1L); \
372 ht+=HBITS(m); \ 357 ht+=HBITS(m); \
373 m1=L2HBITS(m); \ 358 m1=L2HBITS(m); \
374 lt=(lt+m1)&BN_MASK2; if (lt < m1) ht++; \ 359 lt=(lt+m1)&BN_MASK2; if (lt < m1) ht++; \
@@ -433,19 +418,20 @@ void bn_sqr_comba4(BN_ULONG *r,const BN_ULONG *a);
433int bn_cmp_words(const BN_ULONG *a,const BN_ULONG *b,int n); 418int bn_cmp_words(const BN_ULONG *a,const BN_ULONG *b,int n);
434int bn_cmp_part_words(const BN_ULONG *a, const BN_ULONG *b, 419int bn_cmp_part_words(const BN_ULONG *a, const BN_ULONG *b,
435 int cl, int dl); 420 int cl, int dl);
436#if 0
437/* bn_mul.c rollback <appro> */
438void bn_mul_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,int n2, 421void bn_mul_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,int n2,
439 int dna,int dnb,BN_ULONG *t); 422 int dna,int dnb,BN_ULONG *t);
440void bn_mul_part_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b, 423void bn_mul_part_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,
441 int n,int tna,int tnb,BN_ULONG *t); 424 int n,int tna,int tnb,BN_ULONG *t);
442#endif
443void bn_sqr_recursive(BN_ULONG *r,const BN_ULONG *a, int n2, BN_ULONG *t); 425void bn_sqr_recursive(BN_ULONG *r,const BN_ULONG *a, int n2, BN_ULONG *t);
444void bn_mul_low_normal(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b, int n); 426void bn_mul_low_normal(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b, int n);
445void bn_mul_low_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,int n2, 427void bn_mul_low_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,int n2,
446 BN_ULONG *t); 428 BN_ULONG *t);
447void bn_mul_high(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,BN_ULONG *l,int n2, 429void bn_mul_high(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,BN_ULONG *l,int n2,
448 BN_ULONG *t); 430 BN_ULONG *t);
431BN_ULONG bn_add_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
432 int cl, int dl);
433BN_ULONG bn_sub_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
434 int cl, int dl);
449 435
450#ifdef __cplusplus 436#ifdef __cplusplus
451} 437}
diff --git a/src/lib/libcrypto/bn/bn_lib.c b/src/lib/libcrypto/bn/bn_lib.c
index fa0ff485ad..ce2ae78419 100644
--- a/src/lib/libcrypto/bn/bn_lib.c
+++ b/src/lib/libcrypto/bn/bn_lib.c
@@ -145,10 +145,10 @@ char *BN_options(void)
145 { 145 {
146 init++; 146 init++;
147#ifdef BN_LLONG 147#ifdef BN_LLONG
148 sprintf(data,"bn(%d,%d)",(int)sizeof(BN_ULLONG)*8, 148 snprintf(data,sizeof data,"bn(%d,%d)",(int)sizeof(BN_ULLONG)*8,
149 (int)sizeof(BN_ULONG)*8); 149 (int)sizeof(BN_ULONG)*8);
150#else 150#else
151 sprintf(data,"bn(%d,%d)",(int)sizeof(BN_ULONG)*8, 151 snprintf(data,sizeof data,"bn(%d,%d)",(int)sizeof(BN_ULONG)*8,
152 (int)sizeof(BN_ULONG)*8); 152 (int)sizeof(BN_ULONG)*8);
153#endif 153#endif
154 } 154 }
@@ -263,12 +263,12 @@ void BN_clear_free(BIGNUM *a)
263 if (a == NULL) return; 263 if (a == NULL) return;
264 if (a->d != NULL) 264 if (a->d != NULL)
265 { 265 {
266 OPENSSL_cleanse(a->d,a->dmax*sizeof(a->d[0])); 266 memset(a->d,0,a->dmax*sizeof(a->d[0]));
267 if (!(BN_get_flags(a,BN_FLG_STATIC_DATA))) 267 if (!(BN_get_flags(a,BN_FLG_STATIC_DATA)))
268 OPENSSL_free(a->d); 268 OPENSSL_free(a->d);
269 } 269 }
270 i=BN_get_flags(a,BN_FLG_MALLOCED); 270 i=BN_get_flags(a,BN_FLG_MALLOCED);
271 OPENSSL_cleanse(a,sizeof(BIGNUM)); 271 memset(a,0,sizeof(BIGNUM));
272 if (i) 272 if (i)
273 OPENSSL_free(a); 273 OPENSSL_free(a);
274 } 274 }
diff --git a/src/lib/libcrypto/bn/bn_mul.c b/src/lib/libcrypto/bn/bn_mul.c
index cb93ac3356..b03458d002 100644
--- a/src/lib/libcrypto/bn/bn_mul.c
+++ b/src/lib/libcrypto/bn/bn_mul.c
@@ -56,10 +56,325 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef BN_DEBUG
60# undef NDEBUG /* avoid conflicting definitions */
61# define NDEBUG
62#endif
63
59#include <stdio.h> 64#include <stdio.h>
65#include <assert.h>
60#include "cryptlib.h" 66#include "cryptlib.h"
61#include "bn_lcl.h" 67#include "bn_lcl.h"
62 68
69#if defined(OPENSSL_NO_ASM) || !(defined(__i386) || defined(__i386__)) || defined(__DJGPP__) /* Assembler implementation exists only for x86 */
70/* Here follows specialised variants of bn_add_words() and
71 bn_sub_words(). They have the property performing operations on
72 arrays of different sizes. The sizes of those arrays is expressed through
73 cl, which is the common length ( basicall, min(len(a),len(b)) ), and dl,
74 which is the delta between the two lengths, calculated as len(a)-len(b).
75 All lengths are the number of BN_ULONGs... For the operations that require
76 a result array as parameter, it must have the length cl+abs(dl).
77 These functions should probably end up in bn_asm.c as soon as there are
78 assembler counterparts for the systems that use assembler files. */
79
80BN_ULONG bn_sub_part_words(BN_ULONG *r,
81 const BN_ULONG *a, const BN_ULONG *b,
82 int cl, int dl)
83 {
84 BN_ULONG c, t;
85
86 assert(cl >= 0);
87 c = bn_sub_words(r, a, b, cl);
88
89 if (dl == 0)
90 return c;
91
92 r += cl;
93 a += cl;
94 b += cl;
95
96 if (dl < 0)
97 {
98#ifdef BN_COUNT
99 fprintf(stderr, " bn_sub_part_words %d + %d (dl < 0, c = %d)\n", cl, dl, c);
100#endif
101 for (;;)
102 {
103 t = b[0];
104 r[0] = (0-t-c)&BN_MASK2;
105 if (t != 0) c=1;
106 if (++dl >= 0) break;
107
108 t = b[1];
109 r[1] = (0-t-c)&BN_MASK2;
110 if (t != 0) c=1;
111 if (++dl >= 0) break;
112
113 t = b[2];
114 r[2] = (0-t-c)&BN_MASK2;
115 if (t != 0) c=1;
116 if (++dl >= 0) break;
117
118 t = b[3];
119 r[3] = (0-t-c)&BN_MASK2;
120 if (t != 0) c=1;
121 if (++dl >= 0) break;
122
123 b += 4;
124 r += 4;
125 }
126 }
127 else
128 {
129 int save_dl = dl;
130#ifdef BN_COUNT
131 fprintf(stderr, " bn_sub_part_words %d + %d (dl > 0, c = %d)\n", cl, dl, c);
132#endif
133 while(c)
134 {
135 t = a[0];
136 r[0] = (t-c)&BN_MASK2;
137 if (t != 0) c=0;
138 if (--dl <= 0) break;
139
140 t = a[1];
141 r[1] = (t-c)&BN_MASK2;
142 if (t != 0) c=0;
143 if (--dl <= 0) break;
144
145 t = a[2];
146 r[2] = (t-c)&BN_MASK2;
147 if (t != 0) c=0;
148 if (--dl <= 0) break;
149
150 t = a[3];
151 r[3] = (t-c)&BN_MASK2;
152 if (t != 0) c=0;
153 if (--dl <= 0) break;
154
155 save_dl = dl;
156 a += 4;
157 r += 4;
158 }
159 if (dl > 0)
160 {
161#ifdef BN_COUNT
162 fprintf(stderr, " bn_sub_part_words %d + %d (dl > 0, c == 0)\n", cl, dl);
163#endif
164 if (save_dl > dl)
165 {
166 switch (save_dl - dl)
167 {
168 case 1:
169 r[1] = a[1];
170 if (--dl <= 0) break;
171 case 2:
172 r[2] = a[2];
173 if (--dl <= 0) break;
174 case 3:
175 r[3] = a[3];
176 if (--dl <= 0) break;
177 }
178 a += 4;
179 r += 4;
180 }
181 }
182 if (dl > 0)
183 {
184#ifdef BN_COUNT
185 fprintf(stderr, " bn_sub_part_words %d + %d (dl > 0, copy)\n", cl, dl);
186#endif
187 for(;;)
188 {
189 r[0] = a[0];
190 if (--dl <= 0) break;
191 r[1] = a[1];
192 if (--dl <= 0) break;
193 r[2] = a[2];
194 if (--dl <= 0) break;
195 r[3] = a[3];
196 if (--dl <= 0) break;
197
198 a += 4;
199 r += 4;
200 }
201 }
202 }
203 return c;
204 }
205#endif
206
207BN_ULONG bn_add_part_words(BN_ULONG *r,
208 const BN_ULONG *a, const BN_ULONG *b,
209 int cl, int dl)
210 {
211 BN_ULONG c, l, t;
212
213 assert(cl >= 0);
214 c = bn_add_words(r, a, b, cl);
215
216 if (dl == 0)
217 return c;
218
219 r += cl;
220 a += cl;
221 b += cl;
222
223 if (dl < 0)
224 {
225 int save_dl = dl;
226#ifdef BN_COUNT
227 fprintf(stderr, " bn_add_part_words %d + %d (dl < 0, c = %d)\n", cl, dl, c);
228#endif
229 while (c)
230 {
231 l=(c+b[0])&BN_MASK2;
232 c=(l < c);
233 r[0]=l;
234 if (++dl >= 0) break;
235
236 l=(c+b[1])&BN_MASK2;
237 c=(l < c);
238 r[1]=l;
239 if (++dl >= 0) break;
240
241 l=(c+b[2])&BN_MASK2;
242 c=(l < c);
243 r[2]=l;
244 if (++dl >= 0) break;
245
246 l=(c+b[3])&BN_MASK2;
247 c=(l < c);
248 r[3]=l;
249 if (++dl >= 0) break;
250
251 save_dl = dl;
252 b+=4;
253 r+=4;
254 }
255 if (dl < 0)
256 {
257#ifdef BN_COUNT
258 fprintf(stderr, " bn_add_part_words %d + %d (dl < 0, c == 0)\n", cl, dl);
259#endif
260 if (save_dl < dl)
261 {
262 switch (dl - save_dl)
263 {
264 case 1:
265 r[1] = b[1];
266 if (++dl >= 0) break;
267 case 2:
268 r[2] = b[2];
269 if (++dl >= 0) break;
270 case 3:
271 r[3] = b[3];
272 if (++dl >= 0) break;
273 }
274 b += 4;
275 r += 4;
276 }
277 }
278 if (dl < 0)
279 {
280#ifdef BN_COUNT
281 fprintf(stderr, " bn_add_part_words %d + %d (dl < 0, copy)\n", cl, dl);
282#endif
283 for(;;)
284 {
285 r[0] = b[0];
286 if (++dl >= 0) break;
287 r[1] = b[1];
288 if (++dl >= 0) break;
289 r[2] = b[2];
290 if (++dl >= 0) break;
291 r[3] = b[3];
292 if (++dl >= 0) break;
293
294 b += 4;
295 r += 4;
296 }
297 }
298 }
299 else
300 {
301 int save_dl = dl;
302#ifdef BN_COUNT
303 fprintf(stderr, " bn_add_part_words %d + %d (dl > 0)\n", cl, dl);
304#endif
305 while (c)
306 {
307 t=(a[0]+c)&BN_MASK2;
308 c=(t < c);
309 r[0]=t;
310 if (--dl <= 0) break;
311
312 t=(a[1]+c)&BN_MASK2;
313 c=(t < c);
314 r[1]=t;
315 if (--dl <= 0) break;
316
317 t=(a[2]+c)&BN_MASK2;
318 c=(t < c);
319 r[2]=t;
320 if (--dl <= 0) break;
321
322 t=(a[3]+c)&BN_MASK2;
323 c=(t < c);
324 r[3]=t;
325 if (--dl <= 0) break;
326
327 save_dl = dl;
328 a+=4;
329 r+=4;
330 }
331#ifdef BN_COUNT
332 fprintf(stderr, " bn_add_part_words %d + %d (dl > 0, c == 0)\n", cl, dl);
333#endif
334 if (dl > 0)
335 {
336 if (save_dl > dl)
337 {
338 switch (save_dl - dl)
339 {
340 case 1:
341 r[1] = a[1];
342 if (--dl <= 0) break;
343 case 2:
344 r[2] = a[2];
345 if (--dl <= 0) break;
346 case 3:
347 r[3] = a[3];
348 if (--dl <= 0) break;
349 }
350 a += 4;
351 r += 4;
352 }
353 }
354 if (dl > 0)
355 {
356#ifdef BN_COUNT
357 fprintf(stderr, " bn_add_part_words %d + %d (dl > 0, copy)\n", cl, dl);
358#endif
359 for(;;)
360 {
361 r[0] = a[0];
362 if (--dl <= 0) break;
363 r[1] = a[1];
364 if (--dl <= 0) break;
365 r[2] = a[2];
366 if (--dl <= 0) break;
367 r[3] = a[3];
368 if (--dl <= 0) break;
369
370 a += 4;
371 r += 4;
372 }
373 }
374 }
375 return c;
376 }
377
63#ifdef BN_RECURSION 378#ifdef BN_RECURSION
64/* Karatsuba recursive multiplication algorithm 379/* Karatsuba recursive multiplication algorithm
65 * (cf. Knuth, The Art of Computer Programming, Vol. 2) */ 380 * (cf. Knuth, The Art of Computer Programming, Vol. 2) */
@@ -75,14 +390,15 @@
75 * a[1]*b[1] 390 * a[1]*b[1]
76 */ 391 */
77void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2, 392void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
78 BN_ULONG *t) 393 int dna, int dnb, BN_ULONG *t)
79 { 394 {
80 int n=n2/2,c1,c2; 395 int n=n2/2,c1,c2;
396 int tna=n+dna, tnb=n+dnb;
81 unsigned int neg,zero; 397 unsigned int neg,zero;
82 BN_ULONG ln,lo,*p; 398 BN_ULONG ln,lo,*p;
83 399
84# ifdef BN_COUNT 400# ifdef BN_COUNT
85 printf(" bn_mul_recursive %d * %d\n",n2,n2); 401 fprintf(stderr," bn_mul_recursive %d * %d\n",n2,n2);
86# endif 402# endif
87# ifdef BN_MUL_COMBA 403# ifdef BN_MUL_COMBA
88# if 0 404# if 0
@@ -92,34 +408,40 @@ void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
92 return; 408 return;
93 } 409 }
94# endif 410# endif
95 if (n2 == 8) 411 /* Only call bn_mul_comba 8 if n2 == 8 and the
412 * two arrays are complete [steve]
413 */
414 if (n2 == 8 && dna == 0 && dnb == 0)
96 { 415 {
97 bn_mul_comba8(r,a,b); 416 bn_mul_comba8(r,a,b);
98 return; 417 return;
99 } 418 }
100# endif /* BN_MUL_COMBA */ 419# endif /* BN_MUL_COMBA */
420 /* Else do normal multiply */
101 if (n2 < BN_MUL_RECURSIVE_SIZE_NORMAL) 421 if (n2 < BN_MUL_RECURSIVE_SIZE_NORMAL)
102 { 422 {
103 /* This should not happen */ 423 bn_mul_normal(r,a,n2+dna,b,n2+dnb);
104 bn_mul_normal(r,a,n2,b,n2); 424 if ((dna + dnb) < 0)
425 memset(&r[2*n2 + dna + dnb], 0,
426 sizeof(BN_ULONG) * -(dna + dnb));
105 return; 427 return;
106 } 428 }
107 /* r=(a[0]-a[1])*(b[1]-b[0]) */ 429 /* r=(a[0]-a[1])*(b[1]-b[0]) */
108 c1=bn_cmp_words(a,&(a[n]),n); 430 c1=bn_cmp_part_words(a,&(a[n]),tna,n-tna);
109 c2=bn_cmp_words(&(b[n]),b,n); 431 c2=bn_cmp_part_words(&(b[n]),b,tnb,tnb-n);
110 zero=neg=0; 432 zero=neg=0;
111 switch (c1*3+c2) 433 switch (c1*3+c2)
112 { 434 {
113 case -4: 435 case -4:
114 bn_sub_words(t, &(a[n]),a, n); /* - */ 436 bn_sub_part_words(t, &(a[n]),a, tna,tna-n); /* - */
115 bn_sub_words(&(t[n]),b, &(b[n]),n); /* - */ 437 bn_sub_part_words(&(t[n]),b, &(b[n]),tnb,n-tnb); /* - */
116 break; 438 break;
117 case -3: 439 case -3:
118 zero=1; 440 zero=1;
119 break; 441 break;
120 case -2: 442 case -2:
121 bn_sub_words(t, &(a[n]),a, n); /* - */ 443 bn_sub_part_words(t, &(a[n]),a, tna,tna-n); /* - */
122 bn_sub_words(&(t[n]),&(b[n]),b, n); /* + */ 444 bn_sub_part_words(&(t[n]),&(b[n]),b, tnb,tnb-n); /* + */
123 neg=1; 445 neg=1;
124 break; 446 break;
125 case -1: 447 case -1:
@@ -128,21 +450,22 @@ void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
128 zero=1; 450 zero=1;
129 break; 451 break;
130 case 2: 452 case 2:
131 bn_sub_words(t, a, &(a[n]),n); /* + */ 453 bn_sub_part_words(t, a, &(a[n]),tna,n-tna); /* + */
132 bn_sub_words(&(t[n]),b, &(b[n]),n); /* - */ 454 bn_sub_part_words(&(t[n]),b, &(b[n]),tnb,n-tnb); /* - */
133 neg=1; 455 neg=1;
134 break; 456 break;
135 case 3: 457 case 3:
136 zero=1; 458 zero=1;
137 break; 459 break;
138 case 4: 460 case 4:
139 bn_sub_words(t, a, &(a[n]),n); 461 bn_sub_part_words(t, a, &(a[n]),tna,n-tna);
140 bn_sub_words(&(t[n]),&(b[n]),b, n); 462 bn_sub_part_words(&(t[n]),&(b[n]),b, tnb,tnb-n);
141 break; 463 break;
142 } 464 }
143 465
144# ifdef BN_MUL_COMBA 466# ifdef BN_MUL_COMBA
145 if (n == 4) 467 if (n == 4 && dna == 0 && dnb == 0) /* XXX: bn_mul_comba4 could take
468 extra args to do this well */
146 { 469 {
147 if (!zero) 470 if (!zero)
148 bn_mul_comba4(&(t[n2]),t,&(t[n])); 471 bn_mul_comba4(&(t[n2]),t,&(t[n]));
@@ -152,7 +475,9 @@ void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
152 bn_mul_comba4(r,a,b); 475 bn_mul_comba4(r,a,b);
153 bn_mul_comba4(&(r[n2]),&(a[n]),&(b[n])); 476 bn_mul_comba4(&(r[n2]),&(a[n]),&(b[n]));
154 } 477 }
155 else if (n == 8) 478 else if (n == 8 && dna == 0 && dnb == 0) /* XXX: bn_mul_comba8 could
479 take extra args to do this
480 well */
156 { 481 {
157 if (!zero) 482 if (!zero)
158 bn_mul_comba8(&(t[n2]),t,&(t[n])); 483 bn_mul_comba8(&(t[n2]),t,&(t[n]));
@@ -167,11 +492,11 @@ void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
167 { 492 {
168 p= &(t[n2*2]); 493 p= &(t[n2*2]);
169 if (!zero) 494 if (!zero)
170 bn_mul_recursive(&(t[n2]),t,&(t[n]),n,p); 495 bn_mul_recursive(&(t[n2]),t,&(t[n]),n,0,0,p);
171 else 496 else
172 memset(&(t[n2]),0,n2*sizeof(BN_ULONG)); 497 memset(&(t[n2]),0,n2*sizeof(BN_ULONG));
173 bn_mul_recursive(r,a,b,n,p); 498 bn_mul_recursive(r,a,b,n,0,0,p);
174 bn_mul_recursive(&(r[n2]),&(a[n]),&(b[n]),n,p); 499 bn_mul_recursive(&(r[n2]),&(a[n]),&(b[n]),n,dna,dnb,p);
175 } 500 }
176 501
177 /* t[32] holds (a[0]-a[1])*(b[1]-b[0]), c1 is the sign 502 /* t[32] holds (a[0]-a[1])*(b[1]-b[0]), c1 is the sign
@@ -220,39 +545,39 @@ void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
220 545
221/* n+tn is the word length 546/* n+tn is the word length
222 * t needs to be n*4 is size, as does r */ 547 * t needs to be n*4 is size, as does r */
223void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int tn, 548void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n,
224 int n, BN_ULONG *t) 549 int tna, int tnb, BN_ULONG *t)
225 { 550 {
226 int i,j,n2=n*2; 551 int i,j,n2=n*2;
227 unsigned int c1,c2,neg,zero; 552 unsigned int c1,c2,neg,zero;
228 BN_ULONG ln,lo,*p; 553 BN_ULONG ln,lo,*p;
229 554
230# ifdef BN_COUNT 555# ifdef BN_COUNT
231 printf(" bn_mul_part_recursive %d * %d\n",tn+n,tn+n); 556 fprintf(stderr," bn_mul_part_recursive (%d+%d) * (%d+%d)\n",
557 tna, n, tnb, n);
232# endif 558# endif
233 if (n < 8) 559 if (n < 8)
234 { 560 {
235 i=tn+n; 561 bn_mul_normal(r,a,n+tna,b,n+tnb);
236 bn_mul_normal(r,a,i,b,i);
237 return; 562 return;
238 } 563 }
239 564
240 /* r=(a[0]-a[1])*(b[1]-b[0]) */ 565 /* r=(a[0]-a[1])*(b[1]-b[0]) */
241 c1=bn_cmp_words(a,&(a[n]),n); 566 c1=bn_cmp_part_words(a,&(a[n]),tna,n-tna);
242 c2=bn_cmp_words(&(b[n]),b,n); 567 c2=bn_cmp_part_words(&(b[n]),b,tnb,tnb-n);
243 zero=neg=0; 568 zero=neg=0;
244 switch (c1*3+c2) 569 switch (c1*3+c2)
245 { 570 {
246 case -4: 571 case -4:
247 bn_sub_words(t, &(a[n]),a, n); /* - */ 572 bn_sub_part_words(t, &(a[n]),a, tna,tna-n); /* - */
248 bn_sub_words(&(t[n]),b, &(b[n]),n); /* - */ 573 bn_sub_part_words(&(t[n]),b, &(b[n]),tnb,n-tnb); /* - */
249 break; 574 break;
250 case -3: 575 case -3:
251 zero=1; 576 zero=1;
252 /* break; */ 577 /* break; */
253 case -2: 578 case -2:
254 bn_sub_words(t, &(a[n]),a, n); /* - */ 579 bn_sub_part_words(t, &(a[n]),a, tna,tna-n); /* - */
255 bn_sub_words(&(t[n]),&(b[n]),b, n); /* + */ 580 bn_sub_part_words(&(t[n]),&(b[n]),b, tnb,tnb-n); /* + */
256 neg=1; 581 neg=1;
257 break; 582 break;
258 case -1: 583 case -1:
@@ -261,16 +586,16 @@ void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int tn,
261 zero=1; 586 zero=1;
262 /* break; */ 587 /* break; */
263 case 2: 588 case 2:
264 bn_sub_words(t, a, &(a[n]),n); /* + */ 589 bn_sub_part_words(t, a, &(a[n]),tna,n-tna); /* + */
265 bn_sub_words(&(t[n]),b, &(b[n]),n); /* - */ 590 bn_sub_part_words(&(t[n]),b, &(b[n]),tnb,n-tnb); /* - */
266 neg=1; 591 neg=1;
267 break; 592 break;
268 case 3: 593 case 3:
269 zero=1; 594 zero=1;
270 /* break; */ 595 /* break; */
271 case 4: 596 case 4:
272 bn_sub_words(t, a, &(a[n]),n); 597 bn_sub_part_words(t, a, &(a[n]),tna,n-tna);
273 bn_sub_words(&(t[n]),&(b[n]),b, n); 598 bn_sub_part_words(&(t[n]),&(b[n]),b, tnb,tnb-n);
274 break; 599 break;
275 } 600 }
276 /* The zero case isn't yet implemented here. The speedup 601 /* The zero case isn't yet implemented here. The speedup
@@ -289,54 +614,59 @@ void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int tn,
289 { 614 {
290 bn_mul_comba8(&(t[n2]),t,&(t[n])); 615 bn_mul_comba8(&(t[n2]),t,&(t[n]));
291 bn_mul_comba8(r,a,b); 616 bn_mul_comba8(r,a,b);
292 bn_mul_normal(&(r[n2]),&(a[n]),tn,&(b[n]),tn); 617 bn_mul_normal(&(r[n2]),&(a[n]),tna,&(b[n]),tnb);
293 memset(&(r[n2+tn*2]),0,sizeof(BN_ULONG)*(n2-tn*2)); 618 memset(&(r[n2+tna+tnb]),0,sizeof(BN_ULONG)*(n2-tna-tnb));
294 } 619 }
295 else 620 else
296 { 621 {
297 p= &(t[n2*2]); 622 p= &(t[n2*2]);
298 bn_mul_recursive(&(t[n2]),t,&(t[n]),n,p); 623 bn_mul_recursive(&(t[n2]),t,&(t[n]),n,0,0,p);
299 bn_mul_recursive(r,a,b,n,p); 624 bn_mul_recursive(r,a,b,n,0,0,p);
300 i=n/2; 625 i=n/2;
301 /* If there is only a bottom half to the number, 626 /* If there is only a bottom half to the number,
302 * just do it */ 627 * just do it */
303 j=tn-i; 628 if (tna > tnb)
629 j = tna - i;
630 else
631 j = tnb - i;
304 if (j == 0) 632 if (j == 0)
305 { 633 {
306 bn_mul_recursive(&(r[n2]),&(a[n]),&(b[n]),i,p); 634 bn_mul_recursive(&(r[n2]),&(a[n]),&(b[n]),
635 i,tna-i,tnb-i,p);
307 memset(&(r[n2+i*2]),0,sizeof(BN_ULONG)*(n2-i*2)); 636 memset(&(r[n2+i*2]),0,sizeof(BN_ULONG)*(n2-i*2));
308 } 637 }
309 else if (j > 0) /* eg, n == 16, i == 8 and tn == 11 */ 638 else if (j > 0) /* eg, n == 16, i == 8 and tn == 11 */
310 { 639 {
311 bn_mul_part_recursive(&(r[n2]),&(a[n]),&(b[n]), 640 bn_mul_part_recursive(&(r[n2]),&(a[n]),&(b[n]),
312 j,i,p); 641 i,tna-i,tnb-i,p);
313 memset(&(r[n2+tn*2]),0, 642 memset(&(r[n2+tna+tnb]),0,
314 sizeof(BN_ULONG)*(n2-tn*2)); 643 sizeof(BN_ULONG)*(n2-tna-tnb));
315 } 644 }
316 else /* (j < 0) eg, n == 16, i == 8 and tn == 5 */ 645 else /* (j < 0) eg, n == 16, i == 8 and tn == 5 */
317 { 646 {
318 memset(&(r[n2]),0,sizeof(BN_ULONG)*n2); 647 memset(&(r[n2]),0,sizeof(BN_ULONG)*n2);
319 if (tn < BN_MUL_RECURSIVE_SIZE_NORMAL) 648 if (tna < BN_MUL_RECURSIVE_SIZE_NORMAL
649 && tnb < BN_MUL_RECURSIVE_SIZE_NORMAL)
320 { 650 {
321 bn_mul_normal(&(r[n2]),&(a[n]),tn,&(b[n]),tn); 651 bn_mul_normal(&(r[n2]),&(a[n]),tna,&(b[n]),tnb);
322 } 652 }
323 else 653 else
324 { 654 {
325 for (;;) 655 for (;;)
326 { 656 {
327 i/=2; 657 i/=2;
328 if (i < tn) 658 if (i < tna && i < tnb)
329 { 659 {
330 bn_mul_part_recursive(&(r[n2]), 660 bn_mul_part_recursive(&(r[n2]),
331 &(a[n]),&(b[n]), 661 &(a[n]),&(b[n]),
332 tn-i,i,p); 662 i,tna-i,tnb-i,p);
333 break; 663 break;
334 } 664 }
335 else if (i == tn) 665 else if (i <= tna && i <= tnb)
336 { 666 {
337 bn_mul_recursive(&(r[n2]), 667 bn_mul_recursive(&(r[n2]),
338 &(a[n]),&(b[n]), 668 &(a[n]),&(b[n]),
339 i,p); 669 i,tna-i,tnb-i,p);
340 break; 670 break;
341 } 671 }
342 } 672 }
@@ -397,10 +727,10 @@ void bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
397 int n=n2/2; 727 int n=n2/2;
398 728
399# ifdef BN_COUNT 729# ifdef BN_COUNT
400 printf(" bn_mul_low_recursive %d * %d\n",n2,n2); 730 fprintf(stderr," bn_mul_low_recursive %d * %d\n",n2,n2);
401# endif 731# endif
402 732
403 bn_mul_recursive(r,a,b,n,&(t[0])); 733 bn_mul_recursive(r,a,b,n,0,0,&(t[0]));
404 if (n >= BN_MUL_LOW_RECURSIVE_SIZE_NORMAL) 734 if (n >= BN_MUL_LOW_RECURSIVE_SIZE_NORMAL)
405 { 735 {
406 bn_mul_low_recursive(&(t[0]),&(a[0]),&(b[n]),n,&(t[n2])); 736 bn_mul_low_recursive(&(t[0]),&(a[0]),&(b[n]),n,&(t[n2]));
@@ -431,7 +761,7 @@ void bn_mul_high(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, BN_ULONG *l, int n2,
431 BN_ULONG ll,lc,*lp,*mp; 761 BN_ULONG ll,lc,*lp,*mp;
432 762
433# ifdef BN_COUNT 763# ifdef BN_COUNT
434 printf(" bn_mul_high %d * %d\n",n2,n2); 764 fprintf(stderr," bn_mul_high %d * %d\n",n2,n2);
435# endif 765# endif
436 n=n2/2; 766 n=n2/2;
437 767
@@ -484,8 +814,8 @@ void bn_mul_high(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, BN_ULONG *l, int n2,
484 else 814 else
485# endif 815# endif
486 { 816 {
487 bn_mul_recursive(&(t[0]),&(r[0]),&(r[n]),n,&(t[n2])); 817 bn_mul_recursive(&(t[0]),&(r[0]),&(r[n]),n,0,0,&(t[n2]));
488 bn_mul_recursive(r,&(a[n]),&(b[n]),n,&(t[n2])); 818 bn_mul_recursive(r,&(a[n]),&(b[n]),n,0,0,&(t[n2]));
489 } 819 }
490 820
491 /* s0 == low(al*bl) 821 /* s0 == low(al*bl)
@@ -610,19 +940,19 @@ void bn_mul_high(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, BN_ULONG *l, int n2,
610 940
611int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) 941int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
612 { 942 {
943 int ret=0;
613 int top,al,bl; 944 int top,al,bl;
614 BIGNUM *rr; 945 BIGNUM *rr;
615 int ret = 0;
616#if defined(BN_MUL_COMBA) || defined(BN_RECURSION) 946#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)
617 int i; 947 int i;
618#endif 948#endif
619#ifdef BN_RECURSION 949#ifdef BN_RECURSION
620 BIGNUM *t; 950 BIGNUM *t=NULL;
621 int j,k; 951 int j=0,k;
622#endif 952#endif
623 953
624#ifdef BN_COUNT 954#ifdef BN_COUNT
625 printf("BN_mul %d * %d\n",a->top,b->top); 955 fprintf(stderr,"BN_mul %d * %d\n",a->top,b->top);
626#endif 956#endif
627 957
628 bn_check_top(a); 958 bn_check_top(a);
@@ -675,21 +1005,55 @@ int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
675#ifdef BN_RECURSION 1005#ifdef BN_RECURSION
676 if ((al >= BN_MULL_SIZE_NORMAL) && (bl >= BN_MULL_SIZE_NORMAL)) 1006 if ((al >= BN_MULL_SIZE_NORMAL) && (bl >= BN_MULL_SIZE_NORMAL))
677 { 1007 {
678 if (i == 1 && !BN_get_flags(b,BN_FLG_STATIC_DATA) && bl<b->dmax) 1008 if (i >= -1 && i <= 1)
679 { 1009 {
680#if 0 /* tribute to const-ification, bl<b->dmax above covers for this */ 1010 int sav_j =0;
681 if (bn_wexpand(b,al) == NULL) goto err; 1011 /* Find out the power of two lower or equal
682#endif 1012 to the longest of the two numbers */
683 b->d[bl]=0; 1013 if (i >= 0)
1014 {
1015 j = BN_num_bits_word((BN_ULONG)al);
1016 }
1017 if (i == -1)
1018 {
1019 j = BN_num_bits_word((BN_ULONG)bl);
1020 }
1021 sav_j = j;
1022 j = 1<<(j-1);
1023 assert(j <= al || j <= bl);
1024 k = j+j;
1025 t = BN_CTX_get(ctx);
1026 if (al > j || bl > j)
1027 {
1028 bn_wexpand(t,k*4);
1029 bn_wexpand(rr,k*4);
1030 bn_mul_part_recursive(rr->d,a->d,b->d,
1031 j,al-j,bl-j,t->d);
1032 }
1033 else /* al <= j || bl <= j */
1034 {
1035 bn_wexpand(t,k*2);
1036 bn_wexpand(rr,k*2);
1037 bn_mul_recursive(rr->d,a->d,b->d,
1038 j,al-j,bl-j,t->d);
1039 }
1040 rr->top=top;
1041 goto end;
1042 }
1043#if 0
1044 if (i == 1 && !BN_get_flags(b,BN_FLG_STATIC_DATA))
1045 {
1046 BIGNUM *tmp_bn = (BIGNUM *)b;
1047 if (bn_wexpand(tmp_bn,al) == NULL) goto err;
1048 tmp_bn->d[bl]=0;
684 bl++; 1049 bl++;
685 i--; 1050 i--;
686 } 1051 }
687 else if (i == -1 && !BN_get_flags(a,BN_FLG_STATIC_DATA) && al<a->dmax) 1052 else if (i == -1 && !BN_get_flags(a,BN_FLG_STATIC_DATA))
688 { 1053 {
689#if 0 /* tribute to const-ification, al<a->dmax above covers for this */ 1054 BIGNUM *tmp_bn = (BIGNUM *)a;
690 if (bn_wexpand(a,bl) == NULL) goto err; 1055 if (bn_wexpand(tmp_bn,bl) == NULL) goto err;
691#endif 1056 tmp_bn->d[al]=0;
692 a->d[al]=0;
693 al++; 1057 al++;
694 i++; 1058 i++;
695 } 1059 }
@@ -706,26 +1070,17 @@ int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
706 if (bn_wexpand(t,k*2) == NULL) goto err; 1070 if (bn_wexpand(t,k*2) == NULL) goto err;
707 if (bn_wexpand(rr,k*2) == NULL) goto err; 1071 if (bn_wexpand(rr,k*2) == NULL) goto err;
708 bn_mul_recursive(rr->d,a->d,b->d,al,t->d); 1072 bn_mul_recursive(rr->d,a->d,b->d,al,t->d);
709 rr->top=top;
710 goto end;
711 } 1073 }
712#if 0 /* tribute to const-ification, rsa/dsa performance is not affected */
713 else 1074 else
714 { 1075 {
715 if (bn_wexpand(a,k) == NULL ) goto err; 1076 if (bn_wexpand(t,k*4) == NULL) goto err;
716 if (bn_wexpand(b,k) == NULL ) goto err; 1077 if (bn_wexpand(rr,k*4) == NULL) goto err;
717 if (bn_wexpand(t,k*4) == NULL ) goto err;
718 if (bn_wexpand(rr,k*4) == NULL ) goto err;
719 for (i=a->top; i<k; i++)
720 a->d[i]=0;
721 for (i=b->top; i<k; i++)
722 b->d[i]=0;
723 bn_mul_part_recursive(rr->d,a->d,b->d,al-j,j,t->d); 1078 bn_mul_part_recursive(rr->d,a->d,b->d,al-j,j,t->d);
724 } 1079 }
725 rr->top=top; 1080 rr->top=top;
726 goto end; 1081 goto end;
727#endif
728 } 1082 }
1083#endif
729 } 1084 }
730#endif /* BN_RECURSION */ 1085#endif /* BN_RECURSION */
731 if (bn_wexpand(rr,top) == NULL) goto err; 1086 if (bn_wexpand(rr,top) == NULL) goto err;
@@ -748,7 +1103,7 @@ void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb)
748 BN_ULONG *rr; 1103 BN_ULONG *rr;
749 1104
750#ifdef BN_COUNT 1105#ifdef BN_COUNT
751 printf(" bn_mul_normal %d * %d\n",na,nb); 1106 fprintf(stderr," bn_mul_normal %d * %d\n",na,nb);
752#endif 1107#endif
753 1108
754 if (na < nb) 1109 if (na < nb)
@@ -761,7 +1116,13 @@ void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb)
761 1116
762 } 1117 }
763 rr= &(r[na]); 1118 rr= &(r[na]);
764 rr[0]=bn_mul_words(r,a,na,b[0]); 1119 if (nb <= 0)
1120 {
1121 (void)bn_mul_words(r,a,na,0);
1122 return;
1123 }
1124 else
1125 rr[0]=bn_mul_words(r,a,na,b[0]);
765 1126
766 for (;;) 1127 for (;;)
767 { 1128 {
@@ -782,7 +1143,7 @@ void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb)
782void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n) 1143void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
783 { 1144 {
784#ifdef BN_COUNT 1145#ifdef BN_COUNT
785 printf(" bn_mul_low_normal %d * %d\n",n,n); 1146 fprintf(stderr," bn_mul_low_normal %d * %d\n",n,n);
786#endif 1147#endif
787 bn_mul_words(r,a,n,b[0]); 1148 bn_mul_words(r,a,n,b[0]);
788 1149
diff --git a/src/lib/libcrypto/bn/bn_prime.c b/src/lib/libcrypto/bn/bn_prime.c
index e072d9255c..918b9237c6 100644
--- a/src/lib/libcrypto/bn/bn_prime.c
+++ b/src/lib/libcrypto/bn/bn_prime.c
@@ -140,7 +140,6 @@ BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe,
140 BN_CTX *ctx; 140 BN_CTX *ctx;
141 int checks = BN_prime_checks_for_size(bits); 141 int checks = BN_prime_checks_for_size(bits);
142 142
143 BN_init(&t);
144 ctx=BN_CTX_new(); 143 ctx=BN_CTX_new();
145 if (ctx == NULL) goto err; 144 if (ctx == NULL) goto err;
146 if (ret == NULL) 145 if (ret == NULL)
@@ -149,6 +148,7 @@ BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe,
149 } 148 }
150 else 149 else
151 rnd=ret; 150 rnd=ret;
151 BN_init(&t);
152loop: 152loop:
153 /* make a random number and set the top and bottom bits */ 153 /* make a random number and set the top and bottom bits */
154 if (add == NULL) 154 if (add == NULL)
diff --git a/src/lib/libcrypto/bn/bn_print.c b/src/lib/libcrypto/bn/bn_print.c
index 5f46b1826c..e3b6aa235b 100644
--- a/src/lib/libcrypto/bn/bn_print.c
+++ b/src/lib/libcrypto/bn/bn_print.c
@@ -119,6 +119,7 @@ char *BN_bn2dec(const BIGNUM *a)
119 } 119 }
120 if ((t=BN_dup(a)) == NULL) goto err; 120 if ((t=BN_dup(a)) == NULL) goto err;
121 121
122#define BUF_REMAIN (num+3 - (size_t)(p - buf))
122 p=buf; 123 p=buf;
123 lp=bn_data; 124 lp=bn_data;
124 if (t->neg) *(p++)='-'; 125 if (t->neg) *(p++)='-';
@@ -139,12 +140,12 @@ char *BN_bn2dec(const BIGNUM *a)
139 /* We now have a series of blocks, BN_DEC_NUM chars 140 /* We now have a series of blocks, BN_DEC_NUM chars
140 * in length, where the last one needs truncation. 141 * in length, where the last one needs truncation.
141 * The blocks need to be reversed in order. */ 142 * The blocks need to be reversed in order. */
142 sprintf(p,BN_DEC_FMT1,*lp); 143 snprintf(p,BUF_REMAIN,BN_DEC_FMT1,*lp);
143 while (*p) p++; 144 while (*p) p++;
144 while (lp != bn_data) 145 while (lp != bn_data)
145 { 146 {
146 lp--; 147 lp--;
147 sprintf(p,BN_DEC_FMT2,*lp); 148 snprintf(p,BUF_REMAIN,BN_DEC_FMT2,*lp);
148 while (*p) p++; 149 while (*p) p++;
149 } 150 }
150 } 151 }
diff --git a/src/lib/libcrypto/bn/bn_rand.c b/src/lib/libcrypto/bn/bn_rand.c
index 893c9d2af9..9e08ccd22e 100644
--- a/src/lib/libcrypto/bn/bn_rand.c
+++ b/src/lib/libcrypto/bn/bn_rand.c
@@ -201,7 +201,7 @@ static int bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom)
201err: 201err:
202 if (buf != NULL) 202 if (buf != NULL)
203 { 203 {
204 OPENSSL_cleanse(buf,bytes); 204 memset(buf,0,bytes);
205 OPENSSL_free(buf); 205 OPENSSL_free(buf);
206 } 206 }
207 return(ret); 207 return(ret);
diff --git a/src/lib/libcrypto/bn/bn_word.c b/src/lib/libcrypto/bn/bn_word.c
index 988e0ca7b3..cd59baa2c4 100644
--- a/src/lib/libcrypto/bn/bn_word.c
+++ b/src/lib/libcrypto/bn/bn_word.c
@@ -123,10 +123,7 @@ int BN_add_word(BIGNUM *a, BN_ULONG w)
123 i=0; 123 i=0;
124 for (;;) 124 for (;;)
125 { 125 {
126 if (i >= a->top) 126 l=(a->d[i]+(BN_ULONG)w)&BN_MASK2;
127 l=w;
128 else
129 l=(a->d[i]+(BN_ULONG)w)&BN_MASK2;
130 a->d[i]=l; 127 a->d[i]=l;
131 if (w > l) 128 if (w > l)
132 w=1; 129 w=1;
diff --git a/src/lib/libcrypto/bn/bnspeed.c b/src/lib/libcrypto/bn/bnspeed.c
new file mode 100644
index 0000000000..b554ac8cf8
--- /dev/null
+++ b/src/lib/libcrypto/bn/bnspeed.c
@@ -0,0 +1,233 @@
1/* unused */
2
3/* crypto/bn/bnspeed.c */
4/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
5 * All rights reserved.
6 *
7 * This package is an SSL implementation written
8 * by Eric Young (eay@cryptsoft.com).
9 * The implementation was written so as to conform with Netscapes SSL.
10 *
11 * This library is free for commercial and non-commercial use as long as
12 * the following conditions are aheared to. The following conditions
13 * apply to all code found in this distribution, be it the RC4, RSA,
14 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
15 * included with this distribution is covered by the same copyright terms
16 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
17 *
18 * Copyright remains Eric Young's, and as such any Copyright notices in
19 * the code are not to be removed.
20 * If this package is used in a product, Eric Young should be given attribution
21 * as the author of the parts of the library used.
22 * This can be in the form of a textual message at program startup or
23 * in documentation (online or textual) provided with the package.
24 *
25 * Redistribution and use in source and binary forms, with or without
26 * modification, are permitted provided that the following conditions
27 * are met:
28 * 1. Redistributions of source code must retain the copyright
29 * notice, this list of conditions and the following disclaimer.
30 * 2. Redistributions in binary form must reproduce the above copyright
31 * notice, this list of conditions and the following disclaimer in the
32 * documentation and/or other materials provided with the distribution.
33 * 3. All advertising materials mentioning features or use of this software
34 * must display the following acknowledgement:
35 * "This product includes cryptographic software written by
36 * Eric Young (eay@cryptsoft.com)"
37 * The word 'cryptographic' can be left out if the rouines from the library
38 * being used are not cryptographic related :-).
39 * 4. If you include any Windows specific code (or a derivative thereof) from
40 * the apps directory (application code) you must include an acknowledgement:
41 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
42 *
43 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
44 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
47 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53 * SUCH DAMAGE.
54 *
55 * The licence and distribution terms for any publically available version or
56 * derivative of this code cannot be changed. i.e. this code cannot simply be
57 * copied and put under another distribution licence
58 * [including the GNU Public Licence.]
59 */
60
61/* most of this code has been pilfered from my libdes speed.c program */
62
63#define BASENUM 1000000
64#undef PROG
65#define PROG bnspeed_main
66
67#include <stdio.h>
68#include <stdlib.h>
69#include <signal.h>
70#include <string.h>
71#include <openssl/crypto.h>
72#include <openssl/err.h>
73
74#if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX)
75#define TIMES
76#endif
77
78#ifndef _IRIX
79#include <time.h>
80#endif
81#ifdef TIMES
82#include <sys/types.h>
83#include <sys/times.h>
84#endif
85
86/* Depending on the VMS version, the tms structure is perhaps defined.
87 The __TMS macro will show if it was. If it wasn't defined, we should
88 undefine TIMES, since that tells the rest of the program how things
89 should be handled. -- Richard Levitte */
90#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
91#undef TIMES
92#endif
93
94#ifndef TIMES
95#include <sys/timeb.h>
96#endif
97
98#if defined(sun) || defined(__ultrix)
99#define _POSIX_SOURCE
100#include <limits.h>
101#include <sys/param.h>
102#endif
103
104#include <openssl/bn.h>
105#include <openssl/x509.h>
106
107/* The following if from times(3) man page. It may need to be changed */
108#ifndef HZ
109# ifndef CLK_TCK
110# ifndef _BSD_CLK_TCK_ /* FreeBSD hack */
111# define HZ 100.0
112# else /* _BSD_CLK_TCK_ */
113# define HZ ((double)_BSD_CLK_TCK_)
114# endif
115# else /* CLK_TCK */
116# define HZ ((double)CLK_TCK)
117# endif
118#endif
119
120#undef BUFSIZE
121#define BUFSIZE ((long)1024*8)
122int run=0;
123
124static double Time_F(int s);
125#define START 0
126#define STOP 1
127
128static double Time_F(int s)
129 {
130 double ret;
131#ifdef TIMES
132 static struct tms tstart,tend;
133
134 if (s == START)
135 {
136 times(&tstart);
137 return(0);
138 }
139 else
140 {
141 times(&tend);
142 ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
143 return((ret < 1e-3)?1e-3:ret);
144 }
145#else /* !times() */
146 static struct timeb tstart,tend;
147 long i;
148
149 if (s == START)
150 {
151 ftime(&tstart);
152 return(0);
153 }
154 else
155 {
156 ftime(&tend);
157 i=(long)tend.millitm-(long)tstart.millitm;
158 ret=((double)(tend.time-tstart.time))+((double)i)/1000.0;
159 return((ret < 0.001)?0.001:ret);
160 }
161#endif
162 }
163
164#define NUM_SIZES 5
165static int sizes[NUM_SIZES]={128,256,512,1024,2048};
166/*static int sizes[NUM_SIZES]={59,179,299,419,539}; */
167
168void do_mul(BIGNUM *r,BIGNUM *a,BIGNUM *b,BN_CTX *ctx);
169
170int main(int argc, char **argv)
171 {
172 BN_CTX *ctx;
173 BIGNUM a,b,c;
174
175 ctx=BN_CTX_new();
176 BN_init(&a);
177 BN_init(&b);
178 BN_init(&c);
179
180 do_mul(&a,&b,&c,ctx);
181 }
182
183void do_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx)
184 {
185 int i,j,k;
186 double tm;
187 long num;
188
189 for (i=0; i<NUM_SIZES; i++)
190 {
191 num=BASENUM;
192 if (i) num/=(i*3);
193 BN_rand(a,sizes[i],1,0);
194 for (j=i; j<NUM_SIZES; j++)
195 {
196 BN_rand(b,sizes[j],1,0);
197 Time_F(START);
198 for (k=0; k<num; k++)
199 BN_mul(r,b,a,ctx);
200 tm=Time_F(STOP);
201 printf("mul %4d x %4d -> %8.3fms\n",sizes[i],sizes[j],tm*1000.0/num);
202 }
203 }
204
205 for (i=0; i<NUM_SIZES; i++)
206 {
207 num=BASENUM;
208 if (i) num/=(i*3);
209 BN_rand(a,sizes[i],1,0);
210 Time_F(START);
211 for (k=0; k<num; k++)
212 BN_sqr(r,a,ctx);
213 tm=Time_F(STOP);
214 printf("sqr %4d x %4d -> %8.3fms\n",sizes[i],sizes[i],tm*1000.0/num);
215 }
216
217 for (i=0; i<NUM_SIZES; i++)
218 {
219 num=BASENUM/10;
220 if (i) num/=(i*3);
221 BN_rand(a,sizes[i]-1,1,0);
222 for (j=i; j<NUM_SIZES; j++)
223 {
224 BN_rand(b,sizes[j],1,0);
225 Time_F(START);
226 for (k=0; k<100000; k++)
227 BN_div(r, NULL, b, a,ctx);
228 tm=Time_F(STOP);
229 printf("div %4d / %4d -> %8.3fms\n",sizes[j],sizes[i]-1,tm*1000.0/num);
230 }
231 }
232 }
233
diff --git a/src/lib/libcrypto/bn/bntest.c b/src/lib/libcrypto/bn/bntest.c
new file mode 100644
index 0000000000..8158a67374
--- /dev/null
+++ b/src/lib/libcrypto/bn/bntest.c
@@ -0,0 +1,1243 @@
1/* crypto/bn/bntest.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <stdlib.h>
61#include <string.h>
62
63#include "e_os.h"
64
65#include <openssl/bio.h>
66#include <openssl/bn.h>
67#include <openssl/rand.h>
68#include <openssl/x509.h>
69#include <openssl/err.h>
70
71#ifdef OPENSSL_SYS_WINDOWS
72#include "../bio/bss_file.c"
73#endif
74
75const int num0 = 100; /* number of tests */
76const int num1 = 50; /* additional tests for some functions */
77const int num2 = 5; /* number of tests for slow functions */
78
79int test_add(BIO *bp);
80int test_sub(BIO *bp);
81int test_lshift1(BIO *bp);
82int test_lshift(BIO *bp,BN_CTX *ctx,BIGNUM *a_);
83int test_rshift1(BIO *bp);
84int test_rshift(BIO *bp,BN_CTX *ctx);
85int test_div(BIO *bp,BN_CTX *ctx);
86int test_div_recp(BIO *bp,BN_CTX *ctx);
87int test_mul(BIO *bp);
88int test_sqr(BIO *bp,BN_CTX *ctx);
89int test_mont(BIO *bp,BN_CTX *ctx);
90int test_mod(BIO *bp,BN_CTX *ctx);
91int test_mod_mul(BIO *bp,BN_CTX *ctx);
92int test_mod_exp(BIO *bp,BN_CTX *ctx);
93int test_exp(BIO *bp,BN_CTX *ctx);
94int test_kron(BIO *bp,BN_CTX *ctx);
95int test_sqrt(BIO *bp,BN_CTX *ctx);
96int rand_neg(void);
97static int results=0;
98
99#ifdef OPENSSL_NO_STDIO
100#define APPS_WIN16
101#include "bss_file.c"
102#endif
103
104static unsigned char lst[]="\xC6\x4F\x43\x04\x2A\xEA\xCA\x6E\x58\x36\x80\x5B\xE8\xC9"
105"\x9B\x04\x5D\x48\x36\xC2\xFD\x16\xC9\x64\xF0";
106
107static const char rnd_seed[] = "string to make the random number generator think it has entropy";
108
109static void message(BIO *out, char *m)
110 {
111 fprintf(stderr, "test %s\n", m);
112 BIO_puts(out, "print \"test ");
113 BIO_puts(out, m);
114 BIO_puts(out, "\\n\"\n");
115 }
116
117int main(int argc, char *argv[])
118 {
119 BN_CTX *ctx;
120 BIO *out;
121 char *outfile=NULL;
122
123 results = 0;
124
125 RAND_seed(rnd_seed, sizeof rnd_seed); /* or BN_generate_prime may fail */
126
127 argc--;
128 argv++;
129 while (argc >= 1)
130 {
131 if (strcmp(*argv,"-results") == 0)
132 results=1;
133 else if (strcmp(*argv,"-out") == 0)
134 {
135 if (--argc < 1) break;
136 outfile= *(++argv);
137 }
138 argc--;
139 argv++;
140 }
141
142
143 ctx=BN_CTX_new();
144 if (ctx == NULL) exit(1);
145
146 out=BIO_new(BIO_s_file());
147 if (out == NULL) exit(1);
148 if (outfile == NULL)
149 {
150 BIO_set_fp(out,stdout,BIO_NOCLOSE);
151 }
152 else
153 {
154 if (!BIO_write_filename(out,outfile))
155 {
156 perror(outfile);
157 exit(1);
158 }
159 }
160
161 if (!results)
162 BIO_puts(out,"obase=16\nibase=16\n");
163
164 message(out,"BN_add");
165 if (!test_add(out)) goto err;
166 BIO_flush(out);
167
168 message(out,"BN_sub");
169 if (!test_sub(out)) goto err;
170 BIO_flush(out);
171
172 message(out,"BN_lshift1");
173 if (!test_lshift1(out)) goto err;
174 BIO_flush(out);
175
176 message(out,"BN_lshift (fixed)");
177 if (!test_lshift(out,ctx,BN_bin2bn(lst,sizeof(lst)-1,NULL)))
178 goto err;
179 BIO_flush(out);
180
181 message(out,"BN_lshift");
182 if (!test_lshift(out,ctx,NULL)) goto err;
183 BIO_flush(out);
184
185 message(out,"BN_rshift1");
186 if (!test_rshift1(out)) goto err;
187 BIO_flush(out);
188
189 message(out,"BN_rshift");
190 if (!test_rshift(out,ctx)) goto err;
191 BIO_flush(out);
192
193 message(out,"BN_sqr");
194 if (!test_sqr(out,ctx)) goto err;
195 BIO_flush(out);
196
197 message(out,"BN_mul");
198 if (!test_mul(out)) goto err;
199 BIO_flush(out);
200
201 message(out,"BN_div");
202 if (!test_div(out,ctx)) goto err;
203 BIO_flush(out);
204
205 message(out,"BN_div_recp");
206 if (!test_div_recp(out,ctx)) goto err;
207 BIO_flush(out);
208
209 message(out,"BN_mod");
210 if (!test_mod(out,ctx)) goto err;
211 BIO_flush(out);
212
213 message(out,"BN_mod_mul");
214 if (!test_mod_mul(out,ctx)) goto err;
215 BIO_flush(out);
216
217 message(out,"BN_mont");
218 if (!test_mont(out,ctx)) goto err;
219 BIO_flush(out);
220
221 message(out,"BN_mod_exp");
222 if (!test_mod_exp(out,ctx)) goto err;
223 BIO_flush(out);
224
225 message(out,"BN_exp");
226 if (!test_exp(out,ctx)) goto err;
227 BIO_flush(out);
228
229 message(out,"BN_kronecker");
230 if (!test_kron(out,ctx)) goto err;
231 BIO_flush(out);
232
233 message(out,"BN_mod_sqrt");
234 if (!test_sqrt(out,ctx)) goto err;
235 BIO_flush(out);
236
237 BN_CTX_free(ctx);
238 BIO_free(out);
239
240/**/
241 exit(0);
242err:
243 BIO_puts(out,"1\n"); /* make sure the Perl script fed by bc notices
244 * the failure, see test_bn in test/Makefile.ssl*/
245 BIO_flush(out);
246 ERR_load_crypto_strings();
247 ERR_print_errors_fp(stderr);
248 exit(1);
249 return(1);
250 }
251
252int test_add(BIO *bp)
253 {
254 BIGNUM a,b,c;
255 int i;
256
257 BN_init(&a);
258 BN_init(&b);
259 BN_init(&c);
260
261 BN_bntest_rand(&a,512,0,0);
262 for (i=0; i<num0; i++)
263 {
264 BN_bntest_rand(&b,450+i,0,0);
265 a.neg=rand_neg();
266 b.neg=rand_neg();
267 BN_add(&c,&a,&b);
268 if (bp != NULL)
269 {
270 if (!results)
271 {
272 BN_print(bp,&a);
273 BIO_puts(bp," + ");
274 BN_print(bp,&b);
275 BIO_puts(bp," - ");
276 }
277 BN_print(bp,&c);
278 BIO_puts(bp,"\n");
279 }
280 a.neg=!a.neg;
281 b.neg=!b.neg;
282 BN_add(&c,&c,&b);
283 BN_add(&c,&c,&a);
284 if(!BN_is_zero(&c))
285 {
286 fprintf(stderr,"Add test failed!\n");
287 return 0;
288 }
289 }
290 BN_free(&a);
291 BN_free(&b);
292 BN_free(&c);
293 return(1);
294 }
295
296int test_sub(BIO *bp)
297 {
298 BIGNUM a,b,c;
299 int i;
300
301 BN_init(&a);
302 BN_init(&b);
303 BN_init(&c);
304
305 for (i=0; i<num0+num1; i++)
306 {
307 if (i < num1)
308 {
309 BN_bntest_rand(&a,512,0,0);
310 BN_copy(&b,&a);
311 if (BN_set_bit(&a,i)==0) return(0);
312 BN_add_word(&b,i);
313 }
314 else
315 {
316 BN_bntest_rand(&b,400+i-num1,0,0);
317 a.neg=rand_neg();
318 b.neg=rand_neg();
319 }
320 BN_sub(&c,&a,&b);
321 if (bp != NULL)
322 {
323 if (!results)
324 {
325 BN_print(bp,&a);
326 BIO_puts(bp," - ");
327 BN_print(bp,&b);
328 BIO_puts(bp," - ");
329 }
330 BN_print(bp,&c);
331 BIO_puts(bp,"\n");
332 }
333 BN_add(&c,&c,&b);
334 BN_sub(&c,&c,&a);
335 if(!BN_is_zero(&c))
336 {
337 fprintf(stderr,"Subtract test failed!\n");
338 return 0;
339 }
340 }
341 BN_free(&a);
342 BN_free(&b);
343 BN_free(&c);
344 return(1);
345 }
346
347int test_div(BIO *bp, BN_CTX *ctx)
348 {
349 BIGNUM a,b,c,d,e;
350 int i;
351
352 BN_init(&a);
353 BN_init(&b);
354 BN_init(&c);
355 BN_init(&d);
356 BN_init(&e);
357
358 for (i=0; i<num0+num1; i++)
359 {
360 if (i < num1)
361 {
362 BN_bntest_rand(&a,400,0,0);
363 BN_copy(&b,&a);
364 BN_lshift(&a,&a,i);
365 BN_add_word(&a,i);
366 }
367 else
368 BN_bntest_rand(&b,50+3*(i-num1),0,0);
369 a.neg=rand_neg();
370 b.neg=rand_neg();
371 BN_div(&d,&c,&a,&b,ctx);
372 if (bp != NULL)
373 {
374 if (!results)
375 {
376 BN_print(bp,&a);
377 BIO_puts(bp," / ");
378 BN_print(bp,&b);
379 BIO_puts(bp," - ");
380 }
381 BN_print(bp,&d);
382 BIO_puts(bp,"\n");
383
384 if (!results)
385 {
386 BN_print(bp,&a);
387 BIO_puts(bp," % ");
388 BN_print(bp,&b);
389 BIO_puts(bp," - ");
390 }
391 BN_print(bp,&c);
392 BIO_puts(bp,"\n");
393 }
394 BN_mul(&e,&d,&b,ctx);
395 BN_add(&d,&e,&c);
396 BN_sub(&d,&d,&a);
397 if(!BN_is_zero(&d))
398 {
399 fprintf(stderr,"Division test failed!\n");
400 return 0;
401 }
402 }
403 BN_free(&a);
404 BN_free(&b);
405 BN_free(&c);
406 BN_free(&d);
407 BN_free(&e);
408 return(1);
409 }
410
411int test_div_recp(BIO *bp, BN_CTX *ctx)
412 {
413 BIGNUM a,b,c,d,e;
414 BN_RECP_CTX recp;
415 int i;
416
417 BN_RECP_CTX_init(&recp);
418 BN_init(&a);
419 BN_init(&b);
420 BN_init(&c);
421 BN_init(&d);
422 BN_init(&e);
423
424 for (i=0; i<num0+num1; i++)
425 {
426 if (i < num1)
427 {
428 BN_bntest_rand(&a,400,0,0);
429 BN_copy(&b,&a);
430 BN_lshift(&a,&a,i);
431 BN_add_word(&a,i);
432 }
433 else
434 BN_bntest_rand(&b,50+3*(i-num1),0,0);
435 a.neg=rand_neg();
436 b.neg=rand_neg();
437 BN_RECP_CTX_set(&recp,&b,ctx);
438 BN_div_recp(&d,&c,&a,&recp,ctx);
439 if (bp != NULL)
440 {
441 if (!results)
442 {
443 BN_print(bp,&a);
444 BIO_puts(bp," / ");
445 BN_print(bp,&b);
446 BIO_puts(bp," - ");
447 }
448 BN_print(bp,&d);
449 BIO_puts(bp,"\n");
450
451 if (!results)
452 {
453 BN_print(bp,&a);
454 BIO_puts(bp," % ");
455 BN_print(bp,&b);
456 BIO_puts(bp," - ");
457 }
458 BN_print(bp,&c);
459 BIO_puts(bp,"\n");
460 }
461 BN_mul(&e,&d,&b,ctx);
462 BN_add(&d,&e,&c);
463 BN_sub(&d,&d,&a);
464 if(!BN_is_zero(&d))
465 {
466 fprintf(stderr,"Reciprocal division test failed!\n");
467 fprintf(stderr,"a=");
468 BN_print_fp(stderr,&a);
469 fprintf(stderr,"\nb=");
470 BN_print_fp(stderr,&b);
471 fprintf(stderr,"\n");
472 return 0;
473 }
474 }
475 BN_free(&a);
476 BN_free(&b);
477 BN_free(&c);
478 BN_free(&d);
479 BN_free(&e);
480 BN_RECP_CTX_free(&recp);
481 return(1);
482 }
483
484int test_mul(BIO *bp)
485 {
486 BIGNUM a,b,c,d,e;
487 int i;
488 BN_CTX *ctx;
489
490 ctx = BN_CTX_new();
491 if (ctx == NULL) exit(1);
492
493 BN_init(&a);
494 BN_init(&b);
495 BN_init(&c);
496 BN_init(&d);
497 BN_init(&e);
498
499 for (i=0; i<num0+num1; i++)
500 {
501 if (i <= num1)
502 {
503 BN_bntest_rand(&a,100,0,0);
504 BN_bntest_rand(&b,100,0,0);
505 }
506 else
507 BN_bntest_rand(&b,i-num1,0,0);
508 a.neg=rand_neg();
509 b.neg=rand_neg();
510 BN_mul(&c,&a,&b,ctx);
511 if (bp != NULL)
512 {
513 if (!results)
514 {
515 BN_print(bp,&a);
516 BIO_puts(bp," * ");
517 BN_print(bp,&b);
518 BIO_puts(bp," - ");
519 }
520 BN_print(bp,&c);
521 BIO_puts(bp,"\n");
522 }
523 BN_div(&d,&e,&c,&a,ctx);
524 BN_sub(&d,&d,&b);
525 if(!BN_is_zero(&d) || !BN_is_zero(&e))
526 {
527 fprintf(stderr,"Multiplication test failed!\n");
528 return 0;
529 }
530 }
531 BN_free(&a);
532 BN_free(&b);
533 BN_free(&c);
534 BN_free(&d);
535 BN_free(&e);
536 BN_CTX_free(ctx);
537 return(1);
538 }
539
540int test_sqr(BIO *bp, BN_CTX *ctx)
541 {
542 BIGNUM a,c,d,e;
543 int i;
544
545 BN_init(&a);
546 BN_init(&c);
547 BN_init(&d);
548 BN_init(&e);
549
550 for (i=0; i<num0; i++)
551 {
552 BN_bntest_rand(&a,40+i*10,0,0);
553 a.neg=rand_neg();
554 BN_sqr(&c,&a,ctx);
555 if (bp != NULL)
556 {
557 if (!results)
558 {
559 BN_print(bp,&a);
560 BIO_puts(bp," * ");
561 BN_print(bp,&a);
562 BIO_puts(bp," - ");
563 }
564 BN_print(bp,&c);
565 BIO_puts(bp,"\n");
566 }
567 BN_div(&d,&e,&c,&a,ctx);
568 BN_sub(&d,&d,&a);
569 if(!BN_is_zero(&d) || !BN_is_zero(&e))
570 {
571 fprintf(stderr,"Square test failed!\n");
572 return 0;
573 }
574 }
575 BN_free(&a);
576 BN_free(&c);
577 BN_free(&d);
578 BN_free(&e);
579 return(1);
580 }
581
582int test_mont(BIO *bp, BN_CTX *ctx)
583 {
584 BIGNUM a,b,c,d,A,B;
585 BIGNUM n;
586 int i;
587 BN_MONT_CTX *mont;
588
589 BN_init(&a);
590 BN_init(&b);
591 BN_init(&c);
592 BN_init(&d);
593 BN_init(&A);
594 BN_init(&B);
595 BN_init(&n);
596
597 mont=BN_MONT_CTX_new();
598
599 BN_bntest_rand(&a,100,0,0); /**/
600 BN_bntest_rand(&b,100,0,0); /**/
601 for (i=0; i<num2; i++)
602 {
603 int bits = (200*(i+1))/num2;
604
605 if (bits == 0)
606 continue;
607 BN_bntest_rand(&n,bits,0,1);
608 BN_MONT_CTX_set(mont,&n,ctx);
609
610 BN_nnmod(&a,&a,&n,ctx);
611 BN_nnmod(&b,&b,&n,ctx);
612
613 BN_to_montgomery(&A,&a,mont,ctx);
614 BN_to_montgomery(&B,&b,mont,ctx);
615
616 BN_mod_mul_montgomery(&c,&A,&B,mont,ctx);/**/
617 BN_from_montgomery(&A,&c,mont,ctx);/**/
618 if (bp != NULL)
619 {
620 if (!results)
621 {
622#ifdef undef
623fprintf(stderr,"%d * %d %% %d\n",
624BN_num_bits(&a),
625BN_num_bits(&b),
626BN_num_bits(mont->N));
627#endif
628 BN_print(bp,&a);
629 BIO_puts(bp," * ");
630 BN_print(bp,&b);
631 BIO_puts(bp," % ");
632 BN_print(bp,&(mont->N));
633 BIO_puts(bp," - ");
634 }
635 BN_print(bp,&A);
636 BIO_puts(bp,"\n");
637 }
638 BN_mod_mul(&d,&a,&b,&n,ctx);
639 BN_sub(&d,&d,&A);
640 if(!BN_is_zero(&d))
641 {
642 fprintf(stderr,"Montgomery multiplication test failed!\n");
643 return 0;
644 }
645 }
646 BN_MONT_CTX_free(mont);
647 BN_free(&a);
648 BN_free(&b);
649 BN_free(&c);
650 BN_free(&d);
651 BN_free(&A);
652 BN_free(&B);
653 BN_free(&n);
654 return(1);
655 }
656
657int test_mod(BIO *bp, BN_CTX *ctx)
658 {
659 BIGNUM *a,*b,*c,*d,*e;
660 int i;
661
662 a=BN_new();
663 b=BN_new();
664 c=BN_new();
665 d=BN_new();
666 e=BN_new();
667
668 BN_bntest_rand(a,1024,0,0); /**/
669 for (i=0; i<num0; i++)
670 {
671 BN_bntest_rand(b,450+i*10,0,0); /**/
672 a->neg=rand_neg();
673 b->neg=rand_neg();
674 BN_mod(c,a,b,ctx);/**/
675 if (bp != NULL)
676 {
677 if (!results)
678 {
679 BN_print(bp,a);
680 BIO_puts(bp," % ");
681 BN_print(bp,b);
682 BIO_puts(bp," - ");
683 }
684 BN_print(bp,c);
685 BIO_puts(bp,"\n");
686 }
687 BN_div(d,e,a,b,ctx);
688 BN_sub(e,e,c);
689 if(!BN_is_zero(e))
690 {
691 fprintf(stderr,"Modulo test failed!\n");
692 return 0;
693 }
694 }
695 BN_free(a);
696 BN_free(b);
697 BN_free(c);
698 BN_free(d);
699 BN_free(e);
700 return(1);
701 }
702
703int test_mod_mul(BIO *bp, BN_CTX *ctx)
704 {
705 BIGNUM *a,*b,*c,*d,*e;
706 int i,j;
707
708 a=BN_new();
709 b=BN_new();
710 c=BN_new();
711 d=BN_new();
712 e=BN_new();
713
714 for (j=0; j<3; j++) {
715 BN_bntest_rand(c,1024,0,0); /**/
716 for (i=0; i<num0; i++)
717 {
718 BN_bntest_rand(a,475+i*10,0,0); /**/
719 BN_bntest_rand(b,425+i*11,0,0); /**/
720 a->neg=rand_neg();
721 b->neg=rand_neg();
722 if (!BN_mod_mul(e,a,b,c,ctx))
723 {
724 unsigned long l;
725
726 while ((l=ERR_get_error()))
727 fprintf(stderr,"ERROR:%s\n",
728 ERR_error_string(l,NULL));
729 exit(1);
730 }
731 if (bp != NULL)
732 {
733 if (!results)
734 {
735 BN_print(bp,a);
736 BIO_puts(bp," * ");
737 BN_print(bp,b);
738 BIO_puts(bp," % ");
739 BN_print(bp,c);
740 if ((a->neg ^ b->neg) && !BN_is_zero(e))
741 {
742 /* If (a*b) % c is negative, c must be added
743 * in order to obtain the normalized remainder
744 * (new with OpenSSL 0.9.7, previous versions of
745 * BN_mod_mul could generate negative results)
746 */
747 BIO_puts(bp," + ");
748 BN_print(bp,c);
749 }
750 BIO_puts(bp," - ");
751 }
752 BN_print(bp,e);
753 BIO_puts(bp,"\n");
754 }
755 BN_mul(d,a,b,ctx);
756 BN_sub(d,d,e);
757 BN_div(a,b,d,c,ctx);
758 if(!BN_is_zero(b))
759 {
760 fprintf(stderr,"Modulo multiply test failed!\n");
761 ERR_print_errors_fp(stderr);
762 return 0;
763 }
764 }
765 }
766 BN_free(a);
767 BN_free(b);
768 BN_free(c);
769 BN_free(d);
770 BN_free(e);
771 return(1);
772 }
773
774int test_mod_exp(BIO *bp, BN_CTX *ctx)
775 {
776 BIGNUM *a,*b,*c,*d,*e;
777 int i;
778
779 a=BN_new();
780 b=BN_new();
781 c=BN_new();
782 d=BN_new();
783 e=BN_new();
784
785 BN_bntest_rand(c,30,0,1); /* must be odd for montgomery */
786 for (i=0; i<num2; i++)
787 {
788 BN_bntest_rand(a,20+i*5,0,0); /**/
789 BN_bntest_rand(b,2+i,0,0); /**/
790
791 if (!BN_mod_exp(d,a,b,c,ctx))
792 return(00);
793
794 if (bp != NULL)
795 {
796 if (!results)
797 {
798 BN_print(bp,a);
799 BIO_puts(bp," ^ ");
800 BN_print(bp,b);
801 BIO_puts(bp," % ");
802 BN_print(bp,c);
803 BIO_puts(bp," - ");
804 }
805 BN_print(bp,d);
806 BIO_puts(bp,"\n");
807 }
808 BN_exp(e,a,b,ctx);
809 BN_sub(e,e,d);
810 BN_div(a,b,e,c,ctx);
811 if(!BN_is_zero(b))
812 {
813 fprintf(stderr,"Modulo exponentiation test failed!\n");
814 return 0;
815 }
816 }
817 BN_free(a);
818 BN_free(b);
819 BN_free(c);
820 BN_free(d);
821 BN_free(e);
822 return(1);
823 }
824
825int test_exp(BIO *bp, BN_CTX *ctx)
826 {
827 BIGNUM *a,*b,*d,*e,*one;
828 int i;
829
830 a=BN_new();
831 b=BN_new();
832 d=BN_new();
833 e=BN_new();
834 one=BN_new();
835 BN_one(one);
836
837 for (i=0; i<num2; i++)
838 {
839 BN_bntest_rand(a,20+i*5,0,0); /**/
840 BN_bntest_rand(b,2+i,0,0); /**/
841
842 if (!BN_exp(d,a,b,ctx))
843 return(00);
844
845 if (bp != NULL)
846 {
847 if (!results)
848 {
849 BN_print(bp,a);
850 BIO_puts(bp," ^ ");
851 BN_print(bp,b);
852 BIO_puts(bp," - ");
853 }
854 BN_print(bp,d);
855 BIO_puts(bp,"\n");
856 }
857 BN_one(e);
858 for( ; !BN_is_zero(b) ; BN_sub(b,b,one))
859 BN_mul(e,e,a,ctx);
860 BN_sub(e,e,d);
861 if(!BN_is_zero(e))
862 {
863 fprintf(stderr,"Exponentiation test failed!\n");
864 return 0;
865 }
866 }
867 BN_free(a);
868 BN_free(b);
869 BN_free(d);
870 BN_free(e);
871 BN_free(one);
872 return(1);
873 }
874
875static void genprime_cb(int p, int n, void *arg)
876 {
877 char c='*';
878
879 if (p == 0) c='.';
880 if (p == 1) c='+';
881 if (p == 2) c='*';
882 if (p == 3) c='\n';
883 putc(c, stderr);
884 fflush(stderr);
885 (void)n;
886 (void)arg;
887 }
888
889int test_kron(BIO *bp, BN_CTX *ctx)
890 {
891 BIGNUM *a,*b,*r,*t;
892 int i;
893 int legendre, kronecker;
894 int ret = 0;
895
896 a = BN_new();
897 b = BN_new();
898 r = BN_new();
899 t = BN_new();
900 if (a == NULL || b == NULL || r == NULL || t == NULL) goto err;
901
902 /* We test BN_kronecker(a, b, ctx) just for b odd (Jacobi symbol).
903 * In this case we know that if b is prime, then BN_kronecker(a, b, ctx)
904 * is congruent to $a^{(b-1)/2}$, modulo $b$ (Legendre symbol).
905 * So we generate a random prime b and compare these values
906 * for a number of random a's. (That is, we run the Solovay-Strassen
907 * primality test to confirm that b is prime, except that we
908 * don't want to test whether b is prime but whether BN_kronecker
909 * works.) */
910
911 if (!BN_generate_prime(b, 512, 0, NULL, NULL, genprime_cb, NULL)) goto err;
912 b->neg = rand_neg();
913 putc('\n', stderr);
914
915 for (i = 0; i < num0; i++)
916 {
917 if (!BN_bntest_rand(a, 512, 0, 0)) goto err;
918 a->neg = rand_neg();
919
920 /* t := (|b|-1)/2 (note that b is odd) */
921 if (!BN_copy(t, b)) goto err;
922 t->neg = 0;
923 if (!BN_sub_word(t, 1)) goto err;
924 if (!BN_rshift1(t, t)) goto err;
925 /* r := a^t mod b */
926 b->neg=0;
927
928 if (!BN_mod_exp_recp(r, a, t, b, ctx)) goto err;
929 b->neg=1;
930
931 if (BN_is_word(r, 1))
932 legendre = 1;
933 else if (BN_is_zero(r))
934 legendre = 0;
935 else
936 {
937 if (!BN_add_word(r, 1)) goto err;
938 if (0 != BN_ucmp(r, b))
939 {
940 fprintf(stderr, "Legendre symbol computation failed\n");
941 goto err;
942 }
943 legendre = -1;
944 }
945
946 kronecker = BN_kronecker(a, b, ctx);
947 if (kronecker < -1) goto err;
948 /* we actually need BN_kronecker(a, |b|) */
949 if (a->neg && b->neg)
950 kronecker = -kronecker;
951
952 if (legendre != kronecker)
953 {
954 fprintf(stderr, "legendre != kronecker; a = ");
955 BN_print_fp(stderr, a);
956 fprintf(stderr, ", b = ");
957 BN_print_fp(stderr, b);
958 fprintf(stderr, "\n");
959 goto err;
960 }
961
962 putc('.', stderr);
963 fflush(stderr);
964 }
965
966 putc('\n', stderr);
967 fflush(stderr);
968 ret = 1;
969 err:
970 if (a != NULL) BN_free(a);
971 if (b != NULL) BN_free(b);
972 if (r != NULL) BN_free(r);
973 if (t != NULL) BN_free(t);
974 return ret;
975 }
976
977int test_sqrt(BIO *bp, BN_CTX *ctx)
978 {
979 BIGNUM *a,*p,*r;
980 int i, j;
981 int ret = 0;
982
983 a = BN_new();
984 p = BN_new();
985 r = BN_new();
986 if (a == NULL || p == NULL || r == NULL) goto err;
987
988 for (i = 0; i < 16; i++)
989 {
990 if (i < 8)
991 {
992 unsigned primes[8] = { 2, 3, 5, 7, 11, 13, 17, 19 };
993
994 if (!BN_set_word(p, primes[i])) goto err;
995 }
996 else
997 {
998 if (!BN_set_word(a, 32)) goto err;
999 if (!BN_set_word(r, 2*i + 1)) goto err;
1000
1001 if (!BN_generate_prime(p, 256, 0, a, r, genprime_cb, NULL)) goto err;
1002 putc('\n', stderr);
1003 }
1004 p->neg = rand_neg();
1005
1006 for (j = 0; j < num2; j++)
1007 {
1008 /* construct 'a' such that it is a square modulo p,
1009 * but in general not a proper square and not reduced modulo p */
1010 if (!BN_bntest_rand(r, 256, 0, 3)) goto err;
1011 if (!BN_nnmod(r, r, p, ctx)) goto err;
1012 if (!BN_mod_sqr(r, r, p, ctx)) goto err;
1013 if (!BN_bntest_rand(a, 256, 0, 3)) goto err;
1014 if (!BN_nnmod(a, a, p, ctx)) goto err;
1015 if (!BN_mod_sqr(a, a, p, ctx)) goto err;
1016 if (!BN_mul(a, a, r, ctx)) goto err;
1017 if (rand_neg())
1018 if (!BN_sub(a, a, p)) goto err;
1019
1020 if (!BN_mod_sqrt(r, a, p, ctx)) goto err;
1021 if (!BN_mod_sqr(r, r, p, ctx)) goto err;
1022
1023 if (!BN_nnmod(a, a, p, ctx)) goto err;
1024
1025 if (BN_cmp(a, r) != 0)
1026 {
1027 fprintf(stderr, "BN_mod_sqrt failed: a = ");
1028 BN_print_fp(stderr, a);
1029 fprintf(stderr, ", r = ");
1030 BN_print_fp(stderr, r);
1031 fprintf(stderr, ", p = ");
1032 BN_print_fp(stderr, p);
1033 fprintf(stderr, "\n");
1034 goto err;
1035 }
1036
1037 putc('.', stderr);
1038 fflush(stderr);
1039 }
1040
1041 putc('\n', stderr);
1042 fflush(stderr);
1043 }
1044 ret = 1;
1045 err:
1046 if (a != NULL) BN_free(a);
1047 if (p != NULL) BN_free(p);
1048 if (r != NULL) BN_free(r);
1049 return ret;
1050 }
1051
1052int test_lshift(BIO *bp,BN_CTX *ctx,BIGNUM *a_)
1053 {
1054 BIGNUM *a,*b,*c,*d;
1055 int i;
1056
1057 b=BN_new();
1058 c=BN_new();
1059 d=BN_new();
1060 BN_one(c);
1061
1062 if(a_)
1063 a=a_;
1064 else
1065 {
1066 a=BN_new();
1067 BN_bntest_rand(a,200,0,0); /**/
1068 a->neg=rand_neg();
1069 }
1070 for (i=0; i<num0; i++)
1071 {
1072 BN_lshift(b,a,i+1);
1073 BN_add(c,c,c);
1074 if (bp != NULL)
1075 {
1076 if (!results)
1077 {
1078 BN_print(bp,a);
1079 BIO_puts(bp," * ");
1080 BN_print(bp,c);
1081 BIO_puts(bp," - ");
1082 }
1083 BN_print(bp,b);
1084 BIO_puts(bp,"\n");
1085 }
1086 BN_mul(d,a,c,ctx);
1087 BN_sub(d,d,b);
1088 if(!BN_is_zero(d))
1089 {
1090 fprintf(stderr,"Left shift test failed!\n");
1091 fprintf(stderr,"a=");
1092 BN_print_fp(stderr,a);
1093 fprintf(stderr,"\nb=");
1094 BN_print_fp(stderr,b);
1095 fprintf(stderr,"\nc=");
1096 BN_print_fp(stderr,c);
1097 fprintf(stderr,"\nd=");
1098 BN_print_fp(stderr,d);
1099 fprintf(stderr,"\n");
1100 return 0;
1101 }
1102 }
1103 BN_free(a);
1104 BN_free(b);
1105 BN_free(c);
1106 BN_free(d);
1107 return(1);
1108 }
1109
1110int test_lshift1(BIO *bp)
1111 {
1112 BIGNUM *a,*b,*c;
1113 int i;
1114
1115 a=BN_new();
1116 b=BN_new();
1117 c=BN_new();
1118
1119 BN_bntest_rand(a,200,0,0); /**/
1120 a->neg=rand_neg();
1121 for (i=0; i<num0; i++)
1122 {
1123 BN_lshift1(b,a);
1124 if (bp != NULL)
1125 {
1126 if (!results)
1127 {
1128 BN_print(bp,a);
1129 BIO_puts(bp," * 2");
1130 BIO_puts(bp," - ");
1131 }
1132 BN_print(bp,b);
1133 BIO_puts(bp,"\n");
1134 }
1135 BN_add(c,a,a);
1136 BN_sub(a,b,c);
1137 if(!BN_is_zero(a))
1138 {
1139 fprintf(stderr,"Left shift one test failed!\n");
1140 return 0;
1141 }
1142
1143 BN_copy(a,b);
1144 }
1145 BN_free(a);
1146 BN_free(b);
1147 BN_free(c);
1148 return(1);
1149 }
1150
1151int test_rshift(BIO *bp,BN_CTX *ctx)
1152 {
1153 BIGNUM *a,*b,*c,*d,*e;
1154 int i;
1155
1156 a=BN_new();
1157 b=BN_new();
1158 c=BN_new();
1159 d=BN_new();
1160 e=BN_new();
1161 BN_one(c);
1162
1163 BN_bntest_rand(a,200,0,0); /**/
1164 a->neg=rand_neg();
1165 for (i=0; i<num0; i++)
1166 {
1167 BN_rshift(b,a,i+1);
1168 BN_add(c,c,c);
1169 if (bp != NULL)
1170 {
1171 if (!results)
1172 {
1173 BN_print(bp,a);
1174 BIO_puts(bp," / ");
1175 BN_print(bp,c);
1176 BIO_puts(bp," - ");
1177 }
1178 BN_print(bp,b);
1179 BIO_puts(bp,"\n");
1180 }
1181 BN_div(d,e,a,c,ctx);
1182 BN_sub(d,d,b);
1183 if(!BN_is_zero(d))
1184 {
1185 fprintf(stderr,"Right shift test failed!\n");
1186 return 0;
1187 }
1188 }
1189 BN_free(a);
1190 BN_free(b);
1191 BN_free(c);
1192 BN_free(d);
1193 BN_free(e);
1194 return(1);
1195 }
1196
1197int test_rshift1(BIO *bp)
1198 {
1199 BIGNUM *a,*b,*c;
1200 int i;
1201
1202 a=BN_new();
1203 b=BN_new();
1204 c=BN_new();
1205
1206 BN_bntest_rand(a,200,0,0); /**/
1207 a->neg=rand_neg();
1208 for (i=0; i<num0; i++)
1209 {
1210 BN_rshift1(b,a);
1211 if (bp != NULL)
1212 {
1213 if (!results)
1214 {
1215 BN_print(bp,a);
1216 BIO_puts(bp," / 2");
1217 BIO_puts(bp," - ");
1218 }
1219 BN_print(bp,b);
1220 BIO_puts(bp,"\n");
1221 }
1222 BN_sub(c,a,b);
1223 BN_sub(c,c,b);
1224 if(!BN_is_zero(c) && !BN_abs_is_word(c, 1))
1225 {
1226 fprintf(stderr,"Right shift one test failed!\n");
1227 return 0;
1228 }
1229 BN_copy(a,b);
1230 }
1231 BN_free(a);
1232 BN_free(b);
1233 BN_free(c);
1234 return(1);
1235 }
1236
1237int rand_neg(void)
1238 {
1239 static unsigned int neg=0;
1240 static int sign[8]={0,0,0,1,1,0,1,1};
1241
1242 return(sign[(neg++)%8]);
1243 }
diff --git a/src/lib/libcrypto/bn/divtest.c b/src/lib/libcrypto/bn/divtest.c
new file mode 100644
index 0000000000..13ba86e3c4
--- /dev/null
+++ b/src/lib/libcrypto/bn/divtest.c
@@ -0,0 +1,41 @@
1#include <openssl/bn.h>
2#include <openssl/rand.h>
3
4static int rand(n)
5{
6 unsigned char x[2];
7 RAND_pseudo_bytes(x,2);
8 return (x[0] + 2*x[1]);
9}
10
11static void bug(char *m, BIGNUM *a, BIGNUM *b)
12{
13 printf("%s!\na=",m);
14 BN_print_fp(stdout, a);
15 printf("\nb=");
16 BN_print_fp(stdout, b);
17 printf("\n");
18 fflush(stdout);
19}
20
21main()
22{
23 BIGNUM *a=BN_new(), *b=BN_new(), *c=BN_new(), *d=BN_new(),
24 *C=BN_new(), *D=BN_new();
25 BN_RECP_CTX *recp=BN_RECP_CTX_new();
26 BN_CTX *ctx=BN_CTX_new();
27
28 for(;;) {
29 BN_pseudo_rand(a,rand(),0,0);
30 BN_pseudo_rand(b,rand(),0,0);
31 if (BN_is_zero(b)) continue;
32
33 BN_RECP_CTX_set(recp,b,ctx);
34 if (BN_div(C,D,a,b,ctx) != 1)
35 bug("BN_div failed",a,b);
36 if (BN_div_recp(c,d,a,recp,ctx) != 1)
37 bug("BN_div_recp failed",a,b);
38 else if (BN_cmp(c,C) != 0 || BN_cmp(c,C) != 0)
39 bug("mismatch",a,b);
40 }
41}
diff --git a/src/lib/libcrypto/bn/exp.c b/src/lib/libcrypto/bn/exp.c
new file mode 100644
index 0000000000..4865b0ef74
--- /dev/null
+++ b/src/lib/libcrypto/bn/exp.c
@@ -0,0 +1,62 @@
1/* unused */
2
3#include <stdio.h>
4#include <openssl/tmdiff.h>
5#include "bn_lcl.h"
6
7#define SIZE 256
8#define NUM (8*8*8)
9#define MOD (8*8*8*8*8)
10
11main(argc,argv)
12int argc;
13char *argv[];
14 {
15 BN_CTX ctx;
16 BIGNUM a,b,c,r,rr,t,l;
17 int j,i,size=SIZE,num=NUM,mod=MOD;
18 char *start,*end;
19 BN_MONT_CTX mont;
20 double d,md;
21
22 BN_MONT_CTX_init(&mont);
23 BN_CTX_init(&ctx);
24 BN_init(&a);
25 BN_init(&b);
26 BN_init(&c);
27 BN_init(&r);
28
29 start=ms_time_new();
30 end=ms_time_new();
31 while (size <= 1024*8)
32 {
33 BN_rand(&a,size,0,0);
34 BN_rand(&b,size,1,0);
35 BN_rand(&c,size,0,1);
36
37 BN_mod(&a,&a,&c,&ctx);
38
39 ms_time_get(start);
40 for (i=0; i<10; i++)
41 BN_MONT_CTX_set(&mont,&c,&ctx);
42 ms_time_get(end);
43 md=ms_time_diff(start,end);
44
45 ms_time_get(start);
46 for (i=0; i<num; i++)
47 {
48 /* bn_mull(&r,&a,&b,&ctx); */
49 /* BN_sqr(&r,&a,&ctx); */
50 BN_mod_exp_mont(&r,&a,&b,&c,&ctx,&mont);
51 }
52 ms_time_get(end);
53 d=ms_time_diff(start,end)/* *50/33 */;
54 printf("%5d bit:%6.2f %6d %6.4f %4d m_set(%5.4f)\n",size,
55 d,num,d/num,(int)((d/num)*mod),md/10.0);
56 num/=8;
57 mod/=8;
58 if (num <= 0) num=1;
59 size*=2;
60 }
61
62 }
diff --git a/src/lib/libcrypto/bn/expspeed.c b/src/lib/libcrypto/bn/expspeed.c
new file mode 100644
index 0000000000..07a1bcf51c
--- /dev/null
+++ b/src/lib/libcrypto/bn/expspeed.c
@@ -0,0 +1,353 @@
1/* unused */
2
3/* crypto/bn/expspeed.c */
4/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
5 * All rights reserved.
6 *
7 * This package is an SSL implementation written
8 * by Eric Young (eay@cryptsoft.com).
9 * The implementation was written so as to conform with Netscapes SSL.
10 *
11 * This library is free for commercial and non-commercial use as long as
12 * the following conditions are aheared to. The following conditions
13 * apply to all code found in this distribution, be it the RC4, RSA,
14 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
15 * included with this distribution is covered by the same copyright terms
16 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
17 *
18 * Copyright remains Eric Young's, and as such any Copyright notices in
19 * the code are not to be removed.
20 * If this package is used in a product, Eric Young should be given attribution
21 * as the author of the parts of the library used.
22 * This can be in the form of a textual message at program startup or
23 * in documentation (online or textual) provided with the package.
24 *
25 * Redistribution and use in source and binary forms, with or without
26 * modification, are permitted provided that the following conditions
27 * are met:
28 * 1. Redistributions of source code must retain the copyright
29 * notice, this list of conditions and the following disclaimer.
30 * 2. Redistributions in binary form must reproduce the above copyright
31 * notice, this list of conditions and the following disclaimer in the
32 * documentation and/or other materials provided with the distribution.
33 * 3. All advertising materials mentioning features or use of this software
34 * must display the following acknowledgement:
35 * "This product includes cryptographic software written by
36 * Eric Young (eay@cryptsoft.com)"
37 * The word 'cryptographic' can be left out if the rouines from the library
38 * being used are not cryptographic related :-).
39 * 4. If you include any Windows specific code (or a derivative thereof) from
40 * the apps directory (application code) you must include an acknowledgement:
41 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
42 *
43 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
44 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
47 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53 * SUCH DAMAGE.
54 *
55 * The licence and distribution terms for any publically available version or
56 * derivative of this code cannot be changed. i.e. this code cannot simply be
57 * copied and put under another distribution licence
58 * [including the GNU Public Licence.]
59 */
60
61/* most of this code has been pilfered from my libdes speed.c program */
62
63#define BASENUM 5000
64#define NUM_START 0
65
66
67/* determine timings for modexp, modmul, modsqr, gcd, Kronecker symbol,
68 * modular inverse, or modular square roots */
69#define TEST_EXP
70#undef TEST_MUL
71#undef TEST_SQR
72#undef TEST_GCD
73#undef TEST_KRON
74#undef TEST_INV
75#undef TEST_SQRT
76#define P_MOD_64 9 /* least significant 6 bits for prime to be used for BN_sqrt timings */
77
78#if defined(TEST_EXP) + defined(TEST_MUL) + defined(TEST_SQR) + defined(TEST_GCD) + defined(TEST_KRON) + defined(TEST_INV) +defined(TEST_SQRT) != 1
79# error "choose one test"
80#endif
81
82#if defined(TEST_INV) || defined(TEST_SQRT)
83# define C_PRIME
84static void genprime_cb(int p, int n, void *arg);
85#endif
86
87
88
89#undef PROG
90#define PROG bnspeed_main
91
92#include <stdio.h>
93#include <stdlib.h>
94#include <signal.h>
95#include <string.h>
96#include <openssl/crypto.h>
97#include <openssl/err.h>
98#include <openssl/rand.h>
99
100#if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX)
101#define TIMES
102#endif
103
104#ifndef _IRIX
105#include <time.h>
106#endif
107#ifdef TIMES
108#include <sys/types.h>
109#include <sys/times.h>
110#endif
111
112/* Depending on the VMS version, the tms structure is perhaps defined.
113 The __TMS macro will show if it was. If it wasn't defined, we should
114 undefine TIMES, since that tells the rest of the program how things
115 should be handled. -- Richard Levitte */
116#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
117#undef TIMES
118#endif
119
120#ifndef TIMES
121#include <sys/timeb.h>
122#endif
123
124#if defined(sun) || defined(__ultrix)
125#define _POSIX_SOURCE
126#include <limits.h>
127#include <sys/param.h>
128#endif
129
130#include <openssl/bn.h>
131#include <openssl/x509.h>
132
133/* The following if from times(3) man page. It may need to be changed */
134#ifndef HZ
135# ifndef CLK_TCK
136# ifndef _BSD_CLK_TCK_ /* FreeBSD hack */
137# define HZ 100.0
138# else /* _BSD_CLK_TCK_ */
139# define HZ ((double)_BSD_CLK_TCK_)
140# endif
141# else /* CLK_TCK */
142# define HZ ((double)CLK_TCK)
143# endif
144#endif
145
146#undef BUFSIZE
147#define BUFSIZE ((long)1024*8)
148int run=0;
149
150static double Time_F(int s);
151#define START 0
152#define STOP 1
153
154static double Time_F(int s)
155 {
156 double ret;
157#ifdef TIMES
158 static struct tms tstart,tend;
159
160 if (s == START)
161 {
162 times(&tstart);
163 return(0);
164 }
165 else
166 {
167 times(&tend);
168 ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
169 return((ret < 1e-3)?1e-3:ret);
170 }
171#else /* !times() */
172 static struct timeb tstart,tend;
173 long i;
174
175 if (s == START)
176 {
177 ftime(&tstart);
178 return(0);
179 }
180 else
181 {
182 ftime(&tend);
183 i=(long)tend.millitm-(long)tstart.millitm;
184 ret=((double)(tend.time-tstart.time))+((double)i)/1000.0;
185 return((ret < 0.001)?0.001:ret);
186 }
187#endif
188 }
189
190#define NUM_SIZES 7
191#if NUM_START > NUM_SIZES
192# error "NUM_START > NUM_SIZES"
193#endif
194static int sizes[NUM_SIZES]={128,256,512,1024,2048,4096,8192};
195static int mul_c[NUM_SIZES]={8*8*8*8*8*8,8*8*8*8*8,8*8*8*8,8*8*8,8*8,8,1};
196/*static int sizes[NUM_SIZES]={59,179,299,419,539}; */
197
198#define RAND_SEED(string) { const char str[] = string; RAND_seed(string, sizeof str); }
199
200void do_mul_exp(BIGNUM *r,BIGNUM *a,BIGNUM *b,BIGNUM *c,BN_CTX *ctx);
201
202int main(int argc, char **argv)
203 {
204 BN_CTX *ctx;
205 BIGNUM *a,*b,*c,*r;
206
207#if 1
208 if (!CRYPTO_set_mem_debug_functions(0,0,0,0,0))
209 abort();
210#endif
211
212 ctx=BN_CTX_new();
213 a=BN_new();
214 b=BN_new();
215 c=BN_new();
216 r=BN_new();
217
218 while (!RAND_status())
219 /* not enough bits */
220 RAND_SEED("I demand a manual recount!");
221
222 do_mul_exp(r,a,b,c,ctx);
223 return 0;
224 }
225
226void do_mul_exp(BIGNUM *r, BIGNUM *a, BIGNUM *b, BIGNUM *c, BN_CTX *ctx)
227 {
228 int i,k;
229 double tm;
230 long num;
231
232 num=BASENUM;
233 for (i=NUM_START; i<NUM_SIZES; i++)
234 {
235#ifdef C_PRIME
236# ifdef TEST_SQRT
237 if (!BN_set_word(a, 64)) goto err;
238 if (!BN_set_word(b, P_MOD_64)) goto err;
239# define ADD a
240# define REM b
241# else
242# define ADD NULL
243# define REM NULL
244# endif
245 if (!BN_generate_prime(c,sizes[i],0,ADD,REM,genprime_cb,NULL)) goto err;
246 putc('\n', stderr);
247 fflush(stderr);
248#endif
249
250 for (k=0; k<num; k++)
251 {
252 if (k%50 == 0) /* Average over num/50 different choices of random numbers. */
253 {
254 if (!BN_pseudo_rand(a,sizes[i],1,0)) goto err;
255
256 if (!BN_pseudo_rand(b,sizes[i],1,0)) goto err;
257
258#ifndef C_PRIME
259 if (!BN_pseudo_rand(c,sizes[i],1,1)) goto err;
260#endif
261
262#ifdef TEST_SQRT
263 if (!BN_mod_sqr(a,a,c,ctx)) goto err;
264 if (!BN_mod_sqr(b,b,c,ctx)) goto err;
265#else
266 if (!BN_nnmod(a,a,c,ctx)) goto err;
267 if (!BN_nnmod(b,b,c,ctx)) goto err;
268#endif
269
270 if (k == 0)
271 Time_F(START);
272 }
273
274#if defined(TEST_EXP)
275 if (!BN_mod_exp(r,a,b,c,ctx)) goto err;
276#elif defined(TEST_MUL)
277 {
278 int i = 0;
279 for (i = 0; i < 50; i++)
280 if (!BN_mod_mul(r,a,b,c,ctx)) goto err;
281 }
282#elif defined(TEST_SQR)
283 {
284 int i = 0;
285 for (i = 0; i < 50; i++)
286 {
287 if (!BN_mod_sqr(r,a,c,ctx)) goto err;
288 if (!BN_mod_sqr(r,b,c,ctx)) goto err;
289 }
290 }
291#elif defined(TEST_GCD)
292 if (!BN_gcd(r,a,b,ctx)) goto err;
293 if (!BN_gcd(r,b,c,ctx)) goto err;
294 if (!BN_gcd(r,c,a,ctx)) goto err;
295#elif defined(TEST_KRON)
296 if (-2 == BN_kronecker(a,b,ctx)) goto err;
297 if (-2 == BN_kronecker(b,c,ctx)) goto err;
298 if (-2 == BN_kronecker(c,a,ctx)) goto err;
299#elif defined(TEST_INV)
300 if (!BN_mod_inverse(r,a,c,ctx)) goto err;
301 if (!BN_mod_inverse(r,b,c,ctx)) goto err;
302#else /* TEST_SQRT */
303 if (!BN_mod_sqrt(r,a,c,ctx)) goto err;
304 if (!BN_mod_sqrt(r,b,c,ctx)) goto err;
305#endif
306 }
307 tm=Time_F(STOP);
308 printf(
309#if defined(TEST_EXP)
310 "modexp %4d ^ %4d %% %4d"
311#elif defined(TEST_MUL)
312 "50*modmul %4d %4d %4d"
313#elif defined(TEST_SQR)
314 "100*modsqr %4d %4d %4d"
315#elif defined(TEST_GCD)
316 "3*gcd %4d %4d %4d"
317#elif defined(TEST_KRON)
318 "3*kronecker %4d %4d %4d"
319#elif defined(TEST_INV)
320 "2*inv %4d %4d mod %4d"
321#else /* TEST_SQRT */
322 "2*sqrt [prime == %d (mod 64)] %4d %4d mod %4d"
323#endif
324 " -> %8.3fms %5.1f (%ld)\n",
325#ifdef TEST_SQRT
326 P_MOD_64,
327#endif
328 sizes[i],sizes[i],sizes[i],tm*1000.0/num,tm*mul_c[i]/num, num);
329 num/=7;
330 if (num <= 0) num=1;
331 }
332 return;
333
334 err:
335 ERR_print_errors_fp(stderr);
336 }
337
338
339#ifdef C_PRIME
340static void genprime_cb(int p, int n, void *arg)
341 {
342 char c='*';
343
344 if (p == 0) c='.';
345 if (p == 1) c='+';
346 if (p == 2) c='*';
347 if (p == 3) c='\n';
348 putc(c, stderr);
349 fflush(stderr);
350 (void)n;
351 (void)arg;
352 }
353#endif
diff --git a/src/lib/libcrypto/bn/exptest.c b/src/lib/libcrypto/bn/exptest.c
new file mode 100644
index 0000000000..5ca570d1a8
--- /dev/null
+++ b/src/lib/libcrypto/bn/exptest.c
@@ -0,0 +1,187 @@
1/* crypto/bn/exptest.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <stdlib.h>
61#include <string.h>
62#include <openssl/bio.h>
63#include <openssl/bn.h>
64#include <openssl/rand.h>
65#include <openssl/err.h>
66#ifdef OPENSSL_SYS_WINDOWS
67#include "../bio/bss_file.c"
68#endif
69
70#define NUM_BITS (BN_BITS*2)
71
72static const char rnd_seed[] = "string to make the random number generator think it has entropy";
73
74int main(int argc, char *argv[])
75 {
76 BN_CTX *ctx;
77 BIO *out=NULL;
78 int i,ret;
79 unsigned char c;
80 BIGNUM *r_mont,*r_recp,*r_simple,*a,*b,*m;
81
82 RAND_seed(rnd_seed, sizeof rnd_seed); /* or BN_rand may fail, and we don't
83 * even check its return value
84 * (which we should) */
85
86 ERR_load_BN_strings();
87
88 ctx=BN_CTX_new();
89 if (ctx == NULL) exit(1);
90 r_mont=BN_new();
91 r_recp=BN_new();
92 r_simple=BN_new();
93 a=BN_new();
94 b=BN_new();
95 m=BN_new();
96 if ( (r_mont == NULL) || (r_recp == NULL) ||
97 (a == NULL) || (b == NULL))
98 goto err;
99
100 out=BIO_new(BIO_s_file());
101
102 if (out == NULL) exit(1);
103 BIO_set_fp(out,stdout,BIO_NOCLOSE);
104
105 for (i=0; i<200; i++)
106 {
107 RAND_bytes(&c,1);
108 c=(c%BN_BITS)-BN_BITS2;
109 BN_rand(a,NUM_BITS+c,0,0);
110
111 RAND_bytes(&c,1);
112 c=(c%BN_BITS)-BN_BITS2;
113 BN_rand(b,NUM_BITS+c,0,0);
114
115 RAND_bytes(&c,1);
116 c=(c%BN_BITS)-BN_BITS2;
117 BN_rand(m,NUM_BITS+c,0,1);
118
119 BN_mod(a,a,m,ctx);
120 BN_mod(b,b,m,ctx);
121
122 ret=BN_mod_exp_mont(r_mont,a,b,m,ctx,NULL);
123 if (ret <= 0)
124 {
125 printf("BN_mod_exp_mont() problems\n");
126 ERR_print_errors(out);
127 exit(1);
128 }
129
130 ret=BN_mod_exp_recp(r_recp,a,b,m,ctx);
131 if (ret <= 0)
132 {
133 printf("BN_mod_exp_recp() problems\n");
134 ERR_print_errors(out);
135 exit(1);
136 }
137
138 ret=BN_mod_exp_simple(r_simple,a,b,m,ctx);
139 if (ret <= 0)
140 {
141 printf("BN_mod_exp_simple() problems\n");
142 ERR_print_errors(out);
143 exit(1);
144 }
145
146 if (BN_cmp(r_simple, r_mont) == 0
147 && BN_cmp(r_simple,r_recp) == 0)
148 {
149 printf(".");
150 fflush(stdout);
151 }
152 else
153 {
154 if (BN_cmp(r_simple,r_mont) != 0)
155 printf("\nsimple and mont results differ\n");
156 if (BN_cmp(r_simple,r_recp) != 0)
157 printf("\nsimple and recp results differ\n");
158
159 printf("a (%3d) = ",BN_num_bits(a)); BN_print(out,a);
160 printf("\nb (%3d) = ",BN_num_bits(b)); BN_print(out,b);
161 printf("\nm (%3d) = ",BN_num_bits(m)); BN_print(out,m);
162 printf("\nsimple ="); BN_print(out,r_simple);
163 printf("\nrecp ="); BN_print(out,r_recp);
164 printf("\nmont ="); BN_print(out,r_mont);
165 printf("\n");
166 exit(1);
167 }
168 }
169 BN_free(r_mont);
170 BN_free(r_recp);
171 BN_free(r_simple);
172 BN_free(a);
173 BN_free(b);
174 BN_free(m);
175 BN_CTX_free(ctx);
176 ERR_remove_state(0);
177 CRYPTO_mem_leaks(out);
178 BIO_free(out);
179 printf(" done\n");
180 exit(0);
181err:
182 ERR_load_crypto_strings();
183 ERR_print_errors(out);
184 exit(1);
185 return(1);
186 }
187
diff --git a/src/lib/libcrypto/bn/todo b/src/lib/libcrypto/bn/todo
new file mode 100644
index 0000000000..e47e381aea
--- /dev/null
+++ b/src/lib/libcrypto/bn/todo
@@ -0,0 +1,3 @@
1Cache RECP_CTX values
2make the result argument independant of the inputs.
3split up the _exp_ functions
diff --git a/src/lib/libcrypto/bn/vms-helper.c b/src/lib/libcrypto/bn/vms-helper.c
new file mode 100644
index 0000000000..4b63149bf3
--- /dev/null
+++ b/src/lib/libcrypto/bn/vms-helper.c
@@ -0,0 +1,68 @@
1/* vms-helper.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#include <stdio.h>
57#include "cryptlib.h"
58#include "bn_lcl.h"
59
60bn_div_words_abort(int i)
61{
62#ifdef BN_DEBUG
63#if !defined(OPENSSL_NO_STDIO) && !defined(OPENSSL_SYS_WIN16)
64 fprintf(stderr,"Division would overflow (%d)\n",i);
65#endif
66 abort();
67#endif
68}
diff --git a/src/lib/libcrypto/buffer/Makefile.ssl b/src/lib/libcrypto/buffer/Makefile.ssl
new file mode 100644
index 0000000000..240a6b9a89
--- /dev/null
+++ b/src/lib/libcrypto/buffer/Makefile.ssl
@@ -0,0 +1,94 @@
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/buffer.c b/src/lib/libcrypto/buffer/buffer.c
index d96487e7db..9299baba9e 100644
--- a/src/lib/libcrypto/buffer/buffer.c
+++ b/src/lib/libcrypto/buffer/buffer.c
@@ -125,43 +125,6 @@ int BUF_MEM_grow(BUF_MEM *str, int len)
125 return(len); 125 return(len);
126 } 126 }
127 127
128int BUF_MEM_grow_clean(BUF_MEM *str, int len)
129 {
130 char *ret;
131 unsigned int n;
132
133 if (str->length >= len)
134 {
135 memset(&str->data[len],0,str->length-len);
136 str->length=len;
137 return(len);
138 }
139 if (str->max >= len)
140 {
141 memset(&str->data[str->length],0,len-str->length);
142 str->length=len;
143 return(len);
144 }
145 n=(len+3)/3*4;
146 if (str->data == NULL)
147 ret=OPENSSL_malloc(n);
148 else
149 ret=OPENSSL_realloc_clean(str->data,str->max,n);
150 if (ret == NULL)
151 {
152 BUFerr(BUF_F_BUF_MEM_GROW,ERR_R_MALLOC_FAILURE);
153 len=0;
154 }
155 else
156 {
157 str->data=ret;
158 str->max=n;
159 memset(&str->data[str->length],0,len-str->length);
160 str->length=len;
161 }
162 return(len);
163 }
164
165char *BUF_strdup(const char *str) 128char *BUF_strdup(const char *str)
166 { 129 {
167 char *ret; 130 char *ret;
@@ -180,23 +143,3 @@ char *BUF_strdup(const char *str)
180 return(ret); 143 return(ret);
181 } 144 }
182 145
183size_t BUF_strlcpy(char *dst, const char *src, size_t size)
184 {
185 size_t l = 0;
186 for(; size > 1 && *src; size--)
187 {
188 *dst++ = *src++;
189 l++;
190 }
191 if (size)
192 *dst = '\0';
193 return l + strlen(src);
194 }
195
196size_t BUF_strlcat(char *dst, const char *src, size_t size)
197 {
198 size_t l = 0;
199 for(; size > 0 && *dst; size--, dst++)
200 l++;
201 return l + BUF_strlcpy(dst, src, size);
202 }
diff --git a/src/lib/libcrypto/buffer/buffer.h b/src/lib/libcrypto/buffer/buffer.h
index 465dc34f3f..11e2d0359a 100644
--- a/src/lib/libcrypto/buffer/buffer.h
+++ b/src/lib/libcrypto/buffer/buffer.h
@@ -63,9 +63,6 @@
63extern "C" { 63extern "C" {
64#endif 64#endif
65 65
66#include <stddef.h>
67#include <sys/types.h>
68
69typedef struct buf_mem_st 66typedef struct buf_mem_st
70 { 67 {
71 int length; /* current number of bytes */ 68 int length; /* current number of bytes */
@@ -76,14 +73,8 @@ typedef struct buf_mem_st
76BUF_MEM *BUF_MEM_new(void); 73BUF_MEM *BUF_MEM_new(void);
77void BUF_MEM_free(BUF_MEM *a); 74void BUF_MEM_free(BUF_MEM *a);
78int BUF_MEM_grow(BUF_MEM *str, int len); 75int BUF_MEM_grow(BUF_MEM *str, int len);
79int BUF_MEM_grow_clean(BUF_MEM *str, int len);
80char * BUF_strdup(const char *str); 76char * BUF_strdup(const char *str);
81 77
82/* safe string functions */
83size_t BUF_strlcpy(char *dst,const char *src,size_t siz);
84size_t BUF_strlcat(char *dst,const char *src,size_t siz);
85
86
87/* BEGIN ERROR CODES */ 78/* BEGIN ERROR CODES */
88/* The following lines are auto generated by the script mkerr.pl. Any changes 79/* The following lines are auto generated by the script mkerr.pl. Any changes
89 * made after this point may be overwritten when the script is next run. 80 * made after this point may be overwritten when the script is next run.
diff --git a/src/lib/libcrypto/cast/Makefile.ssl b/src/lib/libcrypto/cast/Makefile.ssl
new file mode 100644
index 0000000000..2defbdd68a
--- /dev/null
+++ b/src/lib/libcrypto/cast/Makefile.ssl
@@ -0,0 +1,125 @@
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)
28
29GENERAL=Makefile
30TEST=casttest.c
31APPS=
32
33LIB=$(TOP)/libcrypto.a
34LIBSRC=c_skey.c c_ecb.c c_enc.c c_cfb64.c c_ofb64.c
35LIBOBJ=c_skey.o c_ecb.o $(CAST_ENC) c_cfb64.o c_ofb64.o
36
37SRC= $(LIBSRC)
38
39EXHEADER= cast.h
40HEADER= cast_s.h cast_lcl.h $(EXHEADER)
41
42ALL= $(GENERAL) $(SRC) $(HEADER)
43
44top:
45 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
46
47all: lib
48
49lib: $(LIBOBJ)
50 $(AR) $(LIB) $(LIBOBJ)
51 $(RANLIB) $(LIB) || echo Never mind.
52 @touch lib
53
54# elf
55asm/cx86-elf.o: asm/cx86unix.cpp
56 $(CPP) -DELF -x c asm/cx86unix.cpp | as -o asm/cx86-elf.o
57
58# solaris
59asm/cx86-sol.o: asm/cx86unix.cpp
60 $(CC) -E -DSOL asm/cx86unix.cpp | sed 's/^#.*//' > asm/cx86-sol.s
61 as -o asm/cx86-sol.o asm/cx86-sol.s
62 rm -f asm/cx86-sol.s
63
64# a.out
65asm/cx86-out.o: asm/cx86unix.cpp
66 $(CPP) -DOUT asm/cx86unix.cpp | as -o asm/cx86-out.o
67
68# bsdi
69asm/cx86bsdi.o: asm/cx86unix.cpp
70 $(CPP) -DBSDI asm/cx86unix.cpp | sed 's/ :/:/' | as -o asm/cx86bsdi.o
71
72asm/cx86unix.cpp: asm/cast-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl
73 (cd asm; $(PERL) cast-586.pl cpp $(PROCESSOR) >cx86unix.cpp)
74
75files:
76 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
77
78links:
79 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
80 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
81 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
82 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
83
84install:
85 @for i in $(EXHEADER) ; \
86 do \
87 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
88 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
89 done;
90
91tags:
92 ctags $(SRC)
93
94tests:
95
96lint:
97 lint -DLINT $(INCLUDES) $(SRC)>fluff
98
99depend:
100 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC)
101
102dclean:
103 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
104 mv -f Makefile.new $(MAKEFILE)
105
106clean:
107 rm -f asm/cx86unix.cpp *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
108
109# DO NOT DELETE THIS LINE -- make depend depends on it.
110
111c_cfb64.o: ../../e_os.h ../../include/openssl/cast.h
112c_cfb64.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
113c_cfb64.o: c_cfb64.c cast_lcl.h
114c_ecb.o: ../../e_os.h ../../include/openssl/cast.h
115c_ecb.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
116c_ecb.o: ../../include/openssl/opensslv.h c_ecb.c cast_lcl.h
117c_enc.o: ../../e_os.h ../../include/openssl/cast.h
118c_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
119c_enc.o: c_enc.c cast_lcl.h
120c_ofb64.o: ../../e_os.h ../../include/openssl/cast.h
121c_ofb64.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
122c_ofb64.o: c_ofb64.c cast_lcl.h
123c_skey.o: ../../e_os.h ../../include/openssl/cast.h
124c_skey.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
125c_skey.o: c_skey.c cast_lcl.h cast_s.h
diff --git a/src/lib/libcrypto/cast/asm/readme b/src/lib/libcrypto/cast/asm/readme
new file mode 100644
index 0000000000..fbcd76289e
--- /dev/null
+++ b/src/lib/libcrypto/cast/asm/readme
@@ -0,0 +1,7 @@
1There is a ppro flag in cast-586 which turns on/off
2generation of pentium pro/II friendly code
3
4This flag makes the inner loop one cycle longer, but generates
5code that runs %30 faster on the pentium pro/II, while only %7 slower
6on the pentium. By default, this flag is on.
7
diff --git a/src/lib/libcrypto/cast/cast_spd.c b/src/lib/libcrypto/cast/cast_spd.c
new file mode 100644
index 0000000000..76abf50d98
--- /dev/null
+++ b/src/lib/libcrypto/cast/cast_spd.c
@@ -0,0 +1,275 @@
1/* crypto/cast/cast_spd.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/* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */
60/* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */
61
62#if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX)
63#define TIMES
64#endif
65
66#include <stdio.h>
67
68#include <openssl/e_os2.h>
69#include OPENSSL_UNISTD_IO
70OPENSSL_DECLARE_EXIT
71
72#include <signal.h>
73#ifndef _IRIX
74#include <time.h>
75#endif
76#ifdef TIMES
77#include <sys/types.h>
78#include <sys/times.h>
79#endif
80
81/* Depending on the VMS version, the tms structure is perhaps defined.
82 The __TMS macro will show if it was. If it wasn't defined, we should
83 undefine TIMES, since that tells the rest of the program how things
84 should be handled. -- Richard Levitte */
85#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
86#undef TIMES
87#endif
88
89#ifndef TIMES
90#include <sys/timeb.h>
91#endif
92
93#if defined(sun) || defined(__ultrix)
94#define _POSIX_SOURCE
95#include <limits.h>
96#include <sys/param.h>
97#endif
98
99#include <openssl/cast.h>
100
101/* The following if from times(3) man page. It may need to be changed */
102#ifndef HZ
103#ifndef CLK_TCK
104#define HZ 100.0
105#else /* CLK_TCK */
106#define HZ ((double)CLK_TCK)
107#endif
108#endif
109
110#define BUFSIZE ((long)1024)
111long run=0;
112
113double Time_F(int s);
114#ifdef SIGALRM
115#if defined(__STDC__) || defined(sgi) || defined(_AIX)
116#define SIGRETTYPE void
117#else
118#define SIGRETTYPE int
119#endif
120
121SIGRETTYPE sig_done(int sig);
122SIGRETTYPE sig_done(int sig)
123 {
124 signal(SIGALRM,sig_done);
125 run=0;
126#ifdef LINT
127 sig=sig;
128#endif
129 }
130#endif
131
132#define START 0
133#define STOP 1
134
135double Time_F(int s)
136 {
137 double ret;
138#ifdef TIMES
139 static struct tms tstart,tend;
140
141 if (s == START)
142 {
143 times(&tstart);
144 return(0);
145 }
146 else
147 {
148 times(&tend);
149 ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
150 return((ret == 0.0)?1e-6:ret);
151 }
152#else /* !times() */
153 static struct timeb tstart,tend;
154 long i;
155
156 if (s == START)
157 {
158 ftime(&tstart);
159 return(0);
160 }
161 else
162 {
163 ftime(&tend);
164 i=(long)tend.millitm-(long)tstart.millitm;
165 ret=((double)(tend.time-tstart.time))+((double)i)/1e3;
166 return((ret == 0.0)?1e-6:ret);
167 }
168#endif
169 }
170
171int main(int argc, char **argv)
172 {
173 long count;
174 static unsigned char buf[BUFSIZE];
175 static unsigned char key[] ={
176 0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
177 0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10,
178 };
179 CAST_KEY sch;
180 double a,b,c,d;
181#ifndef SIGALRM
182 long ca,cb,cc;
183#endif
184
185#ifndef TIMES
186 printf("To get the most accurate results, try to run this\n");
187 printf("program when this computer is idle.\n");
188#endif
189
190#ifndef SIGALRM
191 printf("First we calculate the approximate speed ...\n");
192 CAST_set_key(&sch,16,key);
193 count=10;
194 do {
195 long i;
196 CAST_LONG data[2];
197
198 count*=2;
199 Time_F(START);
200 for (i=count; i; i--)
201 CAST_encrypt(data,&sch);
202 d=Time_F(STOP);
203 } while (d < 3.0);
204 ca=count/512;
205 cb=count;
206 cc=count*8/BUFSIZE+1;
207 printf("Doing CAST_set_key %ld times\n",ca);
208#define COND(d) (count != (d))
209#define COUNT(d) (d)
210#else
211#define COND(c) (run)
212#define COUNT(d) (count)
213 signal(SIGALRM,sig_done);
214 printf("Doing CAST_set_key for 10 seconds\n");
215 alarm(10);
216#endif
217
218 Time_F(START);
219 for (count=0,run=1; COND(ca); count+=4)
220 {
221 CAST_set_key(&sch,16,key);
222 CAST_set_key(&sch,16,key);
223 CAST_set_key(&sch,16,key);
224 CAST_set_key(&sch,16,key);
225 }
226 d=Time_F(STOP);
227 printf("%ld cast set_key's in %.2f seconds\n",count,d);
228 a=((double)COUNT(ca))/d;
229
230#ifdef SIGALRM
231 printf("Doing CAST_encrypt's for 10 seconds\n");
232 alarm(10);
233#else
234 printf("Doing CAST_encrypt %ld times\n",cb);
235#endif
236 Time_F(START);
237 for (count=0,run=1; COND(cb); count+=4)
238 {
239 CAST_LONG data[2];
240
241 CAST_encrypt(data,&sch);
242 CAST_encrypt(data,&sch);
243 CAST_encrypt(data,&sch);
244 CAST_encrypt(data,&sch);
245 }
246 d=Time_F(STOP);
247 printf("%ld CAST_encrypt's in %.2f second\n",count,d);
248 b=((double)COUNT(cb)*8)/d;
249
250#ifdef SIGALRM
251 printf("Doing CAST_cbc_encrypt on %ld byte blocks for 10 seconds\n",
252 BUFSIZE);
253 alarm(10);
254#else
255 printf("Doing CAST_cbc_encrypt %ld times on %ld byte blocks\n",cc,
256 BUFSIZE);
257#endif
258 Time_F(START);
259 for (count=0,run=1; COND(cc); count++)
260 CAST_cbc_encrypt(buf,buf,BUFSIZE,&sch,
261 &(key[0]),CAST_ENCRYPT);
262 d=Time_F(STOP);
263 printf("%ld CAST_cbc_encrypt's of %ld byte blocks in %.2f second\n",
264 count,BUFSIZE,d);
265 c=((double)COUNT(cc)*BUFSIZE)/d;
266
267 printf("CAST set_key per sec = %12.2f (%9.3fuS)\n",a,1.0e6/a);
268 printf("CAST raw ecb bytes per sec = %12.2f (%9.3fuS)\n",b,8.0e6/b);
269 printf("CAST cbc bytes per sec = %12.2f (%9.3fuS)\n",c,8.0e6/c);
270 exit(0);
271#if defined(LINT) || defined(OPENSSL_SYS_MSDOS)
272 return(0);
273#endif
274 }
275
diff --git a/src/lib/libcrypto/cast/castopts.c b/src/lib/libcrypto/cast/castopts.c
new file mode 100644
index 0000000000..1b858d153b
--- /dev/null
+++ b/src/lib/libcrypto/cast/castopts.c
@@ -0,0 +1,339 @@
1/* crypto/cast/castopts.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/* define PART1, PART2, PART3 or PART4 to build only with a few of the options.
60 * This is for machines with 64k code segment size restrictions. */
61
62#if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC))
63#define TIMES
64#endif
65
66#include <stdio.h>
67
68#include <openssl/e_os2.h>
69#include OPENSSL_UNISTD_IO
70OPENSSL_DECLARE_EXIT
71
72#include <signal.h>
73#ifndef _IRIX
74#include <time.h>
75#endif
76#ifdef TIMES
77#include <sys/types.h>
78#include <sys/times.h>
79#endif
80
81/* Depending on the VMS version, the tms structure is perhaps defined.
82 The __TMS macro will show if it was. If it wasn't defined, we should
83 undefine TIMES, since that tells the rest of the program how things
84 should be handled. -- Richard Levitte */
85#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
86#undef TIMES
87#endif
88
89#ifndef TIMES
90#include <sys/timeb.h>
91#endif
92
93#if defined(sun) || defined(__ultrix)
94#define _POSIX_SOURCE
95#include <limits.h>
96#include <sys/param.h>
97#endif
98
99#include <openssl/cast.h>
100
101#define CAST_DEFAULT_OPTIONS
102
103#undef E_CAST
104#define CAST_encrypt CAST_encrypt_normal
105#define CAST_decrypt CAST_decrypt_normal
106#define CAST_cbc_encrypt CAST_cbc_encrypt_normal
107#undef HEADER_CAST_LOCL_H
108#include "c_enc.c"
109
110#define CAST_PTR
111#undef CAST_PTR2
112#undef E_CAST
113#undef CAST_encrypt
114#undef CAST_decrypt
115#undef CAST_cbc_encrypt
116#define CAST_encrypt CAST_encrypt_ptr
117#define CAST_decrypt CAST_decrypt_ptr
118#define CAST_cbc_encrypt CAST_cbc_encrypt_ptr
119#undef HEADER_CAST_LOCL_H
120#include "c_enc.c"
121
122#undef CAST_PTR
123#define CAST_PTR2
124#undef E_CAST
125#undef CAST_encrypt
126#undef CAST_decrypt
127#undef CAST_cbc_encrypt
128#define CAST_encrypt CAST_encrypt_ptr2
129#define CAST_decrypt CAST_decrypt_ptr2
130#define CAST_cbc_encrypt CAST_cbc_encrypt_ptr2
131#undef HEADER_CAST_LOCL_H
132#include "c_enc.c"
133
134/* The following if from times(3) man page. It may need to be changed */
135#ifndef HZ
136# ifndef CLK_TCK
137# ifndef _BSD_CLK_TCK_ /* FreeBSD fix */
138# define HZ 100.0
139# else /* _BSD_CLK_TCK_ */
140# define HZ ((double)_BSD_CLK_TCK_)
141# endif
142# else /* CLK_TCK */
143# define HZ ((double)CLK_TCK)
144# endif
145#endif
146
147#define BUFSIZE ((long)1024)
148long run=0;
149
150double Time_F(int s);
151#ifdef SIGALRM
152#if defined(__STDC__) || defined(sgi)
153#define SIGRETTYPE void
154#else
155#define SIGRETTYPE int
156#endif
157
158SIGRETTYPE sig_done(int sig);
159SIGRETTYPE sig_done(int sig)
160 {
161 signal(SIGALRM,sig_done);
162 run=0;
163#ifdef LINT
164 sig=sig;
165#endif
166 }
167#endif
168
169#define START 0
170#define STOP 1
171
172double Time_F(int s)
173 {
174 double ret;
175#ifdef TIMES
176 static struct tms tstart,tend;
177
178 if (s == START)
179 {
180 times(&tstart);
181 return(0);
182 }
183 else
184 {
185 times(&tend);
186 ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
187 return((ret == 0.0)?1e-6:ret);
188 }
189#else /* !times() */
190 static struct timeb tstart,tend;
191 long i;
192
193 if (s == START)
194 {
195 ftime(&tstart);
196 return(0);
197 }
198 else
199 {
200 ftime(&tend);
201 i=(long)tend.millitm-(long)tstart.millitm;
202 ret=((double)(tend.time-tstart.time))+((double)i)/1000.0;
203 return((ret == 0.0)?1e-6:ret);
204 }
205#endif
206 }
207
208#ifdef SIGALRM
209#define print_name(name) fprintf(stderr,"Doing %s's for 10 seconds\n",name); alarm(10);
210#else
211#define print_name(name) fprintf(stderr,"Doing %s %ld times\n",name,cb);
212#endif
213
214#define time_it(func,name,index) \
215 print_name(name); \
216 Time_F(START); \
217 for (count=0,run=1; COND(cb); count+=4) \
218 { \
219 unsigned long d[2]; \
220 func(d,&sch); \
221 func(d,&sch); \
222 func(d,&sch); \
223 func(d,&sch); \
224 } \
225 tm[index]=Time_F(STOP); \
226 fprintf(stderr,"%ld %s's in %.2f second\n",count,name,tm[index]); \
227 tm[index]=((double)COUNT(cb))/tm[index];
228
229#define print_it(name,index) \
230 fprintf(stderr,"%s bytes per sec = %12.2f (%5.1fuS)\n",name, \
231 tm[index]*8,1.0e6/tm[index]);
232
233int main(int argc, char **argv)
234 {
235 long count;
236 static unsigned char buf[BUFSIZE];
237 static char key[16]={ 0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
238 0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0};
239 CAST_KEY sch;
240 double d,tm[16],max=0;
241 int rank[16];
242 char *str[16];
243 int max_idx=0,i,num=0,j;
244#ifndef SIGALARM
245 long ca,cb,cc,cd,ce;
246#endif
247
248 for (i=0; i<12; i++)
249 {
250 tm[i]=0.0;
251 rank[i]=0;
252 }
253
254#ifndef TIMES
255 fprintf(stderr,"To get the most accurate results, try to run this\n");
256 fprintf(stderr,"program when this computer is idle.\n");
257#endif
258
259 CAST_set_key(&sch,16,key);
260
261#ifndef SIGALRM
262 fprintf(stderr,"First we calculate the approximate speed ...\n");
263 count=10;
264 do {
265 long i;
266 unsigned long data[2];
267
268 count*=2;
269 Time_F(START);
270 for (i=count; i; i--)
271 CAST_encrypt(data,&sch);
272 d=Time_F(STOP);
273 } while (d < 3.0);
274 ca=count;
275 cb=count*3;
276 cc=count*3*8/BUFSIZE+1;
277 cd=count*8/BUFSIZE+1;
278
279 ce=count/20+1;
280#define COND(d) (count != (d))
281#define COUNT(d) (d)
282#else
283#define COND(c) (run)
284#define COUNT(d) (count)
285 signal(SIGALRM,sig_done);
286 alarm(10);
287#endif
288
289 time_it(CAST_encrypt_normal, "CAST_encrypt_normal ", 0);
290 time_it(CAST_encrypt_ptr, "CAST_encrypt_ptr ", 1);
291 time_it(CAST_encrypt_ptr2, "CAST_encrypt_ptr2 ", 2);
292 num+=3;
293
294 str[0]="<nothing>";
295 print_it("CAST_encrypt_normal ",0);
296 max=tm[0];
297 max_idx=0;
298 str[1]="ptr ";
299 print_it("CAST_encrypt_ptr ",1);
300 if (max < tm[1]) { max=tm[1]; max_idx=1; }
301 str[2]="ptr2 ";
302 print_it("CAST_encrypt_ptr2 ",2);
303 if (max < tm[2]) { max=tm[2]; max_idx=2; }
304
305 printf("options CAST ecb/s\n");
306 printf("%s %12.2f 100.0%%\n",str[max_idx],tm[max_idx]);
307 d=tm[max_idx];
308 tm[max_idx]= -2.0;
309 max= -1.0;
310 for (;;)
311 {
312 for (i=0; i<3; i++)
313 {
314 if (max < tm[i]) { max=tm[i]; j=i; }
315 }
316 if (max < 0.0) break;
317 printf("%s %12.2f %4.1f%%\n",str[j],tm[j],tm[j]/d*100.0);
318 tm[j]= -2.0;
319 max= -1.0;
320 }
321
322 switch (max_idx)
323 {
324 case 0:
325 printf("-DCAST_DEFAULT_OPTIONS\n");
326 break;
327 case 1:
328 printf("-DCAST_PTR\n");
329 break;
330 case 2:
331 printf("-DCAST_PTR2\n");
332 break;
333 }
334 exit(0);
335#if defined(LINT) || defined(OPENSSL_SYS_MSDOS)
336 return(0);
337#endif
338 }
339
diff --git a/src/lib/libcrypto/cast/casts.cpp b/src/lib/libcrypto/cast/casts.cpp
new file mode 100644
index 0000000000..8d7bd468d2
--- /dev/null
+++ b/src/lib/libcrypto/cast/casts.cpp
@@ -0,0 +1,70 @@
1//
2// gettsc.inl
3//
4// gives access to the Pentium's (secret) cycle counter
5//
6// This software was written by Leonard Janke (janke@unixg.ubc.ca)
7// in 1996-7 and is entered, by him, into the public domain.
8
9#if defined(__WATCOMC__)
10void GetTSC(unsigned long&);
11#pragma aux GetTSC = 0x0f 0x31 "mov [edi], eax" parm [edi] modify [edx eax];
12#elif defined(__GNUC__)
13inline
14void GetTSC(unsigned long& tsc)
15{
16 asm volatile(".byte 15, 49\n\t"
17 : "=eax" (tsc)
18 :
19 : "%edx", "%eax");
20}
21#elif defined(_MSC_VER)
22inline
23void GetTSC(unsigned long& tsc)
24{
25 unsigned long a;
26 __asm _emit 0fh
27 __asm _emit 31h
28 __asm mov a, eax;
29 tsc=a;
30}
31#endif
32
33#include <stdio.h>
34#include <stdlib.h>
35#include <openssl/cast.h>
36
37void main(int argc,char *argv[])
38 {
39 CAST_KEY key;
40 unsigned long s1,s2,e1,e2;
41 unsigned long data[2];
42 int i,j;
43 static unsigned char d[16]={0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF};
44
45 CAST_set_key(&key, 16,d);
46
47 for (j=0; j<6; j++)
48 {
49 for (i=0; i<1000; i++) /**/
50 {
51 CAST_encrypt(&data[0],&key);
52 GetTSC(s1);
53 CAST_encrypt(&data[0],&key);
54 CAST_encrypt(&data[0],&key);
55 CAST_encrypt(&data[0],&key);
56 GetTSC(e1);
57 GetTSC(s2);
58 CAST_encrypt(&data[0],&key);
59 CAST_encrypt(&data[0],&key);
60 CAST_encrypt(&data[0],&key);
61 CAST_encrypt(&data[0],&key);
62 GetTSC(e2);
63 CAST_encrypt(&data[0],&key);
64 }
65
66 printf("cast %d %d (%d)\n",
67 e1-s1,e2-s2,((e2-s2)-(e1-s1)));
68 }
69 }
70
diff --git a/src/lib/libcrypto/cast/casttest.c b/src/lib/libcrypto/cast/casttest.c
new file mode 100644
index 0000000000..099e790886
--- /dev/null
+++ b/src/lib/libcrypto/cast/casttest.c
@@ -0,0 +1,230 @@
1/* crypto/cast/casttest.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 <stdlib.h>
62
63#ifdef OPENSSL_NO_CAST
64int main(int argc, char *argv[])
65{
66 printf("No CAST support\n");
67 return(0);
68}
69#else
70#include <openssl/cast.h>
71
72#define FULL_TEST
73
74static unsigned char k[16]={
75 0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78,
76 0x23,0x45,0x67,0x89,0x34,0x56,0x78,0x9A
77 };
78
79static unsigned char in[8]={ 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF};
80
81static int k_len[3]={16,10,5};
82static unsigned char c[3][8]={
83 {0x23,0x8B,0x4F,0xE5,0x84,0x7E,0x44,0xB2},
84 {0xEB,0x6A,0x71,0x1A,0x2C,0x02,0x27,0x1B},
85 {0x7A,0xC8,0x16,0xD1,0x6E,0x9B,0x30,0x2E},
86 };
87static unsigned char out[80];
88
89static unsigned char in_a[16]={
90 0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78,
91 0x23,0x45,0x67,0x89,0x34,0x56,0x78,0x9A};
92static unsigned char in_b[16]={
93 0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78,
94 0x23,0x45,0x67,0x89,0x34,0x56,0x78,0x9A};
95
96static unsigned char c_a[16]={
97 0xEE,0xA9,0xD0,0xA2,0x49,0xFD,0x3B,0xA6,
98 0xB3,0x43,0x6F,0xB8,0x9D,0x6D,0xCA,0x92};
99static unsigned char c_b[16]={
100 0xB2,0xC9,0x5E,0xB0,0x0C,0x31,0xAD,0x71,
101 0x80,0xAC,0x05,0xB8,0xE8,0x3D,0x69,0x6E};
102
103#if 0
104char *text="Hello to all people out there";
105
106static unsigned char cfb_key[16]={
107 0xe1,0xf0,0xc3,0xd2,0xa5,0xb4,0x87,0x96,
108 0x69,0x78,0x4b,0x5a,0x2d,0x3c,0x0f,0x1e,
109 };
110static unsigned char cfb_iv[80]={0x34,0x12,0x78,0x56,0xab,0x90,0xef,0xcd};
111static unsigned char cfb_buf1[40],cfb_buf2[40],cfb_tmp[8];
112#define CFB_TEST_SIZE 24
113static unsigned char plain[CFB_TEST_SIZE]=
114 {
115 0x4e,0x6f,0x77,0x20,0x69,0x73,
116 0x20,0x74,0x68,0x65,0x20,0x74,
117 0x69,0x6d,0x65,0x20,0x66,0x6f,
118 0x72,0x20,0x61,0x6c,0x6c,0x20
119 };
120static unsigned char cfb_cipher64[CFB_TEST_SIZE]={
121 0x59,0xD8,0xE2,0x65,0x00,0x58,0x6C,0x3F,
122 0x2C,0x17,0x25,0xD0,0x1A,0x38,0xB7,0x2A,
123 0x39,0x61,0x37,0xDC,0x79,0xFB,0x9F,0x45
124
125/* 0xF9,0x78,0x32,0xB5,0x42,0x1A,0x6B,0x38,
126 0x9A,0x44,0xD6,0x04,0x19,0x43,0xC4,0xD9,
127 0x3D,0x1E,0xAE,0x47,0xFC,0xCF,0x29,0x0B,*/
128 };
129#endif
130
131int main(int argc, char *argv[])
132 {
133#ifdef FULL_TEST
134 long l;
135 CAST_KEY key_b;
136#endif
137 int i,z,err=0;
138 CAST_KEY key;
139
140 for (z=0; z<3; z++)
141 {
142 CAST_set_key(&key,k_len[z],k);
143
144 CAST_ecb_encrypt(in,out,&key,CAST_ENCRYPT);
145 if (memcmp(out,&(c[z][0]),8) != 0)
146 {
147 printf("ecb cast error encrypting for keysize %d\n",k_len[z]*8);
148 printf("got :");
149 for (i=0; i<8; i++)
150 printf("%02X ",out[i]);
151 printf("\n");
152 printf("expected:");
153 for (i=0; i<8; i++)
154 printf("%02X ",c[z][i]);
155 err=20;
156 printf("\n");
157 }
158
159 CAST_ecb_encrypt(out,out,&key,CAST_DECRYPT);
160 if (memcmp(out,in,8) != 0)
161 {
162 printf("ecb cast error decrypting for keysize %d\n",k_len[z]*8);
163 printf("got :");
164 for (i=0; i<8; i++)
165 printf("%02X ",out[i]);
166 printf("\n");
167 printf("expected:");
168 for (i=0; i<8; i++)
169 printf("%02X ",in[i]);
170 printf("\n");
171 err=3;
172 }
173 }
174 if (err == 0)
175 printf("ecb cast5 ok\n");
176
177#ifdef FULL_TEST
178 {
179 unsigned char out_a[16],out_b[16];
180 static char *hex="0123456789ABCDEF";
181
182 printf("This test will take some time....");
183 fflush(stdout);
184 memcpy(out_a,in_a,sizeof(in_a));
185 memcpy(out_b,in_b,sizeof(in_b));
186 i=1;
187
188 for (l=0; l<1000000L; l++)
189 {
190 CAST_set_key(&key_b,16,out_b);
191 CAST_ecb_encrypt(&(out_a[0]),&(out_a[0]),&key_b,CAST_ENCRYPT);
192 CAST_ecb_encrypt(&(out_a[8]),&(out_a[8]),&key_b,CAST_ENCRYPT);
193 CAST_set_key(&key,16,out_a);
194 CAST_ecb_encrypt(&(out_b[0]),&(out_b[0]),&key,CAST_ENCRYPT);
195 CAST_ecb_encrypt(&(out_b[8]),&(out_b[8]),&key,CAST_ENCRYPT);
196 if ((l & 0xffff) == 0xffff)
197 {
198 printf("%c",hex[i&0x0f]);
199 fflush(stdout);
200 i++;
201 }
202 }
203
204 if ( (memcmp(out_a,c_a,sizeof(c_a)) != 0) ||
205 (memcmp(out_b,c_b,sizeof(c_b)) != 0))
206 {
207 printf("\n");
208 printf("Error\n");
209
210 printf("A out =");
211 for (i=0; i<16; i++) printf("%02X ",out_a[i]);
212 printf("\nactual=");
213 for (i=0; i<16; i++) printf("%02X ",c_a[i]);
214 printf("\n");
215
216 printf("B out =");
217 for (i=0; i<16; i++) printf("%02X ",out_b[i]);
218 printf("\nactual=");
219 for (i=0; i<16; i++) printf("%02X ",c_b[i]);
220 printf("\n");
221 }
222 else
223 printf(" ok\n");
224 }
225#endif
226
227 exit(err);
228 return(err);
229 }
230#endif
diff --git a/src/lib/libcrypto/comp/Makefile.ssl b/src/lib/libcrypto/comp/Makefile.ssl
new file mode 100644
index 0000000000..7c1ec81229
--- /dev/null
+++ b/src/lib/libcrypto/comp/Makefile.ssl
@@ -0,0 +1,114 @@
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 8c0876151a..cd2f8a491b 100644
--- a/src/lib/libcrypto/comp/c_zlib.c
+++ b/src/lib/libcrypto/comp/c_zlib.c
@@ -208,11 +208,11 @@ COMP_METHOD *COMP_zlib(void)
208 = (inflateInit__ft) DSO_bind_func(zlib_dso, 208 = (inflateInit__ft) DSO_bind_func(zlib_dso,
209 "inflateInit_"); 209 "inflateInit_");
210 zlib_loaded++; 210 zlib_loaded++;
211 meth = &zlib_method;
211 } 212 }
212 } 213 }
213 214
214#endif 215#elif defined(ZLIB)
215#if defined(ZLIB) || defined(ZLIB_SHARED)
216 meth = &zlib_method; 216 meth = &zlib_method;
217#endif 217#endif
218 218
diff --git a/src/lib/libcrypto/conf/Makefile.ssl b/src/lib/libcrypto/conf/Makefile.ssl
new file mode 100644
index 0000000000..133c2329e6
--- /dev/null
+++ b/src/lib/libcrypto/conf/Makefile.ssl
@@ -0,0 +1,183 @@
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/cnf_save.c b/src/lib/libcrypto/conf/cnf_save.c
new file mode 100644
index 0000000000..1439487526
--- /dev/null
+++ b/src/lib/libcrypto/conf/cnf_save.c
@@ -0,0 +1,106 @@
1/* crypto/conf/cnf_save.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/conf.h>
61
62static void print_conf(CONF_VALUE *cv);
63static IMPLEMENT_LHASH_DOALL_FN(print_conf, CONF_VALUE *);
64
65main()
66 {
67 LHASH *conf;
68 long l;
69
70 conf=CONF_load(NULL,"../../apps/openssl.cnf",&l);
71 if (conf == NULL)
72 {
73 fprintf(stderr,"error loading config, line %ld\n",l);
74 exit(1);
75 }
76
77 lh_doall(conf,LHASH_DOALL_FN(print_conf));
78 }
79
80
81static void print_conf(CONF_VALUE *cv)
82 {
83 int i;
84 CONF_VALUE *v;
85 char *section;
86 char *name;
87 char *value;
88 STACK *s;
89
90 /* If it is a single entry, return */
91
92 if (cv->name != NULL) return;
93
94 printf("[ %s ]\n",cv->section);
95 s=(STACK *)cv->value;
96
97 for (i=0; i<sk_num(s); i++)
98 {
99 v=(CONF_VALUE *)sk_value(s,i);
100 section=(v->section == NULL)?"None":v->section;
101 name=(v->name == NULL)?"None":v->name;
102 value=(v->value == NULL)?"None":v->value;
103 printf("%s=%s\n",name,value);
104 }
105 printf("\n");
106 }
diff --git a/src/lib/libcrypto/conf/conf_def.c b/src/lib/libcrypto/conf/conf_def.c
index 57d2739ae0..48ff6f1120 100644
--- a/src/lib/libcrypto/conf/conf_def.c
+++ b/src/lib/libcrypto/conf/conf_def.c
@@ -208,8 +208,7 @@ static int def_load(CONF *conf, const char *name, long *line)
208 208
209static int def_load_bio(CONF *conf, BIO *in, long *line) 209static int def_load_bio(CONF *conf, BIO *in, long *line)
210 { 210 {
211/* The macro BUFSIZE conflicts with a system macro in VxWorks */ 211#define BUFSIZE 512
212#define CONFBUFSIZE 512
213 int bufnum=0,i,ii; 212 int bufnum=0,i,ii;
214 BUF_MEM *buff=NULL; 213 BUF_MEM *buff=NULL;
215 char *s,*p,*end; 214 char *s,*p,*end;
@@ -235,7 +234,7 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
235 CONFerr(CONF_F_CONF_LOAD_BIO,ERR_R_MALLOC_FAILURE); 234 CONFerr(CONF_F_CONF_LOAD_BIO,ERR_R_MALLOC_FAILURE);
236 goto err; 235 goto err;
237 } 236 }
238 strcpy(section,"default"); 237 strlcpy(section,"default",10);
239 238
240 if (_CONF_new_data(conf) == 0) 239 if (_CONF_new_data(conf) == 0)
241 { 240 {
@@ -253,21 +252,20 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
253 section_sk=(STACK_OF(CONF_VALUE) *)sv->value; 252 section_sk=(STACK_OF(CONF_VALUE) *)sv->value;
254 253
255 bufnum=0; 254 bufnum=0;
256 again=0;
257 for (;;) 255 for (;;)
258 { 256 {
259 if (!BUF_MEM_grow(buff,bufnum+CONFBUFSIZE)) 257 again=0;
258 if (!BUF_MEM_grow(buff,bufnum+BUFSIZE))
260 { 259 {
261 CONFerr(CONF_F_CONF_LOAD_BIO,ERR_R_BUF_LIB); 260 CONFerr(CONF_F_CONF_LOAD_BIO,ERR_R_BUF_LIB);
262 goto err; 261 goto err;
263 } 262 }
264 p= &(buff->data[bufnum]); 263 p= &(buff->data[bufnum]);
265 *p='\0'; 264 *p='\0';
266 BIO_gets(in, p, CONFBUFSIZE-1); 265 BIO_gets(in, p, BUFSIZE-1);
267 p[CONFBUFSIZE-1]='\0'; 266 p[BUFSIZE-1]='\0';
268 ii=i=strlen(p); 267 ii=i=strlen(p);
269 if (i == 0 && !again) break; 268 if (i == 0) break;
270 again=0;
271 while (i > 0) 269 while (i > 0)
272 { 270 {
273 if ((p[i-1] != '\r') && (p[i-1] != '\n')) 271 if ((p[i-1] != '\r') && (p[i-1] != '\n'))
@@ -277,7 +275,7 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
277 } 275 }
278 /* we removed some trailing stuff so there is a new 276 /* we removed some trailing stuff so there is a new
279 * line on the end. */ 277 * line on the end. */
280 if (ii && i == ii) 278 if (i == ii)
281 again=1; /* long line */ 279 again=1; /* long line */
282 else 280 else
283 { 281 {
@@ -392,7 +390,7 @@ again:
392 ERR_R_MALLOC_FAILURE); 390 ERR_R_MALLOC_FAILURE);
393 goto err; 391 goto err;
394 } 392 }
395 strcpy(v->name,pname); 393 strlcpy(v->name,pname,strlen(pname)+1);
396 if (!str_copy(conf,psection,&(v->value),start)) goto err; 394 if (!str_copy(conf,psection,&(v->value),start)) goto err;
397 395
398 if (strcmp(psection,section) != 0) 396 if (strcmp(psection,section) != 0)
@@ -447,7 +445,7 @@ err:
447 if (buff != NULL) BUF_MEM_free(buff); 445 if (buff != NULL) BUF_MEM_free(buff);
448 if (section != NULL) OPENSSL_free(section); 446 if (section != NULL) OPENSSL_free(section);
449 if (line != NULL) *line=eline; 447 if (line != NULL) *line=eline;
450 sprintf(btmp,"%ld",eline); 448 snprintf(btmp,sizeof btmp,"%ld",eline);
451 ERR_add_error_data(2,"line ",btmp); 449 ERR_add_error_data(2,"line ",btmp);
452 if ((h != conf->data) && (conf->data != NULL)) 450 if ((h != conf->data) && (conf->data != NULL))
453 { 451 {
@@ -629,7 +627,7 @@ static int str_copy(CONF *conf, char *section, char **pto, char *from)
629 CONFerr(CONF_F_STR_COPY,CONF_R_VARIABLE_HAS_NO_VALUE); 627 CONFerr(CONF_F_STR_COPY,CONF_R_VARIABLE_HAS_NO_VALUE);
630 goto err; 628 goto err;
631 } 629 }
632 BUF_MEM_grow_clean(buf,(strlen(p)+len-(e-from))); 630 BUF_MEM_grow(buf,(strlen(p)+len-(e-from)));
633 while (*p) 631 while (*p)
634 buf->data[to++]= *(p++); 632 buf->data[to++]= *(p++);
635 from=e; 633 from=e;
diff --git a/src/lib/libcrypto/conf/conf_mall.c b/src/lib/libcrypto/conf/conf_mall.c
index 4ba40cf44c..d702af689b 100644
--- a/src/lib/libcrypto/conf/conf_mall.c
+++ b/src/lib/libcrypto/conf/conf_mall.c
@@ -63,9 +63,7 @@
63#include <openssl/dso.h> 63#include <openssl/dso.h>
64#include <openssl/x509.h> 64#include <openssl/x509.h>
65#include <openssl/asn1.h> 65#include <openssl/asn1.h>
66#ifndef OPENSSL_NO_ENGINE
67#include <openssl/engine.h> 66#include <openssl/engine.h>
68#endif
69 67
70/* Load all OpenSSL builtin modules */ 68/* Load all OpenSSL builtin modules */
71 69
@@ -73,8 +71,6 @@ void OPENSSL_load_builtin_modules(void)
73 { 71 {
74 /* Add builtin modules here */ 72 /* Add builtin modules here */
75 ASN1_add_oid_module(); 73 ASN1_add_oid_module();
76#ifndef OPENSSL_NO_ENGINE
77 ENGINE_add_conf_module(); 74 ENGINE_add_conf_module();
78#endif
79 } 75 }
80 76
diff --git a/src/lib/libcrypto/conf/conf_mod.c b/src/lib/libcrypto/conf/conf_mod.c
index edcc08921c..5a747e8c84 100644
--- a/src/lib/libcrypto/conf/conf_mod.c
+++ b/src/lib/libcrypto/conf/conf_mod.c
@@ -232,7 +232,7 @@ static int module_run(const CONF *cnf, char *name, char *value,
232 { 232 {
233 char rcode[DECIMAL_SIZE(ret)+1]; 233 char rcode[DECIMAL_SIZE(ret)+1];
234 CONFerr(CONF_F_CONF_MODULES_LOAD, CONF_R_MODULE_INITIALIZATION_ERROR); 234 CONFerr(CONF_F_CONF_MODULES_LOAD, CONF_R_MODULE_INITIALIZATION_ERROR);
235 sprintf(rcode, "%-8d", ret); 235 snprintf(rcode, sizeof rcode, "%-8d", ret);
236 ERR_add_error_data(6, "module=", name, ", value=", value, ", retcode=", rcode); 236 ERR_add_error_data(6, "module=", name, ", value=", value, ", retcode=", rcode);
237 } 237 }
238 } 238 }
@@ -561,11 +561,11 @@ char *CONF_get1_default_config_file(void)
561 561
562 if (!file) 562 if (!file)
563 return NULL; 563 return NULL;
564 strcpy(file,X509_get_default_cert_area()); 564 strlcpy(file,X509_get_default_cert_area(),len + 1);
565#ifndef OPENSSL_SYS_VMS 565#ifndef OPENSSL_SYS_VMS
566 strcat(file,"/"); 566 strlcat(file,"/",len + 1);
567#endif 567#endif
568 strcat(file,OPENSSL_CONF); 568 strlcat(file,OPENSSL_CONF,len + 1);
569 569
570 return file; 570 return file;
571 } 571 }
diff --git a/src/lib/libcrypto/conf/conf_sap.c b/src/lib/libcrypto/conf/conf_sap.c
index e15c2e5546..97fb174303 100644
--- a/src/lib/libcrypto/conf/conf_sap.c
+++ b/src/lib/libcrypto/conf/conf_sap.c
@@ -63,9 +63,7 @@
63#include <openssl/dso.h> 63#include <openssl/dso.h>
64#include <openssl/x509.h> 64#include <openssl/x509.h>
65#include <openssl/asn1.h> 65#include <openssl/asn1.h>
66#ifndef OPENSSL_NO_ENGINE
67#include <openssl/engine.h> 66#include <openssl/engine.h>
68#endif
69 67
70/* This is the automatic configuration loader: it is called automatically by 68/* This is the automatic configuration loader: it is called automatically by
71 * OpenSSL when any of a number of standard initialisation functions are called, 69 * OpenSSL when any of a number of standard initialisation functions are called,
@@ -80,10 +78,8 @@ void OPENSSL_config(const char *config_name)
80 return; 78 return;
81 79
82 OPENSSL_load_builtin_modules(); 80 OPENSSL_load_builtin_modules();
83#ifndef OPENSSL_NO_ENGINE
84 /* Need to load ENGINEs */ 81 /* Need to load ENGINEs */
85 ENGINE_load_builtin_engines(); 82 ENGINE_load_builtin_engines();
86#endif
87 /* Add others here? */ 83 /* Add others here? */
88 84
89 85
diff --git a/src/lib/libcrypto/conf/test.c b/src/lib/libcrypto/conf/test.c
new file mode 100644
index 0000000000..7fab85053e
--- /dev/null
+++ b/src/lib/libcrypto/conf/test.c
@@ -0,0 +1,98 @@
1/* crypto/conf/test.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <stdlib.h>
61#include <openssl/conf.h>
62#include <openssl/err.h>
63
64main()
65 {
66 LHASH *conf;
67 long eline;
68 char *s,*s2;
69
70#ifdef USE_WIN32
71 CONF_set_default_method(CONF_WIN32);
72#endif
73 conf=CONF_load(NULL,"ssleay.cnf",&eline);
74 if (conf == NULL)
75 {
76 ERR_load_crypto_strings();
77 printf("unable to load configuration, line %ld\n",eline);
78 ERR_print_errors_fp(stderr);
79 exit(1);
80 }
81 lh_stats(conf,stdout);
82 lh_node_stats(conf,stdout);
83 lh_node_usage_stats(conf,stdout);
84
85 s=CONF_get_string(conf,NULL,"init2");
86 printf("init2=%s\n",(s == NULL)?"NULL":s);
87
88 s=CONF_get_string(conf,NULL,"cipher1");
89 printf("cipher1=%s\n",(s == NULL)?"NULL":s);
90
91 s=CONF_get_string(conf,"s_client","cipher1");
92 printf("s_client:cipher1=%s\n",(s == NULL)?"NULL":s);
93
94 printf("---------------------------- DUMP ------------------------\n");
95 CONF_dump_fp(conf, stdout);
96
97 exit(0);
98 }
diff --git a/src/lib/libcrypto/cryptlib.c b/src/lib/libcrypto/cryptlib.c
index 2924def2bb..612b3b93b4 100644
--- a/src/lib/libcrypto/cryptlib.c
+++ b/src/lib/libcrypto/cryptlib.c
@@ -89,7 +89,6 @@ static const char* lock_names[CRYPTO_NUM_LOCKS] =
89 "ssl_session", 89 "ssl_session",
90 "ssl_sess_cert", 90 "ssl_sess_cert",
91 "ssl", 91 "ssl",
92 "ssl_method",
93 "rand", 92 "rand",
94 "rand2", 93 "rand2",
95 "debug_malloc", 94 "debug_malloc",
@@ -104,8 +103,7 @@ static const char* lock_names[CRYPTO_NUM_LOCKS] =
104 "dynlock", 103 "dynlock",
105 "engine", 104 "engine",
106 "ui", 105 "ui",
107 "hwcrhk", /* This is a HACK which will disappear in 0.9.8 */ 106#if CRYPTO_NUM_LOCKS != 31
108#if CRYPTO_NUM_LOCKS != 33
109# error "Inconsistency between crypto.h and cryptlib.c" 107# error "Inconsistency between crypto.h and cryptlib.c"
110#endif 108#endif
111 }; 109 };
@@ -208,18 +206,10 @@ int CRYPTO_get_new_dynlockid(void)
208 i=sk_CRYPTO_dynlock_find(dyn_locks,NULL); 206 i=sk_CRYPTO_dynlock_find(dyn_locks,NULL);
209 /* If there was none, push, thereby creating a new one */ 207 /* If there was none, push, thereby creating a new one */
210 if (i == -1) 208 if (i == -1)
211 /* Since sk_push() returns the number of items on the 209 i=sk_CRYPTO_dynlock_push(dyn_locks,pointer);
212 stack, not the location of the pushed item, we need
213 to transform the returned number into a position,
214 by decreasing it. */
215 i=sk_CRYPTO_dynlock_push(dyn_locks,pointer) - 1;
216 else
217 /* If we found a place with a NULL pointer, put our pointer
218 in it. */
219 sk_CRYPTO_dynlock_set(dyn_locks,i,pointer);
220 CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK); 210 CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
221 211
222 if (i == -1) 212 if (!i)
223 { 213 {
224 dynlock_destroy_callback(pointer->data,__FILE__,__LINE__); 214 dynlock_destroy_callback(pointer->data,__FILE__,__LINE__);
225 OPENSSL_free(pointer); 215 OPENSSL_free(pointer);
@@ -411,17 +401,15 @@ void CRYPTO_lock(int mode, int type, const char *file, int line)
411#endif 401#endif
412 if (type < 0) 402 if (type < 0)
413 { 403 {
414 if (dynlock_lock_callback != NULL) 404 struct CRYPTO_dynlock_value *pointer
415 { 405 = CRYPTO_get_dynlock_value(type);
416 struct CRYPTO_dynlock_value *pointer
417 = CRYPTO_get_dynlock_value(type);
418
419 OPENSSL_assert(pointer != NULL);
420 406
407 if (pointer && dynlock_lock_callback)
408 {
421 dynlock_lock_callback(mode, pointer, file, line); 409 dynlock_lock_callback(mode, pointer, file, line);
422
423 CRYPTO_destroy_dynlockid(type);
424 } 410 }
411
412 CRYPTO_destroy_dynlockid(type);
425 } 413 }
426 else 414 else
427 if (locking_callback != NULL) 415 if (locking_callback != NULL)
@@ -472,7 +460,7 @@ const char *CRYPTO_get_lock_name(int type)
472 return("dynamic"); 460 return("dynamic");
473 else if (type < CRYPTO_NUM_LOCKS) 461 else if (type < CRYPTO_NUM_LOCKS)
474 return(lock_names[type]); 462 return(lock_names[type]);
475 else if (type-CRYPTO_NUM_LOCKS > sk_num(app_locks)) 463 else if (type-CRYPTO_NUM_LOCKS >= sk_num(app_locks))
476 return("ERROR"); 464 return("ERROR");
477 else 465 else
478 return(sk_value(app_locks,type-CRYPTO_NUM_LOCKS)); 466 return(sk_value(app_locks,type-CRYPTO_NUM_LOCKS));
@@ -504,11 +492,3 @@ BOOL WINAPI DLLEntryPoint(HINSTANCE hinstDLL, DWORD fdwReason,
504#endif 492#endif
505 493
506#endif 494#endif
507
508void OpenSSLDie(const char *file,int line,const char *assertion)
509 {
510 fprintf(stderr,
511 "%s(%d): OpenSSL internal error, assertion failed: %s\n",
512 file,line,assertion);
513 abort();
514 }
diff --git a/src/lib/libcrypto/cryptlib.h b/src/lib/libcrypto/cryptlib.h
index 0d6b9d59f0..88e4ae509f 100644
--- a/src/lib/libcrypto/cryptlib.h
+++ b/src/lib/libcrypto/cryptlib.h
@@ -89,9 +89,9 @@ extern "C" {
89#define X509_CERT_DIR_EVP "SSL_CERT_DIR" 89#define X509_CERT_DIR_EVP "SSL_CERT_DIR"
90#define X509_CERT_FILE_EVP "SSL_CERT_FILE" 90#define X509_CERT_FILE_EVP "SSL_CERT_FILE"
91 91
92/* size of string representations */ 92/* size of string represenations */
93#define DECIMAL_SIZE(type) ((sizeof(type)*8+2)/3+1) 93#define DECIMAL_SIZE(type) ((sizeof(type)*8+2)/3+1)
94#define HEX_SIZE(type) (sizeof(type)*2) 94#define HEX_SIZE(type) ((sizeof(type)*2)
95 95
96#ifdef __cplusplus 96#ifdef __cplusplus
97} 97}
diff --git a/src/lib/libcrypto/crypto-lib.com b/src/lib/libcrypto/crypto-lib.com
new file mode 100644
index 0000000000..dfcff11860
--- /dev/null
+++ b/src/lib/libcrypto/crypto-lib.com
@@ -0,0 +1,1512 @@
1$!
2$! CRYPTO-LIB.COM
3$! Written By: Robert Byer
4$! Vice-President
5$! A-Com Computing, Inc.
6$! byer@mail.all-net.net
7$!
8$! Changes by Richard Levitte <richard@levitte.org>
9$!
10$! 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$! or VAX.
13$!
14$! 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$!
17$! Specify the following as P1 to build just that part or ALL to just
18$! build everything.
19$!
20$! LIBRARY To just compile the [.xxx.EXE.CRYPTO]LIBCRYPTO.OLB Library.
21$! APPS To just compile the [.xxx.EXE.CRYPTO]*.EXE
22$! ALL To do both LIBRARY and APPS
23$!
24$! Specify RSAREF as P2 to compile with the RSAREF library instead of
25$! the regular one. If you specify NORSAREF it will compile with the
26$! regular RSAREF routines. (Note: If you are in the United States
27$! you MUST compile with RSAREF unless you have a license from RSA).
28$!
29$! Note: The RSAREF libraries are NOT INCLUDED and you have to
30$! download it from "ftp://ftp.rsa.com/rsaref". You have to
31$! get the ".tar-Z" file as the ".zip" file dosen't have the
32$! directory structure stored. You have to extract the file
33$! into the [.RSAREF] directory under the root directory as that
34$! is where the scripts will look for the files.
35$!
36$! Specify DEBUG or NODEBUG as P3 to compile with or without debugger
37$! information.
38$!
39$! Specify which compiler at P4 to try to compile under.
40$!
41$! VAXC For VAX C.
42$! DECC For DEC C.
43$! GNUC For GNU C.
44$!
45$! If you don't speficy a compiler, it will try to determine which
46$! "C" compiler to use.
47$!
48$! P5, if defined, sets a TCP/IP library to use, through one of the following
49$! keywords:
50$!
51$! UCX for UCX
52$! TCPIP for TCPIP (post UCX)
53$! SOCKETSHR for SOCKETSHR+NETLIB
54$!
55$! P6, if defined, sets a compiler thread NOT needed on OpenVMS 7.1 (and up)
56$!
57$! P7, if defined, sets a choice of crypto methods to compile.
58$! WARNING: this should only be done to recompile some part of an already
59$! fully compiled library.
60$!
61$!
62$! Define A TCP/IP Library That We Will Need To Link To.
63$! (That Is, If We Need To Link To One.)
64$!
65$ TCPIP_LIB = ""
66$!
67$! Check Which Architecture We Are Using.
68$!
69$ IF (F$GETSYI("CPU").GE.128)
70$ THEN
71$!
72$! The Architecture Is AXP
73$!
74$ ARCH := AXP
75$!
76$! Else...
77$!
78$ ELSE
79$!
80$! The Architecture Is VAX.
81$!
82$ ARCH := VAX
83$!
84$! End The Architecture Check.
85$!
86$ ENDIF
87$!
88$! Define The Different Encryption Types.
89$!
90$ ENCRYPT_TYPES = "Basic,MD2,MD4,MD5,SHA,MDC2,HMAC,RIPEMD,"+ -
91 "DES,RC2,RC4,RC5,IDEA,BF,CAST,"+ -
92 "BN,EC,RSA,DSA,DH,DSO,ENGINE,AES,"+ -
93 "BUFFER,BIO,STACK,LHASH,RAND,ERR,OBJECTS,"+ -
94 "EVP,EVP_2,ASN1,ASN1_2,PEM,X509,X509V3,"+ -
95 "CONF,TXT_DB,PKCS7,PKCS12,COMP,OCSP,UI,KRB5"
96$ ENCRYPT_PROGRAMS = "DES,PKCS7"
97$!
98$! Check To Make Sure We Have Valid Command Line Parameters.
99$!
100$ GOSUB CHECK_OPTIONS
101$!
102$! Initialise logical names and such
103$!
104$ GOSUB INITIALISE
105$!
106$! Tell The User What Kind of Machine We Run On.
107$!
108$ WRITE SYS$OUTPUT "Compiling On A ",ARCH," Machine."
109$!
110$! Define The OBJ Directory.
111$!
112$ OBJ_DIR := SYS$DISK:[-.'ARCH'.OBJ.CRYPTO]
113$!
114$! Check To See If The Architecture Specific OBJ Directory Exists.
115$!
116$ IF (F$PARSE(OBJ_DIR).EQS."")
117$ THEN
118$!
119$! It Dosen't Exist, So Create It.
120$!
121$ CREATE/DIR 'OBJ_DIR'
122$!
123$! End The Architecture Specific OBJ Directory Check.
124$!
125$ ENDIF
126$!
127$! Define The EXE Directory.
128$!
129$ EXE_DIR := SYS$DISK:[-.'ARCH'.EXE.CRYPTO]
130$!
131$! Check To See If The Architecture Specific Directory Exists.
132$!
133$ IF (F$PARSE(EXE_DIR).EQS."")
134$ THEN
135$!
136$! It Dosen't Exist, So Create It.
137$!
138$ CREATE/DIRECTORY 'EXE_DIR'
139$!
140$! End The Architecture Specific Directory Check.
141$!
142$ ENDIF
143$!
144$! Define The Library Name.
145$!
146$ LIB_NAME := 'EXE_DIR'LIBCRYPTO.OLB
147$!
148$! Define The CRYPTO-LIB We Are To Use.
149$!
150$ CRYPTO_LIB := 'EXE_DIR'LIBCRYPTO.OLB
151$!
152$! Define The RSAREF-LIB We Are To Use.
153$!
154$ RSAREF_LIB := SYS$DISK:[-.'ARCH'.EXE.RSAREF]LIBRSAGLUE.OLB
155$!
156$! Check To See If We Already Have A "[.xxx.EXE.CRYPTO]LIBCRYPTO.OLB" Library...
157$!
158$ IF (F$SEARCH(LIB_NAME).EQS."")
159$ THEN
160$!
161$! Guess Not, Create The Library.
162$!
163$ LIBRARY/CREATE/OBJECT 'LIB_NAME'
164$!
165$! End The Library Check.
166$!
167$ ENDIF
168$!
169$! Build our options file for the application
170$!
171$ GOSUB CHECK_OPT_FILE
172$!
173$! Define The Different Encryption "library" Strings.
174$!
175$ APPS_DES = "DES/DES,CBC3_ENC"
176$ APPS_PKCS7 = "ENC/ENC;DEC/DEC;SIGN/SIGN;VERIFY/VERIFY,EXAMPLE"
177$
178$ LIB_ = "cryptlib,mem,mem_dbg,cversion,ex_data,tmdiff,cpt_err,ebcdic,uid,o_time"
179$ LIB_MD2 = "md2_dgst,md2_one"
180$ LIB_MD4 = "md4_dgst,md4_one"
181$ LIB_MD5 = "md5_dgst,md5_one"
182$ LIB_SHA = "sha_dgst,sha1dgst,sha_one,sha1_one"
183$ LIB_MDC2 = "mdc2dgst,mdc2_one"
184$ LIB_HMAC = "hmac"
185$ LIB_RIPEMD = "rmd_dgst,rmd_one"
186$ LIB_DES = "set_key,ecb_enc,cbc_enc,"+ -
187 "ecb3_enc,cfb64enc,cfb64ede,cfb_enc,ofb64ede,"+ -
188 "enc_read,enc_writ,ofb64enc,"+ -
189 "ofb_enc,str2key,pcbc_enc,qud_cksm,rand_key,"+ -
190 "des_enc,fcrypt_b,"+ -
191 "fcrypt,xcbc_enc,rpc_enc,cbc_cksm,"+ -
192 "ede_cbcm_enc,des_old,des_old2,read2pwd"
193$ LIB_RC2 = "rc2_ecb,rc2_skey,rc2_cbc,rc2cfb64,rc2ofb64"
194$ LIB_RC4 = "rc4_skey,rc4_enc"
195$ LIB_RC5 = "rc5_skey,rc5_ecb,rc5_enc,rc5cfb64,rc5ofb64"
196$ LIB_IDEA = "i_cbc,i_cfb64,i_ofb64,i_ecb,i_skey"
197$ LIB_BF = "bf_skey,bf_ecb,bf_enc,bf_cfb64,bf_ofb64"
198$ LIB_CAST = "c_skey,c_ecb,c_enc,c_cfb64,c_ofb64"
199$ LIB_BN_ASM = "[.asm]vms.mar,vms-helper"
200$ IF F$TRNLNM("OPENSSL_NO_ASM").OR.ARCH.EQS."AXP" THEN LIB_BN_ASM = "bn_asm"
201$ LIB_BN = "bn_add,bn_div,bn_exp,bn_lib,bn_ctx,bn_mul,bn_mod,"+ -
202 "bn_print,bn_rand,bn_shift,bn_word,bn_blind,"+ -
203 "bn_kron,bn_sqrt,bn_gcd,bn_prime,bn_err,bn_sqr,"+LIB_BN_ASM+","+ -
204 "bn_recp,bn_mont,bn_mpi,bn_exp2"
205$ LIB_RSA = "rsa_eay,rsa_gen,rsa_lib,rsa_sign,rsa_saos,rsa_err,"+ -
206 "rsa_pk1,rsa_ssl,rsa_none,rsa_oaep,rsa_chk,rsa_null,"+ -
207 "rsa_asn1"
208$ LIB_EC = "ec_lib,ecp_smpl,ecp_mont,ecp_recp,ecp_nist,ec_cvt,ec_mult,"+ -
209 "ec_err"
210$ LIB_DSA = "dsa_gen,dsa_key,dsa_lib,dsa_asn1,dsa_vrf,dsa_sign,dsa_err,dsa_ossl"
211$ LIB_DH = "dh_asn1,dh_gen,dh_key,dh_lib,dh_check,dh_err"
212$ LIB_DSO = "dso_dl,dso_dlfcn,dso_err,dso_lib,dso_null,"+ -
213 "dso_openssl,dso_win32,dso_vms"
214$ LIB_ENGINE = "eng_err,eng_lib,eng_list,eng_init,eng_ctrl,"+ -
215 "eng_table,eng_pkey,eng_fat,eng_all,"+ -
216 "tb_rsa,tb_dsa,tb_dh,tb_rand,tb_cipher,tb_digest,"+ -
217 "eng_openssl,eng_dyn,eng_cnf,"+ -
218 "hw_atalla,hw_cswift,hw_ncipher,hw_nuron,hw_ubsec,"+ -
219 "hw_openbsd_dev_crypto,hw_aep,hw_sureware,hw_4758_cca"
220$ LIB_AES = "aes_core,aes_misc,aes_ecb,aes_cbc,aes_cfb,aes_ofb,aes_ctr"
221$ LIB_BUFFER = "buffer,buf_err"
222$ LIB_BIO = "bio_lib,bio_cb,bio_err,"+ -
223 "bss_mem,bss_null,bss_fd,"+ -
224 "bss_file,bss_sock,bss_conn,"+ -
225 "bf_null,bf_buff,b_print,b_dump,"+ -
226 "b_sock,bss_acpt,bf_nbio,bss_rtcp,bss_bio,bss_log,"+ -
227 "bf_lbuf"
228$ LIB_STACK = "stack"
229$ LIB_LHASH = "lhash,lh_stats"
230$ LIB_RAND = "md_rand,randfile,rand_lib,rand_err,rand_egd,"+ -
231 "rand_vms"
232$ LIB_ERR = "err,err_all,err_prn"
233$ LIB_OBJECTS = "o_names,obj_dat,obj_lib,obj_err"
234$ LIB_EVP = "encode,digest,evp_enc,evp_key,evp_acnf,"+ -
235 "e_des,e_bf,e_idea,e_des3,"+ -
236 "e_rc4,e_aes,names,"+ -
237 "e_xcbc_d,e_rc2,e_cast,e_rc5"
238$ LIB_EVP_2 = "m_null,m_md2,m_md4,m_md5,m_sha,m_sha1," + -
239 "m_dss,m_dss1,m_mdc2,m_ripemd,"+ -
240 "p_open,p_seal,p_sign,p_verify,p_lib,p_enc,p_dec,"+ -
241 "bio_md,bio_b64,bio_enc,evp_err,e_null,"+ -
242 "c_all,c_allc,c_alld,evp_lib,bio_ok,"+-
243 "evp_pkey,evp_pbe,p5_crpt,p5_crpt2"
244$ LIB_ASN1 = "a_object,a_bitstr,a_utctm,a_gentm,a_time,a_int,a_octet,"+ -
245 "a_print,a_type,a_set,a_dup,a_d2i_fp,a_i2d_fp,"+ -
246 "a_enum,a_utf8,a_sign,a_digest,a_verify,a_mbstr,a_strex,"+ -
247 "x_algor,x_val,x_pubkey,x_sig,x_req,x_attrib,x_bignum,"+ -
248 "x_long,x_name,x_x509,x_x509a,x_crl,x_info,x_spki,nsseq,"+ -
249 "d2i_pu,d2i_pr,i2d_pu,i2d_pr"
250$ LIB_ASN1_2 = "t_req,t_x509,t_x509a,t_crl,t_pkey,t_spki,t_bitst,"+ -
251 "tasn_new,tasn_fre,tasn_enc,tasn_dec,tasn_utl,tasn_typ,"+ -
252 "f_int,f_string,n_pkey,"+ -
253 "f_enum,a_hdr,x_pkey,a_bool,x_exten,"+ -
254 "asn1_par,asn1_lib,asn1_err,a_meth,a_bytes,a_strnid,"+ -
255 "evp_asn1,asn_pack,p5_pbe,p5_pbev2,p8_pkey,asn_moid"
256$ LIB_PEM = "pem_sign,pem_seal,pem_info,pem_lib,pem_all,pem_err,"+ -
257 "pem_x509,pem_xaux,pem_oth,pem_pk8,pem_pkey"
258$ LIB_X509 = "x509_def,x509_d2,x509_r2x,x509_cmp,"+ -
259 "x509_obj,x509_req,x509spki,x509_vfy,"+ -
260 "x509_set,x509cset,x509rset,x509_err,"+ -
261 "x509name,x509_v3,x509_ext,x509_att,"+ -
262 "x509type,x509_lu,x_all,x509_txt,"+ -
263 "x509_trs,by_file,by_dir"
264$ LIB_X509V3 = "v3_bcons,v3_bitst,v3_conf,v3_extku,v3_ia5,v3_lib,"+ -
265 "v3_prn,v3_utl,v3err,v3_genn,v3_alt,v3_skey,v3_akey,v3_pku,"+ -
266 "v3_int,v3_enum,v3_sxnet,v3_cpols,v3_crld,v3_purp,v3_info,"+ -
267 "v3_ocsp,v3_akeya"
268$ LIB_CONF = "conf_err,conf_lib,conf_api,conf_def,conf_mod,conf_mall,conf_sap"
269$ LIB_TXT_DB = "txt_db"
270$ LIB_PKCS7 = "pk7_asn1,pk7_lib,pkcs7err,pk7_doit,pk7_smime,pk7_attr,"+ -
271 "pk7_mime"
272$ LIB_PKCS12 = "p12_add,p12_asn,p12_attr,p12_crpt,p12_crt,p12_decr,"+ -
273 "p12_init,p12_key,p12_kiss,p12_mutl,"+ -
274 "p12_utl,p12_npas,pk12err,p12_p8d,p12_p8e"
275$ LIB_COMP = "comp_lib,comp_err,"+ -
276 "c_rle,c_zlib"
277$ LIB_OCSP = "ocsp_asn,ocsp_ext,ocsp_ht,ocsp_lib,ocsp_cl,"+ -
278 "ocsp_srv,ocsp_prn,ocsp_vfy,ocsp_err"
279$ LIB_UI_COMPAT = ",ui_compat"
280$ LIB_UI = "ui_err,ui_lib,ui_openssl,ui_util"+LIB_UI_COMPAT
281$ LIB_KRB5 = "krb5_asn"
282$!
283$! Setup exceptional compilations
284$!
285$ COMPILEWITH_CC3 = ",bss_rtcp,"
286$ COMPILEWITH_CC4 = ",a_utctm,bss_log,o_time,"
287$ COMPILEWITH_CC5 = ",md2_dgst,md4_dgst,md5_dgst,mdc2dgst," + -
288 "sha_dgst,sha1dgst,rmd_dgst,bf_enc,"
289$!
290$! Check To See If We Are Going To Use RSAREF.
291$!
292$ IF (RSAREF.EQS."TRUE" .AND. ENCRYPT_TYPES - "RSA".NES.ENCRYPT_TYPES -
293 .AND. (BUILDALL .EQS. "TRUE" .OR. BUILDALL .EQS. "LIBRARY"))
294$ THEN
295$!
296$! Check To See If The File [-.RSAREF]RSAREF.C Is Actually There.
297$!
298$ IF (F$SEARCH("SYS$DISK:[-.RSAREF]RSAREF.C").EQS."")
299$ THEN
300$!
301$! Tell The User That The File Doesn't Exist.
302$!
303$ WRITE SYS$OUTPUT ""
304$ WRITE SYS$OUTPUT "The File [-.RSAREF]RSAREF.C Doesn't Exist."
305$ WRITE SYS$OUTPUT ""
306$!
307$! Exit The Build.
308$!
309$ GOTO EXIT
310$!
311$! End The [-.RSAREF]RSAREF.C Check.
312$!
313$ ENDIF
314$!
315$! Tell The User We Are Compiling The [-.RSAREF]RSAREF File.
316$!
317$ WRITE SYS$OUTPUT "Compiling The [-.RSAREF]RSAREF File."
318$!
319$! Compile [-.RSAREF]RSAREF.C
320$!
321$ CC/OBJECT='OBJ_DIR'RSAREF.OBJ SYS$DISK:[-.RSAREF]RSAREF.C
322$!
323$! Add It To The Library.
324$!
325$ LIBRARY/REPLACE 'LIB_NAME' 'OBJ_DIR'RSAREF.OBJ
326$!
327$! Delete The Object File.
328$!
329$ DELETE 'OBJ_DIR'RSAREF.OBJ;*
330$!
331$! Check To See If The File [-.RSAREF]RSAR_ERR.C Is Actually There.
332$!
333$ IF (F$SEARCH("SYS$DISK:[-.RSAREF]RSAR_ERR.C").EQS."")
334$ THEN
335$!
336$! Tell The User That The File Doesn't Exist.
337$!
338$ WRITE SYS$OUTPUT ""
339$ WRITE SYS$OUTPUT "The File [-.RSAREF]RSAR_ERR.C Doesn't Exist."
340$ WRITE SYS$OUTPUT ""
341$!
342$! Exit The Build.
343$!
344$ GOTO EXIT
345$!
346$! End The [-.RSAREF]RSAR_ERR.C File Check.
347$!
348$ ENDIF
349$!
350$! Tell The User We Are Compiling The [-.RSAREF]RSAR_ERR File.
351$!
352$ WRITE SYS$OUTPUT "Compiling The [-.RSAREF]RSAR_ERR File."
353$!
354$! Compile [-.RSAREF]RSAR_ERR.C
355$!
356$ CC/OBJECT='OBJ_DIR'RSAR_ERR.OBJ SYS$DISK:[-.RSAREF]RSAR_ERR.C
357$!
358$! Add It To The Library.
359$!
360$ LIBRARY/REPLACE 'LIB_NAME' 'OBJ_DIR'RSAR_ERR.OBJ
361$!
362$! Delete The Object File.
363$!
364$ DELETE 'OBJ_DIR'RSAR_ERR.OBJ;*
365$!
366$! End The RSAREF Check.
367$!
368$ ENDIF
369$!
370$! Figure Out What Other Modules We Are To Build.
371$!
372$ BUILD_SET:
373$!
374$! Define A Module Counter.
375$!
376$ MODULE_COUNTER = 0
377$!
378$! Top Of The Loop.
379$!
380$ MODULE_NEXT:
381$!
382$! Extract The Module Name From The Encryption List.
383$!
384$ MODULE_NAME = F$ELEMENT(MODULE_COUNTER,",",ENCRYPT_TYPES)
385$ IF MODULE_NAME.EQS."Basic" THEN MODULE_NAME = ""
386$ MODULE_NAME1 = MODULE_NAME
387$!
388$! Check To See If We Are At The End Of The Module List.
389$!
390$ IF (MODULE_NAME.EQS.",")
391$ THEN
392$!
393$! We Are At The End Of The Module List, Go To MODULE_DONE.
394$!
395$ GOTO MODULE_DONE
396$!
397$! End The Module List Check.
398$!
399$ ENDIF
400$!
401$! Increment The Moudle Counter.
402$!
403$ MODULE_COUNTER = MODULE_COUNTER + 1
404$!
405$! Create The Library and Apps Module Names.
406$!
407$ LIB_MODULE = "LIB_" + MODULE_NAME
408$ APPS_MODULE = "APPS_" + MODULE_NAME
409$ IF (MODULE_NAME.EQS."ASN1_2")
410$ THEN
411$ MODULE_NAME = "ASN1"
412$ ENDIF
413$ IF (MODULE_NAME.EQS."EVP_2")
414$ THEN
415$ MODULE_NAME = "EVP"
416$ ENDIF
417$!
418$! Set state (can be LIB and APPS)
419$!
420$ STATE = "LIB"
421$ IF BUILDALL .EQS. "APPS" THEN STATE = "APPS"
422$!
423$! Check if the library module name actually is defined
424$!
425$ IF F$TYPE('LIB_MODULE') .EQS. ""
426$ THEN
427$ WRITE SYS$ERROR ""
428$ WRITE SYS$ERROR "The module ",MODULE_NAME," does not exist. Continuing..."
429$ WRITE SYS$ERROR ""
430$ GOTO MODULE_NEXT
431$ ENDIF
432$!
433$! Top Of The Module Loop.
434$!
435$ MODULE_AGAIN:
436$!
437$! Tell The User What Module We Are Building.
438$!
439$ IF (MODULE_NAME1.NES."")
440$ THEN
441$ IF STATE .EQS. "LIB"
442$ THEN
443$ WRITE SYS$OUTPUT "Compiling The ",MODULE_NAME1," Library Files. (",BUILDALL,",",STATE,")"
444$ ELSE IF F$TYPE('APPS_MODULE') .NES. ""
445$ THEN
446$ WRITE SYS$OUTPUT "Compiling The ",MODULE_NAME1," Applications. (",BUILDALL,",",STATE,")"
447$ ENDIF
448$ ENDIF
449$ ENDIF
450$!
451$! Define A File Counter And Set It To "0".
452$!
453$ FILE_COUNTER = 0
454$ APPLICATION = ""
455$ APPLICATION_COUNTER = 0
456$!
457$! Top Of The File Loop.
458$!
459$ NEXT_FILE:
460$!
461$! Look in the LIB_MODULE is we're in state LIB
462$!
463$ IF STATE .EQS. "LIB"
464$ THEN
465$!
466$! O.K, Extract The File Name From The File List.
467$!
468$ FILE_NAME = F$ELEMENT(FILE_COUNTER,",",'LIB_MODULE')
469$!
470$! else
471$!
472$ ELSE
473$ FILE_NAME = ","
474$!
475$ IF F$TYPE('APPS_MODULE') .NES. ""
476$ THEN
477$!
478$! Extract The File Name From The File List.
479$! This part is a bit more complicated.
480$!
481$ IF APPLICATION .EQS. ""
482$ THEN
483$ APPLICATION = F$ELEMENT(APPLICATION_COUNTER,";",'APPS_MODULE')
484$ APPLICATION_COUNTER = APPLICATION_COUNTER + 1
485$ APPLICATION_OBJECTS = F$ELEMENT(1,"/",APPLICATION)
486$ APPLICATION = F$ELEMENT(0,"/",APPLICATION)
487$ FILE_COUNTER = 0
488$ ENDIF
489$
490$! WRITE SYS$OUTPUT "DEBUG: SHOW SYMBOL APPLICATION*"
491$! SHOW SYMBOL APPLICATION*
492$!
493$ IF APPLICATION .NES. ";"
494$ THEN
495$ FILE_NAME = F$ELEMENT(FILE_COUNTER,",",APPLICATION_OBJECTS)
496$ IF FILE_NAME .EQS. ","
497$ THEN
498$ APPLICATION = ""
499$ GOTO NEXT_FILE
500$ ENDIF
501$ ENDIF
502$ ENDIF
503$ ENDIF
504$!
505$! Check To See If We Are At The End Of The File List.
506$!
507$ IF (FILE_NAME.EQS.",")
508$ THEN
509$!
510$! We Are At The End Of The File List, Change State Or Goto FILE_DONE.
511$!
512$ IF STATE .EQS. "LIB" .AND. BUILDALL .NES. "LIBRARY"
513$ THEN
514$ STATE = "APPS"
515$ GOTO MODULE_AGAIN
516$ ELSE
517$ GOTO FILE_DONE
518$ ENDIF
519$!
520$! End The File List Check.
521$!
522$ ENDIF
523$!
524$! Increment The Counter.
525$!
526$ FILE_COUNTER = FILE_COUNTER + 1
527$!
528$! Create The Source File Name.
529$!
530$ TMP_FILE_NAME = F$ELEMENT(1,"]",FILE_NAME)
531$ IF TMP_FILE_NAME .EQS. "]" THEN TMP_FILE_NAME = FILE_NAME
532$ IF F$ELEMENT(0,".",TMP_FILE_NAME) .EQS. TMP_FILE_NAME THEN -
533 FILE_NAME = FILE_NAME + ".c"
534$ IF (MODULE_NAME.NES."")
535$ THEN
536$ SOURCE_FILE = "SYS$DISK:[." + MODULE_NAME+ "]" + FILE_NAME
537$ ELSE
538$ SOURCE_FILE = "SYS$DISK:[]" + FILE_NAME
539$ ENDIF
540$ SOURCE_FILE = SOURCE_FILE - "]["
541$!
542$! Create The Object File Name.
543$!
544$ OBJECT_FILE = OBJ_DIR + F$PARSE(FILE_NAME,,,"NAME","SYNTAX_ONLY") + ".OBJ"
545$ ON WARNING THEN GOTO NEXT_FILE
546$!
547$! Check To See If The File We Want To Compile Is Actually There.
548$!
549$ IF (F$SEARCH(SOURCE_FILE).EQS."")
550$ THEN
551$!
552$! Tell The User That The File Doesn't Exist.
553$!
554$ WRITE SYS$OUTPUT ""
555$ WRITE SYS$OUTPUT "The File ",SOURCE_FILE," Doesn't Exist."
556$ WRITE SYS$OUTPUT ""
557$!
558$! Exit The Build.
559$!
560$ GOTO EXIT
561$!
562$! End The File Exist Check.
563$!
564$ ENDIF
565$!
566$! Tell The User We Are Compiling The File.
567$!
568$ IF (MODULE_NAME.EQS."")
569$ THEN
570$ WRITE SYS$OUTPUT "Compiling The ",FILE_NAME," File. (",BUILDALL,",",STATE,")"
571$ ENDIF
572$ IF (MODULE_NAME.NES."")
573$ THEN
574$ WRITE SYS$OUTPUT " ",FILE_NAME,""
575$ ENDIF
576$!
577$! Compile The File.
578$!
579$ ON ERROR THEN GOTO NEXT_FILE
580$ FILE_NAME0 = F$ELEMENT(0,".",FILE_NAME)
581$ IF FILE_NAME - ".mar" .NES. FILE_NAME
582$ THEN
583$ MACRO/OBJECT='OBJECT_FILE' 'SOURCE_FILE'
584$ ELSE
585$ IF COMPILEWITH_CC3 - FILE_NAME0 .NES. COMPILEWITH_CC3
586$ THEN
587$ CC3/OBJECT='OBJECT_FILE' 'SOURCE_FILE'
588$ ELSE
589$ IF COMPILEWITH_CC4 - FILE_NAME0 .NES. COMPILEWITH_CC4
590$ THEN
591$ CC4/OBJECT='OBJECT_FILE' 'SOURCE_FILE'
592$ ELSE
593$ IF COMPILEWITH_CC5 - FILE_NAME0 .NES. COMPILEWITH_CC5
594$ THEN
595$ CC5/OBJECT='OBJECT_FILE' 'SOURCE_FILE'
596$ ELSE
597$ CC/OBJECT='OBJECT_FILE' 'SOURCE_FILE'
598$ ENDIF
599$ ENDIF
600$ ENDIF
601$ ENDIF
602$ IF STATE .EQS. "LIB"
603$ THEN
604$!
605$! Add It To The Library.
606$!
607$ LIBRARY/REPLACE 'LIB_NAME' 'OBJECT_FILE'
608$!
609$! Time To Clean Up The Object File.
610$!
611$ DELETE 'OBJECT_FILE';*
612$ ENDIF
613$!
614$! Go Back And Do It Again.
615$!
616$ GOTO NEXT_FILE
617$!
618$! All Done With This Library Part.
619$!
620$ FILE_DONE:
621$!
622$! Time To Build Some Applications
623$!
624$ IF F$TYPE('APPS_MODULE') .NES. "" .AND. BUILDALL .NES. "LIBRARY"
625$ THEN
626$ APPLICATION_COUNTER = 0
627$ NEXT_APPLICATION:
628$ APPLICATION = F$ELEMENT(APPLICATION_COUNTER,";",'APPS_MODULE')
629$ IF APPLICATION .EQS. ";" THEN GOTO APPLICATION_DONE
630$
631$ APPLICATION_COUNTER = APPLICATION_COUNTER + 1
632$ APPLICATION_OBJECTS = F$ELEMENT(1,"/",APPLICATION)
633$ APPLICATION = F$ELEMENT(0,"/",APPLICATION)
634$
635$! WRITE SYS$OUTPUT "DEBUG: SHOW SYMBOL APPLICATION*"
636$! SHOW SYMBOL APPLICATION*
637$!
638$! Tell the user what happens
639$!
640$ WRITE SYS$OUTPUT " ",APPLICATION,".exe"
641$!
642$! Link The Program, Check To See If We Need To Link With RSAREF Or Not.
643$!
644$ ON ERROR THEN GOTO NEXT_APPLICATION
645$ IF (RSAREF.EQS."TRUE")
646$ THEN
647$!
648$! Check To See If We Are To Link With A Specific TCP/IP Library.
649$!
650$ IF (TCPIP_LIB.NES."")
651$ THEN
652$!
653$! Link With The RSAREF Library And A Specific TCP/IP Library.
654$!
655$ LINK/'DEBUGGER'/'TRACEBACK'/EXE='EXE_DIR''APPLICATION'.EXE -
656 'OBJ_DIR''APPLICATION_OBJECTS', -
657 'CRYPTO_LIB'/LIBRARY,'RSAREF_LIB'/LIBRARY, -
658 'TCPIP_LIB','OPT_FILE'/OPTION
659$!
660$! Else...
661$!
662$ ELSE
663$!
664$! Link With The RSAREF Library And NO TCP/IP Library.
665$!
666$ LINK/'DEBUGGER'/'TRACEBACK'/EXE='EXE_DIR''APPLICATION'.EXE -
667 'OBJ_DIR''APPLICATION_OBJECTS', -
668 'CRYPTO_LIB'/LIBRARY,'RSAREF_LIB'/LIBRARY, -
669 'OPT_FILE'/OPTION
670$!
671$! End The TCP/IP Library Check.
672$!
673$ ENDIF
674$!
675$! Else...
676$!
677$ ELSE
678$!
679$! Don't Link With The RSAREF Routines.
680$!
681$!
682$! Check To See If We Are To Link With A Specific TCP/IP Library.
683$!
684$ IF (TCPIP_LIB.NES."")
685$ THEN
686$!
687$! Don't Link With The RSAREF Routines And TCP/IP Library.
688$!
689$ LINK/'DEBUGGER'/'TRACEBACK'/EXE='EXE_DIR''APPLICATION'.EXE -
690 'OBJ_DIR''APPLICATION_OBJECTS', -
691 'CRYPTO_LIB'/LIBRARY, -
692 'TCPIP_LIB','OPT_FILE'/OPTION
693$!
694$! Else...
695$!
696$ ELSE
697$!
698$! Don't Link With The RSAREF Routines And Link With A TCP/IP Library.
699$!
700$ LINK/'DEBUGGER'/'TRACEBACK'/EXE='EXE_DIR''APPLICATION'.EXE -
701 'OBJ_DIR''APPLICATION_OBJECTS',-
702 'CRYPTO_LIB'/LIBRARY, -
703 'OPT_FILE'/OPTION
704$!
705$! End The TCP/IP Library Check.
706$!
707$ ENDIF
708$!
709$! End The RSAREF Link Check.
710$!
711$ ENDIF
712$ GOTO NEXT_APPLICATION
713$ APPLICATION_DONE:
714$ ENDIF
715$!
716$! Go Back And Get The Next Module.
717$!
718$ GOTO MODULE_NEXT
719$!
720$! All Done With This Module.
721$!
722$ MODULE_DONE:
723$!
724$! Tell The User That We Are All Done.
725$!
726$ WRITE SYS$OUTPUT "All Done..."
727$ EXIT:
728$ GOSUB CLEANUP
729$ EXIT
730$!
731$! Check For The Link Option FIle.
732$!
733$ CHECK_OPT_FILE:
734$!
735$! Check To See If We Need To Make A VAX C Option File.
736$!
737$ IF (COMPILER.EQS."VAXC")
738$ THEN
739$!
740$! Check To See If We Already Have A VAX C Linker Option File.
741$!
742$ IF (F$SEARCH(OPT_FILE).EQS."")
743$ THEN
744$!
745$! We Need A VAX C Linker Option File.
746$!
747$ CREATE 'OPT_FILE'
748$DECK
749!
750! Default System Options File To Link Agianst
751! The Sharable VAX C Runtime Library.
752!
753SYS$SHARE:VAXCRTL.EXE/SHARE
754$EOD
755$!
756$! End The Option File Check.
757$!
758$ ENDIF
759$!
760$! End The VAXC Check.
761$!
762$ ENDIF
763$!
764$! Check To See If We Need A GNU C Option File.
765$!
766$ IF (COMPILER.EQS."GNUC")
767$ THEN
768$!
769$! Check To See If We Already Have A GNU C Linker Option File.
770$!
771$ IF (F$SEARCH(OPT_FILE).EQS."")
772$ THEN
773$!
774$! We Need A GNU C Linker Option File.
775$!
776$ CREATE 'OPT_FILE'
777$DECK
778!
779! Default System Options File To Link Agianst
780! The Sharable C Runtime Library.
781!
782GNU_CC:[000000]GCCLIB/LIBRARY
783SYS$SHARE:VAXCRTL/SHARE
784$EOD
785$!
786$! End The Option File Check.
787$!
788$ ENDIF
789$!
790$! End The GNU C Check.
791$!
792$ ENDIF
793$!
794$! Check To See If We Need A DEC C Option File.
795$!
796$ IF (COMPILER.EQS."DECC")
797$ THEN
798$!
799$! Check To See If We Already Have A DEC C Linker Option File.
800$!
801$ IF (F$SEARCH(OPT_FILE).EQS."")
802$ THEN
803$!
804$! Figure Out If We Need An AXP Or A VAX Linker Option File.
805$!
806$ IF ARCH .EQS. "VAX"
807$ THEN
808$!
809$! We Need A DEC C Linker Option File For VAX.
810$!
811$ CREATE 'OPT_FILE'
812$DECK
813!
814! Default System Options File To Link Agianst
815! The Sharable DEC C Runtime Library.
816!
817SYS$SHARE:DECC$SHR.EXE/SHARE
818$EOD
819$!
820$! Else...
821$!
822$ ELSE
823$!
824$! Create The AXP Linker Option File.
825$!
826$ CREATE 'OPT_FILE'
827$DECK
828!
829! Default System Options File For AXP To Link Agianst
830! The Sharable C Runtime Library.
831!
832SYS$SHARE:CMA$OPEN_LIB_SHR/SHARE
833SYS$SHARE:CMA$OPEN_RTL/SHARE
834$EOD
835$!
836$! End The VAX/AXP DEC C Option File Check.
837$!
838$ ENDIF
839$!
840$! End The Option File Search.
841$!
842$ ENDIF
843$!
844$! End The DEC C Check.
845$!
846$ ENDIF
847$!
848$! Tell The User What Linker Option File We Are Using.
849$!
850$ WRITE SYS$OUTPUT "Using Linker Option File ",OPT_FILE,"."
851$!
852$! Time To RETURN.
853$!
854$ RETURN
855$!
856$! Check The User's Options.
857$!
858$ CHECK_OPTIONS:
859$!
860$! Check To See If P1 Is Blank.
861$!
862$ IF (P1.EQS."ALL")
863$ THEN
864$!
865$! P1 Is Blank, So Build Everything.
866$!
867$ BUILDALL = "TRUE"
868$!
869$! Else...
870$!
871$ ELSE
872$!
873$! Else, Check To See If P1 Has A Valid Arguement.
874$!
875$ IF (P1.EQS."LIBRARY").OR.(P1.EQS."APPS")
876$ THEN
877$!
878$! A Valid Arguement.
879$!
880$ BUILDALL = P1
881$!
882$! Else...
883$!
884$ ELSE
885$!
886$! Tell The User We Don't Know What They Want.
887$!
888$ WRITE SYS$OUTPUT ""
889$ WRITE SYS$OUTPUT "The Option ",P1," Is Invalid. The Valid Options Are:"
890$ WRITE SYS$OUTPUT ""
891$ WRITE SYS$OUTPUT " ALL : Just Build Everything."
892$ WRITE SYS$OUTPUT " LIBRARY : To Compile Just The [.xxx.EXE.SSL]LIBCRYPTO.OLB Library."
893$ WRITE SYS$OUTPUT " APPS : To Compile Just The [.xxx.EXE.SSL]*.EXE Programs."
894$ WRITE SYS$OUTPUT ""
895$ WRITE SYS$OUTPUT " Where 'xxx' Stands For:"
896$ WRITE SYS$OUTPUT ""
897$ WRITE SYS$OUTPUT " AXP : Alpha Architecture."
898$ WRITE SYS$OUTPUT " VAX : VAX Architecture."
899$ WRITE SYS$OUTPUT ""
900$!
901$! Time To EXIT.
902$!
903$ EXIT
904$!
905$! End The Valid Arguement Check.
906$!
907$ ENDIF
908$!
909$! End The P1 Check.
910$!
911$ ENDIF
912$!
913$! Check To See If P2 Is Blank.
914$!
915$ P2 = "NORSAREF"
916$ IF (P2.EQS."NORSAREF")
917$ THEN
918$!
919$! P2 Is NORSAREF, So Compile With The Regular RSA Libraries.
920$!
921$ RSAREF = "FALSE"
922$ ELSE
923$!
924$! Check To See If We Are To Use The RSAREF Library.
925$!
926$ IF (P2.EQS."RSAREF")
927$ THEN
928$!
929$! Check To Make Sure We Have The RSAREF Source Code Directory.
930$!
931$ IF (F$SEARCH("SYS$DISK:[-.RSAREF]SOURCE.DIR").EQS."")
932$ THEN
933$!
934$! We Don't Have The RSAREF Souce Code Directory, So Tell The
935$! User This.
936$!
937$ WRITE SYS$OUTPUT ""
938$ WRITE SYS$OUTPUT "It appears that you don't have the RSAREF Souce Code."
939$ WRITE SYS$OUTPUT "You need to go to 'ftp://ftp.rsa.com/rsaref'. You have to"
940$ WRITE SYS$OUTPUT "get the '.tar-Z' file as the '.zip' file doesn't have the"
941$ WRITE SYS$OUTPUT "directory structure stored. You have to extract the file"
942$ WRITE SYS$OUTPUT "into the [.RSAREF] directory under the root directory"
943$ WRITE SYS$OUTPUT "as that is where the scripts will look for the files."
944$ WRITE SYS$OUTPUT ""
945$!
946$! Time To Exit.
947$!
948$ EXIT
949$!
950$! Else, Compile Using The RSAREF Library.
951$!
952$ ELSE
953$ RSAREF = "TRUE"
954$ ENDIF
955$ ELSE
956$!
957$! They Entered An Invalid Option..
958$!
959$ WRITE SYS$OUTPUT ""
960$ WRITE SYS$OUTPUT "The Option ",P2," Is Invalid. The Valid Options Are:"
961$ WRITE SYS$OUTPUT ""
962$ WRITE SYS$OUTPUT " RSAREF : Compile With The RSAREF Library."
963$ WRITE SYS$OUTPUT " NORSAREF : Compile With The Regular RSA Library."
964$ WRITE SYS$OUTPUT ""
965$!
966$! Time To EXIT.
967$!
968$ EXIT
969$!
970$! End The Valid Arguement Check.
971$!
972$ ENDIF
973$!
974$! End The P2 Check.
975$!
976$ ENDIF
977$!
978$! Check To See If P3 Is Blank.
979$!
980$ IF (P3.EQS."NODEBUG")
981$ THEN
982$!
983$! P3 Is NODEBUG, So Compile Without The Debugger Information.
984$!
985$ DEBUGGER = "NODEBUG"
986$ TRACEBACK = "NOTRACEBACK"
987$ GCC_OPTIMIZE = "OPTIMIZE"
988$ CC_OPTIMIZE = "OPTIMIZE"
989$ MACRO_OPTIMIZE = "OPTIMIZE"
990$ WRITE SYS$OUTPUT "No Debugger Information Will Be Produced During Compile."
991$ WRITE SYS$OUTPUT "Compiling With Compiler Optimization."
992$ ELSE
993$!
994$! Check To See If We Are To Compile With Debugger Information.
995$!
996$ IF (P3.EQS."DEBUG")
997$ THEN
998$!
999$! Compile With Debugger Information.
1000$!
1001$ DEBUGGER = "DEBUG"
1002$ TRACEBACK = "TRACEBACK"
1003$ GCC_OPTIMIZE = "NOOPTIMIZE"
1004$ CC_OPTIMIZE = "NOOPTIMIZE"
1005$ MACRO_OPTIMIZE = "NOOPTIMIZE"
1006$ WRITE SYS$OUTPUT "Debugger Information Will Be Produced During Compile."
1007$ WRITE SYS$OUTPUT "Compiling Without Compiler Optimization."
1008$ ELSE
1009$!
1010$! They Entered An Invalid Option..
1011$!
1012$ WRITE SYS$OUTPUT ""
1013$ WRITE SYS$OUTPUT "The Option ",P3," Is Invalid. The Valid Options Are:"
1014$ WRITE SYS$OUTPUT ""
1015$ WRITE SYS$OUTPUT " DEBUG : Compile With The Debugger Information."
1016$ WRITE SYS$OUTPUT " NODEBUG : Compile Without The Debugger Information."
1017$ WRITE SYS$OUTPUT ""
1018$!
1019$! Time To EXIT.
1020$!
1021$ EXIT
1022$!
1023$! End The Valid Arguement Check.
1024$!
1025$ ENDIF
1026$!
1027$! End The P3 Check.
1028$!
1029$ ENDIF
1030$!
1031$! Special Threads For OpenVMS v7.1 Or Later
1032$!
1033$! Written By: Richard Levitte
1034$! richard@levitte.org
1035$!
1036$!
1037$! Check To See If We Have A Option For P6.
1038$!
1039$ IF (P6.EQS."")
1040$ THEN
1041$!
1042$! Get The Version Of VMS We Are Using.
1043$!
1044$ ISSEVEN :=
1045$ TMP = F$ELEMENT(0,"-",F$EXTRACT(1,4,F$GETSYI("VERSION")))
1046$ TMP = F$INTEGER(F$ELEMENT(0,".",TMP)+F$ELEMENT(1,".",TMP))
1047$!
1048$! Check To See If The VMS Version Is v7.1 Or Later.
1049$!
1050$ IF (TMP.GE.71)
1051$ THEN
1052$!
1053$! We Have OpenVMS v7.1 Or Later, So Use The Special Threads.
1054$!
1055$ ISSEVEN := ,PTHREAD_USE_D4
1056$!
1057$! End The VMS Version Check.
1058$!
1059$ ENDIF
1060$!
1061$! End The P6 Check.
1062$!
1063$ ENDIF
1064$!
1065$! Check To See If P4 Is Blank.
1066$!
1067$ IF (P4.EQS."")
1068$ THEN
1069$!
1070$! O.K., The User Didn't Specify A Compiler, Let's Try To
1071$! Find Out Which One To Use.
1072$!
1073$! Check To See If We Have GNU C.
1074$!
1075$ IF (F$TRNLNM("GNU_CC").NES."")
1076$ THEN
1077$!
1078$! Looks Like GNUC, Set To Use GNUC.
1079$!
1080$ P4 = "GNUC"
1081$!
1082$! Else...
1083$!
1084$ ELSE
1085$!
1086$! Check To See If We Have VAXC Or DECC.
1087$!
1088$ IF (ARCH.EQS."AXP").OR.(F$TRNLNM("DECC$CC_DEFAULT").NES."")
1089$ THEN
1090$!
1091$! Looks Like DECC, Set To Use DECC.
1092$!
1093$ P4 = "DECC"
1094$!
1095$! Else...
1096$!
1097$ ELSE
1098$!
1099$! Looks Like VAXC, Set To Use VAXC.
1100$!
1101$ P4 = "VAXC"
1102$!
1103$! End The VAXC Compiler Check.
1104$!
1105$ ENDIF
1106$!
1107$! End The DECC & VAXC Compiler Check.
1108$!
1109$ ENDIF
1110$!
1111$! End The Compiler Check.
1112$!
1113$ ENDIF
1114$!
1115$! Check To See If We Have A Option For P5.
1116$!
1117$ IF (P5.EQS."")
1118$ THEN
1119$!
1120$! Find out what socket library we have available
1121$!
1122$ IF F$PARSE("SOCKETSHR:") .NES. ""
1123$ THEN
1124$!
1125$! We have SOCKETSHR, and it is my opinion that it's the best to use.
1126$!
1127$ P5 = "SOCKETSHR"
1128$!
1129$! Tell the user
1130$!
1131$ WRITE SYS$OUTPUT "Using SOCKETSHR for TCP/IP"
1132$!
1133$! Else, let's look for something else
1134$!
1135$ ELSE
1136$!
1137$! Like UCX (the reason to do this before Multinet is that the UCX
1138$! emulation is easier to use...)
1139$!
1140$ IF F$TRNLNM("UCX$IPC_SHR") .NES. "" -
1141 .OR. F$PARSE("SYS$SHARE:UCX$IPC_SHR.EXE") .NES. "" -
1142 .OR. F$PARSE("SYS$LIBRARY:UCX$IPC.OLB") .NES. ""
1143$ THEN
1144$!
1145$! Last resort: a UCX or UCX-compatible library
1146$!
1147$ P5 = "UCX"
1148$!
1149$! Tell the user
1150$!
1151$ WRITE SYS$OUTPUT "Using UCX or an emulation thereof for TCP/IP"
1152$!
1153$! That was all...
1154$!
1155$ ENDIF
1156$ ENDIF
1157$ ENDIF
1158$!
1159$! Set Up Initial CC Definitions, Possibly With User Ones
1160$!
1161$ CCDEFS = "TCPIP_TYPE_''P5',DSO_VMS"
1162$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS
1163$ CCEXTRAFLAGS = ""
1164$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS
1165$ CCDISABLEWARNINGS = "LONGLONGTYPE,LONGLONGSUFX"
1166$ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" THEN -
1167 CCDISABLEWARNINGS = CCDISABLEWARNINGS + "," + USER_CCDISABLEWARNINGS
1168$!
1169$! Check To See If The User Entered A Valid Paramter.
1170$!
1171$ IF (P4.EQS."VAXC").OR.(P4.EQS."DECC").OR.(P4.EQS."GNUC")
1172$ THEN
1173$!
1174$! Check To See If The User Wanted DECC.
1175$!
1176$ IF (P4.EQS."DECC")
1177$ THEN
1178$!
1179$! Looks Like DECC, Set To Use DECC.
1180$!
1181$ COMPILER = "DECC"
1182$!
1183$! Tell The User We Are Using DECC.
1184$!
1185$ WRITE SYS$OUTPUT "Using DECC 'C' Compiler."
1186$!
1187$! Use DECC...
1188$!
1189$ CC = "CC"
1190$ IF ARCH.EQS."VAX" .AND. F$TRNLNM("DECC$CC_DEFAULT").NES."/DECC" -
1191 THEN CC = "CC/DECC"
1192$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/STANDARD=ANSI89" + -
1193 "/NOLIST/PREFIX=ALL" + -
1194 "/INCLUDE=(SYS$DISK:[],SYS$DISK:[-],SYS$DISK:[.ENGINE.VENDOR_DEFNS],SYS$DISK:[.EVP])" + -
1195 CCEXTRAFLAGS
1196$!
1197$! Define The Linker Options File Name.
1198$!
1199$ OPT_FILE = "SYS$DISK:[]VAX_DECC_OPTIONS.OPT"
1200$!
1201$! End DECC Check.
1202$!
1203$ ENDIF
1204$!
1205$! Check To See If We Are To Use VAXC.
1206$!
1207$ IF (P4.EQS."VAXC")
1208$ THEN
1209$!
1210$! Looks Like VAXC, Set To Use VAXC.
1211$!
1212$ COMPILER = "VAXC"
1213$!
1214$! Tell The User We Are Using VAX C.
1215$!
1216$ WRITE SYS$OUTPUT "Using VAXC 'C' Compiler."
1217$!
1218$! Compile Using VAXC.
1219$!
1220$ CC = "CC"
1221$ IF ARCH.EQS."AXP"
1222$ THEN
1223$ WRITE SYS$OUTPUT "There is no VAX C on Alpha!"
1224$ EXIT
1225$ ENDIF
1226$ IF F$TRNLNM("DECC$CC_DEFAULT").EQS."/DECC" THEN CC = "CC/VAXC"
1227$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/NOLIST" + -
1228 "/INCLUDE=(SYS$DISK:[],SYS$DISK:[-],SYS$DISK:[.ENGINE.VENDOR_DEFNS])" + -
1229 CCEXTRAFLAGS
1230$ CCDEFS = """VAXC""," + CCDEFS
1231$!
1232$! Define <sys> As SYS$COMMON:[SYSLIB]
1233$!
1234$ DEFINE/NOLOG SYS SYS$COMMON:[SYSLIB]
1235$!
1236$! Define The Linker Options File Name.
1237$!
1238$ OPT_FILE = "SYS$DISK:[]VAX_VAXC_OPTIONS.OPT"
1239$!
1240$! End VAXC Check
1241$!
1242$ ENDIF
1243$!
1244$! Check To See If We Are To Use GNU C.
1245$!
1246$ IF (P4.EQS."GNUC")
1247$ THEN
1248$!
1249$! Looks Like GNUC, Set To Use GNUC.
1250$!
1251$ COMPILER = "GNUC"
1252$!
1253$! Tell The User We Are Using GNUC.
1254$!
1255$ WRITE SYS$OUTPUT "Using GNU 'C' Compiler."
1256$!
1257$! Use GNU C...
1258$!
1259$ CC = "GCC/NOCASE_HACK/''GCC_OPTIMIZE'/''DEBUGGER'/NOLIST" + -
1260 "/INCLUDE=(SYS$DISK:[],SYS$DISK:[-],SYS$DISK:[.ENGINE.VENDOR_DEFNS])" + -
1261 CCEXTRAFLAGS
1262$!
1263$! Define The Linker Options File Name.
1264$!
1265$ OPT_FILE = "SYS$DISK:[]VAX_GNUC_OPTIONS.OPT"
1266$!
1267$! End The GNU C Check.
1268$!
1269$ ENDIF
1270$!
1271$! Set up default defines
1272$!
1273$ CCDEFS = """FLAT_INC=1""," + CCDEFS
1274$!
1275$! Check To See If We Are To Compile With RSAREF Routines.
1276$!
1277$ IF (RSAREF.EQS."TRUE")
1278$ THEN
1279$!
1280$! Compile With RSAREF.
1281$!
1282$ CCDEFS = CCDEFS + ",""RSAref=1"""
1283$!
1284$! Tell The User This.
1285$!
1286$ WRITE SYS$OUTPUT "Compiling With RSAREF Routines."
1287$!
1288$! Else, We Don't Care. Compile Without The RSAREF Library.
1289$!
1290$ ELSE
1291$!
1292$! Tell The User We Are Compile Without The RSAREF Routines.
1293$!
1294$ WRITE SYS$OUTPUT "Compiling Without The RSAREF Routines.
1295$!
1296$! End The RSAREF Check.
1297$!
1298$ ENDIF
1299$!
1300$! Finish up the definition of CC.
1301$!
1302$ IF COMPILER .EQS. "DECC"
1303$ THEN
1304$ IF CCDISABLEWARNINGS .EQS. ""
1305$ THEN
1306$ CC4DISABLEWARNINGS = "DOLLARID"
1307$ ELSE
1308$ CC4DISABLEWARNINGS = CCDISABLEWARNINGS + ",DOLLARID"
1309$ CCDISABLEWARNINGS = "/WARNING=(DISABLE=(" + CCDISABLEWARNINGS + "))"
1310$ ENDIF
1311$ CC4DISABLEWARNINGS = "/WARNING=(DISABLE=(" + CC4DISABLEWARNINGS + "))"
1312$ ELSE
1313$ CCDISABLEWARNINGS = ""
1314$ CC4DISABLEWARNINGS = ""
1315$ ENDIF
1316$ CC3 = CC + "/DEFINE=(" + CCDEFS + ISSEVEN + ")" + CCDISABLEWARNINGS
1317$ CC = CC + "/DEFINE=(" + CCDEFS + ")" + CCDISABLEWARNINGS
1318$ IF ARCH .EQS. "VAX" .AND. COMPILER .EQS. "DECC" .AND. P3 .NES. "DEBUG"
1319$ THEN
1320$ CC5 = CC + "/OPTIMIZE=NODISJOINT"
1321$ ELSE
1322$ CC5 = CC + "/NOOPTIMIZE"
1323$ ENDIF
1324$ CC4 = CC - CCDISABLEWARNINGS + CC4DISABLEWARNINGS
1325$!
1326$! Show user the result
1327$!
1328$ WRITE/SYMBOL SYS$OUTPUT "Main C Compiling Command: ",CC
1329$!
1330$! Else The User Entered An Invalid Arguement.
1331$!
1332$ ELSE
1333$!
1334$! Tell The User We Don't Know What They Want.
1335$!
1336$ WRITE SYS$OUTPUT ""
1337$ WRITE SYS$OUTPUT "The Option ",P4," Is Invalid. The Valid Options Are:"
1338$ WRITE SYS$OUTPUT ""
1339$ WRITE SYS$OUTPUT " VAXC : To Compile With VAX C."
1340$ WRITE SYS$OUTPUT " DECC : To Compile With DEC C."
1341$ WRITE SYS$OUTPUT " GNUC : To Compile With GNU C."
1342$ WRITE SYS$OUTPUT ""
1343$!
1344$! Time To EXIT.
1345$!
1346$ EXIT
1347$!
1348$! End The Valid Arguement Check.
1349$!
1350$ ENDIF
1351$!
1352$! Build a MACRO command for the architecture at hand
1353$!
1354$ IF ARCH .EQS. "VAX" THEN MACRO = "MACRO/''DEBUGGER'"
1355$ IF ARCH .EQS. "AXP" THEN MACRO = "MACRO/MIGRATION/''DEBUGGER'/''MACRO_OPTIMIZE'"
1356$!
1357$! Show user the result
1358$!
1359$ WRITE/SYMBOL SYS$OUTPUT "Main MACRO Compiling Command: ",MACRO
1360$!
1361$! Time to check the contents, and to make sure we get the correct library.
1362$!
1363$ IF P5.EQS."SOCKETSHR" .OR. P5.EQS."MULTINET" .OR. P5.EQS."UCX" -
1364 .OR. P5.EQS."TCPIP" .OR. P5.EQS."NONE"
1365$ THEN
1366$!
1367$! Check to see if SOCKETSHR was chosen
1368$!
1369$ IF P5.EQS."SOCKETSHR"
1370$ THEN
1371$!
1372$! Set the library to use SOCKETSHR
1373$!
1374$ TCPIP_LIB = "SYS$DISK:[-.VMS]SOCKETSHR_SHR.OPT/OPT"
1375$!
1376$! Done with SOCKETSHR
1377$!
1378$ ENDIF
1379$!
1380$! Check to see if MULTINET was chosen
1381$!
1382$ IF P5.EQS."MULTINET"
1383$ THEN
1384$!
1385$! Set the library to use UCX emulation.
1386$!
1387$ P5 = "UCX"
1388$!
1389$! Done with MULTINET
1390$!
1391$ ENDIF
1392$!
1393$! Check to see if UCX was chosen
1394$!
1395$ IF P5.EQS."UCX"
1396$ THEN
1397$!
1398$! Set the library to use UCX.
1399$!
1400$ TCPIP_LIB = "SYS$DISK:[-.VMS]UCX_SHR_DECC.OPT/OPT"
1401$ IF F$TRNLNM("UCX$IPC_SHR") .NES. ""
1402$ THEN
1403$ TCPIP_LIB = "SYS$DISK:[-.VMS]UCX_SHR_DECC_LOG.OPT/OPT"
1404$ ELSE
1405$ IF COMPILER .NES. "DECC" .AND. ARCH .EQS. "VAX" THEN -
1406 TCPIP_LIB = "SYS$DISK:[-.VMS]UCX_SHR_VAXC.OPT/OPT"
1407$ ENDIF
1408$!
1409$! Done with UCX
1410$!
1411$ ENDIF
1412$!
1413$! Check to see if TCPIP was chosen
1414$!
1415$ IF P5.EQS."TCPIP"
1416$ THEN
1417$!
1418$! Set the library to use TCPIP (post UCX).
1419$!
1420$ TCPIP_LIB = "SYS$DISK:[-.VMS]TCPIP_SHR_DECC.OPT/OPT"
1421$!
1422$! Done with TCPIP
1423$!
1424$ ENDIF
1425$!
1426$! Check to see if NONE was chosen
1427$!
1428$ IF P5.EQS."NONE"
1429$ THEN
1430$!
1431$! Do not use a TCPIP library.
1432$!
1433$ TCPIP_LIB = ""
1434$!
1435$! Done with TCPIP
1436$!
1437$ ENDIF
1438$!
1439$! Print info
1440$!
1441$ WRITE SYS$OUTPUT "TCP/IP library spec: ", TCPIP_LIB
1442$!
1443$! Else The User Entered An Invalid Arguement.
1444$!
1445$ ELSE
1446$!
1447$! Tell The User We Don't Know What They Want.
1448$!
1449$ WRITE SYS$OUTPUT ""
1450$ WRITE SYS$OUTPUT "The Option ",P5," Is Invalid. The Valid Options Are:"
1451$ WRITE SYS$OUTPUT ""
1452$ WRITE SYS$OUTPUT " SOCKETSHR : To link with SOCKETSHR TCP/IP library."
1453$ WRITE SYS$OUTPUT " UCX : To link with UCX TCP/IP library."
1454$ WRITE SYS$OUTPUT " TCPIP : To link with TCPIP (post UCX) TCP/IP library."
1455$ WRITE SYS$OUTPUT ""
1456$!
1457$! Time To EXIT.
1458$!
1459$ EXIT
1460$!
1461$! Done with TCP/IP libraries
1462$!
1463$ ENDIF
1464$!
1465$! Check if the user wanted to compile just a subset of all the encryption
1466$! methods.
1467$!
1468$ IF P7 .NES. ""
1469$ THEN
1470$ ENCRYPT_TYPES = P7
1471$! NYI: ENCRYPT_PROGRAMS = P7
1472$ ENDIF
1473$!
1474$! Time To RETURN...
1475$!
1476$ RETURN
1477$!
1478$ INITIALISE:
1479$!
1480$! Save old value of the logical name OPENSSL
1481$!
1482$ __SAVE_OPENSSL = F$TRNLNM("OPENSSL","LNM$PROCESS_TABLE")
1483$!
1484$! Save directory information
1485$!
1486$ __HERE = F$PARSE(F$PARSE("A.;",F$ENVIRONMENT("PROCEDURE"))-"A.;","[]A.;") - "A.;"
1487$ __HERE = F$EDIT(__HERE,"UPCASE")
1488$ __TOP = __HERE - "CRYPTO]"
1489$ __INCLUDE = __TOP + "INCLUDE.OPENSSL]"
1490$!
1491$! Set up the logical name OPENSSL to point at the include directory
1492$!
1493$ DEFINE OPENSSL/NOLOG '__INCLUDE'
1494$!
1495$! Done
1496$!
1497$ RETURN
1498$!
1499$ CLEANUP:
1500$!
1501$! Restore the logical name OPENSSL if it had a value
1502$!
1503$ IF __SAVE_OPENSSL .EQS. ""
1504$ THEN
1505$ DEASSIGN OPENSSL
1506$ ELSE
1507$ DEFINE/NOLOG OPENSSL '__SAVE_OPENSSL'
1508$ ENDIF
1509$!
1510$! Done
1511$!
1512$ RETURN
diff --git a/src/lib/libcrypto/crypto.h b/src/lib/libcrypto/crypto.h
index 273bc5e3f8..fc6ff860af 100644
--- a/src/lib/libcrypto/crypto.h
+++ b/src/lib/libcrypto/crypto.h
@@ -96,39 +96,37 @@ extern "C" {
96 * names in cryptlib.c 96 * names in cryptlib.c
97 */ 97 */
98 98
99#define CRYPTO_LOCK_ERR 1 99#define CRYPTO_LOCK_ERR 1
100#define CRYPTO_LOCK_EX_DATA 2 100#define CRYPTO_LOCK_EX_DATA 2
101#define CRYPTO_LOCK_X509 3 101#define CRYPTO_LOCK_X509 3
102#define CRYPTO_LOCK_X509_INFO 4 102#define CRYPTO_LOCK_X509_INFO 4
103#define CRYPTO_LOCK_X509_PKEY 5 103#define CRYPTO_LOCK_X509_PKEY 5
104#define CRYPTO_LOCK_X509_CRL 6 104#define CRYPTO_LOCK_X509_CRL 6
105#define CRYPTO_LOCK_X509_REQ 7 105#define CRYPTO_LOCK_X509_REQ 7
106#define CRYPTO_LOCK_DSA 8 106#define CRYPTO_LOCK_DSA 8
107#define CRYPTO_LOCK_RSA 9 107#define CRYPTO_LOCK_RSA 9
108#define CRYPTO_LOCK_EVP_PKEY 10 108#define CRYPTO_LOCK_EVP_PKEY 10
109#define CRYPTO_LOCK_X509_STORE 11 109#define CRYPTO_LOCK_X509_STORE 11
110#define CRYPTO_LOCK_SSL_CTX 12 110#define CRYPTO_LOCK_SSL_CTX 12
111#define CRYPTO_LOCK_SSL_CERT 13 111#define CRYPTO_LOCK_SSL_CERT 13
112#define CRYPTO_LOCK_SSL_SESSION 14 112#define CRYPTO_LOCK_SSL_SESSION 14
113#define CRYPTO_LOCK_SSL_SESS_CERT 15 113#define CRYPTO_LOCK_SSL_SESS_CERT 15
114#define CRYPTO_LOCK_SSL 16 114#define CRYPTO_LOCK_SSL 16
115#define CRYPTO_LOCK_SSL_METHOD 17 115#define CRYPTO_LOCK_RAND 17
116#define CRYPTO_LOCK_RAND 18 116#define CRYPTO_LOCK_RAND2 18
117#define CRYPTO_LOCK_RAND2 19 117#define CRYPTO_LOCK_MALLOC 19
118#define CRYPTO_LOCK_MALLOC 20 118#define CRYPTO_LOCK_BIO 20
119#define CRYPTO_LOCK_BIO 21 119#define CRYPTO_LOCK_GETHOSTBYNAME 21
120#define CRYPTO_LOCK_GETHOSTBYNAME 22 120#define CRYPTO_LOCK_GETSERVBYNAME 22
121#define CRYPTO_LOCK_GETSERVBYNAME 23 121#define CRYPTO_LOCK_READDIR 23
122#define CRYPTO_LOCK_READDIR 24 122#define CRYPTO_LOCK_RSA_BLINDING 24
123#define CRYPTO_LOCK_RSA_BLINDING 25 123#define CRYPTO_LOCK_DH 25
124#define CRYPTO_LOCK_DH 26 124#define CRYPTO_LOCK_MALLOC2 26
125#define CRYPTO_LOCK_MALLOC2 27 125#define CRYPTO_LOCK_DSO 27
126#define CRYPTO_LOCK_DSO 28 126#define CRYPTO_LOCK_DYNLOCK 28
127#define CRYPTO_LOCK_DYNLOCK 29 127#define CRYPTO_LOCK_ENGINE 29
128#define CRYPTO_LOCK_ENGINE 30 128#define CRYPTO_LOCK_UI 30
129#define CRYPTO_LOCK_UI 31 129#define CRYPTO_NUM_LOCKS 31
130#define CRYPTO_LOCK_HWCRHK 32 /* This is a HACK which will disappear in 0.9.8 */
131#define CRYPTO_NUM_LOCKS 33
132 130
133#define CRYPTO_LOCK 1 131#define CRYPTO_LOCK 1
134#define CRYPTO_UNLOCK 2 132#define CRYPTO_UNLOCK 2
@@ -150,7 +148,7 @@ extern "C" {
150#endif 148#endif
151#else 149#else
152#define CRYPTO_w_lock(a) 150#define CRYPTO_w_lock(a)
153#define CRYPTO_w_unlock(a) 151#define CRYPTO_w_unlock(a)
154#define CRYPTO_r_lock(a) 152#define CRYPTO_r_lock(a)
155#define CRYPTO_r_unlock(a) 153#define CRYPTO_r_unlock(a)
156#define CRYPTO_add(a,b,c) ((*(a))+=(b)) 154#define CRYPTO_add(a,b,c) ((*(a))+=(b))
@@ -280,8 +278,6 @@ int CRYPTO_is_mem_check_on(void);
280#define OPENSSL_malloc(num) CRYPTO_malloc((int)num,__FILE__,__LINE__) 278#define OPENSSL_malloc(num) CRYPTO_malloc((int)num,__FILE__,__LINE__)
281#define OPENSSL_realloc(addr,num) \ 279#define OPENSSL_realloc(addr,num) \
282 CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__) 280 CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__)
283#define OPENSSL_realloc_clean(addr,old_num,num) \
284 CRYPTO_realloc_clean(addr,old_num,num,__FILE__,__LINE__)
285#define OPENSSL_remalloc(addr,num) \ 281#define OPENSSL_remalloc(addr,num) \
286 CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__) 282 CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__)
287#define OPENSSL_freeFunc CRYPTO_free 283#define OPENSSL_freeFunc CRYPTO_free
@@ -384,12 +380,8 @@ void CRYPTO_free_locked(void *);
384void *CRYPTO_malloc(int num, const char *file, int line); 380void *CRYPTO_malloc(int num, const char *file, int line);
385void CRYPTO_free(void *); 381void CRYPTO_free(void *);
386void *CRYPTO_realloc(void *addr,int num, const char *file, int line); 382void *CRYPTO_realloc(void *addr,int num, const char *file, int line);
387void *CRYPTO_realloc_clean(void *addr,int old_num,int num,const char *file,
388 int line);
389void *CRYPTO_remalloc(void *addr,int num, const char *file, int line); 383void *CRYPTO_remalloc(void *addr,int num, const char *file, int line);
390 384
391void OPENSSL_cleanse(void *ptr, size_t len);
392
393void CRYPTO_set_mem_debug_options(long bits); 385void CRYPTO_set_mem_debug_options(long bits);
394long CRYPTO_get_mem_debug_options(void); 386long CRYPTO_get_mem_debug_options(void);
395 387
@@ -430,9 +422,6 @@ void CRYPTO_mem_leaks(struct bio_st *bio);
430typedef void *CRYPTO_MEM_LEAK_CB(unsigned long, const char *, int, int, void *); 422typedef void *CRYPTO_MEM_LEAK_CB(unsigned long, const char *, int, int, void *);
431void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb); 423void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb);
432 424
433/* die if we have to */
434void OpenSSLDie(const char *file,int line,const char *assertion);
435#define OPENSSL_assert(e) ((e) ? (void)0 : OpenSSLDie(__FILE__, __LINE__, #e))
436 425
437/* BEGIN ERROR CODES */ 426/* BEGIN ERROR CODES */
438/* The following lines are auto generated by the script mkerr.pl. Any changes 427/* The following lines are auto generated by the script mkerr.pl. Any changes
diff --git a/src/lib/libcrypto/cversion.c b/src/lib/libcrypto/cversion.c
index 8ecfba7b16..56471fa74c 100644
--- a/src/lib/libcrypto/cversion.c
+++ b/src/lib/libcrypto/cversion.c
@@ -61,7 +61,9 @@
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/crypto.h> 62#include <openssl/crypto.h>
63 63
64#ifndef NO_WINDOWS_BRAINDEATH
64#include "buildinf.h" 65#include "buildinf.h"
66#endif
65 67
66const char *SSLeay_version(int t) 68const char *SSLeay_version(int t)
67 { 69 {
@@ -72,7 +74,7 @@ const char *SSLeay_version(int t)
72#ifdef DATE 74#ifdef DATE
73 static char buf[sizeof(DATE)+11]; 75 static char buf[sizeof(DATE)+11];
74 76
75 sprintf(buf,"built on: %s",DATE); 77 snprintf(buf,sizeof buf,"built on: %s",DATE);
76 return(buf); 78 return(buf);
77#else 79#else
78 return("built on: date not available"); 80 return("built on: date not available");
@@ -83,7 +85,7 @@ const char *SSLeay_version(int t)
83#ifdef CFLAGS 85#ifdef CFLAGS
84 static char buf[sizeof(CFLAGS)+11]; 86 static char buf[sizeof(CFLAGS)+11];
85 87
86 sprintf(buf,"compiler: %s",CFLAGS); 88 snprintf(buf,sizeof buf,"compiler: %s",CFLAGS);
87 return(buf); 89 return(buf);
88#else 90#else
89 return("compiler: information not available"); 91 return("compiler: information not available");
@@ -94,7 +96,7 @@ const char *SSLeay_version(int t)
94#ifdef PLATFORM 96#ifdef PLATFORM
95 static char buf[sizeof(PLATFORM)+11]; 97 static char buf[sizeof(PLATFORM)+11];
96 98
97 sprintf(buf,"platform: %s", PLATFORM); 99 snprintf(buf,sizeof buf,"platform: %s", PLATFORM);
98 return(buf); 100 return(buf);
99#else 101#else
100 return("platform: information not available"); 102 return("platform: information not available");
diff --git a/src/lib/libcrypto/des/DES.pm b/src/lib/libcrypto/des/DES.pm
new file mode 100644
index 0000000000..6a175b6ca4
--- /dev/null
+++ b/src/lib/libcrypto/des/DES.pm
@@ -0,0 +1,19 @@
1package DES;
2
3require Exporter;
4require DynaLoader;
5@ISA = qw(Exporter DynaLoader);
6# Items to export into callers namespace by default
7# (move infrequently used names to @EXPORT_OK below)
8@EXPORT = qw(
9);
10# Other items we are prepared to export if requested
11@EXPORT_OK = qw(
12crypt
13);
14
15# Preloaded methods go here. Autoload methods go after __END__, and are
16# processed by the autosplit program.
17bootstrap DES;
181;
19__END__
diff --git a/src/lib/libcrypto/des/DES.xs b/src/lib/libcrypto/des/DES.xs
new file mode 100644
index 0000000000..b8050b9edf
--- /dev/null
+++ b/src/lib/libcrypto/des/DES.xs
@@ -0,0 +1,268 @@
1#include "EXTERN.h"
2#include "perl.h"
3#include "XSUB.h"
4#include "des.h"
5
6#define deschar char
7static STRLEN len;
8
9static int
10not_here(s)
11char *s;
12{
13 croak("%s not implemented on this architecture", s);
14 return -1;
15}
16
17MODULE = DES PACKAGE = DES PREFIX = des_
18
19char *
20des_crypt(buf,salt)
21 char * buf
22 char * salt
23
24void
25des_set_odd_parity(key)
26 des_cblock * key
27PPCODE:
28 {
29 SV *s;
30
31 s=sv_newmortal();
32 sv_setpvn(s,(char *)key,8);
33 des_set_odd_parity((des_cblock *)SvPV(s,na));
34 PUSHs(s);
35 }
36
37int
38des_is_weak_key(key)
39 des_cblock * key
40
41des_key_schedule
42des_set_key(key)
43 des_cblock * key
44CODE:
45 des_set_key(key,RETVAL);
46OUTPUT:
47RETVAL
48
49des_cblock
50des_ecb_encrypt(input,ks,encrypt)
51 des_cblock * input
52 des_key_schedule * ks
53 int encrypt
54CODE:
55 des_ecb_encrypt(input,&RETVAL,*ks,encrypt);
56OUTPUT:
57RETVAL
58
59void
60des_cbc_encrypt(input,ks,ivec,encrypt)
61 char * input
62 des_key_schedule * ks
63 des_cblock * ivec
64 int encrypt
65PPCODE:
66 {
67 SV *s;
68 STRLEN len,l;
69 char *c;
70
71 l=SvCUR(ST(0));
72 len=((((unsigned long)l)+7)/8)*8;
73 s=sv_newmortal();
74 sv_setpvn(s,"",0);
75 SvGROW(s,len);
76 SvCUR_set(s,len);
77 c=(char *)SvPV(s,na);
78 des_cbc_encrypt((des_cblock *)input,(des_cblock *)c,
79 l,*ks,ivec,encrypt);
80 sv_setpvn(ST(2),(char *)c[len-8],8);
81 PUSHs(s);
82 }
83
84void
85des_cbc3_encrypt(input,ks1,ks2,ivec1,ivec2,encrypt)
86 char * input
87 des_key_schedule * ks1
88 des_key_schedule * ks2
89 des_cblock * ivec1
90 des_cblock * ivec2
91 int encrypt
92PPCODE:
93 {
94 SV *s;
95 STRLEN len,l;
96
97 l=SvCUR(ST(0));
98 len=((((unsigned long)l)+7)/8)*8;
99 s=sv_newmortal();
100 sv_setpvn(s,"",0);
101 SvGROW(s,len);
102 SvCUR_set(s,len);
103 des_3cbc_encrypt((des_cblock *)input,(des_cblock *)SvPV(s,na),
104 l,*ks1,*ks2,ivec1,ivec2,encrypt);
105 sv_setpvn(ST(3),(char *)ivec1,8);
106 sv_setpvn(ST(4),(char *)ivec2,8);
107 PUSHs(s);
108 }
109
110void
111des_cbc_cksum(input,ks,ivec)
112 char * input
113 des_key_schedule * ks
114 des_cblock * ivec
115PPCODE:
116 {
117 SV *s1,*s2;
118 STRLEN len,l;
119 des_cblock c;
120 unsigned long i1,i2;
121
122 s1=sv_newmortal();
123 s2=sv_newmortal();
124 l=SvCUR(ST(0));
125 des_cbc_cksum((des_cblock *)input,(des_cblock *)c,
126 l,*ks,ivec);
127 i1=c[4]|(c[5]<<8)|(c[6]<<16)|(c[7]<<24);
128 i2=c[0]|(c[1]<<8)|(c[2]<<16)|(c[3]<<24);
129 sv_setiv(s1,i1);
130 sv_setiv(s2,i2);
131 sv_setpvn(ST(2),(char *)c,8);
132 PUSHs(s1);
133 PUSHs(s2);
134 }
135
136void
137des_cfb_encrypt(input,numbits,ks,ivec,encrypt)
138 char * input
139 int numbits
140 des_key_schedule * ks
141 des_cblock * ivec
142 int encrypt
143PPCODE:
144 {
145 SV *s;
146 STRLEN len;
147 char *c;
148
149 len=SvCUR(ST(0));
150 s=sv_newmortal();
151 sv_setpvn(s,"",0);
152 SvGROW(s,len);
153 SvCUR_set(s,len);
154 c=(char *)SvPV(s,na);
155 des_cfb_encrypt((unsigned char *)input,(unsigned char *)c,
156 (int)numbits,(long)len,*ks,ivec,encrypt);
157 sv_setpvn(ST(3),(char *)ivec,8);
158 PUSHs(s);
159 }
160
161des_cblock *
162des_ecb3_encrypt(input,ks1,ks2,encrypt)
163 des_cblock * input
164 des_key_schedule * ks1
165 des_key_schedule * ks2
166 int encrypt
167CODE:
168 {
169 des_cblock c;
170
171 des_ecb3_encrypt((des_cblock *)input,(des_cblock *)&c,
172 *ks1,*ks2,encrypt);
173 RETVAL= &c;
174 }
175OUTPUT:
176RETVAL
177
178void
179des_ofb_encrypt(input,numbits,ks,ivec)
180 unsigned char * input
181 int numbits
182 des_key_schedule * ks
183 des_cblock * ivec
184PPCODE:
185 {
186 SV *s;
187 STRLEN len,l;
188 unsigned char *c;
189
190 len=SvCUR(ST(0));
191 s=sv_newmortal();
192 sv_setpvn(s,"",0);
193 SvGROW(s,len);
194 SvCUR_set(s,len);
195 c=(unsigned char *)SvPV(s,na);
196 des_ofb_encrypt((unsigned char *)input,(unsigned char *)c,
197 numbits,len,*ks,ivec);
198 sv_setpvn(ST(3),(char *)ivec,8);
199 PUSHs(s);
200 }
201
202void
203des_pcbc_encrypt(input,ks,ivec,encrypt)
204 char * input
205 des_key_schedule * ks
206 des_cblock * ivec
207 int encrypt
208PPCODE:
209 {
210 SV *s;
211 STRLEN len,l;
212 char *c;
213
214 l=SvCUR(ST(0));
215 len=((((unsigned long)l)+7)/8)*8;
216 s=sv_newmortal();
217 sv_setpvn(s,"",0);
218 SvGROW(s,len);
219 SvCUR_set(s,len);
220 c=(char *)SvPV(s,na);
221 des_pcbc_encrypt((des_cblock *)input,(des_cblock *)c,
222 l,*ks,ivec,encrypt);
223 sv_setpvn(ST(2),(char *)c[len-8],8);
224 PUSHs(s);
225 }
226
227des_cblock *
228des_random_key()
229CODE:
230 {
231 des_cblock c;
232
233 des_random_key(c);
234 RETVAL=&c;
235 }
236OUTPUT:
237RETVAL
238
239des_cblock *
240des_string_to_key(str)
241char * str
242CODE:
243 {
244 des_cblock c;
245
246 des_string_to_key(str,&c);
247 RETVAL=&c;
248 }
249OUTPUT:
250RETVAL
251
252void
253des_string_to_2keys(str)
254char * str
255PPCODE:
256 {
257 des_cblock c1,c2;
258 SV *s1,*s2;
259
260 des_string_to_2keys(str,&c1,&c2);
261 EXTEND(sp,2);
262 s1=sv_newmortal();
263 sv_setpvn(s1,(char *)c1,8);
264 s2=sv_newmortal();
265 sv_setpvn(s2,(char *)c2,8);
266 PUSHs(s1);
267 PUSHs(s2);
268 }
diff --git a/src/lib/libcrypto/des/FILES b/src/lib/libcrypto/des/FILES
new file mode 100644
index 0000000000..4c7ea2de7a
--- /dev/null
+++ b/src/lib/libcrypto/des/FILES
@@ -0,0 +1,96 @@
1/* General stuff */
2COPYRIGHT - Copyright info.
3MODES.DES - A description of the features of the different modes of DES.
4FILES - This file.
5INSTALL - How to make things compile.
6Imakefile - For use with kerberos.
7README - What this package is.
8VERSION - Which version this is and what was changed.
9KERBEROS - Kerberos version 4 notes.
10Makefile.PL - An old makefile to build with perl5, not current.
11Makefile.ssl - The SSLeay makefile
12Makefile.uni - The normal unix makefile.
13GNUmakefile - The makefile for use with glibc.
14makefile.bc - A Borland C makefile
15times - Some outputs from 'speed' on some machines.
16vms.com - For use when compiling under VMS
17
18/* My SunOS des(1) replacement */
19des.c - des(1) source code.
20des.man - des(1) manual.
21
22/* Testing and timing programs. */
23destest.c - Source for libdes.a test program.
24speed.c - Source for libdes.a timing program.
25rpw.c - Source for libdes.a testing password reading routines.
26
27/* libdes.a source code */
28des_crypt.man - libdes.a manual page.
29des.h - Public libdes.a header file.
30ecb_enc.c - des_ecb_encrypt() source, this contains the basic DES code.
31ecb3_enc.c - des_ecb3_encrypt() source.
32cbc_ckm.c - des_cbc_cksum() source.
33cbc_enc.c - des_cbc_encrypt() source.
34ncbc_enc.c - des_cbc_encrypt() that is 'normal' in that it copies
35 the new iv values back in the passed iv vector.
36ede_enc.c - des_ede3_cbc_encrypt() cbc mode des using triple DES.
37cbc3_enc.c - des_3cbc_encrypt() source, don't use this function.
38cfb_enc.c - des_cfb_encrypt() source.
39cfb64enc.c - des_cfb64_encrypt() cfb in 64 bit mode but setup to be
40 used as a stream cipher.
41cfb64ede.c - des_ede3_cfb64_encrypt() cfb in 64 bit mode but setup to be
42 used as a stream cipher and using triple DES.
43ofb_enc.c - des_cfb_encrypt() source.
44ofb64_enc.c - des_ofb_encrypt() ofb in 64 bit mode but setup to be
45 used as a stream cipher.
46ofb64ede.c - des_ede3_ofb64_encrypt() ofb in 64 bit mode but setup to be
47 used as a stream cipher and using triple DES.
48enc_read.c - des_enc_read() source.
49enc_writ.c - des_enc_write() source.
50pcbc_enc.c - des_pcbc_encrypt() source.
51qud_cksm.c - quad_cksum() source.
52rand_key.c - des_random_key() source.
53read_pwd.c - Source for des_read_password() plus related functions.
54set_key.c - Source for des_set_key().
55str2key.c - Covert a string of any length into a key.
56fcrypt.c - A small, fast version of crypt(3).
57des_locl.h - Internal libdes.a header file.
58podd.h - Odd parity tables - used in des_set_key().
59sk.h - Lookup tables used in des_set_key().
60spr.h - What is left of the S tables - used in ecb_encrypt().
61des_ver.h - header file for the external definition of the
62 version string.
63des.doc - SSLeay documentation for the library.
64
65/* The perl scripts - you can ignore these files they are only
66 * included for the curious */
67des.pl - des in perl anyone? des_set_key and des_ecb_encrypt
68 both done in a perl library.
69testdes.pl - Testing program for des.pl
70doIP - Perl script used to develop IP xor/shift code.
71doPC1 - Perl script used to develop PC1 xor/shift code.
72doPC2 - Generates sk.h.
73PC1 - Output of doPC1 should be the same as output from PC1.
74PC2 - used in development of doPC2.
75shifts.pl - Perl library used by my perl scripts.
76
77/* I started making a perl5 dynamic library for libdes
78 * but did not fully finish, these files are part of that effort. */
79DES.pm
80DES.pod
81DES.xs
82t
83typemap
84
85/* The following are for use with sun RPC implementaions. */
86rpc_des.h
87rpc_enc.c
88
89/* The following are contibuted by Mark Murray <mark@grondar.za>. They
90 * are not normally built into libdes due to machine specific routines
91 * contained in them. They are for use in the most recent incarnation of
92 * export kerberos v 4 (eBones). */
93supp.c
94new_rkey.c
95
96
diff --git a/src/lib/libcrypto/des/INSTALL b/src/lib/libcrypto/des/INSTALL
new file mode 100644
index 0000000000..32457d775c
--- /dev/null
+++ b/src/lib/libcrypto/des/INSTALL
@@ -0,0 +1,69 @@
1Check the CC and CFLAGS lines in the makefile
2
3If your C library does not support the times(3) function, change the
4#define TIMES to
5#undef TIMES in speed.c
6If it does, check the HZ value for the times(3) function.
7If your system does not define CLK_TCK it will be assumed to
8be 100.0.
9
10If possible use gcc v 2.7.?
11Turn on the maximum optimising (normally '-O3 -fomit-frame-pointer' for gcc)
12In recent times, some system compilers give better performace.
13
14type 'make'
15
16run './destest' to check things are ok.
17run './rpw' to check the tty code for reading passwords works.
18run './speed' to see how fast those optimisations make the library run :-)
19run './des_opts' to determin the best compile time options.
20
21The output from des_opts should be put in the makefile options and des_enc.c
22should be rebuilt. For 64 bit computers, do not use the DES_PTR option.
23For the DEC Alpha, edit des.h and change DES_LONG to 'unsigned int'
24and then you can use the 'DES_PTR' option.
25
26The file options.txt has the options listed for best speed on quite a
27few systems. Look and the options (UNROLL, PTR, RISC2 etc) and then
28turn on the relevent option in the Makefile
29
30There are some special Makefile targets that make life easier.
31make cc - standard cc build
32make gcc - standard gcc build
33make x86-elf - x86 assembler (elf), linux-elf.
34make x86-out - x86 assembler (a.out), FreeBSD
35make x86-solaris- x86 assembler
36make x86-bsdi - x86 assembler (a.out with primative assembler).
37
38If at all possible use the assembler (for Windows NT/95, use
39asm/win32.obj to link with). The x86 assembler is very very fast.
40
41A make install will by default install
42libdes.a in /usr/local/lib/libdes.a
43des in /usr/local/bin/des
44des_crypt.man in /usr/local/man/man3/des_crypt.3
45des.man in /usr/local/man/man1/des.1
46des.h in /usr/include/des.h
47
48des(1) should be compatible with sunOS's but I have been unable to
49test it.
50
51These routines should compile on MSDOS, most 32bit and 64bit version
52of Unix (BSD and SYSV) and VMS, without modification.
53The only problems should be #include files that are in the wrong places.
54
55These routines can be compiled under MSDOS.
56I have successfully encrypted files using des(1) under MSDOS and then
57decrypted the files on a SparcStation.
58I have been able to compile and test the routines with
59Microsoft C v 5.1 and Turbo C v 2.0.
60The code in this library is in no way optimised for the 16bit
61operation of MSDOS.
62
63When building for glibc, ignore all of the above and just unpack into
64glibc-1.??/des and then gmake as per normal.
65
66As a final note on performace. Certain CPUs like sparcs and Alpha often give
67a %10 speed difference depending on the link order. It is rather anoying
68when one program reports 'x' DES encrypts a second and another reports
69'x*0.9' the speed.
diff --git a/src/lib/libcrypto/des/Imakefile b/src/lib/libcrypto/des/Imakefile
new file mode 100644
index 0000000000..1b9b5629e1
--- /dev/null
+++ b/src/lib/libcrypto/des/Imakefile
@@ -0,0 +1,35 @@
1# This Imakefile has not been tested for a while but it should still
2# work when placed in the correct directory in the kerberos v 4 distribution
3
4SRCS= cbc_cksm.c cbc_enc.c ecb_enc.c pcbc_enc.c \
5 qud_cksm.c rand_key.c read_pwd.c set_key.c str2key.c \
6 enc_read.c enc_writ.c fcrypt.c cfb_enc.c \
7 ecb3_enc.c ofb_enc.c ofb64enc.c
8
9OBJS= cbc_cksm.o cbc_enc.o ecb_enc.o pcbc_enc.o \
10 qud_cksm.o rand_key.o read_pwd.o set_key.o str2key.o \
11 enc_read.o enc_writ.o fcrypt.o cfb_enc.o \
12 ecb3_enc.o ofb_enc.o ofb64enc.o
13
14GENERAL=COPYRIGHT FILES INSTALL Imakefile README VERSION makefile times \
15 vms.com KERBEROS
16DES= des.c des.man
17TESTING=destest.c speed.c rpw.c
18LIBDES= des_crypt.man des.h des_locl.h podd.h sk.h spr.h
19
20PERL= des.pl testdes.pl doIP doPC1 doPC2 PC1 PC2 shifts.pl
21
22CODE= $(GENERAL) $(DES) $(TESTING) $(SRCS) $(LIBDES) $(PERL)
23
24SRCDIR=$(SRCTOP)/lib/des
25
26DBG= -O
27INCLUDE= -I$(SRCDIR)
28CC= cc
29
30library_obj_rule()
31
32install_library_target(des,$(OBJS),$(SRCS),)
33
34test(destest,libdes.a,)
35test(rpw,libdes.a,)
diff --git a/src/lib/libcrypto/des/KERBEROS b/src/lib/libcrypto/des/KERBEROS
new file mode 100644
index 0000000000..f401b10014
--- /dev/null
+++ b/src/lib/libcrypto/des/KERBEROS
@@ -0,0 +1,41 @@
1 [ This is an old file, I don't know if it is true anymore
2 but I will leave the file here - eay 21/11/95 ]
3
4To use this library with Bones (kerberos without DES):
51) Get my modified Bones - eBones. It can be found on
6 gondwana.ecr.mu.oz.au (128.250.1.63) /pub/athena/eBones-p9.tar.Z
7 and
8 nic.funet.fi (128.214.6.100) /pub/unix/security/Kerberos/eBones-p9.tar.Z
9
102) Unpack this library in src/lib/des, makeing sure it is version
11 3.00 or greater (libdes.tar.93-10-07.Z). This versions differences
12 from the version in comp.sources.misc volume 29 patchlevel2.
13 The primarily difference is that it should compile under kerberos :-).
14 It can be found at.
15 ftp.psy.uq.oz.au (130.102.32.1) /pub/DES/libdes.tar.93-10-07.Z
16
17Now do a normal kerberos build and things should work.
18
19One problem I found when I was build on my local sun.
20---
21For sunOS 4.1.1 apply the following patch to src/util/ss/make_commands.c
22
23*** make_commands.c.orig Fri Jul 3 04:18:35 1987
24--- make_commands.c Wed May 20 08:47:42 1992
25***************
26*** 98,104 ****
27 if (!rename(o_file, z_file)) {
28 if (!vfork()) {
29 chdir("/tmp");
30! execl("/bin/ld", "ld", "-o", o_file+5, "-s", "-r", "-n",
31 z_file+5, 0);
32 perror("/bin/ld");
33 _exit(1);
34--- 98,104 ----
35 if (!rename(o_file, z_file)) {
36 if (!vfork()) {
37 chdir("/tmp");
38! execl("/bin/ld", "ld", "-o", o_file+5, "-s", "-r",
39 z_file+5, 0);
40 perror("/bin/ld");
41 _exit(1);
diff --git a/src/lib/libcrypto/des/Makefile.ssl b/src/lib/libcrypto/des/Makefile.ssl
new file mode 100644
index 0000000000..826ffcc58c
--- /dev/null
+++ b/src/lib/libcrypto/des/Makefile.ssl
@@ -0,0 +1,325 @@
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)
25
26GENERAL=Makefile
27TEST=destest.c
28APPS=
29
30LIB=$(TOP)/libcrypto.a
31LIBSRC= cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c \
32 ecb3_enc.c ecb_enc.c enc_read.c enc_writ.c \
33 fcrypt.c ofb64enc.c ofb_enc.c pcbc_enc.c \
34 qud_cksm.c rand_key.c rpc_enc.c set_key.c \
35 des_enc.c fcrypt_b.c \
36 xcbc_enc.c \
37 str2key.c cfb64ede.c ofb64ede.c ede_cbcm_enc.c des_old.c des_old2.c \
38 read2pwd.c
39
40LIBOBJ= set_key.o ecb_enc.o cbc_enc.o \
41 ecb3_enc.o cfb64enc.o cfb64ede.o cfb_enc.o ofb64ede.o \
42 enc_read.o enc_writ.o ofb64enc.o \
43 ofb_enc.o str2key.o pcbc_enc.o qud_cksm.o rand_key.o \
44 ${DES_ENC} \
45 fcrypt.o xcbc_enc.o rpc_enc.o cbc_cksm.o \
46 ede_cbcm_enc.o des_old.o des_old2.o read2pwd.o
47
48SRC= $(LIBSRC)
49
50EXHEADER= des.h des_old.h
51HEADER= des_locl.h rpc_des.h spr.h des_ver.h $(EXHEADER)
52
53ALL= $(GENERAL) $(SRC) $(HEADER)
54
55top:
56 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
57
58all: lib
59
60lib: $(LIBOBJ)
61 $(AR) $(LIB) $(LIBOBJ)
62 $(RANLIB) $(LIB) || echo Never mind.
63 @touch lib
64
65des: des.o cbc3_enc.o lib
66 $(CC) $(CFLAGS) -o des des.o cbc3_enc.o $(LIB)
67
68# elf
69asm/dx86-elf.o: asm/dx86unix.cpp
70 $(CPP) -DELF -x c asm/dx86unix.cpp | as -o asm/dx86-elf.o
71
72asm/yx86-elf.o: asm/yx86unix.cpp
73 $(CPP) -DELF -x c asm/yx86unix.cpp | as -o asm/yx86-elf.o
74
75# solaris
76asm/dx86-sol.o: asm/dx86unix.cpp
77 $(CC) -E -DSOL asm/dx86unix.cpp | sed 's/^#.*//' > asm/dx86-sol.s
78 as -o asm/dx86-sol.o asm/dx86-sol.s
79 rm -f asm/dx86-sol.s
80
81asm/yx86-sol.o: asm/yx86unix.cpp
82 $(CC) -E -DSOL asm/yx86unix.cpp | sed 's/^#.*//' > asm/yx86-sol.s
83 as -o asm/yx86-sol.o asm/yx86-sol.s
84 rm -f asm/yx86-sol.s
85
86# a.out
87asm/dx86-out.o: asm/dx86unix.cpp
88 $(CPP) -DOUT asm/dx86unix.cpp | as -o asm/dx86-out.o
89
90asm/yx86-out.o: asm/yx86unix.cpp
91 $(CPP) -DOUT asm/yx86unix.cpp | as -o asm/yx86-out.o
92
93# bsdi
94asm/dx86bsdi.o: asm/dx86unix.cpp
95 $(CPP) -DBSDI asm/dx86unix.cpp | sed 's/ :/:/' | as -o asm/dx86bsdi.o
96
97asm/yx86bsdi.o: asm/yx86unix.cpp
98 $(CPP) -DBSDI asm/yx86unix.cpp | sed 's/ :/:/' | as -o asm/yx86bsdi.o
99
100asm/dx86unix.cpp: asm/des-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl
101 (cd asm; $(PERL) des-586.pl cpp >dx86unix.cpp)
102
103asm/yx86unix.cpp: asm/crypt586.pl ../perlasm/x86asm.pl
104 (cd asm; $(PERL) crypt586.pl cpp >yx86unix.cpp)
105
106files:
107 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
108
109links:
110 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
111 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
112 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
113 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
114
115install: installs
116
117installs:
118 @for i in $(EXHEADER) ; \
119 do \
120 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
121 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
122 done;
123
124tags:
125 ctags $(SRC)
126
127tests:
128
129lint:
130 lint -DLINT $(INCLUDES) $(SRC)>fluff
131
132depend:
133 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC)
134
135dclean:
136 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
137 mv -f Makefile.new $(MAKEFILE)
138
139clean:
140 rm -f asm/dx86unix.cpp asm/yx86unix.cpp *.o asm/*.o *.obj des lib tags core .pure .nfs* *.old *.bak fluff
141
142# DO NOT DELETE THIS LINE -- make depend depends on it.
143
144cbc_cksm.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
145cbc_cksm.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
146cbc_cksm.o: ../../include/openssl/opensslconf.h
147cbc_cksm.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
148cbc_cksm.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
149cbc_cksm.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
150cbc_cksm.o: cbc_cksm.c des_locl.h
151cbc_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
152cbc_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
153cbc_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
154cbc_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
155cbc_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
156cbc_enc.o: ../../include/openssl/ui_compat.h cbc_enc.c des_locl.h ncbc_enc.c
157cfb64ede.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
158cfb64ede.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
159cfb64ede.o: ../../include/openssl/opensslconf.h
160cfb64ede.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
161cfb64ede.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
162cfb64ede.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
163cfb64ede.o: cfb64ede.c des_locl.h
164cfb64enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
165cfb64enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
166cfb64enc.o: ../../include/openssl/opensslconf.h
167cfb64enc.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
168cfb64enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
169cfb64enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
170cfb64enc.o: cfb64enc.c des_locl.h
171cfb_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
172cfb_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
173cfb_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
174cfb_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
175cfb_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
176cfb_enc.o: ../../include/openssl/ui_compat.h cfb_enc.c des_locl.h
177des_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
178des_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
179des_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
180des_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
181des_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
182des_enc.o: ../../include/openssl/ui_compat.h des_enc.c des_locl.h ncbc_enc.c
183des_old.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
184des_old.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
185des_old.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
186des_old.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
187des_old.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
188des_old.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
189des_old.o: ../../include/openssl/ui_compat.h des_old.c
190des_old2.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
191des_old2.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
192des_old2.o: ../../include/openssl/opensslconf.h
193des_old2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
194des_old2.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
195des_old2.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
196des_old2.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
197des_old2.o: des_old2.c
198ecb3_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
199ecb3_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
200ecb3_enc.o: ../../include/openssl/opensslconf.h
201ecb3_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
202ecb3_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
203ecb3_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
204ecb3_enc.o: des_locl.h ecb3_enc.c
205ecb_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
206ecb_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
207ecb_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
208ecb_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
209ecb_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
210ecb_enc.o: ../../include/openssl/ui_compat.h des_locl.h des_ver.h ecb_enc.c
211ecb_enc.o: spr.h
212ede_cbcm_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
213ede_cbcm_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
214ede_cbcm_enc.o: ../../include/openssl/opensslconf.h
215ede_cbcm_enc.o: ../../include/openssl/opensslv.h
216ede_cbcm_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
217ede_cbcm_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
218ede_cbcm_enc.o: ../../include/openssl/ui_compat.h des_locl.h ede_cbcm_enc.c
219enc_read.o: ../../e_os.h ../../include/openssl/bio.h
220enc_read.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
221enc_read.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
222enc_read.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
223enc_read.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
224enc_read.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
225enc_read.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
226enc_read.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
227enc_read.o: ../cryptlib.h des_locl.h enc_read.c
228enc_writ.o: ../../e_os.h ../../include/openssl/bio.h
229enc_writ.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
230enc_writ.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
231enc_writ.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
232enc_writ.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
233enc_writ.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
234enc_writ.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
235enc_writ.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
236enc_writ.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
237enc_writ.o: ../cryptlib.h des_locl.h enc_writ.c
238fcrypt.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
239fcrypt.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
240fcrypt.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
241fcrypt.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
242fcrypt.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
243fcrypt.o: ../../include/openssl/ui_compat.h des_locl.h fcrypt.c
244fcrypt_b.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
245fcrypt_b.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
246fcrypt_b.o: ../../include/openssl/opensslconf.h
247fcrypt_b.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
248fcrypt_b.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
249fcrypt_b.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
250fcrypt_b.o: des_locl.h fcrypt_b.c
251ofb64ede.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
252ofb64ede.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
253ofb64ede.o: ../../include/openssl/opensslconf.h
254ofb64ede.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
255ofb64ede.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
256ofb64ede.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
257ofb64ede.o: des_locl.h ofb64ede.c
258ofb64enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
259ofb64enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
260ofb64enc.o: ../../include/openssl/opensslconf.h
261ofb64enc.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
262ofb64enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
263ofb64enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
264ofb64enc.o: des_locl.h ofb64enc.c
265ofb_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
266ofb_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
267ofb_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
268ofb_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
269ofb_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
270ofb_enc.o: ../../include/openssl/ui_compat.h des_locl.h ofb_enc.c
271pcbc_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
272pcbc_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
273pcbc_enc.o: ../../include/openssl/opensslconf.h
274pcbc_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
275pcbc_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
276pcbc_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
277pcbc_enc.o: des_locl.h pcbc_enc.c
278qud_cksm.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
279qud_cksm.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
280qud_cksm.o: ../../include/openssl/opensslconf.h
281qud_cksm.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
282qud_cksm.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
283qud_cksm.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
284qud_cksm.o: des_locl.h qud_cksm.c
285rand_key.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
286rand_key.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
287rand_key.o: ../../include/openssl/opensslconf.h
288rand_key.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
289rand_key.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
290rand_key.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
291rand_key.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
292rand_key.o: rand_key.c
293read2pwd.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
294read2pwd.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
295read2pwd.o: ../../include/openssl/opensslconf.h
296read2pwd.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
297read2pwd.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
298read2pwd.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
299read2pwd.o: read2pwd.c
300rpc_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
301rpc_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
302rpc_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
303rpc_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
304rpc_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
305rpc_enc.o: ../../include/openssl/ui_compat.h des_locl.h des_ver.h rpc_des.h
306rpc_enc.o: rpc_enc.c
307set_key.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
308set_key.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
309set_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
310set_key.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
311set_key.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
312set_key.o: ../../include/openssl/ui_compat.h des_locl.h set_key.c
313str2key.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
314str2key.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
315str2key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
316str2key.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
317str2key.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
318str2key.o: ../../include/openssl/ui_compat.h des_locl.h str2key.c
319xcbc_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
320xcbc_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
321xcbc_enc.o: ../../include/openssl/opensslconf.h
322xcbc_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
323xcbc_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
324xcbc_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
325xcbc_enc.o: des_locl.h xcbc_enc.c
diff --git a/src/lib/libcrypto/des/README b/src/lib/libcrypto/des/README
new file mode 100644
index 0000000000..621a5ab467
--- /dev/null
+++ b/src/lib/libcrypto/des/README
@@ -0,0 +1,54 @@
1
2 libdes, Version 4.01 10-Jan-97
3
4 Copyright (c) 1997, Eric Young
5 All rights reserved.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms specified in COPYRIGHT.
9
10--
11The primary ftp site for this library is
12ftp://ftp.psy.uq.oz.au/pub/Crypto/DES/libdes-x.xx.tar.gz
13libdes is now also shipped with SSLeay. Primary ftp site of
14ftp://ftp.psy.uq.oz.au/pub/Crypto/SSL/SSLeay-x.x.x.tar.gz
15
16The best way to build this library is to build it as part of SSLeay.
17
18This kit builds a DES encryption library and a DES encryption program.
19It supports ecb, cbc, ofb, cfb, triple ecb, triple cbc, triple ofb,
20triple cfb, desx, and MIT's pcbc encryption modes and also has a fast
21implementation of crypt(3).
22It contains support routines to read keys from a terminal,
23generate a random key, generate a key from an arbitrary length string,
24read/write encrypted data from/to a file descriptor.
25
26The implementation was written so as to conform with the manual entry
27for the des_crypt(3) library routines from MIT's project Athena.
28
29destest should be run after compilation to test the des routines.
30rpw should be run after compilation to test the read password routines.
31The des program is a replacement for the sun des command. I believe it
32conforms to the sun version.
33
34The Imakefile is setup for use in the kerberos distribution.
35
36These routines are best compiled with gcc or any other good
37optimising compiler.
38Just turn you optimiser up to the highest settings and run destest
39after the build to make sure everything works.
40
41I believe these routines are close to the fastest and most portable DES
42routines that use small lookup tables (4.5k) that are publicly available.
43The fcrypt routine is faster than ufc's fcrypt (when compiling with
44gcc2 -O2) on the sparc 2 (1410 vs 1270) but is not so good on other machines
45(on a sun3/260 168 vs 336). It is a function of CPU on chip cache size.
46[ 10-Jan-97 and a function of an incorrect speed testing program in
47 ufc which gave much better test figures that reality ].
48
49It is worth noting that on sparc and Alpha CPUs, performance of the DES
50library can vary by upto %10 due to the positioning of files after application
51linkage.
52
53Eric Young (eay@cryptsoft.com)
54
diff --git a/src/lib/libcrypto/des/VERSION b/src/lib/libcrypto/des/VERSION
new file mode 100644
index 0000000000..c7d01542bc
--- /dev/null
+++ b/src/lib/libcrypto/des/VERSION
@@ -0,0 +1,412 @@
1 Fixed the weak key values which were wrong :-(
2 Defining SIGACTION causes sigaction() to be used instead of signal().
3 SIGUSR1/SIGUSR2 are no longer mapped in the read tty stuff because it
4 can cause problems. This should hopefully not affect normal
5 applications.
6
7Version 4.04
8 Fixed a few tests in destest. Also added x86 assember for
9 des_ncbc_encrypt() which is the standard cbc mode function.
10 This makes a very very large performace difference.
11 Ariel Glenn ariel@columbia.edu reports that the terminal
12 'turn echo off' can return (errno == EINVAL) under solaris
13 when redirection is used. So I now catch that as well as ENOTTY.
14
15
16Version 4.03
17 Left a static out of enc_write.c, which caused to buffer to be
18 continiously malloc()ed. Does anyone use these functions? I keep
19 on feeling like removing them since I only had these in there
20 for a version of kerberised login. Anyway, this was pointed out
21 by Theo de Raadt <deraadt@cvs.openbsd.org>
22 The 'n' bit ofb code was wrong, it was not shifting the shift
23 register. It worked correctly for n == 64. Thanks to
24 Gigi Ankeny <Gigi.Ankeny@Eng.Sun.COM> for pointing this one out.
25
26Version 4.02
27 I was doing 'if (memcmp(weak_keys[i],key,sizeof(key)) == 0)'
28 when checking for weak keys which is wrong :-(, pointed out by
29 Markus F.X.J. Oberhumer <markus.oberhumer@jk.uni-linz.ac.at>.
30
31Version 4.01
32 Even faster inner loop in the DES assembler for x86 and a modification
33 for IP/FP which is faster on x86. Both of these changes are
34 from Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk>. His
35 changes make the assembler run %40 faster on a pentium. This is just
36 a case of getting the instruction sequence 'just right'.
37 All credit to 'Svend' :-)
38 Quite a few special x86 'make' targets.
39 A libdes-l (lite) distribution.
40
41Version 4.00
42 After a bit of a pause, I'll up the major version number since this
43 is mostly a performace release. I've added x86 assembler and
44 added more options for performance. A %28 speedup for gcc
45 on a pentium and the assembler is a %50 speedup.
46 MIPS CPU's, sparc and Alpha are the main CPU's with speedups.
47 Run des_opts to work out which options should be used.
48 DES_RISC1/DES_RISC2 use alternative inner loops which use
49 more registers but should give speedups on any CPU that does
50 dual issue (pentium). DES_UNROLL unrolls the inner loop,
51 which costs in code size.
52
53Version 3.26
54 I've finally removed one of the shifts in D_ENCRYPT. This
55 meant I've changed the des_SPtrans table (spr.h), the set_key()
56 function and some things in des_enc.c. This has definitly
57 made things faster :-). I've known about this one for some
58 time but I've been too lazy to follow it up :-).
59 Noticed that in the D_ENCRYPT() macro, we can just do L^=(..)^(..)^..
60 instead of L^=((..)|(..)|(..).. This should save a register at
61 least.
62 Assember for x86. The file to replace is des_enc.c, which is replaced
63 by one of the assembler files found in asm. Look at des/asm/readme
64 for more info.
65
66 /* Modification to fcrypt so it can be compiled to support
67 HPUX 10.x's long password format, define -DLONGCRYPT to use this.
68 Thanks to Jens Kupferschmidt <bt1cu@hpboot.rz.uni-leipzig.de>. */
69
70 SIGWINCH case put in des_read_passwd() so the function does not
71 'exit' if this function is recieved.
72
73Version 3.25 17/07/96
74 Modified read_pwd.c so that stdin can be read if not a tty.
75 Thanks to Jeff Barber <jeffb@issl.atl.hp.com> for the patches.
76 des_init_random_number_generator() shortened due to VMS linker
77 limits.
78 Added RSA's DESX cbc mode. It is a form of cbc encryption, with 2
79 8 byte quantites xored before and after encryption.
80 des_xcbc_encryption() - the name is funny to preserve the des_
81 prefix on all functions.
82
83Version 3.24 20/04/96
84 The DES_PTR macro option checked and used by SSLeay configuration
85
86Version 3.23 11/04/96
87 Added DES_LONG. If defined to 'unsigned int' on the DEC Alpha,
88 it gives a %20 speedup :-)
89 Fixed the problem with des.pl under perl5. The patches were
90 sent by Ed Kubaitis (ejk@uiuc.edu).
91 if fcrypt.c, changed values to handle illegal salt values the way
92 normal crypt() implementations do. Some programs apparently use
93 them :-(. The patch was sent by Bjorn Gronvall <bg@sics.se>
94
95Version 3.22 29/11/95
96 Bug in des(1), an error with the uuencoding stuff when the
97 'data' is small, thanks to Geoff Keating <keagchon@mehta.anu.edu.au>
98 for the patch.
99
100Version 3.21 22/11/95
101 After some emailing back and forth with
102 Colin Plumb <colin@nyx10.cs.du.edu>, I've tweaked a few things
103 and in a future version I will probably put in some of the
104 optimisation he suggested for use with the DES_USE_PTR option.
105 Extra routines from Mark Murray <mark@grondar.za> for use in
106 freeBSD. They mostly involve random number generation for use
107 with kerberos. They involve evil machine specific system calls
108 etc so I would normally suggest pushing this stuff into the
109 application and/or using RAND_seed()/RAND_bytes() if you are
110 using this DES library as part of SSLeay.
111 Redone the read_pw() function so that it is cleaner and
112 supports termios, thanks to Sameer Parekh <sameer@c2.org>
113 for the initial patches for this.
114 Renamed 3ecb_encrypt() to ecb3_encrypt(). This has been
115 done just to make things more consistent.
116 I have also now added triple DES versions of cfb and ofb.
117
118Version 3.20
119 Damn, Damn, Damn, as pointed out by Mike_Spreitzer.PARC@xerox.com,
120 my des_random_seed() function was only copying 4 bytes of the
121 passed seed into the init structure. It is now fixed to copy 8.
122 My own suggestion is to used something like MD5 :-)
123
124Version 3.19
125 While looking at my code one day, I though, why do I keep on
126 calling des_encrypt(in,out,ks,enc) when every function that
127 calls it has in and out the same. So I dropped the 'out'
128 parameter, people should not be using this function.
129
130Version 3.18 30/08/95
131 Fixed a few bit with the distribution and the filenames.
132 3.17 had been munged via a move to DOS and back again.
133 NO CODE CHANGES
134
135Version 3.17 14/07/95
136 Fixed ede3 cbc which I had broken in 3.16. I have also
137 removed some unneeded variables in 7-8 of the routines.
138
139Version 3.16 26/06/95
140 Added des_encrypt2() which does not use IP/FP, used by triple
141 des routines. Tweaked things a bit elsewhere. %13 speedup on
142 sparc and %6 on a R4400 for ede3 cbc mode.
143
144Version 3.15 06/06/95
145 Added des_ncbc_encrypt(), it is des_cbc mode except that it is
146 'normal' and copies the new iv value back over the top of the
147 passed parameter.
148 CHANGED des_ede3_cbc_encrypt() so that it too now overwrites
149 the iv. THIS WILL BREAK EXISTING CODE, but since this function
150 only new, I feel I can change it, not so with des_cbc_encrypt :-(.
151 I need to update the documentation.
152
153Version 3.14 31/05/95
154 New release upon the world, as part of my SSL implementation.
155 New copyright and usage stuff. Basically free for all to use
156 as long as you say it came from me :-)
157
158Version 3.13 31/05/95
159 A fix in speed.c, if HZ is not defined, I set it to 100.0
160 which is reasonable for most unixes except SunOS 4.x.
161 I now have a #ifdef sun but timing for SunOS 4.x looked very
162 good :-(. At my last job where I used SunOS 4.x, it was
163 defined to be 60.0 (look at the old INSTALL documentation), at
164 the last release had it changed to 100.0 since I now work with
165 Solaris2 and SVR4 boxes.
166 Thanks to Rory Chisholm <rchishol@math.ethz.ch> for pointing this
167 one out.
168
169Version 3.12 08/05/95
170 As pointed out by The Crypt Keeper <tck@bend.UCSD.EDU>,
171 my D_ENCRYPT macro in crypt() had an un-necessary variable.
172 It has been removed.
173
174Version 3.11 03/05/95
175 Added des_ede3_cbc_encrypt() which is cbc mode des with 3 keys
176 and one iv. It is a standard and I needed it for my SSL code.
177 It makes more sense to use this for triple DES than
178 3cbc_encrypt(). I have also added (or should I say tested :-)
179 cfb64_encrypt() which is cfb64 but it will encrypt a partial
180 number of bytes - 3 bytes in 3 bytes out. Again this is for
181 my SSL library, as a form of encryption to use with SSL
182 telnet.
183
184Version 3.10 22/03/95
185 Fixed a bug in 3cbc_encrypt() :-(. When making repeated calls
186 to cbc3_encrypt, the 2 iv values that were being returned to
187 be used in the next call were reversed :-(.
188 Many thanks to Bill Wade <wade@Stoner.COM> for pointing out
189 this error.
190
191Version 3.09 01/02/95
192 Fixed des_random_key to far more random, it was rather feeble
193 with regards to picking the initial seed. The problem was
194 pointed out by Olaf Kirch <okir@monad.swb.de>.
195
196Version 3.08 14/12/94
197 Added Makefile.PL so libdes can be built into perl5.
198 Changed des_locl.h so RAND is always defined.
199
200Version 3.07 05/12/94
201 Added GNUmake and stuff so the library can be build with
202 glibc.
203
204Version 3.06 30/08/94
205 Added rpc_enc.c which contains _des_crypt. This is for use in
206 secure_rpc v 4.0
207 Finally fixed the cfb_enc problems.
208 Fixed a few parameter parsing bugs in des (-3 and -b), thanks
209 to Rob McMillan <R.McMillan@its.gu.edu.au>
210
211Version 3.05 21/04/94
212 for unsigned long l; gcc does not produce ((l>>34) == 0)
213 This causes bugs in cfb_enc.
214 Thanks to Hadmut Danisch <danisch@ira.uka.de>
215
216Version 3.04 20/04/94
217 Added a version number to des.c and libdes.a
218
219Version 3.03 12/01/94
220 Fixed a bug in non zero iv in 3cbc_enc.
221
222Version 3.02 29/10/93
223 I now work in a place where there are 6+ architectures and 14+
224 OS versions :-).
225 Fixed TERMIO definition so the most sys V boxes will work :-)
226
227Release upon comp.sources.misc
228Version 3.01 08/10/93
229 Added des_3cbc_encrypt()
230
231Version 3.00 07/10/93
232 Fixed up documentation.
233 quad_cksum definitely compatible with MIT's now.
234
235Version 2.30 24/08/93
236 Triple DES now defaults to triple cbc but can do triple ecb
237 with the -b flag.
238 Fixed some MSDOS uuen/uudecoding problems, thanks to
239 Added prototypes.
240
241Version 2.22 29/06/93
242 Fixed a bug in des_is_weak_key() which stopped it working :-(
243 thanks to engineering@MorningStar.Com.
244
245Version 2.21 03/06/93
246 des(1) with no arguments gives quite a bit of help.
247 Added -c (generate ckecksum) flag to des(1).
248 Added -3 (triple DES) flag to des(1).
249 Added cfb and ofb routines to the library.
250
251Version 2.20 11/03/93
252 Added -u (uuencode) flag to des(1).
253 I have been playing with byte order in quad_cksum to make it
254 compatible with MIT's version. All I can say is avid this
255 function if possible since MIT's output is endian dependent.
256
257Version 2.12 14/10/92
258 Added MSDOS specific macro in ecb_encrypt which gives a %70
259 speed up when the code is compiled with turbo C.
260
261Version 2.11 12/10/92
262 Speedup in set_key (recoding of PC-1)
263 I now do it in 47 simple operations, down from 60.
264 Thanks to John Fletcher (john_fletcher@lccmail.ocf.llnl.gov)
265 for motivating me to look for a faster system :-)
266 The speedup is probably less that 1% but it is still 13
267 instructions less :-).
268
269Version 2.10 06/10/92
270 The code now works on the 64bit ETA10 and CRAY without modifications or
271 #defines. I believe the code should work on any machine that
272 defines long, int or short to be 8 bytes long.
273 Thanks to Shabbir J. Safdar (shabby@mentor.cc.purdue.edu)
274 for helping me fix the code to run on 64bit machines (he had
275 access to an ETA10).
276 Thanks also to John Fletcher <john_fletcher@lccmail.ocf.llnl.gov>
277 for testing the routines on a CRAY.
278 read_password.c has been renamed to read_passwd.c
279 string_to_key.c has been renamed to string2key.c
280
281Version 2.00 14/09/92
282 Made mods so that the library should work on 64bit CPU's.
283 Removed all my uchar and ulong defs. To many different
284 versions of unix define them in their header files in too many
285 different combinations :-)
286 IRIX - Sillicon Graphics mods (mostly in read_password.c).
287 Thanks to Andrew Daviel (advax@erich.triumf.ca)
288
289Version 1.99 26/08/92
290 Fixed a bug or 2 in enc_read.c
291 Fixed a bug in enc_write.c
292 Fixed a pseudo bug in fcrypt.c (very obscure).
293
294Version 1.98 31/07/92
295 Support for the ETA10. This is a strange machine that defines
296 longs and ints as 8 bytes and shorts as 4 bytes.
297 Since I do evil things with long * that assume that they are 4
298 bytes. Look in the Makefile for the option to compile for
299 this machine. quad_cksum appears to have problems but I
300 will don't have the time to fix it right now, and this is not
301 a function that uses DES and so will not effect the main uses
302 of the library.
303
304Version 1.97 20/05/92 eay
305 Fixed the Imakefile and made some changes to des.h to fix some
306 problems when building this package with Kerberos v 4.
307
308Version 1.96 18/05/92 eay
309 Fixed a small bug in string_to_key() where problems could
310 occur if des_check_key was set to true and the string
311 generated a weak key.
312
313Patch2 posted to comp.sources.misc
314Version 1.95 13/05/92 eay
315 Added an alternative version of the D_ENCRYPT macro in
316 ecb_encrypt and fcrypt. Depending on the compiler, one version or the
317 other will be faster. This was inspired by
318 Dana How <how@isl.stanford.edu>, and her pointers about doing the
319 *(ulong *)((uchar *)ptr+(value&0xfc))
320 vs
321 ptr[value&0x3f]
322 to stop the C compiler doing a <<2 to convert the long array index.
323
324Version 1.94 05/05/92 eay
325 Fixed an incompatibility between my string_to_key and the MIT
326 version. When the key is longer than 8 chars, I was wrapping
327 with a different method. To use the old version, define
328 OLD_STR_TO_KEY in the makefile. Thanks to
329 viktor@newsu.shearson.com (Viktor Dukhovni).
330
331Version 1.93 28/04/92 eay
332 Fixed the VMS mods so that echo is now turned off in
333 read_password. Thanks again to brennan@coco.cchs.su.oz.AU.
334 MSDOS support added. The routines can be compiled with
335 Turbo C (v2.0) and MSC (v5.1). Make sure MSDOS is defined.
336
337Patch1 posted to comp.sources.misc
338Version 1.92 13/04/92 eay
339 Changed D_ENCRYPT so that the rotation of R occurs outside of
340 the loop. This required rotating all the longs in sp.h (now
341 called spr.h). Thanks to Richard Outerbridge <71755.204@CompuServe.COM>
342 speed.c has been changed so it will work without SIGALRM. If
343 times(3) is not present it will try to use ftime() instead.
344
345Version 1.91 08/04/92 eay
346 Added -E/-D options to des(1) so it can use string_to_key.
347 Added SVR4 mods suggested by witr@rwwa.COM
348 Added VMS mods suggested by brennan@coco.cchs.su.oz.AU. If
349 anyone knows how to turn of tty echo in VMS please tell me or
350 implement it yourself :-).
351 Changed FILE *IN/*OUT to *DES_IN/*DES_OUT since it appears VMS
352 does not like IN/OUT being used.
353
354Libdes posted to comp.sources.misc
355Version 1.9 24/03/92 eay
356 Now contains a fast small crypt replacement.
357 Added des(1) command.
358 Added des_rw_mode so people can use cbc encryption with
359 enc_read and enc_write.
360
361Version 1.8 15/10/91 eay
362 Bug in cbc_cksum.
363 Many thanks to Keith Reynolds (keithr@sco.COM) for pointing this
364 one out.
365
366Version 1.7 24/09/91 eay
367 Fixed set_key :-)
368 set_key is 4 times faster and takes less space.
369 There are a few minor changes that could be made.
370
371Version 1.6 19/09/1991 eay
372 Finally go IP and FP finished.
373 Now I need to fix set_key.
374 This version is quite a bit faster that 1.51
375
376Version 1.52 15/06/1991 eay
377 20% speedup in ecb_encrypt by changing the E bit selection
378 to use 2 32bit words. This also required modification of the
379 sp table. There is still a way to speedup the IP and IP-1
380 (hints from outer@sq.com) still working on this one :-(.
381
382Version 1.51 07/06/1991 eay
383 Faster des_encrypt by loop unrolling
384 Fixed bug in quad_cksum.c (thanks to hughes@logos.ucs.indiana.edu)
385
386Version 1.50 28/05/1991 eay
387 Optimised the code a bit more for the sparc. I have improved the
388 speed of the inner des_encrypt by speeding up the initial and
389 final permutations.
390
391Version 1.40 23/10/1990 eay
392 Fixed des_random_key, it did not produce a random key :-(
393
394Version 1.30 2/10/1990 eay
395 Have made des_quad_cksum the same as MIT's, the full package
396 should be compatible with MIT's
397 Have tested on a DECstation 3100
398 Still need to fix des_set_key (make it faster).
399 Does des_cbc_encrypts at 70.5k/sec on a 3100.
400
401Version 1.20 18/09/1990 eay
402 Fixed byte order dependencies.
403 Fixed (I hope) all the word alignment problems.
404 Speedup in des_ecb_encrypt.
405
406Version 1.10 11/09/1990 eay
407 Added des_enc_read and des_enc_write.
408 Still need to fix des_quad_cksum.
409 Still need to document des_enc_read and des_enc_write.
410
411Version 1.00 27/08/1990 eay
412
diff --git a/src/lib/libcrypto/des/asm/crypt586.pl b/src/lib/libcrypto/des/asm/crypt586.pl
index 1d04ed6def..3d41d82f69 100644
--- a/src/lib/libcrypto/des/asm/crypt586.pl
+++ b/src/lib/libcrypto/des/asm/crypt586.pl
@@ -26,18 +26,11 @@ sub fcrypt_body
26 26
27 &comment(""); 27 &comment("");
28 &comment("Load the 2 words"); 28 &comment("Load the 2 words");
29 $trans="ebp"; 29 $ks="ebp";
30 30
31 &xor( $L, $L); 31 &xor( $L, $L);
32 &xor( $R, $R); 32 &xor( $R, $R);
33 33 &mov($ks,&wparam(1));
34 # PIC-ification:-)
35 &picmeup("edx","DES_SPtrans");
36 #if ($cpp) { &picmeup("edx","DES_SPtrans"); }
37 #else { &lea("edx",&DWP("DES_SPtrans")); }
38 &push("edx"); # becomes &swtmp(1)
39 #
40 &mov($trans,&wparam(1)); # reloaded with DES_SPtrans in D_ENCRYPT
41 34
42 &push(&DWC(25)); # add a variable 35 &push(&DWC(25)); # add a variable
43 36
@@ -46,11 +39,11 @@ sub fcrypt_body
46 { 39 {
47 &comment(""); 40 &comment("");
48 &comment("Round $i"); 41 &comment("Round $i");
49 &D_ENCRYPT($i,$L,$R,$i*2,$trans,"eax","ebx","ecx","edx"); 42 &D_ENCRYPT($i,$L,$R,$i*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx");
50 43
51 &comment(""); 44 &comment("");
52 &comment("Round ".sprintf("%d",$i+1)); 45 &comment("Round ".sprintf("%d",$i+1));
53 &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$trans,"eax","ebx","ecx","edx"); 46 &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx");
54 } 47 }
55 &mov("ebx", &swtmp(0)); 48 &mov("ebx", &swtmp(0));
56 &mov("eax", $L); 49 &mov("eax", $L);
@@ -68,14 +61,14 @@ sub fcrypt_body
68 &mov(&DWP(0,"edx","",0),"eax"); 61 &mov(&DWP(0,"edx","",0),"eax");
69 &mov(&DWP(4,"edx","",0),$L); 62 &mov(&DWP(4,"edx","",0),$L);
70 63
71 &add("esp",8); # remove variables 64 &pop("ecx"); # remove variable
72 65
73 &function_end($name); 66 &function_end($name);
74 } 67 }
75 68
76sub D_ENCRYPT 69sub D_ENCRYPT
77 { 70 {
78 local($r,$L,$R,$S,$trans,$u,$tmp1,$tmp2,$t)=@_; 71 local($r,$L,$R,$S,$ks,$desSP,$u,$tmp1,$tmp2,$t)=@_;
79 72
80 &mov( $u, &wparam(2)); # 2 73 &mov( $u, &wparam(2)); # 2
81 &mov( $t, $R); 74 &mov( $t, $R);
@@ -92,9 +85,9 @@ sub D_ENCRYPT
92 &shl( $tmp2, 16); # 1 85 &shl( $tmp2, 16); # 1
93 &xor( $u, $tmp1); # 2 86 &xor( $u, $tmp1); # 2
94 &xor( $t, $tmp2); # 2 87 &xor( $t, $tmp2); # 2
95 &mov( $tmp1, &DWP(&n2a($S*4),$trans,"",0)); # 2 88 &mov( $tmp1, &DWP(&n2a($S*4),$ks,"",0)); # 2
96 &xor( $u, $tmp1); 89 &xor( $u, $tmp1);
97 &mov( $tmp2, &DWP(&n2a(($S+1)*4),$trans,"",0)); # 2 90 &mov( $tmp2, &DWP(&n2a(($S+1)*4),$ks,"",0)); # 2
98 &xor( $u, $R); 91 &xor( $u, $R);
99 &xor( $t, $R); 92 &xor( $t, $R);
100 &xor( $t, $tmp2); 93 &xor( $t, $tmp2);
@@ -106,28 +99,31 @@ sub D_ENCRYPT
106 &movb( &LB($tmp1), &LB($u) ); 99 &movb( &LB($tmp1), &LB($u) );
107 &movb( &LB($tmp2), &HB($u) ); 100 &movb( &LB($tmp2), &HB($u) );
108 &rotr( $t, 4 ); 101 &rotr( $t, 4 );
109 &mov( $trans, &swtmp(1)); 102 &mov( $ks, &DWP(" $desSP",$tmp1,"",0));
110 &xor( $L, &DWP(" ",$trans,$tmp1,0));
111 &movb( &LB($tmp1), &LB($t) ); 103 &movb( &LB($tmp1), &LB($t) );
112 &xor( $L, &DWP("0x200",$trans,$tmp2,0)); 104 &xor( $L, $ks);
105 &mov( $ks, &DWP("0x200+$desSP",$tmp2,"",0));
106 &xor( $L, $ks);
113 &movb( &LB($tmp2), &HB($t) ); 107 &movb( &LB($tmp2), &HB($t) );
114 &shr( $u, 16); 108 &shr( $u, 16);
115 &xor( $L, &DWP("0x100",$trans,$tmp1,0)); 109 &mov( $ks, &DWP("0x100+$desSP",$tmp1,"",0));
110 &xor( $L, $ks);
116 &movb( &LB($tmp1), &HB($u) ); 111 &movb( &LB($tmp1), &HB($u) );
117 &shr( $t, 16); 112 &shr( $t, 16);
118 &xor( $L, &DWP("0x300",$trans,$tmp2,0)); 113 &mov( $ks, &DWP("0x300+$desSP",$tmp2,"",0));
114 &xor( $L, $ks);
115 &mov( $ks, &wparam(1));
119 &movb( &LB($tmp2), &HB($t) ); 116 &movb( &LB($tmp2), &HB($t) );
120 &and( $u, "0xff" ); 117 &and( $u, "0xff" );
121 &and( $t, "0xff" ); 118 &and( $t, "0xff" );
122 &mov( $tmp1, &DWP("0x600",$trans,$tmp1,0)); 119 &mov( $tmp1, &DWP("0x600+$desSP",$tmp1,"",0));
123 &xor( $L, $tmp1); 120 &xor( $L, $tmp1);
124 &mov( $tmp1, &DWP("0x700",$trans,$tmp2,0)); 121 &mov( $tmp1, &DWP("0x700+$desSP",$tmp2,"",0));
125 &xor( $L, $tmp1); 122 &xor( $L, $tmp1);
126 &mov( $tmp1, &DWP("0x400",$trans,$u,0)); 123 &mov( $tmp1, &DWP("0x400+$desSP",$u,"",0));
127 &xor( $L, $tmp1); 124 &xor( $L, $tmp1);
128 &mov( $tmp1, &DWP("0x500",$trans,$t,0)); 125 &mov( $tmp1, &DWP("0x500+$desSP",$t,"",0));
129 &xor( $L, $tmp1); 126 &xor( $L, $tmp1);
130 &mov( $trans, &wparam(1));
131 } 127 }
132 128
133sub n2a 129sub n2a
diff --git a/src/lib/libcrypto/des/asm/des-586.pl b/src/lib/libcrypto/des/asm/des-586.pl
index b75d3c6b3a..0d08e8a3a9 100644
--- a/src/lib/libcrypto/des/asm/des-586.pl
+++ b/src/lib/libcrypto/des/asm/des-586.pl
@@ -40,7 +40,7 @@ sub DES_encrypt
40 40
41 &comment(""); 41 &comment("");
42 &comment("Load the 2 words"); 42 &comment("Load the 2 words");
43 $trans="ebp"; 43 $ks="ebp";
44 44
45 if ($do_ip) 45 if ($do_ip)
46 { 46 {
@@ -72,12 +72,7 @@ sub DES_encrypt
72 &rotl($L,3); 72 &rotl($L,3);
73 } 73 }
74 74
75 # PIC-ification:-) 75 &mov( $ks, &wparam(1) );
76 &picmeup($trans,"DES_SPtrans");
77 #if ($cpp) { &picmeup($trans,"DES_SPtrans"); }
78 #else { &lea($trans,&DWP("DES_SPtrans")); }
79
80 &mov( "ecx", &wparam(1) );
81 &cmp("ebx","0"); 76 &cmp("ebx","0");
82 &je(&label("start_decrypt")); 77 &je(&label("start_decrypt"));
83 78
@@ -85,11 +80,11 @@ sub DES_encrypt
85 { 80 {
86 &comment(""); 81 &comment("");
87 &comment("Round $i"); 82 &comment("Round $i");
88 &D_ENCRYPT($i,$L,$R,$i*2,$trans,"eax","ebx","ecx","edx"); 83 &D_ENCRYPT($i,$L,$R,$i*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx");
89 84
90 &comment(""); 85 &comment("");
91 &comment("Round ".sprintf("%d",$i+1)); 86 &comment("Round ".sprintf("%d",$i+1));
92 &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$trans,"eax","ebx","ecx","edx"); 87 &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx");
93 } 88 }
94 &jmp(&label("end")); 89 &jmp(&label("end"));
95 90
@@ -99,10 +94,10 @@ sub DES_encrypt
99 { 94 {
100 &comment(""); 95 &comment("");
101 &comment("Round $i"); 96 &comment("Round $i");
102 &D_ENCRYPT(15-$i,$L,$R,$i*2,$trans,"eax","ebx","ecx","edx"); 97 &D_ENCRYPT(15-$i,$L,$R,$i*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx");
103 &comment(""); 98 &comment("");
104 &comment("Round ".sprintf("%d",$i-1)); 99 &comment("Round ".sprintf("%d",$i-1));
105 &D_ENCRYPT(15-$i+1,$R,$L,($i-1)*2,$trans,"eax","ebx","ecx","edx"); 100 &D_ENCRYPT(15-$i+1,$R,$L,($i-1)*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx");
106 } 101 }
107 102
108 &set_label("end"); 103 &set_label("end");
@@ -139,36 +134,43 @@ sub DES_encrypt
139 134
140sub D_ENCRYPT 135sub D_ENCRYPT
141 { 136 {
142 local($r,$L,$R,$S,$trans,$u,$tmp1,$tmp2,$t)=@_; 137 local($r,$L,$R,$S,$ks,$desSP,$u,$tmp1,$tmp2,$t)=@_;
143 138
144 &mov( $u, &DWP(&n2a($S*4),$tmp2,"",0)); 139 &mov( $u, &DWP(&n2a($S*4),$ks,"",0));
145 &xor( $tmp1, $tmp1); 140 &xor( $tmp1, $tmp1);
146 &mov( $t, &DWP(&n2a(($S+1)*4),$tmp2,"",0)); 141 &mov( $t, &DWP(&n2a(($S+1)*4),$ks,"",0));
147 &xor( $u, $R); 142 &xor( $u, $R);
148 &xor( $tmp2, $tmp2);
149 &xor( $t, $R); 143 &xor( $t, $R);
150 &and( $u, "0xfcfcfcfc" ); 144 &and( $u, "0xfcfcfcfc" );
151 &and( $t, "0xcfcfcfcf" ); 145 &and( $t, "0xcfcfcfcf" );
152 &movb( &LB($tmp1), &LB($u) ); 146 &movb( &LB($tmp1), &LB($u) );
153 &movb( &LB($tmp2), &HB($u) ); 147 &movb( &LB($tmp2), &HB($u) );
154 &rotr( $t, 4 ); 148 &rotr( $t, 4 );
155 &xor( $L, &DWP(" ",$trans,$tmp1,0)); 149 &mov( $ks, &DWP(" $desSP",$tmp1,"",0));
156 &movb( &LB($tmp1), &LB($t) ); 150 &movb( &LB($tmp1), &LB($t) );
157 &xor( $L, &DWP("0x200",$trans,$tmp2,0)); 151 &xor( $L, $ks);
152 &mov( $ks, &DWP("0x200+$desSP",$tmp2,"",0));
153 &xor( $L, $ks); ######
158 &movb( &LB($tmp2), &HB($t) ); 154 &movb( &LB($tmp2), &HB($t) );
159 &shr( $u, 16); 155 &shr( $u, 16);
160 &xor( $L, &DWP("0x100",$trans,$tmp1,0)); 156 &mov( $ks, &DWP("0x100+$desSP",$tmp1,"",0));
157 &xor( $L, $ks); ######
161 &movb( &LB($tmp1), &HB($u) ); 158 &movb( &LB($tmp1), &HB($u) );
162 &shr( $t, 16); 159 &shr( $t, 16);
163 &xor( $L, &DWP("0x300",$trans,$tmp2,0)); 160 &mov( $ks, &DWP("0x300+$desSP",$tmp2,"",0));
161 &xor( $L, $ks);
162 &mov( $ks, &wparam(1) );
164 &movb( &LB($tmp2), &HB($t) ); 163 &movb( &LB($tmp2), &HB($t) );
165 &and( $u, "0xff" ); 164 &and( $u, "0xff" );
166 &and( $t, "0xff" ); 165 &and( $t, "0xff" );
167 &xor( $L, &DWP("0x600",$trans,$tmp1,0)); 166 &mov( $tmp1, &DWP("0x600+$desSP",$tmp1,"",0));
168 &xor( $L, &DWP("0x700",$trans,$tmp2,0)); 167 &xor( $L, $tmp1);
169 &mov( $tmp2, &wparam(1) ); 168 &mov( $tmp1, &DWP("0x700+$desSP",$tmp2,"",0));
170 &xor( $L, &DWP("0x400",$trans,$u,0)); 169 &xor( $L, $tmp1);
171 &xor( $L, &DWP("0x500",$trans,$t,0)); 170 &mov( $tmp1, &DWP("0x400+$desSP",$u,"",0));
171 &xor( $L, $tmp1);
172 &mov( $tmp1, &DWP("0x500+$desSP",$t,"",0));
173 &xor( $L, $tmp1);
172 } 174 }
173 175
174sub n2a 176sub n2a
diff --git a/src/lib/libcrypto/des/asm/des686.pl b/src/lib/libcrypto/des/asm/des686.pl
new file mode 100644
index 0000000000..d3ad5d5edd
--- /dev/null
+++ b/src/lib/libcrypto/des/asm/des686.pl
@@ -0,0 +1,230 @@
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/asm/readme b/src/lib/libcrypto/des/asm/readme
new file mode 100644
index 0000000000..1beafe253b
--- /dev/null
+++ b/src/lib/libcrypto/des/asm/readme
@@ -0,0 +1,131 @@
1First up, let me say I don't like writing in assembler. It is not portable,
2dependant on the particular CPU architecture release and is generally a pig
3to debug and get right. Having said that, the x86 architecture is probably
4the most important for speed due to number of boxes and since
5it appears to be the worst architecture to to get
6good C compilers for. So due to this, I have lowered myself to do
7assembler for the inner DES routines in libdes :-).
8
9The file to implement in assembler is des_enc.c. Replace the following
104 functions
11des_encrypt1(DES_LONG data[2],des_key_schedule ks, int encrypt);
12des_encrypt2(DES_LONG data[2],des_key_schedule ks, int encrypt);
13des_encrypt3(DES_LONG data[2],des_key_schedule ks1,ks2,ks3);
14des_decrypt3(DES_LONG data[2],des_key_schedule ks1,ks2,ks3);
15
16They encrypt/decrypt the 64 bits held in 'data' using
17the 'ks' key schedules. The only difference between the 4 functions is that
18des_encrypt2() does not perform IP() or FP() on the data (this is an
19optimization for when doing triple DES and des_encrypt3() and des_decrypt3()
20perform triple des. The triple DES routines are in here because it does
21make a big difference to have them located near the des_encrypt2 function
22at link time..
23
24Now as we all know, there are lots of different operating systems running on
25x86 boxes, and unfortunately they normally try to make sure their assembler
26formating is not the same as the other peoples.
27The 4 main formats I know of are
28Microsoft Windows 95/Windows NT
29Elf Includes Linux and FreeBSD(?).
30a.out The older Linux.
31Solaris Same as Elf but different comments :-(.
32
33Now I was not overly keen to write 4 different copies of the same code,
34so I wrote a few perl routines to output the correct assembler, given
35a target assembler type. This code is ugly and is just a hack.
36The libraries are x86unix.pl and x86ms.pl.
37des586.pl, des686.pl and des-som[23].pl are the programs to actually
38generate the assembler.
39
40So to generate elf assembler
41perl des-som3.pl elf >dx86-elf.s
42For Windows 95/NT
43perl des-som2.pl win32 >win32.asm
44
45[ update 4 Jan 1996 ]
46I have added another way to do things.
47perl des-som3.pl cpp >dx86-cpp.s
48generates a file that will be included by dx86unix.cpp when it is compiled.
49To build for elf, a.out, solaris, bsdi etc,
50cc -E -DELF asm/dx86unix.cpp | as -o asm/dx86-elf.o
51cc -E -DSOL asm/dx86unix.cpp | as -o asm/dx86-sol.o
52cc -E -DOUT asm/dx86unix.cpp | as -o asm/dx86-out.o
53cc -E -DBSDI asm/dx86unix.cpp | as -o asm/dx86bsdi.o
54This was done to cut down the number of files in the distribution.
55
56Now the ugly part. I acquired my copy of Intels
57"Optimization's For Intel's 32-Bit Processors" and found a few interesting
58things. First, the aim of the exersize is to 'extract' one byte at a time
59from a word and do an array lookup. This involves getting the byte from
60the 4 locations in the word and moving it to a new word and doing the lookup.
61The most obvious way to do this is
62xor eax, eax # clear word
63movb al, cl # get low byte
64xor edi DWORD PTR 0x100+des_SP[eax] # xor in word
65movb al, ch # get next byte
66xor edi DWORD PTR 0x300+des_SP[eax] # xor in word
67shr ecx 16
68which seems ok. For the pentium, this system appears to be the best.
69One has to do instruction interleaving to keep both functional units
70operating, but it is basically very efficient.
71
72Now the crunch. When a full register is used after a partial write, eg.
73mov al, cl
74xor edi, DWORD PTR 0x100+des_SP[eax]
75386 - 1 cycle stall
76486 - 1 cycle stall
77586 - 0 cycle stall
78686 - at least 7 cycle stall (page 22 of the above mentioned document).
79
80So the technique that produces the best results on a pentium, according to
81the documentation, will produce hideous results on a pentium pro.
82
83To get around this, des686.pl will generate code that is not as fast on
84a pentium, should be very good on a pentium pro.
85mov eax, ecx # copy word
86shr ecx, 8 # line up next byte
87and eax, 0fch # mask byte
88xor edi DWORD PTR 0x100+des_SP[eax] # xor in array lookup
89mov eax, ecx # get word
90shr ecx 8 # line up next byte
91and eax, 0fch # mask byte
92xor edi DWORD PTR 0x300+des_SP[eax] # xor in array lookup
93
94Due to the execution units in the pentium, this actually works quite well.
95For a pentium pro it should be very good. This is the type of output
96Visual C++ generates.
97
98There is a third option. instead of using
99mov al, ch
100which is bad on the pentium pro, one may be able to use
101movzx eax, ch
102which may not incur the partial write penalty. On the pentium,
103this instruction takes 4 cycles so is not worth using but on the
104pentium pro it appears it may be worth while. I need access to one to
105experiment :-).
106
107eric (20 Oct 1996)
108
10922 Nov 1996 - I have asked people to run the 2 different version on pentium
110pros and it appears that the intel documentation is wrong. The
111mov al,bh is still faster on a pentium pro, so just use the des586.pl
112install des686.pl
113
1143 Dec 1996 - I added des_encrypt3/des_decrypt3 because I have moved these
115functions into des_enc.c because it does make a massive performance
116difference on some boxes to have the functions code located close to
117the des_encrypt2() function.
118
1199 Jan 1997 - des-som2.pl is now the correct perl script to use for
120pentiums. It contains an inner loop from
121Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk> which does raw ecb DES calls at
122273,000 per second. He had a previous version at 250,000 and the best
123I was able to get was 203,000. The content has not changed, this is all
124due to instruction sequencing (and actual instructions choice) which is able
125to keep both functional units of the pentium going.
126We may have lost the ugly register usage restrictions when x86 went 32 bit
127but for the pentium it has been replaced by evil instruction ordering tricks.
128
12913 Jan 1997 - des-som3.pl, more optimizations from Svend Olaf.
130raw DES at 281,000 per second on a pentium 100.
131
diff --git a/src/lib/libcrypto/des/cbc3_enc.c b/src/lib/libcrypto/des/cbc3_enc.c
new file mode 100644
index 0000000000..b5db4e14f7
--- /dev/null
+++ b/src/lib/libcrypto/des/cbc3_enc.c
@@ -0,0 +1,99 @@
1/* crypto/des/cbc3_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
61/* HAS BUGS! DON'T USE - this is only present for use in des.c */
62void DES_3cbc_encrypt(DES_cblock *input, DES_cblock *output, long length,
63 DES_key_schedule ks1, DES_key_schedule ks2, DES_cblock *iv1,
64 DES_cblock *iv2, int enc)
65 {
66 int off=((int)length-1)/8;
67 long l8=((length+7)/8)*8;
68 DES_cblock niv1,niv2;
69
70 if (enc == DES_ENCRYPT)
71 {
72 DES_cbc_encrypt((unsigned char*)input,
73 (unsigned char*)output,length,&ks1,iv1,enc);
74 if (length >= sizeof(DES_cblock))
75 memcpy(niv1,output[off],sizeof(DES_cblock));
76 DES_cbc_encrypt((unsigned char*)output,
77 (unsigned char*)output,l8,&ks2,iv1,!enc);
78 DES_cbc_encrypt((unsigned char*)output,
79 (unsigned char*)output,l8,&ks1,iv2,enc);
80 if (length >= sizeof(DES_cblock))
81 memcpy(niv2,output[off],sizeof(DES_cblock));
82 }
83 else
84 {
85 if (length >= sizeof(DES_cblock))
86 memcpy(niv2,input[off],sizeof(DES_cblock));
87 DES_cbc_encrypt((unsigned char*)input,
88 (unsigned char*)output,l8,&ks1,iv2,enc);
89 DES_cbc_encrypt((unsigned char*)output,
90 (unsigned char*)output,l8,&ks2,iv1,!enc);
91 if (length >= sizeof(DES_cblock))
92 memcpy(niv1,output[off],sizeof(DES_cblock));
93 DES_cbc_encrypt((unsigned char*)output,
94 (unsigned char*)output,length,&ks1,iv1,enc);
95 }
96 memcpy(*iv1,niv1,sizeof(DES_cblock));
97 memcpy(*iv2,niv2,sizeof(DES_cblock));
98 }
99
diff --git a/src/lib/libcrypto/des/cbc_cksm.c b/src/lib/libcrypto/des/cbc_cksm.c
index 09a7ba56aa..6c5305b99d 100644
--- a/src/lib/libcrypto/des/cbc_cksm.c
+++ b/src/lib/libcrypto/des/cbc_cksm.c
@@ -93,14 +93,5 @@ DES_LONG DES_cbc_cksum(const unsigned char *in, DES_cblock *output,
93 l2c(tout1,out); 93 l2c(tout1,out);
94 } 94 }
95 tout0=tin0=tin1=tin[0]=tin[1]=0; 95 tout0=tin0=tin1=tin[0]=tin[1]=0;
96 /*
97 Transform the data in tout1 so that it will
98 match the return value that the MIT Kerberos
99 mit_des_cbc_cksum API returns.
100 */
101 tout1 = ((tout1 >> 24L) & 0x000000FF)
102 | ((tout1 >> 8L) & 0x0000FF00)
103 | ((tout1 << 8L) & 0x00FF0000)
104 | ((tout1 << 24L) & 0xFF000000);
105 return(tout1); 96 return(tout1);
106 } 97 }
diff --git a/src/lib/libcrypto/des/des-lib.com b/src/lib/libcrypto/des/des-lib.com
new file mode 100644
index 0000000000..fc2c35a1ce
--- /dev/null
+++ b/src/lib/libcrypto/des/des-lib.com
@@ -0,0 +1,1003 @@
1$!
2$! DES-LIB.COM
3$! Written By: Robert Byer
4$! Vice-President
5$! A-Com Computing, Inc.
6$! byer@mail.all-net.net
7$!
8$! Changes by Richard Levitte <richard@levitte.org>
9$!
10$! This command files compiles and creates the
11$! "[.xxx.EXE.CRYPTO.DES]LIBDES.OLB" library. The "xxx" denotes the machine
12$! architecture of AXP or VAX.
13$!
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.
16$!
17$! Specify one of the following to build just that part, specify "ALL" to
18$! just build everything.
19$!
20$! ALL To Just Build "Everything".
21$! LIBRARY To Just Build The [.xxx.EXE.CRYPTO.DES]LIBDES.OLB Library.
22$! DESTEST To Just Build The [.xxx.EXE.CRYPTO.DES]DESTEST.EXE Program.
23$! SPEED To Just Build The [.xxx.EXE.CRYPTO.DES]SPEED.EXE Program.
24$! RPW To Just Build The [.xxx.EXE.CRYPTO.DES]RPW.EXE Program.
25$! DES To Just Build The [.xxx.EXE.CRYPTO.DES]DES.EXE Program.
26$! DES_OPTS To Just Build The [.xxx.EXE.CRYPTO.DES]DES_OPTS.EXE Program.
27$!
28$! Specify either DEBUG or NODEBUG as P2 to compile with or without
29$! debugging information.
30$!
31$! Specify which compiler at P3 to try to compile under.
32$!
33$! VAXC For VAX C.
34$! DECC For DEC C.
35$! GNUC For GNU C.
36$!
37$! If you don't speficy a compiler, it will try to determine which
38$! "C" compiler to try to use.
39$!
40$! P4, if defined, sets a compiler thread NOT needed on OpenVMS 7.1 (and up)
41$!
42$!
43$! Make sure we know what architecture we run on.
44$!
45$!
46$! Check Which Architecture We Are Using.
47$!
48$ IF (F$GETSYI("CPU").GE.128)
49$ THEN
50$!
51$! The Architecture Is AXP.
52$!
53$ ARCH := AXP
54$!
55$! Else...
56$!
57$ ELSE
58$!
59$! The Architecture Is VAX.
60$!
61$ ARCH := VAX
62$!
63$! End The Architecture Check.
64$!
65$ ENDIF
66$!
67$! Check To Make Sure We Have Valid Command Line Parameters.
68$!
69$ GOSUB CHECK_OPTIONS
70$!
71$! Tell The User What Kind of Machine We Run On.
72$!
73$ WRITE SYS$OUTPUT "Compiling On A ",ARCH," Machine."
74$!
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.
80$!
81$ IF (F$PARSE(OBJ_DIR).EQS."")
82$ THEN
83$!
84$! It Dosen't Exist, So Create It.
85$!
86$ CREATE/DIR 'OBJ_DIR'
87$!
88$! End The Architecture Specific OBJ Directory Check.
89$!
90$ ENDIF
91$!
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$!
98$ IF (F$PARSE(EXE_DIR).EQS."")
99$ THEN
100$!
101$! It Dosen't Exist, So Create It.
102$!
103$ CREATE/DIR 'EXE_DIR'
104$!
105$! End The Architecture Specific Directory Check.
106$!
107$ ENDIF
108$!
109$! Define The Library Name.
110$!
111$ LIB_NAME := 'EXE_DIR'LIBDES.OLB
112$!
113$! Check To See What We Are To Do.
114$!
115$ IF (BUILDALL.EQS."TRUE")
116$ THEN
117$!
118$! Since Nothing Special Was Specified, Do Everything.
119$!
120$ GOSUB LIBRARY
121$ GOSUB DESTEST
122$ GOSUB SPEED
123$ GOSUB RPW
124$ GOSUB DES
125$ GOSUB DES_OPTS
126$!
127$! Else...
128$!
129$ ELSE
130$!
131$! Build Just What The User Wants Us To Build.
132$!
133$ GOSUB 'BUILDALL'
134$!
135$! End The BUILDALL Check.
136$!
137$ ENDIF
138$!
139$! Time To EXIT.
140$!
141$ EXIT
142$ LIBRARY:
143$!
144$! Tell The User That We Are Compiling.
145$!
146$ WRITE SYS$OUTPUT "Compiling The ",LIB_NAME," Files."
147$!
148$! Check To See If We Already Have A "[.xxx.EXE.CRYPTO.DES]LIBDES.OLB" Library...
149$!
150$ IF (F$SEARCH(LIB_NAME).EQS."")
151$ THEN
152$!
153$! Guess Not, Create The Library.
154$!
155$ LIBRARY/CREATE/OBJECT 'LIB_NAME'
156$!
157$! End The Library Exist Check.
158$!
159$ ENDIF
160$!
161$! Define The DES Library Files.
162$!
163$ LIB_DES = "set_key,ecb_enc,cbc_enc,"+ -
164 "ecb3_enc,cfb64enc,cfb64ede,cfb_enc,ofb64ede,"+ -
165 "enc_read,enc_writ,ofb64enc,"+ -
166 "ofb_enc,str2key,pcbc_enc,qud_cksm,rand_key,"+ -
167 "des_enc,fcrypt_b,read2pwd,"+ -
168 "fcrypt,xcbc_enc,read_pwd,rpc_enc,cbc_cksm,supp"
169$!
170$! Define A File Counter And Set It To "0".
171$!
172$ FILE_COUNTER = 0
173$!
174$! Top Of The File Loop.
175$!
176$ NEXT_FILE:
177$!
178$! O.K, Extract The File Name From The File List.
179$!
180$ FILE_NAME = F$ELEMENT(FILE_COUNTER,",",LIB_DES)
181$!
182$! Check To See If We Are At The End Of The File List.
183$!
184$ IF (FILE_NAME.EQS.",") THEN GOTO FILE_DONE
185$!
186$! Increment The Counter.
187$!
188$ FILE_COUNTER = FILE_COUNTER + 1
189$!
190$! Create The Source File Name.
191$!
192$ SOURCE_FILE = "SYS$DISK:[]" + FILE_NAME + ".C"
193$!
194$! Tell The User We Are Compiling The Source File.
195$!
196$ WRITE SYS$OUTPUT " ",FILE_NAME,".C"
197$!
198$! Create The Object File Name.
199$!
200$ OBJECT_FILE = OBJ_DIR + FILE_NAME + "." + ARCH + "OBJ"
201$ ON WARNING THEN GOTO NEXT_FILE
202$!
203$! Check To See If The File We Want To Compile Actually Exists.
204$!
205$ IF (F$SEARCH(SOURCE_FILE).EQS."")
206$ THEN
207$!
208$! Tell The User That The File Dosen't Exist.
209$!
210$ WRITE SYS$OUTPUT ""
211$ WRITE SYS$OUTPUT "The File ",SOURCE_FILE," Dosen't Exist."
212$ WRITE SYS$OUTPUT ""
213$!
214$! Exit The Build.
215$!
216$ EXIT
217$!
218$! End The File Exists Check.
219$!
220$ ENDIF
221$!
222$! Compile The File.
223$!
224$ ON ERROR THEN GOTO NEXT_FILE
225$ CC/OBJECT='OBJECT_FILE' 'SOURCE_FILE'
226$!
227$! Add It To The Library.
228$!
229$ LIBRARY/REPLACE/OBJECT 'LIB_NAME' 'OBJECT_FILE'
230$!
231$! Time To Clean Up The Object File.
232$!
233$ DELETE 'OBJECT_FILE';*
234$!
235$! Go Back And Do It Again.
236$!
237$ GOTO NEXT_FILE
238$!
239$! All Done With This Library Part.
240$!
241$ FILE_DONE:
242$!
243$! Tell The User That We Are All Done.
244$!
245$ WRITE SYS$OUTPUT "Library ",LIB_NAME," Built."
246$!
247$! All Done, Time To Return.
248$!
249$ RETURN
250$!
251$! Compile The DESTEST Program.
252$!
253$ DESTEST:
254$!
255$! Check To See If We Have The Proper Libraries.
256$!
257$ GOSUB LIB_CHECK
258$!
259$! Check To See If We Have A Linker Option File.
260$!
261$ GOSUB CHECK_OPT_FILE
262$!
263$! Check To See If The File We Want To Compile Actually Exists.
264$!
265$ IF (F$SEARCH("SYS$DISK:[]DESTEST.C").EQS."")
266$ THEN
267$!
268$! Tell The User That The File Dosen't Exist.
269$!
270$ WRITE SYS$OUTPUT ""
271$ WRITE SYS$OUTPUT "The File DESTEST.C Dosen't Exist."
272$ WRITE SYS$OUTPUT ""
273$!
274$! Exit The Build.
275$!
276$ EXIT
277$!
278$! End The DESTEST.C File Check.
279$!
280$ ENDIF
281$!
282$! Tell The User What We Are Building.
283$!
284$ WRITE SYS$OUTPUT "Building ",EXE_DIR,"DESTEST.EXE"
285$!
286$! Compile The DESTEST Program.
287$!
288$ CC/OBJECT='OBJ_DIR'DESTEST.OBJ SYS$DISK:[]DESTEST.C
289$!
290$! Link The DESTEST Program.
291$!
292$ LINK/'DEBUGGER'/'TRACEBACK'/CONTIGUOUS/EXE='EXE_DIR'DESTEST.EXE -
293 'OBJ_DIR'DESTEST.OBJ,'LIB_NAME'/LIBRARY,'OPT_FILE'/OPTION
294$!
295$! All Done, Time To Return.
296$!
297$ RETURN
298$!
299$! Compile The SPEED Program.
300$!
301$ SPEED:
302$!
303$! Check To See If We Have The Proper Libraries.
304$!
305$ GOSUB LIB_CHECK
306$!
307$! Check To See If We Have A Linker Option File.
308$!
309$ GOSUB CHECK_OPT_FILE
310$!
311$! Check To See If The File We Want To Compile Actually Exists.
312$!
313$ IF (F$SEARCH("SYS$DISK:[]SPEED.C").EQS."")
314$ THEN
315$!
316$! Tell The User That The File Dosen't Exist.
317$!
318$ WRITE SYS$OUTPUT ""
319$ WRITE SYS$OUTPUT "The File SPEED.C Dosen't Exist."
320$ WRITE SYS$OUTPUT ""
321$!
322$! Exit The Build.
323$!
324$ EXIT
325$!
326$! End The SPEED.C File Check.
327$!
328$ ENDIF
329$!
330$! Tell The User What We Are Building.
331$!
332$ WRITE SYS$OUTPUT "Building ",EXE_DIR,"SPEED.EXE"
333$!
334$! Compile The SPEED Program.
335$!
336$ CC/OBJECT='OBJ_DIR'SPEED.OBJ SYS$DISK:[]SPEED.C
337$!
338$! Link The SPEED Program.
339$!
340$ LINK/'DEBUGGER'/'TRACEBACK'/CONTIGUOUS/EXE='EXE_DIR'SPEED.EXE -
341 'OBJ_DIR'SPEED.OBJ,'LIB_NAME'/LIBRARY,'OPT_FILE'/OPTION
342$!
343$! All Done, Time To Return.
344$!
345$ RETURN
346$!
347$! Compile The RPW Program.
348$!
349$ RPW:
350$!
351$! Check To See If We Have The Proper Libraries.
352$!
353$ GOSUB LIB_CHECK
354$!
355$! Check To See If We Have A Linker Option File.
356$!
357$ GOSUB CHECK_OPT_FILE
358$!
359$! Check To See If The File We Want To Compile Actually Exists.
360$!
361$ IF (F$SEARCH("SYS$DISK:[]RPW.C").EQS."")
362$ THEN
363$!
364$! Tell The User That The File Dosen't Exist.
365$!
366$ WRITE SYS$OUTPUT ""
367$ WRITE SYS$OUTPUT "The File RPW.C Dosen't Exist."
368$ WRITE SYS$OUTPUT ""
369$!
370$! Exit The Build.
371$!
372$ EXIT
373$!
374$! End The RPW.C File Check.
375$!
376$ ENDIF
377$!
378$! Tell The User What We Are Building.
379$!
380$ WRITE SYS$OUTPUT "Building ",EXE_DIR,"RPW.EXE"
381$!
382$! Compile The RPW Program.
383$!
384$ CC/OBJECT='OBJ_DIR'RPW.OBJ SYS$DISK:[]RPW.C
385$!
386$! Link The RPW Program.
387$!
388$ LINK/'DEBUGGER'/'TRACEBACK'/CONTIGUOUS/EXE='EXE_DIR'RPW.EXE -
389 'OBJ_DIR'RPW.OBJ,'LIB_NAME'/LIBRARY,'OPT_FILE'/OPTION
390$!
391$! All Done, Time To Return.
392$!
393$ RETURN
394$!
395$! Compile The DES Program.
396$!
397$ DES:
398$!
399$! Check To See If We Have The Proper Libraries.
400$!
401$ GOSUB LIB_CHECK
402$!
403$! Check To See If We Have A Linker Option File.
404$!
405$ GOSUB CHECK_OPT_FILE
406$!
407$! Check To See If The File We Want To Compile Actually Exists.
408$!
409$ IF (F$SEARCH("SYS$DISK:[]DES.C").EQS."")
410$ THEN
411$!
412$! Tell The User That The File Dosen't Exist.
413$!
414$ WRITE SYS$OUTPUT ""
415$ WRITE SYS$OUTPUT "The File DES.C Dosen't Exist."
416$ WRITE SYS$OUTPUT ""
417$!
418$! Exit The Build.
419$!
420$ EXIT
421$!
422$! End The DES.C File Check.
423$!
424$ ENDIF
425$!
426$! Tell The User What We Are Building.
427$!
428$ WRITE SYS$OUTPUT "Building ",EXE_DIR,"DES.EXE"
429$!
430$! Compile The DES Program.
431$!
432$ CC/OBJECT='OBJ_DIR'DES.OBJ SYS$DISK:[]DES.C
433$ CC/OBJECT='OBJ_DIR'DES.OBJ SYS$DISK:[]CBC3_ENC.C
434$!
435$! Link The DES Program.
436$!
437$ LINK/'DEBUGGER'/'TRACEBACK'/CONTIGUOUS/EXE='EXE_DIR'DES.EXE -
438 'OBJ_DIR'DES.OBJ,'OBJ_DIR'CBC3_ENC.OBJ,-
439 'LIB_NAME'/LIBRARY,'OPT_FILE'/OPTION
440$!
441$! All Done, Time To Return.
442$!
443$ RETURN
444$!
445$! Compile The DES_OPTS Program.
446$!
447$ DES_OPTS:
448$!
449$! Check To See If We Have The Proper Libraries.
450$!
451$ GOSUB LIB_CHECK
452$!
453$! Check To See If We Have A Linker Option File.
454$!
455$ GOSUB CHECK_OPT_FILE
456$!
457$! Check To See If The File We Want To Compile Actually Exists.
458$!
459$ IF (F$SEARCH("SYS$DISK:[]DES_OPTS.C").EQS."")
460$ THEN
461$!
462$! Tell The User That The File Dosen't Exist.
463$!
464$ WRITE SYS$OUTPUT ""
465$ WRITE SYS$OUTPUT "The File DES_OPTS.C Dosen't Exist."
466$ WRITE SYS$OUTPUT ""
467$!
468$! Exit The Build.
469$!
470$ EXIT
471$!
472$! End The DES_OPTS.C File Check.
473$!
474$ ENDIF
475$!
476$! Tell The User What We Are Building.
477$!
478$ WRITE SYS$OUTPUT "Building ",EXE_DIR,"DES_OPTS.EXE"
479$!
480$! Compile The DES_OPTS Program.
481$!
482$ CC/OBJECT='OBJ_DIR'DES_OPTS.OBJ SYS$DISK:[]DES_OPTS.C
483$!
484$! Link The DES_OPTS Program.
485$!
486$ LINK/'DEBUGGER'/'TRACEBACK'/CONTIGUOUS/EXE='EXE_DIR'DES_OPTS.EXE -
487 'OBJ_DIR'DES_OPTS.OBJ,'LIB_NAME'/LIBRARY,'OPT_FILE'/OPTION
488$!
489$! All Done, Time To Return.
490$!
491$ RETURN
492$ EXIT
493$!
494$! Check For The Link Option FIle.
495$!
496$ CHECK_OPT_FILE:
497$!
498$! Check To See If We Need To Make A VAX C Option File.
499$!
500$ IF (COMPILER.EQS."VAXC")
501$ THEN
502$!
503$! Check To See If We Already Have A VAX C Linker Option File.
504$!
505$ IF (F$SEARCH(OPT_FILE).EQS."")
506$ THEN
507$!
508$! We Need A VAX C Linker Option File.
509$!
510$ CREATE 'OPT_FILE'
511$DECK
512!
513! Default System Options File To Link Agianst
514! The Sharable VAX C Runtime Library.
515!
516SYS$SHARE:VAXCRTL.EXE/SHARE
517$EOD
518$!
519$! End The Option File Check.
520$!
521$ ENDIF
522$!
523$! End The VAXC Check.
524$!
525$ ENDIF
526$!
527$! Check To See If We Need A GNU C Option File.
528$!
529$ IF (COMPILER.EQS."GNUC")
530$ THEN
531$!
532$! Check To See If We Already Have A GNU C Linker Option File.
533$!
534$ IF (F$SEARCH(OPT_FILE).EQS."")
535$ THEN
536$!
537$! We Need A GNU C Linker Option File.
538$!
539$ CREATE 'OPT_FILE'
540$DECK
541!
542! Default System Options File To Link Agianst
543! The Sharable C Runtime Library.
544!
545GNU_CC:[000000]GCCLIB/LIBRARY
546SYS$SHARE:VAXCRTL/SHARE
547$EOD
548$!
549$! End The Option File Check.
550$!
551$ ENDIF
552$!
553$! End The GNU C Check.
554$!
555$ ENDIF
556$!
557$! Check To See If We Need A DEC C Option File.
558$!
559$ IF (COMPILER.EQS."DECC")
560$ THEN
561$!
562$! Check To See If We Already Have A DEC C Linker Option File.
563$!
564$ IF (F$SEARCH(OPT_FILE).EQS."")
565$ THEN
566$!
567$! Figure Out If We Need An AXP Or A VAX Linker Option File.
568$!
569$ IF (F$GETSYI("CPU").LT.128)
570$ THEN
571$!
572$! We Need A DEC C Linker Option File For VAX.
573$!
574$ CREATE 'OPT_FILE'
575$DECK
576!
577! Default System Options File To Link Agianst
578! The Sharable DEC C Runtime Library.
579!
580SYS$SHARE:DECC$SHR.EXE/SHARE
581$EOD
582$!
583$! Else...
584$!
585$ ELSE
586$!
587$! Create The AXP Linker Option File.
588$!
589$ CREATE 'OPT_FILE'
590$DECK
591!
592! Default System Options File For AXP To Link Agianst
593! The Sharable C Runtime Library.
594!
595SYS$SHARE:CMA$OPEN_LIB_SHR/SHARE
596SYS$SHARE:CMA$OPEN_RTL/SHARE
597$EOD
598$!
599$! End The VAX/AXP DEC C Option File Check.
600$!
601$ ENDIF
602$!
603$! End The Option File Search.
604$!
605$ ENDIF
606$!
607$! End The DEC C Check.
608$!
609$ ENDIF
610$!
611$! Tell The User What Linker Option File We Are Using.
612$!
613$ WRITE SYS$OUTPUT "Using Linker Option File ",OPT_FILE,"."
614$!
615$! Time To RETURN.
616$!
617$ RETURN
618$!
619$! Library Check.
620$!
621$ LIB_CHECK:
622$!
623$! Look For The Library LIBDES.OLB.
624$!
625$ IF (F$SEARCH(LIB_NAME).EQS."")
626$ THEN
627$!
628$! Tell The User We Can't Find The [.xxx.CRYPTO.DES]LIBDES.OLB Library.
629$!
630$ WRITE SYS$OUTPUT ""
631$ WRITE SYS$OUTPUT "Can't Find The Library ",LIB_NAME,"."
632$ WRITE SYS$OUTPUT "We Can't Link Without It."
633$ WRITE SYS$OUTPUT ""
634$!
635$! Since We Can't Link Without It, Exit.
636$!
637$ EXIT
638$ ENDIF
639$!
640$! Time To Return.
641$!
642$ RETURN
643$!
644$! Check The User's Options.
645$!
646$ CHECK_OPTIONS:
647$!
648$! Check To See If We Are To "Just Build Everything".
649$!
650$ IF (P1.EQS."ALL")
651$ THEN
652$!
653$! P1 Is "ALL", So Build Everything.
654$!
655$ BUILDALL = "TRUE"
656$!
657$! Else...
658$!
659$ ELSE
660$!
661$! Else, Check To See If P1 Has A Valid Arguement.
662$!
663$ 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$ THEN
666$!
667$! A Valid Arguement.
668$!
669$ BUILDALL = P1
670$!
671$! Else...
672$!
673$ ELSE
674$!
675$! Tell The User We Don't Know What They Want.
676$!
677$ WRITE SYS$OUTPUT ""
678$ WRITE SYS$OUTPUT "The Option ",P1," Is Invalid. The Valid Options Are:"
679$ WRITE SYS$OUTPUT ""
680$ 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 " 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 " RPW : To Compile Just The [.xxx.EXE.CRYPTO.DES]RPW.EXE Program."
685$ WRITE SYS$OUTPUT " DES : To Compile Just The [.xxx.EXE.CRYPTO.DES]DES.EXE Program."
686$ WRITE SYS$OUTPUT " DES_OPTS : To Compile Just The [.xxx.EXE.CRYTPO.DES]DES_OPTS.EXE Program."
687$ WRITE SYS$OUTPUT ""
688$ WRITE SYS$OUTPUT " Where 'xxx' Stands For: "
689$ WRITE SYS$OUTPUT ""
690$ WRITE SYS$OUTPUT " AXP : Alpha Architecture."
691$ WRITE SYS$OUTPUT " VAX : VAX Architecture."
692$ WRITE SYS$OUTPUT ""
693$!
694$! Time To EXIT.
695$!
696$ EXIT
697$!
698$! End The Valid Arguement Check.
699$!
700$ ENDIF
701$!
702$! End The P1 Check.
703$!
704$ ENDIF
705$!
706$! Check To See If We Are To Compile Without Debugger Information.
707$!
708$ IF (P2.EQS."NODEBUG")
709$ THEN
710$!
711$! P2 Is Blank, So Compile Without Debugger Information.
712$!
713$ DEBUGGER = "NODEBUG"
714$ TRACEBACK = "NOTRACEBACK"
715$ GCC_OPTIMIZE = "OPTIMIZE"
716$ CC_OPTIMIZE = "OPTIMIZE"
717$ WRITE SYS$OUTPUT "No Debugger Information Will Be Produced During Compile."
718$ WRITE SYS$OUTPUT "Compiling With Compiler Optimization."
719$!
720$! Else...
721$!
722$ ELSE
723$!
724$! Check To See If We Are To Compile With Debugger Information.
725$!
726$ IF (P2.EQS."DEBUG")
727$ THEN
728$!
729$! Compile With Debugger Information.
730$!
731$ DEBUGGER = "DEBUG"
732$ TRACEBACK = "TRACEBACK"
733$ GCC_OPTIMIZE = "NOOPTIMIZE"
734$ CC_OPTIMIZE = "NOOPTIMIZE"
735$ WRITE SYS$OUTPUT "Debugger Information Will Be Produced During Compile."
736$ WRITE SYS$OUTPUT "Compiling Without Compiler Optimization."
737$!
738$! Else...
739$!
740$ ELSE
741$!
742$! Tell The User Entered An Invalid Option..
743$!
744$ WRITE SYS$OUTPUT ""
745$ WRITE SYS$OUTPUT "The Option ",P2," Is Invalid. The Valid Options Are:"
746$ WRITE SYS$OUTPUT ""
747$ WRITE SYS$OUTPUT " DEBUG : Compile With The Debugger Information."
748$ WRITE SYS$OUTPUT " NODEBUG : Compile Without The Debugger Information."
749$ WRITE SYS$OUTPUT ""
750$!
751$! Time To EXIT.
752$!
753$ EXIT
754$!
755$! End The Valid Arguement Check.
756$!
757$ ENDIF
758$!
759$! End The P2 Check.
760$!
761$ ENDIF
762$!
763$! Special Threads For OpenVMS v7.1 Or Later.
764$!
765$! Written By: Richard Levitte
766$! richard@levitte.org
767$!
768$!
769$! Check To See If We Have A Option For P4.
770$!
771$ IF (P4.EQS."")
772$ THEN
773$!
774$! Get The Version Of VMS We Are Using.
775$!
776$ ISSEVEN := ""
777$ TMP = F$ELEMENT(0,"-",F$EXTRACT(1,4,F$GETSYI("VERSION")))
778$ TMP = F$INTEGER(F$ELEMENT(0,".",TMP)+F$ELEMENT(1,".",TMP))
779$!
780$! Check To See If The VMS Version Is v7.1 Or Later.
781$!
782$ IF (TMP.GE.71)
783$ THEN
784$!
785$! We Have OpenVMS v7.1 Or Later, So Use The Special Threads.
786$!
787$ ISSEVEN := ,PTHREAD_USE_D4
788$!
789$! End The VMS Version Check.
790$!
791$ ENDIF
792$!
793$! End The P4 Check.
794$!
795$ ENDIF
796$!
797$! Check To See If P3 Is Blank.
798$!
799$ IF (P3.EQS."")
800$ THEN
801$!
802$! O.K., The User Didn't Specify A Compiler, Let's Try To
803$! Find Out Which One To Use.
804$!
805$! Check To See If We Have GNU C.
806$!
807$ IF (F$TRNLNM("GNU_CC").NES."")
808$ THEN
809$!
810$! Looks Like GNUC, Set To Use GNUC.
811$!
812$ P3 = "GNUC"
813$!
814$! Else...
815$!
816$ ELSE
817$!
818$! Check To See If We Have VAXC Or DECC.
819$!
820$ IF (ARCH.EQS."AXP").OR.(F$TRNLNM("DECC$CC_DEFAULT").NES."")
821$ THEN
822$!
823$! Looks Like DECC, Set To Use DECC.
824$!
825$ P3 = "DECC"
826$!
827$! Else...
828$!
829$ ELSE
830$!
831$! Looks Like VAXC, Set To Use VAXC.
832$!
833$ P3 = "VAXC"
834$!
835$! End The VAXC Compiler Check.
836$!
837$ ENDIF
838$!
839$! End The DECC & VAXC Compiler Check.
840$!
841$ ENDIF
842$!
843$! End The Compiler Check.
844$!
845$ ENDIF
846$!
847$! Set Up Initial CC Definitions, Possibly With User Ones
848$!
849$ CCDEFS = ""
850$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = USER_CCDEFS
851$ CCEXTRAFLAGS = ""
852$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS
853$ CCDISABLEWARNINGS = ""
854$ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" THEN -
855 CCDISABLEWARNINGS = USER_CCDISABLEWARNINGS
856$!
857$! Check To See If The User Entered A Valid Paramter.
858$!
859$ IF (P3.EQS."VAXC").OR.(P3.EQS."DECC").OR.(P3.EQS."GNUC")
860$ THEN
861$!
862$! Check To See If The User Wanted DECC.
863$!
864$ IF (P3.EQS."DECC")
865$ THEN
866$!
867$! Looks Like DECC, Set To Use DECC.
868$!
869$ COMPILER = "DECC"
870$!
871$! Tell The User We Are Using DECC.
872$!
873$ WRITE SYS$OUTPUT "Using DECC 'C' Compiler."
874$!
875$! Use DECC...
876$!
877$ CC = "CC"
878$ IF ARCH.EQS."VAX" .AND. F$TRNLNM("DECC$CC_DEFAULT").NES."/DECC" -
879 THEN CC = "CC/DECC"
880$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/STANDARD=ANSI89" + -
881 "/NOLIST/PREFIX=ALL" + CCEXTRAFLAGS
882$!
883$! Define The Linker Options File Name.
884$!
885$ OPT_FILE = "SYS$DISK:[]VAX_DECC_OPTIONS.OPT"
886$!
887$! End DECC Check.
888$!
889$ ENDIF
890$!
891$! Check To See If We Are To Use VAXC.
892$!
893$ IF (P3.EQS."VAXC")
894$ THEN
895$!
896$! Looks Like VAXC, Set To Use VAXC.
897$!
898$ COMPILER = "VAXC"
899$!
900$! Tell The User We Are Using VAX C.
901$!
902$ WRITE SYS$OUTPUT "Using VAXC 'C' Compiler."
903$!
904$! Compile Using VAXC.
905$!
906$ CC = "CC"
907$ IF ARCH.EQS."AXP"
908$ THEN
909$ WRITE SYS$OUTPUT "There is no VAX C on Alpha!"
910$ EXIT
911$ ENDIF
912$ IF F$TRNLNM("DECC$CC_DEFAULT").EQS."/DECC" THEN CC = "CC/VAXC"
913$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/NOLIST" + CCEXTRAFLAGS
914$ CCDEFS = """VAXC""," + CCDEFS
915$!
916$! Define <sys> As SYS$COMMON:[SYSLIB]
917$!
918$ DEFINE/NOLOG SYS SYS$COMMON:[SYSLIB]
919$!
920$! Define The Linker Options File Name.
921$!
922$ OPT_FILE = "SYS$DISK:[]VAX_VAXC_OPTIONS.OPT"
923$!
924$! End VAXC Check
925$!
926$ ENDIF
927$!
928$! Check To See If We Are To Use GNU C.
929$!
930$ IF (P3.EQS."GNUC")
931$ THEN
932$!
933$! Looks Like GNUC, Set To Use GNUC.
934$!
935$ COMPILER = "GNUC"
936$!
937$! Tell The User We Are Using GNUC.
938$!
939$ WRITE SYS$OUTPUT "Using GNU 'C' Compiler."
940$!
941$! Use GNU C...
942$!
943$ CC = "GCC/NOCASE_HACK/''GCC_OPTIMIZE'/''DEBUGGER'/NOLIST" + CCEXTRAFLAGS
944$!
945$! Define The Linker Options File Name.
946$!
947$ OPT_FILE = "SYS$DISK:[]VAX_GNUC_OPTIONS.OPT"
948$!
949$! End The GNU C Check.
950$!
951$ ENDIF
952$!
953$! Set up default defines
954$!
955$ CCDEFS = """FLAT_INC=1""," + CCDEFS
956$!
957$! Finish up the definition of CC.
958$!
959$ IF COMPILER .EQS. "DECC"
960$ THEN
961$ IF CCDISABLEWARNINGS .EQS. ""
962$ THEN
963$ CC4DISABLEWARNINGS = "DOLLARID"
964$ ELSE
965$ CC4DISABLEWARNINGS = CCDISABLEWARNINGS + ",DOLLARID"
966$ CCDISABLEWARNINGS = "/WARNING=(DISABLE=(" + CCDISABLEWARNINGS + "))"
967$ ENDIF
968$ CC4DISABLEWARNINGS = "/WARNING=(DISABLE=(" + CC4DISABLEWARNINGS + "))"
969$ ELSE
970$ CCDISABLEWARNINGS = ""
971$ CC4DISABLEWARNINGS = ""
972$ ENDIF
973$ CC = CC + "/DEFINE=(" + CCDEFS + ")" + CCDISABLEWARNINGS
974$!
975$! Show user the result
976$!
977$ WRITE SYS$OUTPUT "Main Compiling Command: ",CC
978$!
979$! Else The User Entered An Invalid Arguement.
980$!
981$ ELSE
982$!
983$! Tell The User We Don't Know What They Want.
984$!
985$ WRITE SYS$OUTPUT ""
986$ WRITE SYS$OUTPUT "The Option ",P3," Is Invalid. The Valid Options Are:"
987$ WRITE SYS$OUTPUT ""
988$ WRITE SYS$OUTPUT " VAXC : To Compile With VAX C."
989$ WRITE SYS$OUTPUT " DECC : To Compile With DEC C."
990$ WRITE SYS$OUTPUT " GNUC : To Compile With GNU C."
991$ WRITE SYS$OUTPUT ""
992$!
993$! Time To EXIT.
994$!
995$ EXIT
996$!
997$! End The P3 Check.
998$!
999$ ENDIF
1000$!
1001$! Time To RETURN...
1002$!
1003$ RETURN
diff --git a/src/lib/libcrypto/des/des.c b/src/lib/libcrypto/des/des.c
new file mode 100644
index 0000000000..d8c846b23d
--- /dev/null
+++ b/src/lib/libcrypto/des/des.c
@@ -0,0 +1,932 @@
1/* crypto/des/des.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <stdlib.h>
61#include <string.h>
62#include <openssl/opensslconf.h>
63#ifndef OPENSSL_SYS_MSDOS
64#ifndef OPENSSL_SYS_VMS
65#include OPENSSL_UNISTD
66#else /* OPENSSL_SYS_VMS */
67#ifdef __DECC
68#include <unistd.h>
69#else /* not __DECC */
70#include <math.h>
71#endif /* __DECC */
72#endif /* OPENSSL_SYS_VMS */
73#else /* OPENSSL_SYS_MSDOS */
74#include <io.h>
75#endif
76
77#include <time.h>
78#include "des_ver.h"
79
80#ifdef OPENSSL_SYS_VMS
81#include <types.h>
82#include <stat.h>
83#else
84#ifndef _IRIX
85#include <sys/types.h>
86#endif
87#include <sys/stat.h>
88#endif
89#include <openssl/des.h>
90#include <openssl/rand.h>
91#include <openssl/ui_compat.h>
92
93void usage(void);
94void doencryption(void);
95int uufwrite(unsigned char *data, int size, unsigned int num, FILE *fp);
96void uufwriteEnd(FILE *fp);
97int uufread(unsigned char *out,int size,unsigned int num,FILE *fp);
98int uuencode(unsigned char *in,int num,unsigned char *out);
99int uudecode(unsigned char *in,int num,unsigned char *out);
100void DES_3cbc_encrypt(DES_cblock *input,DES_cblock *output,long length,
101 DES_key_schedule sk1,DES_key_schedule sk2,
102 DES_cblock *ivec1,DES_cblock *ivec2,int enc);
103#ifdef OPENSSL_SYS_VMS
104#define EXIT(a) exit(a&0x10000000L)
105#else
106#define EXIT(a) exit(a)
107#endif
108
109#define BUFSIZE (8*1024)
110#define VERIFY 1
111#define KEYSIZ 8
112#define KEYSIZB 1024 /* should hit tty line limit first :-) */
113char key[KEYSIZB+1];
114int do_encrypt,longk=0;
115FILE *DES_IN,*DES_OUT,*CKSUM_OUT;
116char uuname[200];
117unsigned char uubuf[50];
118int uubufnum=0;
119#define INUUBUFN (45*100)
120#define OUTUUBUF (65*100)
121unsigned char b[OUTUUBUF];
122unsigned char bb[300];
123DES_cblock cksum={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
124char cksumname[200]="";
125
126int vflag,cflag,eflag,dflag,kflag,bflag,fflag,sflag,uflag,flag3,hflag,error;
127
128int main(int argc, char **argv)
129 {
130 int i;
131 struct stat ins,outs;
132 char *p;
133 char *in=NULL,*out=NULL;
134
135 vflag=cflag=eflag=dflag=kflag=hflag=bflag=fflag=sflag=uflag=flag3=0;
136 error=0;
137 memset(key,0,sizeof(key));
138
139 for (i=1; i<argc; i++)
140 {
141 p=argv[i];
142 if ((p[0] == '-') && (p[1] != '\0'))
143 {
144 p++;
145 while (*p)
146 {
147 switch (*(p++))
148 {
149 case '3':
150 flag3=1;
151 longk=1;
152 break;
153 case 'c':
154 cflag=1;
155 strncpy(cksumname,p,200);
156 cksumname[sizeof(cksumname)-1]='\0';
157 p+=strlen(cksumname);
158 break;
159 case 'C':
160 cflag=1;
161 longk=1;
162 strncpy(cksumname,p,200);
163 cksumname[sizeof(cksumname)-1]='\0';
164 p+=strlen(cksumname);
165 break;
166 case 'e':
167 eflag=1;
168 break;
169 case 'v':
170 vflag=1;
171 break;
172 case 'E':
173 eflag=1;
174 longk=1;
175 break;
176 case 'd':
177 dflag=1;
178 break;
179 case 'D':
180 dflag=1;
181 longk=1;
182 break;
183 case 'b':
184 bflag=1;
185 break;
186 case 'f':
187 fflag=1;
188 break;
189 case 's':
190 sflag=1;
191 break;
192 case 'u':
193 uflag=1;
194 strncpy(uuname,p,200);
195 uuname[sizeof(uuname)-1]='\0';
196 p+=strlen(uuname);
197 break;
198 case 'h':
199 hflag=1;
200 break;
201 case 'k':
202 kflag=1;
203 if ((i+1) == argc)
204 {
205 fputs("must have a key with the -k option\n",stderr);
206 error=1;
207 }
208 else
209 {
210 int j;
211
212 i++;
213 strncpy(key,argv[i],KEYSIZB);
214 for (j=strlen(argv[i])-1; j>=0; j--)
215 argv[i][j]='\0';
216 }
217 break;
218 default:
219 fprintf(stderr,"'%c' unknown flag\n",p[-1]);
220 error=1;
221 break;
222 }
223 }
224 }
225 else
226 {
227 if (in == NULL)
228 in=argv[i];
229 else if (out == NULL)
230 out=argv[i];
231 else
232 error=1;
233 }
234 }
235 if (error) usage();
236 /* We either
237 * do checksum or
238 * do encrypt or
239 * do decrypt or
240 * do decrypt then ckecksum or
241 * do checksum then encrypt
242 */
243 if (((eflag+dflag) == 1) || cflag)
244 {
245 if (eflag) do_encrypt=DES_ENCRYPT;
246 if (dflag) do_encrypt=DES_DECRYPT;
247 }
248 else
249 {
250 if (vflag)
251 {
252#ifndef _Windows
253 fprintf(stderr,"des(1) built with %s\n",libdes_version);
254#endif
255 EXIT(1);
256 }
257 else usage();
258 }
259
260#ifndef _Windows
261 if (vflag) fprintf(stderr,"des(1) built with %s\n",libdes_version);
262#endif
263 if ( (in != NULL) &&
264 (out != NULL) &&
265#ifndef OPENSSL_SYS_MSDOS
266 (stat(in,&ins) != -1) &&
267 (stat(out,&outs) != -1) &&
268 (ins.st_dev == outs.st_dev) &&
269 (ins.st_ino == outs.st_ino))
270#else /* OPENSSL_SYS_MSDOS */
271 (strcmp(in,out) == 0))
272#endif
273 {
274 fputs("input and output file are the same\n",stderr);
275 EXIT(3);
276 }
277
278 if (!kflag)
279 if (des_read_pw_string(key,KEYSIZB+1,"Enter key:",eflag?VERIFY:0))
280 {
281 fputs("password error\n",stderr);
282 EXIT(2);
283 }
284
285 if (in == NULL)
286 DES_IN=stdin;
287 else if ((DES_IN=fopen(in,"r")) == NULL)
288 {
289 perror("opening input file");
290 EXIT(4);
291 }
292
293 CKSUM_OUT=stdout;
294 if (out == NULL)
295 {
296 DES_OUT=stdout;
297 CKSUM_OUT=stderr;
298 }
299 else if ((DES_OUT=fopen(out,"w")) == NULL)
300 {
301 perror("opening output file");
302 EXIT(5);
303 }
304
305#ifdef OPENSSL_SYS_MSDOS
306 /* This should set the file to binary mode. */
307 {
308#include <fcntl.h>
309 if (!(uflag && dflag))
310 setmode(fileno(DES_IN),O_BINARY);
311 if (!(uflag && eflag))
312 setmode(fileno(DES_OUT),O_BINARY);
313 }
314#endif
315
316 doencryption();
317 fclose(DES_IN);
318 fclose(DES_OUT);
319 EXIT(0);
320 }
321
322void usage(void)
323 {
324 char **u;
325 static const char *Usage[]={
326"des <options> [input-file [output-file]]",
327"options:",
328"-v : des(1) version number",
329"-e : encrypt using SunOS compatible user key to DES key conversion.",
330"-E : encrypt ",
331"-d : decrypt using SunOS compatible user key to DES key conversion.",
332"-D : decrypt ",
333"-c[ckname] : generate a cbc_cksum using SunOS compatible user key to",
334" DES key conversion and output to ckname (stdout default,",
335" stderr if data being output on stdout). The checksum is",
336" generated before encryption and after decryption if used",
337" in conjunction with -[eEdD].",
338"-C[ckname] : generate a cbc_cksum as for -c but compatible with -[ED].",
339"-k key : use key 'key'",
340"-h : the key that is entered will be a hexadecimal number",
341" that is used directly as the des key",
342"-u[uuname] : input file is uudecoded if -[dD] or output uuencoded data if -[eE]",
343" (uuname is the filename to put in the uuencode header).",
344"-b : encrypt using DES in ecb encryption mode, the default is cbc mode.",
345"-3 : encrypt using triple DES encryption. This uses 2 keys",
346" generated from the input key. If the input key is less",
347" than 8 characters long, this is equivalent to normal",
348" encryption. Default is triple cbc, -b makes it triple ecb.",
349NULL
350};
351 for (u=(char **)Usage; *u; u++)
352 {
353 fputs(*u,stderr);
354 fputc('\n',stderr);
355 }
356
357 EXIT(1);
358 }
359
360void doencryption(void)
361 {
362#ifdef _LIBC
363 extern unsigned long time();
364#endif
365
366 register int i;
367 DES_key_schedule ks,ks2;
368 DES_cblock iv,iv2;
369 char *p;
370 int num=0,j,k,l,rem,ll,len,last,ex=0;
371 DES_cblock kk,k2;
372 FILE *O;
373 int Exit=0;
374#ifndef OPENSSL_SYS_MSDOS
375 static unsigned char buf[BUFSIZE+8],obuf[BUFSIZE+8];
376#else
377 static unsigned char *buf=NULL,*obuf=NULL;
378
379 if (buf == NULL)
380 {
381 if ( (( buf=OPENSSL_malloc(BUFSIZE+8)) == NULL) ||
382 ((obuf=OPENSSL_malloc(BUFSIZE+8)) == NULL))
383 {
384 fputs("Not enough memory\n",stderr);
385 Exit=10;
386 goto problems;
387 }
388 }
389#endif
390
391 if (hflag)
392 {
393 j=(flag3?16:8);
394 p=key;
395 for (i=0; i<j; i++)
396 {
397 k=0;
398 if ((*p <= '9') && (*p >= '0'))
399 k=(*p-'0')<<4;
400 else if ((*p <= 'f') && (*p >= 'a'))
401 k=(*p-'a'+10)<<4;
402 else if ((*p <= 'F') && (*p >= 'A'))
403 k=(*p-'A'+10)<<4;
404 else
405 {
406 fputs("Bad hex key\n",stderr);
407 Exit=9;
408 goto problems;
409 }
410 p++;
411 if ((*p <= '9') && (*p >= '0'))
412 k|=(*p-'0');
413 else if ((*p <= 'f') && (*p >= 'a'))
414 k|=(*p-'a'+10);
415 else if ((*p <= 'F') && (*p >= 'A'))
416 k|=(*p-'A'+10);
417 else
418 {
419 fputs("Bad hex key\n",stderr);
420 Exit=9;
421 goto problems;
422 }
423 p++;
424 if (i < 8)
425 kk[i]=k;
426 else
427 k2[i-8]=k;
428 }
429 DES_set_key_unchecked(&k2,&ks2);
430 memset(k2,0,sizeof(k2));
431 }
432 else if (longk || flag3)
433 {
434 if (flag3)
435 {
436 DES_string_to_2keys(key,&kk,&k2);
437 DES_set_key_unchecked(&k2,&ks2);
438 memset(k2,0,sizeof(k2));
439 }
440 else
441 DES_string_to_key(key,&kk);
442 }
443 else
444 for (i=0; i<KEYSIZ; i++)
445 {
446 l=0;
447 k=key[i];
448 for (j=0; j<8; j++)
449 {
450 if (k&1) l++;
451 k>>=1;
452 }
453 if (l & 1)
454 kk[i]=key[i]&0x7f;
455 else
456 kk[i]=key[i]|0x80;
457 }
458
459 DES_set_key_unchecked(&kk,&ks);
460 memset(key,0,sizeof(key));
461 memset(kk,0,sizeof(kk));
462 /* woops - A bug that does not showup under unix :-( */
463 memset(iv,0,sizeof(iv));
464 memset(iv2,0,sizeof(iv2));
465
466 l=1;
467 rem=0;
468 /* first read */
469 if (eflag || (!dflag && cflag))
470 {
471 for (;;)
472 {
473 num=l=fread(&(buf[rem]),1,BUFSIZE,DES_IN);
474 l+=rem;
475 num+=rem;
476 if (l < 0)
477 {
478 perror("read error");
479 Exit=6;
480 goto problems;
481 }
482
483 rem=l%8;
484 len=l-rem;
485 if (feof(DES_IN))
486 {
487 for (i=7-rem; i>0; i--)
488 RAND_pseudo_bytes(buf + l++, 1);
489 buf[l++]=rem;
490 ex=1;
491 len+=rem;
492 }
493 else
494 l-=rem;
495
496 if (cflag)
497 {
498 DES_cbc_cksum(buf,&cksum,
499 (long)len,&ks,&cksum);
500 if (!eflag)
501 {
502 if (feof(DES_IN)) break;
503 else continue;
504 }
505 }
506
507 if (bflag && !flag3)
508 for (i=0; i<l; i+=8)
509 DES_ecb_encrypt(
510 (DES_cblock *)&(buf[i]),
511 (DES_cblock *)&(obuf[i]),
512 &ks,do_encrypt);
513 else if (flag3 && bflag)
514 for (i=0; i<l; i+=8)
515 DES_ecb2_encrypt(
516 (DES_cblock *)&(buf[i]),
517 (DES_cblock *)&(obuf[i]),
518 &ks,&ks2,do_encrypt);
519 else if (flag3 && !bflag)
520 {
521 char tmpbuf[8];
522
523 if (rem) memcpy(tmpbuf,&(buf[l]),
524 (unsigned int)rem);
525 DES_3cbc_encrypt(
526 (DES_cblock *)buf,(DES_cblock *)obuf,
527 (long)l,ks,ks2,&iv,
528 &iv2,do_encrypt);
529 if (rem) memcpy(&(buf[l]),tmpbuf,
530 (unsigned int)rem);
531 }
532 else
533 {
534 DES_cbc_encrypt(
535 buf,obuf,
536 (long)l,&ks,&iv,do_encrypt);
537 if (l >= 8) memcpy(iv,&(obuf[l-8]),8);
538 }
539 if (rem) memcpy(buf,&(buf[l]),(unsigned int)rem);
540
541 i=0;
542 while (i < l)
543 {
544 if (uflag)
545 j=uufwrite(obuf,1,(unsigned int)l-i,
546 DES_OUT);
547 else
548 j=fwrite(obuf,1,(unsigned int)l-i,
549 DES_OUT);
550 if (j == -1)
551 {
552 perror("Write error");
553 Exit=7;
554 goto problems;
555 }
556 i+=j;
557 }
558 if (feof(DES_IN))
559 {
560 if (uflag) uufwriteEnd(DES_OUT);
561 break;
562 }
563 }
564 }
565 else /* decrypt */
566 {
567 ex=1;
568 for (;;)
569 {
570 if (ex) {
571 if (uflag)
572 l=uufread(buf,1,BUFSIZE,DES_IN);
573 else
574 l=fread(buf,1,BUFSIZE,DES_IN);
575 ex=0;
576 rem=l%8;
577 l-=rem;
578 }
579 if (l < 0)
580 {
581 perror("read error");
582 Exit=6;
583 goto problems;
584 }
585
586 if (bflag && !flag3)
587 for (i=0; i<l; i+=8)
588 DES_ecb_encrypt(
589 (DES_cblock *)&(buf[i]),
590 (DES_cblock *)&(obuf[i]),
591 &ks,do_encrypt);
592 else if (flag3 && bflag)
593 for (i=0; i<l; i+=8)
594 DES_ecb2_encrypt(
595 (DES_cblock *)&(buf[i]),
596 (DES_cblock *)&(obuf[i]),
597 &ks,&ks2,do_encrypt);
598 else if (flag3 && !bflag)
599 {
600 DES_3cbc_encrypt(
601 (DES_cblock *)buf,(DES_cblock *)obuf,
602 (long)l,ks,ks2,&iv,
603 &iv2,do_encrypt);
604 }
605 else
606 {
607 DES_cbc_encrypt(
608 buf,obuf,
609 (long)l,&ks,&iv,do_encrypt);
610 if (l >= 8) memcpy(iv,&(buf[l-8]),8);
611 }
612
613 if (uflag)
614 ll=uufread(&(buf[rem]),1,BUFSIZE,DES_IN);
615 else
616 ll=fread(&(buf[rem]),1,BUFSIZE,DES_IN);
617 ll+=rem;
618 rem=ll%8;
619 ll-=rem;
620 if (feof(DES_IN) && (ll == 0))
621 {
622 last=obuf[l-1];
623
624 if ((last > 7) || (last < 0))
625 {
626 fputs("The file was not decrypted correctly.\n",
627 stderr);
628 Exit=8;
629 last=0;
630 }
631 l=l-8+last;
632 }
633 i=0;
634 if (cflag) DES_cbc_cksum(obuf,
635 (DES_cblock *)cksum,(long)l/8*8,&ks,
636 (DES_cblock *)cksum);
637 while (i != l)
638 {
639 j=fwrite(obuf,1,(unsigned int)l-i,DES_OUT);
640 if (j == -1)
641 {
642 perror("Write error");
643 Exit=7;
644 goto problems;
645 }
646 i+=j;
647 }
648 l=ll;
649 if ((l == 0) && feof(DES_IN)) break;
650 }
651 }
652 if (cflag)
653 {
654 l=0;
655 if (cksumname[0] != '\0')
656 {
657 if ((O=fopen(cksumname,"w")) != NULL)
658 {
659 CKSUM_OUT=O;
660 l=1;
661 }
662 }
663 for (i=0; i<8; i++)
664 fprintf(CKSUM_OUT,"%02X",cksum[i]);
665 fprintf(CKSUM_OUT,"\n");
666 if (l) fclose(CKSUM_OUT);
667 }
668problems:
669 memset(buf,0,sizeof(buf));
670 memset(obuf,0,sizeof(obuf));
671 memset(&ks,0,sizeof(ks));
672 memset(&ks2,0,sizeof(ks2));
673 memset(iv,0,sizeof(iv));
674 memset(iv2,0,sizeof(iv2));
675 memset(kk,0,sizeof(kk));
676 memset(k2,0,sizeof(k2));
677 memset(uubuf,0,sizeof(uubuf));
678 memset(b,0,sizeof(b));
679 memset(bb,0,sizeof(bb));
680 memset(cksum,0,sizeof(cksum));
681 if (Exit) EXIT(Exit);
682 }
683
684/* We ignore this parameter but it should be > ~50 I believe */
685int uufwrite(unsigned char *data, int size, unsigned int num, FILE *fp)
686 {
687 int i,j,left,rem,ret=num;
688 static int start=1;
689
690 if (start)
691 {
692 fprintf(fp,"begin 600 %s\n",
693 (uuname[0] == '\0')?"text.d":uuname);
694 start=0;
695 }
696
697 if (uubufnum)
698 {
699 if (uubufnum+num < 45)
700 {
701 memcpy(&(uubuf[uubufnum]),data,(unsigned int)num);
702 uubufnum+=num;
703 return(num);
704 }
705 else
706 {
707 i=45-uubufnum;
708 memcpy(&(uubuf[uubufnum]),data,(unsigned int)i);
709 j=uuencode((unsigned char *)uubuf,45,b);
710 fwrite(b,1,(unsigned int)j,fp);
711 uubufnum=0;
712 data+=i;
713 num-=i;
714 }
715 }
716
717 for (i=0; i<(((int)num)-INUUBUFN); i+=INUUBUFN)
718 {
719 j=uuencode(&(data[i]),INUUBUFN,b);
720 fwrite(b,1,(unsigned int)j,fp);
721 }
722 rem=(num-i)%45;
723 left=(num-i-rem);
724 if (left)
725 {
726 j=uuencode(&(data[i]),left,b);
727 fwrite(b,1,(unsigned int)j,fp);
728 i+=left;
729 }
730 if (i != num)
731 {
732 memcpy(uubuf,&(data[i]),(unsigned int)rem);
733 uubufnum=rem;
734 }
735 return(ret);
736 }
737
738void uufwriteEnd(FILE *fp)
739 {
740 int j;
741 static const char *end=" \nend\n";
742
743 if (uubufnum != 0)
744 {
745 uubuf[uubufnum]='\0';
746 uubuf[uubufnum+1]='\0';
747 uubuf[uubufnum+2]='\0';
748 j=uuencode(uubuf,uubufnum,b);
749 fwrite(b,1,(unsigned int)j,fp);
750 }
751 fwrite(end,1,strlen(end),fp);
752 }
753
754/* int size: should always be > ~ 60; I actually ignore this parameter :-) */
755int uufread(unsigned char *out, int size, unsigned int num, FILE *fp)
756 {
757 int i,j,tot;
758 static int done=0;
759 static int valid=0;
760 static int start=1;
761
762 if (start)
763 {
764 for (;;)
765 {
766 b[0]='\0';
767 fgets((char *)b,300,fp);
768 if (b[0] == '\0')
769 {
770 fprintf(stderr,"no 'begin' found in uuencoded input\n");
771 return(-1);
772 }
773 if (strncmp((char *)b,"begin ",6) == 0) break;
774 }
775 start=0;
776 }
777 if (done) return(0);
778 tot=0;
779 if (valid)
780 {
781 memcpy(out,bb,(unsigned int)valid);
782 tot=valid;
783 valid=0;
784 }
785 for (;;)
786 {
787 b[0]='\0';
788 fgets((char *)b,300,fp);
789 if (b[0] == '\0') break;
790 i=strlen((char *)b);
791 if ((b[0] == 'e') && (b[1] == 'n') && (b[2] == 'd'))
792 {
793 done=1;
794 while (!feof(fp))
795 {
796 fgets((char *)b,300,fp);
797 }
798 break;
799 }
800 i=uudecode(b,i,bb);
801 if (i < 0) break;
802 if ((i+tot+8) > num)
803 {
804 /* num to copy to make it a multiple of 8 */
805 j=(num/8*8)-tot-8;
806 memcpy(&(out[tot]),bb,(unsigned int)j);
807 tot+=j;
808 memcpy(bb,&(bb[j]),(unsigned int)i-j);
809 valid=i-j;
810 break;
811 }
812 memcpy(&(out[tot]),bb,(unsigned int)i);
813 tot+=i;
814 }
815 return(tot);
816 }
817
818#define ccc2l(c,l) (l =((DES_LONG)(*((c)++)))<<16, \
819 l|=((DES_LONG)(*((c)++)))<< 8, \
820 l|=((DES_LONG)(*((c)++))))
821
822#define l2ccc(l,c) (*((c)++)=(unsigned char)(((l)>>16)&0xff), \
823 *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
824 *((c)++)=(unsigned char)(((l) )&0xff))
825
826
827int uuencode(unsigned char *in, int num, unsigned char *out)
828 {
829 int j,i,n,tot=0;
830 DES_LONG l;
831 register unsigned char *p;
832 p=out;
833
834 for (j=0; j<num; j+=45)
835 {
836 if (j+45 > num)
837 i=(num-j);
838 else i=45;
839 *(p++)=i+' ';
840 for (n=0; n<i; n+=3)
841 {
842 ccc2l(in,l);
843 *(p++)=((l>>18)&0x3f)+' ';
844 *(p++)=((l>>12)&0x3f)+' ';
845 *(p++)=((l>> 6)&0x3f)+' ';
846 *(p++)=((l )&0x3f)+' ';
847 tot+=4;
848 }
849 *(p++)='\n';
850 tot+=2;
851 }
852 *p='\0';
853 l=0;
854 return(tot);
855 }
856
857int uudecode(unsigned char *in, int num, unsigned char *out)
858 {
859 int j,i,k;
860 unsigned int n=0,space=0;
861 DES_LONG l;
862 DES_LONG w,x,y,z;
863 unsigned int blank=(unsigned int)'\n'-' ';
864
865 for (j=0; j<num; )
866 {
867 n= *(in++)-' ';
868 if (n == blank)
869 {
870 n=0;
871 in--;
872 }
873 if (n > 60)
874 {
875 fprintf(stderr,"uuencoded line length too long\n");
876 return(-1);
877 }
878 j++;
879
880 for (i=0; i<n; j+=4,i+=3)
881 {
882 /* the following is for cases where spaces are
883 * removed from lines.
884 */
885 if (space)
886 {
887 w=x=y=z=0;
888 }
889 else
890 {
891 w= *(in++)-' ';
892 x= *(in++)-' ';
893 y= *(in++)-' ';
894 z= *(in++)-' ';
895 }
896 if ((w > 63) || (x > 63) || (y > 63) || (z > 63))
897 {
898 k=0;
899 if (w == blank) k=1;
900 if (x == blank) k=2;
901 if (y == blank) k=3;
902 if (z == blank) k=4;
903 space=1;
904 switch (k) {
905 case 1: w=0; in--;
906 case 2: x=0; in--;
907 case 3: y=0; in--;
908 case 4: z=0; in--;
909 break;
910 case 0:
911 space=0;
912 fprintf(stderr,"bad uuencoded data values\n");
913 w=x=y=z=0;
914 return(-1);
915 break;
916 }
917 }
918 l=(w<<18)|(x<<12)|(y<< 6)|(z );
919 l2ccc(l,out);
920 }
921 if (*(in++) != '\n')
922 {
923 fprintf(stderr,"missing nl in uuencoded line\n");
924 w=x=y=z=0;
925 return(-1);
926 }
927 j++;
928 }
929 *out='\0';
930 w=x=y=z=0;
931 return(n);
932 }
diff --git a/src/lib/libcrypto/des/des.h b/src/lib/libcrypto/des/des.h
index daaf239dbe..dfe5ff64e4 100644
--- a/src/lib/libcrypto/des/des.h
+++ b/src/lib/libcrypto/des/des.h
@@ -56,8 +56,8 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef HEADER_NEW_DES_H 59#ifndef HEADER_DES_H
60#define HEADER_NEW_DES_H 60#define HEADER_DES_H
61 61
62#ifdef OPENSSL_NO_DES 62#ifdef OPENSSL_NO_DES
63#error DES is disabled. 63#error DES is disabled.
@@ -71,6 +71,8 @@
71# define OPENSSL_EXTERN OPENSSL_EXPORT 71# define OPENSSL_EXTERN OPENSSL_EXPORT
72#endif 72#endif
73 73
74#define des_SPtrans DES_SPtrans
75
74#ifdef __cplusplus 76#ifdef __cplusplus
75extern "C" { 77extern "C" {
76#endif 78#endif
diff --git a/src/lib/libcrypto/des/des.pod b/src/lib/libcrypto/des/des.pod
new file mode 100644
index 0000000000..bf479e83d2
--- /dev/null
+++ b/src/lib/libcrypto/des/des.pod
@@ -0,0 +1,217 @@
1=pod
2
3=head1 NAME
4
5des - encrypt or decrypt data using Data Encryption Standard
6
7=head1 SYNOPSIS
8
9B<des>
10(
11B<-e>
12|
13B<-E>
14) | (
15B<-d>
16|
17B<-D>
18) | (
19B<->[B<cC>][B<ckname>]
20) |
21[
22B<-b3hfs>
23] [
24B<-k>
25I<key>
26]
27] [
28B<-u>[I<uuname>]
29[
30I<input-file>
31[
32I<output-file>
33] ]
34
35=head1 NOTE
36
37This page describes the B<des> stand-alone program, not the B<openssl des>
38command.
39
40=head1 DESCRIPTION
41
42B<des>
43encrypts and decrypts data using the
44Data Encryption Standard algorithm.
45One of
46B<-e>, B<-E>
47(for encrypt) or
48B<-d>, B<-D>
49(for decrypt) must be specified.
50It is also possible to use
51B<-c>
52or
53B<-C>
54in conjunction or instead of the a encrypt/decrypt option to generate
55a 16 character hexadecimal checksum, generated via the
56I<des_cbc_cksum>.
57
58Two standard encryption modes are supported by the
59B<des>
60program, Cipher Block Chaining (the default) and Electronic Code Book
61(specified with
62B<-b>).
63
64The key used for the DES
65algorithm is obtained by prompting the user unless the
66B<-k>
67I<key>
68option is given.
69If the key is an argument to the
70B<des>
71command, it is potentially visible to users executing
72ps(1)
73or a derivative. To minimise this possibility,
74B<des>
75takes care to destroy the key argument immediately upon entry.
76If your shell keeps a history file be careful to make sure it is not
77world readable.
78
79Since this program attempts to maintain compatibility with sunOS's
80des(1) command, there are 2 different methods used to convert the user
81supplied key to a des key.
82Whenever and one or more of
83B<-E>, B<-D>, B<-C>
84or
85B<-3>
86options are used, the key conversion procedure will not be compatible
87with the sunOS des(1) version but will use all the user supplied
88character to generate the des key.
89B<des>
90command reads from standard input unless
91I<input-file>
92is specified and writes to standard output unless
93I<output-file>
94is given.
95
96=head1 OPTIONS
97
98=over 4
99
100=item B<-b>
101
102Select ECB
103(eight bytes at a time) encryption mode.
104
105=item B<-3>
106
107Encrypt using triple encryption.
108By default triple cbc encryption is used but if the
109B<-b>
110option is used then triple ECB encryption is performed.
111If the key is less than 8 characters long, the flag has no effect.
112
113=item B<-e>
114
115Encrypt data using an 8 byte key in a manner compatible with sunOS
116des(1).
117
118=item B<-E>
119
120Encrypt data using a key of nearly unlimited length (1024 bytes).
121This will product a more secure encryption.
122
123=item B<-d>
124
125Decrypt data that was encrypted with the B<-e> option.
126
127=item B<-D>
128
129Decrypt data that was encrypted with the B<-E> option.
130
131=item B<-c>
132
133Generate a 16 character hexadecimal cbc checksum and output this to
134stderr.
135If a filename was specified after the
136B<-c>
137option, the checksum is output to that file.
138The checksum is generated using a key generated in a sunOS compatible
139manner.
140
141=item B<-C>
142
143A cbc checksum is generated in the same manner as described for the
144B<-c>
145option but the DES key is generated in the same manner as used for the
146B<-E>
147and
148B<-D>
149options
150
151=item B<-f>
152
153Does nothing - allowed for compatibility with sunOS des(1) command.
154
155=item B<-s>
156
157Does nothing - allowed for compatibility with sunOS des(1) command.
158
159=item B<-k> I<key>
160
161Use the encryption
162I<key>
163specified.
164
165=item B<-h>
166
167The
168I<key>
169is assumed to be a 16 character hexadecimal number.
170If the
171B<-3>
172option is used the key is assumed to be a 32 character hexadecimal
173number.
174
175=item B<-u>
176
177This flag is used to read and write uuencoded files. If decrypting,
178the input file is assumed to contain uuencoded, DES encrypted data.
179If encrypting, the characters following the B<-u> are used as the name of
180the uuencoded file to embed in the begin line of the uuencoded
181output. If there is no name specified after the B<-u>, the name text.des
182will be embedded in the header.
183
184=head1 SEE ALSO
185
186ps(1),
187L<des_crypt(3)|des_crypt(3)>
188
189=head1 BUGS
190
191The problem with using the
192B<-e>
193option is the short key length.
194It would be better to use a real 56-bit key rather than an
195ASCII-based 56-bit pattern. Knowing that the key was derived from ASCII
196radically reduces the time necessary for a brute-force cryptographic attack.
197My attempt to remove this problem is to add an alternative text-key to
198DES-key function. This alternative function (accessed via
199B<-E>, B<-D>, B<-S>
200and
201B<-3>)
202uses DES to help generate the key.
203
204Be carefully when using the B<-u> option. Doing B<des -ud> I<filename> will
205not decrypt filename (the B<-u> option will gobble the B<-d> option).
206
207The VMS operating system operates in a world where files are always a
208multiple of 512 bytes. This causes problems when encrypted data is
209send from Unix to VMS since a 88 byte file will suddenly be padded
210with 424 null bytes. To get around this problem, use the B<-u> option
211to uuencode the data before it is send to the VMS system.
212
213=head1 AUTHOR
214
215Eric Young (eay@cryptsoft.com)
216
217=cut
diff --git a/src/lib/libcrypto/des/des3s.cpp b/src/lib/libcrypto/des/des3s.cpp
new file mode 100644
index 0000000000..02d527c057
--- /dev/null
+++ b/src/lib/libcrypto/des/des3s.cpp
@@ -0,0 +1,67 @@
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/des.h>
36
37void main(int argc,char *argv[])
38 {
39 des_key_schedule key1,key2,key3;
40 unsigned long s1,s2,e1,e2;
41 unsigned long data[2];
42 int i,j;
43
44 for (j=0; j<6; j++)
45 {
46 for (i=0; i<1000; i++) /**/
47 {
48 des_encrypt3(&data[0],key1,key2,key3);
49 GetTSC(s1);
50 des_encrypt3(&data[0],key1,key2,key3);
51 des_encrypt3(&data[0],key1,key2,key3);
52 des_encrypt3(&data[0],key1,key2,key3);
53 GetTSC(e1);
54 GetTSC(s2);
55 des_encrypt3(&data[0],key1,key2,key3);
56 des_encrypt3(&data[0],key1,key2,key3);
57 des_encrypt3(&data[0],key1,key2,key3);
58 des_encrypt3(&data[0],key1,key2,key3);
59 GetTSC(e2);
60 des_encrypt3(&data[0],key1,key2,key3);
61 }
62
63 printf("des %d %d (%d)\n",
64 e1-s1,e2-s2,((e2-s2)-(e1-s1)));
65 }
66 }
67
diff --git a/src/lib/libcrypto/des/des_locl.h b/src/lib/libcrypto/des/des_locl.h
index e44e8e98b2..70e833be3f 100644
--- a/src/lib/libcrypto/des/des_locl.h
+++ b/src/lib/libcrypto/des/des_locl.h
@@ -162,18 +162,7 @@
162 162
163#if defined(OPENSSL_SYS_WIN32) && defined(_MSC_VER) 163#if defined(OPENSSL_SYS_WIN32) && defined(_MSC_VER)
164#define ROTATE(a,n) (_lrotr(a,n)) 164#define ROTATE(a,n) (_lrotr(a,n))
165#elif defined(__GNUC__) && __GNUC__>=2 && !defined(__STRICT_ANSI__) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) && !defined(PEDANTIC) 165#else
166# if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__)
167# define ROTATE(a,n) ({ register unsigned int ret; \
168 asm ("rorl %1,%0" \
169 : "=r"(ret) \
170 : "I"(n),"0"(a) \
171 : "cc"); \
172 ret; \
173 })
174# endif
175#endif
176#ifndef ROTATE
177#define ROTATE(a,n) (((a)>>(n))+((a)<<(32-(n)))) 166#define ROTATE(a,n) (((a)>>(n))+((a)<<(32-(n))))
178#endif 167#endif
179 168
diff --git a/src/lib/libcrypto/des/des_old.c b/src/lib/libcrypto/des/des_old.c
new file mode 100644
index 0000000000..7e4cd7180d
--- /dev/null
+++ b/src/lib/libcrypto/des/des_old.c
@@ -0,0 +1,271 @@
1/* crypto/des/des_old.c -*- mode:C; c-file-style: "eay" -*- */
2
3/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
4 *
5 * The function names in here are deprecated and are only present to
6 * provide an interface compatible with libdes. OpenSSL now provides
7 * functions where "des_" has been replaced with "DES_" in the names,
8 * to make it possible to make incompatible changes that are needed
9 * for C type security and other stuff.
10 *
11 * Please consider starting to use the DES_ functions rather than the
12 * des_ ones. The des_ functions will dissapear completely before
13 * OpenSSL 1.0!
14 *
15 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
16 */
17
18/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
19 * project 2001.
20 */
21/* ====================================================================
22 * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.
23 *
24 * Redistribution and use in source and binary forms, with or without
25 * modification, are permitted provided that the following conditions
26 * are met:
27 *
28 * 1. Redistributions of source code must retain the above copyright
29 * notice, this list of conditions and the following disclaimer.
30 *
31 * 2. Redistributions in binary form must reproduce the above copyright
32 * notice, this list of conditions and the following disclaimer in
33 * the documentation and/or other materials provided with the
34 * distribution.
35 *
36 * 3. All advertising materials mentioning features or use of this
37 * software must display the following acknowledgment:
38 * "This product includes software developed by the OpenSSL Project
39 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40 *
41 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42 * endorse or promote products derived from this software without
43 * prior written permission. For written permission, please contact
44 * openssl-core@openssl.org.
45 *
46 * 5. Products derived from this software may not be called "OpenSSL"
47 * nor may "OpenSSL" appear in their names without prior written
48 * permission of the OpenSSL Project.
49 *
50 * 6. Redistributions of any form whatsoever must retain the following
51 * acknowledgment:
52 * "This product includes software developed by the OpenSSL Project
53 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54 *
55 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66 * OF THE POSSIBILITY OF SUCH DAMAGE.
67 * ====================================================================
68 *
69 * This product includes cryptographic software written by Eric Young
70 * (eay@cryptsoft.com). This product includes software written by Tim
71 * Hudson (tjh@cryptsoft.com).
72 *
73 */
74
75#define OPENSSL_DES_LIBDES_COMPATIBILITY
76#include <openssl/des.h>
77#include <openssl/rand.h>
78
79const char *_ossl_old_des_options(void)
80 {
81 return DES_options();
82 }
83void _ossl_old_des_ecb3_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,
84 des_key_schedule ks1,des_key_schedule ks2,
85 des_key_schedule ks3, int enc)
86 {
87 DES_ecb3_encrypt((const_DES_cblock *)input, output,
88 (DES_key_schedule *)ks1, (DES_key_schedule *)ks2,
89 (DES_key_schedule *)ks3, enc);
90 }
91DES_LONG _ossl_old_des_cbc_cksum(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,
92 long length,des_key_schedule schedule,_ossl_old_des_cblock *ivec)
93 {
94 return DES_cbc_cksum((unsigned char *)input, output, length,
95 (DES_key_schedule *)schedule, ivec);
96 }
97void _ossl_old_des_cbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length,
98 des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc)
99 {
100 DES_cbc_encrypt((unsigned char *)input, (unsigned char *)output,
101 length, (DES_key_schedule *)schedule, ivec, enc);
102 }
103void _ossl_old_des_ncbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length,
104 des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc)
105 {
106 DES_ncbc_encrypt((unsigned char *)input, (unsigned char *)output,
107 length, (DES_key_schedule *)schedule, ivec, enc);
108 }
109void _ossl_old_des_xcbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length,
110 des_key_schedule schedule,_ossl_old_des_cblock *ivec,
111 _ossl_old_des_cblock *inw,_ossl_old_des_cblock *outw,int enc)
112 {
113 DES_xcbc_encrypt((unsigned char *)input, (unsigned char *)output,
114 length, (DES_key_schedule *)schedule, ivec, inw, outw, enc);
115 }
116void _ossl_old_des_cfb_encrypt(unsigned char *in,unsigned char *out,int numbits,
117 long length,des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc)
118 {
119 DES_cfb_encrypt(in, out, numbits, length,
120 (DES_key_schedule *)schedule, ivec, enc);
121 }
122void _ossl_old_des_ecb_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,
123 des_key_schedule ks,int enc)
124 {
125 DES_ecb_encrypt(input, output, (DES_key_schedule *)ks, enc);
126 }
127void _ossl_old_des_encrypt(DES_LONG *data,des_key_schedule ks, int enc)
128 {
129 DES_encrypt1(data, (DES_key_schedule *)ks, enc);
130 }
131void _ossl_old_des_encrypt2(DES_LONG *data,des_key_schedule ks, int enc)
132 {
133 DES_encrypt2(data, (DES_key_schedule *)ks, enc);
134 }
135void _ossl_old_des_encrypt3(DES_LONG *data, des_key_schedule ks1,
136 des_key_schedule ks2, des_key_schedule ks3)
137 {
138 DES_encrypt3(data, (DES_key_schedule *)ks1, (DES_key_schedule *)ks2,
139 (DES_key_schedule *)ks3);
140 }
141void _ossl_old_des_decrypt3(DES_LONG *data, des_key_schedule ks1,
142 des_key_schedule ks2, des_key_schedule ks3)
143 {
144 DES_decrypt3(data, (DES_key_schedule *)ks1, (DES_key_schedule *)ks2,
145 (DES_key_schedule *)ks3);
146 }
147void _ossl_old_des_ede3_cbc_encrypt(_ossl_old_des_cblock *input, _ossl_old_des_cblock *output,
148 long length, des_key_schedule ks1, des_key_schedule ks2,
149 des_key_schedule ks3, _ossl_old_des_cblock *ivec, int enc)
150 {
151 DES_ede3_cbc_encrypt((unsigned char *)input, (unsigned char *)output,
152 length, (DES_key_schedule *)ks1, (DES_key_schedule *)ks2,
153 (DES_key_schedule *)ks3, ivec, enc);
154 }
155void _ossl_old_des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out,
156 long length, des_key_schedule ks1, des_key_schedule ks2,
157 des_key_schedule ks3, _ossl_old_des_cblock *ivec, int *num, int enc)
158 {
159 DES_ede3_cfb64_encrypt(in, out, length,
160 (DES_key_schedule *)ks1, (DES_key_schedule *)ks2,
161 (DES_key_schedule *)ks3, ivec, num, enc);
162 }
163void _ossl_old_des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out,
164 long length, des_key_schedule ks1, des_key_schedule ks2,
165 des_key_schedule ks3, _ossl_old_des_cblock *ivec, int *num)
166 {
167 DES_ede3_ofb64_encrypt(in, out, length,
168 (DES_key_schedule *)ks1, (DES_key_schedule *)ks2,
169 (DES_key_schedule *)ks3, ivec, num);
170 }
171
172void _ossl_old_des_xwhite_in2out(_ossl_old_des_cblock (*des_key), _ossl_old_des_cblock (*in_white),
173 _ossl_old_des_cblock (*out_white))
174 {
175 DES_xwhite_in2out(des_key, in_white, out_white);
176 }
177
178int _ossl_old_des_enc_read(int fd,char *buf,int len,des_key_schedule sched,
179 _ossl_old_des_cblock *iv)
180 {
181 return DES_enc_read(fd, buf, len, (DES_key_schedule *)sched, iv);
182 }
183int _ossl_old_des_enc_write(int fd,char *buf,int len,des_key_schedule sched,
184 _ossl_old_des_cblock *iv)
185 {
186 return DES_enc_write(fd, buf, len, (DES_key_schedule *)sched, iv);
187 }
188char *_ossl_old_des_fcrypt(const char *buf,const char *salt, char *ret)
189 {
190 return DES_fcrypt(buf, salt, ret);
191 }
192char *_ossl_old_des_crypt(const char *buf,const char *salt)
193 {
194 return DES_crypt(buf, salt);
195 }
196char *_ossl_old_crypt(const char *buf,const char *salt)
197 {
198 return DES_crypt(buf, salt);
199 }
200void _ossl_old_des_ofb_encrypt(unsigned char *in,unsigned char *out,
201 int numbits,long length,des_key_schedule schedule,_ossl_old_des_cblock *ivec)
202 {
203 DES_ofb_encrypt(in, out, numbits, length, (DES_key_schedule *)schedule,
204 ivec);
205 }
206void _ossl_old_des_pcbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length,
207 des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc)
208 {
209 DES_pcbc_encrypt((unsigned char *)input, (unsigned char *)output,
210 length, (DES_key_schedule *)schedule, ivec, enc);
211 }
212DES_LONG _ossl_old_des_quad_cksum(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,
213 long length,int out_count,_ossl_old_des_cblock *seed)
214 {
215 return DES_quad_cksum((unsigned char *)input, output, length,
216 out_count, seed);
217 }
218void _ossl_old_des_random_seed(_ossl_old_des_cblock key)
219 {
220 RAND_seed(key, sizeof(_ossl_old_des_cblock));
221 }
222void _ossl_old_des_random_key(_ossl_old_des_cblock ret)
223 {
224 DES_random_key((DES_cblock *)ret);
225 }
226int _ossl_old_des_read_password(_ossl_old_des_cblock *key, const char *prompt,
227 int verify)
228 {
229 return DES_read_password(key, prompt, verify);
230 }
231int _ossl_old_des_read_2passwords(_ossl_old_des_cblock *key1, _ossl_old_des_cblock *key2,
232 const char *prompt, int verify)
233 {
234 return DES_read_2passwords(key1, key2, prompt, verify);
235 }
236void _ossl_old_des_set_odd_parity(_ossl_old_des_cblock *key)
237 {
238 DES_set_odd_parity(key);
239 }
240int _ossl_old_des_is_weak_key(_ossl_old_des_cblock *key)
241 {
242 return DES_is_weak_key(key);
243 }
244int _ossl_old_des_set_key(_ossl_old_des_cblock *key,des_key_schedule schedule)
245 {
246 return DES_set_key(key, (DES_key_schedule *)schedule);
247 }
248int _ossl_old_des_key_sched(_ossl_old_des_cblock *key,des_key_schedule schedule)
249 {
250 return DES_key_sched(key, (DES_key_schedule *)schedule);
251 }
252void _ossl_old_des_string_to_key(char *str,_ossl_old_des_cblock *key)
253 {
254 DES_string_to_key(str, key);
255 }
256void _ossl_old_des_string_to_2keys(char *str,_ossl_old_des_cblock *key1,_ossl_old_des_cblock *key2)
257 {
258 DES_string_to_2keys(str, key1, key2);
259 }
260void _ossl_old_des_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
261 des_key_schedule schedule, _ossl_old_des_cblock *ivec, int *num, int enc)
262 {
263 DES_cfb64_encrypt(in, out, length, (DES_key_schedule *)schedule,
264 ivec, num, enc);
265 }
266void _ossl_old_des_ofb64_encrypt(unsigned char *in, unsigned char *out, long length,
267 des_key_schedule schedule, _ossl_old_des_cblock *ivec, int *num)
268 {
269 DES_ofb64_encrypt(in, out, length, (DES_key_schedule *)schedule,
270 ivec, num);
271 }
diff --git a/src/lib/libcrypto/des/des_old.h b/src/lib/libcrypto/des/des_old.h
new file mode 100644
index 0000000000..fe32f21f61
--- /dev/null
+++ b/src/lib/libcrypto/des/des_old.h
@@ -0,0 +1,439 @@
1/* crypto/des/des_old.h -*- mode:C; c-file-style: "eay" -*- */
2
3/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
4 *
5 * The function names in here are deprecated and are only present to
6 * provide an interface compatible with openssl 0.9.6 and older as
7 * well as libdes. OpenSSL now provides functions where "des_" has
8 * been replaced with "DES_" in the names, to make it possible to
9 * make incompatible changes that are needed for C type security and
10 * other stuff.
11 *
12 * This include files has two compatibility modes:
13 *
14 * - If OPENSSL_DES_LIBDES_COMPATIBILITY is defined, you get an API
15 * that is compatible with libdes and SSLeay.
16 * - If OPENSSL_DES_LIBDES_COMPATIBILITY isn't defined, you get an
17 * API that is compatible with OpenSSL 0.9.5x to 0.9.6x.
18 *
19 * Note that these modes break earlier snapshots of OpenSSL, where
20 * libdes compatibility was the only available mode or (later on) the
21 * prefered compatibility mode. However, after much consideration
22 * (and more or less violent discussions with external parties), it
23 * was concluded that OpenSSL should be compatible with earlier versions
24 * of itself before anything else. Also, in all honesty, libdes is
25 * an old beast that shouldn't really be used any more.
26 *
27 * Please consider starting to use the DES_ functions rather than the
28 * des_ ones. The des_ functions will disappear completely before
29 * OpenSSL 1.0!
30 *
31 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
32 */
33
34/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
35 * project 2001.
36 */
37/* ====================================================================
38 * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
39 *
40 * Redistribution and use in source and binary forms, with or without
41 * modification, are permitted provided that the following conditions
42 * are met:
43 *
44 * 1. Redistributions of source code must retain the above copyright
45 * notice, this list of conditions and the following disclaimer.
46 *
47 * 2. Redistributions in binary form must reproduce the above copyright
48 * notice, this list of conditions and the following disclaimer in
49 * the documentation and/or other materials provided with the
50 * distribution.
51 *
52 * 3. All advertising materials mentioning features or use of this
53 * software must display the following acknowledgment:
54 * "This product includes software developed by the OpenSSL Project
55 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
56 *
57 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
58 * endorse or promote products derived from this software without
59 * prior written permission. For written permission, please contact
60 * openssl-core@openssl.org.
61 *
62 * 5. Products derived from this software may not be called "OpenSSL"
63 * nor may "OpenSSL" appear in their names without prior written
64 * permission of the OpenSSL Project.
65 *
66 * 6. Redistributions of any form whatsoever must retain the following
67 * acknowledgment:
68 * "This product includes software developed by the OpenSSL Project
69 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
70 *
71 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
72 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
73 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
74 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
75 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
76 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
77 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
78 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
79 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
80 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
81 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
82 * OF THE POSSIBILITY OF SUCH DAMAGE.
83 * ====================================================================
84 *
85 * This product includes cryptographic software written by Eric Young
86 * (eay@cryptsoft.com). This product includes software written by Tim
87 * Hudson (tjh@cryptsoft.com).
88 *
89 */
90
91#ifndef HEADER_DES_OLD_H
92#define HEADER_DES_OLD_H
93
94#ifdef OPENSSL_NO_DES
95#error DES is disabled.
96#endif
97
98#ifndef HEADER_DES_H
99#error You must include des.h, not des_old.h directly.
100#endif
101
102#ifdef _KERBEROS_DES_H
103#error <openssl/des_old.h> replaces <kerberos/des.h>.
104#endif
105
106#include <openssl/opensslconf.h> /* DES_LONG */
107#include <openssl/e_os2.h> /* OPENSSL_EXTERN */
108#include <openssl/symhacks.h>
109
110#ifdef OPENSSL_BUILD_SHLIBCRYPTO
111# undef OPENSSL_EXTERN
112# define OPENSSL_EXTERN OPENSSL_EXPORT
113#endif
114
115#ifdef __cplusplus
116extern "C" {
117#endif
118
119typedef unsigned char _ossl_old_des_cblock[8];
120typedef struct _ossl_old_des_ks_struct
121 {
122 union {
123 _ossl_old_des_cblock _;
124 /* make sure things are correct size on machines with
125 * 8 byte longs */
126 DES_LONG pad[2];
127 } ks;
128 } _ossl_old_des_key_schedule[16];
129
130#ifndef OPENSSL_DES_LIBDES_COMPATIBILITY
131#define des_cblock DES_cblock
132#define const_des_cblock const_DES_cblock
133#define des_key_schedule DES_key_schedule
134#define des_ecb3_encrypt(i,o,k1,k2,k3,e)\
135 DES_ecb3_encrypt((i),(o),&(k1),&(k2),&(k3),(e))
136#define des_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e)\
137 DES_ede3_cbc_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(e))
138#define des_ede3_cbcm_encrypt(i,o,l,k1,k2,k3,iv1,iv2,e)\
139 DES_ede3_cbcm_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv1),(iv2),(e))
140#define des_ede3_cfb64_encrypt(i,o,l,k1,k2,k3,iv,n,e)\
141 DES_ede3_cfb64_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(n),(e))
142#define des_ede3_ofb64_encrypt(i,o,l,k1,k2,k3,iv,n)\
143 DES_ede3_ofb64_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(n))
144#define des_options()\
145 DES_options()
146#define des_cbc_cksum(i,o,l,k,iv)\
147 DES_cbc_cksum((i),(o),(l),&(k),(iv))
148#define des_cbc_encrypt(i,o,l,k,iv,e)\
149 DES_cbc_encrypt((i),(o),(l),&(k),(iv),(e))
150#define des_ncbc_encrypt(i,o,l,k,iv,e)\
151 DES_ncbc_encrypt((i),(o),(l),&(k),(iv),(e))
152#define des_xcbc_encrypt(i,o,l,k,iv,inw,outw,e)\
153 DES_xcbc_encrypt((i),(o),(l),&(k),(iv),(inw),(outw),(e))
154#define des_cfb_encrypt(i,o,n,l,k,iv,e)\
155 DES_cfb_encrypt((i),(o),(n),(l),&(k),(iv),(e))
156#define des_ecb_encrypt(i,o,k,e)\
157 DES_ecb_encrypt((i),(o),&(k),(e))
158#define des_encrypt1(d,k,e)\
159 DES_encrypt1((d),&(k),(e))
160#define des_encrypt2(d,k,e)\
161 DES_encrypt2((d),&(k),(e))
162#define des_encrypt3(d,k1,k2,k3)\
163 DES_encrypt3((d),&(k1),&(k2),&(k3))
164#define des_decrypt3(d,k1,k2,k3)\
165 DES_decrypt3((d),&(k1),&(k2),&(k3))
166#define des_xwhite_in2out(k,i,o)\
167 DES_xwhite_in2out((k),(i),(o))
168#define des_enc_read(f,b,l,k,iv)\
169 DES_enc_read((f),(b),(l),&(k),(iv))
170#define des_enc_write(f,b,l,k,iv)\
171 DES_enc_write((f),(b),(l),&(k),(iv))
172#define des_fcrypt(b,s,r)\
173 DES_fcrypt((b),(s),(r))
174#define des_crypt(b,s)\
175 DES_crypt((b),(s))
176#if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT) && !defined(__OpenBSD__)
177#define crypt(b,s)\
178 DES_crypt((b),(s))
179#endif
180#define des_ofb_encrypt(i,o,n,l,k,iv)\
181 DES_ofb_encrypt((i),(o),(n),(l),&(k),(iv))
182#define des_pcbc_encrypt(i,o,l,k,iv,e)\
183 DES_pcbc_encrypt((i),(o),(l),&(k),(iv),(e))
184#define des_quad_cksum(i,o,l,c,s)\
185 DES_quad_cksum((i),(o),(l),(c),(s))
186#define des_random_seed(k)\
187 _ossl_096_des_random_seed((k))
188#define des_random_key(r)\
189 DES_random_key((r))
190#define des_read_password(k,p,v) \
191 DES_read_password((k),(p),(v))
192#define des_read_2passwords(k1,k2,p,v) \
193 DES_read_2passwords((k1),(k2),(p),(v))
194#define des_set_odd_parity(k)\
195 DES_set_odd_parity((k))
196#define des_check_key_parity(k)\
197 DES_check_key_parity((k))
198#define des_is_weak_key(k)\
199 DES_is_weak_key((k))
200#define des_set_key(k,ks)\
201 DES_set_key((k),&(ks))
202#define des_key_sched(k,ks)\
203 DES_key_sched((k),&(ks))
204#define des_set_key_checked(k,ks)\
205 DES_set_key_checked((k),&(ks))
206#define des_set_key_unchecked(k,ks)\
207 DES_set_key_unchecked((k),&(ks))
208#define des_string_to_key(s,k)\
209 DES_string_to_key((s),(k))
210#define des_string_to_2keys(s,k1,k2)\
211 DES_string_to_2keys((s),(k1),(k2))
212#define des_cfb64_encrypt(i,o,l,ks,iv,n,e)\
213 DES_cfb64_encrypt((i),(o),(l),&(ks),(iv),(n),(e))
214#define des_ofb64_encrypt(i,o,l,ks,iv,n)\
215 DES_ofb64_encrypt((i),(o),(l),&(ks),(iv),(n))
216
217
218#define des_ecb2_encrypt(i,o,k1,k2,e) \
219 des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))
220
221#define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \
222 des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))
223
224#define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \
225 des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))
226
227#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \
228 des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))
229
230#define des_check_key DES_check_key
231#define des_rw_mode DES_rw_mode
232#else /* libdes compatibility */
233/* Map all symbol names to _ossl_old_des_* form, so we avoid all
234 clashes with libdes */
235#define des_cblock _ossl_old_des_cblock
236#define des_key_schedule _ossl_old_des_key_schedule
237#define des_ecb3_encrypt(i,o,k1,k2,k3,e)\
238 _ossl_old_des_ecb3_encrypt((i),(o),(k1),(k2),(k3),(e))
239#define des_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e)\
240 _ossl_old_des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(e))
241#define des_ede3_cfb64_encrypt(i,o,l,k1,k2,k3,iv,n,e)\
242 _ossl_old_des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(n),(e))
243#define des_ede3_ofb64_encrypt(i,o,l,k1,k2,k3,iv,n)\
244 _ossl_old_des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(n))
245#define des_options()\
246 _ossl_old_des_options()
247#define des_cbc_cksum(i,o,l,k,iv)\
248 _ossl_old_des_cbc_cksum((i),(o),(l),(k),(iv))
249#define des_cbc_encrypt(i,o,l,k,iv,e)\
250 _ossl_old_des_cbc_encrypt((i),(o),(l),(k),(iv),(e))
251#define des_ncbc_encrypt(i,o,l,k,iv,e)\
252 _ossl_old_des_ncbc_encrypt((i),(o),(l),(k),(iv),(e))
253#define des_xcbc_encrypt(i,o,l,k,iv,inw,outw,e)\
254 _ossl_old_des_xcbc_encrypt((i),(o),(l),(k),(iv),(inw),(outw),(e))
255#define des_cfb_encrypt(i,o,n,l,k,iv,e)\
256 _ossl_old_des_cfb_encrypt((i),(o),(n),(l),(k),(iv),(e))
257#define des_ecb_encrypt(i,o,k,e)\
258 _ossl_old_des_ecb_encrypt((i),(o),(k),(e))
259#define des_encrypt(d,k,e)\
260 _ossl_old_des_encrypt((d),(k),(e))
261#define des_encrypt2(d,k,e)\
262 _ossl_old_des_encrypt2((d),(k),(e))
263#define des_encrypt3(d,k1,k2,k3)\
264 _ossl_old_des_encrypt3((d),(k1),(k2),(k3))
265#define des_decrypt3(d,k1,k2,k3)\
266 _ossl_old_des_decrypt3((d),(k1),(k2),(k3))
267#define des_xwhite_in2out(k,i,o)\
268 _ossl_old_des_xwhite_in2out((k),(i),(o))
269#define des_enc_read(f,b,l,k,iv)\
270 _ossl_old_des_enc_read((f),(b),(l),(k),(iv))
271#define des_enc_write(f,b,l,k,iv)\
272 _ossl_old_des_enc_write((f),(b),(l),(k),(iv))
273#define des_fcrypt(b,s,r)\
274 _ossl_old_des_fcrypt((b),(s),(r))
275#define des_crypt(b,s)\
276 _ossl_old_des_crypt((b),(s))
277#if 0
278#define crypt(b,s)\
279 _ossl_old_crypt((b),(s))
280#endif
281#define des_ofb_encrypt(i,o,n,l,k,iv)\
282 _ossl_old_des_ofb_encrypt((i),(o),(n),(l),(k),(iv))
283#define des_pcbc_encrypt(i,o,l,k,iv,e)\
284 _ossl_old_des_pcbc_encrypt((i),(o),(l),(k),(iv),(e))
285#define des_quad_cksum(i,o,l,c,s)\
286 _ossl_old_des_quad_cksum((i),(o),(l),(c),(s))
287#define des_random_seed(k)\
288 _ossl_old_des_random_seed((k))
289#define des_random_key(r)\
290 _ossl_old_des_random_key((r))
291#define des_read_password(k,p,v) \
292 _ossl_old_des_read_password((k),(p),(v))
293#define des_read_2passwords(k1,k2,p,v) \
294 _ossl_old_des_read_2passwords((k1),(k2),(p),(v))
295#define des_set_odd_parity(k)\
296 _ossl_old_des_set_odd_parity((k))
297#define des_is_weak_key(k)\
298 _ossl_old_des_is_weak_key((k))
299#define des_set_key(k,ks)\
300 _ossl_old_des_set_key((k),(ks))
301#define des_key_sched(k,ks)\
302 _ossl_old_des_key_sched((k),(ks))
303#define des_string_to_key(s,k)\
304 _ossl_old_des_string_to_key((s),(k))
305#define des_string_to_2keys(s,k1,k2)\
306 _ossl_old_des_string_to_2keys((s),(k1),(k2))
307#define des_cfb64_encrypt(i,o,l,ks,iv,n,e)\
308 _ossl_old_des_cfb64_encrypt((i),(o),(l),(ks),(iv),(n),(e))
309#define des_ofb64_encrypt(i,o,l,ks,iv,n)\
310 _ossl_old_des_ofb64_encrypt((i),(o),(l),(ks),(iv),(n))
311
312
313#define des_ecb2_encrypt(i,o,k1,k2,e) \
314 des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))
315
316#define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \
317 des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))
318
319#define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \
320 des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))
321
322#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \
323 des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))
324
325#define des_check_key DES_check_key
326#define des_rw_mode DES_rw_mode
327#endif
328
329const char *_ossl_old_des_options(void);
330void _ossl_old_des_ecb3_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,
331 _ossl_old_des_key_schedule ks1,_ossl_old_des_key_schedule ks2,
332 _ossl_old_des_key_schedule ks3, int enc);
333DES_LONG _ossl_old_des_cbc_cksum(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,
334 long length,_ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec);
335void _ossl_old_des_cbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length,
336 _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc);
337void _ossl_old_des_ncbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length,
338 _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc);
339void _ossl_old_des_xcbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length,
340 _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,
341 _ossl_old_des_cblock *inw,_ossl_old_des_cblock *outw,int enc);
342void _ossl_old_des_cfb_encrypt(unsigned char *in,unsigned char *out,int numbits,
343 long length,_ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc);
344void _ossl_old_des_ecb_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,
345 _ossl_old_des_key_schedule ks,int enc);
346void _ossl_old_des_encrypt(DES_LONG *data,_ossl_old_des_key_schedule ks, int enc);
347void _ossl_old_des_encrypt2(DES_LONG *data,_ossl_old_des_key_schedule ks, int enc);
348void _ossl_old_des_encrypt3(DES_LONG *data, _ossl_old_des_key_schedule ks1,
349 _ossl_old_des_key_schedule ks2, _ossl_old_des_key_schedule ks3);
350void _ossl_old_des_decrypt3(DES_LONG *data, _ossl_old_des_key_schedule ks1,
351 _ossl_old_des_key_schedule ks2, _ossl_old_des_key_schedule ks3);
352void _ossl_old_des_ede3_cbc_encrypt(_ossl_old_des_cblock *input, _ossl_old_des_cblock *output,
353 long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2,
354 _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int enc);
355void _ossl_old_des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out,
356 long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2,
357 _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int *num, int enc);
358void _ossl_old_des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out,
359 long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2,
360 _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int *num);
361
362void _ossl_old_des_xwhite_in2out(_ossl_old_des_cblock (*des_key), _ossl_old_des_cblock (*in_white),
363 _ossl_old_des_cblock (*out_white));
364
365int _ossl_old_des_enc_read(int fd,char *buf,int len,_ossl_old_des_key_schedule sched,
366 _ossl_old_des_cblock *iv);
367int _ossl_old_des_enc_write(int fd,char *buf,int len,_ossl_old_des_key_schedule sched,
368 _ossl_old_des_cblock *iv);
369char *_ossl_old_des_fcrypt(const char *buf,const char *salt, char *ret);
370char *_ossl_old_des_crypt(const char *buf,const char *salt);
371#if !defined(PERL5) && !defined(NeXT)
372char *_ossl_old_crypt(const char *buf,const char *salt);
373#endif
374void _ossl_old_des_ofb_encrypt(unsigned char *in,unsigned char *out,
375 int numbits,long length,_ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec);
376void _ossl_old_des_pcbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length,
377 _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc);
378DES_LONG _ossl_old_des_quad_cksum(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,
379 long length,int out_count,_ossl_old_des_cblock *seed);
380void _ossl_old_des_random_seed(_ossl_old_des_cblock key);
381void _ossl_old_des_random_key(_ossl_old_des_cblock ret);
382int _ossl_old_des_read_password(_ossl_old_des_cblock *key,const char *prompt,int verify);
383int _ossl_old_des_read_2passwords(_ossl_old_des_cblock *key1,_ossl_old_des_cblock *key2,
384 const char *prompt,int verify);
385void _ossl_old_des_set_odd_parity(_ossl_old_des_cblock *key);
386int _ossl_old_des_is_weak_key(_ossl_old_des_cblock *key);
387int _ossl_old_des_set_key(_ossl_old_des_cblock *key,_ossl_old_des_key_schedule schedule);
388int _ossl_old_des_key_sched(_ossl_old_des_cblock *key,_ossl_old_des_key_schedule schedule);
389void _ossl_old_des_string_to_key(char *str,_ossl_old_des_cblock *key);
390void _ossl_old_des_string_to_2keys(char *str,_ossl_old_des_cblock *key1,_ossl_old_des_cblock *key2);
391void _ossl_old_des_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
392 _ossl_old_des_key_schedule schedule, _ossl_old_des_cblock *ivec, int *num, int enc);
393void _ossl_old_des_ofb64_encrypt(unsigned char *in, unsigned char *out, long length,
394 _ossl_old_des_key_schedule schedule, _ossl_old_des_cblock *ivec, int *num);
395
396void _ossl_096_des_random_seed(des_cblock *key);
397
398/* The following definitions provide compatibility with the MIT Kerberos
399 * library. The _ossl_old_des_key_schedule structure is not binary compatible. */
400
401#define _KERBEROS_DES_H
402
403#define KRBDES_ENCRYPT DES_ENCRYPT
404#define KRBDES_DECRYPT DES_DECRYPT
405
406#ifdef KERBEROS
407# define ENCRYPT DES_ENCRYPT
408# define DECRYPT DES_DECRYPT
409#endif
410
411#ifndef NCOMPAT
412# define C_Block des_cblock
413# define Key_schedule des_key_schedule
414# define KEY_SZ DES_KEY_SZ
415# define string_to_key des_string_to_key
416# define read_pw_string des_read_pw_string
417# define random_key des_random_key
418# define pcbc_encrypt des_pcbc_encrypt
419# define set_key des_set_key
420# define key_sched des_key_sched
421# define ecb_encrypt des_ecb_encrypt
422# define cbc_encrypt des_cbc_encrypt
423# define ncbc_encrypt des_ncbc_encrypt
424# define xcbc_encrypt des_xcbc_encrypt
425# define cbc_cksum des_cbc_cksum
426# define quad_cksum des_quad_cksum
427# define check_parity des_check_key_parity
428#endif
429
430#define des_fixup_key_parity DES_fixup_key_parity
431
432#ifdef __cplusplus
433}
434#endif
435
436/* for DES_read_pw_string et al */
437#include <openssl/ui_compat.h>
438
439#endif
diff --git a/src/lib/libcrypto/des/des_old2.c b/src/lib/libcrypto/des/des_old2.c
new file mode 100644
index 0000000000..c8fa3ee135
--- /dev/null
+++ b/src/lib/libcrypto/des/des_old2.c
@@ -0,0 +1,82 @@
1/* crypto/des/des_old.c -*- mode:C; c-file-style: "eay" -*- */
2
3/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
4 *
5 * The function names in here are deprecated and are only present to
6 * provide an interface compatible with OpenSSL 0.9.6c. OpenSSL now
7 * provides functions where "des_" has been replaced with "DES_" in
8 * the names, to make it possible to make incompatible changes that
9 * are needed for C type security and other stuff.
10 *
11 * Please consider starting to use the DES_ functions rather than the
12 * des_ ones. The des_ functions will dissapear completely before
13 * OpenSSL 1.0!
14 *
15 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
16 */
17
18/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
19 * project 2001.
20 */
21/* ====================================================================
22 * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.
23 *
24 * Redistribution and use in source and binary forms, with or without
25 * modification, are permitted provided that the following conditions
26 * are met:
27 *
28 * 1. Redistributions of source code must retain the above copyright
29 * notice, this list of conditions and the following disclaimer.
30 *
31 * 2. Redistributions in binary form must reproduce the above copyright
32 * notice, this list of conditions and the following disclaimer in
33 * the documentation and/or other materials provided with the
34 * distribution.
35 *
36 * 3. All advertising materials mentioning features or use of this
37 * software must display the following acknowledgment:
38 * "This product includes software developed by the OpenSSL Project
39 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40 *
41 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42 * endorse or promote products derived from this software without
43 * prior written permission. For written permission, please contact
44 * openssl-core@openssl.org.
45 *
46 * 5. Products derived from this software may not be called "OpenSSL"
47 * nor may "OpenSSL" appear in their names without prior written
48 * permission of the OpenSSL Project.
49 *
50 * 6. Redistributions of any form whatsoever must retain the following
51 * acknowledgment:
52 * "This product includes software developed by the OpenSSL Project
53 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54 *
55 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66 * OF THE POSSIBILITY OF SUCH DAMAGE.
67 * ====================================================================
68 *
69 * This product includes cryptographic software written by Eric Young
70 * (eay@cryptsoft.com). This product includes software written by Tim
71 * Hudson (tjh@cryptsoft.com).
72 *
73 */
74
75#undef OPENSSL_DES_LIBDES_COMPATIBILITY
76#include <openssl/des.h>
77#include <openssl/rand.h>
78
79void _ossl_096_des_random_seed(DES_cblock *key)
80 {
81 RAND_seed(key, sizeof(DES_cblock));
82 }
diff --git a/src/lib/libcrypto/des/des_opts.c b/src/lib/libcrypto/des/des_opts.c
new file mode 100644
index 0000000000..79278b920e
--- /dev/null
+++ b/src/lib/libcrypto/des/des_opts.c
@@ -0,0 +1,604 @@
1/* crypto/des/des_opts.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/* define PART1, PART2, PART3 or PART4 to build only with a few of the options.
60 * This is for machines with 64k code segment size restrictions. */
61
62#if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX)
63#define TIMES
64#endif
65
66#include <stdio.h>
67#ifndef OPENSSL_SYS_MSDOS
68#include <openssl/e_os2.h>
69#include OPENSSL_UNISTD
70#else
71#include <io.h>
72extern void exit();
73#endif
74#include <signal.h>
75#ifndef _IRIX
76#include <time.h>
77#endif
78#ifdef TIMES
79#include <sys/types.h>
80#include <sys/times.h>
81#endif
82
83/* Depending on the VMS version, the tms structure is perhaps defined.
84 The __TMS macro will show if it was. If it wasn't defined, we should
85 undefine TIMES, since that tells the rest of the program how things
86 should be handled. -- Richard Levitte */
87#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
88#undef TIMES
89#endif
90
91#ifndef TIMES
92#include <sys/timeb.h>
93#endif
94
95
96#if defined(sun) || defined(__ultrix)
97#define _POSIX_SOURCE
98#include <limits.h>
99#include <sys/param.h>
100#endif
101
102#include <openssl/des.h>
103#include "spr.h"
104
105#define DES_DEFAULT_OPTIONS
106
107#if !defined(PART1) && !defined(PART2) && !defined(PART3) && !defined(PART4)
108#define PART1
109#define PART2
110#define PART3
111#define PART4
112#endif
113
114#ifdef PART1
115
116#undef DES_UNROLL
117#undef DES_RISC1
118#undef DES_RISC2
119#undef DES_PTR
120#undef D_ENCRYPT
121#define DES_encrypt1 des_encrypt_u4_cisc_idx
122#define DES_encrypt2 des_encrypt2_u4_cisc_idx
123#define DES_encrypt3 des_encrypt3_u4_cisc_idx
124#define DES_decrypt3 des_decrypt3_u4_cisc_idx
125#undef HEADER_DES_LOCL_H
126#include "des_enc.c"
127
128#define DES_UNROLL
129#undef DES_RISC1
130#undef DES_RISC2
131#undef DES_PTR
132#undef D_ENCRYPT
133#undef DES_encrypt1
134#undef DES_encrypt2
135#undef DES_encrypt3
136#undef DES_decrypt3
137#define DES_encrypt1 des_encrypt_u16_cisc_idx
138#define DES_encrypt2 des_encrypt2_u16_cisc_idx
139#define DES_encrypt3 des_encrypt3_u16_cisc_idx
140#define DES_decrypt3 des_decrypt3_u16_cisc_idx
141#undef HEADER_DES_LOCL_H
142#include "des_enc.c"
143
144#undef DES_UNROLL
145#define DES_RISC1
146#undef DES_RISC2
147#undef DES_PTR
148#undef D_ENCRYPT
149#undef DES_encrypt1
150#undef DES_encrypt2
151#undef DES_encrypt3
152#undef DES_decrypt3
153#define DES_encrypt1 des_encrypt_u4_risc1_idx
154#define DES_encrypt2 des_encrypt2_u4_risc1_idx
155#define DES_encrypt3 des_encrypt3_u4_risc1_idx
156#define DES_decrypt3 des_decrypt3_u4_risc1_idx
157#undef HEADER_DES_LOCL_H
158#include "des_enc.c"
159
160#endif
161
162#ifdef PART2
163
164#undef DES_UNROLL
165#undef DES_RISC1
166#define DES_RISC2
167#undef DES_PTR
168#undef D_ENCRYPT
169#undef DES_encrypt1
170#undef DES_encrypt2
171#undef DES_encrypt3
172#undef DES_decrypt3
173#define DES_encrypt1 des_encrypt_u4_risc2_idx
174#define DES_encrypt2 des_encrypt2_u4_risc2_idx
175#define DES_encrypt3 des_encrypt3_u4_risc2_idx
176#define DES_decrypt3 des_decrypt3_u4_risc2_idx
177#undef HEADER_DES_LOCL_H
178#include "des_enc.c"
179
180#define DES_UNROLL
181#define DES_RISC1
182#undef DES_RISC2
183#undef DES_PTR
184#undef D_ENCRYPT
185#undef DES_encrypt1
186#undef DES_encrypt2
187#undef DES_encrypt3
188#undef DES_decrypt3
189#define DES_encrypt1 des_encrypt_u16_risc1_idx
190#define DES_encrypt2 des_encrypt2_u16_risc1_idx
191#define DES_encrypt3 des_encrypt3_u16_risc1_idx
192#define DES_decrypt3 des_decrypt3_u16_risc1_idx
193#undef HEADER_DES_LOCL_H
194#include "des_enc.c"
195
196#define DES_UNROLL
197#undef DES_RISC1
198#define DES_RISC2
199#undef DES_PTR
200#undef D_ENCRYPT
201#undef DES_encrypt1
202#undef DES_encrypt2
203#undef DES_encrypt3
204#undef DES_decrypt3
205#define DES_encrypt1 des_encrypt_u16_risc2_idx
206#define DES_encrypt2 des_encrypt2_u16_risc2_idx
207#define DES_encrypt3 des_encrypt3_u16_risc2_idx
208#define DES_decrypt3 des_decrypt3_u16_risc2_idx
209#undef HEADER_DES_LOCL_H
210#include "des_enc.c"
211
212#endif
213
214#ifdef PART3
215
216#undef DES_UNROLL
217#undef DES_RISC1
218#undef DES_RISC2
219#define DES_PTR
220#undef D_ENCRYPT
221#undef DES_encrypt1
222#undef DES_encrypt2
223#undef DES_encrypt3
224#undef DES_decrypt3
225#define DES_encrypt1 des_encrypt_u4_cisc_ptr
226#define DES_encrypt2 des_encrypt2_u4_cisc_ptr
227#define DES_encrypt3 des_encrypt3_u4_cisc_ptr
228#define DES_decrypt3 des_decrypt3_u4_cisc_ptr
229#undef HEADER_DES_LOCL_H
230#include "des_enc.c"
231
232#define DES_UNROLL
233#undef DES_RISC1
234#undef DES_RISC2
235#define DES_PTR
236#undef D_ENCRYPT
237#undef DES_encrypt1
238#undef DES_encrypt2
239#undef DES_encrypt3
240#undef DES_decrypt3
241#define DES_encrypt1 des_encrypt_u16_cisc_ptr
242#define DES_encrypt2 des_encrypt2_u16_cisc_ptr
243#define DES_encrypt3 des_encrypt3_u16_cisc_ptr
244#define DES_decrypt3 des_decrypt3_u16_cisc_ptr
245#undef HEADER_DES_LOCL_H
246#include "des_enc.c"
247
248#undef DES_UNROLL
249#define DES_RISC1
250#undef DES_RISC2
251#define DES_PTR
252#undef D_ENCRYPT
253#undef DES_encrypt1
254#undef DES_encrypt2
255#undef DES_encrypt3
256#undef DES_decrypt3
257#define DES_encrypt1 des_encrypt_u4_risc1_ptr
258#define DES_encrypt2 des_encrypt2_u4_risc1_ptr
259#define DES_encrypt3 des_encrypt3_u4_risc1_ptr
260#define DES_decrypt3 des_decrypt3_u4_risc1_ptr
261#undef HEADER_DES_LOCL_H
262#include "des_enc.c"
263
264#endif
265
266#ifdef PART4
267
268#undef DES_UNROLL
269#undef DES_RISC1
270#define DES_RISC2
271#define DES_PTR
272#undef D_ENCRYPT
273#undef DES_encrypt1
274#undef DES_encrypt2
275#undef DES_encrypt3
276#undef DES_decrypt3
277#define DES_encrypt1 des_encrypt_u4_risc2_ptr
278#define DES_encrypt2 des_encrypt2_u4_risc2_ptr
279#define DES_encrypt3 des_encrypt3_u4_risc2_ptr
280#define DES_decrypt3 des_decrypt3_u4_risc2_ptr
281#undef HEADER_DES_LOCL_H
282#include "des_enc.c"
283
284#define DES_UNROLL
285#define DES_RISC1
286#undef DES_RISC2
287#define DES_PTR
288#undef D_ENCRYPT
289#undef DES_encrypt1
290#undef DES_encrypt2
291#undef DES_encrypt3
292#undef DES_decrypt3
293#define DES_encrypt1 des_encrypt_u16_risc1_ptr
294#define DES_encrypt2 des_encrypt2_u16_risc1_ptr
295#define DES_encrypt3 des_encrypt3_u16_risc1_ptr
296#define DES_decrypt3 des_decrypt3_u16_risc1_ptr
297#undef HEADER_DES_LOCL_H
298#include "des_enc.c"
299
300#define DES_UNROLL
301#undef DES_RISC1
302#define DES_RISC2
303#define DES_PTR
304#undef D_ENCRYPT
305#undef DES_encrypt1
306#undef DES_encrypt2
307#undef DES_encrypt3
308#undef DES_decrypt3
309#define DES_encrypt1 des_encrypt_u16_risc2_ptr
310#define DES_encrypt2 des_encrypt2_u16_risc2_ptr
311#define DES_encrypt3 des_encrypt3_u16_risc2_ptr
312#define DES_decrypt3 des_decrypt3_u16_risc2_ptr
313#undef HEADER_DES_LOCL_H
314#include "des_enc.c"
315
316#endif
317
318/* The following if from times(3) man page. It may need to be changed */
319#ifndef HZ
320# ifndef CLK_TCK
321# ifndef _BSD_CLK_TCK_ /* FreeBSD fix */
322# define HZ 100.0
323# else /* _BSD_CLK_TCK_ */
324# define HZ ((double)_BSD_CLK_TCK_)
325# endif
326# else /* CLK_TCK */
327# define HZ ((double)CLK_TCK)
328# endif
329#endif
330
331#define BUFSIZE ((long)1024)
332long run=0;
333
334double Time_F(int s);
335#ifdef SIGALRM
336#if defined(__STDC__) || defined(sgi)
337#define SIGRETTYPE void
338#else
339#define SIGRETTYPE int
340#endif
341
342SIGRETTYPE sig_done(int sig);
343SIGRETTYPE sig_done(int sig)
344 {
345 signal(SIGALRM,sig_done);
346 run=0;
347#ifdef LINT
348 sig=sig;
349#endif
350 }
351#endif
352
353#define START 0
354#define STOP 1
355
356double Time_F(int s)
357 {
358 double ret;
359#ifdef TIMES
360 static struct tms tstart,tend;
361
362 if (s == START)
363 {
364 times(&tstart);
365 return(0);
366 }
367 else
368 {
369 times(&tend);
370 ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
371 return((ret == 0.0)?1e-6:ret);
372 }
373#else /* !times() */
374 static struct timeb tstart,tend;
375 long i;
376
377 if (s == START)
378 {
379 ftime(&tstart);
380 return(0);
381 }
382 else
383 {
384 ftime(&tend);
385 i=(long)tend.millitm-(long)tstart.millitm;
386 ret=((double)(tend.time-tstart.time))+((double)i)/1000.0;
387 return((ret == 0.0)?1e-6:ret);
388 }
389#endif
390 }
391
392#ifdef SIGALRM
393#define print_name(name) fprintf(stderr,"Doing %s's for 10 seconds\n",name); alarm(10);
394#else
395#define print_name(name) fprintf(stderr,"Doing %s %ld times\n",name,cb);
396#endif
397
398#define time_it(func,name,index) \
399 print_name(name); \
400 Time_F(START); \
401 for (count=0,run=1; COND(cb); count++) \
402 { \
403 unsigned long d[2]; \
404 func(d,&sch,DES_ENCRYPT); \
405 } \
406 tm[index]=Time_F(STOP); \
407 fprintf(stderr,"%ld %s's in %.2f second\n",count,name,tm[index]); \
408 tm[index]=((double)COUNT(cb))/tm[index];
409
410#define print_it(name,index) \
411 fprintf(stderr,"%s bytes per sec = %12.2f (%5.1fuS)\n",name, \
412 tm[index]*8,1.0e6/tm[index]);
413
414int main(int argc, char **argv)
415 {
416 long count;
417 static unsigned char buf[BUFSIZE];
418 static DES_cblock key ={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0};
419 static DES_cblock key2={0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
420 static DES_cblock key3={0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34};
421 DES_key_schedule sch,sch2,sch3;
422 double d,tm[16],max=0;
423 int rank[16];
424 char *str[16];
425 int max_idx=0,i,num=0,j;
426#ifndef SIGALARM
427 long ca,cb,cc,cd,ce;
428#endif
429
430 for (i=0; i<12; i++)
431 {
432 tm[i]=0.0;
433 rank[i]=0;
434 }
435
436#ifndef TIMES
437 fprintf(stderr,"To get the most accurate results, try to run this\n");
438 fprintf(stderr,"program when this computer is idle.\n");
439#endif
440
441 DES_set_key_unchecked(&key,&sch);
442 DES_set_key_unchecked(&key2,&sch2);
443 DES_set_key_unchecked(&key3,&sch3);
444
445#ifndef SIGALRM
446 fprintf(stderr,"First we calculate the approximate speed ...\n");
447 DES_set_key_unchecked(&key,sch);
448 count=10;
449 do {
450 long i;
451 unsigned long data[2];
452
453 count*=2;
454 Time_F(START);
455 for (i=count; i; i--)
456 DES_encrypt1(data,&(sch[0]),DES_ENCRYPT);
457 d=Time_F(STOP);
458 } while (d < 3.0);
459 ca=count;
460 cb=count*3;
461 cc=count*3*8/BUFSIZE+1;
462 cd=count*8/BUFSIZE+1;
463
464 ce=count/20+1;
465#define COND(d) (count != (d))
466#define COUNT(d) (d)
467#else
468#define COND(c) (run)
469#define COUNT(d) (count)
470 signal(SIGALRM,sig_done);
471 alarm(10);
472#endif
473
474#ifdef PART1
475 time_it(des_encrypt_u4_cisc_idx, "des_encrypt_u4_cisc_idx ", 0);
476 time_it(des_encrypt_u16_cisc_idx, "des_encrypt_u16_cisc_idx ", 1);
477 time_it(des_encrypt_u4_risc1_idx, "des_encrypt_u4_risc1_idx ", 2);
478 num+=3;
479#endif
480#ifdef PART2
481 time_it(des_encrypt_u16_risc1_idx,"des_encrypt_u16_risc1_idx", 3);
482 time_it(des_encrypt_u4_risc2_idx, "des_encrypt_u4_risc2_idx ", 4);
483 time_it(des_encrypt_u16_risc2_idx,"des_encrypt_u16_risc2_idx", 5);
484 num+=3;
485#endif
486#ifdef PART3
487 time_it(des_encrypt_u4_cisc_ptr, "des_encrypt_u4_cisc_ptr ", 6);
488 time_it(des_encrypt_u16_cisc_ptr, "des_encrypt_u16_cisc_ptr ", 7);
489 time_it(des_encrypt_u4_risc1_ptr, "des_encrypt_u4_risc1_ptr ", 8);
490 num+=3;
491#endif
492#ifdef PART4
493 time_it(des_encrypt_u16_risc1_ptr,"des_encrypt_u16_risc1_ptr", 9);
494 time_it(des_encrypt_u4_risc2_ptr, "des_encrypt_u4_risc2_ptr ",10);
495 time_it(des_encrypt_u16_risc2_ptr,"des_encrypt_u16_risc2_ptr",11);
496 num+=3;
497#endif
498
499#ifdef PART1
500 str[0]=" 4 c i";
501 print_it("des_encrypt_u4_cisc_idx ",0);
502 max=tm[0];
503 max_idx=0;
504 str[1]="16 c i";
505 print_it("des_encrypt_u16_cisc_idx ",1);
506 if (max < tm[1]) { max=tm[1]; max_idx=1; }
507 str[2]=" 4 r1 i";
508 print_it("des_encrypt_u4_risc1_idx ",2);
509 if (max < tm[2]) { max=tm[2]; max_idx=2; }
510#endif
511#ifdef PART2
512 str[3]="16 r1 i";
513 print_it("des_encrypt_u16_risc1_idx",3);
514 if (max < tm[3]) { max=tm[3]; max_idx=3; }
515 str[4]=" 4 r2 i";
516 print_it("des_encrypt_u4_risc2_idx ",4);
517 if (max < tm[4]) { max=tm[4]; max_idx=4; }
518 str[5]="16 r2 i";
519 print_it("des_encrypt_u16_risc2_idx",5);
520 if (max < tm[5]) { max=tm[5]; max_idx=5; }
521#endif
522#ifdef PART3
523 str[6]=" 4 c p";
524 print_it("des_encrypt_u4_cisc_ptr ",6);
525 if (max < tm[6]) { max=tm[6]; max_idx=6; }
526 str[7]="16 c p";
527 print_it("des_encrypt_u16_cisc_ptr ",7);
528 if (max < tm[7]) { max=tm[7]; max_idx=7; }
529 str[8]=" 4 r1 p";
530 print_it("des_encrypt_u4_risc1_ptr ",8);
531 if (max < tm[8]) { max=tm[8]; max_idx=8; }
532#endif
533#ifdef PART4
534 str[9]="16 r1 p";
535 print_it("des_encrypt_u16_risc1_ptr",9);
536 if (max < tm[9]) { max=tm[9]; max_idx=9; }
537 str[10]=" 4 r2 p";
538 print_it("des_encrypt_u4_risc2_ptr ",10);
539 if (max < tm[10]) { max=tm[10]; max_idx=10; }
540 str[11]="16 r2 p";
541 print_it("des_encrypt_u16_risc2_ptr",11);
542 if (max < tm[11]) { max=tm[11]; max_idx=11; }
543#endif
544 printf("options des ecb/s\n");
545 printf("%s %12.2f 100.0%%\n",str[max_idx],tm[max_idx]);
546 d=tm[max_idx];
547 tm[max_idx]= -2.0;
548 max= -1.0;
549 for (;;)
550 {
551 for (i=0; i<12; i++)
552 {
553 if (max < tm[i]) { max=tm[i]; j=i; }
554 }
555 if (max < 0.0) break;
556 printf("%s %12.2f %4.1f%%\n",str[j],tm[j],tm[j]/d*100.0);
557 tm[j]= -2.0;
558 max= -1.0;
559 }
560
561 switch (max_idx)
562 {
563 case 0:
564 printf("-DDES_DEFAULT_OPTIONS\n");
565 break;
566 case 1:
567 printf("-DDES_UNROLL\n");
568 break;
569 case 2:
570 printf("-DDES_RISC1\n");
571 break;
572 case 3:
573 printf("-DDES_UNROLL -DDES_RISC1\n");
574 break;
575 case 4:
576 printf("-DDES_RISC2\n");
577 break;
578 case 5:
579 printf("-DDES_UNROLL -DDES_RISC2\n");
580 break;
581 case 6:
582 printf("-DDES_PTR\n");
583 break;
584 case 7:
585 printf("-DDES_UNROLL -DDES_PTR\n");
586 break;
587 case 8:
588 printf("-DDES_RISC1 -DDES_PTR\n");
589 break;
590 case 9:
591 printf("-DDES_UNROLL -DDES_RISC1 -DDES_PTR\n");
592 break;
593 case 10:
594 printf("-DDES_RISC2 -DDES_PTR\n");
595 break;
596 case 11:
597 printf("-DDES_UNROLL -DDES_RISC2 -DDES_PTR\n");
598 break;
599 }
600 exit(0);
601#if defined(LINT) || defined(OPENSSL_SYS_MSDOS)
602 return(0);
603#endif
604 }
diff --git a/src/lib/libcrypto/des/des_ver.h b/src/lib/libcrypto/des/des_ver.h
new file mode 100644
index 0000000000..ec9cc736e3
--- /dev/null
+++ b/src/lib/libcrypto/des/des_ver.h
@@ -0,0 +1,67 @@
1/* crypto/des/des_ver.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#include <openssl/e_os2.h>
60
61#ifdef OPENSSL_BUILD_SHLIBCRYPTO
62# undef OPENSSL_EXTERN
63# define OPENSSL_EXTERN OPENSSL_EXPORT
64#endif
65
66OPENSSL_EXTERN const char *DES_version; /* SSLeay version string */
67OPENSSL_EXTERN const char *libdes_version; /* old libdes version string */
diff --git a/src/lib/libcrypto/des/dess.cpp b/src/lib/libcrypto/des/dess.cpp
new file mode 100644
index 0000000000..5549bab90a
--- /dev/null
+++ b/src/lib/libcrypto/des/dess.cpp
@@ -0,0 +1,67 @@
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/des.h>
36
37void main(int argc,char *argv[])
38 {
39 des_key_schedule key;
40 unsigned long s1,s2,e1,e2;
41 unsigned long data[2];
42 int i,j;
43
44 for (j=0; j<6; j++)
45 {
46 for (i=0; i<1000; i++) /**/
47 {
48 des_encrypt1(&data[0],key,1);
49 GetTSC(s1);
50 des_encrypt1(&data[0],key,1);
51 des_encrypt1(&data[0],key,1);
52 des_encrypt1(&data[0],key,1);
53 GetTSC(e1);
54 GetTSC(s2);
55 des_encrypt1(&data[0],key,1);
56 des_encrypt1(&data[0],key,1);
57 des_encrypt1(&data[0],key,1);
58 des_encrypt1(&data[0],key,1);
59 GetTSC(e2);
60 des_encrypt1(&data[0],key,1);
61 }
62
63 printf("des %d %d (%d)\n",
64 e1-s1,e2-s2,((e2-s2)-(e1-s1)));
65 }
66 }
67
diff --git a/src/lib/libcrypto/des/destest.c b/src/lib/libcrypto/des/destest.c
new file mode 100644
index 0000000000..58e8c35dcb
--- /dev/null
+++ b/src/lib/libcrypto/des/destest.c
@@ -0,0 +1,946 @@
1/* crypto/des/destest.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <stdlib.h>
61
62#include <openssl/e_os2.h>
63#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN16) || defined(OPENSSL_SYS_WINDOWS)
64#ifndef OPENSSL_SYS_MSDOS
65#define OPENSSL_SYS_MSDOS
66#endif
67#endif
68
69#ifndef OPENSSL_SYS_MSDOS
70#if !defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_VMS_DECC)
71#include OPENSSL_UNISTD
72#endif
73#else
74#include <io.h>
75#endif
76#include <string.h>
77
78#ifdef OPENSSL_NO_DES
79int main(int argc, char *argv[])
80{
81 printf("No DES support\n");
82 return(0);
83}
84#else
85#include <openssl/des.h>
86
87#if defined(PERL5) || defined(__FreeBSD__) || defined(NeXT)
88#define crypt(c,s) (des_crypt((c),(s)))
89#endif
90
91/* tisk tisk - the test keys don't all have odd parity :-( */
92/* test data */
93#define NUM_TESTS 34
94static unsigned char key_data[NUM_TESTS][8]={
95 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
96 {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},
97 {0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
98 {0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11},
99 {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF},
100 {0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11},
101 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
102 {0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10},
103 {0x7C,0xA1,0x10,0x45,0x4A,0x1A,0x6E,0x57},
104 {0x01,0x31,0xD9,0x61,0x9D,0xC1,0x37,0x6E},
105 {0x07,0xA1,0x13,0x3E,0x4A,0x0B,0x26,0x86},
106 {0x38,0x49,0x67,0x4C,0x26,0x02,0x31,0x9E},
107 {0x04,0xB9,0x15,0xBA,0x43,0xFE,0xB5,0xB6},
108 {0x01,0x13,0xB9,0x70,0xFD,0x34,0xF2,0xCE},
109 {0x01,0x70,0xF1,0x75,0x46,0x8F,0xB5,0xE6},
110 {0x43,0x29,0x7F,0xAD,0x38,0xE3,0x73,0xFE},
111 {0x07,0xA7,0x13,0x70,0x45,0xDA,0x2A,0x16},
112 {0x04,0x68,0x91,0x04,0xC2,0xFD,0x3B,0x2F},
113 {0x37,0xD0,0x6B,0xB5,0x16,0xCB,0x75,0x46},
114 {0x1F,0x08,0x26,0x0D,0x1A,0xC2,0x46,0x5E},
115 {0x58,0x40,0x23,0x64,0x1A,0xBA,0x61,0x76},
116 {0x02,0x58,0x16,0x16,0x46,0x29,0xB0,0x07},
117 {0x49,0x79,0x3E,0xBC,0x79,0xB3,0x25,0x8F},
118 {0x4F,0xB0,0x5E,0x15,0x15,0xAB,0x73,0xA7},
119 {0x49,0xE9,0x5D,0x6D,0x4C,0xA2,0x29,0xBF},
120 {0x01,0x83,0x10,0xDC,0x40,0x9B,0x26,0xD6},
121 {0x1C,0x58,0x7F,0x1C,0x13,0x92,0x4F,0xEF},
122 {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01},
123 {0x1F,0x1F,0x1F,0x1F,0x0E,0x0E,0x0E,0x0E},
124 {0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1,0xFE},
125 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
126 {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},
127 {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF},
128 {0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10}};
129
130static unsigned char plain_data[NUM_TESTS][8]={
131 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
132 {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},
133 {0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x01},
134 {0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11},
135 {0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11},
136 {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF},
137 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
138 {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF},
139 {0x01,0xA1,0xD6,0xD0,0x39,0x77,0x67,0x42},
140 {0x5C,0xD5,0x4C,0xA8,0x3D,0xEF,0x57,0xDA},
141 {0x02,0x48,0xD4,0x38,0x06,0xF6,0x71,0x72},
142 {0x51,0x45,0x4B,0x58,0x2D,0xDF,0x44,0x0A},
143 {0x42,0xFD,0x44,0x30,0x59,0x57,0x7F,0xA2},
144 {0x05,0x9B,0x5E,0x08,0x51,0xCF,0x14,0x3A},
145 {0x07,0x56,0xD8,0xE0,0x77,0x47,0x61,0xD2},
146 {0x76,0x25,0x14,0xB8,0x29,0xBF,0x48,0x6A},
147 {0x3B,0xDD,0x11,0x90,0x49,0x37,0x28,0x02},
148 {0x26,0x95,0x5F,0x68,0x35,0xAF,0x60,0x9A},
149 {0x16,0x4D,0x5E,0x40,0x4F,0x27,0x52,0x32},
150 {0x6B,0x05,0x6E,0x18,0x75,0x9F,0x5C,0xCA},
151 {0x00,0x4B,0xD6,0xEF,0x09,0x17,0x60,0x62},
152 {0x48,0x0D,0x39,0x00,0x6E,0xE7,0x62,0xF2},
153 {0x43,0x75,0x40,0xC8,0x69,0x8F,0x3C,0xFA},
154 {0x07,0x2D,0x43,0xA0,0x77,0x07,0x52,0x92},
155 {0x02,0xFE,0x55,0x77,0x81,0x17,0xF1,0x2A},
156 {0x1D,0x9D,0x5C,0x50,0x18,0xF7,0x28,0xC2},
157 {0x30,0x55,0x32,0x28,0x6D,0x6F,0x29,0x5A},
158 {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF},
159 {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF},
160 {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF},
161 {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},
162 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
163 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
164 {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}};
165
166static unsigned char cipher_data[NUM_TESTS][8]={
167 {0x8C,0xA6,0x4D,0xE9,0xC1,0xB1,0x23,0xA7},
168 {0x73,0x59,0xB2,0x16,0x3E,0x4E,0xDC,0x58},
169 {0x95,0x8E,0x6E,0x62,0x7A,0x05,0x55,0x7B},
170 {0xF4,0x03,0x79,0xAB,0x9E,0x0E,0xC5,0x33},
171 {0x17,0x66,0x8D,0xFC,0x72,0x92,0x53,0x2D},
172 {0x8A,0x5A,0xE1,0xF8,0x1A,0xB8,0xF2,0xDD},
173 {0x8C,0xA6,0x4D,0xE9,0xC1,0xB1,0x23,0xA7},
174 {0xED,0x39,0xD9,0x50,0xFA,0x74,0xBC,0xC4},
175 {0x69,0x0F,0x5B,0x0D,0x9A,0x26,0x93,0x9B},
176 {0x7A,0x38,0x9D,0x10,0x35,0x4B,0xD2,0x71},
177 {0x86,0x8E,0xBB,0x51,0xCA,0xB4,0x59,0x9A},
178 {0x71,0x78,0x87,0x6E,0x01,0xF1,0x9B,0x2A},
179 {0xAF,0x37,0xFB,0x42,0x1F,0x8C,0x40,0x95},
180 {0x86,0xA5,0x60,0xF1,0x0E,0xC6,0xD8,0x5B},
181 {0x0C,0xD3,0xDA,0x02,0x00,0x21,0xDC,0x09},
182 {0xEA,0x67,0x6B,0x2C,0xB7,0xDB,0x2B,0x7A},
183 {0xDF,0xD6,0x4A,0x81,0x5C,0xAF,0x1A,0x0F},
184 {0x5C,0x51,0x3C,0x9C,0x48,0x86,0xC0,0x88},
185 {0x0A,0x2A,0xEE,0xAE,0x3F,0xF4,0xAB,0x77},
186 {0xEF,0x1B,0xF0,0x3E,0x5D,0xFA,0x57,0x5A},
187 {0x88,0xBF,0x0D,0xB6,0xD7,0x0D,0xEE,0x56},
188 {0xA1,0xF9,0x91,0x55,0x41,0x02,0x0B,0x56},
189 {0x6F,0xBF,0x1C,0xAF,0xCF,0xFD,0x05,0x56},
190 {0x2F,0x22,0xE4,0x9B,0xAB,0x7C,0xA1,0xAC},
191 {0x5A,0x6B,0x61,0x2C,0xC2,0x6C,0xCE,0x4A},
192 {0x5F,0x4C,0x03,0x8E,0xD1,0x2B,0x2E,0x41},
193 {0x63,0xFA,0xC0,0xD0,0x34,0xD9,0xF7,0x93},
194 {0x61,0x7B,0x3A,0x0C,0xE8,0xF0,0x71,0x00},
195 {0xDB,0x95,0x86,0x05,0xF8,0xC8,0xC6,0x06},
196 {0xED,0xBF,0xD1,0xC6,0x6C,0x29,0xCC,0xC7},
197 {0x35,0x55,0x50,0xB2,0x15,0x0E,0x24,0x51},
198 {0xCA,0xAA,0xAF,0x4D,0xEA,0xF1,0xDB,0xAE},
199 {0xD5,0xD4,0x4F,0xF7,0x20,0x68,0x3D,0x0D},
200 {0x2A,0x2B,0xB0,0x08,0xDF,0x97,0xC2,0xF2}};
201
202static unsigned char cipher_ecb2[NUM_TESTS-1][8]={
203 {0x92,0x95,0xB5,0x9B,0xB3,0x84,0x73,0x6E},
204 {0x19,0x9E,0x9D,0x6D,0xF3,0x9A,0xA8,0x16},
205 {0x2A,0x4B,0x4D,0x24,0x52,0x43,0x84,0x27},
206 {0x35,0x84,0x3C,0x01,0x9D,0x18,0xC5,0xB6},
207 {0x4A,0x5B,0x2F,0x42,0xAA,0x77,0x19,0x25},
208 {0xA0,0x6B,0xA9,0xB8,0xCA,0x5B,0x17,0x8A},
209 {0xAB,0x9D,0xB7,0xFB,0xED,0x95,0xF2,0x74},
210 {0x3D,0x25,0x6C,0x23,0xA7,0x25,0x2F,0xD6},
211 {0xB7,0x6F,0xAB,0x4F,0xBD,0xBD,0xB7,0x67},
212 {0x8F,0x68,0x27,0xD6,0x9C,0xF4,0x1A,0x10},
213 {0x82,0x57,0xA1,0xD6,0x50,0x5E,0x81,0x85},
214 {0xA2,0x0F,0x0A,0xCD,0x80,0x89,0x7D,0xFA},
215 {0xCD,0x2A,0x53,0x3A,0xDB,0x0D,0x7E,0xF3},
216 {0xD2,0xC2,0xBE,0x27,0xE8,0x1B,0x68,0xE3},
217 {0xE9,0x24,0xCF,0x4F,0x89,0x3C,0x5B,0x0A},
218 {0xA7,0x18,0xC3,0x9F,0xFA,0x9F,0xD7,0x69},
219 {0x77,0x2C,0x79,0xB1,0xD2,0x31,0x7E,0xB1},
220 {0x49,0xAB,0x92,0x7F,0xD0,0x22,0x00,0xB7},
221 {0xCE,0x1C,0x6C,0x7D,0x85,0xE3,0x4A,0x6F},
222 {0xBE,0x91,0xD6,0xE1,0x27,0xB2,0xE9,0x87},
223 {0x70,0x28,0xAE,0x8F,0xD1,0xF5,0x74,0x1A},
224 {0xAA,0x37,0x80,0xBB,0xF3,0x22,0x1D,0xDE},
225 {0xA6,0xC4,0xD2,0x5E,0x28,0x93,0xAC,0xB3},
226 {0x22,0x07,0x81,0x5A,0xE4,0xB7,0x1A,0xAD},
227 {0xDC,0xCE,0x05,0xE7,0x07,0xBD,0xF5,0x84},
228 {0x26,0x1D,0x39,0x2C,0xB3,0xBA,0xA5,0x85},
229 {0xB4,0xF7,0x0F,0x72,0xFB,0x04,0xF0,0xDC},
230 {0x95,0xBA,0xA9,0x4E,0x87,0x36,0xF2,0x89},
231 {0xD4,0x07,0x3A,0xF1,0x5A,0x17,0x82,0x0E},
232 {0xEF,0x6F,0xAF,0xA7,0x66,0x1A,0x7E,0x89},
233 {0xC1,0x97,0xF5,0x58,0x74,0x8A,0x20,0xE7},
234 {0x43,0x34,0xCF,0xDA,0x22,0xC4,0x86,0xC8},
235 {0x08,0xD7,0xB4,0xFB,0x62,0x9D,0x08,0x85}};
236
237static unsigned char cbc_key [8]={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef};
238static unsigned char cbc2_key[8]={0xf1,0xe0,0xd3,0xc2,0xb5,0xa4,0x97,0x86};
239static unsigned char cbc3_key[8]={0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10};
240static unsigned char cbc_iv [8]={0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10};
241/* Changed the following text constant to binary so it will work on ebcdic
242 * machines :-) */
243/* static char cbc_data[40]="7654321 Now is the time for \0001"; */
244static unsigned char cbc_data[40]={
245 0x37,0x36,0x35,0x34,0x33,0x32,0x31,0x20,
246 0x4E,0x6F,0x77,0x20,0x69,0x73,0x20,0x74,
247 0x68,0x65,0x20,0x74,0x69,0x6D,0x65,0x20,
248 0x66,0x6F,0x72,0x20,0x00,0x31,0x00,0x00,
249 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
250 };
251
252static unsigned char cbc_ok[32]={
253 0xcc,0xd1,0x73,0xff,0xab,0x20,0x39,0xf4,
254 0xac,0xd8,0xae,0xfd,0xdf,0xd8,0xa1,0xeb,
255 0x46,0x8e,0x91,0x15,0x78,0x88,0xba,0x68,
256 0x1d,0x26,0x93,0x97,0xf7,0xfe,0x62,0xb4};
257
258#ifdef SCREW_THE_PARITY
259#error "SCREW_THE_PARITY is not ment to be defined."
260#error "Original vectors are preserved for reference only."
261static unsigned char cbc2_key[8]={0xf0,0xe1,0xd2,0xc3,0xb4,0xa5,0x96,0x87};
262static unsigned char xcbc_ok[32]={
263 0x86,0x74,0x81,0x0D,0x61,0xA4,0xA5,0x48,
264 0xB9,0x93,0x03,0xE1,0xB8,0xBB,0xBD,0xBD,
265 0x64,0x30,0x0B,0xB9,0x06,0x65,0x81,0x76,
266 0x04,0x1D,0x77,0x62,0x17,0xCA,0x2B,0xD2,
267 };
268#else
269static unsigned char xcbc_ok[32]={
270 0x84,0x6B,0x29,0x14,0x85,0x1E,0x9A,0x29,
271 0x54,0x73,0x2F,0x8A,0xA0,0xA6,0x11,0xC1,
272 0x15,0xCD,0xC2,0xD7,0x95,0x1B,0x10,0x53,
273 0xA6,0x3C,0x5E,0x03,0xB2,0x1A,0xA3,0xC4,
274 };
275#endif
276
277static unsigned char cbc3_ok[32]={
278 0x3F,0xE3,0x01,0xC9,0x62,0xAC,0x01,0xD0,
279 0x22,0x13,0x76,0x3C,0x1C,0xBD,0x4C,0xDC,
280 0x79,0x96,0x57,0xC0,0x64,0xEC,0xF5,0xD4,
281 0x1C,0x67,0x38,0x12,0xCF,0xDE,0x96,0x75};
282
283static unsigned char pcbc_ok[32]={
284 0xcc,0xd1,0x73,0xff,0xab,0x20,0x39,0xf4,
285 0x6d,0xec,0xb4,0x70,0xa0,0xe5,0x6b,0x15,
286 0xae,0xa6,0xbf,0x61,0xed,0x7d,0x9c,0x9f,
287 0xf7,0x17,0x46,0x3b,0x8a,0xb3,0xcc,0x88};
288
289static unsigned char cfb_key[8]={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef};
290static unsigned char cfb_iv[8]={0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef};
291static unsigned char cfb_buf1[40],cfb_buf2[40],cfb_tmp[8];
292static unsigned char plain[24]=
293 {
294 0x4e,0x6f,0x77,0x20,0x69,0x73,
295 0x20,0x74,0x68,0x65,0x20,0x74,
296 0x69,0x6d,0x65,0x20,0x66,0x6f,
297 0x72,0x20,0x61,0x6c,0x6c,0x20
298 };
299static unsigned char cfb_cipher8[24]= {
300 0xf3,0x1f,0xda,0x07,0x01,0x14, 0x62,0xee,0x18,0x7f,0x43,0xd8,
301 0x0a,0x7c,0xd9,0xb5,0xb0,0xd2, 0x90,0xda,0x6e,0x5b,0x9a,0x87 };
302static unsigned char cfb_cipher16[24]={
303 0xF3,0x09,0x87,0x87,0x7F,0x57, 0xF7,0x3C,0x36,0xB6,0xDB,0x70,
304 0xD8,0xD5,0x34,0x19,0xD3,0x86, 0xB2,0x23,0xB7,0xB2,0xAD,0x1B };
305static unsigned char cfb_cipher32[24]={
306 0xF3,0x09,0x62,0x49,0xA4,0xDF, 0xA4,0x9F,0x33,0xDC,0x7B,0xAD,
307 0x4C,0xC8,0x9F,0x64,0xE4,0x53, 0xE5,0xEC,0x67,0x20,0xDA,0xB6 };
308static unsigned char cfb_cipher48[24]={
309 0xF3,0x09,0x62,0x49,0xC7,0xF4, 0x30,0xB5,0x15,0xEC,0xBB,0x85,
310 0x97,0x5A,0x13,0x8C,0x68,0x60, 0xE2,0x38,0x34,0x3C,0xDC,0x1F };
311static unsigned char cfb_cipher64[24]={
312 0xF3,0x09,0x62,0x49,0xC7,0xF4, 0x6E,0x51,0xA6,0x9E,0x83,0x9B,
313 0x1A,0x92,0xF7,0x84,0x03,0x46, 0x71,0x33,0x89,0x8E,0xA6,0x22 };
314
315static unsigned char ofb_key[8]={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef};
316static unsigned char ofb_iv[8]={0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef};
317static unsigned char ofb_buf1[24],ofb_buf2[24],ofb_tmp[8];
318static unsigned char ofb_cipher[24]=
319 {
320 0xf3,0x09,0x62,0x49,0xc7,0xf4,0x6e,0x51,
321 0x35,0xf2,0x4a,0x24,0x2e,0xeb,0x3d,0x3f,
322 0x3d,0x6d,0x5b,0xe3,0x25,0x5a,0xf8,0xc3
323 };
324
325static DES_LONG cbc_cksum_ret=0xB462FEF7L;
326static unsigned char cbc_cksum_data[8]={0x1D,0x26,0x93,0x97,0xf7,0xfe,0x62,0xb4};
327
328static char *pt(unsigned char *p);
329static int cfb_test(int bits, unsigned char *cfb_cipher);
330static int cfb64_test(unsigned char *cfb_cipher);
331static int ede_cfb64_test(unsigned char *cfb_cipher);
332int main(int argc, char *argv[])
333 {
334 int i,j,err=0;
335 des_cblock in,out,outin,iv3,iv2;
336 des_key_schedule ks,ks2,ks3;
337 unsigned char cbc_in[40];
338 unsigned char cbc_out[40];
339 DES_LONG cs;
340 unsigned char cret[8];
341#ifdef _CRAY
342 struct {
343 int a:32;
344 int b:32;
345 } lqret[2];
346#else
347 DES_LONG lqret[4];
348#endif
349 int num;
350 char *str;
351
352#ifndef OPENSSL_NO_DESCBCM
353 printf("Doing cbcm\n");
354 if ((j=DES_set_key_checked(&cbc_key,&ks)) != 0)
355 {
356 printf("Key error %d\n",j);
357 err=1;
358 }
359 if ((j=DES_set_key_checked(&cbc2_key,&ks2)) != 0)
360 {
361 printf("Key error %d\n",j);
362 err=1;
363 }
364 if ((j=DES_set_key_checked(&cbc3_key,&ks3)) != 0)
365 {
366 printf("Key error %d\n",j);
367 err=1;
368 }
369 memset(cbc_out,0,40);
370 memset(cbc_in,0,40);
371 i=strlen((char *)cbc_data)+1;
372 /* i=((i+7)/8)*8; */
373 memcpy(iv3,cbc_iv,sizeof(cbc_iv));
374 memset(iv2,'\0',sizeof iv2);
375
376 DES_ede3_cbcm_encrypt(cbc_data,cbc_out,16L,&ks,&ks2,&ks3,&iv3,&iv2,
377 DES_ENCRYPT);
378 DES_ede3_cbcm_encrypt(&cbc_data[16],&cbc_out[16],i-16,&ks,&ks2,&ks3,
379 &iv3,&iv2,DES_ENCRYPT);
380 /* if (memcmp(cbc_out,cbc3_ok,
381 (unsigned int)(strlen((char *)cbc_data)+1+7)/8*8) != 0)
382 {
383 printf("des_ede3_cbc_encrypt encrypt error\n");
384 err=1;
385 }
386 */
387 memcpy(iv3,cbc_iv,sizeof(cbc_iv));
388 memset(iv2,'\0',sizeof iv2);
389 DES_ede3_cbcm_encrypt(cbc_out,cbc_in,i,&ks,&ks2,&ks3,&iv3,&iv2,DES_DECRYPT);
390 if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0)
391 {
392 int n;
393
394 printf("des_ede3_cbcm_encrypt decrypt error\n");
395 for(n=0 ; n < i ; ++n)
396 printf(" %02x",cbc_data[n]);
397 printf("\n");
398 for(n=0 ; n < i ; ++n)
399 printf(" %02x",cbc_in[n]);
400 printf("\n");
401 err=1;
402 }
403#endif
404
405 printf("Doing ecb\n");
406 for (i=0; i<NUM_TESTS; i++)
407 {
408 DES_set_key_unchecked(&key_data[i],&ks);
409 memcpy(in,plain_data[i],8);
410 memset(out,0,8);
411 memset(outin,0,8);
412 des_ecb_encrypt(&in,&out,ks,DES_ENCRYPT);
413 des_ecb_encrypt(&out,&outin,ks,DES_DECRYPT);
414
415 if (memcmp(out,cipher_data[i],8) != 0)
416 {
417 printf("Encryption error %2d\nk=%s p=%s o=%s act=%s\n",
418 i+1,pt(key_data[i]),pt(in),pt(cipher_data[i]),
419 pt(out));
420 err=1;
421 }
422 if (memcmp(in,outin,8) != 0)
423 {
424 printf("Decryption error %2d\nk=%s p=%s o=%s act=%s\n",
425 i+1,pt(key_data[i]),pt(out),pt(in),pt(outin));
426 err=1;
427 }
428 }
429
430#ifndef LIBDES_LIT
431 printf("Doing ede ecb\n");
432 for (i=0; i<(NUM_TESTS-1); i++)
433 {
434 DES_set_key_unchecked(&key_data[i],&ks);
435 DES_set_key_unchecked(&key_data[i+1],&ks2);
436 DES_set_key_unchecked(&key_data[i+2],&ks3);
437 memcpy(in,plain_data[i],8);
438 memset(out,0,8);
439 memset(outin,0,8);
440 des_ecb2_encrypt(&in,&out,ks,ks2,DES_ENCRYPT);
441 des_ecb2_encrypt(&out,&outin,ks,ks2,DES_DECRYPT);
442
443 if (memcmp(out,cipher_ecb2[i],8) != 0)
444 {
445 printf("Encryption error %2d\nk=%s p=%s o=%s act=%s\n",
446 i+1,pt(key_data[i]),pt(in),pt(cipher_ecb2[i]),
447 pt(out));
448 err=1;
449 }
450 if (memcmp(in,outin,8) != 0)
451 {
452 printf("Decryption error %2d\nk=%s p=%s o=%s act=%s\n",
453 i+1,pt(key_data[i]),pt(out),pt(in),pt(outin));
454 err=1;
455 }
456 }
457#endif
458
459 printf("Doing cbc\n");
460 if ((j=DES_set_key_checked(&cbc_key,&ks)) != 0)
461 {
462 printf("Key error %d\n",j);
463 err=1;
464 }
465 memset(cbc_out,0,40);
466 memset(cbc_in,0,40);
467 memcpy(iv3,cbc_iv,sizeof(cbc_iv));
468 des_ncbc_encrypt(cbc_data,cbc_out,strlen((char *)cbc_data)+1,ks,
469 &iv3,DES_ENCRYPT);
470 if (memcmp(cbc_out,cbc_ok,32) != 0)
471 {
472 printf("cbc_encrypt encrypt error\n");
473 err=1;
474 }
475
476 memcpy(iv3,cbc_iv,sizeof(cbc_iv));
477 des_ncbc_encrypt(cbc_out,cbc_in,strlen((char *)cbc_data)+1,ks,
478 &iv3,DES_DECRYPT);
479 if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)) != 0)
480 {
481 printf("cbc_encrypt decrypt error\n");
482 err=1;
483 }
484
485#ifndef LIBDES_LIT
486 printf("Doing desx cbc\n");
487 if ((j=DES_set_key_checked(&cbc_key,&ks)) != 0)
488 {
489 printf("Key error %d\n",j);
490 err=1;
491 }
492 memset(cbc_out,0,40);
493 memset(cbc_in,0,40);
494 memcpy(iv3,cbc_iv,sizeof(cbc_iv));
495 des_xcbc_encrypt(cbc_data,cbc_out,strlen((char *)cbc_data)+1,ks,
496 &iv3,&cbc2_key,&cbc3_key, DES_ENCRYPT);
497 if (memcmp(cbc_out,xcbc_ok,32) != 0)
498 {
499 printf("des_xcbc_encrypt encrypt error\n");
500 err=1;
501 }
502 memcpy(iv3,cbc_iv,sizeof(cbc_iv));
503 des_xcbc_encrypt(cbc_out,cbc_in,strlen((char *)cbc_data)+1,ks,
504 &iv3,&cbc2_key,&cbc3_key, DES_DECRYPT);
505 if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0)
506 {
507 printf("des_xcbc_encrypt decrypt error\n");
508 err=1;
509 }
510#endif
511
512 printf("Doing ede cbc\n");
513 if ((j=DES_set_key_checked(&cbc_key,&ks)) != 0)
514 {
515 printf("Key error %d\n",j);
516 err=1;
517 }
518 if ((j=DES_set_key_checked(&cbc2_key,&ks2)) != 0)
519 {
520 printf("Key error %d\n",j);
521 err=1;
522 }
523 if ((j=DES_set_key_checked(&cbc3_key,&ks3)) != 0)
524 {
525 printf("Key error %d\n",j);
526 err=1;
527 }
528 memset(cbc_out,0,40);
529 memset(cbc_in,0,40);
530 i=strlen((char *)cbc_data)+1;
531 /* i=((i+7)/8)*8; */
532 memcpy(iv3,cbc_iv,sizeof(cbc_iv));
533
534 des_ede3_cbc_encrypt(cbc_data,cbc_out,16L,ks,ks2,ks3,&iv3,
535 DES_ENCRYPT);
536 des_ede3_cbc_encrypt(&(cbc_data[16]),&(cbc_out[16]),i-16,ks,ks2,ks3,
537 &iv3,DES_ENCRYPT);
538 if (memcmp(cbc_out,cbc3_ok,
539 (unsigned int)(strlen((char *)cbc_data)+1+7)/8*8) != 0)
540 {
541 int n;
542
543 printf("des_ede3_cbc_encrypt encrypt error\n");
544 for(n=0 ; n < i ; ++n)
545 printf(" %02x",cbc_out[n]);
546 printf("\n");
547 for(n=0 ; n < i ; ++n)
548 printf(" %02x",cbc3_ok[n]);
549 printf("\n");
550 err=1;
551 }
552
553 memcpy(iv3,cbc_iv,sizeof(cbc_iv));
554 des_ede3_cbc_encrypt(cbc_out,cbc_in,i,ks,ks2,ks3,&iv3,DES_DECRYPT);
555 if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0)
556 {
557 int n;
558
559 printf("des_ede3_cbc_encrypt decrypt error\n");
560 for(n=0 ; n < i ; ++n)
561 printf(" %02x",cbc_data[n]);
562 printf("\n");
563 for(n=0 ; n < i ; ++n)
564 printf(" %02x",cbc_in[n]);
565 printf("\n");
566 err=1;
567 }
568
569#ifndef LIBDES_LIT
570 printf("Doing pcbc\n");
571 if ((j=DES_set_key_checked(&cbc_key,&ks)) != 0)
572 {
573 printf("Key error %d\n",j);
574 err=1;
575 }
576 memset(cbc_out,0,40);
577 memset(cbc_in,0,40);
578 des_pcbc_encrypt(cbc_data,cbc_out,strlen((char *)cbc_data)+1,ks,
579 &cbc_iv,DES_ENCRYPT);
580 if (memcmp(cbc_out,pcbc_ok,32) != 0)
581 {
582 printf("pcbc_encrypt encrypt error\n");
583 err=1;
584 }
585 des_pcbc_encrypt(cbc_out,cbc_in,strlen((char *)cbc_data)+1,ks,&cbc_iv,
586 DES_DECRYPT);
587 if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0)
588 {
589 printf("pcbc_encrypt decrypt error\n");
590 err=1;
591 }
592
593 printf("Doing ");
594 printf("cfb8 ");
595 err+=cfb_test(8,cfb_cipher8);
596 printf("cfb16 ");
597 err+=cfb_test(16,cfb_cipher16);
598 printf("cfb32 ");
599 err+=cfb_test(32,cfb_cipher32);
600 printf("cfb48 ");
601 err+=cfb_test(48,cfb_cipher48);
602 printf("cfb64 ");
603 err+=cfb_test(64,cfb_cipher64);
604
605 printf("cfb64() ");
606 err+=cfb64_test(cfb_cipher64);
607
608 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
609 for (i=0; i<sizeof(plain); i++)
610 des_cfb_encrypt(&(plain[i]),&(cfb_buf1[i]),
611 8,1,ks,&cfb_tmp,DES_ENCRYPT);
612 if (memcmp(cfb_cipher8,cfb_buf1,sizeof(plain)) != 0)
613 {
614 printf("cfb_encrypt small encrypt error\n");
615 err=1;
616 }
617
618 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
619 for (i=0; i<sizeof(plain); i++)
620 des_cfb_encrypt(&(cfb_buf1[i]),&(cfb_buf2[i]),
621 8,1,ks,&cfb_tmp,DES_DECRYPT);
622 if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0)
623 {
624 printf("cfb_encrypt small decrypt error\n");
625 err=1;
626 }
627
628 printf("ede_cfb64() ");
629 err+=ede_cfb64_test(cfb_cipher64);
630
631 printf("done\n");
632
633 printf("Doing ofb\n");
634 DES_set_key_checked(&ofb_key,&ks);
635 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
636 des_ofb_encrypt(plain,ofb_buf1,64,sizeof(plain)/8,ks,&ofb_tmp);
637 if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0)
638 {
639 printf("ofb_encrypt encrypt error\n");
640printf("%02X %02X %02X %02X %02X %02X %02X %02X\n",
641ofb_buf1[8+0], ofb_buf1[8+1], ofb_buf1[8+2], ofb_buf1[8+3],
642ofb_buf1[8+4], ofb_buf1[8+5], ofb_buf1[8+6], ofb_buf1[8+7]);
643printf("%02X %02X %02X %02X %02X %02X %02X %02X\n",
644ofb_buf1[8+0], ofb_cipher[8+1], ofb_cipher[8+2], ofb_cipher[8+3],
645ofb_buf1[8+4], ofb_cipher[8+5], ofb_cipher[8+6], ofb_cipher[8+7]);
646 err=1;
647 }
648 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
649 des_ofb_encrypt(ofb_buf1,ofb_buf2,64,sizeof(ofb_buf1)/8,ks,&ofb_tmp);
650 if (memcmp(plain,ofb_buf2,sizeof(ofb_buf2)) != 0)
651 {
652 printf("ofb_encrypt decrypt error\n");
653printf("%02X %02X %02X %02X %02X %02X %02X %02X\n",
654ofb_buf2[8+0], ofb_buf2[8+1], ofb_buf2[8+2], ofb_buf2[8+3],
655ofb_buf2[8+4], ofb_buf2[8+5], ofb_buf2[8+6], ofb_buf2[8+7]);
656printf("%02X %02X %02X %02X %02X %02X %02X %02X\n",
657plain[8+0], plain[8+1], plain[8+2], plain[8+3],
658plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
659 err=1;
660 }
661
662 printf("Doing ofb64\n");
663 DES_set_key_checked(&ofb_key,&ks);
664 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
665 memset(ofb_buf1,0,sizeof(ofb_buf1));
666 memset(ofb_buf2,0,sizeof(ofb_buf1));
667 num=0;
668 for (i=0; i<sizeof(plain); i++)
669 {
670 des_ofb64_encrypt(&(plain[i]),&(ofb_buf1[i]),1,ks,&ofb_tmp,
671 &num);
672 }
673 if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0)
674 {
675 printf("ofb64_encrypt encrypt error\n");
676 err=1;
677 }
678 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
679 num=0;
680 des_ofb64_encrypt(ofb_buf1,ofb_buf2,sizeof(ofb_buf1),ks,&ofb_tmp,
681 &num);
682 if (memcmp(plain,ofb_buf2,sizeof(ofb_buf2)) != 0)
683 {
684 printf("ofb64_encrypt decrypt error\n");
685 err=1;
686 }
687
688 printf("Doing ede_ofb64\n");
689 DES_set_key_checked(&ofb_key,&ks);
690 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
691 memset(ofb_buf1,0,sizeof(ofb_buf1));
692 memset(ofb_buf2,0,sizeof(ofb_buf1));
693 num=0;
694 for (i=0; i<sizeof(plain); i++)
695 {
696 des_ede3_ofb64_encrypt(&(plain[i]),&(ofb_buf1[i]),1,ks,ks,
697 ks,&ofb_tmp,&num);
698 }
699 if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0)
700 {
701 printf("ede_ofb64_encrypt encrypt error\n");
702 err=1;
703 }
704 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
705 num=0;
706 des_ede3_ofb64_encrypt(ofb_buf1,ofb_buf2,sizeof(ofb_buf1),ks,ks,ks,
707 &ofb_tmp,&num);
708 if (memcmp(plain,ofb_buf2,sizeof(ofb_buf2)) != 0)
709 {
710 printf("ede_ofb64_encrypt decrypt error\n");
711 err=1;
712 }
713
714 printf("Doing cbc_cksum\n");
715 DES_set_key_checked(&cbc_key,&ks);
716 cs=des_cbc_cksum(cbc_data,&cret,strlen((char *)cbc_data),ks,&cbc_iv);
717 if (cs != cbc_cksum_ret)
718 {
719 printf("bad return value (%08lX), should be %08lX\n",
720 (unsigned long)cs,(unsigned long)cbc_cksum_ret);
721 err=1;
722 }
723 if (memcmp(cret,cbc_cksum_data,8) != 0)
724 {
725 printf("bad cbc_cksum block returned\n");
726 err=1;
727 }
728
729 printf("Doing quad_cksum\n");
730 cs=des_quad_cksum(cbc_data,(des_cblock *)lqret,
731 (long)strlen((char *)cbc_data),2,(des_cblock *)cbc_iv);
732 if (cs != 0x70d7a63aL)
733 {
734 printf("quad_cksum error, ret %08lx should be 70d7a63a\n",
735 (unsigned long)cs);
736 err=1;
737 }
738#ifdef _CRAY
739 if (lqret[0].a != 0x327eba8dL)
740 {
741 printf("quad_cksum error, out[0] %08lx is not %08lx\n",
742 (unsigned long)lqret[0].a,0x327eba8dUL);
743 err=1;
744 }
745 if (lqret[0].b != 0x201a49ccL)
746 {
747 printf("quad_cksum error, out[1] %08lx is not %08lx\n",
748 (unsigned long)lqret[0].b,0x201a49ccUL);
749 err=1;
750 }
751 if (lqret[1].a != 0x70d7a63aL)
752 {
753 printf("quad_cksum error, out[2] %08lx is not %08lx\n",
754 (unsigned long)lqret[1].a,0x70d7a63aUL);
755 err=1;
756 }
757 if (lqret[1].b != 0x501c2c26L)
758 {
759 printf("quad_cksum error, out[3] %08lx is not %08lx\n",
760 (unsigned long)lqret[1].b,0x501c2c26UL);
761 err=1;
762 }
763#else
764 if (lqret[0] != 0x327eba8dL)
765 {
766 printf("quad_cksum error, out[0] %08lx is not %08lx\n",
767 (unsigned long)lqret[0],0x327eba8dUL);
768 err=1;
769 }
770 if (lqret[1] != 0x201a49ccL)
771 {
772 printf("quad_cksum error, out[1] %08lx is not %08lx\n",
773 (unsigned long)lqret[1],0x201a49ccUL);
774 err=1;
775 }
776 if (lqret[2] != 0x70d7a63aL)
777 {
778 printf("quad_cksum error, out[2] %08lx is not %08lx\n",
779 (unsigned long)lqret[2],0x70d7a63aUL);
780 err=1;
781 }
782 if (lqret[3] != 0x501c2c26L)
783 {
784 printf("quad_cksum error, out[3] %08lx is not %08lx\n",
785 (unsigned long)lqret[3],0x501c2c26UL);
786 err=1;
787 }
788#endif
789#endif
790
791 printf("input word alignment test");
792 for (i=0; i<4; i++)
793 {
794 printf(" %d",i);
795 des_ncbc_encrypt(&(cbc_out[i]),cbc_in,
796 strlen((char *)cbc_data)+1,ks,
797 &cbc_iv,DES_ENCRYPT);
798 }
799 printf("\noutput word alignment test");
800 for (i=0; i<4; i++)
801 {
802 printf(" %d",i);
803 des_ncbc_encrypt(cbc_out,&(cbc_in[i]),
804 strlen((char *)cbc_data)+1,ks,
805 &cbc_iv,DES_ENCRYPT);
806 }
807 printf("\n");
808 printf("fast crypt test ");
809 str=crypt("testing","ef");
810 if (strcmp("efGnQx2725bI2",str) != 0)
811 {
812 printf("fast crypt error, %s should be efGnQx2725bI2\n",str);
813 err=1;
814 }
815 str=crypt("bca76;23","yA");
816 if (strcmp("yA1Rp/1hZXIJk",str) != 0)
817 {
818 printf("fast crypt error, %s should be yA1Rp/1hZXIJk\n",str);
819 err=1;
820 }
821 printf("\n");
822 return(err);
823 }
824
825static char *pt(unsigned char *p)
826 {
827 static char bufs[10][20];
828 static int bnum=0;
829 char *ret;
830 int i;
831 static char *f="0123456789ABCDEF";
832
833 ret= &(bufs[bnum++][0]);
834 bnum%=10;
835 for (i=0; i<8; i++)
836 {
837 ret[i*2]=f[(p[i]>>4)&0xf];
838 ret[i*2+1]=f[p[i]&0xf];
839 }
840 ret[16]='\0';
841 return(ret);
842 }
843
844#ifndef LIBDES_LIT
845
846static int cfb_test(int bits, unsigned char *cfb_cipher)
847 {
848 des_key_schedule ks;
849 int i,err=0;
850
851 DES_set_key_checked(&cfb_key,&ks);
852 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
853 des_cfb_encrypt(plain,cfb_buf1,bits,sizeof(plain),ks,&cfb_tmp,
854 DES_ENCRYPT);
855 if (memcmp(cfb_cipher,cfb_buf1,sizeof(plain)) != 0)
856 {
857 err=1;
858 printf("cfb_encrypt encrypt error\n");
859 for (i=0; i<24; i+=8)
860 printf("%s\n",pt(&(cfb_buf1[i])));
861 }
862 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
863 des_cfb_encrypt(cfb_buf1,cfb_buf2,bits,sizeof(plain),ks,&cfb_tmp,
864 DES_DECRYPT);
865 if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0)
866 {
867 err=1;
868 printf("cfb_encrypt decrypt error\n");
869 for (i=0; i<24; i+=8)
870 printf("%s\n",pt(&(cfb_buf1[i])));
871 }
872 return(err);
873 }
874
875static int cfb64_test(unsigned char *cfb_cipher)
876 {
877 des_key_schedule ks;
878 int err=0,i,n;
879
880 DES_set_key_checked(&cfb_key,&ks);
881 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
882 n=0;
883 des_cfb64_encrypt(plain,cfb_buf1,12,ks,&cfb_tmp,&n,DES_ENCRYPT);
884 des_cfb64_encrypt(&(plain[12]),&(cfb_buf1[12]),sizeof(plain)-12,ks,
885 &cfb_tmp,&n,DES_ENCRYPT);
886 if (memcmp(cfb_cipher,cfb_buf1,sizeof(plain)) != 0)
887 {
888 err=1;
889 printf("cfb_encrypt encrypt error\n");
890 for (i=0; i<24; i+=8)
891 printf("%s\n",pt(&(cfb_buf1[i])));
892 }
893 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
894 n=0;
895 des_cfb64_encrypt(cfb_buf1,cfb_buf2,17,ks,&cfb_tmp,&n,DES_DECRYPT);
896 des_cfb64_encrypt(&(cfb_buf1[17]),&(cfb_buf2[17]),
897 sizeof(plain)-17,ks,&cfb_tmp,&n,DES_DECRYPT);
898 if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0)
899 {
900 err=1;
901 printf("cfb_encrypt decrypt error\n");
902 for (i=0; i<24; i+=8)
903 printf("%s\n",pt(&(cfb_buf2[i])));
904 }
905 return(err);
906 }
907
908static int ede_cfb64_test(unsigned char *cfb_cipher)
909 {
910 des_key_schedule ks;
911 int err=0,i,n;
912
913 DES_set_key_checked(&cfb_key,&ks);
914 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
915 n=0;
916 des_ede3_cfb64_encrypt(plain,cfb_buf1,12,ks,ks,ks,&cfb_tmp,&n,
917 DES_ENCRYPT);
918 des_ede3_cfb64_encrypt(&(plain[12]),&(cfb_buf1[12]),
919 sizeof(plain)-12,ks,ks,ks,
920 &cfb_tmp,&n,DES_ENCRYPT);
921 if (memcmp(cfb_cipher,cfb_buf1,sizeof(plain)) != 0)
922 {
923 err=1;
924 printf("ede_cfb_encrypt encrypt error\n");
925 for (i=0; i<24; i+=8)
926 printf("%s\n",pt(&(cfb_buf1[i])));
927 }
928 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
929 n=0;
930 des_ede3_cfb64_encrypt(cfb_buf1,cfb_buf2,(long)17,ks,ks,ks,
931 &cfb_tmp,&n,DES_DECRYPT);
932 des_ede3_cfb64_encrypt(&(cfb_buf1[17]),&(cfb_buf2[17]),
933 sizeof(plain)-17,ks,ks,ks,
934 &cfb_tmp,&n,DES_DECRYPT);
935 if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0)
936 {
937 err=1;
938 printf("ede_cfb_encrypt decrypt error\n");
939 for (i=0; i<24; i+=8)
940 printf("%s\n",pt(&(cfb_buf2[i])));
941 }
942 return(err);
943 }
944
945#endif
946#endif
diff --git a/src/lib/libcrypto/des/ecb_enc.c b/src/lib/libcrypto/des/ecb_enc.c
index 1b70f68806..c828bdd45d 100644
--- a/src/lib/libcrypto/des/ecb_enc.c
+++ b/src/lib/libcrypto/des/ecb_enc.c
@@ -97,7 +97,8 @@ const char *DES_options(void)
97 size="int"; 97 size="int";
98 else 98 else
99 size="long"; 99 size="long";
100 sprintf(buf,"des(%s,%s,%s,%s)",ptr,risc,unroll,size); 100 snprintf(buf,sizeof buf,"des(%s,%s,%s,%s)",ptr,risc,unroll,
101 size);
101 init=0; 102 init=0;
102 } 103 }
103 return(buf); 104 return(buf);
diff --git a/src/lib/libcrypto/des/makefile.bc b/src/lib/libcrypto/des/makefile.bc
new file mode 100644
index 0000000000..1fe6d4915a
--- /dev/null
+++ b/src/lib/libcrypto/des/makefile.bc
@@ -0,0 +1,50 @@
1#
2# Origional BC Makefile from Teun <Teun.Nijssen@kub.nl>
3#
4#
5CC = bcc
6TLIB = tlib /0 /C
7# note: the -3 flag produces code for 386, 486, Pentium etc; omit it for 286s
8OPTIMIZE= -3 -O2
9#WINDOWS= -W
10CFLAGS = -c -ml -d $(OPTIMIZE) $(WINDOWS) -DMSDOS
11LFLAGS = -ml $(WINDOWS)
12
13.c.obj:
14 $(CC) $(CFLAGS) $*.c
15
16.obj.exe:
17 $(CC) $(LFLAGS) -e$*.exe $*.obj libdes.lib
18
19all: $(LIB) destest.exe rpw.exe des.exe speed.exe
20
21# "make clean": use a directory containing only libdes .exe and .obj files...
22clean:
23 del *.exe
24 del *.obj
25 del libdes.lib
26 del libdes.rsp
27
28OBJS= cbc_cksm.obj cbc_enc.obj ecb_enc.obj pcbc_enc.obj \
29 qud_cksm.obj rand_key.obj set_key.obj str2key.obj \
30 enc_read.obj enc_writ.obj fcrypt.obj cfb_enc.obj \
31 ecb3_enc.obj ofb_enc.obj cbc3_enc.obj read_pwd.obj\
32 cfb64enc.obj ofb64enc.obj ede_enc.obj cfb64ede.obj\
33 ofb64ede.obj supp.obj
34
35LIB= libdes.lib
36
37$(LIB): $(OBJS)
38 del $(LIB)
39 makersp "+%s &\n" &&|
40 $(OBJS)
41| >libdes.rsp
42 $(TLIB) libdes.lib @libdes.rsp,nul
43 del libdes.rsp
44
45destest.exe: destest.obj libdes.lib
46rpw.exe: rpw.obj libdes.lib
47speed.exe: speed.obj libdes.lib
48des.exe: des.obj libdes.lib
49
50
diff --git a/src/lib/libcrypto/des/options.txt b/src/lib/libcrypto/des/options.txt
new file mode 100644
index 0000000000..6e2b50f765
--- /dev/null
+++ b/src/lib/libcrypto/des/options.txt
@@ -0,0 +1,39 @@
1Note that the UNROLL option makes the 'inner' des loop unroll all 16 rounds
2instead of the default 4.
3RISC1 and RISC2 are 2 alternatives for the inner loop and
4PTR means to use pointers arithmatic instead of arrays.
5
6FreeBSD - Pentium Pro 200mhz - gcc 2.7.2.2 - assembler 577,000 4620k/s
7IRIX 6.2 - R10000 195mhz - cc (-O3 -n32) - UNROLL RISC2 PTR 496,000 3968k/s
8solaris 2.5.1 usparc 167mhz?? - SC4.0 - UNROLL RISC1 PTR [1] 459,400 3672k/s
9FreeBSD - Pentium Pro 200mhz - gcc 2.7.2.2 - UNROLL RISC1 433,000 3468k/s
10solaris 2.5.1 usparc 167mhz?? - gcc 2.7.2 - UNROLL 380,000 3041k/s
11linux - pentium 100mhz - gcc 2.7.0 - assembler 281,000 2250k/s
12NT 4.0 - pentium 100mhz - VC 4.2 - assembler 281,000 2250k/s
13AIX 4.1? - PPC604 100mhz - cc - UNROLL 275,000 2200k/s
14IRIX 5.3 - R4400 200mhz - gcc 2.6.3 - UNROLL RISC2 PTR 235,300 1882k/s
15IRIX 5.3 - R4400 200mhz - cc - UNROLL RISC2 PTR 233,700 1869k/s
16NT 4.0 - pentium 100mhz - VC 4.2 - UNROLL RISC1 PTR 191,000 1528k/s
17DEC Alpha 165mhz?? - cc - RISC2 PTR [2] 181,000 1448k/s
18linux - pentium 100mhz - gcc 2.7.0 - UNROLL RISC1 PTR 158,500 1268k/s
19HPUX 10 - 9000/887 - cc - UNROLL [3] 148,000 1190k/s
20solaris 2.5.1 - sparc 10 50mhz - gcc 2.7.2 - UNROLL 123,600 989k/s
21IRIX 5.3 - R4000 100mhz - cc - UNROLL RISC2 PTR 101,000 808k/s
22DGUX - 88100 50mhz(?) - gcc 2.6.3 - UNROLL 81,000 648k/s
23solaris 2.4 486 50mhz - gcc 2.6.3 - assembler 65,000 522k/s
24HPUX 10 - 9000/887 - k&r cc (default compiler) - UNROLL PTR 76,000 608k/s
25solaris 2.4 486 50mhz - gcc 2.6.3 - UNROLL RISC2 43,500 344k/s
26AIX - old slow one :-) - cc - 39,000 312k/s
27
28Notes.
29[1] For the ultra sparc, SunC 4.0
30 cc -xtarget=ultra -xarch=v8plus -Xa -xO5, running 'des_opts'
31 gives a speed of 344,000 des/s while 'speed' gives 459,000 des/s.
32 I'll record the higher since it is coming from the library but it
33 is all rather weird.
34[2] Similar to the ultra sparc ([1]), 181,000 for 'des_opts' vs 175,000.
35[3] I was unable to get access to this machine when it was not heavily loaded.
36 As such, my timing program was never able to get more that %30 of the CPU.
37 This would cause the program to give much lower speed numbers because
38 it would be 'fighting' to stay in the cache with the other CPU burning
39 processes.
diff --git a/src/lib/libcrypto/des/read2pwd.c b/src/lib/libcrypto/des/read2pwd.c
new file mode 100644
index 0000000000..b4720c3a98
--- /dev/null
+++ b/src/lib/libcrypto/des/read2pwd.c
@@ -0,0 +1,139 @@
1/* crypto/des/read2pwd.c */
2/* ====================================================================
3 * Copyright (c) 2001-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/* 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#include <string.h>
113#include <openssl/des.h>
114#include <openssl/ui.h>
115
116int DES_read_password(DES_cblock *key, const char *prompt, int verify)
117 {
118 int ok;
119 char buf[BUFSIZ],buff[BUFSIZ];
120
121 if ((ok=UI_UTIL_read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0)
122 DES_string_to_key(buf,key);
123 memset(buf,0,BUFSIZ);
124 memset(buff,0,BUFSIZ);
125 return(ok);
126 }
127
128int DES_read_2passwords(DES_cblock *key1, DES_cblock *key2, const char *prompt,
129 int verify)
130 {
131 int ok;
132 char buf[BUFSIZ],buff[BUFSIZ];
133
134 if ((ok=UI_UTIL_read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0)
135 DES_string_to_2keys(buf,key1,key2);
136 memset(buf,0,BUFSIZ);
137 memset(buff,0,BUFSIZ);
138 return(ok);
139 }
diff --git a/src/lib/libcrypto/des/read_pwd.c b/src/lib/libcrypto/des/read_pwd.c
new file mode 100644
index 0000000000..9061935f21
--- /dev/null
+++ b/src/lib/libcrypto/des/read_pwd.c
@@ -0,0 +1,511 @@
1/* crypto/des/read_pwd.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 <openssl/e_os2.h>
60#if !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_WIN32)
61#ifdef OPENSSL_UNISTD
62# include OPENSSL_UNISTD
63#else
64# include <unistd.h>
65#endif
66/* If unistd.h defines _POSIX_VERSION, we conclude that we
67 * are on a POSIX system and have sigaction and termios. */
68#if defined(_POSIX_VERSION)
69
70# define SIGACTION
71# if !defined(TERMIOS) && !defined(TERMIO) && !defined(SGTTY)
72# define TERMIOS
73# endif
74
75#endif
76#endif
77
78/* #define SIGACTION */ /* Define this if you have sigaction() */
79
80#ifdef WIN16TTY
81#undef OPENSSL_SYS_WIN16
82#undef _WINDOWS
83#include <graph.h>
84#endif
85
86/* 06-Apr-92 Luke Brennan Support for VMS */
87#include "des_locl.h"
88#include "cryptlib.h"
89#include <signal.h>
90#include <stdio.h>
91#include <string.h>
92#include <setjmp.h>
93#include <errno.h>
94
95#ifdef OPENSSL_SYS_VMS /* prototypes for sys$whatever */
96#include <starlet.h>
97#ifdef __DECC
98#pragma message disable DOLLARID
99#endif
100#endif
101
102#ifdef WIN_CONSOLE_BUG
103#include <windows.h>
104#include <wincon.h>
105#endif
106
107
108/* There are 5 types of terminal interface supported,
109 * TERMIO, TERMIOS, VMS, MSDOS and SGTTY
110 */
111
112#if defined(__sgi) && !defined(TERMIOS)
113#define TERMIOS
114#undef TERMIO
115#undef SGTTY
116#endif
117
118#if defined(linux) && !defined(TERMIO)
119#undef TERMIOS
120#define TERMIO
121#undef SGTTY
122#endif
123
124#ifdef _LIBC
125#undef TERMIOS
126#define TERMIO
127#undef SGTTY
128#endif
129
130#if !defined(TERMIO) && !defined(TERMIOS) && !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_MSDOS) && !defined(MAC_OS_pre_X) && !defined(MAC_OS_GUSI_SOURCE)
131#undef TERMIOS
132#undef TERMIO
133#define SGTTY
134#endif
135
136#if defined(OPENSSL_SYS_VSWORKS)
137#undef TERMIOS
138#undef TERMIO
139#undef SGTTY
140#endif
141
142#ifdef TERMIOS
143#include <termios.h>
144#define TTY_STRUCT struct termios
145#define TTY_FLAGS c_lflag
146#define TTY_get(tty,data) tcgetattr(tty,data)
147#define TTY_set(tty,data) tcsetattr(tty,TCSANOW,data)
148#endif
149
150#ifdef TERMIO
151#include <termio.h>
152#define TTY_STRUCT struct termio
153#define TTY_FLAGS c_lflag
154#define TTY_get(tty,data) ioctl(tty,TCGETA,data)
155#define TTY_set(tty,data) ioctl(tty,TCSETA,data)
156#endif
157
158#ifdef SGTTY
159#include <sgtty.h>
160#define TTY_STRUCT struct sgttyb
161#define TTY_FLAGS sg_flags
162#define TTY_get(tty,data) ioctl(tty,TIOCGETP,data)
163#define TTY_set(tty,data) ioctl(tty,TIOCSETP,data)
164#endif
165
166#if !defined(_LIBC) && !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VMS) && !defined(MAC_OS_pre_X)
167#include <sys/ioctl.h>
168#endif
169
170#if defined(OPENSSL_SYS_MSDOS) && !defined(__CYGWIN32__)
171#include <conio.h>
172#define fgets(a,b,c) noecho_fgets(a,b,c)
173#endif
174
175#ifdef OPENSSL_SYS_VMS
176#include <ssdef.h>
177#include <iodef.h>
178#include <ttdef.h>
179#include <descrip.h>
180struct IOSB {
181 short iosb$w_value;
182 short iosb$w_count;
183 long iosb$l_info;
184 };
185#endif
186
187#if defined(MAC_OS_pre_X) || defined(MAC_OS_GUSI_SOURCE)
188/*
189 * This one needs work. As a matter of fact the code is unoperational
190 * and this is only a trick to get it compiled.
191 * <appro@fy.chalmers.se>
192 */
193#define TTY_STRUCT int
194#endif
195
196#ifndef NX509_SIG
197#define NX509_SIG 32
198#endif
199
200static void read_till_nl(FILE *);
201static void recsig(int);
202static void pushsig(void);
203static void popsig(void);
204#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN16)
205static int noecho_fgets(char *buf, int size, FILE *tty);
206#endif
207#ifdef SIGACTION
208 static struct sigaction savsig[NX509_SIG];
209#else
210 static void (*savsig[NX509_SIG])(int );
211#endif
212static jmp_buf save;
213
214int des_read_pw_string(char *buf, int length, const char *prompt,
215 int verify)
216 {
217 char buff[BUFSIZ];
218 int ret;
219
220 ret=des_read_pw(buf,buff,(length>BUFSIZ)?BUFSIZ:length,prompt,verify);
221 memset(buff,0,BUFSIZ);
222 return(ret);
223 }
224
225#ifndef OPENSSL_SYS_WIN16
226
227static void read_till_nl(FILE *in)
228 {
229#define SIZE 4
230 char buf[SIZE+1];
231
232 do {
233 fgets(buf,SIZE,in);
234 } while (strchr(buf,'\n') == NULL);
235 }
236
237
238/* return 0 if ok, 1 (or -1) otherwise */
239int des_read_pw(char *buf, char *buff, int size, const char *prompt,
240 int verify)
241 {
242#ifdef OPENSSL_SYS_VMS
243 struct IOSB iosb;
244 $DESCRIPTOR(terminal,"TT");
245 long tty_orig[3], tty_new[3];
246 long status;
247 unsigned short channel = 0;
248#else
249#if !defined(OPENSSL_SYS_MSDOS) || defined(__DJGPP__)
250 TTY_STRUCT tty_orig,tty_new;
251#endif
252#endif
253 int number;
254 int ok;
255 /* statics are simply to avoid warnings about longjmp clobbering
256 things */
257 static int ps;
258 int is_a_tty;
259 static FILE *tty;
260 char *p;
261
262 if (setjmp(save))
263 {
264 ok=0;
265 goto error;
266 }
267
268 number=5;
269 ok=0;
270 ps=0;
271 is_a_tty=1;
272 tty=NULL;
273
274#ifdef OPENSSL_SYS_MSDOS
275 if ((tty=fopen("con","r")) == NULL)
276 tty=stdin;
277#elif defined(MAC_OS_pre_X) || defined(OPENSSL_SYS_VSWORKS)
278 tty=stdin;
279#else
280#ifndef OPENSSL_SYS_MPE
281 if ((tty=fopen("/dev/tty","r")) == NULL)
282#endif
283 tty=stdin;
284#endif
285
286#if defined(TTY_get) && !defined(OPENSSL_SYS_VMS)
287 if (TTY_get(fileno(tty),&tty_orig) == -1)
288 {
289#ifdef ENOTTY
290 if (errno == ENOTTY)
291 is_a_tty=0;
292 else
293#endif
294#ifdef EINVAL
295 /* Ariel Glenn ariel@columbia.edu reports that solaris
296 * can return EINVAL instead. This should be ok */
297 if (errno == EINVAL)
298 is_a_tty=0;
299 else
300#endif
301 return(-1);
302 }
303 memcpy(&(tty_new),&(tty_orig),sizeof(tty_orig));
304#endif
305#ifdef OPENSSL_SYS_VMS
306 status = sys$assign(&terminal,&channel,0,0);
307 if (status != SS$_NORMAL)
308 return(-1);
309 status=sys$qiow(0,channel,IO$_SENSEMODE,&iosb,0,0,tty_orig,12,0,0,0,0);
310 if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL))
311 return(-1);
312#endif
313
314 pushsig();
315 ps=1;
316
317#ifdef TTY_FLAGS
318 tty_new.TTY_FLAGS &= ~ECHO;
319#endif
320
321#if defined(TTY_set) && !defined(OPENSSL_SYS_VMS)
322 if (is_a_tty && (TTY_set(fileno(tty),&tty_new) == -1))
323#ifdef OPENSSL_SYS_MPE
324 ; /* MPE lies -- echo really has been disabled */
325#else
326 return(-1);
327#endif
328#endif
329#ifdef OPENSSL_SYS_VMS
330 tty_new[0] = tty_orig[0];
331 tty_new[1] = tty_orig[1] | TT$M_NOECHO;
332 tty_new[2] = tty_orig[2];
333 status = sys$qiow(0,channel,IO$_SETMODE,&iosb,0,0,tty_new,12,0,0,0,0);
334 if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL))
335 return(-1);
336#endif
337 ps=2;
338
339 while ((!ok) && (number--))
340 {
341 fputs(prompt,stderr);
342 fflush(stderr);
343
344 buf[0]='\0';
345 fgets(buf,size,tty);
346 if (feof(tty)) goto error;
347 if (ferror(tty)) goto error;
348 if ((p=(char *)strchr(buf,'\n')) != NULL)
349 *p='\0';
350 else read_till_nl(tty);
351 if (verify)
352 {
353 fprintf(stderr,"\nVerifying password - %s",prompt);
354 fflush(stderr);
355 buff[0]='\0';
356 fgets(buff,size,tty);
357 if (feof(tty)) goto error;
358 if ((p=(char *)strchr(buff,'\n')) != NULL)
359 *p='\0';
360 else read_till_nl(tty);
361
362 if (strcmp(buf,buff) != 0)
363 {
364 fprintf(stderr,"\nVerify failure");
365 fflush(stderr);
366 break;
367 /* continue; */
368 }
369 }
370 ok=1;
371 }
372
373error:
374 fprintf(stderr,"\n");
375#if 0
376 perror("fgets(tty)");
377#endif
378 /* What can we do if there is an error? */
379#if defined(TTY_set) && !defined(OPENSSL_SYS_VMS)
380 if (ps >= 2) TTY_set(fileno(tty),&tty_orig);
381#endif
382#ifdef OPENSSL_SYS_VMS
383 if (ps >= 2)
384 status = sys$qiow(0,channel,IO$_SETMODE,&iosb,0,0
385 ,tty_orig,12,0,0,0,0);
386#endif
387
388 if (ps >= 1) popsig();
389 if (stdin != tty) fclose(tty);
390#ifdef OPENSSL_SYS_VMS
391 status = sys$dassgn(channel);
392#endif
393 return(!ok);
394 }
395
396#else /* OPENSSL_SYS_WIN16 */
397
398int des_read_pw(char *buf, char *buff, int size, char *prompt, int verify)
399 {
400 memset(buf,0,size);
401 memset(buff,0,size);
402 return(0);
403 }
404
405#endif
406
407static void pushsig(void)
408 {
409 int i;
410#ifdef SIGACTION
411 struct sigaction sa;
412
413 memset(&sa,0,sizeof sa);
414 sa.sa_handler=recsig;
415#endif
416
417 for (i=1; i<NX509_SIG; i++)
418 {
419#ifdef SIGUSR1
420 if (i == SIGUSR1)
421 continue;
422#endif
423#ifdef SIGUSR2
424 if (i == SIGUSR2)
425 continue;
426#endif
427#ifdef SIGACTION
428 sigaction(i,&sa,&savsig[i]);
429#else
430 savsig[i]=signal(i,recsig);
431#endif
432 }
433
434#ifdef SIGWINCH
435 signal(SIGWINCH,SIG_DFL);
436#endif
437 }
438
439static void popsig(void)
440 {
441 int i;
442
443 for (i=1; i<NX509_SIG; i++)
444 {
445#ifdef SIGUSR1
446 if (i == SIGUSR1)
447 continue;
448#endif
449#ifdef SIGUSR2
450 if (i == SIGUSR2)
451 continue;
452#endif
453#ifdef SIGACTION
454 sigaction(i,&savsig[i],NULL);
455#else
456 signal(i,savsig[i]);
457#endif
458 }
459 }
460
461static void recsig(int i)
462 {
463 longjmp(save,1);
464#ifdef LINT
465 i=i;
466#endif
467 }
468
469#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN16)
470static int noecho_fgets(char *buf, int size, FILE *tty)
471 {
472 int i;
473 char *p;
474
475 p=buf;
476 for (;;)
477 {
478 if (size == 0)
479 {
480 *p='\0';
481 break;
482 }
483 size--;
484#ifdef WIN16TTY
485 i=_inchar();
486#else
487 i=getch();
488#endif
489 if (i == '\r') i='\n';
490 *(p++)=i;
491 if (i == '\n')
492 {
493 *p='\0';
494 break;
495 }
496 }
497#ifdef WIN_CONSOLE_BUG
498/* Win95 has several evil console bugs: one of these is that the
499 * last character read using getch() is passed to the next read: this is
500 * usually a CR so this can be trouble. No STDIO fix seems to work but
501 * flushing the console appears to do the trick.
502 */
503 {
504 HANDLE inh;
505 inh = GetStdHandle(STD_INPUT_HANDLE);
506 FlushConsoleInputBuffer(inh);
507 }
508#endif
509 return(strlen(buf));
510 }
511#endif
diff --git a/src/lib/libcrypto/des/rpc_des.h b/src/lib/libcrypto/des/rpc_des.h
new file mode 100644
index 0000000000..4cbb4d2dcd
--- /dev/null
+++ b/src/lib/libcrypto/des/rpc_des.h
@@ -0,0 +1,131 @@
1/* crypto/des/rpc_des.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/* @(#)des.h 2.2 88/08/10 4.0 RPCSRC; from 2.7 88/02/08 SMI */
60/*
61 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
62 * unrestricted use provided that this legend is included on all tape
63 * media and as a part of the software program in whole or part. Users
64 * may copy or modify Sun RPC without charge, but are not authorized
65 * to license or distribute it to anyone else except as part of a product or
66 * program developed by the user.
67 *
68 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
69 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
70 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
71 *
72 * Sun RPC is provided with no support and without any obligation on the
73 * part of Sun Microsystems, Inc. to assist in its use, correction,
74 * modification or enhancement.
75 *
76 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
77 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
78 * OR ANY PART THEREOF.
79 *
80 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
81 * or profits or other special, indirect and consequential damages, even if
82 * Sun has been advised of the possibility of such damages.
83 *
84 * Sun Microsystems, Inc.
85 * 2550 Garcia Avenue
86 * Mountain View, California 94043
87 */
88/*
89 * Generic DES driver interface
90 * Keep this file hardware independent!
91 * Copyright (c) 1986 by Sun Microsystems, Inc.
92 */
93
94#define DES_MAXLEN 65536 /* maximum # of bytes to encrypt */
95#define DES_QUICKLEN 16 /* maximum # of bytes to encrypt quickly */
96
97#ifdef HEADER_DES_H
98#undef ENCRYPT
99#undef DECRYPT
100#endif
101
102enum desdir { ENCRYPT, DECRYPT };
103enum desmode { CBC, ECB };
104
105/*
106 * parameters to ioctl call
107 */
108struct desparams {
109 unsigned char des_key[8]; /* key (with low bit parity) */
110 enum desdir des_dir; /* direction */
111 enum desmode des_mode; /* mode */
112 unsigned char des_ivec[8]; /* input vector */
113 unsigned des_len; /* number of bytes to crypt */
114 union {
115 unsigned char UDES_data[DES_QUICKLEN];
116 unsigned char *UDES_buf;
117 } UDES;
118# define des_data UDES.UDES_data /* direct data here if quick */
119# define des_buf UDES.UDES_buf /* otherwise, pointer to data */
120};
121
122/*
123 * Encrypt an arbitrary sized buffer
124 */
125#define DESIOCBLOCK _IOWR(d, 6, struct desparams)
126
127/*
128 * Encrypt of small amount of data, quickly
129 */
130#define DESIOCQUICK _IOWR(d, 7, struct desparams)
131
diff --git a/src/lib/libcrypto/des/rpc_enc.c b/src/lib/libcrypto/des/rpc_enc.c
new file mode 100644
index 0000000000..d937d08da5
--- /dev/null
+++ b/src/lib/libcrypto/des/rpc_enc.c
@@ -0,0 +1,98 @@
1/* crypto/des/rpc_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 "rpc_des.h"
60#include "des_locl.h"
61#include "des_ver.h"
62
63int _des_crypt(char *buf,int len,struct desparams *desp);
64int _des_crypt(char *buf, int len, struct desparams *desp)
65 {
66 DES_key_schedule ks;
67 int enc;
68
69 DES_set_key_unchecked(&desp->des_key,&ks);
70 enc=(desp->des_dir == ENCRYPT)?DES_ENCRYPT:DES_DECRYPT;
71
72 if (desp->des_mode == CBC)
73 DES_ecb_encrypt((const_DES_cblock *)desp->UDES.UDES_buf,
74 (DES_cblock *)desp->UDES.UDES_buf,&ks,
75 enc);
76 else
77 {
78 DES_ncbc_encrypt(desp->UDES.UDES_buf,desp->UDES.UDES_buf,
79 len,&ks,&desp->des_ivec,enc);
80#ifdef undef
81 /* len will always be %8 if called from common_crypt
82 * in secure_rpc.
83 * Libdes's cbc encrypt does not copy back the iv,
84 * so we have to do it here. */
85 /* It does now :-) eay 20/09/95 */
86
87 a=(char *)&(desp->UDES.UDES_buf[len-8]);
88 b=(char *)&(desp->des_ivec[0]);
89
90 *(a++)= *(b++); *(a++)= *(b++);
91 *(a++)= *(b++); *(a++)= *(b++);
92 *(a++)= *(b++); *(a++)= *(b++);
93 *(a++)= *(b++); *(a++)= *(b++);
94#endif
95 }
96 return(1);
97 }
98
diff --git a/src/lib/libcrypto/des/rpw.c b/src/lib/libcrypto/des/rpw.c
new file mode 100644
index 0000000000..8a9473c4f9
--- /dev/null
+++ b/src/lib/libcrypto/des/rpw.c
@@ -0,0 +1,99 @@
1/* crypto/des/rpw.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/des.h>
61
62int main(int argc, char *argv[])
63 {
64 DES_cblock k,k1;
65 int i;
66
67 printf("read passwd\n");
68 if ((i=des_read_password(&k,"Enter password:",0)) == 0)
69 {
70 printf("password = ");
71 for (i=0; i<8; i++)
72 printf("%02x ",k[i]);
73 }
74 else
75 printf("error %d\n",i);
76 printf("\n");
77 printf("read 2passwds and verify\n");
78 if ((i=des_read_2passwords(&k,&k1,
79 "Enter verified password:",1)) == 0)
80 {
81 printf("password1 = ");
82 for (i=0; i<8; i++)
83 printf("%02x ",k[i]);
84 printf("\n");
85 printf("password2 = ");
86 for (i=0; i<8; i++)
87 printf("%02x ",k1[i]);
88 printf("\n");
89 exit(1);
90 }
91 else
92 {
93 printf("error %d\n",i);
94 exit(0);
95 }
96#ifdef LINT
97 return(0);
98#endif
99 }
diff --git a/src/lib/libcrypto/des/speed.c b/src/lib/libcrypto/des/speed.c
new file mode 100644
index 0000000000..48fc1d49fc
--- /dev/null
+++ b/src/lib/libcrypto/des/speed.c
@@ -0,0 +1,310 @@
1/* crypto/des/speed.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/* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */
60/* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */
61
62#if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX)
63#define TIMES
64#endif
65
66#include <stdio.h>
67
68#include <openssl/e_os2.h>
69#include OPENSSL_UNISTD_IO
70OPENSSL_DECLARE_EXIT
71
72#include <signal.h>
73#ifndef _IRIX
74#include <time.h>
75#endif
76#ifdef TIMES
77#include <sys/types.h>
78#include <sys/times.h>
79#endif
80
81/* Depending on the VMS version, the tms structure is perhaps defined.
82 The __TMS macro will show if it was. If it wasn't defined, we should
83 undefine TIMES, since that tells the rest of the program how things
84 should be handled. -- Richard Levitte */
85#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
86#undef TIMES
87#endif
88
89#ifndef TIMES
90#include <sys/timeb.h>
91#endif
92
93#if defined(sun) || defined(__ultrix)
94#define _POSIX_SOURCE
95#include <limits.h>
96#include <sys/param.h>
97#endif
98
99#include <openssl/des.h>
100
101/* The following if from times(3) man page. It may need to be changed */
102#ifndef HZ
103# ifndef CLK_TCK
104# ifndef _BSD_CLK_TCK_ /* FreeBSD fix */
105# define HZ 100.0
106# else /* _BSD_CLK_TCK_ */
107# define HZ ((double)_BSD_CLK_TCK_)
108# endif
109# else /* CLK_TCK */
110# define HZ ((double)CLK_TCK)
111# endif
112#endif
113
114#define BUFSIZE ((long)1024)
115long run=0;
116
117double Time_F(int s);
118#ifdef SIGALRM
119#if defined(__STDC__) || defined(sgi) || defined(_AIX)
120#define SIGRETTYPE void
121#else
122#define SIGRETTYPE int
123#endif
124
125SIGRETTYPE sig_done(int sig);
126SIGRETTYPE sig_done(int sig)
127 {
128 signal(SIGALRM,sig_done);
129 run=0;
130#ifdef LINT
131 sig=sig;
132#endif
133 }
134#endif
135
136#define START 0
137#define STOP 1
138
139double Time_F(int s)
140 {
141 double ret;
142#ifdef TIMES
143 static struct tms tstart,tend;
144
145 if (s == START)
146 {
147 times(&tstart);
148 return(0);
149 }
150 else
151 {
152 times(&tend);
153 ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
154 return((ret == 0.0)?1e-6:ret);
155 }
156#else /* !times() */
157 static struct timeb tstart,tend;
158 long i;
159
160 if (s == START)
161 {
162 ftime(&tstart);
163 return(0);
164 }
165 else
166 {
167 ftime(&tend);
168 i=(long)tend.millitm-(long)tstart.millitm;
169 ret=((double)(tend.time-tstart.time))+((double)i)/1e3;
170 return((ret == 0.0)?1e-6:ret);
171 }
172#endif
173 }
174
175int main(int argc, char **argv)
176 {
177 long count;
178 static unsigned char buf[BUFSIZE];
179 static DES_cblock key ={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0};
180 static DES_cblock key2={0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
181 static DES_cblock key3={0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34};
182 DES_key_schedule sch,sch2,sch3;
183 double a,b,c,d,e;
184#ifndef SIGALRM
185 long ca,cb,cc,cd,ce;
186#endif
187
188#ifndef TIMES
189 printf("To get the most accurate results, try to run this\n");
190 printf("program when this computer is idle.\n");
191#endif
192
193 DES_set_key_unchecked(&key2,&sch2);
194 DES_set_key_unchecked(&key3,&sch3);
195
196#ifndef SIGALRM
197 printf("First we calculate the approximate speed ...\n");
198 DES_set_key_unchecked(&key,&sch);
199 count=10;
200 do {
201 long i;
202 DES_LONG data[2];
203
204 count*=2;
205 Time_F(START);
206 for (i=count; i; i--)
207 DES_encrypt1(data,&sch,DES_ENCRYPT);
208 d=Time_F(STOP);
209 } while (d < 3.0);
210 ca=count;
211 cb=count*3;
212 cc=count*3*8/BUFSIZE+1;
213 cd=count*8/BUFSIZE+1;
214 ce=count/20+1;
215 printf("Doing set_key %ld times\n",ca);
216#define COND(d) (count != (d))
217#define COUNT(d) (d)
218#else
219#define COND(c) (run)
220#define COUNT(d) (count)
221 signal(SIGALRM,sig_done);
222 printf("Doing set_key for 10 seconds\n");
223 alarm(10);
224#endif
225
226 Time_F(START);
227 for (count=0,run=1; COND(ca); count++)
228 DES_set_key_unchecked(&key,&sch);
229 d=Time_F(STOP);
230 printf("%ld set_key's in %.2f seconds\n",count,d);
231 a=((double)COUNT(ca))/d;
232
233#ifdef SIGALRM
234 printf("Doing DES_encrypt's for 10 seconds\n");
235 alarm(10);
236#else
237 printf("Doing DES_encrypt %ld times\n",cb);
238#endif
239 Time_F(START);
240 for (count=0,run=1; COND(cb); count++)
241 {
242 DES_LONG data[2];
243
244 DES_encrypt1(data,&sch,DES_ENCRYPT);
245 }
246 d=Time_F(STOP);
247 printf("%ld DES_encrypt's in %.2f second\n",count,d);
248 b=((double)COUNT(cb)*8)/d;
249
250#ifdef SIGALRM
251 printf("Doing DES_cbc_encrypt on %ld byte blocks for 10 seconds\n",
252 BUFSIZE);
253 alarm(10);
254#else
255 printf("Doing DES_cbc_encrypt %ld times on %ld byte blocks\n",cc,
256 BUFSIZE);
257#endif
258 Time_F(START);
259 for (count=0,run=1; COND(cc); count++)
260 DES_ncbc_encrypt(buf,buf,BUFSIZE,&sch,
261 &key,DES_ENCRYPT);
262 d=Time_F(STOP);
263 printf("%ld DES_cbc_encrypt's of %ld byte blocks in %.2f second\n",
264 count,BUFSIZE,d);
265 c=((double)COUNT(cc)*BUFSIZE)/d;
266
267#ifdef SIGALRM
268 printf("Doing DES_ede_cbc_encrypt on %ld byte blocks for 10 seconds\n",
269 BUFSIZE);
270 alarm(10);
271#else
272 printf("Doing DES_ede_cbc_encrypt %ld times on %ld byte blocks\n",cd,
273 BUFSIZE);
274#endif
275 Time_F(START);
276 for (count=0,run=1; COND(cd); count++)
277 DES_ede3_cbc_encrypt(buf,buf,BUFSIZE,
278 &sch,
279 &sch2,
280 &sch3,
281 &key,
282 DES_ENCRYPT);
283 d=Time_F(STOP);
284 printf("%ld DES_ede_cbc_encrypt's of %ld byte blocks in %.2f second\n",
285 count,BUFSIZE,d);
286 d=((double)COUNT(cd)*BUFSIZE)/d;
287
288#ifdef SIGALRM
289 printf("Doing crypt for 10 seconds\n");
290 alarm(10);
291#else
292 printf("Doing crypt %ld times\n",ce);
293#endif
294 Time_F(START);
295 for (count=0,run=1; COND(ce); count++)
296 crypt("testing1","ef");
297 e=Time_F(STOP);
298 printf("%ld crypts in %.2f second\n",count,e);
299 e=((double)COUNT(ce))/e;
300
301 printf("set_key per sec = %12.2f (%9.3fuS)\n",a,1.0e6/a);
302 printf("DES raw ecb bytes per sec = %12.2f (%9.3fuS)\n",b,8.0e6/b);
303 printf("DES cbc bytes per sec = %12.2f (%9.3fuS)\n",c,8.0e6/c);
304 printf("DES ede cbc bytes per sec = %12.2f (%9.3fuS)\n",d,8.0e6/d);
305 printf("crypt per sec = %12.2f (%9.3fuS)\n",e,1.0e6/e);
306 exit(0);
307#if defined(LINT) || defined(OPENSSL_SYS_MSDOS)
308 return(0);
309#endif
310 }
diff --git a/src/lib/libcrypto/des/str2key.c b/src/lib/libcrypto/des/str2key.c
index 0373db469c..36c3f81d99 100644
--- a/src/lib/libcrypto/des/str2key.c
+++ b/src/lib/libcrypto/des/str2key.c
@@ -94,7 +94,7 @@ void DES_string_to_key(const char *str, DES_cblock *key)
94 DES_set_key_unchecked(key,&ks); 94 DES_set_key_unchecked(key,&ks);
95#endif 95#endif
96 DES_cbc_cksum((const unsigned char*)str,key,length,&ks,key); 96 DES_cbc_cksum((const unsigned char*)str,key,length,&ks,key);
97 OPENSSL_cleanse(&ks,sizeof(ks)); 97 memset(&ks,0,sizeof(ks));
98 DES_set_odd_parity(key); 98 DES_set_odd_parity(key);
99 } 99 }
100 100
@@ -167,7 +167,7 @@ void DES_string_to_2keys(const char *str, DES_cblock *key1, DES_cblock *key2)
167 DES_set_key_unchecked(key2,&ks); 167 DES_set_key_unchecked(key2,&ks);
168#endif 168#endif
169 DES_cbc_cksum((const unsigned char*)str,key2,length,&ks,key2); 169 DES_cbc_cksum((const unsigned char*)str,key2,length,&ks,key2);
170 OPENSSL_cleanse(&ks,sizeof(ks)); 170 memset(&ks,0,sizeof(ks));
171 DES_set_odd_parity(key1); 171 DES_set_odd_parity(key1);
172 DES_set_odd_parity(key2); 172 DES_set_odd_parity(key2);
173 } 173 }
diff --git a/src/lib/libcrypto/des/t/test b/src/lib/libcrypto/des/t/test
new file mode 100644
index 0000000000..97acd0552e
--- /dev/null
+++ b/src/lib/libcrypto/des/t/test
@@ -0,0 +1,27 @@
1#!./perl
2
3BEGIN { push(@INC, qw(../../../lib ../../lib ../lib lib)); }
4
5use DES;
6
7$key='00000000';
8$ks=DES::set_key($key);
9@a=split(//,$ks);
10foreach (@a) { printf "%02x-",ord($_); }
11print "\n";
12
13
14$key=DES::random_key();
15print "($_)\n";
16@a=split(//,$key);
17foreach (@a) { printf "%02x-",ord($_); }
18print "\n";
19$str="this is and again into the breach";
20($k1,$k2)=DES::string_to_2keys($str);
21@a=split(//,$k1);
22foreach (@a) { printf "%02x-",ord($_); }
23print "\n";
24@a=split(//,$k2);
25foreach (@a) { printf "%02x-",ord($_); }
26print "\n";
27
diff --git a/src/lib/libcrypto/des/times/486-50.sol b/src/lib/libcrypto/des/times/486-50.sol
new file mode 100644
index 0000000000..0de62d6db3
--- /dev/null
+++ b/src/lib/libcrypto/des/times/486-50.sol
@@ -0,0 +1,16 @@
1Solaris 2.4, 486 50mhz, gcc 2.6.3
2options des ecb/s
316 r2 i 43552.51 100.0%
416 r1 i 43487.45 99.9%
516 c p 43003.23 98.7%
616 r2 p 42339.00 97.2%
716 c i 41900.91 96.2%
816 r1 p 41360.64 95.0%
9 4 c i 38728.48 88.9%
10 4 c p 38225.63 87.8%
11 4 r1 i 38085.79 87.4%
12 4 r2 i 37825.64 86.9%
13 4 r2 p 34611.00 79.5%
14 4 r1 p 31802.00 73.0%
15-DDES_UNROLL -DDES_RISC2
16
diff --git a/src/lib/libcrypto/des/times/586-100.lnx b/src/lib/libcrypto/des/times/586-100.lnx
new file mode 100644
index 0000000000..4323914a11
--- /dev/null
+++ b/src/lib/libcrypto/des/times/586-100.lnx
@@ -0,0 +1,20 @@
1Pentium 100
2Linux 2 kernel
3gcc 2.7.0 -O3 -fomit-frame-pointer
4No X server running, just a console, it makes the top speed jump from 151,000
5to 158,000 :-).
6options des ecb/s
7assember 281000.00 177.1%
816 r1 p 158667.40 100.0%
916 r1 i 148471.70 93.6%
1016 r2 p 143961.80 90.7%
1116 r2 i 141689.20 89.3%
12 4 r1 i 140100.00 88.3%
13 4 r2 i 134049.40 84.5%
1416 c i 124145.20 78.2%
1516 c p 121584.20 76.6%
16 4 c i 118116.00 74.4%
17 4 r2 p 117977.90 74.4%
18 4 c p 114971.40 72.5%
19 4 r1 p 114578.40 72.2%
20-DDES_UNROLL -DDES_RISC1 -DDES_PTR
diff --git a/src/lib/libcrypto/des/times/686-200.fre b/src/lib/libcrypto/des/times/686-200.fre
new file mode 100644
index 0000000000..7d83f6adee
--- /dev/null
+++ b/src/lib/libcrypto/des/times/686-200.fre
@@ -0,0 +1,18 @@
1Pentium 100
2Free BSD 2.1.5 kernel
3gcc 2.7.2.2 -O3 -fomit-frame-pointer
4options des ecb/s
5assember 578000.00 133.1%
616 r2 i 434454.80 100.0%
716 r1 i 433621.43 99.8%
816 r2 p 431375.69 99.3%
9 4 r1 i 423722.30 97.5%
10 4 r2 i 422399.40 97.2%
1116 r1 p 421739.40 97.1%
1216 c i 399027.94 91.8%
1316 c p 372251.70 85.7%
14 4 c i 365118.35 84.0%
15 4 c p 352880.51 81.2%
16 4 r2 p 255104.90 58.7%
17 4 r1 p 251289.18 57.8%
18-DDES_UNROLL -DDES_RISC2
diff --git a/src/lib/libcrypto/des/times/aix.cc b/src/lib/libcrypto/des/times/aix.cc
new file mode 100644
index 0000000000..d96b74e2ce
--- /dev/null
+++ b/src/lib/libcrypto/des/times/aix.cc
@@ -0,0 +1,26 @@
1From: Paco Garcia <pgarcia@cam.es>
2
3This machine is a Bull Estrella Minitower Model MT604-100
4Processor : PPC604
5P.Speed : 100Mhz
6Data/Instr Cache : 16 K
7L2 Cache : 256 K
8PCI BUS Speed : 33 Mhz
9TransfRate PCI : 132 MB/s
10Memory : 96 MB
11
12options des ecb/s
13 4 c p 275118.61 100.0%
14 4 c i 273545.07 99.4%
15 4 r2 p 270441.02 98.3%
16 4 r1 p 253052.15 92.0%
17 4 r2 i 240842.97 87.5%
18 4 r1 i 240556.66 87.4%
1916 c i 224603.99 81.6%
2016 c p 224483.98 81.6%
2116 r2 p 215691.19 78.4%
2216 r1 p 208332.83 75.7%
2316 r1 i 199206.50 72.4%
2416 r2 i 198963.70 72.3%
25-DDES_PTR
26
diff --git a/src/lib/libcrypto/des/times/alpha.cc b/src/lib/libcrypto/des/times/alpha.cc
new file mode 100644
index 0000000000..95c17efae7
--- /dev/null
+++ b/src/lib/libcrypto/des/times/alpha.cc
@@ -0,0 +1,18 @@
1cc -O2
2DES_LONG is 'unsigned int'
3
4options des ecb/s
5 4 r2 p 181146.14 100.0%
616 r2 p 172102.94 95.0%
7 4 r2 i 165424.11 91.3%
816 c p 160468.64 88.6%
9 4 c p 156653.59 86.5%
10 4 c i 155245.18 85.7%
11 4 r1 p 154729.68 85.4%
1216 r2 i 154137.69 85.1%
1316 r1 p 152357.96 84.1%
1416 c i 148743.91 82.1%
15 4 r1 i 146695.59 81.0%
1616 r1 i 144961.00 80.0%
17-DDES_RISC2 -DDES_PTR
18
diff --git a/src/lib/libcrypto/des/times/hpux.cc b/src/lib/libcrypto/des/times/hpux.cc
new file mode 100644
index 0000000000..3de856ddac
--- /dev/null
+++ b/src/lib/libcrypto/des/times/hpux.cc
@@ -0,0 +1,17 @@
1HPUX 10 - 9000/887 - cc -D_HPUX_SOURCE -Aa +ESlit +O2 -Wl,-a,archive
2
3options des ecb/s
416 c i 149448.90 100.0%
5 4 c i 145861.79 97.6%
616 r2 i 141710.96 94.8%
716 r1 i 139455.33 93.3%
8 4 r2 i 138800.00 92.9%
9 4 r1 i 136692.65 91.5%
1016 r2 p 110228.17 73.8%
1116 r1 p 109397.07 73.2%
1216 c p 109209.89 73.1%
13 4 c p 108014.71 72.3%
14 4 r2 p 107873.88 72.2%
15 4 r1 p 107685.83 72.1%
16-DDES_UNROLL
17
diff --git a/src/lib/libcrypto/des/times/sparc.gcc b/src/lib/libcrypto/des/times/sparc.gcc
new file mode 100644
index 0000000000..8eaa042104
--- /dev/null
+++ b/src/lib/libcrypto/des/times/sparc.gcc
@@ -0,0 +1,17 @@
1solaris 2.5.1 - sparc 10 50mhz - gcc 2.7.2
2
3options des ecb/s
416 c i 124382.70 100.0%
5 4 c i 118884.68 95.6%
616 c p 112261.20 90.3%
716 r2 i 111777.10 89.9%
816 r2 p 108896.30 87.5%
916 r1 p 108791.59 87.5%
10 4 c p 107290.10 86.3%
11 4 r1 p 104583.80 84.1%
1216 r1 i 104206.20 83.8%
13 4 r2 p 103709.80 83.4%
14 4 r2 i 98306.43 79.0%
15 4 r1 i 91525.80 73.6%
16-DDES_UNROLL
17
diff --git a/src/lib/libcrypto/des/times/usparc.cc b/src/lib/libcrypto/des/times/usparc.cc
new file mode 100644
index 0000000000..f6ec8e8831
--- /dev/null
+++ b/src/lib/libcrypto/des/times/usparc.cc
@@ -0,0 +1,31 @@
1solaris 2.5.1 usparc 167mhz?? - SC4.0 cc -fast -Xa -xO5
2
3For the ultra sparc, SunC 4.0 cc -fast -Xa -xO5, running 'des_opts'
4gives a speed of 475,000 des/s while 'speed' gives 417,000 des/s.
5I belive the difference is tied up in optimisation that the compiler
6is able to perform when the code is 'inlined'. For 'speed', the DES
7routines are being linked from a library. I'll record the higher
8speed since if performance is everything, you can always inline
9'des_enc.c'.
10
11[ 16-Jan-06 - I've been playing with the
12 '-xtarget=ultra -xarch=v8plus -Xa -xO5 -Xa'
13 and while it makes the des_opts numbers much slower, it makes the
14 actual 'speed' numbers look better which is a realistic version of
15 using the libraries. ]
16
17options des ecb/s
1816 r1 p 475516.90 100.0%
1916 r2 p 439388.10 92.4%
2016 c i 427001.40 89.8%
2116 c p 419516.50 88.2%
22 4 r2 p 409491.70 86.1%
23 4 r1 p 404266.90 85.0%
24 4 c p 398121.00 83.7%
25 4 c i 370588.40 77.9%
26 4 r1 i 362742.20 76.3%
2716 r2 i 331275.50 69.7%
2816 r1 i 324730.60 68.3%
29 4 r2 i 63535.10 13.4% <-- very very weird, must be cache problems.
30-DDES_UNROLL -DDES_RISC1 -DDES_PTR
31
diff --git a/src/lib/libcrypto/des/typemap b/src/lib/libcrypto/des/typemap
new file mode 100644
index 0000000000..a524f53634
--- /dev/null
+++ b/src/lib/libcrypto/des/typemap
@@ -0,0 +1,34 @@
1#
2# DES SECTION
3#
4deschar * T_DESCHARP
5des_cblock * T_CBLOCK
6des_cblock T_CBLOCK
7des_key_schedule T_SCHEDULE
8des_key_schedule * T_SCHEDULE
9
10INPUT
11T_CBLOCK
12 $var=(des_cblock *)SvPV($arg,len);
13 if (len < DES_KEY_SZ)
14 {
15 croak(\"$var needs to be at least %u bytes long\",DES_KEY_SZ);
16 }
17
18T_SCHEDULE
19 $var=(des_key_schedule *)SvPV($arg,len);
20 if (len < DES_SCHEDULE_SZ)
21 {
22 croak(\"$var needs to be at least %u bytes long\",
23 DES_SCHEDULE_SZ);
24 }
25
26OUTPUT
27T_CBLOCK
28 sv_setpvn($arg,(char *)$var,DES_KEY_SZ);
29
30T_SCHEDULE
31 sv_setpvn($arg,(char *)$var,DES_SCHEDULE_SZ);
32
33T_DESCHARP
34 sv_setpvn($arg,(char *)$var,len);
diff --git a/src/lib/libcrypto/dh/Makefile.ssl b/src/lib/libcrypto/dh/Makefile.ssl
new file mode 100644
index 0000000000..5e1aaae160
--- /dev/null
+++ b/src/lib/libcrypto/dh/Makefile.ssl
@@ -0,0 +1,136 @@
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/asn1.h ../../include/openssl/bio.h
116dh_key.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
117dh_key.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
118dh_key.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
119dh_key.o: ../../include/openssl/engine.h ../../include/openssl/err.h
120dh_key.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
121dh_key.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
122dh_key.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
123dh_key.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
124dh_key.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
125dh_key.o: ../cryptlib.h dh_key.c
126dh_lib.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
127dh_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
128dh_lib.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
129dh_lib.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
130dh_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h
131dh_lib.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
132dh_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
133dh_lib.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
134dh_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
135dh_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
136dh_lib.o: ../cryptlib.h dh_lib.c
diff --git a/src/lib/libcrypto/dh/dh.h b/src/lib/libcrypto/dh/dh.h
index 05851f8429..d51dc130f4 100644
--- a/src/lib/libcrypto/dh/dh.h
+++ b/src/lib/libcrypto/dh/dh.h
@@ -101,7 +101,7 @@ struct dh_st
101 int version; 101 int version;
102 BIGNUM *p; 102 BIGNUM *p;
103 BIGNUM *g; 103 BIGNUM *g;
104 long length; /* optional */ 104 int length; /* optional */
105 BIGNUM *pub_key; /* g^x */ 105 BIGNUM *pub_key; /* g^x */
106 BIGNUM *priv_key; /* x */ 106 BIGNUM *priv_key; /* x */
107 107
diff --git a/src/lib/libcrypto/dh/dh1024.pem b/src/lib/libcrypto/dh/dh1024.pem
new file mode 100644
index 0000000000..81d43f6a3e
--- /dev/null
+++ b/src/lib/libcrypto/dh/dh1024.pem
@@ -0,0 +1,5 @@
1-----BEGIN DH PARAMETERS-----
2MIGHAoGBAJf2QmHKtQXdKCjhPx1ottPb0PMTBH9A6FbaWMsTuKG/K3g6TG1Z1fkq
3/Gz/PWk/eLI9TzFgqVAuPvr3q14a1aZeVUMTgo2oO5/y2UHe6VaJ+trqCTat3xlx
4/mNbIK9HA2RgPC3gWfVLZQrY+gz3ASHHR5nXWHEyvpuZm7m3h+irAgEC
5-----END DH PARAMETERS-----
diff --git a/src/lib/libcrypto/dh/dh192.pem b/src/lib/libcrypto/dh/dh192.pem
new file mode 100644
index 0000000000..521c07271d
--- /dev/null
+++ b/src/lib/libcrypto/dh/dh192.pem
@@ -0,0 +1,3 @@
1-----BEGIN DH PARAMETERS-----
2MB4CGQDUoLoCULb9LsYm5+/WN992xxbiLQlEuIsCAQM=
3-----END DH PARAMETERS-----
diff --git a/src/lib/libcrypto/dh/dh2048.pem b/src/lib/libcrypto/dh/dh2048.pem
new file mode 100644
index 0000000000..295460f508
--- /dev/null
+++ b/src/lib/libcrypto/dh/dh2048.pem
@@ -0,0 +1,16 @@
1-----BEGIN DH PARAMETERS-----
2MIIBCAKCAQEA7ZKJNYJFVcs7+6J2WmkEYb8h86tT0s0h2v94GRFS8Q7B4lW9aG9o
3AFO5Imov5Jo0H2XMWTKKvbHbSe3fpxJmw/0hBHAY8H/W91hRGXKCeyKpNBgdL8sh
4z22SrkO2qCnHJ6PLAMXy5fsKpFmFor2tRfCzrfnggTXu2YOzzK7q62bmqVdmufEo
5pT8igNcLpvZxk5uBDvhakObMym9mX3rAEBoe8PwttggMYiiw7NuJKO4MqD1llGkW
6aVM8U2ATsCun1IKHrRxynkE1/MJ86VHeYYX8GZt2YA8z+GuzylIOKcMH6JAWzMwA
7Gbatw6QwizOhr9iMjZ0B26TE3X8LvW84wwIBAg==
8-----END DH PARAMETERS-----
9-----BEGIN DH PARAMETERS-----
10MIIBCAKCAQEArtA3w73zP6Lu3EOQtwogiXt3AXXpuS6yD4BhzNS1pZFyPHk0/an5
118ydEkPhQZHKDW+BZJxxPLANaTudWo2YT8TgtvUdN6KSgMiEi6McwqDw+SADuvW+F
12SKUYFxG6VFIxyEP6xBdf+vhJxEDbRG2EYsHDRRtJ76gp9cSKTHusf2R+4AAVGqnt
13gRAbNqtcOar/7FSj+Pl8G3v0Bty0LcCSpbqgYlnv6z+rErQmmC6PPvSz97TDMCok
14yKpCE9hFA1zkqK3TH4FmFvGeIaXJUIBZf4mArWuBTjWFW3nmhESRUn1VK3K3x42N
15a5k6c2+EhrMFiLjxuH6JZoqL0/E93FF9SwIBAg==
16-----END DH PARAMETERS-----
diff --git a/src/lib/libcrypto/dh/dh4096.pem b/src/lib/libcrypto/dh/dh4096.pem
new file mode 100644
index 0000000000..390943a21d
--- /dev/null
+++ b/src/lib/libcrypto/dh/dh4096.pem
@@ -0,0 +1,14 @@
1-----BEGIN DH PARAMETERS-----
2MIICCAKCAgEA/urRnb6vkPYc/KEGXWnbCIOaKitq7ySIq9dTH7s+Ri59zs77zty7
3vfVlSe6VFTBWgYjD2XKUFmtqq6CqXMhVX5ElUDoYDpAyTH85xqNFLzFC7nKrff/H
4TFKNttp22cZE9V0IPpzedPfnQkE7aUdmF9JnDyv21Z/818O93u1B4r0szdnmEvEF
5bKuIxEHX+bp0ZR7RqE1AeifXGJX3d6tsd2PMAObxwwsv55RGkn50vHO4QxtTARr1
6rRUV5j3B3oPMgC7Offxx+98Xn45B1/G0Prp11anDsR1PGwtaCYipqsvMwQUSJtyE
7EOQWk+yFkeMe4vWv367eEi0Sd/wnC+TSXBE3pYvpYerJ8n1MceI5GQTdarJ77OW9
8bGTHmxRsLSCM1jpLdPja5jjb4siAa6EHc4qN9c/iFKS3PQPJEnX7pXKBRs5f7AF3
9W3RIGt+G9IVNZfXaS7Z/iCpgzgvKCs0VeqN38QsJGtC1aIkwOeyjPNy2G6jJ4yqH
10ovXYt/0mc00vCWeSNS1wren0pR2EiLxX0ypjjgsU1mk/Z3b/+zVf7fZSIB+nDLjb
11NPtUlJCVGnAeBK1J1nG3TQicqowOXoM6ISkdaXj5GPJdXHab2+S7cqhKGv5qC7rR
12jT6sx7RUr0CNTxzLI7muV2/a4tGmj0PSdXQdsZ7tw7gbXlaWT1+MM2MCAQI=
13-----END DH PARAMETERS-----
14
diff --git a/src/lib/libcrypto/dh/dh512.pem b/src/lib/libcrypto/dh/dh512.pem
new file mode 100644
index 0000000000..0a4d863ebe
--- /dev/null
+++ b/src/lib/libcrypto/dh/dh512.pem
@@ -0,0 +1,4 @@
1-----BEGIN DH PARAMETERS-----
2MEYCQQDaWDwW2YUiidDkr3VvTMqS3UvlM7gE+w/tlO+cikQD7VdGUNNpmdsp13Yn
3a6LT1BLiGPTdHghM9tgAPnxHdOgzAgEC
4-----END DH PARAMETERS-----
diff --git a/src/lib/libcrypto/dh/dh_key.c b/src/lib/libcrypto/dh/dh_key.c
index 77f2f50b51..1a0efca2c4 100644
--- a/src/lib/libcrypto/dh/dh_key.c
+++ b/src/lib/libcrypto/dh/dh_key.c
@@ -61,6 +61,7 @@
61#include <openssl/bn.h> 61#include <openssl/bn.h>
62#include <openssl/rand.h> 62#include <openssl/rand.h>
63#include <openssl/dh.h> 63#include <openssl/dh.h>
64#include <openssl/engine.h>
64 65
65static int generate_key(DH *dh); 66static int generate_key(DH *dh);
66static int compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh); 67static int compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh);
diff --git a/src/lib/libcrypto/dh/dh_lib.c b/src/lib/libcrypto/dh/dh_lib.c
index 09965ee2ea..ba5fd41057 100644
--- a/src/lib/libcrypto/dh/dh_lib.c
+++ b/src/lib/libcrypto/dh/dh_lib.c
@@ -60,9 +60,7 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/bn.h> 61#include <openssl/bn.h>
62#include <openssl/dh.h> 62#include <openssl/dh.h>
63#ifndef OPENSSL_NO_ENGINE
64#include <openssl/engine.h> 63#include <openssl/engine.h>
65#endif
66 64
67const char *DH_version="Diffie-Hellman" OPENSSL_VERSION_PTEXT; 65const char *DH_version="Diffie-Hellman" OPENSSL_VERSION_PTEXT;
68 66
@@ -87,13 +85,11 @@ int DH_set_method(DH *dh, const DH_METHOD *meth)
87 const DH_METHOD *mtmp; 85 const DH_METHOD *mtmp;
88 mtmp = dh->meth; 86 mtmp = dh->meth;
89 if (mtmp->finish) mtmp->finish(dh); 87 if (mtmp->finish) mtmp->finish(dh);
90#ifndef OPENSSL_NO_ENGINE
91 if (dh->engine) 88 if (dh->engine)
92 { 89 {
93 ENGINE_finish(dh->engine); 90 ENGINE_finish(dh->engine);
94 dh->engine = NULL; 91 dh->engine = NULL;
95 } 92 }
96#endif
97 dh->meth = meth; 93 dh->meth = meth;
98 if (meth->init) meth->init(dh); 94 if (meth->init) meth->init(dh);
99 return 1; 95 return 1;
@@ -116,7 +112,6 @@ DH *DH_new_method(ENGINE *engine)
116 } 112 }
117 113
118 ret->meth = DH_get_default_method(); 114 ret->meth = DH_get_default_method();
119#ifndef OPENSSL_NO_ENGINE
120 if (engine) 115 if (engine)
121 { 116 {
122 if (!ENGINE_init(engine)) 117 if (!ENGINE_init(engine))
@@ -140,7 +135,6 @@ DH *DH_new_method(ENGINE *engine)
140 return NULL; 135 return NULL;
141 } 136 }
142 } 137 }
143#endif
144 138
145 ret->pad=0; 139 ret->pad=0;
146 ret->version=0; 140 ret->version=0;
@@ -160,10 +154,8 @@ DH *DH_new_method(ENGINE *engine)
160 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DH, ret, &ret->ex_data); 154 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DH, ret, &ret->ex_data);
161 if ((ret->meth->init != NULL) && !ret->meth->init(ret)) 155 if ((ret->meth->init != NULL) && !ret->meth->init(ret))
162 { 156 {
163#ifndef OPENSSL_NO_ENGINE
164 if (ret->engine) 157 if (ret->engine)
165 ENGINE_finish(ret->engine); 158 ENGINE_finish(ret->engine);
166#endif
167 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DH, ret, &ret->ex_data); 159 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DH, ret, &ret->ex_data);
168 OPENSSL_free(ret); 160 OPENSSL_free(ret);
169 ret=NULL; 161 ret=NULL;
@@ -190,10 +182,8 @@ void DH_free(DH *r)
190 182
191 if (r->meth->finish) 183 if (r->meth->finish)
192 r->meth->finish(r); 184 r->meth->finish(r);
193#ifndef OPENSSL_NO_ENGINE
194 if (r->engine) 185 if (r->engine)
195 ENGINE_finish(r->engine); 186 ENGINE_finish(r->engine);
196#endif
197 187
198 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DH, r, &r->ex_data); 188 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DH, r, &r->ex_data);
199 189
diff --git a/src/lib/libcrypto/dh/dhtest.c b/src/lib/libcrypto/dh/dhtest.c
new file mode 100644
index 0000000000..34894ced73
--- /dev/null
+++ b/src/lib/libcrypto/dh/dhtest.c
@@ -0,0 +1,216 @@
1/* crypto/dh/dhtest.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <stdlib.h>
61#include <string.h>
62#ifdef OPENSSL_SYS_WINDOWS
63#include "../bio/bss_file.c"
64#endif
65#include <openssl/crypto.h>
66#include <openssl/bio.h>
67#include <openssl/bn.h>
68#include <openssl/rand.h>
69#include <openssl/err.h>
70
71#ifdef OPENSSL_NO_DH
72int main(int argc, char *argv[])
73{
74 printf("No DH support\n");
75 return(0);
76}
77#else
78#include <openssl/dh.h>
79
80#ifdef OPENSSL_SYS_WIN16
81#define MS_CALLBACK _far _loadds
82#else
83#define MS_CALLBACK
84#endif
85
86static void MS_CALLBACK cb(int p, int n, void *arg);
87#ifdef OPENSSL_NO_STDIO
88#define APPS_WIN16
89#include "bss_file.c"
90#endif
91
92static const char rnd_seed[] = "string to make the random number generator think it has entropy";
93
94int main(int argc, char *argv[])
95 {
96 DH *a;
97 DH *b=NULL;
98 char buf[12];
99 unsigned char *abuf=NULL,*bbuf=NULL;
100 int i,alen,blen,aout,bout,ret=1;
101 BIO *out;
102
103 CRYPTO_malloc_debug_init();
104 CRYPTO_dbg_set_options(V_CRYPTO_MDEBUG_ALL);
105 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
106
107#ifdef OPENSSL_SYS_WIN32
108 CRYPTO_malloc_init();
109#endif
110
111 RAND_seed(rnd_seed, sizeof rnd_seed);
112
113 out=BIO_new(BIO_s_file());
114 if (out == NULL) exit(1);
115 BIO_set_fp(out,stdout,BIO_NOCLOSE);
116
117 a=DH_generate_parameters(64,DH_GENERATOR_5,cb,out);
118 if (a == NULL) goto err;
119
120 if (!DH_check(a, &i)) goto err;
121 if (i & DH_CHECK_P_NOT_PRIME)
122 BIO_puts(out, "p value is not prime\n");
123 if (i & DH_CHECK_P_NOT_SAFE_PRIME)
124 BIO_puts(out, "p value is not a safe prime\n");
125 if (i & DH_UNABLE_TO_CHECK_GENERATOR)
126 BIO_puts(out, "unable to check the generator value\n");
127 if (i & DH_NOT_SUITABLE_GENERATOR)
128 BIO_puts(out, "the g value is not a generator\n");
129
130 BIO_puts(out,"\np =");
131 BN_print(out,a->p);
132 BIO_puts(out,"\ng =");
133 BN_print(out,a->g);
134 BIO_puts(out,"\n");
135
136 b=DH_new();
137 if (b == NULL) goto err;
138
139 b->p=BN_dup(a->p);
140 b->g=BN_dup(a->g);
141 if ((b->p == NULL) || (b->g == NULL)) goto err;
142
143 if (!DH_generate_key(a)) goto err;
144 BIO_puts(out,"pri 1=");
145 BN_print(out,a->priv_key);
146 BIO_puts(out,"\npub 1=");
147 BN_print(out,a->pub_key);
148 BIO_puts(out,"\n");
149
150 if (!DH_generate_key(b)) goto err;
151 BIO_puts(out,"pri 2=");
152 BN_print(out,b->priv_key);
153 BIO_puts(out,"\npub 2=");
154 BN_print(out,b->pub_key);
155 BIO_puts(out,"\n");
156
157 alen=DH_size(a);
158 abuf=(unsigned char *)OPENSSL_malloc(alen);
159 aout=DH_compute_key(abuf,b->pub_key,a);
160
161 BIO_puts(out,"key1 =");
162 for (i=0; i<aout; i++)
163 {
164 sprintf(buf,"%02X",abuf[i]);
165 BIO_puts(out,buf);
166 }
167 BIO_puts(out,"\n");
168
169 blen=DH_size(b);
170 bbuf=(unsigned char *)OPENSSL_malloc(blen);
171 bout=DH_compute_key(bbuf,a->pub_key,b);
172
173 BIO_puts(out,"key2 =");
174 for (i=0; i<bout; i++)
175 {
176 sprintf(buf,"%02X",bbuf[i]);
177 BIO_puts(out,buf);
178 }
179 BIO_puts(out,"\n");
180 if ((aout < 4) || (bout != aout) || (memcmp(abuf,bbuf,aout) != 0))
181 {
182 fprintf(stderr,"Error in DH routines\n");
183 ret=1;
184 }
185 else
186 ret=0;
187err:
188 ERR_print_errors_fp(stderr);
189
190 if (abuf != NULL) OPENSSL_free(abuf);
191 if (bbuf != NULL) OPENSSL_free(bbuf);
192 if(b != NULL) DH_free(b);
193 if(a != NULL) DH_free(a);
194 BIO_free(out);
195 CRYPTO_cleanup_all_ex_data();
196 ERR_remove_state(0);
197 CRYPTO_mem_leaks_fp(stderr);
198 exit(ret);
199 return(ret);
200 }
201
202static void MS_CALLBACK cb(int p, int n, void *arg)
203 {
204 char c='*';
205
206 if (p == 0) c='.';
207 if (p == 1) c='+';
208 if (p == 2) c='*';
209 if (p == 3) c='\n';
210 BIO_write((BIO *)arg,&c,1);
211 (void)BIO_flush((BIO *)arg);
212#ifdef LINT
213 p=n;
214#endif
215 }
216#endif
diff --git a/src/lib/libcrypto/dh/example b/src/lib/libcrypto/dh/example
new file mode 100644
index 0000000000..16a33d2910
--- /dev/null
+++ b/src/lib/libcrypto/dh/example
@@ -0,0 +1,50 @@
1From owner-cypherpunks@toad.com Mon Sep 25 10:50:51 1995
2Received: from minbne.mincom.oz.au by orb.mincom.oz.au with SMTP id AA10562
3 (5.65c/IDA-1.4.4 for eay); Wed, 27 Sep 1995 19:41:55 +1000
4Received: by minbne.mincom.oz.au id AA19958
5 (5.65c/IDA-1.4.4 for eay@orb.mincom.oz.au); Wed, 27 Sep 1995 19:34:59 +1000
6Received: from relay3.UU.NET by bunyip.cc.uq.oz.au with SMTP (PP);
7 Wed, 27 Sep 1995 19:13:05 +1000
8Received: from toad.com by relay3.UU.NET with SMTP id QQzizb16156;
9 Wed, 27 Sep 1995 04:48:46 -0400
10Received: by toad.com id AA07905; Tue, 26 Sep 95 06:31:45 PDT
11Received: from by toad.com id AB07851; Tue, 26 Sep 95 06:31:40 PDT
12Received: from servo.qualcomm.com (servo.qualcomm.com [129.46.128.14])
13 by cygnus.com (8.6.12/8.6.9) with ESMTP id RAA18442
14 for <cypherpunks@toad.com>; Mon, 25 Sep 1995 17:52:47 -0700
15Received: (karn@localhost) by servo.qualcomm.com (8.6.12/QC-BSD-2.5.1)
16 id RAA14732; Mon, 25 Sep 1995 17:50:51 -0700
17Date: Mon, 25 Sep 1995 17:50:51 -0700
18From: Phil Karn <karn@qualcomm.com>
19Message-Id: <199509260050.RAA14732@servo.qualcomm.com>
20To: cypherpunks@toad.com, ipsec-dev@eit.com
21Subject: Primality verification needed
22Sender: owner-cypherpunks@toad.com
23Precedence: bulk
24Status: RO
25X-Status:
26
27Hi. I've generated a 2047-bit "strong" prime number that I would like to
28use with Diffie-Hellman key exchange. I assert that not only is this number
29'p' prime, but so is (p-1)/2.
30
31I've used the mpz_probab_prime() function in the Gnu Math Package (GMP) version
321.3.2 to test this number. This function uses the Miller-Rabin primality test.
33However, to increase my confidence that this number really is a strong prime,
34I'd like to ask others to confirm it with other tests. Here's the number in hex:
35
3672a925f760b2f954ed287f1b0953f3e6aef92e456172f9fe86fdd8822241b9c9788fbc289982743e
37fbcd2ccf062b242d7a567ba8bbb40d79bca7b8e0b6c05f835a5b938d985816bc648985adcff5402a
38a76756b36c845a840a1d059ce02707e19cf47af0b5a882f32315c19d1b86a56c5389c5e9bee16b65
39fde7b1a8d74a7675de9b707d4c5a4633c0290c95ff30a605aeb7ae864ff48370f13cf01d49adb9f2
403d19a439f753ee7703cf342d87f431105c843c78ca4df639931f3458fae8a94d1687e99a76ed99d0
41ba87189f42fd31ad8262c54a8cf5914ae6c28c540d714a5f6087a171fb74f4814c6f968d72386ef3
4256a05180c3bec7ddd5ef6fe76b1f717b
43
44The generator, g, for this prime is 2.
45
46Thanks!
47
48Phil Karn
49
50
diff --git a/src/lib/libcrypto/dh/generate b/src/lib/libcrypto/dh/generate
new file mode 100644
index 0000000000..5d407231df
--- /dev/null
+++ b/src/lib/libcrypto/dh/generate
@@ -0,0 +1,65 @@
1From: stewarts@ix.netcom.com (Bill Stewart)
2Newsgroups: sci.crypt
3Subject: Re: Diffie-Hellman key exchange
4Date: Wed, 11 Oct 1995 23:08:28 GMT
5Organization: Freelance Information Architect
6Lines: 32
7Message-ID: <45hir2$7l8@ixnews7.ix.netcom.com>
8References: <458rhn$76m$1@mhadf.production.compuserve.com>
9NNTP-Posting-Host: ix-pl4-16.ix.netcom.com
10X-NETCOM-Date: Wed Oct 11 4:09:22 PM PDT 1995
11X-Newsreader: Forte Free Agent 1.0.82
12
13Kent Briggs <72124.3234@CompuServe.COM> wrote:
14
15>I have a copy of the 1976 IEEE article describing the
16>Diffie-Hellman public key exchange algorithm: y=a^x mod q. I'm
17>looking for sources that give examples of secure a,q pairs and
18>possible some source code that I could examine.
19
20q should be prime, and ideally should be a "strong prime",
21which means it's of the form 2n+1 where n is also prime.
22q also needs to be long enough to prevent the attacks LaMacchia and
23Odlyzko described (some variant on a factoring attack which generates
24a large pile of simultaneous equations and then solves them);
25long enough is about the same size as factoring, so 512 bits may not
26be secure enough for most applications. (The 192 bits used by
27"secure NFS" was certainly not long enough.)
28
29a should be a generator for q, which means it needs to be
30relatively prime to q-1. Usually a small prime like 2, 3 or 5 will
31work.
32
33....
34
35Date: Tue, 26 Sep 1995 13:52:36 MST
36From: "Richard Schroeppel" <rcs@cs.arizona.edu>
37To: karn
38Cc: ho@cs.arizona.edu
39Subject: random large primes
40
41Since your prime is really random, proving it is hard.
42My personal limit on rigorously proved primes is ~350 digits.
43If you really want a proof, we should talk to Francois Morain,
44or the Australian group.
45
46If you want 2 to be a generator (mod P), then you need it
47to be a non-square. If (P-1)/2 is also prime, then
48non-square == primitive-root for bases << P.
49
50In the case at hand, this means 2 is a generator iff P = 11 (mod 24).
51If you want this, you should restrict your sieve accordingly.
52
533 is a generator iff P = 5 (mod 12).
54
555 is a generator iff P = 3 or 7 (mod 10).
56
572 is perfectly usable as a base even if it's a non-generator, since
58it still covers half the space of possible residues. And an
59eavesdropper can always determine the low-bit of your exponent for
60a generator anyway.
61
62Rich rcs@cs.arizona.edu
63
64
65
diff --git a/src/lib/libcrypto/dh/p1024.c b/src/lib/libcrypto/dh/p1024.c
new file mode 100644
index 0000000000..368ceca4eb
--- /dev/null
+++ b/src/lib/libcrypto/dh/p1024.c
@@ -0,0 +1,92 @@
1/* crypto/dh/p1024.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/bn.h>
61#include <openssl/asn1.h>
62#include <openssl/dh.h>
63#include <openssl/pem.h>
64
65unsigned char data[]={0x97,0xF6,0x42,0x61,0xCA,0xB5,0x05,0xDD,
66 0x28,0x28,0xE1,0x3F,0x1D,0x68,0xB6,0xD3,
67 0xDB,0xD0,0xF3,0x13,0x04,0x7F,0x40,0xE8,
68 0x56,0xDA,0x58,0xCB,0x13,0xB8,0xA1,0xBF,
69 0x2B,0x78,0x3A,0x4C,0x6D,0x59,0xD5,0xF9,
70 0x2A,0xFC,0x6C,0xFF,0x3D,0x69,0x3F,0x78,
71 0xB2,0x3D,0x4F,0x31,0x60,0xA9,0x50,0x2E,
72 0x3E,0xFA,0xF7,0xAB,0x5E,0x1A,0xD5,0xA6,
73 0x5E,0x55,0x43,0x13,0x82,0x8D,0xA8,0x3B,
74 0x9F,0xF2,0xD9,0x41,0xDE,0xE9,0x56,0x89,
75 0xFA,0xDA,0xEA,0x09,0x36,0xAD,0xDF,0x19,
76 0x71,0xFE,0x63,0x5B,0x20,0xAF,0x47,0x03,
77 0x64,0x60,0x3C,0x2D,0xE0,0x59,0xF5,0x4B,
78 0x65,0x0A,0xD8,0xFA,0x0C,0xF7,0x01,0x21,
79 0xC7,0x47,0x99,0xD7,0x58,0x71,0x32,0xBE,
80 0x9B,0x99,0x9B,0xB9,0xB7,0x87,0xE8,0xAB,
81 };
82
83main()
84 {
85 DH *dh;
86
87 dh=DH_new();
88 dh->p=BN_bin2bn(data,sizeof(data),NULL);
89 dh->g=BN_new();
90 BN_set_word(dh->g,2);
91 PEM_write_DHparams(stdout,dh);
92 }
diff --git a/src/lib/libcrypto/dh/p192.c b/src/lib/libcrypto/dh/p192.c
new file mode 100644
index 0000000000..7bdf40410e
--- /dev/null
+++ b/src/lib/libcrypto/dh/p192.c
@@ -0,0 +1,80 @@
1/* crypto/dh/p192.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/bn.h>
61#include <openssl/asn1.h>
62#include <openssl/dh.h>
63#include <openssl/pem.h>
64
65unsigned char data[]={
660xD4,0xA0,0xBA,0x02,0x50,0xB6,0xFD,0x2E,
670xC6,0x26,0xE7,0xEF,0xD6,0x37,0xDF,0x76,
680xC7,0x16,0xE2,0x2D,0x09,0x44,0xB8,0x8B,
69 };
70
71main()
72 {
73 DH *dh;
74
75 dh=DH_new();
76 dh->p=BN_bin2bn(data,sizeof(data),NULL);
77 dh->g=BN_new();
78 BN_set_word(dh->g,3);
79 PEM_write_DHparams(stdout,dh);
80 }
diff --git a/src/lib/libcrypto/dh/p512.c b/src/lib/libcrypto/dh/p512.c
new file mode 100644
index 0000000000..a9b6aa83f0
--- /dev/null
+++ b/src/lib/libcrypto/dh/p512.c
@@ -0,0 +1,85 @@
1/* crypto/dh/p512.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/bn.h>
61#include <openssl/asn1.h>
62#include <openssl/dh.h>
63#include <openssl/pem.h>
64
65unsigned char data[]={
660xDA,0x58,0x3C,0x16,0xD9,0x85,0x22,0x89,
670xD0,0xE4,0xAF,0x75,0x6F,0x4C,0xCA,0x92,
680xDD,0x4B,0xE5,0x33,0xB8,0x04,0xFB,0x0F,
690xED,0x94,0xEF,0x9C,0x8A,0x44,0x03,0xED,
700x57,0x46,0x50,0xD3,0x69,0x99,0xDB,0x29,
710xD7,0x76,0x27,0x6B,0xA2,0xD3,0xD4,0x12,
720xE2,0x18,0xF4,0xDD,0x1E,0x08,0x4C,0xF6,
730xD8,0x00,0x3E,0x7C,0x47,0x74,0xE8,0x33,
74 };
75
76main()
77 {
78 DH *dh;
79
80 dh=DH_new();
81 dh->p=BN_bin2bn(data,sizeof(data),NULL);
82 dh->g=BN_new();
83 BN_set_word(dh->g,2);
84 PEM_write_DHparams(stdout,dh);
85 }
diff --git a/src/lib/libcrypto/doc/DH_generate_parameters.pod b/src/lib/libcrypto/doc/DH_generate_parameters.pod
index 9081e9ea7c..4a2d653758 100644
--- a/src/lib/libcrypto/doc/DH_generate_parameters.pod
+++ b/src/lib/libcrypto/doc/DH_generate_parameters.pod
@@ -59,8 +59,7 @@ a usable generator.
59 59
60=head1 SEE ALSO 60=head1 SEE ALSO
61 61
62L<dh(3)|dh(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>, 62L<dh(3)|dh(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>, L<DH_free(3)|DH_free(3)>
63L<DH_free(3)|DH_free(3)>
64 63
65=head1 HISTORY 64=head1 HISTORY
66 65
diff --git a/src/lib/libcrypto/doc/DSA_SIG_new.pod b/src/lib/libcrypto/doc/DSA_SIG_new.pod
index 3ac6140038..45df4c0661 100644
--- a/src/lib/libcrypto/doc/DSA_SIG_new.pod
+++ b/src/lib/libcrypto/doc/DSA_SIG_new.pod
@@ -30,8 +30,7 @@ DSA_SIG_free() returns no value.
30 30
31=head1 SEE ALSO 31=head1 SEE ALSO
32 32
33L<dsa(3)|dsa(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, 33L<dsa(3)|dsa(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<DSA_do_sign(3)|DSA_do_sign(3)>
34L<DSA_do_sign(3)|DSA_do_sign(3)>
35 34
36=head1 HISTORY 35=head1 HISTORY
37 36
diff --git a/src/lib/libcrypto/doc/DSA_generate_key.pod b/src/lib/libcrypto/doc/DSA_generate_key.pod
index af83ccfaa1..9906a2d7e0 100644
--- a/src/lib/libcrypto/doc/DSA_generate_key.pod
+++ b/src/lib/libcrypto/doc/DSA_generate_key.pod
@@ -24,8 +24,7 @@ The error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
24 24
25=head1 SEE ALSO 25=head1 SEE ALSO
26 26
27L<dsa(3)|dsa(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>, 27L<dsa(3)|dsa(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>, L<DSA_generate_parameters(3)|DSA_generate_parameters(3)>
28L<DSA_generate_parameters(3)|DSA_generate_parameters(3)>
29 28
30=head1 HISTORY 29=head1 HISTORY
31 30
diff --git a/src/lib/libcrypto/doc/ERR_get_error.pod b/src/lib/libcrypto/doc/ERR_get_error.pod
index 34443045fc..9fdedbcb91 100644
--- a/src/lib/libcrypto/doc/ERR_get_error.pod
+++ b/src/lib/libcrypto/doc/ERR_get_error.pod
@@ -5,7 +5,7 @@
5ERR_get_error, ERR_peek_error, ERR_peek_last_error, 5ERR_get_error, ERR_peek_error, ERR_peek_last_error,
6ERR_get_error_line, ERR_peek_error_line, ERR_peek_last_error_line, 6ERR_get_error_line, ERR_peek_error_line, ERR_peek_last_error_line,
7ERR_get_error_line_data, ERR_peek_error_line_data, 7ERR_get_error_line_data, ERR_peek_error_line_data,
8ERR_peek_last_error_line_data - obtain error code and data 8ERR_peek_error_line_data - obtain error code and data
9 9
10=head1 SYNOPSIS 10=head1 SYNOPSIS
11 11
diff --git a/src/lib/libcrypto/doc/EVP_DigestInit.pod b/src/lib/libcrypto/doc/EVP_DigestInit.pod
index 5901c39526..58afd8f0b8 100644
--- a/src/lib/libcrypto/doc/EVP_DigestInit.pod
+++ b/src/lib/libcrypto/doc/EVP_DigestInit.pod
@@ -236,9 +236,9 @@ even though they are identical digests.
236 236
237=head1 SEE ALSO 237=head1 SEE ALSO
238 238
239L<evp(3)|evp(3)>, L<hmac(3)|hmac(3)>, L<md2(3)|md2(3)>, 239L<evp(3)|evp(3)>, L<HMAC(3)|HMAC(3)>, L<MD2(3)|MD2(3)>,
240L<md5(3)|md5(3)>, L<mdc2(3)|mdc2(3)>, L<ripemd(3)|ripemd(3)>, 240L<MD5(3)|MD5(3)>, L<MDC2(3)|MDC2(3)>, L<RIPEMD160(3)|RIPEMD160(3)>,
241L<sha(3)|sha(3)>, L<dgst(1)|dgst(1)> 241L<SHA1(3)|SHA1(3)>
242 242
243=head1 HISTORY 243=head1 HISTORY
244 244
diff --git a/src/lib/libcrypto/doc/EVP_EncryptInit.pod b/src/lib/libcrypto/doc/EVP_EncryptInit.pod
index daf57e5895..75cceb1ca2 100644
--- a/src/lib/libcrypto/doc/EVP_EncryptInit.pod
+++ b/src/lib/libcrypto/doc/EVP_EncryptInit.pod
@@ -419,7 +419,7 @@ Encrypt a string using blowfish:
419 EVP_CIPHER_CTX ctx; 419 EVP_CIPHER_CTX ctx;
420 FILE *out; 420 FILE *out;
421 EVP_CIPHER_CTX_init(&ctx); 421 EVP_CIPHER_CTX_init(&ctx);
422 EVP_EncryptInit_ex(&ctx, EVP_bf_cbc(), NULL, key, iv); 422 EVP_EncryptInit_ex(&ctx, NULL, EVP_bf_cbc(), key, iv);
423 423
424 if(!EVP_EncryptUpdate(&ctx, outbuf, &outlen, intext, strlen(intext))) 424 if(!EVP_EncryptUpdate(&ctx, outbuf, &outlen, intext, strlen(intext)))
425 { 425 {
diff --git a/src/lib/libcrypto/doc/EVP_SealInit.pod b/src/lib/libcrypto/doc/EVP_SealInit.pod
index b5e477e294..25ef07f7c7 100644
--- a/src/lib/libcrypto/doc/EVP_SealInit.pod
+++ b/src/lib/libcrypto/doc/EVP_SealInit.pod
@@ -18,28 +18,22 @@ EVP_SealInit, EVP_SealUpdate, EVP_SealFinal - EVP envelope encryption
18=head1 DESCRIPTION 18=head1 DESCRIPTION
19 19
20The EVP envelope routines are a high level interface to envelope 20The EVP envelope routines are a high level interface to envelope
21encryption. They generate a random key and IV (if required) then 21encryption. They generate a random key and then "envelope" it by
22"envelope" it by using public key encryption. Data can then be 22using public key encryption. Data can then be encrypted using this
23encrypted using this key. 23key.
24 24
25EVP_SealInit() initializes a cipher context B<ctx> for encryption 25EVP_SealInit() initializes a cipher context B<ctx> for encryption
26with cipher B<type> using a random secret key and IV. B<type> is normally 26with cipher B<type> using a random secret key and IV supplied in
27supplied by a function such as EVP_des_cbc(). The secret key is encrypted 27the B<iv> parameter. B<type> is normally supplied by a function such
28using one or more public keys, this allows the same encrypted data to be 28as EVP_des_cbc(). The secret key is encrypted using one or more public
29decrypted using any of the corresponding private keys. B<ek> is an array of 29keys, this allows the same encrypted data to be decrypted using any
30buffers where the public key encrypted secret key will be written, each buffer 30of the corresponding private keys. B<ek> is an array of buffers where
31must contain enough room for the corresponding encrypted key: that is 31the public key encrypted secret key will be written, each buffer must
32contain enough room for the corresponding encrypted key: that is
32B<ek[i]> must have room for B<EVP_PKEY_size(pubk[i])> bytes. The actual 33B<ek[i]> must have room for B<EVP_PKEY_size(pubk[i])> bytes. The actual
33size of each encrypted secret key is written to the array B<ekl>. B<pubk> is 34size of each encrypted secret key is written to the array B<ekl>. B<pubk> is
34an array of B<npubk> public keys. 35an array of B<npubk> public keys.
35 36
36The B<iv> parameter is a buffer where the generated IV is written to. It must
37contain enough room for the corresponding cipher's IV, as determined by (for
38example) EVP_CIPHER_iv_length(type).
39
40If the cipher does not require an IV then the B<iv> parameter is ignored
41and can be B<NULL>.
42
43EVP_SealUpdate() and EVP_SealFinal() have exactly the same properties 37EVP_SealUpdate() and EVP_SealFinal() have exactly the same properties
44as the EVP_EncryptUpdate() and EVP_EncryptFinal() routines, as 38as the EVP_EncryptUpdate() and EVP_EncryptFinal() routines, as
45documented on the L<EVP_EncryptInit(3)|EVP_EncryptInit(3)> manual 39documented on the L<EVP_EncryptInit(3)|EVP_EncryptInit(3)> manual
diff --git a/src/lib/libcrypto/doc/EVP_SignInit.pod b/src/lib/libcrypto/doc/EVP_SignInit.pod
index b203c3a1c5..e65e54ce52 100644
--- a/src/lib/libcrypto/doc/EVP_SignInit.pod
+++ b/src/lib/libcrypto/doc/EVP_SignInit.pod
@@ -81,10 +81,10 @@ EVP_SignUpdate() could not be made after calling EVP_SignFinal().
81=head1 SEE ALSO 81=head1 SEE ALSO
82 82
83L<EVP_VerifyInit(3)|EVP_VerifyInit(3)>, 83L<EVP_VerifyInit(3)|EVP_VerifyInit(3)>,
84L<EVP_DigestInit(3)|EVP_DigestInit(3)>, L<err(3)|err(3)>, 84L<EVP_DigestInit(3)|EVP_DigestInit(3)>, L<ERR_get_error(3)|ERR_get_error(3)>,
85L<evp(3)|evp(3)>, L<hmac(3)|hmac(3)>, L<md2(3)|md2(3)>, 85L<evp(3)|evp(3)>, L<HMAC(3)|HMAC(3)>, L<MD2(3)|MD2(3)>,
86L<md5(3)|md5(3)>, L<mdc2(3)|mdc2(3)>, L<ripemd(3)|ripemd(3)>, 86L<MD5(3)|MD5(3)>, L<MDC2(3)|MDC2(3)>, L<RIPEMD(3)|RIPEMD(3)>,
87L<sha(3)|sha(3)>, L<dgst(1)|dgst(1)> 87L<SHA1(3)|SHA1(3)>, L<digest(1)|digest(1)>
88 88
89=head1 HISTORY 89=head1 HISTORY
90 90
diff --git a/src/lib/libcrypto/doc/OpenSSL_add_all_algorithms.pod b/src/lib/libcrypto/doc/OpenSSL_add_all_algorithms.pod
index 486c903430..e63411b5bb 100644
--- a/src/lib/libcrypto/doc/OpenSSL_add_all_algorithms.pod
+++ b/src/lib/libcrypto/doc/OpenSSL_add_all_algorithms.pod
@@ -36,7 +36,7 @@ None of the functions return a value.
36 36
37=head1 NOTES 37=head1 NOTES
38 38
39A typical application will will call OpenSSL_add_all_algorithms() initially and 39A typical application will call OpenSSL_add_all_algorithms() initially and
40EVP_cleanup() before exiting. 40EVP_cleanup() before exiting.
41 41
42An application does not need to add algorithms to use them explicitly, for example 42An application does not need to add algorithms to use them explicitly, for example
diff --git a/src/lib/libcrypto/doc/RAND_bytes.pod b/src/lib/libcrypto/doc/RAND_bytes.pod
index ce6329ce54..b03748b918 100644
--- a/src/lib/libcrypto/doc/RAND_bytes.pod
+++ b/src/lib/libcrypto/doc/RAND_bytes.pod
@@ -35,8 +35,7 @@ method.
35 35
36=head1 SEE ALSO 36=head1 SEE ALSO
37 37
38L<rand(3)|rand(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, 38L<rand(3)|rand(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<RAND_add(3)|RAND_add(3)>
39L<RAND_add(3)|RAND_add(3)>
40 39
41=head1 HISTORY 40=head1 HISTORY
42 41
diff --git a/src/lib/libcrypto/doc/RSA_generate_key.pod b/src/lib/libcrypto/doc/RSA_generate_key.pod
index 52dbb14a53..11bc0b3459 100644
--- a/src/lib/libcrypto/doc/RSA_generate_key.pod
+++ b/src/lib/libcrypto/doc/RSA_generate_key.pod
@@ -59,8 +59,7 @@ RSA_generate_key() goes into an infinite loop for illegal input values.
59 59
60=head1 SEE ALSO 60=head1 SEE ALSO
61 61
62L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>, 62L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>, L<RSA_free(3)|RSA_free(3)>
63L<RSA_free(3)|RSA_free(3)>
64 63
65=head1 HISTORY 64=head1 HISTORY
66 65
diff --git a/src/lib/libcrypto/doc/RSA_print.pod b/src/lib/libcrypto/doc/RSA_print.pod
index e28d107d1c..ff2d353d1a 100644
--- a/src/lib/libcrypto/doc/RSA_print.pod
+++ b/src/lib/libcrypto/doc/RSA_print.pod
@@ -2,9 +2,9 @@
2 2
3=head1 NAME 3=head1 NAME
4 4
5RSA_print, RSA_print_fp, 5RSA_print, RSA_print_fp, DHparams_print, DHparams_print_fp, DSA_print,
6DSAparams_print, DSAparams_print_fp, DSA_print, DSA_print_fp, 6DSA_print_fp, DHparams_print, DHparams_print_fp - print cryptographic
7DHparams_print, DHparams_print_fp - print cryptographic parameters 7parameters
8 8
9=head1 SYNOPSIS 9=head1 SYNOPSIS
10 10
@@ -44,6 +44,6 @@ L<dh(3)|dh(3)>, L<dsa(3)|dsa(3)>, L<rsa(3)|rsa(3)>, L<BN_bn2bin(3)|BN_bn2bin(3)>
44 44
45RSA_print(), RSA_print_fp(), DSA_print(), DSA_print_fp(), DH_print(), 45RSA_print(), RSA_print_fp(), DSA_print(), DSA_print_fp(), DH_print(),
46DH_print_fp() are available in all versions of SSLeay and OpenSSL. 46DH_print_fp() are available in all versions of SSLeay and OpenSSL.
47DSAparams_print() and DSAparams_print_pf() were added in SSLeay 0.8. 47DSAparams_print() and DSAparams_print_fp() were added in SSLeay 0.8.
48 48
49=cut 49=cut
diff --git a/src/lib/libcrypto/doc/RSA_private_encrypt.pod b/src/lib/libcrypto/doc/RSA_private_encrypt.pod
index 746a80c79e..0d1b2bd541 100644
--- a/src/lib/libcrypto/doc/RSA_private_encrypt.pod
+++ b/src/lib/libcrypto/doc/RSA_private_encrypt.pod
@@ -59,8 +59,8 @@ obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
59 59
60=head1 SEE ALSO 60=head1 SEE ALSO
61 61
62L<ERR_get_error(3)|ERR_get_error(3)>, L<rsa(3)|rsa(3)>, 62L<ERR_get_error(3)|ERR_get_error(3)>, L<rsa(3)|rsa(3)>, L<RSA_sign(3)|RSA_sign(3)>,
63L<RSA_sign(3)|RSA_sign(3)>, L<RSA_verify(3)|RSA_verify(3)> 63L<RSA_verify(3)|RSA_verify(3)>
64 64
65=head1 HISTORY 65=head1 HISTORY
66 66
diff --git a/src/lib/libcrypto/doc/RSA_public_encrypt.pod b/src/lib/libcrypto/doc/RSA_public_encrypt.pod
index d53e19d2b7..8022a23f99 100644
--- a/src/lib/libcrypto/doc/RSA_public_encrypt.pod
+++ b/src/lib/libcrypto/doc/RSA_public_encrypt.pod
@@ -72,8 +72,7 @@ SSL, PKCS #1 v2.0
72 72
73=head1 SEE ALSO 73=head1 SEE ALSO
74 74
75L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>, 75L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>, L<RSA_size(3)|RSA_size(3)>
76L<RSA_size(3)|RSA_size(3)>
77 76
78=head1 HISTORY 77=head1 HISTORY
79 78
diff --git a/src/lib/libcrypto/doc/RSA_set_method.pod b/src/lib/libcrypto/doc/RSA_set_method.pod
index 0a305f6b14..0687c2242a 100644
--- a/src/lib/libcrypto/doc/RSA_set_method.pod
+++ b/src/lib/libcrypto/doc/RSA_set_method.pod
@@ -3,12 +3,13 @@
3=head1 NAME 3=head1 NAME
4 4
5RSA_set_default_method, RSA_get_default_method, RSA_set_method, 5RSA_set_default_method, RSA_get_default_method, RSA_set_method,
6RSA_get_method, RSA_PKCS1_SSLeay, RSA_null_method, RSA_flags, 6RSA_get_method, RSA_PKCS1_SSLeay,
7RSA_new_method - select RSA method 7RSA_null_method, RSA_flags, RSA_new_method - select RSA method
8 8
9=head1 SYNOPSIS 9=head1 SYNOPSIS
10 10
11 #include <openssl/rsa.h> 11 #include <openssl/rsa.h>
12 #include <openssl/engine.h>
12 13
13 void RSA_set_default_method(const RSA_METHOD *meth); 14 void RSA_set_default_method(const RSA_METHOD *meth);
14 15
@@ -24,7 +25,7 @@ RSA_new_method - select RSA method
24 25
25 int RSA_flags(const RSA *rsa); 26 int RSA_flags(const RSA *rsa);
26 27
27 RSA *RSA_new_method(RSA_METHOD *method); 28 RSA *RSA_new_method(ENGINE *engine);
28 29
29=head1 DESCRIPTION 30=head1 DESCRIPTION
30 31
@@ -69,12 +70,6 @@ B<engine> will be used for the RSA operations. If B<engine> is NULL, the
69default ENGINE for RSA operations is used, and if no default ENGINE is set, 70default ENGINE for RSA operations is used, and if no default ENGINE is set,
70the RSA_METHOD controlled by RSA_set_default_method() is used. 71the RSA_METHOD controlled by RSA_set_default_method() is used.
71 72
72RSA_flags() returns the B<flags> that are set for B<rsa>'s current method.
73
74RSA_new_method() allocates and initializes an B<RSA> structure so that
75B<method> will be used for the RSA operations. If B<method> is B<NULL>,
76the default method is used.
77
78=head1 THE RSA_METHOD STRUCTURE 73=head1 THE RSA_METHOD STRUCTURE
79 74
80 typedef struct rsa_meth_st 75 typedef struct rsa_meth_st
diff --git a/src/lib/libcrypto/doc/RSA_sign_ASN1_OCTET_STRING.pod b/src/lib/libcrypto/doc/RSA_sign_ASN1_OCTET_STRING.pod
index e70380bbfc..b8c7bbb7e3 100644
--- a/src/lib/libcrypto/doc/RSA_sign_ASN1_OCTET_STRING.pod
+++ b/src/lib/libcrypto/doc/RSA_sign_ASN1_OCTET_STRING.pod
@@ -47,8 +47,8 @@ These functions serve no recognizable purpose.
47 47
48=head1 SEE ALSO 48=head1 SEE ALSO
49 49
50L<ERR_get_error(3)|ERR_get_error(3)>, L<objects(3)|objects(3)>, 50L<ERR_get_error(3)|ERR_get_error(3)>, L<objects(3)|objects(3)>, L<rand(3)|rand(3)>,
51L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>, L<RSA_sign(3)|RSA_sign(3)>, 51L<rsa(3)|rsa(3)>, L<RSA_sign(3)|RSA_sign(3)>,
52L<RSA_verify(3)|RSA_verify(3)> 52L<RSA_verify(3)|RSA_verify(3)>
53 53
54=head1 HISTORY 54=head1 HISTORY
diff --git a/src/lib/libcrypto/doc/d2i_DHparams.pod b/src/lib/libcrypto/doc/d2i_DHparams.pod
index 1e98aebeca..a6d1743d39 100644
--- a/src/lib/libcrypto/doc/d2i_DHparams.pod
+++ b/src/lib/libcrypto/doc/d2i_DHparams.pod
@@ -2,7 +2,7 @@
2 2
3=head1 NAME 3=head1 NAME
4 4
5d2i_DHparams, i2d_DHparams - PKCS#3 DH parameter functions. 5d2i_DHparams, i2d_DHparams - ...
6 6
7=head1 SYNOPSIS 7=head1 SYNOPSIS
8 8
@@ -13,18 +13,18 @@ d2i_DHparams, i2d_DHparams - PKCS#3 DH parameter functions.
13 13
14=head1 DESCRIPTION 14=head1 DESCRIPTION
15 15
16These functions decode and encode PKCS#3 DH parameters using the 16...
17DHparameter structure described in PKCS#3.
18 17
19Othewise these behave in a similar way to d2i_X509() and i2d_X509() 18=head1 RETURN VALUES
20described in the L<d2i_X509(3)|d2i_X509(3)> manual page. 19
20...
21 21
22=head1 SEE ALSO 22=head1 SEE ALSO
23 23
24L<d2i_X509(3)|d2i_X509(3)> 24...
25 25
26=head1 HISTORY 26=head1 HISTORY
27 27
28TBA 28...
29 29
30=cut 30=cut
diff --git a/src/lib/libcrypto/doc/d2i_RSAPublicKey.pod b/src/lib/libcrypto/doc/d2i_RSAPublicKey.pod
index 7c71bcbf3d..ff4d0d57db 100644
--- a/src/lib/libcrypto/doc/d2i_RSAPublicKey.pod
+++ b/src/lib/libcrypto/doc/d2i_RSAPublicKey.pod
@@ -2,9 +2,7 @@
2 2
3=head1 NAME 3=head1 NAME
4 4
5d2i_RSAPublicKey, i2d_RSAPublicKey, d2i_RSAPrivateKey, i2d_RSAPrivateKey, 5d2i_RSAPublicKey, i2d_RSAPublicKey, d2i_RSAPrivateKey, i2d_RSAPrivateKey, i2d_Netscape_RSA, d2i_Netscape_RSA - ...
6d2i_RSA_PUBKEY, i2d_RSA_PUBKEY, i2d_Netscape_RSA,
7d2i_Netscape_RSA - RSA public and private key encoding functions.
8 6
9=head1 SYNOPSIS 7=head1 SYNOPSIS
10 8
@@ -14,10 +12,6 @@ d2i_Netscape_RSA - RSA public and private key encoding functions.
14 12
15 int i2d_RSAPublicKey(RSA *a, unsigned char **pp); 13 int i2d_RSAPublicKey(RSA *a, unsigned char **pp);
16 14
17 RSA * d2i_RSA_PUBKEY(RSA **a, unsigned char **pp, long length);
18
19 int i2d_RSA_PUBKEY(RSA *a, unsigned char **pp);
20
21 RSA * d2i_RSAPrivateKey(RSA **a, unsigned char **pp, long length); 15 RSA * d2i_RSAPrivateKey(RSA **a, unsigned char **pp, long length);
22 16
23 int i2d_RSAPrivateKey(RSA *a, unsigned char **pp); 17 int i2d_RSAPrivateKey(RSA *a, unsigned char **pp);
@@ -28,39 +22,18 @@ d2i_Netscape_RSA - RSA public and private key encoding functions.
28 22
29=head1 DESCRIPTION 23=head1 DESCRIPTION
30 24
31d2i_RSAPublicKey() and i2d_RSAPublicKey() decode and encode a PKCS#1 RSAPublicKey 25...
32structure.
33
34d2i_RSA_PUKEY() and i2d_RSA_PUKEY() decode and encode an RSA public key using a
35SubjectPublicKeyInfo (certificate public key) structure.
36
37d2i_RSAPrivateKey(), i2d_RSAPrivateKey() decode and encode a PKCS#1 RSAPrivateKey
38structure.
39
40d2i_Netscape_RSA(), i2d_Netscape_RSA() decode and encode an RSA private key in
41NET format.
42
43The usage of all of these functions is similar to the d2i_X509() and
44i2d_X509() described in the L<d2i_X509(3)|d2i_X509(3)> manual page.
45
46=head1 NOTES
47
48The B<RSA> structure passed to the private key encoding functions should have
49all the PKCS#1 private key components present.
50 26
51The data encoded by the private key functions is unencrypted and therefore 27=head1 RETURN VALUES
52offers no private key security.
53 28
54The NET format functions are present to provide compatibility with certain very 29...
55old software. This format has some severe security weaknesses and should be
56avoided if possible.
57 30
58=head1 SEE ALSO 31=head1 SEE ALSO
59 32
60L<d2i_X509(3)|d2i_X509(3)> 33...
61 34
62=head1 HISTORY 35=head1 HISTORY
63 36
64TBA 37...
65 38
66=cut 39=cut
diff --git a/src/lib/libcrypto/doc/dsa.pod b/src/lib/libcrypto/doc/dsa.pod
index da07d2b930..ae2e5d81f9 100644
--- a/src/lib/libcrypto/doc/dsa.pod
+++ b/src/lib/libcrypto/doc/dsa.pod
@@ -101,8 +101,7 @@ Standard, DSS), ANSI X9.30
101=head1 SEE ALSO 101=head1 SEE ALSO
102 102
103L<bn(3)|bn(3)>, L<dh(3)|dh(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)>, 103L<bn(3)|bn(3)>, L<dh(3)|dh(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)>,
104L<rsa(3)|rsa(3)>, L<sha(3)|sha(3)>, L<engine(3)|engine(3)>, 104L<rsa(3)|rsa(3)>, L<SHA1(3)|SHA1(3)>, L<DSA_new(3)|DSA_new(3)>,
105L<DSA_new(3)|DSA_new(3)>,
106L<DSA_size(3)|DSA_size(3)>, 105L<DSA_size(3)|DSA_size(3)>,
107L<DSA_generate_parameters(3)|DSA_generate_parameters(3)>, 106L<DSA_generate_parameters(3)|DSA_generate_parameters(3)>,
108L<DSA_dup_DH(3)|DSA_dup_DH(3)>, 107L<DSA_dup_DH(3)|DSA_dup_DH(3)>,
diff --git a/src/lib/libcrypto/dsa/Makefile.ssl b/src/lib/libcrypto/dsa/Makefile.ssl
new file mode 100644
index 0000000000..d308caafca
--- /dev/null
+++ b/src/lib/libcrypto/dsa/Makefile.ssl
@@ -0,0 +1,177 @@
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/engine.h
147dsa_ossl.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
148dsa_ossl.o: ../../include/openssl/opensslconf.h
149dsa_ossl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
150dsa_ossl.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
151dsa_ossl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
152dsa_ossl.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
153dsa_ossl.o: ../cryptlib.h dsa_ossl.c
154dsa_sign.o: ../../e_os.h ../../include/openssl/asn1.h
155dsa_sign.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
156dsa_sign.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
157dsa_sign.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
158dsa_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
159dsa_sign.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
160dsa_sign.o: ../../include/openssl/opensslconf.h
161dsa_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
162dsa_sign.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
163dsa_sign.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
164dsa_sign.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
165dsa_sign.o: ../cryptlib.h dsa_sign.c
166dsa_vrf.o: ../../e_os.h ../../include/openssl/asn1.h
167dsa_vrf.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h
168dsa_vrf.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
169dsa_vrf.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
170dsa_vrf.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
171dsa_vrf.o: ../../include/openssl/engine.h ../../include/openssl/err.h
172dsa_vrf.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
173dsa_vrf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
174dsa_vrf.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
175dsa_vrf.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
176dsa_vrf.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
177dsa_vrf.o: ../cryptlib.h dsa_vrf.c
diff --git a/src/lib/libcrypto/dsa/README b/src/lib/libcrypto/dsa/README
new file mode 100644
index 0000000000..6a7e9c170a
--- /dev/null
+++ b/src/lib/libcrypto/dsa/README
@@ -0,0 +1,4 @@
1The stuff in here is based on patches supplied to me by
2Steven Schoch <schoch@sheba.arc.nasa.gov> to do DSS.
3I have since modified a them a little but a debt of gratitude
4is due for doing the initial work.
diff --git a/src/lib/libcrypto/dsa/dsa_lib.c b/src/lib/libcrypto/dsa/dsa_lib.c
index 4171af24c6..da2cdfa3d6 100644
--- a/src/lib/libcrypto/dsa/dsa_lib.c
+++ b/src/lib/libcrypto/dsa/dsa_lib.c
@@ -63,9 +63,7 @@
63#include <openssl/bn.h> 63#include <openssl/bn.h>
64#include <openssl/dsa.h> 64#include <openssl/dsa.h>
65#include <openssl/asn1.h> 65#include <openssl/asn1.h>
66#ifndef OPENSSL_NO_ENGINE
67#include <openssl/engine.h> 66#include <openssl/engine.h>
68#endif
69 67
70const char *DSA_version="DSA" OPENSSL_VERSION_PTEXT; 68const char *DSA_version="DSA" OPENSSL_VERSION_PTEXT;
71 69
@@ -95,13 +93,11 @@ int DSA_set_method(DSA *dsa, const DSA_METHOD *meth)
95 const DSA_METHOD *mtmp; 93 const DSA_METHOD *mtmp;
96 mtmp = dsa->meth; 94 mtmp = dsa->meth;
97 if (mtmp->finish) mtmp->finish(dsa); 95 if (mtmp->finish) mtmp->finish(dsa);
98#ifndef OPENSSL_NO_ENGINE
99 if (dsa->engine) 96 if (dsa->engine)
100 { 97 {
101 ENGINE_finish(dsa->engine); 98 ENGINE_finish(dsa->engine);
102 dsa->engine = NULL; 99 dsa->engine = NULL;
103 } 100 }
104#endif
105 dsa->meth = meth; 101 dsa->meth = meth;
106 if (meth->init) meth->init(dsa); 102 if (meth->init) meth->init(dsa);
107 return 1; 103 return 1;
@@ -118,7 +114,6 @@ DSA *DSA_new_method(ENGINE *engine)
118 return(NULL); 114 return(NULL);
119 } 115 }
120 ret->meth = DSA_get_default_method(); 116 ret->meth = DSA_get_default_method();
121#ifndef OPENSSL_NO_ENGINE
122 if (engine) 117 if (engine)
123 { 118 {
124 if (!ENGINE_init(engine)) 119 if (!ENGINE_init(engine))
@@ -143,7 +138,6 @@ DSA *DSA_new_method(ENGINE *engine)
143 return NULL; 138 return NULL;
144 } 139 }
145 } 140 }
146#endif
147 141
148 ret->pad=0; 142 ret->pad=0;
149 ret->version=0; 143 ret->version=0;
@@ -164,10 +158,8 @@ DSA *DSA_new_method(ENGINE *engine)
164 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data); 158 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data);
165 if ((ret->meth->init != NULL) && !ret->meth->init(ret)) 159 if ((ret->meth->init != NULL) && !ret->meth->init(ret))
166 { 160 {
167#ifndef OPENSSL_NO_ENGINE
168 if (ret->engine) 161 if (ret->engine)
169 ENGINE_finish(ret->engine); 162 ENGINE_finish(ret->engine);
170#endif
171 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data); 163 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data);
172 OPENSSL_free(ret); 164 OPENSSL_free(ret);
173 ret=NULL; 165 ret=NULL;
@@ -197,10 +189,8 @@ void DSA_free(DSA *r)
197 189
198 if(r->meth->finish) 190 if(r->meth->finish)
199 r->meth->finish(r); 191 r->meth->finish(r);
200#ifndef OPENSSL_NO_ENGINE
201 if(r->engine) 192 if(r->engine)
202 ENGINE_finish(r->engine); 193 ENGINE_finish(r->engine);
203#endif
204 194
205 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, r, &r->ex_data); 195 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, r, &r->ex_data);
206 196
@@ -234,10 +224,7 @@ int DSA_size(const DSA *r)
234 { 224 {
235 int ret,i; 225 int ret,i;
236 ASN1_INTEGER bs; 226 ASN1_INTEGER bs;
237 unsigned char buf[4]; /* 4 bytes looks really small. 227 unsigned char buf[4];
238 However, i2d_ASN1_INTEGER() will not look
239 beyond the first byte, as long as the second
240 parameter is NULL. */
241 228
242 i=BN_num_bits(r->q); 229 i=BN_num_bits(r->q);
243 bs.length=(i+7)/8; 230 bs.length=(i+7)/8;
diff --git a/src/lib/libcrypto/dsa/dsa_ossl.c b/src/lib/libcrypto/dsa/dsa_ossl.c
index b9e7f3ea5c..37dd5fc994 100644
--- a/src/lib/libcrypto/dsa/dsa_ossl.c
+++ b/src/lib/libcrypto/dsa/dsa_ossl.c
@@ -64,6 +64,7 @@
64#include <openssl/dsa.h> 64#include <openssl/dsa.h>
65#include <openssl/rand.h> 65#include <openssl/rand.h>
66#include <openssl/asn1.h> 66#include <openssl/asn1.h>
67#include <openssl/engine.h>
67 68
68static 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);
69static 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);
@@ -105,15 +106,13 @@ static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
105 int i,reason=ERR_R_BN_LIB; 106 int i,reason=ERR_R_BN_LIB;
106 DSA_SIG *ret=NULL; 107 DSA_SIG *ret=NULL;
107 108
108 BN_init(&m);
109 BN_init(&xr);
110
111 if (!dsa->p || !dsa->q || !dsa->g) 109 if (!dsa->p || !dsa->q || !dsa->g)
112 { 110 {
113 reason=DSA_R_MISSING_PARAMETERS; 111 reason=DSA_R_MISSING_PARAMETERS;
114 goto err; 112 goto err;
115 } 113 }
116 114 BN_init(&m);
115 BN_init(&xr);
117 s=BN_new(); 116 s=BN_new();
118 if (s == NULL) goto err; 117 if (s == NULL) goto err;
119 118
@@ -179,9 +178,6 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp)
179 DSAerr(DSA_F_DSA_SIGN_SETUP,DSA_R_MISSING_PARAMETERS); 178 DSAerr(DSA_F_DSA_SIGN_SETUP,DSA_R_MISSING_PARAMETERS);
180 return 0; 179 return 0;
181 } 180 }
182
183 BN_init(&k);
184
185 if (ctx_in == NULL) 181 if (ctx_in == NULL)
186 { 182 {
187 if ((ctx=BN_CTX_new()) == NULL) goto err; 183 if ((ctx=BN_CTX_new()) == NULL) goto err;
@@ -189,6 +185,7 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp)
189 else 185 else
190 ctx=ctx_in; 186 ctx=ctx_in;
191 187
188 BN_init(&k);
192 if ((r=BN_new()) == NULL) goto err; 189 if ((r=BN_new()) == NULL) goto err;
193 kinv=NULL; 190 kinv=NULL;
194 191
@@ -244,12 +241,11 @@ static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig,
244 return -1; 241 return -1;
245 } 242 }
246 243
244 if ((ctx=BN_CTX_new()) == NULL) goto err;
247 BN_init(&u1); 245 BN_init(&u1);
248 BN_init(&u2); 246 BN_init(&u2);
249 BN_init(&t1); 247 BN_init(&t1);
250 248
251 if ((ctx=BN_CTX_new()) == NULL) goto err;
252
253 if (BN_is_zero(sig->r) || sig->r->neg || BN_ucmp(sig->r, dsa->q) >= 0) 249 if (BN_is_zero(sig->r) || sig->r->neg || BN_ucmp(sig->r, dsa->q) >= 0)
254 { 250 {
255 ret = 0; 251 ret = 0;
diff --git a/src/lib/libcrypto/dsa/dsa_sign.c b/src/lib/libcrypto/dsa/dsa_sign.c
index 89205026f0..e9469ca62f 100644
--- a/src/lib/libcrypto/dsa/dsa_sign.c
+++ b/src/lib/libcrypto/dsa/dsa_sign.c
@@ -64,6 +64,7 @@
64#include <openssl/dsa.h> 64#include <openssl/dsa.h>
65#include <openssl/rand.h> 65#include <openssl/rand.h>
66#include <openssl/asn1.h> 66#include <openssl/asn1.h>
67#include <openssl/engine.h>
67 68
68DSA_SIG * DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) 69DSA_SIG * DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
69 { 70 {
diff --git a/src/lib/libcrypto/dsa/dsa_vrf.c b/src/lib/libcrypto/dsa/dsa_vrf.c
index c4aeddd056..066c6b5b28 100644
--- a/src/lib/libcrypto/dsa/dsa_vrf.c
+++ b/src/lib/libcrypto/dsa/dsa_vrf.c
@@ -65,6 +65,7 @@
65#include <openssl/rand.h> 65#include <openssl/rand.h>
66#include <openssl/asn1.h> 66#include <openssl/asn1.h>
67#include <openssl/asn1_mac.h> 67#include <openssl/asn1_mac.h>
68#include <openssl/engine.h>
68 69
69int DSA_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, 70int DSA_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig,
70 DSA *dsa) 71 DSA *dsa)
diff --git a/src/lib/libcrypto/dsa/dsagen.c b/src/lib/libcrypto/dsa/dsagen.c
new file mode 100644
index 0000000000..a0b0976640
--- /dev/null
+++ b/src/lib/libcrypto/dsa/dsagen.c
@@ -0,0 +1,111 @@
1/* crypto/dsa/dsagen.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/dsa.h>
61
62#define TEST
63#define GENUINE_DSA
64
65#ifdef GENUINE_DSA
66#define LAST_VALUE 0xbd
67#else
68#define LAST_VALUE 0xd3
69#endif
70
71#ifdef TEST
72unsigned char seed[20]={
73 0xd5,0x01,0x4e,0x4b,
74 0x60,0xef,0x2b,0xa8,
75 0xb6,0x21,0x1b,0x40,
76 0x62,0xba,0x32,0x24,
77 0xe0,0x42,0x7d,LAST_VALUE};
78#endif
79
80int cb(int p, int n)
81 {
82 char c='*';
83
84 if (p == 0) c='.';
85 if (p == 1) c='+';
86 if (p == 2) c='*';
87 if (p == 3) c='\n';
88 printf("%c",c);
89 fflush(stdout);
90 }
91
92main()
93 {
94 int i;
95 BIGNUM *n;
96 BN_CTX *ctx;
97 unsigned char seed_buf[20];
98 DSA *dsa;
99 int counter,h;
100 BIO *bio_err=NULL;
101
102 if (bio_err == NULL)
103 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
104
105 memcpy(seed_buf,seed,20);
106 dsa=DSA_generate_parameters(1024,seed,20,&counter,&h,cb);
107
108 if (dsa == NULL)
109 DSA_print(bio_err,dsa,0);
110 }
111
diff --git a/src/lib/libcrypto/dsa/dsatest.c b/src/lib/libcrypto/dsa/dsatest.c
new file mode 100644
index 0000000000..12da64f9f4
--- /dev/null
+++ b/src/lib/libcrypto/dsa/dsatest.c
@@ -0,0 +1,237 @@
1/* crypto/dsa/dsatest.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <stdlib.h>
61#include <string.h>
62#include <sys/types.h>
63#include <sys/stat.h>
64#include <openssl/crypto.h>
65#include <openssl/rand.h>
66#include <openssl/bio.h>
67#include <openssl/err.h>
68#include <openssl/engine.h>
69#ifdef OPENSSL_SYS_WINDOWS
70#include "../bio/bss_file.c"
71#endif
72
73#ifdef OPENSSL_NO_DSA
74int main(int argc, char *argv[])
75{
76 printf("No DSA support\n");
77 return(0);
78}
79#else
80#include <openssl/dsa.h>
81
82#ifdef OPENSSL_SYS_WIN16
83#define MS_CALLBACK _far _loadds
84#else
85#define MS_CALLBACK
86#endif
87
88static void MS_CALLBACK dsa_cb(int p, int n, void *arg);
89
90/* seed, out_p, out_q, out_g are taken from the updated Appendix 5 to
91 * FIPS PUB 186 and also appear in Appendix 5 to FIPS PIB 186-1 */
92static unsigned char seed[20]={
93 0xd5,0x01,0x4e,0x4b,0x60,0xef,0x2b,0xa8,0xb6,0x21,0x1b,0x40,
94 0x62,0xba,0x32,0x24,0xe0,0x42,0x7d,0xd3,
95 };
96
97static unsigned char out_p[]={
98 0x8d,0xf2,0xa4,0x94,0x49,0x22,0x76,0xaa,
99 0x3d,0x25,0x75,0x9b,0xb0,0x68,0x69,0xcb,
100 0xea,0xc0,0xd8,0x3a,0xfb,0x8d,0x0c,0xf7,
101 0xcb,0xb8,0x32,0x4f,0x0d,0x78,0x82,0xe5,
102 0xd0,0x76,0x2f,0xc5,0xb7,0x21,0x0e,0xaf,
103 0xc2,0xe9,0xad,0xac,0x32,0xab,0x7a,0xac,
104 0x49,0x69,0x3d,0xfb,0xf8,0x37,0x24,0xc2,
105 0xec,0x07,0x36,0xee,0x31,0xc8,0x02,0x91,
106 };
107
108static unsigned char out_q[]={
109 0xc7,0x73,0x21,0x8c,0x73,0x7e,0xc8,0xee,
110 0x99,0x3b,0x4f,0x2d,0xed,0x30,0xf4,0x8e,
111 0xda,0xce,0x91,0x5f,
112 };
113
114static unsigned char out_g[]={
115 0x62,0x6d,0x02,0x78,0x39,0xea,0x0a,0x13,
116 0x41,0x31,0x63,0xa5,0x5b,0x4c,0xb5,0x00,
117 0x29,0x9d,0x55,0x22,0x95,0x6c,0xef,0xcb,
118 0x3b,0xff,0x10,0xf3,0x99,0xce,0x2c,0x2e,
119 0x71,0xcb,0x9d,0xe5,0xfa,0x24,0xba,0xbf,
120 0x58,0xe5,0xb7,0x95,0x21,0x92,0x5c,0x9c,
121 0xc4,0x2e,0x9f,0x6f,0x46,0x4b,0x08,0x8c,
122 0xc5,0x72,0xaf,0x53,0xe6,0xd7,0x88,0x02,
123 };
124
125static const unsigned char str1[]="12345678901234567890";
126
127static const char rnd_seed[] = "string to make the random number generator think it has entropy";
128
129static BIO *bio_err=NULL;
130
131int main(int argc, char **argv)
132 {
133 DSA *dsa=NULL;
134 int counter,ret=0,i,j;
135 unsigned char buf[256];
136 unsigned long h;
137 unsigned char sig[256];
138 unsigned int siglen;
139
140 if (bio_err == NULL)
141 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
142
143 CRYPTO_malloc_debug_init();
144 CRYPTO_dbg_set_options(V_CRYPTO_MDEBUG_ALL);
145 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
146
147 ERR_load_crypto_strings();
148 RAND_seed(rnd_seed, sizeof rnd_seed);
149
150 BIO_printf(bio_err,"test generation of DSA parameters\n");
151
152 dsa=DSA_generate_parameters(512,seed,20,&counter,&h,dsa_cb,bio_err);
153
154 BIO_printf(bio_err,"seed\n");
155 for (i=0; i<20; i+=4)
156 {
157 BIO_printf(bio_err,"%02X%02X%02X%02X ",
158 seed[i],seed[i+1],seed[i+2],seed[i+3]);
159 }
160 BIO_printf(bio_err,"\ncounter=%d h=%d\n",counter,h);
161
162 if (dsa == NULL) goto end;
163 DSA_print(bio_err,dsa,0);
164 if (counter != 105)
165 {
166 BIO_printf(bio_err,"counter should be 105\n");
167 goto end;
168 }
169 if (h != 2)
170 {
171 BIO_printf(bio_err,"h should be 2\n");
172 goto end;
173 }
174
175 i=BN_bn2bin(dsa->q,buf);
176 j=sizeof(out_q);
177 if ((i != j) || (memcmp(buf,out_q,i) != 0))
178 {
179 BIO_printf(bio_err,"q value is wrong\n");
180 goto end;
181 }
182
183 i=BN_bn2bin(dsa->p,buf);
184 j=sizeof(out_p);
185 if ((i != j) || (memcmp(buf,out_p,i) != 0))
186 {
187 BIO_printf(bio_err,"p value is wrong\n");
188 goto end;
189 }
190
191 i=BN_bn2bin(dsa->g,buf);
192 j=sizeof(out_g);
193 if ((i != j) || (memcmp(buf,out_g,i) != 0))
194 {
195 BIO_printf(bio_err,"g value is wrong\n");
196 goto end;
197 }
198 DSA_generate_key(dsa);
199 DSA_sign(0, str1, 20, sig, &siglen, dsa);
200 if (DSA_verify(0, str1, 20, sig, siglen, dsa) == 1)
201 ret=1;
202end:
203 if (!ret)
204 ERR_print_errors(bio_err);
205 if (dsa != NULL) DSA_free(dsa);
206 CRYPTO_cleanup_all_ex_data();
207 ERR_remove_state(0);
208 ERR_free_strings();
209 CRYPTO_mem_leaks(bio_err);
210 if (bio_err != NULL)
211 {
212 BIO_free(bio_err);
213 bio_err = NULL;
214 }
215 exit(!ret);
216 return(0);
217 }
218
219static void MS_CALLBACK dsa_cb(int p, int n, void *arg)
220 {
221 char c='*';
222 static int ok=0,num=0;
223
224 if (p == 0) { c='.'; num++; };
225 if (p == 1) c='+';
226 if (p == 2) { c='*'; ok++; }
227 if (p == 3) c='\n';
228 BIO_write(arg,&c,1);
229 (void)BIO_flush(arg);
230
231 if (!ok && (p == 0) && (num > 1))
232 {
233 BIO_printf((BIO *)arg,"error in dsatest\n");
234 exit(1);
235 }
236 }
237#endif
diff --git a/src/lib/libcrypto/dsa/fips186a.txt b/src/lib/libcrypto/dsa/fips186a.txt
new file mode 100644
index 0000000000..3a2e0a0d51
--- /dev/null
+++ b/src/lib/libcrypto/dsa/fips186a.txt
@@ -0,0 +1,122 @@
1The origional FIPE 180 used SHA-0 (FIPS 180) for its appendix 5
2examples. This is an updated version that uses SHA-1 (FIPS 180-1)
3supplied to me by Wei Dai
4--
5 APPENDIX 5. EXAMPLE OF THE DSA
6
7
8This appendix is for informational purposes only and is not required to meet
9the standard.
10
11Let L = 512 (size of p). The values in this example are expressed in
12hexadecimal notation. The p and q given here were generated by the prime
13generation standard described in appendix 2 using the 160-bit SEED:
14
15 d5014e4b 60ef2ba8 b6211b40 62ba3224 e0427dd3
16
17With this SEED, the algorithm found p and q when the counter was at 105.
18
19x was generated by the algorithm described in appendix 3, section 3.1, using
20the SHA to construct G (as in appendix 3, section 3.3) and a 160-bit XSEED:
21
22XSEED =
23
24 bd029bbe 7f51960b cf9edb2b 61f06f0f eb5a38b6
25
26t =
27 67452301 EFCDAB89 98BADCFE 10325476 C3D2E1F0
28
29x = G(t,XSEED) mod q
30
31k was generated by the algorithm described in appendix 3, section 3.2, using
32the SHA to construct G (as in appendix 3, section 3.3) and a 160-bit KSEED:
33
34KSEED =
35
36 687a66d9 0648f993 867e121f 4ddf9ddb 01205584
37
38t =
39 EFCDAB89 98BADCFE 10325476 C3D2E1F0 67452301
40
41k = G(t,KSEED) mod q
42
43Finally:
44
45h = 2
46
47p =
48 8df2a494 492276aa 3d25759b b06869cb eac0d83a fb8d0cf7
49 cbb8324f 0d7882e5 d0762fc5 b7210eaf c2e9adac 32ab7aac
50 49693dfb f83724c2 ec0736ee 31c80291
51
52
53q =
54 c773218c 737ec8ee 993b4f2d ed30f48e dace915f
55
56
57g =
58 626d0278 39ea0a13 413163a5 5b4cb500 299d5522 956cefcb
59 3bff10f3 99ce2c2e 71cb9de5 fa24babf 58e5b795 21925c9c
60 c42e9f6f 464b088c c572af53 e6d78802
61
62
63x =
64 2070b322 3dba372f de1c0ffc 7b2e3b49 8b260614
65
66
67k =
68 358dad57 1462710f 50e254cf 1a376b2b deaadfbf
69
70
71kinv =
72
73 0d516729 8202e49b 4116ac10 4fc3f415 ae52f917
74
75M = ASCII form of "abc" (See FIPS PUB 180-1, Appendix A)
76
77SHA(M) =
78
79 a9993e36 4706816a ba3e2571 7850c26c 9cd0d89d
80
81
82y =
83
84 19131871 d75b1612 a819f29d 78d1b0d7 346f7aa7 7bb62a85
85 9bfd6c56 75da9d21 2d3a36ef 1672ef66 0b8c7c25 5cc0ec74
86 858fba33 f44c0669 9630a76b 030ee333
87
88
89r =
90 8bac1ab6 6410435c b7181f95 b16ab97c 92b341c0
91
92s =
93 41e2345f 1f56df24 58f426d1 55b4ba2d b6dcd8c8
94
95
96w =
97 9df4ece5 826be95f ed406d41 b43edc0b 1c18841b
98
99
100u1 =
101 bf655bd0 46f0b35e c791b004 804afcbb 8ef7d69d
102
103
104u2 =
105 821a9263 12e97ade abcc8d08 2b527897 8a2df4b0
106
107
108gu1 mod p =
109
110 51b1bf86 7888e5f3 af6fb476 9dd016bc fe667a65 aafc2753
111 9063bd3d 2b138b4c e02cc0c0 2ec62bb6 7306c63e 4db95bbf
112 6f96662a 1987a21b e4ec1071 010b6069
113
114
115yu2 mod p =
116
117 8b510071 2957e950 50d6b8fd 376a668e 4b0d633c 1e46e665
118 5c611a72 e2b28483 be52c74d 4b30de61 a668966e dc307a67
119 c19441f4 22bf3c34 08aeba1f 0a4dbec7
120
121v =
122 8bac1ab6 6410435c b7181f95 b16ab97c 92b341c0
diff --git a/src/lib/libcrypto/dso/Makefile.ssl b/src/lib/libcrypto/dso/Makefile.ssl
new file mode 100644
index 0000000000..5a55125824
--- /dev/null
+++ b/src/lib/libcrypto/dso/Makefile.ssl
@@ -0,0 +1,142 @@
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/README b/src/lib/libcrypto/dso/README
new file mode 100644
index 0000000000..d0bc9a89fb
--- /dev/null
+++ b/src/lib/libcrypto/dso/README
@@ -0,0 +1,22 @@
1NOTES
2-----
3
4I've checked out HPUX (well, version 11 at least) and shl_t is
5a pointer type so it's safe to use in the way it has been in
6dso_dl.c. On the other hand, HPUX11 support dlfcn too and
7according to their man page, prefer developers to move to that.
8I'll leave Richard's changes there as I guess dso_dl is needed
9for HPUX10.20.
10
11There is now a callback scheme in place where filename conversion can
12(a) be turned off altogether through the use of the
13 DSO_FLAG_NO_NAME_TRANSLATION flag,
14(b) be handled by default using the default DSO_METHOD's converter
15(c) overriden per-DSO by setting the override callback
16(d) a mix of (b) and (c) - eg. implement an override callback that;
17 (i) checks if we're win32 (if(strstr(dso->meth->name, "win32")....)
18 and if so, convert "blah" into "blah32.dll" (the default is
19 otherwise to make it "blah.dll").
20 (ii) default to the normal behaviour - we're not on win32, eg.
21 finish with (return dso->meth->dso_name_converter(dso,NULL)).
22
diff --git a/src/lib/libcrypto/dso/dso_dl.c b/src/lib/libcrypto/dso/dso_dl.c
new file mode 100644
index 0000000000..195717e993
--- /dev/null
+++ b/src/lib/libcrypto/dso/dso_dl.c
@@ -0,0 +1,284 @@
1/* dso_dl.c */
2/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
3 * project 2000.
4 */
5/* ====================================================================
6 * Copyright (c) 2000 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 "cryptlib.h"
61#include <openssl/dso.h>
62
63#ifndef DSO_DL
64DSO_METHOD *DSO_METHOD_dl(void)
65 {
66 return NULL;
67 }
68#else
69
70#include <dl.h>
71
72/* Part of the hack in "dl_load" ... */
73#define DSO_MAX_TRANSLATED_SIZE 256
74
75static int dl_load(DSO *dso);
76static int dl_unload(DSO *dso);
77static void *dl_bind_var(DSO *dso, const char *symname);
78static DSO_FUNC_TYPE dl_bind_func(DSO *dso, const char *symname);
79#if 0
80static int dl_unbind_var(DSO *dso, char *symname, void *symptr);
81static int dl_unbind_func(DSO *dso, char *symname, DSO_FUNC_TYPE symptr);
82static int dl_init(DSO *dso);
83static int dl_finish(DSO *dso);
84static int dl_ctrl(DSO *dso, int cmd, long larg, void *parg);
85#endif
86static char *dl_name_converter(DSO *dso, const char *filename);
87
88static DSO_METHOD dso_meth_dl = {
89 "OpenSSL 'dl' shared library method",
90 dl_load,
91 dl_unload,
92 dl_bind_var,
93 dl_bind_func,
94/* For now, "unbind" doesn't exist */
95#if 0
96 NULL, /* unbind_var */
97 NULL, /* unbind_func */
98#endif
99 NULL, /* ctrl */
100 dl_name_converter,
101 NULL, /* init */
102 NULL /* finish */
103 };
104
105DSO_METHOD *DSO_METHOD_dl(void)
106 {
107 return(&dso_meth_dl);
108 }
109
110/* For this DSO_METHOD, our meth_data STACK will contain;
111 * (i) the handle (shl_t) returned from shl_load().
112 * NB: I checked on HPUX11 and shl_t is itself a pointer
113 * type so the cast is safe.
114 */
115
116static int dl_load(DSO *dso)
117 {
118 shl_t ptr = NULL;
119 /* We don't do any fancy retries or anything, just take the method's
120 * (or DSO's if it has the callback set) best translation of the
121 * platform-independant filename and try once with that. */
122 char *filename= DSO_convert_filename(dso, NULL);
123
124 if(filename == NULL)
125 {
126 DSOerr(DSO_F_DL_LOAD,DSO_R_NO_FILENAME);
127 goto err;
128 }
129 ptr = shl_load(filename, BIND_IMMEDIATE|DYNAMIC_PATH, NULL);
130 if(ptr == NULL)
131 {
132 DSOerr(DSO_F_DL_LOAD,DSO_R_LOAD_FAILED);
133 ERR_add_error_data(4, "filename(", filename, "): ",
134 strerror(errno));
135 goto err;
136 }
137 if(!sk_push(dso->meth_data, (char *)ptr))
138 {
139 DSOerr(DSO_F_DL_LOAD,DSO_R_STACK_ERROR);
140 goto err;
141 }
142 /* Success, stick the converted filename we've loaded under into the DSO
143 * (it also serves as the indicator that we are currently loaded). */
144 dso->loaded_filename = filename;
145 return(1);
146err:
147 /* Cleanup! */
148 if(filename != NULL)
149 OPENSSL_free(filename);
150 if(ptr != NULL)
151 shl_unload(ptr);
152 return(0);
153 }
154
155static int dl_unload(DSO *dso)
156 {
157 shl_t ptr;
158 if(dso == NULL)
159 {
160 DSOerr(DSO_F_DL_UNLOAD,ERR_R_PASSED_NULL_PARAMETER);
161 return(0);
162 }
163 if(sk_num(dso->meth_data) < 1)
164 return(1);
165 /* Is this statement legal? */
166 ptr = (shl_t)sk_pop(dso->meth_data);
167 if(ptr == NULL)
168 {
169 DSOerr(DSO_F_DL_UNLOAD,DSO_R_NULL_HANDLE);
170 /* Should push the value back onto the stack in
171 * case of a retry. */
172 sk_push(dso->meth_data, (char *)ptr);
173 return(0);
174 }
175 shl_unload(ptr);
176 return(1);
177 }
178
179static void *dl_bind_var(DSO *dso, const char *symname)
180 {
181 shl_t ptr;
182 void *sym;
183
184 if((dso == NULL) || (symname == NULL))
185 {
186 DSOerr(DSO_F_DL_BIND_VAR,ERR_R_PASSED_NULL_PARAMETER);
187 return(NULL);
188 }
189 if(sk_num(dso->meth_data) < 1)
190 {
191 DSOerr(DSO_F_DL_BIND_VAR,DSO_R_STACK_ERROR);
192 return(NULL);
193 }
194 ptr = (shl_t)sk_value(dso->meth_data, sk_num(dso->meth_data) - 1);
195 if(ptr == NULL)
196 {
197 DSOerr(DSO_F_DL_BIND_VAR,DSO_R_NULL_HANDLE);
198 return(NULL);
199 }
200 if (shl_findsym(&ptr, symname, TYPE_UNDEFINED, &sym) < 0)
201 {
202 DSOerr(DSO_F_DL_BIND_VAR,DSO_R_SYM_FAILURE);
203 ERR_add_error_data(4, "symname(", symname, "): ",
204 strerror(errno));
205 return(NULL);
206 }
207 return(sym);
208 }
209
210static DSO_FUNC_TYPE dl_bind_func(DSO *dso, const char *symname)
211 {
212 shl_t ptr;
213 void *sym;
214
215 if((dso == NULL) || (symname == NULL))
216 {
217 DSOerr(DSO_F_DL_BIND_FUNC,ERR_R_PASSED_NULL_PARAMETER);
218 return(NULL);
219 }
220 if(sk_num(dso->meth_data) < 1)
221 {
222 DSOerr(DSO_F_DL_BIND_FUNC,DSO_R_STACK_ERROR);
223 return(NULL);
224 }
225 ptr = (shl_t)sk_value(dso->meth_data, sk_num(dso->meth_data) - 1);
226 if(ptr == NULL)
227 {
228 DSOerr(DSO_F_DL_BIND_FUNC,DSO_R_NULL_HANDLE);
229 return(NULL);
230 }
231 if (shl_findsym(&ptr, symname, TYPE_UNDEFINED, &sym) < 0)
232 {
233 DSOerr(DSO_F_DL_BIND_FUNC,DSO_R_SYM_FAILURE);
234 ERR_add_error_data(4, "symname(", symname, "): ",
235 strerror(errno));
236 return(NULL);
237 }
238 return((DSO_FUNC_TYPE)sym);
239 }
240
241/* This function is identical to the one in dso_dlfcn.c, but as it is highly
242 * unlikely that both the "dl" *and* "dlfcn" variants are being compiled at the
243 * same time, there's no great duplicating the code. Figuring out an elegant
244 * way to share one copy of the code would be more difficult and would not
245 * leave the implementations independant. */
246#if defined(__hpux)
247static const char extension[] = ".sl";
248#else
249static const char extension[] = ".so";
250#endif
251static char *dl_name_converter(DSO *dso, const char *filename)
252 {
253 char *translated;
254 int len, rsize, transform;
255
256 len = strlen(filename);
257 rsize = len + 1;
258 transform = (strstr(filename, "/") == NULL);
259 {
260 /* We will convert this to "%s.s?" or "lib%s.s?" */
261 rsize += strlen(extension);/* The length of ".s?" */
262 if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0)
263 rsize += 3; /* The length of "lib" */
264 }
265 translated = OPENSSL_malloc(rsize);
266 if(translated == NULL)
267 {
268 DSOerr(DSO_F_DL_NAME_CONVERTER,
269 DSO_R_NAME_TRANSLATION_FAILED);
270 return(NULL);
271 }
272 if(transform)
273 {
274 if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0)
275 sprintf(translated, "lib%s%s", filename, extension);
276 else
277 sprintf(translated, "%s%s", filename, extension);
278 }
279 else
280 sprintf(translated, "%s", filename);
281 return(translated);
282 }
283
284#endif /* DSO_DL */
diff --git a/src/lib/libcrypto/dso/dso_lib.c b/src/lib/libcrypto/dso/dso_lib.c
index 556069b9b8..85ac5103cd 100644
--- a/src/lib/libcrypto/dso/dso_lib.c
+++ b/src/lib/libcrypto/dso/dso_lib.c
@@ -383,7 +383,7 @@ int DSO_set_filename(DSO *dso, const char *filename)
383 DSOerr(DSO_F_DSO_SET_FILENAME,ERR_R_MALLOC_FAILURE); 383 DSOerr(DSO_F_DSO_SET_FILENAME,ERR_R_MALLOC_FAILURE);
384 return(0); 384 return(0);
385 } 385 }
386 strcpy(copied, filename); 386 strlcpy(copied, filename, strlen(filename) + 1);
387 if(dso->filename) 387 if(dso->filename)
388 OPENSSL_free(dso->filename); 388 OPENSSL_free(dso->filename);
389 dso->filename = copied; 389 dso->filename = copied;
@@ -422,7 +422,7 @@ char *DSO_convert_filename(DSO *dso, const char *filename)
422 ERR_R_MALLOC_FAILURE); 422 ERR_R_MALLOC_FAILURE);
423 return(NULL); 423 return(NULL);
424 } 424 }
425 strcpy(result, filename); 425 strlcpy(result, filename, strlen(filename) + 1);
426 } 426 }
427 return(result); 427 return(result);
428 } 428 }
diff --git a/src/lib/libcrypto/dso/dso_vms.c b/src/lib/libcrypto/dso/dso_vms.c
new file mode 100644
index 0000000000..1674619d17
--- /dev/null
+++ b/src/lib/libcrypto/dso/dso_vms.c
@@ -0,0 +1,379 @@
1/* dso_vms.c */
2/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
3 * project 2000.
4 */
5/* ====================================================================
6 * Copyright (c) 2000 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 <string.h>
61#include <errno.h>
62#include "cryptlib.h"
63#include <openssl/dso.h>
64#ifdef OPENSSL_SYS_VMS
65#pragma message disable DOLLARID
66#include <lib$routines.h>
67#include <stsdef.h>
68#include <descrip.h>
69#include <starlet.h>
70#endif
71
72#ifndef OPENSSL_SYS_VMS
73DSO_METHOD *DSO_METHOD_vms(void)
74 {
75 return NULL;
76 }
77#else
78#pragma message disable DOLLARID
79
80static int vms_load(DSO *dso);
81static int vms_unload(DSO *dso);
82static void *vms_bind_var(DSO *dso, const char *symname);
83static DSO_FUNC_TYPE vms_bind_func(DSO *dso, const char *symname);
84#if 0
85static int vms_unbind_var(DSO *dso, char *symname, void *symptr);
86static int vms_unbind_func(DSO *dso, char *symname, DSO_FUNC_TYPE symptr);
87static int vms_init(DSO *dso);
88static int vms_finish(DSO *dso);
89static long vms_ctrl(DSO *dso, int cmd, long larg, void *parg);
90#endif
91static char *vms_name_converter(DSO *dso, const char *filename);
92
93static DSO_METHOD dso_meth_vms = {
94 "OpenSSL 'VMS' shared library method",
95 vms_load,
96 NULL, /* unload */
97 vms_bind_var,
98 vms_bind_func,
99/* For now, "unbind" doesn't exist */
100#if 0
101 NULL, /* unbind_var */
102 NULL, /* unbind_func */
103#endif
104 NULL, /* ctrl */
105 vms_name_converter,
106 NULL, /* init */
107 NULL /* finish */
108 };
109
110/* On VMS, the only "handle" is the file name. LIB$FIND_IMAGE_SYMBOL depends
111 * on the reference to the file name being the same for all calls regarding
112 * one shared image, so we'll just store it in an instance of the following
113 * structure and put a pointer to that instance in the meth_data stack.
114 */
115typedef struct dso_internal_st
116 {
117 /* This should contain the name only, no directory,
118 * no extension, nothing but a name. */
119 struct dsc$descriptor_s filename_dsc;
120 char filename[FILENAME_MAX+1];
121 /* This contains whatever is not in filename, if needed.
122 * Normally not defined. */
123 struct dsc$descriptor_s imagename_dsc;
124 char imagename[FILENAME_MAX+1];
125 } DSO_VMS_INTERNAL;
126
127
128DSO_METHOD *DSO_METHOD_vms(void)
129 {
130 return(&dso_meth_vms);
131 }
132
133static int vms_load(DSO *dso)
134 {
135 void *ptr = NULL;
136 /* See applicable comments in dso_dl.c */
137 char *filename = DSO_convert_filename(dso, NULL);
138 DSO_VMS_INTERNAL *p;
139 const char *sp1, *sp2; /* Search result */
140
141 if(filename == NULL)
142 {
143 DSOerr(DSO_F_DLFCN_LOAD,DSO_R_NO_FILENAME);
144 goto err;
145 }
146
147 /* A file specification may look like this:
148 *
149 * node::dev:[dir-spec]name.type;ver
150 *
151 * or (for compatibility with TOPS-20):
152 *
153 * node::dev:<dir-spec>name.type;ver
154 *
155 * and the dir-spec uses '.' as separator. Also, a dir-spec
156 * may consist of several parts, with mixed use of [] and <>:
157 *
158 * [dir1.]<dir2>
159 *
160 * We need to split the file specification into the name and
161 * the rest (both before and after the name itself).
162 */
163 /* Start with trying to find the end of a dir-spec, and save the
164 position of the byte after in sp1 */
165 sp1 = strrchr(filename, ']');
166 sp2 = strrchr(filename, '>');
167 if (sp1 == NULL) sp1 = sp2;
168 if (sp2 != NULL && sp2 > sp1) sp1 = sp2;
169 if (sp1 == NULL) sp1 = strrchr(filename, ':');
170 if (sp1 == NULL)
171 sp1 = filename;
172 else
173 sp1++; /* The byte after the found character */
174 /* Now, let's see if there's a type, and save the position in sp2 */
175 sp2 = strchr(sp1, '.');
176 /* If we found it, that's where we'll cut. Otherwise, look for a
177 version number and save the position in sp2 */
178 if (sp2 == NULL) sp2 = strchr(sp1, ';');
179 /* If there was still nothing to find, set sp2 to point at the end of
180 the string */
181 if (sp2 == NULL) sp2 = sp1 + strlen(sp1);
182
183 /* Check that we won't get buffer overflows */
184 if (sp2 - sp1 > FILENAME_MAX
185 || (sp1 - filename) + strlen(sp2) > FILENAME_MAX)
186 {
187 DSOerr(DSO_F_VMS_LOAD,DSO_R_FILENAME_TOO_BIG);
188 goto err;
189 }
190
191 p = (DSO_VMS_INTERNAL *)OPENSSL_malloc(sizeof(DSO_VMS_INTERNAL));
192 if(p == NULL)
193 {
194 DSOerr(DSO_F_VMS_LOAD,ERR_R_MALLOC_FAILURE);
195 goto err;
196 }
197
198 strncpy(p->filename, sp1, sp2-sp1);
199 p->filename[sp2-sp1] = '\0';
200
201 strncpy(p->imagename, filename, sp1-filename);
202 p->imagename[sp1-filename] = '\0';
203 strcat(p->imagename, sp2);
204
205 p->filename_dsc.dsc$w_length = strlen(p->filename);
206 p->filename_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
207 p->filename_dsc.dsc$b_class = DSC$K_CLASS_S;
208 p->filename_dsc.dsc$a_pointer = p->filename;
209 p->imagename_dsc.dsc$w_length = strlen(p->imagename);
210 p->imagename_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
211 p->imagename_dsc.dsc$b_class = DSC$K_CLASS_S;
212 p->imagename_dsc.dsc$a_pointer = p->imagename;
213
214 if(!sk_push(dso->meth_data, (char *)p))
215 {
216 DSOerr(DSO_F_VMS_LOAD,DSO_R_STACK_ERROR);
217 goto err;
218 }
219
220 /* Success (for now, we lie. We actually do not know...) */
221 dso->loaded_filename = filename;
222 return(1);
223err:
224 /* Cleanup! */
225 if(p != NULL)
226 OPENSSL_free(p);
227 if(filename != NULL)
228 OPENSSL_free(filename);
229 return(0);
230 }
231
232/* Note that this doesn't actually unload the shared image, as there is no
233 * such thing in VMS. Next time it get loaded again, a new copy will
234 * actually be loaded.
235 */
236static int vms_unload(DSO *dso)
237 {
238 DSO_VMS_INTERNAL *p;
239 if(dso == NULL)
240 {
241 DSOerr(DSO_F_VMS_UNLOAD,ERR_R_PASSED_NULL_PARAMETER);
242 return(0);
243 }
244 if(sk_num(dso->meth_data) < 1)
245 return(1);
246 p = (DSO_VMS_INTERNAL *)sk_pop(dso->meth_data);
247 if(p == NULL)
248 {
249 DSOerr(DSO_F_VMS_UNLOAD,DSO_R_NULL_HANDLE);
250 return(0);
251 }
252 /* Cleanup */
253 OPENSSL_free(p);
254 return(1);
255 }
256
257/* We must do this in a separate function because of the way the exception
258 handler works (it makes this function return */
259static int do_find_symbol(DSO_VMS_INTERNAL *ptr,
260 struct dsc$descriptor_s *symname_dsc, void **sym,
261 unsigned long flags)
262 {
263 /* Make sure that signals are caught and returned instead of
264 aborting the program. The exception handler gets unestablished
265 automatically on return from this function. */
266 lib$establish(lib$sig_to_ret);
267
268 if(ptr->imagename_dsc.dsc$w_length)
269 return lib$find_image_symbol(&ptr->filename_dsc,
270 symname_dsc, sym,
271 &ptr->imagename_dsc, flags);
272 else
273 return lib$find_image_symbol(&ptr->filename_dsc,
274 symname_dsc, sym,
275 0, flags);
276 }
277
278void vms_bind_sym(DSO *dso, const char *symname, void **sym)
279 {
280 DSO_VMS_INTERNAL *ptr;
281 int status;
282#if 0
283 int flags = (1<<4); /* LIB$M_FIS_MIXEDCASE, but this symbol isn't
284 defined in VMS older than 7.0 or so */
285#else
286 int flags = 0;
287#endif
288 struct dsc$descriptor_s symname_dsc;
289 *sym = NULL;
290
291 symname_dsc.dsc$w_length = strlen(symname);
292 symname_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
293 symname_dsc.dsc$b_class = DSC$K_CLASS_S;
294 symname_dsc.dsc$a_pointer = (char *)symname; /* The cast is needed */
295
296 if((dso == NULL) || (symname == NULL))
297 {
298 DSOerr(DSO_F_VMS_BIND_VAR,ERR_R_PASSED_NULL_PARAMETER);
299 return;
300 }
301 if(sk_num(dso->meth_data) < 1)
302 {
303 DSOerr(DSO_F_VMS_BIND_VAR,DSO_R_STACK_ERROR);
304 return;
305 }
306 ptr = (DSO_VMS_INTERNAL *)sk_value(dso->meth_data,
307 sk_num(dso->meth_data) - 1);
308 if(ptr == NULL)
309 {
310 DSOerr(DSO_F_VMS_BIND_VAR,DSO_R_NULL_HANDLE);
311 return;
312 }
313
314 if(dso->flags & DSO_FLAG_UPCASE_SYMBOL) flags = 0;
315
316 status = do_find_symbol(ptr, &symname_dsc, sym, flags);
317
318 if(!$VMS_STATUS_SUCCESS(status))
319 {
320 unsigned short length;
321 char errstring[257];
322 struct dsc$descriptor_s errstring_dsc;
323
324 errstring_dsc.dsc$w_length = sizeof(errstring);
325 errstring_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
326 errstring_dsc.dsc$b_class = DSC$K_CLASS_S;
327 errstring_dsc.dsc$a_pointer = errstring;
328
329 *sym = NULL;
330
331 status = sys$getmsg(status, &length, &errstring_dsc, 1, 0);
332
333 if (!$VMS_STATUS_SUCCESS(status))
334 lib$signal(status); /* This is really bad. Abort! */
335 else
336 {
337 errstring[length] = '\0';
338
339 DSOerr(DSO_F_VMS_BIND_VAR,DSO_R_SYM_FAILURE);
340 if (ptr->imagename_dsc.dsc$w_length)
341 ERR_add_error_data(9,
342 "Symbol ", symname,
343 " in ", ptr->filename,
344 " (", ptr->imagename, ")",
345 ": ", errstring);
346 else
347 ERR_add_error_data(6,
348 "Symbol ", symname,
349 " in ", ptr->filename,
350 ": ", errstring);
351 }
352 return;
353 }
354 return;
355 }
356
357static void *vms_bind_var(DSO *dso, const char *symname)
358 {
359 void *sym = 0;
360 vms_bind_sym(dso, symname, &sym);
361 return sym;
362 }
363
364static DSO_FUNC_TYPE vms_bind_func(DSO *dso, const char *symname)
365 {
366 DSO_FUNC_TYPE sym = 0;
367 vms_bind_sym(dso, symname, (void **)&sym);
368 return sym;
369 }
370
371static char *vms_name_converter(DSO *dso, const char *filename)
372 {
373 int len = strlen(filename);
374 char *not_translated = OPENSSL_malloc(len+1);
375 strcpy(not_translated,filename);
376 return(not_translated);
377 }
378
379#endif /* OPENSSL_SYS_VMS */
diff --git a/src/lib/libcrypto/dso/dso_win32.c b/src/lib/libcrypto/dso/dso_win32.c
new file mode 100644
index 0000000000..af8586d754
--- /dev/null
+++ b/src/lib/libcrypto/dso/dso_win32.c
@@ -0,0 +1,279 @@
1/* dso_win32.c */
2/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL
3 * project 2000.
4 */
5/* ====================================================================
6 * Copyright (c) 2000 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 <string.h>
61#include "cryptlib.h"
62#include <openssl/dso.h>
63
64#ifndef OPENSSL_SYS_WIN32
65DSO_METHOD *DSO_METHOD_win32(void)
66 {
67 return NULL;
68 }
69#else
70
71/* Part of the hack in "win32_load" ... */
72#define DSO_MAX_TRANSLATED_SIZE 256
73
74static int win32_load(DSO *dso);
75static int win32_unload(DSO *dso);
76static void *win32_bind_var(DSO *dso, const char *symname);
77static DSO_FUNC_TYPE win32_bind_func(DSO *dso, const char *symname);
78#if 0
79static int win32_unbind_var(DSO *dso, char *symname, void *symptr);
80static int win32_unbind_func(DSO *dso, char *symname, DSO_FUNC_TYPE symptr);
81static int win32_init(DSO *dso);
82static int win32_finish(DSO *dso);
83static long win32_ctrl(DSO *dso, int cmd, long larg, void *parg);
84#endif
85static char *win32_name_converter(DSO *dso, const char *filename);
86
87static DSO_METHOD dso_meth_win32 = {
88 "OpenSSL 'win32' shared library method",
89 win32_load,
90 win32_unload,
91 win32_bind_var,
92 win32_bind_func,
93/* For now, "unbind" doesn't exist */
94#if 0
95 NULL, /* unbind_var */
96 NULL, /* unbind_func */
97#endif
98 NULL, /* ctrl */
99 win32_name_converter,
100 NULL, /* init */
101 NULL /* finish */
102 };
103
104DSO_METHOD *DSO_METHOD_win32(void)
105 {
106 return(&dso_meth_win32);
107 }
108
109/* For this DSO_METHOD, our meth_data STACK will contain;
110 * (i) a pointer to the handle (HINSTANCE) returned from
111 * LoadLibrary(), and copied.
112 */
113
114static int win32_load(DSO *dso)
115 {
116 HINSTANCE h = NULL, *p = NULL;
117 /* See applicable comments from dso_dl.c */
118 char *filename = DSO_convert_filename(dso, NULL);
119
120 if(filename == NULL)
121 {
122 DSOerr(DSO_F_WIN32_LOAD,DSO_R_NO_FILENAME);
123 goto err;
124 }
125 h = LoadLibrary(filename);
126 if(h == NULL)
127 {
128 DSOerr(DSO_F_WIN32_LOAD,DSO_R_LOAD_FAILED);
129 ERR_add_error_data(3, "filename(", filename, ")");
130 goto err;
131 }
132 p = (HINSTANCE *)OPENSSL_malloc(sizeof(HINSTANCE));
133 if(p == NULL)
134 {
135 DSOerr(DSO_F_WIN32_LOAD,ERR_R_MALLOC_FAILURE);
136 goto err;
137 }
138 *p = h;
139 if(!sk_push(dso->meth_data, (char *)p))
140 {
141 DSOerr(DSO_F_WIN32_LOAD,DSO_R_STACK_ERROR);
142 goto err;
143 }
144 /* Success */
145 dso->loaded_filename = filename;
146 return(1);
147err:
148 /* Cleanup !*/
149 if(filename != NULL)
150 OPENSSL_free(filename);
151 if(p != NULL)
152 OPENSSL_free(p);
153 if(h != NULL)
154 FreeLibrary(h);
155 return(0);
156 }
157
158static int win32_unload(DSO *dso)
159 {
160 HINSTANCE *p;
161 if(dso == NULL)
162 {
163 DSOerr(DSO_F_WIN32_UNLOAD,ERR_R_PASSED_NULL_PARAMETER);
164 return(0);
165 }
166 if(sk_num(dso->meth_data) < 1)
167 return(1);
168 p = (HINSTANCE *)sk_pop(dso->meth_data);
169 if(p == NULL)
170 {
171 DSOerr(DSO_F_WIN32_UNLOAD,DSO_R_NULL_HANDLE);
172 return(0);
173 }
174 if(!FreeLibrary(*p))
175 {
176 DSOerr(DSO_F_WIN32_UNLOAD,DSO_R_UNLOAD_FAILED);
177 /* We should push the value back onto the stack in
178 * case of a retry. */
179 sk_push(dso->meth_data, (char *)p);
180 return(0);
181 }
182 /* Cleanup */
183 OPENSSL_free(p);
184 return(1);
185 }
186
187/* Using GetProcAddress for variables? TODO: Check this out in
188 * the Win32 API docs, there's probably a variant for variables. */
189static void *win32_bind_var(DSO *dso, const char *symname)
190 {
191 HINSTANCE *ptr;
192 void *sym;
193
194 if((dso == NULL) || (symname == NULL))
195 {
196 DSOerr(DSO_F_WIN32_BIND_VAR,ERR_R_PASSED_NULL_PARAMETER);
197 return(NULL);
198 }
199 if(sk_num(dso->meth_data) < 1)
200 {
201 DSOerr(DSO_F_WIN32_BIND_VAR,DSO_R_STACK_ERROR);
202 return(NULL);
203 }
204 ptr = (HINSTANCE *)sk_value(dso->meth_data, sk_num(dso->meth_data) - 1);
205 if(ptr == NULL)
206 {
207 DSOerr(DSO_F_WIN32_BIND_VAR,DSO_R_NULL_HANDLE);
208 return(NULL);
209 }
210 sym = GetProcAddress(*ptr, symname);
211 if(sym == NULL)
212 {
213 DSOerr(DSO_F_WIN32_BIND_VAR,DSO_R_SYM_FAILURE);
214 ERR_add_error_data(3, "symname(", symname, ")");
215 return(NULL);
216 }
217 return(sym);
218 }
219
220static DSO_FUNC_TYPE win32_bind_func(DSO *dso, const char *symname)
221 {
222 HINSTANCE *ptr;
223 void *sym;
224
225 if((dso == NULL) || (symname == NULL))
226 {
227 DSOerr(DSO_F_WIN32_BIND_FUNC,ERR_R_PASSED_NULL_PARAMETER);
228 return(NULL);
229 }
230 if(sk_num(dso->meth_data) < 1)
231 {
232 DSOerr(DSO_F_WIN32_BIND_FUNC,DSO_R_STACK_ERROR);
233 return(NULL);
234 }
235 ptr = (HINSTANCE *)sk_value(dso->meth_data, sk_num(dso->meth_data) - 1);
236 if(ptr == NULL)
237 {
238 DSOerr(DSO_F_WIN32_BIND_FUNC,DSO_R_NULL_HANDLE);
239 return(NULL);
240 }
241 sym = GetProcAddress(*ptr, symname);
242 if(sym == NULL)
243 {
244 DSOerr(DSO_F_WIN32_BIND_FUNC,DSO_R_SYM_FAILURE);
245 ERR_add_error_data(3, "symname(", symname, ")");
246 return(NULL);
247 }
248 return((DSO_FUNC_TYPE)sym);
249 }
250
251static char *win32_name_converter(DSO *dso, const char *filename)
252 {
253 char *translated;
254 int len, transform;
255
256 len = strlen(filename);
257 transform = ((strstr(filename, "/") == NULL) &&
258 (strstr(filename, "\\") == NULL) &&
259 (strstr(filename, ":") == NULL));
260 if(transform)
261 /* We will convert this to "%s.dll" */
262 translated = OPENSSL_malloc(len + 5);
263 else
264 /* We will simply duplicate filename */
265 translated = OPENSSL_malloc(len + 1);
266 if(translated == NULL)
267 {
268 DSOerr(DSO_F_WIN32_NAME_CONVERTER,
269 DSO_R_NAME_TRANSLATION_FAILED);
270 return(NULL);
271 }
272 if(transform)
273 sprintf(translated, "%s.dll", filename);
274 else
275 sprintf(translated, "%s", filename);
276 return(translated);
277 }
278
279#endif /* OPENSSL_SYS_WIN32 */
diff --git a/src/lib/libcrypto/ebcdic.c b/src/lib/libcrypto/ebcdic.c
new file mode 100644
index 0000000000..d1bece87f7
--- /dev/null
+++ b/src/lib/libcrypto/ebcdic.c
@@ -0,0 +1,218 @@
1/* crypto/ebcdic.c */
2
3#ifdef CHARSET_EBCDIC
4#include "ebcdic.h"
5/* Initial Port for Apache-1.3 by <Martin.Kraemer@Mch.SNI.De>
6 * Adapted for OpenSSL-0.9.4 by <Martin.Kraemer@Mch.SNI.De>
7 */
8
9#ifdef _OSD_POSIX
10/*
11 "BS2000 OSD" is a POSIX subsystem on a main frame.
12 It is made by Siemens AG, Germany, for their BS2000 mainframe machines.
13 Within the POSIX subsystem, the same character set was chosen as in
14 "native BS2000", namely EBCDIC. (EDF04)
15
16 The name "ASCII" in these routines is misleading: actually, conversion
17 is not between EBCDIC and ASCII, but EBCDIC(EDF04) and ISO-8859.1;
18 that means that (western european) national characters are preserved.
19
20 This table is identical to the one used by rsh/rcp/ftp and other POSIX tools.
21*/
22
23/* Here's the bijective ebcdic-to-ascii table: */
24const unsigned char os_toascii[256] = {
25/*00*/ 0x00, 0x01, 0x02, 0x03, 0x85, 0x09, 0x86, 0x7f,
26 0x87, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /*................*/
27/*10*/ 0x10, 0x11, 0x12, 0x13, 0x8f, 0x0a, 0x08, 0x97,
28 0x18, 0x19, 0x9c, 0x9d, 0x1c, 0x1d, 0x1e, 0x1f, /*................*/
29/*20*/ 0x80, 0x81, 0x82, 0x83, 0x84, 0x92, 0x17, 0x1b,
30 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07, /*................*/
31/*30*/ 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04,
32 0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a, /*................*/
33/*40*/ 0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5,
34 0xe7, 0xf1, 0x60, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, /* .........`.<(+|*/
35/*50*/ 0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef,
36 0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x9f, /*&.........!$*);.*/
37/*60*/ 0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5,
38 0xc7, 0xd1, 0x5e, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, /*-/........^,%_>?*/
39/*70*/ 0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf,
40 0xcc, 0xa8, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, /*..........:#@'="*/
41/*80*/ 0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
42 0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1, /*.abcdefghi......*/
43/*90*/ 0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
44 0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4, /*.jklmnopqr......*/
45/*a0*/ 0xb5, 0xaf, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
46 0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0xdd, 0xde, 0xae, /*..stuvwxyz......*/
47/*b0*/ 0xa2, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc,
48 0xbd, 0xbe, 0xac, 0x5b, 0x5c, 0x5d, 0xb4, 0xd7, /*...........[\]..*/
49/*c0*/ 0xf9, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
50 0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5, /*.ABCDEFGHI......*/
51/*d0*/ 0xa6, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
52 0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xdb, 0xfa, 0xff, /*.JKLMNOPQR......*/
53/*e0*/ 0xd9, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
54 0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5, /*..STUVWXYZ......*/
55/*f0*/ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
56 0x38, 0x39, 0xb3, 0x7b, 0xdc, 0x7d, 0xda, 0x7e /*0123456789.{.}.~*/
57};
58
59
60/* The ascii-to-ebcdic table: */
61const unsigned char os_toebcdic[256] = {
62/*00*/ 0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f,
63 0x16, 0x05, 0x15, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /*................*/
64/*10*/ 0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26,
65 0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f, /*................*/
66/*20*/ 0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d,
67 0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61, /* !"#$%&'()*+,-./ */
68/*30*/ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
69 0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f, /*0123456789:;<=>?*/
70/*40*/ 0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
71 0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, /*@ABCDEFGHIJKLMNO*/
72/*50*/ 0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6,
73 0xe7, 0xe8, 0xe9, 0xbb, 0xbc, 0xbd, 0x6a, 0x6d, /*PQRSTUVWXYZ[\]^_*/
74/*60*/ 0x4a, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
75 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, /*`abcdefghijklmno*/
76/*70*/ 0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6,
77 0xa7, 0xa8, 0xa9, 0xfb, 0x4f, 0xfd, 0xff, 0x07, /*pqrstuvwxyz{|}~.*/
78/*80*/ 0x20, 0x21, 0x22, 0x23, 0x24, 0x04, 0x06, 0x08,
79 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x14, /*................*/
80/*90*/ 0x30, 0x31, 0x25, 0x33, 0x34, 0x35, 0x36, 0x17,
81 0x38, 0x39, 0x3a, 0x3b, 0x1a, 0x1b, 0x3e, 0x5f, /*................*/
82/*a0*/ 0x41, 0xaa, 0xb0, 0xb1, 0x9f, 0xb2, 0xd0, 0xb5,
83 0x79, 0xb4, 0x9a, 0x8a, 0xba, 0xca, 0xaf, 0xa1, /*................*/
84/*b0*/ 0x90, 0x8f, 0xea, 0xfa, 0xbe, 0xa0, 0xb6, 0xb3,
85 0x9d, 0xda, 0x9b, 0x8b, 0xb7, 0xb8, 0xb9, 0xab, /*................*/
86/*c0*/ 0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9e, 0x68,
87 0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77, /*................*/
88/*d0*/ 0xac, 0x69, 0xed, 0xee, 0xeb, 0xef, 0xec, 0xbf,
89 0x80, 0xe0, 0xfe, 0xdd, 0xfc, 0xad, 0xae, 0x59, /*................*/
90/*e0*/ 0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9c, 0x48,
91 0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, /*................*/
92/*f0*/ 0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1,
93 0x70, 0xc0, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf /*................*/
94};
95
96#else /*_OSD_POSIX*/
97
98/*
99This code does basic character mapping for IBM's TPF and OS/390 operating systems.
100It is a modified version of the BS2000 table.
101
102Bijective EBCDIC (character set IBM-1047) to US-ASCII table:
103This table is bijective - there are no ambigous or duplicate characters.
104*/
105const unsigned char os_toascii[256] = {
106 0x00, 0x01, 0x02, 0x03, 0x85, 0x09, 0x86, 0x7f, /* 00-0f: */
107 0x87, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* ................ */
108 0x10, 0x11, 0x12, 0x13, 0x8f, 0x0a, 0x08, 0x97, /* 10-1f: */
109 0x18, 0x19, 0x9c, 0x9d, 0x1c, 0x1d, 0x1e, 0x1f, /* ................ */
110 0x80, 0x81, 0x82, 0x83, 0x84, 0x92, 0x17, 0x1b, /* 20-2f: */
111 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07, /* ................ */
112 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04, /* 30-3f: */
113 0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a, /* ................ */
114 0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5, /* 40-4f: */
115 0xe7, 0xf1, 0xa2, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, /* ...........<(+| */
116 0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef, /* 50-5f: */
117 0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x5e, /* &.........!$*);^ */
118 0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5, /* 60-6f: */
119 0xc7, 0xd1, 0xa6, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, /* -/.........,%_>? */
120 0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf, /* 70-7f: */
121 0xcc, 0x60, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, /* .........`:#@'=" */
122 0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 80-8f: */
123 0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1, /* .abcdefghi...... */
124 0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, /* 90-9f: */
125 0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4, /* .jklmnopqr...... */
126 0xb5, 0x7e, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, /* a0-af: */
127 0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0x5b, 0xde, 0xae, /* .~stuvwxyz...[.. */
128 0xac, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc, /* b0-bf: */
129 0xbd, 0xbe, 0xdd, 0xa8, 0xaf, 0x5d, 0xb4, 0xd7, /* .............].. */
130 0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* c0-cf: */
131 0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5, /* {ABCDEFGHI...... */
132 0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, /* d0-df: */
133 0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xf9, 0xfa, 0xff, /* }JKLMNOPQR...... */
134 0x5c, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* e0-ef: */
135 0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5, /* \.STUVWXYZ...... */
136 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* f0-ff: */
137 0x38, 0x39, 0xb3, 0xdb, 0xdc, 0xd9, 0xda, 0x9f /* 0123456789...... */
138};
139
140
141/*
142The US-ASCII to EBCDIC (character set IBM-1047) table:
143This table is bijective (no ambiguous or duplicate characters)
144*/
145const unsigned char os_toebcdic[256] = {
146 0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f, /* 00-0f: */
147 0x16, 0x05, 0x15, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* ................ */
148 0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26, /* 10-1f: */
149 0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f, /* ................ */
150 0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d, /* 20-2f: */
151 0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61, /* !"#$%&'()*+,-./ */
152 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 30-3f: */
153 0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f, /* 0123456789:;<=>? */
154 0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 40-4f: */
155 0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, /* @ABCDEFGHIJKLMNO */
156 0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, /* 50-5f: */
157 0xe7, 0xe8, 0xe9, 0xad, 0xe0, 0xbd, 0x5f, 0x6d, /* PQRSTUVWXYZ[\]^_ */
158 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 60-6f: */
159 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, /* `abcdefghijklmno */
160 0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, /* 70-7f: */
161 0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0xa1, 0x07, /* pqrstuvwxyz{|}~. */
162 0x20, 0x21, 0x22, 0x23, 0x24, 0x04, 0x06, 0x08, /* 80-8f: */
163 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x14, /* ................ */
164 0x30, 0x31, 0x25, 0x33, 0x34, 0x35, 0x36, 0x17, /* 90-9f: */
165 0x38, 0x39, 0x3a, 0x3b, 0x1a, 0x1b, 0x3e, 0xff, /* ................ */
166 0x41, 0xaa, 0x4a, 0xb1, 0x9f, 0xb2, 0x6a, 0xb5, /* a0-af: */
167 0xbb, 0xb4, 0x9a, 0x8a, 0xb0, 0xca, 0xaf, 0xbc, /* ................ */
168 0x90, 0x8f, 0xea, 0xfa, 0xbe, 0xa0, 0xb6, 0xb3, /* b0-bf: */
169 0x9d, 0xda, 0x9b, 0x8b, 0xb7, 0xb8, 0xb9, 0xab, /* ................ */
170 0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9e, 0x68, /* c0-cf: */
171 0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77, /* ................ */
172 0xac, 0x69, 0xed, 0xee, 0xeb, 0xef, 0xec, 0xbf, /* d0-df: */
173 0x80, 0xfd, 0xfe, 0xfb, 0xfc, 0xba, 0xae, 0x59, /* ................ */
174 0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9c, 0x48, /* e0-ef: */
175 0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, /* ................ */
176 0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1, /* f0-ff: */
177 0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf /* ................ */
178};
179#endif /*_OSD_POSIX*/
180
181/* Translate a memory block from EBCDIC (host charset) to ASCII (net charset)
182 * dest and srce may be identical, or separate memory blocks, but
183 * should not overlap. These functions intentionally have an interface
184 * compatible to memcpy(3).
185 */
186
187void *
188ebcdic2ascii(void *dest, const void *srce, size_t count)
189{
190 unsigned char *udest = dest;
191 const unsigned char *usrce = srce;
192
193 while (count-- != 0) {
194 *udest++ = os_toascii[*usrce++];
195 }
196
197 return dest;
198}
199
200void *
201ascii2ebcdic(void *dest, const void *srce, size_t count)
202{
203 unsigned char *udest = dest;
204 const unsigned char *usrce = srce;
205
206 while (count-- != 0) {
207 *udest++ = os_toebcdic[*usrce++];
208 }
209
210 return dest;
211}
212
213#else /*CHARSET_EBCDIC*/
214#include <openssl/e_os2.h>
215#if defined(PEDANTIC) || defined(__DECC) || defined(OPENSSL_SYS_MACOSX)
216static void *dummy=&dummy;
217#endif
218#endif
diff --git a/src/lib/libcrypto/ebcdic.h b/src/lib/libcrypto/ebcdic.h
new file mode 100644
index 0000000000..6d65afcf9e
--- /dev/null
+++ b/src/lib/libcrypto/ebcdic.h
@@ -0,0 +1,19 @@
1/* crypto/ebcdic.h */
2
3#ifndef HEADER_EBCDIC_H
4#define HEADER_EBCDIC_H
5
6#include <sys/types.h>
7
8/* Avoid name clashes with other applications */
9#define os_toascii _openssl_os_toascii
10#define os_toebcdic _openssl_os_toebcdic
11#define ebcdic2ascii _openssl_ebcdic2ascii
12#define ascii2ebcdic _openssl_ascii2ebcdic
13
14extern const unsigned char os_toascii[256];
15extern const unsigned char os_toebcdic[256];
16void *ebcdic2ascii(void *dest, const void *srce, size_t count);
17void *ascii2ebcdic(void *dest, const void *srce, size_t count);
18
19#endif
diff --git a/src/lib/libcrypto/ec/Makefile.ssl b/src/lib/libcrypto/ec/Makefile.ssl
new file mode 100644
index 0000000000..ed602b4a7f
--- /dev/null
+++ b/src/lib/libcrypto/ec/Makefile.ssl
@@ -0,0 +1,128 @@
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 6d6a9b7127..a52d4edf14 100644
--- a/src/lib/libcrypto/ec/ec.h
+++ b/src/lib/libcrypto/ec/ec.h
@@ -195,6 +195,7 @@ void ERR_load_EC_strings(void);
195#define EC_F_EC_GROUP_GET0_GENERATOR 139 195#define EC_F_EC_GROUP_GET0_GENERATOR 139
196#define EC_F_EC_GROUP_GET_COFACTOR 140 196#define EC_F_EC_GROUP_GET_COFACTOR 140
197#define EC_F_EC_GROUP_GET_CURVE_GFP 130 197#define EC_F_EC_GROUP_GET_CURVE_GFP 130
198#define EC_F_EC_GROUP_GET_EXTRA_DATA 107
198#define EC_F_EC_GROUP_GET_ORDER 141 199#define EC_F_EC_GROUP_GET_ORDER 141
199#define EC_F_EC_GROUP_NEW 108 200#define EC_F_EC_GROUP_NEW 108
200#define EC_F_EC_GROUP_PRECOMPUTE_MULT 142 201#define EC_F_EC_GROUP_PRECOMPUTE_MULT 142
@@ -231,6 +232,7 @@ void ERR_load_EC_strings(void);
231#define EC_R_INVALID_FIELD 103 232#define EC_R_INVALID_FIELD 103
232#define EC_R_INVALID_FORM 104 233#define EC_R_INVALID_FORM 104
233#define EC_R_NOT_INITIALIZED 111 234#define EC_R_NOT_INITIALIZED 111
235#define EC_R_NO_SUCH_EXTRA_DATA 105
234#define EC_R_POINT_AT_INFINITY 106 236#define EC_R_POINT_AT_INFINITY 106
235#define EC_R_POINT_IS_NOT_ON_CURVE 107 237#define EC_R_POINT_IS_NOT_ON_CURVE 107
236#define EC_R_SLOT_FULL 108 238#define EC_R_SLOT_FULL 108
diff --git a/src/lib/libcrypto/ec/ec_err.c b/src/lib/libcrypto/ec/ec_err.c
index d37b6aba87..394cdc021f 100644
--- a/src/lib/libcrypto/ec/ec_err.c
+++ b/src/lib/libcrypto/ec/ec_err.c
@@ -84,6 +84,7 @@ static ERR_STRING_DATA EC_str_functs[]=
84{ERR_PACK(0,EC_F_EC_GROUP_GET0_GENERATOR,0), "EC_GROUP_get0_generator"}, 84{ERR_PACK(0,EC_F_EC_GROUP_GET0_GENERATOR,0), "EC_GROUP_get0_generator"},
85{ERR_PACK(0,EC_F_EC_GROUP_GET_COFACTOR,0), "EC_GROUP_get_cofactor"}, 85{ERR_PACK(0,EC_F_EC_GROUP_GET_COFACTOR,0), "EC_GROUP_get_cofactor"},
86{ERR_PACK(0,EC_F_EC_GROUP_GET_CURVE_GFP,0), "EC_GROUP_get_curve_GFp"}, 86{ERR_PACK(0,EC_F_EC_GROUP_GET_CURVE_GFP,0), "EC_GROUP_get_curve_GFp"},
87{ERR_PACK(0,EC_F_EC_GROUP_GET_EXTRA_DATA,0), "EC_GROUP_get_extra_data"},
87{ERR_PACK(0,EC_F_EC_GROUP_GET_ORDER,0), "EC_GROUP_get_order"}, 88{ERR_PACK(0,EC_F_EC_GROUP_GET_ORDER,0), "EC_GROUP_get_order"},
88{ERR_PACK(0,EC_F_EC_GROUP_NEW,0), "EC_GROUP_new"}, 89{ERR_PACK(0,EC_F_EC_GROUP_NEW,0), "EC_GROUP_new"},
89{ERR_PACK(0,EC_F_EC_GROUP_PRECOMPUTE_MULT,0), "EC_GROUP_precompute_mult"}, 90{ERR_PACK(0,EC_F_EC_GROUP_PRECOMPUTE_MULT,0), "EC_GROUP_precompute_mult"},
@@ -123,6 +124,7 @@ static ERR_STRING_DATA EC_str_reasons[]=
123{EC_R_INVALID_FIELD ,"invalid field"}, 124{EC_R_INVALID_FIELD ,"invalid field"},
124{EC_R_INVALID_FORM ,"invalid form"}, 125{EC_R_INVALID_FORM ,"invalid form"},
125{EC_R_NOT_INITIALIZED ,"not initialized"}, 126{EC_R_NOT_INITIALIZED ,"not initialized"},
127{EC_R_NO_SUCH_EXTRA_DATA ,"no such extra data"},
126{EC_R_POINT_AT_INFINITY ,"point at infinity"}, 128{EC_R_POINT_AT_INFINITY ,"point at infinity"},
127{EC_R_POINT_IS_NOT_ON_CURVE ,"point is not on curve"}, 129{EC_R_POINT_IS_NOT_ON_CURVE ,"point is not on curve"},
128{EC_R_SLOT_FULL ,"slot full"}, 130{EC_R_SLOT_FULL ,"slot full"},
diff --git a/src/lib/libcrypto/ec/ec_lib.c b/src/lib/libcrypto/ec/ec_lib.c
index deb522060f..0cf485de60 100644
--- a/src/lib/libcrypto/ec/ec_lib.c
+++ b/src/lib/libcrypto/ec/ec_lib.c
@@ -128,7 +128,7 @@ void EC_GROUP_clear_free(EC_GROUP *group)
128 128
129 EC_GROUP_clear_free_extra_data(group); 129 EC_GROUP_clear_free_extra_data(group);
130 130
131 OPENSSL_cleanse(group, sizeof *group); 131 memset(group, 0, sizeof *group);
132 OPENSSL_free(group); 132 OPENSSL_free(group);
133 } 133 }
134 134
@@ -268,9 +268,7 @@ void *EC_GROUP_get_extra_data(const EC_GROUP *group, void *(*extra_data_dup_func
268 || (group->extra_data_free_func != extra_data_free_func) 268 || (group->extra_data_free_func != extra_data_free_func)
269 || (group->extra_data_clear_free_func != extra_data_clear_free_func)) 269 || (group->extra_data_clear_free_func != extra_data_clear_free_func))
270 { 270 {
271#if 0 /* this was an error in 0.9.7, but that does not make a lot of sense */ 271 ECerr(EC_F_EC_GROUP_GET_EXTRA_DATA, EC_R_NO_SUCH_EXTRA_DATA);
272 ECerr(..._F_EC_GROUP_GET_EXTRA_DATA, ..._R_NO_SUCH_EXTRA_DATA);
273#endif
274 return NULL; 272 return NULL;
275 } 273 }
276 274
@@ -359,7 +357,7 @@ void EC_POINT_clear_free(EC_POINT *point)
359 point->meth->point_clear_finish(point); 357 point->meth->point_clear_finish(point);
360 else if (point->meth != NULL && point->meth->point_finish != 0) 358 else if (point->meth != NULL && point->meth->point_finish != 0)
361 point->meth->point_finish(point); 359 point->meth->point_finish(point);
362 OPENSSL_cleanse(point, sizeof *point); 360 memset(point, 0, sizeof *point);
363 OPENSSL_free(point); 361 OPENSSL_free(point);
364 } 362 }
365 363
diff --git a/src/lib/libcrypto/ec/ec_mult.c b/src/lib/libcrypto/ec/ec_mult.c
index 4dbc931120..603ba31b81 100644
--- a/src/lib/libcrypto/ec/ec_mult.c
+++ b/src/lib/libcrypto/ec/ec_mult.c
@@ -209,17 +209,6 @@ int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
209 EC_POINT ***val_sub = NULL; /* pointers to sub-arrays of 'val' */ 209 EC_POINT ***val_sub = NULL; /* pointers to sub-arrays of 'val' */
210 int ret = 0; 210 int ret = 0;
211 211
212 if (group->meth != r->meth)
213 {
214 ECerr(EC_F_EC_POINTS_MUL, EC_R_INCOMPATIBLE_OBJECTS);
215 return 0;
216 }
217
218 if ((scalar == NULL) && (num == 0))
219 {
220 return EC_POINT_set_to_infinity(group, r);
221 }
222
223 if (scalar != NULL) 212 if (scalar != NULL)
224 { 213 {
225 generator = EC_GROUP_get0_generator(group); 214 generator = EC_GROUP_get0_generator(group);
diff --git a/src/lib/libcrypto/ec/ecp_recp.c b/src/lib/libcrypto/ec/ecp_recp.c
new file mode 100644
index 0000000000..fec843b5c8
--- /dev/null
+++ b/src/lib/libcrypto/ec/ecp_recp.c
@@ -0,0 +1,133 @@
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
new file mode 100644
index 0000000000..eab46cc080
--- /dev/null
+++ b/src/lib/libcrypto/ec/ectest.c
@@ -0,0 +1,634 @@
1/* crypto/ec/ectest.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 <stdio.h>
57#include <stdlib.h>
58#include <string.h>
59#include <time.h>
60
61
62#ifdef OPENSSL_NO_EC
63int main(int argc, char * argv[]) { puts("Elliptic curves are disabled."); return 0; }
64#else
65
66
67#include <openssl/ec.h>
68#include <openssl/engine.h>
69#include <openssl/err.h>
70
71#define ABORT do { \
72 fflush(stdout); \
73 fprintf(stderr, "%s:%d: ABORT\n", __FILE__, __LINE__); \
74 ERR_print_errors_fp(stderr); \
75 exit(1); \
76} while (0)
77
78#if 0
79static void timings(EC_GROUP *group, int multi, BN_CTX *ctx)
80 {
81 clock_t clck;
82 int i, j;
83 BIGNUM *s, *s0;
84 EC_POINT *P;
85
86 s = BN_new();
87 s0 = BN_new();
88 if (s == NULL || s0 == NULL) ABORT;
89
90 if (!EC_GROUP_get_curve_GFp(group, s, NULL, NULL, ctx)) ABORT;
91 fprintf(stdout, "Timings for %d bit prime, ", (int)BN_num_bits(s));
92 if (!EC_GROUP_get_order(group, s, ctx)) ABORT;
93 fprintf(stdout, "%d bit scalars ", (int)BN_num_bits(s));
94 fflush(stdout);
95
96 P = EC_POINT_new(group);
97 if (P == NULL) ABORT;
98 EC_POINT_copy(P, EC_GROUP_get0_generator(group));
99
100 clck = clock();
101 for (i = 0; i < 10; i++)
102 {
103 if (!BN_pseudo_rand(s, BN_num_bits(s), 0, 0)) ABORT;
104 if (multi)
105 {
106 if (!BN_pseudo_rand(s0, BN_num_bits(s), 0, 0)) ABORT;
107 }
108 for (j = 0; j < 10; j++)
109 {
110 if (!EC_POINT_mul(group, P, s, multi ? P : NULL, multi ? s0 : NULL, ctx)) ABORT;
111 }
112 fprintf(stdout, ".");
113 fflush(stdout);
114 }
115 fprintf(stdout, "\n");
116
117 clck = clock() - clck;
118
119#ifdef CLOCKS_PER_SEC
120 /* "To determine the time in seconds, the value returned
121 * by the clock function should be divided by the value
122 * of the macro CLOCKS_PER_SEC."
123 * -- ISO/IEC 9899 */
124# define UNIT "s"
125#else
126 /* "`CLOCKS_PER_SEC' undeclared (first use this function)"
127 * -- cc on NeXTstep/OpenStep */
128# define UNIT "units"
129# define CLOCKS_PER_SEC 1
130#endif
131
132 fprintf(stdout, "%i %s in %.2f " UNIT "\n", i*j,
133 multi ? "s*P+t*Q operations" : "point multiplications",
134 (double)clck/CLOCKS_PER_SEC);
135 fprintf(stdout, "average: %.4f " UNIT "\n", (double)clck/(CLOCKS_PER_SEC*i*j));
136
137 EC_POINT_free(P);
138 BN_free(s);
139 BN_free(s0);
140 }
141#endif
142
143int main(int argc, char *argv[])
144 {
145 BN_CTX *ctx = NULL;
146 BIGNUM *p, *a, *b;
147 EC_GROUP *group;
148 EC_GROUP *P_192 = NULL, *P_224 = NULL, *P_256 = NULL, *P_384 = NULL, *P_521 = NULL;
149 EC_POINT *P, *Q, *R;
150 BIGNUM *x, *y, *z;
151 unsigned char buf[100];
152 size_t i, len;
153 int k;
154
155 /* enable memory leak checking unless explicitly disabled */
156 if (!((getenv("OPENSSL_DEBUG_MEMORY") != NULL) && (0 == strcmp(getenv("OPENSSL_DEBUG_MEMORY"), "off"))))
157 {
158 CRYPTO_malloc_debug_init();
159 CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
160 }
161 else
162 {
163 /* OPENSSL_DEBUG_MEMORY=off */
164 CRYPTO_set_mem_debug_functions(0, 0, 0, 0, 0);
165 }
166 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
167 ERR_load_crypto_strings();
168
169#if 1 /* optional */
170 ctx = BN_CTX_new();
171 if (!ctx) ABORT;
172#endif
173
174 p = BN_new();
175 a = BN_new();
176 b = BN_new();
177 if (!p || !a || !b) ABORT;
178
179 if (!BN_hex2bn(&p, "17")) ABORT;
180 if (!BN_hex2bn(&a, "1")) ABORT;
181 if (!BN_hex2bn(&b, "1")) ABORT;
182
183 group = EC_GROUP_new(EC_GFp_mont_method()); /* applications should use EC_GROUP_new_curve_GFp
184 * so that the library gets to choose the EC_METHOD */
185 if (!group) ABORT;
186
187 if (!EC_GROUP_set_curve_GFp(group, p, a, b, ctx)) ABORT;
188
189 {
190 EC_GROUP *tmp;
191 tmp = EC_GROUP_new(EC_GROUP_method_of(group));
192 if (!tmp) ABORT;
193 if (!EC_GROUP_copy(tmp, group));
194 EC_GROUP_free(group);
195 group = tmp;
196 }
197
198 if (!EC_GROUP_get_curve_GFp(group, p, a, b, ctx)) ABORT;
199
200 fprintf(stdout, "Curve defined by Weierstrass equation\n y^2 = x^3 + a*x + b (mod 0x");
201 BN_print_fp(stdout, p);
202 fprintf(stdout, ")\n a = 0x");
203 BN_print_fp(stdout, a);
204 fprintf(stdout, "\n b = 0x");
205 BN_print_fp(stdout, b);
206 fprintf(stdout, "\n");
207
208 P = EC_POINT_new(group);
209 Q = EC_POINT_new(group);
210 R = EC_POINT_new(group);
211 if (!P || !Q || !R) ABORT;
212
213 if (!EC_POINT_set_to_infinity(group, P)) ABORT;
214 if (!EC_POINT_is_at_infinity(group, P)) ABORT;
215
216 buf[0] = 0;
217 if (!EC_POINT_oct2point(group, Q, buf, 1, ctx)) ABORT;
218
219 if (!EC_POINT_add(group, P, P, Q, ctx)) ABORT;
220 if (!EC_POINT_is_at_infinity(group, P)) ABORT;
221
222 x = BN_new();
223 y = BN_new();
224 z = BN_new();
225 if (!x || !y || !z) ABORT;
226
227 if (!BN_hex2bn(&x, "D")) ABORT;
228 if (!EC_POINT_set_compressed_coordinates_GFp(group, Q, x, 1, ctx)) ABORT;
229 if (!EC_POINT_is_on_curve(group, Q, ctx))
230 {
231 if (!EC_POINT_get_affine_coordinates_GFp(group, Q, x, y, ctx)) ABORT;
232 fprintf(stderr, "Point is not on curve: x = 0x");
233 BN_print_fp(stderr, x);
234 fprintf(stderr, ", y = 0x");
235 BN_print_fp(stderr, y);
236 fprintf(stderr, "\n");
237 ABORT;
238 }
239
240 fprintf(stdout, "A cyclic subgroup:\n");
241 k = 100;
242 do
243 {
244 if (k-- == 0) ABORT;
245
246 if (EC_POINT_is_at_infinity(group, P))
247 fprintf(stdout, " point at infinity\n");
248 else
249 {
250 if (!EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx)) ABORT;
251
252 fprintf(stdout, " x = 0x");
253 BN_print_fp(stdout, x);
254 fprintf(stdout, ", y = 0x");
255 BN_print_fp(stdout, y);
256 fprintf(stdout, "\n");
257 }
258
259 if (!EC_POINT_copy(R, P)) ABORT;
260 if (!EC_POINT_add(group, P, P, Q, ctx)) ABORT;
261
262#if 0 /* optional */
263 {
264 EC_POINT *points[3];
265
266 points[0] = R;
267 points[1] = Q;
268 points[2] = P;
269 if (!EC_POINTs_make_affine(group, 2, points, ctx)) ABORT;
270 }
271#endif
272
273 }
274 while (!EC_POINT_is_at_infinity(group, P));
275
276 if (!EC_POINT_add(group, P, Q, R, ctx)) ABORT;
277 if (!EC_POINT_is_at_infinity(group, P)) ABORT;
278
279 len = EC_POINT_point2oct(group, Q, POINT_CONVERSION_COMPRESSED, buf, sizeof buf, ctx);
280 if (len == 0) ABORT;
281 if (!EC_POINT_oct2point(group, P, buf, len, ctx)) ABORT;
282 if (0 != EC_POINT_cmp(group, P, Q, ctx)) ABORT;
283 fprintf(stdout, "Generator as octect string, compressed form:\n ");
284 for (i = 0; i < len; i++) fprintf(stdout, "%02X", buf[i]);
285
286 len = EC_POINT_point2oct(group, Q, POINT_CONVERSION_UNCOMPRESSED, buf, sizeof buf, ctx);
287 if (len == 0) ABORT;
288 if (!EC_POINT_oct2point(group, P, buf, len, ctx)) ABORT;
289 if (0 != EC_POINT_cmp(group, P, Q, ctx)) ABORT;
290 fprintf(stdout, "\nGenerator as octect string, uncompressed form:\n ");
291 for (i = 0; i < len; i++) fprintf(stdout, "%02X", buf[i]);
292
293 len = EC_POINT_point2oct(group, Q, POINT_CONVERSION_HYBRID, buf, sizeof buf, ctx);
294 if (len == 0) ABORT;
295 if (!EC_POINT_oct2point(group, P, buf, len, ctx)) ABORT;
296 if (0 != EC_POINT_cmp(group, P, Q, ctx)) ABORT;
297 fprintf(stdout, "\nGenerator as octect string, hybrid form:\n ");
298 for (i = 0; i < len; i++) fprintf(stdout, "%02X", buf[i]);
299
300 if (!EC_POINT_get_Jprojective_coordinates_GFp(group, R, x, y, z, ctx)) ABORT;
301 fprintf(stdout, "\nA representation of the inverse of that generator in\nJacobian projective coordinates:\n X = 0x");
302 BN_print_fp(stdout, x);
303 fprintf(stdout, ", Y = 0x");
304 BN_print_fp(stdout, y);
305 fprintf(stdout, ", Z = 0x");
306 BN_print_fp(stdout, z);
307 fprintf(stdout, "\n");
308
309 if (!EC_POINT_invert(group, P, ctx)) ABORT;
310 if (0 != EC_POINT_cmp(group, P, R, ctx)) ABORT;
311
312
313 /* Curve P-192 (FIPS PUB 186-2, App. 6) */
314
315 if (!BN_hex2bn(&p, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF")) ABORT;
316 if (1 != BN_is_prime(p, BN_prime_checks, 0, ctx, NULL)) ABORT;
317 if (!BN_hex2bn(&a, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC")) ABORT;
318 if (!BN_hex2bn(&b, "64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1")) ABORT;
319 if (!EC_GROUP_set_curve_GFp(group, p, a, b, ctx)) ABORT;
320
321 if (!BN_hex2bn(&x, "188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012")) ABORT;
322 if (!EC_POINT_set_compressed_coordinates_GFp(group, P, x, 1, ctx)) ABORT;
323 if (!EC_POINT_is_on_curve(group, P, ctx)) ABORT;
324 if (!BN_hex2bn(&z, "FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831")) ABORT;
325 if (!EC_GROUP_set_generator(group, P, z, BN_value_one())) ABORT;
326
327 if (!EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx)) ABORT;
328 fprintf(stdout, "\nNIST curve P-192 -- Generator:\n x = 0x");
329 BN_print_fp(stdout, x);
330 fprintf(stdout, "\n y = 0x");
331 BN_print_fp(stdout, y);
332 fprintf(stdout, "\n");
333 /* G_y value taken from the standard: */
334 if (!BN_hex2bn(&z, "07192B95FFC8DA78631011ED6B24CDD573F977A11E794811")) ABORT;
335 if (0 != BN_cmp(y, z)) ABORT;
336
337 fprintf(stdout, "verify group order ...");
338 fflush(stdout);
339 if (!EC_GROUP_get_order(group, z, ctx)) ABORT;
340 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT;
341 if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
342 fprintf(stdout, ".");
343 fflush(stdout);
344 if (!EC_GROUP_precompute_mult(group, ctx)) ABORT;
345 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT;
346 if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
347 fprintf(stdout, " ok\n");
348
349 if (!(P_192 = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT;
350 if (!EC_GROUP_copy(P_192, group)) ABORT;
351
352
353 /* Curve P-224 (FIPS PUB 186-2, App. 6) */
354
355 if (!BN_hex2bn(&p, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001")) ABORT;
356 if (1 != BN_is_prime(p, BN_prime_checks, 0, ctx, NULL)) ABORT;
357 if (!BN_hex2bn(&a, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE")) ABORT;
358 if (!BN_hex2bn(&b, "B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4")) ABORT;
359 if (!EC_GROUP_set_curve_GFp(group, p, a, b, ctx)) ABORT;
360
361 if (!BN_hex2bn(&x, "B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21")) ABORT;
362 if (!EC_POINT_set_compressed_coordinates_GFp(group, P, x, 0, ctx)) ABORT;
363 if (!EC_POINT_is_on_curve(group, P, ctx)) ABORT;
364 if (!BN_hex2bn(&z, "FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D")) ABORT;
365 if (!EC_GROUP_set_generator(group, P, z, BN_value_one())) ABORT;
366
367 if (!EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx)) ABORT;
368 fprintf(stdout, "\nNIST curve P-224 -- Generator:\n x = 0x");
369 BN_print_fp(stdout, x);
370 fprintf(stdout, "\n y = 0x");
371 BN_print_fp(stdout, y);
372 fprintf(stdout, "\n");
373 /* G_y value taken from the standard: */
374 if (!BN_hex2bn(&z, "BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34")) ABORT;
375 if (0 != BN_cmp(y, z)) ABORT;
376
377 fprintf(stdout, "verify group order ...");
378 fflush(stdout);
379 if (!EC_GROUP_get_order(group, z, ctx)) ABORT;
380 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT;
381 if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
382 fprintf(stdout, ".");
383 fflush(stdout);
384 if (!EC_GROUP_precompute_mult(group, ctx)) ABORT;
385 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT;
386 if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
387 fprintf(stdout, " ok\n");
388
389 if (!(P_224 = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT;
390 if (!EC_GROUP_copy(P_224, group)) ABORT;
391
392
393 /* Curve P-256 (FIPS PUB 186-2, App. 6) */
394
395 if (!BN_hex2bn(&p, "FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF")) ABORT;
396 if (1 != BN_is_prime(p, BN_prime_checks, 0, ctx, NULL)) ABORT;
397 if (!BN_hex2bn(&a, "FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC")) ABORT;
398 if (!BN_hex2bn(&b, "5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B")) ABORT;
399 if (!EC_GROUP_set_curve_GFp(group, p, a, b, ctx)) ABORT;
400
401 if (!BN_hex2bn(&x, "6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296")) ABORT;
402 if (!EC_POINT_set_compressed_coordinates_GFp(group, P, x, 1, ctx)) ABORT;
403 if (!EC_POINT_is_on_curve(group, P, ctx)) ABORT;
404 if (!BN_hex2bn(&z, "FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E"
405 "84F3B9CAC2FC632551")) ABORT;
406 if (!EC_GROUP_set_generator(group, P, z, BN_value_one())) ABORT;
407
408 if (!EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx)) ABORT;
409 fprintf(stdout, "\nNIST curve P-256 -- Generator:\n x = 0x");
410 BN_print_fp(stdout, x);
411 fprintf(stdout, "\n y = 0x");
412 BN_print_fp(stdout, y);
413 fprintf(stdout, "\n");
414 /* G_y value taken from the standard: */
415 if (!BN_hex2bn(&z, "4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5")) ABORT;
416 if (0 != BN_cmp(y, z)) ABORT;
417
418 fprintf(stdout, "verify group order ...");
419 fflush(stdout);
420 if (!EC_GROUP_get_order(group, z, ctx)) ABORT;
421 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT;
422 if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
423 fprintf(stdout, ".");
424 fflush(stdout);
425 if (!EC_GROUP_precompute_mult(group, ctx)) ABORT;
426 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT;
427 if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
428 fprintf(stdout, " ok\n");
429
430 if (!(P_256 = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT;
431 if (!EC_GROUP_copy(P_256, group)) ABORT;
432
433
434 /* Curve P-384 (FIPS PUB 186-2, App. 6) */
435
436 if (!BN_hex2bn(&p, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
437 "FFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF")) ABORT;
438 if (1 != BN_is_prime(p, BN_prime_checks, 0, ctx, NULL)) ABORT;
439 if (!BN_hex2bn(&a, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
440 "FFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC")) ABORT;
441 if (!BN_hex2bn(&b, "B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141"
442 "120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF")) ABORT;
443 if (!EC_GROUP_set_curve_GFp(group, p, a, b, ctx)) ABORT;
444
445 if (!BN_hex2bn(&x, "AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B"
446 "9859F741E082542A385502F25DBF55296C3A545E3872760AB7")) ABORT;
447 if (!EC_POINT_set_compressed_coordinates_GFp(group, P, x, 1, ctx)) ABORT;
448 if (!EC_POINT_is_on_curve(group, P, ctx)) ABORT;
449 if (!BN_hex2bn(&z, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
450 "FFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973")) ABORT;
451 if (!EC_GROUP_set_generator(group, P, z, BN_value_one())) ABORT;
452
453 if (!EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx)) ABORT;
454 fprintf(stdout, "\nNIST curve P-384 -- Generator:\n x = 0x");
455 BN_print_fp(stdout, x);
456 fprintf(stdout, "\n y = 0x");
457 BN_print_fp(stdout, y);
458 fprintf(stdout, "\n");
459 /* G_y value taken from the standard: */
460 if (!BN_hex2bn(&z, "3617DE4A96262C6F5D9E98BF9292DC29F8F41DBD289A14"
461 "7CE9DA3113B5F0B8C00A60B1CE1D7E819D7A431D7C90EA0E5F")) ABORT;
462 if (0 != BN_cmp(y, z)) ABORT;
463
464 fprintf(stdout, "verify group order ...");
465 fflush(stdout);
466 if (!EC_GROUP_get_order(group, z, ctx)) ABORT;
467 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT;
468 if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
469 fprintf(stdout, ".");
470 fflush(stdout);
471 if (!EC_GROUP_precompute_mult(group, ctx)) ABORT;
472 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT;
473 if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
474 fprintf(stdout, " ok\n");
475
476 if (!(P_384 = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT;
477 if (!EC_GROUP_copy(P_384, group)) ABORT;
478
479
480 /* Curve P-521 (FIPS PUB 186-2, App. 6) */
481
482 if (!BN_hex2bn(&p, "1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
483 "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
484 "FFFFFFFFFFFFFFFFFFFFFFFFFFFF")) ABORT;
485 if (1 != BN_is_prime(p, BN_prime_checks, 0, ctx, NULL)) ABORT;
486 if (!BN_hex2bn(&a, "1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
487 "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
488 "FFFFFFFFFFFFFFFFFFFFFFFFFFFC")) ABORT;
489 if (!BN_hex2bn(&b, "051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B"
490 "315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573"
491 "DF883D2C34F1EF451FD46B503F00")) ABORT;
492 if (!EC_GROUP_set_curve_GFp(group, p, a, b, ctx)) ABORT;
493
494 if (!BN_hex2bn(&x, "C6858E06B70404E9CD9E3ECB662395B4429C648139053F"
495 "B521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B"
496 "3C1856A429BF97E7E31C2E5BD66")) ABORT;
497 if (!EC_POINT_set_compressed_coordinates_GFp(group, P, x, 0, ctx)) ABORT;
498 if (!EC_POINT_is_on_curve(group, P, ctx)) ABORT;
499 if (!BN_hex2bn(&z, "1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
500 "FFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5"
501 "C9B8899C47AEBB6FB71E91386409")) ABORT;
502 if (!EC_GROUP_set_generator(group, P, z, BN_value_one())) ABORT;
503
504 if (!EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx)) ABORT;
505 fprintf(stdout, "\nNIST curve P-521 -- Generator:\n x = 0x");
506 BN_print_fp(stdout, x);
507 fprintf(stdout, "\n y = 0x");
508 BN_print_fp(stdout, y);
509 fprintf(stdout, "\n");
510 /* G_y value taken from the standard: */
511 if (!BN_hex2bn(&z, "11839296A789A3BC0045C8A5FB42C7D1BD998F54449579"
512 "B446817AFBD17273E662C97EE72995EF42640C550B9013FAD0761353C"
513 "7086A272C24088BE94769FD16650")) ABORT;
514 if (0 != BN_cmp(y, z)) ABORT;
515
516 fprintf(stdout, "verify group order ...");
517 fflush(stdout);
518 if (!EC_GROUP_get_order(group, z, ctx)) ABORT;
519 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT;
520 if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
521 fprintf(stdout, ".");
522 fflush(stdout);
523 if (!EC_GROUP_precompute_mult(group, ctx)) ABORT;
524 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT;
525 if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
526 fprintf(stdout, " ok\n");
527
528 if (!(P_521 = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT;
529 if (!EC_GROUP_copy(P_521, group)) ABORT;
530
531
532 /* more tests using the last curve */
533
534 if (!EC_POINT_copy(Q, P)) ABORT;
535 if (EC_POINT_is_at_infinity(group, Q)) ABORT;
536 if (!EC_POINT_dbl(group, P, P, ctx)) ABORT;
537 if (!EC_POINT_is_on_curve(group, P, ctx)) ABORT;
538 if (!EC_POINT_invert(group, Q, ctx)) ABORT; /* P = -2Q */
539
540 if (!EC_POINT_add(group, R, P, Q, ctx)) ABORT;
541 if (!EC_POINT_add(group, R, R, Q, ctx)) ABORT;
542 if (!EC_POINT_is_at_infinity(group, R)) ABORT; /* R = P + 2Q */
543
544 {
545 const EC_POINT *points[3];
546 const BIGNUM *scalars[3];
547
548 if (EC_POINT_is_at_infinity(group, Q)) ABORT;
549 points[0] = Q;
550 points[1] = Q;
551 points[2] = Q;
552
553 if (!BN_add(y, z, BN_value_one())) ABORT;
554 if (BN_is_odd(y)) ABORT;
555 if (!BN_rshift1(y, y)) ABORT;
556 scalars[0] = y; /* (group order + 1)/2, so y*Q + y*Q = Q */
557 scalars[1] = y;
558
559 fprintf(stdout, "combined multiplication ...");
560 fflush(stdout);
561
562 /* z is still the group order */
563 if (!EC_POINTs_mul(group, P, NULL, 2, points, scalars, ctx)) ABORT;
564 if (!EC_POINTs_mul(group, R, z, 2, points, scalars, ctx)) ABORT;
565 if (0 != EC_POINT_cmp(group, P, R, ctx)) ABORT;
566 if (0 != EC_POINT_cmp(group, R, Q, ctx)) ABORT;
567
568 fprintf(stdout, ".");
569 fflush(stdout);
570
571 if (!BN_pseudo_rand(y, BN_num_bits(y), 0, 0)) ABORT;
572 if (!BN_add(z, z, y)) ABORT;
573 z->neg = 1;
574 scalars[0] = y;
575 scalars[1] = z; /* z = -(order + y) */
576
577 if (!EC_POINTs_mul(group, P, NULL, 2, points, scalars, ctx)) ABORT;
578 if (!EC_POINT_is_at_infinity(group, P)) ABORT;
579
580 fprintf(stdout, ".");
581 fflush(stdout);
582
583 if (!BN_pseudo_rand(x, BN_num_bits(y) - 1, 0, 0)) ABORT;
584 if (!BN_add(z, x, y)) ABORT;
585 z->neg = 1;
586 scalars[0] = x;
587 scalars[1] = y;
588 scalars[2] = z; /* z = -(x+y) */
589
590 if (!EC_POINTs_mul(group, P, NULL, 3, points, scalars, ctx)) ABORT;
591 if (!EC_POINT_is_at_infinity(group, P)) ABORT;
592
593 fprintf(stdout, " ok\n\n");
594 }
595
596
597#if 0
598 timings(P_192, 0, ctx);
599 timings(P_192, 1, ctx);
600 timings(P_224, 0, ctx);
601 timings(P_224, 1, ctx);
602 timings(P_256, 0, ctx);
603 timings(P_256, 1, ctx);
604 timings(P_384, 0, ctx);
605 timings(P_384, 1, ctx);
606 timings(P_521, 0, ctx);
607 timings(P_521, 1, ctx);
608#endif
609
610
611 if (ctx)
612 BN_CTX_free(ctx);
613 BN_free(p); BN_free(a); BN_free(b);
614 EC_GROUP_free(group);
615 EC_POINT_free(P);
616 EC_POINT_free(Q);
617 EC_POINT_free(R);
618 BN_free(x); BN_free(y); BN_free(z);
619
620 if (P_192) EC_GROUP_free(P_192);
621 if (P_224) EC_GROUP_free(P_224);
622 if (P_256) EC_GROUP_free(P_256);
623 if (P_384) EC_GROUP_free(P_384);
624 if (P_521) EC_GROUP_free(P_521);
625
626 ENGINE_cleanup();
627 CRYPTO_cleanup_all_ex_data();
628 ERR_free_strings();
629 ERR_remove_state(0);
630 CRYPTO_mem_leaks_fp(stderr);
631
632 return 0;
633 }
634#endif
diff --git a/src/lib/libcrypto/engine/Makefile.ssl b/src/lib/libcrypto/engine/Makefile.ssl
new file mode 100644
index 0000000000..8bc8985e02
--- /dev/null
+++ b/src/lib/libcrypto/engine/Makefile.ssl
@@ -0,0 +1,556 @@
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)
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_cswift.o: ../../e_os.h ../../include/openssl/asn1.h
308hw_cswift.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
309hw_cswift.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
310hw_cswift.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
311hw_cswift.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
312hw_cswift.o: ../../include/openssl/engine.h ../../include/openssl/err.h
313hw_cswift.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
314hw_cswift.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
315hw_cswift.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
316hw_cswift.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
317hw_cswift.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
318hw_cswift.o: ../cryptlib.h hw_cswift.c hw_cswift_err.c hw_cswift_err.h
319hw_cswift.o: vendor_defns/cswift.h
320hw_ncipher.o: ../../e_os.h ../../include/openssl/aes.h
321hw_ncipher.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
322hw_ncipher.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
323hw_ncipher.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
324hw_ncipher.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
325hw_ncipher.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
326hw_ncipher.o: ../../include/openssl/dsa.h ../../include/openssl/dso.h
327hw_ncipher.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
328hw_ncipher.o: ../../include/openssl/err.h ../../include/openssl/evp.h
329hw_ncipher.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
330hw_ncipher.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
331hw_ncipher.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
332hw_ncipher.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
333hw_ncipher.o: ../../include/openssl/opensslconf.h
334hw_ncipher.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
335hw_ncipher.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
336hw_ncipher.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
337hw_ncipher.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
338hw_ncipher.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
339hw_ncipher.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
340hw_ncipher.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
341hw_ncipher.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
342hw_ncipher.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
343hw_ncipher.o: ../../include/openssl/x509_vfy.h ../cryptlib.h hw_ncipher.c
344hw_ncipher.o: hw_ncipher_err.c hw_ncipher_err.h vendor_defns/hwcryptohook.h
345hw_nuron.o: ../../e_os.h ../../include/openssl/asn1.h
346hw_nuron.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
347hw_nuron.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
348hw_nuron.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
349hw_nuron.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
350hw_nuron.o: ../../include/openssl/engine.h ../../include/openssl/err.h
351hw_nuron.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
352hw_nuron.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
353hw_nuron.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
354hw_nuron.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
355hw_nuron.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
356hw_nuron.o: ../cryptlib.h hw_nuron.c hw_nuron_err.c hw_nuron_err.h
357hw_cryptodev.o: ../../include/openssl/aes.h
358hw_cryptodev.o: ../../include/openssl/asn1.h
359hw_cryptodev.o: ../../include/openssl/bio.h
360hw_cryptodev.o: ../../include/openssl/blowfish.h
361hw_cryptodev.o: ../../include/openssl/bn.h
362hw_cryptodev.o: ../../include/openssl/cast.h
363hw_cryptodev.o: ../../include/openssl/conf.h
364hw_cryptodev.o: ../../include/openssl/crypto.h
365hw_cryptodev.o: ../../include/openssl/des.h
366hw_cryptodev.o: ../../include/openssl/des_old.h
367hw_cryptodev.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
368hw_cryptodev.o: ../../include/openssl/e_os2.h
369hw_cryptodev.o: ../../include/openssl/engine.h
370hw_cryptodev.o: ../../include/openssl/err.h
371hw_cryptodev.o: ../../include/openssl/evp.h
372hw_cryptodev.o: ../../include/openssl/idea.h
373hw_cryptodev.o: ../../include/openssl/lhash.h
374hw_cryptodev.o: ../../include/openssl/md2.h
375hw_cryptodev.o: ../../include/openssl/md4.h
376hw_cryptodev.o: ../../include/openssl/md5.h
377hw_cryptodev.o: ../../include/openssl/mdc2.h
378hw_cryptodev.o: ../../include/openssl/obj_mac.h
379hw_cryptodev.o: ../../include/openssl/objects.h
380hw_cryptodev.o: ../../include/openssl/opensslconf.h
381hw_cryptodev.o: ../../include/openssl/opensslv.h
382hw_cryptodev.o: ../../include/openssl/ossl_typ.h
383hw_cryptodev.o: ../../include/openssl/rand.h
384hw_cryptodev.o: ../../include/openssl/rc2.h
385hw_cryptodev.o: ../../include/openssl/rc4.h
386hw_cryptodev.o: ../../include/openssl/rc5.h
387hw_cryptodev.o: ../../include/openssl/ripemd.h
388hw_cryptodev.o: ../../include/openssl/rsa.h
389hw_cryptodev.o: ../../include/openssl/safestack.h
390hw_cryptodev.o: ../../include/openssl/sha.h
391hw_cryptodev.o: ../../include/openssl/stack.h
392hw_cryptodev.o: ../../include/openssl/symhacks.h
393hw_cryptodev.o: ../../include/openssl/ui.h
394hw_cryptodev.o: ../../include/openssl/ui_compat.h ../evp/evp_locl.h
395hw_cryptodev.o: eng_int.h hw_cryptodev.c
396hw_sureware.o: ../../e_os.h ../../include/openssl/aes.h
397hw_sureware.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
398hw_sureware.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
399hw_sureware.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
400hw_sureware.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
401hw_sureware.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
402hw_sureware.o: ../../include/openssl/dsa.h ../../include/openssl/dso.h
403hw_sureware.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
404hw_sureware.o: ../../include/openssl/err.h ../../include/openssl/evp.h
405hw_sureware.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
406hw_sureware.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
407hw_sureware.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
408hw_sureware.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
409hw_sureware.o: ../../include/openssl/opensslconf.h
410hw_sureware.o: ../../include/openssl/opensslv.h
411hw_sureware.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h
412hw_sureware.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h
413hw_sureware.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
414hw_sureware.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
415hw_sureware.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
416hw_sureware.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
417hw_sureware.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
418hw_sureware.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
419hw_sureware.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
420hw_sureware.o: ../cryptlib.h eng_int.h engine.h hw_sureware.c hw_sureware_err.c
421hw_sureware.o: hw_sureware_err.h vendor_defns/sureware.h
422hw_ubsec.o: ../../e_os.h ../../include/openssl/asn1.h
423hw_ubsec.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
424hw_ubsec.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
425hw_ubsec.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
426hw_ubsec.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
427hw_ubsec.o: ../../include/openssl/engine.h ../../include/openssl/err.h
428hw_ubsec.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
429hw_ubsec.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
430hw_ubsec.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
431hw_ubsec.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
432hw_ubsec.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
433hw_ubsec.o: ../cryptlib.h hw_ubsec.c hw_ubsec_err.c hw_ubsec_err.h
434hw_ubsec.o: vendor_defns/hw_ubsec.h
435tb_cipher.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
436tb_cipher.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
437tb_cipher.o: ../../include/openssl/bn.h ../../include/openssl/cast.h
438tb_cipher.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
439tb_cipher.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
440tb_cipher.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
441tb_cipher.o: ../../include/openssl/engine.h ../../include/openssl/err.h
442tb_cipher.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
443tb_cipher.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
444tb_cipher.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
445tb_cipher.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
446tb_cipher.o: ../../include/openssl/objects.h
447tb_cipher.o: ../../include/openssl/opensslconf.h
448tb_cipher.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
449tb_cipher.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
450tb_cipher.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
451tb_cipher.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
452tb_cipher.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
453tb_cipher.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
454tb_cipher.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
455tb_cipher.o: eng_int.h tb_cipher.c
456tb_dh.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
457tb_dh.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
458tb_dh.o: ../../include/openssl/bn.h ../../include/openssl/cast.h
459tb_dh.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
460tb_dh.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
461tb_dh.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
462tb_dh.o: ../../include/openssl/engine.h ../../include/openssl/err.h
463tb_dh.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
464tb_dh.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
465tb_dh.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
466tb_dh.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
467tb_dh.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
468tb_dh.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
469tb_dh.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
470tb_dh.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
471tb_dh.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
472tb_dh.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
473tb_dh.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
474tb_dh.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h eng_int.h
475tb_dh.o: tb_dh.c
476tb_digest.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
477tb_digest.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
478tb_digest.o: ../../include/openssl/bn.h ../../include/openssl/cast.h
479tb_digest.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
480tb_digest.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
481tb_digest.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
482tb_digest.o: ../../include/openssl/engine.h ../../include/openssl/err.h
483tb_digest.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
484tb_digest.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
485tb_digest.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
486tb_digest.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
487tb_digest.o: ../../include/openssl/objects.h
488tb_digest.o: ../../include/openssl/opensslconf.h
489tb_digest.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
490tb_digest.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
491tb_digest.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
492tb_digest.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
493tb_digest.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
494tb_digest.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
495tb_digest.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
496tb_digest.o: eng_int.h tb_digest.c
497tb_dsa.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
498tb_dsa.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
499tb_dsa.o: ../../include/openssl/bn.h ../../include/openssl/cast.h
500tb_dsa.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
501tb_dsa.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
502tb_dsa.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
503tb_dsa.o: ../../include/openssl/engine.h ../../include/openssl/err.h
504tb_dsa.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
505tb_dsa.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
506tb_dsa.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
507tb_dsa.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
508tb_dsa.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
509tb_dsa.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
510tb_dsa.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
511tb_dsa.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
512tb_dsa.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
513tb_dsa.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
514tb_dsa.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
515tb_dsa.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
516tb_dsa.o: eng_int.h tb_dsa.c
517tb_rand.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
518tb_rand.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
519tb_rand.o: ../../include/openssl/bn.h ../../include/openssl/cast.h
520tb_rand.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
521tb_rand.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
522tb_rand.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
523tb_rand.o: ../../include/openssl/engine.h ../../include/openssl/err.h
524tb_rand.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
525tb_rand.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
526tb_rand.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
527tb_rand.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
528tb_rand.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
529tb_rand.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
530tb_rand.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
531tb_rand.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
532tb_rand.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
533tb_rand.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
534tb_rand.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
535tb_rand.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
536tb_rand.o: eng_int.h tb_rand.c
537tb_rsa.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
538tb_rsa.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
539tb_rsa.o: ../../include/openssl/bn.h ../../include/openssl/cast.h
540tb_rsa.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
541tb_rsa.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
542tb_rsa.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
543tb_rsa.o: ../../include/openssl/engine.h ../../include/openssl/err.h
544tb_rsa.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
545tb_rsa.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
546tb_rsa.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
547tb_rsa.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
548tb_rsa.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
549tb_rsa.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
550tb_rsa.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
551tb_rsa.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
552tb_rsa.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
553tb_rsa.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
554tb_rsa.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
555tb_rsa.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
556tb_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 0f6992a40d..bc50465422 100644
--- a/src/lib/libcrypto/engine/eng_all.c
+++ b/src/lib/libcrypto/engine/eng_all.c
@@ -60,6 +60,10 @@
60#include <openssl/engine.h> 60#include <openssl/engine.h>
61#include "eng_int.h" 61#include "eng_int.h"
62 62
63#ifdef __OpenBSD__
64static int openbsd_default_loaded = 0;
65#endif
66
63void ENGINE_load_builtin_engines(void) 67void ENGINE_load_builtin_engines(void)
64 { 68 {
65 /* There's no longer any need for an "openssl" ENGINE unless, one day, 69 /* There's no longer any need for an "openssl" ENGINE unless, one day,
@@ -95,19 +99,21 @@ void ENGINE_load_builtin_engines(void)
95#ifndef OPENSSL_NO_HW_4758_CCA 99#ifndef OPENSSL_NO_HW_4758_CCA
96 ENGINE_load_4758cca(); 100 ENGINE_load_4758cca();
97#endif 101#endif
98#if defined(__OpenBSD__) || defined(__FreeBSD__) 102#ifdef OPENSSL_OPENBSD_DEV_CRYPTO
103 ENGINE_load_openbsd_dev_crypto();
104#endif
105#ifdef __OpenBSD__
99 ENGINE_load_cryptodev(); 106 ENGINE_load_cryptodev();
100#endif 107#endif
101#endif 108#endif
102 } 109 }
103 110
104#if defined(__OpenBSD__) || defined(__FreeBSD__) 111#ifdef __OpenBSD__
105void ENGINE_setup_bsd_cryptodev(void) { 112void ENGINE_setup_openbsd(void) {
106 static int bsd_cryptodev_default_loaded = 0; 113 if (!openbsd_default_loaded) {
107 if (!bsd_cryptodev_default_loaded) {
108 ENGINE_load_cryptodev(); 114 ENGINE_load_cryptodev();
109 ENGINE_register_all_complete(); 115 ENGINE_register_all_complete();
110 } 116 }
111 bsd_cryptodev_default_loaded=1; 117 openbsd_default_loaded=1;
112} 118}
113#endif 119#endif
diff --git a/src/lib/libcrypto/engine/eng_ctrl.c b/src/lib/libcrypto/engine/eng_ctrl.c
index ad3858395b..0d56e69d27 100644
--- a/src/lib/libcrypto/engine/eng_ctrl.c
+++ b/src/lib/libcrypto/engine/eng_ctrl.c
@@ -160,15 +160,19 @@ static int int_ctrl_helper(ENGINE *e, int cmd, long i, void *p, void (*f)())
160 case ENGINE_CTRL_GET_NAME_LEN_FROM_CMD: 160 case ENGINE_CTRL_GET_NAME_LEN_FROM_CMD:
161 return strlen(e->cmd_defns[idx].cmd_name); 161 return strlen(e->cmd_defns[idx].cmd_name);
162 case ENGINE_CTRL_GET_NAME_FROM_CMD: 162 case ENGINE_CTRL_GET_NAME_FROM_CMD:
163 return sprintf(s, "%s", e->cmd_defns[idx].cmd_name); 163 return snprintf(s,strlen(e->cmd_defns[idx].cmd_name) + 1,
164 "%s", e->cmd_defns[idx].cmd_name);
164 case ENGINE_CTRL_GET_DESC_LEN_FROM_CMD: 165 case ENGINE_CTRL_GET_DESC_LEN_FROM_CMD:
165 if(e->cmd_defns[idx].cmd_desc) 166 if(e->cmd_defns[idx].cmd_desc)
166 return strlen(e->cmd_defns[idx].cmd_desc); 167 return strlen(e->cmd_defns[idx].cmd_desc);
167 return strlen(int_no_description); 168 return strlen(int_no_description);
168 case ENGINE_CTRL_GET_DESC_FROM_CMD: 169 case ENGINE_CTRL_GET_DESC_FROM_CMD:
169 if(e->cmd_defns[idx].cmd_desc) 170 if(e->cmd_defns[idx].cmd_desc)
170 return sprintf(s, "%s", e->cmd_defns[idx].cmd_desc); 171 return snprintf(s,
171 return sprintf(s, "%s", int_no_description); 172 strlen(e->cmd_defns[idx].cmd_desc) + 1,
173 "%s", e->cmd_defns[idx].cmd_desc);
174 return snprintf(s, strlen(int_no_description) + 1,"%s",
175 int_no_description);
172 case ENGINE_CTRL_GET_CMD_FLAGS: 176 case ENGINE_CTRL_GET_CMD_FLAGS:
173 return e->cmd_defns[idx].cmd_flags; 177 return e->cmd_defns[idx].cmd_flags;
174 } 178 }
diff --git a/src/lib/libcrypto/engine/eng_err.c b/src/lib/libcrypto/engine/eng_err.c
index 814d95ee32..f6c5630395 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-2002 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
@@ -96,7 +96,6 @@ static ERR_STRING_DATA ENGINE_str_functs[]=
96{ERR_PACK(0,ENGINE_F_ENGINE_SET_NAME,0), "ENGINE_set_name"}, 96{ERR_PACK(0,ENGINE_F_ENGINE_SET_NAME,0), "ENGINE_set_name"},
97{ERR_PACK(0,ENGINE_F_ENGINE_TABLE_REGISTER,0), "ENGINE_TABLE_REGISTER"}, 97{ERR_PACK(0,ENGINE_F_ENGINE_TABLE_REGISTER,0), "ENGINE_TABLE_REGISTER"},
98{ERR_PACK(0,ENGINE_F_ENGINE_UNLOAD_KEY,0), "ENGINE_UNLOAD_KEY"}, 98{ERR_PACK(0,ENGINE_F_ENGINE_UNLOAD_KEY,0), "ENGINE_UNLOAD_KEY"},
99{ERR_PACK(0,ENGINE_F_ENGINE_UP_REF,0), "ENGINE_up_ref"},
100{ERR_PACK(0,ENGINE_F_INT_CTRL_HELPER,0), "INT_CTRL_HELPER"}, 99{ERR_PACK(0,ENGINE_F_INT_CTRL_HELPER,0), "INT_CTRL_HELPER"},
101{ERR_PACK(0,ENGINE_F_INT_ENGINE_CONFIGURE,0), "INT_ENGINE_CONFIGURE"}, 100{ERR_PACK(0,ENGINE_F_INT_ENGINE_CONFIGURE,0), "INT_ENGINE_CONFIGURE"},
102{ERR_PACK(0,ENGINE_F_LOG_MESSAGE,0), "LOG_MESSAGE"}, 101{ERR_PACK(0,ENGINE_F_LOG_MESSAGE,0), "LOG_MESSAGE"},
diff --git a/src/lib/libcrypto/engine/eng_fat.c b/src/lib/libcrypto/engine/eng_fat.c
index 0d7dae00b2..f7edb5ad32 100644
--- a/src/lib/libcrypto/engine/eng_fat.c
+++ b/src/lib/libcrypto/engine/eng_fat.c
@@ -66,18 +66,18 @@ int ENGINE_set_default(ENGINE *e, unsigned int flags)
66 if((flags & ENGINE_METHOD_DIGESTS) && !ENGINE_set_default_digests(e)) 66 if((flags & ENGINE_METHOD_DIGESTS) && !ENGINE_set_default_digests(e))
67 return 0; 67 return 0;
68#ifndef OPENSSL_NO_RSA 68#ifndef OPENSSL_NO_RSA
69 if((flags & ENGINE_METHOD_RSA) && !ENGINE_set_default_RSA(e)) 69 if((flags & ENGINE_METHOD_RSA) & !ENGINE_set_default_RSA(e))
70 return 0; 70 return 0;
71#endif 71#endif
72#ifndef OPENSSL_NO_DSA 72#ifndef OPENSSL_NO_DSA
73 if((flags & ENGINE_METHOD_DSA) && !ENGINE_set_default_DSA(e)) 73 if((flags & ENGINE_METHOD_DSA) & !ENGINE_set_default_DSA(e))
74 return 0; 74 return 0;
75#endif 75#endif
76#ifndef OPENSSL_NO_DH 76#ifndef OPENSSL_NO_DH
77 if((flags & ENGINE_METHOD_DH) && !ENGINE_set_default_DH(e)) 77 if((flags & ENGINE_METHOD_DH) & !ENGINE_set_default_DH(e))
78 return 0; 78 return 0;
79#endif 79#endif
80 if((flags & ENGINE_METHOD_RAND) && !ENGINE_set_default_RAND(e)) 80 if((flags & ENGINE_METHOD_RAND) & !ENGINE_set_default_RAND(e))
81 return 0; 81 return 0;
82 return 1; 82 return 1;
83 } 83 }
diff --git a/src/lib/libcrypto/engine/eng_list.c b/src/lib/libcrypto/engine/eng_list.c
index 1cc3217f4c..0c220558e7 100644
--- a/src/lib/libcrypto/engine/eng_list.c
+++ b/src/lib/libcrypto/engine/eng_list.c
@@ -191,14 +191,14 @@ ENGINE *ENGINE_get_first(void)
191 { 191 {
192 ENGINE *ret; 192 ENGINE *ret;
193 193
194 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); 194 CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
195 ret = engine_list_head; 195 ret = engine_list_head;
196 if(ret) 196 if(ret)
197 { 197 {
198 ret->struct_ref++; 198 ret->struct_ref++;
199 engine_ref_debug(ret, 0, 1) 199 engine_ref_debug(ret, 0, 1)
200 } 200 }
201 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); 201 CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
202 return ret; 202 return ret;
203 } 203 }
204 204
@@ -206,14 +206,14 @@ ENGINE *ENGINE_get_last(void)
206 { 206 {
207 ENGINE *ret; 207 ENGINE *ret;
208 208
209 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); 209 CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
210 ret = engine_list_tail; 210 ret = engine_list_tail;
211 if(ret) 211 if(ret)
212 { 212 {
213 ret->struct_ref++; 213 ret->struct_ref++;
214 engine_ref_debug(ret, 0, 1) 214 engine_ref_debug(ret, 0, 1)
215 } 215 }
216 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); 216 CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
217 return ret; 217 return ret;
218 } 218 }
219 219
@@ -227,7 +227,7 @@ ENGINE *ENGINE_get_next(ENGINE *e)
227 ERR_R_PASSED_NULL_PARAMETER); 227 ERR_R_PASSED_NULL_PARAMETER);
228 return 0; 228 return 0;
229 } 229 }
230 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); 230 CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
231 ret = e->next; 231 ret = e->next;
232 if(ret) 232 if(ret)
233 { 233 {
@@ -235,7 +235,7 @@ ENGINE *ENGINE_get_next(ENGINE *e)
235 ret->struct_ref++; 235 ret->struct_ref++;
236 engine_ref_debug(ret, 0, 1) 236 engine_ref_debug(ret, 0, 1)
237 } 237 }
238 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); 238 CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
239 /* Release the structural reference to the previous ENGINE */ 239 /* Release the structural reference to the previous ENGINE */
240 ENGINE_free(e); 240 ENGINE_free(e);
241 return ret; 241 return ret;
@@ -250,7 +250,7 @@ ENGINE *ENGINE_get_prev(ENGINE *e)
250 ERR_R_PASSED_NULL_PARAMETER); 250 ERR_R_PASSED_NULL_PARAMETER);
251 return 0; 251 return 0;
252 } 252 }
253 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); 253 CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
254 ret = e->prev; 254 ret = e->prev;
255 if(ret) 255 if(ret)
256 { 256 {
@@ -258,7 +258,7 @@ ENGINE *ENGINE_get_prev(ENGINE *e)
258 ret->struct_ref++; 258 ret->struct_ref++;
259 engine_ref_debug(ret, 0, 1) 259 engine_ref_debug(ret, 0, 1)
260 } 260 }
261 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); 261 CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
262 /* Release the structural reference to the previous ENGINE */ 262 /* Release the structural reference to the previous ENGINE */
263 ENGINE_free(e); 263 ENGINE_free(e);
264 return ret; 264 return ret;
@@ -346,7 +346,7 @@ ENGINE *ENGINE_by_id(const char *id)
346 ERR_R_PASSED_NULL_PARAMETER); 346 ERR_R_PASSED_NULL_PARAMETER);
347 return NULL; 347 return NULL;
348 } 348 }
349 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); 349 CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
350 iterator = engine_list_head; 350 iterator = engine_list_head;
351 while(iterator && (strcmp(id, iterator->id) != 0)) 351 while(iterator && (strcmp(id, iterator->id) != 0))
352 iterator = iterator->next; 352 iterator = iterator->next;
@@ -372,7 +372,7 @@ ENGINE *ENGINE_by_id(const char *id)
372 engine_ref_debug(iterator, 0, 1) 372 engine_ref_debug(iterator, 0, 1)
373 } 373 }
374 } 374 }
375 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); 375 CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
376 if(iterator == NULL) 376 if(iterator == NULL)
377 { 377 {
378 ENGINEerr(ENGINE_F_ENGINE_BY_ID, 378 ENGINEerr(ENGINE_F_ENGINE_BY_ID,
@@ -381,14 +381,3 @@ ENGINE *ENGINE_by_id(const char *id)
381 } 381 }
382 return iterator; 382 return iterator;
383 } 383 }
384
385int ENGINE_up_ref(ENGINE *e)
386 {
387 if (e == NULL)
388 {
389 ENGINEerr(ENGINE_F_ENGINE_UP_REF,ERR_R_PASSED_NULL_PARAMETER);
390 return 0;
391 }
392 CRYPTO_add(&e->struct_ref,1,CRYPTO_LOCK_ENGINE);
393 return 1;
394 }
diff --git a/src/lib/libcrypto/engine/eng_openssl.c b/src/lib/libcrypto/engine/eng_openssl.c
index 54579eea2e..e9d976f46b 100644
--- a/src/lib/libcrypto/engine/eng_openssl.c
+++ b/src/lib/libcrypto/engine/eng_openssl.c
@@ -63,7 +63,6 @@
63#include <openssl/engine.h> 63#include <openssl/engine.h>
64#include <openssl/dso.h> 64#include <openssl/dso.h>
65#include <openssl/pem.h> 65#include <openssl/pem.h>
66#include <openssl/evp.h>
67 66
68/* This testing gunk is implemented (and explained) lower down. It also assumes 67/* This testing gunk is implemented (and explained) lower down. It also assumes
69 * the application explicitly calls "ENGINE_load_openssl()" because this is no 68 * the application explicitly calls "ENGINE_load_openssl()" because this is no
@@ -79,21 +78,6 @@
79/* #define TEST_ENG_OPENSSL_SHA_P_UPDATE */ 78/* #define TEST_ENG_OPENSSL_SHA_P_UPDATE */
80/* #define TEST_ENG_OPENSSL_SHA_P_FINAL */ 79/* #define TEST_ENG_OPENSSL_SHA_P_FINAL */
81 80
82/* Now check what of those algorithms are actually enabled */
83#ifdef OPENSSL_NO_RC4
84#undef TEST_ENG_OPENSSL_RC4
85#undef TEST_ENG_OPENSSL_RC4_OTHERS
86#undef TEST_ENG_OPENSSL_RC4_P_INIT
87#undef TEST_ENG_OPENSSL_RC4_P_CIPHER
88#endif
89#if defined(OPENSSL_NO_SHA) || defined(OPENSSL_NO_SHA0) || defined(OPENSSL_NO_SHA1)
90#undef TEST_ENG_OPENSSL_SHA
91#undef TEST_ENG_OPENSSL_SHA_OTHERS
92#undef TEST_ENG_OPENSSL_SHA_P_INIT
93#undef TEST_ENG_OPENSSL_SHA_P_UPDATE
94#undef TEST_ENG_OPENSSL_SHA_P_FINAL
95#endif
96
97#ifdef TEST_ENG_OPENSSL_RC4 81#ifdef TEST_ENG_OPENSSL_RC4
98static int openssl_ciphers(ENGINE *e, const EVP_CIPHER **cipher, 82static int openssl_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
99 const int **nids, int nid); 83 const int **nids, int nid);
@@ -196,6 +180,7 @@ IMPLEMENT_DYNAMIC_BIND_FN(bind_fn)
196 * the "init_key" handler is called. 180 * the "init_key" handler is called.
197 * TEST_ENG_OPENSSL_RC4_P_CIPHER - ditto for the "cipher" handler. 181 * TEST_ENG_OPENSSL_RC4_P_CIPHER - ditto for the "cipher" handler.
198 */ 182 */
183#include <openssl/evp.h>
199#include <openssl/rc4.h> 184#include <openssl/rc4.h>
200#define TEST_RC4_KEY_SIZE 16 185#define TEST_RC4_KEY_SIZE 16
201static int test_cipher_nids[] = {NID_rc4,NID_rc4_40}; 186static int test_cipher_nids[] = {NID_rc4,NID_rc4_40};
@@ -280,6 +265,7 @@ static int openssl_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
280 265
281#ifdef TEST_ENG_OPENSSL_SHA 266#ifdef TEST_ENG_OPENSSL_SHA
282/* Much the same sort of comment as for TEST_ENG_OPENSSL_RC4 */ 267/* Much the same sort of comment as for TEST_ENG_OPENSSL_RC4 */
268#include <openssl/evp.h>
283#include <openssl/sha.h> 269#include <openssl/sha.h>
284static int test_digest_nids[] = {NID_sha1}; 270static int test_digest_nids[] = {NID_sha1};
285static int test_digest_nids_number = 1; 271static int test_digest_nids_number = 1;
diff --git a/src/lib/libcrypto/engine/engine.h b/src/lib/libcrypto/engine/engine.h
index 8686879e1a..fd17ff616d 100644
--- a/src/lib/libcrypto/engine/engine.h
+++ b/src/lib/libcrypto/engine/engine.h
@@ -59,12 +59,6 @@
59#ifndef HEADER_ENGINE_H 59#ifndef HEADER_ENGINE_H
60#define HEADER_ENGINE_H 60#define HEADER_ENGINE_H
61 61
62#include <openssl/opensslconf.h>
63
64#ifdef OPENSSL_NO_ENGINE
65#error ENGINE is disabled.
66#endif
67
68#include <openssl/ossl_typ.h> 62#include <openssl/ossl_typ.h>
69#include <openssl/bn.h> 63#include <openssl/bn.h>
70#ifndef OPENSSL_NO_RSA 64#ifndef OPENSSL_NO_RSA
@@ -313,8 +307,11 @@ void ENGINE_load_ubsec(void);
313void ENGINE_load_aep(void); 307void ENGINE_load_aep(void);
314void ENGINE_load_sureware(void); 308void ENGINE_load_sureware(void);
315void ENGINE_load_4758cca(void); 309void ENGINE_load_4758cca(void);
316void ENGINE_load_cryptodev(void); 310void ENGINE_load_openbsd_dev_crypto(void);
317void ENGINE_load_builtin_engines(void); 311void ENGINE_load_builtin_engines(void);
312#ifdef __OpenBSD__
313void ENGINE_load_cryptodev(void);
314#endif
318 315
319/* Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation 316/* Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation
320 * "registry" handling. */ 317 * "registry" handling. */
@@ -412,7 +409,6 @@ int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg,
412 * compatibility! */ 409 * compatibility! */
413ENGINE *ENGINE_new(void); 410ENGINE *ENGINE_new(void);
414int ENGINE_free(ENGINE *e); 411int ENGINE_free(ENGINE *e);
415int ENGINE_up_ref(ENGINE *e);
416int ENGINE_set_id(ENGINE *e, const char *id); 412int ENGINE_set_id(ENGINE *e, const char *id);
417int ENGINE_set_name(ENGINE *e, const char *name); 413int ENGINE_set_name(ENGINE *e, const char *name);
418int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth); 414int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth);
@@ -669,7 +665,6 @@ void ERR_load_ENGINE_strings(void);
669#define ENGINE_F_ENGINE_SET_NAME 130 665#define ENGINE_F_ENGINE_SET_NAME 130
670#define ENGINE_F_ENGINE_TABLE_REGISTER 184 666#define ENGINE_F_ENGINE_TABLE_REGISTER 184
671#define ENGINE_F_ENGINE_UNLOAD_KEY 152 667#define ENGINE_F_ENGINE_UNLOAD_KEY 152
672#define ENGINE_F_ENGINE_UP_REF 190
673#define ENGINE_F_INT_CTRL_HELPER 172 668#define ENGINE_F_INT_CTRL_HELPER 172
674#define ENGINE_F_INT_ENGINE_CONFIGURE 188 669#define ENGINE_F_INT_ENGINE_CONFIGURE 188
675#define ENGINE_F_LOG_MESSAGE 141 670#define ENGINE_F_LOG_MESSAGE 141
diff --git a/src/lib/libcrypto/engine/enginetest.c b/src/lib/libcrypto/engine/enginetest.c
new file mode 100644
index 0000000000..87fa8c57b7
--- /dev/null
+++ b/src/lib/libcrypto/engine/enginetest.c
@@ -0,0 +1,274 @@
1/* crypto/engine/enginetest.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 <openssl/e_os2.h>
60#include <stdio.h>
61#include <string.h>
62#include <openssl/buffer.h>
63#include <openssl/crypto.h>
64#include <openssl/engine.h>
65#include <openssl/err.h>
66
67static void display_engine_list()
68 {
69 ENGINE *h;
70 int loop;
71
72 h = ENGINE_get_first();
73 loop = 0;
74 printf("listing available engine types\n");
75 while(h)
76 {
77 printf("engine %i, id = \"%s\", name = \"%s\"\n",
78 loop++, ENGINE_get_id(h), ENGINE_get_name(h));
79 h = ENGINE_get_next(h);
80 }
81 printf("end of list\n");
82 /* ENGINE_get_first() increases the struct_ref counter, so we
83 must call ENGINE_free() to decrease it again */
84 ENGINE_free(h);
85 }
86
87int main(int argc, char *argv[])
88 {
89 ENGINE *block[512];
90 char buf[256];
91 const char *id, *name;
92 ENGINE *ptr;
93 int loop;
94 int to_return = 1;
95 ENGINE *new_h1 = NULL;
96 ENGINE *new_h2 = NULL;
97 ENGINE *new_h3 = NULL;
98 ENGINE *new_h4 = NULL;
99
100 /* enable memory leak checking unless explicitly disabled */
101 if (!((getenv("OPENSSL_DEBUG_MEMORY") != NULL) && (0 == strcmp(getenv("OPENSSL_DEBUG_MEMORY"), "off"))))
102 {
103 CRYPTO_malloc_debug_init();
104 CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
105 }
106 else
107 {
108 /* OPENSSL_DEBUG_MEMORY=off */
109 CRYPTO_set_mem_debug_functions(0, 0, 0, 0, 0);
110 }
111 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
112 ERR_load_crypto_strings();
113
114 memset(block, 0, 512 * sizeof(ENGINE *));
115 if(((new_h1 = ENGINE_new()) == NULL) ||
116 !ENGINE_set_id(new_h1, "test_id0") ||
117 !ENGINE_set_name(new_h1, "First test item") ||
118 ((new_h2 = ENGINE_new()) == NULL) ||
119 !ENGINE_set_id(new_h2, "test_id1") ||
120 !ENGINE_set_name(new_h2, "Second test item") ||
121 ((new_h3 = ENGINE_new()) == NULL) ||
122 !ENGINE_set_id(new_h3, "test_id2") ||
123 !ENGINE_set_name(new_h3, "Third test item") ||
124 ((new_h4 = ENGINE_new()) == NULL) ||
125 !ENGINE_set_id(new_h4, "test_id3") ||
126 !ENGINE_set_name(new_h4, "Fourth test item"))
127 {
128 printf("Couldn't set up test ENGINE structures\n");
129 goto end;
130 }
131 printf("\nenginetest beginning\n\n");
132 display_engine_list();
133 if(!ENGINE_add(new_h1))
134 {
135 printf("Add failed!\n");
136 goto end;
137 }
138 display_engine_list();
139 ptr = ENGINE_get_first();
140 if(!ENGINE_remove(ptr))
141 {
142 printf("Remove failed!\n");
143 goto end;
144 }
145 if (ptr)
146 ENGINE_free(ptr);
147 display_engine_list();
148 if(!ENGINE_add(new_h3) || !ENGINE_add(new_h2))
149 {
150 printf("Add failed!\n");
151 goto end;
152 }
153 display_engine_list();
154 if(!ENGINE_remove(new_h2))
155 {
156 printf("Remove failed!\n");
157 goto end;
158 }
159 display_engine_list();
160 if(!ENGINE_add(new_h4))
161 {
162 printf("Add failed!\n");
163 goto end;
164 }
165 display_engine_list();
166 if(ENGINE_add(new_h3))
167 {
168 printf("Add *should* have failed but didn't!\n");
169 goto end;
170 }
171 else
172 printf("Add that should fail did.\n");
173 ERR_clear_error();
174 if(ENGINE_remove(new_h2))
175 {
176 printf("Remove *should* have failed but didn't!\n");
177 goto end;
178 }
179 else
180 printf("Remove that should fail did.\n");
181 ERR_clear_error();
182 if(!ENGINE_remove(new_h3))
183 {
184 printf("Remove failed!\n");
185 goto end;
186 }
187 display_engine_list();
188 if(!ENGINE_remove(new_h4))
189 {
190 printf("Remove failed!\n");
191 goto end;
192 }
193 display_engine_list();
194 /* Depending on whether there's any hardware support compiled
195 * in, this remove may be destined to fail. */
196 ptr = ENGINE_get_first();
197 if(ptr)
198 if(!ENGINE_remove(ptr))
199 printf("Remove failed!i - probably no hardware "
200 "support present.\n");
201 if (ptr)
202 ENGINE_free(ptr);
203 display_engine_list();
204 if(!ENGINE_add(new_h1) || !ENGINE_remove(new_h1))
205 {
206 printf("Couldn't add and remove to an empty list!\n");
207 goto end;
208 }
209 else
210 printf("Successfully added and removed to an empty list!\n");
211 printf("About to beef up the engine-type list\n");
212 for(loop = 0; loop < 512; loop++)
213 {
214 sprintf(buf, "id%i", loop);
215 id = BUF_strdup(buf);
216 sprintf(buf, "Fake engine type %i", loop);
217 name = BUF_strdup(buf);
218 if(((block[loop] = ENGINE_new()) == NULL) ||
219 !ENGINE_set_id(block[loop], id) ||
220 !ENGINE_set_name(block[loop], name))
221 {
222 printf("Couldn't create block of ENGINE structures.\n"
223 "I'll probably also core-dump now, damn.\n");
224 goto end;
225 }
226 }
227 for(loop = 0; loop < 512; loop++)
228 {
229 if(!ENGINE_add(block[loop]))
230 {
231 printf("\nAdding stopped at %i, (%s,%s)\n",
232 loop, ENGINE_get_id(block[loop]),
233 ENGINE_get_name(block[loop]));
234 goto cleanup_loop;
235 }
236 else
237 printf("."); fflush(stdout);
238 }
239cleanup_loop:
240 printf("\nAbout to empty the engine-type list\n");
241 while((ptr = ENGINE_get_first()) != NULL)
242 {
243 if(!ENGINE_remove(ptr))
244 {
245 printf("\nRemove failed!\n");
246 goto end;
247 }
248 ENGINE_free(ptr);
249 printf("."); fflush(stdout);
250 }
251 for(loop = 0; loop < 512; loop++)
252 {
253 OPENSSL_free((void *)ENGINE_get_id(block[loop]));
254 OPENSSL_free((void *)ENGINE_get_name(block[loop]));
255 }
256 printf("\nTests completed happily\n");
257 to_return = 0;
258end:
259 if(to_return)
260 ERR_print_errors_fp(stderr);
261 if(new_h1) ENGINE_free(new_h1);
262 if(new_h2) ENGINE_free(new_h2);
263 if(new_h3) ENGINE_free(new_h3);
264 if(new_h4) ENGINE_free(new_h4);
265 for(loop = 0; loop < 512; loop++)
266 if(block[loop])
267 ENGINE_free(block[loop]);
268 ENGINE_cleanup();
269 CRYPTO_cleanup_all_ex_data();
270 ERR_free_strings();
271 ERR_remove_state(0);
272 CRYPTO_mem_leaks_fp(stderr);
273 return to_return;
274 }
diff --git a/src/lib/libcrypto/engine/hw.ec b/src/lib/libcrypto/engine/hw.ec
new file mode 100644
index 0000000000..5481a43918
--- /dev/null
+++ b/src/lib/libcrypto/engine/hw.ec
@@ -0,0 +1,8 @@
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
new file mode 100644
index 0000000000..6d41b9ed2a
--- /dev/null
+++ b/src/lib/libcrypto/engine/hw_4758_cca.c
@@ -0,0 +1,967 @@
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
226static ENGINE *engine_4758_cca(void)
227 {
228 ENGINE *ret = ENGINE_new();
229 if(!ret)
230 return NULL;
231 if(!bind_helper(ret))
232 {
233 ENGINE_free(ret);
234 return NULL;
235 }
236 return ret;
237 }
238
239void ENGINE_load_4758cca(void)
240 {
241 ENGINE *e_4758 = engine_4758_cca();
242 if (!e_4758) return;
243 ENGINE_add(e_4758);
244 ENGINE_free(e_4758);
245 ERR_clear_error();
246 }
247
248static int ibm_4758_cca_destroy(ENGINE *e)
249 {
250 ERR_unload_CCA4758_strings();
251 free_CCA4758_LIB_NAME();
252 return 1;
253 }
254
255static int ibm_4758_cca_init(ENGINE *e)
256 {
257 if(dso)
258 {
259 CCA4758err(CCA4758_F_IBM_4758_CCA_INIT,CCA4758_R_ALREADY_LOADED);
260 goto err;
261 }
262
263 dso = DSO_load(NULL, get_CCA4758_LIB_NAME(), NULL, 0);
264 if(!dso)
265 {
266 CCA4758err(CCA4758_F_IBM_4758_CCA_INIT,CCA4758_R_DSO_FAILURE);
267 goto err;
268 }
269
270#ifndef OPENSSL_NO_RSA
271 if(!(keyRecordRead = (F_KEYRECORDREAD)
272 DSO_bind_func(dso, n_keyRecordRead)) ||
273 !(randomNumberGenerate = (F_RANDOMNUMBERGENERATE)
274 DSO_bind_func(dso, n_randomNumberGenerate)) ||
275 !(digitalSignatureGenerate = (F_DIGITALSIGNATUREGENERATE)
276 DSO_bind_func(dso, n_digitalSignatureGenerate)) ||
277 !(digitalSignatureVerify = (F_DIGITALSIGNATUREVERIFY)
278 DSO_bind_func(dso, n_digitalSignatureVerify)) ||
279 !(publicKeyExtract = (F_PUBLICKEYEXTRACT)
280 DSO_bind_func(dso, n_publicKeyExtract)) ||
281 !(pkaEncrypt = (F_PKAENCRYPT)
282 DSO_bind_func(dso, n_pkaEncrypt)) ||
283 !(pkaDecrypt = (F_PKADECRYPT)
284 DSO_bind_func(dso, n_pkaDecrypt)))
285 {
286 CCA4758err(CCA4758_F_IBM_4758_CCA_INIT,CCA4758_R_DSO_FAILURE);
287 goto err;
288 }
289#else
290 if(!(randomNumberGenerate = (F_RANDOMNUMBERGENERATE)
291 DSO_bind_func(dso, n_randomNumberGenerate)))
292 {
293 CCA4758err(CCA4758_F_IBM_4758_CCA_INIT,CCA4758_R_DSO_FAILURE);
294 goto err;
295 }
296#endif
297
298 hndidx = RSA_get_ex_new_index(0, "IBM 4758 CCA RSA key handle",
299 NULL, NULL, cca_ex_free);
300
301 return 1;
302err:
303 if(dso)
304 DSO_free(dso);
305 dso = NULL;
306
307 keyRecordRead = (F_KEYRECORDREAD)0;
308 randomNumberGenerate = (F_RANDOMNUMBERGENERATE)0;
309 digitalSignatureGenerate = (F_DIGITALSIGNATUREGENERATE)0;
310 digitalSignatureVerify = (F_DIGITALSIGNATUREVERIFY)0;
311 publicKeyExtract = (F_PUBLICKEYEXTRACT)0;
312 pkaEncrypt = (F_PKAENCRYPT)0;
313 pkaDecrypt = (F_PKADECRYPT)0;
314 return 0;
315 }
316
317static int ibm_4758_cca_finish(ENGINE *e)
318 {
319 free_CCA4758_LIB_NAME();
320 if(!dso)
321 {
322 CCA4758err(CCA4758_F_IBM_4758_CCA_FINISH,
323 CCA4758_R_NOT_LOADED);
324 return 0;
325 }
326 if(!DSO_free(dso))
327 {
328 CCA4758err(CCA4758_F_IBM_4758_CCA_FINISH,
329 CCA4758_R_UNIT_FAILURE);
330 return 0;
331 }
332 dso = NULL;
333 keyRecordRead = (F_KEYRECORDREAD)0;
334 randomNumberGenerate = (F_RANDOMNUMBERGENERATE)0;
335 digitalSignatureGenerate = (F_DIGITALSIGNATUREGENERATE)0;
336 digitalSignatureVerify = (F_DIGITALSIGNATUREVERIFY)0;
337 publicKeyExtract = (F_PUBLICKEYEXTRACT)0;
338 pkaEncrypt = (F_PKAENCRYPT)0;
339 pkaDecrypt = (F_PKADECRYPT)0;
340 return 1;
341 }
342
343static int ibm_4758_cca_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
344 {
345 int initialised = ((dso == NULL) ? 0 : 1);
346 switch(cmd)
347 {
348 case CCA4758_CMD_SO_PATH:
349 if(p == NULL)
350 {
351 CCA4758err(CCA4758_F_IBM_4758_CCA_CTRL,
352 ERR_R_PASSED_NULL_PARAMETER);
353 return 0;
354 }
355 if(initialised)
356 {
357 CCA4758err(CCA4758_F_IBM_4758_CCA_CTRL,
358 CCA4758_R_ALREADY_LOADED);
359 return 0;
360 }
361 return set_CCA4758_LIB_NAME((const char *)p);
362 default:
363 break;
364 }
365 CCA4758err(CCA4758_F_IBM_4758_CCA_CTRL,
366 CCA4758_R_COMMAND_NOT_IMPLEMENTED);
367 return 0;
368 }
369
370#ifndef OPENSSL_NO_RSA
371
372#define MAX_CCA_PKA_TOKEN_SIZE 2500
373
374static EVP_PKEY *ibm_4758_load_privkey(ENGINE* e, const char* key_id,
375 UI_METHOD *ui_method, void *callback_data)
376 {
377 RSA *rtmp = NULL;
378 EVP_PKEY *res = NULL;
379 unsigned char* keyToken = NULL;
380 unsigned char pubKeyToken[MAX_CCA_PKA_TOKEN_SIZE];
381 long pubKeyTokenLength = MAX_CCA_PKA_TOKEN_SIZE;
382 long keyTokenLength = MAX_CCA_PKA_TOKEN_SIZE;
383 long returnCode;
384 long reasonCode;
385 long exitDataLength = 0;
386 long ruleArrayLength = 0;
387 unsigned char exitData[8];
388 unsigned char ruleArray[8];
389 unsigned char keyLabel[64];
390 long keyLabelLength = strlen(key_id);
391 unsigned char modulus[256];
392 long modulusFieldLength = sizeof(modulus);
393 long modulusLength = 0;
394 unsigned char exponent[256];
395 long exponentLength = sizeof(exponent);
396
397 if (keyLabelLength > sizeof(keyLabel))
398 {
399 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY,
400 CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
401 return NULL;
402 }
403
404 memset(keyLabel,' ', sizeof(keyLabel));
405 memcpy(keyLabel, key_id, keyLabelLength);
406
407 keyToken = OPENSSL_malloc(MAX_CCA_PKA_TOKEN_SIZE + sizeof(long));
408 if (!keyToken)
409 {
410 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY,
411 ERR_R_MALLOC_FAILURE);
412 goto err;
413 }
414
415 keyRecordRead(&returnCode, &reasonCode, &exitDataLength,
416 exitData, &ruleArrayLength, ruleArray, keyLabel,
417 &keyTokenLength, keyToken+sizeof(long));
418
419 if (returnCode)
420 {
421 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY,
422 CCA4758_R_FAILED_LOADING_PRIVATE_KEY);
423 goto err;
424 }
425
426 publicKeyExtract(&returnCode, &reasonCode, &exitDataLength,
427 exitData, &ruleArrayLength, ruleArray, &keyTokenLength,
428 keyToken+sizeof(long), &pubKeyTokenLength, pubKeyToken);
429
430 if (returnCode)
431 {
432 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY,
433 CCA4758_R_FAILED_LOADING_PRIVATE_KEY);
434 goto err;
435 }
436
437 if (!getModulusAndExponent(pubKeyToken, &exponentLength,
438 exponent, &modulusLength, &modulusFieldLength,
439 modulus))
440 {
441 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY,
442 CCA4758_R_FAILED_LOADING_PRIVATE_KEY);
443 goto err;
444 }
445
446 (*(long*)keyToken) = keyTokenLength;
447 rtmp = RSA_new_method(e);
448 RSA_set_ex_data(rtmp, hndidx, (char *)keyToken);
449
450 rtmp->e = BN_bin2bn(exponent, exponentLength, NULL);
451 rtmp->n = BN_bin2bn(modulus, modulusFieldLength, NULL);
452 rtmp->flags |= RSA_FLAG_EXT_PKEY;
453
454 res = EVP_PKEY_new();
455 EVP_PKEY_assign_RSA(res, rtmp);
456
457 return res;
458err:
459 if (keyToken)
460 OPENSSL_free(keyToken);
461 if (res)
462 EVP_PKEY_free(res);
463 if (rtmp)
464 RSA_free(rtmp);
465 return NULL;
466 }
467
468static EVP_PKEY *ibm_4758_load_pubkey(ENGINE* e, const char* key_id,
469 UI_METHOD *ui_method, void *callback_data)
470 {
471 RSA *rtmp = NULL;
472 EVP_PKEY *res = NULL;
473 unsigned char* keyToken = NULL;
474 long keyTokenLength = MAX_CCA_PKA_TOKEN_SIZE;
475 long returnCode;
476 long reasonCode;
477 long exitDataLength = 0;
478 long ruleArrayLength = 0;
479 unsigned char exitData[8];
480 unsigned char ruleArray[8];
481 unsigned char keyLabel[64];
482 long keyLabelLength = strlen(key_id);
483 unsigned char modulus[512];
484 long modulusFieldLength = sizeof(modulus);
485 long modulusLength = 0;
486 unsigned char exponent[512];
487 long exponentLength = sizeof(exponent);
488
489 if (keyLabelLength > sizeof(keyLabel))
490 {
491 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY,
492 CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
493 return NULL;
494 }
495
496 memset(keyLabel,' ', sizeof(keyLabel));
497 memcpy(keyLabel, key_id, keyLabelLength);
498
499 keyToken = OPENSSL_malloc(MAX_CCA_PKA_TOKEN_SIZE + sizeof(long));
500 if (!keyToken)
501 {
502 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PUBKEY,
503 ERR_R_MALLOC_FAILURE);
504 goto err;
505 }
506
507 keyRecordRead(&returnCode, &reasonCode, &exitDataLength, exitData,
508 &ruleArrayLength, ruleArray, keyLabel, &keyTokenLength,
509 keyToken+sizeof(long));
510
511 if (returnCode)
512 {
513 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY,
514 ERR_R_MALLOC_FAILURE);
515 goto err;
516 }
517
518 if (!getModulusAndExponent(keyToken+sizeof(long), &exponentLength,
519 exponent, &modulusLength, &modulusFieldLength, modulus))
520 {
521 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY,
522 CCA4758_R_FAILED_LOADING_PUBLIC_KEY);
523 goto err;
524 }
525
526 (*(long*)keyToken) = keyTokenLength;
527 rtmp = RSA_new_method(e);
528 RSA_set_ex_data(rtmp, hndidx, (char *)keyToken);
529 rtmp->e = BN_bin2bn(exponent, exponentLength, NULL);
530 rtmp->n = BN_bin2bn(modulus, modulusFieldLength, NULL);
531 rtmp->flags |= RSA_FLAG_EXT_PKEY;
532 res = EVP_PKEY_new();
533 EVP_PKEY_assign_RSA(res, rtmp);
534
535 return res;
536err:
537 if (keyToken)
538 OPENSSL_free(keyToken);
539 if (res)
540 EVP_PKEY_free(res);
541 if (rtmp)
542 RSA_free(rtmp);
543 return NULL;
544 }
545
546static int cca_rsa_pub_enc(int flen, const unsigned char *from,
547 unsigned char *to, RSA *rsa,int padding)
548 {
549 long returnCode;
550 long reasonCode;
551 long lflen = flen;
552 long exitDataLength = 0;
553 unsigned char exitData[8];
554 long ruleArrayLength = 1;
555 unsigned char ruleArray[8] = "PKCS-1.2";
556 long dataStructureLength = 0;
557 unsigned char dataStructure[8];
558 long outputLength = RSA_size(rsa);
559 long keyTokenLength;
560 unsigned char* keyToken = (unsigned char*)RSA_get_ex_data(rsa, hndidx);
561
562 keyTokenLength = *(long*)keyToken;
563 keyToken+=sizeof(long);
564
565 pkaEncrypt(&returnCode, &reasonCode, &exitDataLength, exitData,
566 &ruleArrayLength, ruleArray, &lflen, (unsigned char*)from,
567 &dataStructureLength, dataStructure, &keyTokenLength,
568 keyToken, &outputLength, to);
569
570 if (returnCode || reasonCode)
571 return -(returnCode << 16 | reasonCode);
572 return outputLength;
573 }
574
575static int cca_rsa_priv_dec(int flen, const unsigned char *from,
576 unsigned char *to, RSA *rsa,int padding)
577 {
578 long returnCode;
579 long reasonCode;
580 long lflen = flen;
581 long exitDataLength = 0;
582 unsigned char exitData[8];
583 long ruleArrayLength = 1;
584 unsigned char ruleArray[8] = "PKCS-1.2";
585 long dataStructureLength = 0;
586 unsigned char dataStructure[8];
587 long outputLength = RSA_size(rsa);
588 long keyTokenLength;
589 unsigned char* keyToken = (unsigned char*)RSA_get_ex_data(rsa, hndidx);
590
591 keyTokenLength = *(long*)keyToken;
592 keyToken+=sizeof(long);
593
594 pkaDecrypt(&returnCode, &reasonCode, &exitDataLength, exitData,
595 &ruleArrayLength, ruleArray, &lflen, (unsigned char*)from,
596 &dataStructureLength, dataStructure, &keyTokenLength,
597 keyToken, &outputLength, to);
598
599 return (returnCode | reasonCode) ? 0 : 1;
600 }
601
602#define SSL_SIG_LEN 36
603
604static int cca_rsa_verify(int type, const unsigned char *m, unsigned int m_len,
605 unsigned char *sigbuf, unsigned int siglen, const RSA *rsa)
606 {
607 long returnCode;
608 long reasonCode;
609 long lsiglen = siglen;
610 long exitDataLength = 0;
611 unsigned char exitData[8];
612 long ruleArrayLength = 1;
613 unsigned char ruleArray[8] = "PKCS-1.1";
614 long keyTokenLength;
615 unsigned char* keyToken = (unsigned char*)RSA_get_ex_data(rsa, hndidx);
616 long length = SSL_SIG_LEN;
617 long keyLength ;
618 unsigned char *hashBuffer = NULL;
619 X509_SIG sig;
620 ASN1_TYPE parameter;
621 X509_ALGOR algorithm;
622 ASN1_OCTET_STRING digest;
623
624 keyTokenLength = *(long*)keyToken;
625 keyToken+=sizeof(long);
626
627 if (type == NID_md5 || type == NID_sha1)
628 {
629 sig.algor = &algorithm;
630 algorithm.algorithm = OBJ_nid2obj(type);
631
632 if (!algorithm.algorithm)
633 {
634 CCA4758err(CCA4758_F_IBM_4758_CCA_VERIFY,
635 CCA4758_R_UNKNOWN_ALGORITHM_TYPE);
636 return 0;
637 }
638
639 if (!algorithm.algorithm->length)
640 {
641 CCA4758err(CCA4758_F_IBM_4758_CCA_VERIFY,
642 CCA4758_R_ASN1_OID_UNKNOWN_FOR_MD);
643 return 0;
644 }
645
646 parameter.type = V_ASN1_NULL;
647 parameter.value.ptr = NULL;
648 algorithm.parameter = &parameter;
649
650 sig.digest = &digest;
651 sig.digest->data = (unsigned char*)m;
652 sig.digest->length = m_len;
653
654 length = i2d_X509_SIG(&sig, NULL);
655 }
656
657 keyLength = RSA_size(rsa);
658
659 if (length - RSA_PKCS1_PADDING > keyLength)
660 {
661 CCA4758err(CCA4758_F_IBM_4758_CCA_VERIFY,
662 CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
663 return 0;
664 }
665
666 switch (type)
667 {
668 case NID_md5_sha1 :
669 if (m_len != SSL_SIG_LEN)
670 {
671 CCA4758err(CCA4758_F_IBM_4758_CCA_VERIFY,
672 CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
673 return 0;
674 }
675
676 hashBuffer = (unsigned char *)m;
677 length = m_len;
678 break;
679 case NID_md5 :
680 {
681 unsigned char *ptr;
682 ptr = hashBuffer = OPENSSL_malloc(
683 (unsigned int)keyLength+1);
684 if (!hashBuffer)
685 {
686 CCA4758err(CCA4758_F_IBM_4758_CCA_VERIFY,
687 ERR_R_MALLOC_FAILURE);
688 return 0;
689 }
690
691 i2d_X509_SIG(&sig, &ptr);
692 }
693 break;
694 case NID_sha1 :
695 {
696 unsigned char *ptr;
697 ptr = hashBuffer = OPENSSL_malloc(
698 (unsigned int)keyLength+1);
699 if (!hashBuffer)
700 {
701 CCA4758err(CCA4758_F_IBM_4758_CCA_VERIFY,
702 ERR_R_MALLOC_FAILURE);
703 return 0;
704 }
705 i2d_X509_SIG(&sig, &ptr);
706 }
707 break;
708 default:
709 return 0;
710 }
711
712 digitalSignatureVerify(&returnCode, &reasonCode, &exitDataLength,
713 exitData, &ruleArrayLength, ruleArray, &keyTokenLength,
714 keyToken, &length, hashBuffer, &lsiglen, sigbuf);
715
716 if (type == NID_sha1 || type == NID_md5)
717 {
718 memset(hashBuffer, 0, keyLength+1);
719 OPENSSL_free(hashBuffer);
720 }
721
722 return ((returnCode || reasonCode) ? 0 : 1);
723 }
724
725#define SSL_SIG_LEN 36
726
727static int cca_rsa_sign(int type, const unsigned char *m, unsigned int m_len,
728 unsigned char *sigret, unsigned int *siglen, const RSA *rsa)
729 {
730 long returnCode;
731 long reasonCode;
732 long exitDataLength = 0;
733 unsigned char exitData[8];
734 long ruleArrayLength = 1;
735 unsigned char ruleArray[8] = "PKCS-1.1";
736 long outputLength=256;
737 long outputBitLength;
738 long keyTokenLength;
739 unsigned char *hashBuffer = NULL;
740 unsigned char* keyToken = (unsigned char*)RSA_get_ex_data(rsa, hndidx);
741 long length = SSL_SIG_LEN;
742 long keyLength ;
743 X509_SIG sig;
744 ASN1_TYPE parameter;
745 X509_ALGOR algorithm;
746 ASN1_OCTET_STRING digest;
747
748 keyTokenLength = *(long*)keyToken;
749 keyToken+=sizeof(long);
750
751 if (type == NID_md5 || type == NID_sha1)
752 {
753 sig.algor = &algorithm;
754 algorithm.algorithm = OBJ_nid2obj(type);
755
756 if (!algorithm.algorithm)
757 {
758 CCA4758err(CCA4758_F_IBM_4758_CCA_SIGN,
759 CCA4758_R_UNKNOWN_ALGORITHM_TYPE);
760 return 0;
761 }
762
763 if (!algorithm.algorithm->length)
764 {
765 CCA4758err(CCA4758_F_IBM_4758_CCA_SIGN,
766 CCA4758_R_ASN1_OID_UNKNOWN_FOR_MD);
767 return 0;
768 }
769
770 parameter.type = V_ASN1_NULL;
771 parameter.value.ptr = NULL;
772 algorithm.parameter = &parameter;
773
774 sig.digest = &digest;
775 sig.digest->data = (unsigned char*)m;
776 sig.digest->length = m_len;
777
778 length = i2d_X509_SIG(&sig, NULL);
779 }
780
781 keyLength = RSA_size(rsa);
782
783 if (length - RSA_PKCS1_PADDING > keyLength)
784 {
785 CCA4758err(CCA4758_F_IBM_4758_CCA_SIGN,
786 CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
787 return 0;
788 }
789
790 switch (type)
791 {
792 case NID_md5_sha1 :
793 if (m_len != SSL_SIG_LEN)
794 {
795 CCA4758err(CCA4758_F_IBM_4758_CCA_SIGN,
796 CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
797 return 0;
798 }
799 hashBuffer = (unsigned char*)m;
800 length = m_len;
801 break;
802 case NID_md5 :
803 {
804 unsigned char *ptr;
805 ptr = hashBuffer = OPENSSL_malloc(
806 (unsigned int)keyLength+1);
807 if (!hashBuffer)
808 {
809 CCA4758err(CCA4758_F_IBM_4758_CCA_VERIFY,
810 ERR_R_MALLOC_FAILURE);
811 return 0;
812 }
813 i2d_X509_SIG(&sig, &ptr);
814 }
815 break;
816 case NID_sha1 :
817 {
818 unsigned char *ptr;
819 ptr = hashBuffer = OPENSSL_malloc(
820 (unsigned int)keyLength+1);
821 if (!hashBuffer)
822 {
823 CCA4758err(CCA4758_F_IBM_4758_CCA_VERIFY,
824 ERR_R_MALLOC_FAILURE);
825 return 0;
826 }
827 i2d_X509_SIG(&sig, &ptr);
828 }
829 break;
830 default:
831 return 0;
832 }
833
834 digitalSignatureGenerate(&returnCode, &reasonCode, &exitDataLength,
835 exitData, &ruleArrayLength, ruleArray, &keyTokenLength,
836 keyToken, &length, hashBuffer, &outputLength, &outputBitLength,
837 sigret);
838
839 if (type == NID_sha1 || type == NID_md5)
840 {
841 memset(hashBuffer, 0, keyLength+1);
842 OPENSSL_free(hashBuffer);
843 }
844
845 *siglen = outputLength;
846
847 return ((returnCode || reasonCode) ? 0 : 1);
848 }
849
850static int getModulusAndExponent(const unsigned char*token, long *exponentLength,
851 unsigned char *exponent, long *modulusLength, long *modulusFieldLength,
852 unsigned char *modulus)
853 {
854 unsigned long len;
855
856 if (*token++ != (char)0x1E) /* internal PKA token? */
857 return 0;
858
859 if (*token++) /* token version must be zero */
860 return 0;
861
862 len = *token++;
863 len = len << 8;
864 len |= (unsigned char)*token++;
865
866 token += 4; /* skip reserved bytes */
867
868 if (*token++ == (char)0x04)
869 {
870 if (*token++) /* token version must be zero */
871 return 0;
872
873 len = *token++;
874 len = len << 8;
875 len |= (unsigned char)*token++;
876
877 token+=2; /* skip reserved section */
878
879 len = *token++;
880 len = len << 8;
881 len |= (unsigned char)*token++;
882
883 *exponentLength = len;
884
885 len = *token++;
886 len = len << 8;
887 len |= (unsigned char)*token++;
888
889 *modulusLength = len;
890
891 len = *token++;
892 len = len << 8;
893 len |= (unsigned char)*token++;
894
895 *modulusFieldLength = len;
896
897 memcpy(exponent, token, *exponentLength);
898 token+= *exponentLength;
899
900 memcpy(modulus, token, *modulusFieldLength);
901 return 1;
902 }
903 return 0;
904 }
905
906#endif /* OPENSSL_NO_RSA */
907
908static int cca_random_status(void)
909 {
910 return 1;
911 }
912
913static int cca_get_random_bytes(unsigned char* buf, int num)
914 {
915 long ret_code;
916 long reason_code;
917 long exit_data_length;
918 unsigned char exit_data[4];
919 unsigned char form[] = "RANDOM ";
920 unsigned char rand_buf[8];
921
922 while(num >= sizeof(rand_buf))
923 {
924 randomNumberGenerate(&ret_code, &reason_code, &exit_data_length,
925 exit_data, form, rand_buf);
926 if (ret_code)
927 return 0;
928 num -= sizeof(rand_buf);
929 memcpy(buf, rand_buf, sizeof(rand_buf));
930 buf += sizeof(rand_buf);
931 }
932
933 if (num)
934 {
935 randomNumberGenerate(&ret_code, &reason_code, NULL, NULL,
936 form, rand_buf);
937 if (ret_code)
938 return 0;
939 memcpy(buf, rand_buf, num);
940 }
941
942 return 1;
943 }
944
945static void cca_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad, int idx,
946 long argl, void *argp)
947 {
948 if (item)
949 OPENSSL_free(item);
950 }
951
952/* Goo to handle building as a dynamic engine */
953#ifdef ENGINE_DYNAMIC_SUPPORT
954static int bind_fn(ENGINE *e, const char *id)
955 {
956 if(id && (strcmp(id, engine_4758_cca_id) != 0))
957 return 0;
958 if(!bind_helper(e))
959 return 0;
960 return 1;
961 }
962IMPLEMENT_DYNAMIC_CHECK_FN()
963IMPLEMENT_DYNAMIC_BIND_FN(bind_fn)
964#endif /* ENGINE_DYNAMIC_SUPPORT */
965
966#endif /* !OPENSSL_NO_HW_4758_CCA */
967#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
new file mode 100644
index 0000000000..7ea5c63707
--- /dev/null
+++ b/src/lib/libcrypto/engine/hw_4758_cca_err.c
@@ -0,0 +1,149 @@
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
new file mode 100644
index 0000000000..2fc563ab11
--- /dev/null
+++ b/src/lib/libcrypto/engine/hw_4758_cca_err.h
@@ -0,0 +1,93 @@
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
new file mode 100644
index 0000000000..8b8380a582
--- /dev/null
+++ b/src/lib/libcrypto/engine/hw_aep.c
@@ -0,0 +1,1119 @@
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
478 p_AEP_OpenConnection = NULL;
479 p_AEP_ModExp = NULL;
480 p_AEP_ModExpCrt = NULL;
481#ifdef AEPRAND
482 p_AEP_GenRandom = NULL;
483#endif
484 p_AEP_Initialize = NULL;
485 p_AEP_Finalize = NULL;
486 p_AEP_SetBNCallBacks = NULL;
487 p_AEP_CloseConnection = NULL;
488
489 return to_return;
490 }
491
492/* Destructor (complements the "ENGINE_aep()" constructor) */
493static int aep_destroy(ENGINE *e)
494 {
495 free_AEP_LIBNAME();
496 ERR_unload_AEPHK_strings();
497 return 1;
498 }
499
500static int aep_finish(ENGINE *e)
501 {
502 int to_return = 0, in_use;
503 AEP_RV rv;
504
505 if(aep_dso == NULL)
506 {
507 AEPHKerr(AEPHK_F_AEP_FINISH,AEPHK_R_NOT_LOADED);
508 goto err;
509 }
510
511 rv = aep_close_all_connections(0, &in_use);
512 if (rv != AEP_R_OK)
513 {
514 AEPHKerr(AEPHK_F_AEP_FINISH,AEPHK_R_CLOSE_HANDLES_FAILED);
515 goto err;
516 }
517 if (in_use)
518 {
519 AEPHKerr(AEPHK_F_AEP_FINISH,AEPHK_R_CONNECTIONS_IN_USE);
520 goto err;
521 }
522
523 rv = p_AEP_Finalize();
524 if (rv != AEP_R_OK)
525 {
526 AEPHKerr(AEPHK_F_AEP_FINISH,AEPHK_R_FINALIZE_FAILED);
527 goto err;
528 }
529
530 if(!DSO_free(aep_dso))
531 {
532 AEPHKerr(AEPHK_F_AEP_FINISH,AEPHK_R_UNIT_FAILURE);
533 goto err;
534 }
535
536 aep_dso = NULL;
537 p_AEP_CloseConnection = NULL;
538 p_AEP_OpenConnection = NULL;
539 p_AEP_ModExp = NULL;
540 p_AEP_ModExpCrt = NULL;
541#ifdef AEPRAND
542 p_AEP_GenRandom = NULL;
543#endif
544 p_AEP_Initialize = NULL;
545 p_AEP_Finalize = NULL;
546 p_AEP_SetBNCallBacks = NULL;
547
548 to_return = 1;
549 err:
550 return to_return;
551 }
552
553static int aep_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
554 {
555 int initialised = ((aep_dso == NULL) ? 0 : 1);
556 switch(cmd)
557 {
558 case AEP_CMD_SO_PATH:
559 if(p == NULL)
560 {
561 AEPHKerr(AEPHK_F_AEP_CTRL,
562 ERR_R_PASSED_NULL_PARAMETER);
563 return 0;
564 }
565 if(initialised)
566 {
567 AEPHKerr(AEPHK_F_AEP_CTRL,
568 AEPHK_R_ALREADY_LOADED);
569 return 0;
570 }
571 return set_AEP_LIBNAME((const char*)p);
572 default:
573 break;
574 }
575 AEPHKerr(AEPHK_F_AEP_CTRL,AEPHK_R_CTRL_COMMAND_NOT_IMPLEMENTED);
576 return 0;
577 }
578
579static int aep_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
580 const BIGNUM *m, BN_CTX *ctx)
581 {
582 int to_return = 0;
583 int r_len = 0;
584 AEP_CONNECTION_HNDL hConnection;
585 AEP_RV rv;
586
587 r_len = BN_num_bits(m);
588
589 /* Perform in software if modulus is too large for hardware. */
590
591 if (r_len > max_key_len){
592 AEPHKerr(AEPHK_F_AEP_MOD_EXP, AEPHK_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
593 return BN_mod_exp(r, a, p, m, ctx);
594 }
595
596 /*Grab a connection from the pool*/
597 rv = aep_get_connection(&hConnection);
598 if (rv != AEP_R_OK)
599 {
600 AEPHKerr(AEPHK_F_AEP_MOD_EXP,AEPHK_R_GET_HANDLE_FAILED);
601 return BN_mod_exp(r, a, p, m, ctx);
602 }
603
604 /*To the card with the mod exp*/
605 rv = p_AEP_ModExp(hConnection,(void*)a, (void*)p,(void*)m, (void*)r,NULL);
606
607 if (rv != AEP_R_OK)
608 {
609 AEPHKerr(AEPHK_F_AEP_MOD_EXP,AEPHK_R_MOD_EXP_FAILED);
610 rv = aep_close_connection(hConnection);
611 return BN_mod_exp(r, a, p, m, ctx);
612 }
613
614 /*Return the connection to the pool*/
615 rv = aep_return_connection(hConnection);
616 if (rv != AEP_R_OK)
617 {
618 AEPHKerr(AEPHK_F_AEP_RAND,AEPHK_R_RETURN_CONNECTION_FAILED);
619 goto err;
620 }
621
622 to_return = 1;
623 err:
624 return to_return;
625 }
626
627static AEP_RV aep_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
628 const BIGNUM *q, const BIGNUM *dmp1,
629 const BIGNUM *dmq1,const BIGNUM *iqmp, BN_CTX *ctx)
630 {
631 AEP_RV rv = AEP_R_OK;
632 AEP_CONNECTION_HNDL hConnection;
633
634 /*Grab a connection from the pool*/
635 rv = aep_get_connection(&hConnection);
636 if (rv != AEP_R_OK)
637 {
638 AEPHKerr(AEPHK_F_AEP_MOD_EXP_CRT,AEPHK_R_GET_HANDLE_FAILED);
639 return FAIL_TO_SW;
640 }
641
642 /*To the card with the mod exp*/
643 rv = p_AEP_ModExpCrt(hConnection,(void*)a, (void*)p, (void*)q, (void*)dmp1,(void*)dmq1,
644 (void*)iqmp,(void*)r,NULL);
645 if (rv != AEP_R_OK)
646 {
647 AEPHKerr(AEPHK_F_AEP_MOD_EXP_CRT,AEPHK_R_MOD_EXP_CRT_FAILED);
648 rv = aep_close_connection(hConnection);
649 return FAIL_TO_SW;
650 }
651
652 /*Return the connection to the pool*/
653 rv = aep_return_connection(hConnection);
654 if (rv != AEP_R_OK)
655 {
656 AEPHKerr(AEPHK_F_AEP_RAND,AEPHK_R_RETURN_CONNECTION_FAILED);
657 goto err;
658 }
659
660 err:
661 return rv;
662 }
663
664
665#ifdef AEPRAND
666static int aep_rand(unsigned char *buf,int len )
667 {
668 AEP_RV rv = AEP_R_OK;
669 AEP_CONNECTION_HNDL hConnection;
670
671 CRYPTO_w_lock(CRYPTO_LOCK_RAND);
672
673 /*Can the request be serviced with what's already in the buffer?*/
674 if (len <= rand_block_bytes)
675 {
676 memcpy(buf, &rand_block[RAND_BLK_SIZE - rand_block_bytes], len);
677 rand_block_bytes -= len;
678 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
679 }
680 else
681 /*If not the get another block of random bytes*/
682 {
683 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
684
685 rv = aep_get_connection(&hConnection);
686 if (rv != AEP_R_OK)
687 {
688 AEPHKerr(AEPHK_F_AEP_RAND,AEPHK_R_GET_HANDLE_FAILED);
689 goto err_nounlock;
690 }
691
692 if (len > RAND_BLK_SIZE)
693 {
694 rv = p_AEP_GenRandom(hConnection, len, 2, buf, NULL);
695 if (rv != AEP_R_OK)
696 {
697 AEPHKerr(AEPHK_F_AEP_RAND,AEPHK_R_GET_RANDOM_FAILED);
698 goto err_nounlock;
699 }
700 }
701 else
702 {
703 CRYPTO_w_lock(CRYPTO_LOCK_RAND);
704
705 rv = p_AEP_GenRandom(hConnection, RAND_BLK_SIZE, 2, &rand_block[0], NULL);
706 if (rv != AEP_R_OK)
707 {
708 AEPHKerr(AEPHK_F_AEP_RAND,AEPHK_R_GET_RANDOM_FAILED);
709
710 goto err;
711 }
712
713 rand_block_bytes = RAND_BLK_SIZE;
714
715 memcpy(buf, &rand_block[RAND_BLK_SIZE - rand_block_bytes], len);
716 rand_block_bytes -= len;
717
718 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
719 }
720
721 rv = aep_return_connection(hConnection);
722 if (rv != AEP_R_OK)
723 {
724 AEPHKerr(AEPHK_F_AEP_RAND,AEPHK_R_RETURN_CONNECTION_FAILED);
725
726 goto err_nounlock;
727 }
728 }
729
730 return 1;
731 err:
732 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
733 err_nounlock:
734 return 0;
735 }
736
737static int aep_rand_status(void)
738{
739 return 1;
740}
741#endif
742
743#ifndef OPENSSL_NO_RSA
744static int aep_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
745 {
746 BN_CTX *ctx = NULL;
747 int to_return = 0;
748 AEP_RV rv = AEP_R_OK;
749
750 if ((ctx = BN_CTX_new()) == NULL)
751 goto err;
752
753 if (!aep_dso)
754 {
755 AEPHKerr(AEPHK_F_AEP_RSA_MOD_EXP,AEPHK_R_NOT_LOADED);
756 goto err;
757 }
758
759 /*See if we have all the necessary bits for a crt*/
760 if (rsa->q && rsa->dmp1 && rsa->dmq1 && rsa->iqmp)
761 {
762 rv = aep_mod_exp_crt(r0,I,rsa->p,rsa->q, rsa->dmp1,rsa->dmq1,rsa->iqmp,ctx);
763
764 if (rv == FAIL_TO_SW){
765 const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
766 to_return = (*meth->rsa_mod_exp)(r0, I, rsa);
767 goto err;
768 }
769 else if (rv != AEP_R_OK)
770 goto err;
771 }
772 else
773 {
774 if (!rsa->d || !rsa->n)
775 {
776 AEPHKerr(AEPHK_F_AEP_RSA_MOD_EXP,AEPHK_R_MISSING_KEY_COMPONENTS);
777 goto err;
778 }
779
780 rv = aep_mod_exp(r0,I,rsa->d,rsa->n,ctx);
781 if (rv != AEP_R_OK)
782 goto err;
783
784 }
785
786 to_return = 1;
787
788 err:
789 if(ctx)
790 BN_CTX_free(ctx);
791 return to_return;
792}
793#endif
794
795#ifndef OPENSSL_NO_DSA
796static int aep_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,
797 BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
798 BN_CTX *ctx, BN_MONT_CTX *in_mont)
799 {
800 BIGNUM t;
801 int to_return = 0;
802 BN_init(&t);
803
804 /* let rr = a1 ^ p1 mod m */
805 if (!aep_mod_exp(rr,a1,p1,m,ctx)) goto end;
806 /* let t = a2 ^ p2 mod m */
807 if (!aep_mod_exp(&t,a2,p2,m,ctx)) goto end;
808 /* let rr = rr * t mod m */
809 if (!BN_mod_mul(rr,rr,&t,m,ctx)) goto end;
810 to_return = 1;
811 end:
812 BN_free(&t);
813 return to_return;
814 }
815
816static int aep_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a,
817 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
818 BN_MONT_CTX *m_ctx)
819 {
820 return aep_mod_exp(r, a, p, m, ctx);
821 }
822#endif
823
824/* This function is aliased to mod_exp (with the mont stuff dropped). */
825static int aep_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
826 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
827 {
828 return aep_mod_exp(r, a, p, m, ctx);
829 }
830
831#ifndef OPENSSL_NO_DH
832/* This function is aliased to mod_exp (with the dh and mont dropped). */
833static int aep_mod_exp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a,
834 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
835 BN_MONT_CTX *m_ctx)
836 {
837 return aep_mod_exp(r, a, p, m, ctx);
838 }
839#endif
840
841static AEP_RV aep_get_connection(AEP_CONNECTION_HNDL_PTR phConnection)
842 {
843 int count;
844 AEP_RV rv = AEP_R_OK;
845
846 /*Get the current process id*/
847 pid_t curr_pid;
848
849 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
850
851 curr_pid = getpid();
852
853 /*Check if this is the first time this is being called from the current
854 process*/
855 if (recorded_pid != curr_pid)
856 {
857 /*Remember our pid so we can check if we're in a new process*/
858 recorded_pid = curr_pid;
859
860 /*Call Finalize to make sure we have not inherited some data
861 from a parent process*/
862 p_AEP_Finalize();
863
864 /*Initialise the AEP API*/
865 rv = p_AEP_Initialize(NULL);
866
867 if (rv != AEP_R_OK)
868 {
869 AEPHKerr(AEPHK_F_AEP_GET_CONNECTION,AEPHK_R_INIT_FAILURE);
870 recorded_pid = 0;
871 goto end;
872 }
873
874 /*Set the AEP big num call back functions*/
875 rv = p_AEP_SetBNCallBacks(&GetBigNumSize, &MakeAEPBigNum,
876 &ConvertAEPBigNum);
877
878 if (rv != AEP_R_OK)
879 {
880 AEPHKerr(AEPHK_F_AEP_GET_CONNECTION,AEPHK_R_SETBNCALLBACK_FAILURE);
881 recorded_pid = 0;
882 goto end;
883 }
884
885#ifdef AEPRAND
886 /*Reset the rand byte count*/
887 rand_block_bytes = 0;
888#endif
889
890 /*Init the structures*/
891 for (count = 0;count < MAX_PROCESS_CONNECTIONS;count ++)
892 {
893 aep_app_conn_table[count].conn_state = NotConnected;
894 aep_app_conn_table[count].conn_hndl = 0;
895 }
896
897 /*Open a connection*/
898 rv = p_AEP_OpenConnection(phConnection);
899
900 if (rv != AEP_R_OK)
901 {
902 AEPHKerr(AEPHK_F_AEP_GET_CONNECTION,AEPHK_R_UNIT_FAILURE);
903 recorded_pid = 0;
904 goto end;
905 }
906
907 aep_app_conn_table[0].conn_state = InUse;
908 aep_app_conn_table[0].conn_hndl = *phConnection;
909 goto end;
910 }
911 /*Check the existing connections to see if we can find a free one*/
912 for (count = 0;count < MAX_PROCESS_CONNECTIONS;count ++)
913 {
914 if (aep_app_conn_table[count].conn_state == Connected)
915 {
916 aep_app_conn_table[count].conn_state = InUse;
917 *phConnection = aep_app_conn_table[count].conn_hndl;
918 goto end;
919 }
920 }
921 /*If no connections available, we're going to have to try
922 to open a new one*/
923 for (count = 0;count < MAX_PROCESS_CONNECTIONS;count ++)
924 {
925 if (aep_app_conn_table[count].conn_state == NotConnected)
926 {
927 /*Open a connection*/
928 rv = p_AEP_OpenConnection(phConnection);
929
930 if (rv != AEP_R_OK)
931 {
932 AEPHKerr(AEPHK_F_AEP_GET_CONNECTION,AEPHK_R_UNIT_FAILURE);
933 goto end;
934 }
935
936 aep_app_conn_table[count].conn_state = InUse;
937 aep_app_conn_table[count].conn_hndl = *phConnection;
938 goto end;
939 }
940 }
941 rv = AEP_R_GENERAL_ERROR;
942 end:
943 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
944 return rv;
945 }
946
947
948static AEP_RV aep_return_connection(AEP_CONNECTION_HNDL hConnection)
949 {
950 int count;
951
952 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
953
954 /*Find the connection item that matches this connection handle*/
955 for(count = 0;count < MAX_PROCESS_CONNECTIONS;count ++)
956 {
957 if (aep_app_conn_table[count].conn_hndl == hConnection)
958 {
959 aep_app_conn_table[count].conn_state = Connected;
960 break;
961 }
962 }
963
964 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
965
966 return AEP_R_OK;
967 }
968
969static AEP_RV aep_close_connection(AEP_CONNECTION_HNDL hConnection)
970 {
971 int count;
972 AEP_RV rv = AEP_R_OK;
973
974 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
975
976 /*Find the connection item that matches this connection handle*/
977 for(count = 0;count < MAX_PROCESS_CONNECTIONS;count ++)
978 {
979 if (aep_app_conn_table[count].conn_hndl == hConnection)
980 {
981 rv = p_AEP_CloseConnection(aep_app_conn_table[count].conn_hndl);
982 if (rv != AEP_R_OK)
983 goto end;
984 aep_app_conn_table[count].conn_state = NotConnected;
985 aep_app_conn_table[count].conn_hndl = 0;
986 break;
987 }
988 }
989
990 end:
991 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
992 return rv;
993 }
994
995static AEP_RV aep_close_all_connections(int use_engine_lock, int *in_use)
996 {
997 int count;
998 AEP_RV rv = AEP_R_OK;
999
1000 *in_use = 0;
1001 if (use_engine_lock) CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
1002 for (count = 0;count < MAX_PROCESS_CONNECTIONS;count ++)
1003 {
1004 switch (aep_app_conn_table[count].conn_state)
1005 {
1006 case Connected:
1007 rv = p_AEP_CloseConnection(aep_app_conn_table[count].conn_hndl);
1008 if (rv != AEP_R_OK)
1009 goto end;
1010 aep_app_conn_table[count].conn_state = NotConnected;
1011 aep_app_conn_table[count].conn_hndl = 0;
1012 break;
1013 case InUse:
1014 (*in_use)++;
1015 break;
1016 case NotConnected:
1017 break;
1018 }
1019 }
1020 end:
1021 if (use_engine_lock) CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
1022 return rv;
1023 }
1024
1025/*BigNum call back functions, used to convert OpenSSL bignums into AEP bignums.
1026 Note only 32bit Openssl build support*/
1027
1028static AEP_RV GetBigNumSize(AEP_VOID_PTR ArbBigNum, AEP_U32* BigNumSize)
1029 {
1030 BIGNUM* bn;
1031
1032 /*Cast the ArbBigNum pointer to our BIGNUM struct*/
1033 bn = (BIGNUM*) ArbBigNum;
1034
1035#ifdef SIXTY_FOUR_BIT_LONG
1036 *BigNumSize = bn->top << 3;
1037#else
1038 /*Size of the bignum in bytes is equal to the bn->top (no of 32 bit
1039 words) multiplies by 4*/
1040 *BigNumSize = bn->top << 2;
1041#endif
1042
1043 return AEP_R_OK;
1044 }
1045
1046static AEP_RV MakeAEPBigNum(AEP_VOID_PTR ArbBigNum, AEP_U32 BigNumSize,
1047 unsigned char* AEP_BigNum)
1048 {
1049 BIGNUM* bn;
1050
1051#ifndef SIXTY_FOUR_BIT_LONG
1052 unsigned char* buf;
1053 int i;
1054#endif
1055
1056 /*Cast the ArbBigNum pointer to our BIGNUM struct*/
1057 bn = (BIGNUM*) ArbBigNum;
1058
1059#ifdef SIXTY_FOUR_BIT_LONG
1060 memcpy(AEP_BigNum, bn->d, BigNumSize);
1061#else
1062 /*Must copy data into a (monotone) least significant byte first format
1063 performing endian conversion if necessary*/
1064 for(i=0;i<bn->top;i++)
1065 {
1066 buf = (unsigned char*)&bn->d[i];
1067
1068 *((AEP_U32*)AEP_BigNum) = (AEP_U32)
1069 ((unsigned) buf[1] << 8 | buf[0]) |
1070 ((unsigned) buf[3] << 8 | buf[2]) << 16;
1071
1072 AEP_BigNum += 4;
1073 }
1074#endif
1075
1076 return AEP_R_OK;
1077 }
1078
1079/*Turn an AEP Big Num back to a user big num*/
1080static AEP_RV ConvertAEPBigNum(void* ArbBigNum, AEP_U32 BigNumSize,
1081 unsigned char* AEP_BigNum)
1082 {
1083 BIGNUM* bn;
1084#ifndef SIXTY_FOUR_BIT_LONG
1085 int i;
1086#endif
1087
1088 bn = (BIGNUM*)ArbBigNum;
1089
1090 /*Expand the result bn so that it can hold our big num.
1091 Size is in bits*/
1092 bn_expand(bn, (int)(BigNumSize << 3));
1093
1094#ifdef SIXTY_FOUR_BIT_LONG
1095 bn->top = BigNumSize >> 3;
1096
1097 if((BigNumSize & 7) != 0)
1098 bn->top++;
1099
1100 memset(bn->d, 0, bn->top << 3);
1101
1102 memcpy(bn->d, AEP_BigNum, BigNumSize);
1103#else
1104 bn->top = BigNumSize >> 2;
1105
1106 for(i=0;i<bn->top;i++)
1107 {
1108 bn->d[i] = (AEP_U32)
1109 ((unsigned) AEP_BigNum[3] << 8 | AEP_BigNum[2]) << 16 |
1110 ((unsigned) AEP_BigNum[1] << 8 | AEP_BigNum[0]);
1111 AEP_BigNum += 4;
1112 }
1113#endif
1114
1115 return AEP_R_OK;
1116}
1117
1118#endif /* !OPENSSL_NO_HW_AEP */
1119#endif /* !OPENSSL_NO_HW */
diff --git a/src/lib/libcrypto/engine/hw_aep_err.c b/src/lib/libcrypto/engine/hw_aep_err.c
new file mode 100644
index 0000000000..092f532946
--- /dev/null
+++ b/src/lib/libcrypto/engine/hw_aep_err.c
@@ -0,0 +1,157 @@
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
new file mode 100644
index 0000000000..8fe4cf921f
--- /dev/null
+++ b/src/lib/libcrypto/engine/hw_aep_err.h
@@ -0,0 +1,101 @@
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
new file mode 100644
index 0000000000..6151c46902
--- /dev/null
+++ b/src/lib/libcrypto/engine/hw_atalla.c
@@ -0,0 +1,592 @@
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
245static ENGINE *engine_atalla(void)
246 {
247 ENGINE *ret = ENGINE_new();
248 if(!ret)
249 return NULL;
250 if(!bind_helper(ret))
251 {
252 ENGINE_free(ret);
253 return NULL;
254 }
255 return ret;
256 }
257
258void ENGINE_load_atalla(void)
259 {
260 /* Copied from eng_[openssl|dyn].c */
261 ENGINE *toadd = engine_atalla();
262 if(!toadd) return;
263 ENGINE_add(toadd);
264 ENGINE_free(toadd);
265 ERR_clear_error();
266 }
267
268/* This is a process-global DSO handle used for loading and unloading
269 * the Atalla library. NB: This is only set (or unset) during an
270 * init() or finish() call (reference counts permitting) and they're
271 * operating with global locks, so this should be thread-safe
272 * implicitly. */
273static DSO *atalla_dso = NULL;
274
275/* These are the function pointers that are (un)set when the library has
276 * successfully (un)loaded. */
277static tfnASI_GetHardwareConfig *p_Atalla_GetHardwareConfig = NULL;
278static tfnASI_RSAPrivateKeyOpFn *p_Atalla_RSAPrivateKeyOpFn = NULL;
279static tfnASI_GetPerformanceStatistics *p_Atalla_GetPerformanceStatistics = NULL;
280
281/* These are the static string constants for the DSO file name and the function
282 * symbol names to bind to. Regrettably, the DSO name on *nix appears to be
283 * "atasi.so" rather than something more consistent like "libatasi.so". At the
284 * time of writing, I'm not sure what the file name on win32 is but clearly
285 * native name translation is not possible (eg libatasi.so on *nix, and
286 * atasi.dll on win32). For the purposes of testing, I have created a symbollic
287 * link called "libatasi.so" so that we can use native name-translation - a
288 * better solution will be needed. */
289static const char *ATALLA_LIBNAME = NULL;
290static const char *get_ATALLA_LIBNAME(void)
291 {
292 if(ATALLA_LIBNAME)
293 return ATALLA_LIBNAME;
294 return "atasi";
295 }
296static void free_ATALLA_LIBNAME(void)
297 {
298 if(ATALLA_LIBNAME)
299 OPENSSL_free((void*)ATALLA_LIBNAME);
300 ATALLA_LIBNAME = NULL;
301 }
302static long set_ATALLA_LIBNAME(const char *name)
303 {
304 free_ATALLA_LIBNAME();
305 return (((ATALLA_LIBNAME = BUF_strdup(name)) != NULL) ? 1 : 0);
306 }
307static const char *ATALLA_F1 = "ASI_GetHardwareConfig";
308static const char *ATALLA_F2 = "ASI_RSAPrivateKeyOpFn";
309static const char *ATALLA_F3 = "ASI_GetPerformanceStatistics";
310
311/* Destructor (complements the "ENGINE_atalla()" constructor) */
312static int atalla_destroy(ENGINE *e)
313 {
314 free_ATALLA_LIBNAME();
315 /* Unload the atalla error strings so any error state including our
316 * functs or reasons won't lead to a segfault (they simply get displayed
317 * without corresponding string data because none will be found). */
318 ERR_unload_ATALLA_strings();
319 return 1;
320 }
321
322/* (de)initialisation functions. */
323static int atalla_init(ENGINE *e)
324 {
325 tfnASI_GetHardwareConfig *p1;
326 tfnASI_RSAPrivateKeyOpFn *p2;
327 tfnASI_GetPerformanceStatistics *p3;
328 /* Not sure of the origin of this magic value, but Ben's code had it
329 * and it seemed to have been working for a few people. :-) */
330 unsigned int config_buf[1024];
331
332 if(atalla_dso != NULL)
333 {
334 ATALLAerr(ATALLA_F_ATALLA_INIT,ATALLA_R_ALREADY_LOADED);
335 goto err;
336 }
337 /* Attempt to load libatasi.so/atasi.dll/whatever. Needs to be
338 * changed unfortunately because the Atalla drivers don't have
339 * standard library names that can be platform-translated well. */
340 /* TODO: Work out how to actually map to the names the Atalla
341 * drivers really use - for now a symbollic link needs to be
342 * created on the host system from libatasi.so to atasi.so on
343 * unix variants. */
344 atalla_dso = DSO_load(NULL, get_ATALLA_LIBNAME(), NULL, 0);
345 if(atalla_dso == NULL)
346 {
347 ATALLAerr(ATALLA_F_ATALLA_INIT,ATALLA_R_NOT_LOADED);
348 goto err;
349 }
350 if(!(p1 = (tfnASI_GetHardwareConfig *)DSO_bind_func(
351 atalla_dso, ATALLA_F1)) ||
352 !(p2 = (tfnASI_RSAPrivateKeyOpFn *)DSO_bind_func(
353 atalla_dso, ATALLA_F2)) ||
354 !(p3 = (tfnASI_GetPerformanceStatistics *)DSO_bind_func(
355 atalla_dso, ATALLA_F3)))
356 {
357 ATALLAerr(ATALLA_F_ATALLA_INIT,ATALLA_R_NOT_LOADED);
358 goto err;
359 }
360 /* Copy the pointers */
361 p_Atalla_GetHardwareConfig = p1;
362 p_Atalla_RSAPrivateKeyOpFn = p2;
363 p_Atalla_GetPerformanceStatistics = p3;
364 /* Perform a basic test to see if there's actually any unit
365 * running. */
366 if(p1(0L, config_buf) != 0)
367 {
368 ATALLAerr(ATALLA_F_ATALLA_INIT,ATALLA_R_UNIT_FAILURE);
369 goto err;
370 }
371 /* Everything's fine. */
372 return 1;
373err:
374 if(atalla_dso)
375 DSO_free(atalla_dso);
376 p_Atalla_GetHardwareConfig = NULL;
377 p_Atalla_RSAPrivateKeyOpFn = NULL;
378 p_Atalla_GetPerformanceStatistics = NULL;
379 return 0;
380 }
381
382static int atalla_finish(ENGINE *e)
383 {
384 free_ATALLA_LIBNAME();
385 if(atalla_dso == NULL)
386 {
387 ATALLAerr(ATALLA_F_ATALLA_FINISH,ATALLA_R_NOT_LOADED);
388 return 0;
389 }
390 if(!DSO_free(atalla_dso))
391 {
392 ATALLAerr(ATALLA_F_ATALLA_FINISH,ATALLA_R_UNIT_FAILURE);
393 return 0;
394 }
395 atalla_dso = NULL;
396 p_Atalla_GetHardwareConfig = NULL;
397 p_Atalla_RSAPrivateKeyOpFn = NULL;
398 p_Atalla_GetPerformanceStatistics = NULL;
399 return 1;
400 }
401
402static int atalla_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
403 {
404 int initialised = ((atalla_dso == NULL) ? 0 : 1);
405 switch(cmd)
406 {
407 case ATALLA_CMD_SO_PATH:
408 if(p == NULL)
409 {
410 ATALLAerr(ATALLA_F_ATALLA_CTRL,ERR_R_PASSED_NULL_PARAMETER);
411 return 0;
412 }
413 if(initialised)
414 {
415 ATALLAerr(ATALLA_F_ATALLA_CTRL,ATALLA_R_ALREADY_LOADED);
416 return 0;
417 }
418 return set_ATALLA_LIBNAME((const char *)p);
419 default:
420 break;
421 }
422 ATALLAerr(ATALLA_F_ATALLA_CTRL,ATALLA_R_CTRL_COMMAND_NOT_IMPLEMENTED);
423 return 0;
424 }
425
426static int atalla_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
427 const BIGNUM *m, BN_CTX *ctx)
428 {
429 /* I need somewhere to store temporary serialised values for
430 * use with the Atalla API calls. A neat cheat - I'll use
431 * BIGNUMs from the BN_CTX but access their arrays directly as
432 * byte arrays <grin>. This way I don't have to clean anything
433 * up. */
434 BIGNUM *modulus;
435 BIGNUM *exponent;
436 BIGNUM *argument;
437 BIGNUM *result;
438 RSAPrivateKey keydata;
439 int to_return, numbytes;
440
441 modulus = exponent = argument = result = NULL;
442 to_return = 0; /* expect failure */
443
444 if(!atalla_dso)
445 {
446 ATALLAerr(ATALLA_F_ATALLA_MOD_EXP,ATALLA_R_NOT_LOADED);
447 goto err;
448 }
449 /* Prepare the params */
450 BN_CTX_start(ctx);
451 modulus = BN_CTX_get(ctx);
452 exponent = BN_CTX_get(ctx);
453 argument = BN_CTX_get(ctx);
454 result = BN_CTX_get(ctx);
455 if (!result)
456 {
457 ATALLAerr(ATALLA_F_ATALLA_MOD_EXP,ATALLA_R_BN_CTX_FULL);
458 goto err;
459 }
460 if(!bn_wexpand(modulus, m->top) || !bn_wexpand(exponent, m->top) ||
461 !bn_wexpand(argument, m->top) || !bn_wexpand(result, m->top))
462 {
463 ATALLAerr(ATALLA_F_ATALLA_MOD_EXP,ATALLA_R_BN_EXPAND_FAIL);
464 goto err;
465 }
466 /* Prepare the key-data */
467 memset(&keydata, 0,sizeof keydata);
468 numbytes = BN_num_bytes(m);
469 memset(exponent->d, 0, numbytes);
470 memset(modulus->d, 0, numbytes);
471 BN_bn2bin(p, (unsigned char *)exponent->d + numbytes - BN_num_bytes(p));
472 BN_bn2bin(m, (unsigned char *)modulus->d + numbytes - BN_num_bytes(m));
473 keydata.privateExponent.data = (unsigned char *)exponent->d;
474 keydata.privateExponent.len = numbytes;
475 keydata.modulus.data = (unsigned char *)modulus->d;
476 keydata.modulus.len = numbytes;
477 /* Prepare the argument */
478 memset(argument->d, 0, numbytes);
479 memset(result->d, 0, numbytes);
480 BN_bn2bin(a, (unsigned char *)argument->d + numbytes - BN_num_bytes(a));
481 /* Perform the operation */
482 if(p_Atalla_RSAPrivateKeyOpFn(&keydata, (unsigned char *)result->d,
483 (unsigned char *)argument->d,
484 keydata.modulus.len) != 0)
485 {
486 ATALLAerr(ATALLA_F_ATALLA_MOD_EXP,ATALLA_R_REQUEST_FAILED);
487 goto err;
488 }
489 /* Convert the response */
490 BN_bin2bn((unsigned char *)result->d, numbytes, r);
491 to_return = 1;
492err:
493 BN_CTX_end(ctx);
494 return to_return;
495 }
496
497#ifndef OPENSSL_NO_RSA
498static int atalla_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
499 {
500 BN_CTX *ctx = NULL;
501 int to_return = 0;
502
503 if(!atalla_dso)
504 {
505 ATALLAerr(ATALLA_F_ATALLA_RSA_MOD_EXP,ATALLA_R_NOT_LOADED);
506 goto err;
507 }
508 if((ctx = BN_CTX_new()) == NULL)
509 goto err;
510 if(!rsa->d || !rsa->n)
511 {
512 ATALLAerr(ATALLA_F_ATALLA_RSA_MOD_EXP,ATALLA_R_MISSING_KEY_COMPONENTS);
513 goto err;
514 }
515 to_return = atalla_mod_exp(r0, I, rsa->d, rsa->n, ctx);
516err:
517 if(ctx)
518 BN_CTX_free(ctx);
519 return to_return;
520 }
521#endif
522
523#ifndef OPENSSL_NO_DSA
524/* This code was liberated and adapted from the commented-out code in
525 * dsa_ossl.c. Because of the unoptimised form of the Atalla acceleration
526 * (it doesn't have a CRT form for RSA), this function means that an
527 * Atalla system running with a DSA server certificate can handshake
528 * around 5 or 6 times faster/more than an equivalent system running with
529 * RSA. Just check out the "signs" statistics from the RSA and DSA parts
530 * of "openssl speed -engine atalla dsa1024 rsa1024". */
531static int atalla_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,
532 BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
533 BN_CTX *ctx, BN_MONT_CTX *in_mont)
534 {
535 BIGNUM t;
536 int to_return = 0;
537
538 BN_init(&t);
539 /* let rr = a1 ^ p1 mod m */
540 if (!atalla_mod_exp(rr,a1,p1,m,ctx)) goto end;
541 /* let t = a2 ^ p2 mod m */
542 if (!atalla_mod_exp(&t,a2,p2,m,ctx)) goto end;
543 /* let rr = rr * t mod m */
544 if (!BN_mod_mul(rr,rr,&t,m,ctx)) goto end;
545 to_return = 1;
546end:
547 BN_free(&t);
548 return to_return;
549 }
550
551static int atalla_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a,
552 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
553 BN_MONT_CTX *m_ctx)
554 {
555 return atalla_mod_exp(r, a, p, m, ctx);
556 }
557#endif
558
559/* This function is aliased to mod_exp (with the mont stuff dropped). */
560static int atalla_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
561 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
562 {
563 return atalla_mod_exp(r, a, p, m, ctx);
564 }
565
566#ifndef OPENSSL_NO_DH
567/* This function is aliased to mod_exp (with the dh and mont dropped). */
568static int atalla_mod_exp_dh(const DH *dh, BIGNUM *r,
569 const BIGNUM *a, const BIGNUM *p,
570 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
571 {
572 return atalla_mod_exp(r, a, p, m, ctx);
573 }
574#endif
575
576/* This stuff is needed if this ENGINE is being compiled into a self-contained
577 * shared-library. */
578#ifdef ENGINE_DYNAMIC_SUPPORT
579static int bind_fn(ENGINE *e, const char *id)
580 {
581 if(id && (strcmp(id, engine_atalla_id) != 0))
582 return 0;
583 if(!bind_helper(e))
584 return 0;
585 return 1;
586 }
587IMPLEMENT_DYNAMIC_CHECK_FN()
588IMPLEMENT_DYNAMIC_BIND_FN(bind_fn)
589#endif /* ENGINE_DYNAMIC_SUPPORT */
590
591#endif /* !OPENSSL_NO_HW_ATALLA */
592#endif /* !OPENSSL_NO_HW */
diff --git a/src/lib/libcrypto/engine/hw_atalla_err.c b/src/lib/libcrypto/engine/hw_atalla_err.c
new file mode 100644
index 0000000000..1df9c4570c
--- /dev/null
+++ b/src/lib/libcrypto/engine/hw_atalla_err.c
@@ -0,0 +1,145 @@
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
new file mode 100644
index 0000000000..cdac052d8c
--- /dev/null
+++ b/src/lib/libcrypto/engine/hw_atalla_err.h
@@ -0,0 +1,89 @@
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_cryptodev.c b/src/lib/libcrypto/engine/hw_cryptodev.c
new file mode 100644
index 0000000000..034c7ca213
--- /dev/null
+++ b/src/lib/libcrypto/engine/hw_cryptodev.c
@@ -0,0 +1,1106 @@
1/*
2 * Copyright (c) 2002 Bob Beck <beck@openbsd.org>
3 * Copyright (c) 2002 Theo de Raadt
4 * Copyright (c) 2002 Markus Friedl
5 * 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 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the author nor the names of contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
20 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 */
31
32#include <sys/types.h>
33#include <sys/param.h>
34#include <crypto/cryptodev.h>
35#include <sys/ioctl.h>
36#include <errno.h>
37#include <stdio.h>
38#include <unistd.h>
39#include <fcntl.h>
40#include <stdarg.h>
41#include <syslog.h>
42#include <ssl/objects.h>
43#include <ssl/engine.h>
44#include <ssl/evp.h>
45#include <errno.h>
46#include <string.h>
47
48struct dev_crypto_state {
49 struct session_op d_sess;
50 int d_fd;
51};
52
53static u_int32_t cryptodev_asymfeat = 0;
54
55static int get_asym_dev_crypto(void);
56static int open_dev_crypto(void);
57static int get_dev_crypto(void);
58static int cryptodev_max_iv(int cipher);
59static int cryptodev_key_length_valid(int cipher, int len);
60static int cipher_nid_to_cryptodev(int nid);
61static int get_cryptodev_ciphers(const int **cnids);
62static int get_cryptodev_digests(const int **cnids);
63static int cryptodev_usable_ciphers(const int **nids);
64static int cryptodev_usable_digests(const int **nids);
65static int cryptodev_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
66 const unsigned char *in, unsigned int inl);
67static int cryptodev_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
68 const unsigned char *iv, int enc);
69static int cryptodev_cleanup(EVP_CIPHER_CTX *ctx);
70static int cryptodev_engine_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
71 const int **nids, int nid);
72static int cryptodev_engine_digests(ENGINE *e, const EVP_MD **digest,
73 const int **nids, int nid);
74static int bn2crparam(const BIGNUM *a, struct crparam *crp);
75static int crparam2bn(struct crparam *crp, BIGNUM *a);
76static void zapparams(struct crypt_kop *kop);
77static int cryptodev_asym(struct crypt_kop *kop, int rlen, BIGNUM *r,
78 int slen, BIGNUM *s);
79
80static int cryptodev_bn_mod_exp(BIGNUM *r, const BIGNUM *a,
81 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
82static int cryptodev_rsa_nocrt_mod_exp(BIGNUM *r0, const BIGNUM *I,
83 RSA *rsa);
84static int cryptodev_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa);
85static int cryptodev_dsa_bn_mod_exp(DSA *dsa, BIGNUM *r, BIGNUM *a,
86 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
87static int cryptodev_dsa_dsa_mod_exp(DSA *dsa, BIGNUM *t1, BIGNUM *g,
88 BIGNUM *u1, BIGNUM *pub_key, BIGNUM *u2, BIGNUM *p,
89 BN_CTX *ctx, BN_MONT_CTX *mont);
90static DSA_SIG *cryptodev_dsa_do_sign(const unsigned char *dgst,
91 int dlen, DSA *dsa);
92static int cryptodev_dsa_verify(const unsigned char *dgst, int dgst_len,
93 DSA_SIG *sig, DSA *dsa);
94static int cryptodev_mod_exp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a,
95 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
96 BN_MONT_CTX *m_ctx);
97static int cryptodev_dh_compute_key(unsigned char *key,
98 const BIGNUM *pub_key, DH *dh);
99static int cryptodev_ctrl(ENGINE *e, int cmd, long i, void *p,
100 void (*f)());
101void ENGINE_load_cryptodev(void);
102
103static const ENGINE_CMD_DEFN cryptodev_defns[] = {
104 {ENGINE_CMD_BASE,
105 "SO_PATH",
106 "Specifies the path to the some stupid shared library",
107 ENGINE_CMD_FLAG_STRING},
108 { 0, NULL, NULL, 0 }
109};
110
111static struct {
112 int id;
113 int nid;
114 int ivmax;
115 int keylen;
116} ciphers[] = {
117 { CRYPTO_DES_CBC, NID_des_cbc, 8, 8, },
118 { CRYPTO_3DES_CBC, NID_des_ede3_cbc, 8, 24, },
119 { CRYPTO_AES_CBC, NID_aes_128_cbc, 16, 16, },
120 { CRYPTO_BLF_CBC, NID_bf_cbc, 8, 16, },
121 { CRYPTO_CAST_CBC, NID_cast5_cbc, 8, 16, },
122 { CRYPTO_SKIPJACK_CBC, NID_undef, 0, 0, },
123 { 0, NID_undef, 0, 0, },
124};
125
126static struct {
127 int id;
128 int nid;
129} digests[] = {
130 { CRYPTO_SHA1_HMAC, NID_hmacWithSHA1, },
131 { CRYPTO_RIPEMD160_HMAC, NID_ripemd160, },
132 { CRYPTO_MD5_KPDK, NID_undef, },
133 { CRYPTO_SHA1_KPDK, NID_undef, },
134 { CRYPTO_MD5, NID_md5, },
135 { CRYPTO_SHA1, NID_undef, },
136 { 0, NID_undef, },
137};
138
139/*
140 * Return a fd if /dev/crypto seems usable, 0 otherwise.
141 */
142static int
143open_dev_crypto(void)
144{
145 static int fd = -1;
146
147 if (fd == -1) {
148 if ((fd = open("/dev/crypto", O_RDWR, 0)) == -1)
149 return (-1);
150 /* close on exec */
151 if (fcntl(fd, F_SETFD, 1) == -1) {
152 close(fd);
153 fd = -1;
154 return (-1);
155 }
156 }
157 return (fd);
158}
159
160static int
161get_dev_crypto(void)
162{
163 int fd, retfd;
164
165 if ((fd = open_dev_crypto()) == -1)
166 return (-1);
167 if (ioctl(fd, CRIOGET, &retfd) == -1)
168 return (-1);
169
170 /* close on exec */
171 if (fcntl(retfd, F_SETFD, 1) == -1) {
172 close(retfd);
173 return (-1);
174 }
175 return (retfd);
176}
177
178/* Caching version for asym operations */
179static int
180get_asym_dev_crypto(void)
181{
182 static int fd = -1;
183
184 if (fd == -1)
185 fd = get_dev_crypto();
186 return fd;
187}
188
189/*
190 * XXXX this needs to be set for each alg - and determined from
191 * a running card.
192 */
193static int
194cryptodev_max_iv(int cipher)
195{
196 int i;
197
198 for (i = 0; ciphers[i].id; i++)
199 if (ciphers[i].id == cipher)
200 return (ciphers[i].ivmax);
201 return (0);
202}
203
204/*
205 * XXXX this needs to be set for each alg - and determined from
206 * a running card. For now, fake it out - but most of these
207 * for real devices should return 1 for the supported key
208 * sizes the device can handle.
209 */
210static int
211cryptodev_key_length_valid(int cipher, int len)
212{
213 int i;
214
215 for (i = 0; ciphers[i].id; i++)
216 if (ciphers[i].id == cipher)
217 return (ciphers[i].keylen == len);
218 return (0);
219}
220
221/* convert libcrypto nids to cryptodev */
222static int
223cipher_nid_to_cryptodev(int nid)
224{
225 int i;
226
227 for (i = 0; ciphers[i].id; i++)
228 if (ciphers[i].nid == nid)
229 return (ciphers[i].id);
230 return (0);
231}
232
233/*
234 * Find out what ciphers /dev/crypto will let us have a session for.
235 * XXX note, that some of these openssl doesn't deal with yet!
236 * returning them here is harmless, as long as we return NULL
237 * when asked for a handler in the cryptodev_engine_ciphers routine
238 */
239static int
240get_cryptodev_ciphers(const int **cnids)
241{
242 static int nids[CRYPTO_ALGORITHM_MAX];
243 struct session_op sess;
244 int fd, i, count = 0;
245
246 if ((fd = get_dev_crypto()) < 0) {
247 *nids = NULL;
248 return (0);
249 }
250 memset(&sess, 0, sizeof(sess));
251 sess.key = (caddr_t)"123456781234567812345678";
252
253 for (i = 0; ciphers[i].id && count < CRYPTO_ALGORITHM_MAX; i++) {
254 if (ciphers[i].nid == NID_undef)
255 continue;
256 sess.cipher = ciphers[i].id;
257 sess.keylen = ciphers[i].keylen;
258 sess.mac = 0;
259 if (ioctl(fd, CIOCGSESSION, &sess) != -1 &&
260 ioctl(fd, CIOCFSESSION, &sess.ses) != -1)
261 nids[count++] = ciphers[i].nid;
262 }
263 close(fd);
264
265 if (count > 0)
266 *cnids = nids;
267 else
268 *cnids = NULL;
269 return (count);
270}
271
272/*
273 * Find out what digests /dev/crypto will let us have a session for.
274 * XXX note, that some of these openssl doesn't deal with yet!
275 * returning them here is harmless, as long as we return NULL
276 * when asked for a handler in the cryptodev_engine_digests routine
277 */
278static int
279get_cryptodev_digests(const int **cnids)
280{
281 static int nids[CRYPTO_ALGORITHM_MAX];
282 struct session_op sess;
283 int fd, i, count = 0;
284
285 if ((fd = get_dev_crypto()) < 0) {
286 *nids = NULL;
287 return (0);
288 }
289 memset(&sess, 0, sizeof(sess));
290 for (i = 0; digests[i].id && count < CRYPTO_ALGORITHM_MAX; i++) {
291 if (digests[i].nid == NID_undef)
292 continue;
293 sess.mac = digests[i].id;
294 sess.cipher = 0;
295 if (ioctl(fd, CIOCGSESSION, &sess) != -1 &&
296 ioctl(fd, CIOCFSESSION, &sess.ses) != -1)
297 nids[count++] = digests[i].nid;
298 }
299 close(fd);
300
301 if (count > 0)
302 *cnids = nids;
303 else
304 *cnids = NULL;
305 return (count);
306}
307
308/*
309 * Find the useable ciphers|digests from dev/crypto - this is the first
310 * thing called by the engine init crud which determines what it
311 * can use for ciphers from this engine. We want to return
312 * only what we can do, anythine else is handled by software.
313 *
314 * If we can't initialize the device to do anything useful for
315 * any reason, we want to return a NULL array, and 0 length,
316 * which forces everything to be done is software. By putting
317 * the initalization of the device in here, we ensure we can
318 * use this engine as the default, and if for whatever reason
319 * /dev/crypto won't do what we want it will just be done in
320 * software
321 *
322 * This can (should) be greatly expanded to perhaps take into
323 * account speed of the device, and what we want to do.
324 * (although the disabling of particular alg's could be controlled
325 * by the device driver with sysctl's.) - this is where we
326 * want most of the decisions made about what we actually want
327 * to use from /dev/crypto.
328 */
329static int
330cryptodev_usable_ciphers(const int **nids)
331{
332 return (get_cryptodev_ciphers(nids));
333}
334
335static int
336cryptodev_usable_digests(const int **nids)
337{
338 /*
339 * XXXX just disable all digests for now, because it sucks.
340 * we need a better way to decide this - i.e. I may not
341 * want digests on slow cards like hifn on fast machines,
342 * but might want them on slow or loaded machines, etc.
343 * will also want them when using crypto cards that don't
344 * suck moose gonads - would be nice to be able to decide something
345 * as reasonable default without having hackery that's card dependent.
346 * of course, the default should probably be just do everything,
347 * with perhaps a sysctl to turn algoritms off (or have them off
348 * by default) on cards that generally suck like the hifn.
349 */
350 *nids = NULL;
351 return (0);
352}
353
354static int
355cryptodev_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
356 const unsigned char *in, unsigned int inl)
357{
358 struct crypt_op cryp;
359 struct dev_crypto_state *state = ctx->cipher_data;
360 struct session_op *sess = &state->d_sess;
361 void *iiv;
362 unsigned char save_iv[EVP_MAX_IV_LENGTH];
363
364 if (state->d_fd < 0)
365 return (0);
366 if (!inl)
367 return (1);
368 if ((inl % ctx->cipher->block_size) != 0)
369 return (0);
370
371 memset(&cryp, 0, sizeof(cryp));
372
373 cryp.ses = sess->ses;
374 cryp.flags = 0;
375 cryp.len = inl;
376 cryp.src = (caddr_t) in;
377 cryp.dst = (caddr_t) out;
378 cryp.mac = 0;
379
380 cryp.op = ctx->encrypt ? COP_ENCRYPT : COP_DECRYPT;
381
382 if (ctx->cipher->iv_len) {
383 cryp.iv = (caddr_t) ctx->iv;
384 if (!ctx->encrypt) {
385 iiv = (void *) in + inl - ctx->cipher->iv_len;
386 memcpy(save_iv, iiv, ctx->cipher->iv_len);
387 }
388 } else
389 cryp.iv = NULL;
390
391 if (ioctl(state->d_fd, CIOCCRYPT, &cryp) == -1) {
392 /* XXX need better errror handling
393 * this can fail for a number of different reasons.
394 */
395 return (0);
396 }
397
398 if (ctx->cipher->iv_len) {
399 if (ctx->encrypt)
400 iiv = (void *) out + inl - ctx->cipher->iv_len;
401 else
402 iiv = save_iv;
403 memcpy(ctx->iv, iiv, ctx->cipher->iv_len);
404 }
405 return (1);
406}
407
408static int
409cryptodev_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
410 const unsigned char *iv, int enc)
411{
412 struct dev_crypto_state *state = ctx->cipher_data;
413 struct session_op *sess = &state->d_sess;
414 int cipher;
415
416 if ((cipher = cipher_nid_to_cryptodev(ctx->cipher->nid)) == NID_undef)
417 return (0);
418
419 if (ctx->cipher->iv_len > cryptodev_max_iv(cipher))
420 return (0);
421
422 if (!cryptodev_key_length_valid(cipher, ctx->key_len))
423 return (0);
424
425 memset(sess, 0, sizeof(struct session_op));
426
427 if ((state->d_fd = get_dev_crypto()) < 0)
428 return (0);
429
430 sess->key = (unsigned char *)key;
431 sess->keylen = ctx->key_len;
432 sess->cipher = cipher;
433
434 if (ioctl(state->d_fd, CIOCGSESSION, sess) == -1) {
435 close(state->d_fd);
436 state->d_fd = -1;
437 return (0);
438 }
439 return (1);
440}
441
442/*
443 * free anything we allocated earlier when initting a
444 * session, and close the session.
445 */
446static int
447cryptodev_cleanup(EVP_CIPHER_CTX *ctx)
448{
449 int ret = 0;
450 struct dev_crypto_state *state = ctx->cipher_data;
451 struct session_op *sess = &state->d_sess;
452
453 if (state->d_fd < 0)
454 return (0);
455
456 /* XXX if this ioctl fails, someting's wrong. the invoker
457 * may have called us with a bogus ctx, or we could
458 * have a device that for whatever reason just doesn't
459 * want to play ball - it's not clear what's right
460 * here - should this be an error? should it just
461 * increase a counter, hmm. For right now, we return
462 * 0 - I don't believe that to be "right". we could
463 * call the gorpy openssl lib error handlers that
464 * print messages to users of the library. hmm..
465 */
466
467 if (ioctl(state->d_fd, CIOCFSESSION, &sess->ses) == -1) {
468 ret = 0;
469 } else {
470 ret = 1;
471 }
472 close(state->d_fd);
473 state->d_fd = -1;
474
475 return (ret);
476}
477
478/*
479 * libcrypto EVP stuff - this is how we get wired to EVP so the engine
480 * gets called when libcrypto requests a cipher NID.
481 */
482
483/* DES CBC EVP */
484const EVP_CIPHER cryptodev_des_cbc = {
485 NID_des_cbc,
486 8, 8, 8,
487 EVP_CIPH_CBC_MODE,
488 cryptodev_init_key,
489 cryptodev_cipher,
490 cryptodev_cleanup,
491 sizeof(struct dev_crypto_state),
492 EVP_CIPHER_set_asn1_iv,
493 EVP_CIPHER_get_asn1_iv,
494 NULL
495};
496
497/* 3DES CBC EVP */
498const EVP_CIPHER cryptodev_3des_cbc = {
499 NID_des_ede3_cbc,
500 8, 24, 8,
501 EVP_CIPH_CBC_MODE,
502 cryptodev_init_key,
503 cryptodev_cipher,
504 cryptodev_cleanup,
505 sizeof(struct dev_crypto_state),
506 EVP_CIPHER_set_asn1_iv,
507 EVP_CIPHER_get_asn1_iv,
508 NULL
509};
510
511const EVP_CIPHER cryptodev_bf_cbc = {
512 NID_bf_cbc,
513 8, 16, 8,
514 EVP_CIPH_CBC_MODE,
515 cryptodev_init_key,
516 cryptodev_cipher,
517 cryptodev_cleanup,
518 sizeof(struct dev_crypto_state),
519 EVP_CIPHER_set_asn1_iv,
520 EVP_CIPHER_get_asn1_iv,
521 NULL
522};
523
524const EVP_CIPHER cryptodev_cast_cbc = {
525 NID_cast5_cbc,
526 8, 16, 8,
527 EVP_CIPH_CBC_MODE,
528 cryptodev_init_key,
529 cryptodev_cipher,
530 cryptodev_cleanup,
531 sizeof(struct dev_crypto_state),
532 EVP_CIPHER_set_asn1_iv,
533 EVP_CIPHER_get_asn1_iv,
534 NULL
535};
536
537const EVP_CIPHER cryptodev_aes_cbc = {
538 NID_aes_128_cbc,
539 16, 16, 16,
540 EVP_CIPH_CBC_MODE,
541 cryptodev_init_key,
542 cryptodev_cipher,
543 cryptodev_cleanup,
544 sizeof(struct dev_crypto_state),
545 EVP_CIPHER_set_asn1_iv,
546 EVP_CIPHER_get_asn1_iv,
547 NULL
548};
549
550/*
551 * Registered by the ENGINE when used to find out how to deal with
552 * a particular NID in the ENGINE. this says what we'll do at the
553 * top level - note, that list is restricted by what we answer with
554 */
555static int
556cryptodev_engine_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
557 const int **nids, int nid)
558{
559 if (!cipher)
560 return (cryptodev_usable_ciphers(nids));
561
562 switch (nid) {
563 case NID_des_ede3_cbc:
564 *cipher = &cryptodev_3des_cbc;
565 break;
566 case NID_des_cbc:
567 *cipher = &cryptodev_des_cbc;
568 break;
569 case NID_bf_cbc:
570 *cipher = &cryptodev_bf_cbc;
571 break;
572 case NID_cast5_cbc:
573 *cipher = &cryptodev_cast_cbc;
574 break;
575 case NID_aes_128_cbc:
576 *cipher = &cryptodev_aes_cbc;
577 break;
578 default:
579 *cipher = NULL;
580 break;
581 }
582 return (*cipher != NULL);
583}
584
585static int
586cryptodev_engine_digests(ENGINE *e, const EVP_MD **digest,
587 const int **nids, int nid)
588{
589 if (!digest)
590 return (cryptodev_usable_digests(nids));
591
592 switch (nid) {
593 case NID_md5:
594 *digest = NULL; /* need to make a clean md5 critter */
595 break;
596 default:
597 *digest = NULL;
598 break;
599 }
600 return (*digest != NULL);
601}
602
603/*
604 * Convert a BIGNUM to the representation that /dev/crypto needs.
605 * Upon completion of use, the caller is responsible for freeing
606 * crp->crp_p.
607 */
608static int
609bn2crparam(const BIGNUM *a, struct crparam *crp)
610{
611 int i, j, k;
612 ssize_t words, bytes, bits;
613 u_char *b;
614
615 crp->crp_p = NULL;
616 crp->crp_nbits = 0;
617
618 bits = BN_num_bits(a);
619 bytes = (bits + 7) / 8;
620
621 b = malloc(bytes);
622 if (b == NULL)
623 return (1);
624
625 crp->crp_p = b;
626 crp->crp_nbits = bits;
627
628 for (i = 0, j = 0; i < a->top; i++) {
629 for (k = 0; k < BN_BITS2 / 8; k++) {
630 if ((j + k) >= bytes)
631 return (0);
632 b[j + k] = a->d[i] >> (k * 8);
633 }
634 j += BN_BITS2 / 8;
635 }
636 return (0);
637}
638
639/* Convert a /dev/crypto parameter to a BIGNUM */
640static int
641crparam2bn(struct crparam *crp, BIGNUM *a)
642{
643 u_int8_t *pd;
644 int i, bytes;
645
646 bytes = (crp->crp_nbits + 7) / 8;
647
648 if (bytes == 0)
649 return (-1);
650
651 if ((pd = (u_int8_t *) malloc(bytes)) == NULL)
652 return (-1);
653
654 for (i = 0; i < bytes; i++)
655 pd[i] = crp->crp_p[bytes - i - 1];
656
657 BN_bin2bn(pd, bytes, a);
658 free(pd);
659
660 return (0);
661}
662
663static void
664zapparams(struct crypt_kop *kop)
665{
666 int i;
667
668 for (i = 0; i <= kop->crk_iparams + kop->crk_oparams; i++) {
669 if (kop->crk_param[i].crp_p)
670 free(kop->crk_param[i].crp_p);
671 kop->crk_param[i].crp_p = NULL;
672 kop->crk_param[i].crp_nbits = 0;
673 }
674}
675
676static int
677cryptodev_asym(struct crypt_kop *kop, int rlen, BIGNUM *r, int slen, BIGNUM *s)
678{
679 int fd, ret = -1;
680
681 if ((fd = get_asym_dev_crypto()) < 0)
682 return (ret);
683
684 if (r) {
685 kop->crk_param[kop->crk_iparams].crp_p = calloc(rlen, sizeof(char));
686 kop->crk_param[kop->crk_iparams].crp_nbits = rlen * 8;
687 kop->crk_oparams++;
688 }
689 if (s) {
690 kop->crk_param[kop->crk_iparams+1].crp_p = calloc(slen, sizeof(char));
691 kop->crk_param[kop->crk_iparams+1].crp_nbits = slen * 8;
692 kop->crk_oparams++;
693 }
694
695 if (ioctl(fd, CIOCKEY, kop) == 0) {
696 if (r)
697 crparam2bn(&kop->crk_param[kop->crk_iparams], r);
698 if (s)
699 crparam2bn(&kop->crk_param[kop->crk_iparams+1], s);
700 ret = 0;
701 }
702
703 return (ret);
704}
705
706static int
707cryptodev_bn_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
708 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont)
709{
710 struct crypt_kop kop;
711 int ret = 1;
712
713 /* Currently, we know we can do mod exp iff we can do any
714 * asymmetric operations at all.
715 */
716 if (cryptodev_asymfeat == 0) {
717 ret = BN_mod_exp(r, a, p, m, ctx);
718 return (ret);
719 }
720
721 memset(&kop, 0, sizeof kop);
722 kop.crk_op = CRK_MOD_EXP;
723
724 /* inputs: a^p % m */
725 if (bn2crparam(a, &kop.crk_param[0]))
726 goto err;
727 if (bn2crparam(p, &kop.crk_param[1]))
728 goto err;
729 if (bn2crparam(m, &kop.crk_param[2]))
730 goto err;
731 kop.crk_iparams = 3;
732
733 if (cryptodev_asym(&kop, BN_num_bytes(m), r, 0, NULL) == -1) {
734 const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
735 ret = meth->bn_mod_exp(r, a, p, m, ctx, in_mont);
736 }
737err:
738 zapparams(&kop);
739 return (ret);
740}
741
742static int
743cryptodev_rsa_nocrt_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
744{
745 int r;
746 BN_CTX *ctx;
747
748 ctx = BN_CTX_new();
749 r = cryptodev_bn_mod_exp(r0, I, rsa->d, rsa->n, ctx, NULL);
750 BN_CTX_free(ctx);
751 return (r);
752}
753
754static int
755cryptodev_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
756{
757 struct crypt_kop kop;
758 int ret = 1;
759
760 if (!rsa->p || !rsa->q || !rsa->dmp1 || !rsa->dmq1 || !rsa->iqmp) {
761 /* XXX 0 means failure?? */
762 return (0);
763 }
764
765 memset(&kop, 0, sizeof kop);
766 kop.crk_op = CRK_MOD_EXP_CRT;
767 /* inputs: rsa->p rsa->q I rsa->dmp1 rsa->dmq1 rsa->iqmp */
768 if (bn2crparam(rsa->p, &kop.crk_param[0]))
769 goto err;
770 if (bn2crparam(rsa->q, &kop.crk_param[1]))
771 goto err;
772 if (bn2crparam(I, &kop.crk_param[2]))
773 goto err;
774 if (bn2crparam(rsa->dmp1, &kop.crk_param[3]))
775 goto err;
776 if (bn2crparam(rsa->dmq1, &kop.crk_param[4]))
777 goto err;
778 if (bn2crparam(rsa->iqmp, &kop.crk_param[5]))
779 goto err;
780 kop.crk_iparams = 6;
781
782 if (cryptodev_asym(&kop, BN_num_bytes(rsa->n), r0, 0, NULL) == -1) {
783 const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
784 ret = (*meth->rsa_mod_exp)(r0, I, rsa);
785 }
786err:
787 zapparams(&kop);
788 return (ret);
789}
790
791static RSA_METHOD cryptodev_rsa = {
792 "cryptodev RSA method",
793 NULL, /* rsa_pub_enc */
794 NULL, /* rsa_pub_dec */
795 NULL, /* rsa_priv_enc */
796 NULL, /* rsa_priv_dec */
797 NULL,
798 NULL,
799 NULL, /* init */
800 NULL, /* finish */
801 0, /* flags */
802 NULL, /* app_data */
803 NULL, /* rsa_sign */
804 NULL /* rsa_verify */
805};
806
807static int
808cryptodev_dsa_bn_mod_exp(DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
809 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
810{
811 return (cryptodev_bn_mod_exp(r, a, p, m, ctx, m_ctx));
812}
813
814static int
815cryptodev_dsa_dsa_mod_exp(DSA *dsa, BIGNUM *t1, BIGNUM *g,
816 BIGNUM *u1, BIGNUM *pub_key, BIGNUM *u2, BIGNUM *p,
817 BN_CTX *ctx, BN_MONT_CTX *mont)
818{
819 BIGNUM t2;
820 int ret = 0;
821
822 BN_init(&t2);
823
824 /* v = ( g^u1 * y^u2 mod p ) mod q */
825 /* let t1 = g ^ u1 mod p */
826 ret = 0;
827
828 if (!dsa->meth->bn_mod_exp(dsa,t1,dsa->g,u1,dsa->p,ctx,mont))
829 goto err;
830
831 /* let t2 = y ^ u2 mod p */
832 if (!dsa->meth->bn_mod_exp(dsa,&t2,dsa->pub_key,u2,dsa->p,ctx,mont))
833 goto err;
834 /* let u1 = t1 * t2 mod p */
835 if (!BN_mod_mul(u1,t1,&t2,dsa->p,ctx))
836 goto err;
837
838 BN_copy(t1,u1);
839
840 ret = 1;
841err:
842 BN_free(&t2);
843 return(ret);
844}
845
846static DSA_SIG *
847cryptodev_dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
848{
849 struct crypt_kop kop;
850 BIGNUM *r = NULL, *s = NULL;
851 DSA_SIG *dsaret = NULL;
852
853 if ((r = BN_new()) == NULL)
854 goto err;
855 if ((s = BN_new()) == NULL) {
856 BN_free(r);
857 goto err;
858 }
859
860 memset(&kop, 0, sizeof kop);
861 kop.crk_op = CRK_DSA_SIGN;
862
863 /* inputs: dgst dsa->p dsa->q dsa->g dsa->priv_key */
864 kop.crk_param[0].crp_p = (caddr_t)dgst;
865 kop.crk_param[0].crp_nbits = dlen * 8;
866 if (bn2crparam(dsa->p, &kop.crk_param[1]))
867 goto err;
868 if (bn2crparam(dsa->q, &kop.crk_param[2]))
869 goto err;
870 if (bn2crparam(dsa->g, &kop.crk_param[3]))
871 goto err;
872 if (bn2crparam(dsa->priv_key, &kop.crk_param[4]))
873 goto err;
874 kop.crk_iparams = 5;
875
876 if (cryptodev_asym(&kop, BN_num_bytes(dsa->q), r,
877 BN_num_bytes(dsa->q), s) == 0) {
878 dsaret = DSA_SIG_new();
879 dsaret->r = r;
880 dsaret->s = s;
881 } else {
882 const DSA_METHOD *meth = DSA_OpenSSL();
883 BN_free(r);
884 BN_free(s);
885 dsaret = (meth->dsa_do_sign)(dgst, dlen, dsa);
886 }
887err:
888 kop.crk_param[0].crp_p = NULL;
889 zapparams(&kop);
890 return (dsaret);
891}
892
893static int
894cryptodev_dsa_verify(const unsigned char *dgst, int dlen,
895 DSA_SIG *sig, DSA *dsa)
896{
897 struct crypt_kop kop;
898 int dsaret = 1;
899
900 memset(&kop, 0, sizeof kop);
901 kop.crk_op = CRK_DSA_VERIFY;
902
903 /* inputs: dgst dsa->p dsa->q dsa->g dsa->pub_key sig->r sig->s */
904 kop.crk_param[0].crp_p = (caddr_t)dgst;
905 kop.crk_param[0].crp_nbits = dlen * 8;
906 if (bn2crparam(dsa->p, &kop.crk_param[1]))
907 goto err;
908 if (bn2crparam(dsa->q, &kop.crk_param[2]))
909 goto err;
910 if (bn2crparam(dsa->g, &kop.crk_param[3]))
911 goto err;
912 if (bn2crparam(dsa->pub_key, &kop.crk_param[4]))
913 goto err;
914 if (bn2crparam(sig->r, &kop.crk_param[5]))
915 goto err;
916 if (bn2crparam(sig->s, &kop.crk_param[6]))
917 goto err;
918 kop.crk_iparams = 7;
919
920 if (cryptodev_asym(&kop, 0, NULL, 0, NULL) == 0) {
921 dsaret = kop.crk_status;
922 } else {
923 const DSA_METHOD *meth = DSA_OpenSSL();
924
925 dsaret = (meth->dsa_do_verify)(dgst, dlen, sig, dsa);
926 }
927err:
928 kop.crk_param[0].crp_p = NULL;
929 zapparams(&kop);
930 return (dsaret);
931}
932
933static DSA_METHOD cryptodev_dsa = {
934 "cryptodev DSA method",
935 NULL,
936 NULL, /* dsa_sign_setup */
937 NULL,
938 NULL, /* dsa_mod_exp */
939 NULL,
940 NULL, /* init */
941 NULL, /* finish */
942 0, /* flags */
943 NULL /* app_data */
944};
945
946static int
947cryptodev_mod_exp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a,
948 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
949 BN_MONT_CTX *m_ctx)
950{
951 return (cryptodev_bn_mod_exp(r, a, p, m, ctx, m_ctx));
952}
953
954static int
955cryptodev_dh_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh)
956{
957 struct crypt_kop kop;
958 int dhret = 1;
959 int fd, keylen;
960
961 if ((fd = get_asym_dev_crypto()) < 0) {
962 const DH_METHOD *meth = DH_OpenSSL();
963
964 return ((meth->compute_key)(key, pub_key, dh));
965 }
966
967 keylen = BN_num_bits(dh->p);
968
969 memset(&kop, 0, sizeof kop);
970 kop.crk_op = CRK_DH_COMPUTE_KEY;
971
972 /* inputs: dh->priv_key pub_key dh->p key */
973 if (bn2crparam(dh->priv_key, &kop.crk_param[0]))
974 goto err;
975 if (bn2crparam(pub_key, &kop.crk_param[1]))
976 goto err;
977 if (bn2crparam(dh->p, &kop.crk_param[2]))
978 goto err;
979 kop.crk_iparams = 3;
980
981 kop.crk_param[3].crp_p = key;
982 kop.crk_param[3].crp_nbits = keylen * 8;
983 kop.crk_oparams = 1;
984
985 if (ioctl(fd, CIOCKEY, &kop) == -1) {
986 const DH_METHOD *meth = DH_OpenSSL();
987
988 dhret = (meth->compute_key)(key, pub_key, dh);
989 }
990err:
991 kop.crk_param[3].crp_p = NULL;
992 zapparams(&kop);
993 return (dhret);
994}
995
996static DH_METHOD cryptodev_dh = {
997 "cryptodev DH method",
998 NULL, /* cryptodev_dh_generate_key */
999 NULL,
1000 NULL,
1001 NULL,
1002 NULL,
1003 0, /* flags */
1004 NULL /* app_data */
1005};
1006
1007/*
1008 * ctrl right now is just a wrapper that doesn't do much
1009 * but I expect we'll want some options soon.
1010 */
1011static int
1012cryptodev_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
1013{
1014 struct syslog_data sd = SYSLOG_DATA_INIT;
1015
1016 switch (cmd) {
1017 default:
1018 syslog_r(LOG_ERR, &sd,
1019 "cryptodev_ctrl: unknown command %d", cmd);
1020 break;
1021 }
1022 return (1);
1023}
1024
1025void
1026ENGINE_load_cryptodev(void)
1027{
1028 ENGINE *engine = ENGINE_new();
1029 int fd;
1030
1031 if (engine == NULL)
1032 return;
1033 if ((fd = get_dev_crypto()) < 0)
1034 return;
1035
1036 /*
1037 * find out what asymmetric crypto algorithms we support
1038 */
1039 if (ioctl(fd, CIOCASYMFEAT, &cryptodev_asymfeat) == -1) {
1040 close(fd);
1041 return;
1042 }
1043 close(fd);
1044
1045 if (!ENGINE_set_id(engine, "cryptodev") ||
1046 !ENGINE_set_name(engine, "OpenBSD cryptodev engine") ||
1047 !ENGINE_set_ciphers(engine, cryptodev_engine_ciphers) ||
1048 !ENGINE_set_digests(engine, cryptodev_engine_digests) ||
1049 !ENGINE_set_ctrl_function(engine, cryptodev_ctrl) ||
1050 !ENGINE_set_cmd_defns(engine, cryptodev_defns)) {
1051 ENGINE_free(engine);
1052 return;
1053 }
1054
1055 if (ENGINE_set_RSA(engine, &cryptodev_rsa)) {
1056 const RSA_METHOD *rsa_meth = RSA_PKCS1_SSLeay();
1057
1058 cryptodev_rsa.bn_mod_exp = rsa_meth->bn_mod_exp;
1059 cryptodev_rsa.rsa_mod_exp = rsa_meth->rsa_mod_exp;
1060 cryptodev_rsa.rsa_pub_enc = rsa_meth->rsa_pub_enc;
1061 cryptodev_rsa.rsa_pub_dec = rsa_meth->rsa_pub_dec;
1062 cryptodev_rsa.rsa_priv_enc = rsa_meth->rsa_priv_enc;
1063 cryptodev_rsa.rsa_priv_dec = rsa_meth->rsa_priv_dec;
1064 if (cryptodev_asymfeat & CRF_MOD_EXP) {
1065 cryptodev_rsa.bn_mod_exp = cryptodev_bn_mod_exp;
1066 if (cryptodev_asymfeat & CRF_MOD_EXP_CRT)
1067 cryptodev_rsa.rsa_mod_exp =
1068 cryptodev_rsa_mod_exp;
1069 else
1070 cryptodev_rsa.rsa_mod_exp =
1071 cryptodev_rsa_nocrt_mod_exp;
1072 }
1073 }
1074
1075 if (ENGINE_set_DSA(engine, &cryptodev_dsa)) {
1076 const DSA_METHOD *meth = DSA_OpenSSL();
1077
1078 memcpy(&cryptodev_dsa, meth, sizeof(DSA_METHOD));
1079 if (cryptodev_asymfeat & CRF_DSA_SIGN)
1080 cryptodev_dsa.dsa_do_sign = cryptodev_dsa_do_sign;
1081 if (cryptodev_asymfeat & CRF_MOD_EXP) {
1082 cryptodev_dsa.bn_mod_exp = cryptodev_dsa_bn_mod_exp;
1083 cryptodev_dsa.dsa_mod_exp = cryptodev_dsa_dsa_mod_exp;
1084 }
1085 if (cryptodev_asymfeat & CRF_DSA_VERIFY)
1086 cryptodev_dsa.dsa_do_verify = cryptodev_dsa_verify;
1087 }
1088
1089 if (ENGINE_set_DH(engine, &cryptodev_dh)){
1090 const DH_METHOD *dh_meth = DH_OpenSSL();
1091
1092 cryptodev_dh.generate_key = dh_meth->generate_key;
1093 cryptodev_dh.compute_key = dh_meth->compute_key;
1094 cryptodev_dh.bn_mod_exp = dh_meth->bn_mod_exp;
1095 if (cryptodev_asymfeat & CRF_MOD_EXP) {
1096 cryptodev_dh.bn_mod_exp = cryptodev_mod_exp_dh;
1097 if (cryptodev_asymfeat & CRF_DH_COMPUTE_KEY)
1098 cryptodev_dh.compute_key =
1099 cryptodev_dh_compute_key;
1100 }
1101 }
1102
1103 ENGINE_add(engine);
1104 ENGINE_free(engine);
1105 ERR_clear_error();
1106}
diff --git a/src/lib/libcrypto/engine/hw_cswift.c b/src/lib/libcrypto/engine/hw_cswift.c
new file mode 100644
index 0000000000..f5c897bdbb
--- /dev/null
+++ b/src/lib/libcrypto/engine/hw_cswift.c
@@ -0,0 +1,924 @@
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)());
93
94/* BIGNUM stuff */
95static int cswift_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
96 const BIGNUM *m, BN_CTX *ctx);
97static int cswift_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
98 const BIGNUM *q, const BIGNUM *dmp1, const BIGNUM *dmq1,
99 const BIGNUM *iqmp, BN_CTX *ctx);
100
101#ifndef OPENSSL_NO_RSA
102/* RSA stuff */
103static int cswift_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa);
104#endif
105/* This function is aliased to mod_exp (with the mont stuff dropped). */
106static int cswift_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#ifndef OPENSSL_NO_DSA
110/* DSA stuff */
111static DSA_SIG *cswift_dsa_sign(const unsigned char *dgst, int dlen, DSA *dsa);
112static int cswift_dsa_verify(const unsigned char *dgst, int dgst_len,
113 DSA_SIG *sig, DSA *dsa);
114#endif
115
116#ifndef OPENSSL_NO_DH
117/* DH stuff */
118/* This function is alised to mod_exp (with the DH and mont dropped). */
119static int cswift_mod_exp_dh(const DH *dh, BIGNUM *r,
120 const BIGNUM *a, const BIGNUM *p,
121 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
122#endif
123
124/* The definitions for control commands specific to this engine */
125#define CSWIFT_CMD_SO_PATH ENGINE_CMD_BASE
126static const ENGINE_CMD_DEFN cswift_cmd_defns[] = {
127 {CSWIFT_CMD_SO_PATH,
128 "SO_PATH",
129 "Specifies the path to the 'cswift' shared library",
130 ENGINE_CMD_FLAG_STRING},
131 {0, NULL, NULL, 0}
132 };
133
134#ifndef OPENSSL_NO_RSA
135/* Our internal RSA_METHOD that we provide pointers to */
136static RSA_METHOD cswift_rsa =
137 {
138 "CryptoSwift RSA method",
139 NULL,
140 NULL,
141 NULL,
142 NULL,
143 cswift_rsa_mod_exp,
144 cswift_mod_exp_mont,
145 NULL,
146 NULL,
147 0,
148 NULL,
149 NULL,
150 NULL
151 };
152#endif
153
154#ifndef OPENSSL_NO_DSA
155/* Our internal DSA_METHOD that we provide pointers to */
156static DSA_METHOD cswift_dsa =
157 {
158 "CryptoSwift DSA method",
159 cswift_dsa_sign,
160 NULL, /* dsa_sign_setup */
161 cswift_dsa_verify,
162 NULL, /* dsa_mod_exp */
163 NULL, /* bn_mod_exp */
164 NULL, /* init */
165 NULL, /* finish */
166 0, /* flags */
167 NULL /* app_data */
168 };
169#endif
170
171#ifndef OPENSSL_NO_DH
172/* Our internal DH_METHOD that we provide pointers to */
173static DH_METHOD cswift_dh =
174 {
175 "CryptoSwift DH method",
176 NULL,
177 NULL,
178 cswift_mod_exp_dh,
179 NULL,
180 NULL,
181 0,
182 NULL
183 };
184#endif
185
186/* Constants used when creating the ENGINE */
187static const char *engine_cswift_id = "cswift";
188static const char *engine_cswift_name = "CryptoSwift hardware engine support";
189
190/* This internal function is used by ENGINE_cswift() and possibly by the
191 * "dynamic" ENGINE support too */
192static int bind_helper(ENGINE *e)
193 {
194#ifndef OPENSSL_NO_RSA
195 const RSA_METHOD *meth1;
196#endif
197#ifndef OPENSSL_NO_DH
198 const DH_METHOD *meth2;
199#endif
200 if(!ENGINE_set_id(e, engine_cswift_id) ||
201 !ENGINE_set_name(e, engine_cswift_name) ||
202#ifndef OPENSSL_NO_RSA
203 !ENGINE_set_RSA(e, &cswift_rsa) ||
204#endif
205#ifndef OPENSSL_NO_DSA
206 !ENGINE_set_DSA(e, &cswift_dsa) ||
207#endif
208#ifndef OPENSSL_NO_DH
209 !ENGINE_set_DH(e, &cswift_dh) ||
210#endif
211 !ENGINE_set_destroy_function(e, cswift_destroy) ||
212 !ENGINE_set_init_function(e, cswift_init) ||
213 !ENGINE_set_finish_function(e, cswift_finish) ||
214 !ENGINE_set_ctrl_function(e, cswift_ctrl) ||
215 !ENGINE_set_cmd_defns(e, cswift_cmd_defns))
216 return 0;
217
218#ifndef OPENSSL_NO_RSA
219 /* We know that the "PKCS1_SSLeay()" functions hook properly
220 * to the cswift-specific mod_exp and mod_exp_crt so we use
221 * those functions. NB: We don't use ENGINE_openssl() or
222 * anything "more generic" because something like the RSAref
223 * code may not hook properly, and if you own one of these
224 * cards then you have the right to do RSA operations on it
225 * anyway! */
226 meth1 = RSA_PKCS1_SSLeay();
227 cswift_rsa.rsa_pub_enc = meth1->rsa_pub_enc;
228 cswift_rsa.rsa_pub_dec = meth1->rsa_pub_dec;
229 cswift_rsa.rsa_priv_enc = meth1->rsa_priv_enc;
230 cswift_rsa.rsa_priv_dec = meth1->rsa_priv_dec;
231#endif
232
233#ifndef OPENSSL_NO_DH
234 /* Much the same for Diffie-Hellman */
235 meth2 = DH_OpenSSL();
236 cswift_dh.generate_key = meth2->generate_key;
237 cswift_dh.compute_key = meth2->compute_key;
238#endif
239
240 /* Ensure the cswift error handling is set up */
241 ERR_load_CSWIFT_strings();
242 return 1;
243 }
244
245static ENGINE *engine_cswift(void)
246 {
247 ENGINE *ret = ENGINE_new();
248 if(!ret)
249 return NULL;
250 if(!bind_helper(ret))
251 {
252 ENGINE_free(ret);
253 return NULL;
254 }
255 return ret;
256 }
257
258void ENGINE_load_cswift(void)
259 {
260 /* Copied from eng_[openssl|dyn].c */
261 ENGINE *toadd = engine_cswift();
262 if(!toadd) return;
263 ENGINE_add(toadd);
264 ENGINE_free(toadd);
265 ERR_clear_error();
266 }
267
268/* This is a process-global DSO handle used for loading and unloading
269 * the CryptoSwift library. NB: This is only set (or unset) during an
270 * init() or finish() call (reference counts permitting) and they're
271 * operating with global locks, so this should be thread-safe
272 * implicitly. */
273static DSO *cswift_dso = NULL;
274
275/* These are the function pointers that are (un)set when the library has
276 * successfully (un)loaded. */
277t_swAcquireAccContext *p_CSwift_AcquireAccContext = NULL;
278t_swAttachKeyParam *p_CSwift_AttachKeyParam = NULL;
279t_swSimpleRequest *p_CSwift_SimpleRequest = NULL;
280t_swReleaseAccContext *p_CSwift_ReleaseAccContext = NULL;
281
282/* Used in the DSO operations. */
283static const char *CSWIFT_LIBNAME = NULL;
284static const char *get_CSWIFT_LIBNAME(void)
285 {
286 if(CSWIFT_LIBNAME)
287 return CSWIFT_LIBNAME;
288 return "swift";
289 }
290static void free_CSWIFT_LIBNAME(void)
291 {
292 if(CSWIFT_LIBNAME)
293 OPENSSL_free((void*)CSWIFT_LIBNAME);
294 CSWIFT_LIBNAME = NULL;
295 }
296static long set_CSWIFT_LIBNAME(const char *name)
297 {
298 free_CSWIFT_LIBNAME();
299 return (((CSWIFT_LIBNAME = BUF_strdup(name)) != NULL) ? 1 : 0);
300 }
301static const char *CSWIFT_F1 = "swAcquireAccContext";
302static const char *CSWIFT_F2 = "swAttachKeyParam";
303static const char *CSWIFT_F3 = "swSimpleRequest";
304static const char *CSWIFT_F4 = "swReleaseAccContext";
305
306
307/* CryptoSwift library functions and mechanics - these are used by the
308 * higher-level functions further down. NB: As and where there's no
309 * error checking, take a look lower down where these functions are
310 * called, the checking and error handling is probably down there. */
311
312/* utility function to obtain a context */
313static int get_context(SW_CONTEXT_HANDLE *hac)
314 {
315 SW_STATUS status;
316
317 status = p_CSwift_AcquireAccContext(hac);
318 if(status != SW_OK)
319 return 0;
320 return 1;
321 }
322
323/* similarly to release one. */
324static void release_context(SW_CONTEXT_HANDLE hac)
325 {
326 p_CSwift_ReleaseAccContext(hac);
327 }
328
329/* Destructor (complements the "ENGINE_cswift()" constructor) */
330static int cswift_destroy(ENGINE *e)
331 {
332 free_CSWIFT_LIBNAME();
333 ERR_unload_CSWIFT_strings();
334 return 1;
335 }
336
337/* (de)initialisation functions. */
338static int cswift_init(ENGINE *e)
339 {
340 SW_CONTEXT_HANDLE hac;
341 t_swAcquireAccContext *p1;
342 t_swAttachKeyParam *p2;
343 t_swSimpleRequest *p3;
344 t_swReleaseAccContext *p4;
345
346 if(cswift_dso != NULL)
347 {
348 CSWIFTerr(CSWIFT_F_CSWIFT_INIT,CSWIFT_R_ALREADY_LOADED);
349 goto err;
350 }
351 /* Attempt to load libswift.so/swift.dll/whatever. */
352 cswift_dso = DSO_load(NULL, get_CSWIFT_LIBNAME(), NULL, 0);
353 if(cswift_dso == NULL)
354 {
355 CSWIFTerr(CSWIFT_F_CSWIFT_INIT,CSWIFT_R_NOT_LOADED);
356 goto err;
357 }
358 if(!(p1 = (t_swAcquireAccContext *)
359 DSO_bind_func(cswift_dso, CSWIFT_F1)) ||
360 !(p2 = (t_swAttachKeyParam *)
361 DSO_bind_func(cswift_dso, CSWIFT_F2)) ||
362 !(p3 = (t_swSimpleRequest *)
363 DSO_bind_func(cswift_dso, CSWIFT_F3)) ||
364 !(p4 = (t_swReleaseAccContext *)
365 DSO_bind_func(cswift_dso, CSWIFT_F4)))
366 {
367 CSWIFTerr(CSWIFT_F_CSWIFT_INIT,CSWIFT_R_NOT_LOADED);
368 goto err;
369 }
370 /* Copy the pointers */
371 p_CSwift_AcquireAccContext = p1;
372 p_CSwift_AttachKeyParam = p2;
373 p_CSwift_SimpleRequest = p3;
374 p_CSwift_ReleaseAccContext = p4;
375 /* Try and get a context - if not, we may have a DSO but no
376 * accelerator! */
377 if(!get_context(&hac))
378 {
379 CSWIFTerr(CSWIFT_F_CSWIFT_INIT,CSWIFT_R_UNIT_FAILURE);
380 goto err;
381 }
382 release_context(hac);
383 /* Everything's fine. */
384 return 1;
385err:
386 if(cswift_dso)
387 DSO_free(cswift_dso);
388 p_CSwift_AcquireAccContext = NULL;
389 p_CSwift_AttachKeyParam = NULL;
390 p_CSwift_SimpleRequest = NULL;
391 p_CSwift_ReleaseAccContext = NULL;
392 return 0;
393 }
394
395static int cswift_finish(ENGINE *e)
396 {
397 free_CSWIFT_LIBNAME();
398 if(cswift_dso == NULL)
399 {
400 CSWIFTerr(CSWIFT_F_CSWIFT_FINISH,CSWIFT_R_NOT_LOADED);
401 return 0;
402 }
403 if(!DSO_free(cswift_dso))
404 {
405 CSWIFTerr(CSWIFT_F_CSWIFT_FINISH,CSWIFT_R_UNIT_FAILURE);
406 return 0;
407 }
408 cswift_dso = NULL;
409 p_CSwift_AcquireAccContext = NULL;
410 p_CSwift_AttachKeyParam = NULL;
411 p_CSwift_SimpleRequest = NULL;
412 p_CSwift_ReleaseAccContext = NULL;
413 return 1;
414 }
415
416static int cswift_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
417 {
418 int initialised = ((cswift_dso == NULL) ? 0 : 1);
419 switch(cmd)
420 {
421 case CSWIFT_CMD_SO_PATH:
422 if(p == NULL)
423 {
424 CSWIFTerr(CSWIFT_F_CSWIFT_CTRL,ERR_R_PASSED_NULL_PARAMETER);
425 return 0;
426 }
427 if(initialised)
428 {
429 CSWIFTerr(CSWIFT_F_CSWIFT_CTRL,CSWIFT_R_ALREADY_LOADED);
430 return 0;
431 }
432 return set_CSWIFT_LIBNAME((const char *)p);
433 default:
434 break;
435 }
436 CSWIFTerr(CSWIFT_F_CSWIFT_CTRL,CSWIFT_R_CTRL_COMMAND_NOT_IMPLEMENTED);
437 return 0;
438 }
439
440/* Un petit mod_exp */
441static int cswift_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
442 const BIGNUM *m, BN_CTX *ctx)
443 {
444 /* I need somewhere to store temporary serialised values for
445 * use with the CryptoSwift API calls. A neat cheat - I'll use
446 * BIGNUMs from the BN_CTX but access their arrays directly as
447 * byte arrays <grin>. This way I don't have to clean anything
448 * up. */
449 BIGNUM *modulus;
450 BIGNUM *exponent;
451 BIGNUM *argument;
452 BIGNUM *result;
453 SW_STATUS sw_status;
454 SW_LARGENUMBER arg, res;
455 SW_PARAM sw_param;
456 SW_CONTEXT_HANDLE hac;
457 int to_return, acquired;
458
459 modulus = exponent = argument = result = NULL;
460 to_return = 0; /* expect failure */
461 acquired = 0;
462
463 if(!get_context(&hac))
464 {
465 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP,CSWIFT_R_UNIT_FAILURE);
466 goto err;
467 }
468 acquired = 1;
469 /* Prepare the params */
470 BN_CTX_start(ctx);
471 modulus = BN_CTX_get(ctx);
472 exponent = BN_CTX_get(ctx);
473 argument = BN_CTX_get(ctx);
474 result = BN_CTX_get(ctx);
475 if(!result)
476 {
477 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP,CSWIFT_R_BN_CTX_FULL);
478 goto err;
479 }
480 if(!bn_wexpand(modulus, m->top) || !bn_wexpand(exponent, p->top) ||
481 !bn_wexpand(argument, a->top) || !bn_wexpand(result, m->top))
482 {
483 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP,CSWIFT_R_BN_EXPAND_FAIL);
484 goto err;
485 }
486 sw_param.type = SW_ALG_EXP;
487 sw_param.up.exp.modulus.nbytes = BN_bn2bin(m,
488 (unsigned char *)modulus->d);
489 sw_param.up.exp.modulus.value = (unsigned char *)modulus->d;
490 sw_param.up.exp.exponent.nbytes = BN_bn2bin(p,
491 (unsigned char *)exponent->d);
492 sw_param.up.exp.exponent.value = (unsigned char *)exponent->d;
493 /* Attach the key params */
494 sw_status = p_CSwift_AttachKeyParam(hac, &sw_param);
495 switch(sw_status)
496 {
497 case SW_OK:
498 break;
499 case SW_ERR_INPUT_SIZE:
500 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP,CSWIFT_R_BAD_KEY_SIZE);
501 goto err;
502 default:
503 {
504 char tmpbuf[DECIMAL_SIZE(sw_status)+1];
505 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP,CSWIFT_R_REQUEST_FAILED);
506 sprintf(tmpbuf, "%ld", sw_status);
507 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);
508 }
509 goto err;
510 }
511 /* Prepare the argument and response */
512 arg.nbytes = BN_bn2bin(a, (unsigned char *)argument->d);
513 arg.value = (unsigned char *)argument->d;
514 res.nbytes = BN_num_bytes(m);
515 memset(result->d, 0, res.nbytes);
516 res.value = (unsigned char *)result->d;
517 /* Perform the operation */
518 if((sw_status = p_CSwift_SimpleRequest(hac, SW_CMD_MODEXP, &arg, 1,
519 &res, 1)) != SW_OK)
520 {
521 char tmpbuf[DECIMAL_SIZE(sw_status)+1];
522 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP,CSWIFT_R_REQUEST_FAILED);
523 sprintf(tmpbuf, "%ld", sw_status);
524 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);
525 goto err;
526 }
527 /* Convert the response */
528 BN_bin2bn((unsigned char *)result->d, res.nbytes, r);
529 to_return = 1;
530err:
531 if(acquired)
532 release_context(hac);
533 BN_CTX_end(ctx);
534 return to_return;
535 }
536
537/* Un petit mod_exp chinois */
538static int cswift_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
539 const BIGNUM *q, const BIGNUM *dmp1,
540 const BIGNUM *dmq1, const BIGNUM *iqmp, BN_CTX *ctx)
541 {
542 SW_STATUS sw_status;
543 SW_LARGENUMBER arg, res;
544 SW_PARAM sw_param;
545 SW_CONTEXT_HANDLE hac;
546 BIGNUM *rsa_p = NULL;
547 BIGNUM *rsa_q = NULL;
548 BIGNUM *rsa_dmp1 = NULL;
549 BIGNUM *rsa_dmq1 = NULL;
550 BIGNUM *rsa_iqmp = NULL;
551 BIGNUM *argument = NULL;
552 BIGNUM *result = NULL;
553 int to_return = 0; /* expect failure */
554 int acquired = 0;
555
556 if(!get_context(&hac))
557 {
558 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_UNIT_FAILURE);
559 goto err;
560 }
561 acquired = 1;
562 /* Prepare the params */
563 BN_CTX_start(ctx);
564 rsa_p = BN_CTX_get(ctx);
565 rsa_q = BN_CTX_get(ctx);
566 rsa_dmp1 = BN_CTX_get(ctx);
567 rsa_dmq1 = BN_CTX_get(ctx);
568 rsa_iqmp = BN_CTX_get(ctx);
569 argument = BN_CTX_get(ctx);
570 result = BN_CTX_get(ctx);
571 if(!result)
572 {
573 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_BN_CTX_FULL);
574 goto err;
575 }
576 if(!bn_wexpand(rsa_p, p->top) || !bn_wexpand(rsa_q, q->top) ||
577 !bn_wexpand(rsa_dmp1, dmp1->top) ||
578 !bn_wexpand(rsa_dmq1, dmq1->top) ||
579 !bn_wexpand(rsa_iqmp, iqmp->top) ||
580 !bn_wexpand(argument, a->top) ||
581 !bn_wexpand(result, p->top + q->top))
582 {
583 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_BN_EXPAND_FAIL);
584 goto err;
585 }
586 sw_param.type = SW_ALG_CRT;
587 sw_param.up.crt.p.nbytes = BN_bn2bin(p, (unsigned char *)rsa_p->d);
588 sw_param.up.crt.p.value = (unsigned char *)rsa_p->d;
589 sw_param.up.crt.q.nbytes = BN_bn2bin(q, (unsigned char *)rsa_q->d);
590 sw_param.up.crt.q.value = (unsigned char *)rsa_q->d;
591 sw_param.up.crt.dmp1.nbytes = BN_bn2bin(dmp1,
592 (unsigned char *)rsa_dmp1->d);
593 sw_param.up.crt.dmp1.value = (unsigned char *)rsa_dmp1->d;
594 sw_param.up.crt.dmq1.nbytes = BN_bn2bin(dmq1,
595 (unsigned char *)rsa_dmq1->d);
596 sw_param.up.crt.dmq1.value = (unsigned char *)rsa_dmq1->d;
597 sw_param.up.crt.iqmp.nbytes = BN_bn2bin(iqmp,
598 (unsigned char *)rsa_iqmp->d);
599 sw_param.up.crt.iqmp.value = (unsigned char *)rsa_iqmp->d;
600 /* Attach the key params */
601 sw_status = p_CSwift_AttachKeyParam(hac, &sw_param);
602 switch(sw_status)
603 {
604 case SW_OK:
605 break;
606 case SW_ERR_INPUT_SIZE:
607 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_BAD_KEY_SIZE);
608 goto err;
609 default:
610 {
611 char tmpbuf[DECIMAL_SIZE(sw_status)+1];
612 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_REQUEST_FAILED);
613 sprintf(tmpbuf, "%ld", sw_status);
614 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);
615 }
616 goto err;
617 }
618 /* Prepare the argument and response */
619 arg.nbytes = BN_bn2bin(a, (unsigned char *)argument->d);
620 arg.value = (unsigned char *)argument->d;
621 res.nbytes = 2 * BN_num_bytes(p);
622 memset(result->d, 0, res.nbytes);
623 res.value = (unsigned char *)result->d;
624 /* Perform the operation */
625 if((sw_status = p_CSwift_SimpleRequest(hac, SW_CMD_MODEXP_CRT, &arg, 1,
626 &res, 1)) != SW_OK)
627 {
628 char tmpbuf[DECIMAL_SIZE(sw_status)+1];
629 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_REQUEST_FAILED);
630 sprintf(tmpbuf, "%ld", sw_status);
631 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);
632 goto err;
633 }
634 /* Convert the response */
635 BN_bin2bn((unsigned char *)result->d, res.nbytes, r);
636 to_return = 1;
637err:
638 if(acquired)
639 release_context(hac);
640 BN_CTX_end(ctx);
641 return to_return;
642 }
643
644#ifndef OPENSSL_NO_RSA
645static int cswift_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
646 {
647 BN_CTX *ctx;
648 int to_return = 0;
649
650 if((ctx = BN_CTX_new()) == NULL)
651 goto err;
652 if(!rsa->p || !rsa->q || !rsa->dmp1 || !rsa->dmq1 || !rsa->iqmp)
653 {
654 CSWIFTerr(CSWIFT_F_CSWIFT_RSA_MOD_EXP,CSWIFT_R_MISSING_KEY_COMPONENTS);
655 goto err;
656 }
657 to_return = cswift_mod_exp_crt(r0, I, rsa->p, rsa->q, rsa->dmp1,
658 rsa->dmq1, rsa->iqmp, ctx);
659err:
660 if(ctx)
661 BN_CTX_free(ctx);
662 return to_return;
663 }
664#endif
665
666/* This function is aliased to mod_exp (with the mont stuff dropped). */
667static int cswift_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
668 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
669 {
670 return cswift_mod_exp(r, a, p, m, ctx);
671 }
672
673#ifndef OPENSSL_NO_DSA
674static DSA_SIG *cswift_dsa_sign(const unsigned char *dgst, int dlen, DSA *dsa)
675 {
676 SW_CONTEXT_HANDLE hac;
677 SW_PARAM sw_param;
678 SW_STATUS sw_status;
679 SW_LARGENUMBER arg, res;
680 unsigned char *ptr;
681 BN_CTX *ctx;
682 BIGNUM *dsa_p = NULL;
683 BIGNUM *dsa_q = NULL;
684 BIGNUM *dsa_g = NULL;
685 BIGNUM *dsa_key = NULL;
686 BIGNUM *result = NULL;
687 DSA_SIG *to_return = NULL;
688 int acquired = 0;
689
690 if((ctx = BN_CTX_new()) == NULL)
691 goto err;
692 if(!get_context(&hac))
693 {
694 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_SIGN,CSWIFT_R_UNIT_FAILURE);
695 goto err;
696 }
697 acquired = 1;
698 /* Prepare the params */
699 BN_CTX_start(ctx);
700 dsa_p = BN_CTX_get(ctx);
701 dsa_q = BN_CTX_get(ctx);
702 dsa_g = BN_CTX_get(ctx);
703 dsa_key = BN_CTX_get(ctx);
704 result = BN_CTX_get(ctx);
705 if(!result)
706 {
707 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_SIGN,CSWIFT_R_BN_CTX_FULL);
708 goto err;
709 }
710 if(!bn_wexpand(dsa_p, dsa->p->top) ||
711 !bn_wexpand(dsa_q, dsa->q->top) ||
712 !bn_wexpand(dsa_g, dsa->g->top) ||
713 !bn_wexpand(dsa_key, dsa->priv_key->top) ||
714 !bn_wexpand(result, dsa->p->top))
715 {
716 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_SIGN,CSWIFT_R_BN_EXPAND_FAIL);
717 goto err;
718 }
719 sw_param.type = SW_ALG_DSA;
720 sw_param.up.dsa.p.nbytes = BN_bn2bin(dsa->p,
721 (unsigned char *)dsa_p->d);
722 sw_param.up.dsa.p.value = (unsigned char *)dsa_p->d;
723 sw_param.up.dsa.q.nbytes = BN_bn2bin(dsa->q,
724 (unsigned char *)dsa_q->d);
725 sw_param.up.dsa.q.value = (unsigned char *)dsa_q->d;
726 sw_param.up.dsa.g.nbytes = BN_bn2bin(dsa->g,
727 (unsigned char *)dsa_g->d);
728 sw_param.up.dsa.g.value = (unsigned char *)dsa_g->d;
729 sw_param.up.dsa.key.nbytes = BN_bn2bin(dsa->priv_key,
730 (unsigned char *)dsa_key->d);
731 sw_param.up.dsa.key.value = (unsigned char *)dsa_key->d;
732 /* Attach the key params */
733 sw_status = p_CSwift_AttachKeyParam(hac, &sw_param);
734 switch(sw_status)
735 {
736 case SW_OK:
737 break;
738 case SW_ERR_INPUT_SIZE:
739 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_SIGN,CSWIFT_R_BAD_KEY_SIZE);
740 goto err;
741 default:
742 {
743 char tmpbuf[DECIMAL_SIZE(sw_status)+1];
744 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_SIGN,CSWIFT_R_REQUEST_FAILED);
745 sprintf(tmpbuf, "%ld", sw_status);
746 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);
747 }
748 goto err;
749 }
750 /* Prepare the argument and response */
751 arg.nbytes = dlen;
752 arg.value = (unsigned char *)dgst;
753 res.nbytes = BN_num_bytes(dsa->p);
754 memset(result->d, 0, res.nbytes);
755 res.value = (unsigned char *)result->d;
756 /* Perform the operation */
757 sw_status = p_CSwift_SimpleRequest(hac, SW_CMD_DSS_SIGN, &arg, 1,
758 &res, 1);
759 if(sw_status != SW_OK)
760 {
761 char tmpbuf[DECIMAL_SIZE(sw_status)+1];
762 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_SIGN,CSWIFT_R_REQUEST_FAILED);
763 sprintf(tmpbuf, "%ld", sw_status);
764 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);
765 goto err;
766 }
767 /* Convert the response */
768 ptr = (unsigned char *)result->d;
769 if((to_return = DSA_SIG_new()) == NULL)
770 goto err;
771 to_return->r = BN_bin2bn((unsigned char *)result->d, 20, NULL);
772 to_return->s = BN_bin2bn((unsigned char *)result->d + 20, 20, NULL);
773
774err:
775 if(acquired)
776 release_context(hac);
777 if(ctx)
778 {
779 BN_CTX_end(ctx);
780 BN_CTX_free(ctx);
781 }
782 return to_return;
783 }
784
785static int cswift_dsa_verify(const unsigned char *dgst, int dgst_len,
786 DSA_SIG *sig, DSA *dsa)
787 {
788 SW_CONTEXT_HANDLE hac;
789 SW_PARAM sw_param;
790 SW_STATUS sw_status;
791 SW_LARGENUMBER arg[2], res;
792 unsigned long sig_result;
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 *argument = NULL;
799 int to_return = -1;
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_VERIFY,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 argument = BN_CTX_get(ctx);
817 if(!argument)
818 {
819 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_VERIFY,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->pub_key->top) ||
826 !bn_wexpand(argument, 40))
827 {
828 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_VERIFY,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->pub_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_VERIFY,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_VERIFY,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[0].nbytes = dgst_len;
864 arg[0].value = (unsigned char *)dgst;
865 arg[1].nbytes = 40;
866 arg[1].value = (unsigned char *)argument->d;
867 memset(arg[1].value, 0, 40);
868 BN_bn2bin(sig->r, arg[1].value + 20 - BN_num_bytes(sig->r));
869 BN_bn2bin(sig->s, arg[1].value + 40 - BN_num_bytes(sig->s));
870 res.nbytes = 4; /* unsigned long */
871 res.value = (unsigned char *)(&sig_result);
872 /* Perform the operation */
873 sw_status = p_CSwift_SimpleRequest(hac, SW_CMD_DSS_VERIFY, arg, 2,
874 &res, 1);
875 if(sw_status != SW_OK)
876 {
877 char tmpbuf[DECIMAL_SIZE(sw_status)+1];
878 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_VERIFY,CSWIFT_R_REQUEST_FAILED);
879 sprintf(tmpbuf, "%ld", sw_status);
880 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);
881 goto err;
882 }
883 /* Convert the response */
884 to_return = ((sig_result == 0) ? 0 : 1);
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#endif
897
898#ifndef OPENSSL_NO_DH
899/* This function is aliased to mod_exp (with the dh and mont dropped). */
900static int cswift_mod_exp_dh(const DH *dh, BIGNUM *r,
901 const BIGNUM *a, const BIGNUM *p,
902 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
903 {
904 return cswift_mod_exp(r, a, p, m, ctx);
905 }
906#endif
907
908/* This stuff is needed if this ENGINE is being compiled into a self-contained
909 * shared-library. */
910#ifdef ENGINE_DYNAMIC_SUPPORT
911static int bind_fn(ENGINE *e, const char *id)
912 {
913 if(id && (strcmp(id, engine_cswift_id) != 0))
914 return 0;
915 if(!bind_helper(e))
916 return 0;
917 return 1;
918 }
919IMPLEMENT_DYNAMIC_CHECK_FN()
920IMPLEMENT_DYNAMIC_BIND_FN(bind_fn)
921#endif /* ENGINE_DYNAMIC_SUPPORT */
922
923#endif /* !OPENSSL_NO_HW_CSWIFT */
924#endif /* !OPENSSL_NO_HW */
diff --git a/src/lib/libcrypto/engine/hw_cswift_err.c b/src/lib/libcrypto/engine/hw_cswift_err.c
new file mode 100644
index 0000000000..684f53bf27
--- /dev/null
+++ b/src/lib/libcrypto/engine/hw_cswift_err.c
@@ -0,0 +1,149 @@
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
new file mode 100644
index 0000000000..7120c3216f
--- /dev/null
+++ b/src/lib/libcrypto/engine/hw_cswift_err.h
@@ -0,0 +1,93 @@
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
new file mode 100644
index 0000000000..a43d4360f2
--- /dev/null
+++ b/src/lib/libcrypto/engine/hw_ncipher.c
@@ -0,0 +1,1342 @@
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 */
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
100/* BIGNUM stuff */
101static int hwcrhk_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
102 const BIGNUM *m, BN_CTX *ctx);
103
104#ifndef OPENSSL_NO_RSA
105/* RSA stuff */
106static int hwcrhk_rsa_mod_exp(BIGNUM *r, const BIGNUM *I, RSA *rsa);
107#endif
108/* This function is aliased to mod_exp (with the mont stuff dropped). */
109static int hwcrhk_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
110 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
111
112#ifndef OPENSSL_NO_DH
113/* DH stuff */
114/* This function is alised to mod_exp (with the DH and mont dropped). */
115static int hwcrhk_mod_exp_dh(const DH *dh, BIGNUM *r,
116 const BIGNUM *a, const BIGNUM *p,
117 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
118#endif
119
120/* RAND stuff */
121static int hwcrhk_rand_bytes(unsigned char *buf, int num);
122static int hwcrhk_rand_status(void);
123
124/* KM stuff */
125static EVP_PKEY *hwcrhk_load_privkey(ENGINE *eng, const char *key_id,
126 UI_METHOD *ui_method, void *callback_data);
127static EVP_PKEY *hwcrhk_load_pubkey(ENGINE *eng, const char *key_id,
128 UI_METHOD *ui_method, void *callback_data);
129static void hwcrhk_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad,
130 int ind,long argl, void *argp);
131
132/* Interaction stuff */
133static int hwcrhk_insert_card(const char *prompt_info,
134 const char *wrong_info,
135 HWCryptoHook_PassphraseContext *ppctx,
136 HWCryptoHook_CallerContext *cactx);
137static int hwcrhk_get_pass(const char *prompt_info,
138 int *len_io, char *buf,
139 HWCryptoHook_PassphraseContext *ppctx,
140 HWCryptoHook_CallerContext *cactx);
141static void hwcrhk_log_message(void *logstr, const char *message);
142
143/* The definitions for control commands specific to this engine */
144#define HWCRHK_CMD_SO_PATH ENGINE_CMD_BASE
145#define HWCRHK_CMD_FORK_CHECK (ENGINE_CMD_BASE + 1)
146#define HWCRHK_CMD_THREAD_LOCKING (ENGINE_CMD_BASE + 2)
147#define HWCRHK_CMD_SET_USER_INTERFACE (ENGINE_CMD_BASE + 3)
148#define HWCRHK_CMD_SET_CALLBACK_DATA (ENGINE_CMD_BASE + 4)
149static const ENGINE_CMD_DEFN hwcrhk_cmd_defns[] = {
150 {HWCRHK_CMD_SO_PATH,
151 "SO_PATH",
152 "Specifies the path to the 'hwcrhk' shared library",
153 ENGINE_CMD_FLAG_STRING},
154 {HWCRHK_CMD_FORK_CHECK,
155 "FORK_CHECK",
156 "Turns fork() checking on or off (boolean)",
157 ENGINE_CMD_FLAG_NUMERIC},
158 {HWCRHK_CMD_THREAD_LOCKING,
159 "THREAD_LOCKING",
160 "Turns thread-safe locking on or off (boolean)",
161 ENGINE_CMD_FLAG_NUMERIC},
162 {HWCRHK_CMD_SET_USER_INTERFACE,
163 "SET_USER_INTERFACE",
164 "Set the global user interface (internal)",
165 ENGINE_CMD_FLAG_INTERNAL},
166 {HWCRHK_CMD_SET_CALLBACK_DATA,
167 "SET_CALLBACK_DATA",
168 "Set the global user interface extra data (internal)",
169 ENGINE_CMD_FLAG_INTERNAL},
170 {0, NULL, NULL, 0}
171 };
172
173#ifndef OPENSSL_NO_RSA
174/* Our internal RSA_METHOD that we provide pointers to */
175static RSA_METHOD hwcrhk_rsa =
176 {
177 "nCipher RSA method",
178 NULL,
179 NULL,
180 NULL,
181 NULL,
182 hwcrhk_rsa_mod_exp,
183 hwcrhk_mod_exp_mont,
184 NULL,
185 NULL,
186 0,
187 NULL,
188 NULL,
189 NULL
190 };
191#endif
192
193#ifndef OPENSSL_NO_DH
194/* Our internal DH_METHOD that we provide pointers to */
195static DH_METHOD hwcrhk_dh =
196 {
197 "nCipher DH method",
198 NULL,
199 NULL,
200 hwcrhk_mod_exp_dh,
201 NULL,
202 NULL,
203 0,
204 NULL
205 };
206#endif
207
208static RAND_METHOD hwcrhk_rand =
209 {
210 /* "nCipher RAND method", */
211 NULL,
212 hwcrhk_rand_bytes,
213 NULL,
214 NULL,
215 hwcrhk_rand_bytes,
216 hwcrhk_rand_status,
217 };
218
219/* Constants used when creating the ENGINE */
220static const char *engine_hwcrhk_id = "chil";
221static const char *engine_hwcrhk_name = "nCipher hardware engine support";
222
223/* Internal stuff for HWCryptoHook */
224
225/* Some structures needed for proper use of thread locks */
226/* hwcryptohook.h has some typedefs that turn struct HWCryptoHook_MutexValue
227 into HWCryptoHook_Mutex */
228struct HWCryptoHook_MutexValue
229 {
230 int lockid;
231 };
232
233/* hwcryptohook.h has some typedefs that turn
234 struct HWCryptoHook_PassphraseContextValue
235 into HWCryptoHook_PassphraseContext */
236struct HWCryptoHook_PassphraseContextValue
237 {
238 UI_METHOD *ui_method;
239 void *callback_data;
240 };
241
242/* hwcryptohook.h has some typedefs that turn
243 struct HWCryptoHook_CallerContextValue
244 into HWCryptoHook_CallerContext */
245struct HWCryptoHook_CallerContextValue
246 {
247 pem_password_cb *password_callback; /* Deprecated! Only present for
248 backward compatibility! */
249 UI_METHOD *ui_method;
250 void *callback_data;
251 };
252
253/* The MPI structure in HWCryptoHook is pretty compatible with OpenSSL
254 BIGNUM's, so lets define a couple of conversion macros */
255#define BN2MPI(mp, bn) \
256 {mp.size = bn->top * sizeof(BN_ULONG); mp.buf = (unsigned char *)bn->d;}
257#define MPI2BN(bn, mp) \
258 {mp.size = bn->dmax * sizeof(BN_ULONG); mp.buf = (unsigned char *)bn->d;}
259
260static BIO *logstream = NULL;
261static int disable_mutex_callbacks = 0;
262
263/* One might wonder why these are needed, since one can pass down at least
264 a UI_METHOD and a pointer to callback data to the key-loading functions.
265 The thing is that the ModExp and RSAImmed functions can load keys as well,
266 if the data they get is in a special, nCipher-defined format (hint: if you
267 look at the private exponent of the RSA data as a string, you'll see this
268 string: "nCipher KM tool key id", followed by some bytes, followed a key
269 identity string, followed by more bytes. This happens when you use "embed"
270 keys instead of "hwcrhk" keys). Unfortunately, those functions do not take
271 any passphrase or caller context, and our functions can't really take any
272 callback data either. Still, the "insert_card" and "get_passphrase"
273 callbacks may be called down the line, and will need to know what user
274 interface callbacks to call, and having callback data from the application
275 may be a nice thing as well, so we need to keep track of that globally. */
276static HWCryptoHook_CallerContext password_context = { NULL, NULL, NULL };
277
278/* Stuff to pass to the HWCryptoHook library */
279static HWCryptoHook_InitInfo hwcrhk_globals = {
280 HWCryptoHook_InitFlags_SimpleForkCheck, /* Flags */
281 &logstream, /* logstream */
282 sizeof(BN_ULONG), /* limbsize */
283 0, /* mslimb first: false for BNs */
284 -1, /* msbyte first: use native */
285 0, /* Max mutexes, 0 = no small limit */
286 0, /* Max simultaneous, 0 = default */
287
288 /* The next few are mutex stuff: we write wrapper functions
289 around the OS mutex functions. We initialise them to 0
290 here, and change that to actual function pointers in hwcrhk_init()
291 if dynamic locks are supported (that is, if the application
292 programmer has made sure of setting up callbacks bafore starting
293 this engine) *and* if disable_mutex_callbacks hasn't been set by
294 a call to ENGINE_ctrl(ENGINE_CTRL_CHIL_NO_LOCKING). */
295 sizeof(HWCryptoHook_Mutex),
296 0,
297 0,
298 0,
299 0,
300
301 /* The next few are condvar stuff: we write wrapper functions
302 round the OS functions. Currently not implemented and not
303 and absolute necessity even in threaded programs, therefore
304 0'ed. Will hopefully be implemented some day, since it
305 enhances the efficiency of HWCryptoHook. */
306 0, /* sizeof(HWCryptoHook_CondVar), */
307 0, /* hwcrhk_cv_init, */
308 0, /* hwcrhk_cv_wait, */
309 0, /* hwcrhk_cv_signal, */
310 0, /* hwcrhk_cv_broadcast, */
311 0, /* hwcrhk_cv_destroy, */
312
313 hwcrhk_get_pass, /* pass phrase */
314 hwcrhk_insert_card, /* insert a card */
315 hwcrhk_log_message /* Log message */
316};
317
318
319/* Now, to our own code */
320
321/* This internal function is used by ENGINE_ncipher() and possibly by the
322 * "dynamic" ENGINE support too */
323static int bind_helper(ENGINE *e)
324 {
325#ifndef OPENSSL_NO_RSA
326 const RSA_METHOD *meth1;
327#endif
328#ifndef OPENSSL_NO_DH
329 const DH_METHOD *meth2;
330#endif
331 if(!ENGINE_set_id(e, engine_hwcrhk_id) ||
332 !ENGINE_set_name(e, engine_hwcrhk_name) ||
333#ifndef OPENSSL_NO_RSA
334 !ENGINE_set_RSA(e, &hwcrhk_rsa) ||
335#endif
336#ifndef OPENSSL_NO_DH
337 !ENGINE_set_DH(e, &hwcrhk_dh) ||
338#endif
339 !ENGINE_set_RAND(e, &hwcrhk_rand) ||
340 !ENGINE_set_destroy_function(e, hwcrhk_destroy) ||
341 !ENGINE_set_init_function(e, hwcrhk_init) ||
342 !ENGINE_set_finish_function(e, hwcrhk_finish) ||
343 !ENGINE_set_ctrl_function(e, hwcrhk_ctrl) ||
344 !ENGINE_set_load_privkey_function(e, hwcrhk_load_privkey) ||
345 !ENGINE_set_load_pubkey_function(e, hwcrhk_load_pubkey) ||
346 !ENGINE_set_cmd_defns(e, hwcrhk_cmd_defns))
347 return 0;
348
349#ifndef OPENSSL_NO_RSA
350 /* We know that the "PKCS1_SSLeay()" functions hook properly
351 * to the cswift-specific mod_exp and mod_exp_crt so we use
352 * those functions. NB: We don't use ENGINE_openssl() or
353 * anything "more generic" because something like the RSAref
354 * code may not hook properly, and if you own one of these
355 * cards then you have the right to do RSA operations on it
356 * anyway! */
357 meth1 = RSA_PKCS1_SSLeay();
358 hwcrhk_rsa.rsa_pub_enc = meth1->rsa_pub_enc;
359 hwcrhk_rsa.rsa_pub_dec = meth1->rsa_pub_dec;
360 hwcrhk_rsa.rsa_priv_enc = meth1->rsa_priv_enc;
361 hwcrhk_rsa.rsa_priv_dec = meth1->rsa_priv_dec;
362#endif
363
364#ifndef OPENSSL_NO_DH
365 /* Much the same for Diffie-Hellman */
366 meth2 = DH_OpenSSL();
367 hwcrhk_dh.generate_key = meth2->generate_key;
368 hwcrhk_dh.compute_key = meth2->compute_key;
369#endif
370
371 /* Ensure the hwcrhk error handling is set up */
372 ERR_load_HWCRHK_strings();
373 return 1;
374 }
375
376static ENGINE *engine_ncipher(void)
377 {
378 ENGINE *ret = ENGINE_new();
379 if(!ret)
380 return NULL;
381 if(!bind_helper(ret))
382 {
383 ENGINE_free(ret);
384 return NULL;
385 }
386 return ret;
387 }
388
389void ENGINE_load_chil(void)
390 {
391 /* Copied from eng_[openssl|dyn].c */
392 ENGINE *toadd = engine_ncipher();
393 if(!toadd) return;
394 ENGINE_add(toadd);
395 ENGINE_free(toadd);
396 ERR_clear_error();
397 }
398
399/* This is a process-global DSO handle used for loading and unloading
400 * the HWCryptoHook library. NB: This is only set (or unset) during an
401 * init() or finish() call (reference counts permitting) and they're
402 * operating with global locks, so this should be thread-safe
403 * implicitly. */
404static DSO *hwcrhk_dso = NULL;
405static HWCryptoHook_ContextHandle hwcrhk_context = 0;
406#ifndef OPENSSL_NO_RSA
407static int hndidx_rsa = -1; /* Index for KM handle. Not really used yet. */
408#endif
409
410/* These are the function pointers that are (un)set when the library has
411 * successfully (un)loaded. */
412static HWCryptoHook_Init_t *p_hwcrhk_Init = NULL;
413static HWCryptoHook_Finish_t *p_hwcrhk_Finish = NULL;
414static HWCryptoHook_ModExp_t *p_hwcrhk_ModExp = NULL;
415#ifndef OPENSSL_NO_RSA
416static HWCryptoHook_RSA_t *p_hwcrhk_RSA = NULL;
417#endif
418static HWCryptoHook_RandomBytes_t *p_hwcrhk_RandomBytes = NULL;
419#ifndef OPENSSL_NO_RSA
420static HWCryptoHook_RSALoadKey_t *p_hwcrhk_RSALoadKey = NULL;
421static HWCryptoHook_RSAGetPublicKey_t *p_hwcrhk_RSAGetPublicKey = NULL;
422static HWCryptoHook_RSAUnloadKey_t *p_hwcrhk_RSAUnloadKey = NULL;
423#endif
424static HWCryptoHook_ModExpCRT_t *p_hwcrhk_ModExpCRT = NULL;
425
426/* Used in the DSO operations. */
427static const char *HWCRHK_LIBNAME = NULL;
428static void free_HWCRHK_LIBNAME(void)
429 {
430 if(HWCRHK_LIBNAME)
431 OPENSSL_free((void*)HWCRHK_LIBNAME);
432 HWCRHK_LIBNAME = NULL;
433 }
434static const char *get_HWCRHK_LIBNAME(void)
435 {
436 if(HWCRHK_LIBNAME)
437 return HWCRHK_LIBNAME;
438 return "nfhwcrhk";
439 }
440static long set_HWCRHK_LIBNAME(const char *name)
441 {
442 free_HWCRHK_LIBNAME();
443 return (((HWCRHK_LIBNAME = BUF_strdup(name)) != NULL) ? 1 : 0);
444 }
445static const char *n_hwcrhk_Init = "HWCryptoHook_Init";
446static const char *n_hwcrhk_Finish = "HWCryptoHook_Finish";
447static const char *n_hwcrhk_ModExp = "HWCryptoHook_ModExp";
448#ifndef OPENSSL_NO_RSA
449static const char *n_hwcrhk_RSA = "HWCryptoHook_RSA";
450#endif
451static const char *n_hwcrhk_RandomBytes = "HWCryptoHook_RandomBytes";
452#ifndef OPENSSL_NO_RSA
453static const char *n_hwcrhk_RSALoadKey = "HWCryptoHook_RSALoadKey";
454static const char *n_hwcrhk_RSAGetPublicKey = "HWCryptoHook_RSAGetPublicKey";
455static const char *n_hwcrhk_RSAUnloadKey = "HWCryptoHook_RSAUnloadKey";
456#endif
457static const char *n_hwcrhk_ModExpCRT = "HWCryptoHook_ModExpCRT";
458
459/* HWCryptoHook library functions and mechanics - these are used by the
460 * higher-level functions further down. NB: As and where there's no
461 * error checking, take a look lower down where these functions are
462 * called, the checking and error handling is probably down there. */
463
464/* utility function to obtain a context */
465static int get_context(HWCryptoHook_ContextHandle *hac,
466 HWCryptoHook_CallerContext *cac)
467 {
468 char tempbuf[1024];
469 HWCryptoHook_ErrMsgBuf rmsg;
470
471 rmsg.buf = tempbuf;
472 rmsg.size = sizeof(tempbuf);
473
474 *hac = p_hwcrhk_Init(&hwcrhk_globals, sizeof(hwcrhk_globals), &rmsg,
475 cac);
476 if (!*hac)
477 return 0;
478 return 1;
479 }
480
481/* similarly to release one. */
482static void release_context(HWCryptoHook_ContextHandle hac)
483 {
484 p_hwcrhk_Finish(hac);
485 }
486
487/* Destructor (complements the "ENGINE_ncipher()" constructor) */
488static int hwcrhk_destroy(ENGINE *e)
489 {
490 free_HWCRHK_LIBNAME();
491 ERR_unload_HWCRHK_strings();
492 return 1;
493 }
494
495/* (de)initialisation functions. */
496static int hwcrhk_init(ENGINE *e)
497 {
498 HWCryptoHook_Init_t *p1;
499 HWCryptoHook_Finish_t *p2;
500 HWCryptoHook_ModExp_t *p3;
501#ifndef OPENSSL_NO_RSA
502 HWCryptoHook_RSA_t *p4;
503 HWCryptoHook_RSALoadKey_t *p5;
504 HWCryptoHook_RSAGetPublicKey_t *p6;
505 HWCryptoHook_RSAUnloadKey_t *p7;
506#endif
507 HWCryptoHook_RandomBytes_t *p8;
508 HWCryptoHook_ModExpCRT_t *p9;
509
510 if(hwcrhk_dso != NULL)
511 {
512 HWCRHKerr(HWCRHK_F_HWCRHK_INIT,HWCRHK_R_ALREADY_LOADED);
513 goto err;
514 }
515 /* Attempt to load libnfhwcrhk.so/nfhwcrhk.dll/whatever. */
516 hwcrhk_dso = DSO_load(NULL, get_HWCRHK_LIBNAME(), NULL, 0);
517 if(hwcrhk_dso == NULL)
518 {
519 HWCRHKerr(HWCRHK_F_HWCRHK_INIT,HWCRHK_R_DSO_FAILURE);
520 goto err;
521 }
522 if(!(p1 = (HWCryptoHook_Init_t *)
523 DSO_bind_func(hwcrhk_dso, n_hwcrhk_Init)) ||
524 !(p2 = (HWCryptoHook_Finish_t *)
525 DSO_bind_func(hwcrhk_dso, n_hwcrhk_Finish)) ||
526 !(p3 = (HWCryptoHook_ModExp_t *)
527 DSO_bind_func(hwcrhk_dso, n_hwcrhk_ModExp)) ||
528#ifndef OPENSSL_NO_RSA
529 !(p4 = (HWCryptoHook_RSA_t *)
530 DSO_bind_func(hwcrhk_dso, n_hwcrhk_RSA)) ||
531 !(p5 = (HWCryptoHook_RSALoadKey_t *)
532 DSO_bind_func(hwcrhk_dso, n_hwcrhk_RSALoadKey)) ||
533 !(p6 = (HWCryptoHook_RSAGetPublicKey_t *)
534 DSO_bind_func(hwcrhk_dso, n_hwcrhk_RSAGetPublicKey)) ||
535 !(p7 = (HWCryptoHook_RSAUnloadKey_t *)
536 DSO_bind_func(hwcrhk_dso, n_hwcrhk_RSAUnloadKey)) ||
537#endif
538 !(p8 = (HWCryptoHook_RandomBytes_t *)
539 DSO_bind_func(hwcrhk_dso, n_hwcrhk_RandomBytes)) ||
540 !(p9 = (HWCryptoHook_ModExpCRT_t *)
541 DSO_bind_func(hwcrhk_dso, n_hwcrhk_ModExpCRT)))
542 {
543 HWCRHKerr(HWCRHK_F_HWCRHK_INIT,HWCRHK_R_DSO_FAILURE);
544 goto err;
545 }
546 /* Copy the pointers */
547 p_hwcrhk_Init = p1;
548 p_hwcrhk_Finish = p2;
549 p_hwcrhk_ModExp = p3;
550#ifndef OPENSSL_NO_RSA
551 p_hwcrhk_RSA = p4;
552 p_hwcrhk_RSALoadKey = p5;
553 p_hwcrhk_RSAGetPublicKey = p6;
554 p_hwcrhk_RSAUnloadKey = p7;
555#endif
556 p_hwcrhk_RandomBytes = p8;
557 p_hwcrhk_ModExpCRT = p9;
558
559 /* Check if the application decided to support dynamic locks,
560 and if it does, use them. */
561 if (disable_mutex_callbacks == 0 &&
562 CRYPTO_get_dynlock_create_callback() != NULL &&
563 CRYPTO_get_dynlock_lock_callback() != NULL &&
564 CRYPTO_get_dynlock_destroy_callback() != NULL)
565 {
566 hwcrhk_globals.mutex_init = hwcrhk_mutex_init;
567 hwcrhk_globals.mutex_acquire = hwcrhk_mutex_lock;
568 hwcrhk_globals.mutex_release = hwcrhk_mutex_unlock;
569 hwcrhk_globals.mutex_destroy = hwcrhk_mutex_destroy;
570 }
571
572 /* Try and get a context - if not, we may have a DSO but no
573 * accelerator! */
574 if(!get_context(&hwcrhk_context, &password_context))
575 {
576 HWCRHKerr(HWCRHK_F_HWCRHK_INIT,HWCRHK_R_UNIT_FAILURE);
577 goto err;
578 }
579 /* Everything's fine. */
580#ifndef OPENSSL_NO_RSA
581 if (hndidx_rsa == -1)
582 hndidx_rsa = RSA_get_ex_new_index(0,
583 "nFast HWCryptoHook RSA key handle",
584 NULL, NULL, hwcrhk_ex_free);
585#endif
586 return 1;
587err:
588 if(hwcrhk_dso)
589 DSO_free(hwcrhk_dso);
590 hwcrhk_dso = NULL;
591 p_hwcrhk_Init = NULL;
592 p_hwcrhk_Finish = NULL;
593 p_hwcrhk_ModExp = NULL;
594#ifndef OPENSSL_NO_RSA
595 p_hwcrhk_RSA = NULL;
596 p_hwcrhk_RSALoadKey = NULL;
597 p_hwcrhk_RSAGetPublicKey = NULL;
598 p_hwcrhk_RSAUnloadKey = NULL;
599#endif
600 p_hwcrhk_ModExpCRT = NULL;
601 p_hwcrhk_RandomBytes = NULL;
602 return 0;
603 }
604
605static int hwcrhk_finish(ENGINE *e)
606 {
607 int to_return = 1;
608 free_HWCRHK_LIBNAME();
609 if(hwcrhk_dso == NULL)
610 {
611 HWCRHKerr(HWCRHK_F_HWCRHK_FINISH,HWCRHK_R_NOT_LOADED);
612 to_return = 0;
613 goto err;
614 }
615 release_context(hwcrhk_context);
616 if(!DSO_free(hwcrhk_dso))
617 {
618 HWCRHKerr(HWCRHK_F_HWCRHK_FINISH,HWCRHK_R_DSO_FAILURE);
619 to_return = 0;
620 goto err;
621 }
622 err:
623 if (logstream)
624 BIO_free(logstream);
625 hwcrhk_dso = NULL;
626 p_hwcrhk_Init = NULL;
627 p_hwcrhk_Finish = NULL;
628 p_hwcrhk_ModExp = NULL;
629#ifndef OPENSSL_NO_RSA
630 p_hwcrhk_RSA = NULL;
631 p_hwcrhk_RSALoadKey = NULL;
632 p_hwcrhk_RSAGetPublicKey = NULL;
633 p_hwcrhk_RSAUnloadKey = NULL;
634#endif
635 p_hwcrhk_ModExpCRT = NULL;
636 p_hwcrhk_RandomBytes = NULL;
637 return to_return;
638 }
639
640static int hwcrhk_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
641 {
642 int to_return = 1;
643
644 switch(cmd)
645 {
646 case HWCRHK_CMD_SO_PATH:
647 if(hwcrhk_dso)
648 {
649 HWCRHKerr(HWCRHK_F_HWCRHK_CTRL,HWCRHK_R_ALREADY_LOADED);
650 return 0;
651 }
652 if(p == NULL)
653 {
654 HWCRHKerr(HWCRHK_F_HWCRHK_CTRL,ERR_R_PASSED_NULL_PARAMETER);
655 return 0;
656 }
657 return set_HWCRHK_LIBNAME((const char *)p);
658 case ENGINE_CTRL_SET_LOGSTREAM:
659 {
660 BIO *bio = (BIO *)p;
661
662 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
663 if (logstream)
664 {
665 BIO_free(logstream);
666 logstream = NULL;
667 }
668 if (CRYPTO_add(&bio->references,1,CRYPTO_LOCK_BIO) > 1)
669 logstream = bio;
670 else
671 HWCRHKerr(HWCRHK_F_HWCRHK_CTRL,HWCRHK_R_BIO_WAS_FREED);
672 }
673 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
674 break;
675 case ENGINE_CTRL_SET_PASSWORD_CALLBACK:
676 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
677 password_context.password_callback = (pem_password_cb *)f;
678 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
679 break;
680 case ENGINE_CTRL_SET_USER_INTERFACE:
681 case HWCRHK_CMD_SET_USER_INTERFACE:
682 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
683 password_context.ui_method = (UI_METHOD *)p;
684 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
685 break;
686 case ENGINE_CTRL_SET_CALLBACK_DATA:
687 case HWCRHK_CMD_SET_CALLBACK_DATA:
688 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
689 password_context.callback_data = p;
690 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
691 break;
692 /* this enables or disables the "SimpleForkCheck" flag used in the
693 * initialisation structure. */
694 case ENGINE_CTRL_CHIL_SET_FORKCHECK:
695 case HWCRHK_CMD_FORK_CHECK:
696 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
697 if(i)
698 hwcrhk_globals.flags |=
699 HWCryptoHook_InitFlags_SimpleForkCheck;
700 else
701 hwcrhk_globals.flags &=
702 ~HWCryptoHook_InitFlags_SimpleForkCheck;
703 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
704 break;
705 /* This will prevent the initialisation function from "installing"
706 * the mutex-handling callbacks, even if they are available from
707 * within the library (or were provided to the library from the
708 * calling application). This is to remove any baggage for
709 * applications not using multithreading. */
710 case ENGINE_CTRL_CHIL_NO_LOCKING:
711 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
712 disable_mutex_callbacks = 1;
713 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
714 break;
715 case HWCRHK_CMD_THREAD_LOCKING:
716 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
717 disable_mutex_callbacks = ((i == 0) ? 0 : 1);
718 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
719 break;
720
721 /* The command isn't understood by this engine */
722 default:
723 HWCRHKerr(HWCRHK_F_HWCRHK_CTRL,
724 HWCRHK_R_CTRL_COMMAND_NOT_IMPLEMENTED);
725 to_return = 0;
726 break;
727 }
728
729 return to_return;
730 }
731
732static EVP_PKEY *hwcrhk_load_privkey(ENGINE *eng, const char *key_id,
733 UI_METHOD *ui_method, void *callback_data)
734 {
735#ifndef OPENSSL_NO_RSA
736 RSA *rtmp = NULL;
737#endif
738 EVP_PKEY *res = NULL;
739#ifndef OPENSSL_NO_RSA
740 HWCryptoHook_MPI e, n;
741 HWCryptoHook_RSAKeyHandle *hptr;
742#endif
743#if !defined(OPENSSL_NO_RSA)
744 char tempbuf[1024];
745 HWCryptoHook_ErrMsgBuf rmsg;
746#endif
747 HWCryptoHook_PassphraseContext ppctx;
748
749#if !defined(OPENSSL_NO_RSA)
750 rmsg.buf = tempbuf;
751 rmsg.size = sizeof(tempbuf);
752#endif
753
754 if(!hwcrhk_context)
755 {
756 HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PRIVKEY,
757 HWCRHK_R_NOT_INITIALISED);
758 goto err;
759 }
760#ifndef OPENSSL_NO_RSA
761 hptr = OPENSSL_malloc(sizeof(HWCryptoHook_RSAKeyHandle));
762 if (!hptr)
763 {
764 HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PRIVKEY,
765 ERR_R_MALLOC_FAILURE);
766 goto err;
767 }
768 ppctx.ui_method = ui_method;
769 ppctx.callback_data = callback_data;
770 if (p_hwcrhk_RSALoadKey(hwcrhk_context, key_id, hptr,
771 &rmsg, &ppctx))
772 {
773 HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PRIVKEY,
774 HWCRHK_R_CHIL_ERROR);
775 ERR_add_error_data(1,rmsg.buf);
776 goto err;
777 }
778 if (!*hptr)
779 {
780 HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PRIVKEY,
781 HWCRHK_R_NO_KEY);
782 goto err;
783 }
784#endif
785#ifndef OPENSSL_NO_RSA
786 rtmp = RSA_new_method(eng);
787 RSA_set_ex_data(rtmp, hndidx_rsa, (char *)hptr);
788 rtmp->e = BN_new();
789 rtmp->n = BN_new();
790 rtmp->flags |= RSA_FLAG_EXT_PKEY;
791 MPI2BN(rtmp->e, e);
792 MPI2BN(rtmp->n, n);
793 if (p_hwcrhk_RSAGetPublicKey(*hptr, &n, &e, &rmsg)
794 != HWCRYPTOHOOK_ERROR_MPISIZE)
795 {
796 HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PUBKEY,HWCRHK_R_CHIL_ERROR);
797 ERR_add_error_data(1,rmsg.buf);
798 goto err;
799 }
800
801 bn_expand2(rtmp->e, e.size/sizeof(BN_ULONG));
802 bn_expand2(rtmp->n, n.size/sizeof(BN_ULONG));
803 MPI2BN(rtmp->e, e);
804 MPI2BN(rtmp->n, n);
805
806 if (p_hwcrhk_RSAGetPublicKey(*hptr, &n, &e, &rmsg))
807 {
808 HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PUBKEY,
809 HWCRHK_R_CHIL_ERROR);
810 ERR_add_error_data(1,rmsg.buf);
811 goto err;
812 }
813 rtmp->e->top = e.size / sizeof(BN_ULONG);
814 bn_fix_top(rtmp->e);
815 rtmp->n->top = n.size / sizeof(BN_ULONG);
816 bn_fix_top(rtmp->n);
817
818 res = EVP_PKEY_new();
819 EVP_PKEY_assign_RSA(res, rtmp);
820#endif
821
822 if (!res)
823 HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PUBKEY,
824 HWCRHK_R_PRIVATE_KEY_ALGORITHMS_DISABLED);
825
826 return res;
827 err:
828 if (res)
829 EVP_PKEY_free(res);
830#ifndef OPENSSL_NO_RSA
831 if (rtmp)
832 RSA_free(rtmp);
833#endif
834 return NULL;
835 }
836
837static EVP_PKEY *hwcrhk_load_pubkey(ENGINE *eng, const char *key_id,
838 UI_METHOD *ui_method, void *callback_data)
839 {
840 EVP_PKEY *res = NULL;
841
842#ifndef OPENSSL_NO_RSA
843 res = hwcrhk_load_privkey(eng, key_id,
844 ui_method, callback_data);
845#endif
846
847 if (res)
848 switch(res->type)
849 {
850#ifndef OPENSSL_NO_RSA
851 case EVP_PKEY_RSA:
852 {
853 RSA *rsa = NULL;
854
855 CRYPTO_w_lock(CRYPTO_LOCK_EVP_PKEY);
856 rsa = res->pkey.rsa;
857 res->pkey.rsa = RSA_new();
858 res->pkey.rsa->n = rsa->n;
859 res->pkey.rsa->e = rsa->e;
860 rsa->n = NULL;
861 rsa->e = NULL;
862 CRYPTO_w_unlock(CRYPTO_LOCK_EVP_PKEY);
863 RSA_free(rsa);
864 }
865 break;
866#endif
867 default:
868 HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PUBKEY,
869 HWCRHK_R_CTRL_COMMAND_NOT_IMPLEMENTED);
870 goto err;
871 }
872
873 return res;
874 err:
875 if (res)
876 EVP_PKEY_free(res);
877 return NULL;
878 }
879
880/* A little mod_exp */
881static int hwcrhk_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
882 const BIGNUM *m, BN_CTX *ctx)
883 {
884 char tempbuf[1024];
885 HWCryptoHook_ErrMsgBuf rmsg;
886 /* Since HWCryptoHook_MPI is pretty compatible with BIGNUM's,
887 we use them directly, plus a little macro magic. We only
888 thing we need to make sure of is that enough space is allocated. */
889 HWCryptoHook_MPI m_a, m_p, m_n, m_r;
890 int to_return, ret;
891
892 to_return = 0; /* expect failure */
893 rmsg.buf = tempbuf;
894 rmsg.size = sizeof(tempbuf);
895
896 if(!hwcrhk_context)
897 {
898 HWCRHKerr(HWCRHK_F_HWCRHK_MOD_EXP,HWCRHK_R_NOT_INITIALISED);
899 goto err;
900 }
901 /* Prepare the params */
902 bn_expand2(r, m->top); /* Check for error !! */
903 BN2MPI(m_a, a);
904 BN2MPI(m_p, p);
905 BN2MPI(m_n, m);
906 MPI2BN(r, m_r);
907
908 /* Perform the operation */
909 ret = p_hwcrhk_ModExp(hwcrhk_context, m_a, m_p, m_n, &m_r, &rmsg);
910
911 /* Convert the response */
912 r->top = m_r.size / sizeof(BN_ULONG);
913 bn_fix_top(r);
914
915 if (ret < 0)
916 {
917 /* FIXME: When this error is returned, HWCryptoHook is
918 telling us that falling back to software computation
919 might be a good thing. */
920 if(ret == HWCRYPTOHOOK_ERROR_FALLBACK)
921 {
922 HWCRHKerr(HWCRHK_F_HWCRHK_MOD_EXP,HWCRHK_R_REQUEST_FALLBACK);
923 }
924 else
925 {
926 HWCRHKerr(HWCRHK_F_HWCRHK_MOD_EXP,HWCRHK_R_REQUEST_FAILED);
927 }
928 ERR_add_error_data(1,rmsg.buf);
929 goto err;
930 }
931
932 to_return = 1;
933err:
934 return to_return;
935 }
936
937#ifndef OPENSSL_NO_RSA
938static int hwcrhk_rsa_mod_exp(BIGNUM *r, const BIGNUM *I, RSA *rsa)
939 {
940 char tempbuf[1024];
941 HWCryptoHook_ErrMsgBuf rmsg;
942 HWCryptoHook_RSAKeyHandle *hptr;
943 int to_return = 0, ret;
944
945 rmsg.buf = tempbuf;
946 rmsg.size = sizeof(tempbuf);
947
948 if(!hwcrhk_context)
949 {
950 HWCRHKerr(HWCRHK_F_HWCRHK_MOD_EXP,HWCRHK_R_NOT_INITIALISED);
951 goto err;
952 }
953
954 /* This provides support for nForce keys. Since that's opaque data
955 all we do is provide a handle to the proper key and let HWCryptoHook
956 take care of the rest. */
957 if ((hptr = (HWCryptoHook_RSAKeyHandle *) RSA_get_ex_data(rsa, hndidx_rsa))
958 != NULL)
959 {
960 HWCryptoHook_MPI m_a, m_r;
961
962 if(!rsa->n)
963 {
964 HWCRHKerr(HWCRHK_F_HWCRHK_RSA_MOD_EXP,
965 HWCRHK_R_MISSING_KEY_COMPONENTS);
966 goto err;
967 }
968
969 /* Prepare the params */
970 bn_expand2(r, rsa->n->top); /* Check for error !! */
971 BN2MPI(m_a, I);
972 MPI2BN(r, m_r);
973
974 /* Perform the operation */
975 ret = p_hwcrhk_RSA(m_a, *hptr, &m_r, &rmsg);
976
977 /* Convert the response */
978 r->top = m_r.size / sizeof(BN_ULONG);
979 bn_fix_top(r);
980
981 if (ret < 0)
982 {
983 /* FIXME: When this error is returned, HWCryptoHook is
984 telling us that falling back to software computation
985 might be a good thing. */
986 if(ret == HWCRYPTOHOOK_ERROR_FALLBACK)
987 {
988 HWCRHKerr(HWCRHK_F_HWCRHK_RSA_MOD_EXP,
989 HWCRHK_R_REQUEST_FALLBACK);
990 }
991 else
992 {
993 HWCRHKerr(HWCRHK_F_HWCRHK_RSA_MOD_EXP,
994 HWCRHK_R_REQUEST_FAILED);
995 }
996 ERR_add_error_data(1,rmsg.buf);
997 goto err;
998 }
999 }
1000 else
1001 {
1002 HWCryptoHook_MPI m_a, m_p, m_q, m_dmp1, m_dmq1, m_iqmp, m_r;
1003
1004 if(!rsa->p || !rsa->q || !rsa->dmp1 || !rsa->dmq1 || !rsa->iqmp)
1005 {
1006 HWCRHKerr(HWCRHK_F_HWCRHK_RSA_MOD_EXP,
1007 HWCRHK_R_MISSING_KEY_COMPONENTS);
1008 goto err;
1009 }
1010
1011 /* Prepare the params */
1012 bn_expand2(r, rsa->n->top); /* Check for error !! */
1013 BN2MPI(m_a, I);
1014 BN2MPI(m_p, rsa->p);
1015 BN2MPI(m_q, rsa->q);
1016 BN2MPI(m_dmp1, rsa->dmp1);
1017 BN2MPI(m_dmq1, rsa->dmq1);
1018 BN2MPI(m_iqmp, rsa->iqmp);
1019 MPI2BN(r, m_r);
1020
1021 /* Perform the operation */
1022 ret = p_hwcrhk_ModExpCRT(hwcrhk_context, m_a, m_p, m_q,
1023 m_dmp1, m_dmq1, m_iqmp, &m_r, NULL);
1024
1025 /* Convert the response */
1026 r->top = m_r.size / sizeof(BN_ULONG);
1027 bn_fix_top(r);
1028
1029 if (ret < 0)
1030 {
1031 /* FIXME: When this error is returned, HWCryptoHook is
1032 telling us that falling back to software computation
1033 might be a good thing. */
1034 if(ret == HWCRYPTOHOOK_ERROR_FALLBACK)
1035 {
1036 HWCRHKerr(HWCRHK_F_HWCRHK_RSA_MOD_EXP,
1037 HWCRHK_R_REQUEST_FALLBACK);
1038 }
1039 else
1040 {
1041 HWCRHKerr(HWCRHK_F_HWCRHK_RSA_MOD_EXP,
1042 HWCRHK_R_REQUEST_FAILED);
1043 }
1044 ERR_add_error_data(1,rmsg.buf);
1045 goto err;
1046 }
1047 }
1048 /* If we're here, we must be here with some semblance of success :-) */
1049 to_return = 1;
1050err:
1051 return to_return;
1052 }
1053#endif
1054
1055/* This function is aliased to mod_exp (with the mont stuff dropped). */
1056static int hwcrhk_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
1057 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
1058 {
1059 return hwcrhk_mod_exp(r, a, p, m, ctx);
1060 }
1061
1062#ifndef OPENSSL_NO_DH
1063/* This function is aliased to mod_exp (with the dh and mont dropped). */
1064static int hwcrhk_mod_exp_dh(const DH *dh, BIGNUM *r,
1065 const BIGNUM *a, const BIGNUM *p,
1066 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
1067 {
1068 return hwcrhk_mod_exp(r, a, p, m, ctx);
1069 }
1070#endif
1071
1072/* Random bytes are good */
1073static int hwcrhk_rand_bytes(unsigned char *buf, int num)
1074 {
1075 char tempbuf[1024];
1076 HWCryptoHook_ErrMsgBuf rmsg;
1077 int to_return = 0; /* assume failure */
1078 int ret;
1079
1080 rmsg.buf = tempbuf;
1081 rmsg.size = sizeof(tempbuf);
1082
1083 if(!hwcrhk_context)
1084 {
1085 HWCRHKerr(HWCRHK_F_HWCRHK_RAND_BYTES,HWCRHK_R_NOT_INITIALISED);
1086 goto err;
1087 }
1088
1089 ret = p_hwcrhk_RandomBytes(hwcrhk_context, buf, num, &rmsg);
1090 if (ret < 0)
1091 {
1092 /* FIXME: When this error is returned, HWCryptoHook is
1093 telling us that falling back to software computation
1094 might be a good thing. */
1095 if(ret == HWCRYPTOHOOK_ERROR_FALLBACK)
1096 {
1097 HWCRHKerr(HWCRHK_F_HWCRHK_RAND_BYTES,
1098 HWCRHK_R_REQUEST_FALLBACK);
1099 }
1100 else
1101 {
1102 HWCRHKerr(HWCRHK_F_HWCRHK_RAND_BYTES,
1103 HWCRHK_R_REQUEST_FAILED);
1104 }
1105 ERR_add_error_data(1,rmsg.buf);
1106 goto err;
1107 }
1108 to_return = 1;
1109 err:
1110 return to_return;
1111 }
1112
1113static int hwcrhk_rand_status(void)
1114 {
1115 return 1;
1116 }
1117
1118/* This cleans up an RSA KM key, called when ex_data is freed */
1119
1120static void hwcrhk_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad,
1121 int ind,long argl, void *argp)
1122{
1123 char tempbuf[1024];
1124 HWCryptoHook_ErrMsgBuf rmsg;
1125#ifndef OPENSSL_NO_RSA
1126 HWCryptoHook_RSAKeyHandle *hptr;
1127#endif
1128#if !defined(OPENSSL_NO_RSA)
1129 int ret;
1130#endif
1131
1132 rmsg.buf = tempbuf;
1133 rmsg.size = sizeof(tempbuf);
1134
1135#ifndef OPENSSL_NO_RSA
1136 hptr = (HWCryptoHook_RSAKeyHandle *) item;
1137 if(hptr)
1138 {
1139 ret = p_hwcrhk_RSAUnloadKey(*hptr, NULL);
1140 OPENSSL_free(hptr);
1141 }
1142#endif
1143}
1144
1145/* Mutex calls: since the HWCryptoHook model closely follows the POSIX model
1146 * these just wrap the POSIX functions and add some logging.
1147 */
1148
1149static int hwcrhk_mutex_init(HWCryptoHook_Mutex* mt,
1150 HWCryptoHook_CallerContext *cactx)
1151 {
1152 mt->lockid = CRYPTO_get_new_dynlockid();
1153 if (mt->lockid == 0)
1154 return 1; /* failure */
1155 return 0; /* success */
1156 }
1157
1158static int hwcrhk_mutex_lock(HWCryptoHook_Mutex *mt)
1159 {
1160 CRYPTO_w_lock(mt->lockid);
1161 return 0;
1162 }
1163
1164static void hwcrhk_mutex_unlock(HWCryptoHook_Mutex * mt)
1165 {
1166 CRYPTO_w_unlock(mt->lockid);
1167 }
1168
1169static void hwcrhk_mutex_destroy(HWCryptoHook_Mutex *mt)
1170 {
1171 CRYPTO_destroy_dynlockid(mt->lockid);
1172 }
1173
1174static int hwcrhk_get_pass(const char *prompt_info,
1175 int *len_io, char *buf,
1176 HWCryptoHook_PassphraseContext *ppctx,
1177 HWCryptoHook_CallerContext *cactx)
1178 {
1179 pem_password_cb *callback = NULL;
1180 void *callback_data = NULL;
1181 UI_METHOD *ui_method = NULL;
1182
1183 if (cactx)
1184 {
1185 if (cactx->ui_method)
1186 ui_method = cactx->ui_method;
1187 if (cactx->password_callback)
1188 callback = cactx->password_callback;
1189 if (cactx->callback_data)
1190 callback_data = cactx->callback_data;
1191 }
1192 if (ppctx)
1193 {
1194 if (ppctx->ui_method)
1195 {
1196 ui_method = ppctx->ui_method;
1197 callback = NULL;
1198 }
1199 if (ppctx->callback_data)
1200 callback_data = ppctx->callback_data;
1201 }
1202 if (callback == NULL && ui_method == NULL)
1203 {
1204 HWCRHKerr(HWCRHK_F_HWCRHK_GET_PASS,HWCRHK_R_NO_CALLBACK);
1205 return -1;
1206 }
1207
1208 if (ui_method)
1209 {
1210 UI *ui = UI_new_method(ui_method);
1211 if (ui)
1212 {
1213 int ok;
1214 char *prompt = UI_construct_prompt(ui,
1215 "pass phrase", prompt_info);
1216
1217 ok = UI_add_input_string(ui,prompt,
1218 UI_INPUT_FLAG_DEFAULT_PWD,
1219 buf,0,(*len_io) - 1);
1220 UI_add_user_data(ui, callback_data);
1221 UI_ctrl(ui, UI_CTRL_PRINT_ERRORS, 1, 0, 0);
1222
1223 if (ok >= 0)
1224 do
1225 {
1226 ok=UI_process(ui);
1227 }
1228 while (ok < 0 && UI_ctrl(ui, UI_CTRL_IS_REDOABLE, 0, 0, 0));
1229
1230 if (ok >= 0)
1231 *len_io = strlen(buf);
1232
1233 UI_free(ui);
1234 OPENSSL_free(prompt);
1235 }
1236 }
1237 else
1238 {
1239 *len_io = callback(buf, *len_io, 0, callback_data);
1240 }
1241 if(!*len_io)
1242 return -1;
1243 return 0;
1244 }
1245
1246static int hwcrhk_insert_card(const char *prompt_info,
1247 const char *wrong_info,
1248 HWCryptoHook_PassphraseContext *ppctx,
1249 HWCryptoHook_CallerContext *cactx)
1250 {
1251 int ok = -1;
1252 UI *ui;
1253 void *callback_data = NULL;
1254 UI_METHOD *ui_method = NULL;
1255
1256 if (cactx)
1257 {
1258 if (cactx->ui_method)
1259 ui_method = cactx->ui_method;
1260 if (cactx->callback_data)
1261 callback_data = cactx->callback_data;
1262 }
1263 if (ppctx)
1264 {
1265 if (ppctx->ui_method)
1266 ui_method = ppctx->ui_method;
1267 if (ppctx->callback_data)
1268 callback_data = ppctx->callback_data;
1269 }
1270 if (ui_method == NULL)
1271 {
1272 HWCRHKerr(HWCRHK_F_HWCRHK_INSERT_CARD,
1273 HWCRHK_R_NO_CALLBACK);
1274 return -1;
1275 }
1276
1277 ui = UI_new_method(ui_method);
1278
1279 if (ui)
1280 {
1281 char answer;
1282 char buf[BUFSIZ];
1283
1284 if (wrong_info)
1285 BIO_snprintf(buf, sizeof(buf)-1,
1286 "Current card: \"%s\"\n", wrong_info);
1287 ok = UI_dup_info_string(ui, buf);
1288 if (ok >= 0 && prompt_info)
1289 {
1290 BIO_snprintf(buf, sizeof(buf)-1,
1291 "Insert card \"%s\"", prompt_info);
1292 ok = UI_dup_input_boolean(ui, buf,
1293 "\n then hit <enter> or C<enter> to cancel\n",
1294 "\r\n", "Cc", UI_INPUT_FLAG_ECHO, &answer);
1295 }
1296 UI_add_user_data(ui, callback_data);
1297
1298 if (ok >= 0)
1299 ok = UI_process(ui);
1300 UI_free(ui);
1301
1302 if (ok == -2 || (ok >= 0 && answer == 'C'))
1303 ok = 1;
1304 else if (ok < 0)
1305 ok = -1;
1306 else
1307 ok = 0;
1308 }
1309 return ok;
1310 }
1311
1312static void hwcrhk_log_message(void *logstr, const char *message)
1313 {
1314 BIO *lstream = NULL;
1315
1316 CRYPTO_w_lock(CRYPTO_LOCK_BIO);
1317 if (logstr)
1318 lstream=*(BIO **)logstr;
1319 if (lstream)
1320 {
1321 BIO_write(lstream, message, strlen(message));
1322 }
1323 CRYPTO_w_unlock(CRYPTO_LOCK_BIO);
1324 }
1325
1326/* This stuff is needed if this ENGINE is being compiled into a self-contained
1327 * shared-library. */
1328#ifdef ENGINE_DYNAMIC_SUPPORT
1329static int bind_fn(ENGINE *e, const char *id)
1330 {
1331 if(id && (strcmp(id, engine_hwcrhk_id) != 0))
1332 return 0;
1333 if(!bind_helper(e))
1334 return 0;
1335 return 1;
1336 }
1337IMPLEMENT_DYNAMIC_CHECK_FN()
1338IMPLEMENT_DYNAMIC_BIND_FN(bind_fn)
1339#endif /* ENGINE_DYNAMIC_SUPPORT */
1340
1341#endif /* !OPENSSL_NO_HW_NCIPHER */
1342#endif /* !OPENSSL_NO_HW */
diff --git a/src/lib/libcrypto/engine/hw_ncipher_err.c b/src/lib/libcrypto/engine/hw_ncipher_err.c
new file mode 100644
index 0000000000..24024cfc6f
--- /dev/null
+++ b/src/lib/libcrypto/engine/hw_ncipher_err.c
@@ -0,0 +1,156 @@
1/* hw_ncipher_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_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_MISSING_KEY_COMPONENTS ,"missing key components"},
90{HWCRHK_R_NOT_INITIALISED ,"not initialised"},
91{HWCRHK_R_NOT_LOADED ,"not loaded"},
92{HWCRHK_R_NO_CALLBACK ,"no callback"},
93{HWCRHK_R_NO_KEY ,"no key"},
94{HWCRHK_R_PRIVATE_KEY_ALGORITHMS_DISABLED,"private key algorithms disabled"},
95{HWCRHK_R_REQUEST_FAILED ,"request failed"},
96{HWCRHK_R_REQUEST_FALLBACK ,"request fallback"},
97{HWCRHK_R_UNIT_FAILURE ,"unit failure"},
98{0,NULL}
99 };
100
101#endif
102
103#ifdef HWCRHK_LIB_NAME
104static ERR_STRING_DATA HWCRHK_lib_name[]=
105 {
106{0 ,HWCRHK_LIB_NAME},
107{0,NULL}
108 };
109#endif
110
111
112static int HWCRHK_lib_error_code=0;
113static int HWCRHK_error_init=1;
114
115static void ERR_load_HWCRHK_strings(void)
116 {
117 if (HWCRHK_lib_error_code == 0)
118 HWCRHK_lib_error_code=ERR_get_next_error_library();
119
120 if (HWCRHK_error_init)
121 {
122 HWCRHK_error_init=0;
123#ifndef OPENSSL_NO_ERR
124 ERR_load_strings(HWCRHK_lib_error_code,HWCRHK_str_functs);
125 ERR_load_strings(HWCRHK_lib_error_code,HWCRHK_str_reasons);
126#endif
127
128#ifdef HWCRHK_LIB_NAME
129 HWCRHK_lib_name->error = ERR_PACK(HWCRHK_lib_error_code,0,0);
130 ERR_load_strings(0,HWCRHK_lib_name);
131#endif
132 }
133 }
134
135static void ERR_unload_HWCRHK_strings(void)
136 {
137 if (HWCRHK_error_init == 0)
138 {
139#ifndef OPENSSL_NO_ERR
140 ERR_unload_strings(HWCRHK_lib_error_code,HWCRHK_str_functs);
141 ERR_unload_strings(HWCRHK_lib_error_code,HWCRHK_str_reasons);
142#endif
143
144#ifdef HWCRHK_LIB_NAME
145 ERR_unload_strings(0,HWCRHK_lib_name);
146#endif
147 HWCRHK_error_init=1;
148 }
149 }
150
151static void ERR_HWCRHK_error(int function, int reason, char *file, int line)
152 {
153 if (HWCRHK_lib_error_code == 0)
154 HWCRHK_lib_error_code=ERR_get_next_error_library();
155 ERR_PUT_error(HWCRHK_lib_error_code,function,reason,file,line);
156 }
diff --git a/src/lib/libcrypto/engine/hw_ncipher_err.h b/src/lib/libcrypto/engine/hw_ncipher_err.h
new file mode 100644
index 0000000000..4d65b1d470
--- /dev/null
+++ b/src/lib/libcrypto/engine/hw_ncipher_err.h
@@ -0,0 +1,100 @@
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_MISSING_KEY_COMPONENTS 105
88#define HWCRHK_R_NOT_INITIALISED 106
89#define HWCRHK_R_NOT_LOADED 107
90#define HWCRHK_R_NO_CALLBACK 108
91#define HWCRHK_R_NO_KEY 109
92#define HWCRHK_R_PRIVATE_KEY_ALGORITHMS_DISABLED 110
93#define HWCRHK_R_REQUEST_FAILED 111
94#define HWCRHK_R_REQUEST_FALLBACK 112
95#define HWCRHK_R_UNIT_FAILURE 113
96
97#ifdef __cplusplus
98}
99#endif
100#endif
diff --git a/src/lib/libcrypto/engine/hw_nuron.c b/src/lib/libcrypto/engine/hw_nuron.c
new file mode 100644
index 0000000000..130b6d8b40
--- /dev/null
+++ b/src/lib/libcrypto/engine/hw_nuron.c
@@ -0,0 +1,416 @@
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
377static ENGINE *engine_nuron(void)
378 {
379 ENGINE *ret = ENGINE_new();
380 if(!ret)
381 return NULL;
382 if(!bind_helper(ret))
383 {
384 ENGINE_free(ret);
385 return NULL;
386 }
387 return ret;
388 }
389
390void ENGINE_load_nuron(void)
391 {
392 /* Copied from eng_[openssl|dyn].c */
393 ENGINE *toadd = engine_nuron();
394 if(!toadd) return;
395 ENGINE_add(toadd);
396 ENGINE_free(toadd);
397 ERR_clear_error();
398 }
399
400/* This stuff is needed if this ENGINE is being compiled into a self-contained
401 * shared-library. */
402#ifdef ENGINE_DYNAMIC_SUPPORT
403static int bind_fn(ENGINE *e, const char *id)
404 {
405 if(id && (strcmp(id, engine_nuron_id) != 0))
406 return 0;
407 if(!bind_helper(e))
408 return 0;
409 return 1;
410 }
411IMPLEMENT_DYNAMIC_CHECK_FN()
412IMPLEMENT_DYNAMIC_BIND_FN(bind_fn)
413#endif /* ENGINE_DYNAMIC_SUPPORT */
414
415#endif /* !OPENSSL_NO_HW_NURON */
416#endif /* !OPENSSL_NO_HW */
diff --git a/src/lib/libcrypto/engine/hw_nuron_err.c b/src/lib/libcrypto/engine/hw_nuron_err.c
new file mode 100644
index 0000000000..df9d7bde76
--- /dev/null
+++ b/src/lib/libcrypto/engine/hw_nuron_err.c
@@ -0,0 +1,142 @@
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
new file mode 100644
index 0000000000..a56bfdf303
--- /dev/null
+++ b/src/lib/libcrypto/engine/hw_nuron_err.h
@@ -0,0 +1,86 @@
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_openbsd_dev_crypto.c b/src/lib/libcrypto/engine/hw_openbsd_dev_crypto.c
new file mode 100644
index 0000000000..b8aab545db
--- /dev/null
+++ b/src/lib/libcrypto/engine/hw_openbsd_dev_crypto.c
@@ -0,0 +1,594 @@
1/* Written by Ben Laurie <ben@algroup.co.uk> August 2001 */
2/* ====================================================================
3 * Copyright (c) 1999-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 * 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 <openssl/engine.h>
57#include <openssl/evp.h>
58#include "eng_int.h"
59/* Maybe this is needed? ... */
60#ifdef FLAT_INC
61#include "evp_locl.h"
62#else
63#include "../evp/evp_locl.h"
64#endif
65#include <openssl/conf.h>
66
67#ifndef OPENSSL_OPENBSD_DEV_CRYPTO
68
69void ENGINE_load_openbsd_dev_crypto(void)
70 {
71 /* This is a NOP unless OPENSSL_OPENBSD_DEV_CRYPTO is defined */
72 return;
73 }
74
75#else /* OPENSSL_OPENBSD_DEV_CRYPTO */
76
77#include <fcntl.h>
78#include <stdio.h>
79#include <errno.h>
80#include <assert.h>
81#include <unistd.h>
82#include <sys/ioctl.h>
83
84#include <crypto/cryptodev.h>
85
86/****************************************************/
87/* Declare the normal generic ENGINE stuff here ... */
88
89static int dev_crypto_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
90 const int **nids, int nid);
91static int dev_crypto_digests(ENGINE *e, const EVP_MD **digest,
92 const int **nids, int nid);
93
94static const char dev_crypto_id[] = "openbsd_dev_crypto";
95static const char dev_crypto_name[] = "OpenBSD /dev/crypto";
96
97static long allow_misaligned;
98
99#define DEV_CRYPTO_CMD_ALLOW_MISALIGNED ENGINE_CMD_BASE
100static const ENGINE_CMD_DEFN dev_crypto_cmd_defns[]=
101 {
102 { DEV_CRYPTO_CMD_ALLOW_MISALIGNED,
103 "allow_misaligned",
104 "Permit misaligned data to be used",
105 ENGINE_CMD_FLAG_NUMERIC },
106 { 0, NULL, NULL, 0 }
107 };
108
109static int dev_crypto_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
110 {
111 switch(cmd)
112 {
113 case DEV_CRYPTO_CMD_ALLOW_MISALIGNED:
114 allow_misaligned=i;
115 printf("allow misaligned=%ld\n",allow_misaligned);
116 break;
117 }
118
119 return 1;
120 }
121
122static ENGINE *engine_openbsd_dev_crypto(void)
123 {
124 ENGINE *engine=ENGINE_new();
125
126 if(!ENGINE_set_id(engine, dev_crypto_id) ||
127 !ENGINE_set_name(engine, dev_crypto_name) ||
128 !ENGINE_set_ciphers(engine, dev_crypto_ciphers) ||
129 !ENGINE_set_digests(engine, dev_crypto_digests) ||
130 !ENGINE_set_ctrl_function(engine, dev_crypto_ctrl) ||
131 !ENGINE_set_cmd_defns(engine, dev_crypto_cmd_defns))
132 {
133 ENGINE_free(engine);
134 return NULL;
135 }
136
137 return engine;
138 }
139
140void ENGINE_load_openbsd_dev_crypto(void)
141 {
142 /* Copied from eng_[openssl|dyn].c */
143 ENGINE *toadd = engine_openbsd_dev_crypto();
144 if(!toadd) return;
145 ENGINE_add(toadd);
146 ENGINE_free(toadd);
147 ERR_clear_error();
148 }
149
150/******************************************************************************/
151/* Clip in the stuff from crypto/evp/openbsd_hw.c here. NB: What has changed? */
152/* I've removed the exposed EVP_*** functions, they're accessed through the */
153/* "dev_crypto_[ciphers|digests]" handlers. I've also moved the EVP_CIPHER */
154/* and EVP_MD structures to the bottom where they are close to the handlers */
155/* that expose them. What should be done? The global data (file-descriptors, */
156/* etc) should be put into ENGINE's ex_data support, and per-context data */
157/* (also file-descriptors perhaps) should be put into the contexts. Also code */
158/* formatting, fprintf statements, and OpenSSL-style error handling should be */
159/* added (dynamically, like the other ENGINEs). Also, "dynamic" support */
160/* be added to this ENGINE once it's up and running so that it could be built */
161/* as a shared-library. What else? device initialisation should take place */
162/* inside an ENGINE 'init()' handler (and likewise 'finish()'). ciphers and */
163/* digests won't be used by the framework unless the ENGINE has been */
164/* successfully initialised (that's one of the things you get for free) so */
165/* initialisation, including returning failure if device setup fails, can be */
166/* handled quite cleanly. This could presumably handle the opening (and then */
167/* closing inside 'finish()') of the 'cryptodev_fd' file-descriptor). */
168
169/* longest key supported in hardware */
170#define MAX_HW_KEY 24
171#define MAX_HW_IV 8
172
173#define MD5_DIGEST_LENGTH 16
174#define MD5_CBLOCK 64
175
176static int fd;
177static int dev_failed;
178
179typedef struct session_op session_op;
180
181#define CDATA(ctx) EVP_C_DATA(session_op,ctx)
182
183static void err(const char *str)
184 {
185 fprintf(stderr,"%s: errno %d\n",str,errno);
186 }
187
188static int dev_crypto_init(session_op *ses)
189 {
190 if(dev_failed)
191 return 0;
192 if(!fd)
193 {
194 int cryptodev_fd;
195
196 if ((cryptodev_fd=open("/dev/crypto",O_RDWR,0)) < 0)
197 {
198 err("/dev/crypto");
199 dev_failed=1;
200 return 0;
201 }
202 if (ioctl(cryptodev_fd,CRIOGET,&fd) == -1)
203 {
204 err("CRIOGET failed");
205 close(cryptodev_fd);
206 dev_failed=1;
207 return 0;
208 }
209 close(cryptodev_fd);
210 }
211 assert(ses);
212 memset(ses,'\0',sizeof *ses);
213
214 return 1;
215 }
216
217static int dev_crypto_cleanup(EVP_CIPHER_CTX *ctx)
218 {
219 fprintf(stderr,"cleanup %d\n",CDATA(ctx)->ses);
220 if(ioctl(fd,CIOCFSESSION,&CDATA(ctx)->ses) == -1)
221 err("CIOCFSESSION failed");
222
223 OPENSSL_free(CDATA(ctx)->key);
224
225 return 1;
226 }
227
228static int dev_crypto_init_key(EVP_CIPHER_CTX *ctx,int cipher,
229 const unsigned char *key,int klen)
230 {
231 if(!dev_crypto_init(CDATA(ctx)))
232 return 0;
233
234 CDATA(ctx)->key=OPENSSL_malloc(MAX_HW_KEY);
235
236 assert(ctx->cipher->iv_len <= MAX_HW_IV);
237
238 memcpy(CDATA(ctx)->key,key,klen);
239
240 CDATA(ctx)->cipher=cipher;
241 CDATA(ctx)->keylen=klen;
242
243 if (ioctl(fd,CIOCGSESSION,CDATA(ctx)) == -1)
244 {
245 err("CIOCGSESSION failed");
246 return 0;
247 }
248 return 1;
249 }
250
251static int dev_crypto_cipher(EVP_CIPHER_CTX *ctx,unsigned char *out,
252 const unsigned char *in,unsigned int inl)
253 {
254 struct crypt_op cryp;
255 unsigned char lb[MAX_HW_IV];
256
257 if(!inl)
258 return 1;
259
260 assert(CDATA(ctx));
261 assert(!dev_failed);
262
263 memset(&cryp,'\0',sizeof cryp);
264 cryp.ses=CDATA(ctx)->ses;
265 cryp.op=ctx->encrypt ? COP_ENCRYPT : COP_DECRYPT;
266 cryp.flags=0;
267 cryp.len=inl;
268 assert((inl&(ctx->cipher->block_size-1)) == 0);
269 cryp.src=(caddr_t)in;
270 cryp.dst=(caddr_t)out;
271 cryp.mac=0;
272 if(ctx->cipher->iv_len)
273 cryp.iv=(caddr_t)ctx->iv;
274
275 if(!ctx->encrypt)
276 memcpy(lb,&in[cryp.len-ctx->cipher->iv_len],ctx->cipher->iv_len);
277
278 if(ioctl(fd, CIOCCRYPT, &cryp) == -1)
279 {
280 if(errno == EINVAL) /* buffers are misaligned */
281 {
282 unsigned int cinl=0;
283 char *cin=NULL;
284 char *cout=NULL;
285
286 /* NB: this can only make cinl != inl with stream ciphers */
287 cinl=(inl+3)/4*4;
288
289 if(((unsigned long)in&3) || cinl != inl)
290 {
291 cin=OPENSSL_malloc(cinl);
292 memcpy(cin,in,inl);
293 cryp.src=cin;
294 }
295
296 if(((unsigned long)out&3) || cinl != inl)
297 {
298 cout=OPENSSL_malloc(cinl);
299 cryp.dst=cout;
300 }
301
302 cryp.len=cinl;
303
304 if(ioctl(fd, CIOCCRYPT, &cryp) == -1)
305 {
306 err("CIOCCRYPT(2) failed");
307 printf("src=%p dst=%p\n",cryp.src,cryp.dst);
308 abort();
309 return 0;
310 }
311
312 if(cout)
313 {
314 memcpy(out,cout,inl);
315 OPENSSL_free(cout);
316 }
317 if(cin)
318 OPENSSL_free(cin);
319 }
320 else
321 {
322 err("CIOCCRYPT failed");
323 abort();
324 return 0;
325 }
326 }
327
328 if(ctx->encrypt)
329 memcpy(ctx->iv,&out[cryp.len-ctx->cipher->iv_len],ctx->cipher->iv_len);
330 else
331 memcpy(ctx->iv,lb,ctx->cipher->iv_len);
332
333 return 1;
334 }
335
336static int dev_crypto_des_ede3_init_key(EVP_CIPHER_CTX *ctx,
337 const unsigned char *key,
338 const unsigned char *iv, int enc)
339 { return dev_crypto_init_key(ctx,CRYPTO_3DES_CBC,key,24); }
340
341static int dev_crypto_rc4_init_key(EVP_CIPHER_CTX *ctx,
342 const unsigned char *key,
343 const unsigned char *iv, int enc)
344 { return dev_crypto_init_key(ctx,CRYPTO_ARC4,key,16); }
345
346typedef struct
347 {
348 session_op sess;
349 char *data;
350 int len;
351 unsigned char md[EVP_MAX_MD_SIZE];
352 } MD_DATA;
353
354static int dev_crypto_init_digest(MD_DATA *md_data,int mac)
355 {
356 if(!dev_crypto_init(&md_data->sess))
357 return 0;
358
359 md_data->len=0;
360 md_data->data=NULL;
361
362 md_data->sess.mac=mac;
363
364 if (ioctl(fd,CIOCGSESSION,&md_data->sess) == -1)
365 {
366 err("CIOCGSESSION failed");
367 return 0;
368 }
369 fprintf(stderr,"opened %d\n",md_data->sess.ses);
370 return 1;
371 }
372
373static int dev_crypto_cleanup_digest(MD_DATA *md_data)
374 {
375 fprintf(stderr,"cleanup %d\n",md_data->sess.ses);
376 if (ioctl(fd,CIOCFSESSION,&md_data->sess.ses) == -1)
377 {
378 err("CIOCFSESSION failed");
379 return 0;
380 }
381
382 return 1;
383 }
384
385/* FIXME: if device can do chained MACs, then don't accumulate */
386/* FIXME: move accumulation to the framework */
387static int dev_crypto_md5_init(EVP_MD_CTX *ctx)
388 { return dev_crypto_init_digest(ctx->md_data,CRYPTO_MD5); }
389
390static int do_digest(int ses,unsigned char *md,const void *data,int len)
391 {
392 struct crypt_op cryp;
393 static unsigned char md5zero[16]=
394 {
395 0xd4,0x1d,0x8c,0xd9,0x8f,0x00,0xb2,0x04,
396 0xe9,0x80,0x09,0x98,0xec,0xf8,0x42,0x7e
397 };
398
399 /* some cards can't do zero length */
400 if(!len)
401 {
402 memcpy(md,md5zero,16);
403 return 1;
404 }
405
406 memset(&cryp,'\0',sizeof cryp);
407 cryp.ses=ses;
408 cryp.op=COP_ENCRYPT;/* required to do the MAC rather than check it */
409 cryp.len=len;
410 cryp.src=(caddr_t)data;
411 cryp.dst=(caddr_t)data; /* FIXME!!! */
412 cryp.mac=(caddr_t)md;
413
414 if(ioctl(fd, CIOCCRYPT, &cryp) == -1)
415 {
416 if(errno == EINVAL && allow_misaligned) /* buffer is misaligned */
417 {
418 char *dcopy;
419
420 dcopy=OPENSSL_malloc(len);
421 memcpy(dcopy,data,len);
422 cryp.src=dcopy;
423 cryp.dst=cryp.src; /* FIXME!!! */
424
425 if(ioctl(fd, CIOCCRYPT, &cryp) == -1)
426 {
427 err("CIOCCRYPT(MAC2) failed");
428 abort();
429 return 0;
430 }
431 OPENSSL_free(dcopy);
432 }
433 else
434 {
435 err("CIOCCRYPT(MAC) failed");
436 abort();
437 return 0;
438 }
439 }
440 /* printf("done\n"); */
441
442 return 1;
443 }
444
445static int dev_crypto_md5_update(EVP_MD_CTX *ctx,const void *data,
446 unsigned long len)
447 {
448 MD_DATA *md_data=ctx->md_data;
449
450 if(ctx->flags&EVP_MD_CTX_FLAG_ONESHOT)
451 return do_digest(md_data->sess.ses,md_data->md,data,len);
452
453 md_data->data=OPENSSL_realloc(md_data->data,md_data->len+len);
454 memcpy(md_data->data+md_data->len,data,len);
455 md_data->len+=len;
456
457 return 1;
458 }
459
460static int dev_crypto_md5_final(EVP_MD_CTX *ctx,unsigned char *md)
461 {
462 int ret;
463 MD_DATA *md_data=ctx->md_data;
464
465 if(ctx->flags&EVP_MD_CTX_FLAG_ONESHOT)
466 {
467 memcpy(md,md_data->md,MD5_DIGEST_LENGTH);
468 ret=1;
469 }
470 else
471 {
472 ret=do_digest(md_data->sess.ses,md,md_data->data,md_data->len);
473 OPENSSL_free(md_data->data);
474 md_data->data=NULL;
475 md_data->len=0;
476 }
477
478 return ret;
479 }
480
481static int dev_crypto_md5_copy(EVP_MD_CTX *to,const EVP_MD_CTX *from)
482 {
483 const MD_DATA *from_md=from->md_data;
484 MD_DATA *to_md=to->md_data;
485
486 /* How do we copy sessions? */
487 assert(from->digest->flags&EVP_MD_FLAG_ONESHOT);
488
489 to_md->data=OPENSSL_malloc(from_md->len);
490 memcpy(to_md->data,from_md->data,from_md->len);
491
492 return 1;
493 }
494
495static int dev_crypto_md5_cleanup(EVP_MD_CTX *ctx)
496 {
497 return dev_crypto_cleanup_digest(ctx->md_data);
498 }
499
500/**************************************************************************/
501/* Here are the moved declarations of the EVP_CIPHER and EVP_MD */
502/* implementations. They're down here to be within easy editor-distance */
503/* of the digests and ciphers handler functions. */
504
505#define dev_crypto_des_ede3_cbc_cipher dev_crypto_cipher
506
507BLOCK_CIPHER_def_cbc(dev_crypto_des_ede3, session_op, NID_des_ede3, 8, 24, 8,
508 0, dev_crypto_des_ede3_init_key,
509 dev_crypto_cleanup,
510 EVP_CIPHER_set_asn1_iv,
511 EVP_CIPHER_get_asn1_iv,
512 NULL)
513
514static const EVP_CIPHER r4_cipher=
515 {
516 NID_rc4,
517 1,16,0, /* FIXME: key should be up to 256 bytes */
518 EVP_CIPH_VARIABLE_LENGTH,
519 dev_crypto_rc4_init_key,
520 dev_crypto_cipher,
521 dev_crypto_cleanup,
522 sizeof(session_op),
523 NULL,
524 NULL,
525 NULL
526 };
527
528static const EVP_MD md5_md=
529 {
530 NID_md5,
531 NID_md5WithRSAEncryption,
532 MD5_DIGEST_LENGTH,
533 EVP_MD_FLAG_ONESHOT, /* XXX: set according to device info... */
534 dev_crypto_md5_init,
535 dev_crypto_md5_update,
536 dev_crypto_md5_final,
537 dev_crypto_md5_copy,
538 dev_crypto_md5_cleanup,
539 EVP_PKEY_RSA_method,
540 MD5_CBLOCK,
541 sizeof(MD_DATA),
542 };
543
544/****************************************************************/
545/* Implement the dev_crypto_[ciphers|digests] handlers here ... */
546
547static int cipher_nids[] = {NID_des_ede3_cbc, NID_rc4};
548static int cipher_nids_num = 2;
549static int digest_nids[] = {NID_md5};
550static int digest_nids_num = 1;
551
552static int dev_crypto_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
553 const int **nids, int nid)
554 {
555 if(!cipher)
556 {
557 /* We are returning a list of supported nids */
558 *nids = cipher_nids;
559 return cipher_nids_num;
560 }
561 /* We are being asked for a specific cipher */
562 if(nid == NID_rc4)
563 *cipher = &r4_cipher;
564 else if(nid == NID_des_ede3_cbc)
565 *cipher = &dev_crypto_des_ede3_cbc;
566 else
567 {
568 *cipher = NULL;
569 return 0;
570 }
571 return 1;
572 }
573
574static int dev_crypto_digests(ENGINE *e, const EVP_MD **digest,
575 const int **nids, int nid)
576 {
577 if(!digest)
578 {
579 /* We are returning a list of supported nids */
580 *nids = digest_nids;
581 return digest_nids_num;
582 }
583 /* We are being asked for a specific digest */
584 if(nid == NID_md5)
585 *digest = &md5_md;
586 else
587 {
588 *digest = NULL;
589 return 0;
590 }
591 return 1;
592 }
593
594#endif /* OPENSSL_OPENBSD_DEV_CRYPTO */
diff --git a/src/lib/libcrypto/engine/hw_sureware_err.c b/src/lib/libcrypto/engine/hw_sureware_err.c
new file mode 100644
index 0000000000..69955dadbb
--- /dev/null
+++ b/src/lib/libcrypto/engine/hw_sureware_err.c
@@ -0,0 +1,150 @@
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
new file mode 100644
index 0000000000..bc52af5e05
--- /dev/null
+++ b/src/lib/libcrypto/engine/hw_sureware_err.h
@@ -0,0 +1,94 @@
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
new file mode 100644
index 0000000000..ed8401ec16
--- /dev/null
+++ b/src/lib/libcrypto/engine/hw_ubsec.c
@@ -0,0 +1,1059 @@
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
245static ENGINE *engine_ubsec(void)
246 {
247 ENGINE *ret = ENGINE_new();
248 if(!ret)
249 return NULL;
250 if(!bind_helper(ret))
251 {
252 ENGINE_free(ret);
253 return NULL;
254 }
255 return ret;
256 }
257
258void ENGINE_load_ubsec(void)
259 {
260 /* Copied from eng_[openssl|dyn].c */
261 ENGINE *toadd = engine_ubsec();
262 if(!toadd) return;
263 ENGINE_add(toadd);
264 ENGINE_free(toadd);
265 ERR_clear_error();
266 }
267
268/* This is a process-global DSO handle used for loading and unloading
269 * the UBSEC library. NB: This is only set (or unset) during an
270 * init() or finish() call (reference counts permitting) and they're
271 * operating with global locks, so this should be thread-safe
272 * implicitly. */
273
274static DSO *ubsec_dso = NULL;
275
276/* These are the function pointers that are (un)set when the library has
277 * successfully (un)loaded. */
278
279static t_UBSEC_ubsec_bytes_to_bits *p_UBSEC_ubsec_bytes_to_bits = NULL;
280static t_UBSEC_ubsec_bits_to_bytes *p_UBSEC_ubsec_bits_to_bytes = NULL;
281static t_UBSEC_ubsec_open *p_UBSEC_ubsec_open = NULL;
282static t_UBSEC_ubsec_close *p_UBSEC_ubsec_close = NULL;
283#ifndef OPENSSL_NO_DH
284static t_UBSEC_diffie_hellman_generate_ioctl
285 *p_UBSEC_diffie_hellman_generate_ioctl = NULL;
286static t_UBSEC_diffie_hellman_agree_ioctl *p_UBSEC_diffie_hellman_agree_ioctl = NULL;
287#endif
288/* #ifndef OPENSSL_NO_RSA */
289static t_UBSEC_rsa_mod_exp_ioctl *p_UBSEC_rsa_mod_exp_ioctl = NULL;
290static t_UBSEC_rsa_mod_exp_crt_ioctl *p_UBSEC_rsa_mod_exp_crt_ioctl = NULL;
291/* #endif */
292#ifndef OPENSSL_NO_DSA
293static t_UBSEC_dsa_sign_ioctl *p_UBSEC_dsa_sign_ioctl = NULL;
294static t_UBSEC_dsa_verify_ioctl *p_UBSEC_dsa_verify_ioctl = NULL;
295#endif
296static t_UBSEC_math_accelerate_ioctl *p_UBSEC_math_accelerate_ioctl = NULL;
297static t_UBSEC_rng_ioctl *p_UBSEC_rng_ioctl = NULL;
298static t_UBSEC_max_key_len_ioctl *p_UBSEC_max_key_len_ioctl = NULL;
299
300static int max_key_len = 1024; /* ??? */
301
302/*
303 * These are the static string constants for the DSO file name and the function
304 * symbol names to bind to.
305 */
306
307static const char *UBSEC_LIBNAME = NULL;
308static const char *get_UBSEC_LIBNAME(void)
309 {
310 if(UBSEC_LIBNAME)
311 return UBSEC_LIBNAME;
312 return "ubsec";
313 }
314static void free_UBSEC_LIBNAME(void)
315 {
316 if(UBSEC_LIBNAME)
317 OPENSSL_free((void*)UBSEC_LIBNAME);
318 UBSEC_LIBNAME = NULL;
319 }
320static long set_UBSEC_LIBNAME(const char *name)
321 {
322 free_UBSEC_LIBNAME();
323 return (((UBSEC_LIBNAME = BUF_strdup(name)) != NULL) ? 1 : 0);
324 }
325static const char *UBSEC_F1 = "ubsec_bytes_to_bits";
326static const char *UBSEC_F2 = "ubsec_bits_to_bytes";
327static const char *UBSEC_F3 = "ubsec_open";
328static const char *UBSEC_F4 = "ubsec_close";
329#ifndef OPENSSL_NO_DH
330static const char *UBSEC_F5 = "diffie_hellman_generate_ioctl";
331static const char *UBSEC_F6 = "diffie_hellman_agree_ioctl";
332#endif
333/* #ifndef OPENSSL_NO_RSA */
334static const char *UBSEC_F7 = "rsa_mod_exp_ioctl";
335static const char *UBSEC_F8 = "rsa_mod_exp_crt_ioctl";
336/* #endif */
337#ifndef OPENSSL_NO_DSA
338static const char *UBSEC_F9 = "dsa_sign_ioctl";
339static const char *UBSEC_F10 = "dsa_verify_ioctl";
340#endif
341static const char *UBSEC_F11 = "math_accelerate_ioctl";
342static const char *UBSEC_F12 = "rng_ioctl";
343static const char *UBSEC_F13 = "ubsec_max_key_len_ioctl";
344
345/* Destructor (complements the "ENGINE_ubsec()" constructor) */
346static int ubsec_destroy(ENGINE *e)
347 {
348 free_UBSEC_LIBNAME();
349 ERR_unload_UBSEC_strings();
350 return 1;
351 }
352
353/* (de)initialisation functions. */
354static int ubsec_init(ENGINE *e)
355 {
356 t_UBSEC_ubsec_bytes_to_bits *p1;
357 t_UBSEC_ubsec_bits_to_bytes *p2;
358 t_UBSEC_ubsec_open *p3;
359 t_UBSEC_ubsec_close *p4;
360#ifndef OPENSSL_NO_DH
361 t_UBSEC_diffie_hellman_generate_ioctl *p5;
362 t_UBSEC_diffie_hellman_agree_ioctl *p6;
363#endif
364/* #ifndef OPENSSL_NO_RSA */
365 t_UBSEC_rsa_mod_exp_ioctl *p7;
366 t_UBSEC_rsa_mod_exp_crt_ioctl *p8;
367/* #endif */
368#ifndef OPENSSL_NO_DSA
369 t_UBSEC_dsa_sign_ioctl *p9;
370 t_UBSEC_dsa_verify_ioctl *p10;
371#endif
372 t_UBSEC_math_accelerate_ioctl *p11;
373 t_UBSEC_rng_ioctl *p12;
374 t_UBSEC_max_key_len_ioctl *p13;
375 int fd = 0;
376
377 if(ubsec_dso != NULL)
378 {
379 UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_ALREADY_LOADED);
380 goto err;
381 }
382 /*
383 * Attempt to load libubsec.so/ubsec.dll/whatever.
384 */
385 ubsec_dso = DSO_load(NULL, get_UBSEC_LIBNAME(), NULL, 0);
386 if(ubsec_dso == NULL)
387 {
388 UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_DSO_FAILURE);
389 goto err;
390 }
391
392 if (
393 !(p1 = (t_UBSEC_ubsec_bytes_to_bits *) DSO_bind_func(ubsec_dso, UBSEC_F1)) ||
394 !(p2 = (t_UBSEC_ubsec_bits_to_bytes *) DSO_bind_func(ubsec_dso, UBSEC_F2)) ||
395 !(p3 = (t_UBSEC_ubsec_open *) DSO_bind_func(ubsec_dso, UBSEC_F3)) ||
396 !(p4 = (t_UBSEC_ubsec_close *) DSO_bind_func(ubsec_dso, UBSEC_F4)) ||
397#ifndef OPENSSL_NO_DH
398 !(p5 = (t_UBSEC_diffie_hellman_generate_ioctl *)
399 DSO_bind_func(ubsec_dso, UBSEC_F5)) ||
400 !(p6 = (t_UBSEC_diffie_hellman_agree_ioctl *)
401 DSO_bind_func(ubsec_dso, UBSEC_F6)) ||
402#endif
403/* #ifndef OPENSSL_NO_RSA */
404 !(p7 = (t_UBSEC_rsa_mod_exp_ioctl *) DSO_bind_func(ubsec_dso, UBSEC_F7)) ||
405 !(p8 = (t_UBSEC_rsa_mod_exp_crt_ioctl *) DSO_bind_func(ubsec_dso, UBSEC_F8)) ||
406/* #endif */
407#ifndef OPENSSL_NO_DSA
408 !(p9 = (t_UBSEC_dsa_sign_ioctl *) DSO_bind_func(ubsec_dso, UBSEC_F9)) ||
409 !(p10 = (t_UBSEC_dsa_verify_ioctl *) DSO_bind_func(ubsec_dso, UBSEC_F10)) ||
410#endif
411 !(p11 = (t_UBSEC_math_accelerate_ioctl *)
412 DSO_bind_func(ubsec_dso, UBSEC_F11)) ||
413 !(p12 = (t_UBSEC_rng_ioctl *) DSO_bind_func(ubsec_dso, UBSEC_F12)) ||
414 !(p13 = (t_UBSEC_max_key_len_ioctl *) DSO_bind_func(ubsec_dso, UBSEC_F13)))
415 {
416 UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_DSO_FAILURE);
417 goto err;
418 }
419
420 /* Copy the pointers */
421 p_UBSEC_ubsec_bytes_to_bits = p1;
422 p_UBSEC_ubsec_bits_to_bytes = p2;
423 p_UBSEC_ubsec_open = p3;
424 p_UBSEC_ubsec_close = p4;
425#ifndef OPENSSL_NO_DH
426 p_UBSEC_diffie_hellman_generate_ioctl = p5;
427 p_UBSEC_diffie_hellman_agree_ioctl = p6;
428#endif
429#ifndef OPENSSL_NO_RSA
430 p_UBSEC_rsa_mod_exp_ioctl = p7;
431 p_UBSEC_rsa_mod_exp_crt_ioctl = p8;
432#endif
433#ifndef OPENSSL_NO_DSA
434 p_UBSEC_dsa_sign_ioctl = p9;
435 p_UBSEC_dsa_verify_ioctl = p10;
436#endif
437 p_UBSEC_math_accelerate_ioctl = p11;
438 p_UBSEC_rng_ioctl = p12;
439 p_UBSEC_max_key_len_ioctl = p13;
440
441 /* Perform an open to see if there's actually any unit running. */
442 if (((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) > 0) && (p_UBSEC_max_key_len_ioctl(fd, &max_key_len) == 0))
443 {
444 p_UBSEC_ubsec_close(fd);
445 return 1;
446 }
447 else
448 {
449 UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_UNIT_FAILURE);
450 }
451
452err:
453 if(ubsec_dso)
454 DSO_free(ubsec_dso);
455 p_UBSEC_ubsec_bytes_to_bits = NULL;
456 p_UBSEC_ubsec_bits_to_bytes = NULL;
457 p_UBSEC_ubsec_open = NULL;
458 p_UBSEC_ubsec_close = NULL;
459#ifndef OPENSSL_NO_DH
460 p_UBSEC_diffie_hellman_generate_ioctl = NULL;
461 p_UBSEC_diffie_hellman_agree_ioctl = NULL;
462#endif
463#ifndef OPENSSL_NO_RSA
464 p_UBSEC_rsa_mod_exp_ioctl = NULL;
465 p_UBSEC_rsa_mod_exp_crt_ioctl = NULL;
466#endif
467#ifndef OPENSSL_NO_DSA
468 p_UBSEC_dsa_sign_ioctl = NULL;
469 p_UBSEC_dsa_verify_ioctl = NULL;
470#endif
471 p_UBSEC_math_accelerate_ioctl = NULL;
472 p_UBSEC_rng_ioctl = NULL;
473 p_UBSEC_max_key_len_ioctl = NULL;
474
475 return 0;
476 }
477
478static int ubsec_finish(ENGINE *e)
479 {
480 free_UBSEC_LIBNAME();
481 if(ubsec_dso == NULL)
482 {
483 UBSECerr(UBSEC_F_UBSEC_FINISH, UBSEC_R_NOT_LOADED);
484 return 0;
485 }
486 if(!DSO_free(ubsec_dso))
487 {
488 UBSECerr(UBSEC_F_UBSEC_FINISH, UBSEC_R_DSO_FAILURE);
489 return 0;
490 }
491 ubsec_dso = NULL;
492 p_UBSEC_ubsec_bytes_to_bits = NULL;
493 p_UBSEC_ubsec_bits_to_bytes = NULL;
494 p_UBSEC_ubsec_open = NULL;
495 p_UBSEC_ubsec_close = NULL;
496#ifndef OPENSSL_NO_DH
497 p_UBSEC_diffie_hellman_generate_ioctl = NULL;
498 p_UBSEC_diffie_hellman_agree_ioctl = NULL;
499#endif
500#ifndef OPENSSL_NO_RSA
501 p_UBSEC_rsa_mod_exp_ioctl = NULL;
502 p_UBSEC_rsa_mod_exp_crt_ioctl = NULL;
503#endif
504#ifndef OPENSSL_NO_DSA
505 p_UBSEC_dsa_sign_ioctl = NULL;
506 p_UBSEC_dsa_verify_ioctl = NULL;
507#endif
508 p_UBSEC_math_accelerate_ioctl = NULL;
509 p_UBSEC_rng_ioctl = NULL;
510 p_UBSEC_max_key_len_ioctl = NULL;
511 return 1;
512 }
513
514static int ubsec_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
515 {
516 int initialised = ((ubsec_dso == NULL) ? 0 : 1);
517 switch(cmd)
518 {
519 case UBSEC_CMD_SO_PATH:
520 if(p == NULL)
521 {
522 UBSECerr(UBSEC_F_UBSEC_CTRL,ERR_R_PASSED_NULL_PARAMETER);
523 return 0;
524 }
525 if(initialised)
526 {
527 UBSECerr(UBSEC_F_UBSEC_CTRL,UBSEC_R_ALREADY_LOADED);
528 return 0;
529 }
530 return set_UBSEC_LIBNAME((const char *)p);
531 default:
532 break;
533 }
534 UBSECerr(UBSEC_F_UBSEC_CTRL,UBSEC_R_CTRL_COMMAND_NOT_IMPLEMENTED);
535 return 0;
536 }
537
538static int ubsec_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
539 const BIGNUM *m, BN_CTX *ctx)
540 {
541 int y_len = 0;
542 int fd;
543
544 if(ubsec_dso == NULL)
545 {
546 UBSECerr(UBSEC_F_UBSEC_MOD_EXP, UBSEC_R_NOT_LOADED);
547 return 0;
548 }
549
550 /* Check if hardware can't handle this argument. */
551 y_len = BN_num_bits(m);
552 if (y_len > max_key_len) {
553 UBSECerr(UBSEC_F_UBSEC_MOD_EXP, UBSEC_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
554 return BN_mod_exp(r, a, p, m, ctx);
555 }
556
557 if(!bn_wexpand(r, m->top))
558 {
559 UBSECerr(UBSEC_F_UBSEC_MOD_EXP, UBSEC_R_BN_EXPAND_FAIL);
560 return 0;
561 }
562 memset(r->d, 0, BN_num_bytes(m));
563
564 if ((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) <= 0) {
565 fd = 0;
566 UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_UNIT_FAILURE);
567 return BN_mod_exp(r, a, p, m, ctx);
568 }
569
570 if (p_UBSEC_rsa_mod_exp_ioctl(fd, (unsigned char *)a->d, BN_num_bits(a),
571 (unsigned char *)m->d, BN_num_bits(m), (unsigned char *)p->d,
572 BN_num_bits(p), (unsigned char *)r->d, &y_len) != 0)
573 {
574 UBSECerr(UBSEC_F_UBSEC_MOD_EXP, UBSEC_R_REQUEST_FAILED);
575 p_UBSEC_ubsec_close(fd);
576
577 return BN_mod_exp(r, a, p, m, ctx);
578 }
579
580 p_UBSEC_ubsec_close(fd);
581
582 r->top = (BN_num_bits(m)+BN_BITS2-1)/BN_BITS2;
583 return 1;
584 }
585
586#ifndef OPENSSL_NO_RSA
587static int ubsec_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
588 {
589 BN_CTX *ctx;
590 int to_return = 0;
591
592 if((ctx = BN_CTX_new()) == NULL)
593 goto err;
594
595 if(!rsa->p || !rsa->q || !rsa->dmp1 || !rsa->dmq1 || !rsa->iqmp)
596 {
597 UBSECerr(UBSEC_F_UBSEC_RSA_MOD_EXP, UBSEC_R_MISSING_KEY_COMPONENTS);
598 goto err;
599 }
600
601 to_return = ubsec_mod_exp_crt(r0, I, rsa->p, rsa->q, rsa->dmp1,
602 rsa->dmq1, rsa->iqmp, ctx);
603 if (to_return == FAIL_TO_SOFTWARE)
604 {
605 /*
606 * Do in software as hardware failed.
607 */
608 const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
609 to_return = (*meth->rsa_mod_exp)(r0, I, rsa);
610 }
611err:
612 if(ctx)
613 BN_CTX_free(ctx);
614 return to_return;
615 }
616#endif
617
618static int ubsec_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
619 const BIGNUM *q, const BIGNUM *dp,
620 const BIGNUM *dq, const BIGNUM *qinv, BN_CTX *ctx)
621 {
622 int y_len,
623 m_len,
624 fd;
625
626 m_len = BN_num_bytes(p) + BN_num_bytes(q) + 1;
627 y_len = BN_num_bits(p) + BN_num_bits(q);
628
629 /* Check if hardware can't handle this argument. */
630 if (y_len > max_key_len) {
631 UBSECerr(UBSEC_F_UBSEC_MOD_EXP, UBSEC_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
632 return FAIL_TO_SOFTWARE;
633 }
634
635 if (!bn_wexpand(r, p->top + q->top + 1)) {
636 UBSECerr(UBSEC_F_UBSEC_RSA_MOD_EXP_CRT, UBSEC_R_BN_EXPAND_FAIL);
637 return 0;
638 }
639
640 if ((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) <= 0) {
641 fd = 0;
642 UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_UNIT_FAILURE);
643 return FAIL_TO_SOFTWARE;
644 }
645
646 if (p_UBSEC_rsa_mod_exp_crt_ioctl(fd,
647 (unsigned char *)a->d, BN_num_bits(a),
648 (unsigned char *)qinv->d, BN_num_bits(qinv),
649 (unsigned char *)dp->d, BN_num_bits(dp),
650 (unsigned char *)p->d, BN_num_bits(p),
651 (unsigned char *)dq->d, BN_num_bits(dq),
652 (unsigned char *)q->d, BN_num_bits(q),
653 (unsigned char *)r->d, &y_len) != 0) {
654 UBSECerr(UBSEC_F_UBSEC_MOD_EXP, UBSEC_R_REQUEST_FAILED);
655 p_UBSEC_ubsec_close(fd);
656 return FAIL_TO_SOFTWARE;
657 }
658
659 p_UBSEC_ubsec_close(fd);
660
661 r->top = (BN_num_bits(p) + BN_num_bits(q) + BN_BITS2 - 1)/BN_BITS2;
662 return 1;
663}
664
665#ifndef OPENSSL_NO_DSA
666#ifdef NOT_USED
667static int ubsec_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,
668 BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
669 BN_CTX *ctx, BN_MONT_CTX *in_mont)
670 {
671 BIGNUM t;
672 int to_return = 0;
673
674 BN_init(&t);
675 /* let rr = a1 ^ p1 mod m */
676 if (!ubsec_mod_exp(rr,a1,p1,m,ctx)) goto end;
677 /* let t = a2 ^ p2 mod m */
678 if (!ubsec_mod_exp(&t,a2,p2,m,ctx)) goto end;
679 /* let rr = rr * t mod m */
680 if (!BN_mod_mul(rr,rr,&t,m,ctx)) goto end;
681 to_return = 1;
682end:
683 BN_free(&t);
684 return to_return;
685 }
686
687static int ubsec_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a,
688 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
689 BN_MONT_CTX *m_ctx)
690 {
691 return ubsec_mod_exp(r, a, p, m, ctx);
692 }
693#endif
694#endif
695
696/*
697 * This function is aliased to mod_exp (with the mont stuff dropped).
698 */
699static int ubsec_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
700 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
701 {
702 int ret = 0;
703
704#ifndef OPENSSL_NO_RSA
705 /* Do in software if the key is too large for the hardware. */
706 if (BN_num_bits(m) > max_key_len)
707 {
708 const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
709 ret = (*meth->bn_mod_exp)(r, a, p, m, ctx, m_ctx);
710 }
711 else
712#endif
713 {
714 ret = ubsec_mod_exp(r, a, p, m, ctx);
715 }
716
717 return ret;
718 }
719
720#ifndef OPENSSL_NO_DH
721/* This function is aliased to mod_exp (with the dh and mont dropped). */
722static int ubsec_mod_exp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a,
723 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
724 BN_MONT_CTX *m_ctx)
725 {
726 return ubsec_mod_exp(r, a, p, m, ctx);
727 }
728#endif
729
730#ifndef OPENSSL_NO_DSA
731static DSA_SIG *ubsec_dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
732 {
733 DSA_SIG *to_return = NULL;
734 int s_len = 160, r_len = 160, d_len, fd;
735 BIGNUM m, *r=NULL, *s=NULL;
736
737 BN_init(&m);
738
739 s = BN_new();
740 r = BN_new();
741 if ((s == NULL) || (r==NULL))
742 goto err;
743
744 d_len = p_UBSEC_ubsec_bytes_to_bits((unsigned char *)dgst, dlen);
745
746 if(!bn_wexpand(r, (160+BN_BITS2-1)/BN_BITS2) ||
747 (!bn_wexpand(s, (160+BN_BITS2-1)/BN_BITS2))) {
748 UBSECerr(UBSEC_F_UBSEC_DSA_SIGN, UBSEC_R_BN_EXPAND_FAIL);
749 goto err;
750 }
751
752 if (BN_bin2bn(dgst,dlen,&m) == NULL) {
753 UBSECerr(UBSEC_F_UBSEC_DSA_SIGN, UBSEC_R_BN_EXPAND_FAIL);
754 goto err;
755 }
756
757 if ((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) <= 0) {
758 const DSA_METHOD *meth;
759 fd = 0;
760 UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_UNIT_FAILURE);
761 meth = DSA_OpenSSL();
762 to_return = meth->dsa_do_sign(dgst, dlen, dsa);
763 goto err;
764 }
765
766 if (p_UBSEC_dsa_sign_ioctl(fd, 0, /* compute hash before signing */
767 (unsigned char *)dgst, d_len,
768 NULL, 0, /* compute random value */
769 (unsigned char *)dsa->p->d, BN_num_bits(dsa->p),
770 (unsigned char *)dsa->q->d, BN_num_bits(dsa->q),
771 (unsigned char *)dsa->g->d, BN_num_bits(dsa->g),
772 (unsigned char *)dsa->priv_key->d, BN_num_bits(dsa->priv_key),
773 (unsigned char *)r->d, &r_len,
774 (unsigned char *)s->d, &s_len ) != 0) {
775 const DSA_METHOD *meth;
776
777 UBSECerr(UBSEC_F_UBSEC_DSA_SIGN, UBSEC_R_REQUEST_FAILED);
778 p_UBSEC_ubsec_close(fd);
779 meth = DSA_OpenSSL();
780 to_return = meth->dsa_do_sign(dgst, dlen, dsa);
781
782 goto err;
783 }
784
785 p_UBSEC_ubsec_close(fd);
786
787 r->top = (160+BN_BITS2-1)/BN_BITS2;
788 s->top = (160+BN_BITS2-1)/BN_BITS2;
789
790 to_return = DSA_SIG_new();
791 if(to_return == NULL) {
792 UBSECerr(UBSEC_F_UBSEC_DSA_SIGN, UBSEC_R_BN_EXPAND_FAIL);
793 goto err;
794 }
795
796 to_return->r = r;
797 to_return->s = s;
798
799err:
800 if (!to_return) {
801 if (r) BN_free(r);
802 if (s) BN_free(s);
803 }
804 BN_clear_free(&m);
805 return to_return;
806}
807
808static int ubsec_dsa_verify(const unsigned char *dgst, int dgst_len,
809 DSA_SIG *sig, DSA *dsa)
810 {
811 int v_len, d_len;
812 int to_return = 0;
813 int fd;
814 BIGNUM v;
815
816 BN_init(&v);
817
818 if(!bn_wexpand(&v, dsa->p->top)) {
819 UBSECerr(UBSEC_F_UBSEC_DSA_VERIFY ,UBSEC_R_BN_EXPAND_FAIL);
820 goto err;
821 }
822
823 v_len = BN_num_bits(dsa->p);
824
825 d_len = p_UBSEC_ubsec_bytes_to_bits((unsigned char *)dgst, dgst_len);
826
827 if ((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) <= 0) {
828 const DSA_METHOD *meth;
829 fd = 0;
830 UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_UNIT_FAILURE);
831 meth = DSA_OpenSSL();
832 to_return = meth->dsa_do_verify(dgst, dgst_len, sig, dsa);
833 goto err;
834 }
835
836 if (p_UBSEC_dsa_verify_ioctl(fd, 0, /* compute hash before signing */
837 (unsigned char *)dgst, d_len,
838 (unsigned char *)dsa->p->d, BN_num_bits(dsa->p),
839 (unsigned char *)dsa->q->d, BN_num_bits(dsa->q),
840 (unsigned char *)dsa->g->d, BN_num_bits(dsa->g),
841 (unsigned char *)dsa->pub_key->d, BN_num_bits(dsa->pub_key),
842 (unsigned char *)sig->r->d, BN_num_bits(sig->r),
843 (unsigned char *)sig->s->d, BN_num_bits(sig->s),
844 (unsigned char *)v.d, &v_len) != 0) {
845 const DSA_METHOD *meth;
846 UBSECerr(UBSEC_F_UBSEC_DSA_VERIFY , UBSEC_R_REQUEST_FAILED);
847 p_UBSEC_ubsec_close(fd);
848
849 meth = DSA_OpenSSL();
850 to_return = meth->dsa_do_verify(dgst, dgst_len, sig, dsa);
851
852 goto err;
853 }
854
855 p_UBSEC_ubsec_close(fd);
856
857 to_return = 1;
858err:
859 BN_clear_free(&v);
860 return to_return;
861 }
862#endif
863
864#ifndef OPENSSL_NO_DH
865static int ubsec_dh_compute_key (unsigned char *key,const BIGNUM *pub_key,DH *dh)
866 {
867 int ret = -1,
868 k_len,
869 fd;
870
871 k_len = BN_num_bits(dh->p);
872
873 if ((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) <= 0)
874 {
875 const DH_METHOD *meth;
876 ENGINEerr(UBSEC_F_UBSEC_INIT, UBSEC_R_UNIT_FAILURE);
877 meth = DH_OpenSSL();
878 ret = meth->compute_key(key, pub_key, dh);
879 goto err;
880 }
881
882 if (p_UBSEC_diffie_hellman_agree_ioctl(fd,
883 (unsigned char *)dh->priv_key->d, BN_num_bits(dh->priv_key),
884 (unsigned char *)pub_key->d, BN_num_bits(pub_key),
885 (unsigned char *)dh->p->d, BN_num_bits(dh->p),
886 key, &k_len) != 0)
887 {
888 /* Hardware's a no go, failover to software */
889 const DH_METHOD *meth;
890 ENGINEerr(UBSEC_F_UBSEC_DH_COMPUTE_KEY, UBSEC_R_REQUEST_FAILED);
891 p_UBSEC_ubsec_close(fd);
892
893 meth = DH_OpenSSL();
894 ret = meth->compute_key(key, pub_key, dh);
895
896 goto err;
897 }
898
899 p_UBSEC_ubsec_close(fd);
900
901 ret = p_UBSEC_ubsec_bits_to_bytes(k_len);
902err:
903 return ret;
904 }
905
906static int ubsec_dh_generate_key (DH *dh)
907 {
908 int ret = 0,
909 random_bits = 0,
910 pub_key_len = 0,
911 priv_key_len = 0,
912 fd;
913 BIGNUM *pub_key = NULL;
914 BIGNUM *priv_key = NULL;
915
916 /*
917 * How many bits should Random x be? dh_key.c
918 * sets the range from 0 to num_bits(modulus) ???
919 */
920
921 if (dh->priv_key == NULL)
922 {
923 priv_key = BN_new();
924 if (priv_key == NULL) goto err;
925 priv_key_len = BN_num_bits(dh->p);
926 bn_wexpand(priv_key, dh->p->top);
927 do
928 if (!BN_rand_range(priv_key, dh->p)) goto err;
929 while (BN_is_zero(priv_key));
930 random_bits = BN_num_bits(priv_key);
931 }
932 else
933 {
934 priv_key = dh->priv_key;
935 }
936
937 if (dh->pub_key == NULL)
938 {
939 pub_key = BN_new();
940 pub_key_len = BN_num_bits(dh->p);
941 bn_wexpand(pub_key, dh->p->top);
942 if(pub_key == NULL) goto err;
943 }
944 else
945 {
946 pub_key = dh->pub_key;
947 }
948
949 if ((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) <= 0)
950 {
951 const DH_METHOD *meth;
952 ENGINEerr(UBSEC_F_UBSEC_INIT, UBSEC_R_UNIT_FAILURE);
953 meth = DH_OpenSSL();
954 ret = meth->generate_key(dh);
955 goto err;
956 }
957
958 if (p_UBSEC_diffie_hellman_generate_ioctl(fd,
959 (unsigned char *)priv_key->d, &priv_key_len,
960 (unsigned char *)pub_key->d, &pub_key_len,
961 (unsigned char *)dh->g->d, BN_num_bits(dh->g),
962 (unsigned char *)dh->p->d, BN_num_bits(dh->p),
963 0, 0, random_bits) != 0)
964 {
965 /* Hardware's a no go, failover to software */
966 const DH_METHOD *meth;
967
968 ENGINEerr(UBSEC_F_UBSEC_DH_COMPUTE_KEY, UBSEC_R_REQUEST_FAILED);
969 p_UBSEC_ubsec_close(fd);
970
971 meth = DH_OpenSSL();
972 ret = meth->generate_key(dh);
973
974 goto err;
975 }
976
977 p_UBSEC_ubsec_close(fd);
978
979 dh->pub_key = pub_key;
980 dh->pub_key->top = (pub_key_len + BN_BITS2-1) / BN_BITS2;
981 dh->priv_key = priv_key;
982 dh->priv_key->top = (priv_key_len + BN_BITS2-1) / BN_BITS2;
983
984 ret = 1;
985err:
986 return ret;
987 }
988#endif
989
990#ifdef NOT_USED
991static int ubsec_rand_bytes(unsigned char * buf,
992 int num)
993 {
994 int ret = 0,
995 fd;
996
997 if ((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) <= 0)
998 {
999 const RAND_METHOD *meth;
1000 ENGINEerr(UBSEC_F_UBSEC_INIT, UBSEC_R_UNIT_FAILURE);
1001 num = p_UBSEC_ubsec_bits_to_bytes(num);
1002 meth = RAND_SSLeay();
1003 meth->seed(buf, num);
1004 ret = meth->bytes(buf, num);
1005 goto err;
1006 }
1007
1008 num *= 8; /* bytes to bits */
1009
1010 if (p_UBSEC_rng_ioctl(fd,
1011 UBSEC_RNG_DIRECT,
1012 buf,
1013 &num) != 0)
1014 {
1015 /* Hardware's a no go, failover to software */
1016 const RAND_METHOD *meth;
1017
1018 ENGINEerr(UBSEC_F_UBSEC_RNG_BYTES, UBSEC_R_REQUEST_FAILED);
1019 p_UBSEC_ubsec_close(fd);
1020
1021 num = p_UBSEC_ubsec_bits_to_bytes(num);
1022 meth = RAND_SSLeay();
1023 meth->seed(buf, num);
1024 ret = meth->bytes(buf, num);
1025
1026 goto err;
1027 }
1028
1029 p_UBSEC_ubsec_close(fd);
1030
1031 ret = 1;
1032err:
1033 return(ret);
1034 }
1035
1036
1037static int ubsec_rand_status(void)
1038 {
1039 return 0;
1040 }
1041#endif
1042
1043/* This stuff is needed if this ENGINE is being compiled into a self-contained
1044 * shared-library. */
1045#ifdef ENGINE_DYNAMIC_SUPPORT
1046static int bind_fn(ENGINE *e, const char *id)
1047 {
1048 if(id && (strcmp(id, engine_ubsec_id) != 0))
1049 return 0;
1050 if(!bind_helper(e))
1051 return 0;
1052 return 1;
1053 }
1054IMPLEMENT_DYNAMIC_CHECK_FN()
1055IMPLEMENT_DYNAMIC_BIND_FN(bind_fn)
1056#endif /* ENGINE_DYNAMIC_SUPPORT */
1057
1058#endif /* !OPENSSL_NO_HW_UBSEC */
1059#endif /* !OPENSSL_NO_HW */
diff --git a/src/lib/libcrypto/engine/hw_ubsec_err.c b/src/lib/libcrypto/engine/hw_ubsec_err.c
new file mode 100644
index 0000000000..d707331fc2
--- /dev/null
+++ b/src/lib/libcrypto/engine/hw_ubsec_err.c
@@ -0,0 +1,151 @@
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
new file mode 100644
index 0000000000..023d3be771
--- /dev/null
+++ b/src/lib/libcrypto/engine/hw_ubsec_err.h
@@ -0,0 +1,95 @@
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/tb_cipher.c b/src/lib/libcrypto/engine/tb_cipher.c
index 50b3cec1fa..c5a50fc910 100644
--- a/src/lib/libcrypto/engine/tb_cipher.c
+++ b/src/lib/libcrypto/engine/tb_cipher.c
@@ -81,7 +81,7 @@ int ENGINE_register_ciphers(ENGINE *e)
81 int num_nids = e->ciphers(e, NULL, &nids, 0); 81 int num_nids = e->ciphers(e, NULL, &nids, 0);
82 if(num_nids > 0) 82 if(num_nids > 0)
83 return engine_table_register(&cipher_table, 83 return engine_table_register(&cipher_table,
84 engine_unregister_all_ciphers, e, nids, 84 &engine_unregister_all_ciphers, e, nids,
85 num_nids, 0); 85 num_nids, 0);
86 } 86 }
87 return 1; 87 return 1;
@@ -103,7 +103,7 @@ int ENGINE_set_default_ciphers(ENGINE *e)
103 int num_nids = e->ciphers(e, NULL, &nids, 0); 103 int num_nids = e->ciphers(e, NULL, &nids, 0);
104 if(num_nids > 0) 104 if(num_nids > 0)
105 return engine_table_register(&cipher_table, 105 return engine_table_register(&cipher_table,
106 engine_unregister_all_ciphers, e, nids, 106 &engine_unregister_all_ciphers, e, nids,
107 num_nids, 1); 107 num_nids, 1);
108 } 108 }
109 return 1; 109 return 1;
diff --git a/src/lib/libcrypto/engine/tb_dh.c b/src/lib/libcrypto/engine/tb_dh.c
index e290e1702b..c9347235ea 100644
--- a/src/lib/libcrypto/engine/tb_dh.c
+++ b/src/lib/libcrypto/engine/tb_dh.c
@@ -78,7 +78,7 @@ int ENGINE_register_DH(ENGINE *e)
78 { 78 {
79 if(e->dh_meth) 79 if(e->dh_meth)
80 return engine_table_register(&dh_table, 80 return engine_table_register(&dh_table,
81 engine_unregister_all_DH, e, &dummy_nid, 1, 0); 81 &engine_unregister_all_DH, e, &dummy_nid, 1, 0);
82 return 1; 82 return 1;
83 } 83 }
84 84
@@ -94,7 +94,7 @@ int ENGINE_set_default_DH(ENGINE *e)
94 { 94 {
95 if(e->dh_meth) 95 if(e->dh_meth)
96 return engine_table_register(&dh_table, 96 return engine_table_register(&dh_table,
97 engine_unregister_all_DH, e, &dummy_nid, 1, 1); 97 &engine_unregister_all_DH, e, &dummy_nid, 1, 1);
98 return 1; 98 return 1;
99 } 99 }
100 100
diff --git a/src/lib/libcrypto/engine/tb_digest.c b/src/lib/libcrypto/engine/tb_digest.c
index e82d2a17c9..2c4dd6f796 100644
--- a/src/lib/libcrypto/engine/tb_digest.c
+++ b/src/lib/libcrypto/engine/tb_digest.c
@@ -81,7 +81,7 @@ int ENGINE_register_digests(ENGINE *e)
81 int num_nids = e->digests(e, NULL, &nids, 0); 81 int num_nids = e->digests(e, NULL, &nids, 0);
82 if(num_nids > 0) 82 if(num_nids > 0)
83 return engine_table_register(&digest_table, 83 return engine_table_register(&digest_table,
84 engine_unregister_all_digests, e, nids, 84 &engine_unregister_all_digests, e, nids,
85 num_nids, 0); 85 num_nids, 0);
86 } 86 }
87 return 1; 87 return 1;
@@ -103,7 +103,7 @@ int ENGINE_set_default_digests(ENGINE *e)
103 int num_nids = e->digests(e, NULL, &nids, 0); 103 int num_nids = e->digests(e, NULL, &nids, 0);
104 if(num_nids > 0) 104 if(num_nids > 0)
105 return engine_table_register(&digest_table, 105 return engine_table_register(&digest_table,
106 engine_unregister_all_digests, e, nids, 106 &engine_unregister_all_digests, e, nids,
107 num_nids, 1); 107 num_nids, 1);
108 } 108 }
109 return 1; 109 return 1;
diff --git a/src/lib/libcrypto/engine/tb_dsa.c b/src/lib/libcrypto/engine/tb_dsa.c
index 80170591f2..e9209476b8 100644
--- a/src/lib/libcrypto/engine/tb_dsa.c
+++ b/src/lib/libcrypto/engine/tb_dsa.c
@@ -78,7 +78,7 @@ int ENGINE_register_DSA(ENGINE *e)
78 { 78 {
79 if(e->dsa_meth) 79 if(e->dsa_meth)
80 return engine_table_register(&dsa_table, 80 return engine_table_register(&dsa_table,
81 engine_unregister_all_DSA, e, &dummy_nid, 1, 0); 81 &engine_unregister_all_DSA, e, &dummy_nid, 1, 0);
82 return 1; 82 return 1;
83 } 83 }
84 84
@@ -94,7 +94,7 @@ int ENGINE_set_default_DSA(ENGINE *e)
94 { 94 {
95 if(e->dsa_meth) 95 if(e->dsa_meth)
96 return engine_table_register(&dsa_table, 96 return engine_table_register(&dsa_table,
97 engine_unregister_all_DSA, e, &dummy_nid, 1, 0); 97 &engine_unregister_all_DSA, e, &dummy_nid, 1, 0);
98 return 1; 98 return 1;
99 } 99 }
100 100
diff --git a/src/lib/libcrypto/engine/tb_rand.c b/src/lib/libcrypto/engine/tb_rand.c
index 69b67111bc..0b1d031f1e 100644
--- a/src/lib/libcrypto/engine/tb_rand.c
+++ b/src/lib/libcrypto/engine/tb_rand.c
@@ -78,7 +78,7 @@ int ENGINE_register_RAND(ENGINE *e)
78 { 78 {
79 if(e->rand_meth) 79 if(e->rand_meth)
80 return engine_table_register(&rand_table, 80 return engine_table_register(&rand_table,
81 engine_unregister_all_RAND, e, &dummy_nid, 1, 0); 81 &engine_unregister_all_RAND, e, &dummy_nid, 1, 0);
82 return 1; 82 return 1;
83 } 83 }
84 84
@@ -94,7 +94,7 @@ int ENGINE_set_default_RAND(ENGINE *e)
94 { 94 {
95 if(e->rand_meth) 95 if(e->rand_meth)
96 return engine_table_register(&rand_table, 96 return engine_table_register(&rand_table,
97 engine_unregister_all_RAND, e, &dummy_nid, 1, 1); 97 &engine_unregister_all_RAND, e, &dummy_nid, 1, 1);
98 return 1; 98 return 1;
99 } 99 }
100 100
diff --git a/src/lib/libcrypto/engine/tb_rsa.c b/src/lib/libcrypto/engine/tb_rsa.c
index fee4867f52..f84fea3968 100644
--- a/src/lib/libcrypto/engine/tb_rsa.c
+++ b/src/lib/libcrypto/engine/tb_rsa.c
@@ -78,7 +78,7 @@ int ENGINE_register_RSA(ENGINE *e)
78 { 78 {
79 if(e->rsa_meth) 79 if(e->rsa_meth)
80 return engine_table_register(&rsa_table, 80 return engine_table_register(&rsa_table,
81 engine_unregister_all_RSA, e, &dummy_nid, 1, 0); 81 &engine_unregister_all_RSA, e, &dummy_nid, 1, 0);
82 return 1; 82 return 1;
83 } 83 }
84 84
@@ -94,7 +94,7 @@ int ENGINE_set_default_RSA(ENGINE *e)
94 { 94 {
95 if(e->rsa_meth) 95 if(e->rsa_meth)
96 return engine_table_register(&rsa_table, 96 return engine_table_register(&rsa_table,
97 engine_unregister_all_RSA, e, &dummy_nid, 1, 1); 97 &engine_unregister_all_RSA, e, &dummy_nid, 1, 1);
98 return 1; 98 return 1;
99 } 99 }
100 100
diff --git a/src/lib/libcrypto/engine/vendor_defns/aep.h b/src/lib/libcrypto/engine/vendor_defns/aep.h
new file mode 100644
index 0000000000..2b2792d2d6
--- /dev/null
+++ b/src/lib/libcrypto/engine/vendor_defns/aep.h
@@ -0,0 +1,178 @@
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
new file mode 100644
index 0000000000..149970d441
--- /dev/null
+++ b/src/lib/libcrypto/engine/vendor_defns/atalla.h
@@ -0,0 +1,48 @@
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
new file mode 100644
index 0000000000..60079326bb
--- /dev/null
+++ b/src/lib/libcrypto/engine/vendor_defns/cswift.h
@@ -0,0 +1,234 @@
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
new file mode 100644
index 0000000000..296636e81a
--- /dev/null
+++ b/src/lib/libcrypto/engine/vendor_defns/hw_4758_cca.h
@@ -0,0 +1,149 @@
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/err/Makefile.ssl b/src/lib/libcrypto/err/Makefile.ssl
new file mode 100644
index 0000000000..f0c95e2ef2
--- /dev/null
+++ b/src/lib/libcrypto/err/Makefile.ssl
@@ -0,0 +1,119 @@
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 b873270c04..9b532d1f4c 100644
--- a/src/lib/libcrypto/err/err.c
+++ b/src/lib/libcrypto/err/err.c
@@ -211,7 +211,6 @@ static ERR_STRING_DATA ERR_str_reasons[]=
211 211
212{0,NULL}, 212{0,NULL},
213 }; 213 };
214#endif
215 214
216 215
217/* Define the predeclared (but externally opaque) "ERR_FNS" type */ 216/* Define the predeclared (but externally opaque) "ERR_FNS" type */
@@ -492,7 +491,6 @@ static int int_err_get_next_lib(void)
492 } 491 }
493 492
494 493
495#ifndef OPENSSL_NO_ERR
496#define NUM_SYS_STR_REASONS 127 494#define NUM_SYS_STR_REASONS 127
497#define LEN_SYS_STR_REASON 32 495#define LEN_SYS_STR_REASON 32
498 496
@@ -1025,7 +1023,7 @@ void ERR_add_error_data(int num, ...)
1025 else 1023 else
1026 str=p; 1024 str=p;
1027 } 1025 }
1028 strcat(str,a); 1026 strlcat(str,a,s+1);
1029 } 1027 }
1030 } 1028 }
1031 ERR_set_error_data(str,ERR_TXT_MALLOCED|ERR_TXT_STRING); 1029 ERR_set_error_data(str,ERR_TXT_MALLOCED|ERR_TXT_STRING);
diff --git a/src/lib/libcrypto/err/err_all.c b/src/lib/libcrypto/err/err_all.c
index dc505d9d9d..90029fd159 100644
--- a/src/lib/libcrypto/err/err_all.c
+++ b/src/lib/libcrypto/err/err_all.c
@@ -82,9 +82,7 @@
82#include <openssl/pkcs12.h> 82#include <openssl/pkcs12.h>
83#include <openssl/rand.h> 83#include <openssl/rand.h>
84#include <openssl/dso.h> 84#include <openssl/dso.h>
85#ifndef OPENSSL_NO_ENGINE
86#include <openssl/engine.h> 85#include <openssl/engine.h>
87#endif
88#include <openssl/ocsp.h> 86#include <openssl/ocsp.h>
89#include <openssl/err.h> 87#include <openssl/err.h>
90 88
@@ -124,9 +122,7 @@ void ERR_load_crypto_strings(void)
124 ERR_load_PKCS12_strings(); 122 ERR_load_PKCS12_strings();
125 ERR_load_RAND_strings(); 123 ERR_load_RAND_strings();
126 ERR_load_DSO_strings(); 124 ERR_load_DSO_strings();
127#ifndef OPENSSL_NO_ENGINE
128 ERR_load_ENGINE_strings(); 125 ERR_load_ENGINE_strings();
129#endif
130 ERR_load_OCSP_strings(); 126 ERR_load_OCSP_strings();
131 ERR_load_UI_strings(); 127 ERR_load_UI_strings();
132#endif 128#endif
diff --git a/src/lib/libcrypto/err/err_prn.c b/src/lib/libcrypto/err/err_prn.c
index 81e34bd6ce..c156663f0e 100644
--- a/src/lib/libcrypto/err/err_prn.c
+++ b/src/lib/libcrypto/err/err_prn.c
@@ -62,6 +62,7 @@
62#include "cryptlib.h" 62#include "cryptlib.h"
63#include <openssl/buffer.h> 63#include <openssl/buffer.h>
64#include <openssl/err.h> 64#include <openssl/err.h>
65#include <openssl/crypto.h>
65 66
66void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u), 67void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u),
67 void *u) 68 void *u)
diff --git a/src/lib/libcrypto/evp/Makefile.ssl b/src/lib/libcrypto/evp/Makefile.ssl
new file mode 100644
index 0000000000..58843f61a9
--- /dev/null
+++ b/src/lib/libcrypto/evp/Makefile.ssl
@@ -0,0 +1,1060 @@
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 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TESTDATA)
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/err.h
189c_all.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
190c_all.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
191c_all.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
192c_all.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
193c_all.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
194c_all.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
195c_all.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
196c_all.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
197c_all.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
198c_all.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
199c_all.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
200c_all.o: ../../include/openssl/ui_compat.h ../cryptlib.h c_all.c
201c_allc.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
202c_allc.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
203c_allc.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
204c_allc.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
205c_allc.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
206c_allc.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
207c_allc.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
208c_allc.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
209c_allc.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
210c_allc.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
211c_allc.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
212c_allc.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
213c_allc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
214c_allc.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
215c_allc.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
216c_allc.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
217c_allc.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
218c_allc.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
219c_allc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
220c_allc.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
221c_allc.o: ../../include/openssl/x509_vfy.h ../cryptlib.h c_allc.c
222c_alld.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
223c_alld.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
224c_alld.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
225c_alld.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
226c_alld.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
227c_alld.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
228c_alld.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
229c_alld.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
230c_alld.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
231c_alld.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
232c_alld.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
233c_alld.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
234c_alld.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
235c_alld.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
236c_alld.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
237c_alld.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
238c_alld.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
239c_alld.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
240c_alld.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
241c_alld.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
242c_alld.o: ../../include/openssl/x509_vfy.h ../cryptlib.h c_alld.c
243digest.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
244digest.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
245digest.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
246digest.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
247digest.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
248digest.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
249digest.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
250digest.o: ../../include/openssl/err.h ../../include/openssl/evp.h
251digest.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
252digest.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
253digest.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
254digest.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
255digest.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
256digest.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
257digest.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
258digest.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
259digest.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
260digest.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
261digest.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
262digest.o: ../../include/openssl/ui_compat.h ../cryptlib.h digest.c
263e_aes.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
264e_aes.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
265e_aes.o: ../../include/openssl/bn.h ../../include/openssl/cast.h
266e_aes.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
267e_aes.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
268e_aes.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
269e_aes.o: ../../include/openssl/err.h ../../include/openssl/evp.h
270e_aes.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
271e_aes.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
272e_aes.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
273e_aes.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
274e_aes.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
275e_aes.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rc2.h
276e_aes.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
277e_aes.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
278e_aes.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
279e_aes.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
280e_aes.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h e_aes.c
281e_aes.o: evp_locl.h
282e_bf.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
283e_bf.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
284e_bf.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
285e_bf.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
286e_bf.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
287e_bf.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
288e_bf.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
289e_bf.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
290e_bf.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
291e_bf.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
292e_bf.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
293e_bf.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
294e_bf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
295e_bf.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
296e_bf.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
297e_bf.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
298e_bf.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
299e_bf.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
300e_bf.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_bf.c evp_locl.h
301e_cast.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
302e_cast.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
303e_cast.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
304e_cast.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
305e_cast.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
306e_cast.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
307e_cast.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
308e_cast.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
309e_cast.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
310e_cast.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
311e_cast.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
312e_cast.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
313e_cast.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
314e_cast.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
315e_cast.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
316e_cast.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
317e_cast.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
318e_cast.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
319e_cast.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_cast.c evp_locl.h
320e_des.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
321e_des.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
322e_des.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
323e_des.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
324e_des.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
325e_des.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
326e_des.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
327e_des.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
328e_des.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
329e_des.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
330e_des.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
331e_des.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
332e_des.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
333e_des.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
334e_des.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
335e_des.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
336e_des.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
337e_des.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
338e_des.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_des.c evp_locl.h
339e_des3.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
340e_des3.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
341e_des3.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
342e_des3.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
343e_des3.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
344e_des3.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
345e_des3.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
346e_des3.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
347e_des3.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
348e_des3.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
349e_des3.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
350e_des3.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
351e_des3.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
352e_des3.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
353e_des3.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
354e_des3.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
355e_des3.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
356e_des3.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
357e_des3.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_des3.c evp_locl.h
358e_idea.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
359e_idea.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
360e_idea.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
361e_idea.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
362e_idea.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
363e_idea.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
364e_idea.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
365e_idea.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
366e_idea.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
367e_idea.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
368e_idea.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
369e_idea.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
370e_idea.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
371e_idea.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
372e_idea.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
373e_idea.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
374e_idea.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
375e_idea.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
376e_idea.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_idea.c evp_locl.h
377e_null.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
378e_null.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
379e_null.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
380e_null.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
381e_null.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
382e_null.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
383e_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
384e_null.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
385e_null.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
386e_null.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
387e_null.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
388e_null.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
389e_null.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
390e_null.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
391e_null.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
392e_null.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
393e_null.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
394e_null.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
395e_null.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_null.c
396e_rc2.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
397e_rc2.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
398e_rc2.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
399e_rc2.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
400e_rc2.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
401e_rc2.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
402e_rc2.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
403e_rc2.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
404e_rc2.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
405e_rc2.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
406e_rc2.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
407e_rc2.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
408e_rc2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
409e_rc2.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
410e_rc2.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
411e_rc2.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
412e_rc2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
413e_rc2.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
414e_rc2.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_rc2.c evp_locl.h
415e_rc4.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
416e_rc4.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
417e_rc4.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
418e_rc4.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
419e_rc4.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
420e_rc4.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
421e_rc4.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
422e_rc4.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
423e_rc4.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
424e_rc4.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
425e_rc4.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
426e_rc4.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
427e_rc4.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
428e_rc4.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
429e_rc4.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
430e_rc4.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
431e_rc4.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
432e_rc4.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
433e_rc4.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_rc4.c
434e_rc5.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
435e_rc5.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
436e_rc5.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
437e_rc5.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
438e_rc5.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
439e_rc5.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
440e_rc5.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
441e_rc5.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
442e_rc5.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
443e_rc5.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
444e_rc5.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
445e_rc5.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
446e_rc5.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
447e_rc5.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
448e_rc5.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
449e_rc5.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
450e_rc5.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
451e_rc5.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
452e_rc5.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_rc5.c evp_locl.h
453e_xcbc_d.o: ../../e_os.h ../../include/openssl/aes.h
454e_xcbc_d.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
455e_xcbc_d.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
456e_xcbc_d.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
457e_xcbc_d.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
458e_xcbc_d.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
459e_xcbc_d.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
460e_xcbc_d.o: ../../include/openssl/err.h ../../include/openssl/evp.h
461e_xcbc_d.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
462e_xcbc_d.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
463e_xcbc_d.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
464e_xcbc_d.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
465e_xcbc_d.o: ../../include/openssl/opensslconf.h
466e_xcbc_d.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
467e_xcbc_d.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
468e_xcbc_d.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
469e_xcbc_d.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
470e_xcbc_d.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
471e_xcbc_d.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
472e_xcbc_d.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_xcbc_d.c
473encode.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
474encode.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
475encode.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
476encode.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
477encode.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
478encode.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
479encode.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
480encode.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
481encode.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
482encode.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
483encode.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
484encode.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
485encode.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
486encode.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
487encode.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
488encode.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
489encode.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
490encode.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
491encode.o: ../../include/openssl/ui_compat.h ../cryptlib.h encode.c
492evp_acnf.o: ../../e_os.h ../../include/openssl/aes.h
493evp_acnf.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
494evp_acnf.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
495evp_acnf.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
496evp_acnf.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
497evp_acnf.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
498evp_acnf.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
499evp_acnf.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
500evp_acnf.o: ../../include/openssl/err.h ../../include/openssl/evp.h
501evp_acnf.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
502evp_acnf.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
503evp_acnf.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
504evp_acnf.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
505evp_acnf.o: ../../include/openssl/opensslconf.h
506evp_acnf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
507evp_acnf.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
508evp_acnf.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
509evp_acnf.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
510evp_acnf.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
511evp_acnf.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
512evp_acnf.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
513evp_acnf.o: ../cryptlib.h evp_acnf.c
514evp_enc.o: ../../e_os.h ../../include/openssl/aes.h
515evp_enc.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
516evp_enc.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
517evp_enc.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
518evp_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
519evp_enc.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
520evp_enc.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
521evp_enc.o: ../../include/openssl/engine.h ../../include/openssl/err.h
522evp_enc.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
523evp_enc.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
524evp_enc.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
525evp_enc.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
526evp_enc.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
527evp_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
528evp_enc.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
529evp_enc.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
530evp_enc.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
531evp_enc.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
532evp_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
533evp_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
534evp_enc.o: ../cryptlib.h evp_enc.c evp_locl.h
535evp_err.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
536evp_err.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
537evp_err.o: ../../include/openssl/bn.h ../../include/openssl/cast.h
538evp_err.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
539evp_err.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
540evp_err.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
541evp_err.o: ../../include/openssl/err.h ../../include/openssl/evp.h
542evp_err.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
543evp_err.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
544evp_err.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
545evp_err.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
546evp_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
547evp_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rc2.h
548evp_err.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
549evp_err.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
550evp_err.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
551evp_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
552evp_err.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
553evp_err.o: evp_err.c
554evp_key.o: ../../e_os.h ../../include/openssl/aes.h
555evp_key.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
556evp_key.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
557evp_key.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
558evp_key.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
559evp_key.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
560evp_key.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
561evp_key.o: ../../include/openssl/err.h ../../include/openssl/evp.h
562evp_key.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
563evp_key.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
564evp_key.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
565evp_key.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
566evp_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
567evp_key.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
568evp_key.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
569evp_key.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
570evp_key.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
571evp_key.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
572evp_key.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
573evp_key.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
574evp_key.o: ../../include/openssl/x509_vfy.h ../cryptlib.h evp_key.c
575evp_lib.o: ../../e_os.h ../../include/openssl/aes.h
576evp_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
577evp_lib.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
578evp_lib.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
579evp_lib.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
580evp_lib.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
581evp_lib.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
582evp_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h
583evp_lib.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
584evp_lib.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
585evp_lib.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
586evp_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
587evp_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
588evp_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rc2.h
589evp_lib.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
590evp_lib.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
591evp_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
592evp_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
593evp_lib.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
594evp_lib.o: ../cryptlib.h evp_lib.c
595evp_pbe.o: ../../e_os.h ../../include/openssl/aes.h
596evp_pbe.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
597evp_pbe.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
598evp_pbe.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
599evp_pbe.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
600evp_pbe.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
601evp_pbe.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
602evp_pbe.o: ../../include/openssl/err.h ../../include/openssl/evp.h
603evp_pbe.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
604evp_pbe.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
605evp_pbe.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
606evp_pbe.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
607evp_pbe.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
608evp_pbe.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
609evp_pbe.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
610evp_pbe.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
611evp_pbe.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
612evp_pbe.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
613evp_pbe.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
614evp_pbe.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
615evp_pbe.o: ../../include/openssl/x509_vfy.h ../cryptlib.h evp_pbe.c
616evp_pkey.o: ../../e_os.h ../../include/openssl/aes.h
617evp_pkey.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
618evp_pkey.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
619evp_pkey.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
620evp_pkey.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
621evp_pkey.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
622evp_pkey.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
623evp_pkey.o: ../../include/openssl/err.h ../../include/openssl/evp.h
624evp_pkey.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
625evp_pkey.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
626evp_pkey.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
627evp_pkey.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
628evp_pkey.o: ../../include/openssl/opensslconf.h
629evp_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
630evp_pkey.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
631evp_pkey.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
632evp_pkey.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
633evp_pkey.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
634evp_pkey.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
635evp_pkey.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
636evp_pkey.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
637evp_pkey.o: ../../include/openssl/x509_vfy.h ../cryptlib.h evp_pkey.c
638m_dss.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
639m_dss.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
640m_dss.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
641m_dss.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
642m_dss.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
643m_dss.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
644m_dss.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
645m_dss.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
646m_dss.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
647m_dss.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
648m_dss.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
649m_dss.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
650m_dss.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
651m_dss.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
652m_dss.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
653m_dss.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
654m_dss.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
655m_dss.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
656m_dss.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
657m_dss.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
658m_dss.o: ../cryptlib.h m_dss.c
659m_dss1.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
660m_dss1.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
661m_dss1.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
662m_dss1.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
663m_dss1.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
664m_dss1.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
665m_dss1.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
666m_dss1.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
667m_dss1.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
668m_dss1.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
669m_dss1.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
670m_dss1.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
671m_dss1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
672m_dss1.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
673m_dss1.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
674m_dss1.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
675m_dss1.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
676m_dss1.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
677m_dss1.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
678m_dss1.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
679m_dss1.o: ../cryptlib.h m_dss1.c
680m_md2.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
681m_md2.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
682m_md2.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
683m_md2.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
684m_md2.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
685m_md2.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
686m_md2.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
687m_md2.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
688m_md2.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
689m_md2.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
690m_md2.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
691m_md2.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
692m_md2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
693m_md2.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
694m_md2.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
695m_md2.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
696m_md2.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
697m_md2.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
698m_md2.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
699m_md2.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
700m_md2.o: ../cryptlib.h m_md2.c
701m_md4.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
702m_md4.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
703m_md4.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
704m_md4.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
705m_md4.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
706m_md4.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
707m_md4.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
708m_md4.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
709m_md4.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
710m_md4.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
711m_md4.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
712m_md4.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
713m_md4.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
714m_md4.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
715m_md4.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
716m_md4.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
717m_md4.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
718m_md4.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
719m_md4.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
720m_md4.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
721m_md4.o: ../cryptlib.h m_md4.c
722m_md5.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
723m_md5.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
724m_md5.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
725m_md5.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
726m_md5.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
727m_md5.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
728m_md5.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
729m_md5.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
730m_md5.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
731m_md5.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
732m_md5.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
733m_md5.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
734m_md5.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
735m_md5.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
736m_md5.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
737m_md5.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
738m_md5.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
739m_md5.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
740m_md5.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
741m_md5.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
742m_md5.o: ../cryptlib.h m_md5.c
743m_mdc2.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
744m_mdc2.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
745m_mdc2.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
746m_mdc2.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
747m_mdc2.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
748m_mdc2.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
749m_mdc2.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
750m_mdc2.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
751m_mdc2.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
752m_mdc2.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
753m_mdc2.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
754m_mdc2.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
755m_mdc2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
756m_mdc2.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
757m_mdc2.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
758m_mdc2.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
759m_mdc2.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
760m_mdc2.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
761m_mdc2.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
762m_mdc2.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
763m_mdc2.o: ../cryptlib.h m_mdc2.c
764m_null.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
765m_null.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
766m_null.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
767m_null.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
768m_null.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
769m_null.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
770m_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
771m_null.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
772m_null.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
773m_null.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
774m_null.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
775m_null.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
776m_null.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
777m_null.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
778m_null.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
779m_null.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
780m_null.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
781m_null.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
782m_null.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
783m_null.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
784m_null.o: ../cryptlib.h m_null.c
785m_ripemd.o: ../../e_os.h ../../include/openssl/aes.h
786m_ripemd.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
787m_ripemd.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
788m_ripemd.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
789m_ripemd.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
790m_ripemd.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
791m_ripemd.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
792m_ripemd.o: ../../include/openssl/err.h ../../include/openssl/evp.h
793m_ripemd.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
794m_ripemd.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
795m_ripemd.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
796m_ripemd.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
797m_ripemd.o: ../../include/openssl/opensslconf.h
798m_ripemd.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
799m_ripemd.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
800m_ripemd.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
801m_ripemd.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
802m_ripemd.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
803m_ripemd.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
804m_ripemd.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
805m_ripemd.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
806m_ripemd.o: ../cryptlib.h m_ripemd.c
807m_sha.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
808m_sha.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
809m_sha.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
810m_sha.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
811m_sha.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
812m_sha.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
813m_sha.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
814m_sha.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
815m_sha.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
816m_sha.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
817m_sha.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
818m_sha.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
819m_sha.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
820m_sha.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
821m_sha.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
822m_sha.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
823m_sha.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
824m_sha.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
825m_sha.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
826m_sha.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
827m_sha.o: ../cryptlib.h m_sha.c
828m_sha1.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
829m_sha1.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
830m_sha1.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
831m_sha1.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
832m_sha1.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
833m_sha1.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
834m_sha1.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
835m_sha1.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
836m_sha1.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
837m_sha1.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
838m_sha1.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
839m_sha1.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
840m_sha1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
841m_sha1.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
842m_sha1.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
843m_sha1.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
844m_sha1.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
845m_sha1.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
846m_sha1.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
847m_sha1.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
848m_sha1.o: ../cryptlib.h m_sha1.c
849names.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
850names.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
851names.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
852names.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
853names.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
854names.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
855names.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
856names.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
857names.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
858names.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
859names.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
860names.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
861names.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
862names.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
863names.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
864names.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
865names.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
866names.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
867names.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
868names.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
869names.o: ../cryptlib.h names.c
870p5_crpt.o: ../../e_os.h ../../include/openssl/aes.h
871p5_crpt.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
872p5_crpt.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
873p5_crpt.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
874p5_crpt.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
875p5_crpt.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
876p5_crpt.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
877p5_crpt.o: ../../include/openssl/err.h ../../include/openssl/evp.h
878p5_crpt.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
879p5_crpt.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
880p5_crpt.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
881p5_crpt.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
882p5_crpt.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
883p5_crpt.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
884p5_crpt.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
885p5_crpt.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
886p5_crpt.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
887p5_crpt.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
888p5_crpt.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
889p5_crpt.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
890p5_crpt.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p5_crpt.c
891p5_crpt2.o: ../../e_os.h ../../include/openssl/aes.h
892p5_crpt2.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
893p5_crpt2.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
894p5_crpt2.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
895p5_crpt2.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
896p5_crpt2.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
897p5_crpt2.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
898p5_crpt2.o: ../../include/openssl/err.h ../../include/openssl/evp.h
899p5_crpt2.o: ../../include/openssl/hmac.h ../../include/openssl/idea.h
900p5_crpt2.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
901p5_crpt2.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
902p5_crpt2.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
903p5_crpt2.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
904p5_crpt2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
905p5_crpt2.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
906p5_crpt2.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
907p5_crpt2.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
908p5_crpt2.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
909p5_crpt2.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
910p5_crpt2.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
911p5_crpt2.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
912p5_crpt2.o: ../cryptlib.h p5_crpt2.c
913p_dec.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
914p_dec.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
915p_dec.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
916p_dec.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
917p_dec.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
918p_dec.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
919p_dec.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
920p_dec.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
921p_dec.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
922p_dec.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
923p_dec.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
924p_dec.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
925p_dec.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
926p_dec.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
927p_dec.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
928p_dec.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
929p_dec.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
930p_dec.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
931p_dec.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
932p_dec.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
933p_dec.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p_dec.c
934p_enc.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
935p_enc.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
936p_enc.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
937p_enc.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
938p_enc.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
939p_enc.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
940p_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
941p_enc.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
942p_enc.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
943p_enc.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
944p_enc.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
945p_enc.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
946p_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
947p_enc.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
948p_enc.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
949p_enc.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
950p_enc.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
951p_enc.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
952p_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
953p_enc.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
954p_enc.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p_enc.c
955p_lib.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
956p_lib.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h
957p_lib.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
958p_lib.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
959p_lib.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
960p_lib.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
961p_lib.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
962p_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h
963p_lib.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
964p_lib.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
965p_lib.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
966p_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
967p_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
968p_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
969p_lib.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
970p_lib.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
971p_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
972p_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
973p_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
974p_lib.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
975p_lib.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p_lib.c
976p_open.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
977p_open.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
978p_open.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
979p_open.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
980p_open.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
981p_open.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
982p_open.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
983p_open.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
984p_open.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
985p_open.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
986p_open.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
987p_open.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
988p_open.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
989p_open.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
990p_open.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
991p_open.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
992p_open.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
993p_open.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
994p_open.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
995p_open.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
996p_open.o: ../cryptlib.h p_open.c
997p_seal.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
998p_seal.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
999p_seal.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
1000p_seal.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
1001p_seal.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
1002p_seal.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
1003p_seal.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
1004p_seal.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
1005p_seal.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
1006p_seal.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
1007p_seal.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
1008p_seal.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
1009p_seal.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
1010p_seal.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
1011p_seal.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
1012p_seal.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
1013p_seal.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
1014p_seal.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
1015p_seal.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
1016p_seal.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
1017p_seal.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p_seal.c
1018p_sign.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/asn1.h
1019p_sign.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
1020p_sign.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
1021p_sign.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
1022p_sign.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
1023p_sign.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
1024p_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
1025p_sign.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
1026p_sign.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
1027p_sign.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
1028p_sign.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
1029p_sign.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
1030p_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
1031p_sign.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
1032p_sign.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
1033p_sign.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
1034p_sign.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
1035p_sign.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
1036p_sign.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
1037p_sign.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
1038p_sign.o: ../cryptlib.h p_sign.c
1039p_verify.o: ../../e_os.h ../../include/openssl/aes.h
1040p_verify.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
1041p_verify.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
1042p_verify.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
1043p_verify.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
1044p_verify.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
1045p_verify.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
1046p_verify.o: ../../include/openssl/err.h ../../include/openssl/evp.h
1047p_verify.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
1048p_verify.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
1049p_verify.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
1050p_verify.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
1051p_verify.o: ../../include/openssl/opensslconf.h
1052p_verify.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
1053p_verify.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
1054p_verify.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
1055p_verify.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
1056p_verify.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
1057p_verify.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
1058p_verify.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
1059p_verify.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
1060p_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 6e550f6a43..f12eac1b55 100644
--- a/src/lib/libcrypto/evp/bio_b64.c
+++ b/src/lib/libcrypto/evp/bio_b64.c
@@ -165,7 +165,6 @@ static int b64_read(BIO *b, char *out, int outl)
165 { 165 {
166 i=ctx->buf_len-ctx->buf_off; 166 i=ctx->buf_len-ctx->buf_off;
167 if (i > outl) i=outl; 167 if (i > outl) i=outl;
168 OPENSSL_assert(ctx->buf_off+i < sizeof ctx->buf);
169 memcpy(out,&(ctx->buf[ctx->buf_off]),i); 168 memcpy(out,&(ctx->buf[ctx->buf_off]),i);
170 ret=i; 169 ret=i;
171 out+=i; 170 out+=i;
diff --git a/src/lib/libcrypto/evp/bio_enc.c b/src/lib/libcrypto/evp/bio_enc.c
index ab81851503..64fb2353af 100644
--- a/src/lib/libcrypto/evp/bio_enc.c
+++ b/src/lib/libcrypto/evp/bio_enc.c
@@ -132,7 +132,7 @@ static int enc_free(BIO *a)
132 if (a == NULL) return(0); 132 if (a == NULL) return(0);
133 b=(BIO_ENC_CTX *)a->ptr; 133 b=(BIO_ENC_CTX *)a->ptr;
134 EVP_CIPHER_CTX_cleanup(&(b->cipher)); 134 EVP_CIPHER_CTX_cleanup(&(b->cipher));
135 OPENSSL_cleanse(a->ptr,sizeof(BIO_ENC_CTX)); 135 memset(a->ptr,0,sizeof(BIO_ENC_CTX));
136 OPENSSL_free(a->ptr); 136 OPENSSL_free(a->ptr);
137 a->ptr=NULL; 137 a->ptr=NULL;
138 a->init=0; 138 a->init=0;
@@ -271,7 +271,7 @@ static int enc_write(BIO *b, const char *in, int inl)
271 if (i <= 0) 271 if (i <= 0)
272 { 272 {
273 BIO_copy_next_retry(b); 273 BIO_copy_next_retry(b);
274 return (ret == inl) ? i : ret - inl; 274 return(i);
275 } 275 }
276 n-=i; 276 n-=i;
277 ctx->buf_off+=i; 277 ctx->buf_off+=i;
@@ -325,7 +325,10 @@ again:
325 { 325 {
326 i=enc_write(b,NULL,0); 326 i=enc_write(b,NULL,0);
327 if (i < 0) 327 if (i < 0)
328 return i; 328 {
329 ret=i;
330 break;
331 }
329 } 332 }
330 333
331 if (!ctx->finished) 334 if (!ctx->finished)
diff --git a/src/lib/libcrypto/evp/bio_ok.c b/src/lib/libcrypto/evp/bio_ok.c
new file mode 100644
index 0000000000..d2be03be82
--- /dev/null
+++ b/src/lib/libcrypto/evp/bio_ok.c
@@ -0,0 +1,575 @@
1/* crypto/evp/bio_ok.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/*
60 From: Arne Ansper <arne@cyber.ee>
61
62 Why BIO_f_reliable?
63
64 I wrote function which took BIO* as argument, read data from it
65 and processed it. Then I wanted to store the input file in
66 encrypted form. OK I pushed BIO_f_cipher to the BIO stack
67 and everything was OK. BUT if user types wrong password
68 BIO_f_cipher outputs only garbage and my function crashes. Yes
69 I can and I should fix my function, but BIO_f_cipher is
70 easy way to add encryption support to many existing applications
71 and it's hard to debug and fix them all.
72
73 So I wanted another BIO which would catch the incorrect passwords and
74 file damages which cause garbage on BIO_f_cipher's output.
75
76 The easy way is to push the BIO_f_md and save the checksum at
77 the end of the file. However there are several problems with this
78 approach:
79
80 1) you must somehow separate checksum from actual data.
81 2) you need lot's of memory when reading the file, because you
82 must read to the end of the file and verify the checksum before
83 letting the application to read the data.
84
85 BIO_f_reliable tries to solve both problems, so that you can
86 read and write arbitrary long streams using only fixed amount
87 of memory.
88
89 BIO_f_reliable splits data stream into blocks. Each block is prefixed
90 with it's length and suffixed with it's digest. So you need only
91 several Kbytes of memory to buffer single block before verifying
92 it's digest.
93
94 BIO_f_reliable goes further and adds several important capabilities:
95
96 1) the digest of the block is computed over the whole stream
97 -- so nobody can rearrange the blocks or remove or replace them.
98
99 2) to detect invalid passwords right at the start BIO_f_reliable
100 adds special prefix to the stream. In order to avoid known plain-text
101 attacks this prefix is generated as follows:
102
103 *) digest is initialized with random seed instead of
104 standardized one.
105 *) same seed is written to output
106 *) well-known text is then hashed and the output
107 of the digest is also written to output.
108
109 reader can now read the seed from stream, hash the same string
110 and then compare the digest output.
111
112 Bad things: BIO_f_reliable knows what's going on in EVP_Digest. I
113 initially wrote and tested this code on x86 machine and wrote the
114 digests out in machine-dependent order :( There are people using
115 this code and I cannot change this easily without making existing
116 data files unreadable.
117
118*/
119
120#include <stdio.h>
121#include <errno.h>
122#include "cryptlib.h"
123#include <openssl/buffer.h>
124#include <openssl/bio.h>
125#include <openssl/evp.h>
126#include <openssl/rand.h>
127
128static int ok_write(BIO *h, const char *buf, int num);
129static int ok_read(BIO *h, char *buf, int size);
130static long ok_ctrl(BIO *h, int cmd, long arg1, void *arg2);
131static int ok_new(BIO *h);
132static int ok_free(BIO *data);
133static long ok_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp);
134
135static void sig_out(BIO* b);
136static void sig_in(BIO* b);
137static void block_out(BIO* b);
138static void block_in(BIO* b);
139#define OK_BLOCK_SIZE (1024*4)
140#define OK_BLOCK_BLOCK 4
141#define IOBS (OK_BLOCK_SIZE+ OK_BLOCK_BLOCK+ 3*EVP_MAX_MD_SIZE)
142#define WELLKNOWN "The quick brown fox jumped over the lazy dog's back."
143
144#ifndef L_ENDIAN
145#define swapem(x) \
146 ((unsigned long int)((((unsigned long int)(x) & 0x000000ffU) << 24) | \
147 (((unsigned long int)(x) & 0x0000ff00U) << 8) | \
148 (((unsigned long int)(x) & 0x00ff0000U) >> 8) | \
149 (((unsigned long int)(x) & 0xff000000U) >> 24)))
150#else
151#define swapem(x) (x)
152#endif
153
154typedef struct ok_struct
155 {
156 int buf_len;
157 int buf_off;
158 int buf_len_save;
159 int buf_off_save;
160 int cont; /* <= 0 when finished */
161 int finished;
162 EVP_MD_CTX md;
163 int blockout; /* output block is ready */
164 int sigio; /* must process signature */
165 unsigned char buf[IOBS];
166 } BIO_OK_CTX;
167
168static BIO_METHOD methods_ok=
169 {
170 BIO_TYPE_CIPHER,"reliable",
171 ok_write,
172 ok_read,
173 NULL, /* ok_puts, */
174 NULL, /* ok_gets, */
175 ok_ctrl,
176 ok_new,
177 ok_free,
178 ok_callback_ctrl,
179 };
180
181BIO_METHOD *BIO_f_reliable(void)
182 {
183 return(&methods_ok);
184 }
185
186static int ok_new(BIO *bi)
187 {
188 BIO_OK_CTX *ctx;
189
190 ctx=(BIO_OK_CTX *)OPENSSL_malloc(sizeof(BIO_OK_CTX));
191 if (ctx == NULL) return(0);
192
193 ctx->buf_len=0;
194 ctx->buf_off=0;
195 ctx->buf_len_save=0;
196 ctx->buf_off_save=0;
197 ctx->cont=1;
198 ctx->finished=0;
199 ctx->blockout= 0;
200 ctx->sigio=1;
201
202 EVP_MD_CTX_init(&ctx->md);
203
204 bi->init=0;
205 bi->ptr=(char *)ctx;
206 bi->flags=0;
207 return(1);
208 }
209
210static int ok_free(BIO *a)
211 {
212 if (a == NULL) return(0);
213 EVP_MD_CTX_cleanup(&((BIO_OK_CTX *)a->ptr)->md);
214 memset(a->ptr,0,sizeof(BIO_OK_CTX));
215 OPENSSL_free(a->ptr);
216 a->ptr=NULL;
217 a->init=0;
218 a->flags=0;
219 return(1);
220 }
221
222static int ok_read(BIO *b, char *out, int outl)
223 {
224 int ret=0,i,n;
225 BIO_OK_CTX *ctx;
226
227 if (out == NULL) return(0);
228 ctx=(BIO_OK_CTX *)b->ptr;
229
230 if ((ctx == NULL) || (b->next_bio == NULL) || (b->init == 0)) return(0);
231
232 while(outl > 0)
233 {
234
235 /* copy clean bytes to output buffer */
236 if (ctx->blockout)
237 {
238 i=ctx->buf_len-ctx->buf_off;
239 if (i > outl) i=outl;
240 memcpy(out,&(ctx->buf[ctx->buf_off]),i);
241 ret+=i;
242 out+=i;
243 outl-=i;
244 ctx->buf_off+=i;
245
246 /* all clean bytes are out */
247 if (ctx->buf_len == ctx->buf_off)
248 {
249 ctx->buf_off=0;
250
251 /* copy start of the next block into proper place */
252 if(ctx->buf_len_save- ctx->buf_off_save > 0)
253 {
254 ctx->buf_len= ctx->buf_len_save- ctx->buf_off_save;
255 memmove(ctx->buf, &(ctx->buf[ctx->buf_off_save]),
256 ctx->buf_len);
257 }
258 else
259 {
260 ctx->buf_len=0;
261 }
262 ctx->blockout= 0;
263 }
264 }
265
266 /* output buffer full -- cancel */
267 if (outl == 0) break;
268
269 /* no clean bytes in buffer -- fill it */
270 n=IOBS- ctx->buf_len;
271 i=BIO_read(b->next_bio,&(ctx->buf[ctx->buf_len]),n);
272
273 if (i <= 0) break; /* nothing new */
274
275 ctx->buf_len+= i;
276
277 /* no signature yet -- check if we got one */
278 if (ctx->sigio == 1) sig_in(b);
279
280 /* signature ok -- check if we got block */
281 if (ctx->sigio == 0) block_in(b);
282
283 /* invalid block -- cancel */
284 if (ctx->cont <= 0) break;
285
286 }
287
288 BIO_clear_retry_flags(b);
289 BIO_copy_next_retry(b);
290 return(ret);
291 }
292
293static int ok_write(BIO *b, const char *in, int inl)
294 {
295 int ret=0,n,i;
296 BIO_OK_CTX *ctx;
297
298 ctx=(BIO_OK_CTX *)b->ptr;
299 ret=inl;
300
301 if ((ctx == NULL) || (b->next_bio == NULL) || (b->init == 0)) return(0);
302
303 if(ctx->sigio) sig_out(b);
304
305 do{
306 BIO_clear_retry_flags(b);
307 n=ctx->buf_len-ctx->buf_off;
308 while (ctx->blockout && n > 0)
309 {
310 i=BIO_write(b->next_bio,&(ctx->buf[ctx->buf_off]),n);
311 if (i <= 0)
312 {
313 BIO_copy_next_retry(b);
314 if(!BIO_should_retry(b))
315 ctx->cont= 0;
316 return(i);
317 }
318 ctx->buf_off+=i;
319 n-=i;
320 }
321
322 /* at this point all pending data has been written */
323 ctx->blockout= 0;
324 if (ctx->buf_len == ctx->buf_off)
325 {
326 ctx->buf_len=OK_BLOCK_BLOCK;
327 ctx->buf_off=0;
328 }
329
330 if ((in == NULL) || (inl <= 0)) return(0);
331
332 n= (inl+ ctx->buf_len > OK_BLOCK_SIZE+ OK_BLOCK_BLOCK) ?
333 OK_BLOCK_SIZE+ OK_BLOCK_BLOCK- ctx->buf_len : inl;
334
335 memcpy((unsigned char *)(&(ctx->buf[ctx->buf_len])),(unsigned char *)in,n);
336 ctx->buf_len+= n;
337 inl-=n;
338 in+=n;
339
340 if(ctx->buf_len >= OK_BLOCK_SIZE+ OK_BLOCK_BLOCK)
341 {
342 block_out(b);
343 }
344 }while(inl > 0);
345
346 BIO_clear_retry_flags(b);
347 BIO_copy_next_retry(b);
348 return(ret);
349 }
350
351static long ok_ctrl(BIO *b, int cmd, long num, void *ptr)
352 {
353 BIO_OK_CTX *ctx;
354 EVP_MD *md;
355 const EVP_MD **ppmd;
356 long ret=1;
357 int i;
358
359 ctx=b->ptr;
360
361 switch (cmd)
362 {
363 case BIO_CTRL_RESET:
364 ctx->buf_len=0;
365 ctx->buf_off=0;
366 ctx->buf_len_save=0;
367 ctx->buf_off_save=0;
368 ctx->cont=1;
369 ctx->finished=0;
370 ctx->blockout= 0;
371 ctx->sigio=1;
372 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
373 break;
374 case BIO_CTRL_EOF: /* More to read */
375 if (ctx->cont <= 0)
376 ret=1;
377 else
378 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
379 break;
380 case BIO_CTRL_PENDING: /* More to read in buffer */
381 case BIO_CTRL_WPENDING: /* More to read in buffer */
382 ret=ctx->blockout ? ctx->buf_len-ctx->buf_off : 0;
383 if (ret <= 0)
384 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
385 break;
386 case BIO_CTRL_FLUSH:
387 /* do a final write */
388 if(ctx->blockout == 0)
389 block_out(b);
390
391 while (ctx->blockout)
392 {
393 i=ok_write(b,NULL,0);
394 if (i < 0)
395 {
396 ret=i;
397 break;
398 }
399 }
400
401 ctx->finished=1;
402 ctx->buf_off=ctx->buf_len=0;
403 ctx->cont=(int)ret;
404
405 /* Finally flush the underlying BIO */
406 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
407 break;
408 case BIO_C_DO_STATE_MACHINE:
409 BIO_clear_retry_flags(b);
410 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
411 BIO_copy_next_retry(b);
412 break;
413 case BIO_CTRL_INFO:
414 ret=(long)ctx->cont;
415 break;
416 case BIO_C_SET_MD:
417 md=ptr;
418 EVP_DigestInit_ex(&ctx->md, md, NULL);
419 b->init=1;
420 break;
421 case BIO_C_GET_MD:
422 if (b->init)
423 {
424 ppmd=ptr;
425 *ppmd=ctx->md.digest;
426 }
427 else
428 ret=0;
429 break;
430 default:
431 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
432 break;
433 }
434 return(ret);
435 }
436
437static long ok_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp)
438 {
439 long ret=1;
440
441 if (b->next_bio == NULL) return(0);
442 switch (cmd)
443 {
444 default:
445 ret=BIO_callback_ctrl(b->next_bio,cmd,fp);
446 break;
447 }
448 return(ret);
449 }
450
451static void longswap(void *_ptr, int len)
452{
453#ifndef L_ENDIAN
454 int i;
455 char *ptr=_ptr;
456
457 for(i= 0;i < len;i+= 4){
458 *((unsigned long *)&(ptr[i]))= swapem(*((unsigned long *)&(ptr[i])));
459 }
460#endif
461}
462
463static void sig_out(BIO* b)
464 {
465 BIO_OK_CTX *ctx;
466 EVP_MD_CTX *md;
467
468 ctx=b->ptr;
469 md=&ctx->md;
470
471 if(ctx->buf_len+ 2* md->digest->md_size > OK_BLOCK_SIZE) return;
472
473 EVP_DigestInit_ex(md, md->digest, NULL);
474 /* FIXME: there's absolutely no guarantee this makes any sense at all,
475 * particularly now EVP_MD_CTX has been restructured.
476 */
477 RAND_pseudo_bytes(md->md_data, md->digest->md_size);
478 memcpy(&(ctx->buf[ctx->buf_len]), md->md_data, md->digest->md_size);
479 longswap(&(ctx->buf[ctx->buf_len]), md->digest->md_size);
480 ctx->buf_len+= md->digest->md_size;
481
482 EVP_DigestUpdate(md, WELLKNOWN, strlen(WELLKNOWN));
483 EVP_DigestFinal_ex(md, &(ctx->buf[ctx->buf_len]), NULL);
484 ctx->buf_len+= md->digest->md_size;
485 ctx->blockout= 1;
486 ctx->sigio= 0;
487 }
488
489static void sig_in(BIO* b)
490 {
491 BIO_OK_CTX *ctx;
492 EVP_MD_CTX *md;
493 unsigned char tmp[EVP_MAX_MD_SIZE];
494 int ret= 0;
495
496 ctx=b->ptr;
497 md=&ctx->md;
498
499 if(ctx->buf_len- ctx->buf_off < 2* md->digest->md_size) return;
500
501 EVP_DigestInit_ex(md, md->digest, NULL);
502 memcpy(md->md_data, &(ctx->buf[ctx->buf_off]), md->digest->md_size);
503 longswap(md->md_data, md->digest->md_size);
504 ctx->buf_off+= md->digest->md_size;
505
506 EVP_DigestUpdate(md, WELLKNOWN, strlen(WELLKNOWN));
507 EVP_DigestFinal_ex(md, tmp, NULL);
508 ret= memcmp(&(ctx->buf[ctx->buf_off]), tmp, md->digest->md_size) == 0;
509 ctx->buf_off+= md->digest->md_size;
510 if(ret == 1)
511 {
512 ctx->sigio= 0;
513 if(ctx->buf_len != ctx->buf_off)
514 {
515 memmove(ctx->buf, &(ctx->buf[ctx->buf_off]), ctx->buf_len- ctx->buf_off);
516 }
517 ctx->buf_len-= ctx->buf_off;
518 ctx->buf_off= 0;
519 }
520 else
521 {
522 ctx->cont= 0;
523 }
524 }
525
526static void block_out(BIO* b)
527 {
528 BIO_OK_CTX *ctx;
529 EVP_MD_CTX *md;
530 unsigned long tl;
531
532 ctx=b->ptr;
533 md=&ctx->md;
534
535 tl= ctx->buf_len- OK_BLOCK_BLOCK;
536 tl= swapem(tl);
537 memcpy(ctx->buf, &tl, OK_BLOCK_BLOCK);
538 tl= swapem(tl);
539 EVP_DigestUpdate(md, (unsigned char*) &(ctx->buf[OK_BLOCK_BLOCK]), tl);
540 EVP_DigestFinal_ex(md, &(ctx->buf[ctx->buf_len]), NULL);
541 ctx->buf_len+= md->digest->md_size;
542 ctx->blockout= 1;
543 }
544
545static void block_in(BIO* b)
546 {
547 BIO_OK_CTX *ctx;
548 EVP_MD_CTX *md;
549 long tl= 0;
550 unsigned char tmp[EVP_MAX_MD_SIZE];
551
552 ctx=b->ptr;
553 md=&ctx->md;
554
555 memcpy(&tl, ctx->buf, OK_BLOCK_BLOCK);
556 tl= swapem(tl);
557 if (ctx->buf_len < tl+ OK_BLOCK_BLOCK+ md->digest->md_size) return;
558
559 EVP_DigestUpdate(md, (unsigned char*) &(ctx->buf[OK_BLOCK_BLOCK]), tl);
560 EVP_DigestFinal_ex(md, tmp, NULL);
561 if(memcmp(&(ctx->buf[tl+ OK_BLOCK_BLOCK]), tmp, md->digest->md_size) == 0)
562 {
563 /* there might be parts from next block lurking around ! */
564 ctx->buf_off_save= tl+ OK_BLOCK_BLOCK+ md->digest->md_size;
565 ctx->buf_len_save= ctx->buf_len;
566 ctx->buf_off= OK_BLOCK_BLOCK;
567 ctx->buf_len= tl+ OK_BLOCK_BLOCK;
568 ctx->blockout= 1;
569 }
570 else
571 {
572 ctx->cont= 0;
573 }
574 }
575
diff --git a/src/lib/libcrypto/evp/c_all.c b/src/lib/libcrypto/evp/c_all.c
index 1b31a14e37..3d59812e20 100644
--- a/src/lib/libcrypto/evp/c_all.c
+++ b/src/lib/libcrypto/evp/c_all.c
@@ -73,9 +73,5 @@ void OPENSSL_add_all_algorithms_noconf(void)
73 { 73 {
74 OpenSSL_add_all_ciphers(); 74 OpenSSL_add_all_ciphers();
75 OpenSSL_add_all_digests(); 75 OpenSSL_add_all_digests();
76#ifndef OPENSSL_NO_ENGINE 76 ENGINE_setup_openbsd();
77# if defined(__OpenBSD__) || defined(__FreeBSD__)
78 ENGINE_setup_bsd_cryptodev();
79# endif
80#endif
81 } 77 }
diff --git a/src/lib/libcrypto/evp/c_allc.c b/src/lib/libcrypto/evp/c_allc.c
new file mode 100644
index 0000000000..341a958fd4
--- /dev/null
+++ b/src/lib/libcrypto/evp/c_allc.c
@@ -0,0 +1,180 @@
1/* crypto/evp/c_allc.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/pkcs12.h>
63#include <openssl/objects.h>
64
65void OpenSSL_add_all_ciphers(void)
66 {
67
68#ifndef OPENSSL_NO_DES
69 EVP_add_cipher(EVP_des_cfb());
70 EVP_add_cipher(EVP_des_ede_cfb());
71 EVP_add_cipher(EVP_des_ede3_cfb());
72
73 EVP_add_cipher(EVP_des_ofb());
74 EVP_add_cipher(EVP_des_ede_ofb());
75 EVP_add_cipher(EVP_des_ede3_ofb());
76
77 EVP_add_cipher(EVP_desx_cbc());
78 EVP_add_cipher_alias(SN_desx_cbc,"DESX");
79 EVP_add_cipher_alias(SN_desx_cbc,"desx");
80
81 EVP_add_cipher(EVP_des_cbc());
82 EVP_add_cipher_alias(SN_des_cbc,"DES");
83 EVP_add_cipher_alias(SN_des_cbc,"des");
84 EVP_add_cipher(EVP_des_ede_cbc());
85 EVP_add_cipher(EVP_des_ede3_cbc());
86 EVP_add_cipher_alias(SN_des_ede3_cbc,"DES3");
87 EVP_add_cipher_alias(SN_des_ede3_cbc,"des3");
88
89 EVP_add_cipher(EVP_des_ecb());
90 EVP_add_cipher(EVP_des_ede());
91 EVP_add_cipher(EVP_des_ede3());
92#endif
93
94#ifndef OPENSSL_NO_RC4
95 EVP_add_cipher(EVP_rc4());
96 EVP_add_cipher(EVP_rc4_40());
97#endif
98
99#ifndef OPENSSL_NO_IDEA
100 EVP_add_cipher(EVP_idea_ecb());
101 EVP_add_cipher(EVP_idea_cfb());
102 EVP_add_cipher(EVP_idea_ofb());
103 EVP_add_cipher(EVP_idea_cbc());
104 EVP_add_cipher_alias(SN_idea_cbc,"IDEA");
105 EVP_add_cipher_alias(SN_idea_cbc,"idea");
106#endif
107
108#ifndef OPENSSL_NO_RC2
109 EVP_add_cipher(EVP_rc2_ecb());
110 EVP_add_cipher(EVP_rc2_cfb());
111 EVP_add_cipher(EVP_rc2_ofb());
112 EVP_add_cipher(EVP_rc2_cbc());
113 EVP_add_cipher(EVP_rc2_40_cbc());
114 EVP_add_cipher(EVP_rc2_64_cbc());
115 EVP_add_cipher_alias(SN_rc2_cbc,"RC2");
116 EVP_add_cipher_alias(SN_rc2_cbc,"rc2");
117#endif
118
119#ifndef OPENSSL_NO_BF
120 EVP_add_cipher(EVP_bf_ecb());
121 EVP_add_cipher(EVP_bf_cfb());
122 EVP_add_cipher(EVP_bf_ofb());
123 EVP_add_cipher(EVP_bf_cbc());
124 EVP_add_cipher_alias(SN_bf_cbc,"BF");
125 EVP_add_cipher_alias(SN_bf_cbc,"bf");
126 EVP_add_cipher_alias(SN_bf_cbc,"blowfish");
127#endif
128
129#ifndef OPENSSL_NO_CAST
130 EVP_add_cipher(EVP_cast5_ecb());
131 EVP_add_cipher(EVP_cast5_cfb());
132 EVP_add_cipher(EVP_cast5_ofb());
133 EVP_add_cipher(EVP_cast5_cbc());
134 EVP_add_cipher_alias(SN_cast5_cbc,"CAST");
135 EVP_add_cipher_alias(SN_cast5_cbc,"cast");
136 EVP_add_cipher_alias(SN_cast5_cbc,"CAST-cbc");
137 EVP_add_cipher_alias(SN_cast5_cbc,"cast-cbc");
138#endif
139
140#ifndef OPENSSL_NO_RC5
141 EVP_add_cipher(EVP_rc5_32_12_16_ecb());
142 EVP_add_cipher(EVP_rc5_32_12_16_cfb());
143 EVP_add_cipher(EVP_rc5_32_12_16_ofb());
144 EVP_add_cipher(EVP_rc5_32_12_16_cbc());
145 EVP_add_cipher_alias(SN_rc5_cbc,"rc5");
146 EVP_add_cipher_alias(SN_rc5_cbc,"RC5");
147#endif
148
149#ifndef OPENSSL_NO_AES
150 EVP_add_cipher(EVP_aes_128_ecb());
151 EVP_add_cipher(EVP_aes_128_cbc());
152 EVP_add_cipher(EVP_aes_128_cfb());
153 EVP_add_cipher(EVP_aes_128_ofb());
154#if 0
155 EVP_add_cipher(EVP_aes_128_ctr());
156#endif
157 EVP_add_cipher_alias(SN_aes_128_cbc,"AES128");
158 EVP_add_cipher_alias(SN_aes_128_cbc,"aes128");
159 EVP_add_cipher(EVP_aes_192_ecb());
160 EVP_add_cipher(EVP_aes_192_cbc());
161 EVP_add_cipher(EVP_aes_192_cfb());
162 EVP_add_cipher(EVP_aes_192_ofb());
163#if 0
164 EVP_add_cipher(EVP_aes_192_ctr());
165#endif
166 EVP_add_cipher_alias(SN_aes_192_cbc,"AES192");
167 EVP_add_cipher_alias(SN_aes_192_cbc,"aes192");
168 EVP_add_cipher(EVP_aes_256_ecb());
169 EVP_add_cipher(EVP_aes_256_cbc());
170 EVP_add_cipher(EVP_aes_256_cfb());
171 EVP_add_cipher(EVP_aes_256_ofb());
172#if 0
173 EVP_add_cipher(EVP_aes_256_ctr());
174#endif
175 EVP_add_cipher_alias(SN_aes_256_cbc,"AES256");
176 EVP_add_cipher_alias(SN_aes_256_cbc,"aes256");
177#endif
178 PKCS12_PBE_add();
179 PKCS5_PBE_add();
180 }
diff --git a/src/lib/libcrypto/evp/c_alld.c b/src/lib/libcrypto/evp/c_alld.c
new file mode 100644
index 0000000000..be91cdb037
--- /dev/null
+++ b/src/lib/libcrypto/evp/c_alld.c
@@ -0,0 +1,103 @@
1/* crypto/evp/c_alld.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/pkcs12.h>
63#include <openssl/objects.h>
64
65void OpenSSL_add_all_digests(void)
66 {
67#ifndef OPENSSL_NO_MD2
68 EVP_add_digest(EVP_md2());
69#endif
70#ifndef OPENSSL_NO_MD4
71 EVP_add_digest(EVP_md4());
72#endif
73#ifndef OPENSSL_NO_MD5
74 EVP_add_digest(EVP_md5());
75 EVP_add_digest_alias(SN_md5,"ssl2-md5");
76 EVP_add_digest_alias(SN_md5,"ssl3-md5");
77#endif
78#ifndef OPENSSL_NO_SHA
79 EVP_add_digest(EVP_sha());
80#ifndef OPENSSL_NO_DSA
81 EVP_add_digest(EVP_dss());
82#endif
83#endif
84#ifndef OPENSSL_NO_SHA
85 EVP_add_digest(EVP_sha1());
86 EVP_add_digest_alias(SN_sha1,"ssl3-sha1");
87 EVP_add_digest_alias(SN_sha1WithRSAEncryption,SN_sha1WithRSA);
88#ifndef OPENSSL_NO_DSA
89 EVP_add_digest(EVP_dss1());
90 EVP_add_digest_alias(SN_dsaWithSHA1,SN_dsaWithSHA1_2);
91 EVP_add_digest_alias(SN_dsaWithSHA1,"DSS1");
92 EVP_add_digest_alias(SN_dsaWithSHA1,"dss1");
93#endif
94#endif
95#if !defined(OPENSSL_NO_MDC2) && !defined(OPENSSL_NO_DES)
96 EVP_add_digest(EVP_mdc2());
97#endif
98#ifndef OPENSSL_NO_RIPEMD
99 EVP_add_digest(EVP_ripemd160());
100 EVP_add_digest_alias(SN_ripemd160,"ripemd");
101 EVP_add_digest_alias(SN_ripemd160,"rmd160");
102#endif
103 }
diff --git a/src/lib/libcrypto/evp/digest.c b/src/lib/libcrypto/evp/digest.c
index b22eed4421..a969ac69ed 100644
--- a/src/lib/libcrypto/evp/digest.c
+++ b/src/lib/libcrypto/evp/digest.c
@@ -113,9 +113,7 @@
113#include "cryptlib.h" 113#include "cryptlib.h"
114#include <openssl/objects.h> 114#include <openssl/objects.h>
115#include <openssl/evp.h> 115#include <openssl/evp.h>
116#ifndef OPENSSL_NO_ENGINE
117#include <openssl/engine.h> 116#include <openssl/engine.h>
118#endif
119 117
120void EVP_MD_CTX_init(EVP_MD_CTX *ctx) 118void EVP_MD_CTX_init(EVP_MD_CTX *ctx)
121 { 119 {
@@ -140,7 +138,6 @@ int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type)
140int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl) 138int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl)
141 { 139 {
142 EVP_MD_CTX_clear_flags(ctx,EVP_MD_CTX_FLAG_CLEANED); 140 EVP_MD_CTX_clear_flags(ctx,EVP_MD_CTX_FLAG_CLEANED);
143#ifndef OPENSSL_NO_ENGINE
144 /* Whether it's nice or not, "Inits" can be used on "Final"'d contexts 141 /* Whether it's nice or not, "Inits" can be used on "Final"'d contexts
145 * so this context may already have an ENGINE! Try to avoid releasing 142 * so this context may already have an ENGINE! Try to avoid releasing
146 * the previous handle, re-querying for an ENGINE, and having a 143 * the previous handle, re-querying for an ENGINE, and having a
@@ -186,13 +183,11 @@ int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl)
186 else 183 else
187 ctx->engine = NULL; 184 ctx->engine = NULL;
188 } 185 }
189 else 186 else if(!ctx->digest)
190 if(!ctx->digest)
191 { 187 {
192 EVPerr(EVP_F_EVP_DIGESTINIT, EVP_R_NO_DIGEST_SET); 188 EVPerr(EVP_F_EVP_DIGESTINIT, EVP_R_NO_DIGEST_SET);
193 return 0; 189 return 0;
194 } 190 }
195#endif
196 if (ctx->digest != type) 191 if (ctx->digest != type)
197 { 192 {
198 if (ctx->digest && ctx->digest->ctx_size) 193 if (ctx->digest && ctx->digest->ctx_size)
@@ -201,9 +196,7 @@ int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl)
201 if (type->ctx_size) 196 if (type->ctx_size)
202 ctx->md_data=OPENSSL_malloc(type->ctx_size); 197 ctx->md_data=OPENSSL_malloc(type->ctx_size);
203 } 198 }
204#ifndef OPENSSL_NO_ENGINE
205skip_to_init: 199skip_to_init:
206#endif
207 return ctx->digest->init(ctx); 200 return ctx->digest->init(ctx);
208 } 201 }
209 202
@@ -226,8 +219,6 @@ int EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size)
226int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size) 219int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size)
227 { 220 {
228 int ret; 221 int ret;
229
230 OPENSSL_assert(ctx->digest->md_size <= EVP_MAX_MD_SIZE);
231 ret=ctx->digest->final(ctx,md); 222 ret=ctx->digest->final(ctx,md);
232 if (size != NULL) 223 if (size != NULL)
233 *size=ctx->digest->md_size; 224 *size=ctx->digest->md_size;
@@ -253,14 +244,12 @@ int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in)
253 EVPerr(EVP_F_EVP_MD_CTX_COPY,EVP_R_INPUT_NOT_INITIALIZED); 244 EVPerr(EVP_F_EVP_MD_CTX_COPY,EVP_R_INPUT_NOT_INITIALIZED);
254 return 0; 245 return 0;
255 } 246 }
256#ifndef OPENSSL_NO_ENGINE
257 /* Make sure it's safe to copy a digest context using an ENGINE */ 247 /* Make sure it's safe to copy a digest context using an ENGINE */
258 if (in->engine && !ENGINE_init(in->engine)) 248 if (in->engine && !ENGINE_init(in->engine))
259 { 249 {
260 EVPerr(EVP_F_EVP_MD_CTX_COPY,ERR_R_ENGINE_LIB); 250 EVPerr(EVP_F_EVP_MD_CTX_COPY,ERR_R_ENGINE_LIB);
261 return 0; 251 return 0;
262 } 252 }
263#endif
264 253
265 EVP_MD_CTX_cleanup(out); 254 EVP_MD_CTX_cleanup(out);
266 memcpy(out,in,sizeof *out); 255 memcpy(out,in,sizeof *out);
@@ -310,15 +299,13 @@ int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx)
310 ctx->digest->cleanup(ctx); 299 ctx->digest->cleanup(ctx);
311 if (ctx->digest && ctx->digest->ctx_size && ctx->md_data) 300 if (ctx->digest && ctx->digest->ctx_size && ctx->md_data)
312 { 301 {
313 OPENSSL_cleanse(ctx->md_data,ctx->digest->ctx_size); 302 memset(ctx->md_data,0,ctx->digest->ctx_size);
314 OPENSSL_free(ctx->md_data); 303 OPENSSL_free(ctx->md_data);
315 } 304 }
316#ifndef OPENSSL_NO_ENGINE
317 if(ctx->engine) 305 if(ctx->engine)
318 /* The EVP_MD we used belongs to an ENGINE, release the 306 /* The EVP_MD we used belongs to an ENGINE, release the
319 * functional reference we held for this reason. */ 307 * functional reference we held for this reason. */
320 ENGINE_finish(ctx->engine); 308 ENGINE_finish(ctx->engine);
321#endif
322 memset(ctx,'\0',sizeof *ctx); 309 memset(ctx,'\0',sizeof *ctx);
323 310
324 return 1; 311 return 1;
diff --git a/src/lib/libcrypto/evp/e_aes.c b/src/lib/libcrypto/evp/e_aes.c
index fe8bcda631..c323fa2892 100644
--- a/src/lib/libcrypto/evp/e_aes.c
+++ b/src/lib/libcrypto/evp/e_aes.c
@@ -52,6 +52,7 @@
52#include <openssl/evp.h> 52#include <openssl/evp.h>
53#include <openssl/err.h> 53#include <openssl/err.h>
54#include <string.h> 54#include <string.h>
55#include <assert.h>
55#include <openssl/aes.h> 56#include <openssl/aes.h>
56#include "evp_locl.h" 57#include "evp_locl.h"
57 58
diff --git a/src/lib/libcrypto/evp/e_dsa.c b/src/lib/libcrypto/evp/e_dsa.c
new file mode 100644
index 0000000000..b96f2738b3
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_dsa.c
@@ -0,0 +1,71 @@
1/* crypto/evp/e_dsa.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/objects.h>
63#include <openssl/x509.h>
64
65static EVP_PKEY_METHOD dss_method=
66 {
67 DSA_sign,
68 DSA_verify,
69 {EVP_PKEY_DSA,EVP_PKEY_DSA2,EVP_PKEY_DSA3,NULL},
70 };
71
diff --git a/src/lib/libcrypto/evp/e_idea.c b/src/lib/libcrypto/evp/e_idea.c
index b9efa75ae7..ed838d3e62 100644
--- a/src/lib/libcrypto/evp/e_idea.c
+++ b/src/lib/libcrypto/evp/e_idea.c
@@ -109,7 +109,7 @@ static int idea_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
109 109
110 idea_set_encrypt_key(key,&tmp); 110 idea_set_encrypt_key(key,&tmp);
111 idea_set_decrypt_key(&tmp,ctx->cipher_data); 111 idea_set_decrypt_key(&tmp,ctx->cipher_data);
112 OPENSSL_cleanse((unsigned char *)&tmp, 112 memset((unsigned char *)&tmp,0,
113 sizeof(IDEA_KEY_SCHEDULE)); 113 sizeof(IDEA_KEY_SCHEDULE));
114 } 114 }
115 return 1; 115 return 1;
diff --git a/src/lib/libcrypto/evp/e_rc2.c b/src/lib/libcrypto/evp/e_rc2.c
index d42cbfd17e..4685198e2e 100644
--- a/src/lib/libcrypto/evp/e_rc2.c
+++ b/src/lib/libcrypto/evp/e_rc2.c
@@ -174,7 +174,6 @@ static int rc2_get_asn1_type_and_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
174 if (type != NULL) 174 if (type != NULL)
175 { 175 {
176 l=EVP_CIPHER_CTX_iv_length(c); 176 l=EVP_CIPHER_CTX_iv_length(c);
177 OPENSSL_assert(l <= sizeof iv);
178 i=ASN1_TYPE_get_int_octetstring(type,&num,iv,l); 177 i=ASN1_TYPE_get_int_octetstring(type,&num,iv,l);
179 if (i != l) 178 if (i != l)
180 return(-1); 179 return(-1);
diff --git a/src/lib/libcrypto/evp/e_rc4.c b/src/lib/libcrypto/evp/e_rc4.c
index d58f507837..4064cc5fa0 100644
--- a/src/lib/libcrypto/evp/e_rc4.c
+++ b/src/lib/libcrypto/evp/e_rc4.c
@@ -69,6 +69,8 @@
69 69
70typedef struct 70typedef struct
71 { 71 {
72 /* FIXME: what is the key for? */
73 unsigned char key[EVP_RC4_KEY_SIZE];
72 RC4_KEY ks; /* working key */ 74 RC4_KEY ks; /* working key */
73 } EVP_RC4_KEY; 75 } EVP_RC4_KEY;
74 76
@@ -119,8 +121,9 @@ const EVP_CIPHER *EVP_rc4_40(void)
119static int rc4_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 121static int rc4_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
120 const unsigned char *iv, int enc) 122 const unsigned char *iv, int enc)
121 { 123 {
124 memcpy(&data(ctx)->key[0],key,EVP_CIPHER_CTX_key_length(ctx));
122 RC4_set_key(&data(ctx)->ks,EVP_CIPHER_CTX_key_length(ctx), 125 RC4_set_key(&data(ctx)->ks,EVP_CIPHER_CTX_key_length(ctx),
123 key); 126 data(ctx)->key);
124 return 1; 127 return 1;
125 } 128 }
126 129
diff --git a/src/lib/libcrypto/evp/e_rc5.c b/src/lib/libcrypto/evp/e_rc5.c
new file mode 100644
index 0000000000..3c7713b181
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_rc5.c
@@ -0,0 +1,125 @@
1/* crypto/evp/e_rc5.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 OPENSSL_NO_RC5
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include <openssl/evp.h>
64#include <openssl/objects.h>
65#include "evp_locl.h"
66#include <openssl/rc5.h>
67
68static int r_32_12_16_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
69 const unsigned char *iv,int enc);
70static int rc5_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr);
71
72typedef struct
73 {
74 int rounds; /* number of rounds */
75 RC5_32_KEY ks; /* key schedule */
76 } EVP_RC5_KEY;
77
78#define data(ctx) EVP_C_DATA(EVP_RC5_KEY,ctx)
79
80IMPLEMENT_BLOCK_CIPHER(rc5_32_12_16, ks, RC5_32, EVP_RC5_KEY, NID_rc5,
81 8, RC5_32_KEY_LENGTH, 8, 64,
82 EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT,
83 r_32_12_16_init_key, NULL,
84 NULL, NULL, rc5_ctrl)
85
86static int rc5_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)
87 {
88 switch(type)
89 {
90 case EVP_CTRL_INIT:
91 data(c)->rounds = RC5_12_ROUNDS;
92 return 1;
93
94 case EVP_CTRL_GET_RC5_ROUNDS:
95 *(int *)ptr = data(c)->rounds;
96 return 1;
97
98 case EVP_CTRL_SET_RC5_ROUNDS:
99 switch(arg)
100 {
101 case RC5_8_ROUNDS:
102 case RC5_12_ROUNDS:
103 case RC5_16_ROUNDS:
104 data(c)->rounds = arg;
105 return 1;
106
107 default:
108 EVPerr(EVP_F_RC5_CTRL, EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS);
109 return 0;
110 }
111
112 default:
113 return -1;
114 }
115 }
116
117static int r_32_12_16_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
118 const unsigned char *iv, int enc)
119 {
120 RC5_32_set_key(&data(ctx)->ks,EVP_CIPHER_CTX_key_length(ctx),
121 key,data(ctx)->rounds);
122 return 1;
123 }
124
125#endif
diff --git a/src/lib/libcrypto/evp/encode.c b/src/lib/libcrypto/evp/encode.c
index 08209357ce..12c6379df1 100644
--- a/src/lib/libcrypto/evp/encode.c
+++ b/src/lib/libcrypto/evp/encode.c
@@ -136,7 +136,6 @@ void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,
136 136
137 *outl=0; 137 *outl=0;
138 if (inl == 0) return; 138 if (inl == 0) return;
139 OPENSSL_assert(ctx->length <= sizeof ctx->enc_data);
140 if ((ctx->num+inl) < ctx->length) 139 if ((ctx->num+inl) < ctx->length)
141 { 140 {
142 memcpy(&(ctx->enc_data[ctx->num]),in,inl); 141 memcpy(&(ctx->enc_data[ctx->num]),in,inl);
@@ -259,7 +258,6 @@ int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,
259 /* only save the good data :-) */ 258 /* only save the good data :-) */
260 if (!B64_NOT_BASE64(v)) 259 if (!B64_NOT_BASE64(v))
261 { 260 {
262 OPENSSL_assert(n < sizeof ctx->enc_data);
263 d[n++]=tmp; 261 d[n++]=tmp;
264 ln++; 262 ln++;
265 } 263 }
diff --git a/src/lib/libcrypto/evp/evp.h b/src/lib/libcrypto/evp/evp.h
index 45a25f968d..7b234d0ad6 100644
--- a/src/lib/libcrypto/evp/evp.h
+++ b/src/lib/libcrypto/evp/evp.h
@@ -74,48 +74,6 @@
74#ifndef OPENSSL_NO_BIO 74#ifndef OPENSSL_NO_BIO
75#include <openssl/bio.h> 75#include <openssl/bio.h>
76#endif 76#endif
77#ifndef OPENSSL_NO_MD2
78#include <openssl/md2.h>
79#endif
80#ifndef OPENSSL_NO_MD4
81#include <openssl/md4.h>
82#endif
83#ifndef OPENSSL_NO_MD5
84#include <openssl/md5.h>
85#endif
86#ifndef OPENSSL_NO_SHA
87#include <openssl/sha.h>
88#endif
89#ifndef OPENSSL_NO_RIPEMD
90#include <openssl/ripemd.h>
91#endif
92#ifndef OPENSSL_NO_DES
93#include <openssl/des.h>
94#endif
95#ifndef OPENSSL_NO_RC4
96#include <openssl/rc4.h>
97#endif
98#ifndef OPENSSL_NO_RC2
99#include <openssl/rc2.h>
100#endif
101#ifndef OPENSSL_NO_RC5
102#include <openssl/rc5.h>
103#endif
104#ifndef OPENSSL_NO_BF
105#include <openssl/blowfish.h>
106#endif
107#ifndef OPENSSL_NO_CAST
108#include <openssl/cast.h>
109#endif
110#ifndef OPENSSL_NO_IDEA
111#include <openssl/idea.h>
112#endif
113#ifndef OPENSSL_NO_MDC2
114#include <openssl/mdc2.h>
115#endif
116#ifndef OPENSSL_NO_AES
117#include <openssl/aes.h>
118#endif
119 77
120/* 78/*
121#define EVP_RC2_KEY_SIZE 16 79#define EVP_RC2_KEY_SIZE 16
@@ -133,18 +91,6 @@
133/* Default PKCS#5 iteration count */ 91/* Default PKCS#5 iteration count */
134#define PKCS5_DEFAULT_ITER 2048 92#define PKCS5_DEFAULT_ITER 2048
135 93
136#ifndef OPENSSL_NO_RSA
137#include <openssl/rsa.h>
138#endif
139
140#ifndef OPENSSL_NO_DSA
141#include <openssl/dsa.h>
142#endif
143
144#ifndef OPENSSL_NO_DH
145#include <openssl/dh.h>
146#endif
147
148#include <openssl/objects.h> 94#include <openssl/objects.h>
149 95
150#define EVP_PK_RSA 0x0001 96#define EVP_PK_RSA 0x0001
diff --git a/src/lib/libcrypto/evp/evp_acnf.c b/src/lib/libcrypto/evp/evp_acnf.c
new file mode 100644
index 0000000000..a68b979bdb
--- /dev/null
+++ b/src/lib/libcrypto/evp/evp_acnf.c
@@ -0,0 +1,74 @@
1/* evp_acnf.c */
2/* Written by Stephen Henson (shenson@bigfoot.com) for the OpenSSL
3 * project 2001.
4 */
5/* ====================================================================
6 * Copyright (c) 2001 The OpenSSL Project. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * 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 "cryptlib.h"
60#include <openssl/evp.h>
61#include <openssl/conf.h>
62#include <openssl/engine.h>
63
64
65/* Load all algorithms and configure OpenSSL.
66 * This function is called automatically when
67 * OPENSSL_LOAD_CONF is set.
68 */
69
70void OPENSSL_add_all_algorithms_conf(void)
71 {
72 OPENSSL_add_all_algorithms_noconf();
73 OPENSSL_config(NULL);
74 }
diff --git a/src/lib/libcrypto/evp/evp_enc.c b/src/lib/libcrypto/evp/evp_enc.c
index be0758a879..32a1c7a2e9 100644
--- a/src/lib/libcrypto/evp/evp_enc.c
+++ b/src/lib/libcrypto/evp/evp_enc.c
@@ -60,11 +60,11 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/evp.h> 61#include <openssl/evp.h>
62#include <openssl/err.h> 62#include <openssl/err.h>
63#ifndef OPENSSL_NO_ENGINE
64#include <openssl/engine.h> 63#include <openssl/engine.h>
65#endif
66#include "evp_locl.h" 64#include "evp_locl.h"
67 65
66#include <assert.h>
67
68const char *EVP_version="EVP" OPENSSL_VERSION_PTEXT; 68const char *EVP_version="EVP" OPENSSL_VERSION_PTEXT;
69 69
70void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *ctx) 70void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *ctx)
@@ -93,7 +93,6 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *imp
93 enc = 1; 93 enc = 1;
94 ctx->encrypt = enc; 94 ctx->encrypt = enc;
95 } 95 }
96#ifndef OPENSSL_NO_ENGINE
97 /* Whether it's nice or not, "Inits" can be used on "Final"'d contexts 96 /* Whether it's nice or not, "Inits" can be used on "Final"'d contexts
98 * so this context may already have an ENGINE! Try to avoid releasing 97 * so this context may already have an ENGINE! Try to avoid releasing
99 * the previous handle, re-querying for an ENGINE, and having a 98 * the previous handle, re-querying for an ENGINE, and having a
@@ -101,7 +100,6 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *imp
101 if (ctx->engine && ctx->cipher && (!cipher || 100 if (ctx->engine && ctx->cipher && (!cipher ||
102 (cipher && (cipher->nid == ctx->cipher->nid)))) 101 (cipher && (cipher->nid == ctx->cipher->nid))))
103 goto skip_to_init; 102 goto skip_to_init;
104#endif
105 if (cipher) 103 if (cipher)
106 { 104 {
107 /* Ensure a context left lying around from last time is cleared 105 /* Ensure a context left lying around from last time is cleared
@@ -111,7 +109,6 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *imp
111 109
112 /* Restore encrypt field: it is zeroed by cleanup */ 110 /* Restore encrypt field: it is zeroed by cleanup */
113 ctx->encrypt = enc; 111 ctx->encrypt = enc;
114#ifndef OPENSSL_NO_ENGINE
115 if(impl) 112 if(impl)
116 { 113 {
117 if (!ENGINE_init(impl)) 114 if (!ENGINE_init(impl))
@@ -145,7 +142,6 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *imp
145 } 142 }
146 else 143 else
147 ctx->engine = NULL; 144 ctx->engine = NULL;
148#endif
149 145
150 ctx->cipher=cipher; 146 ctx->cipher=cipher;
151 ctx->cipher_data=OPENSSL_malloc(ctx->cipher->ctx_size); 147 ctx->cipher_data=OPENSSL_malloc(ctx->cipher->ctx_size);
@@ -165,13 +161,11 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *imp
165 EVPerr(EVP_F_EVP_CIPHERINIT, EVP_R_NO_CIPHER_SET); 161 EVPerr(EVP_F_EVP_CIPHERINIT, EVP_R_NO_CIPHER_SET);
166 return 0; 162 return 0;
167 } 163 }
168#ifndef OPENSSL_NO_ENGINE
169skip_to_init: 164skip_to_init:
170#endif
171 /* we assume block size is a power of 2 in *cryptUpdate */ 165 /* we assume block size is a power of 2 in *cryptUpdate */
172 OPENSSL_assert(ctx->cipher->block_size == 1 166 assert(ctx->cipher->block_size == 1
173 || ctx->cipher->block_size == 8 167 || ctx->cipher->block_size == 8
174 || ctx->cipher->block_size == 16); 168 || ctx->cipher->block_size == 16);
175 169
176 if(!(EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_CUSTOM_IV)) { 170 if(!(EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_CUSTOM_IV)) {
177 switch(EVP_CIPHER_CTX_mode(ctx)) { 171 switch(EVP_CIPHER_CTX_mode(ctx)) {
@@ -187,7 +181,6 @@ skip_to_init:
187 181
188 case EVP_CIPH_CBC_MODE: 182 case EVP_CIPH_CBC_MODE:
189 183
190 OPENSSL_assert(EVP_CIPHER_CTX_iv_length(ctx) <= sizeof ctx->iv);
191 if(iv) memcpy(ctx->oiv, iv, EVP_CIPHER_CTX_iv_length(ctx)); 184 if(iv) memcpy(ctx->oiv, iv, EVP_CIPHER_CTX_iv_length(ctx));
192 memcpy(ctx->iv, ctx->oiv, EVP_CIPHER_CTX_iv_length(ctx)); 185 memcpy(ctx->iv, ctx->oiv, EVP_CIPHER_CTX_iv_length(ctx));
193 break; 186 break;
@@ -244,7 +237,7 @@ int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *imp
244int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, 237int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
245 const unsigned char *key, const unsigned char *iv) 238 const unsigned char *key, const unsigned char *iv)
246 { 239 {
247 return EVP_CipherInit(ctx, cipher, key, iv, 0); 240 return EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, 0);
248 } 241 }
249 242
250int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl, 243int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl,
@@ -258,7 +251,6 @@ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
258 { 251 {
259 int i,j,bl; 252 int i,j,bl;
260 253
261 OPENSSL_assert(inl > 0);
262 if(ctx->buf_len == 0 && (inl&(ctx->block_mask)) == 0) 254 if(ctx->buf_len == 0 && (inl&(ctx->block_mask)) == 0)
263 { 255 {
264 if(ctx->cipher->do_cipher(ctx,out,in,inl)) 256 if(ctx->cipher->do_cipher(ctx,out,in,inl))
@@ -274,7 +266,6 @@ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
274 } 266 }
275 i=ctx->buf_len; 267 i=ctx->buf_len;
276 bl=ctx->cipher->block_size; 268 bl=ctx->cipher->block_size;
277 OPENSSL_assert(bl <= sizeof ctx->buf);
278 if (i != 0) 269 if (i != 0)
279 { 270 {
280 if (i+inl < bl) 271 if (i+inl < bl)
@@ -323,7 +314,6 @@ int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
323 int i,n,b,bl,ret; 314 int i,n,b,bl,ret;
324 315
325 b=ctx->cipher->block_size; 316 b=ctx->cipher->block_size;
326 OPENSSL_assert(b <= sizeof ctx->buf);
327 if (b == 1) 317 if (b == 1)
328 { 318 {
329 *outl=0; 319 *outl=0;
@@ -368,7 +358,6 @@ int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
368 return EVP_EncryptUpdate(ctx, out, outl, in, inl); 358 return EVP_EncryptUpdate(ctx, out, outl, in, inl);
369 359
370 b=ctx->cipher->block_size; 360 b=ctx->cipher->block_size;
371 OPENSSL_assert(b <= sizeof ctx->final);
372 361
373 if(ctx->final_used) 362 if(ctx->final_used)
374 { 363 {
@@ -431,7 +420,6 @@ int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
431 EVPerr(EVP_F_EVP_DECRYPTFINAL,EVP_R_WRONG_FINAL_BLOCK_LENGTH); 420 EVPerr(EVP_F_EVP_DECRYPTFINAL,EVP_R_WRONG_FINAL_BLOCK_LENGTH);
432 return(0); 421 return(0);
433 } 422 }
434 OPENSSL_assert(b <= sizeof ctx->final);
435 n=ctx->final[b-1]; 423 n=ctx->final[b-1];
436 if (n > b) 424 if (n > b)
437 { 425 {
@@ -462,18 +450,16 @@ int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *c)
462 { 450 {
463 if(c->cipher->cleanup && !c->cipher->cleanup(c)) 451 if(c->cipher->cleanup && !c->cipher->cleanup(c))
464 return 0; 452 return 0;
465 /* Cleanse cipher context data */ 453 /* Zero cipher context data */
466 if (c->cipher_data) 454 if (c->cipher_data)
467 OPENSSL_cleanse(c->cipher_data, c->cipher->ctx_size); 455 memset(c->cipher_data, 0, c->cipher->ctx_size);
468 } 456 }
469 if (c->cipher_data) 457 if (c->cipher_data)
470 OPENSSL_free(c->cipher_data); 458 OPENSSL_free(c->cipher_data);
471#ifndef OPENSSL_NO_ENGINE
472 if (c->engine) 459 if (c->engine)
473 /* The EVP_CIPHER we used belongs to an ENGINE, release the 460 /* The EVP_CIPHER we used belongs to an ENGINE, release the
474 * functional reference we held for this reason. */ 461 * functional reference we held for this reason. */
475 ENGINE_finish(c->engine); 462 ENGINE_finish(c->engine);
476#endif
477 memset(c,0,sizeof(EVP_CIPHER_CTX)); 463 memset(c,0,sizeof(EVP_CIPHER_CTX));
478 return 1; 464 return 1;
479 } 465 }
diff --git a/src/lib/libcrypto/evp/evp_key.c b/src/lib/libcrypto/evp/evp_key.c
index 5f387a94d3..4271393069 100644
--- a/src/lib/libcrypto/evp/evp_key.c
+++ b/src/lib/libcrypto/evp/evp_key.c
@@ -103,7 +103,7 @@ int EVP_read_pw_string(char *buf, int len, const char *prompt, int verify)
103 buff,0,(len>=BUFSIZ)?BUFSIZ-1:len,buf); 103 buff,0,(len>=BUFSIZ)?BUFSIZ-1:len,buf);
104 ret = UI_process(ui); 104 ret = UI_process(ui);
105 UI_free(ui); 105 UI_free(ui);
106 OPENSSL_cleanse(buff,BUFSIZ); 106 memset(buff,0,BUFSIZ);
107 return ret; 107 return ret;
108 } 108 }
109 109
@@ -118,8 +118,6 @@ int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md,
118 118
119 nkey=type->key_len; 119 nkey=type->key_len;
120 niv=type->iv_len; 120 niv=type->iv_len;
121 OPENSSL_assert(nkey <= EVP_MAX_KEY_LENGTH);
122 OPENSSL_assert(niv <= EVP_MAX_IV_LENGTH);
123 121
124 if (data == NULL) return(nkey); 122 if (data == NULL) return(nkey);
125 123
@@ -168,7 +166,7 @@ int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md,
168 if ((nkey == 0) && (niv == 0)) break; 166 if ((nkey == 0) && (niv == 0)) break;
169 } 167 }
170 EVP_MD_CTX_cleanup(&c); 168 EVP_MD_CTX_cleanup(&c);
171 OPENSSL_cleanse(&(md_buf[0]),EVP_MAX_MD_SIZE); 169 memset(&(md_buf[0]),0,EVP_MAX_MD_SIZE);
172 return(type->key_len); 170 return(type->key_len);
173 } 171 }
174 172
diff --git a/src/lib/libcrypto/evp/evp_lib.c b/src/lib/libcrypto/evp/evp_lib.c
index 52a3b287be..a431945ef5 100644
--- a/src/lib/libcrypto/evp/evp_lib.c
+++ b/src/lib/libcrypto/evp/evp_lib.c
@@ -90,7 +90,6 @@ int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
90 if (type != NULL) 90 if (type != NULL)
91 { 91 {
92 l=EVP_CIPHER_CTX_iv_length(c); 92 l=EVP_CIPHER_CTX_iv_length(c);
93 OPENSSL_assert(l <= sizeof c->iv);
94 i=ASN1_TYPE_get_octetstring(type,c->oiv,l); 93 i=ASN1_TYPE_get_octetstring(type,c->oiv,l);
95 if (i != l) 94 if (i != l)
96 return(-1); 95 return(-1);
@@ -107,7 +106,6 @@ int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
107 if (type != NULL) 106 if (type != NULL)
108 { 107 {
109 j=EVP_CIPHER_CTX_iv_length(c); 108 j=EVP_CIPHER_CTX_iv_length(c);
110 OPENSSL_assert(j <= sizeof c->iv);
111 i=ASN1_TYPE_set_octetstring(type,c->oiv,j); 109 i=ASN1_TYPE_set_octetstring(type,c->oiv,j);
112 } 110 }
113 return(i); 111 return(i);
diff --git a/src/lib/libcrypto/evp/evp_pbe.c b/src/lib/libcrypto/evp/evp_pbe.c
index 0da88fdcff..4234cd7684 100644
--- a/src/lib/libcrypto/evp/evp_pbe.c
+++ b/src/lib/libcrypto/evp/evp_pbe.c
@@ -87,8 +87,8 @@ int EVP_PBE_CipherInit (ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
87 if (i == -1) { 87 if (i == -1) {
88 char obj_tmp[80]; 88 char obj_tmp[80];
89 EVPerr(EVP_F_EVP_PBE_CIPHERINIT,EVP_R_UNKNOWN_PBE_ALGORITHM); 89 EVPerr(EVP_F_EVP_PBE_CIPHERINIT,EVP_R_UNKNOWN_PBE_ALGORITHM);
90 if (!pbe_obj) strcpy (obj_tmp, "NULL"); 90 if (!pbe_obj) strlcpy (obj_tmp, "NULL", sizeof obj_tmp);
91 else i2t_ASN1_OBJECT(obj_tmp, sizeof obj_tmp, pbe_obj); 91 else i2t_ASN1_OBJECT(obj_tmp, 80, pbe_obj);
92 ERR_add_error_data(2, "TYPE=", obj_tmp); 92 ERR_add_error_data(2, "TYPE=", obj_tmp);
93 return 0; 93 return 0;
94 } 94 }
diff --git a/src/lib/libcrypto/evp/evp_pkey.c b/src/lib/libcrypto/evp/evp_pkey.c
index 34b5b1d21c..30b6fbb03d 100644
--- a/src/lib/libcrypto/evp/evp_pkey.c
+++ b/src/lib/libcrypto/evp/evp_pkey.c
@@ -210,7 +210,7 @@ EVP_PKEY *EVP_PKCS82PKEY (PKCS8_PRIV_KEY_INFO *p8)
210#endif 210#endif
211 default: 211 default:
212 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM); 212 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM);
213 if (!a->algorithm) strcpy (obj_tmp, "NULL"); 213 if (!a->algorithm) strlcpy (obj_tmp, "NULL", sizeof obj_tmp);
214 else i2t_ASN1_OBJECT(obj_tmp, 80, a->algorithm); 214 else i2t_ASN1_OBJECT(obj_tmp, 80, a->algorithm);
215 ERR_add_error_data(2, "TYPE=", obj_tmp); 215 ERR_add_error_data(2, "TYPE=", obj_tmp);
216 EVP_PKEY_free (pkey); 216 EVP_PKEY_free (pkey);
diff --git a/src/lib/libcrypto/evp/evp_test.c b/src/lib/libcrypto/evp/evp_test.c
new file mode 100644
index 0000000000..90294ef686
--- /dev/null
+++ b/src/lib/libcrypto/evp/evp_test.c
@@ -0,0 +1,386 @@
1/* Written by Ben Laurie, 2001 */
2/*
3 * Copyright (c) 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#include <stdio.h>
51#include <string.h>
52#include <openssl/evp.h>
53#include <openssl/engine.h>
54#include <openssl/conf.h>
55
56static void hexdump(FILE *f,const char *title,const unsigned char *s,int l)
57 {
58 int n=0;
59
60 fprintf(f,"%s",title);
61 for( ; n < l ; ++n)
62 {
63 if((n%16) == 0)
64 fprintf(f,"\n%04x",n);
65 fprintf(f," %02x",s[n]);
66 }
67 fprintf(f,"\n");
68 }
69
70static int convert(unsigned char *s)
71 {
72 unsigned char *d;
73
74 for(d=s ; *s ; s+=2,++d)
75 {
76 unsigned int n;
77
78 if(!s[1])
79 {
80 fprintf(stderr,"Odd number of hex digits!");
81 exit(4);
82 }
83 sscanf((char *)s,"%2x",&n);
84 *d=(unsigned char)n;
85 }
86 return s-d;
87 }
88
89static char *sstrsep(char **string, const char *delim)
90 {
91 char isdelim[256];
92 char *token = *string;
93
94 if (**string == 0)
95 return NULL;
96
97 memset(isdelim, 0, 256);
98 isdelim[0] = 1;
99
100 while (*delim)
101 {
102 isdelim[(unsigned char)(*delim)] = 1;
103 delim++;
104 }
105
106 while (!isdelim[(unsigned char)(**string)])
107 {
108 (*string)++;
109 }
110
111 if (**string)
112 {
113 **string = 0;
114 (*string)++;
115 }
116
117 return token;
118 }
119
120static unsigned char *ustrsep(char **p,const char *sep)
121 { return (unsigned char *)sstrsep(p,sep); }
122
123static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn,
124 const unsigned char *iv,int in,
125 const unsigned char *plaintext,int pn,
126 const unsigned char *ciphertext,int cn,
127 int encdec)
128 {
129 EVP_CIPHER_CTX ctx;
130 unsigned char out[4096];
131 int outl,outl2;
132
133 printf("Testing cipher %s%s\n",EVP_CIPHER_name(c),
134 (encdec == 1 ? "(encrypt)" : (encdec == 0 ? "(decrypt)" : "(encrypt/decrypt)")));
135 hexdump(stdout,"Key",key,kn);
136 if(in)
137 hexdump(stdout,"IV",iv,in);
138 hexdump(stdout,"Plaintext",plaintext,pn);
139 hexdump(stdout,"Ciphertext",ciphertext,cn);
140
141 if(kn != c->key_len)
142 {
143 fprintf(stderr,"Key length doesn't match, got %d expected %d\n",kn,
144 c->key_len);
145 exit(5);
146 }
147 EVP_CIPHER_CTX_init(&ctx);
148 if (encdec != 0)
149 {
150 if(!EVP_EncryptInit_ex(&ctx,c,NULL,key,iv))
151 {
152 fprintf(stderr,"EncryptInit failed\n");
153 exit(10);
154 }
155 EVP_CIPHER_CTX_set_padding(&ctx,0);
156
157 if(!EVP_EncryptUpdate(&ctx,out,&outl,plaintext,pn))
158 {
159 fprintf(stderr,"Encrypt failed\n");
160 exit(6);
161 }
162 if(!EVP_EncryptFinal_ex(&ctx,out+outl,&outl2))
163 {
164 fprintf(stderr,"EncryptFinal failed\n");
165 exit(7);
166 }
167
168 if(outl+outl2 != cn)
169 {
170 fprintf(stderr,"Ciphertext length mismatch got %d expected %d\n",
171 outl+outl2,cn);
172 exit(8);
173 }
174
175 if(memcmp(out,ciphertext,cn))
176 {
177 fprintf(stderr,"Ciphertext mismatch\n");
178 hexdump(stderr,"Got",out,cn);
179 hexdump(stderr,"Expected",ciphertext,cn);
180 exit(9);
181 }
182 }
183
184 if (encdec <= 0)
185 {
186 if(!EVP_DecryptInit_ex(&ctx,c,NULL,key,iv))
187 {
188 fprintf(stderr,"DecryptInit failed\n");
189 exit(11);
190 }
191 EVP_CIPHER_CTX_set_padding(&ctx,0);
192
193 if(!EVP_DecryptUpdate(&ctx,out,&outl,ciphertext,cn))
194 {
195 fprintf(stderr,"Decrypt failed\n");
196 exit(6);
197 }
198 if(!EVP_DecryptFinal_ex(&ctx,out+outl,&outl2))
199 {
200 fprintf(stderr,"DecryptFinal failed\n");
201 exit(7);
202 }
203
204 if(outl+outl2 != cn)
205 {
206 fprintf(stderr,"Plaintext length mismatch got %d expected %d\n",
207 outl+outl2,cn);
208 exit(8);
209 }
210
211 if(memcmp(out,plaintext,cn))
212 {
213 fprintf(stderr,"Plaintext mismatch\n");
214 hexdump(stderr,"Got",out,cn);
215 hexdump(stderr,"Expected",plaintext,cn);
216 exit(9);
217 }
218 }
219
220 EVP_CIPHER_CTX_cleanup(&ctx);
221
222 printf("\n");
223 }
224
225static int test_cipher(const char *cipher,const unsigned char *key,int kn,
226 const unsigned char *iv,int in,
227 const unsigned char *plaintext,int pn,
228 const unsigned char *ciphertext,int cn,
229 int encdec)
230 {
231 const EVP_CIPHER *c;
232
233 c=EVP_get_cipherbyname(cipher);
234 if(!c)
235 return 0;
236
237 test1(c,key,kn,iv,in,plaintext,pn,ciphertext,cn,encdec);
238
239 return 1;
240 }
241
242static int test_digest(const char *digest,
243 const unsigned char *plaintext,int pn,
244 const unsigned char *ciphertext, unsigned int cn)
245 {
246 const EVP_MD *d;
247 EVP_MD_CTX ctx;
248 unsigned char md[EVP_MAX_MD_SIZE];
249 unsigned int mdn;
250
251 d=EVP_get_digestbyname(digest);
252 if(!d)
253 return 0;
254
255 printf("Testing digest %s\n",EVP_MD_name(d));
256 hexdump(stdout,"Plaintext",plaintext,pn);
257 hexdump(stdout,"Digest",ciphertext,cn);
258
259 EVP_MD_CTX_init(&ctx);
260 if(!EVP_DigestInit_ex(&ctx,d, NULL))
261 {
262 fprintf(stderr,"DigestInit failed\n");
263 exit(100);
264 }
265 if(!EVP_DigestUpdate(&ctx,plaintext,pn))
266 {
267 fprintf(stderr,"DigestUpdate failed\n");
268 exit(101);
269 }
270 if(!EVP_DigestFinal_ex(&ctx,md,&mdn))
271 {
272 fprintf(stderr,"DigestFinal failed\n");
273 exit(101);
274 }
275 EVP_MD_CTX_cleanup(&ctx);
276
277 if(mdn != cn)
278 {
279 fprintf(stderr,"Digest length mismatch, got %d expected %d\n",mdn,cn);
280 exit(102);
281 }
282
283 if(memcmp(md,ciphertext,cn))
284 {
285 fprintf(stderr,"Digest mismatch\n");
286 hexdump(stderr,"Got",md,cn);
287 hexdump(stderr,"Expected",ciphertext,cn);
288 exit(103);
289 }
290
291 printf("\n");
292
293 EVP_MD_CTX_cleanup(&ctx);
294
295 return 1;
296 }
297
298int main(int argc,char **argv)
299 {
300 const char *szTestFile;
301 FILE *f;
302
303 if(argc != 2)
304 {
305 fprintf(stderr,"%s <test file>\n",argv[0]);
306 exit(1);
307 }
308 CRYPTO_malloc_debug_init();
309 CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
310 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
311
312 szTestFile=argv[1];
313
314 f=fopen(szTestFile,"r");
315 if(!f)
316 {
317 perror(szTestFile);
318 exit(2);
319 }
320
321 /* Load up the software EVP_CIPHER and EVP_MD definitions */
322 OpenSSL_add_all_ciphers();
323 OpenSSL_add_all_digests();
324 /* Load all compiled-in ENGINEs */
325 ENGINE_load_builtin_engines();
326#if 0
327 OPENSSL_config();
328#endif
329 /* Register all available ENGINE implementations of ciphers and digests.
330 * This could perhaps be changed to "ENGINE_register_all_complete()"? */
331 ENGINE_register_all_ciphers();
332 ENGINE_register_all_digests();
333 /* If we add command-line options, this statement should be switchable.
334 * It'll prevent ENGINEs being ENGINE_init()ialised for cipher/digest use if
335 * they weren't already initialised. */
336 /* ENGINE_set_cipher_flags(ENGINE_CIPHER_FLAG_NOINIT); */
337
338 for( ; ; )
339 {
340 char line[4096];
341 char *p;
342 char *cipher;
343 unsigned char *iv,*key,*plaintext,*ciphertext;
344 int encdec;
345 int kn,in,pn,cn;
346
347 if(!fgets((char *)line,sizeof line,f))
348 break;
349 if(line[0] == '#' || line[0] == '\n')
350 continue;
351 p=line;
352 cipher=sstrsep(&p,":");
353 key=ustrsep(&p,":");
354 iv=ustrsep(&p,":");
355 plaintext=ustrsep(&p,":");
356 ciphertext=ustrsep(&p,":");
357 if (p[-1] == '\n') {
358 p[-1] = '\0';
359 encdec = -1;
360 } else {
361 encdec = atoi(sstrsep(&p,"\n"));
362 }
363
364
365 kn=convert(key);
366 in=convert(iv);
367 pn=convert(plaintext);
368 cn=convert(ciphertext);
369
370 if(!test_cipher(cipher,key,kn,iv,in,plaintext,pn,ciphertext,cn,encdec)
371 && !test_digest(cipher,plaintext,pn,ciphertext,cn))
372 {
373 fprintf(stderr,"Can't find %s\n",cipher);
374 exit(3);
375 }
376 }
377
378 ENGINE_cleanup();
379 EVP_cleanup();
380 CRYPTO_cleanup_all_ex_data();
381 ERR_remove_state(0);
382 ERR_free_strings();
383 CRYPTO_mem_leaks_fp(stderr);
384
385 return 0;
386 }
diff --git a/src/lib/libcrypto/evp/evptests.txt b/src/lib/libcrypto/evp/evptests.txt
new file mode 100644
index 0000000000..80bd9c7765
--- /dev/null
+++ b/src/lib/libcrypto/evp/evptests.txt
@@ -0,0 +1,183 @@
1#cipher:key:iv:plaintext:ciphertext:0/1(decrypt/encrypt)
2#digest:::input:output
3
4# SHA(1) tests (from shatest.c)
5SHA1:::616263:a9993e364706816aba3e25717850c26c9cd0d89d
6
7# MD5 tests (from md5test.c)
8MD5::::d41d8cd98f00b204e9800998ecf8427e
9MD5:::61:0cc175b9c0f1b6a831c399e269772661
10MD5:::616263:900150983cd24fb0d6963f7d28e17f72
11MD5:::6d65737361676520646967657374:f96b697d7cb7938d525a2f31aaf161d0
12MD5:::6162636465666768696a6b6c6d6e6f707172737475767778797a:c3fcd3d76192e4007dfb496cca67e13b
13MD5:::4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a30313233343536373839:d174ab98d277d9f5a5611c2c9f419d9f
14MD5:::3132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930:57edf4a22be3c955ac49da2e2107b67a
15
16# AES 128 ECB tests (from FIPS-197 test vectors, encrypt)
17
18AES-128-ECB:000102030405060708090A0B0C0D0E0F::00112233445566778899AABBCCDDEEFF:69C4E0D86A7B0430D8CDB78070B4C55A:1
19
20# AES 192 ECB tests (from FIPS-197 test vectors, encrypt)
21
22AES-192-ECB:000102030405060708090A0B0C0D0E0F1011121314151617::00112233445566778899AABBCCDDEEFF:DDA97CA4864CDFE06EAF70A0EC0D7191:1
23
24# AES 256 ECB tests (from FIPS-197 test vectors, encrypt)
25
26AES-256-ECB:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F::00112233445566778899AABBCCDDEEFF:8EA2B7CA516745BFEAFC49904B496089:1
27
28# AES 128 ECB tests (from NIST test vectors, encrypt)
29
30#AES-128-ECB:00000000000000000000000000000000::00000000000000000000000000000000:C34C052CC0DA8D73451AFE5F03BE297F:1
31
32# AES 128 ECB tests (from NIST test vectors, decrypt)
33
34#AES-128-ECB:00000000000000000000000000000000::44416AC2D1F53C583303917E6BE9EBE0:00000000000000000000000000000000:0
35
36# AES 192 ECB tests (from NIST test vectors, decrypt)
37
38#AES-192-ECB:000000000000000000000000000000000000000000000000::48E31E9E256718F29229319C19F15BA4:00000000000000000000000000000000:0
39
40# AES 256 ECB tests (from NIST test vectors, decrypt)
41
42#AES-256-ECB:0000000000000000000000000000000000000000000000000000000000000000::058CCFFDBBCB382D1F6F56585D8A4ADE:00000000000000000000000000000000:0
43
44# AES 128 CBC tests (from NIST test vectors, encrypt)
45
46#AES-128-CBC:00000000000000000000000000000000:00000000000000000000000000000000:00000000000000000000000000000000:8A05FC5E095AF4848A08D328D3688E3D:1
47
48# AES 192 CBC tests (from NIST test vectors, encrypt)
49
50#AES-192-CBC:000000000000000000000000000000000000000000000000:00000000000000000000000000000000:00000000000000000000000000000000:7BD966D53AD8C1BB85D2ADFAE87BB104:1
51
52# AES 256 CBC tests (from NIST test vectors, encrypt)
53
54#AES-256-CBC:0000000000000000000000000000000000000000000000000000000000000000:00000000000000000000000000000000:00000000000000000000000000000000:FE3C53653E2F45B56FCD88B2CC898FF0:1
55
56# AES 128 CBC tests (from NIST test vectors, decrypt)
57
58#AES-128-CBC:00000000000000000000000000000000:00000000000000000000000000000000:FACA37E0B0C85373DF706E73F7C9AF86:00000000000000000000000000000000:0
59
60# AES tests from NIST document SP800-38A
61# For all ECB encrypts and decrypts, the transformed sequence is
62# AES-bits-ECB:key::plaintext:ciphertext:encdec
63# ECB-AES128.Encrypt and ECB-AES128.Decrypt
64AES-128-ECB:2B7E151628AED2A6ABF7158809CF4F3C::6BC1BEE22E409F96E93D7E117393172A:3AD77BB40D7A3660A89ECAF32466EF97
65AES-128-ECB:2B7E151628AED2A6ABF7158809CF4F3C::AE2D8A571E03AC9C9EB76FAC45AF8E51:F5D3D58503B9699DE785895A96FDBAAF
66AES-128-ECB:2B7E151628AED2A6ABF7158809CF4F3C::30C81C46A35CE411E5FBC1191A0A52EF:43B1CD7F598ECE23881B00E3ED030688
67AES-128-ECB:2B7E151628AED2A6ABF7158809CF4F3C::F69F2445DF4F9B17AD2B417BE66C3710:7B0C785E27E8AD3F8223207104725DD4
68# ECB-AES192.Encrypt and ECB-AES192.Decrypt
69AES-192-ECB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B::6BC1BEE22E409F96E93D7E117393172A:BD334F1D6E45F25FF712A214571FA5CC
70AES-192-ECB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B::AE2D8A571E03AC9C9EB76FAC45AF8E51:974104846D0AD3AD7734ECB3ECEE4EEF
71AES-192-ECB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B::30C81C46A35CE411E5FBC1191A0A52EF:EF7AFD2270E2E60ADCE0BA2FACE6444E
72AES-192-ECB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B::F69F2445DF4F9B17AD2B417BE66C3710:9A4B41BA738D6C72FB16691603C18E0E
73# ECB-AES256.Encrypt and ECB-AES256.Decrypt
74AES-256-ECB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4::6BC1BEE22E409F96E93D7E117393172A:F3EED1BDB5D2A03C064B5A7E3DB181F8
75AES-256-ECB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4::AE2D8A571E03AC9C9EB76FAC45AF8E51:591CCB10D410ED26DC5BA74A31362870
76AES-256-ECB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4::30C81C46A35CE411E5FBC1191A0A52EF:B6ED21B99CA6F4F9F153E7B1BEAFED1D
77AES-256-ECB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4::F69F2445DF4F9B17AD2B417BE66C3710:23304B7A39F9F3FF067D8D8F9E24ECC7
78# For all CBC encrypts and decrypts, the transformed sequence is
79# AES-bits-CBC:key:IV/ciphertext':plaintext:ciphertext:encdec
80# CBC-AES128.Encrypt and CBC-AES128.Decrypt
81AES-128-CBC:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:7649ABAC8119B246CEE98E9B12E9197D
82AES-128-CBC:2B7E151628AED2A6ABF7158809CF4F3C:7649ABAC8119B246CEE98E9B12E9197D:AE2D8A571E03AC9C9EB76FAC45AF8E51:5086CB9B507219EE95DB113A917678B2
83AES-128-CBC:2B7E151628AED2A6ABF7158809CF4F3C:5086CB9B507219EE95DB113A917678B2:30C81C46A35CE411E5FBC1191A0A52EF:73BED6B8E3C1743B7116E69E22229516
84AES-128-CBC:2B7E151628AED2A6ABF7158809CF4F3C:73BED6B8E3C1743B7116E69E22229516:F69F2445DF4F9B17AD2B417BE66C3710:3FF1CAA1681FAC09120ECA307586E1A7
85# CBC-AES192.Encrypt and CBC-AES192.Decrypt
86AES-192-CBC:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:4F021DB243BC633D7178183A9FA071E8
87AES-192-CBC:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:4F021DB243BC633D7178183A9FA071E8:AE2D8A571E03AC9C9EB76FAC45AF8E51:B4D9ADA9AD7DEDF4E5E738763F69145A
88AES-192-CBC:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:B4D9ADA9AD7DEDF4E5E738763F69145A:30C81C46A35CE411E5FBC1191A0A52EF:571B242012FB7AE07FA9BAAC3DF102E0
89AES-192-CBC:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:571B242012FB7AE07FA9BAAC3DF102E0:F69F2445DF4F9B17AD2B417BE66C3710:08B0E27988598881D920A9E64F5615CD
90# CBC-AES256.Encrypt and CBC-AES256.Decrypt
91AES-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:F58C4C04D6E5F1BA779EABFB5F7BFBD6
92AES-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:F58C4C04D6E5F1BA779EABFB5F7BFBD6:AE2D8A571E03AC9C9EB76FAC45AF8E51:9CFC4E967EDB808D679F777BC6702C7D
93AES-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:9CFC4E967EDB808D679F777BC6702C7D:30C81C46A35CE411E5FBC1191A0A52EF:39F23369A9D9BACFA530E26304231461
94AES-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:39F23369A9D9BACFA530E26304231461:F69F2445DF4F9B17AD2B417BE66C3710:B2EB05E2C39BE9FCDA6C19078C6A9D1B
95# We don't support CFB{1,8}-AESxxx.{En,De}crypt
96# For all CFB128 encrypts and decrypts, the transformed sequence is
97# AES-bits-CFB:key:IV/ciphertext':plaintext:ciphertext:encdec
98# CFB128-AES128.Encrypt
99AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:3B3FD92EB72DAD20333449F8E83CFB4A:1
100AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:3B3FD92EB72DAD20333449F8E83CFB4A:AE2D8A571E03AC9C9EB76FAC45AF8E51:C8A64537A0B3A93FCDE3CDAD9F1CE58B:1
101AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:C8A64537A0B3A93FCDE3CDAD9F1CE58B:30C81C46A35CE411E5FBC1191A0A52EF:26751F67A3CBB140B1808CF187A4F4DF:1
102AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:26751F67A3CBB140B1808CF187A4F4DF:F69F2445DF4F9B17AD2B417BE66C3710:C04B05357C5D1C0EEAC4C66F9FF7F2E6:1
103# CFB128-AES128.Decrypt
104AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:3B3FD92EB72DAD20333449F8E83CFB4A:0
105AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:3B3FD92EB72DAD20333449F8E83CFB4A:AE2D8A571E03AC9C9EB76FAC45AF8E51:C8A64537A0B3A93FCDE3CDAD9F1CE58B:0
106AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:C8A64537A0B3A93FCDE3CDAD9F1CE58B:30C81C46A35CE411E5FBC1191A0A52EF:26751F67A3CBB140B1808CF187A4F4DF:0
107AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:26751F67A3CBB140B1808CF187A4F4DF:F69F2445DF4F9B17AD2B417BE66C3710:C04B05357C5D1C0EEAC4C66F9FF7F2E6:0
108# CFB128-AES192.Encrypt
109AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:CDC80D6FDDF18CAB34C25909C99A4174:1
110AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:CDC80D6FDDF18CAB34C25909C99A4174:AE2D8A571E03AC9C9EB76FAC45AF8E51:67CE7F7F81173621961A2B70171D3D7A:1
111AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:67CE7F7F81173621961A2B70171D3D7A:30C81C46A35CE411E5FBC1191A0A52EF:2E1E8A1DD59B88B1C8E60FED1EFAC4C9:1
112AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:2E1E8A1DD59B88B1C8E60FED1EFAC4C9:F69F2445DF4F9B17AD2B417BE66C3710:C05F9F9CA9834FA042AE8FBA584B09FF:1
113# CFB128-AES192.Decrypt
114AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:CDC80D6FDDF18CAB34C25909C99A4174:0
115AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:CDC80D6FDDF18CAB34C25909C99A4174:AE2D8A571E03AC9C9EB76FAC45AF8E51:67CE7F7F81173621961A2B70171D3D7A:0
116AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:67CE7F7F81173621961A2B70171D3D7A:30C81C46A35CE411E5FBC1191A0A52EF:2E1E8A1DD59B88B1C8E60FED1EFAC4C9:0
117AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:2E1E8A1DD59B88B1C8E60FED1EFAC4C9:F69F2445DF4F9B17AD2B417BE66C3710:C05F9F9CA9834FA042AE8FBA584B09FF:0
118# CFB128-AES256.Encrypt
119AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:DC7E84BFDA79164B7ECD8486985D3860:1
120AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:DC7E84BFDA79164B7ECD8486985D3860:AE2D8A571E03AC9C9EB76FAC45AF8E51:39FFED143B28B1C832113C6331E5407B:1
121AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:39FFED143B28B1C832113C6331E5407B:30C81C46A35CE411E5FBC1191A0A52EF:DF10132415E54B92A13ED0A8267AE2F9:1
122AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:DF10132415E54B92A13ED0A8267AE2F9:F69F2445DF4F9B17AD2B417BE66C3710:75A385741AB9CEF82031623D55B1E471:1
123# CFB128-AES256.Decrypt
124AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:DC7E84BFDA79164B7ECD8486985D3860:0
125AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:DC7E84BFDA79164B7ECD8486985D3860:AE2D8A571E03AC9C9EB76FAC45AF8E51:39FFED143B28B1C832113C6331E5407B:0
126AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:39FFED143B28B1C832113C6331E5407B:30C81C46A35CE411E5FBC1191A0A52EF:DF10132415E54B92A13ED0A8267AE2F9:0
127AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:DF10132415E54B92A13ED0A8267AE2F9:F69F2445DF4F9B17AD2B417BE66C3710:75A385741AB9CEF82031623D55B1E471:0
128# For all OFB encrypts and decrypts, the transformed sequence is
129# AES-bits-CFB:key:IV/output':plaintext:ciphertext:encdec
130# OFB-AES128.Encrypt
131AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:3B3FD92EB72DAD20333449F8E83CFB4A:1
132AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:50FE67CC996D32B6DA0937E99BAFEC60:AE2D8A571E03AC9C9EB76FAC45AF8E51:7789508D16918F03F53C52DAC54ED825:1
133AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:D9A4DADA0892239F6B8B3D7680E15674:30C81C46A35CE411E5FBC1191A0A52EF:9740051E9C5FECF64344F7A82260EDCC:1
134AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:A78819583F0308E7A6BF36B1386ABF23:F69F2445DF4F9B17AD2B417BE66C3710:304C6528F659C77866A510D9C1D6AE5E:1
135# OFB-AES128.Decrypt
136AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:3B3FD92EB72DAD20333449F8E83CFB4A:0
137AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:50FE67CC996D32B6DA0937E99BAFEC60:AE2D8A571E03AC9C9EB76FAC45AF8E51:7789508D16918F03F53C52DAC54ED825:0
138AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:D9A4DADA0892239F6B8B3D7680E15674:30C81C46A35CE411E5FBC1191A0A52EF:9740051E9C5FECF64344F7A82260EDCC:0
139AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:A78819583F0308E7A6BF36B1386ABF23:F69F2445DF4F9B17AD2B417BE66C3710:304C6528F659C77866A510D9C1D6AE5E:0
140# OFB-AES192.Encrypt
141AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:CDC80D6FDDF18CAB34C25909C99A4174:1
142AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:A609B38DF3B1133DDDFF2718BA09565E:AE2D8A571E03AC9C9EB76FAC45AF8E51:FCC28B8D4C63837C09E81700C1100401:1
143AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:52EF01DA52602FE0975F78AC84BF8A50:30C81C46A35CE411E5FBC1191A0A52EF:8D9A9AEAC0F6596F559C6D4DAF59A5F2:1
144AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:BD5286AC63AABD7EB067AC54B553F71D:F69F2445DF4F9B17AD2B417BE66C3710:6D9F200857CA6C3E9CAC524BD9ACC92A:1
145# OFB-AES192.Decrypt
146AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:CDC80D6FDDF18CAB34C25909C99A4174:0
147AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:A609B38DF3B1133DDDFF2718BA09565E:AE2D8A571E03AC9C9EB76FAC45AF8E51:FCC28B8D4C63837C09E81700C1100401:0
148AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:52EF01DA52602FE0975F78AC84BF8A50:30C81C46A35CE411E5FBC1191A0A52EF:8D9A9AEAC0F6596F559C6D4DAF59A5F2:0
149AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:BD5286AC63AABD7EB067AC54B553F71D:F69F2445DF4F9B17AD2B417BE66C3710:6D9F200857CA6C3E9CAC524BD9ACC92A:0
150# OFB-AES256.Encrypt
151AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:DC7E84BFDA79164B7ECD8486985D3860:1
152AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:B7BF3A5DF43989DD97F0FA97EBCE2F4A:AE2D8A571E03AC9C9EB76FAC45AF8E51:4FEBDC6740D20B3AC88F6AD82A4FB08D:1
153AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:E1C656305ED1A7A6563805746FE03EDC:30C81C46A35CE411E5FBC1191A0A52EF:71AB47A086E86EEDF39D1C5BBA97C408:1
154AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:41635BE625B48AFC1666DD42A09D96E7:F69F2445DF4F9B17AD2B417BE66C3710:0126141D67F37BE8538F5A8BE740E484:1
155# OFB-AES256.Decrypt
156AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:DC7E84BFDA79164B7ECD8486985D3860:0
157AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:B7BF3A5DF43989DD97F0FA97EBCE2F4A:AE2D8A571E03AC9C9EB76FAC45AF8E51:4FEBDC6740D20B3AC88F6AD82A4FB08D:0
158AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:E1C656305ED1A7A6563805746FE03EDC:30C81C46A35CE411E5FBC1191A0A52EF:71AB47A086E86EEDF39D1C5BBA97C408:0
159AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:41635BE625B48AFC1666DD42A09D96E7:F69F2445DF4F9B17AD2B417BE66C3710:0126141D67F37BE8538F5A8BE740E484:0
160
161# DES ECB tests (from destest)
162
163DES-ECB:0000000000000000::0000000000000000:8CA64DE9C1B123A7
164DES-ECB:FFFFFFFFFFFFFFFF::FFFFFFFFFFFFFFFF:7359B2163E4EDC58
165DES-ECB:3000000000000000::1000000000000001:958E6E627A05557B
166DES-ECB:1111111111111111::1111111111111111:F40379AB9E0EC533
167DES-ECB:0123456789ABCDEF::1111111111111111:17668DFC7292532D
168DES-ECB:1111111111111111::0123456789ABCDEF:8A5AE1F81AB8F2DD
169DES-ECB:FEDCBA9876543210::0123456789ABCDEF:ED39D950FA74BCC4
170
171# DESX-CBC tests (from destest)
172DESX-CBC:0123456789abcdeff1e0d3c2b5a49786fedcba9876543210:fedcba9876543210:37363534333231204E6F77206973207468652074696D6520666F722000000000:846B2914851E9A2954732F8AA0A611C115CDC2D7951B1053A63C5E03B21AA3C4
173
174# DES EDE3 CBC tests (from destest)
175DES-EDE3-CBC:0123456789abcdeff1e0d3c2b5a49786fedcba9876543210:fedcba9876543210:37363534333231204E6F77206973207468652074696D6520666F722000000000:3FE301C962AC01D02213763C1CBD4CDC799657C064ECF5D41C673812CFDE9675
176
177# RC4 tests (from rc4test)
178RC4:0123456789abcdef0123456789abcdef::0123456789abcdef:75b7878099e0c596
179RC4:0123456789abcdef0123456789abcdef::0000000000000000:7494c2e7104b0879
180RC4:00000000000000000000000000000000::0000000000000000:de188941a3375d3a
181RC4:ef012345ef012345ef012345ef012345::0000000000000000000000000000000000000000:d6a141a7ec3c38dfbd615a1162e1c7ba36b67858
182RC4:0123456789abcdef0123456789abcdef::123456789ABCDEF0123456789ABCDEF0123456789ABCDEF012345678:66a0949f8af7d6891f7f832ba833c00c892ebe30143ce28740011ecf
183RC4:ef012345ef012345ef012345ef012345::00000000000000000000:d6a141a7ec3c38dfbd61
diff --git a/src/lib/libcrypto/evp/m_md2.c b/src/lib/libcrypto/evp/m_md2.c
new file mode 100644
index 0000000000..50914c83b3
--- /dev/null
+++ b/src/lib/libcrypto/evp/m_md2.c
@@ -0,0 +1,96 @@
1/* crypto/evp/m_md2.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 OPENSSL_NO_MD2
60#include <stdio.h>
61#include "cryptlib.h"
62#include <openssl/evp.h>
63#include <openssl/objects.h>
64#include <openssl/x509.h>
65#include <openssl/md2.h>
66
67static int init(EVP_MD_CTX *ctx)
68 { return MD2_Init(ctx->md_data); }
69
70static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count)
71 { return MD2_Update(ctx->md_data,data,count); }
72
73static int final(EVP_MD_CTX *ctx,unsigned char *md)
74 { return MD2_Final(md,ctx->md_data); }
75
76static const EVP_MD md2_md=
77 {
78 NID_md2,
79 NID_md2WithRSAEncryption,
80 MD2_DIGEST_LENGTH,
81 0,
82 init,
83 update,
84 final,
85 NULL,
86 NULL,
87 EVP_PKEY_RSA_method,
88 MD2_BLOCK,
89 sizeof(EVP_MD *)+sizeof(MD2_CTX),
90 };
91
92const EVP_MD *EVP_md2(void)
93 {
94 return(&md2_md);
95 }
96#endif
diff --git a/src/lib/libcrypto/evp/m_mdc2.c b/src/lib/libcrypto/evp/m_mdc2.c
new file mode 100644
index 0000000000..9f6467c931
--- /dev/null
+++ b/src/lib/libcrypto/evp/m_mdc2.c
@@ -0,0 +1,96 @@
1/* crypto/evp/m_mdc2.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 OPENSSL_NO_MDC2
60#include <stdio.h>
61#include "cryptlib.h"
62#include <openssl/evp.h>
63#include <openssl/objects.h>
64#include <openssl/x509.h>
65#include <openssl/mdc2.h>
66
67static int init(EVP_MD_CTX *ctx)
68 { return MDC2_Init(ctx->md_data); }
69
70static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count)
71 { return MDC2_Update(ctx->md_data,data,count); }
72
73static int final(EVP_MD_CTX *ctx,unsigned char *md)
74 { return MDC2_Final(md,ctx->md_data); }
75
76static const EVP_MD mdc2_md=
77 {
78 NID_mdc2,
79 NID_mdc2WithRSA,
80 MDC2_DIGEST_LENGTH,
81 0,
82 init,
83 update,
84 final,
85 NULL,
86 NULL,
87 EVP_PKEY_RSA_ASN1_OCTET_STRING_method,
88 MDC2_BLOCK,
89 sizeof(EVP_MD *)+sizeof(MDC2_CTX),
90 };
91
92const EVP_MD *EVP_mdc2(void)
93 {
94 return(&mdc2_md);
95 }
96#endif
diff --git a/src/lib/libcrypto/evp/m_sha.c b/src/lib/libcrypto/evp/m_sha.c
new file mode 100644
index 0000000000..10697c7ed3
--- /dev/null
+++ b/src/lib/libcrypto/evp/m_sha.c
@@ -0,0 +1,95 @@
1/* crypto/evp/m_sha.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 OPENSSL_NO_SHA
60#include <stdio.h>
61#include "cryptlib.h"
62#include <openssl/evp.h>
63#include <openssl/objects.h>
64#include <openssl/x509.h>
65
66static int init(EVP_MD_CTX *ctx)
67 { return SHA_Init(ctx->md_data); }
68
69static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count)
70 { return SHA_Update(ctx->md_data,data,count); }
71
72static int final(EVP_MD_CTX *ctx,unsigned char *md)
73 { return SHA_Final(md,ctx->md_data); }
74
75static const EVP_MD sha_md=
76 {
77 NID_sha,
78 NID_shaWithRSAEncryption,
79 SHA_DIGEST_LENGTH,
80 0,
81 init,
82 update,
83 final,
84 NULL,
85 NULL,
86 EVP_PKEY_RSA_method,
87 SHA_CBLOCK,
88 sizeof(EVP_MD *)+sizeof(SHA_CTX),
89 };
90
91const EVP_MD *EVP_sha(void)
92 {
93 return(&sha_md);
94 }
95#endif
diff --git a/src/lib/libcrypto/evp/openbsd_hw.c b/src/lib/libcrypto/evp/openbsd_hw.c
new file mode 100644
index 0000000000..3831a5731e
--- /dev/null
+++ b/src/lib/libcrypto/evp/openbsd_hw.c
@@ -0,0 +1,446 @@
1/* Written by Ben Laurie, 2001 */
2/*
3 * Copyright (c) 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#include <openssl/evp.h>
51#include <openssl/objects.h>
52#include <openssl/rsa.h>
53#include "evp_locl.h"
54
55/* This stuff should now all be supported through
56 * crypto/engine/hw_openbsd_dev_crypto.c unless I botched it up */
57static void *dummy=&dummy;
58
59#if 0
60
61/* check flag after OpenSSL headers to ensure make depend works */
62#ifdef OPENSSL_OPENBSD_DEV_CRYPTO
63
64#include <fcntl.h>
65#include <stdio.h>
66#include <errno.h>
67#include <sys/ioctl.h>
68#include <crypto/cryptodev.h>
69#include <unistd.h>
70#include <assert.h>
71
72/* longest key supported in hardware */
73#define MAX_HW_KEY 24
74#define MAX_HW_IV 8
75
76#define MD5_DIGEST_LENGTH 16
77#define MD5_CBLOCK 64
78
79static int fd;
80static int dev_failed;
81
82typedef struct session_op session_op;
83
84#define CDATA(ctx) EVP_C_DATA(session_op,ctx)
85
86static void err(const char *str)
87 {
88 fprintf(stderr,"%s: errno %d\n",str,errno);
89 }
90
91static int dev_crypto_init(session_op *ses)
92 {
93 if(dev_failed)
94 return 0;
95 if(!fd)
96 {
97 int cryptodev_fd;
98
99 if ((cryptodev_fd=open("/dev/crypto",O_RDWR,0)) < 0)
100 {
101 err("/dev/crypto");
102 dev_failed=1;
103 return 0;
104 }
105 if (ioctl(cryptodev_fd,CRIOGET,&fd) == -1)
106 {
107 err("CRIOGET failed");
108 close(cryptodev_fd);
109 dev_failed=1;
110 return 0;
111 }
112 close(cryptodev_fd);
113 }
114 assert(ses);
115 memset(ses,'\0',sizeof *ses);
116
117 return 1;
118 }
119
120static int dev_crypto_cleanup(EVP_CIPHER_CTX *ctx)
121 {
122 if(ioctl(fd,CIOCFSESSION,&CDATA(ctx)->ses) == -1)
123 err("CIOCFSESSION failed");
124
125 OPENSSL_free(CDATA(ctx)->key);
126
127 return 1;
128 }
129
130static int dev_crypto_init_key(EVP_CIPHER_CTX *ctx,int cipher,
131 const unsigned char *key,int klen)
132 {
133 if(!dev_crypto_init(CDATA(ctx)))
134 return 0;
135
136 CDATA(ctx)->key=OPENSSL_malloc(MAX_HW_KEY);
137
138 assert(ctx->cipher->iv_len <= MAX_HW_IV);
139
140 memcpy(CDATA(ctx)->key,key,klen);
141
142 CDATA(ctx)->cipher=cipher;
143 CDATA(ctx)->keylen=klen;
144
145 if (ioctl(fd,CIOCGSESSION,CDATA(ctx)) == -1)
146 {
147 err("CIOCGSESSION failed");
148 return 0;
149 }
150 return 1;
151 }
152
153static int dev_crypto_cipher(EVP_CIPHER_CTX *ctx,unsigned char *out,
154 const unsigned char *in,unsigned int inl)
155 {
156 struct crypt_op cryp;
157 unsigned char lb[MAX_HW_IV];
158
159 if(!inl)
160 return 1;
161
162 assert(CDATA(ctx));
163 assert(!dev_failed);
164
165 memset(&cryp,'\0',sizeof cryp);
166 cryp.ses=CDATA(ctx)->ses;
167 cryp.op=ctx->encrypt ? COP_ENCRYPT : COP_DECRYPT;
168 cryp.flags=0;
169 cryp.len=inl;
170 assert((inl&(ctx->cipher->block_size-1)) == 0);
171 cryp.src=(caddr_t)in;
172 cryp.dst=(caddr_t)out;
173 cryp.mac=0;
174 if(ctx->cipher->iv_len)
175 cryp.iv=(caddr_t)ctx->iv;
176
177 if(!ctx->encrypt)
178 memcpy(lb,&in[cryp.len-ctx->cipher->iv_len],ctx->cipher->iv_len);
179
180 if(ioctl(fd, CIOCCRYPT, &cryp) == -1)
181 {
182 if(errno == EINVAL) /* buffers are misaligned */
183 {
184 unsigned int cinl=0;
185 char *cin=NULL;
186 char *cout=NULL;
187
188 /* NB: this can only make cinl != inl with stream ciphers */
189 cinl=(inl+3)/4*4;
190
191 if(((unsigned long)in&3) || cinl != inl)
192 {
193 cin=OPENSSL_malloc(cinl);
194 memcpy(cin,in,inl);
195 cryp.src=cin;
196 }
197
198 if(((unsigned long)out&3) || cinl != inl)
199 {
200 cout=OPENSSL_malloc(cinl);
201 cryp.dst=cout;
202 }
203
204 cryp.len=cinl;
205
206 if(ioctl(fd, CIOCCRYPT, &cryp) == -1)
207 {
208 err("CIOCCRYPT(2) failed");
209 printf("src=%p dst=%p\n",cryp.src,cryp.dst);
210 abort();
211 return 0;
212 }
213
214 if(cout)
215 {
216 memcpy(out,cout,inl);
217 OPENSSL_free(cout);
218 }
219 if(cin)
220 OPENSSL_free(cin);
221 }
222 else
223 {
224 err("CIOCCRYPT failed");
225 abort();
226 return 0;
227 }
228 }
229
230 if(ctx->encrypt)
231 memcpy(ctx->iv,&out[cryp.len-ctx->cipher->iv_len],ctx->cipher->iv_len);
232 else
233 memcpy(ctx->iv,lb,ctx->cipher->iv_len);
234
235 return 1;
236 }
237
238static int dev_crypto_des_ede3_init_key(EVP_CIPHER_CTX *ctx,
239 const unsigned char *key,
240 const unsigned char *iv, int enc)
241 { return dev_crypto_init_key(ctx,CRYPTO_3DES_CBC,key,24); }
242
243#define dev_crypto_des_ede3_cbc_cipher dev_crypto_cipher
244
245BLOCK_CIPHER_def_cbc(dev_crypto_des_ede3, session_op, NID_des_ede3, 8, 24, 8,
246 0, dev_crypto_des_ede3_init_key,
247 dev_crypto_cleanup,
248 EVP_CIPHER_set_asn1_iv,
249 EVP_CIPHER_get_asn1_iv,
250 NULL)
251
252static int dev_crypto_rc4_init_key(EVP_CIPHER_CTX *ctx,
253 const unsigned char *key,
254 const unsigned char *iv, int enc)
255 { return dev_crypto_init_key(ctx,CRYPTO_ARC4,key,16); }
256
257static const EVP_CIPHER r4_cipher=
258 {
259 NID_rc4,
260 1,16,0, /* FIXME: key should be up to 256 bytes */
261 EVP_CIPH_VARIABLE_LENGTH,
262 dev_crypto_rc4_init_key,
263 dev_crypto_cipher,
264 dev_crypto_cleanup,
265 sizeof(session_op),
266 NULL,
267 NULL,
268 NULL
269 };
270
271const EVP_CIPHER *EVP_dev_crypto_rc4(void)
272 { return &r4_cipher; }
273
274typedef struct
275 {
276 session_op sess;
277 char *data;
278 int len;
279 unsigned char md[EVP_MAX_MD_SIZE];
280 } MD_DATA;
281
282static int dev_crypto_init_digest(MD_DATA *md_data,int mac)
283 {
284 if(!dev_crypto_init(&md_data->sess))
285 return 0;
286
287 md_data->len=0;
288 md_data->data=NULL;
289
290 md_data->sess.mac=mac;
291
292 if (ioctl(fd,CIOCGSESSION,&md_data->sess) == -1)
293 {
294 err("CIOCGSESSION failed");
295 return 0;
296 }
297 return 1;
298 }
299
300static int dev_crypto_cleanup_digest(MD_DATA *md_data)
301 {
302 if (ioctl(fd,CIOCFSESSION,&md_data->sess.ses) == -1)
303 {
304 err("CIOCFSESSION failed");
305 return 0;
306 }
307
308 return 1;
309 }
310
311/* FIXME: if device can do chained MACs, then don't accumulate */
312/* FIXME: move accumulation to the framework */
313static int dev_crypto_md5_init(EVP_MD_CTX *ctx)
314 { return dev_crypto_init_digest(ctx->md_data,CRYPTO_MD5); }
315
316static int do_digest(int ses,unsigned char *md,const void *data,int len)
317 {
318 struct crypt_op cryp;
319 static unsigned char md5zero[16]=
320 {
321 0xd4,0x1d,0x8c,0xd9,0x8f,0x00,0xb2,0x04,
322 0xe9,0x80,0x09,0x98,0xec,0xf8,0x42,0x7e
323 };
324
325 /* some cards can't do zero length */
326 if(!len)
327 {
328 memcpy(md,md5zero,16);
329 return 1;
330 }
331
332 memset(&cryp,'\0',sizeof cryp);
333 cryp.ses=ses;
334 cryp.op=COP_ENCRYPT;/* required to do the MAC rather than check it */
335 cryp.len=len;
336 cryp.src=(caddr_t)data;
337 cryp.dst=(caddr_t)data; // FIXME!!!
338 cryp.mac=(caddr_t)md;
339
340 if(ioctl(fd, CIOCCRYPT, &cryp) == -1)
341 {
342 if(errno == EINVAL) /* buffer is misaligned */
343 {
344 char *dcopy;
345
346 dcopy=OPENSSL_malloc(len);
347 memcpy(dcopy,data,len);
348 cryp.src=dcopy;
349 cryp.dst=cryp.src; // FIXME!!!
350
351 if(ioctl(fd, CIOCCRYPT, &cryp) == -1)
352 {
353 err("CIOCCRYPT(MAC2) failed");
354 abort();
355 return 0;
356 }
357 OPENSSL_free(dcopy);
358 }
359 else
360 {
361 err("CIOCCRYPT(MAC) failed");
362 abort();
363 return 0;
364 }
365 }
366 // printf("done\n");
367
368 return 1;
369 }
370
371static int dev_crypto_md5_update(EVP_MD_CTX *ctx,const void *data,
372 unsigned long len)
373 {
374 MD_DATA *md_data=ctx->md_data;
375
376 if(ctx->flags&EVP_MD_CTX_FLAG_ONESHOT)
377 return do_digest(md_data->sess.ses,md_data->md,data,len);
378
379 md_data->data=OPENSSL_realloc(md_data->data,md_data->len+len);
380 memcpy(md_data->data+md_data->len,data,len);
381 md_data->len+=len;
382
383 return 1;
384 }
385
386static int dev_crypto_md5_final(EVP_MD_CTX *ctx,unsigned char *md)
387 {
388 int ret;
389 MD_DATA *md_data=ctx->md_data;
390
391 if(ctx->flags&EVP_MD_CTX_FLAG_ONESHOT)
392 {
393 memcpy(md,md_data->md,MD5_DIGEST_LENGTH);
394 ret=1;
395 }
396 else
397 {
398 ret=do_digest(md_data->sess.ses,md,md_data->data,md_data->len);
399 OPENSSL_free(md_data->data);
400 md_data->data=NULL;
401 md_data->len=0;
402 }
403
404 return ret;
405 }
406
407static int dev_crypto_md5_copy(EVP_MD_CTX *to,const EVP_MD_CTX *from)
408 {
409 const MD_DATA *from_md=from->md_data;
410 MD_DATA *to_md=to->md_data;
411
412 // How do we copy sessions?
413 assert(from->digest->flags&EVP_MD_FLAG_ONESHOT);
414
415 to_md->data=OPENSSL_malloc(from_md->len);
416 memcpy(to_md->data,from_md->data,from_md->len);
417
418 return 1;
419 }
420
421static int dev_crypto_md5_cleanup(EVP_MD_CTX *ctx)
422 {
423 return dev_crypto_cleanup_digest(ctx->md_data);
424 }
425
426static const EVP_MD md5_md=
427 {
428 NID_md5,
429 NID_md5WithRSAEncryption,
430 MD5_DIGEST_LENGTH,
431 EVP_MD_FLAG_ONESHOT, // XXX: set according to device info...
432 dev_crypto_md5_init,
433 dev_crypto_md5_update,
434 dev_crypto_md5_final,
435 dev_crypto_md5_copy,
436 dev_crypto_md5_cleanup,
437 EVP_PKEY_RSA_method,
438 MD5_CBLOCK,
439 sizeof(MD_DATA),
440 };
441
442const EVP_MD *EVP_dev_crypto_md5(void)
443 { return &md5_md; }
444
445#endif
446#endif
diff --git a/src/lib/libcrypto/evp/p5_crpt.c b/src/lib/libcrypto/evp/p5_crpt.c
index a1874e83b2..27a8286489 100644
--- a/src/lib/libcrypto/evp/p5_crpt.c
+++ b/src/lib/libcrypto/evp/p5_crpt.c
@@ -140,14 +140,12 @@ int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen,
140 EVP_DigestFinal_ex (&ctx, md_tmp, NULL); 140 EVP_DigestFinal_ex (&ctx, md_tmp, NULL);
141 } 141 }
142 EVP_MD_CTX_cleanup(&ctx); 142 EVP_MD_CTX_cleanup(&ctx);
143 OPENSSL_assert(EVP_CIPHER_key_length(cipher) <= sizeof md_tmp);
144 memcpy(key, md_tmp, EVP_CIPHER_key_length(cipher)); 143 memcpy(key, md_tmp, EVP_CIPHER_key_length(cipher));
145 OPENSSL_assert(EVP_CIPHER_iv_length(cipher) <= 16);
146 memcpy(iv, md_tmp + (16 - EVP_CIPHER_iv_length(cipher)), 144 memcpy(iv, md_tmp + (16 - EVP_CIPHER_iv_length(cipher)),
147 EVP_CIPHER_iv_length(cipher)); 145 EVP_CIPHER_iv_length(cipher));
148 EVP_CipherInit_ex(cctx, cipher, NULL, key, iv, en_de); 146 EVP_CipherInit_ex(cctx, cipher, NULL, key, iv, en_de);
149 OPENSSL_cleanse(md_tmp, EVP_MAX_MD_SIZE); 147 memset(md_tmp, 0, EVP_MAX_MD_SIZE);
150 OPENSSL_cleanse(key, EVP_MAX_KEY_LENGTH); 148 memset(key, 0, EVP_MAX_KEY_LENGTH);
151 OPENSSL_cleanse(iv, EVP_MAX_IV_LENGTH); 149 memset(iv, 0, EVP_MAX_IV_LENGTH);
152 return 1; 150 return 1;
153} 151}
diff --git a/src/lib/libcrypto/evp/p5_crpt2.c b/src/lib/libcrypto/evp/p5_crpt2.c
index 1f94e1ef88..7485d6a278 100644
--- a/src/lib/libcrypto/evp/p5_crpt2.c
+++ b/src/lib/libcrypto/evp/p5_crpt2.c
@@ -190,7 +190,6 @@ int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
190 goto err; 190 goto err;
191 } 191 }
192 keylen = EVP_CIPHER_CTX_key_length(ctx); 192 keylen = EVP_CIPHER_CTX_key_length(ctx);
193 OPENSSL_assert(keylen <= sizeof key);
194 193
195 /* Now decode key derivation function */ 194 /* Now decode key derivation function */
196 195
@@ -231,7 +230,7 @@ int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
231 iter = ASN1_INTEGER_get(kdf->iter); 230 iter = ASN1_INTEGER_get(kdf->iter);
232 PKCS5_PBKDF2_HMAC_SHA1(pass, passlen, salt, saltlen, iter, keylen, key); 231 PKCS5_PBKDF2_HMAC_SHA1(pass, passlen, salt, saltlen, iter, keylen, key);
233 EVP_CipherInit_ex(ctx, NULL, NULL, key, NULL, en_de); 232 EVP_CipherInit_ex(ctx, NULL, NULL, key, NULL, en_de);
234 OPENSSL_cleanse(key, keylen); 233 memset(key, 0, keylen);
235 PBKDF2PARAM_free(kdf); 234 PBKDF2PARAM_free(kdf);
236 return 1; 235 return 1;
237 236
diff --git a/src/lib/libcrypto/evp/p_open.c b/src/lib/libcrypto/evp/p_open.c
index 5a933d1cda..6976f2a867 100644
--- a/src/lib/libcrypto/evp/p_open.c
+++ b/src/lib/libcrypto/evp/p_open.c
@@ -101,7 +101,7 @@ int EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, unsigned char *ek,
101 101
102 ret=1; 102 ret=1;
103err: 103err:
104 if (key != NULL) OPENSSL_cleanse(key,size); 104 if (key != NULL) memset(key,0,size);
105 OPENSSL_free(key); 105 OPENSSL_free(key);
106 return(ret); 106 return(ret);
107 } 107 }
diff --git a/src/lib/libcrypto/hmac/Makefile.ssl b/src/lib/libcrypto/hmac/Makefile.ssl
new file mode 100644
index 0000000000..2bb3264f0e
--- /dev/null
+++ b/src/lib/libcrypto/hmac/Makefile.ssl
@@ -0,0 +1,99 @@
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: ../../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/cast.h
85hmac.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
86hmac.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
87hmac.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
88hmac.o: ../../include/openssl/evp.h ../../include/openssl/hmac.h
89hmac.o: ../../include/openssl/idea.h ../../include/openssl/md2.h
90hmac.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
91hmac.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
92hmac.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
93hmac.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
94hmac.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
95hmac.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
96hmac.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
97hmac.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
98hmac.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
99hmac.o: ../../include/openssl/ui_compat.h hmac.c
diff --git a/src/lib/libcrypto/hmac/hmac.c b/src/lib/libcrypto/hmac/hmac.c
index 4c91f919d5..da363b7950 100644
--- a/src/lib/libcrypto/hmac/hmac.c
+++ b/src/lib/libcrypto/hmac/hmac.c
@@ -59,7 +59,6 @@
59#include <stdlib.h> 59#include <stdlib.h>
60#include <string.h> 60#include <string.h>
61#include <openssl/hmac.h> 61#include <openssl/hmac.h>
62#include "cryptlib.h"
63 62
64void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len, 63void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
65 const EVP_MD *md, ENGINE *impl) 64 const EVP_MD *md, ENGINE *impl)
@@ -79,7 +78,6 @@ void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
79 { 78 {
80 reset=1; 79 reset=1;
81 j=EVP_MD_block_size(md); 80 j=EVP_MD_block_size(md);
82 OPENSSL_assert(j <= sizeof ctx->key);
83 if (j < len) 81 if (j < len)
84 { 82 {
85 EVP_DigestInit_ex(&ctx->md_ctx,md, impl); 83 EVP_DigestInit_ex(&ctx->md_ctx,md, impl);
@@ -89,7 +87,6 @@ void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
89 } 87 }
90 else 88 else
91 { 89 {
92 OPENSSL_assert(len <= sizeof ctx->key);
93 memcpy(ctx->key,key,len); 90 memcpy(ctx->key,key,len);
94 ctx->key_length=len; 91 ctx->key_length=len;
95 } 92 }
diff --git a/src/lib/libcrypto/hmac/hmactest.c b/src/lib/libcrypto/hmac/hmactest.c
new file mode 100644
index 0000000000..96d3beb8e6
--- /dev/null
+++ b/src/lib/libcrypto/hmac/hmactest.c
@@ -0,0 +1,160 @@
1/* crypto/hmac/hmactest.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 <stdlib.h>
62
63#ifdef OPENSSL_NO_HMAC
64int main(int argc, char *argv[])
65{
66 printf("No HMAC support\n");
67 return(0);
68}
69#else
70#include <openssl/hmac.h>
71#include <openssl/md5.h>
72
73#ifdef CHARSET_EBCDIC
74#include <openssl/ebcdic.h>
75#endif
76
77static struct test_st
78 {
79 unsigned char key[16];
80 int key_len;
81 unsigned char data[64];
82 int data_len;
83 unsigned char *digest;
84 } test[4]={
85 { "",
86 0,
87 "More text test vectors to stuff up EBCDIC machines :-)",
88 54,
89 (unsigned char *)"e9139d1e6ee064ef8cf514fc7dc83e86",
90 },{ {0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,
91 0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,},
92 16,
93 "Hi There",
94 8,
95 (unsigned char *)"9294727a3638bb1c13f48ef8158bfc9d",
96 },{ "Jefe",
97 4,
98 "what do ya want for nothing?",
99 28,
100 (unsigned char *)"750c783e6ab0b503eaa86e310a5db738",
101 },{
102 {0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,
103 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,},
104 16,
105 {0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,
106 0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,
107 0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,
108 0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,
109 0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,
110 0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,
111 0xdd,0xdd},
112 50,
113 (unsigned char *)"56be34521d144c88dbb8c733f0e8b3f6",
114 },
115 };
116
117
118static char *pt(unsigned char *md);
119int main(int argc, char *argv[])
120 {
121 int i,err=0;
122 char *p;
123
124#ifdef CHARSET_EBCDIC
125 ebcdic2ascii(test[0].data, test[0].data, test[0].data_len);
126 ebcdic2ascii(test[1].data, test[1].data, test[1].data_len);
127 ebcdic2ascii(test[2].key, test[2].key, test[2].key_len);
128 ebcdic2ascii(test[2].data, test[2].data, test[2].data_len);
129#endif
130
131 for (i=0; i<4; i++)
132 {
133 p=pt(HMAC(EVP_md5(),
134 test[i].key, test[i].key_len,
135 test[i].data, test[i].data_len,
136 NULL,NULL));
137
138 if (strcmp(p,(char *)test[i].digest) != 0)
139 {
140 printf("error calculating HMAC on %d entry'\n",i);
141 printf("got %s instead of %s\n",p,test[i].digest);
142 err++;
143 }
144 else
145 printf("test %d ok\n",i);
146 }
147 exit(err);
148 return(0);
149 }
150
151static char *pt(unsigned char *md)
152 {
153 int i;
154 static char buf[80];
155
156 for (i=0; i<MD5_DIGEST_LENGTH; i++)
157 sprintf(&(buf[i*2]),"%02x",md[i]);
158 return(buf);
159 }
160#endif
diff --git a/src/lib/libcrypto/idea/Makefile.ssl b/src/lib/libcrypto/idea/Makefile.ssl
new file mode 100644
index 0000000000..87c9aa484b
--- /dev/null
+++ b/src/lib/libcrypto/idea/Makefile.ssl
@@ -0,0 +1,91 @@
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/install.com b/src/lib/libcrypto/install.com
new file mode 100644
index 0000000000..b3d155e964
--- /dev/null
+++ b/src/lib/libcrypto/install.com
@@ -0,0 +1,138 @@
1$! INSTALL.COM -- Installs the files in a given directory tree
2$!
3$! Author: Richard Levitte <richard@levitte.org>
4$! Time of creation: 22-MAY-1998 10:13
5$!
6$! P1 root of the directory tree
7$!
8$ IF P1 .EQS. ""
9$ THEN
10$ WRITE SYS$OUTPUT "First argument missing."
11$ WRITE SYS$OUTPUT "Should be the directory where you want things installed."
12$ EXIT
13$ ENDIF
14$
15$ ROOT = F$PARSE(P1,"[]A.;0",,,"SYNTAX_ONLY,NO_CONCEAL") - "A.;0"
16$ ROOT_DEV = F$PARSE(ROOT,,,"DEVICE","SYNTAX_ONLY")
17$ ROOT_DIR = F$PARSE(ROOT,,,"DIRECTORY","SYNTAX_ONLY") -
18 - "[000000." - "][" - "[" - "]"
19$ ROOT = ROOT_DEV + "[" + ROOT_DIR
20$
21$ DEFINE/NOLOG WRK_SSLROOT 'ROOT'.] /TRANS=CONC
22$ DEFINE/NOLOG WRK_SSLVLIB WRK_SSLROOT:[VAX_LIB]
23$ DEFINE/NOLOG WRK_SSLALIB WRK_SSLROOT:[ALPHA_LIB]
24$ DEFINE/NOLOG WRK_SSLINCLUDE WRK_SSLROOT:[INCLUDE]
25$
26$ IF F$PARSE("WRK_SSLROOT:[000000]") .EQS. "" THEN -
27 CREATE/DIR/LOG WRK_SSLROOT:[000000]
28$ IF F$PARSE("WRK_SSLVLIB:") .EQS. "" THEN -
29 CREATE/DIR/LOG WRK_SSLVLIB:
30$ IF F$PARSE("WRK_SSLALIB:") .EQS. "" THEN -
31 CREATE/DIR/LOG WRK_SSLALIB:
32$ IF F$PARSE("WRK_SSLINCLUDE:") .EQS. "" THEN -
33 CREATE/DIR/LOG WRK_SSLINCLUDE:
34$
35$ SDIRS := ,MD2,MD4,MD5,SHA,MDC2,HMAC,RIPEMD,-
36 DES,RC2,RC4,RC5,IDEA,BF,CAST,-
37 BN,EC,RSA,DSA,DH,DSO,ENGINE,AES,-
38 BUFFER,BIO,STACK,LHASH,RAND,ERR,OBJECTS,-
39 EVP,ASN1,PEM,X509,X509V3,CONF,TXT_DB,PKCS7,PKCS12,COMP,OCSP,-
40 UI,KRB5
41$ EXHEADER_ := crypto.h,tmdiff.h,opensslv.h,opensslconf.h,ebcdic.h,-
42 symhacks.h,ossl_typ.h
43$ EXHEADER_MD2 := md2.h
44$ EXHEADER_MD4 := md4.h
45$ EXHEADER_MD5 := md5.h
46$ EXHEADER_SHA := sha.h
47$ EXHEADER_MDC2 := mdc2.h
48$ EXHEADER_HMAC := hmac.h
49$ EXHEADER_RIPEMD := ripemd.h
50$ EXHEADER_DES := des.h,des_old.h
51$ EXHEADER_RC2 := rc2.h
52$ EXHEADER_RC4 := rc4.h
53$ EXHEADER_RC5 := rc5.h
54$ EXHEADER_IDEA := idea.h
55$ EXHEADER_BF := blowfish.h
56$ EXHEADER_CAST := cast.h
57$ EXHEADER_BN := bn.h
58$ EXHEADER_EC := ec.h
59$ EXHEADER_RSA := rsa.h
60$ EXHEADER_DSA := dsa.h
61$ EXHEADER_DH := dh.h
62$ EXHEADER_DSO := dso.h
63$ EXHEADER_ENGINE := engine.h
64$ EXHEADER_AES := aes.h
65$ EXHEADER_BUFFER := buffer.h
66$ EXHEADER_BIO := bio.h
67$ EXHEADER_STACK := stack.h,safestack.h
68$ EXHEADER_LHASH := lhash.h
69$ EXHEADER_RAND := rand.h
70$ EXHEADER_ERR := err.h
71$ EXHEADER_OBJECTS := objects.h,obj_mac.h
72$ EXHEADER_EVP := evp.h
73$ EXHEADER_ASN1 := asn1.h,asn1_mac.h,asn1t.h
74$ EXHEADER_PEM := pem.h,pem2.h
75$ EXHEADER_X509 := x509.h,x509_vfy.h
76$ EXHEADER_X509V3 := x509v3.h
77$ EXHEADER_CONF := conf.h,conf_api.h
78$ EXHEADER_TXT_DB := txt_db.h
79$ EXHEADER_PKCS7 := pkcs7.h
80$ EXHEADER_PKCS12 := pkcs12.h
81$ EXHEADER_COMP := comp.h
82$ EXHEADER_OCSP := ocsp.h
83$ EXHEADER_UI := ui.h,ui_compat.h
84$ EXHEADER_KRB5 := krb5_asn.h
85$ LIBS := LIBCRYPTO
86$
87$ VEXE_DIR := [-.VAX.EXE.CRYPTO]
88$ AEXE_DIR := [-.AXP.EXE.CRYPTO]
89$
90$ I = 0
91$ LOOP_SDIRS:
92$ D = F$EDIT(F$ELEMENT(I, ",", SDIRS),"TRIM")
93$ I = I + 1
94$ IF D .EQS. "," THEN GOTO LOOP_SDIRS_END
95$ tmp = EXHEADER_'D'
96$ IF D .EQS. ""
97$ THEN
98$ COPY 'tmp' WRK_SSLINCLUDE: /LOG
99$ ELSE
100$ COPY [.'D']'tmp' WRK_SSLINCLUDE: /LOG
101$ ENDIF
102$ SET FILE/PROT=WORLD:RE WRK_SSLINCLUDE:'tmp'
103$ GOTO LOOP_SDIRS
104$ LOOP_SDIRS_END:
105$
106$ I = 0
107$ LOOP_LIB:
108$ E = F$EDIT(F$ELEMENT(I, ",", LIBS),"TRIM")
109$ I = I + 1
110$ IF E .EQS. "," THEN GOTO LOOP_LIB_END
111$ SET NOON
112$ IF F$SEARCH(VEXE_DIR+E+".OLB") .NES. ""
113$ THEN
114$ COPY 'VEXE_DIR''E'.OLB WRK_SSLVLIB:'E'.OLB/log
115$ SET FILE/PROT=W:RE WRK_SSLVLIB:'E'.OLB
116$ ENDIF
117$ ! Preparing for the time when we have shareable images
118$ IF F$SEARCH(VEXE_DIR+E+".EXE") .NES. ""
119$ THEN
120$ COPY 'VEXE_DIR''E'.EXE WRK_SSLVLIB:'E'.EXE/log
121$ SET FILE/PROT=W:RE WRK_SSLVLIB:'E'.EXE
122$ ENDIF
123$ IF F$SEARCH(AEXE_DIR+E+".OLB") .NES. ""
124$ THEN
125$ COPY 'AEXE_DIR''E'.OLB WRK_SSLALIB:'E'.OLB/log
126$ SET FILE/PROT=W:RE WRK_SSLALIB:'E'.OLB
127$ ENDIF
128$ ! Preparing for the time when we have shareable images
129$ IF F$SEARCH(AEXE_DIR+E+".EXE") .NES. ""
130$ THEN
131$ COPY 'AEXE_DIR''E'.EXE WRK_SSLALIB:'E'.EXE/log
132$ SET FILE/PROT=W:RE WRK_SSLALIB:'E'.EXE
133$ ENDIF
134$ SET ON
135$ GOTO LOOP_LIB
136$ LOOP_LIB_END:
137$
138$ EXIT
diff --git a/src/lib/libcrypto/krb5/Makefile.ssl b/src/lib/libcrypto/krb5/Makefile.ssl
new file mode 100644
index 0000000000..7ad0cbb0bc
--- /dev/null
+++ b/src/lib/libcrypto/krb5/Makefile.ssl
@@ -0,0 +1,90 @@
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)
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
new file mode 100644
index 0000000000..b3ad272cf7
--- /dev/null
+++ b/src/lib/libcrypto/lhash/Makefile.ssl
@@ -0,0 +1,93 @@
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..8e6f57c741 100644
--- a/src/lib/libcrypto/lhash/lh_stats.c
+++ b/src/lib/libcrypto/lhash/lh_stats.c
@@ -179,29 +179,63 @@ end:;
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 char buf[128];
183 BIO_printf(out,"num_nodes = %u\n",lh->num_nodes); 183
184 BIO_printf(out,"num_alloc_nodes = %u\n",lh->num_alloc_nodes); 184 snprintf(buf,sizeof buf,"num_items = %lu\n",lh->num_items);
185 BIO_printf(out,"num_expands = %lu\n",lh->num_expands); 185 BIO_puts(out,buf);
186 BIO_printf(out,"num_expand_reallocs = %lu\n", 186 snprintf(buf,sizeof buf,"num_nodes = %u\n",lh->num_nodes);
187 lh->num_expand_reallocs); 187 BIO_puts(out,buf);
188 BIO_printf(out,"num_contracts = %lu\n",lh->num_contracts); 188 snprintf(buf,sizeof buf,"num_alloc_nodes = %u\n",
189 BIO_printf(out,"num_contract_reallocs = %lu\n", 189 lh->num_alloc_nodes);
190 lh->num_contract_reallocs); 190 BIO_puts(out,buf);
191 BIO_printf(out,"num_hash_calls = %lu\n",lh->num_hash_calls); 191 snprintf(buf,sizeof buf,"num_expands = %lu\n",
192 BIO_printf(out,"num_comp_calls = %lu\n",lh->num_comp_calls); 192 lh->num_expands);
193 BIO_printf(out,"num_insert = %lu\n",lh->num_insert); 193 BIO_puts(out,buf);
194 BIO_printf(out,"num_replace = %lu\n",lh->num_replace); 194 snprintf(buf,sizeof buf,"num_expand_reallocs = %lu\n",
195 BIO_printf(out,"num_delete = %lu\n",lh->num_delete); 195 lh->num_expand_reallocs);
196 BIO_printf(out,"num_no_delete = %lu\n",lh->num_no_delete); 196 BIO_puts(out,buf);
197 BIO_printf(out,"num_retrieve = %lu\n",lh->num_retrieve); 197 snprintf(buf,sizeof buf,"num_contracts = %lu\n",
198 BIO_printf(out,"num_retrieve_miss = %lu\n",lh->num_retrieve_miss); 198 lh->num_contracts);
199 BIO_printf(out,"num_hash_comps = %lu\n",lh->num_hash_comps); 199 BIO_puts(out,buf);
200 snprintf(buf,sizeof buf,"num_contract_reallocs = %lu\n",
201 lh->num_contract_reallocs);
202 BIO_puts(out,buf);
203 snprintf(buf,sizeof buf,"num_hash_calls = %lu\n",
204 lh->num_hash_calls);
205 BIO_puts(out,buf);
206 snprintf(buf,sizeof buf,"num_comp_calls = %lu\n",
207 lh->num_comp_calls);
208 BIO_puts(out,buf);
209 snprintf(buf,sizeof buf,"num_insert = %lu\n",
210 lh->num_insert);
211 BIO_puts(out,buf);
212 snprintf(buf,sizeof buf,"num_replace = %lu\n",
213 lh->num_replace);
214 BIO_puts(out,buf);
215 snprintf(buf,sizeof buf,"num_delete = %lu\n",
216 lh->num_delete);
217 BIO_puts(out,buf);
218 snprintf(buf,sizeof buf,"num_no_delete = %lu\n",
219 lh->num_no_delete);
220 BIO_puts(out,buf);
221 snprintf(buf,sizeof buf,"num_retrieve = %lu\n",
222 lh->num_retrieve);
223 BIO_puts(out,buf);
224 snprintf(buf,sizeof buf,"num_retrieve_miss = %lu\n",
225 lh->num_retrieve_miss);
226 BIO_puts(out,buf);
227 snprintf(buf,sizeof buf,"num_hash_comps = %lu\n",
228 lh->num_hash_comps);
229 BIO_puts(out,buf);
200#if 0 230#if 0
201 BIO_printf(out,"p = %u\n",lh->p); 231 snprintf(buf,sizeof buf,"p = %u\n",lh->p);
202 BIO_printf(out,"pmax = %u\n",lh->pmax); 232 BIO_puts(out,buf);
203 BIO_printf(out,"up_load = %lu\n",lh->up_load); 233 snprintf(buf,sizeof buf,"pmax = %u\n",lh->pmax);
204 BIO_printf(out,"down_load = %lu\n",lh->down_load); 234 BIO_puts(out,buf);
235 snprintf(buf,sizeof buf,"up_load = %lu\n",lh->up_load);
236 BIO_puts(out,buf);
237 snprintf(buf,sizeof buf,"down_load = %lu\n",lh->down_load);
238 BIO_puts(out,buf);
205#endif 239#endif
206 } 240 }
207 241
@@ -209,12 +243,14 @@ void lh_node_stats_bio(const LHASH *lh, BIO *out)
209 { 243 {
210 LHASH_NODE *n; 244 LHASH_NODE *n;
211 unsigned int i,num; 245 unsigned int i,num;
246 char buf[128];
212 247
213 for (i=0; i<lh->num_nodes; i++) 248 for (i=0; i<lh->num_nodes; i++)
214 { 249 {
215 for (n=lh->b[i],num=0; n != NULL; n=n->next) 250 for (n=lh->b[i],num=0; n != NULL; n=n->next)
216 num++; 251 num++;
217 BIO_printf(out,"node %6u -> %3u\n",i,num); 252 snprintf(buf,sizeof buf,"node %6u -> %3u\n",i,num);
253 BIO_puts(out,buf);
218 } 254 }
219 } 255 }
220 256
@@ -224,6 +260,7 @@ void lh_node_usage_stats_bio(const LHASH *lh, BIO *out)
224 unsigned long num; 260 unsigned long num;
225 unsigned int i; 261 unsigned int i;
226 unsigned long total=0,n_used=0; 262 unsigned long total=0,n_used=0;
263 char buf[128];
227 264
228 for (i=0; i<lh->num_nodes; i++) 265 for (i=0; i<lh->num_nodes; i++)
229 { 266 {
@@ -235,14 +272,18 @@ void lh_node_usage_stats_bio(const LHASH *lh, BIO *out)
235 total+=num; 272 total+=num;
236 } 273 }
237 } 274 }
238 BIO_printf(out,"%lu nodes used out of %u\n",n_used,lh->num_nodes); 275 snprintf(buf,sizeof buf,"%lu nodes used out of %u\n",n_used,
239 BIO_printf(out,"%lu items\n",total); 276 lh->num_nodes);
277 BIO_puts(out,buf);
278 snprintf(buf,sizeof buf,"%lu items\n",total);
279 BIO_puts(out,buf);
240 if (n_used == 0) return; 280 if (n_used == 0) return;
241 BIO_printf(out,"load %d.%02d actual load %d.%02d\n", 281 snprintf(buf,sizeof buf,"load %d.%02d actual load %d.%02d\n",
242 (int)(total/lh->num_nodes), 282 (int)(total/lh->num_nodes),
243 (int)((total%lh->num_nodes)*100/lh->num_nodes), 283 (int)((total%lh->num_nodes)*100/lh->num_nodes),
244 (int)(total/n_used), 284 (int)(total/n_used),
245 (int)((total%n_used)*100/n_used)); 285 (int)((total%n_used)*100/n_used));
286 BIO_puts(out,buf);
246 } 287 }
247 288
248#endif 289#endif
diff --git a/src/lib/libcrypto/lhash/lh_test.c b/src/lib/libcrypto/lhash/lh_test.c
new file mode 100644
index 0000000000..85700c859b
--- /dev/null
+++ b/src/lib/libcrypto/lhash/lh_test.c
@@ -0,0 +1,88 @@
1/* crypto/lhash/lh_test.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <stdlib.h>
61#include <string.h>
62#include <openssl/lhash.h>
63
64main()
65 {
66 LHASH *conf;
67 char buf[256];
68 int i;
69
70 conf=lh_new(lh_strhash,strcmp);
71 for (;;)
72 {
73 char *p;
74
75 buf[0]='\0';
76 fgets(buf,256,stdin);
77 if (buf[0] == '\0') break;
78 i=strlen(buf);
79 p=OPENSSL_malloc(i+1);
80 memcpy(p,buf,i+1);
81 lh_insert(conf,p);
82 }
83
84 lh_node_stats(conf,stdout);
85 lh_stats(conf,stdout);
86 lh_node_usage_stats(conf,stdout);
87 exit(0);
88 }
diff --git a/src/lib/libcrypto/lhash/num.pl b/src/lib/libcrypto/lhash/num.pl
new file mode 100644
index 0000000000..30fedf9cd5
--- /dev/null
+++ b/src/lib/libcrypto/lhash/num.pl
@@ -0,0 +1,17 @@
1#!/usr/local/bin/perl
2
3#node 10 -> 4
4
5while (<>)
6 {
7 next unless /^node/;
8 chop;
9 @a=split;
10 $num{$a[3]}++;
11 }
12
13@a=sort {$a <=> $b } keys %num;
14foreach (0 .. $a[$#a])
15 {
16 printf "%4d:%4d\n",$_,$num{$_};
17 }
diff --git a/src/lib/libcrypto/md2/Makefile.ssl b/src/lib/libcrypto/md2/Makefile.ssl
new file mode 100644
index 0000000000..e89a17f3a4
--- /dev/null
+++ b/src/lib/libcrypto/md2/Makefile.ssl
@@ -0,0 +1,90 @@
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/md2.h ../../include/openssl/opensslconf.h
83md2_dgst.o: ../../include/openssl/opensslv.h md2_dgst.c
84md2_one.o: ../../e_os.h ../../include/openssl/bio.h
85md2_one.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
86md2_one.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
87md2_one.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
88md2_one.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
89md2_one.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
90md2_one.o: ../../include/openssl/symhacks.h ../cryptlib.h md2_one.c
diff --git a/src/lib/libcrypto/md2/md2.c b/src/lib/libcrypto/md2/md2.c
new file mode 100644
index 0000000000..f4d6f62264
--- /dev/null
+++ b/src/lib/libcrypto/md2/md2.c
@@ -0,0 +1,124 @@
1/* crypto/md2/md2.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <stdlib.h>
61#include <openssl/md2.h>
62
63#define BUFSIZE 1024*16
64
65void do_fp(FILE *f);
66void pt(unsigned char *md);
67int read(int, void *, unsigned int);
68void exit(int);
69int main(int argc, char *argv[])
70 {
71 int i,err=0;
72 FILE *IN;
73
74 if (argc == 1)
75 {
76 do_fp(stdin);
77 }
78 else
79 {
80 for (i=1; i<argc; i++)
81 {
82 IN=fopen(argv[i],"r");
83 if (IN == NULL)
84 {
85 perror(argv[i]);
86 err++;
87 continue;
88 }
89 printf("MD2(%s)= ",argv[i]);
90 do_fp(IN);
91 fclose(IN);
92 }
93 }
94 exit(err);
95 return(err);
96 }
97
98void do_fp(FILE *f)
99 {
100 MD2_CTX c;
101 unsigned char md[MD2_DIGEST_LENGTH];
102 int fd,i;
103 static unsigned char buf[BUFSIZE];
104
105 fd=fileno(f);
106 MD2_Init(&c);
107 for (;;)
108 {
109 i=read(fd,buf,BUFSIZE);
110 if (i <= 0) break;
111 MD2_Update(&c,buf,(unsigned long)i);
112 }
113 MD2_Final(&(md[0]),&c);
114 pt(md);
115 }
116
117void pt(unsigned char *md)
118 {
119 int i;
120
121 for (i=0; i<MD2_DIGEST_LENGTH; i++)
122 printf("%02x",md[i]);
123 printf("\n");
124 }
diff --git a/src/lib/libcrypto/md2/md2.h b/src/lib/libcrypto/md2/md2.h
new file mode 100644
index 0000000000..ad9241455c
--- /dev/null
+++ b/src/lib/libcrypto/md2/md2.h
@@ -0,0 +1,91 @@
1/* crypto/md/md2.h */
2/* Copyright (C) 1995-1997 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 HEADER_MD2_H
60#define HEADER_MD2_H
61
62#ifdef OPENSSL_NO_MD2
63#error MD2 is disabled.
64#endif
65
66#define MD2_DIGEST_LENGTH 16
67#define MD2_BLOCK 16
68#include <openssl/opensslconf.h> /* MD2_INT */
69
70#ifdef __cplusplus
71extern "C" {
72#endif
73
74typedef struct MD2state_st
75 {
76 int num;
77 unsigned char data[MD2_BLOCK];
78 MD2_INT cksm[MD2_BLOCK];
79 MD2_INT state[MD2_BLOCK];
80 } MD2_CTX;
81
82const char *MD2_options(void);
83int MD2_Init(MD2_CTX *c);
84int MD2_Update(MD2_CTX *c, const unsigned char *data, unsigned long len);
85int MD2_Final(unsigned char *md, MD2_CTX *c);
86unsigned char *MD2(const unsigned char *d, unsigned long n,unsigned char *md);
87#ifdef __cplusplus
88}
89#endif
90
91#endif
diff --git a/src/lib/libcrypto/md2/md2_dgst.c b/src/lib/libcrypto/md2/md2_dgst.c
new file mode 100644
index 0000000000..e25dd00e02
--- /dev/null
+++ b/src/lib/libcrypto/md2/md2_dgst.c
@@ -0,0 +1,226 @@
1/* crypto/md2/md2_dgst.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <stdlib.h>
61#include <string.h>
62#include <openssl/md2.h>
63#include <openssl/opensslv.h>
64
65const char *MD2_version="MD2" OPENSSL_VERSION_PTEXT;
66
67/* Implemented from RFC1319 The MD2 Message-Digest Algorithm
68 */
69
70#define UCHAR unsigned char
71
72static void md2_block(MD2_CTX *c, const unsigned char *d);
73/* The magic S table - I have converted it to hex since it is
74 * basically just a random byte string. */
75static MD2_INT S[256]={
76 0x29, 0x2E, 0x43, 0xC9, 0xA2, 0xD8, 0x7C, 0x01,
77 0x3D, 0x36, 0x54, 0xA1, 0xEC, 0xF0, 0x06, 0x13,
78 0x62, 0xA7, 0x05, 0xF3, 0xC0, 0xC7, 0x73, 0x8C,
79 0x98, 0x93, 0x2B, 0xD9, 0xBC, 0x4C, 0x82, 0xCA,
80 0x1E, 0x9B, 0x57, 0x3C, 0xFD, 0xD4, 0xE0, 0x16,
81 0x67, 0x42, 0x6F, 0x18, 0x8A, 0x17, 0xE5, 0x12,
82 0xBE, 0x4E, 0xC4, 0xD6, 0xDA, 0x9E, 0xDE, 0x49,
83 0xA0, 0xFB, 0xF5, 0x8E, 0xBB, 0x2F, 0xEE, 0x7A,
84 0xA9, 0x68, 0x79, 0x91, 0x15, 0xB2, 0x07, 0x3F,
85 0x94, 0xC2, 0x10, 0x89, 0x0B, 0x22, 0x5F, 0x21,
86 0x80, 0x7F, 0x5D, 0x9A, 0x5A, 0x90, 0x32, 0x27,
87 0x35, 0x3E, 0xCC, 0xE7, 0xBF, 0xF7, 0x97, 0x03,
88 0xFF, 0x19, 0x30, 0xB3, 0x48, 0xA5, 0xB5, 0xD1,
89 0xD7, 0x5E, 0x92, 0x2A, 0xAC, 0x56, 0xAA, 0xC6,
90 0x4F, 0xB8, 0x38, 0xD2, 0x96, 0xA4, 0x7D, 0xB6,
91 0x76, 0xFC, 0x6B, 0xE2, 0x9C, 0x74, 0x04, 0xF1,
92 0x45, 0x9D, 0x70, 0x59, 0x64, 0x71, 0x87, 0x20,
93 0x86, 0x5B, 0xCF, 0x65, 0xE6, 0x2D, 0xA8, 0x02,
94 0x1B, 0x60, 0x25, 0xAD, 0xAE, 0xB0, 0xB9, 0xF6,
95 0x1C, 0x46, 0x61, 0x69, 0x34, 0x40, 0x7E, 0x0F,
96 0x55, 0x47, 0xA3, 0x23, 0xDD, 0x51, 0xAF, 0x3A,
97 0xC3, 0x5C, 0xF9, 0xCE, 0xBA, 0xC5, 0xEA, 0x26,
98 0x2C, 0x53, 0x0D, 0x6E, 0x85, 0x28, 0x84, 0x09,
99 0xD3, 0xDF, 0xCD, 0xF4, 0x41, 0x81, 0x4D, 0x52,
100 0x6A, 0xDC, 0x37, 0xC8, 0x6C, 0xC1, 0xAB, 0xFA,
101 0x24, 0xE1, 0x7B, 0x08, 0x0C, 0xBD, 0xB1, 0x4A,
102 0x78, 0x88, 0x95, 0x8B, 0xE3, 0x63, 0xE8, 0x6D,
103 0xE9, 0xCB, 0xD5, 0xFE, 0x3B, 0x00, 0x1D, 0x39,
104 0xF2, 0xEF, 0xB7, 0x0E, 0x66, 0x58, 0xD0, 0xE4,
105 0xA6, 0x77, 0x72, 0xF8, 0xEB, 0x75, 0x4B, 0x0A,
106 0x31, 0x44, 0x50, 0xB4, 0x8F, 0xED, 0x1F, 0x1A,
107 0xDB, 0x99, 0x8D, 0x33, 0x9F, 0x11, 0x83, 0x14,
108 };
109
110const char *MD2_options(void)
111 {
112 if (sizeof(MD2_INT) == 1)
113 return("md2(char)");
114 else
115 return("md2(int)");
116 }
117
118int MD2_Init(MD2_CTX *c)
119 {
120 c->num=0;
121 memset(c->state,0,MD2_BLOCK*sizeof(MD2_INT));
122 memset(c->cksm,0,MD2_BLOCK*sizeof(MD2_INT));
123 memset(c->data,0,MD2_BLOCK);
124 return 1;
125 }
126
127int MD2_Update(MD2_CTX *c, const unsigned char *data, unsigned long len)
128 {
129 register UCHAR *p;
130
131 if (len == 0) return 1;
132
133 p=c->data;
134 if (c->num != 0)
135 {
136 if ((c->num+len) >= MD2_BLOCK)
137 {
138 memcpy(&(p[c->num]),data,MD2_BLOCK-c->num);
139 md2_block(c,c->data);
140 data+=(MD2_BLOCK - c->num);
141 len-=(MD2_BLOCK - c->num);
142 c->num=0;
143 /* drop through and do the rest */
144 }
145 else
146 {
147 memcpy(&(p[c->num]),data,(int)len);
148 /* data+=len; */
149 c->num+=(int)len;
150 return 1;
151 }
152 }
153 /* we now can process the input data in blocks of MD2_BLOCK
154 * chars and save the leftovers to c->data. */
155 while (len >= MD2_BLOCK)
156 {
157 md2_block(c,data);
158 data+=MD2_BLOCK;
159 len-=MD2_BLOCK;
160 }
161 memcpy(p,data,(int)len);
162 c->num=(int)len;
163 return 1;
164 }
165
166static void md2_block(MD2_CTX *c, const unsigned char *d)
167 {
168 register MD2_INT t,*sp1,*sp2;
169 register int i,j;
170 MD2_INT state[48];
171
172 sp1=c->state;
173 sp2=c->cksm;
174 j=sp2[MD2_BLOCK-1];
175 for (i=0; i<16; i++)
176 {
177 state[i]=sp1[i];
178 state[i+16]=t=d[i];
179 state[i+32]=(t^sp1[i]);
180 j=sp2[i]^=S[t^j];
181 }
182 t=0;
183 for (i=0; i<18; i++)
184 {
185 for (j=0; j<48; j+=8)
186 {
187 t= state[j+ 0]^=S[t];
188 t= state[j+ 1]^=S[t];
189 t= state[j+ 2]^=S[t];
190 t= state[j+ 3]^=S[t];
191 t= state[j+ 4]^=S[t];
192 t= state[j+ 5]^=S[t];
193 t= state[j+ 6]^=S[t];
194 t= state[j+ 7]^=S[t];
195 }
196 t=(t+i)&0xff;
197 }
198 memcpy(sp1,state,16*sizeof(MD2_INT));
199 memset(state,0,48*sizeof(MD2_INT));
200 }
201
202int MD2_Final(unsigned char *md, MD2_CTX *c)
203 {
204 int i,v;
205 register UCHAR *cp;
206 register MD2_INT *p1,*p2;
207
208 cp=c->data;
209 p1=c->state;
210 p2=c->cksm;
211 v=MD2_BLOCK-c->num;
212 for (i=c->num; i<MD2_BLOCK; i++)
213 cp[i]=(UCHAR)v;
214
215 md2_block(c,cp);
216
217 for (i=0; i<MD2_BLOCK; i++)
218 cp[i]=(UCHAR)p2[i];
219 md2_block(c,cp);
220
221 for (i=0; i<16; i++)
222 md[i]=(UCHAR)(p1[i]&0xff);
223 memset((char *)&c,0,sizeof(c));
224 return 1;
225 }
226
diff --git a/src/lib/libcrypto/md2/md2_one.c b/src/lib/libcrypto/md2/md2_one.c
new file mode 100644
index 0000000000..b12c37ce4d
--- /dev/null
+++ b/src/lib/libcrypto/md2/md2_one.c
@@ -0,0 +1,93 @@
1/* crypto/md2/md2_one.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/md2.h>
62
63/* This is a separate file so that #defines in cryptlib.h can
64 * map my MD functions to different names */
65
66unsigned char *MD2(const unsigned char *d, unsigned long n, unsigned char *md)
67 {
68 MD2_CTX c;
69 static unsigned char m[MD2_DIGEST_LENGTH];
70
71 if (md == NULL) md=m;
72 MD2_Init(&c);
73#ifndef CHARSET_EBCDIC
74 MD2_Update(&c,d,n);
75#else
76 {
77 char temp[1024];
78 unsigned long chunk;
79
80 while (n > 0)
81 {
82 chunk = (n > sizeof(temp)) ? sizeof(temp) : n;
83 ebcdic2ascii(temp, d, chunk);
84 MD2_Update(&c,temp,chunk);
85 n -= chunk;
86 d += chunk;
87 }
88 }
89#endif
90 MD2_Final(md,&c);
91 memset(&c,0,sizeof(c)); /* Security consideration */
92 return(md);
93 }
diff --git a/src/lib/libcrypto/md2/md2test.c b/src/lib/libcrypto/md2/md2test.c
new file mode 100644
index 0000000000..7d3664faf5
--- /dev/null
+++ b/src/lib/libcrypto/md2/md2test.c
@@ -0,0 +1,138 @@
1/* crypto/md2/md2test.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <stdlib.h>
61#include <string.h>
62#include <openssl/md2.h>
63
64#ifdef OPENSSL_NO_MD2
65int main(int argc, char *argv[])
66{
67 printf("No MD2 support\n");
68 return(0);
69}
70#else
71#include <openssl/evp.h>
72
73#ifdef CHARSET_EBCDIC
74#include <openssl/ebcdic.h>
75#endif
76
77static char *test[]={
78 "",
79 "a",
80 "abc",
81 "message digest",
82 "abcdefghijklmnopqrstuvwxyz",
83 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
84 "12345678901234567890123456789012345678901234567890123456789012345678901234567890",
85 NULL,
86 };
87
88static char *ret[]={
89 "8350e5a3e24c153df2275c9f80692773",
90 "32ec01ec4a6dac72c0ab96fb34c0b5d1",
91 "da853b0d3f88d99b30283a69e6ded6bb",
92 "ab4f496bfb2a530b219ff33031fe06b0",
93 "4e8ddff3650292ab5a4108c3aa47940b",
94 "da33def2a42df13975352846c30338cd",
95 "d5976f79d83d3a0dc9806c3c66f3efd8",
96 };
97
98static char *pt(unsigned char *md);
99int main(int argc, char *argv[])
100 {
101 int i,err=0;
102 char **P,**R;
103 char *p;
104 unsigned char md[MD2_DIGEST_LENGTH];
105
106 P=test;
107 R=ret;
108 i=1;
109 while (*P != NULL)
110 {
111 EVP_Digest((unsigned char *)*P,(unsigned long)strlen(*P),md,NULL,EVP_md2(), NULL);
112 p=pt(md);
113 if (strcmp(p,*R) != 0)
114 {
115 printf("error calculating MD2 on '%s'\n",*P);
116 printf("got %s instead of %s\n",p,*R);
117 err++;
118 }
119 else
120 printf("test %d ok\n",i);
121 i++;
122 R++;
123 P++;
124 }
125 exit(err);
126 return(0);
127 }
128
129static char *pt(unsigned char *md)
130 {
131 int i;
132 static char buf[80];
133
134 for (i=0; i<MD2_DIGEST_LENGTH; i++)
135 sprintf(&(buf[i*2]),"%02x",md[i]);
136 return(buf);
137 }
138#endif
diff --git a/src/lib/libcrypto/md32_common.h b/src/lib/libcrypto/md32_common.h
index 573850b122..353d2b96ad 100644
--- a/src/lib/libcrypto/md32_common.h
+++ b/src/lib/libcrypto/md32_common.h
@@ -1,6 +1,6 @@
1/* crypto/md32_common.h */ 1/* crypto/md32_common.h */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2002 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
@@ -198,7 +198,7 @@
198 * 198 *
199 * <appro@fy.chalmers.se> 199 * <appro@fy.chalmers.se>
200 */ 200 */
201# if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) 201# if defined(__i386) || defined(__i386__)
202# define ROTATE(a,n) ({ register unsigned int ret; \ 202# define ROTATE(a,n) ({ register unsigned int ret; \
203 asm ( \ 203 asm ( \
204 "roll %1,%0" \ 204 "roll %1,%0" \
@@ -224,7 +224,7 @@
224 */ 224 */
225# if defined(__GNUC__) && __GNUC__>=2 && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) 225# if defined(__GNUC__) && __GNUC__>=2 && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM)
226 /* some GNU C inline assembler templates by <appro@fy.chalmers.se> */ 226 /* some GNU C inline assembler templates by <appro@fy.chalmers.se> */
227# if (defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__)) && !defined(I386_ONLY) 227# if (defined(__i386) || defined(__i386__)) && !defined(I386_ONLY)
228# define BE_FETCH32(a) ({ register unsigned int l=(a);\ 228# define BE_FETCH32(a) ({ register unsigned int l=(a);\
229 asm ( \ 229 asm ( \
230 "bswapl %0" \ 230 "bswapl %0" \
@@ -456,10 +456,7 @@ int HASH_UPDATE (HASH_CTX *c, const void *data_, unsigned long len)
456 { 456 {
457 ew=(c->num>>2); 457 ew=(c->num>>2);
458 ec=(c->num&0x03); 458 ec=(c->num&0x03);
459 if (sc) 459 l=p[sw]; HOST_p_c2l(data,l,sc); p[sw++]=l;
460 l=p[sw];
461 HOST_p_c2l(data,l,sc);
462 p[sw++]=l;
463 for (; sw < ew; sw++) 460 for (; sw < ew; sw++)
464 { 461 {
465 HOST_c2l(data,l); p[sw]=l; 462 HOST_c2l(data,l); p[sw]=l;
@@ -606,32 +603,7 @@ int HASH_FINAL (unsigned char *md, HASH_CTX *c)
606 c->num=0; 603 c->num=0;
607 /* clear stuff, HASH_BLOCK may be leaving some stuff on the stack 604 /* clear stuff, HASH_BLOCK may be leaving some stuff on the stack
608 * but I'm not worried :-) 605 * but I'm not worried :-)
609 OPENSSL_cleanse((void *)c,sizeof(HASH_CTX)); 606 memset((void *)c,0,sizeof(HASH_CTX));
610 */ 607 */
611 return 1; 608 return 1;
612 } 609 }
613
614#ifndef MD32_REG_T
615#define MD32_REG_T long
616/*
617 * This comment was originaly written for MD5, which is why it
618 * discusses A-D. But it basically applies to all 32-bit digests,
619 * which is why it was moved to common header file.
620 *
621 * In case you wonder why A-D are declared as long and not
622 * as MD5_LONG. Doing so results in slight performance
623 * boost on LP64 architectures. The catch is we don't
624 * really care if 32 MSBs of a 64-bit register get polluted
625 * with eventual overflows as we *save* only 32 LSBs in
626 * *either* case. Now declaring 'em long excuses the compiler
627 * from keeping 32 MSBs zeroed resulting in 13% performance
628 * improvement under SPARC Solaris7/64 and 5% under AlphaLinux.
629 * Well, to be honest it should say that this *prevents*
630 * performance degradation.
631 * <appro@fy.chalmers.se>
632 * Apparently there're LP64 compilers that generate better
633 * code if A-D are declared int. Most notably GCC-x86_64
634 * generates better code.
635 * <appro@fy.chalmers.se>
636 */
637#endif
diff --git a/src/lib/libcrypto/md4/Makefile.ssl b/src/lib/libcrypto/md4/Makefile.ssl
new file mode 100644
index 0000000000..1de72571d8
--- /dev/null
+++ b/src/lib/libcrypto/md4/Makefile.ssl
@@ -0,0 +1,88 @@
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/e_os2.h ../../include/openssl/md4.h
88md4_one.o: ../../include/openssl/opensslconf.h md4_one.c
diff --git a/src/lib/libcrypto/md4/md4.c b/src/lib/libcrypto/md4/md4.c
new file mode 100644
index 0000000000..e4b0aac011
--- /dev/null
+++ b/src/lib/libcrypto/md4/md4.c
@@ -0,0 +1,127 @@
1/* crypto/md4/md4.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <stdlib.h>
61#include <openssl/md4.h>
62
63#define BUFSIZE 1024*16
64
65void do_fp(FILE *f);
66void pt(unsigned char *md);
67#ifndef _OSD_POSIX
68int read(int, void *, unsigned int);
69#endif
70
71int main(int argc, char **argv)
72 {
73 int i,err=0;
74 FILE *IN;
75
76 if (argc == 1)
77 {
78 do_fp(stdin);
79 }
80 else
81 {
82 for (i=1; i<argc; i++)
83 {
84 IN=fopen(argv[i],"r");
85 if (IN == NULL)
86 {
87 perror(argv[i]);
88 err++;
89 continue;
90 }
91 printf("MD4(%s)= ",argv[i]);
92 do_fp(IN);
93 fclose(IN);
94 }
95 }
96 exit(err);
97 }
98
99void do_fp(FILE *f)
100 {
101 MD4_CTX c;
102 unsigned char md[MD4_DIGEST_LENGTH];
103 int fd;
104 int i;
105 static unsigned char buf[BUFSIZE];
106
107 fd=fileno(f);
108 MD4_Init(&c);
109 for (;;)
110 {
111 i=read(fd,buf,BUFSIZE);
112 if (i <= 0) break;
113 MD4_Update(&c,buf,(unsigned long)i);
114 }
115 MD4_Final(&(md[0]),&c);
116 pt(md);
117 }
118
119void pt(unsigned char *md)
120 {
121 int i;
122
123 for (i=0; i<MD4_DIGEST_LENGTH; i++)
124 printf("%02x",md[i]);
125 printf("\n");
126 }
127
diff --git a/src/lib/libcrypto/md4/md4_dgst.c b/src/lib/libcrypto/md4/md4_dgst.c
index 7afb7185b6..6446f5f5e7 100644
--- a/src/lib/libcrypto/md4/md4_dgst.c
+++ b/src/lib/libcrypto/md4/md4_dgst.c
@@ -86,7 +86,21 @@ int MD4_Init(MD4_CTX *c)
86void md4_block_host_order (MD4_CTX *c, const void *data, int num) 86void md4_block_host_order (MD4_CTX *c, const void *data, int num)
87 { 87 {
88 const MD4_LONG *X=data; 88 const MD4_LONG *X=data;
89 register unsigned MD32_REG_T A,B,C,D; 89 register unsigned long A,B,C,D;
90 /*
91 * In case you wonder why A-D are declared as long and not
92 * as MD4_LONG. Doing so results in slight performance
93 * boost on LP64 architectures. The catch is we don't
94 * really care if 32 MSBs of a 64-bit register get polluted
95 * with eventual overflows as we *save* only 32 LSBs in
96 * *either* case. Now declaring 'em long excuses the compiler
97 * from keeping 32 MSBs zeroed resulting in 13% performance
98 * improvement under SPARC Solaris7/64 and 5% under AlphaLinux.
99 * Well, to be honest it should say that this *prevents*
100 * performance degradation.
101 *
102 * <appro@fy.chalmers.se>
103 */
90 104
91 A=c->A; 105 A=c->A;
92 B=c->B; 106 B=c->B;
@@ -162,11 +176,25 @@ void md4_block_host_order (MD4_CTX *c, const void *data, int num)
162void md4_block_data_order (MD4_CTX *c, const void *data_, int num) 176void md4_block_data_order (MD4_CTX *c, const void *data_, int num)
163 { 177 {
164 const unsigned char *data=data_; 178 const unsigned char *data=data_;
165 register unsigned MD32_REG_T A,B,C,D,l; 179 register unsigned long A,B,C,D,l;
180 /*
181 * In case you wonder why A-D are declared as long and not
182 * as MD4_LONG. Doing so results in slight performance
183 * boost on LP64 architectures. The catch is we don't
184 * really care if 32 MSBs of a 64-bit register get polluted
185 * with eventual overflows as we *save* only 32 LSBs in
186 * *either* case. Now declaring 'em long excuses the compiler
187 * from keeping 32 MSBs zeroed resulting in 13% performance
188 * improvement under SPARC Solaris7/64 and 5% under AlphaLinux.
189 * Well, to be honest it should say that this *prevents*
190 * performance degradation.
191 *
192 * <appro@fy.chalmers.se>
193 */
166#ifndef MD32_XARRAY 194#ifndef MD32_XARRAY
167 /* See comment in crypto/sha/sha_locl.h for details. */ 195 /* See comment in crypto/sha/sha_locl.h for details. */
168 unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, 196 unsigned long XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
169 XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15; 197 XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15;
170# define X(i) XX##i 198# define X(i) XX##i
171#else 199#else
172 MD4_LONG XX[MD4_LBLOCK]; 200 MD4_LONG XX[MD4_LBLOCK];
diff --git a/src/lib/libcrypto/md4/md4_one.c b/src/lib/libcrypto/md4/md4_one.c
index 00565507e4..87a995d38d 100644
--- a/src/lib/libcrypto/md4/md4_one.c
+++ b/src/lib/libcrypto/md4/md4_one.c
@@ -59,7 +59,6 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <string.h> 60#include <string.h>
61#include <openssl/md4.h> 61#include <openssl/md4.h>
62#include <openssl/crypto.h>
63 62
64#ifdef CHARSET_EBCDIC 63#ifdef CHARSET_EBCDIC
65#include <openssl/ebcdic.h> 64#include <openssl/ebcdic.h>
@@ -90,7 +89,7 @@ unsigned char *MD4(const unsigned char *d, unsigned long n, unsigned char *md)
90 } 89 }
91#endif 90#endif
92 MD4_Final(md,&c); 91 MD4_Final(md,&c);
93 OPENSSL_cleanse(&c,sizeof(c)); /* security consideration */ 92 memset(&c,0,sizeof(c)); /* security consideration */
94 return(md); 93 return(md);
95 } 94 }
96 95
diff --git a/src/lib/libcrypto/md4/md4s.cpp b/src/lib/libcrypto/md4/md4s.cpp
new file mode 100644
index 0000000000..c0ec97fc9f
--- /dev/null
+++ b/src/lib/libcrypto/md4/md4s.cpp
@@ -0,0 +1,78 @@
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/md4.h>
36
37extern "C" {
38void md4_block_x86(MD4_CTX *ctx, unsigned char *buffer,int num);
39}
40
41void main(int argc,char *argv[])
42 {
43 unsigned char buffer[64*256];
44 MD4_CTX ctx;
45 unsigned long s1,s2,e1,e2;
46 unsigned char k[16];
47 unsigned long data[2];
48 unsigned char iv[8];
49 int i,num=0,numm;
50 int j=0;
51
52 if (argc >= 2)
53 num=atoi(argv[1]);
54
55 if (num == 0) num=16;
56 if (num > 250) num=16;
57 numm=num+2;
58 num*=64;
59 numm*=64;
60
61 for (j=0; j<6; j++)
62 {
63 for (i=0; i<10; i++) /**/
64 {
65 md4_block_x86(&ctx,buffer,numm);
66 GetTSC(s1);
67 md4_block_x86(&ctx,buffer,numm);
68 GetTSC(e1);
69 GetTSC(s2);
70 md4_block_x86(&ctx,buffer,num);
71 GetTSC(e2);
72 md4_block_x86(&ctx,buffer,num);
73 }
74 printf("md4 (%d bytes) %d %d (%.2f)\n",num,
75 e1-s1,e2-s2,(double)((e1-s1)-(e2-s2))/2);
76 }
77 }
78
diff --git a/src/lib/libcrypto/md4/md4test.c b/src/lib/libcrypto/md4/md4test.c
new file mode 100644
index 0000000000..e0fdc42282
--- /dev/null
+++ b/src/lib/libcrypto/md4/md4test.c
@@ -0,0 +1,134 @@
1/* crypto/md4/md4test.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 <stdlib.h>
62
63#ifdef OPENSSL_NO_MD4
64int main(int argc, char *argv[])
65{
66 printf("No MD4 support\n");
67 return(0);
68}
69#else
70#include <openssl/evp.h>
71#include <openssl/md4.h>
72
73static char *test[]={
74 "",
75 "a",
76 "abc",
77 "message digest",
78 "abcdefghijklmnopqrstuvwxyz",
79 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
80 "12345678901234567890123456789012345678901234567890123456789012345678901234567890",
81 NULL,
82 };
83
84static char *ret[]={
85"31d6cfe0d16ae931b73c59d7e0c089c0",
86"bde52cb31de33e46245e05fbdbd6fb24",
87"a448017aaf21d8525fc10ae87aa6729d",
88"d9130a8164549fe818874806e1c7014b",
89"d79e1c308aa5bbcdeea8ed63df412da9",
90"043f8582f241db351ce627e153e7f0e4",
91"e33b4ddc9c38f2199c3e7b164fcc0536",
92};
93
94static char *pt(unsigned char *md);
95int main(int argc, char *argv[])
96 {
97 int i,err=0;
98 unsigned char **P,**R;
99 char *p;
100 unsigned char md[MD4_DIGEST_LENGTH];
101
102 P=(unsigned char **)test;
103 R=(unsigned char **)ret;
104 i=1;
105 while (*P != NULL)
106 {
107 EVP_Digest(&(P[0][0]),(unsigned long)strlen((char *)*P),md,NULL,EVP_md4(), NULL);
108 p=pt(md);
109 if (strcmp(p,(char *)*R) != 0)
110 {
111 printf("error calculating MD4 on '%s'\n",*P);
112 printf("got %s instead of %s\n",p,*R);
113 err++;
114 }
115 else
116 printf("test %d ok\n",i);
117 i++;
118 R++;
119 P++;
120 }
121 exit(err);
122 return(0);
123 }
124
125static char *pt(unsigned char *md)
126 {
127 int i;
128 static char buf[80];
129
130 for (i=0; i<MD4_DIGEST_LENGTH; i++)
131 sprintf(&(buf[i*2]),"%02x",md[i]);
132 return(buf);
133 }
134#endif
diff --git a/src/lib/libcrypto/md5/Makefile.ssl b/src/lib/libcrypto/md5/Makefile.ssl
new file mode 100644
index 0000000000..5f1bbfb8ff
--- /dev/null
+++ b/src/lib/libcrypto/md5/Makefile.ssl
@@ -0,0 +1,135 @@
1#
2# SSLeay/crypto/md5/Makefile
3#
4
5DIR= md5
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
20MD5_ASM_OBJ=
21
22CFLAGS= $(INCLUDES) $(CFLAG)
23
24# We let the C compiler driver to take care of .s files. This is done in
25# order to be excused from maintaining a separate set of architecture
26# dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
27# gcc, then the driver will automatically translate it to -xarch=v8plus
28# and pass it down to assembler.
29AS=$(CC) -c
30ASFLAGS=$(CFLAGS)
31
32GENERAL=Makefile
33TEST=md5test.c
34APPS=
35
36LIB=$(TOP)/libcrypto.a
37LIBSRC=md5_dgst.c md5_one.c
38LIBOBJ=md5_dgst.o md5_one.o $(MD5_ASM_OBJ)
39
40SRC= $(LIBSRC)
41
42EXHEADER= md5.h
43HEADER= md5_locl.h $(EXHEADER)
44
45ALL= $(GENERAL) $(SRC) $(HEADER)
46
47top:
48 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
49
50all: lib
51
52lib: $(LIBOBJ)
53 $(AR) $(LIB) $(LIBOBJ)
54 $(RANLIB) $(LIB) || echo Never mind.
55 @touch lib
56
57# elf
58asm/mx86-elf.o: asm/mx86unix.cpp
59 $(CPP) -DELF -x c asm/mx86unix.cpp | as -o asm/mx86-elf.o
60
61# solaris
62asm/mx86-sol.o: asm/mx86unix.cpp
63 $(CC) -E -DSOL asm/mx86unix.cpp | sed 's/^#.*//' > asm/mx86-sol.s
64 as -o asm/mx86-sol.o asm/mx86-sol.s
65 rm -f asm/mx86-sol.s
66
67# a.out
68asm/mx86-out.o: asm/mx86unix.cpp
69 $(CPP) -DOUT asm/mx86unix.cpp | as -o asm/mx86-out.o
70
71# bsdi
72asm/mx86bsdi.o: asm/mx86unix.cpp
73 $(CPP) -DBSDI asm/mx86unix.cpp | sed 's/ :/:/' | as -o asm/mx86bsdi.o
74
75asm/mx86unix.cpp: asm/md5-586.pl ../perlasm/x86asm.pl
76 (cd asm; $(PERL) md5-586.pl cpp >mx86unix.cpp)
77
78asm/md5-sparcv8plus.o: asm/md5-sparcv9.S
79 $(CC) $(ASFLAGS) -DMD5_BLOCK_DATA_ORDER -c \
80 -o asm/md5-sparcv8plus.o asm/md5-sparcv9.S
81
82# Old GNU assembler doesn't understand V9 instructions, so we
83# hire /usr/ccs/bin/as to do the job. Note that option is called
84# *-gcc27, but even gcc 2>=8 users may experience similar problem
85# if they didn't bother to upgrade GNU assembler. Such users should
86# not choose this option, but be adviced to *remove* GNU assembler
87# or upgrade it.
88asm/md5-sparcv8plus-gcc27.o: asm/md5-sparcv9.S
89 $(CC) $(ASFLAGS) -DMD5_BLOCK_DATA_ORDER -E asm/md5-sparcv9.S | \
90 /usr/ccs/bin/as -xarch=v8plus - -o asm/md5-sparcv8plus-gcc27.o
91
92asm/md5-sparcv9.o: asm/md5-sparcv9.S
93 $(CC) $(ASFLAGS) -DMD5_BLOCK_DATA_ORDER -c \
94 -o asm/md5-sparcv9.o asm/md5-sparcv9.S
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:
106 @for i in $(EXHEADER) ; \
107 do \
108 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
109 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
110 done;
111
112tags:
113 ctags $(SRC)
114
115tests:
116
117lint:
118 lint -DLINT $(INCLUDES) $(SRC)>fluff
119
120depend:
121 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC)
122
123dclean:
124 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
125 mv -f Makefile.new $(MAKEFILE)
126
127clean:
128 rm -f asm/mx86unix.cpp *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
129
130# DO NOT DELETE THIS LINE -- make depend depends on it.
131
132md5_dgst.o: ../../include/openssl/md5.h ../../include/openssl/opensslconf.h
133md5_dgst.o: ../../include/openssl/opensslv.h ../md32_common.h md5_dgst.c
134md5_dgst.o: md5_locl.h
135md5_one.o: ../../include/openssl/md5.h md5_one.c
diff --git a/src/lib/libcrypto/md5/asm/md5-sparcv9.S b/src/lib/libcrypto/md5/asm/md5-sparcv9.S
new file mode 100644
index 0000000000..a599ed5660
--- /dev/null
+++ b/src/lib/libcrypto/md5/asm/md5-sparcv9.S
@@ -0,0 +1,1029 @@
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 -DULTRASPARC -DMD5_BLOCK_DATA_ORDER md5_block.sparc.S | \
38 * as -xarch=v8plus /dev/fd/0 -o md5-sparcv9.o
39 */
40
41#define A %o0
42#define B %o1
43#define C %o2
44#define D %o3
45#define T1 %o4
46#define T2 %o5
47
48#define R0 %l0
49#define R1 %l1
50#define R2 %l2
51#define R3 %l3
52#define R4 %l4
53#define R5 %l5
54#define R6 %l6
55#define R7 %l7
56#define R8 %i3
57#define R9 %i4
58#define R10 %i5
59#define R11 %g1
60#define R12 %g2
61#define R13 %g3
62#define RX %g4
63
64#define Aptr %i0+0
65#define Bptr %i0+4
66#define Cptr %i0+8
67#define Dptr %i0+12
68
69#define Aval R5 /* those not used at the end of the last round */
70#define Bval R6
71#define Cval R7
72#define Dval R8
73
74#if defined(MD5_BLOCK_DATA_ORDER)
75# if defined(OPENSSL_SYSNAME_ULTRASPARC)
76# define LOAD lda
77# define X(i) [%i1+i*4]%asi
78# define md5_block md5_block_asm_data_order_aligned
79# define ASI_PRIMARY_LITTLE 0x88
80# else
81# error "MD5_BLOCK_DATA_ORDER is supported only on UltraSPARC!"
82# endif
83#else
84# define LOAD ld
85# define X(i) [%i1+i*4]
86# define md5_block md5_block_asm_host_order
87#endif
88
89.section ".text",#alloc,#execinstr
90
91#if defined(__SUNPRO_C) && defined(__sparcv9)
92 /* They've said -xarch=v9 at command line */
93 .register %g2,#scratch
94 .register %g3,#scratch
95# define FRAME -192
96#elif defined(__GNUC__) && defined(__arch64__)
97 /* They've said -m64 at command line */
98 .register %g2,#scratch
99 .register %g3,#scratch
100# define FRAME -192
101#else
102# define FRAME -96
103#endif
104
105.align 32
106
107.global md5_block
108md5_block:
109 save %sp,FRAME,%sp
110
111 ld [Dptr],D
112 ld [Cptr],C
113 ld [Bptr],B
114 ld [Aptr],A
115#ifdef ASI_PRIMARY_LITTLE
116 rd %asi,%o7 ! How dare I? Well, I just do:-)
117 wr %g0,ASI_PRIMARY_LITTLE,%asi
118#endif
119 LOAD X(0),R0
120
121.Lmd5_block_loop:
122
123!!!!!!!!Round 0
124
125 xor C,D,T1
126 sethi %hi(0xd76aa478),T2
127 and T1,B,T1
128 or T2,%lo(0xd76aa478),T2 !=
129 xor T1,D,T1
130 add T1,R0,T1
131 LOAD X(1),R1
132 add T1,T2,T1 !=
133 add A,T1,A
134 sll A,7,T2
135 srl A,32-7,A
136 or A,T2,A !=
137 xor B,C,T1
138 add A,B,A
139
140 sethi %hi(0xe8c7b756),T2
141 and T1,A,T1 !=
142 or T2,%lo(0xe8c7b756),T2
143 xor T1,C,T1
144 LOAD X(2),R2
145 add T1,R1,T1 !=
146 add T1,T2,T1
147 add D,T1,D
148 sll D,12,T2
149 srl D,32-12,D !=
150 or D,T2,D
151 xor A,B,T1
152 add D,A,D
153
154 sethi %hi(0x242070db),T2 !=
155 and T1,D,T1
156 or T2,%lo(0x242070db),T2
157 xor T1,B,T1
158 add T1,R2,T1 !=
159 LOAD X(3),R3
160 add T1,T2,T1
161 add C,T1,C
162 sll C,17,T2 !=
163 srl C,32-17,C
164 or C,T2,C
165 xor D,A,T1
166 add C,D,C !=
167
168 sethi %hi(0xc1bdceee),T2
169 and T1,C,T1
170 or T2,%lo(0xc1bdceee),T2
171 xor T1,A,T1 !=
172 add T1,R3,T1
173 LOAD X(4),R4
174 add T1,T2,T1
175 add B,T1,B !=
176 sll B,22,T2
177 srl B,32-22,B
178 or B,T2,B
179 xor C,D,T1 !=
180 add B,C,B
181
182 sethi %hi(0xf57c0faf),T2
183 and T1,B,T1
184 or T2,%lo(0xf57c0faf),T2 !=
185 xor T1,D,T1
186 add T1,R4,T1
187 LOAD X(5),R5
188 add T1,T2,T1 !=
189 add A,T1,A
190 sll A,7,T2
191 srl A,32-7,A
192 or A,T2,A !=
193 xor B,C,T1
194 add A,B,A
195
196 sethi %hi(0x4787c62a),T2
197 and T1,A,T1 !=
198 or T2,%lo(0x4787c62a),T2
199 xor T1,C,T1
200 LOAD X(6),R6
201 add T1,R5,T1 !=
202 add T1,T2,T1
203 add D,T1,D
204 sll D,12,T2
205 srl D,32-12,D !=
206 or D,T2,D
207 xor A,B,T1
208 add D,A,D
209
210 sethi %hi(0xa8304613),T2 !=
211 and T1,D,T1
212 or T2,%lo(0xa8304613),T2
213 xor T1,B,T1
214 add T1,R6,T1 !=
215 LOAD X(7),R7
216 add T1,T2,T1
217 add C,T1,C
218 sll C,17,T2 !=
219 srl C,32-17,C
220 or C,T2,C
221 xor D,A,T1
222 add C,D,C !=
223
224 sethi %hi(0xfd469501),T2
225 and T1,C,T1
226 or T2,%lo(0xfd469501),T2
227 xor T1,A,T1 !=
228 add T1,R7,T1
229 LOAD X(8),R8
230 add T1,T2,T1
231 add B,T1,B !=
232 sll B,22,T2
233 srl B,32-22,B
234 or B,T2,B
235 xor C,D,T1 !=
236 add B,C,B
237
238 sethi %hi(0x698098d8),T2
239 and T1,B,T1
240 or T2,%lo(0x698098d8),T2 !=
241 xor T1,D,T1
242 add T1,R8,T1
243 LOAD X(9),R9
244 add T1,T2,T1 !=
245 add A,T1,A
246 sll A,7,T2
247 srl A,32-7,A
248 or A,T2,A !=
249 xor B,C,T1
250 add A,B,A
251
252 sethi %hi(0x8b44f7af),T2
253 and T1,A,T1 !=
254 or T2,%lo(0x8b44f7af),T2
255 xor T1,C,T1
256 LOAD X(10),R10
257 add T1,R9,T1 !=
258 add T1,T2,T1
259 add D,T1,D
260 sll D,12,T2
261 srl D,32-12,D !=
262 or D,T2,D
263 xor A,B,T1
264 add D,A,D
265
266 sethi %hi(0xffff5bb1),T2 !=
267 and T1,D,T1
268 or T2,%lo(0xffff5bb1),T2
269 xor T1,B,T1
270 add T1,R10,T1 !=
271 LOAD X(11),R11
272 add T1,T2,T1
273 add C,T1,C
274 sll C,17,T2 !=
275 srl C,32-17,C
276 or C,T2,C
277 xor D,A,T1
278 add C,D,C !=
279
280 sethi %hi(0x895cd7be),T2
281 and T1,C,T1
282 or T2,%lo(0x895cd7be),T2
283 xor T1,A,T1 !=
284 add T1,R11,T1
285 LOAD X(12),R12
286 add T1,T2,T1
287 add B,T1,B !=
288 sll B,22,T2
289 srl B,32-22,B
290 or B,T2,B
291 xor C,D,T1 !=
292 add B,C,B
293
294 sethi %hi(0x6b901122),T2
295 and T1,B,T1
296 or T2,%lo(0x6b901122),T2 !=
297 xor T1,D,T1
298 add T1,R12,T1
299 LOAD X(13),R13
300 add T1,T2,T1 !=
301 add A,T1,A
302 sll A,7,T2
303 srl A,32-7,A
304 or A,T2,A !=
305 xor B,C,T1
306 add A,B,A
307
308 sethi %hi(0xfd987193),T2
309 and T1,A,T1 !=
310 or T2,%lo(0xfd987193),T2
311 xor T1,C,T1
312 LOAD X(14),RX
313 add T1,R13,T1 !=
314 add T1,T2,T1
315 add D,T1,D
316 sll D,12,T2
317 srl D,32-12,D !=
318 or D,T2,D
319 xor A,B,T1
320 add D,A,D
321
322 sethi %hi(0xa679438e),T2 !=
323 and T1,D,T1
324 or T2,%lo(0xa679438e),T2
325 xor T1,B,T1
326 add T1,RX,T1 !=
327 LOAD X(15),RX
328 add T1,T2,T1
329 add C,T1,C
330 sll C,17,T2 !=
331 srl C,32-17,C
332 or C,T2,C
333 xor D,A,T1
334 add C,D,C !=
335
336 sethi %hi(0x49b40821),T2
337 and T1,C,T1
338 or T2,%lo(0x49b40821),T2
339 xor T1,A,T1 !=
340 add T1,RX,T1
341 !pre-LOADed X(1),R1
342 add T1,T2,T1
343 add B,T1,B
344 sll B,22,T2 !=
345 srl B,32-22,B
346 or B,T2,B
347 add B,C,B
348
349!!!!!!!!Round 1
350
351 xor B,C,T1 !=
352 sethi %hi(0xf61e2562),T2
353 and T1,D,T1
354 or T2,%lo(0xf61e2562),T2
355 xor T1,C,T1 !=
356 add T1,R1,T1
357 !pre-LOADed X(6),R6
358 add T1,T2,T1
359 add A,T1,A
360 sll A,5,T2 !=
361 srl A,32-5,A
362 or A,T2,A
363 add A,B,A
364
365 xor A,B,T1 !=
366 sethi %hi(0xc040b340),T2
367 and T1,C,T1
368 or T2,%lo(0xc040b340),T2
369 xor T1,B,T1 !=
370 add T1,R6,T1
371 !pre-LOADed X(11),R11
372 add T1,T2,T1
373 add D,T1,D
374 sll D,9,T2 !=
375 srl D,32-9,D
376 or D,T2,D
377 add D,A,D
378
379 xor D,A,T1 !=
380 sethi %hi(0x265e5a51),T2
381 and T1,B,T1
382 or T2,%lo(0x265e5a51),T2
383 xor T1,A,T1 !=
384 add T1,R11,T1
385 !pre-LOADed X(0),R0
386 add T1,T2,T1
387 add C,T1,C
388 sll C,14,T2 !=
389 srl C,32-14,C
390 or C,T2,C
391 add C,D,C
392
393 xor C,D,T1 !=
394 sethi %hi(0xe9b6c7aa),T2
395 and T1,A,T1
396 or T2,%lo(0xe9b6c7aa),T2
397 xor T1,D,T1 !=
398 add T1,R0,T1
399 !pre-LOADed X(5),R5
400 add T1,T2,T1
401 add B,T1,B
402 sll B,20,T2 !=
403 srl B,32-20,B
404 or B,T2,B
405 add B,C,B
406
407 xor B,C,T1 !=
408 sethi %hi(0xd62f105d),T2
409 and T1,D,T1
410 or T2,%lo(0xd62f105d),T2
411 xor T1,C,T1 !=
412 add T1,R5,T1
413 !pre-LOADed X(10),R10
414 add T1,T2,T1
415 add A,T1,A
416 sll A,5,T2 !=
417 srl A,32-5,A
418 or A,T2,A
419 add A,B,A
420
421 xor A,B,T1 !=
422 sethi %hi(0x02441453),T2
423 and T1,C,T1
424 or T2,%lo(0x02441453),T2
425 xor T1,B,T1 !=
426 add T1,R10,T1
427 LOAD X(15),RX
428 add T1,T2,T1
429 add D,T1,D !=
430 sll D,9,T2
431 srl D,32-9,D
432 or D,T2,D
433 add D,A,D !=
434
435 xor D,A,T1
436 sethi %hi(0xd8a1e681),T2
437 and T1,B,T1
438 or T2,%lo(0xd8a1e681),T2 !=
439 xor T1,A,T1
440 add T1,RX,T1
441 !pre-LOADed X(4),R4
442 add T1,T2,T1
443 add C,T1,C !=
444 sll C,14,T2
445 srl C,32-14,C
446 or C,T2,C
447 add C,D,C !=
448
449 xor C,D,T1
450 sethi %hi(0xe7d3fbc8),T2
451 and T1,A,T1
452 or T2,%lo(0xe7d3fbc8),T2 !=
453 xor T1,D,T1
454 add T1,R4,T1
455 !pre-LOADed X(9),R9
456 add T1,T2,T1
457 add B,T1,B !=
458 sll B,20,T2
459 srl B,32-20,B
460 or B,T2,B
461 add B,C,B !=
462
463 xor B,C,T1
464 sethi %hi(0x21e1cde6),T2
465 and T1,D,T1
466 or T2,%lo(0x21e1cde6),T2 !=
467 xor T1,C,T1
468 add T1,R9,T1
469 LOAD X(14),RX
470 add T1,T2,T1 !=
471 add A,T1,A
472 sll A,5,T2
473 srl A,32-5,A
474 or A,T2,A !=
475 add A,B,A
476
477 xor A,B,T1
478 sethi %hi(0xc33707d6),T2
479 and T1,C,T1 !=
480 or T2,%lo(0xc33707d6),T2
481 xor T1,B,T1
482 add T1,RX,T1
483 !pre-LOADed X(3),R3
484 add T1,T2,T1 !=
485 add D,T1,D
486 sll D,9,T2
487 srl D,32-9,D
488 or D,T2,D !=
489 add D,A,D
490
491 xor D,A,T1
492 sethi %hi(0xf4d50d87),T2
493 and T1,B,T1 !=
494 or T2,%lo(0xf4d50d87),T2
495 xor T1,A,T1
496 add T1,R3,T1
497 !pre-LOADed X(8),R8
498 add T1,T2,T1 !=
499 add C,T1,C
500 sll C,14,T2
501 srl C,32-14,C
502 or C,T2,C !=
503 add C,D,C
504
505 xor C,D,T1
506 sethi %hi(0x455a14ed),T2
507 and T1,A,T1 !=
508 or T2,%lo(0x455a14ed),T2
509 xor T1,D,T1
510 add T1,R8,T1
511 !pre-LOADed X(13),R13
512 add T1,T2,T1 !=
513 add B,T1,B
514 sll B,20,T2
515 srl B,32-20,B
516 or B,T2,B !=
517 add B,C,B
518
519 xor B,C,T1
520 sethi %hi(0xa9e3e905),T2
521 and T1,D,T1 !=
522 or T2,%lo(0xa9e3e905),T2
523 xor T1,C,T1
524 add T1,R13,T1
525 !pre-LOADed X(2),R2
526 add T1,T2,T1 !=
527 add A,T1,A
528 sll A,5,T2
529 srl A,32-5,A
530 or A,T2,A !=
531 add A,B,A
532
533 xor A,B,T1
534 sethi %hi(0xfcefa3f8),T2
535 and T1,C,T1 !=
536 or T2,%lo(0xfcefa3f8),T2
537 xor T1,B,T1
538 add T1,R2,T1
539 !pre-LOADed X(7),R7
540 add T1,T2,T1 !=
541 add D,T1,D
542 sll D,9,T2
543 srl D,32-9,D
544 or D,T2,D !=
545 add D,A,D
546
547 xor D,A,T1
548 sethi %hi(0x676f02d9),T2
549 and T1,B,T1 !=
550 or T2,%lo(0x676f02d9),T2
551 xor T1,A,T1
552 add T1,R7,T1
553 !pre-LOADed X(12),R12
554 add T1,T2,T1 !=
555 add C,T1,C
556 sll C,14,T2
557 srl C,32-14,C
558 or C,T2,C !=
559 add C,D,C
560
561 xor C,D,T1
562 sethi %hi(0x8d2a4c8a),T2
563 and T1,A,T1 !=
564 or T2,%lo(0x8d2a4c8a),T2
565 xor T1,D,T1
566 add T1,R12,T1
567 !pre-LOADed X(5),R5
568 add T1,T2,T1 !=
569 add B,T1,B
570 sll B,20,T2
571 srl B,32-20,B
572 or B,T2,B !=
573 add B,C,B
574
575!!!!!!!!Round 2
576
577 xor B,C,T1
578 sethi %hi(0xfffa3942),T2
579 xor T1,D,T1 !=
580 or T2,%lo(0xfffa3942),T2
581 add T1,R5,T1
582 !pre-LOADed X(8),R8
583 add T1,T2,T1
584 add A,T1,A !=
585 sll A,4,T2
586 srl A,32-4,A
587 or A,T2,A
588 add A,B,A !=
589
590 xor A,B,T1
591 sethi %hi(0x8771f681),T2
592 xor T1,C,T1
593 or T2,%lo(0x8771f681),T2 !=
594 add T1,R8,T1
595 !pre-LOADed X(11),R11
596 add T1,T2,T1
597 add D,T1,D
598 sll D,11,T2 !=
599 srl D,32-11,D
600 or D,T2,D
601 add D,A,D
602
603 xor D,A,T1 !=
604 sethi %hi(0x6d9d6122),T2
605 xor T1,B,T1
606 or T2,%lo(0x6d9d6122),T2
607 add T1,R11,T1 !=
608 LOAD X(14),RX
609 add T1,T2,T1
610 add C,T1,C
611 sll C,16,T2 !=
612 srl C,32-16,C
613 or C,T2,C
614 add C,D,C
615
616 xor C,D,T1 !=
617 sethi %hi(0xfde5380c),T2
618 xor T1,A,T1
619 or T2,%lo(0xfde5380c),T2
620 add T1,RX,T1 !=
621 !pre-LOADed X(1),R1
622 add T1,T2,T1
623 add B,T1,B
624 sll B,23,T2
625 srl B,32-23,B !=
626 or B,T2,B
627 add B,C,B
628
629 xor B,C,T1
630 sethi %hi(0xa4beea44),T2 !=
631 xor T1,D,T1
632 or T2,%lo(0xa4beea44),T2
633 add T1,R1,T1
634 !pre-LOADed X(4),R4
635 add T1,T2,T1 !=
636 add A,T1,A
637 sll A,4,T2
638 srl A,32-4,A
639 or A,T2,A !=
640 add A,B,A
641
642 xor A,B,T1
643 sethi %hi(0x4bdecfa9),T2
644 xor T1,C,T1 !=
645 or T2,%lo(0x4bdecfa9),T2
646 add T1,R4,T1
647 !pre-LOADed X(7),R7
648 add T1,T2,T1
649 add D,T1,D !=
650 sll D,11,T2
651 srl D,32-11,D
652 or D,T2,D
653 add D,A,D !=
654
655 xor D,A,T1
656 sethi %hi(0xf6bb4b60),T2
657 xor T1,B,T1
658 or T2,%lo(0xf6bb4b60),T2 !=
659 add T1,R7,T1
660 !pre-LOADed X(10),R10
661 add T1,T2,T1
662 add C,T1,C
663 sll C,16,T2 !=
664 srl C,32-16,C
665 or C,T2,C
666 add C,D,C
667
668 xor C,D,T1 !=
669 sethi %hi(0xbebfbc70),T2
670 xor T1,A,T1
671 or T2,%lo(0xbebfbc70),T2
672 add T1,R10,T1 !=
673 !pre-LOADed X(13),R13
674 add T1,T2,T1
675 add B,T1,B
676 sll B,23,T2
677 srl B,32-23,B !=
678 or B,T2,B
679 add B,C,B
680
681 xor B,C,T1
682 sethi %hi(0x289b7ec6),T2 !=
683 xor T1,D,T1
684 or T2,%lo(0x289b7ec6),T2
685 add T1,R13,T1
686 !pre-LOADed X(0),R0
687 add T1,T2,T1 !=
688 add A,T1,A
689 sll A,4,T2
690 srl A,32-4,A
691 or A,T2,A !=
692 add A,B,A
693
694 xor A,B,T1
695 sethi %hi(0xeaa127fa),T2
696 xor T1,C,T1 !=
697 or T2,%lo(0xeaa127fa),T2
698 add T1,R0,T1
699 !pre-LOADed X(3),R3
700 add T1,T2,T1
701 add D,T1,D !=
702 sll D,11,T2
703 srl D,32-11,D
704 or D,T2,D
705 add D,A,D !=
706
707 xor D,A,T1
708 sethi %hi(0xd4ef3085),T2
709 xor T1,B,T1
710 or T2,%lo(0xd4ef3085),T2 !=
711 add T1,R3,T1
712 !pre-LOADed X(6),R6
713 add T1,T2,T1
714 add C,T1,C
715 sll C,16,T2 !=
716 srl C,32-16,C
717 or C,T2,C
718 add C,D,C
719
720 xor C,D,T1 !=
721 sethi %hi(0x04881d05),T2
722 xor T1,A,T1
723 or T2,%lo(0x04881d05),T2
724 add T1,R6,T1 !=
725 !pre-LOADed X(9),R9
726 add T1,T2,T1
727 add B,T1,B
728 sll B,23,T2
729 srl B,32-23,B !=
730 or B,T2,B
731 add B,C,B
732
733 xor B,C,T1
734 sethi %hi(0xd9d4d039),T2 !=
735 xor T1,D,T1
736 or T2,%lo(0xd9d4d039),T2
737 add T1,R9,T1
738 !pre-LOADed X(12),R12
739 add T1,T2,T1 !=
740 add A,T1,A
741 sll A,4,T2
742 srl A,32-4,A
743 or A,T2,A !=
744 add A,B,A
745
746 xor A,B,T1
747 sethi %hi(0xe6db99e5),T2
748 xor T1,C,T1 !=
749 or T2,%lo(0xe6db99e5),T2
750 add T1,R12,T1
751 LOAD X(15),RX
752 add T1,T2,T1 !=
753 add D,T1,D
754 sll D,11,T2
755 srl D,32-11,D
756 or D,T2,D !=
757 add D,A,D
758
759 xor D,A,T1
760 sethi %hi(0x1fa27cf8),T2
761 xor T1,B,T1 !=
762 or T2,%lo(0x1fa27cf8),T2
763 add T1,RX,T1
764 !pre-LOADed X(2),R2
765 add T1,T2,T1
766 add C,T1,C !=
767 sll C,16,T2
768 srl C,32-16,C
769 or C,T2,C
770 add C,D,C !=
771
772 xor C,D,T1
773 sethi %hi(0xc4ac5665),T2
774 xor T1,A,T1
775 or T2,%lo(0xc4ac5665),T2 !=
776 add T1,R2,T1
777 !pre-LOADed X(0),R0
778 add T1,T2,T1
779 add B,T1,B
780 sll B,23,T2 !=
781 srl B,32-23,B
782 or B,T2,B
783 add B,C,B
784
785!!!!!!!!Round 3
786
787 orn B,D,T1 !=
788 sethi %hi(0xf4292244),T2
789 xor T1,C,T1
790 or T2,%lo(0xf4292244),T2
791 add T1,R0,T1 !=
792 !pre-LOADed X(7),R7
793 add T1,T2,T1
794 add A,T1,A
795 sll A,6,T2
796 srl A,32-6,A !=
797 or A,T2,A
798 add A,B,A
799
800 orn A,C,T1
801 sethi %hi(0x432aff97),T2 !=
802 xor T1,B,T1
803 or T2,%lo(0x432aff97),T2
804 LOAD X(14),RX
805 add T1,R7,T1 !=
806 add T1,T2,T1
807 add D,T1,D
808 sll D,10,T2
809 srl D,32-10,D !=
810 or D,T2,D
811 add D,A,D
812
813 orn D,B,T1
814 sethi %hi(0xab9423a7),T2 !=
815 xor T1,A,T1
816 or T2,%lo(0xab9423a7),T2
817 add T1,RX,T1
818 !pre-LOADed X(5),R5
819 add T1,T2,T1 !=
820 add C,T1,C
821 sll C,15,T2
822 srl C,32-15,C
823 or C,T2,C !=
824 add C,D,C
825
826 orn C,A,T1
827 sethi %hi(0xfc93a039),T2
828 xor T1,D,T1 !=
829 or T2,%lo(0xfc93a039),T2
830 add T1,R5,T1
831 !pre-LOADed X(12),R12
832 add T1,T2,T1
833 add B,T1,B !=
834 sll B,21,T2
835 srl B,32-21,B
836 or B,T2,B
837 add B,C,B !=
838
839 orn B,D,T1
840 sethi %hi(0x655b59c3),T2
841 xor T1,C,T1
842 or T2,%lo(0x655b59c3),T2 !=
843 add T1,R12,T1
844 !pre-LOADed X(3),R3
845 add T1,T2,T1
846 add A,T1,A
847 sll A,6,T2 !=
848 srl A,32-6,A
849 or A,T2,A
850 add A,B,A
851
852 orn A,C,T1 !=
853 sethi %hi(0x8f0ccc92),T2
854 xor T1,B,T1
855 or T2,%lo(0x8f0ccc92),T2
856 add T1,R3,T1 !=
857 !pre-LOADed X(10),R10
858 add T1,T2,T1
859 add D,T1,D
860 sll D,10,T2
861 srl D,32-10,D !=
862 or D,T2,D
863 add D,A,D
864
865 orn D,B,T1
866 sethi %hi(0xffeff47d),T2 !=
867 xor T1,A,T1
868 or T2,%lo(0xffeff47d),T2
869 add T1,R10,T1
870 !pre-LOADed X(1),R1
871 add T1,T2,T1 !=
872 add C,T1,C
873 sll C,15,T2
874 srl C,32-15,C
875 or C,T2,C !=
876 add C,D,C
877
878 orn C,A,T1
879 sethi %hi(0x85845dd1),T2
880 xor T1,D,T1 !=
881 or T2,%lo(0x85845dd1),T2
882 add T1,R1,T1
883 !pre-LOADed X(8),R8
884 add T1,T2,T1
885 add B,T1,B !=
886 sll B,21,T2
887 srl B,32-21,B
888 or B,T2,B
889 add B,C,B !=
890
891 orn B,D,T1
892 sethi %hi(0x6fa87e4f),T2
893 xor T1,C,T1
894 or T2,%lo(0x6fa87e4f),T2 !=
895 add T1,R8,T1
896 LOAD X(15),RX
897 add T1,T2,T1
898 add A,T1,A !=
899 sll A,6,T2
900 srl A,32-6,A
901 or A,T2,A
902 add A,B,A !=
903
904 orn A,C,T1
905 sethi %hi(0xfe2ce6e0),T2
906 xor T1,B,T1
907 or T2,%lo(0xfe2ce6e0),T2 !=
908 add T1,RX,T1
909 !pre-LOADed X(6),R6
910 add T1,T2,T1
911 add D,T1,D
912 sll D,10,T2 !=
913 srl D,32-10,D
914 or D,T2,D
915 add D,A,D
916
917 orn D,B,T1 !=
918 sethi %hi(0xa3014314),T2
919 xor T1,A,T1
920 or T2,%lo(0xa3014314),T2
921 add T1,R6,T1 !=
922 !pre-LOADed X(13),R13
923 add T1,T2,T1
924 add C,T1,C
925 sll C,15,T2
926 srl C,32-15,C !=
927 or C,T2,C
928 add C,D,C
929
930 orn C,A,T1
931 sethi %hi(0x4e0811a1),T2 !=
932 xor T1,D,T1
933 or T2,%lo(0x4e0811a1),T2
934 !pre-LOADed X(4),R4
935 ld [Aptr],Aval
936 add T1,R13,T1 !=
937 add T1,T2,T1
938 add B,T1,B
939 sll B,21,T2
940 srl B,32-21,B !=
941 or B,T2,B
942 add B,C,B
943
944 orn B,D,T1
945 sethi %hi(0xf7537e82),T2 !=
946 xor T1,C,T1
947 or T2,%lo(0xf7537e82),T2
948 !pre-LOADed X(11),R11
949 ld [Dptr],Dval
950 add T1,R4,T1 !=
951 add T1,T2,T1
952 add A,T1,A
953 sll A,6,T2
954 srl A,32-6,A !=
955 or A,T2,A
956 add A,B,A
957
958 orn A,C,T1
959 sethi %hi(0xbd3af235),T2 !=
960 xor T1,B,T1
961 or T2,%lo(0xbd3af235),T2
962 !pre-LOADed X(2),R2
963 ld [Cptr],Cval
964 add T1,R11,T1 !=
965 add T1,T2,T1
966 add D,T1,D
967 sll D,10,T2
968 srl D,32-10,D !=
969 or D,T2,D
970 add D,A,D
971
972 orn D,B,T1
973 sethi %hi(0x2ad7d2bb),T2 !=
974 xor T1,A,T1
975 or T2,%lo(0x2ad7d2bb),T2
976 !pre-LOADed X(9),R9
977 ld [Bptr],Bval
978 add T1,R2,T1 !=
979 add Aval,A,Aval
980 add T1,T2,T1
981 st Aval,[Aptr]
982 add C,T1,C !=
983 sll C,15,T2
984 add Dval,D,Dval
985 srl C,32-15,C
986 or C,T2,C !=
987 st Dval,[Dptr]
988 add C,D,C
989
990 orn C,A,T1
991 sethi %hi(0xeb86d391),T2 !=
992 xor T1,D,T1
993 or T2,%lo(0xeb86d391),T2
994 add T1,R9,T1
995 !pre-LOADed X(0),R0
996 mov Aval,A !=
997 add T1,T2,T1
998 mov Dval,D
999 add B,T1,B
1000 sll B,21,T2 !=
1001 add Cval,C,Cval
1002 srl B,32-21,B
1003 st Cval,[Cptr]
1004 or B,T2,B !=
1005 add B,C,B
1006
1007 deccc %i2
1008 mov Cval,C
1009 add B,Bval,B !=
1010 inc 64,%i1
1011 nop
1012 st B,[Bptr]
1013 nop !=
1014
1015#ifdef OPENSSL_SYSNAME_ULTRASPARC
1016 bg,a,pt %icc,.Lmd5_block_loop
1017#else
1018 bg,a .Lmd5_block_loop
1019#endif
1020 LOAD X(0),R0
1021
1022#ifdef ASI_PRIMARY_LITTLE
1023 wr %g0,%o7,%asi
1024#endif
1025 ret
1026 restore %g0,0,%o0
1027
1028.type md5_block,#function
1029.size md5_block,(.-md5_block)
diff --git a/src/lib/libcrypto/md5/md5.c b/src/lib/libcrypto/md5/md5.c
new file mode 100644
index 0000000000..7ed0024ae1
--- /dev/null
+++ b/src/lib/libcrypto/md5/md5.c
@@ -0,0 +1,127 @@
1/* crypto/md5/md5.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <stdlib.h>
61#include <openssl/md5.h>
62
63#define BUFSIZE 1024*16
64
65void do_fp(FILE *f);
66void pt(unsigned char *md);
67#ifndef _OSD_POSIX
68int read(int, void *, unsigned int);
69#endif
70
71int main(int argc, char **argv)
72 {
73 int i,err=0;
74 FILE *IN;
75
76 if (argc == 1)
77 {
78 do_fp(stdin);
79 }
80 else
81 {
82 for (i=1; i<argc; i++)
83 {
84 IN=fopen(argv[i],"r");
85 if (IN == NULL)
86 {
87 perror(argv[i]);
88 err++;
89 continue;
90 }
91 printf("MD5(%s)= ",argv[i]);
92 do_fp(IN);
93 fclose(IN);
94 }
95 }
96 exit(err);
97 }
98
99void do_fp(FILE *f)
100 {
101 MD5_CTX c;
102 unsigned char md[MD5_DIGEST_LENGTH];
103 int fd;
104 int i;
105 static unsigned char buf[BUFSIZE];
106
107 fd=fileno(f);
108 MD5_Init(&c);
109 for (;;)
110 {
111 i=read(fd,buf,BUFSIZE);
112 if (i <= 0) break;
113 MD5_Update(&c,buf,(unsigned long)i);
114 }
115 MD5_Final(&(md[0]),&c);
116 pt(md);
117 }
118
119void pt(unsigned char *md)
120 {
121 int i;
122
123 for (i=0; i<MD5_DIGEST_LENGTH; i++)
124 printf("%02x",md[i]);
125 printf("\n");
126 }
127
diff --git a/src/lib/libcrypto/md5/md5.h b/src/lib/libcrypto/md5/md5.h
index a252e02115..52cb753e6a 100644
--- a/src/lib/libcrypto/md5/md5.h
+++ b/src/lib/libcrypto/md5/md5.h
@@ -59,8 +59,6 @@
59#ifndef HEADER_MD5_H 59#ifndef HEADER_MD5_H
60#define HEADER_MD5_H 60#define HEADER_MD5_H
61 61
62#include <openssl/e_os2.h>
63
64#ifdef __cplusplus 62#ifdef __cplusplus
65extern "C" { 63extern "C" {
66#endif 64#endif
@@ -78,7 +76,7 @@ extern "C" {
78 76
79#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) 77#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__)
80#define MD5_LONG unsigned long 78#define MD5_LONG unsigned long
81#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) 79#elif defined(OENSSL_SYS_CRAY) || defined(__ILP64__)
82#define MD5_LONG unsigned long 80#define MD5_LONG unsigned long
83#define MD5_LONG_LOG2 3 81#define MD5_LONG_LOG2 3
84/* 82/*
diff --git a/src/lib/libcrypto/md5/md5_dgst.c b/src/lib/libcrypto/md5/md5_dgst.c
index 9c7abc3697..c38a3f021e 100644
--- a/src/lib/libcrypto/md5/md5_dgst.c
+++ b/src/lib/libcrypto/md5/md5_dgst.c
@@ -86,7 +86,21 @@ int MD5_Init(MD5_CTX *c)
86void md5_block_host_order (MD5_CTX *c, const void *data, int num) 86void md5_block_host_order (MD5_CTX *c, const void *data, int num)
87 { 87 {
88 const MD5_LONG *X=data; 88 const MD5_LONG *X=data;
89 register unsigned MD32_REG_T A,B,C,D; 89 register unsigned long A,B,C,D;
90 /*
91 * In case you wonder why A-D are declared as long and not
92 * as MD5_LONG. Doing so results in slight performance
93 * boost on LP64 architectures. The catch is we don't
94 * really care if 32 MSBs of a 64-bit register get polluted
95 * with eventual overflows as we *save* only 32 LSBs in
96 * *either* case. Now declaring 'em long excuses the compiler
97 * from keeping 32 MSBs zeroed resulting in 13% performance
98 * improvement under SPARC Solaris7/64 and 5% under AlphaLinux.
99 * Well, to be honest it should say that this *prevents*
100 * performance degradation.
101 *
102 * <appro@fy.chalmers.se>
103 */
90 104
91 A=c->A; 105 A=c->A;
92 B=c->B; 106 B=c->B;
@@ -179,11 +193,25 @@ void md5_block_host_order (MD5_CTX *c, const void *data, int num)
179void md5_block_data_order (MD5_CTX *c, const void *data_, int num) 193void md5_block_data_order (MD5_CTX *c, const void *data_, int num)
180 { 194 {
181 const unsigned char *data=data_; 195 const unsigned char *data=data_;
182 register unsigned MD32_REG_T A,B,C,D,l; 196 register unsigned long A,B,C,D,l;
197 /*
198 * In case you wonder why A-D are declared as long and not
199 * as MD5_LONG. Doing so results in slight performance
200 * boost on LP64 architectures. The catch is we don't
201 * really care if 32 MSBs of a 64-bit register get polluted
202 * with eventual overflows as we *save* only 32 LSBs in
203 * *either* case. Now declaring 'em long excuses the compiler
204 * from keeping 32 MSBs zeroed resulting in 13% performance
205 * improvement under SPARC Solaris7/64 and 5% under AlphaLinux.
206 * Well, to be honest it should say that this *prevents*
207 * performance degradation.
208 *
209 * <appro@fy.chalmers.se>
210 */
183#ifndef MD32_XARRAY 211#ifndef MD32_XARRAY
184 /* See comment in crypto/sha/sha_locl.h for details. */ 212 /* See comment in crypto/sha/sha_locl.h for details. */
185 unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, 213 unsigned long XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
186 XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15; 214 XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15;
187# define X(i) XX##i 215# define X(i) XX##i
188#else 216#else
189 MD5_LONG XX[MD5_LBLOCK]; 217 MD5_LONG XX[MD5_LBLOCK];
diff --git a/src/lib/libcrypto/md5/md5_locl.h b/src/lib/libcrypto/md5/md5_locl.h
index 9e360da732..34c5257306 100644
--- a/src/lib/libcrypto/md5/md5_locl.h
+++ b/src/lib/libcrypto/md5/md5_locl.h
@@ -58,7 +58,7 @@
58 58
59#include <stdlib.h> 59#include <stdlib.h>
60#include <string.h> 60#include <string.h>
61#include <openssl/e_os2.h> 61#include <openssl/opensslconf.h>
62#include <openssl/md5.h> 62#include <openssl/md5.h>
63 63
64#ifndef MD5_LONG_LOG2 64#ifndef MD5_LONG_LOG2
diff --git a/src/lib/libcrypto/md5/md5_one.c b/src/lib/libcrypto/md5/md5_one.c
index c5dd2d81db..b89dec850d 100644
--- a/src/lib/libcrypto/md5/md5_one.c
+++ b/src/lib/libcrypto/md5/md5_one.c
@@ -59,7 +59,6 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <string.h> 60#include <string.h>
61#include <openssl/md5.h> 61#include <openssl/md5.h>
62#include <openssl/crypto.h>
63 62
64#ifdef CHARSET_EBCDIC 63#ifdef CHARSET_EBCDIC
65#include <openssl/ebcdic.h> 64#include <openssl/ebcdic.h>
@@ -90,7 +89,7 @@ unsigned char *MD5(const unsigned char *d, unsigned long n, unsigned char *md)
90 } 89 }
91#endif 90#endif
92 MD5_Final(md,&c); 91 MD5_Final(md,&c);
93 OPENSSL_cleanse(&c,sizeof(c)); /* security consideration */ 92 memset(&c,0,sizeof(c)); /* security consideration */
94 return(md); 93 return(md);
95 } 94 }
96 95
diff --git a/src/lib/libcrypto/md5/md5s.cpp b/src/lib/libcrypto/md5/md5s.cpp
new file mode 100644
index 0000000000..dd343fd4e6
--- /dev/null
+++ b/src/lib/libcrypto/md5/md5s.cpp
@@ -0,0 +1,78 @@
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/md5.h>
36
37extern "C" {
38void md5_block_x86(MD5_CTX *ctx, unsigned char *buffer,int num);
39}
40
41void main(int argc,char *argv[])
42 {
43 unsigned char buffer[64*256];
44 MD5_CTX ctx;
45 unsigned long s1,s2,e1,e2;
46 unsigned char k[16];
47 unsigned long data[2];
48 unsigned char iv[8];
49 int i,num=0,numm;
50 int j=0;
51
52 if (argc >= 2)
53 num=atoi(argv[1]);
54
55 if (num == 0) num=16;
56 if (num > 250) num=16;
57 numm=num+2;
58 num*=64;
59 numm*=64;
60
61 for (j=0; j<6; j++)
62 {
63 for (i=0; i<10; i++) /**/
64 {
65 md5_block_x86(&ctx,buffer,numm);
66 GetTSC(s1);
67 md5_block_x86(&ctx,buffer,numm);
68 GetTSC(e1);
69 GetTSC(s2);
70 md5_block_x86(&ctx,buffer,num);
71 GetTSC(e2);
72 md5_block_x86(&ctx,buffer,num);
73 }
74 printf("md5 (%d bytes) %d %d (%.2f)\n",num,
75 e1-s1,e2-s2,(double)((e1-s1)-(e2-s2))/2);
76 }
77 }
78
diff --git a/src/lib/libcrypto/md5/md5test.c b/src/lib/libcrypto/md5/md5test.c
new file mode 100644
index 0000000000..862b89658a
--- /dev/null
+++ b/src/lib/libcrypto/md5/md5test.c
@@ -0,0 +1,134 @@
1/* crypto/md5/md5test.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 <stdlib.h>
62
63#ifdef OPENSSL_NO_MD5
64int main(int argc, char *argv[])
65{
66 printf("No MD5 support\n");
67 return(0);
68}
69#else
70#include <openssl/evp.h>
71#include <openssl/md5.h>
72
73static char *test[]={
74 "",
75 "a",
76 "abc",
77 "message digest",
78 "abcdefghijklmnopqrstuvwxyz",
79 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
80 "12345678901234567890123456789012345678901234567890123456789012345678901234567890",
81 NULL,
82 };
83
84static char *ret[]={
85 "d41d8cd98f00b204e9800998ecf8427e",
86 "0cc175b9c0f1b6a831c399e269772661",
87 "900150983cd24fb0d6963f7d28e17f72",
88 "f96b697d7cb7938d525a2f31aaf161d0",
89 "c3fcd3d76192e4007dfb496cca67e13b",
90 "d174ab98d277d9f5a5611c2c9f419d9f",
91 "57edf4a22be3c955ac49da2e2107b67a",
92 };
93
94static char *pt(unsigned char *md);
95int main(int argc, char *argv[])
96 {
97 int i,err=0;
98 unsigned char **P,**R;
99 char *p;
100 unsigned char md[MD5_DIGEST_LENGTH];
101
102 P=(unsigned char **)test;
103 R=(unsigned char **)ret;
104 i=1;
105 while (*P != NULL)
106 {
107 EVP_Digest(&(P[0][0]),(unsigned long)strlen((char *)*P),md,NULL,EVP_md5(), NULL);
108 p=pt(md);
109 if (strcmp(p,(char *)*R) != 0)
110 {
111 printf("error calculating MD5 on '%s'\n",*P);
112 printf("got %s instead of %s\n",p,*R);
113 err++;
114 }
115 else
116 printf("test %d ok\n",i);
117 i++;
118 R++;
119 P++;
120 }
121 exit(err);
122 return(0);
123 }
124
125static char *pt(unsigned char *md)
126 {
127 int i;
128 static char buf[80];
129
130 for (i=0; i<MD5_DIGEST_LENGTH; i++)
131 sprintf(&(buf[i*2]),"%02x",md[i]);
132 return(buf);
133 }
134#endif
diff --git a/src/lib/libcrypto/mdc2/Makefile.ssl b/src/lib/libcrypto/mdc2/Makefile.ssl
new file mode 100644
index 0000000000..087b8eb9ee
--- /dev/null
+++ b/src/lib/libcrypto/mdc2/Makefile.ssl
@@ -0,0 +1,98 @@
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
new file mode 100644
index 0000000000..793a8a0f13
--- /dev/null
+++ b/src/lib/libcrypto/mdc2/mdc2.h
@@ -0,0 +1,95 @@
1/* crypto/mdc2/mdc2.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#ifndef HEADER_MDC2_H
60#define HEADER_MDC2_H
61
62#include <openssl/des.h>
63
64#ifdef __cplusplus
65extern "C" {
66#endif
67
68#ifdef OPENSSL_NO_MDC2
69#error MDC2 is disabled.
70#endif
71
72#define MDC2_BLOCK 8
73#define MDC2_DIGEST_LENGTH 16
74
75typedef struct mdc2_ctx_st
76 {
77 int num;
78 unsigned char data[MDC2_BLOCK];
79 DES_cblock h,hh;
80 int pad_type; /* either 1 or 2, default 1 */
81 } MDC2_CTX;
82
83
84int MDC2_Init(MDC2_CTX *c);
85int MDC2_Update(MDC2_CTX *c, const unsigned char *data, unsigned long len);
86int MDC2_Final(unsigned char *md, MDC2_CTX *c);
87unsigned char *MDC2(const unsigned char *d, unsigned long n,
88 unsigned char *md);
89
90#ifdef __cplusplus
91}
92#endif
93
94#endif
95
diff --git a/src/lib/libcrypto/mem.c b/src/lib/libcrypto/mem.c
new file mode 100644
index 0000000000..87d0ebc714
--- /dev/null
+++ b/src/lib/libcrypto/mem.c
@@ -0,0 +1,358 @@
1/* crypto/mem.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <stdlib.h>
61#include <openssl/crypto.h>
62#include "cryptlib.h"
63
64
65static int allow_customize = 1; /* we provide flexible functions for */
66static int allow_customize_debug = 1;/* exchanging memory-related functions at
67 * run-time, but this must be done
68 * before any blocks are actually
69 * allocated; or we'll run into huge
70 * problems when malloc/free pairs
71 * don't match etc. */
72
73
74
75/* the following pointers may be changed as long as 'allow_customize' is set */
76
77static void *(*malloc_func)(size_t) = malloc;
78static void *default_malloc_ex(size_t num, const char *file, int line)
79 { return malloc_func(num); }
80static void *(*malloc_ex_func)(size_t, const char *file, int line)
81 = default_malloc_ex;
82
83static void *(*realloc_func)(void *, size_t)= realloc;
84static void *default_realloc_ex(void *str, size_t num,
85 const char *file, int line)
86 { return realloc_func(str,num); }
87static void *(*realloc_ex_func)(void *, size_t, const char *file, int line)
88 = default_realloc_ex;
89
90static void (*free_func)(void *) = free;
91
92static void *(*malloc_locked_func)(size_t) = malloc;
93static void *default_malloc_locked_ex(size_t num, const char *file, int line)
94 { return malloc_locked_func(num); }
95static void *(*malloc_locked_ex_func)(size_t, const char *file, int line)
96 = default_malloc_locked_ex;
97
98static void (*free_locked_func)(void *) = free;
99
100
101
102/* may be changed as long as 'allow_customize_debug' is set */
103/* XXX use correct function pointer types */
104#ifdef CRYPTO_MDEBUG
105/* use default functions from mem_dbg.c */
106static void (*malloc_debug_func)(void *,int,const char *,int,int)
107 = CRYPTO_dbg_malloc;
108static void (*realloc_debug_func)(void *,void *,int,const char *,int,int)
109 = CRYPTO_dbg_realloc;
110static void (*free_debug_func)(void *,int) = CRYPTO_dbg_free;
111static void (*set_debug_options_func)(long) = CRYPTO_dbg_set_options;
112static long (*get_debug_options_func)(void) = CRYPTO_dbg_get_options;
113#else
114/* applications can use CRYPTO_malloc_debug_init() to select above case
115 * at run-time */
116static void (*malloc_debug_func)(void *,int,const char *,int,int) = NULL;
117static void (*realloc_debug_func)(void *,void *,int,const char *,int,int)
118 = NULL;
119static void (*free_debug_func)(void *,int) = NULL;
120static void (*set_debug_options_func)(long) = NULL;
121static long (*get_debug_options_func)(void) = NULL;
122#endif
123
124
125int CRYPTO_set_mem_functions(void *(*m)(size_t), void *(*r)(void *, size_t),
126 void (*f)(void *))
127 {
128 if (!allow_customize)
129 return 0;
130 if ((m == 0) || (r == 0) || (f == 0))
131 return 0;
132 malloc_func=m; malloc_ex_func=default_malloc_ex;
133 realloc_func=r; realloc_ex_func=default_realloc_ex;
134 free_func=f;
135 malloc_locked_func=m; malloc_locked_ex_func=default_malloc_locked_ex;
136 free_locked_func=f;
137 return 1;
138 }
139
140int CRYPTO_set_mem_ex_functions(
141 void *(*m)(size_t,const char *,int),
142 void *(*r)(void *, size_t,const char *,int),
143 void (*f)(void *))
144 {
145 if (!allow_customize)
146 return 0;
147 if ((m == 0) || (r == 0) || (f == 0))
148 return 0;
149 malloc_func=0; malloc_ex_func=m;
150 realloc_func=0; realloc_ex_func=r;
151 free_func=f;
152 malloc_locked_func=0; malloc_locked_ex_func=m;
153 free_locked_func=f;
154 return 1;
155 }
156
157int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*f)(void *))
158 {
159 if (!allow_customize)
160 return 0;
161 if ((m == NULL) || (f == NULL))
162 return 0;
163 malloc_locked_func=m; malloc_locked_ex_func=default_malloc_locked_ex;
164 free_locked_func=f;
165 return 1;
166 }
167
168int CRYPTO_set_locked_mem_ex_functions(
169 void *(*m)(size_t,const char *,int),
170 void (*f)(void *))
171 {
172 if (!allow_customize)
173 return 0;
174 if ((m == NULL) || (f == NULL))
175 return 0;
176 malloc_locked_func=0; malloc_locked_ex_func=m;
177 free_func=f;
178 return 1;
179 }
180
181int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int),
182 void (*r)(void *,void *,int,const char *,int,int),
183 void (*f)(void *,int),
184 void (*so)(long),
185 long (*go)(void))
186 {
187 if (!allow_customize_debug)
188 return 0;
189 malloc_debug_func=m;
190 realloc_debug_func=r;
191 free_debug_func=f;
192 set_debug_options_func=so;
193 get_debug_options_func=go;
194 return 1;
195 }
196
197
198void CRYPTO_get_mem_functions(void *(**m)(size_t), void *(**r)(void *, size_t),
199 void (**f)(void *))
200 {
201 if (m != NULL) *m = (malloc_ex_func == default_malloc_ex) ?
202 malloc_func : 0;
203 if (r != NULL) *r = (realloc_ex_func == default_realloc_ex) ?
204 realloc_func : 0;
205 if (f != NULL) *f=free_func;
206 }
207
208void CRYPTO_get_mem_ex_functions(
209 void *(**m)(size_t,const char *,int),
210 void *(**r)(void *, size_t,const char *,int),
211 void (**f)(void *))
212 {
213 if (m != NULL) *m = (malloc_ex_func != default_malloc_ex) ?
214 malloc_ex_func : 0;
215 if (r != NULL) *r = (realloc_ex_func != default_realloc_ex) ?
216 realloc_ex_func : 0;
217 if (f != NULL) *f=free_func;
218 }
219
220void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *))
221 {
222 if (m != NULL) *m = (malloc_locked_ex_func == default_malloc_locked_ex) ?
223 malloc_locked_func : 0;
224 if (f != NULL) *f=free_locked_func;
225 }
226
227void CRYPTO_get_locked_mem_ex_functions(
228 void *(**m)(size_t,const char *,int),
229 void (**f)(void *))
230 {
231 if (m != NULL) *m = (malloc_locked_ex_func != default_malloc_locked_ex) ?
232 malloc_locked_ex_func : 0;
233 if (f != NULL) *f=free_locked_func;
234 }
235
236void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int),
237 void (**r)(void *,void *,int,const char *,int,int),
238 void (**f)(void *,int),
239 void (**so)(long),
240 long (**go)(void))
241 {
242 if (m != NULL) *m=malloc_debug_func;
243 if (r != NULL) *r=realloc_debug_func;
244 if (f != NULL) *f=free_debug_func;
245 if (so != NULL) *so=set_debug_options_func;
246 if (go != NULL) *go=get_debug_options_func;
247 }
248
249
250void *CRYPTO_malloc_locked(int num, const char *file, int line)
251 {
252 void *ret = NULL;
253
254 if (num < 0) return NULL;
255
256 allow_customize = 0;
257 if (malloc_debug_func != NULL)
258 {
259 allow_customize_debug = 0;
260 malloc_debug_func(NULL, num, file, line, 0);
261 }
262 ret = malloc_locked_ex_func(num,file,line);
263#ifdef LEVITTE_DEBUG_MEM
264 fprintf(stderr, "LEVITTE_DEBUG_MEM: > 0x%p (%d)\n", ret, num);
265#endif
266 if (malloc_debug_func != NULL)
267 malloc_debug_func(ret, num, file, line, 1);
268
269 return ret;
270 }
271
272void CRYPTO_free_locked(void *str)
273 {
274 if (free_debug_func != NULL)
275 free_debug_func(str, 0);
276#ifdef LEVITTE_DEBUG_MEM
277 fprintf(stderr, "LEVITTE_DEBUG_MEM: < 0x%p\n", str);
278#endif
279 free_locked_func(str);
280 if (free_debug_func != NULL)
281 free_debug_func(NULL, 1);
282 }
283
284void *CRYPTO_malloc(int num, const char *file, int line)
285 {
286 void *ret = NULL;
287
288 if (num < 0) return NULL;
289
290 allow_customize = 0;
291 if (malloc_debug_func != NULL)
292 {
293 allow_customize_debug = 0;
294 malloc_debug_func(NULL, num, file, line, 0);
295 }
296 ret = malloc_ex_func(num,file,line);
297#ifdef LEVITTE_DEBUG_MEM
298 fprintf(stderr, "LEVITTE_DEBUG_MEM: > 0x%p (%d)\n", ret, num);
299#endif
300 if (malloc_debug_func != NULL)
301 malloc_debug_func(ret, num, file, line, 1);
302
303 return ret;
304 }
305
306void *CRYPTO_realloc(void *str, int num, const char *file, int line)
307 {
308 void *ret = NULL;
309
310 if (str == NULL)
311 return CRYPTO_malloc(num, file, line);
312
313 if (num < 0) return NULL;
314
315 if (realloc_debug_func != NULL)
316 realloc_debug_func(str, NULL, num, file, line, 0);
317 ret = realloc_ex_func(str,num,file,line);
318#ifdef LEVITTE_DEBUG_MEM
319 fprintf(stderr, "LEVITTE_DEBUG_MEM: | 0x%p -> 0x%p (%d)\n", str, ret, num);
320#endif
321 if (realloc_debug_func != NULL)
322 realloc_debug_func(str, ret, num, file, line, 1);
323
324 return ret;
325 }
326
327void CRYPTO_free(void *str)
328 {
329 if (free_debug_func != NULL)
330 free_debug_func(str, 0);
331#ifdef LEVITTE_DEBUG_MEM
332 fprintf(stderr, "LEVITTE_DEBUG_MEM: < 0x%p\n", str);
333#endif
334 free_func(str);
335 if (free_debug_func != NULL)
336 free_debug_func(NULL, 1);
337 }
338
339void *CRYPTO_remalloc(void *a, int num, const char *file, int line)
340 {
341 if (a != NULL) OPENSSL_free(a);
342 a=(char *)OPENSSL_malloc(num);
343 return(a);
344 }
345
346
347void CRYPTO_set_mem_debug_options(long bits)
348 {
349 if (set_debug_options_func != NULL)
350 set_debug_options_func(bits);
351 }
352
353long CRYPTO_get_mem_debug_options(void)
354 {
355 if (get_debug_options_func != NULL)
356 return get_debug_options_func();
357 return 0;
358 }
diff --git a/src/lib/libcrypto/mem_dbg.c b/src/lib/libcrypto/mem_dbg.c
index 57bd08f65d..ea94eee6f4 100644
--- a/src/lib/libcrypto/mem_dbg.c
+++ b/src/lib/libcrypto/mem_dbg.c
@@ -102,8 +102,6 @@ typedef struct app_mem_info_st
102 int references; 102 int references;
103 } APP_INFO; 103 } APP_INFO;
104 104
105static void app_info_free(APP_INFO *);
106
107static LHASH *amih=NULL; /* hash-table with those app_mem_info_st's 105static LHASH *amih=NULL; /* hash-table with those app_mem_info_st's
108 * that are at the top of their thread's stack 106 * that are at the top of their thread's stack
109 * (with `thread' as key); 107 * (with `thread' as key);
@@ -142,18 +140,6 @@ static unsigned long disabling_thread = 0; /* Valid iff num_disable > 0.
142 * thread named in disabling_thread). 140 * thread named in disabling_thread).
143 */ 141 */
144 142
145static void app_info_free(APP_INFO *inf)
146 {
147 if (--(inf->references) <= 0)
148 {
149 if (inf->next != NULL)
150 {
151 app_info_free(inf->next);
152 }
153 OPENSSL_free(inf);
154 }
155 }
156
157int CRYPTO_mem_ctrl(int mode) 143int CRYPTO_mem_ctrl(int mode)
158 { 144 {
159 int ret=mh_mode; 145 int ret=mh_mode;
@@ -516,7 +502,9 @@ void CRYPTO_dbg_free(void *addr, int before_p)
516 mp->order, mp->addr, mp->num); 502 mp->order, mp->addr, mp->num);
517#endif 503#endif
518 if (mp->app_info != NULL) 504 if (mp->app_info != NULL)
519 app_info_free(mp->app_info); 505 {
506 mp->app_info->references--;
507 }
520 OPENSSL_free(mp); 508 OPENSSL_free(mp);
521 } 509 }
522 510
@@ -597,6 +585,8 @@ static void print_leak(const MEM *m, MEM_LEAK *l)
597 struct tm *lcl = NULL; 585 struct tm *lcl = NULL;
598 unsigned long ti; 586 unsigned long ti;
599 587
588#define BUF_REMAIN (sizeof buf - (size_t)(bufp - buf))
589
600 if(m->addr == (char *)l->bio) 590 if(m->addr == (char *)l->bio)
601 return; 591 return;
602 592
@@ -604,22 +594,22 @@ static void print_leak(const MEM *m, MEM_LEAK *l)
604 { 594 {
605 lcl = localtime(&m->time); 595 lcl = localtime(&m->time);
606 596
607 sprintf(bufp, "[%02d:%02d:%02d] ", 597 snprintf(bufp, BUF_REMAIN, "[%02d:%02d:%02d] ",
608 lcl->tm_hour,lcl->tm_min,lcl->tm_sec); 598 lcl->tm_hour,lcl->tm_min,lcl->tm_sec);
609 bufp += strlen(bufp); 599 bufp += strlen(bufp);
610 } 600 }
611 601
612 sprintf(bufp, "%5lu file=%s, line=%d, ", 602 snprintf(bufp, BUF_REMAIN, "%5lu file=%s, line=%d, ",
613 m->order,m->file,m->line); 603 m->order,m->file,m->line);
614 bufp += strlen(bufp); 604 bufp += strlen(bufp);
615 605
616 if (options & V_CRYPTO_MDEBUG_THREAD) 606 if (options & V_CRYPTO_MDEBUG_THREAD)
617 { 607 {
618 sprintf(bufp, "thread=%lu, ", m->thread); 608 snprintf(bufp, BUF_REMAIN, "thread=%lu, ", m->thread);
619 bufp += strlen(bufp); 609 bufp += strlen(bufp);
620 } 610 }
621 611
622 sprintf(bufp, "number=%d, address=%08lX\n", 612 snprintf(bufp, BUF_REMAIN, "number=%d, address=%08lX\n",
623 m->num,(unsigned long)m->addr); 613 m->num,(unsigned long)m->addr);
624 bufp += strlen(bufp); 614 bufp += strlen(bufp);
625 615
@@ -641,7 +631,7 @@ static void print_leak(const MEM *m, MEM_LEAK *l)
641 631
642 ami_cnt++; 632 ami_cnt++;
643 memset(buf,'>',ami_cnt); 633 memset(buf,'>',ami_cnt);
644 sprintf(buf + ami_cnt, 634 snprintf(buf + ami_cnt, sizeof buf - ami_cnt,
645 " thread=%lu, file=%s, line=%d, info=\"", 635 " thread=%lu, file=%s, line=%d, info=\"",
646 amip->thread, amip->file, amip->line); 636 amip->thread, amip->file, amip->line);
647 buf_len=strlen(buf); 637 buf_len=strlen(buf);
@@ -653,10 +643,11 @@ static void print_leak(const MEM *m, MEM_LEAK *l)
653 } 643 }
654 else 644 else
655 { 645 {
656 strcpy(buf + buf_len, amip->info); 646 strlcpy(buf + buf_len, amip->info,
647 sizeof buf - buf_len);
657 buf_len = strlen(buf); 648 buf_len = strlen(buf);
658 } 649 }
659 sprintf(buf + buf_len, "\"\n"); 650 snprintf(buf + buf_len, sizeof buf - buf_len, "\"\n");
660 651
661 BIO_puts(l->bio,buf); 652 BIO_puts(l->bio,buf);
662 653
@@ -678,6 +669,7 @@ static IMPLEMENT_LHASH_DOALL_ARG_FN(print_leak, const MEM *, MEM_LEAK *)
678void CRYPTO_mem_leaks(BIO *b) 669void CRYPTO_mem_leaks(BIO *b)
679 { 670 {
680 MEM_LEAK ml; 671 MEM_LEAK ml;
672 char buf[80];
681 673
682 if (mh == NULL && amih == NULL) 674 if (mh == NULL && amih == NULL)
683 return; 675 return;
@@ -692,8 +684,9 @@ void CRYPTO_mem_leaks(BIO *b)
692 (char *)&ml); 684 (char *)&ml);
693 if (ml.chunks != 0) 685 if (ml.chunks != 0)
694 { 686 {
695 BIO_printf(b,"%ld bytes leaked in %d chunks\n", 687 snprintf(buf,sizeof buf,"%ld bytes leaked in %d chunks\n",
696 ml.bytes,ml.chunks); 688 ml.bytes,ml.chunks);
689 BIO_puts(b,buf);
697 } 690 }
698 else 691 else
699 { 692 {
diff --git a/src/lib/libcrypto/o_time.c b/src/lib/libcrypto/o_time.c
index 723eb1b5af..1bc0297b36 100644
--- a/src/lib/libcrypto/o_time.c
+++ b/src/lib/libcrypto/o_time.c
@@ -80,9 +80,6 @@ struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result)
80 ts = result; 80 ts = result;
81#elif !defined(OPENSSL_SYS_VMS) 81#elif !defined(OPENSSL_SYS_VMS)
82 ts = gmtime(timer); 82 ts = gmtime(timer);
83 if (ts == NULL)
84 return NULL;
85
86 memcpy(result, ts, sizeof(struct tm)); 83 memcpy(result, ts, sizeof(struct tm));
87 ts = result; 84 ts = result;
88#endif 85#endif
diff --git a/src/lib/libcrypto/objects/Makefile.ssl b/src/lib/libcrypto/objects/Makefile.ssl
new file mode 100644
index 0000000000..cd5cbc95ce
--- /dev/null
+++ b/src/lib/libcrypto/objects/Makefile.ssl
@@ -0,0 +1,123 @@
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/obj_dat.c b/src/lib/libcrypto/objects/obj_dat.c
index 5d983e3ed4..202bd168ac 100644
--- a/src/lib/libcrypto/objects/obj_dat.c
+++ b/src/lib/libcrypto/objects/obj_dat.c
@@ -462,9 +462,9 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
462 if (i > 2) i=2; 462 if (i > 2) i=2;
463 l-=(long)(i*40); 463 l-=(long)(i*40);
464 464
465 sprintf(tbuf,"%d.%lu",i,l); 465 snprintf(tbuf,sizeof tbuf,"%d.%lu",i,l);
466 i=strlen(tbuf); 466 i=strlen(tbuf);
467 BUF_strlcpy(buf,tbuf,buf_len); 467 strncpy(buf,tbuf,buf_len);
468 buf_len-=i; 468 buf_len-=i;
469 buf+=i; 469 buf+=i;
470 n+=i; 470 n+=i;
@@ -473,10 +473,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
473 for (; idx<len; idx++) { 473 for (; idx<len; idx++) {
474 l|=p[idx]&0x7f; 474 l|=p[idx]&0x7f;
475 if (!(p[idx] & 0x80)) { 475 if (!(p[idx] & 0x80)) {
476 sprintf(tbuf,".%lu",l); 476 snprintf(tbuf,sizeof tbuf,".%lu",l);
477 i=strlen(tbuf); 477 i=strlen(tbuf);
478 if (buf_len > 0) 478 if (buf_len > 0)
479 BUF_strlcpy(buf,tbuf,buf_len); 479 strncpy(buf,tbuf,buf_len);
480 buf_len-=i; 480 buf_len-=i;
481 buf+=i; 481 buf+=i;
482 n+=i; 482 n+=i;
@@ -488,9 +488,10 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
488 s=OBJ_nid2ln(nid); 488 s=OBJ_nid2ln(nid);
489 if (s == NULL) 489 if (s == NULL)
490 s=OBJ_nid2sn(nid); 490 s=OBJ_nid2sn(nid);
491 BUF_strlcpy(buf,s,buf_len); 491 strncpy(buf,s,buf_len);
492 n=strlen(s); 492 n=strlen(s);
493 } 493 }
494 buf[buf_len-1]='\0';
494 return(n); 495 return(n);
495} 496}
496 497
diff --git a/src/lib/libcrypto/objects/obj_dat.pl b/src/lib/libcrypto/objects/obj_dat.pl
index 5dfb84ea00..d0371661f9 100644
--- a/src/lib/libcrypto/objects/obj_dat.pl
+++ b/src/lib/libcrypto/objects/obj_dat.pl
@@ -1,5 +1,9 @@
1#!/usr/local/bin/perl 1#!/usr/local/bin/perl
2 2
3# fixes bug in floating point emulation on sparc64 when
4# this script produces off-by-one output on sparc64
5use integer;
6
3sub obj_cmp 7sub obj_cmp
4 { 8 {
5 local(@a,@b,$_,$r); 9 local(@a,@b,$_,$r);
diff --git a/src/lib/libcrypto/objects/obj_mac.num b/src/lib/libcrypto/objects/obj_mac.num
index 9838072b65..1486199661 100644
--- a/src/lib/libcrypto/objects/obj_mac.num
+++ b/src/lib/libcrypto/objects/obj_mac.num
@@ -645,5 +645,3 @@ rsaOAEPEncryptionSET 644
645itu_t 645 645itu_t 645
646joint_iso_itu_t 646 646joint_iso_itu_t 646
647international_organizations 647 647international_organizations 647
648ms_smartcard_login 648
649ms_upn 649
diff --git a/src/lib/libcrypto/objects/objects.pl b/src/lib/libcrypto/objects/objects.pl
index 76c06cc8f9..76bb8da677 100644
--- a/src/lib/libcrypto/objects/objects.pl
+++ b/src/lib/libcrypto/objects/objects.pl
@@ -107,12 +107,13 @@ while (<IN>)
107 } 107 }
108close IN; 108close IN;
109 109
110open (NUMOUT,">$ARGV[1]") || die "Can't open output file $ARGV[1]"; 110#XXX don't modify input files
111foreach (sort { $a <=> $b } keys %nidn) 111#open (NUMOUT,">$ARGV[1]") || die "Can't open output file $ARGV[1]";
112 { 112#foreach (sort { $a <=> $b } keys %nidn)
113 print NUMOUT $nidn{$_},"\t\t",$_,"\n"; 113# {
114 } 114# print NUMOUT $nidn{$_},"\t\t",$_,"\n";
115close NUMOUT; 115# }
116#close NUMOUT;
116 117
117open (OUT,">$ARGV[2]") || die "Can't open output file $ARGV[2]"; 118open (OUT,">$ARGV[2]") || die "Can't open output file $ARGV[2]";
118print OUT <<'EOF'; 119print OUT <<'EOF';
diff --git a/src/lib/libcrypto/objects/objects.txt b/src/lib/libcrypto/objects/objects.txt
index 3ba11f65cc..71a4908485 100644
--- a/src/lib/libcrypto/objects/objects.txt
+++ b/src/lib/libcrypto/objects/objects.txt
@@ -276,10 +276,6 @@ rsadsi 3 8 : RC5-CBC : rc5-cbc
2761 3 6 1 4 1 311 10 3 3 : msSGC : Microsoft Server Gated Crypto 2761 3 6 1 4 1 311 10 3 3 : msSGC : Microsoft Server Gated Crypto
277!Cname ms-efs 277!Cname ms-efs
2781 3 6 1 4 1 311 10 3 4 : msEFS : Microsoft Encrypted File System 2781 3 6 1 4 1 311 10 3 4 : msEFS : Microsoft Encrypted File System
279!Cname ms-smartcard-login
2801 3 6 1 4 1 311 20 2 2 : msSmartcardLogin : Microsoft Smartcardlogin
281!Cname ms-upn
2821 3 6 1 4 1 311 20 2 3 : msUPN : Microsoft Universal Principal Name
283 279
2841 3 6 1 4 1 188 7 1 1 2 : IDEA-CBC : idea-cbc 2801 3 6 1 4 1 188 7 1 1 2 : IDEA-CBC : idea-cbc
285 : IDEA-ECB : idea-ecb 281 : IDEA-ECB : idea-ecb
@@ -541,7 +537,7 @@ X509 11 : OU : organizationalUnitName
541X509 12 : : title 537X509 12 : : title
542X509 13 : : description 538X509 13 : : description
543X509 41 : name : name 539X509 41 : name : name
544X509 42 : GN : givenName 540X509 42 : gn : givenName
545X509 43 : : initials 541X509 43 : : initials
546X509 44 : : generationQualifier 542X509 44 : : generationQualifier
547X509 45 : : x500UniqueIdentifier 543X509 45 : : x500UniqueIdentifier
diff --git a/src/lib/libcrypto/ocsp/Makefile.ssl b/src/lib/libcrypto/ocsp/Makefile.ssl
new file mode 100644
index 0000000000..2be98179ae
--- /dev/null
+++ b/src/lib/libcrypto/ocsp/Makefile.ssl
@@ -0,0 +1,293 @@
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)
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_asn.c b/src/lib/libcrypto/ocsp/ocsp_asn.c
index 6a3a360d54..8c148cda6a 100644
--- a/src/lib/libcrypto/ocsp/ocsp_asn.c
+++ b/src/lib/libcrypto/ocsp/ocsp_asn.c
@@ -117,7 +117,7 @@ IMPLEMENT_ASN1_FUNCTIONS(OCSP_RESPONSE)
117 117
118ASN1_CHOICE(OCSP_RESPID) = { 118ASN1_CHOICE(OCSP_RESPID) = {
119 ASN1_EXP(OCSP_RESPID, value.byName, X509_NAME, 1), 119 ASN1_EXP(OCSP_RESPID, value.byName, X509_NAME, 1),
120 ASN1_EXP(OCSP_RESPID, value.byKey, ASN1_OCTET_STRING, 2) 120 ASN1_IMP(OCSP_RESPID, value.byKey, ASN1_OCTET_STRING, 2)
121} ASN1_CHOICE_END(OCSP_RESPID) 121} ASN1_CHOICE_END(OCSP_RESPID)
122 122
123IMPLEMENT_ASN1_FUNCTIONS(OCSP_RESPID) 123IMPLEMENT_ASN1_FUNCTIONS(OCSP_RESPID)
diff --git a/src/lib/libcrypto/ocsp/ocsp_ht.c b/src/lib/libcrypto/ocsp/ocsp_ht.c
index 9213e58ae4..b78cd37092 100644
--- a/src/lib/libcrypto/ocsp/ocsp_ht.c
+++ b/src/lib/libcrypto/ocsp/ocsp_ht.c
@@ -64,9 +64,6 @@
64#include <openssl/ocsp.h> 64#include <openssl/ocsp.h>
65#include <openssl/err.h> 65#include <openssl/err.h>
66#include <openssl/buffer.h> 66#include <openssl/buffer.h>
67#ifdef OPENSSL_SYS_SUNOS
68#define strtoul (unsigned long)strtol
69#endif /* OPENSSL_SYS_SUNOS */
70 67
71/* Quick and dirty HTTP OCSP request handler. 68/* Quick and dirty HTTP OCSP request handler.
72 * Could make this a bit cleverer by adding 69 * Could make this a bit cleverer by adding
@@ -97,7 +94,7 @@ Content-Length: %d\r\n\r\n";
97 } 94 }
98 if(!(mem = BIO_new(BIO_s_mem()))) goto err; 95 if(!(mem = BIO_new(BIO_s_mem()))) goto err;
99 /* Copy response to a memory BIO: socket bios can't do gets! */ 96 /* Copy response to a memory BIO: socket bios can't do gets! */
100 while ((len = BIO_read(b, tmpbuf, sizeof tmpbuf))) { 97 while ((len = BIO_read(b, tmpbuf, 1024))) {
101 if(len < 0) { 98 if(len < 0) {
102 OCSPerr(OCSP_F_OCSP_SENDREQ_BIO,OCSP_R_SERVER_READ_ERROR); 99 OCSPerr(OCSP_F_OCSP_SENDREQ_BIO,OCSP_R_SERVER_READ_ERROR);
103 goto err; 100 goto err;
@@ -110,7 +107,7 @@ Content-Length: %d\r\n\r\n";
110 } 107 }
111 /* Parse the HTTP response. This will look like this: 108 /* Parse the HTTP response. This will look like this:
112 * "HTTP/1.0 200 OK". We need to obtain the numeric code and 109 * "HTTP/1.0 200 OK". We need to obtain the numeric code and
113 * (optional) informational message. 110 * informational message.
114 */ 111 */
115 112
116 /* Skip to first white space (passed protocol info) */ 113 /* Skip to first white space (passed protocol info) */
@@ -138,19 +135,13 @@ Content-Length: %d\r\n\r\n";
138 if(*r) goto err; 135 if(*r) goto err;
139 /* Skip over any leading white space in message */ 136 /* Skip over any leading white space in message */
140 while(*q && isspace((unsigned char)*q)) q++; 137 while(*q && isspace((unsigned char)*q)) q++;
141 if(*q) { 138 if(!*q) goto err;
142 /* Finally zap any trailing white space in message (include CRLF) */ 139 /* Finally zap any trailing white space in message (include CRLF) */
143 /* We know q has a non white space character so this is OK */ 140 /* We know q has a non white space character so this is OK */
144 for(r = q + strlen(q) - 1; isspace((unsigned char)*r); r--) *r = 0; 141 for(r = q + strlen(q) - 1; isspace((unsigned char)*r); r--) *r = 0;
145 }
146 if(retcode != 200) { 142 if(retcode != 200) {
147 OCSPerr(OCSP_F_OCSP_SENDREQ_BIO,OCSP_R_SERVER_RESPONSE_ERROR); 143 OCSPerr(OCSP_F_OCSP_SENDREQ_BIO,OCSP_R_SERVER_RESPONSE_ERROR);
148 if(!*q) { 144 ERR_add_error_data(4, "Code=", p, ",Reason=", q);
149 ERR_add_error_data(2, "Code=", p);
150 }
151 else {
152 ERR_add_error_data(4, "Code=", p, ",Reason=", q);
153 }
154 goto err; 145 goto err;
155 } 146 }
156 /* Find blank line marking beginning of content */ 147 /* Find blank line marking beginning of content */
diff --git a/src/lib/libcrypto/opensslconf.h.in b/src/lib/libcrypto/opensslconf.h.in
new file mode 100644
index 0000000000..9082a16c46
--- /dev/null
+++ b/src/lib/libcrypto/opensslconf.h.in
@@ -0,0 +1,158 @@
1/* crypto/opensslconf.h.in */
2
3/* Generate 80386 code? */
4#undef I386_ONLY
5
6#if !(defined(VMS) || defined(__VMS)) /* VMS uses logical names instead */
7#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR)
8#define OPENSSLDIR "/usr/local/ssl"
9#endif
10#endif
11
12#undef OPENSSL_UNISTD
13#define OPENSSL_UNISTD <unistd.h>
14
15#undef OPENSSL_EXPORT_VAR_AS_FUNCTION
16
17#if defined(HEADER_IDEA_H) && !defined(IDEA_INT)
18#define IDEA_INT unsigned int
19#endif
20
21#if defined(HEADER_MD2_H) && !defined(MD2_INT)
22#define MD2_INT unsigned int
23#endif
24
25#if defined(HEADER_RC2_H) && !defined(RC2_INT)
26/* I need to put in a mod for the alpha - eay */
27#define RC2_INT unsigned int
28#endif
29
30#if defined(HEADER_RC4_H)
31#if !defined(RC4_INT)
32/* using int types make the structure larger but make the code faster
33 * on most boxes I have tested - up to %20 faster. */
34/*
35 * I don't know what does "most" mean, but declaring "int" is a must on:
36 * - Intel P6 because partial register stalls are very expensive;
37 * - elder Alpha because it lacks byte load/store instructions;
38 */
39#define RC4_INT unsigned int
40#endif
41#if !defined(RC4_CHUNK)
42/*
43 * This enables code handling data aligned at natural CPU word
44 * boundary. See crypto/rc4/rc4_enc.c for further details.
45 */
46#undef RC4_CHUNK
47#endif
48#endif
49
50#if (defined(HEADER_DES_H) || defined(HEADER_DES_OLD_H)) && !defined(DES_LONG)
51/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
52 * %20 speed up (longs are 8 bytes, int's are 4). */
53#ifndef DES_LONG
54#define DES_LONG unsigned long
55#endif
56#endif
57
58#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H)
59#define CONFIG_HEADER_BN_H
60#undef BN_LLONG
61
62/* Should we define BN_DIV2W here? */
63
64/* Only one for the following should be defined */
65/* The prime number generation stuff may not work when
66 * EIGHT_BIT but I don't care since I've only used this mode
67 * for debuging the bignum libraries */
68#undef SIXTY_FOUR_BIT_LONG
69#undef SIXTY_FOUR_BIT
70#define THIRTY_TWO_BIT
71#undef SIXTEEN_BIT
72#undef EIGHT_BIT
73#endif
74
75#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H)
76#define CONFIG_HEADER_RC4_LOCL_H
77/* if this is defined data[i] is used instead of *data, this is a %20
78 * speedup on x86 */
79#undef RC4_INDEX
80#endif
81
82#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H)
83#define CONFIG_HEADER_BF_LOCL_H
84#undef BF_PTR
85#endif /* HEADER_BF_LOCL_H */
86
87#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H)
88#define CONFIG_HEADER_DES_LOCL_H
89#ifndef DES_DEFAULT_OPTIONS
90/* the following is tweaked from a config script, that is why it is a
91 * protected undef/define */
92#ifndef DES_PTR
93#undef DES_PTR
94#endif
95
96/* This helps C compiler generate the correct code for multiple functional
97 * units. It reduces register dependancies at the expense of 2 more
98 * registers */
99#ifndef DES_RISC1
100#undef DES_RISC1
101#endif
102
103#ifndef DES_RISC2
104#undef DES_RISC2
105#endif
106
107#if defined(DES_RISC1) && defined(DES_RISC2)
108YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
109#endif
110
111/* Unroll the inner loop, this sometimes helps, sometimes hinders.
112 * Very mucy CPU dependant */
113#ifndef DES_UNROLL
114#undef DES_UNROLL
115#endif
116
117/* These default values were supplied by
118 * Peter Gutman <pgut001@cs.auckland.ac.nz>
119 * They are only used if nothing else has been defined */
120#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL)
121/* Special defines which change the way the code is built depending on the
122 CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find
123 even newer MIPS CPU's, but at the moment one size fits all for
124 optimization options. Older Sparc's work better with only UNROLL, but
125 there's no way to tell at compile time what it is you're running on */
126
127#if defined( sun ) /* Newer Sparc's */
128# define DES_PTR
129# define DES_RISC1
130# define DES_UNROLL
131#elif defined( __ultrix ) /* Older MIPS */
132# define DES_PTR
133# define DES_RISC2
134# define DES_UNROLL
135#elif defined( __osf1__ ) /* Alpha */
136# define DES_PTR
137# define DES_RISC2
138#elif defined ( _AIX ) /* RS6000 */
139 /* Unknown */
140#elif defined( __hpux ) /* HP-PA */
141 /* Unknown */
142#elif defined( __aux ) /* 68K */
143 /* Unknown */
144#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */
145# define DES_UNROLL
146#elif defined( __sgi ) /* Newer MIPS */
147# define DES_PTR
148# define DES_RISC2
149# define DES_UNROLL
150#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */
151# define DES_PTR
152# define DES_RISC1
153# define DES_UNROLL
154#endif /* Systems-specific speed defines */
155#endif
156
157#endif /* DES_DEFAULT_OPTIONS */
158#endif /* HEADER_DES_LOCL_H */
diff --git a/src/lib/libcrypto/opensslv.h b/src/lib/libcrypto/opensslv.h
index 08cb1d5018..9689b49c5b 100644
--- a/src/lib/libcrypto/opensslv.h
+++ b/src/lib/libcrypto/opensslv.h
@@ -25,8 +25,8 @@
25 * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for 25 * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for
26 * major minor fix final patch/beta) 26 * major minor fix final patch/beta)
27 */ 27 */
28#define OPENSSL_VERSION_NUMBER 0x0090702fL 28#define OPENSSL_VERSION_NUMBER 0x00907003L
29#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.7b 10 Apr 2003" 29#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.7-beta3 30 Jul 2002"
30#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT 30#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT
31 31
32 32
diff --git a/src/lib/libcrypto/ossl_typ.h b/src/lib/libcrypto/ossl_typ.h
index 285fd0b1d9..6bd42aee4d 100644
--- a/src/lib/libcrypto/ossl_typ.h
+++ b/src/lib/libcrypto/ossl_typ.h
@@ -55,8 +55,6 @@
55#ifndef HEADER_OPENSSL_TYPES_H 55#ifndef HEADER_OPENSSL_TYPES_H
56#define HEADER_OPENSSL_TYPES_H 56#define HEADER_OPENSSL_TYPES_H
57 57
58#include <openssl/e_os2.h>
59
60#ifdef NO_ASN1_TYPEDEFS 58#ifdef NO_ASN1_TYPEDEFS
61#define ASN1_INTEGER ASN1_STRING 59#define ASN1_INTEGER ASN1_STRING
62#define ASN1_ENUMERATED ASN1_STRING 60#define ASN1_ENUMERATED ASN1_STRING
diff --git a/src/lib/libcrypto/pem/Makefile.ssl b/src/lib/libcrypto/pem/Makefile.ssl
new file mode 100644
index 0000000000..5075d9107b
--- /dev/null
+++ b/src/lib/libcrypto/pem/Makefile.ssl
@@ -0,0 +1,336 @@
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 d330cbf9a3..3785fca77d 100644
--- a/src/lib/libcrypto/pem/pem.h
+++ b/src/lib/libcrypto/pem/pem.h
@@ -149,7 +149,7 @@ typedef struct pem_recip_st
149 149
150 int cipher; 150 int cipher;
151 int key_enc; 151 int key_enc;
152 /* char iv[8]; unused and wrong size */ 152 char iv[8];
153 } PEM_USER; 153 } PEM_USER;
154 154
155typedef struct pem_ctx_st 155typedef struct pem_ctx_st
@@ -165,8 +165,7 @@ typedef struct pem_ctx_st
165 165
166 struct { 166 struct {
167 int cipher; 167 int cipher;
168 /* unused, and wrong size 168 unsigned char iv[8];
169 unsigned char iv[8]; */
170 } DEK_info; 169 } DEK_info;
171 170
172 PEM_USER *originator; 171 PEM_USER *originator;
@@ -188,8 +187,7 @@ typedef struct pem_ctx_st
188 EVP_CIPHER *dec; /* date encryption cipher */ 187 EVP_CIPHER *dec; /* date encryption cipher */
189 int key_len; /* key length */ 188 int key_len; /* key length */
190 unsigned char *key; /* key */ 189 unsigned char *key; /* key */
191 /* unused, and wrong size 190 unsigned char iv[8]; /* the iv */
192 unsigned char iv[8]; */
193 191
194 192
195 int data_enc; /* is the data encrypted */ 193 int data_enc; /* is the data encrypted */
diff --git a/src/lib/libcrypto/pem/pem_info.c b/src/lib/libcrypto/pem/pem_info.c
index 9e4af29c95..9a6dffb45c 100644
--- a/src/lib/libcrypto/pem/pem_info.c
+++ b/src/lib/libcrypto/pem/pem_info.c
@@ -324,7 +324,6 @@ int PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc,
324 } 324 }
325 325
326 /* create the right magic header stuff */ 326 /* create the right magic header stuff */
327 OPENSSL_assert(strlen(objstr)+23+2*enc->iv_len+13 <= sizeof buf);
328 buf[0]='\0'; 327 buf[0]='\0';
329 PEM_proc_type(buf,PEM_TYPE_ENCRYPTED); 328 PEM_proc_type(buf,PEM_TYPE_ENCRYPTED);
330 PEM_dek_info(buf,objstr,enc->iv_len,(char *)iv); 329 PEM_dek_info(buf,objstr,enc->iv_len,(char *)iv);
@@ -359,7 +358,7 @@ int PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc,
359 ret=1; 358 ret=1;
360 359
361err: 360err:
362 OPENSSL_cleanse((char *)&ctx,sizeof(ctx)); 361 memset((char *)&ctx,0,sizeof(ctx));
363 OPENSSL_cleanse(buf,PEM_BUFSIZE); 362 memset(buf,0,PEM_BUFSIZE);
364 return(ret); 363 return(ret);
365 } 364 }
diff --git a/src/lib/libcrypto/pem/pem_lib.c b/src/lib/libcrypto/pem/pem_lib.c
index 70b5446797..50f5733654 100644
--- a/src/lib/libcrypto/pem/pem_lib.c
+++ b/src/lib/libcrypto/pem/pem_lib.c
@@ -131,21 +131,23 @@ void PEM_proc_type(char *buf, int type)
131 else 131 else
132 str="BAD-TYPE"; 132 str="BAD-TYPE";
133 133
134 strcat(buf,"Proc-Type: 4,"); 134 strlcat(buf,"Proc-Type: 4,",PEM_BUFSIZE);
135 strcat(buf,str); 135 strlcat(buf,str,PEM_BUFSIZE);
136 strcat(buf,"\n"); 136 strlcat(buf,"\n",PEM_BUFSIZE);
137 } 137 }
138 138
139void PEM_dek_info(char *buf, const char *type, int len, char *str) 139void PEM_dek_info(char *buf, const char *type, int len, char *str)
140 { 140 {
141 static const unsigned char map[17]="0123456789ABCDEF"; 141 static unsigned char map[17]="0123456789ABCDEF";
142 long i; 142 long i;
143 int j; 143 int j;
144 144
145 strcat(buf,"DEK-Info: "); 145 strlcat(buf,"DEK-Info: ",PEM_BUFSIZE);
146 strcat(buf,type); 146 strlcat(buf,type,PEM_BUFSIZE);
147 strcat(buf,","); 147 strlcat(buf,",",PEM_BUFSIZE);
148 j=strlen(buf); 148 j=strlen(buf);
149 if (j + (len * 2) + 1 > PEM_BUFSIZE)
150 return;
149 for (i=0; i<len; i++) 151 for (i=0; i<len; i++)
150 { 152 {
151 buf[j+i*2] =map[(str[i]>>4)&0x0f]; 153 buf[j+i*2] =map[(str[i]>>4)&0x0f];
@@ -249,7 +251,7 @@ int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm, const char
249 ret = 1; 251 ret = 1;
250 252
251err: 253err:
252 if (!ret || !pnm) OPENSSL_free(nm); 254 if (!pnm) OPENSSL_free(nm);
253 OPENSSL_free(header); 255 OPENSSL_free(header);
254 if (!ret) OPENSSL_free(data); 256 if (!ret) OPENSSL_free(data);
255 return ret; 257 return ret;
@@ -304,7 +306,6 @@ int PEM_ASN1_write_bio(int (*i2d)(), const char *name, BIO *bp, char *x,
304 goto err; 306 goto err;
305 } 307 }
306 /* dzise + 8 bytes are needed */ 308 /* dzise + 8 bytes are needed */
307 /* actually it needs the cipher block size extra... */
308 data=(unsigned char *)OPENSSL_malloc((unsigned int)dsize+20); 309 data=(unsigned char *)OPENSSL_malloc((unsigned int)dsize+20);
309 if (data == NULL) 310 if (data == NULL)
310 { 311 {
@@ -334,16 +335,13 @@ int PEM_ASN1_write_bio(int (*i2d)(), const char *name, BIO *bp, char *x,
334 kstr=(unsigned char *)buf; 335 kstr=(unsigned char *)buf;
335 } 336 }
336 RAND_add(data,i,0);/* put in the RSA key. */ 337 RAND_add(data,i,0);/* put in the RSA key. */
337 OPENSSL_assert(enc->iv_len <= sizeof iv);
338 if (RAND_pseudo_bytes(iv,enc->iv_len) < 0) /* Generate a salt */ 338 if (RAND_pseudo_bytes(iv,enc->iv_len) < 0) /* Generate a salt */
339 goto err; 339 goto err;
340 /* The 'iv' is used as the iv and as a salt. It is 340 /* The 'iv' is used as the iv and as a salt. It is
341 * NOT taken from the BytesToKey function */ 341 * NOT taken from the BytesToKey function */
342 EVP_BytesToKey(enc,EVP_md5(),iv,kstr,klen,1,key,NULL); 342 EVP_BytesToKey(enc,EVP_md5(),iv,kstr,klen,1,key,NULL);
343 343
344 if (kstr == (unsigned char *)buf) OPENSSL_cleanse(buf,PEM_BUFSIZE); 344 if (kstr == (unsigned char *)buf) memset(buf,0,PEM_BUFSIZE);
345
346 OPENSSL_assert(strlen(objstr)+23+2*enc->iv_len+13 <= sizeof buf);
347 345
348 buf[0]='\0'; 346 buf[0]='\0';
349 PEM_proc_type(buf,PEM_TYPE_ENCRYPTED); 347 PEM_proc_type(buf,PEM_TYPE_ENCRYPTED);
@@ -366,13 +364,13 @@ int PEM_ASN1_write_bio(int (*i2d)(), const char *name, BIO *bp, char *x,
366 i=PEM_write_bio(bp,name,buf,data,i); 364 i=PEM_write_bio(bp,name,buf,data,i);
367 if (i <= 0) ret=0; 365 if (i <= 0) ret=0;
368err: 366err:
369 OPENSSL_cleanse(key,sizeof(key)); 367 memset(key,0,sizeof(key));
370 OPENSSL_cleanse(iv,sizeof(iv)); 368 memset(iv,0,sizeof(iv));
371 OPENSSL_cleanse((char *)&ctx,sizeof(ctx)); 369 memset((char *)&ctx,0,sizeof(ctx));
372 OPENSSL_cleanse(buf,PEM_BUFSIZE); 370 memset(buf,0,PEM_BUFSIZE);
373 if (data != NULL) 371 if (data != NULL)
374 { 372 {
375 OPENSSL_cleanse(data,(unsigned int)dsize); 373 memset(data,0,(unsigned int)dsize);
376 OPENSSL_free(data); 374 OPENSSL_free(data);
377 } 375 }
378 return(ret); 376 return(ret);
@@ -413,8 +411,8 @@ int PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *plen,
413 EVP_DecryptUpdate(&ctx,data,&i,data,j); 411 EVP_DecryptUpdate(&ctx,data,&i,data,j);
414 o=EVP_DecryptFinal_ex(&ctx,&(data[i]),&j); 412 o=EVP_DecryptFinal_ex(&ctx,&(data[i]),&j);
415 EVP_CIPHER_CTX_cleanup(&ctx); 413 EVP_CIPHER_CTX_cleanup(&ctx);
416 OPENSSL_cleanse((char *)buf,sizeof(buf)); 414 memset((char *)buf,0,sizeof(buf));
417 OPENSSL_cleanse((char *)key,sizeof(key)); 415 memset((char *)key,0,sizeof(key));
418 j+=i; 416 j+=i;
419 if (!o) 417 if (!o)
420 { 418 {
@@ -695,7 +693,7 @@ int PEM_read_bio(BIO *bp, char **name, char **header, unsigned char **data,
695 if (strncmp(buf,"-----END ",9) == 0) 693 if (strncmp(buf,"-----END ",9) == 0)
696 break; 694 break;
697 if (i > 65) break; 695 if (i > 65) break;
698 if (!BUF_MEM_grow_clean(dataB,i+bl+9)) 696 if (!BUF_MEM_grow(dataB,i+bl+9))
699 { 697 {
700 PEMerr(PEM_F_PEM_READ_BIO,ERR_R_MALLOC_FAILURE); 698 PEMerr(PEM_F_PEM_READ_BIO,ERR_R_MALLOC_FAILURE);
701 goto err; 699 goto err;
diff --git a/src/lib/libcrypto/pem/pem_pk8.c b/src/lib/libcrypto/pem/pem_pk8.c
index db38a2a79d..f44182ffb5 100644
--- a/src/lib/libcrypto/pem/pem_pk8.c
+++ b/src/lib/libcrypto/pem/pem_pk8.c
@@ -136,7 +136,7 @@ static int do_pk8pkey(BIO *bp, EVP_PKEY *x, int isder, int nid, const EVP_CIPHER
136 kstr = buf; 136 kstr = buf;
137 } 137 }
138 p8 = PKCS8_encrypt(nid, enc, kstr, klen, NULL, 0, 0, p8inf); 138 p8 = PKCS8_encrypt(nid, enc, kstr, klen, NULL, 0, 0, p8inf);
139 if(kstr == buf) OPENSSL_cleanse(buf, klen); 139 if(kstr == buf) memset(buf, 0, klen);
140 PKCS8_PRIV_KEY_INFO_free(p8inf); 140 PKCS8_PRIV_KEY_INFO_free(p8inf);
141 if(isder) ret = i2d_PKCS8_bio(bp, p8); 141 if(isder) ret = i2d_PKCS8_bio(bp, p8);
142 else ret = PEM_write_bio_PKCS8(bp, p8); 142 else ret = PEM_write_bio_PKCS8(bp, p8);
diff --git a/src/lib/libcrypto/pem/pem_seal.c b/src/lib/libcrypto/pem/pem_seal.c
index 56e08abd70..ae463a301d 100644
--- a/src/lib/libcrypto/pem/pem_seal.c
+++ b/src/lib/libcrypto/pem/pem_seal.c
@@ -112,7 +112,7 @@ int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type, EVP_MD *md_type,
112 ret=npubk; 112 ret=npubk;
113err: 113err:
114 if (s != NULL) OPENSSL_free(s); 114 if (s != NULL) OPENSSL_free(s);
115 OPENSSL_cleanse(key,EVP_MAX_KEY_LENGTH); 115 memset(key,0,EVP_MAX_KEY_LENGTH);
116 return(ret); 116 return(ret);
117 } 117 }
118 118
diff --git a/src/lib/libcrypto/perlasm/alpha.pl b/src/lib/libcrypto/perlasm/alpha.pl
new file mode 100644
index 0000000000..3dac571743
--- /dev/null
+++ b/src/lib/libcrypto/perlasm/alpha.pl
@@ -0,0 +1,434 @@
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/cbc.pl b/src/lib/libcrypto/perlasm/cbc.pl
index 22149c680e..0145c4f0cc 100644
--- a/src/lib/libcrypto/perlasm/cbc.pl
+++ b/src/lib/libcrypto/perlasm/cbc.pl
@@ -146,15 +146,9 @@ sub cbc
146 &mov($count, &wparam(2)); # length 146 &mov($count, &wparam(2)); # length
147 &and($count, 7); 147 &and($count, 7);
148 &jz(&label("finish")); 148 &jz(&label("finish"));
149 &call(&label("PIC_point"));
150&set_label("PIC_point");
151 &blindpop("edx");
152 &lea("ecx",&DWP(&label("cbc_enc_jmp_table")."-".&label("PIC_point"),"edx"));
153 &mov($count,&DWP(0,"ecx",$count,4))
154 &add($count,"edx");
155 &xor("ecx","ecx"); 149 &xor("ecx","ecx");
156 &xor("edx","edx"); 150 &xor("edx","edx");
157 #&mov($count,&DWP(&label("cbc_enc_jmp_table"),"",$count,4)); 151 &mov($count,&DWP(&label("cbc_enc_jmp_table"),"",$count,4));
158 &jmp_ptr($count); 152 &jmp_ptr($count);
159 153
160&set_label("ej7"); 154&set_label("ej7");
@@ -324,23 +318,22 @@ sub cbc
324 318
325 &set_label("cbc_enc_jmp_table",1); 319 &set_label("cbc_enc_jmp_table",1);
326 &data_word("0"); 320 &data_word("0");
327 &data_word(&label("ej1")."-".&label("PIC_point")); 321 &data_word(&label("ej1"));
328 &data_word(&label("ej2")."-".&label("PIC_point")); 322 &data_word(&label("ej2"));
329 &data_word(&label("ej3")."-".&label("PIC_point")); 323 &data_word(&label("ej3"));
330 &data_word(&label("ej4")."-".&label("PIC_point")); 324 &data_word(&label("ej4"));
331 &data_word(&label("ej5")."-".&label("PIC_point")); 325 &data_word(&label("ej5"));
332 &data_word(&label("ej6")."-".&label("PIC_point")); 326 &data_word(&label("ej6"));
333 &data_word(&label("ej7")."-".&label("PIC_point")); 327 &data_word(&label("ej7"));
334 # not used 328 &set_label("cbc_dec_jmp_table",1);
335 #&set_label("cbc_dec_jmp_table",1); 329 &data_word("0");
336 #&data_word("0"); 330 &data_word(&label("dj1"));
337 #&data_word(&label("dj1")."-".&label("PIC_point")); 331 &data_word(&label("dj2"));
338 #&data_word(&label("dj2")."-".&label("PIC_point")); 332 &data_word(&label("dj3"));
339 #&data_word(&label("dj3")."-".&label("PIC_point")); 333 &data_word(&label("dj4"));
340 #&data_word(&label("dj4")."-".&label("PIC_point")); 334 &data_word(&label("dj5"));
341 #&data_word(&label("dj5")."-".&label("PIC_point")); 335 &data_word(&label("dj6"));
342 #&data_word(&label("dj6")."-".&label("PIC_point")); 336 &data_word(&label("dj7"));
343 #&data_word(&label("dj7")."-".&label("PIC_point"));
344 337
345 &function_end_B($name); 338 &function_end_B($name);
346 339
diff --git a/src/lib/libcrypto/perlasm/x86asm.pl b/src/lib/libcrypto/perlasm/x86asm.pl
index 1cb96e914a..9a3d85b098 100644
--- a/src/lib/libcrypto/perlasm/x86asm.pl
+++ b/src/lib/libcrypto/perlasm/x86asm.pl
@@ -18,9 +18,9 @@ sub main'asm_init
18 ($type,$fn,$i386)=@_; 18 ($type,$fn,$i386)=@_;
19 $filename=$fn; 19 $filename=$fn;
20 20
21 $elf=$cpp=$sol=$aout=$win32=$gaswin=0; 21 $cpp=$sol=$aout=$win32=$gaswin=0;
22 if ( ($type eq "elf")) 22 if ( ($type eq "elf"))
23 { $elf=1; require "x86unix.pl"; } 23 { require "x86unix.pl"; }
24 elsif ( ($type eq "a.out")) 24 elsif ( ($type eq "a.out"))
25 { $aout=1; require "x86unix.pl"; } 25 { $aout=1; require "x86unix.pl"; }
26 elsif ( ($type eq "gaswin")) 26 elsif ( ($type eq "gaswin"))
@@ -47,9 +47,6 @@ EOF
47 exit(1); 47 exit(1);
48 } 48 }
49 49
50 $pic=0;
51 for (@ARGV) { $pic=1 if (/\-[fK]PIC/i); }
52
53 &asm_init_output(); 50 &asm_init_output();
54 51
55&comment("Don't even think of reading this code"); 52&comment("Don't even think of reading this code");
@@ -94,7 +91,7 @@ $tmp
94#undef SIZE 91#undef SIZE
95#undef TYPE 92#undef TYPE
96#define SIZE(a,b) 93#define SIZE(a,b)
97#define TYPE(a,b) .def a; .scl 2; .type 32; .endef 94#define TYPE(a,b)
98#endif /* __CYGWIN || __DJGPP */ 95#endif /* __CYGWIN || __DJGPP */
99#endif 96#endif
100 97
diff --git a/src/lib/libcrypto/perlasm/x86ms.pl b/src/lib/libcrypto/perlasm/x86ms.pl
new file mode 100644
index 0000000000..206452341d
--- /dev/null
+++ b/src/lib/libcrypto/perlasm/x86ms.pl
@@ -0,0 +1,365 @@
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 { push(@labels,@_); }
31
32sub main'LB
33 {
34 (defined($lb{$_[0]})) || die "$_[0] does not have a 'low byte'\n";
35 return($lb{$_[0]});
36 }
37
38sub main'HB
39 {
40 (defined($hb{$_[0]})) || die "$_[0] does not have a 'high byte'\n";
41 return($hb{$_[0]});
42 }
43
44sub main'BP
45 {
46 &get_mem("BYTE",@_);
47 }
48
49sub main'DWP
50 {
51 &get_mem("DWORD",@_);
52 }
53
54sub main'BC
55 {
56 return @_;
57 }
58
59sub main'DWC
60 {
61 return @_;
62 }
63
64sub main'stack_push
65 {
66 local($num)=@_;
67 $stack+=$num*4;
68 &main'sub("esp",$num*4);
69 }
70
71sub main'stack_pop
72 {
73 local($num)=@_;
74 $stack-=$num*4;
75 &main'add("esp",$num*4);
76 }
77
78sub get_mem
79 {
80 local($size,$addr,$reg1,$reg2,$idx)=@_;
81 local($t,$post);
82 local($ret)="$size PTR ";
83
84 $addr =~ s/^\s+//;
85 if ($addr =~ /^(.+)\+(.+)$/)
86 {
87 $reg2=&conv($1);
88 $addr="_$2";
89 }
90 elsif ($addr =~ /^[_a-zA-Z]/)
91 {
92 $addr="_$addr";
93 }
94
95 $reg1="$regs{$reg1}" if defined($regs{$reg1});
96 $reg2="$regs{$reg2}" if defined($regs{$reg2});
97 if (($addr ne "") && ($addr ne 0))
98 {
99 if ($addr !~ /^-/)
100 { $ret.=$addr; }
101 else { $post=$addr; }
102 }
103 if ($reg2 ne "")
104 {
105 $t="";
106 $t="*$idx" if ($idx != 0);
107 $reg1="+".$reg1 if ("$reg1$post" ne "");
108 $ret.="[$reg2$t$reg1$post]";
109 }
110 else
111 {
112 $ret.="[$reg1$post]"
113 }
114 return($ret);
115 }
116
117sub main'mov { &out2("mov",@_); }
118sub main'movb { &out2("mov",@_); }
119sub main'and { &out2("and",@_); }
120sub main'or { &out2("or",@_); }
121sub main'shl { &out2("shl",@_); }
122sub main'shr { &out2("shr",@_); }
123sub main'xor { &out2("xor",@_); }
124sub main'xorb { &out2("xor",@_); }
125sub main'add { &out2("add",@_); }
126sub main'adc { &out2("adc",@_); }
127sub main'sub { &out2("sub",@_); }
128sub main'rotl { &out2("rol",@_); }
129sub main'rotr { &out2("ror",@_); }
130sub main'exch { &out2("xchg",@_); }
131sub main'cmp { &out2("cmp",@_); }
132sub main'lea { &out2("lea",@_); }
133sub main'mul { &out1("mul",@_); }
134sub main'div { &out1("div",@_); }
135sub main'dec { &out1("dec",@_); }
136sub main'inc { &out1("inc",@_); }
137sub main'jmp { &out1("jmp",@_); }
138sub main'jmp_ptr { &out1p("jmp",@_); }
139sub main'je { &out1("je",@_); }
140sub main'jle { &out1("jle",@_); }
141sub main'jz { &out1("jz",@_); }
142sub main'jge { &out1("jge",@_); }
143sub main'jl { &out1("jl",@_); }
144sub main'jb { &out1("jb",@_); }
145sub main'jc { &out1("jc",@_); }
146sub main'jnc { &out1("jnc",@_); }
147sub main'jnz { &out1("jnz",@_); }
148sub main'jne { &out1("jne",@_); }
149sub main'jno { &out1("jno",@_); }
150sub main'push { &out1("push",@_); $stack+=4; }
151sub main'pop { &out1("pop",@_); $stack-=4; }
152sub main'bswap { &out1("bswap",@_); &using486(); }
153sub main'not { &out1("not",@_); }
154sub main'call { &out1("call",'_'.$_[0]); }
155sub main'ret { &out0("ret"); }
156sub main'nop { &out0("nop"); }
157
158sub out2
159 {
160 local($name,$p1,$p2)=@_;
161 local($l,$t);
162
163 push(@out,"\t$name\t");
164 $t=&conv($p1).",";
165 $l=length($t);
166 push(@out,$t);
167 $l=4-($l+9)/8;
168 push(@out,"\t" x $l);
169 push(@out,&conv($p2));
170 push(@out,"\n");
171 }
172
173sub out0
174 {
175 local($name)=@_;
176
177 push(@out,"\t$name\n");
178 }
179
180sub out1
181 {
182 local($name,$p1)=@_;
183 local($l,$t);
184
185 push(@out,"\t$name\t".&conv($p1)."\n");
186 }
187
188sub conv
189 {
190 local($p)=@_;
191
192 $p =~ s/0x([0-9A-Fa-f]+)/0$1h/;
193 return $p;
194 }
195
196sub using486
197 {
198 return if $using486;
199 $using486++;
200 grep(s/\.386/\.486/,@out);
201 }
202
203sub main'file
204 {
205 local($file)=@_;
206
207 local($tmp)=<<"EOF";
208 TITLE $file.asm
209 .386
210.model FLAT
211EOF
212 push(@out,$tmp);
213 }
214
215sub main'function_begin
216 {
217 local($func,$extra)=@_;
218
219 push(@labels,$func);
220
221 local($tmp)=<<"EOF";
222_TEXT SEGMENT
223PUBLIC _$func
224$extra
225_$func PROC NEAR
226 push ebp
227 push ebx
228 push esi
229 push edi
230EOF
231 push(@out,$tmp);
232 $stack=20;
233 }
234
235sub main'function_begin_B
236 {
237 local($func,$extra)=@_;
238
239 local($tmp)=<<"EOF";
240_TEXT SEGMENT
241PUBLIC _$func
242$extra
243_$func PROC NEAR
244EOF
245 push(@out,$tmp);
246 $stack=4;
247 }
248
249sub main'function_end
250 {
251 local($func)=@_;
252
253 local($tmp)=<<"EOF";
254 pop edi
255 pop esi
256 pop ebx
257 pop ebp
258 ret
259_$func ENDP
260_TEXT ENDS
261EOF
262 push(@out,$tmp);
263 $stack=0;
264 %label=();
265 }
266
267sub main'function_end_B
268 {
269 local($func)=@_;
270
271 local($tmp)=<<"EOF";
272_$func ENDP
273_TEXT ENDS
274EOF
275 push(@out,$tmp);
276 $stack=0;
277 %label=();
278 }
279
280sub main'function_end_A
281 {
282 local($func)=@_;
283
284 local($tmp)=<<"EOF";
285 pop edi
286 pop esi
287 pop ebx
288 pop ebp
289 ret
290EOF
291 push(@out,$tmp);
292 }
293
294sub main'file_end
295 {
296 push(@out,"END\n");
297 }
298
299sub main'wparam
300 {
301 local($num)=@_;
302
303 return(&main'DWP($stack+$num*4,"esp","",0));
304 }
305
306sub main'swtmp
307 {
308 return(&main'DWP($_[0]*4,"esp","",0));
309 }
310
311# Should use swtmp, which is above esp. Linix can trash the stack above esp
312#sub main'wtmp
313# {
314# local($num)=@_;
315#
316# return(&main'DWP(-(($num+1)*4),"esp","",0));
317# }
318
319sub main'comment
320 {
321 foreach (@_)
322 {
323 push(@out,"\t; $_\n");
324 }
325 }
326
327sub main'label
328 {
329 if (!defined($label{$_[0]}))
330 {
331 $label{$_[0]}="\$${label}${_[0]}";
332 $label++;
333 }
334 return($label{$_[0]});
335 }
336
337sub main'set_label
338 {
339 if (!defined($label{$_[0]}))
340 {
341 $label{$_[0]}="${label}${_[0]}";
342 $label++;
343 }
344 if((defined $_[2]) && ($_[2] == 1))
345 {
346 push(@out,"$label{$_[0]}::\n");
347 }
348 else
349 {
350 push(@out,"$label{$_[0]}:\n");
351 }
352 }
353
354sub main'data_word
355 {
356 push(@out,"\tDD\t$_[0]\n");
357 }
358
359sub out1p
360 {
361 local($name,$p1)=@_;
362 local($l,$t);
363
364 push(@out,"\t$name\t ".&conv($p1)."\n");
365 }
diff --git a/src/lib/libcrypto/perlasm/x86nasm.pl b/src/lib/libcrypto/perlasm/x86nasm.pl
new file mode 100644
index 0000000000..519d8a5867
--- /dev/null
+++ b/src/lib/libcrypto/perlasm/x86nasm.pl
@@ -0,0 +1,342 @@
1#!/usr/local/bin/perl
2
3package x86nasm;
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); }
30
31sub main'external_label
32{
33 push(@labels,@_);
34 foreach (@_) {
35 push(@out, "extern\t_$_\n");
36 }
37}
38
39sub main'LB
40 {
41 (defined($lb{$_[0]})) || die "$_[0] does not have a 'low byte'\n";
42 return($lb{$_[0]});
43 }
44
45sub main'HB
46 {
47 (defined($hb{$_[0]})) || die "$_[0] does not have a 'high byte'\n";
48 return($hb{$_[0]});
49 }
50
51sub main'BP
52 {
53 &get_mem("BYTE",@_);
54 }
55
56sub main'DWP
57 {
58 &get_mem("DWORD",@_);
59 }
60
61sub main'BC
62 {
63 return "BYTE @_";
64 }
65
66sub main'DWC
67 {
68 return "DWORD @_";
69 }
70
71sub main'stack_push
72 {
73 my($num)=@_;
74 $stack+=$num*4;
75 &main'sub("esp",$num*4);
76 }
77
78sub main'stack_pop
79 {
80 my($num)=@_;
81 $stack-=$num*4;
82 &main'add("esp",$num*4);
83 }
84
85sub get_mem
86 {
87 my($size,$addr,$reg1,$reg2,$idx)=@_;
88 my($t,$post);
89 my($ret)="[";
90 $addr =~ s/^\s+//;
91 if ($addr =~ /^(.+)\+(.+)$/)
92 {
93 $reg2=&conv($1);
94 $addr="_$2";
95 }
96 elsif ($addr =~ /^[_a-zA-Z]/)
97 {
98 $addr="_$addr";
99 }
100
101 $reg1="$regs{$reg1}" if defined($regs{$reg1});
102 $reg2="$regs{$reg2}" if defined($regs{$reg2});
103 if (($addr ne "") && ($addr ne 0))
104 {
105 if ($addr !~ /^-/)
106 { $ret.="${addr}+"; }
107 else { $post=$addr; }
108 }
109 if ($reg2 ne "")
110 {
111 $t="";
112 $t="*$idx" if ($idx != 0);
113 $reg1="+".$reg1 if ("$reg1$post" ne "");
114 $ret.="$reg2$t$reg1$post]";
115 }
116 else
117 {
118 $ret.="$reg1$post]"
119 }
120 return($ret);
121 }
122
123sub main'mov { &out2("mov",@_); }
124sub main'movb { &out2("mov",@_); }
125sub main'and { &out2("and",@_); }
126sub main'or { &out2("or",@_); }
127sub main'shl { &out2("shl",@_); }
128sub main'shr { &out2("shr",@_); }
129sub main'xor { &out2("xor",@_); }
130sub main'xorb { &out2("xor",@_); }
131sub main'add { &out2("add",@_); }
132sub main'adc { &out2("adc",@_); }
133sub main'sub { &out2("sub",@_); }
134sub main'rotl { &out2("rol",@_); }
135sub main'rotr { &out2("ror",@_); }
136sub main'exch { &out2("xchg",@_); }
137sub main'cmp { &out2("cmp",@_); }
138sub main'lea { &out2("lea",@_); }
139sub main'mul { &out1("mul",@_); }
140sub main'div { &out1("div",@_); }
141sub main'dec { &out1("dec",@_); }
142sub main'inc { &out1("inc",@_); }
143sub main'jmp { &out1("jmp",@_); }
144sub main'jmp_ptr { &out1p("jmp",@_); }
145
146# This is a bit of a kludge: declare all branches as NEAR.
147sub main'je { &out1("je NEAR",@_); }
148sub main'jle { &out1("jle NEAR",@_); }
149sub main'jz { &out1("jz NEAR",@_); }
150sub main'jge { &out1("jge NEAR",@_); }
151sub main'jl { &out1("jl NEAR",@_); }
152sub main'jb { &out1("jb NEAR",@_); }
153sub main'jc { &out1("jc NEAR",@_); }
154sub main'jnc { &out1("jnc NEAR",@_); }
155sub main'jnz { &out1("jnz NEAR",@_); }
156sub main'jne { &out1("jne NEAR",@_); }
157sub main'jno { &out1("jno NEAR",@_); }
158
159sub main'push { &out1("push",@_); $stack+=4; }
160sub main'pop { &out1("pop",@_); $stack-=4; }
161sub main'bswap { &out1("bswap",@_); &using486(); }
162sub main'not { &out1("not",@_); }
163sub main'call { &out1("call",'_'.$_[0]); }
164sub main'ret { &out0("ret"); }
165sub main'nop { &out0("nop"); }
166
167sub out2
168 {
169 my($name,$p1,$p2)=@_;
170 my($l,$t);
171
172 push(@out,"\t$name\t");
173 $t=&conv($p1).",";
174 $l=length($t);
175 push(@out,$t);
176 $l=4-($l+9)/8;
177 push(@out,"\t" x $l);
178 push(@out,&conv($p2));
179 push(@out,"\n");
180 }
181
182sub out0
183 {
184 my($name)=@_;
185
186 push(@out,"\t$name\n");
187 }
188
189sub out1
190 {
191 my($name,$p1)=@_;
192 my($l,$t);
193 push(@out,"\t$name\t".&conv($p1)."\n");
194 }
195
196sub conv
197 {
198 my($p)=@_;
199 $p =~ s/0x([0-9A-Fa-f]+)/0$1h/;
200 return $p;
201 }
202
203sub using486
204 {
205 return if $using486;
206 $using486++;
207 grep(s/\.386/\.486/,@out);
208 }
209
210sub main'file
211 {
212 push(@out, "segment .text use32\n");
213 }
214
215sub main'function_begin
216 {
217 my($func,$extra)=@_;
218
219 push(@labels,$func);
220 my($tmp)=<<"EOF";
221global _$func
222_$func:
223 push ebp
224 push ebx
225 push esi
226 push edi
227EOF
228 push(@out,$tmp);
229 $stack=20;
230 }
231
232sub main'function_begin_B
233 {
234 my($func,$extra)=@_;
235 my($tmp)=<<"EOF";
236global _$func
237_$func:
238EOF
239 push(@out,$tmp);
240 $stack=4;
241 }
242
243sub main'function_end
244 {
245 my($func)=@_;
246
247 my($tmp)=<<"EOF";
248 pop edi
249 pop esi
250 pop ebx
251 pop ebp
252 ret
253EOF
254 push(@out,$tmp);
255 $stack=0;
256 %label=();
257 }
258
259sub main'function_end_B
260 {
261 $stack=0;
262 %label=();
263 }
264
265sub main'function_end_A
266 {
267 my($func)=@_;
268
269 my($tmp)=<<"EOF";
270 pop edi
271 pop esi
272 pop ebx
273 pop ebp
274 ret
275EOF
276 push(@out,$tmp);
277 }
278
279sub main'file_end
280 {
281 }
282
283sub main'wparam
284 {
285 my($num)=@_;
286
287 return(&main'DWP($stack+$num*4,"esp","",0));
288 }
289
290sub main'swtmp
291 {
292 return(&main'DWP($_[0]*4,"esp","",0));
293 }
294
295# Should use swtmp, which is above esp. Linix can trash the stack above esp
296#sub main'wtmp
297# {
298# my($num)=@_;
299#
300# return(&main'DWP(-(($num+1)*4),"esp","",0));
301# }
302
303sub main'comment
304 {
305 foreach (@_)
306 {
307 push(@out,"\t; $_\n");
308 }
309 }
310
311sub main'label
312 {
313 if (!defined($label{$_[0]}))
314 {
315 $label{$_[0]}="\$${label}${_[0]}";
316 $label++;
317 }
318 return($label{$_[0]});
319 }
320
321sub main'set_label
322 {
323 if (!defined($label{$_[0]}))
324 {
325 $label{$_[0]}="${label}${_[0]}";
326 $label++;
327 }
328 push(@out,"$label{$_[0]}:\n");
329 }
330
331sub main'data_word
332 {
333 push(@out,"\tDD\t$_[0]\n");
334 }
335
336sub out1p
337 {
338 my($name,$p1)=@_;
339 my($l,$t);
340
341 push(@out,"\t$name\t ".&conv($p1)."\n");
342 }
diff --git a/src/lib/libcrypto/perlasm/x86unix.pl b/src/lib/libcrypto/perlasm/x86unix.pl
new file mode 100644
index 0000000000..9ceabf0705
--- /dev/null
+++ b/src/lib/libcrypto/perlasm/x86unix.pl
@@ -0,0 +1,544 @@
1#!/usr/local/bin/perl
2
3package x86unix;
4
5$label="L000";
6$const="";
7$constl=0;
8
9$align=($main'aout)?"4":"16";
10$under=($main'aout)?"_":"";
11$com_start=($main'sol)?"/":"#";
12
13sub main'asm_init_output { @out=(); }
14sub main'asm_get_output { return(@out); }
15sub main'get_labels { return(@labels); }
16sub main'external_label { push(@labels,@_); }
17
18if ($main'cpp)
19 {
20 $align="ALIGN";
21 $under="";
22 $com_start='/*';
23 $com_end='*/';
24 }
25
26%lb=( 'eax', '%al',
27 'ebx', '%bl',
28 'ecx', '%cl',
29 'edx', '%dl',
30 'ax', '%al',
31 'bx', '%bl',
32 'cx', '%cl',
33 'dx', '%dl',
34 );
35
36%hb=( 'eax', '%ah',
37 'ebx', '%bh',
38 'ecx', '%ch',
39 'edx', '%dh',
40 'ax', '%ah',
41 'bx', '%bh',
42 'cx', '%ch',
43 'dx', '%dh',
44 );
45
46%regs=( 'eax', '%eax',
47 'ebx', '%ebx',
48 'ecx', '%ecx',
49 'edx', '%edx',
50 'esi', '%esi',
51 'edi', '%edi',
52 'ebp', '%ebp',
53 'esp', '%esp',
54 );
55
56%reg_val=(
57 'eax', 0x00,
58 'ebx', 0x03,
59 'ecx', 0x01,
60 'edx', 0x02,
61 'esi', 0x06,
62 'edi', 0x07,
63 'ebp', 0x05,
64 'esp', 0x04,
65 );
66
67sub main'LB
68 {
69 (defined($lb{$_[0]})) || die "$_[0] does not have a 'low byte'\n";
70 return($lb{$_[0]});
71 }
72
73sub main'HB
74 {
75 (defined($hb{$_[0]})) || die "$_[0] does not have a 'high byte'\n";
76 return($hb{$_[0]});
77 }
78
79sub main'DWP
80 {
81 local($addr,$reg1,$reg2,$idx)=@_;
82
83 $ret="";
84 $addr =~ s/(^|[+ \t])([A-Za-z_]+[A-Za-z0-9_]+)($|[+ \t])/$1$under$2$3/;
85 $reg1="$regs{$reg1}" if defined($regs{$reg1});
86 $reg2="$regs{$reg2}" if defined($regs{$reg2});
87 $ret.=$addr if ($addr ne "") && ($addr ne 0);
88 if ($reg2 ne "")
89 {
90 if($idx ne "")
91 { $ret.="($reg1,$reg2,$idx)"; }
92 else
93 { $ret.="($reg1,$reg2)"; }
94 }
95 else
96 { $ret.="($reg1)" }
97 return($ret);
98 }
99
100sub main'BP
101 {
102 return(&main'DWP(@_));
103 }
104
105sub main'BC
106 {
107 return @_;
108 }
109
110sub main'DWC
111 {
112 return @_;
113 }
114
115#sub main'BP
116# {
117# local($addr,$reg1,$reg2,$idx)=@_;
118#
119# $ret="";
120#
121# $addr =~ s/(^|[+ \t])([A-Za-z_]+)($|[+ \t])/$1$under$2$3/;
122# $reg1="$regs{$reg1}" if defined($regs{$reg1});
123# $reg2="$regs{$reg2}" if defined($regs{$reg2});
124# $ret.=$addr if ($addr ne "") && ($addr ne 0);
125# if ($reg2 ne "")
126# { $ret.="($reg1,$reg2,$idx)"; }
127# else
128# { $ret.="($reg1)" }
129# return($ret);
130# }
131
132sub main'mov { &out2("movl",@_); }
133sub main'movb { &out2("movb",@_); }
134sub main'and { &out2("andl",@_); }
135sub main'or { &out2("orl",@_); }
136sub main'shl { &out2("sall",@_); }
137sub main'shr { &out2("shrl",@_); }
138sub main'xor { &out2("xorl",@_); }
139sub main'xorb { &out2("xorb",@_); }
140sub main'add { &out2("addl",@_); }
141sub main'adc { &out2("adcl",@_); }
142sub main'sub { &out2("subl",@_); }
143sub main'rotl { &out2("roll",@_); }
144sub main'rotr { &out2("rorl",@_); }
145sub main'exch { &out2("xchg",@_); }
146sub main'cmp { &out2("cmpl",@_); }
147sub main'lea { &out2("leal",@_); }
148sub main'mul { &out1("mull",@_); }
149sub main'div { &out1("divl",@_); }
150sub main'jmp { &out1("jmp",@_); }
151sub main'jmp_ptr { &out1p("jmp",@_); }
152sub main'je { &out1("je",@_); }
153sub main'jle { &out1("jle",@_); }
154sub main'jne { &out1("jne",@_); }
155sub main'jnz { &out1("jnz",@_); }
156sub main'jz { &out1("jz",@_); }
157sub main'jge { &out1("jge",@_); }
158sub main'jl { &out1("jl",@_); }
159sub main'jb { &out1("jb",@_); }
160sub main'jc { &out1("jc",@_); }
161sub main'jnc { &out1("jnc",@_); }
162sub main'jno { &out1("jno",@_); }
163sub main'dec { &out1("decl",@_); }
164sub main'inc { &out1("incl",@_); }
165sub main'push { &out1("pushl",@_); $stack+=4; }
166sub main'pop { &out1("popl",@_); $stack-=4; }
167sub main'pushf { &out0("pushf"); $stack+=4; }
168sub main'popf { &out0("popf"); $stack-=4; }
169sub main'not { &out1("notl",@_); }
170sub main'call { &out1("call",$under.$_[0]); }
171sub main'ret { &out0("ret"); }
172sub main'nop { &out0("nop"); }
173
174# The bswapl instruction is new for the 486. Emulate if i386.
175sub main'bswap
176 {
177 if ($main'i386)
178 {
179 &main'comment("bswapl @_");
180 &main'exch(main'HB(@_),main'LB(@_));
181 &main'rotr(@_,16);
182 &main'exch(main'HB(@_),main'LB(@_));
183 }
184 else
185 {
186 &out1("bswapl",@_);
187 }
188 }
189
190sub out2
191 {
192 local($name,$p1,$p2)=@_;
193 local($l,$ll,$t);
194 local(%special)=( "roll",0xD1C0,"rorl",0xD1C8,
195 "rcll",0xD1D0,"rcrl",0xD1D8,
196 "shll",0xD1E0,"shrl",0xD1E8,
197 "sarl",0xD1F8);
198
199 if ((defined($special{$name})) && defined($regs{$p1}) && ($p2 == 1))
200 {
201 $op=$special{$name}|$reg_val{$p1};
202 $tmp1=sprintf(".byte %d\n",($op>>8)&0xff);
203 $tmp2=sprintf(".byte %d\t",$op &0xff);
204 push(@out,$tmp1);
205 push(@out,$tmp2);
206
207 $p2=&conv($p2);
208 $p1=&conv($p1);
209 &main'comment("$name $p2 $p1");
210 return;
211 }
212
213 push(@out,"\t$name\t");
214 $t=&conv($p2).",";
215 $l=length($t);
216 push(@out,$t);
217 $ll=4-($l+9)/8;
218 $tmp1=sprintf("\t" x $ll);
219 push(@out,$tmp1);
220 push(@out,&conv($p1)."\n");
221 }
222
223sub out1
224 {
225 local($name,$p1)=@_;
226 local($l,$t);
227 local(%special)=("bswapl",0x0FC8);
228
229 if ((defined($special{$name})) && defined($regs{$p1}))
230 {
231 $op=$special{$name}|$reg_val{$p1};
232 $tmp1=sprintf(".byte %d\n",($op>>8)&0xff);
233 $tmp2=sprintf(".byte %d\t",$op &0xff);
234 push(@out,$tmp1);
235 push(@out,$tmp2);
236
237 $p2=&conv($p2);
238 $p1=&conv($p1);
239 &main'comment("$name $p2 $p1");
240 return;
241 }
242
243 push(@out,"\t$name\t".&conv($p1)."\n");
244 }
245
246sub out1p
247 {
248 local($name,$p1)=@_;
249 local($l,$t);
250
251 push(@out,"\t$name\t*".&conv($p1)."\n");
252 }
253
254sub out0
255 {
256 push(@out,"\t$_[0]\n");
257 }
258
259sub conv
260 {
261 local($p)=@_;
262
263# $p =~ s/0x([0-9A-Fa-f]+)/0$1h/;
264
265 $p=$regs{$p} if (defined($regs{$p}));
266
267 $p =~ s/^(-{0,1}[0-9A-Fa-f]+)$/\$$1/;
268 $p =~ s/^(0x[0-9A-Fa-f]+)$/\$$1/;
269 return $p;
270 }
271
272sub main'file
273 {
274 local($file)=@_;
275
276 local($tmp)=<<"EOF";
277 .file "$file.s"
278 .version "01.01"
279gcc2_compiled.:
280EOF
281 push(@out,$tmp);
282 }
283
284sub main'function_begin
285 {
286 local($func)=@_;
287
288 &main'external_label($func);
289 $func=$under.$func;
290
291 local($tmp)=<<"EOF";
292.text
293 .align $align
294.globl $func
295EOF
296 push(@out,$tmp);
297 if ($main'cpp)
298 { $tmp=push(@out,"\tTYPE($func,\@function)\n"); }
299 elsif ($main'gaswin)
300 { $tmp=push(@out,"\t.def\t$func;\t.scl\t2;\t.type\t32;\t.endef\n"); }
301 else { $tmp=push(@out,"\t.type\t$func,\@function\n"); }
302 push(@out,"$func:\n");
303 $tmp=<<"EOF";
304 pushl %ebp
305 pushl %ebx
306 pushl %esi
307 pushl %edi
308
309EOF
310 push(@out,$tmp);
311 $stack=20;
312 }
313
314sub main'function_begin_B
315 {
316 local($func,$extra)=@_;
317
318 &main'external_label($func);
319 $func=$under.$func;
320
321 local($tmp)=<<"EOF";
322.text
323 .align $align
324.globl $func
325EOF
326 push(@out,$tmp);
327 if ($main'cpp)
328 { push(@out,"\tTYPE($func,\@function)\n"); }
329 elsif ($main'gaswin)
330 { $tmp=push(@out,"\t.def\t$func;\t.scl\t2;\t.type\t32;\t.endef\n"); }
331 else { push(@out,"\t.type $func,\@function\n"); }
332 push(@out,"$func:\n");
333 $stack=4;
334 }
335
336sub main'function_end
337 {
338 local($func)=@_;
339
340 $func=$under.$func;
341
342 local($tmp)=<<"EOF";
343 popl %edi
344 popl %esi
345 popl %ebx
346 popl %ebp
347 ret
348.${func}_end:
349EOF
350 push(@out,$tmp);
351
352 if ($main'cpp)
353 { push(@out,"\tSIZE($func,.${func}_end-$func)\n"); }
354 elsif ($main'gaswin)
355 { $tmp=push(@out,"\t.align 4\n"); }
356 else { push(@out,"\t.size\t$func,.${func}_end-$func\n"); }
357 push(@out,".ident \"$func\"\n");
358 $stack=0;
359 %label=();
360 }
361
362sub main'function_end_A
363 {
364 local($func)=@_;
365
366 local($tmp)=<<"EOF";
367 popl %edi
368 popl %esi
369 popl %ebx
370 popl %ebp
371 ret
372EOF
373 push(@out,$tmp);
374 }
375
376sub main'function_end_B
377 {
378 local($func)=@_;
379
380 $func=$under.$func;
381
382 push(@out,".L_${func}_end:\n");
383 if ($main'cpp)
384 { push(@out,"\tSIZE($func,.L_${func}_end-$func)\n"); }
385 elsif ($main'gaswin)
386 { push(@out,"\t.align 4\n"); }
387 else { push(@out,"\t.size\t$func,.L_${func}_end-$func\n"); }
388 push(@out,".ident \"desasm.pl\"\n");
389 $stack=0;
390 %label=();
391 }
392
393sub main'wparam
394 {
395 local($num)=@_;
396
397 return(&main'DWP($stack+$num*4,"esp","",0));
398 }
399
400sub main'stack_push
401 {
402 local($num)=@_;
403 $stack+=$num*4;
404 &main'sub("esp",$num*4);
405 }
406
407sub main'stack_pop
408 {
409 local($num)=@_;
410 $stack-=$num*4;
411 &main'add("esp",$num*4);
412 }
413
414sub main'swtmp
415 {
416 return(&main'DWP($_[0]*4,"esp","",0));
417 }
418
419# Should use swtmp, which is above esp. Linix can trash the stack above esp
420#sub main'wtmp
421# {
422# local($num)=@_;
423#
424# return(&main'DWP(-($num+1)*4,"esp","",0));
425# }
426
427sub main'comment
428 {
429 foreach (@_)
430 {
431 if (/^\s*$/)
432 { push(@out,"\n"); }
433 else
434 { push(@out,"\t$com_start $_ $com_end\n"); }
435 }
436 }
437
438sub main'label
439 {
440 if (!defined($label{$_[0]}))
441 {
442 $label{$_[0]}=".${label}${_[0]}";
443 $label++;
444 }
445 return($label{$_[0]});
446 }
447
448sub main'set_label
449 {
450 if (!defined($label{$_[0]}))
451 {
452 $label{$_[0]}=".${label}${_[0]}";
453 $label++;
454 }
455 push(@out,".align $align\n") if ($_[1] != 0);
456 push(@out,"$label{$_[0]}:\n");
457 }
458
459sub main'file_end
460 {
461 if ($const ne "")
462 {
463 push(@out,".section .rodata\n");
464 push(@out,$const);
465 $const="";
466 }
467 }
468
469sub main'data_word
470 {
471 push(@out,"\t.long $_[0]\n");
472 }
473
474# debug output functions: puts, putx, printf
475
476sub main'puts
477 {
478 &pushvars();
479 &main'push('$Lstring' . ++$constl);
480 &main'call('puts');
481 $stack-=4;
482 &main'add("esp",4);
483 &popvars();
484
485 $const .= "Lstring$constl:\n\t.string \"@_[0]\"\n";
486 }
487
488sub main'putx
489 {
490 &pushvars();
491 &main'push($_[0]);
492 &main'push('$Lstring' . ++$constl);
493 &main'call('printf');
494 &main'add("esp",8);
495 $stack-=8;
496 &popvars();
497
498 $const .= "Lstring$constl:\n\t.string \"\%X\"\n";
499 }
500
501sub main'printf
502 {
503 $ostack = $stack;
504 &pushvars();
505 for ($i = @_ - 1; $i >= 0; $i--)
506 {
507 if ($i == 0) # change this to support %s format strings
508 {
509 &main'push('$Lstring' . ++$constl);
510 $const .= "Lstring$constl:\n\t.string \"@_[$i]\"\n";
511 }
512 else
513 {
514 if ($_[$i] =~ /([0-9]*)\(%esp\)/)
515 {
516 &main'push(($1 + $stack - $ostack) . '(%esp)');
517 }
518 else
519 {
520 &main'push($_[$i]);
521 }
522 }
523 }
524 &main'call('printf');
525 $stack-=4*@_;
526 &main'add("esp",4*@_);
527 &popvars();
528 }
529
530sub pushvars
531 {
532 &main'pushf();
533 &main'push("edx");
534 &main'push("ecx");
535 &main'push("eax");
536 }
537
538sub popvars
539 {
540 &main'pop("eax");
541 &main'pop("ecx");
542 &main'pop("edx");
543 &main'popf();
544 }
diff --git a/src/lib/libcrypto/pkcs12/Makefile.ssl b/src/lib/libcrypto/pkcs12/Makefile.ssl
new file mode 100644
index 0000000000..2b1d175157
--- /dev/null
+++ b/src/lib/libcrypto/pkcs12/Makefile.ssl
@@ -0,0 +1,417 @@
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_crpt.c b/src/lib/libcrypto/pkcs12/p12_crpt.c
index 5e8958612b..97be6a5fb5 100644
--- a/src/lib/libcrypto/pkcs12/p12_crpt.c
+++ b/src/lib/libcrypto/pkcs12/p12_crpt.c
@@ -118,7 +118,7 @@ int PKCS12_PBE_keyivgen (EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
118 } 118 }
119 PBEPARAM_free(pbe); 119 PBEPARAM_free(pbe);
120 EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, en_de); 120 EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, en_de);
121 OPENSSL_cleanse(key, EVP_MAX_KEY_LENGTH); 121 memset(key, 0, EVP_MAX_KEY_LENGTH);
122 OPENSSL_cleanse(iv, EVP_MAX_IV_LENGTH); 122 memset(iv, 0, EVP_MAX_IV_LENGTH);
123 return 1; 123 return 1;
124} 124}
diff --git a/src/lib/libcrypto/pkcs12/p12_decr.c b/src/lib/libcrypto/pkcs12/p12_decr.c
index b5684a83ba..394af368f4 100644
--- a/src/lib/libcrypto/pkcs12/p12_decr.c
+++ b/src/lib/libcrypto/pkcs12/p12_decr.c
@@ -136,7 +136,7 @@ void * PKCS12_item_decrypt_d2i(X509_ALGOR *algor, const ASN1_ITEM *it,
136 } 136 }
137#endif 137#endif
138 ret = ASN1_item_d2i(NULL, &p, outlen, it); 138 ret = ASN1_item_d2i(NULL, &p, outlen, it);
139 if (zbuf) OPENSSL_cleanse(out, outlen); 139 if (zbuf) memset(out, 0, outlen);
140 if(!ret) PKCS12err(PKCS12_F_PKCS12_DECRYPT_D2I,PKCS12_R_DECODE_ERROR); 140 if(!ret) PKCS12err(PKCS12_F_PKCS12_DECRYPT_D2I,PKCS12_R_DECODE_ERROR);
141 OPENSSL_free(out); 141 OPENSSL_free(out);
142 return ret; 142 return ret;
@@ -168,7 +168,7 @@ ASN1_OCTET_STRING *PKCS12_item_i2d_encrypt(X509_ALGOR *algor, const ASN1_ITEM *i
168 OPENSSL_free(in); 168 OPENSSL_free(in);
169 return NULL; 169 return NULL;
170 } 170 }
171 if (zbuf) OPENSSL_cleanse(in, inlen); 171 if (zbuf) memset(in, 0, inlen);
172 OPENSSL_free(in); 172 OPENSSL_free(in);
173 return oct; 173 return oct;
174} 174}
diff --git a/src/lib/libcrypto/pkcs12/p12_key.c b/src/lib/libcrypto/pkcs12/p12_key.c
index 9196a34b4a..0d39ebde8c 100644
--- a/src/lib/libcrypto/pkcs12/p12_key.c
+++ b/src/lib/libcrypto/pkcs12/p12_key.c
@@ -91,7 +91,7 @@ int PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt,
91 ret = PKCS12_key_gen_uni(unipass, uniplen, salt, saltlen, 91 ret = PKCS12_key_gen_uni(unipass, uniplen, salt, saltlen,
92 id, iter, n, out, md_type); 92 id, iter, n, out, md_type);
93 if(unipass) { 93 if(unipass) {
94 OPENSSL_cleanse(unipass, uniplen); /* Clear password from memory */ 94 memset(unipass, 0, uniplen); /* Clear password from memory */
95 OPENSSL_free(unipass); 95 OPENSSL_free(unipass);
96 } 96 }
97 return ret; 97 return ret;
diff --git a/src/lib/libcrypto/pkcs12/p12_npas.c b/src/lib/libcrypto/pkcs12/p12_npas.c
index af708a2743..a549433eeb 100644
--- a/src/lib/libcrypto/pkcs12/p12_npas.c
+++ b/src/lib/libcrypto/pkcs12/p12_npas.c
@@ -107,7 +107,7 @@ static int newpass_p12(PKCS12 *p12, char *oldpass, char *newpass)
107{ 107{
108 STACK_OF(PKCS7) *asafes, *newsafes; 108 STACK_OF(PKCS7) *asafes, *newsafes;
109 STACK_OF(PKCS12_SAFEBAG) *bags; 109 STACK_OF(PKCS12_SAFEBAG) *bags;
110 int i, bagnid, pbe_nid = 0, pbe_iter = 0, pbe_saltlen = 0; 110 int i, bagnid, pbe_nid, pbe_iter, pbe_saltlen;
111 PKCS7 *p7, *p7new; 111 PKCS7 *p7, *p7new;
112 ASN1_OCTET_STRING *p12_data_tmp = NULL, *macnew = NULL; 112 ASN1_OCTET_STRING *p12_data_tmp = NULL, *macnew = NULL;
113 unsigned char mac[EVP_MAX_MD_SIZE]; 113 unsigned char mac[EVP_MAX_MD_SIZE];
diff --git a/src/lib/libcrypto/pkcs7/Makefile.ssl b/src/lib/libcrypto/pkcs7/Makefile.ssl
new file mode 100644
index 0000000000..1302469def
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/Makefile.ssl
@@ -0,0 +1,243 @@
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/bio_ber.c b/src/lib/libcrypto/pkcs7/bio_ber.c
new file mode 100644
index 0000000000..42331f7ab0
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/bio_ber.c
@@ -0,0 +1,466 @@
1/* crypto/evp/bio_ber.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 <errno.h>
61#include "cryptlib.h"
62#include <openssl/buffer.h>
63#include <openssl/evp.h>
64
65static int ber_write(BIO *h,char *buf,int num);
66static int ber_read(BIO *h,char *buf,int size);
67/*static int ber_puts(BIO *h,char *str); */
68/*static int ber_gets(BIO *h,char *str,int size); */
69static long ber_ctrl(BIO *h,int cmd,long arg1,char *arg2);
70static int ber_new(BIO *h);
71static int ber_free(BIO *data);
72static long ber_callback_ctrl(BIO *h,int cmd,void *(*fp)());
73#define BER_BUF_SIZE (32)
74
75/* This is used to hold the state of the BER objects being read. */
76typedef struct ber_struct
77 {
78 int tag;
79 int class;
80 long length;
81 int inf;
82 int num_left;
83 int depth;
84 } BER_CTX;
85
86typedef struct bio_ber_struct
87 {
88 int tag;
89 int class;
90 long length;
91 int inf;
92
93 /* most of the following are used when doing non-blocking IO */
94 /* reading */
95 long num_left; /* number of bytes still to read/write in block */
96 int depth; /* used with indefinite encoding. */
97 int finished; /* No more read data */
98
99 /* writting */
100 char *w_addr;
101 int w_offset;
102 int w_left;
103
104 int buf_len;
105 int buf_off;
106 unsigned char buf[BER_BUF_SIZE];
107 } BIO_BER_CTX;
108
109static BIO_METHOD methods_ber=
110 {
111 BIO_TYPE_CIPHER,"cipher",
112 ber_write,
113 ber_read,
114 NULL, /* ber_puts, */
115 NULL, /* ber_gets, */
116 ber_ctrl,
117 ber_new,
118 ber_free,
119 ber_callback_ctrl,
120 };
121
122BIO_METHOD *BIO_f_ber(void)
123 {
124 return(&methods_ber);
125 }
126
127static int ber_new(BIO *bi)
128 {
129 BIO_BER_CTX *ctx;
130
131 ctx=(BIO_BER_CTX *)OPENSSL_malloc(sizeof(BIO_BER_CTX));
132 if (ctx == NULL) return(0);
133
134 memset((char *)ctx,0,sizeof(BIO_BER_CTX));
135
136 bi->init=0;
137 bi->ptr=(char *)ctx;
138 bi->flags=0;
139 return(1);
140 }
141
142static int ber_free(BIO *a)
143 {
144 BIO_BER_CTX *b;
145
146 if (a == NULL) return(0);
147 b=(BIO_BER_CTX *)a->ptr;
148 memset(a->ptr,0,sizeof(BIO_BER_CTX));
149 OPENSSL_free(a->ptr);
150 a->ptr=NULL;
151 a->init=0;
152 a->flags=0;
153 return(1);
154 }
155
156int bio_ber_get_header(BIO *bio, BIO_BER_CTX *ctx)
157 {
158 char buf[64];
159 int i,j,n;
160 int ret;
161 unsigned char *p;
162 unsigned long length
163 int tag;
164 int class;
165 long max;
166
167 BIO_clear_retry_flags(b);
168
169 /* Pack the buffer down if there is a hole at the front */
170 if (ctx->buf_off != 0)
171 {
172 p=ctx->buf;
173 j=ctx->buf_off;
174 n=ctx->buf_len-j;
175 for (i=0; i<n; i++)
176 {
177 p[0]=p[j];
178 p++;
179 }
180 ctx->buf_len-j;
181 ctx->buf_off=0;
182 }
183
184 /* If there is more room, read some more data */
185 i=BER_BUF_SIZE-ctx->buf_len;
186 if (i)
187 {
188 i=BIO_read(bio->next_bio,&(ctx->buf[ctx->buf_len]),i);
189 if (i <= 0)
190 {
191 BIO_copy_next_retry(b);
192 return(i);
193 }
194 else
195 ctx->buf_len+=i;
196 }
197
198 max=ctx->buf_len;
199 p=ctx->buf;
200 ret=ASN1_get_object(&p,&length,&tag,&class,max);
201
202 if (ret & 0x80)
203 {
204 if ((ctx->buf_len < BER_BUF_SIZE) &&
205 (ERR_GET_REASON(ERR_peek_error()) == ASN1_R_TOO_LONG))
206 {
207 ERR_get_error(); /* clear the error */
208 BIO_set_retry_read(b);
209 }
210 return(-1);
211 }
212
213 /* We have no error, we have a header, so make use of it */
214
215 if ((ctx->tag >= 0) && (ctx->tag != tag))
216 {
217 BIOerr(BIO_F_BIO_BER_GET_HEADER,BIO_R_TAG_MISMATCH);
218 sprintf(buf,"tag=%d, got %d",ctx->tag,tag);
219 ERR_add_error_data(1,buf);
220 return(-1);
221 }
222 if (ret & 0x01)
223 if (ret & V_ASN1_CONSTRUCTED)
224 }
225
226static int ber_read(BIO *b, char *out, int outl)
227 {
228 int ret=0,i,n;
229 BIO_BER_CTX *ctx;
230
231 BIO_clear_retry_flags(b);
232
233 if (out == NULL) return(0);
234 ctx=(BIO_BER_CTX *)b->ptr;
235
236 if ((ctx == NULL) || (b->next_bio == NULL)) return(0);
237
238 if (ctx->finished) return(0);
239
240again:
241 /* First see if we are half way through reading a block */
242 if (ctx->num_left > 0)
243 {
244 if (ctx->num_left < outl)
245 n=ctx->num_left;
246 else
247 n=outl;
248 i=BIO_read(b->next_bio,out,n);
249 if (i <= 0)
250 {
251 BIO_copy_next_retry(b);
252 return(i);
253 }
254 ctx->num_left-=i;
255 outl-=i;
256 ret+=i;
257 if (ctx->num_left <= 0)
258 {
259 ctx->depth--;
260 if (ctx->depth <= 0)
261 ctx->finished=1;
262 }
263 if (outl <= 0)
264 return(ret);
265 else
266 goto again;
267 }
268 else /* we need to read another BER header */
269 {
270 }
271 }
272
273static int ber_write(BIO *b, char *in, int inl)
274 {
275 int ret=0,n,i;
276 BIO_ENC_CTX *ctx;
277
278 ctx=(BIO_ENC_CTX *)b->ptr;
279 ret=inl;
280
281 BIO_clear_retry_flags(b);
282 n=ctx->buf_len-ctx->buf_off;
283 while (n > 0)
284 {
285 i=BIO_write(b->next_bio,&(ctx->buf[ctx->buf_off]),n);
286 if (i <= 0)
287 {
288 BIO_copy_next_retry(b);
289 return(i);
290 }
291 ctx->buf_off+=i;
292 n-=i;
293 }
294 /* at this point all pending data has been written */
295
296 if ((in == NULL) || (inl <= 0)) return(0);
297
298 ctx->buf_off=0;
299 while (inl > 0)
300 {
301 n=(inl > ENC_BLOCK_SIZE)?ENC_BLOCK_SIZE:inl;
302 EVP_CipherUpdate(&(ctx->cipher),
303 (unsigned char *)ctx->buf,&ctx->buf_len,
304 (unsigned char *)in,n);
305 inl-=n;
306 in+=n;
307
308 ctx->buf_off=0;
309 n=ctx->buf_len;
310 while (n > 0)
311 {
312 i=BIO_write(b->next_bio,&(ctx->buf[ctx->buf_off]),n);
313 if (i <= 0)
314 {
315 BIO_copy_next_retry(b);
316 return(i);
317 }
318 n-=i;
319 ctx->buf_off+=i;
320 }
321 ctx->buf_len=0;
322 ctx->buf_off=0;
323 }
324 BIO_copy_next_retry(b);
325 return(ret);
326 }
327
328static long ber_ctrl(BIO *b, int cmd, long num, char *ptr)
329 {
330 BIO *dbio;
331 BIO_ENC_CTX *ctx,*dctx;
332 long ret=1;
333 int i;
334
335 ctx=(BIO_ENC_CTX *)b->ptr;
336
337 switch (cmd)
338 {
339 case BIO_CTRL_RESET:
340 ctx->ok=1;
341 ctx->finished=0;
342 EVP_CipherInit_ex(&(ctx->cipher),NULL,NULL,NULL,NULL,
343 ctx->cipher.berrypt);
344 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
345 break;
346 case BIO_CTRL_EOF: /* More to read */
347 if (ctx->cont <= 0)
348 ret=1;
349 else
350 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
351 break;
352 case BIO_CTRL_WPENDING:
353 ret=ctx->buf_len-ctx->buf_off;
354 if (ret <= 0)
355 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
356 break;
357 case BIO_CTRL_PENDING: /* More to read in buffer */
358 ret=ctx->buf_len-ctx->buf_off;
359 if (ret <= 0)
360 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
361 break;
362 case BIO_CTRL_FLUSH:
363 /* do a final write */
364again:
365 while (ctx->buf_len != ctx->buf_off)
366 {
367 i=ber_write(b,NULL,0);
368 if (i < 0)
369 {
370 ret=i;
371 break;
372 }
373 }
374
375 if (!ctx->finished)
376 {
377 ctx->finished=1;
378 ctx->buf_off=0;
379 ret=EVP_CipherFinal_ex(&(ctx->cipher),
380 (unsigned char *)ctx->buf,
381 &(ctx->buf_len));
382 ctx->ok=(int)ret;
383 if (ret <= 0) break;
384
385 /* push out the bytes */
386 goto again;
387 }
388
389 /* Finally flush the underlying BIO */
390 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
391 break;
392 case BIO_C_GET_CIPHER_STATUS:
393 ret=(long)ctx->ok;
394 break;
395 case BIO_C_DO_STATE_MACHINE:
396 BIO_clear_retry_flags(b);
397 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
398 BIO_copy_next_retry(b);
399 break;
400
401 case BIO_CTRL_DUP:
402 dbio=(BIO *)ptr;
403 dctx=(BIO_ENC_CTX *)dbio->ptr;
404 memcpy(&(dctx->cipher),&(ctx->cipher),sizeof(ctx->cipher));
405 dbio->init=1;
406 break;
407 default:
408 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
409 break;
410 }
411 return(ret);
412 }
413
414static long ber_callback_ctrl(BIO *b, int cmd, void *(*fp)())
415 {
416 long ret=1;
417
418 if (b->next_bio == NULL) return(0);
419 switch (cmd)
420 {
421 default:
422 ret=BIO_callback_ctrl(b->next_bio,cmd,fp);
423 break;
424 }
425 return(ret);
426 }
427
428/*
429void BIO_set_cipher_ctx(b,c)
430BIO *b;
431EVP_CIPHER_ctx *c;
432 {
433 if (b == NULL) return;
434
435 if ((b->callback != NULL) &&
436 (b->callback(b,BIO_CB_CTRL,(char *)c,BIO_CTRL_SET,e,0L) <= 0))
437 return;
438
439 b->init=1;
440 ctx=(BIO_ENC_CTX *)b->ptr;
441 memcpy(ctx->cipher,c,sizeof(EVP_CIPHER_CTX));
442
443 if (b->callback != NULL)
444 b->callback(b,BIO_CB_CTRL,(char *)c,BIO_CTRL_SET,e,1L);
445 }
446*/
447
448void BIO_set_cipher(BIO *b, EVP_CIPHER *c, unsigned char *k, unsigned char *i,
449 int e)
450 {
451 BIO_ENC_CTX *ctx;
452
453 if (b == NULL) return;
454
455 if ((b->callback != NULL) &&
456 (b->callback(b,BIO_CB_CTRL,(char *)c,BIO_CTRL_SET,e,0L) <= 0))
457 return;
458
459 b->init=1;
460 ctx=(BIO_ENC_CTX *)b->ptr;
461 EVP_CipherInit_ex(&(ctx->cipher),c,NULL,k,i,e);
462
463 if (b->callback != NULL)
464 b->callback(b,BIO_CB_CTRL,(char *)c,BIO_CTRL_SET,e,1L);
465 }
466
diff --git a/src/lib/libcrypto/pkcs7/dec.c b/src/lib/libcrypto/pkcs7/dec.c
new file mode 100644
index 0000000000..6752ec568a
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/dec.c
@@ -0,0 +1,248 @@
1/* crypto/pkcs7/verify.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 <string.h>
61#include <openssl/bio.h>
62#include <openssl/x509.h>
63#include <openssl/pem.h>
64#include <openssl/err.h>
65#include <openssl/asn1.h>
66
67int verify_callback(int ok, X509_STORE_CTX *ctx);
68
69BIO *bio_err=NULL;
70
71int main(argc,argv)
72int argc;
73char *argv[];
74 {
75 char *keyfile=NULL;
76 BIO *in;
77 EVP_PKEY *pkey;
78 X509 *x509;
79 PKCS7 *p7;
80 PKCS7_SIGNER_INFO *si;
81 X509_STORE_CTX cert_ctx;
82 X509_STORE *cert_store=NULL;
83 BIO *data,*detached=NULL,*p7bio=NULL;
84 char buf[1024*4];
85 unsigned char *pp;
86 int i,printit=0;
87 STACK_OF(PKCS7_SIGNER_INFO) *sk;
88
89 OpenSSL_add_all_algorithms();
90 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
91
92 data=BIO_new(BIO_s_file());
93 pp=NULL;
94 while (argc > 1)
95 {
96 argc--;
97 argv++;
98 if (strcmp(argv[0],"-p") == 0)
99 {
100 printit=1;
101 }
102 else if ((strcmp(argv[0],"-k") == 0) && (argc >= 2)) {
103 keyfile = argv[1];
104 argc-=1;
105 argv+=1;
106 } else if ((strcmp(argv[0],"-d") == 0) && (argc >= 2))
107 {
108 detached=BIO_new(BIO_s_file());
109 if (!BIO_read_filename(detached,argv[1]))
110 goto err;
111 argc-=1;
112 argv+=1;
113 }
114 else break;
115 }
116
117 if (!BIO_read_filename(data,argv[0])) goto err;
118
119 if(!keyfile) {
120 fprintf(stderr, "No private key file specified\n");
121 goto err;
122 }
123
124 if ((in=BIO_new_file(keyfile,"r")) == NULL) goto err;
125 if ((x509=PEM_read_bio_X509(in,NULL,NULL,NULL)) == NULL) goto err;
126 BIO_reset(in);
127 if ((pkey=PEM_read_bio_PrivateKey(in,NULL,NULL,NULL)) == NULL)
128 goto err;
129 BIO_free(in);
130
131 if (pp == NULL)
132 BIO_set_fp(data,stdin,BIO_NOCLOSE);
133
134
135 /* Load the PKCS7 object from a file */
136 if ((p7=PEM_read_bio_PKCS7(data,NULL,NULL,NULL)) == NULL) goto err;
137
138
139
140 /* This stuff is being setup for certificate verification.
141 * When using SSL, it could be replaced with a
142 * cert_stre=SSL_CTX_get_cert_store(ssl_ctx); */
143 cert_store=X509_STORE_new();
144 X509_STORE_set_default_paths(cert_store);
145 X509_STORE_load_locations(cert_store,NULL,"../../certs");
146 X509_STORE_set_verify_cb_func(cert_store,verify_callback);
147
148 ERR_clear_error();
149
150 /* We need to process the data */
151 /* We cannot support detached encryption */
152 p7bio=PKCS7_dataDecode(p7,pkey,detached,x509);
153
154 if (p7bio == NULL)
155 {
156 printf("problems decoding\n");
157 goto err;
158 }
159
160 /* We now have to 'read' from p7bio to calculate digests etc. */
161 for (;;)
162 {
163 i=BIO_read(p7bio,buf,sizeof(buf));
164 /* print it? */
165 if (i <= 0) break;
166 fwrite(buf,1, i, stdout);
167 }
168
169 /* We can now verify signatures */
170 sk=PKCS7_get_signer_info(p7);
171 if (sk == NULL)
172 {
173 fprintf(stderr, "there are no signatures on this data\n");
174 }
175 else
176 {
177 /* Ok, first we need to, for each subject entry,
178 * see if we can verify */
179 ERR_clear_error();
180 for (i=0; i<sk_PKCS7_SIGNER_INFO_num(sk); i++)
181 {
182 si=sk_PKCS7_SIGNER_INFO_value(sk,i);
183 i=PKCS7_dataVerify(cert_store,&cert_ctx,p7bio,p7,si);
184 if (i <= 0)
185 goto err;
186 else
187 fprintf(stderr,"Signature verified\n");
188 }
189 }
190 X509_STORE_free(cert_store);
191
192 exit(0);
193err:
194 ERR_load_crypto_strings();
195 ERR_print_errors_fp(stderr);
196 exit(1);
197 }
198
199/* should be X509 * but we can just have them as char *. */
200int verify_callback(int ok, X509_STORE_CTX *ctx)
201 {
202 char buf[256];
203 X509 *err_cert;
204 int err,depth;
205
206 err_cert=X509_STORE_CTX_get_current_cert(ctx);
207 err= X509_STORE_CTX_get_error(ctx);
208 depth= X509_STORE_CTX_get_error_depth(ctx);
209
210 X509_NAME_oneline(X509_get_subject_name(err_cert),buf,256);
211 BIO_printf(bio_err,"depth=%d %s\n",depth,buf);
212 if (!ok)
213 {
214 BIO_printf(bio_err,"verify error:num=%d:%s\n",err,
215 X509_verify_cert_error_string(err));
216 if (depth < 6)
217 {
218 ok=1;
219 X509_STORE_CTX_set_error(ctx,X509_V_OK);
220 }
221 else
222 {
223 ok=0;
224 X509_STORE_CTX_set_error(ctx,X509_V_ERR_CERT_CHAIN_TOO_LONG);
225 }
226 }
227 switch (ctx->error)
228 {
229 case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT:
230 X509_NAME_oneline(X509_get_issuer_name(ctx->current_cert),buf,256);
231 BIO_printf(bio_err,"issuer= %s\n",buf);
232 break;
233 case X509_V_ERR_CERT_NOT_YET_VALID:
234 case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD:
235 BIO_printf(bio_err,"notBefore=");
236 ASN1_UTCTIME_print(bio_err,X509_get_notBefore(ctx->current_cert));
237 BIO_printf(bio_err,"\n");
238 break;
239 case X509_V_ERR_CERT_HAS_EXPIRED:
240 case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD:
241 BIO_printf(bio_err,"notAfter=");
242 ASN1_UTCTIME_print(bio_err,X509_get_notAfter(ctx->current_cert));
243 BIO_printf(bio_err,"\n");
244 break;
245 }
246 BIO_printf(bio_err,"verify return:%d\n",ok);
247 return(ok);
248 }
diff --git a/src/lib/libcrypto/pkcs7/des.pem b/src/lib/libcrypto/pkcs7/des.pem
new file mode 100644
index 0000000000..62d1657e3e
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/des.pem
@@ -0,0 +1,15 @@
1
2MIAGCSqGSIb3DQEHA6CAMIACAQAxggHmMIHwAgEAMIGZMIGSMQswCQYDVQQGEwJBVTETMBEG
3A1UECBMKUXVlZW5zbGFuZDERMA8GA1UEBxMIQnJpc2JhbmUxGjAYBgNVBAoTEUNyeXB0c29m
4dCBQdHkgTHRkMSIwIAYDVQQLExlERU1PTlNUUkFUSU9OIEFORCBURVNUSU5HMRswGQYDVQQD
5ExJERU1PIFpFUk8gVkFMVUUgQ0ECAgR+MA0GCSqGSIb3DQEBAQUABEC2vXI1xQDW6lUHM3zQ
6/9uBEBOO5A3TtkrklAXq7v01gsIC21t52qSk36REXY+slhNZ0OQ349tgkTsoETHFLoEwMIHw
7AgEAMIGZMIGSMQswCQYDVQQGEwJBVTETMBEGA1UECBMKUXVlZW5zbGFuZDERMA8GA1UEBxMI
8QnJpc2JhbmUxGjAYBgNVBAoTEUNyeXB0c29mdCBQdHkgTHRkMSIwIAYDVQQLExlERU1PTlNU
9UkFUSU9OIEFORCBURVNUSU5HMRswGQYDVQQDExJERU1PIFpFUk8gVkFMVUUgQ0ECAgR9MA0G
10CSqGSIb3DQEBAQUABEB8ujxbabxXUYJhopuDm3oDq4JNqX6Io4p3ro+ShqfIndsXTZ1v5a2N
11WtLLCWlHn/habjBwZ/DgQgcKASbZ7QxNMIAGCSqGSIb3DQEHATAaBggqhkiG9w0DAjAOAgIA
12oAQIbsL5v1wX98KggAQoAaJ4WHm68fXY1WE5OIjfVBIDpO1K+i8dmKhjnAjrjoyZ9Bwc8rDL
13lgQg4CXb805h5xl+GfvSwUaHJayte1m2mcOhs3J2YyqbQ+MEIMIiJQccmhO3oDKm36CFvYR8
145PjpclVcZyX2ngbwPFMnBAgy0clOAE6UKAAAAAAAAAAAAAA=
15
diff --git a/src/lib/libcrypto/pkcs7/doc b/src/lib/libcrypto/pkcs7/doc
new file mode 100644
index 0000000000..d2e8b7b2a3
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/doc
@@ -0,0 +1,24 @@
1int PKCS7_set_content_type(PKCS7 *p7, int type);
2Call to set the type of PKCS7 object we are working on
3
4int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey,
5 EVP_MD *dgst);
6Use this to setup a signer info
7There will also be functions to add signed and unsigned attributes.
8
9int PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *p7i);
10Add a signer info to the content.
11
12int PKCS7_add_certificae(PKCS7 *p7, X509 *x509);
13int PKCS7_add_crl(PKCS7 *p7, X509_CRL *x509);
14
15----
16
17p7=PKCS7_new();
18PKCS7_set_content_type(p7,NID_pkcs7_signed);
19
20signer=PKCS7_SINGNER_INFO_new();
21PKCS7_SIGNER_INFO_set(signer,x509,pkey,EVP_md5());
22PKCS7_add_signer(py,signer);
23
24we are now setup.
diff --git a/src/lib/libcrypto/pkcs7/enc.c b/src/lib/libcrypto/pkcs7/enc.c
new file mode 100644
index 0000000000..7417f8a4e0
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/enc.c
@@ -0,0 +1,174 @@
1/* crypto/pkcs7/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#include <stdio.h>
59#include <string.h>
60#include <openssl/bio.h>
61#include <openssl/x509.h>
62#include <openssl/pem.h>
63#include <openssl/err.h>
64
65int main(argc,argv)
66int argc;
67char *argv[];
68 {
69 X509 *x509;
70 PKCS7 *p7;
71 BIO *in;
72 BIO *data,*p7bio;
73 char buf[1024*4];
74 int i;
75 int nodetach=1;
76 char *keyfile = NULL;
77 const EVP_CIPHER *cipher=NULL;
78 STACK_OF(X509) *recips=NULL;
79
80 OpenSSL_add_all_algorithms();
81
82 data=BIO_new(BIO_s_file());
83 while(argc > 1)
84 {
85 if (strcmp(argv[1],"-nd") == 0)
86 {
87 nodetach=1;
88 argv++; argc--;
89 }
90 else if ((strcmp(argv[1],"-c") == 0) && (argc >= 2)) {
91 if(!(cipher = EVP_get_cipherbyname(argv[2]))) {
92 fprintf(stderr, "Unknown cipher %s\n", argv[2]);
93 goto err;
94 }
95 argc-=2;
96 argv+=2;
97 } else if ((strcmp(argv[1],"-k") == 0) && (argc >= 2)) {
98 keyfile = argv[2];
99 argc-=2;
100 argv+=2;
101 if (!(in=BIO_new_file(keyfile,"r"))) goto err;
102 if (!(x509=PEM_read_bio_X509(in,NULL,NULL,NULL)))
103 goto err;
104 if(!recips) recips = sk_X509_new_null();
105 sk_X509_push(recips, x509);
106 BIO_free(in);
107 } else break;
108 }
109
110 if(!recips) {
111 fprintf(stderr, "No recipients\n");
112 goto err;
113 }
114
115 if (!BIO_read_filename(data,argv[1])) goto err;
116
117 p7=PKCS7_new();
118#if 0
119 BIO_reset(in);
120 if ((pkey=PEM_read_bio_PrivateKey(in,NULL,NULL)) == NULL) goto err;
121 BIO_free(in);
122 PKCS7_set_type(p7,NID_pkcs7_signedAndEnveloped);
123
124 if (PKCS7_add_signature(p7,x509,pkey,EVP_sha1()) == NULL) goto err;
125 /* we may want to add more */
126 PKCS7_add_certificate(p7,x509);
127#else
128 PKCS7_set_type(p7,NID_pkcs7_enveloped);
129#endif
130 if(!cipher) {
131#ifndef OPENSSL_NO_DES
132 cipher = EVP_des_ede3_cbc();
133#else
134 fprintf(stderr, "No cipher selected\n");
135 goto err;
136#endif
137 }
138
139 if (!PKCS7_set_cipher(p7,cipher)) goto err;
140 for(i = 0; i < sk_X509_num(recips); i++) {
141 if (!PKCS7_add_recipient(p7,sk_X509_value(recips, i))) goto err;
142 }
143 sk_X509_pop_free(recips, X509_free);
144
145 /* Set the content of the signed to 'data' */
146 /* PKCS7_content_new(p7,NID_pkcs7_data); not used in envelope */
147
148 /* could be used, but not in this version :-)
149 if (!nodetach) PKCS7_set_detached(p7,1);
150 */
151
152 if ((p7bio=PKCS7_dataInit(p7,NULL)) == NULL) goto err;
153
154 for (;;)
155 {
156 i=BIO_read(data,buf,sizeof(buf));
157 if (i <= 0) break;
158 BIO_write(p7bio,buf,i);
159 }
160 BIO_flush(p7bio);
161
162 if (!PKCS7_dataFinal(p7,p7bio)) goto err;
163 BIO_free(p7bio);
164
165 PEM_write_PKCS7(stdout,p7);
166 PKCS7_free(p7);
167
168 exit(0);
169err:
170 ERR_load_crypto_strings();
171 ERR_print_errors_fp(stderr);
172 exit(1);
173 }
174
diff --git a/src/lib/libcrypto/pkcs7/es1.pem b/src/lib/libcrypto/pkcs7/es1.pem
new file mode 100644
index 0000000000..47112a238f
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/es1.pem
@@ -0,0 +1,66 @@
1-----BEGIN PKCS7-----
2MIAGCSqGSIb3DQEHA6CAMIACAQAxggHmMIHwAgEAMIGZMIGSMQswCQYDVQQGEwJBVTETMBEG
3A1UECBMKUXVlZW5zbGFuZDERMA8GA1UEBxMIQnJpc2JhbmUxGjAYBgNVBAoTEUNyeXB0c29m
4dCBQdHkgTHRkMSIwIAYDVQQLExlERU1PTlNUUkFUSU9OIEFORCBURVNUSU5HMRswGQYDVQQD
5ExJERU1PIFpFUk8gVkFMVUUgQ0ECAgRuMA0GCSqGSIb3DQEBAQUABEDWak0y/5XZJhQJeCLo
6KECcHXkTEbjzYkYNHIinbiPmRK4QbNfs9z2mA3z/c2ykQ4eAqFR2jyNrUMN/+I5XEiv6MIHw
7AgEAMIGZMIGSMQswCQYDVQQGEwJBVTETMBEGA1UECBMKUXVlZW5zbGFuZDERMA8GA1UEBxMI
8QnJpc2JhbmUxGjAYBgNVBAoTEUNyeXB0c29mdCBQdHkgTHRkMSIwIAYDVQQLExlERU1PTlNU
9UkFUSU9OIEFORCBURVNUSU5HMRswGQYDVQQDExJERU1PIFpFUk8gVkFMVUUgQ0ECAgR9MA0G
10CSqGSIb3DQEBAQUABEAWg9+KgtCjc77Jdj1Ve4wGgHjVHbbSYEA1ZqKFDoi15vSr9hfpHmC4
11ycZzcRo16JkTfolefiHZzmyjVz94vSN6MIAGCSqGSIb3DQEHATAaBggqhkiG9w0DAjAOAgIA
12oAQI7X4Tk4mcbV6ggASBsHl1mCaJ3RhXWlNPCgCRU53d7M5x6TDZRkvwdtdvW96m1lupT03F
13XtonkBqk7oMkH7kGfs5/REQOPjx0QE2Ixmgt1W3szum82EZwA7pZNppcraK7W/odw/7bYZO+
14II3HPmRklE2N9qiu1LPaPUsnYogkO6SennyeL5tZ382vBweL/8pnG0qsbT1OBb65v+llnsjT
15pa1T/p+fIx/iJJGE6K9fYFokC6gXLQ6ozXRdOu5oBDB8mPCYYvAqKycidM/MrGGUkpEtS4f0
16lS31PwQi5YTim8Ig3/TOwVpPX32i46FTuEIEIMHkD/OvpfwCCzXUHHJnKnKUAUvIsSY3vGBs
178ezpUDfBBBj9LHDy32hZ2tQilkDefP5VM2LLdrWgamYEgfiyITQvn08Ul5lQOQxbFKBheFq5
18otCCN4MR+w5eq12xQu6y+f9z0159ag2ru87D0lLtUtXXtCELbO1nUkT2sJ0k/iDs9TOXr6Cx
19go1XKYho83hlkXYiCteVizdAbgVGNsNRD4wtIdajsorET/LuJECgp11YeL9w1dlDB0HLEZfi
20XCsUphH4jGagba3hDeUSibnjSiJlN0ukfuQurBBbI2UkBAujiEAubKPn7C1FZJRSw6CPPX5t
21KEpmcqT1JNk6LO8Js6/1sCmmBh1VGCy1+EuTI9J1p7Dagf4nQ8cHitoCRpHuKZlFHnZyv7tw
22Rn/KOhHaYP2VzAh40gQIvKMAAWh9oFsEEIMwIoOmLwLH5wf+8QdbDhoECH8HwZt9a12dBAjL
23r4j2zlvtfgQIt7nmEM3wz1EECKlc3EIy1irCBBCAKINcermK3A+jI6ISN2RzBFA3dsh/xwMu
24l61aWMBBZzEz/SF92k6n35KZhCC0d6fIVC/1WMv0fnCwQ8oEDynSre216VEFiYKBaQLJe5o/
25mTAxC7Ht3goXnuc+i1FItOkLrgRI/wyvTICEn2WsNZiMADnGaee2bqPnUopo+VMGexJEtCPk
26l0ZNlDJGquPDkpUwaEtecVZzCNyVPYyyF4J/l8rmGDhDdYUIC8IKBEg/ip/E0BuubBLWVbv+
27HRl4QrnGpyCyeXRXXK603QP3sT1Zbbm1v5pI/loOhVHi724LmtXHSyp5qv9MDcxE1PoX10LY
28gBRtlwwESPeCF8bK5jk4xIQMhK5NMHj1Y1KQWTZ9NGITBL4hjRq2qp4Qk5GIpGgOVPopAuCo
29TIyPikpqBRNtLSPRSsDs6QPUPzWBh6JgxwRQblnDKKUkxUcnJiD4i9QtGa/ZabMn4KxtNOBL
305JSh1nJkaLXCZY070131WWPAByLcd5TiXq8x84pmzV5NNk4tiMpoXhJNsx8e4rskQQlKd6ME
31SCe2eYDHKcKPX3WJbUzhrJSQ92/aWnI2iUY8WQ+kSNyiZ2QUjyuUg9Z66g/0d2STlvPOBHT/
32y5ODP2CwbcWX4QmCbUc9TT66fQRIrRVuwvtOfnUueyGgYhJ3HpAJfVaB/7kap5bj7Fi/azW4
339JDfd1bC/W9h0Kyk7RO2gxvE0hIHc26mZJHTm9MNP5D328MnM2MdBEjKjQBtgrp+lFIii7MP
34nGHFTKUkG4WAIZJCf/CsT+p6/SW0qG71Me/YcSw5STB24j+a+HgMV8RVIeUlkP4z0IWWrSoB
35Gh4d/Z0EUMCVHs/HZ/bWgiyhtHpvuVAzidm8D81p1LJ5BQX5/5f/m+q5+fS/npL27dTEbNqs
36LSB6ij3MZAi7LwHWpTn9zWnDajCMEj9vlaV7mcKtHK5iBEg85agFi1h3MvicqLtoFe5hVv9T
37tG0j6CRkjkixPzivltlrf44KHv14gLM0XJxCGyq7vd3l8QYr3+9at0zNnX/yqTiBnsnE5dUE
38SIgrYuz87M2gi/ER9PcDoTtONH3+CkcqVy03q/Sj8cVWD/b1KgEhqnNOfc8Ak9PctyR/ItcR
398Me5XVn1GJKkQJk4O29fxvgNoAQIrIESvUWGshAEQByXiFoFTDUByjTlgjcy77H1lrH+y3P/
40wAInJjJAut9kCNyGJV0PA4kdPB5USWltuO6t8gk4Pd2YBMl09zqUWkAEUCjFrtZ3mapjcGZI
41uQTASKR5LSjXoWxTT5gae/+64MerF/oCEeO3ehRTpjnPrsiRDo0rWIQTaj9+Nro8Z2xtWstw
42RnfoAHIxV1lEamPwjsceBEi2SD9hiifFeO5ECiVoaE1FdXUXhU+jwYAMx6jHWO9hMkYzS9pM
43Y3IyWR5ybtOjiQgkUdvRJPUPGf5DVVMPnymGX25aDh5PYpIESPbsM9akCpOOVuscywcUswmU
44o7dXvlB48WWCfg/al3BQKAZbn5ZXtWNwpUZkrEdHsrxAVv3rxRcdkT3Z1fzUbIuYkLJN200o
45WgRIJvn6RO8KEj7/HOg2sYuuM8nz1kR0TSgwX7/0y/7JfjBa0JIlP7o75sNJscE8oyoIMzuy
46Dvn6/U9g3BCDXn83A/s+ke60qn9gBFC6NAeLOlXal1YVWYhMQNOqCyUfAjiXBTawaysQb1Mk
47YgeNlF8xuEFcUQWIP+vNG7FJ5JPMaMRL4YEoaQ3sVFhYOERJR1cSb+8xt4QCYtBKQgRIUOmJ
48CHW5o1hXJWJiTkZK2qWFcEMzTINSj5EpYFySr8aVBjkRnI7vxegRT/+XZZXoYedQ3UNsnGI3
49DdkWii5VzX0PNF6C60pfBEiVpausYuX7Wjb3Lfm8cBj7GgN69i6Pm2gxtobVcmpo2nS4D714
50ePyhlX9n8kJ6QAcqWMRj22smDPrHVGNTizfzHBh5zNllK9gESJizILOWI327og3ZWp+qUht5
51kNDJCzMK7Z09UAy+h+vq0VTQuEo3FgLzVdqkJujjSL4Nx97lXg51AovrEn3nd4evydwcjKLX
521wRIo72NaeWuUEQ+rt1SlCsOJ7k1ioJSqhrPOfvwcaFcb4beVet1JWiy4yvowTjLDGbUje2s
53xjrlVt4BJWI/uA6jbQsrxSe89ADZBAi5YAlR4qszeAQIXD3VSBVKbRUECNTtyvw9vvqXBAhb
54IZNn4H4cxgQI+XW7GkfL+ekECCCCg2reMyGDBAh1PYqkg3lw3gQQkNlggEPU+BH8eh7Gm7n7
557AQIjC5EWbkil5cEEKcpuqwTWww/X89KnQAg8TcECJPomqHvrlZFBBiRSuIiHpmN+PaujXpv
56qZV2VhjkB2j09GEECOIdv8AVOJgKBAjlHgIqAD9jZQQIXHbs44+wogcEIGGqTACRJxrhMcMG
57X8drNjksIPt+snxTXUBIkTVpZWoABAh6unXPTyIr8QQgBF8xKoX27MWk7iTNmkSNZggZXa2a
58DWCGHSYLngbSOHIECD9XmO6VsvTgBAjfqB70CEW4WwQIVIBkbCocznUEEHB/zFXy/sR4OYHe
59UfbNPnIEEDWBB/NTCLMGE+o8BfyujcAECFik7GQnnF9VBBAhLXExQeWAofZNc6NtN7qZBCC1
60gVIS3ruTwKltmcrgx3heT3M8ZJhCfWa+6KzchnmKygQQ+1NL5sSzR4m/fdrqxHFyUAQYCT2x
61PamQr3wK3h0lyZER+4H0zPM86AhFBBC3CkmvL2vjflMfujnzPBVpBBge9rMbI5+0q9DLrTiT
625F3AIgXLpD8PQWAECHkHVo6RomV3BAgMbi8E271UeAQIqtS8wnI3XngECG3TWmOMb3/iBEha
63y+mvCS6I3n3JfL8e1B5P4qX9/czJRaERLuKpGNjLiL4A+zxN0LZ0UHd0qfmJjwOTxAx3iJAC
64lGXX4nB9ATYPUT5EU+o1Y4sECN01pP6vWNIdBDAsiE0Ts8/9ltJlqX2B3AoOM4qOt9EaCjXf
65lB+aEmrhtjUwuZ6GqS5Ke7P6XnakTk4ECCLIMatNdootAAAAAAAAAAAAAA==
66-----END PKCS7-----
diff --git a/src/lib/libcrypto/pkcs7/example.c b/src/lib/libcrypto/pkcs7/example.c
new file mode 100644
index 0000000000..c993947cc3
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/example.c
@@ -0,0 +1,329 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4#include <openssl/pkcs7.h>
5#include <openssl/asn1_mac.h>
6#include <openssl/x509.h>
7
8int add_signed_time(PKCS7_SIGNER_INFO *si)
9 {
10 ASN1_UTCTIME *sign_time;
11
12 /* The last parameter is the amount to add/subtract from the current
13 * time (in seconds) */
14 sign_time=X509_gmtime_adj(NULL,0);
15 PKCS7_add_signed_attribute(si,NID_pkcs9_signingTime,
16 V_ASN1_UTCTIME,(char *)sign_time);
17 return(1);
18 }
19
20ASN1_UTCTIME *get_signed_time(PKCS7_SIGNER_INFO *si)
21 {
22 ASN1_TYPE *so;
23
24 so=PKCS7_get_signed_attribute(si,NID_pkcs9_signingTime);
25 if (so->type == V_ASN1_UTCTIME)
26 return so->value.utctime;
27 return NULL;
28 }
29
30static int signed_string_nid= -1;
31
32void add_signed_string(PKCS7_SIGNER_INFO *si, char *str)
33 {
34 ASN1_OCTET_STRING *os;
35
36 /* To a an object of OID 1.2.3.4.5, which is an octet string */
37 if (signed_string_nid == -1)
38 signed_string_nid=
39 OBJ_create("1.2.3.4.5","OID_example","Our example OID");
40 os=ASN1_OCTET_STRING_new();
41 ASN1_OCTET_STRING_set(os,(unsigned char*)str,strlen(str));
42 /* When we add, we do not free */
43 PKCS7_add_signed_attribute(si,signed_string_nid,
44 V_ASN1_OCTET_STRING,(char *)os);
45 }
46
47int get_signed_string(PKCS7_SIGNER_INFO *si, char *buf, int len)
48 {
49 ASN1_TYPE *so;
50 ASN1_OCTET_STRING *os;
51 int i;
52
53 if (signed_string_nid == -1)
54 signed_string_nid=
55 OBJ_create("1.2.3.4.5","OID_example","Our example OID");
56 /* To retrieve */
57 so=PKCS7_get_signed_attribute(si,signed_string_nid);
58 if (so != NULL)
59 {
60 if (so->type == V_ASN1_OCTET_STRING)
61 {
62 os=so->value.octet_string;
63 i=os->length;
64 if ((i+1) > len)
65 i=len-1;
66 memcpy(buf,os->data,i);
67 return(i);
68 }
69 }
70 return(0);
71 }
72
73static int signed_seq2string_nid= -1;
74/* ########################################### */
75int add_signed_seq2string(PKCS7_SIGNER_INFO *si, char *str1, char *str2)
76 {
77 /* To add an object of OID 1.9.999, which is a sequence containing
78 * 2 octet strings */
79 unsigned char *p;
80 ASN1_OCTET_STRING *os1,*os2;
81 ASN1_STRING *seq;
82 unsigned char *data;
83 int i,total;
84
85 if (signed_seq2string_nid == -1)
86 signed_seq2string_nid=
87 OBJ_create("1.9.9999","OID_example","Our example OID");
88
89 os1=ASN1_OCTET_STRING_new();
90 os2=ASN1_OCTET_STRING_new();
91 ASN1_OCTET_STRING_set(os1,(unsigned char*)str1,strlen(str1));
92 ASN1_OCTET_STRING_set(os2,(unsigned char*)str1,strlen(str1));
93 i =i2d_ASN1_OCTET_STRING(os1,NULL);
94 i+=i2d_ASN1_OCTET_STRING(os2,NULL);
95 total=ASN1_object_size(1,i,V_ASN1_SEQUENCE);
96
97 data=malloc(total);
98 p=data;
99 ASN1_put_object(&p,1,i,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);
100 i2d_ASN1_OCTET_STRING(os1,&p);
101 i2d_ASN1_OCTET_STRING(os2,&p);
102
103 seq=ASN1_STRING_new();
104 ASN1_STRING_set(seq,data,total);
105 free(data);
106 ASN1_OCTET_STRING_free(os1);
107 ASN1_OCTET_STRING_free(os2);
108
109 PKCS7_add_signed_attribute(si,signed_seq2string_nid,
110 V_ASN1_SEQUENCE,(char *)seq);
111 return(1);
112 }
113
114/* For this case, I will malloc the return strings */
115int get_signed_seq2string(PKCS7_SIGNER_INFO *si, char **str1, char **str2)
116 {
117 ASN1_TYPE *so;
118
119 if (signed_seq2string_nid == -1)
120 signed_seq2string_nid=
121 OBJ_create("1.9.9999","OID_example","Our example OID");
122 /* To retrieve */
123 so=PKCS7_get_signed_attribute(si,signed_seq2string_nid);
124 if (so && (so->type == V_ASN1_SEQUENCE))
125 {
126 ASN1_CTX c;
127 ASN1_STRING *s;
128 long length;
129 ASN1_OCTET_STRING *os1,*os2;
130
131 s=so->value.sequence;
132 c.p=ASN1_STRING_data(s);
133 c.max=c.p+ASN1_STRING_length(s);
134 if (!asn1_GetSequence(&c,&length)) goto err;
135 /* Length is the length of the seqence */
136
137 c.q=c.p;
138 if ((os1=d2i_ASN1_OCTET_STRING(NULL,&c.p,c.slen)) == NULL)
139 goto err;
140 c.slen-=(c.p-c.q);
141
142 c.q=c.p;
143 if ((os2=d2i_ASN1_OCTET_STRING(NULL,&c.p,c.slen)) == NULL)
144 goto err;
145 c.slen-=(c.p-c.q);
146
147 if (!asn1_Finish(&c)) goto err;
148 *str1=malloc(os1->length+1);
149 *str2=malloc(os2->length+1);
150 memcpy(*str1,os1->data,os1->length);
151 memcpy(*str2,os2->data,os2->length);
152 (*str1)[os1->length]='\0';
153 (*str2)[os2->length]='\0';
154 ASN1_OCTET_STRING_free(os1);
155 ASN1_OCTET_STRING_free(os2);
156 return(1);
157 }
158err:
159 return(0);
160 }
161
162
163/* #######################################
164 * THE OTHER WAY TO DO THINGS
165 * #######################################
166 */
167X509_ATTRIBUTE *create_time(void)
168 {
169 ASN1_UTCTIME *sign_time;
170 X509_ATTRIBUTE *ret;
171
172 /* The last parameter is the amount to add/subtract from the current
173 * time (in seconds) */
174 sign_time=X509_gmtime_adj(NULL,0);
175 ret=X509_ATTRIBUTE_create(NID_pkcs9_signingTime,
176 V_ASN1_UTCTIME,(char *)sign_time);
177 return(ret);
178 }
179
180ASN1_UTCTIME *sk_get_time(STACK_OF(X509_ATTRIBUTE) *sk)
181 {
182 ASN1_TYPE *so;
183 PKCS7_SIGNER_INFO si;
184
185 si.auth_attr=sk;
186 so=PKCS7_get_signed_attribute(&si,NID_pkcs9_signingTime);
187 if (so->type == V_ASN1_UTCTIME)
188 return so->value.utctime;
189 return NULL;
190 }
191
192X509_ATTRIBUTE *create_string(char *str)
193 {
194 ASN1_OCTET_STRING *os;
195 X509_ATTRIBUTE *ret;
196
197 /* To a an object of OID 1.2.3.4.5, which is an octet string */
198 if (signed_string_nid == -1)
199 signed_string_nid=
200 OBJ_create("1.2.3.4.5","OID_example","Our example OID");
201 os=ASN1_OCTET_STRING_new();
202 ASN1_OCTET_STRING_set(os,(unsigned char*)str,strlen(str));
203 /* When we add, we do not free */
204 ret=X509_ATTRIBUTE_create(signed_string_nid,
205 V_ASN1_OCTET_STRING,(char *)os);
206 return(ret);
207 }
208
209int sk_get_string(STACK_OF(X509_ATTRIBUTE) *sk, char *buf, int len)
210 {
211 ASN1_TYPE *so;
212 ASN1_OCTET_STRING *os;
213 int i;
214 PKCS7_SIGNER_INFO si;
215
216 si.auth_attr=sk;
217
218 if (signed_string_nid == -1)
219 signed_string_nid=
220 OBJ_create("1.2.3.4.5","OID_example","Our example OID");
221 /* To retrieve */
222 so=PKCS7_get_signed_attribute(&si,signed_string_nid);
223 if (so != NULL)
224 {
225 if (so->type == V_ASN1_OCTET_STRING)
226 {
227 os=so->value.octet_string;
228 i=os->length;
229 if ((i+1) > len)
230 i=len-1;
231 memcpy(buf,os->data,i);
232 return(i);
233 }
234 }
235 return(0);
236 }
237
238X509_ATTRIBUTE *add_seq2string(PKCS7_SIGNER_INFO *si, char *str1, char *str2)
239 {
240 /* To add an object of OID 1.9.999, which is a sequence containing
241 * 2 octet strings */
242 unsigned char *p;
243 ASN1_OCTET_STRING *os1,*os2;
244 ASN1_STRING *seq;
245 X509_ATTRIBUTE *ret;
246 unsigned char *data;
247 int i,total;
248
249 if (signed_seq2string_nid == -1)
250 signed_seq2string_nid=
251 OBJ_create("1.9.9999","OID_example","Our example OID");
252
253 os1=ASN1_OCTET_STRING_new();
254 os2=ASN1_OCTET_STRING_new();
255 ASN1_OCTET_STRING_set(os1,(unsigned char*)str1,strlen(str1));
256 ASN1_OCTET_STRING_set(os2,(unsigned char*)str1,strlen(str1));
257 i =i2d_ASN1_OCTET_STRING(os1,NULL);
258 i+=i2d_ASN1_OCTET_STRING(os2,NULL);
259 total=ASN1_object_size(1,i,V_ASN1_SEQUENCE);
260
261 data=malloc(total);
262 p=data;
263 ASN1_put_object(&p,1,i,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);
264 i2d_ASN1_OCTET_STRING(os1,&p);
265 i2d_ASN1_OCTET_STRING(os2,&p);
266
267 seq=ASN1_STRING_new();
268 ASN1_STRING_set(seq,data,total);
269 free(data);
270 ASN1_OCTET_STRING_free(os1);
271 ASN1_OCTET_STRING_free(os2);
272
273 ret=X509_ATTRIBUTE_create(signed_seq2string_nid,
274 V_ASN1_SEQUENCE,(char *)seq);
275 return(ret);
276 }
277
278/* For this case, I will malloc the return strings */
279int sk_get_seq2string(STACK_OF(X509_ATTRIBUTE) *sk, char **str1, char **str2)
280 {
281 ASN1_TYPE *so;
282 PKCS7_SIGNER_INFO si;
283
284 if (signed_seq2string_nid == -1)
285 signed_seq2string_nid=
286 OBJ_create("1.9.9999","OID_example","Our example OID");
287
288 si.auth_attr=sk;
289 /* To retrieve */
290 so=PKCS7_get_signed_attribute(&si,signed_seq2string_nid);
291 if (so->type == V_ASN1_SEQUENCE)
292 {
293 ASN1_CTX c;
294 ASN1_STRING *s;
295 long length;
296 ASN1_OCTET_STRING *os1,*os2;
297
298 s=so->value.sequence;
299 c.p=ASN1_STRING_data(s);
300 c.max=c.p+ASN1_STRING_length(s);
301 if (!asn1_GetSequence(&c,&length)) goto err;
302 /* Length is the length of the seqence */
303
304 c.q=c.p;
305 if ((os1=d2i_ASN1_OCTET_STRING(NULL,&c.p,c.slen)) == NULL)
306 goto err;
307 c.slen-=(c.p-c.q);
308
309 c.q=c.p;
310 if ((os2=d2i_ASN1_OCTET_STRING(NULL,&c.p,c.slen)) == NULL)
311 goto err;
312 c.slen-=(c.p-c.q);
313
314 if (!asn1_Finish(&c)) goto err;
315 *str1=malloc(os1->length+1);
316 *str2=malloc(os2->length+1);
317 memcpy(*str1,os1->data,os1->length);
318 memcpy(*str2,os2->data,os2->length);
319 (*str1)[os1->length]='\0';
320 (*str2)[os2->length]='\0';
321 ASN1_OCTET_STRING_free(os1);
322 ASN1_OCTET_STRING_free(os2);
323 return(1);
324 }
325err:
326 return(0);
327 }
328
329
diff --git a/src/lib/libcrypto/pkcs7/example.h b/src/lib/libcrypto/pkcs7/example.h
new file mode 100644
index 0000000000..96167de188
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/example.h
@@ -0,0 +1,57 @@
1/* ====================================================================
2 * Copyright (c) 1999 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
55int add_signed_time(PKCS7_SIGNER_INFO *si);
56ASN1_UTCTIME *get_signed_time(PKCS7_SIGNER_INFO *si);
57int get_signed_seq2string(PKCS7_SIGNER_INFO *si, char **str1, char **str2);
diff --git a/src/lib/libcrypto/pkcs7/info.pem b/src/lib/libcrypto/pkcs7/info.pem
new file mode 100644
index 0000000000..989baf8709
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/info.pem
@@ -0,0 +1,57 @@
1issuer :/C=AU/SP=Queensland/L=Brisbane/O=Cryptsoft Pty Ltd/OU=DEMONSTRATION AND TESTING/CN=DEMO ZERO VALUE CA
2subject:/C=AU/SP=Queensland/L=Brisbane/O=Cryptsoft Pty Ltd/OU=SMIME 003/CN=Information/Email=info@cryptsoft.com
3serial :047D
4
5Certificate:
6 Data:
7 Version: 3 (0x2)
8 Serial Number: 1149 (0x47d)
9 Signature Algorithm: md5withRSAEncryption
10 Issuer: C=AU, SP=Queensland, L=Brisbane, O=Cryptsoft Pty Ltd, OU=DEMONSTRATION AND TESTING, CN=DEMO ZERO VALUE CA
11 Validity
12 Not Before: May 13 05:40:58 1998 GMT
13 Not After : May 12 05:40:58 2000 GMT
14 Subject: C=AU, SP=Queensland, L=Brisbane, O=Cryptsoft Pty Ltd, OU=SMIME 003, CN=Information/Email=info@cryptsoft.com
15 Subject Public Key Info:
16 Public Key Algorithm: rsaEncryption
17 Modulus:
18 00:ad:e7:23:89:ee:0d:87:b7:9c:32:44:4b:95:81:
19 73:dd:22:80:4b:2d:c5:60:b8:fe:1e:18:63:ef:dc:
20 89:89:22:df:95:3c:7a:db:3d:9a:06:a8:08:d6:29:
21 fd:ef:41:09:91:ed:bc:ad:98:f9:f6:28:90:62:6f:
22 e7:e7:0c:4d:0b
23 Exponent: 65537 (0x10001)
24 X509v3 extensions:
25 Netscape Comment:
26 Generated with SSLeay
27 Signature Algorithm: md5withRSAEncryption
28 52:15:ea:88:f4:f0:f9:0b:ef:ce:d5:f8:83:40:61:16:5e:55:
29 f9:ce:2d:d1:8b:31:5c:03:c6:2d:10:7c:61:d5:5c:0a:42:97:
30 d1:fd:65:b6:b6:84:a5:39:ec:46:ec:fc:e0:0d:d9:22:da:1b:
31 50:74:ad:92:cb:4e:90:e5:fa:7d
32
33-----BEGIN CERTIFICATE-----
34MIICTDCCAfagAwIBAgICBH0wDQYJKoZIhvcNAQEEBQAwgZIxCzAJBgNVBAYTAkFV
35MRMwEQYDVQQIEwpRdWVlbnNsYW5kMREwDwYDVQQHEwhCcmlzYmFuZTEaMBgGA1UE
36ChMRQ3J5cHRzb2Z0IFB0eSBMdGQxIjAgBgNVBAsTGURFTU9OU1RSQVRJT04gQU5E
37IFRFU1RJTkcxGzAZBgNVBAMTEkRFTU8gWkVSTyBWQUxVRSBDQTAeFw05ODA1MTMw
38NTQwNThaFw0wMDA1MTIwNTQwNThaMIGeMQswCQYDVQQGEwJBVTETMBEGA1UECBMK
39UXVlZW5zbGFuZDERMA8GA1UEBxMIQnJpc2JhbmUxGjAYBgNVBAoTEUNyeXB0c29m
40dCBQdHkgTHRkMRIwEAYDVQQLEwlTTUlNRSAwMDMxFDASBgNVBAMTC0luZm9ybWF0
41aW9uMSEwHwYJKoZIhvcNAQkBFhJpbmZvQGNyeXB0c29mdC5jb20wXDANBgkqhkiG
429w0BAQEFAANLADBIAkEArecjie4Nh7ecMkRLlYFz3SKASy3FYLj+Hhhj79yJiSLf
43lTx62z2aBqgI1in970EJke28rZj59iiQYm/n5wxNCwIDAQABoygwJjAkBglghkgB
44hvhCAQ0EFxYVR2VuZXJhdGVkIHdpdGggU1NMZWF5MA0GCSqGSIb3DQEBBAUAA0EA
45UhXqiPTw+QvvztX4g0BhFl5V+c4t0YsxXAPGLRB8YdVcCkKX0f1ltraEpTnsRuz8
464A3ZItobUHStkstOkOX6fQ==
47-----END CERTIFICATE-----
48
49-----BEGIN RSA PRIVATE KEY-----
50MIIBOgIBAAJBAK3nI4nuDYe3nDJES5WBc90igEstxWC4/h4YY+/ciYki35U8ets9
51mgaoCNYp/e9BCZHtvK2Y+fYokGJv5+cMTQsCAwEAAQJBAIHpvXvqEcOEoDRRHuIG
52fkcB4jPHcr9KE9TpxabH6xs9beN6OJnkePXAHwaz5MnUgSnbpOKq+cw8miKjXwe/
53zVECIQDVLwncT2lRmXarEYHzb+q/0uaSvKhWKKt3kJasLNTrAwIhANDUc/ghut29
54p3jJYjurzUKuG774/5eLjPLsxPPIZzNZAiA/10hSq41UnGqHLEUIS9m2/EeEZe7b
55bm567dfRU9OnVQIgDo8ROrZXSchEGbaog5J5r/Fle83uO8l93R3GqVxKXZkCIFfk
56IPD5PIYQAyyod3hyKKza7ZP4CGY4oOfZetbkSGGG
57-----END RSA PRIVATE KEY-----
diff --git a/src/lib/libcrypto/pkcs7/infokey.pem b/src/lib/libcrypto/pkcs7/infokey.pem
new file mode 100644
index 0000000000..1e2acc954d
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/infokey.pem
@@ -0,0 +1,9 @@
1-----BEGIN RSA PRIVATE KEY-----
2MIIBOgIBAAJBAK3nI4nuDYe3nDJES5WBc90igEstxWC4/h4YY+/ciYki35U8ets9
3mgaoCNYp/e9BCZHtvK2Y+fYokGJv5+cMTQsCAwEAAQJBAIHpvXvqEcOEoDRRHuIG
4fkcB4jPHcr9KE9TpxabH6xs9beN6OJnkePXAHwaz5MnUgSnbpOKq+cw8miKjXwe/
5zVECIQDVLwncT2lRmXarEYHzb+q/0uaSvKhWKKt3kJasLNTrAwIhANDUc/ghut29
6p3jJYjurzUKuG774/5eLjPLsxPPIZzNZAiA/10hSq41UnGqHLEUIS9m2/EeEZe7b
7bm567dfRU9OnVQIgDo8ROrZXSchEGbaog5J5r/Fle83uO8l93R3GqVxKXZkCIFfk
8IPD5PIYQAyyod3hyKKza7ZP4CGY4oOfZetbkSGGG
9-----END RSA PRIVATE KEY-----
diff --git a/src/lib/libcrypto/pkcs7/p7/a1 b/src/lib/libcrypto/pkcs7/p7/a1
new file mode 100644
index 0000000000..56ca943762
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/p7/a1
@@ -0,0 +1,2 @@
1j,H>_æá_­DôzEîLœ VJ³ß觬¤””E3ûáYäx%_Àk
23ê)DLScñ8% ôM \ No newline at end of file
diff --git a/src/lib/libcrypto/pkcs7/p7/a2 b/src/lib/libcrypto/pkcs7/p7/a2
new file mode 100644
index 0000000000..23d8fb5e93
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/p7/a2
@@ -0,0 +1 @@
k~@a”,NâM͹¼ <O( KP—騠¤K²>­×U¿o_½BqrmÎ?Ù t?t÷ÏéId2‰Š \ No newline at end of file
diff --git a/src/lib/libcrypto/pkcs7/p7/cert.p7c b/src/lib/libcrypto/pkcs7/p7/cert.p7c
new file mode 100644
index 0000000000..2b75ec05f7
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/p7/cert.p7c
Binary files differ
diff --git a/src/lib/libcrypto/pkcs7/p7/smime.p7m b/src/lib/libcrypto/pkcs7/p7/smime.p7m
new file mode 100644
index 0000000000..2b6e6f82ba
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/p7/smime.p7m
Binary files differ
diff --git a/src/lib/libcrypto/pkcs7/p7/smime.p7s b/src/lib/libcrypto/pkcs7/p7/smime.p7s
new file mode 100644
index 0000000000..2b5d4fb0e3
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/p7/smime.p7s
Binary files differ
diff --git a/src/lib/libcrypto/pkcs7/pk7_dgst.c b/src/lib/libcrypto/pkcs7/pk7_dgst.c
new file mode 100644
index 0000000000..90edfa5001
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/pk7_dgst.c
@@ -0,0 +1,66 @@
1/* crypto/pkcs7/pk7_dgst.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/rand.h>
63#include <openssl/objects.h>
64#include <openssl/x509.h>
65#include <openssl/pkcs7.h>
66
diff --git a/src/lib/libcrypto/pkcs7/pk7_doit.c b/src/lib/libcrypto/pkcs7/pk7_doit.c
index 0060a2ea3d..4a4ff340ce 100644
--- a/src/lib/libcrypto/pkcs7/pk7_doit.c
+++ b/src/lib/libcrypto/pkcs7/pk7_doit.c
@@ -241,7 +241,7 @@ BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio)
241 M_ASN1_OCTET_STRING_set(ri->enc_key,tmp,jj); 241 M_ASN1_OCTET_STRING_set(ri->enc_key,tmp,jj);
242 } 242 }
243 OPENSSL_free(tmp); 243 OPENSSL_free(tmp);
244 OPENSSL_cleanse(key, keylen); 244 memset(key, 0, keylen);
245 245
246 if (out == NULL) 246 if (out == NULL)
247 out=btmp; 247 out=btmp;
@@ -448,7 +448,7 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
448 } 448 }
449 EVP_CipherInit_ex(evp_ctx,NULL,NULL,tmp,NULL,0); 449 EVP_CipherInit_ex(evp_ctx,NULL,NULL,tmp,NULL,0);
450 450
451 OPENSSL_cleanse(tmp,jj); 451 memset(tmp,0,jj);
452 452
453 if (out == NULL) 453 if (out == NULL)
454 out=etmp; 454 out=etmp;
@@ -578,7 +578,7 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
578 /* We now have the EVP_MD_CTX, lets do the 578 /* We now have the EVP_MD_CTX, lets do the
579 * signing. */ 579 * signing. */
580 EVP_MD_CTX_copy_ex(&ctx_tmp,mdc); 580 EVP_MD_CTX_copy_ex(&ctx_tmp,mdc);
581 if (!BUF_MEM_grow_clean(buf,EVP_PKEY_size(si->pkey))) 581 if (!BUF_MEM_grow(buf,EVP_PKEY_size(si->pkey)))
582 { 582 {
583 PKCS7err(PKCS7_F_PKCS7_DATASIGN,ERR_R_BIO_LIB); 583 PKCS7err(PKCS7_F_PKCS7_DATASIGN,ERR_R_BIO_LIB);
584 goto err; 584 goto err;
diff --git a/src/lib/libcrypto/pkcs7/pk7_enc.c b/src/lib/libcrypto/pkcs7/pk7_enc.c
new file mode 100644
index 0000000000..acbb189c59
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/pk7_enc.c
@@ -0,0 +1,76 @@
1/* crypto/pkcs7/pk7_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 <stdio.h>
60#include "cryptlib.h"
61#include <openssl/evp.h>
62#include <openssl/rand.h>
63#include <openssl/objects.h>
64#include <openssl/x509.h>
65#include <openssl/pkcs7.h>
66
67PKCS7_in_bio(PKCS7 *p7,BIO *in);
68PKCS7_out_bio(PKCS7 *p7,BIO *out);
69
70PKCS7_add_signer(PKCS7 *p7,X509 *cert,EVP_PKEY *key);
71PKCS7_cipher(PKCS7 *p7,EVP_CIPHER *cipher);
72
73PKCS7_Init(PKCS7 *p7);
74PKCS7_Update(PKCS7 *p7);
75PKCS7_Finish(PKCS7 *p7);
76
diff --git a/src/lib/libcrypto/pkcs7/server.pem b/src/lib/libcrypto/pkcs7/server.pem
new file mode 100644
index 0000000000..750aac2094
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/server.pem
@@ -0,0 +1,24 @@
1issuer= /C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test CA (1024 bit)
2subject=/C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Server test cert (512 bit)
3-----BEGIN CERTIFICATE-----
4MIIB6TCCAVICAQAwDQYJKoZIhvcNAQEEBQAwWzELMAkGA1UEBhMCQVUxEzARBgNV
5BAgTClF1ZWVuc2xhbmQxGjAYBgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRswGQYD
6VQQDExJUZXN0IENBICgxMDI0IGJpdCkwHhcNOTcwNjA5MTM1NzQ2WhcNOTgwNjA5
7MTM1NzQ2WjBjMQswCQYDVQQGEwJBVTETMBEGA1UECBMKUXVlZW5zbGFuZDEaMBgG
8A1UEChMRQ3J5cHRTb2Z0IFB0eSBMdGQxIzAhBgNVBAMTGlNlcnZlciB0ZXN0IGNl
9cnQgKDUxMiBiaXQpMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJ+zw4Qnlf8SMVIP
10Fe9GEcStgOY2Ww/dgNdhjeD8ckUJNP5VZkVDTGiXav6ooKXfX3j/7tdkuD8Ey2//
11Kv7+ue0CAwEAATANBgkqhkiG9w0BAQQFAAOBgQB4TMR2CvacKE9wAsu9jyCX8YiW
12mgCM+YoP6kt4Zkj2z5IRfm7WrycKsnpnOR+tGeqAjkCeZ6/36o9l91RvPnN1VJ/i
13xQv2df0KFeMr00IkDdTNAdIWqFkSsZTAY2QAdgenb7MB1joejquYzO2DQIO7+wpH
14irObpESxAZLySCmPPg==
15-----END CERTIFICATE-----
16-----BEGIN RSA PRIVATE KEY-----
17MIIBPAIBAAJBAJ+zw4Qnlf8SMVIPFe9GEcStgOY2Ww/dgNdhjeD8ckUJNP5VZkVD
18TGiXav6ooKXfX3j/7tdkuD8Ey2//Kv7+ue0CAwEAAQJAN6W31vDEP2DjdqhzCDDu
19OA4NACqoiFqyblo7yc2tM4h4xMbC3Yx5UKMN9ZkCtX0gzrz6DyF47bdKcWBzNWCj
20gQIhANEoojVt7hq+SQ6MCN6FTAysGgQf56Q3TYoJMoWvdiXVAiEAw3e3rc+VJpOz
21rHuDo6bgpjUAAXM+v3fcpsfZSNO6V7kCIQCtbVjanpUwvZkMI9by02oUk9taki3b
22PzPfAfNPYAbCJQIhAJXNQDWyqwn/lGmR11cqY2y9nZ1+5w3yHGatLrcDnQHxAiEA
23vnlEGo8K85u+KwIOimM48ZG8oTk7iFdkqLJR1utT3aU=
24-----END RSA PRIVATE KEY-----
diff --git a/src/lib/libcrypto/pkcs7/sign.c b/src/lib/libcrypto/pkcs7/sign.c
new file mode 100644
index 0000000000..8b59885f7e
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/sign.c
@@ -0,0 +1,154 @@
1/* crypto/pkcs7/sign.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 <string.h>
60#include <openssl/bio.h>
61#include <openssl/x509.h>
62#include <openssl/pem.h>
63#include <openssl/err.h>
64
65int main(argc,argv)
66int argc;
67char *argv[];
68 {
69 X509 *x509;
70 EVP_PKEY *pkey;
71 PKCS7 *p7;
72 PKCS7_SIGNER_INFO *si;
73 BIO *in;
74 BIO *data,*p7bio;
75 char buf[1024*4];
76 int i;
77 int nodetach=0;
78
79#ifndef OPENSSL_NO_MD2
80 EVP_add_digest(EVP_md2());
81#endif
82#ifndef OPENSSL_NO_MD5
83 EVP_add_digest(EVP_md5());
84#endif
85#ifndef OPENSSL_NO_SHA1
86 EVP_add_digest(EVP_sha1());
87#endif
88#ifndef OPENSSL_NO_MDC2
89 EVP_add_digest(EVP_mdc2());
90#endif
91
92 data=BIO_new(BIO_s_file());
93again:
94 if (argc > 1)
95 {
96 if (strcmp(argv[1],"-nd") == 0)
97 {
98 nodetach=1;
99 argv++; argc--;
100 goto again;
101 }
102 if (!BIO_read_filename(data,argv[1]))
103 goto err;
104 }
105 else
106 BIO_set_fp(data,stdin,BIO_NOCLOSE);
107
108 if ((in=BIO_new_file("server.pem","r")) == NULL) goto err;
109 if ((x509=PEM_read_bio_X509(in,NULL,NULL,NULL)) == NULL) goto err;
110 BIO_reset(in);
111 if ((pkey=PEM_read_bio_PrivateKey(in,NULL,NULL,NULL)) == NULL) goto err;
112 BIO_free(in);
113
114 p7=PKCS7_new();
115 PKCS7_set_type(p7,NID_pkcs7_signed);
116
117 si=PKCS7_add_signature(p7,x509,pkey,EVP_sha1());
118 if (si == NULL) goto err;
119
120 /* If you do this then you get signing time automatically added */
121 PKCS7_add_signed_attribute(si, NID_pkcs9_contentType, V_ASN1_OBJECT,
122 OBJ_nid2obj(NID_pkcs7_data));
123
124 /* we may want to add more */
125 PKCS7_add_certificate(p7,x509);
126
127 /* Set the content of the signed to 'data' */
128 PKCS7_content_new(p7,NID_pkcs7_data);
129
130 if (!nodetach)
131 PKCS7_set_detached(p7,1);
132
133 if ((p7bio=PKCS7_dataInit(p7,NULL)) == NULL) goto err;
134
135 for (;;)
136 {
137 i=BIO_read(data,buf,sizeof(buf));
138 if (i <= 0) break;
139 BIO_write(p7bio,buf,i);
140 }
141
142 if (!PKCS7_dataFinal(p7,p7bio)) goto err;
143 BIO_free(p7bio);
144
145 PEM_write_PKCS7(stdout,p7);
146 PKCS7_free(p7);
147
148 exit(0);
149err:
150 ERR_load_crypto_strings();
151 ERR_print_errors_fp(stderr);
152 exit(1);
153 }
154
diff --git a/src/lib/libcrypto/pkcs7/t/3des.pem b/src/lib/libcrypto/pkcs7/t/3des.pem
new file mode 100644
index 0000000000..b2b5081a10
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/t/3des.pem
@@ -0,0 +1,16 @@
1-----BEGIN PKCS7-----
2MIAGCSqGSIb3DQEHA6CAMIACAQAxggHmMIHwAgEAMIGZMIGSMQswCQYDVQQGEwJBVTETMBEG
3A1UECBMKUXVlZW5zbGFuZDERMA8GA1UEBxMIQnJpc2JhbmUxGjAYBgNVBAoTEUNyeXB0c29m
4dCBQdHkgTHRkMSIwIAYDVQQLExlERU1PTlNUUkFUSU9OIEFORCBURVNUSU5HMRswGQYDVQQD
5ExJERU1PIFpFUk8gVkFMVUUgQ0ECAgR+MA0GCSqGSIb3DQEBAQUABEC2vXI1xQDW6lUHM3zQ
6/9uBEBOO5A3TtkrklAXq7v01gsIC21t52qSk36REXY+slhNZ0OQ349tgkTsoETHFLoEwMIHw
7AgEAMIGZMIGSMQswCQYDVQQGEwJBVTETMBEGA1UECBMKUXVlZW5zbGFuZDERMA8GA1UEBxMI
8QnJpc2JhbmUxGjAYBgNVBAoTEUNyeXB0c29mdCBQdHkgTHRkMSIwIAYDVQQLExlERU1PTlNU
9UkFUSU9OIEFORCBURVNUSU5HMRswGQYDVQQDExJERU1PIFpFUk8gVkFMVUUgQ0ECAgR9MA0G
10CSqGSIb3DQEBAQUABEB8ujxbabxXUYJhopuDm3oDq4JNqX6Io4p3ro+ShqfIndsXTZ1v5a2N
11WtLLCWlHn/habjBwZ/DgQgcKASbZ7QxNMIAGCSqGSIb3DQEHATAaBggqhkiG9w0DAjAOAgIA
12oAQIbsL5v1wX98KggAQoAaJ4WHm68fXY1WE5OIjfVBIDpO1K+i8dmKhjnAjrjoyZ9Bwc8rDL
13lgQg4CXb805h5xl+GfvSwUaHJayte1m2mcOhs3J2YyqbQ+MEIMIiJQccmhO3oDKm36CFvYR8
145PjpclVcZyX2ngbwPFMnBAgy0clOAE6UKAAAAAAAAAAAAAA=
15-----END PKCS7-----
16
diff --git a/src/lib/libcrypto/pkcs7/t/3dess.pem b/src/lib/libcrypto/pkcs7/t/3dess.pem
new file mode 100644
index 0000000000..23f013516a
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/t/3dess.pem
@@ -0,0 +1,32 @@
1-----BEGIN PKCS7-----
2MIIGHgYJKoZIhvcNAQcCoIIGDzCCBgsCAQExCzAJBgUrDgMCGgUAMAsGCSqGSIb3DQEHAaCC
3BGswggJTMIIB/aADAgECAgIEfjANBgkqhkiG9w0BAQQFADCBkjELMAkGA1UEBhMCQVUxEzAR
4BgNVBAgTClF1ZWVuc2xhbmQxETAPBgNVBAcTCEJyaXNiYW5lMRowGAYDVQQKExFDcnlwdHNv
5ZnQgUHR5IEx0ZDEiMCAGA1UECxMZREVNT05TVFJBVElPTiBBTkQgVEVTVElORzEbMBkGA1UE
6AxMSREVNTyBaRVJPIFZBTFVFIENBMB4XDTk4MDUxMzA2MjY1NloXDTAwMDUxMjA2MjY1Nlow
7gaUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpRdWVlbnNsYW5kMREwDwYDVQQHEwhCcmlzYmFu
8ZTEaMBgGA1UEChMRQ3J5cHRzb2Z0IFB0eSBMdGQxEjAQBgNVBAsTCVNNSU1FIDAwMzEZMBcG
9A1UEAxMQQW5nZWxhIHZhbiBMZWVudDEjMCEGCSqGSIb3DQEJARYUYW5nZWxhQGNyeXB0c29m
10dC5jb20wXDANBgkqhkiG9w0BAQEFAANLADBIAkEAuC3+7dAb2LhuO7gt2cTM8vsNjhG5JfDh
11hX1Vl/wVGbKEEj0MA6vWEolvefQlxB+EzwCtR0YZ7eEC/T/4JoCyeQIDAQABoygwJjAkBglg
12hkgBhvhCAQ0EFxYVR2VuZXJhdGVkIHdpdGggU1NMZWF5MA0GCSqGSIb3DQEBBAUAA0EAUnSP
13igs6TMFISTjw8cBtJYb98czgAVkVFjKyJQwYMH8FbDnCyx6NocM555nsyDstaw8fKR11Khds
14syd3ikkrhDCCAhAwggG6AgEDMA0GCSqGSIb3DQEBBAUAMIGSMQswCQYDVQQGEwJBVTETMBEG
15A1UECBMKUXVlZW5zbGFuZDERMA8GA1UEBxMIQnJpc2JhbmUxGjAYBgNVBAoTEUNyeXB0c29m
16dCBQdHkgTHRkMSIwIAYDVQQLExlERU1PTlNUUkFUSU9OIEFORCBURVNUSU5HMRswGQYDVQQD
17ExJERU1PIFpFUk8gVkFMVUUgQ0EwHhcNOTgwMzAzMDc0MTMyWhcNMDgwMjI5MDc0MTMyWjCB
18kjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClF1ZWVuc2xhbmQxETAPBgNVBAcTCEJyaXNiYW5l
19MRowGAYDVQQKExFDcnlwdHNvZnQgUHR5IEx0ZDEiMCAGA1UECxMZREVNT05TVFJBVElPTiBB
20TkQgVEVTVElORzEbMBkGA1UEAxMSREVNTyBaRVJPIFZBTFVFIENBMFwwDQYJKoZIhvcNAQEB
21BQADSwAwSAJBAL+0E2fLej3FSCwe2A2iRnMuC3z12qHIp6Ky1wo2zZcxft7AI+RfkrWrSGtf
22mfzBEuPrLdfulncC5Y1pNcM8RTUCAwEAATANBgkqhkiG9w0BAQQFAANBAGSbLMphL6F5pp3s
238o0Xyh86FHFdpVOwYx09ELLkuG17V/P9pgIc0Eo/gDMbN+KT3IdgECf8S//pCRA6RrNjcXIx
24ggF7MIIBdwIBATCBmTCBkjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClF1ZWVuc2xhbmQxETAP
25BgNVBAcTCEJyaXNiYW5lMRowGAYDVQQKExFDcnlwdHNvZnQgUHR5IEx0ZDEiMCAGA1UECxMZ
26REVNT05TVFJBVElPTiBBTkQgVEVTVElORzEbMBkGA1UEAxMSREVNTyBaRVJPIFZBTFVFIENB
27AgIEfjAJBgUrDgMCGgUAoHowGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAbBgkqhkiG9w0B
28CQ8xDjAMMAoGCCqGSIb3DQMHMBwGCSqGSIb3DQEJBTEPFw05ODA1MTQwMzM5MzdaMCMGCSqG
29SIb3DQEJBDEWBBQstNMnSV26ba8PapQEDhO21yNFrjANBgkqhkiG9w0BAQEFAARAW9Xb9YXv
30BfcNkutgFX9Gr8iXhBVsNtGEVrjrpkQwpKa7jHI8SjAlLhk/4RFwDHf+ISB9Np3Z1WDWnLcA
319CWR6g==
32-----END PKCS7-----
diff --git a/src/lib/libcrypto/pkcs7/t/c.pem b/src/lib/libcrypto/pkcs7/t/c.pem
new file mode 100644
index 0000000000..a4b55e321a
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/t/c.pem
@@ -0,0 +1,48 @@
1issuer :/C=AU/SP=Queensland/L=Brisbane/O=Cryptsoft Pty Ltd/OU=DEMONSTRATION AND TESTING/CN=DEMO ZERO VALUE CA
2subject:/C=AU/SP=Queensland/L=Brisbane/O=Cryptsoft Pty Ltd/OU=SMIME 003/CN=Information/Email=info@cryptsoft.com
3serial :047D
4
5Certificate:
6 Data:
7 Version: 3 (0x2)
8 Serial Number: 1149 (0x47d)
9 Signature Algorithm: md5withRSAEncryption
10 Issuer: C=AU, SP=Queensland, L=Brisbane, O=Cryptsoft Pty Ltd, OU=DEMONSTRATION AND TESTING, CN=DEMO ZERO VALUE CA
11 Validity
12 Not Before: May 13 05:40:58 1998 GMT
13 Not After : May 12 05:40:58 2000 GMT
14 Subject: C=AU, SP=Queensland, L=Brisbane, O=Cryptsoft Pty Ltd, OU=SMIME 003, CN=Information/Email=info@cryptsoft.com
15 Subject Public Key Info:
16 Public Key Algorithm: rsaEncryption
17 Modulus:
18 00:ad:e7:23:89:ee:0d:87:b7:9c:32:44:4b:95:81:
19 73:dd:22:80:4b:2d:c5:60:b8:fe:1e:18:63:ef:dc:
20 89:89:22:df:95:3c:7a:db:3d:9a:06:a8:08:d6:29:
21 fd:ef:41:09:91:ed:bc:ad:98:f9:f6:28:90:62:6f:
22 e7:e7:0c:4d:0b
23 Exponent: 65537 (0x10001)
24 X509v3 extensions:
25 Netscape Comment:
26 Generated with SSLeay
27 Signature Algorithm: md5withRSAEncryption
28 52:15:ea:88:f4:f0:f9:0b:ef:ce:d5:f8:83:40:61:16:5e:55:
29 f9:ce:2d:d1:8b:31:5c:03:c6:2d:10:7c:61:d5:5c:0a:42:97:
30 d1:fd:65:b6:b6:84:a5:39:ec:46:ec:fc:e0:0d:d9:22:da:1b:
31 50:74:ad:92:cb:4e:90:e5:fa:7d
32
33-----BEGIN CERTIFICATE-----
34MIICTDCCAfagAwIBAgICBH0wDQYJKoZIhvcNAQEEBQAwgZIxCzAJBgNVBAYTAkFV
35MRMwEQYDVQQIEwpRdWVlbnNsYW5kMREwDwYDVQQHEwhCcmlzYmFuZTEaMBgGA1UE
36ChMRQ3J5cHRzb2Z0IFB0eSBMdGQxIjAgBgNVBAsTGURFTU9OU1RSQVRJT04gQU5E
37IFRFU1RJTkcxGzAZBgNVBAMTEkRFTU8gWkVSTyBWQUxVRSBDQTAeFw05ODA1MTMw
38NTQwNThaFw0wMDA1MTIwNTQwNThaMIGeMQswCQYDVQQGEwJBVTETMBEGA1UECBMK
39UXVlZW5zbGFuZDERMA8GA1UEBxMIQnJpc2JhbmUxGjAYBgNVBAoTEUNyeXB0c29m
40dCBQdHkgTHRkMRIwEAYDVQQLEwlTTUlNRSAwMDMxFDASBgNVBAMTC0luZm9ybWF0
41aW9uMSEwHwYJKoZIhvcNAQkBFhJpbmZvQGNyeXB0c29mdC5jb20wXDANBgkqhkiG
429w0BAQEFAANLADBIAkEArecjie4Nh7ecMkRLlYFz3SKASy3FYLj+Hhhj79yJiSLf
43lTx62z2aBqgI1in970EJke28rZj59iiQYm/n5wxNCwIDAQABoygwJjAkBglghkgB
44hvhCAQ0EFxYVR2VuZXJhdGVkIHdpdGggU1NMZWF5MA0GCSqGSIb3DQEBBAUAA0EA
45UhXqiPTw+QvvztX4g0BhFl5V+c4t0YsxXAPGLRB8YdVcCkKX0f1ltraEpTnsRuz8
464A3ZItobUHStkstOkOX6fQ==
47-----END CERTIFICATE-----
48
diff --git a/src/lib/libcrypto/pkcs7/t/ff b/src/lib/libcrypto/pkcs7/t/ff
new file mode 100644
index 0000000000..23f013516a
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/t/ff
@@ -0,0 +1,32 @@
1-----BEGIN PKCS7-----
2MIIGHgYJKoZIhvcNAQcCoIIGDzCCBgsCAQExCzAJBgUrDgMCGgUAMAsGCSqGSIb3DQEHAaCC
3BGswggJTMIIB/aADAgECAgIEfjANBgkqhkiG9w0BAQQFADCBkjELMAkGA1UEBhMCQVUxEzAR
4BgNVBAgTClF1ZWVuc2xhbmQxETAPBgNVBAcTCEJyaXNiYW5lMRowGAYDVQQKExFDcnlwdHNv
5ZnQgUHR5IEx0ZDEiMCAGA1UECxMZREVNT05TVFJBVElPTiBBTkQgVEVTVElORzEbMBkGA1UE
6AxMSREVNTyBaRVJPIFZBTFVFIENBMB4XDTk4MDUxMzA2MjY1NloXDTAwMDUxMjA2MjY1Nlow
7gaUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpRdWVlbnNsYW5kMREwDwYDVQQHEwhCcmlzYmFu
8ZTEaMBgGA1UEChMRQ3J5cHRzb2Z0IFB0eSBMdGQxEjAQBgNVBAsTCVNNSU1FIDAwMzEZMBcG
9A1UEAxMQQW5nZWxhIHZhbiBMZWVudDEjMCEGCSqGSIb3DQEJARYUYW5nZWxhQGNyeXB0c29m
10dC5jb20wXDANBgkqhkiG9w0BAQEFAANLADBIAkEAuC3+7dAb2LhuO7gt2cTM8vsNjhG5JfDh
11hX1Vl/wVGbKEEj0MA6vWEolvefQlxB+EzwCtR0YZ7eEC/T/4JoCyeQIDAQABoygwJjAkBglg
12hkgBhvhCAQ0EFxYVR2VuZXJhdGVkIHdpdGggU1NMZWF5MA0GCSqGSIb3DQEBBAUAA0EAUnSP
13igs6TMFISTjw8cBtJYb98czgAVkVFjKyJQwYMH8FbDnCyx6NocM555nsyDstaw8fKR11Khds
14syd3ikkrhDCCAhAwggG6AgEDMA0GCSqGSIb3DQEBBAUAMIGSMQswCQYDVQQGEwJBVTETMBEG
15A1UECBMKUXVlZW5zbGFuZDERMA8GA1UEBxMIQnJpc2JhbmUxGjAYBgNVBAoTEUNyeXB0c29m
16dCBQdHkgTHRkMSIwIAYDVQQLExlERU1PTlNUUkFUSU9OIEFORCBURVNUSU5HMRswGQYDVQQD
17ExJERU1PIFpFUk8gVkFMVUUgQ0EwHhcNOTgwMzAzMDc0MTMyWhcNMDgwMjI5MDc0MTMyWjCB
18kjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClF1ZWVuc2xhbmQxETAPBgNVBAcTCEJyaXNiYW5l
19MRowGAYDVQQKExFDcnlwdHNvZnQgUHR5IEx0ZDEiMCAGA1UECxMZREVNT05TVFJBVElPTiBB
20TkQgVEVTVElORzEbMBkGA1UEAxMSREVNTyBaRVJPIFZBTFVFIENBMFwwDQYJKoZIhvcNAQEB
21BQADSwAwSAJBAL+0E2fLej3FSCwe2A2iRnMuC3z12qHIp6Ky1wo2zZcxft7AI+RfkrWrSGtf
22mfzBEuPrLdfulncC5Y1pNcM8RTUCAwEAATANBgkqhkiG9w0BAQQFAANBAGSbLMphL6F5pp3s
238o0Xyh86FHFdpVOwYx09ELLkuG17V/P9pgIc0Eo/gDMbN+KT3IdgECf8S//pCRA6RrNjcXIx
24ggF7MIIBdwIBATCBmTCBkjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClF1ZWVuc2xhbmQxETAP
25BgNVBAcTCEJyaXNiYW5lMRowGAYDVQQKExFDcnlwdHNvZnQgUHR5IEx0ZDEiMCAGA1UECxMZ
26REVNT05TVFJBVElPTiBBTkQgVEVTVElORzEbMBkGA1UEAxMSREVNTyBaRVJPIFZBTFVFIENB
27AgIEfjAJBgUrDgMCGgUAoHowGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAbBgkqhkiG9w0B
28CQ8xDjAMMAoGCCqGSIb3DQMHMBwGCSqGSIb3DQEJBTEPFw05ODA1MTQwMzM5MzdaMCMGCSqG
29SIb3DQEJBDEWBBQstNMnSV26ba8PapQEDhO21yNFrjANBgkqhkiG9w0BAQEFAARAW9Xb9YXv
30BfcNkutgFX9Gr8iXhBVsNtGEVrjrpkQwpKa7jHI8SjAlLhk/4RFwDHf+ISB9Np3Z1WDWnLcA
319CWR6g==
32-----END PKCS7-----
diff --git a/src/lib/libcrypto/pkcs7/t/msie-e b/src/lib/libcrypto/pkcs7/t/msie-e
new file mode 100644
index 0000000000..aafae69fc9
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/t/msie-e
@@ -0,0 +1,20 @@
1
2MIAGCSqGSIb3DQEHA6CAMIACAQAxggHCMIHMAgEAMHYwYjERMA8GA1UEBxMISW50ZXJuZXQxFzAV
3BgNVBAoTDlZlcmlTaWduLCBJbmMuMTQwMgYDVQQLEytWZXJpU2lnbiBDbGFzcyAxIENBIC0gSW5k
4aXZpZHVhbCBTdWJzY3JpYmVyAhBgQJiC3qfbCbjdj5INYLnKMA0GCSqGSIb3DQEBAQUABECMzu8y
5wQ/qZbO8cAGMRBF+mPruv3+Dvb9aWNZ2k8njUgqF6mcdhVB2MkGcsG3memRXJBixvMYWVkU3qK4Z
6VuKsMIHwAgEAMIGZMIGSMQswCQYDVQQGEwJBVTETMBEGA1UECBMKUXVlZW5zbGFuZDERMA8GA1UE
7BxMIQnJpc2JhbmUxGjAYBgNVBAoTEUNyeXB0c29mdCBQdHkgTHRkMSIwIAYDVQQLExlERU1PTlNU
8UkFUSU9OIEFORCBURVNUSU5HMRswGQYDVQQDExJERU1PIFpFUk8gVkFMVUUgQ0ECAgRuMA0GCSqG
9SIb3DQEBAQUABEBcWwYFHJbJGhiztt7lzue3Lc9CH5WAbyR+2BZ3uv+JxZfRs1PuaWPOwRa0Vgs3
10YwSJoRfxQj2Gk0wFqG1qt6d1MIAGCSqGSIb3DQEHATAaBggqhkiG9w0DAjAOAgIAoAQI8vRlP/Nx
112iSggASCAZhR5srxyspy7DfomRJ9ff8eMCtaNwEoEx7G25PZRonC57hBvGoScLtEPU3Wp9FEbPN7
12oJESeC+AqMTyTLNy8aQsyC5s53E9UkoIvg62ekYZBbXZqXsrxx4PhiiX3NH8GVh42phB0Chjw0nK
13HZeRDmxGY3Cmk+J+l0uVKxbNIfJIKOguLBnhqmnKH/PrnzDt591u0ULy2aTLqRm+4/1Yat/QPb6J
14eoKGwNPBbS9ogBdrCNCp9ZFg3Xar2AtQHzyTQIfYeH3SRQUpKmRm5U5o9p5emgEdT+ZfJm/J4tSH
15OmbgAFsbHQakA4MBZ4J5qfDJhOA2g5lWk1hIeu5Dn/AaLRZd0yz3oY0Ieo/erPWx/bCqtBzYbMe9
16qSFTedKlbc9EGe3opOTdBZVzK8KH3w3zsy5luxKdOUG59YYb5F1IZiWGiDyuo/HuacX+griu5LeD
17bEzOtZnko+TZXvWIko30fD79j3T4MRRhWXbgj2HKza+4vJ0mzcC/1+GPsJjAEAA/JgIEDU4w6/DI
18/HQHhLAO3G+9xKD7MvmrzkoAAAAAAAAAAAAA
19
20
diff --git a/src/lib/libcrypto/pkcs7/t/msie-e.pem b/src/lib/libcrypto/pkcs7/t/msie-e.pem
new file mode 100644
index 0000000000..a2a5e24e74
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/t/msie-e.pem
@@ -0,0 +1,22 @@
1-----BEGIN PKCS7-----
2MIAGCSqGSIb3DQEHA6CAMIIDkAIBADGCAcIwgcwCAQAwdjBiMREwDwYDVQQHEwhJ
3bnRlcm5ldDEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xNDAyBgNVBAsTK1ZlcmlT
4aWduIENsYXNzIDEgQ0EgLSBJbmRpdmlkdWFsIFN1YnNjcmliZXICEGBAmILep9sJ
5uN2Pkg1gucowDQYJKoZIhvcNAQEBBQAEQIzO7zLBD+pls7xwAYxEEX6Y+u6/f4O9
6v1pY1naTyeNSCoXqZx2FUHYyQZywbeZ6ZFckGLG8xhZWRTeorhlW4qwwgfACAQAw
7gZkwgZIxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpRdWVlbnNsYW5kMREwDwYDVQQH
8EwhCcmlzYmFuZTEaMBgGA1UEChMRQ3J5cHRzb2Z0IFB0eSBMdGQxIjAgBgNVBAsT
9GURFTU9OU1RSQVRJT04gQU5EIFRFU1RJTkcxGzAZBgNVBAMTEkRFTU8gWkVSTyBW
10QUxVRSBDQQICBG4wDQYJKoZIhvcNAQEBBQAEQFxbBgUclskaGLO23uXO57ctz0If
11lYBvJH7YFne6/4nFl9GzU+5pY87BFrRWCzdjBImhF/FCPYaTTAWobWq3p3UwggHD
12BgkqhkiG9w0BBwEwGgYIKoZIhvcNAwIwDgICAKAECPL0ZT/zcdokgIIBmFHmyvHK
13ynLsN+iZEn19/x4wK1o3ASgTHsbbk9lGicLnuEG8ahJwu0Q9Tdan0URs83ugkRJ4
14L4CoxPJMs3LxpCzILmzncT1SSgi+DrZ6RhkFtdmpeyvHHg+GKJfc0fwZWHjamEHQ
15KGPDScodl5EObEZjcKaT4n6XS5UrFs0h8kgo6C4sGeGqacof8+ufMO3n3W7RQvLZ
16pMupGb7j/Vhq39A9vol6gobA08FtL2iAF2sI0Kn1kWDddqvYC1AfPJNAh9h4fdJF
17BSkqZGblTmj2nl6aAR1P5l8mb8ni1Ic6ZuAAWxsdBqQDgwFngnmp8MmE4DaDmVaT
18WEh67kOf8BotFl3TLPehjQh6j96s9bH9sKq0HNhsx72pIVN50qVtz0QZ7eik5N0F
19lXMrwoffDfOzLmW7Ep05Qbn1hhvkXUhmJYaIPK6j8e5pxf6CuK7kt4NsTM61meSj
205Nle9YiSjfR8Pv2PdPgxFGFZduCPYcrNr7i8nSbNwL/X4Y+wmMAQAD8mAgQNTjDr
218Mj8dAeEsA7cb73EoPsy+avOSgAAAAA=
22-----END PKCS7-----
diff --git a/src/lib/libcrypto/pkcs7/t/msie-enc-01 b/src/lib/libcrypto/pkcs7/t/msie-enc-01
new file mode 100644
index 0000000000..2c93ab6462
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/t/msie-enc-01
@@ -0,0 +1,62 @@
1
2MIAGCSqGSIb3DQEHA6CAMIACAQAxgfMwgfACAQAwgZkwgZIxCzAJBgNVBAYTAkFVMRMwEQYD
3VQQIEwpRdWVlbnNsYW5kMREwDwYDVQQHEwhCcmlzYmFuZTEaMBgGA1UEChMRQ3J5cHRzb2Z0
4IFB0eSBMdGQxIjAgBgNVBAsTGURFTU9OU1RSQVRJT04gQU5EIFRFU1RJTkcxGzAZBgNVBAMT
5EkRFTU8gWkVSTyBWQUxVRSBDQQICBG4wDQYJKoZIhvcNAQEBBQAEQKvMaW8xh6oF/X+CJivz
6IZV7yHxlp4O3NHQtWG0A8MOZB+CtKlU7/6g5e/a9Du/TOqxRMqtYRp63pa2Q/mM4IYMwgAYJ
7KoZIhvcNAQcBMBoGCCqGSIb3DQMCMA4CAgCgBAifz6RvzOPYlKCABIGwxtGA/FLBBRs1wbBP
8gDCbSG0yCwjJNsFg89/k6xuXo8c5YTwsw8+XlIVq03navpew6XxxzY090rD2OJ0t6HA6GqrI
9pd8WiSh/Atqn0yfLFmkLqgIAPRfzxUxqUocxLpQsLIFp2YNUGE+yps+UZmIjw/WHfdqrcWTm
10STSvKuy3UkIJZCkGDBpTvqk4BFaHh4oTXEpgpNY+GKxjf9TDN9GQPqQZR7sgQki4t2g4/Saq
11Kl4EMISgluk6swdND0tiHY7v5d6YR29ePCl2/STJ98eJpWkEEC22GNNvOy7ru/Rv2He4MgQg
12optd7sk9MMd9xhJppg7CcH/yDx//HrtgpOcWmn6VxpgECFqon4uXkQtIBIH4PaNclFn7/hLx
13Pw2VmBGaC0SYF3U1jyN96EBxdjqy8Aa6ByMXYDW5BcfqniD5mYXfw+b81lh1kutxaPaV4YJ9
14ZlRUW752N7VHo/fG0/fukoe5W9a8kIhgLpygllb/GP4oSF4wM6n1/OgRzZj2IWFiobKO4d/t
15Mnh+C+PoEVAuFZcxQwi9GqvsK5OoIjVwNx0XcVSOl1TTYS9SwC7ugMBCab73JiruC24pL78Y
16M+NaIpIQ3On4DokJA2ZHtjBjZIxF4tKA144RvFN6pBd6TVE5XM6KD/Vh9bjSmujtEAfdQ3Te
17dvKJsbZuu0stErbvWcRy11I328l557EECAJT7d44OJ3rBBBj6bnnx6dDU2SRqp2CEoQaBAhK
18RBuyhNxkygQIOY9/NhwqAJAECOvX0Zd0DqgoBAjobPpMHhVV3gQQWLU2vEoZ51BwzxdzCmxO
19wwQI4oKfudaNqoAESKzBNAqv5kGumHOlMKsRfrs7jZCcSaOuEj97pYx08FLEgF23cav39MOQ
20NUEM1dNU+EYslL4o3RoSHRjUgPU+2t9c0prS9A/bPARIEOP94PynaTNxwHi3VTK7SzuQmgzA
214n942E9joSiqsQPlsKAb3sPUaLC3SuUxSjNBgfpvD0bmrA/5h+WZoYXvIogFpwjkSmnFBEie
220lh5Ov1aRrvCw5/j3Q/W/4ZtN5U+aeVBJMtA8n0Mxd5kPxHbNVh4oGprZ6wEegV8ht3voyZa
23mZ5Cyxc8ffMYnM/JJI6/oEYEUEMyyiS5FnYyvxKzfMtyn2lZ2st9nZGNNgMc9N62r5HgNbdD
24FHuRdKKzV+8kQfuMc3mOPpK1t9TFY+QgrxiB5p6S7VooI97YtP3PbfknszCEBEh4PdXYbbaR
253AacN3Q5kYYmWsq3WW6xgrg0mmEGosGvwSQxBBuiXZrxScCa4ivEq05UZwyShePvKduOvnUE
262zDO6IXFLZxhTZAESEm9/FovLgGAiJ7iMGmYvsISLJScwG4n+wrSaQNQXizs9N3ykys54wBN
27d/+BQ4F7pncHhDQ2Dyt5MekB8Y8iNOocUTFCu524vQRIaWCXmXP3vU7D21dp0XnAMzRQJ565
28JV3aHRoY7XDa4LePa7PP9ywyafOE5yCW7ndqx3J+2JhTDvSFsW8/q3H3iyeFhykuJVS6BFDK
296CmKbnyyjOfE2iLGJmTFa905V2KrVDCmlEu/xyGMs80yTyZC+ySzM83FMVvLEQmSzcTNUZVp
30DfA1kNXbXkPouBXXT6g8r8JCRljaKKABmgRIlMheOJQRUUU4cgvhMreXPayhq5Ao4VMSCkA5
31hYRCBczm4Di/MMohF0SxIsdRY6gY9CPnrBXAsY6h1RbR7Tw0iQZmeXi52DCiBEj0by+SYMAa
329z0CReIzl8JLL6EVIFz8kFxlkGWjr4dnOzhhPOq/mCpp0WxbavDfdhE87MdXJZBnLwoT62QG
33955HlAoEQBOGJbcESCgd5XSirZ9Y3AbCfuKOqoMBvEUGn+w/pMaqnGvnr5FZhuBDKrhRXqtx
34QsxA//drGUxsrZOuSL/0+fbvo7n2h1Z8Ny86jOvVZAQIAjw2l1Yc5RAESNc9i3I8pKEOVQf/
35UBczJ0NR9aTEF80dRg2lpXwD0ho4N0AvSiVbgxC7cPZHQwIqvq9LHRUs/4n+Vu3SVYU3cAxo
36lUTiCGUSlARIF+TD57SI5+RI+MNtnD9rs4E1ml51YoHGWFj3UPriDmY0FKEwIgqtMXMY3fZ9
37Kq8d83bjDzxwbDX7WwR7KbSeJWT42pCz7kM+BEjjPsOnZHuusXT3x2rrsBnYtYsbt98mSFiS
38KzTtFmXfkOBbCQdit1P76QnYJ1aXMGs6zP6GypQTadK/zYWvlm38QkVwueaJ0woESKW2pqKA
3970h2UMDHOrpepU1lj0YMzmotDHSTU3L909VvUMNg9uqfrQ6mSkb9j5Tl8oF2otOw5EzA1Yda
40KPmgsv62RWLYl80wXQRQwG0e/mgG75jp9lOhJdVXqcYbQpS9viwVaVkwH+69mu/bQI4gjoEs
41UYX6O71Re2z+cYhcm9UrK+DXuSFBXQOIlAFxKMW4B0apd6fU84FsZLMESOorXE5OE0A2B2ji
42J8QI0Exk4hUvWrMNJfUZwFyS7E05xV9ORuX1xmsKqkT4tVR5Nqln4vhvAY860VBoloz0CDkd
438seSBEjeMgRI9FvpYuflIeHg9urkwp6N+1f0DrJJhJY9ZQ0HTQhziJmIfvbEjNqCl7hEC28+
44F8I5tuViLgfSwcFFCvnS6WFoN4X6QdFdqMCbBEjdlI1c+IQGA/IuTDMJYCuQ/v+8BG5ZeWVH
45icPZmXfRat9eFK1dGKAJef6+Tf9HPuDjSpDyffrifsp7Dc34lmm7GN1+ON3ZMtwEUNm6epb8
461RKWjoI7jIKUV/M2p/0eeGSqs4b06KF/VR6dBwsJVL5DpnTsp3MV4j/CAOlRdSPZ5++tsKbM
47aplk+ceqQtpEFz1MYTtVV4+rlrWaBEA1okJyNZ5/tNOwM7B+XfOZ0xw+uyVi9v4byTZM2Qds
48J+d3YGYLAugTGHISLqQEerD8/gGK+/SL06b2gNedXPHtBAiBKX+Mdy3wFQQIqE9gVgvrFNUE
49CKKoTFoMGqnPBAjDPgLCklNfrwQI3Ek1vSq68w8ECBodu2FOZJVkBAgzwjfSr2N9WQQQTCoQ
50KkAbrS9tnjXn1I3+ZwQIrPx3eINo/YUECIeYWCFskxlYBAiDUdvZXwD3vgQIkEyZbbZWbUUE
51CH4+odl1Isk3BBj68fkqJ0fKJRWVLWuW/O3VE4BOPKwFlaIECFseVTdDUho8BAj+cOKvV2WA
52hgQgaXr+wwq+ItblG0Qxz8IVUXX6PV2mIdHwz4SCCvnCsaIECJhBYxdfLI/XBCDswamPn9MR
53yXi2HVQBineV+GtWVkIoZ2dCLFB9mQRMoAQI0nUR5a5AOJoECA+AunKlAlx8BAi5RtFeF4g1
54FQQIz/ie+16LlQcECOmNuVg5DXjMBAjH2nkfpXZgWwQIVdLuO/+kuHAECO/5rEHmyI9vBBD4
5516BU4Rd3YerDQnHtrwOQBCCkho1XxK5Maz8KLCNi20wvcGt8wsIXlj2h5q9ITBq7IgQQvKVY
564OfJ7bKbItP2dylwQgQYPIGxwkkbRXNraONYvN19G8UdF35rFOuIBAjf0sKz/618ZQQIxObr
57xJkRe0sECIC+ssnjEb2NBBBI+XM4OntVWGsRV9Td3sFgBAinGwIroo8O0gQQMGAwgc9PaLaG
58gBCiwSTrYQQIVHjfCQgOtygEUIoraFoANfhZgIShpOd/RRxFU4/7xZR5tMdGoYz/g0thR0lM
59+Hi88FtFD4mAh/Oat4Ri8B7bv04aokjN2UHz6nPbHHjZ8zIqpbYTCy043GNZBAhOqjyB2JbD
60NwQoR23XCYD9x6E20ChHJRXmaHwyMdYXKl5CUxypl7ois+sy2D7jDukS3wQIsTyyPgJi0GsA
61AAAAAAAAAAAA
62
diff --git a/src/lib/libcrypto/pkcs7/t/msie-enc-01.pem b/src/lib/libcrypto/pkcs7/t/msie-enc-01.pem
new file mode 100644
index 0000000000..9abf00b2f2
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/t/msie-enc-01.pem
@@ -0,0 +1,66 @@
1-----BEGIN PKCS7-----
2MIAGCSqGSIb3DQEHA6CAMIILyAIBADGB8zCB8AIBADCBmTCBkjELMAkGA1UEBhMC
3QVUxEzARBgNVBAgTClF1ZWVuc2xhbmQxETAPBgNVBAcTCEJyaXNiYW5lMRowGAYD
4VQQKExFDcnlwdHNvZnQgUHR5IEx0ZDEiMCAGA1UECxMZREVNT05TVFJBVElPTiBB
5TkQgVEVTVElORzEbMBkGA1UEAxMSREVNTyBaRVJPIFZBTFVFIENBAgIEbjANBgkq
6hkiG9w0BAQEFAARAq8xpbzGHqgX9f4ImK/MhlXvIfGWng7c0dC1YbQDww5kH4K0q
7VTv/qDl79r0O79M6rFEyq1hGnrelrZD+YzghgzCCCssGCSqGSIb3DQEHATAaBggq
8hkiG9w0DAjAOAgIAoAQIn8+kb8zj2JSAggqgxtGA/FLBBRs1wbBPgDCbSG0yCwjJ
9NsFg89/k6xuXo8c5YTwsw8+XlIVq03navpew6XxxzY090rD2OJ0t6HA6GqrIpd8W
10iSh/Atqn0yfLFmkLqgIAPRfzxUxqUocxLpQsLIFp2YNUGE+yps+UZmIjw/WHfdqr
11cWTmSTSvKuy3UkIJZCkGDBpTvqk4BFaHh4oTXEpgpNY+GKxjf9TDN9GQPqQZR7sg
12Qki4t2g4/SaqKl6EoJbpOrMHTQ9LYh2O7+XemEdvXjwpdv0kyffHiaVpBBAtthjT
13bzsu67v0b9h3uDKim13uyT0wx33GEmmmDsJwf/IPH/8eu2Ck5xaafpXGmFqon4uX
14kQtIPaNclFn7/hLxPw2VmBGaC0SYF3U1jyN96EBxdjqy8Aa6ByMXYDW5BcfqniD5
15mYXfw+b81lh1kutxaPaV4YJ9ZlRUW752N7VHo/fG0/fukoe5W9a8kIhgLpygllb/
16GP4oSF4wM6n1/OgRzZj2IWFiobKO4d/tMnh+C+PoEVAuFZcxQwi9GqvsK5OoIjVw
17Nx0XcVSOl1TTYS9SwC7ugMBCab73JiruC24pL78YM+NaIpIQ3On4DokJA2ZHtjBj
18ZIxF4tKA144RvFN6pBd6TVE5XM6KD/Vh9bjSmujtEAfdQ3TedvKJsbZuu0stErbv
19WcRy11I328l557ECU+3eODid62PpuefHp0NTZJGqnYIShBpKRBuyhNxkyjmPfzYc
20KgCQ69fRl3QOqCjobPpMHhVV3li1NrxKGedQcM8XcwpsTsPigp+51o2qgKzBNAqv
215kGumHOlMKsRfrs7jZCcSaOuEj97pYx08FLEgF23cav39MOQNUEM1dNU+EYslL4o
223RoSHRjUgPU+2t9c0prS9A/bPBDj/eD8p2kzccB4t1Uyu0s7kJoMwOJ/eNhPY6Eo
23qrED5bCgG97D1Giwt0rlMUozQYH6bw9G5qwP+YflmaGF7yKIBacI5EppxZ7SWHk6
24/VpGu8LDn+PdD9b/hm03lT5p5UEky0DyfQzF3mQ/Eds1WHigamtnrAR6BXyG3e+j
25JlqZnkLLFzx98xicz8kkjr+gRkMyyiS5FnYyvxKzfMtyn2lZ2st9nZGNNgMc9N62
26r5HgNbdDFHuRdKKzV+8kQfuMc3mOPpK1t9TFY+QgrxiB5p6S7VooI97YtP3Pbfkn
27szCEeD3V2G22kdwGnDd0OZGGJlrKt1lusYK4NJphBqLBr8EkMQQbol2a8UnAmuIr
28xKtOVGcMkoXj7ynbjr51BNswzuiFxS2cYU2QSb38Wi8uAYCInuIwaZi+whIslJzA
29bif7CtJpA1BeLOz03fKTKznjAE13/4FDgXumdweENDYPK3kx6QHxjyI06hxRMUK7
30nbi9aWCXmXP3vU7D21dp0XnAMzRQJ565JV3aHRoY7XDa4LePa7PP9ywyafOE5yCW
317ndqx3J+2JhTDvSFsW8/q3H3iyeFhykuJVS6yugpim58soznxNoixiZkxWvdOVdi
32q1QwppRLv8chjLPNMk8mQvskszPNxTFbyxEJks3EzVGVaQ3wNZDV215D6LgV10+o
33PK/CQkZY2iigAZqUyF44lBFRRThyC+Eyt5c9rKGrkCjhUxIKQDmFhEIFzObgOL8w
34yiEXRLEix1FjqBj0I+esFcCxjqHVFtHtPDSJBmZ5eLnYMKL0by+SYMAa9z0CReIz
35l8JLL6EVIFz8kFxlkGWjr4dnOzhhPOq/mCpp0WxbavDfdhE87MdXJZBnLwoT62QG
36955HlAoEQBOGJbcoHeV0oq2fWNwGwn7ijqqDAbxFBp/sP6TGqpxr56+RWYbgQyq4
37UV6rcULMQP/3axlMbK2Trki/9Pn276O59odWfDcvOozr1WQCPDaXVhzlENc9i3I8
38pKEOVQf/UBczJ0NR9aTEF80dRg2lpXwD0ho4N0AvSiVbgxC7cPZHQwIqvq9LHRUs
39/4n+Vu3SVYU3cAxolUTiCGUSlBfkw+e0iOfkSPjDbZw/a7OBNZpedWKBxlhY91D6
404g5mNBShMCIKrTFzGN32fSqvHfN24w88cGw1+1sEeym0niVk+NqQs+5DPuM+w6dk
41e66xdPfHauuwGdi1ixu33yZIWJIrNO0WZd+Q4FsJB2K3U/vpCdgnVpcwazrM/obK
42lBNp0r/Nha+WbfxCRXC55onTCqW2pqKA70h2UMDHOrpepU1lj0YMzmotDHSTU3L9
4309VvUMNg9uqfrQ6mSkb9j5Tl8oF2otOw5EzA1YdaKPmgsv62RWLYl80wXcBtHv5o
44Bu+Y6fZToSXVV6nGG0KUvb4sFWlZMB/uvZrv20COII6BLFGF+ju9UXts/nGIXJvV
45Kyvg17khQV0DiJQBcSjFuAdGqXen1POBbGSz6itcTk4TQDYHaOInxAjQTGTiFS9a
46sw0l9RnAXJLsTTnFX05G5fXGawqqRPi1VHk2qWfi+G8BjzrRUGiWjPQIOR3yx5IE
47SN4y9FvpYuflIeHg9urkwp6N+1f0DrJJhJY9ZQ0HTQhziJmIfvbEjNqCl7hEC28+
48F8I5tuViLgfSwcFFCvnS6WFoN4X6QdFdqMCb3ZSNXPiEBgPyLkwzCWArkP7/vARu
49WXllR4nD2Zl30WrfXhStXRigCXn+vk3/Rz7g40qQ8n364n7Kew3N+JZpuxjdfjjd
502TLc2bp6lvzVEpaOgjuMgpRX8zan/R54ZKqzhvTooX9VHp0HCwlUvkOmdOyncxXi
51P8IA6VF1I9nn762wpsxqmWT5x6pC2kQXPUxhO1VXj6uWtZo1okJyNZ5/tNOwM7B+
52XfOZ0xw+uyVi9v4byTZM2QdsJ+d3YGYLAugTGHISLqQEerD8/gGK+/SL06b2gNed
53XPHtgSl/jHct8BWoT2BWC+sU1aKoTFoMGqnPwz4CwpJTX6/cSTW9KrrzDxodu2FO
54ZJVkM8I30q9jfVlMKhAqQButL22eNefUjf5nrPx3eINo/YWHmFghbJMZWINR29lf
55APe+kEyZbbZWbUV+PqHZdSLJN/rx+SonR8olFZUta5b87dUTgE48rAWVolseVTdD
56Uho8/nDir1dlgIZpev7DCr4i1uUbRDHPwhVRdfo9XaYh0fDPhIIK+cKxophBYxdf
57LI/X7MGpj5/TEcl4th1UAYp3lfhrVlZCKGdnQixQfZkETKDSdRHlrkA4mg+AunKl
58Alx8uUbRXheINRXP+J77XouVB+mNuVg5DXjMx9p5H6V2YFtV0u47/6S4cO/5rEHm
59yI9v+NegVOEXd2Hqw0Jx7a8DkKSGjVfErkxrPwosI2LbTC9wa3zCwheWPaHmr0hM
60GrsivKVY4OfJ7bKbItP2dylwQjyBscJJG0Vza2jjWLzdfRvFHRd+axTriN/SwrP/
61rXxlxObrxJkRe0uAvrLJ4xG9jUj5czg6e1VYaxFX1N3ewWCnGwIroo8O0jBgMIHP
62T2i2hoAQosEk62FUeN8JCA63KIoraFoANfhZgIShpOd/RRxFU4/7xZR5tMdGoYz/
63g0thR0lM+Hi88FtFD4mAh/Oat4Ri8B7bv04aokjN2UHz6nPbHHjZ8zIqpbYTCy04
643GNZTqo8gdiWwzdHbdcJgP3HoTbQKEclFeZofDIx1hcqXkJTHKmXuiKz6zLYPuMO
656RLfsTyyPgJi0GsAAAAA
66-----END PKCS7-----
diff --git a/src/lib/libcrypto/pkcs7/t/msie-enc-02 b/src/lib/libcrypto/pkcs7/t/msie-enc-02
new file mode 100644
index 0000000000..7017055965
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/t/msie-enc-02
@@ -0,0 +1,90 @@
1
2MIAGCSqGSIb3DQEHA6CAMIACAQAxggHCMIHMAgEAMHYwYjERMA8GA1UEBxMISW50ZXJuZXQxFzAV
3BgNVBAoTDlZlcmlTaWduLCBJbmMuMTQwMgYDVQQLEytWZXJpU2lnbiBDbGFzcyAxIENBIC0gSW5k
4aXZpZHVhbCBTdWJzY3JpYmVyAhBgQJiC3qfbCbjdj5INYLnKMA0GCSqGSIb3DQEBAQUABEACr4tn
5kSzvo3aIlHfJLGbfokNCV6FjdDP1vQhL+kdXONqcFCEf9ReETCvaHslIr/Wepc5j2hjZselzgqLn
6rM1ZMIHwAgEAMIGZMIGSMQswCQYDVQQGEwJBVTETMBEGA1UECBMKUXVlZW5zbGFuZDERMA8GA1UE
7BxMIQnJpc2JhbmUxGjAYBgNVBAoTEUNyeXB0c29mdCBQdHkgTHRkMSIwIAYDVQQLExlERU1PTlNU
8UkFUSU9OIEFORCBURVNUSU5HMRswGQYDVQQDExJERU1PIFpFUk8gVkFMVUUgQ0ECAgRuMA0GCSqG
9SIb3DQEBAQUABEBanBxKOvUoRn3DiFY55lly2TPu2Cv+dI/GLrzW6qvnUMZPWGPGaUlPyWLMZrXJ
10xGXZUiRJKTBwDu91fnodUEK9MIAGCSqGSIb3DQEHATAaBggqhkiG9w0DAjAOAgIAoAQImxKZEDWP
11EuOggASCBACBi1bX/qc3geqFyfRpX7JyIo/g4CDr62GlwvassAGlIO8zJ5Z/UDIIooeV6QS4D4OW
12PymKd0WXhwcJI0yBcJTWEoxND27LM7CWFJpA07AoxVCRHTOPgm794NynLecNUOqVTFyS4CRuLhVG
13PAk0nFZG/RE2yMtx4rAkSiVgOexES7wq/xWuoDSSmuTMNQOTbKfkEKqdFLkM/d62gD2wnaph7vKk
14PPK82wdZP8rF3nUUC5c4ahbNoa8g+5B3tIF/Jz3ZZK3vGLU0IWO+i7W451dna13MglDDjXOeikNl
15XLsQdAVo0nsjfGu+f66besJojPzysNA+IEZl6gNWUetl9lim4SqrxubUExdS2rmXnXXmEuEW/HC7
16dlTAeYq5Clqx5id6slhC2C2oegMww3XH9yxHw6OqzvXY6pVPEScEtBMQLgaKFQT+m2SRtbTVFG7c
17QcnUODyVB1IbpQTF1DHeeOX1W/HfpWZym8dzkti6SCyeumHmqO406xDiIMVKtHOqM86nEHuAMZsr
18cLy+ey6TEJvR6S4N8QRzng8JJDZDTJXQN6q84aEudsnOrw2KyOVwPpI6ey4qBsHUgQ8kAFy5lsQa
19WV45h6exgUwbBcKLgPZGFj+OdD2RKJsTb83/UqbJS5Q/lGXhzBlnaYucyJxEprRxbntmcnOEPFJe
20+tRDUwOTd7qlJljdhIJL+uDcooL9Ahgo6Cwep6tduekv2cSEohJeTE8Dvy34YRhMbLvnFNdmnpNy
21rNZDYVVxxaKoyd2AfB8NPFZh1VdAYfI3R1QAQ2kXEef5NNIfVQfMzD9akJn4RP+Kv32Qaxm4FrnK
22xmwRyGJShavIBc2ax+F1r1+NZXuSBHn5vfoRTxOk0ST4dXsw74dnlYUMRaSu4qqUdM9jsXSyeX4Z
23gQgkR2bkaYO6ezFgenFIa7QWVw8rXZAEZ5aibCxbnY1VE41PYIvhlLdbFJhH9gY22s+fFAuwnzyA
24SRjC40A9aAEItRlaPStWSGiqlLRgNkBBwdpv2l2YPBd2QzHx6ek6XGrvRJuAC+Nh62rtQKwpNH54
25YAOHW55maBFW2SQ3TF+cZ6NbbqhCmHTyyR7mcSYc9sXSVDWEhYKQ1iyU870zhHWVpvglZizZetJC
26ZFjYex3b1ngVdcgargOvpPq9urCKKi2mbkqv/EFpzSWGXkKSpfCG/XfMnEOtkNrB8S06vnk2JcJB
27OBqJot+uuSH5hOg0vTpxX2DuONJSiWSWyfRE/lTfJJFXwhod7SXclUyXPeSyibcSic2hVAzDmwjD
2831js/j2k02PI/agPhr3UQ8cMgcNAiaoCKbNaWfn6BGbCAbTchxzUlo2cSJiLlrX2IDZmfXbXmZCo
29m1smWIG+BIIEALiuAxDb6dWLAYyVBoN9hYI4AiPeZAY9MtvQ6AV8o2/EFm6PvYGXy3Hei5830CH0
30PBeX7Kdd6ff1y33TW/l5qSkIL1ULTGR7okFfJePHDmq1dFt6/JOMptiQ8WSu7CsJQvZ9VTFXeYFc
31ZqCPPZc1NrPegNK70Zf9QxWIbDAevJ5KLBf1c6j8pU2/6LnvDY6VjaTvYSgr7vTR8eVzH4Rm77W0
32iOHxg5VcODv6cGSVyuvbX8UAGo8Cmb58ERDtBDJBQXVpWKLNAuDJ9GX8n2zNkpjZLbPSkcmuhqGa
33BJBE/BaCTkUQWlY9dIbRtEnxIU1mfbPPdx1Ppa8DqGDjSOsQdKcKYNNZtayEw++EIpmpdBNsKphC
34fB8UEK2Wkk4ZVW+qyGoi/r0MFsvO1NmSOOZ0o/jy/YHmoeURHhPy97AO3eVTkEAa5CfJEJybmo56
357CDw/FwoGAUCgsoz7rlxzMudr/IhHIH+APinncxXlHO2ecvHD9i8DaHGA8tVifgsUhqQoZieULut
36eF94O5UAxOkv41UZssYTwN4nYrN1QkesZl3BX4ORS4EE30/PQ23ARf3WZptZrCJevGm2ZYzGeh8x
37g17mCDfiLO+bff4qP/4mC96Pu4ia6j4to5BwKIJS/+DCuoD8WeSKF4pugXQkMUiHdQnNnVP9Sp2O
38/4ly5mO8JzrQC59V2bnTNBqPhpno8kfJvK5TypPSVC+bTzern3rJ6UceB3srcn9zxKx9GdNydJQj
39yWjv8ec3n3d1nuQwhz5Q053NBhIjwoGg3Go7LO6i78ZOlpF7dcoAO13NfHLyNjnyHCaiWtVRTct9
40rLf5vN00urSn8YJngHk1eTKK8nHGIcOg6YdYDOD2nE5XwRijKmieG8Xa3eKRzfbL06GrBQENle6J
41mC131bp3cRVxpjq+o6RAbGoMm4yICsL4eTarCQrsyHmoPHqr91UHo91avyxU7knWmEhX27ybmsrs
428aeZwPHixL14TeyhruCqRVvkf1Ks7P+z8MPUboGNqQe2WLN8ktCGEr15O8MJR/em86G03Jfo4oaw
43/DVUH5RwLT6acedOGuzMh/2r8BcmemhVQ8/cWvV4YJ0tOW4hzyVHC5hQf8sZ3LzxXLH6Ohnrbprh
44xvrdbaSdChWZDDP0bCCbxEhkwuBkBeKZrMbwRTP+TPTPYLVTH/CmKLzKh/114tkGkyO3hHS4qExU
45V39F2Sj4mylx+hD0+20D9pntpNi7htccGlOm6yNM69at/3+kLgJJyoIlaxLcCUYHNMifDt+T3p/t
465U4XmD53uUQ6M8dvj/udqPekNSUfse15yrd9pjOt5PcJuqW28q0sFHf9pHIgz3XZFMe5PD7ppw6r
47S+C6Ir4PrYIEggQA7ZDVtiCm+BbtNNB/UJm79/OQ5mp5bTI0kPmDeycaWTa0Ojpum+c/dpG/iJOB
48DICj7jHOXSHT7JlGyX6aSFJUltucAnZvwzhPDmdDaIDiKSk85GqgdDWVfGosSCX9Ph/T3WpIxnwf
49WSDRtIHkWTjly+pe4yy5K6/XISy/L5Zh/fhiI5fjHjgzmlibs2ru4nVw6hBhUvlSSe2BEs5d9h/y
50NH8Wy3qvb2D3jh7hkepFtZJGNTHp8ZUC7Ns2JIpQYObsaxdI65i3mMOu7fRwI+0/4ejsWhP6KCEi
51LgwvLg0qM82ma6YB7qHAHboaczRVEffDcJUG4a5uycB0DoZFn+uEaEFyili20hCn4hVfsqUQk2PT
528Mo1tSl5e30xI1YJZrRgiJm9nHRX6fLizngP+ILJLPHZsPvlSVIfY+/v/FR8feKOjaGhyGF51BAx
53aM2NIQ4jMP5/X+U5gQybi0E6u7rroDhaHsKmCMgXqszwXWCpedA/sEbeHpiTC59YlPPSlIOMc9vP
54Ko/mQCfWy/9icUaIfKQldvkllUxxNkqu6AbIpHVscbAEzSPs5xbQXU8EZNNCDisFnnpY3nQ3eLnl
55m89saTJxRb7NWHRMlmPv7qgD7uMIq3vdOGA7i5wT9MeoNIgK1/DsgH30s6RWjJy4YyyLmRTXPzbj
56hbQVpEmiMRbEidIvUx2OjKVxVQIcgtLsa2lvHQ4XL1cpLr5GVtOgy0fMg5OCDUUDsvjgjgLQ3P2U
57p2nVY5FM6/QpPc5DTLuuR9ekI2/c9Biz09RtcYDUQK2ajdo8h1IyKqHFoB7h48OXxXKKY94DY0TG
58x6PonB/epj8orAw4QKmm5M0vXYwBOqRymCTHTqOJGObdLx1euFFyqguzHJOU2gAGZI0z9Lg1yRuF
59yhdPZyuniIcmtLNxRZ1duYHErcAyX56qndmLXt7UVkATai/rIMuoJLfAsUnVuTUS5p7tJM754UZT
607lTcXvDJgOUNnBRaIcxC3pxvbrYDJ2iFJ72xkxUP2p74gucqg25XnCVmQuLg6zDDxF6CLuw9isxy
61Xg4pkneMN//7fpp8GYl9nyZm2yqYYM+jcw0fcVc64L+X4w/gL3H2UMGgxIHSJp7HIG7VKHtXrNyj
62dPXXPVUsMsAAimqOr0Lr2sZWirfuivLaPTqhbkvG5PF7K3gT80AOIcd/6EIHBy2hZ7ukfjHmdP4L
63yQOhTQklaKzGHI0mypq0uFLWJOUlZnVrMiLP1xrWkpC8Ro9eo6mfjjQ45z8adC43a47klwTEzvod
643rNEFIGJJUEjAN3mbqie7IxoSJknBBJK0D9lZEQ8lZWlq7vuN8JdqPM6xh155jMVsPwjLK6Tzkj5
65BpRD9Tgm3u6HPQSCBADgkWEN75Mu9TGosXY0xm1k6K6sPv8L949CrLWo4r1I2LA072bTGvQP28Vs
66hUA76jgcT1ocC++9PoktIK10YCq5w+FfMAQ04KeCXuAdmiY2iAT4Slea61PMCMta3mVGyLUZCLEm
67P+I0UKR5mlO0fGEcjU9j8TmbjZqxNFqloLsU7oSi7Os0EtYHkdAVrExUyOc/ZDie6fBjdLTmLdCm
68bE9JNwjlbXypdTZupGgLNhKGDIskUAAMwZYayI6YfSIMkNCeAYTnjOuGZZ1msCXGXsfMBR1sfUIj
699UeGjwD8gq+UVVHX/oeoH/m0eJ5ppqi3+nUlgc9DvpYsC/Fg0G2KuYb9B+VJ+a4GMzQSPREoFtQp
70B9dtLkBb7Ha/hpGWTIdqzW0eAo5llyN8FNvl2Fu2IcLaNmWFO69gLjRKQopp0dvFOuwAVI6fvGDj
71p1WigoNbFZl8N+iiWmzKOjoG2ZLbez1clZCms/JPJrXhEMMOxWpVzkQyN336VWHmGgMcjaKCGSeA
722nnESIGuiCXMrkHlGfabYIsKcHFCo2t13uXyZPf0zSPTkuD0Eh92wqC9pvA3gvrrCUfo9Mn3bs+e
73KWKmDlpcs8mDn032oIg+zrQhIduMqXVn3evzeVM3B5MBOGMvg51/SXg7R+MC/463juQQEb9IVe/I
74YGnO//oWm9lw/377Af/qH+FnN02obJw1FvesQIs9e5RHNQykKbO+vmVJQl1nd9DZWrHDNO7/80Yz
752hCm7Tws5nSRN2iFlyRaYJHr7ypxkU2rCak2r6ua7XDwu1qU2RT3+qPjT1RuxQ2oTlHyGkKPMZGC
76Rc+CSWz5aeeCmHZVwdb3nC8YpfsujMiYqygLeuQ82pjKuR7DIKGmnfcOLdv5F+Ek2Wyy0D98iSgk
77+aoQGYLhL9llU13pn21uRsDY5uGcXiIw1IETFlTdgENEv8futZuJsegrp7fmFXyNoNyFNyypeDrM
786ZqR4vKxFjg3tKKeVpkw/W4EAklzMxmNiazGNDBHsnYV3rwPlKa+HeeE2YxnsKwGLCNgRYUXTaJk
79461vS160z3dvh/mLfdZ7MYCkmO3bNE3ELUDAw7YQkSuo9ujzdFKte9LC34sjg9fOex3ThAg5Y50n
80wYm4zBmGM7yEqL8O6QgnM6tIDFS9XryDaLNzcGhMWqMvhzO6sC/AA2WfLgwS517Cp03IkJQWqG9q
81w52+E+GAtpioJfczEhlv9BrhjttdugRSjJrG8SYVYE4zG3Aur5eNBoGaALIOHOtPw8+JovQmIWcF
82oaJ/WQuglFrWtew51IK6F8RiHAOBVavZOuZcO7tV+5enVfreOd0rX8ZOy4hYmHhmF1hOrrWOn+Ee
83E0SYKonXN01BM9xMBIIBSLCvNAppnGPTUGjwbMJRg1VJ2KMiBWH5oJp8tyfIAxMuWFdtaLYbRSOD
84XbOAshPVK8JAY8DQDkzqaCTAkLTfSRAt9yY6SbUpMsRv7xa8nMZNJBJzJT9b/wNjgiOJgaGuJMkV
852g/DX2jfP3PrMM/Sbnz7edORXHj1Pa5XTT8nG5MS0FuZgvevdq3o/gVVAz+ZCKOH3ShMzZvfp01l
86SX5gaJTflmU6cdNwtn2yZ6IScF7OrjUeA9iEoSVR9dQcA+4lB3RAG3LMwcnxXY35D7+PMJzHIZdF
87cSnq+n03ACY2/E/T31iijRH29rvYHGI+mP/ieYs45iq4fTWo6i1HofeWLdP0fX7xW3XO0/hWYFiw
88BxKu66whAbRhaib3XJNvetVs25ToYXyiDpjG+cd5rCMei8sGQwTBj9Zeh0URoeMW1inTP0JvCmMU
89rZgAAAAAAAAAAAAA
90
diff --git a/src/lib/libcrypto/pkcs7/t/msie-enc-02.pem b/src/lib/libcrypto/pkcs7/t/msie-enc-02.pem
new file mode 100644
index 0000000000..279c5d830b
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/t/msie-enc-02.pem
@@ -0,0 +1,106 @@
1-----BEGIN PKCS7-----
2MIAGCSqGSIb3DQEHA6CAMIITQAIBADGCAcIwgcwCAQAwdjBiMREwDwYDVQQHEwhJ
3bnRlcm5ldDEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xNDAyBgNVBAsTK1ZlcmlT
4aWduIENsYXNzIDEgQ0EgLSBJbmRpdmlkdWFsIFN1YnNjcmliZXICEGBAmILep9sJ
5uN2Pkg1gucowDQYJKoZIhvcNAQEBBQAEQAKvi2eRLO+jdoiUd8ksZt+iQ0JXoWN0
6M/W9CEv6R1c42pwUIR/1F4RMK9oeyUiv9Z6lzmPaGNmx6XOCoueszVkwgfACAQAw
7gZkwgZIxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpRdWVlbnNsYW5kMREwDwYDVQQH
8EwhCcmlzYmFuZTEaMBgGA1UEChMRQ3J5cHRzb2Z0IFB0eSBMdGQxIjAgBgNVBAsT
9GURFTU9OU1RSQVRJT04gQU5EIFRFU1RJTkcxGzAZBgNVBAMTEkRFTU8gWkVSTyBW
10QUxVRSBDQQICBG4wDQYJKoZIhvcNAQEBBQAEQFqcHEo69ShGfcOIVjnmWXLZM+7Y
11K/50j8YuvNbqq+dQxk9YY8ZpSU/JYsxmtcnEZdlSJEkpMHAO73V+eh1QQr0wghFz
12BgkqhkiG9w0BBwEwGgYIKoZIhvcNAwIwDgICAKAECJsSmRA1jxLjgIIRSIGLVtf+
13pzeB6oXJ9GlfsnIij+DgIOvrYaXC9qywAaUg7zMnln9QMgiih5XpBLgPg5Y/KYp3
14RZeHBwkjTIFwlNYSjE0PbsszsJYUmkDTsCjFUJEdM4+Cbv3g3Kct5w1Q6pVMXJLg
15JG4uFUY8CTScVkb9ETbIy3HisCRKJWA57ERLvCr/Fa6gNJKa5Mw1A5Nsp+QQqp0U
16uQz93raAPbCdqmHu8qQ88rzbB1k/ysXedRQLlzhqFs2hryD7kHe0gX8nPdlkre8Y
17tTQhY76LtbjnV2drXcyCUMONc56KQ2VcuxB0BWjSeyN8a75/rpt6wmiM/PKw0D4g
18RmXqA1ZR62X2WKbhKqvG5tQTF1LauZeddeYS4Rb8cLt2VMB5irkKWrHmJ3qyWELY
19Lah6AzDDdcf3LEfDo6rO9djqlU8RJwS0ExAuBooVBP6bZJG1tNUUbtxBydQ4PJUH
20UhulBMXUMd545fVb8d+lZnKbx3OS2LpILJ66Yeao7jTrEOIgxUq0c6ozzqcQe4Ax
21mytwvL57LpMQm9HpLg3xBHOeDwkkNkNMldA3qrzhoS52yc6vDYrI5XA+kjp7LioG
22wdSBDyQAXLmWxBpZXjmHp7GBTBsFwouA9kYWP450PZEomxNvzf9SpslLlD+UZeHM
23GWdpi5zInESmtHFue2Zyc4Q8Ul761ENTA5N3uqUmWN2Egkv64Nyigv0CGCjoLB6n
24q1256S/ZxISiEl5MTwO/LfhhGExsu+cU12aek3Ks1kNhVXHFoqjJ3YB8Hw08VmHV
25V0Bh8jdHVABDaRcR5/k00h9VB8zMP1qQmfhE/4q/fZBrGbgWucrGbBHIYlKFq8gF
26zZrH4XWvX41le5IEefm9+hFPE6TRJPh1ezDvh2eVhQxFpK7iqpR0z2OxdLJ5fhmB
27CCRHZuRpg7p7MWB6cUhrtBZXDytdkARnlqJsLFudjVUTjU9gi+GUt1sUmEf2Bjba
28z58UC7CfPIBJGMLjQD1oAQi1GVo9K1ZIaKqUtGA2QEHB2m/aXZg8F3ZDMfHp6Tpc
29au9Em4AL42Hrau1ArCk0fnhgA4dbnmZoEVbZJDdMX5xno1tuqEKYdPLJHuZxJhz2
30xdJUNYSFgpDWLJTzvTOEdZWm+CVmLNl60kJkWNh7HdvWeBV1yBquA6+k+r26sIoq
31LaZuSq/8QWnNJYZeQpKl8Ib9d8ycQ62Q2sHxLTq+eTYlwkE4Gomi3665IfmE6DS9
32OnFfYO440lKJZJbJ9ET+VN8kkVfCGh3tJdyVTJc95LKJtxKJzaFUDMObCMPfWOz+
33PaTTY8j9qA+GvdRDxwyBw0CJqgIps1pZ+foEZsIBtNyHHNSWjZxImIuWtfYgNmZ9
34dteZkKibWyZYgb64rgMQ2+nViwGMlQaDfYWCOAIj3mQGPTLb0OgFfKNvxBZuj72B
35l8tx3oufN9Ah9DwXl+ynXen39ct901v5eakpCC9VC0xke6JBXyXjxw5qtXRbevyT
36jKbYkPFkruwrCUL2fVUxV3mBXGagjz2XNTaz3oDSu9GX/UMViGwwHryeSiwX9XOo
37/KVNv+i57w2OlY2k72EoK+700fHlcx+EZu+1tIjh8YOVXDg7+nBklcrr21/FABqP
38Apm+fBEQ7QQyQUF1aViizQLgyfRl/J9szZKY2S2z0pHJroahmgSQRPwWgk5FEFpW
39PXSG0bRJ8SFNZn2zz3cdT6WvA6hg40jrEHSnCmDTWbWshMPvhCKZqXQTbCqYQnwf
40FBCtlpJOGVVvqshqIv69DBbLztTZkjjmdKP48v2B5qHlER4T8vewDt3lU5BAGuQn
41yRCcm5qOeuwg8PxcKBgFAoLKM+65cczLna/yIRyB/gD4p53MV5RztnnLxw/YvA2h
42xgPLVYn4LFIakKGYnlC7rXhfeDuVAMTpL+NVGbLGE8DeJ2KzdUJHrGZdwV+DkUuB
43BN9Pz0NtwEX91mabWawiXrxptmWMxnofMYNe5gg34izvm33+Kj/+Jgvej7uImuo+
44LaOQcCiCUv/gwrqA/FnkiheKboF0JDFIh3UJzZ1T/Uqdjv+JcuZjvCc60AufVdm5
450zQaj4aZ6PJHybyuU8qT0lQvm083q596yelHHgd7K3J/c8SsfRnTcnSUI8lo7/Hn
46N593dZ7kMIc+UNOdzQYSI8KBoNxqOyzuou/GTpaRe3XKADtdzXxy8jY58hwmolrV
47UU3Lfay3+bzdNLq0p/GCZ4B5NXkyivJxxiHDoOmHWAzg9pxOV8EYoyponhvF2t3i
48kc32y9OhqwUBDZXuiZgtd9W6d3EVcaY6vqOkQGxqDJuMiArC+Hk2qwkK7Mh5qDx6
49q/dVB6PdWr8sVO5J1phIV9u8m5rK7PGnmcDx4sS9eE3soa7gqkVb5H9SrOz/s/DD
501G6BjakHtlizfJLQhhK9eTvDCUf3pvOhtNyX6OKGsPw1VB+UcC0+mnHnThrszIf9
51q/AXJnpoVUPP3Fr1eGCdLTluIc8lRwuYUH/LGdy88Vyx+joZ626a4cb63W2knQoV
52mQwz9Gwgm8RIZMLgZAXimazG8EUz/kz0z2C1Ux/wpii8yof9deLZBpMjt4R0uKhM
53VFd/Rdko+JspcfoQ9PttA/aZ7aTYu4bXHBpTpusjTOvWrf9/pC4CScqCJWsS3AlG
54BzTInw7fk96f7eVOF5g+d7lEOjPHb4/7naj3pDUlH7Htecq3faYzreT3CbqltvKt
55LBR3/aRyIM912RTHuTw+6acOq0vguiK+D62C7ZDVtiCm+BbtNNB/UJm79/OQ5mp5
56bTI0kPmDeycaWTa0Ojpum+c/dpG/iJOBDICj7jHOXSHT7JlGyX6aSFJUltucAnZv
57wzhPDmdDaIDiKSk85GqgdDWVfGosSCX9Ph/T3WpIxnwfWSDRtIHkWTjly+pe4yy5
58K6/XISy/L5Zh/fhiI5fjHjgzmlibs2ru4nVw6hBhUvlSSe2BEs5d9h/yNH8Wy3qv
59b2D3jh7hkepFtZJGNTHp8ZUC7Ns2JIpQYObsaxdI65i3mMOu7fRwI+0/4ejsWhP6
60KCEiLgwvLg0qM82ma6YB7qHAHboaczRVEffDcJUG4a5uycB0DoZFn+uEaEFyili2
610hCn4hVfsqUQk2PT8Mo1tSl5e30xI1YJZrRgiJm9nHRX6fLizngP+ILJLPHZsPvl
62SVIfY+/v/FR8feKOjaGhyGF51BAxaM2NIQ4jMP5/X+U5gQybi0E6u7rroDhaHsKm
63CMgXqszwXWCpedA/sEbeHpiTC59YlPPSlIOMc9vPKo/mQCfWy/9icUaIfKQldvkl
64lUxxNkqu6AbIpHVscbAEzSPs5xbQXU8EZNNCDisFnnpY3nQ3eLnlm89saTJxRb7N
65WHRMlmPv7qgD7uMIq3vdOGA7i5wT9MeoNIgK1/DsgH30s6RWjJy4YyyLmRTXPzbj
66hbQVpEmiMRbEidIvUx2OjKVxVQIcgtLsa2lvHQ4XL1cpLr5GVtOgy0fMg5OCDUUD
67svjgjgLQ3P2Up2nVY5FM6/QpPc5DTLuuR9ekI2/c9Biz09RtcYDUQK2ajdo8h1Iy
68KqHFoB7h48OXxXKKY94DY0TGx6PonB/epj8orAw4QKmm5M0vXYwBOqRymCTHTqOJ
69GObdLx1euFFyqguzHJOU2gAGZI0z9Lg1yRuFyhdPZyuniIcmtLNxRZ1duYHErcAy
70X56qndmLXt7UVkATai/rIMuoJLfAsUnVuTUS5p7tJM754UZT7lTcXvDJgOUNnBRa
71IcxC3pxvbrYDJ2iFJ72xkxUP2p74gucqg25XnCVmQuLg6zDDxF6CLuw9isxyXg4p
72kneMN//7fpp8GYl9nyZm2yqYYM+jcw0fcVc64L+X4w/gL3H2UMGgxIHSJp7HIG7V
73KHtXrNyjdPXXPVUsMsAAimqOr0Lr2sZWirfuivLaPTqhbkvG5PF7K3gT80AOIcd/
746EIHBy2hZ7ukfjHmdP4LyQOhTQklaKzGHI0mypq0uFLWJOUlZnVrMiLP1xrWkpC8
75Ro9eo6mfjjQ45z8adC43a47klwTEzvod3rNEFIGJJUEjAN3mbqie7IxoSJknBBJK
760D9lZEQ8lZWlq7vuN8JdqPM6xh155jMVsPwjLK6Tzkj5BpRD9Tgm3u6HPeCRYQ3v
77ky71MaixdjTGbWTorqw+/wv3j0KstajivUjYsDTvZtMa9A/bxWyFQDvqOBxPWhwL
78770+iS0grXRgKrnD4V8wBDTgp4Je4B2aJjaIBPhKV5rrU8wIy1reZUbItRkIsSY/
794jRQpHmaU7R8YRyNT2PxOZuNmrE0WqWguxTuhKLs6zQS1geR0BWsTFTI5z9kOJ7p
808GN0tOYt0KZsT0k3COVtfKl1Nm6kaAs2EoYMiyRQAAzBlhrIjph9IgyQ0J4BhOeM
8164ZlnWawJcZex8wFHWx9QiP1R4aPAPyCr5RVUdf+h6gf+bR4nmmmqLf6dSWBz0O+
82liwL8WDQbYq5hv0H5Un5rgYzNBI9ESgW1CkH120uQFvsdr+GkZZMh2rNbR4CjmWX
83I3wU2+XYW7Yhwto2ZYU7r2AuNEpCimnR28U67ABUjp+8YOOnVaKCg1sVmXw36KJa
84bMo6OgbZktt7PVyVkKaz8k8mteEQww7FalXORDI3ffpVYeYaAxyNooIZJ4DaecRI
85ga6IJcyuQeUZ9ptgiwpwcUKja3Xe5fJk9/TNI9OS4PQSH3bCoL2m8DeC+usJR+j0
86yfduz54pYqYOWlyzyYOfTfagiD7OtCEh24ypdWfd6/N5UzcHkwE4Yy+DnX9JeDtH
874wL/jreO5BARv0hV78hgac7/+hab2XD/fvsB/+of4Wc3TahsnDUW96xAiz17lEc1
88DKQps76+ZUlCXWd30NlascM07v/zRjPaEKbtPCzmdJE3aIWXJFpgkevvKnGRTasJ
89qTavq5rtcPC7WpTZFPf6o+NPVG7FDahOUfIaQo8xkYJFz4JJbPlp54KYdlXB1vec
90Lxil+y6MyJirKAt65DzamMq5HsMgoaad9w4t2/kX4STZbLLQP3yJKCT5qhAZguEv
912WVTXemfbW5GwNjm4ZxeIjDUgRMWVN2AQ0S/x+61m4mx6Cunt+YVfI2g3IU3LKl4
92OszpmpHi8rEWODe0op5WmTD9bgQCSXMzGY2JrMY0MEeydhXevA+Upr4d54TZjGew
93rAYsI2BFhRdNomTjrW9LXrTPd2+H+Yt91nsxgKSY7ds0TcQtQMDDthCRK6j26PN0
94Uq170sLfiyOD1857HdOECDljnSfBibjMGYYzvISovw7pCCczq0gMVL1evINos3Nw
95aExaoy+HM7qwL8ADZZ8uDBLnXsKnTciQlBaob2rDnb4T4YC2mKgl9zMSGW/0GuGO
962126BFKMmsbxJhVgTjMbcC6vl40GgZoAsg4c60/Dz4mi9CYhZwWhon9ZC6CUWta1
977DnUgroXxGIcA4FVq9k65lw7u1X7l6dV+t453Stfxk7LiFiYeGYXWE6utY6f4R4T
98RJgqidc3TUEz3EywrzQKaZxj01Bo8GzCUYNVSdijIgVh+aCafLcnyAMTLlhXbWi2
99G0Ujg12zgLIT1SvCQGPA0A5M6mgkwJC030kQLfcmOkm1KTLEb+8WvJzGTSQScyU/
100W/8DY4IjiYGhriTJFdoPw19o3z9z6zDP0m58+3nTkVx49T2uV00/JxuTEtBbmYL3
101r3at6P4FVQM/mQijh90oTM2b36dNZUl+YGiU35ZlOnHTcLZ9smeiEnBezq41HgPY
102hKElUfXUHAPuJQd0QBtyzMHJ8V2N+Q+/jzCcxyGXRXEp6vp9NwAmNvxP099Yoo0R
1039va72BxiPpj/4nmLOOYquH01qOotR6H3li3T9H1+8Vt1ztP4VmBYsAcSruusIQG0
104YWom91yTb3rVbNuU6GF8og6YxvnHeawjHovLBkMEwY/WXodFEaHjFtYp0z9Cbwpj
105FK2YAAAAAA==
106-----END PKCS7-----
diff --git a/src/lib/libcrypto/pkcs7/t/msie-s-a-e b/src/lib/libcrypto/pkcs7/t/msie-s-a-e
new file mode 100644
index 0000000000..0067794d70
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/t/msie-s-a-e
@@ -0,0 +1,91 @@
1
2MIAGCSqGSIb3DQEHA6CAMIACAQAxggHCMIHMAgEAMHYwYjERMA8GA1UEBxMISW50ZXJuZXQxFzAV
3BgNVBAoTDlZlcmlTaWduLCBJbmMuMTQwMgYDVQQLEytWZXJpU2lnbiBDbGFzcyAxIENBIC0gSW5k
4aXZpZHVhbCBTdWJzY3JpYmVyAhBgQJiC3qfbCbjdj5INYLnKMA0GCSqGSIb3DQEBAQUABECjscaS
5G0U299fqiEAgTqTFQBp8Ai6zzjl557cVb3k6z4QZ7CbqBjSXAjLbh5e7S5Hd/FrFcDnxl1Ka06ha
6VHGPMIHwAgEAMIGZMIGSMQswCQYDVQQGEwJBVTETMBEGA1UECBMKUXVlZW5zbGFuZDERMA8GA1UE
7BxMIQnJpc2JhbmUxGjAYBgNVBAoTEUNyeXB0c29mdCBQdHkgTHRkMSIwIAYDVQQLExlERU1PTlNU
8UkFUSU9OIEFORCBURVNUSU5HMRswGQYDVQQDExJERU1PIFpFUk8gVkFMVUUgQ0ECAgRuMA0GCSqG
9SIb3DQEBAQUABECsyHXZ1xaiv0UQRvOmVYsaF38AL2XX75wxbCsz5/wOg7g3RP4aicZxaR4sBog0
10f2G1o9om/hu+A0rIYF/L4/GUMIAGCSqGSIb3DQEHATAaBggqhkiG9w0DAjAOAgIAoAQIsozQrnwj
11cc2ggASCBAAQz/LPoJe/+iYWeTwSebz6Q9UeKZzQ2UWm7GLtEM3s3c9SCvpmkwIRdEhLjWaBJMyI
12DiL7t1I1vMf9inB8LXgAcIEYkpNScjS8ERA9Ebb7ieNKSBg7w7B8ATHFxLSlDADqRgoZrB1Ctfgf
13ximp3EgxTgnhtyQhZxXW7kBQyFRwumplrJXOp7albP7IothrOKncw30IJT1fwPxWNMItI9juXF0U
14CbWVSjPzGBo4+XNXMvUO6MplOQEz/ywEQ9E8OZAQex1Zw9qq5ppsXB2pMsYV5sLJGikukMYKquiz
153YK+tN6J8ahLcDUs+VGwqvZi17gpBTlbEP+ZmXJpnO63t1yTEB0V5AZcRKWUOhzlCBM5YUagqNoY
16cpsmSvOK6bYzkUKOrzWpDCAtGZ/Dvul5dTZZmxs2WpM+iyeHXMxO3huy8K1brPTqt1f1sHhuq1jD
171eXedaCjIgUW9qV18vNAQCof/Yb6T/1fxztf/jD7pPLQJ+7LJkKCAEHGcaizpoKqhYcttaEhLq1G
18O+Ohqf7yFegMdTJ3wwP324w5ZYSU5fLo2Z34/Edf6EGvXyTIqVfAmEBALd6JGVdN5GlYYTxrL+eO
19P80Z4ao4YKoxwEmRp5bmQsQ8B29QhOFKmC6eiG5B96qLMtp7Zmu1grDNxTd6OXShWVwYARD0/B1P
20Sy0PAfk9Gb4fAkO9fZJDQYZ7s0mM5iOPEeSR7820TolOb+KfRabLA9d714jsc2jEykKlpP66Bh4j
21aCsyqJ0uUQcE8SnzrKAqGwgWiCGQpiTa+HBiP6eRlRGOKQj5Y06vcNx6Ija4cGe6+yCN8HV8tCY0
22okZK98NQCl5t79R/ZB2c3NvBJH+/g3ulU48ikT3tVmDxE3mOZofZyGFEM99P+YCMScLDxTl3hzGy
230YkI8U855P7qOAbcFfh2T5n+LSELwLhbkymEfZT917GWTfmypBWMvJx0WHeDhKwQYPdzbKgWETnc
24yeKasaCW+oLdhBwrd6Ws2r4MA8cwiYXDLbwYmCxJA8VF++8kubF2HJOjSyMBS+QT2PSV/0D9UWoi
25Vfk7R4OvWBJVvq7nV+lXS0O5igjExxlmx1OaBfg7+Cr/MbK4zVNrKSJn82NnKKt6LC6RaTmvFYay
260sDFxQ7Xo+Th6tDNKmKWJt6Kegfjc+qTWJTKb3kL+UI8vS0zTLy1+M/rZ4ekos/JiS5rYIcAswvg
2758kBgp/0rc6upBeWjBaK5O0aLAeBQfLulo1axWX04OSVKmYeoAltyR6UO9ME3acurQyg7Ta24yqO
28whi/PrIaEiO7dsWvFtzsshVzBLic02NlAkPkMUzliPYnZHWQglDAVxL5K2qhvK1OFCkQpIgBsBDM
296KYRL/mkBIIEALIl927rIkaN37/BQIcxLcSa05YfC0Hl3mxWESt1A0D4lA37A9S8EbYmDfAYlMc0
303HhZGdZEtawfpJFyDHzNZceNWBch6nxeNZCY4YFdsbzuGS0RKpwNA9S/czOJ4p9ymBCxuhGepI3U
31PKbC8C749Www1/wMdAot1n+K7M/PBGR8hWmaH5SS7U3yMwAB1fq2NDjx4ur+Um+MclSdN01MDXzG
32EO+eAo1pdAY8479234l8dB2YVAhZ1ZlJ4KmbqMKJrGJXnQUEYS6/cTDRjsUocsoW7uGg1ci2GiHa
33qjlkfpBfie3SdhFW/K8hwAH0HALs56oFN66wUkP/AaJAPfIUNhR6RpHKzZ9zCC42oB2mNawQRMnF
34ETBl1s/SwMxLKRp7jAfKs4NZxSY6I9z/2dTpzS3tsHMjxVDuxkolvRNWBILEMeL1CBvip2HhmoUw
35/Sz5NDgyzk1aQLV6DQNJ2RZLMZDRCtSwZSBu6lhhSgTJGazP0+NbqXXC5aQTrqrFIcWyDXz+ADle
36kszzYM/gSaQTCALTwfDDaU9Ek3xVgW+XBtExtJ3U+0AN3l0j86rUIdIvp6eWdxWQqv9LtpoorKMD
37KfUc5PYV09Z1JgsT4X51Zzq+74l5dz7udIM7UNbdTpmRm9PDj3TUbGCvNR9hqOEGTLbkvb1ZR24a
38h6uGRl2znB25IpDAGRhNRb9is/pO2tvHwHTDMOjrgvZG/pNvXgSUxz0pRjUjXIcqBe2X2gcQfeal
39r8gY76o83WEGL6ODryV9vTQVHt52+izgpYoBZaVlpgqbZl54c+OE0Zxf9RwXwDbcYu5Ku5E0MPL0
40qUjc0y2+Y6E4P5bAWaZGMGT+ORkyVUzcaWmM/+XlO7PER5wrWlCIMZCX1L/nvioY0q0CKqALn7DJ
41QU+qenbwrb6uwS7uNZY6V86s0aDYpU7yRyqxC5SbuyNJb02gdxUCgpIscFaMUjMVRml4M4BIjX/b
42U+HgHoVMUm8SnN9gRcT2izPrgOGVcMTJjfenzoCKoCPo9RjgGMctgB4DvKamErNU7OrilIfuoqzE
43PNSeP9SPw/zkDmNvMebM499We9CVnsHUWqF00/ZJWoua77+0f1bLS/tmci1JBvIcMo/4SJvgH+KF
44o0gijP9gqAPd5iCOnpnJlHUqRIym42SmyKEDuzdSwXKjAR6j7uXda39JyMJr8gGzEsu0jYRkAmj1
45YdiqwKXUcLMkcj1AKeU/PxTUVw0YKsv/rowrPYww3xQUWqNivrXB7GCHE3BzsYNdHsmziaGIXQbA
46+EBHdkuKrM8BcC+fxhF/l/KUxngsD1E75IcUv8zFDF+sk4CBYHqks9S4JYlcubuizqsILbdGzIMN
47Z7w34k0XT+sEggQAyzr8MHeIJGsT+AYnZr08PeTbyr01JEoT7lPYT6PzX4F63QKKDl+mB+PwLMzY
48CXrxZcUmuay6/MV8w/f5T6vQXdoSw5puWodBYwVReYh1IaEN+jiTapm9YBVmcIsJPO6abHowknSV
49OWSvST0AtAX57fFOTckm+facfBK9s9T1lUUgF44Bh5e8f9qKqfOV44nqdCOEyUm0Dao497ieN4Eg
50XBLNvOZY9+irMiXjp0lcyFvhrJOczfyCr9EiiaiH1TfSzKGKsf2W84iKn/JH6x2eOo7xjwJ40BQD
51c6S1cUNEuqBhP6by0FioOXYOKVyifpxk84Eb+F/4CNdTJTvCPwsiegdfsX/Q53DvKVtXp9Ycam5J
52TmKRHXK/bMHF4ONv3p/O/kn/BqRx+fbbP2eMX8Z1F/ltHKfp6B+06HljUwQLBJs9XtCfqH5Zgdz9
53gad5WZF5ykFArmHDgeFlgggvbZ7z9vqnjN/TH68TxJzauYQ5vLHQ6wGXik4/4uq7/TqNmhxlQEM4
54zVkwsn203bUmKLyz+yl1zItDpn5zy1uXfGo99rBdUzdbdE9LmEFPMaFsaHd4a8oDaUroD7FgCbeD
55JJVld3ac6F8+3QbExPs48OrgA1kI3/UwXr52ldjiYzTLfAGR9BjqNFTw45FUHuMf8TEM5hcHx56w
5695eKAqraDk28o9k+M2UKpcmrdlWoWzdqVVFeWGpM8x9Y9Nt0lf/4VUQgrXjqTkUCQkJyqTeTeGgH
57rn3QBk2XAgpxZhaJs3InW0BkAlBmK99cMinUiJeFt5a4p5wPeXrVuh6V9m7Mpl9hzpogg++EZqah
58fzzNnDgxOZfW342DX052PdgXo0NnkhCk005LvFt6M2mRn0fLgNVfyUZZoOp8cO5ZWbhXXlrhrgUt
59j2zKPK6Q94Zj4kdXHBGpAkrB8ZQ4EGGODE0Dqusm8WPXzB+9236IMHPU7lFbyjBrFNI7O4jg+qRI
60Ipi+7tX0FsilqEbmjG+OPwhZXrdqUqyF+rjKQuSRq7lOeDB4c6S2dq4OOny01i5HCbbyc9UvSHRm
61hOhGqUlzHyHLo3W7j+26V/MhkDXJ+Tx+qfylv4pbliwTteJJj+CZwzjv29qb6lxYi+38Bw10ERap
62m8UCRFBecVN7xXlcIfyeAl666Vi7EBJZv3EdFNrx1nlLwM65nYya7uj6L7IwJWotIUx8E0XH0/cU
63xS/dG8bxf9L/8652h5gq3LI+wTNGuEX0DMuz7BGQG+NtgabrZ6SsKGthGa7eULTpz0McWTLRU0y/
64/tkckpm5pDnXSFbIMskwwjECz82UZBSPpigdN/Pjg5d+0yWu7s3VJxw4ENWPPpzZ+j7sOXmdvn9P
65O1tQd60EO+3awASCBAAZQvWV3/yJ6FxPttbP+qeURpJoPEZfpN2UYZmd8HqtR0YbaOZ6Rln9nvpd
66K9fylXdw9z2xeCbjDWUttJB4VqZxGJM8eCTC1VDVyAOsQ5n7SY55dMkQbU+o4Z/4J5m8+wz50BBI
67LfruL1eZ6/CF6CdvxVRiJ10sXc0Tn2sVMXqkw7Adp1GYoCI9c6VFSFK74+n+y7LVFQ5HBnbQyKJc
68dvdLOXwZOPaFHC5UNXRmOpcwdPqyXUe+xIsOMYbzdlAnI9eGDNeRDktUa/Rh0CbZCxjmJzoZEYOE
69ZjsYZlEfp1Kb61t8z4m28hGLEg88T1Ihmxa2HeUWes1RpmgIOP+/2Lb3smj/l/fpSu4gabFgyCAV
70H5HdCYMScUv8SVu55+tpeO8ELoHHQUXV4rr084O4budzhgNSOPyLGDl5sfDUXiyusPCxS4JVO/KY
716V2Qrtg/q2wtmXpEkZnGT+Qi3WDzwt4W81alztnYMP17oGLmxX71KV9OEiMZjI4WaaGt+OOINLtR
72qefioZ1NI2L1s5M0tybwTsyU9WERM+3pUwXIfJVsbMZRlNaO2OogcHbaR4UWvhOj+3CTG1sThiYQ
73MxMnp1Rpqx3nhyzqLO3TRrkYvxnA3cdPBn9EeqpgBMg7X3hCiMV3Fl5cj/WOMhtHYgY7BgeCXo46
74EFVZ4+WroGZ46xGiRDiIblo8bzLd7QCxvukzxy3mUDgsZQ8pds4N28weSUhBk5MAPbfBpRvXUVJx
75MhKqXucQU1Md1qSGLbuuIQuz9pAGp1JFUx/vEkCgm74daSoVWCZuB+1ZE4f48clvrBj51xMNf8CP
76EFE7vySzVb6X2H1i5X3Z+Y3DdIcWw4Y2FClfcJk4Mwq8Cq2GALGFEge9YSEE9YmyuU6OFeU0ICon
77iXAgZ72SM8fBwJPruLFbdsNYKW+oAfmPisXSWMcZmdSbfk0GYv+vKtu3eegSbWw1UsCVtZOh9E5Z
78uQ83l59CBqO9sV/SFU3WrrJ0qNWxrmXu9nJn5Qf5iCRoFGYNHYHkIG5FS6N00GEDZxGkxmro2d++
79Adj5LVHc/b1cYWmrux+jEqI8ZK8cyTB0XMbBA/HYbx9NXazr7znP4/Mlv3pZToEcYt+lgLHAArtU
80AdhybhbLIwNMq0gr6EwtDklBa3ns4Wx/rJU8H7LGs6gV8uqeaSketv+nz+sQhfctxZ1rx+5qzXfy
81FOQVpO23KDQunBi1Bl9k61Di4q9JWcyADBXPHXJzp7mL8Fk7zdvMAEfuED1phdRm6GgDYoYUs4yQ
82IrhSjFlWyk7hT8475xk3BIv++obvWSAv/3+pF6A6U2RXDChVmnG0JnPa9wYYtdzBmLfZKBjX+DjD
83yEMsuhPsCzuN4R6tBIIBWCVRKmKwdkatmpsQBgDw48u0/Arffl5/DRlS9ee+QffFecUitDdCK+kt
84X5L2fGYrL5g6SltncMIeV1ptx4nuSjC/O944q1KYtqvQiPFWJqEXIRMNbbYOC47sjLza0tEFrimN
85wxcrWGSzsy5R9beFQ1aHPcMrDWfCoviNRk2qPtxuKIC5Qk2ZuOmJLjCiLwUGEb0/1Mpzv3MqQa7d
86mRayXg3DZWJPajxNZv6eS357ElMvwGQmqafb2mlQJwWLsg9m9PG7uqEoyrqSc6MiuY+icLEFib9j
87OfRQrx70rTSKUfTr4MtP0aZZAefjCrpVIyTekhFDOk0Nmx057eonlyGgmGpl5/Uo+t1J1Z11Ya/l
88bNbfmebRISJeTVW0I8FhseAZMI1GSwp/ludJxSLYOgyRkh+GX134MexNo7O9F1SxLCfWaSG9Fc3s
895ify04ua9/t8SGrYZPm/l3MkAAAAAAAAAAAAAA==
90
91
diff --git a/src/lib/libcrypto/pkcs7/t/msie-s-a-e.pem b/src/lib/libcrypto/pkcs7/t/msie-s-a-e.pem
new file mode 100644
index 0000000000..55dbd8f80b
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/t/msie-s-a-e.pem
@@ -0,0 +1,106 @@
1-----BEGIN PKCS7-----
2MIAGCSqGSIb3DQEHA6CAMIITUAIBADGCAcIwgcwCAQAwdjBiMREwDwYDVQQHEwhJ
3bnRlcm5ldDEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xNDAyBgNVBAsTK1ZlcmlT
4aWduIENsYXNzIDEgQ0EgLSBJbmRpdmlkdWFsIFN1YnNjcmliZXICEGBAmILep9sJ
5uN2Pkg1gucowDQYJKoZIhvcNAQEBBQAEQKOxxpIbRTb31+qIQCBOpMVAGnwCLrPO
6OXnntxVveTrPhBnsJuoGNJcCMtuHl7tLkd38WsVwOfGXUprTqFpUcY8wgfACAQAw
7gZkwgZIxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpRdWVlbnNsYW5kMREwDwYDVQQH
8EwhCcmlzYmFuZTEaMBgGA1UEChMRQ3J5cHRzb2Z0IFB0eSBMdGQxIjAgBgNVBAsT
9GURFTU9OU1RSQVRJT04gQU5EIFRFU1RJTkcxGzAZBgNVBAMTEkRFTU8gWkVSTyBW
10QUxVRSBDQQICBG4wDQYJKoZIhvcNAQEBBQAEQKzIddnXFqK/RRBG86ZVixoXfwAv
11ZdfvnDFsKzPn/A6DuDdE/hqJxnFpHiwGiDR/YbWj2ib+G74DSshgX8vj8ZQwghGD
12BgkqhkiG9w0BBwEwGgYIKoZIhvcNAwIwDgICAKAECLKM0K58I3HNgIIRWBDP8s+g
13l7/6JhZ5PBJ5vPpD1R4pnNDZRabsYu0Qzezdz1IK+maTAhF0SEuNZoEkzIgOIvu3
14UjW8x/2KcHwteABwgRiSk1JyNLwRED0RtvuJ40pIGDvDsHwBMcXEtKUMAOpGChms
15HUK1+B/GKancSDFOCeG3JCFnFdbuQFDIVHC6amWslc6ntqVs/sii2Gs4qdzDfQgl
16PV/A/FY0wi0j2O5cXRQJtZVKM/MYGjj5c1cy9Q7oymU5ATP/LARD0Tw5kBB7HVnD
172qrmmmxcHakyxhXmwskaKS6Qxgqq6LPdgr603onxqEtwNSz5UbCq9mLXuCkFOVsQ
18/5mZcmmc7re3XJMQHRXkBlxEpZQ6HOUIEzlhRqCo2hhymyZK84rptjORQo6vNakM
19IC0Zn8O+6Xl1NlmbGzZakz6LJ4dczE7eG7LwrVus9Oq3V/WweG6rWMPV5d51oKMi
20BRb2pXXy80BAKh/9hvpP/V/HO1/+MPuk8tAn7ssmQoIAQcZxqLOmgqqFhy21oSEu
21rUY746Gp/vIV6Ax1MnfDA/fbjDllhJTl8ujZnfj8R1/oQa9fJMipV8CYQEAt3okZ
22V03kaVhhPGsv544/zRnhqjhgqjHASZGnluZCxDwHb1CE4UqYLp6IbkH3qosy2ntm
23a7WCsM3FN3o5dKFZXBgBEPT8HU9LLQ8B+T0Zvh8CQ719kkNBhnuzSYzmI48R5JHv
24zbROiU5v4p9FpssD13vXiOxzaMTKQqWk/roGHiNoKzKonS5RBwTxKfOsoCobCBaI
25IZCmJNr4cGI/p5GVEY4pCPljTq9w3HoiNrhwZ7r7II3wdXy0JjSiRkr3w1AKXm3v
261H9kHZzc28Ekf7+De6VTjyKRPe1WYPETeY5mh9nIYUQz30/5gIxJwsPFOXeHMbLR
27iQjxTznk/uo4BtwV+HZPmf4tIQvAuFuTKYR9lP3XsZZN+bKkFYy8nHRYd4OErBBg
2893NsqBYROdzJ4pqxoJb6gt2EHCt3pazavgwDxzCJhcMtvBiYLEkDxUX77yS5sXYc
29k6NLIwFL5BPY9JX/QP1RaiJV+TtHg69YElW+rudX6VdLQ7mKCMTHGWbHU5oF+Dv4
30Kv8xsrjNU2spImfzY2coq3osLpFpOa8VhrLSwMXFDtej5OHq0M0qYpYm3op6B+Nz
316pNYlMpveQv5Qjy9LTNMvLX4z+tnh6Siz8mJLmtghwCzC+DnyQGCn/Stzq6kF5aM
32Fork7RosB4FB8u6WjVrFZfTg5JUqZh6gCW3JHpQ70wTdpy6tDKDtNrbjKo7CGL8+
33shoSI7t2xa8W3OyyFXMEuJzTY2UCQ+QxTOWI9idkdZCCUMBXEvkraqG8rU4UKRCk
34iAGwEMzophEv+aSyJfdu6yJGjd+/wUCHMS3EmtOWHwtB5d5sVhErdQNA+JQN+wPU
35vBG2Jg3wGJTHNNx4WRnWRLWsH6SRcgx8zWXHjVgXIep8XjWQmOGBXbG87hktESqc
36DQPUv3MzieKfcpgQsboRnqSN1DymwvAu+PVsMNf8DHQKLdZ/iuzPzwRkfIVpmh+U
37ku1N8jMAAdX6tjQ48eLq/lJvjHJUnTdNTA18xhDvngKNaXQGPOO/dt+JfHQdmFQI
38WdWZSeCpm6jCiaxiV50FBGEuv3Ew0Y7FKHLKFu7hoNXIthoh2qo5ZH6QX4nt0nYR
39VvyvIcAB9BwC7OeqBTeusFJD/wGiQD3yFDYUekaRys2fcwguNqAdpjWsEETJxREw
40ZdbP0sDMSykae4wHyrODWcUmOiPc/9nU6c0t7bBzI8VQ7sZKJb0TVgSCxDHi9Qgb
414qdh4ZqFMP0s+TQ4Ms5NWkC1eg0DSdkWSzGQ0QrUsGUgbupYYUoEyRmsz9PjW6l1
42wuWkE66qxSHFsg18/gA5XpLM82DP4EmkEwgC08Hww2lPRJN8VYFvlwbRMbSd1PtA
43Dd5dI/Oq1CHSL6enlncVkKr/S7aaKKyjAyn1HOT2FdPWdSYLE+F+dWc6vu+JeXc+
447nSDO1DW3U6ZkZvTw4901GxgrzUfYajhBky25L29WUduGoerhkZds5wduSKQwBkY
45TUW/YrP6Ttrbx8B0wzDo64L2Rv6Tb14ElMc9KUY1I1yHKgXtl9oHEH3mpa/IGO+q
46PN1hBi+jg68lfb00FR7edvos4KWKAWWlZaYKm2ZeeHPjhNGcX/UcF8A23GLuSruR
47NDDy9KlI3NMtvmOhOD+WwFmmRjBk/jkZMlVM3GlpjP/l5TuzxEecK1pQiDGQl9S/
48574qGNKtAiqgC5+wyUFPqnp28K2+rsEu7jWWOlfOrNGg2KVO8kcqsQuUm7sjSW9N
49oHcVAoKSLHBWjFIzFUZpeDOASI1/21Ph4B6FTFJvEpzfYEXE9osz64DhlXDEyY33
50p86AiqAj6PUY4BjHLYAeA7ymphKzVOzq4pSH7qKsxDzUnj/Uj8P85A5jbzHmzOPf
51VnvQlZ7B1FqhdNP2SVqLmu+/tH9Wy0v7ZnItSQbyHDKP+Eib4B/ihaNIIoz/YKgD
523eYgjp6ZyZR1KkSMpuNkpsihA7s3UsFyowEeo+7l3Wt/ScjCa/IBsxLLtI2EZAJo
539WHYqsCl1HCzJHI9QCnlPz8U1FcNGCrL/66MKz2MMN8UFFqjYr61wexghxNwc7GD
54XR7Js4mhiF0GwPhAR3ZLiqzPAXAvn8YRf5fylMZ4LA9RO+SHFL/MxQxfrJOAgWB6
55pLPUuCWJXLm7os6rCC23RsyDDWe8N+JNF0/ryzr8MHeIJGsT+AYnZr08PeTbyr01
56JEoT7lPYT6PzX4F63QKKDl+mB+PwLMzYCXrxZcUmuay6/MV8w/f5T6vQXdoSw5pu
57WodBYwVReYh1IaEN+jiTapm9YBVmcIsJPO6abHowknSVOWSvST0AtAX57fFOTckm
58+facfBK9s9T1lUUgF44Bh5e8f9qKqfOV44nqdCOEyUm0Dao497ieN4EgXBLNvOZY
599+irMiXjp0lcyFvhrJOczfyCr9EiiaiH1TfSzKGKsf2W84iKn/JH6x2eOo7xjwJ4
600BQDc6S1cUNEuqBhP6by0FioOXYOKVyifpxk84Eb+F/4CNdTJTvCPwsiegdfsX/Q
6153DvKVtXp9Ycam5JTmKRHXK/bMHF4ONv3p/O/kn/BqRx+fbbP2eMX8Z1F/ltHKfp
626B+06HljUwQLBJs9XtCfqH5Zgdz9gad5WZF5ykFArmHDgeFlgggvbZ7z9vqnjN/T
63H68TxJzauYQ5vLHQ6wGXik4/4uq7/TqNmhxlQEM4zVkwsn203bUmKLyz+yl1zItD
64pn5zy1uXfGo99rBdUzdbdE9LmEFPMaFsaHd4a8oDaUroD7FgCbeDJJVld3ac6F8+
653QbExPs48OrgA1kI3/UwXr52ldjiYzTLfAGR9BjqNFTw45FUHuMf8TEM5hcHx56w
6695eKAqraDk28o9k+M2UKpcmrdlWoWzdqVVFeWGpM8x9Y9Nt0lf/4VUQgrXjqTkUC
67QkJyqTeTeGgHrn3QBk2XAgpxZhaJs3InW0BkAlBmK99cMinUiJeFt5a4p5wPeXrV
68uh6V9m7Mpl9hzpogg++EZqahfzzNnDgxOZfW342DX052PdgXo0NnkhCk005LvFt6
69M2mRn0fLgNVfyUZZoOp8cO5ZWbhXXlrhrgUtj2zKPK6Q94Zj4kdXHBGpAkrB8ZQ4
70EGGODE0Dqusm8WPXzB+9236IMHPU7lFbyjBrFNI7O4jg+qRIIpi+7tX0FsilqEbm
71jG+OPwhZXrdqUqyF+rjKQuSRq7lOeDB4c6S2dq4OOny01i5HCbbyc9UvSHRmhOhG
72qUlzHyHLo3W7j+26V/MhkDXJ+Tx+qfylv4pbliwTteJJj+CZwzjv29qb6lxYi+38
73Bw10ERapm8UCRFBecVN7xXlcIfyeAl666Vi7EBJZv3EdFNrx1nlLwM65nYya7uj6
74L7IwJWotIUx8E0XH0/cUxS/dG8bxf9L/8652h5gq3LI+wTNGuEX0DMuz7BGQG+Nt
75gabrZ6SsKGthGa7eULTpz0McWTLRU0y//tkckpm5pDnXSFbIMskwwjECz82UZBSP
76pigdN/Pjg5d+0yWu7s3VJxw4ENWPPpzZ+j7sOXmdvn9PO1tQd60EO+3awBlC9ZXf
77/InoXE+21s/6p5RGkmg8Rl+k3ZRhmZ3weq1HRhto5npGWf2e+l0r1/KVd3D3PbF4
78JuMNZS20kHhWpnEYkzx4JMLVUNXIA6xDmftJjnl0yRBtT6jhn/gnmbz7DPnQEEgt
79+u4vV5nr8IXoJ2/FVGInXSxdzROfaxUxeqTDsB2nUZigIj1zpUVIUrvj6f7LstUV
80DkcGdtDIolx290s5fBk49oUcLlQ1dGY6lzB0+rJdR77Eiw4xhvN2UCcj14YM15EO
81S1Rr9GHQJtkLGOYnOhkRg4RmOxhmUR+nUpvrW3zPibbyEYsSDzxPUiGbFrYd5RZ6
82zVGmaAg4/7/YtveyaP+X9+lK7iBpsWDIIBUfkd0JgxJxS/xJW7nn62l47wQugcdB
83RdXiuvTzg7hu53OGA1I4/IsYOXmx8NReLK6w8LFLglU78pjpXZCu2D+rbC2ZekSR
84mcZP5CLdYPPC3hbzVqXO2dgw/XugYubFfvUpX04SIxmMjhZpoa3444g0u1Gp5+Kh
85nU0jYvWzkzS3JvBOzJT1YREz7elTBch8lWxsxlGU1o7Y6iBwdtpHhRa+E6P7cJMb
86WxOGJhAzEyenVGmrHeeHLOos7dNGuRi/GcDdx08Gf0R6qmAEyDtfeEKIxXcWXlyP
879Y4yG0diBjsGB4JejjoQVVnj5augZnjrEaJEOIhuWjxvMt3tALG+6TPHLeZQOCxl
88Dyl2zg3bzB5JSEGTkwA9t8GlG9dRUnEyEqpe5xBTUx3WpIYtu64hC7P2kAanUkVT
89H+8SQKCbvh1pKhVYJm4H7VkTh/jxyW+sGPnXEw1/wI8QUTu/JLNVvpfYfWLlfdn5
90jcN0hxbDhjYUKV9wmTgzCrwKrYYAsYUSB71hIQT1ibK5To4V5TQgKieJcCBnvZIz
91x8HAk+u4sVt2w1gpb6gB+Y+KxdJYxxmZ1Jt+TQZi/68q27d56BJtbDVSwJW1k6H0
92Tlm5DzeXn0IGo72xX9IVTdausnSo1bGuZe72cmflB/mIJGgUZg0dgeQgbkVLo3TQ
93YQNnEaTGaujZ374B2PktUdz9vVxhaau7H6MSojxkrxzJMHRcxsED8dhvH01drOvv
94Oc/j8yW/ellOgRxi36WAscACu1QB2HJuFssjA0yrSCvoTC0OSUFreezhbH+slTwf
95ssazqBXy6p5pKR62/6fP6xCF9y3FnWvH7mrNd/IU5BWk7bcoNC6cGLUGX2TrUOLi
96r0lZzIAMFc8dcnOnuYvwWTvN28wAR+4QPWmF1GboaANihhSzjJAiuFKMWVbKTuFP
97zjvnGTcEi/76hu9ZIC//f6kXoDpTZFcMKFWacbQmc9r3Bhi13MGYt9koGNf4OMPI
98Qyy6E+wLO43hHq0lUSpisHZGrZqbEAYA8OPLtPwK335efw0ZUvXnvkH3xXnFIrQ3
99QivpLV+S9nxmKy+YOkpbZ3DCHldabceJ7kowvzveOKtSmLar0IjxViahFyETDW22
100DguO7Iy82tLRBa4pjcMXK1hks7MuUfW3hUNWhz3DKw1nwqL4jUZNqj7cbiiAuUJN
101mbjpiS4woi8FBhG9P9TKc79zKkGu3ZkWsl4Nw2ViT2o8TWb+nkt+exJTL8BkJqmn
10229ppUCcFi7IPZvTxu7qhKMq6knOjIrmPonCxBYm/Yzn0UK8e9K00ilH06+DLT9Gm
103WQHn4wq6VSMk3pIRQzpNDZsdOe3qJ5choJhqZef1KPrdSdWddWGv5WzW35nm0SEi
104Xk1VtCPBYbHgGTCNRksKf5bnScUi2DoMkZIfhl9d+DHsTaOzvRdUsSwn1mkhvRXN
1057OYn8tOLmvf7fEhq2GT5v5dzJAAAAAA=
106-----END PKCS7-----
diff --git a/src/lib/libcrypto/pkcs7/t/nav-smime b/src/lib/libcrypto/pkcs7/t/nav-smime
new file mode 100644
index 0000000000..6ee4b597a1
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/t/nav-smime
@@ -0,0 +1,157 @@
1From angela@c2.net.au Thu May 14 13:32:27 1998
2X-UIDL: 83c94dd550e54329bf9571b72038b8c8
3Return-Path: angela@c2.net.au
4Received: from cryptsoft.com (play.cryptsoft.com [203.56.44.3]) by pandora.cryptsoft.com (8.8.3/8.7.3) with ESMTP id NAA27838 for <tjh@cryptsoft.com>; Thu, 14 May 1998 13:32:26 +1000 (EST)
5Message-ID: <355A6779.4B63E64C@cryptsoft.com>
6Date: Thu, 14 May 1998 13:39:37 +1000
7From: Angela van Lent <angela@c2.net.au>
8X-Mailer: Mozilla 4.03 [en] (Win95; U)
9MIME-Version: 1.0
10To: tjh@cryptsoft.com
11Subject: signed
12Content-Type: multipart/signed; protocol="application/x-pkcs7-signature"; micalg=sha1; boundary="------------ms9A58844C95949ECC78A1C54C"
13Content-Length: 2604
14Status: OR
15
16This is a cryptographically signed message in MIME format.
17
18--------------ms9A58844C95949ECC78A1C54C
19Content-Type: text/plain; charset=us-ascii
20Content-Transfer-Encoding: 7bit
21
22signed body
23
24--------------ms9A58844C95949ECC78A1C54C
25Content-Type: application/x-pkcs7-signature; name="smime.p7s"
26Content-Transfer-Encoding: base64
27Content-Disposition: attachment; filename="smime.p7s"
28Content-Description: S/MIME Cryptographic Signature
29
30MIIGHgYJKoZIhvcNAQcCoIIGDzCCBgsCAQExCzAJBgUrDgMCGgUAMAsGCSqGSIb3DQEHAaCC
31BGswggJTMIIB/aADAgECAgIEfjANBgkqhkiG9w0BAQQFADCBkjELMAkGA1UEBhMCQVUxEzAR
32BgNVBAgTClF1ZWVuc2xhbmQxETAPBgNVBAcTCEJyaXNiYW5lMRowGAYDVQQKExFDcnlwdHNv
33ZnQgUHR5IEx0ZDEiMCAGA1UECxMZREVNT05TVFJBVElPTiBBTkQgVEVTVElORzEbMBkGA1UE
34AxMSREVNTyBaRVJPIFZBTFVFIENBMB4XDTk4MDUxMzA2MjY1NloXDTAwMDUxMjA2MjY1Nlow
35gaUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpRdWVlbnNsYW5kMREwDwYDVQQHEwhCcmlzYmFu
36ZTEaMBgGA1UEChMRQ3J5cHRzb2Z0IFB0eSBMdGQxEjAQBgNVBAsTCVNNSU1FIDAwMzEZMBcG
37A1UEAxMQQW5nZWxhIHZhbiBMZWVudDEjMCEGCSqGSIb3DQEJARYUYW5nZWxhQGNyeXB0c29m
38dC5jb20wXDANBgkqhkiG9w0BAQEFAANLADBIAkEAuC3+7dAb2LhuO7gt2cTM8vsNjhG5JfDh
39hX1Vl/wVGbKEEj0MA6vWEolvefQlxB+EzwCtR0YZ7eEC/T/4JoCyeQIDAQABoygwJjAkBglg
40hkgBhvhCAQ0EFxYVR2VuZXJhdGVkIHdpdGggU1NMZWF5MA0GCSqGSIb3DQEBBAUAA0EAUnSP
41igs6TMFISTjw8cBtJYb98czgAVkVFjKyJQwYMH8FbDnCyx6NocM555nsyDstaw8fKR11Khds
42syd3ikkrhDCCAhAwggG6AgEDMA0GCSqGSIb3DQEBBAUAMIGSMQswCQYDVQQGEwJBVTETMBEG
43A1UECBMKUXVlZW5zbGFuZDERMA8GA1UEBxMIQnJpc2JhbmUxGjAYBgNVBAoTEUNyeXB0c29m
44dCBQdHkgTHRkMSIwIAYDVQQLExlERU1PTlNUUkFUSU9OIEFORCBURVNUSU5HMRswGQYDVQQD
45ExJERU1PIFpFUk8gVkFMVUUgQ0EwHhcNOTgwMzAzMDc0MTMyWhcNMDgwMjI5MDc0MTMyWjCB
46kjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClF1ZWVuc2xhbmQxETAPBgNVBAcTCEJyaXNiYW5l
47MRowGAYDVQQKExFDcnlwdHNvZnQgUHR5IEx0ZDEiMCAGA1UECxMZREVNT05TVFJBVElPTiBB
48TkQgVEVTVElORzEbMBkGA1UEAxMSREVNTyBaRVJPIFZBTFVFIENBMFwwDQYJKoZIhvcNAQEB
49BQADSwAwSAJBAL+0E2fLej3FSCwe2A2iRnMuC3z12qHIp6Ky1wo2zZcxft7AI+RfkrWrSGtf
50mfzBEuPrLdfulncC5Y1pNcM8RTUCAwEAATANBgkqhkiG9w0BAQQFAANBAGSbLMphL6F5pp3s
518o0Xyh86FHFdpVOwYx09ELLkuG17V/P9pgIc0Eo/gDMbN+KT3IdgECf8S//pCRA6RrNjcXIx
52ggF7MIIBdwIBATCBmTCBkjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClF1ZWVuc2xhbmQxETAP
53BgNVBAcTCEJyaXNiYW5lMRowGAYDVQQKExFDcnlwdHNvZnQgUHR5IEx0ZDEiMCAGA1UECxMZ
54REVNT05TVFJBVElPTiBBTkQgVEVTVElORzEbMBkGA1UEAxMSREVNTyBaRVJPIFZBTFVFIENB
55AgIEfjAJBgUrDgMCGgUAoHowGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAbBgkqhkiG9w0B
56CQ8xDjAMMAoGCCqGSIb3DQMHMBwGCSqGSIb3DQEJBTEPFw05ODA1MTQwMzM5MzdaMCMGCSqG
57SIb3DQEJBDEWBBQstNMnSV26ba8PapQEDhO21yNFrjANBgkqhkiG9w0BAQEFAARAW9Xb9YXv
58BfcNkutgFX9Gr8iXhBVsNtGEVrjrpkQwpKa7jHI8SjAlLhk/4RFwDHf+ISB9Np3Z1WDWnLcA
599CWR6g==
60--------------ms9A58844C95949ECC78A1C54C--
61
62
63From angela@c2.net.au Thu May 14 13:33:16 1998
64X-UIDL: 8f076c44ff7c5967fd5b00c4588a8731
65Return-Path: angela@c2.net.au
66Received: from cryptsoft.com (play.cryptsoft.com [203.56.44.3]) by pandora.cryptsoft.com (8.8.3/8.7.3) with ESMTP id NAA27847 for <tjh@cryptsoft.com>; Thu, 14 May 1998 13:33:15 +1000 (EST)
67Message-ID: <355A67AB.2AF38806@cryptsoft.com>
68Date: Thu, 14 May 1998 13:40:27 +1000
69From: Angela van Lent <angela@c2.net.au>
70X-Mailer: Mozilla 4.03 [en] (Win95; U)
71MIME-Version: 1.0
72To: tjh@cryptsoft.com
73Subject: signed
74Content-Type: multipart/signed; protocol="application/x-pkcs7-signature"; micalg=sha1; boundary="------------msD7863B84BD61E02C407F2F5E"
75Content-Length: 2679
76Status: OR
77
78This is a cryptographically signed message in MIME format.
79
80--------------msD7863B84BD61E02C407F2F5E
81Content-Type: text/plain; charset=us-ascii
82Content-Transfer-Encoding: 7bit
83
84signed body 2
85
86--------------msD7863B84BD61E02C407F2F5E
87Content-Type: application/x-pkcs7-signature; name="smime.p7s"
88Content-Transfer-Encoding: base64
89Content-Disposition: attachment; filename="smime.p7s"
90Content-Description: S/MIME Cryptographic Signature
91
92MIIGVgYJKoZIhvcNAQcCoIIGRzCCBkMCAQExCzAJBgUrDgMCGgUAMAsGCSqGSIb3DQEHAaCC
93BGswggJTMIIB/aADAgECAgIEfjANBgkqhkiG9w0BAQQFADCBkjELMAkGA1UEBhMCQVUxEzAR
94BgNVBAgTClF1ZWVuc2xhbmQxETAPBgNVBAcTCEJyaXNiYW5lMRowGAYDVQQKExFDcnlwdHNv
95ZnQgUHR5IEx0ZDEiMCAGA1UECxMZREVNT05TVFJBVElPTiBBTkQgVEVTVElORzEbMBkGA1UE
96AxMSREVNTyBaRVJPIFZBTFVFIENBMB4XDTk4MDUxMzA2MjY1NloXDTAwMDUxMjA2MjY1Nlow
97gaUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpRdWVlbnNsYW5kMREwDwYDVQQHEwhCcmlzYmFu
98ZTEaMBgGA1UEChMRQ3J5cHRzb2Z0IFB0eSBMdGQxEjAQBgNVBAsTCVNNSU1FIDAwMzEZMBcG
99A1UEAxMQQW5nZWxhIHZhbiBMZWVudDEjMCEGCSqGSIb3DQEJARYUYW5nZWxhQGNyeXB0c29m
100dC5jb20wXDANBgkqhkiG9w0BAQEFAANLADBIAkEAuC3+7dAb2LhuO7gt2cTM8vsNjhG5JfDh
101hX1Vl/wVGbKEEj0MA6vWEolvefQlxB+EzwCtR0YZ7eEC/T/4JoCyeQIDAQABoygwJjAkBglg
102hkgBhvhCAQ0EFxYVR2VuZXJhdGVkIHdpdGggU1NMZWF5MA0GCSqGSIb3DQEBBAUAA0EAUnSP
103igs6TMFISTjw8cBtJYb98czgAVkVFjKyJQwYMH8FbDnCyx6NocM555nsyDstaw8fKR11Khds
104syd3ikkrhDCCAhAwggG6AgEDMA0GCSqGSIb3DQEBBAUAMIGSMQswCQYDVQQGEwJBVTETMBEG
105A1UECBMKUXVlZW5zbGFuZDERMA8GA1UEBxMIQnJpc2JhbmUxGjAYBgNVBAoTEUNyeXB0c29m
106dCBQdHkgTHRkMSIwIAYDVQQLExlERU1PTlNUUkFUSU9OIEFORCBURVNUSU5HMRswGQYDVQQD
107ExJERU1PIFpFUk8gVkFMVUUgQ0EwHhcNOTgwMzAzMDc0MTMyWhcNMDgwMjI5MDc0MTMyWjCB
108kjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClF1ZWVuc2xhbmQxETAPBgNVBAcTCEJyaXNiYW5l
109MRowGAYDVQQKExFDcnlwdHNvZnQgUHR5IEx0ZDEiMCAGA1UECxMZREVNT05TVFJBVElPTiBB
110TkQgVEVTVElORzEbMBkGA1UEAxMSREVNTyBaRVJPIFZBTFVFIENBMFwwDQYJKoZIhvcNAQEB
111BQADSwAwSAJBAL+0E2fLej3FSCwe2A2iRnMuC3z12qHIp6Ky1wo2zZcxft7AI+RfkrWrSGtf
112mfzBEuPrLdfulncC5Y1pNcM8RTUCAwEAATANBgkqhkiG9w0BAQQFAANBAGSbLMphL6F5pp3s
1138o0Xyh86FHFdpVOwYx09ELLkuG17V/P9pgIc0Eo/gDMbN+KT3IdgECf8S//pCRA6RrNjcXIx
114ggGzMIIBrwIBATCBmTCBkjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClF1ZWVuc2xhbmQxETAP
115BgNVBAcTCEJyaXNiYW5lMRowGAYDVQQKExFDcnlwdHNvZnQgUHR5IEx0ZDEiMCAGA1UECxMZ
116REVNT05TVFJBVElPTiBBTkQgVEVTVElORzEbMBkGA1UEAxMSREVNTyBaRVJPIFZBTFVFIENB
117AgIEfjAJBgUrDgMCGgUAoIGxMBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwHAYJKoZIhvcN
118AQkFMQ8XDTk4MDUxNDAzNDAyN1owIwYJKoZIhvcNAQkEMRYEFOKcV8mNYJnM8rHQajcSEqJN
119rwdDMFIGCSqGSIb3DQEJDzFFMEMwCgYIKoZIhvcNAwcwDgYIKoZIhvcNAwICAgCAMAcGBSsO
120AwIHMA0GCCqGSIb3DQMCAgFAMA0GCCqGSIb3DQMCAgEoMA0GCSqGSIb3DQEBAQUABEADPE/N
121coH+zTFuX5YpolupTKxKK8eEjc48TuADuO8bIHHDE/fEYaWunlwDuTlcFJl1ig0idffPB1qC
122Zp8SSVVY
123--------------msD7863B84BD61E02C407F2F5E--
124
125
126From angela@c2.net.au Thu May 14 14:05:32 1998
127X-UIDL: a7d629b4b9acacaee8b39371b860a32a
128Return-Path: angela@c2.net.au
129Received: from cryptsoft.com (play.cryptsoft.com [203.56.44.3]) by pandora.cryptsoft.com (8.8.3/8.7.3) with ESMTP id OAA28033 for <tjh@cryptsoft.com>; Thu, 14 May 1998 14:05:32 +1000 (EST)
130Message-ID: <355A6F3B.AC385981@cryptsoft.com>
131Date: Thu, 14 May 1998 14:12:43 +1000
132From: Angela van Lent <angela@c2.net.au>
133X-Mailer: Mozilla 4.03 [en] (Win95; U)
134MIME-Version: 1.0
135To: tjh@cryptsoft.com
136Subject: encrypted
137Content-Type: application/x-pkcs7-mime; name="smime.p7m"
138Content-Transfer-Encoding: base64
139Content-Disposition: attachment; filename="smime.p7m"
140Content-Description: S/MIME Encrypted Message
141Content-Length: 905
142Status: OR
143
144MIAGCSqGSIb3DQEHA6CAMIACAQAxggHmMIHwAgEAMIGZMIGSMQswCQYDVQQGEwJBVTETMBEG
145A1UECBMKUXVlZW5zbGFuZDERMA8GA1UEBxMIQnJpc2JhbmUxGjAYBgNVBAoTEUNyeXB0c29m
146dCBQdHkgTHRkMSIwIAYDVQQLExlERU1PTlNUUkFUSU9OIEFORCBURVNUSU5HMRswGQYDVQQD
147ExJERU1PIFpFUk8gVkFMVUUgQ0ECAgR+MA0GCSqGSIb3DQEBAQUABEA92N29Yk39RUY2tIVd
148exGT2MFX3J6H8LB8aDRJjw7843ALgJ5zXpM5+f80QkAWwEN2A6Pl3VxiCeKLi435zXVyMIHw
149AgEAMIGZMIGSMQswCQYDVQQGEwJBVTETMBEGA1UECBMKUXVlZW5zbGFuZDERMA8GA1UEBxMI
150QnJpc2JhbmUxGjAYBgNVBAoTEUNyeXB0c29mdCBQdHkgTHRkMSIwIAYDVQQLExlERU1PTlNU
151UkFUSU9OIEFORCBURVNUSU5HMRswGQYDVQQDExJERU1PIFpFUk8gVkFMVUUgQ0ECAgRuMA0G
152CSqGSIb3DQEBAQUABECR9IfyHtvnjFmZ8B2oUCEs1vxMsG0u1kxKE4RMPFyDqDCEARq7zXMg
153nzSUI7Wgv5USSKDqcLRJeW+jvYURv/nJMIAGCSqGSIb3DQEHATAaBggqhkiG9w0DAjAOAgIA
154oAQIrLqrij2ZMpeggAQoibtn6reRZWuWk5Iv5IAhgitr8EYE4w4ySQ7EMB6mTlBoFpccUMWX
155BwQgQn1UoWCvYAlhDzURdbui64Dc0rS2wtj+kE/InS6y25EEEPe4NUKaF8/UlE+lo3LtILQE
156CL3uV8k7m0iqAAAAAAAAAAAAAA==
157
diff --git a/src/lib/libcrypto/pkcs7/t/s.pem b/src/lib/libcrypto/pkcs7/t/s.pem
new file mode 100644
index 0000000000..4fa925b182
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/t/s.pem
@@ -0,0 +1,57 @@
1-----BEGIN RSA PRIVATE KEY-----
2MIIBOgIBAAJBAK3nI4nuDYe3nDJES5WBc90igEstxWC4/h4YY+/ciYki35U8ets9
3mgaoCNYp/e9BCZHtvK2Y+fYokGJv5+cMTQsCAwEAAQJBAIHpvXvqEcOEoDRRHuIG
4fkcB4jPHcr9KE9TpxabH6xs9beN6OJnkePXAHwaz5MnUgSnbpOKq+cw8miKjXwe/
5zVECIQDVLwncT2lRmXarEYHzb+q/0uaSvKhWKKt3kJasLNTrAwIhANDUc/ghut29
6p3jJYjurzUKuG774/5eLjPLsxPPIZzNZAiA/10hSq41UnGqHLEUIS9m2/EeEZe7b
7bm567dfRU9OnVQIgDo8ROrZXSchEGbaog5J5r/Fle83uO8l93R3GqVxKXZkCIFfk
8IPD5PIYQAyyod3hyKKza7ZP4CGY4oOfZetbkSGGG
9-----END RSA PRIVATE KEY-----
10issuer :/C=AU/SP=Queensland/L=Brisbane/O=Cryptsoft Pty Ltd/OU=DEMONSTRATION AND TESTING/CN=DEMO ZERO VALUE CA
11subject:/C=AU/SP=Queensland/L=Brisbane/O=Cryptsoft Pty Ltd/OU=SMIME 003/CN=Information/Email=info@cryptsoft.com
12serial :047D
13
14Certificate:
15 Data:
16 Version: 3 (0x2)
17 Serial Number: 1149 (0x47d)
18 Signature Algorithm: md5withRSAEncryption
19 Issuer: C=AU, SP=Queensland, L=Brisbane, O=Cryptsoft Pty Ltd, OU=DEMONSTRATION AND TESTING, CN=DEMO ZERO VALUE CA
20 Validity
21 Not Before: May 13 05:40:58 1998 GMT
22 Not After : May 12 05:40:58 2000 GMT
23 Subject: C=AU, SP=Queensland, L=Brisbane, O=Cryptsoft Pty Ltd, OU=SMIME 003, CN=Information/Email=info@cryptsoft.com
24 Subject Public Key Info:
25 Public Key Algorithm: rsaEncryption
26 Modulus:
27 00:ad:e7:23:89:ee:0d:87:b7:9c:32:44:4b:95:81:
28 73:dd:22:80:4b:2d:c5:60:b8:fe:1e:18:63:ef:dc:
29 89:89:22:df:95:3c:7a:db:3d:9a:06:a8:08:d6:29:
30 fd:ef:41:09:91:ed:bc:ad:98:f9:f6:28:90:62:6f:
31 e7:e7:0c:4d:0b
32 Exponent: 65537 (0x10001)
33 X509v3 extensions:
34 Netscape Comment:
35 Generated with SSLeay
36 Signature Algorithm: md5withRSAEncryption
37 52:15:ea:88:f4:f0:f9:0b:ef:ce:d5:f8:83:40:61:16:5e:55:
38 f9:ce:2d:d1:8b:31:5c:03:c6:2d:10:7c:61:d5:5c:0a:42:97:
39 d1:fd:65:b6:b6:84:a5:39:ec:46:ec:fc:e0:0d:d9:22:da:1b:
40 50:74:ad:92:cb:4e:90:e5:fa:7d
41
42-----BEGIN CERTIFICATE-----
43MIICTDCCAfagAwIBAgICBH0wDQYJKoZIhvcNAQEEBQAwgZIxCzAJBgNVBAYTAkFV
44MRMwEQYDVQQIEwpRdWVlbnNsYW5kMREwDwYDVQQHEwhCcmlzYmFuZTEaMBgGA1UE
45ChMRQ3J5cHRzb2Z0IFB0eSBMdGQxIjAgBgNVBAsTGURFTU9OU1RSQVRJT04gQU5E
46IFRFU1RJTkcxGzAZBgNVBAMTEkRFTU8gWkVSTyBWQUxVRSBDQTAeFw05ODA1MTMw
47NTQwNThaFw0wMDA1MTIwNTQwNThaMIGeMQswCQYDVQQGEwJBVTETMBEGA1UECBMK
48UXVlZW5zbGFuZDERMA8GA1UEBxMIQnJpc2JhbmUxGjAYBgNVBAoTEUNyeXB0c29m
49dCBQdHkgTHRkMRIwEAYDVQQLEwlTTUlNRSAwMDMxFDASBgNVBAMTC0luZm9ybWF0
50aW9uMSEwHwYJKoZIhvcNAQkBFhJpbmZvQGNyeXB0c29mdC5jb20wXDANBgkqhkiG
519w0BAQEFAANLADBIAkEArecjie4Nh7ecMkRLlYFz3SKASy3FYLj+Hhhj79yJiSLf
52lTx62z2aBqgI1in970EJke28rZj59iiQYm/n5wxNCwIDAQABoygwJjAkBglghkgB
53hvhCAQ0EFxYVR2VuZXJhdGVkIHdpdGggU1NMZWF5MA0GCSqGSIb3DQEBBAUAA0EA
54UhXqiPTw+QvvztX4g0BhFl5V+c4t0YsxXAPGLRB8YdVcCkKX0f1ltraEpTnsRuz8
554A3ZItobUHStkstOkOX6fQ==
56-----END CERTIFICATE-----
57
diff --git a/src/lib/libcrypto/pkcs7/t/server.pem b/src/lib/libcrypto/pkcs7/t/server.pem
new file mode 100644
index 0000000000..989baf8709
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/t/server.pem
@@ -0,0 +1,57 @@
1issuer :/C=AU/SP=Queensland/L=Brisbane/O=Cryptsoft Pty Ltd/OU=DEMONSTRATION AND TESTING/CN=DEMO ZERO VALUE CA
2subject:/C=AU/SP=Queensland/L=Brisbane/O=Cryptsoft Pty Ltd/OU=SMIME 003/CN=Information/Email=info@cryptsoft.com
3serial :047D
4
5Certificate:
6 Data:
7 Version: 3 (0x2)
8 Serial Number: 1149 (0x47d)
9 Signature Algorithm: md5withRSAEncryption
10 Issuer: C=AU, SP=Queensland, L=Brisbane, O=Cryptsoft Pty Ltd, OU=DEMONSTRATION AND TESTING, CN=DEMO ZERO VALUE CA
11 Validity
12 Not Before: May 13 05:40:58 1998 GMT
13 Not After : May 12 05:40:58 2000 GMT
14 Subject: C=AU, SP=Queensland, L=Brisbane, O=Cryptsoft Pty Ltd, OU=SMIME 003, CN=Information/Email=info@cryptsoft.com
15 Subject Public Key Info:
16 Public Key Algorithm: rsaEncryption
17 Modulus:
18 00:ad:e7:23:89:ee:0d:87:b7:9c:32:44:4b:95:81:
19 73:dd:22:80:4b:2d:c5:60:b8:fe:1e:18:63:ef:dc:
20 89:89:22:df:95:3c:7a:db:3d:9a:06:a8:08:d6:29:
21 fd:ef:41:09:91:ed:bc:ad:98:f9:f6:28:90:62:6f:
22 e7:e7:0c:4d:0b
23 Exponent: 65537 (0x10001)
24 X509v3 extensions:
25 Netscape Comment:
26 Generated with SSLeay
27 Signature Algorithm: md5withRSAEncryption
28 52:15:ea:88:f4:f0:f9:0b:ef:ce:d5:f8:83:40:61:16:5e:55:
29 f9:ce:2d:d1:8b:31:5c:03:c6:2d:10:7c:61:d5:5c:0a:42:97:
30 d1:fd:65:b6:b6:84:a5:39:ec:46:ec:fc:e0:0d:d9:22:da:1b:
31 50:74:ad:92:cb:4e:90:e5:fa:7d
32
33-----BEGIN CERTIFICATE-----
34MIICTDCCAfagAwIBAgICBH0wDQYJKoZIhvcNAQEEBQAwgZIxCzAJBgNVBAYTAkFV
35MRMwEQYDVQQIEwpRdWVlbnNsYW5kMREwDwYDVQQHEwhCcmlzYmFuZTEaMBgGA1UE
36ChMRQ3J5cHRzb2Z0IFB0eSBMdGQxIjAgBgNVBAsTGURFTU9OU1RSQVRJT04gQU5E
37IFRFU1RJTkcxGzAZBgNVBAMTEkRFTU8gWkVSTyBWQUxVRSBDQTAeFw05ODA1MTMw
38NTQwNThaFw0wMDA1MTIwNTQwNThaMIGeMQswCQYDVQQGEwJBVTETMBEGA1UECBMK
39UXVlZW5zbGFuZDERMA8GA1UEBxMIQnJpc2JhbmUxGjAYBgNVBAoTEUNyeXB0c29m
40dCBQdHkgTHRkMRIwEAYDVQQLEwlTTUlNRSAwMDMxFDASBgNVBAMTC0luZm9ybWF0
41aW9uMSEwHwYJKoZIhvcNAQkBFhJpbmZvQGNyeXB0c29mdC5jb20wXDANBgkqhkiG
429w0BAQEFAANLADBIAkEArecjie4Nh7ecMkRLlYFz3SKASy3FYLj+Hhhj79yJiSLf
43lTx62z2aBqgI1in970EJke28rZj59iiQYm/n5wxNCwIDAQABoygwJjAkBglghkgB
44hvhCAQ0EFxYVR2VuZXJhdGVkIHdpdGggU1NMZWF5MA0GCSqGSIb3DQEBBAUAA0EA
45UhXqiPTw+QvvztX4g0BhFl5V+c4t0YsxXAPGLRB8YdVcCkKX0f1ltraEpTnsRuz8
464A3ZItobUHStkstOkOX6fQ==
47-----END CERTIFICATE-----
48
49-----BEGIN RSA PRIVATE KEY-----
50MIIBOgIBAAJBAK3nI4nuDYe3nDJES5WBc90igEstxWC4/h4YY+/ciYki35U8ets9
51mgaoCNYp/e9BCZHtvK2Y+fYokGJv5+cMTQsCAwEAAQJBAIHpvXvqEcOEoDRRHuIG
52fkcB4jPHcr9KE9TpxabH6xs9beN6OJnkePXAHwaz5MnUgSnbpOKq+cw8miKjXwe/
53zVECIQDVLwncT2lRmXarEYHzb+q/0uaSvKhWKKt3kJasLNTrAwIhANDUc/ghut29
54p3jJYjurzUKuG774/5eLjPLsxPPIZzNZAiA/10hSq41UnGqHLEUIS9m2/EeEZe7b
55bm567dfRU9OnVQIgDo8ROrZXSchEGbaog5J5r/Fle83uO8l93R3GqVxKXZkCIFfk
56IPD5PIYQAyyod3hyKKza7ZP4CGY4oOfZetbkSGGG
57-----END RSA PRIVATE KEY-----
diff --git a/src/lib/libcrypto/pkcs7/verify.c b/src/lib/libcrypto/pkcs7/verify.c
new file mode 100644
index 0000000000..b40f26032e
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/verify.c
@@ -0,0 +1,263 @@
1/* crypto/pkcs7/verify.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 <string.h>
60#include <openssl/bio.h>
61#include <openssl/asn1.h>
62#include <openssl/x509.h>
63#include <openssl/pem.h>
64#include <openssl/err.h>
65#include "example.h"
66
67int verify_callback(int ok, X509_STORE_CTX *ctx);
68
69BIO *bio_err=NULL;
70BIO *bio_out=NULL;
71
72int main(argc,argv)
73int argc;
74char *argv[];
75 {
76 PKCS7 *p7;
77 PKCS7_SIGNER_INFO *si;
78 X509_STORE_CTX cert_ctx;
79 X509_STORE *cert_store=NULL;
80 BIO *data,*detached=NULL,*p7bio=NULL;
81 char buf[1024*4];
82 char *pp;
83 int i,printit=0;
84 STACK_OF(PKCS7_SIGNER_INFO) *sk;
85
86 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
87 bio_out=BIO_new_fp(stdout,BIO_NOCLOSE);
88#ifndef OPENSSL_NO_MD2
89 EVP_add_digest(EVP_md2());
90#endif
91#ifndef OPENSSL_NO_MD5
92 EVP_add_digest(EVP_md5());
93#endif
94#ifndef OPENSSL_NO_SHA1
95 EVP_add_digest(EVP_sha1());
96#endif
97#ifndef OPENSSL_NO_MDC2
98 EVP_add_digest(EVP_mdc2());
99#endif
100
101 data=BIO_new(BIO_s_file());
102
103 pp=NULL;
104 while (argc > 1)
105 {
106 argc--;
107 argv++;
108 if (strcmp(argv[0],"-p") == 0)
109 {
110 printit=1;
111 }
112 else if ((strcmp(argv[0],"-d") == 0) && (argc >= 2))
113 {
114 detached=BIO_new(BIO_s_file());
115 if (!BIO_read_filename(detached,argv[1]))
116 goto err;
117 argc--;
118 argv++;
119 }
120 else
121 {
122 pp=argv[0];
123 if (!BIO_read_filename(data,argv[0]))
124 goto err;
125 }
126 }
127
128 if (pp == NULL)
129 BIO_set_fp(data,stdin,BIO_NOCLOSE);
130
131
132 /* Load the PKCS7 object from a file */
133 if ((p7=PEM_read_bio_PKCS7(data,NULL,NULL,NULL)) == NULL) goto err;
134
135 /* This stuff is being setup for certificate verification.
136 * When using SSL, it could be replaced with a
137 * cert_stre=SSL_CTX_get_cert_store(ssl_ctx); */
138 cert_store=X509_STORE_new();
139 X509_STORE_set_default_paths(cert_store);
140 X509_STORE_load_locations(cert_store,NULL,"../../certs");
141 X509_STORE_set_verify_cb_func(cert_store,verify_callback);
142
143 ERR_clear_error();
144
145 /* We need to process the data */
146 if ((PKCS7_get_detached(p7) || detached))
147 {
148 if (detached == NULL)
149 {
150 printf("no data to verify the signature on\n");
151 exit(1);
152 }
153 else
154 p7bio=PKCS7_dataInit(p7,detached);
155 }
156 else
157 {
158 p7bio=PKCS7_dataInit(p7,NULL);
159 }
160
161 /* We now have to 'read' from p7bio to calculate digests etc. */
162 for (;;)
163 {
164 i=BIO_read(p7bio,buf,sizeof(buf));
165 /* print it? */
166 if (i <= 0) break;
167 }
168
169 /* We can now verify signatures */
170 sk=PKCS7_get_signer_info(p7);
171 if (sk == NULL)
172 {
173 printf("there are no signatures on this data\n");
174 exit(1);
175 }
176
177 /* Ok, first we need to, for each subject entry, see if we can verify */
178 for (i=0; i<sk_PKCS7_SIGNER_INFO_num(sk); i++)
179 {
180 ASN1_UTCTIME *tm;
181 char *str1,*str2;
182 int rc;
183
184 si=sk_PKCS7_SIGNER_INFO_value(sk,i);
185 rc=PKCS7_dataVerify(cert_store,&cert_ctx,p7bio,p7,si);
186 if (rc <= 0)
187 goto err;
188 printf("signer info\n");
189 if ((tm=get_signed_time(si)) != NULL)
190 {
191 BIO_printf(bio_out,"Signed time:");
192 ASN1_UTCTIME_print(bio_out,tm);
193 ASN1_UTCTIME_free(tm);
194 BIO_printf(bio_out,"\n");
195 }
196 if (get_signed_seq2string(si,&str1,&str2))
197 {
198 BIO_printf(bio_out,"String 1 is %s\n",str1);
199 BIO_printf(bio_out,"String 2 is %s\n",str2);
200 }
201
202 }
203
204 X509_STORE_free(cert_store);
205
206 printf("done\n");
207 exit(0);
208err:
209 ERR_load_crypto_strings();
210 ERR_print_errors_fp(stderr);
211 exit(1);
212 }
213
214/* should be X509 * but we can just have them as char *. */
215int verify_callback(int ok, X509_STORE_CTX *ctx)
216 {
217 char buf[256];
218 X509 *err_cert;
219 int err,depth;
220
221 err_cert=X509_STORE_CTX_get_current_cert(ctx);
222 err= X509_STORE_CTX_get_error(ctx);
223 depth= X509_STORE_CTX_get_error_depth(ctx);
224
225 X509_NAME_oneline(X509_get_subject_name(err_cert),buf,256);
226 BIO_printf(bio_err,"depth=%d %s\n",depth,buf);
227 if (!ok)
228 {
229 BIO_printf(bio_err,"verify error:num=%d:%s\n",err,
230 X509_verify_cert_error_string(err));
231 if (depth < 6)
232 {
233 ok=1;
234 X509_STORE_CTX_set_error(ctx,X509_V_OK);
235 }
236 else
237 {
238 ok=0;
239 X509_STORE_CTX_set_error(ctx,X509_V_ERR_CERT_CHAIN_TOO_LONG);
240 }
241 }
242 switch (ctx->error)
243 {
244 case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT:
245 X509_NAME_oneline(X509_get_issuer_name(ctx->current_cert),buf,256);
246 BIO_printf(bio_err,"issuer= %s\n",buf);
247 break;
248 case X509_V_ERR_CERT_NOT_YET_VALID:
249 case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD:
250 BIO_printf(bio_err,"notBefore=");
251 ASN1_UTCTIME_print(bio_err,X509_get_notBefore(ctx->current_cert));
252 BIO_printf(bio_err,"\n");
253 break;
254 case X509_V_ERR_CERT_HAS_EXPIRED:
255 case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD:
256 BIO_printf(bio_err,"notAfter=");
257 ASN1_UTCTIME_print(bio_err,X509_get_notAfter(ctx->current_cert));
258 BIO_printf(bio_err,"\n");
259 break;
260 }
261 BIO_printf(bio_err,"verify return:%d\n",ok);
262 return(ok);
263 }
diff --git a/src/lib/libcrypto/rand/Makefile.ssl b/src/lib/libcrypto/rand/Makefile.ssl
new file mode 100644
index 0000000000..73b5f568e8
--- /dev/null
+++ b/src/lib/libcrypto/rand/Makefile.ssl
@@ -0,0 +1,194 @@
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/e_os2.h ../../include/openssl/opensslconf.h
105rand_egd.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
106rand_egd.o: rand_egd.c
107rand_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
108rand_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
109rand_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
110rand_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
111rand_err.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
112rand_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
113rand_err.o: rand_err.c
114rand_lib.o: ../../e_os.h ../../include/openssl/asn1.h
115rand_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
116rand_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
117rand_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
118rand_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
119rand_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
120rand_lib.o: ../../include/openssl/opensslconf.h
121rand_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
122rand_lib.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
123rand_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
124rand_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
125rand_lib.o: ../cryptlib.h rand_lib.c
126rand_os2.o: ../../e_os.h ../../include/openssl/aes.h
127rand_os2.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
128rand_os2.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
129rand_os2.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
130rand_os2.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
131rand_os2.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
132rand_os2.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
133rand_os2.o: ../../include/openssl/err.h ../../include/openssl/evp.h
134rand_os2.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
135rand_os2.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
136rand_os2.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
137rand_os2.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
138rand_os2.o: ../../include/openssl/opensslconf.h
139rand_os2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
140rand_os2.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
141rand_os2.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
142rand_os2.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
143rand_os2.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
144rand_os2.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
145rand_os2.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
146rand_os2.o: ../cryptlib.h rand_lcl.h rand_os2.c
147rand_unix.o: ../../e_os.h ../../include/openssl/aes.h
148rand_unix.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
149rand_unix.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
150rand_unix.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
151rand_unix.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
152rand_unix.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
153rand_unix.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
154rand_unix.o: ../../include/openssl/err.h ../../include/openssl/evp.h
155rand_unix.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
156rand_unix.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
157rand_unix.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
158rand_unix.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
159rand_unix.o: ../../include/openssl/opensslconf.h
160rand_unix.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
161rand_unix.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
162rand_unix.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
163rand_unix.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
164rand_unix.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
165rand_unix.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
166rand_unix.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
167rand_unix.o: ../cryptlib.h rand_lcl.h rand_unix.c
168rand_win.o: ../../e_os.h ../../include/openssl/aes.h
169rand_win.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
170rand_win.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
171rand_win.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
172rand_win.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
173rand_win.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
174rand_win.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
175rand_win.o: ../../include/openssl/err.h ../../include/openssl/evp.h
176rand_win.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
177rand_win.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
178rand_win.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
179rand_win.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
180rand_win.o: ../../include/openssl/opensslconf.h
181rand_win.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
182rand_win.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
183rand_win.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
184rand_win.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
185rand_win.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
186rand_win.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
187rand_win.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
188rand_win.o: ../cryptlib.h rand_lcl.h rand_win.c
189randfile.o: ../../e_os.h ../../include/openssl/crypto.h
190randfile.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
191randfile.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
192randfile.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
193randfile.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
194randfile.o: randfile.c
diff --git a/src/lib/libcrypto/rand/md_rand.c b/src/lib/libcrypto/rand/md_rand.c
new file mode 100644
index 0000000000..a00ed70718
--- /dev/null
+++ b/src/lib/libcrypto/rand/md_rand.c
@@ -0,0 +1,572 @@
1/* crypto/rand/md_rand.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#ifdef MD_RAND_DEBUG
113# ifndef NDEBUG
114# define NDEBUG
115# endif
116#endif
117
118#include <assert.h>
119#include <stdio.h>
120#include <string.h>
121
122#include "e_os.h"
123
124#include <openssl/rand.h>
125#include "rand_lcl.h"
126
127#include <openssl/crypto.h>
128#include <openssl/err.h>
129
130#ifdef BN_DEBUG
131# define PREDICT
132#endif
133
134/* #define PREDICT 1 */
135
136#define STATE_SIZE 1023
137static int state_num=0,state_index=0;
138static unsigned char state[STATE_SIZE+MD_DIGEST_LENGTH];
139static unsigned char md[MD_DIGEST_LENGTH];
140static long md_count[2]={0,0};
141static double entropy=0;
142static int initialized=0;
143
144static unsigned int crypto_lock_rand = 0; /* may be set only when a thread
145 * holds CRYPTO_LOCK_RAND
146 * (to prevent double locking) */
147/* access to lockin_thread is synchronized by CRYPTO_LOCK_RAND2 */
148static unsigned long locking_thread = 0; /* valid iff crypto_lock_rand is set */
149
150
151#ifdef PREDICT
152int rand_predictable=0;
153#endif
154
155const char *RAND_version="RAND" OPENSSL_VERSION_PTEXT;
156
157static void ssleay_rand_cleanup(void);
158static void ssleay_rand_seed(const void *buf, int num);
159static void ssleay_rand_add(const void *buf, int num, double add_entropy);
160static int ssleay_rand_bytes(unsigned char *buf, int num);
161static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num);
162static int ssleay_rand_status(void);
163
164RAND_METHOD rand_ssleay_meth={
165 ssleay_rand_seed,
166 ssleay_rand_bytes,
167 ssleay_rand_cleanup,
168 ssleay_rand_add,
169 ssleay_rand_pseudo_bytes,
170 ssleay_rand_status
171 };
172
173RAND_METHOD *RAND_SSLeay(void)
174 {
175 return(&rand_ssleay_meth);
176 }
177
178static void ssleay_rand_cleanup(void)
179 {
180 memset(state,0,sizeof(state));
181 state_num=0;
182 state_index=0;
183 memset(md,0,MD_DIGEST_LENGTH);
184 md_count[0]=0;
185 md_count[1]=0;
186 entropy=0;
187 initialized=0;
188 }
189
190static void ssleay_rand_add(const void *buf, int num, double add)
191 {
192 int i,j,k,st_idx;
193 long md_c[2];
194 unsigned char local_md[MD_DIGEST_LENGTH];
195 EVP_MD_CTX m;
196 int do_not_lock;
197
198 /*
199 * (Based on the rand(3) manpage)
200 *
201 * The input is chopped up into units of 20 bytes (or less for
202 * the last block). Each of these blocks is run through the hash
203 * function as follows: The data passed to the hash function
204 * is the current 'md', the same number of bytes from the 'state'
205 * (the location determined by in incremented looping index) as
206 * the current 'block', the new key data 'block', and 'count'
207 * (which is incremented after each use).
208 * The result of this is kept in 'md' and also xored into the
209 * 'state' at the same locations that were used as input into the
210 * hash function.
211 */
212
213 /* check if we already have the lock */
214 if (crypto_lock_rand)
215 {
216 CRYPTO_r_lock(CRYPTO_LOCK_RAND2);
217 do_not_lock = (locking_thread == CRYPTO_thread_id());
218 CRYPTO_r_unlock(CRYPTO_LOCK_RAND2);
219 }
220 else
221 do_not_lock = 0;
222
223 if (!do_not_lock) CRYPTO_w_lock(CRYPTO_LOCK_RAND);
224 st_idx=state_index;
225
226 /* use our own copies of the counters so that even
227 * if a concurrent thread seeds with exactly the
228 * same data and uses the same subarray there's _some_
229 * difference */
230 md_c[0] = md_count[0];
231 md_c[1] = md_count[1];
232
233 memcpy(local_md, md, sizeof md);
234
235 /* state_index <= state_num <= STATE_SIZE */
236 state_index += num;
237 if (state_index >= STATE_SIZE)
238 {
239 state_index%=STATE_SIZE;
240 state_num=STATE_SIZE;
241 }
242 else if (state_num < STATE_SIZE)
243 {
244 if (state_index > state_num)
245 state_num=state_index;
246 }
247 /* state_index <= state_num <= STATE_SIZE */
248
249 /* state[st_idx], ..., state[(st_idx + num - 1) % STATE_SIZE]
250 * are what we will use now, but other threads may use them
251 * as well */
252
253 md_count[1] += (num / MD_DIGEST_LENGTH) + (num % MD_DIGEST_LENGTH > 0);
254
255 if (!do_not_lock) CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
256
257 EVP_MD_CTX_init(&m);
258 for (i=0; i<num; i+=MD_DIGEST_LENGTH)
259 {
260 j=(num-i);
261 j=(j > MD_DIGEST_LENGTH)?MD_DIGEST_LENGTH:j;
262
263 MD_Init(&m);
264 MD_Update(&m,local_md,MD_DIGEST_LENGTH);
265 k=(st_idx+j)-STATE_SIZE;
266 if (k > 0)
267 {
268 MD_Update(&m,&(state[st_idx]),j-k);
269 MD_Update(&m,&(state[0]),k);
270 }
271 else
272 MD_Update(&m,&(state[st_idx]),j);
273
274 MD_Update(&m,buf,j);
275 MD_Update(&m,(unsigned char *)&(md_c[0]),sizeof(md_c));
276 MD_Final(&m,local_md);
277 md_c[1]++;
278
279 buf=(const char *)buf + j;
280
281 for (k=0; k<j; k++)
282 {
283 /* Parallel threads may interfere with this,
284 * but always each byte of the new state is
285 * the XOR of some previous value of its
286 * and local_md (itermediate values may be lost).
287 * Alway using locking could hurt performance more
288 * than necessary given that conflicts occur only
289 * when the total seeding is longer than the random
290 * state. */
291 state[st_idx++]^=local_md[k];
292 if (st_idx >= STATE_SIZE)
293 st_idx=0;
294 }
295 }
296 EVP_MD_CTX_cleanup(&m);
297
298 if (!do_not_lock) CRYPTO_w_lock(CRYPTO_LOCK_RAND);
299 /* Don't just copy back local_md into md -- this could mean that
300 * other thread's seeding remains without effect (except for
301 * the incremented counter). By XORing it we keep at least as
302 * much entropy as fits into md. */
303 for (k = 0; k < sizeof md; k++)
304 {
305 md[k] ^= local_md[k];
306 }
307 if (entropy < ENTROPY_NEEDED) /* stop counting when we have enough */
308 entropy += add;
309 if (!do_not_lock) CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
310
311#if !defined(OPENSSL_THREADS) && !defined(OPENSSL_SYS_WIN32)
312 assert(md_c[1] == md_count[1]);
313#endif
314 }
315
316static void ssleay_rand_seed(const void *buf, int num)
317 {
318 ssleay_rand_add(buf, num, num);
319 }
320
321static int ssleay_rand_bytes(unsigned char *buf, int num)
322 {
323 static volatile int stirred_pool = 0;
324 int i,j,k,st_num,st_idx;
325 int num_ceil;
326 int ok;
327 long md_c[2];
328 unsigned char local_md[MD_DIGEST_LENGTH];
329 EVP_MD_CTX m;
330#ifndef GETPID_IS_MEANINGLESS
331 pid_t curr_pid = getpid();
332#endif
333 int do_stir_pool = 0;
334
335#ifdef PREDICT
336 if (rand_predictable)
337 {
338 static unsigned char val=0;
339
340 for (i=0; i<num; i++)
341 buf[i]=val++;
342 return(1);
343 }
344#endif
345
346 if (num <= 0)
347 return 1;
348
349 EVP_MD_CTX_init(&m);
350 /* round upwards to multiple of MD_DIGEST_LENGTH/2 */
351 num_ceil = (1 + (num-1)/(MD_DIGEST_LENGTH/2)) * (MD_DIGEST_LENGTH/2);
352
353 /*
354 * (Based on the rand(3) manpage:)
355 *
356 * For each group of 10 bytes (or less), we do the following:
357 *
358 * Input into the hash function the local 'md' (which is initialized from
359 * the global 'md' before any bytes are generated), the bytes that are to
360 * be overwritten by the random bytes, and bytes from the 'state'
361 * (incrementing looping index). From this digest output (which is kept
362 * in 'md'), the top (up to) 10 bytes are returned to the caller and the
363 * bottom 10 bytes are xored into the 'state'.
364 *
365 * Finally, after we have finished 'num' random bytes for the
366 * caller, 'count' (which is incremented) and the local and global 'md'
367 * are fed into the hash function and the results are kept in the
368 * global 'md'.
369 */
370
371 CRYPTO_w_lock(CRYPTO_LOCK_RAND);
372
373 /* prevent ssleay_rand_bytes() from trying to obtain the lock again */
374 CRYPTO_w_lock(CRYPTO_LOCK_RAND2);
375 locking_thread = CRYPTO_thread_id();
376 CRYPTO_w_unlock(CRYPTO_LOCK_RAND2);
377 crypto_lock_rand = 1;
378
379 if (!initialized)
380 {
381 RAND_poll();
382 initialized = 1;
383 }
384
385 if (!stirred_pool)
386 do_stir_pool = 1;
387
388 ok = (entropy >= ENTROPY_NEEDED);
389 if (!ok)
390 {
391 /* If the PRNG state is not yet unpredictable, then seeing
392 * the PRNG output may help attackers to determine the new
393 * state; thus we have to decrease the entropy estimate.
394 * Once we've had enough initial seeding we don't bother to
395 * adjust the entropy count, though, because we're not ambitious
396 * to provide *information-theoretic* randomness.
397 *
398 * NOTE: This approach fails if the program forks before
399 * we have enough entropy. Entropy should be collected
400 * in a separate input pool and be transferred to the
401 * output pool only when the entropy limit has been reached.
402 */
403 entropy -= num;
404 if (entropy < 0)
405 entropy = 0;
406 }
407
408 if (do_stir_pool)
409 {
410 /* In the output function only half of 'md' remains secret,
411 * so we better make sure that the required entropy gets
412 * 'evenly distributed' through 'state', our randomness pool.
413 * The input function (ssleay_rand_add) chains all of 'md',
414 * which makes it more suitable for this purpose.
415 */
416
417 int n = STATE_SIZE; /* so that the complete pool gets accessed */
418 while (n > 0)
419 {
420#if MD_DIGEST_LENGTH > 20
421# error "Please adjust DUMMY_SEED."
422#endif
423#define DUMMY_SEED "...................." /* at least MD_DIGEST_LENGTH */
424 /* Note that the seed does not matter, it's just that
425 * ssleay_rand_add expects to have something to hash. */
426 ssleay_rand_add(DUMMY_SEED, MD_DIGEST_LENGTH, 0.0);
427 n -= MD_DIGEST_LENGTH;
428 }
429 if (ok)
430 stirred_pool = 1;
431 }
432
433 st_idx=state_index;
434 st_num=state_num;
435 md_c[0] = md_count[0];
436 md_c[1] = md_count[1];
437 memcpy(local_md, md, sizeof md);
438
439 state_index+=num_ceil;
440 if (state_index > state_num)
441 state_index %= state_num;
442
443 /* state[st_idx], ..., state[(st_idx + num_ceil - 1) % st_num]
444 * are now ours (but other threads may use them too) */
445
446 md_count[0] += 1;
447
448 /* before unlocking, we must clear 'crypto_lock_rand' */
449 crypto_lock_rand = 0;
450 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
451
452 while (num > 0)
453 {
454 /* num_ceil -= MD_DIGEST_LENGTH/2 */
455 j=(num >= MD_DIGEST_LENGTH/2)?MD_DIGEST_LENGTH/2:num;
456 num-=j;
457 MD_Init(&m);
458#ifndef GETPID_IS_MEANINGLESS
459 if (curr_pid) /* just in the first iteration to save time */
460 {
461 MD_Update(&m,(unsigned char*)&curr_pid,sizeof curr_pid);
462 curr_pid = 0;
463 }
464#endif
465 MD_Update(&m,local_md,MD_DIGEST_LENGTH);
466 MD_Update(&m,(unsigned char *)&(md_c[0]),sizeof(md_c));
467#ifndef PURIFY
468 MD_Update(&m,buf,j); /* purify complains */
469#endif
470 k=(st_idx+MD_DIGEST_LENGTH/2)-st_num;
471 if (k > 0)
472 {
473 MD_Update(&m,&(state[st_idx]),MD_DIGEST_LENGTH/2-k);
474 MD_Update(&m,&(state[0]),k);
475 }
476 else
477 MD_Update(&m,&(state[st_idx]),MD_DIGEST_LENGTH/2);
478 MD_Final(&m,local_md);
479
480 for (i=0; i<MD_DIGEST_LENGTH/2; i++)
481 {
482 state[st_idx++]^=local_md[i]; /* may compete with other threads */
483 if (st_idx >= st_num)
484 st_idx=0;
485 if (i < j)
486 *(buf++)=local_md[i+MD_DIGEST_LENGTH/2];
487 }
488 }
489
490 MD_Init(&m);
491 MD_Update(&m,(unsigned char *)&(md_c[0]),sizeof(md_c));
492 MD_Update(&m,local_md,MD_DIGEST_LENGTH);
493 CRYPTO_w_lock(CRYPTO_LOCK_RAND);
494 MD_Update(&m,md,MD_DIGEST_LENGTH);
495 MD_Final(&m,md);
496 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
497
498 EVP_MD_CTX_cleanup(&m);
499 if (ok)
500 return(1);
501 else
502 {
503 RANDerr(RAND_F_SSLEAY_RAND_BYTES,RAND_R_PRNG_NOT_SEEDED);
504 ERR_add_error_data(1, "You need to read the OpenSSL FAQ, "
505 "http://www.openssl.org/support/faq.html");
506 return(0);
507 }
508 }
509
510/* pseudo-random bytes that are guaranteed to be unique but not
511 unpredictable */
512static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num)
513 {
514 int ret;
515 unsigned long err;
516
517 ret = RAND_bytes(buf, num);
518 if (ret == 0)
519 {
520 err = ERR_peek_error();
521 if (ERR_GET_LIB(err) == ERR_LIB_RAND &&
522 ERR_GET_REASON(err) == RAND_R_PRNG_NOT_SEEDED)
523 (void)ERR_get_error();
524 }
525 return (ret);
526 }
527
528static int ssleay_rand_status(void)
529 {
530 int ret;
531 int do_not_lock;
532
533 /* check if we already have the lock
534 * (could happen if a RAND_poll() implementation calls RAND_status()) */
535 if (crypto_lock_rand)
536 {
537 CRYPTO_r_lock(CRYPTO_LOCK_RAND2);
538 do_not_lock = (locking_thread == CRYPTO_thread_id());
539 CRYPTO_r_unlock(CRYPTO_LOCK_RAND2);
540 }
541 else
542 do_not_lock = 0;
543
544 if (!do_not_lock)
545 {
546 CRYPTO_w_lock(CRYPTO_LOCK_RAND);
547
548 /* prevent ssleay_rand_bytes() from trying to obtain the lock again */
549 CRYPTO_w_lock(CRYPTO_LOCK_RAND2);
550 locking_thread = CRYPTO_thread_id();
551 CRYPTO_w_unlock(CRYPTO_LOCK_RAND2);
552 crypto_lock_rand = 1;
553 }
554
555 if (!initialized)
556 {
557 RAND_poll();
558 initialized = 1;
559 }
560
561 ret = entropy >= ENTROPY_NEEDED;
562
563 if (!do_not_lock)
564 {
565 /* before unlocking, we must clear 'crypto_lock_rand' */
566 crypto_lock_rand = 0;
567
568 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
569 }
570
571 return ret;
572 }
diff --git a/src/lib/libcrypto/rand/rand.h b/src/lib/libcrypto/rand/rand.h
index 606382dd21..66e39991ec 100644
--- a/src/lib/libcrypto/rand/rand.h
+++ b/src/lib/libcrypto/rand/rand.h
@@ -87,9 +87,7 @@ extern int rand_predictable;
87 87
88int RAND_set_rand_method(const RAND_METHOD *meth); 88int RAND_set_rand_method(const RAND_METHOD *meth);
89const RAND_METHOD *RAND_get_rand_method(void); 89const RAND_METHOD *RAND_get_rand_method(void);
90#ifndef OPENSSL_NO_ENGINE
91int RAND_set_rand_engine(ENGINE *engine); 90int RAND_set_rand_engine(ENGINE *engine);
92#endif
93RAND_METHOD *RAND_SSLeay(void); 91RAND_METHOD *RAND_SSLeay(void);
94void RAND_cleanup(void ); 92void RAND_cleanup(void );
95int RAND_bytes(unsigned char *buf,int num); 93int RAND_bytes(unsigned char *buf,int num);
diff --git a/src/lib/libcrypto/rand/rand_egd.c b/src/lib/libcrypto/rand/rand_egd.c
new file mode 100644
index 0000000000..96019c07a6
--- /dev/null
+++ b/src/lib/libcrypto/rand/rand_egd.c
@@ -0,0 +1,298 @@
1/* crypto/rand/rand_egd.c */
2/* Written by Ulf Moeller and Lutz Jaenicke for the OpenSSL project. */
3/* ====================================================================
4 * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 *
18 * 3. All advertising materials mentioning features or use of this
19 * software must display the following acknowledgment:
20 * "This product includes software developed by the OpenSSL Project
21 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
22 *
23 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
24 * endorse or promote products derived from this software without
25 * prior written permission. For written permission, please contact
26 * openssl-core@openssl.org.
27 *
28 * 5. Products derived from this software may not be called "OpenSSL"
29 * nor may "OpenSSL" appear in their names without prior written
30 * permission of the OpenSSL Project.
31 *
32 * 6. Redistributions of any form whatsoever must retain the following
33 * acknowledgment:
34 * "This product includes software developed by the OpenSSL Project
35 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
36 *
37 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
38 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
39 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
40 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
41 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
43 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
44 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
45 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
46 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
47 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
48 * OF THE POSSIBILITY OF SUCH DAMAGE.
49 * ====================================================================
50 *
51 * This product includes cryptographic software written by Eric Young
52 * (eay@cryptsoft.com). This product includes software written by Tim
53 * Hudson (tjh@cryptsoft.com).
54 *
55 */
56
57#include <openssl/e_os2.h>
58#include <openssl/rand.h>
59
60/*
61 * Query the EGD <URL: http://www.lothar.com/tech/crypto/>.
62 *
63 * This module supplies three routines:
64 *
65 * RAND_query_egd_bytes(path, buf, bytes)
66 * will actually query "bytes" bytes of entropy form the egd-socket located
67 * at path and will write them to buf (if supplied) or will directly feed
68 * it to RAND_seed() if buf==NULL.
69 * The number of bytes is not limited by the maximum chunk size of EGD,
70 * which is 255 bytes. If more than 255 bytes are wanted, several chunks
71 * of entropy bytes are requested. The connection is left open until the
72 * query is competed.
73 * RAND_query_egd_bytes() returns with
74 * -1 if an error occured during connection or communication.
75 * num the number of bytes read from the EGD socket. This number is either
76 * the number of bytes requested or smaller, if the EGD pool is
77 * drained and the daemon signals that the pool is empty.
78 * This routine does not touch any RAND_status(). This is necessary, since
79 * PRNG functions may call it during initialization.
80 *
81 * RAND_egd_bytes(path, bytes) will query "bytes" bytes and have them
82 * used to seed the PRNG.
83 * RAND_egd_bytes() is a wrapper for RAND_query_egd_bytes() with buf=NULL.
84 * Unlike RAND_query_egd_bytes(), RAND_status() is used to test the
85 * seed status so that the return value can reflect the seed state:
86 * -1 if an error occured during connection or communication _or_
87 * if the PRNG has still not received the required seeding.
88 * num the number of bytes read from the EGD socket. This number is either
89 * the number of bytes requested or smaller, if the EGD pool is
90 * drained and the daemon signals that the pool is empty.
91 *
92 * RAND_egd(path) will query 255 bytes and use the bytes retreived to seed
93 * the PRNG.
94 * RAND_egd() is a wrapper for RAND_egd_bytes() with numbytes=255.
95 */
96
97#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(__DJGPP__)
98int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes)
99 {
100 return(-1);
101 }
102int RAND_egd(const char *path)
103 {
104 return(-1);
105 }
106
107int RAND_egd_bytes(const char *path,int bytes)
108 {
109 return(-1);
110 }
111#else
112#include <openssl/opensslconf.h>
113#include OPENSSL_UNISTD
114#include <sys/types.h>
115#include <sys/socket.h>
116#ifndef NO_SYS_UN_H
117# ifdef OPENSSL_SYS_VSWORKS
118# include <streams/un.h>
119# else
120# include <sys/un.h>
121# endif
122#else
123struct sockaddr_un {
124 short sun_family; /* AF_UNIX */
125 char sun_path[108]; /* path name (gag) */
126};
127#endif /* NO_SYS_UN_H */
128#include <string.h>
129#include <errno.h>
130
131#ifndef offsetof
132# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
133#endif
134
135int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes)
136 {
137 int ret = 0;
138 struct sockaddr_un addr;
139 int len, num, numbytes;
140 int fd = -1;
141 int success;
142 unsigned char egdbuf[2], tempbuf[255], *retrievebuf;
143
144 memset(&addr, 0, sizeof(addr));
145 addr.sun_family = AF_UNIX;
146 if (strlen(path) > sizeof(addr.sun_path))
147 return (-1);
148 strlcpy(addr.sun_path,path,sizeof addr.sun_path);
149 len = offsetof(struct sockaddr_un, sun_path) + strlen(path);
150 fd = socket(AF_UNIX, SOCK_STREAM, 0);
151 if (fd == -1) return (-1);
152 success = 0;
153 while (!success)
154 {
155 if (connect(fd, (struct sockaddr *)&addr, len) == 0)
156 success = 1;
157 else
158 {
159 switch (errno)
160 {
161#ifdef EINTR
162 case EINTR:
163#endif
164#ifdef EAGAIN
165 case EAGAIN:
166#endif
167#ifdef EINPROGRESS
168 case EINPROGRESS:
169#endif
170#ifdef EALREADY
171 case EALREADY:
172#endif
173 /* No error, try again */
174 break;
175#ifdef EISCONN
176 case EISCONN:
177 success = 1;
178 break;
179#endif
180 default:
181 goto err; /* failure */
182 }
183 }
184 }
185
186 while(bytes > 0)
187 {
188 egdbuf[0] = 1;
189 egdbuf[1] = bytes < 255 ? bytes : 255;
190 numbytes = 0;
191 while (numbytes != 2)
192 {
193 num = write(fd, egdbuf + numbytes, 2 - numbytes);
194 if (num >= 0)
195 numbytes += num;
196 else
197 {
198 switch (errno)
199 {
200#ifdef EINTR
201 case EINTR:
202#endif
203#ifdef EAGAIN
204 case EAGAIN:
205#endif
206 /* No error, try again */
207 break;
208 default:
209 ret = -1;
210 goto err; /* failure */
211 }
212 }
213 }
214 numbytes = 0;
215 while (numbytes != 1)
216 {
217 num = read(fd, egdbuf, 1);
218 if (num >= 0)
219 numbytes += num;
220 else
221 {
222 switch (errno)
223 {
224#ifdef EINTR
225 case EINTR:
226#endif
227#ifdef EAGAIN
228 case EAGAIN:
229#endif
230 /* No error, try again */
231 break;
232 default:
233 ret = -1;
234 goto err; /* failure */
235 }
236 }
237 }
238 if(egdbuf[0] == 0)
239 goto err;
240 if (buf)
241 retrievebuf = buf + ret;
242 else
243 retrievebuf = tempbuf;
244 numbytes = 0;
245 while (numbytes != egdbuf[0])
246 {
247 num = read(fd, retrievebuf + numbytes, egdbuf[0] - numbytes);
248 if (num >= 0)
249 numbytes += num;
250 else
251 {
252 switch (errno)
253 {
254#ifdef EINTR
255 case EINTR:
256#endif
257#ifdef EAGAIN
258 case EAGAIN:
259#endif
260 /* No error, try again */
261 break;
262 default:
263 ret = -1;
264 goto err; /* failure */
265 }
266 }
267 }
268 ret += egdbuf[0];
269 bytes -= egdbuf[0];
270 if (!buf)
271 RAND_seed(tempbuf, egdbuf[0]);
272 }
273 err:
274 if (fd != -1) close(fd);
275 return(ret);
276 }
277
278
279int RAND_egd_bytes(const char *path, int bytes)
280 {
281 int num, ret = 0;
282
283 num = RAND_query_egd_bytes(path, NULL, bytes);
284 if (num < 1) goto err;
285 if (RAND_status() == 1)
286 ret = num;
287 err:
288 return(ret);
289 }
290
291
292int RAND_egd(const char *path)
293 {
294 return (RAND_egd_bytes(path, 255));
295 }
296
297
298#endif
diff --git a/src/lib/libcrypto/rand/rand_lcl.h b/src/lib/libcrypto/rand/rand_lcl.h
new file mode 100644
index 0000000000..618a8ec899
--- /dev/null
+++ b/src/lib/libcrypto/rand/rand_lcl.h
@@ -0,0 +1,158 @@
1/* crypto/rand/rand_lcl.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 * Copyright (c) 1998-2000 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#ifndef HEADER_RAND_LCL_H
113#define HEADER_RAND_LCL_H
114
115#define ENTROPY_NEEDED 32 /* require 256 bits = 32 bytes of randomness */
116
117
118#if !defined(USE_MD5_RAND) && !defined(USE_SHA1_RAND) && !defined(USE_MDC2_RAND) && !defined(USE_MD2_RAND)
119#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA1)
120#define USE_SHA1_RAND
121#elif !defined(OPENSSL_NO_MD5)
122#define USE_MD5_RAND
123#elif !defined(OPENSSL_NO_MDC2) && !defined(OPENSSL_NO_DES)
124#define USE_MDC2_RAND
125#elif !defined(OPENSSL_NO_MD2)
126#define USE_MD2_RAND
127#else
128#error No message digest algorithm available
129#endif
130#endif
131
132#include <openssl/evp.h>
133#define MD_Update(a,b,c) EVP_DigestUpdate(a,b,c)
134#define MD_Final(a,b) EVP_DigestFinal_ex(a,b,NULL)
135#if defined(USE_MD5_RAND)
136#include <openssl/md5.h>
137#define MD_DIGEST_LENGTH MD5_DIGEST_LENGTH
138#define MD_Init(a) EVP_DigestInit_ex(a,EVP_md5(), NULL)
139#define MD(a,b,c) EVP_Digest(a,b,c,NULL,EVP_md5(), NULL)
140#elif defined(USE_SHA1_RAND)
141#include <openssl/sha.h>
142#define MD_DIGEST_LENGTH SHA_DIGEST_LENGTH
143#define MD_Init(a) EVP_DigestInit_ex(a,EVP_sha1(), NULL)
144#define MD(a,b,c) EVP_Digest(a,b,c,NULL,EVP_sha1(), NULL)
145#elif defined(USE_MDC2_RAND)
146#include <openssl/mdc2.h>
147#define MD_DIGEST_LENGTH MDC2_DIGEST_LENGTH
148#define MD_Init(a) EVP_DigestInit_ex(a,EVP_mdc2(), NULL)
149#define MD(a,b,c) EVP_Digest(a,b,c,NULL,EVP_mdc2(), NULL)
150#elif defined(USE_MD2_RAND)
151#include <openssl/md2.h>
152#define MD_DIGEST_LENGTH MD2_DIGEST_LENGTH
153#define MD_Init(a) EVP_DigestInit_ex(a,EVP_md2(), NULL)
154#define MD(a,b,c) EVP_Digest(a,b,c,NULL,EVP_md2(), NULL)
155#endif
156
157
158#endif
diff --git a/src/lib/libcrypto/rand/rand_lib.c b/src/lib/libcrypto/rand/rand_lib.c
index 513e338985..5cf5dc1188 100644
--- a/src/lib/libcrypto/rand/rand_lib.c
+++ b/src/lib/libcrypto/rand/rand_lib.c
@@ -60,25 +60,19 @@
60#include <time.h> 60#include <time.h>
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/rand.h> 62#include <openssl/rand.h>
63#ifndef OPENSSL_NO_ENGINE
64#include <openssl/engine.h> 63#include <openssl/engine.h>
65#endif
66 64
67#ifndef OPENSSL_NO_ENGINE
68/* non-NULL if default_RAND_meth is ENGINE-provided */ 65/* non-NULL if default_RAND_meth is ENGINE-provided */
69static ENGINE *funct_ref =NULL; 66static ENGINE *funct_ref =NULL;
70#endif
71static const RAND_METHOD *default_RAND_meth = NULL; 67static const RAND_METHOD *default_RAND_meth = NULL;
72 68
73int RAND_set_rand_method(const RAND_METHOD *meth) 69int RAND_set_rand_method(const RAND_METHOD *meth)
74 { 70 {
75#ifndef OPENSSL_NO_ENGINE
76 if(funct_ref) 71 if(funct_ref)
77 { 72 {
78 ENGINE_finish(funct_ref); 73 ENGINE_finish(funct_ref);
79 funct_ref = NULL; 74 funct_ref = NULL;
80 } 75 }
81#endif
82 default_RAND_meth = meth; 76 default_RAND_meth = meth;
83 return 1; 77 return 1;
84 } 78 }
@@ -87,7 +81,6 @@ const RAND_METHOD *RAND_get_rand_method(void)
87 { 81 {
88 if (!default_RAND_meth) 82 if (!default_RAND_meth)
89 { 83 {
90#ifndef OPENSSL_NO_ENGINE
91 ENGINE *e = ENGINE_get_default_RAND(); 84 ENGINE *e = ENGINE_get_default_RAND();
92 if(e) 85 if(e)
93 { 86 {
@@ -101,13 +94,11 @@ const RAND_METHOD *RAND_get_rand_method(void)
101 if(e) 94 if(e)
102 funct_ref = e; 95 funct_ref = e;
103 else 96 else
104#endif
105 default_RAND_meth = RAND_SSLeay(); 97 default_RAND_meth = RAND_SSLeay();
106 } 98 }
107 return default_RAND_meth; 99 return default_RAND_meth;
108 } 100 }
109 101
110#ifndef OPENSSL_NO_ENGINE
111int RAND_set_rand_engine(ENGINE *engine) 102int RAND_set_rand_engine(ENGINE *engine)
112 { 103 {
113 const RAND_METHOD *tmp_meth = NULL; 104 const RAND_METHOD *tmp_meth = NULL;
@@ -127,7 +118,6 @@ int RAND_set_rand_engine(ENGINE *engine)
127 funct_ref = engine; 118 funct_ref = engine;
128 return 1; 119 return 1;
129 } 120 }
130#endif
131 121
132void RAND_cleanup(void) 122void RAND_cleanup(void)
133 { 123 {
diff --git a/src/lib/libcrypto/rand/rand_os2.c b/src/lib/libcrypto/rand/rand_os2.c
new file mode 100644
index 0000000000..c3e36d4e5e
--- /dev/null
+++ b/src/lib/libcrypto/rand/rand_os2.c
@@ -0,0 +1,147 @@
1/* crypto/rand/rand_os2.c */
2/* ====================================================================
3 * Copyright (c) 1998-2000 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 "cryptlib.h"
57#include <openssl/rand.h>
58#include "rand_lcl.h"
59
60#ifdef OPENSSL_SYS_OS2
61
62#define INCL_DOSPROCESS
63#define INCL_DOSPROFILE
64#define INCL_DOSMISC
65#define INCL_DOSMODULEMGR
66#include <os2.h>
67
68#define CMD_KI_RDCNT (0x63)
69
70typedef struct _CPUUTIL {
71 ULONG ulTimeLow; /* Low 32 bits of time stamp */
72 ULONG ulTimeHigh; /* High 32 bits of time stamp */
73 ULONG ulIdleLow; /* Low 32 bits of idle time */
74 ULONG ulIdleHigh; /* High 32 bits of idle time */
75 ULONG ulBusyLow; /* Low 32 bits of busy time */
76 ULONG ulBusyHigh; /* High 32 bits of busy time */
77 ULONG ulIntrLow; /* Low 32 bits of interrupt time */
78 ULONG ulIntrHigh; /* High 32 bits of interrupt time */
79} CPUUTIL;
80
81APIRET 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;
83HMODULE hDoscalls = 0;
84
85int RAND_poll(void)
86{
87 char failed_module[20];
88 QWORD qwTime;
89 ULONG SysVars[QSV_FOREGROUND_PROCESS];
90
91 if (hDoscalls == 0) {
92 ULONG rc = DosLoadModule(failed_module, sizeof(failed_module), "DOSCALLS", &hDoscalls);
93
94 if (rc == 0) {
95 rc = DosQueryProcAddr(hDoscalls, 976, NULL, (PFN *)&DosPerfSysCall);
96
97 if (rc)
98 DosPerfSysCall = NULL;
99
100 rc = DosQueryProcAddr(hDoscalls, 368, NULL, (PFN *)&DosQuerySysState);
101
102 if (rc)
103 DosQuerySysState = NULL;
104 }
105 }
106
107 /* Sample the hi-res timer, runs at around 1.1 MHz */
108 DosTmrQueryTime(&qwTime);
109 RAND_add(&qwTime, sizeof(qwTime), 2);
110
111 /* Sample a bunch of system variables, includes various process & memory statistics */
112 DosQuerySysInfo(1, QSV_FOREGROUND_PROCESS, SysVars, sizeof(SysVars));
113 RAND_add(SysVars, sizeof(SysVars), 4);
114
115 /* If available, sample CPU registers that count at CPU MHz
116 * Only fairly new CPUs (PPro & K6 onwards) & OS/2 versions support this
117 */
118 if (DosPerfSysCall) {
119 CPUUTIL util;
120
121 if (DosPerfSysCall(CMD_KI_RDCNT, (ULONG)&util, 0, 0) == 0) {
122 RAND_add(&util, sizeof(util), 10);
123 }
124 else {
125 DosPerfSysCall = NULL;
126 }
127 }
128
129 /* DosQuerySysState() gives us a huge quantity of process, thread, memory & handle stats */
130 if (DosQuerySysState) {
131 char *buffer = OPENSSL_malloc(256 * 1024);
132
133 if (DosQuerySysState(0x1F, 0, 0, 0, buffer, 256 * 1024) == 0) {
134 /* First 4 bytes in buffer is a pointer to the thread count
135 * there should be at least 1 byte of entropy per thread
136 */
137 RAND_add(buffer, 256 * 1024, **(ULONG **)buffer);
138 }
139
140 OPENSSL_free(buffer);
141 return 1;
142 }
143
144 return 0;
145}
146
147#endif /* OPENSSL_SYS_OS2 */
diff --git a/src/lib/libcrypto/rand/rand_unix.c b/src/lib/libcrypto/rand/rand_unix.c
new file mode 100644
index 0000000000..fa2bab57c6
--- /dev/null
+++ b/src/lib/libcrypto/rand/rand_unix.c
@@ -0,0 +1,257 @@
1/* crypto/rand/rand_unix.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-2000 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#define USE_SOCKETS
113#include "e_os.h"
114#include "cryptlib.h"
115#include <openssl/rand.h>
116#include "rand_lcl.h"
117
118#if !(defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2))
119
120#include <sys/types.h>
121#include <sys/time.h>
122#include <sys/times.h>
123#include <fcntl.h>
124#include <unistd.h>
125#include <time.h>
126
127#ifdef __OpenBSD__
128int RAND_poll(void)
129{
130 u_int32_t rnd = 0, i;
131 unsigned char buf[ENTROPY_NEEDED];
132
133 for (i = 0; i < sizeof(buf); i++) {
134 if (i % 4 == 0)
135 rnd = arc4random();
136 buf[i] = rnd;
137 rnd >>= 8;
138 }
139 RAND_add(buf, sizeof(buf), ENTROPY_NEEDED);
140 memset(buf, 0, sizeof(buf));
141
142 return 1;
143}
144#else
145int RAND_poll(void)
146{
147 unsigned long l;
148 pid_t curr_pid = getpid();
149#if defined(DEVRANDOM) || defined(DEVRANDOM_EGD)
150 unsigned char tmpbuf[ENTROPY_NEEDED];
151 int n = 0;
152#endif
153#ifdef DEVRANDOM
154 static const char *randomfiles[] = { DEVRANDOM, NULL };
155 const char **randomfile = NULL;
156 int fd;
157#endif
158#ifdef DEVRANDOM_EGD
159 static const char *egdsockets[] = { DEVRANDOM_EGD, NULL };
160 const char **egdsocket = NULL;
161#endif
162
163#ifdef DEVRANDOM
164 /* Use a random entropy pool device. Linux, FreeBSD and OpenBSD
165 * have this. Use /dev/urandom if you can as /dev/random may block
166 * if it runs out of random entries. */
167
168 for (randomfile = randomfiles; *randomfile && n < ENTROPY_NEEDED; randomfile++)
169 {
170 if ((fd = open(*randomfile, O_RDONLY|O_NONBLOCK
171#ifdef O_NOCTTY /* If it happens to be a TTY (god forbid), do not make it
172 our controlling tty */
173 |O_NOCTTY
174#endif
175#ifdef O_NOFOLLOW /* Fail if the file is a symbolic link */
176 |O_NOFOLLOW
177#endif
178 )) >= 0)
179 {
180 struct timeval t = { 0, 10*1000 }; /* Spend 10ms on
181 each file. */
182 int r;
183 fd_set fset;
184
185 do
186 {
187 FD_ZERO(&fset);
188 FD_SET(fd, &fset);
189 r = -1;
190
191 if (select(fd+1,&fset,NULL,NULL,&t) < 0)
192 t.tv_usec=0;
193 else if (FD_ISSET(fd, &fset))
194 {
195 r=read(fd,(unsigned char *)tmpbuf+n,
196 ENTROPY_NEEDED-n);
197 if (r > 0)
198 n += r;
199 }
200
201 /* Some Unixen will update t, some
202 won't. For those who won't, give
203 up here, otherwise, we will do
204 this once again for the remaining
205 time. */
206 if (t.tv_usec == 10*1000)
207 t.tv_usec=0;
208 }
209 while ((r > 0 || (errno == EINTR || errno == EAGAIN))
210 && t.tv_usec != 0 && n < ENTROPY_NEEDED);
211
212 close(fd);
213 }
214 }
215#endif
216
217#ifdef DEVRANDOM_EGD
218 /* Use an EGD socket to read entropy from an EGD or PRNGD entropy
219 * collecting daemon. */
220
221 for (egdsocket = egdsockets; *egdsocket && n < ENTROPY_NEEDED; egdsocket++)
222 {
223 int r;
224
225 r = RAND_query_egd_bytes(*egdsocket, (unsigned char *)tmpbuf+n,
226 ENTROPY_NEEDED-n);
227 if (r > 0)
228 n += r;
229 }
230#endif
231
232#if defined(DEVRANDOM) || defined(DEVRANDOM_EGD)
233 if (n > 0)
234 {
235 RAND_add(tmpbuf,sizeof tmpbuf,n);
236 memset(tmpbuf,0,n);
237 }
238#endif
239
240 /* put in some default random data, we need more than just this */
241 l=curr_pid;
242 RAND_add(&l,sizeof(l),0);
243 l=getuid();
244 RAND_add(&l,sizeof(l),0);
245
246 l=time(NULL);
247 RAND_add(&l,sizeof(l),0);
248
249#if defined(DEVRANDOM) || defined(DEVRANDOM_EGD)
250 return 1;
251#else
252 return 0;
253#endif
254}
255
256#endif
257#endif
diff --git a/src/lib/libcrypto/rand/rand_vms.c b/src/lib/libcrypto/rand/rand_vms.c
new file mode 100644
index 0000000000..29b2d7af0b
--- /dev/null
+++ b/src/lib/libcrypto/rand/rand_vms.c
@@ -0,0 +1,135 @@
1/* crypto/rand/rand_vms.c -*- mode:C; c-file-style: "eay" -*- */
2/* Written by Richard Levitte <richard@levitte.org> for the OpenSSL
3 * project 2000.
4 */
5/* ====================================================================
6 * Copyright (c) 1998-2000 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 <openssl/rand.h>
60#include "rand_lcl.h"
61
62#if defined(OPENSSL_SYS_VMS)
63
64#include <descrip.h>
65#include <jpidef.h>
66#include <ssdef.h>
67#include <starlet.h>
68#ifdef __DECC
69# pragma message disable DOLLARID
70#endif
71
72static struct items_data_st
73 {
74 short length, code; /* length is amount of bytes */
75 } items_data[] =
76 { { 4, JPI$_BUFIO },
77 { 4, JPI$_CPUTIM },
78 { 4, JPI$_DIRIO },
79 { 8, JPI$_LOGINTIM },
80 { 4, JPI$_PAGEFLTS },
81 { 4, JPI$_PID },
82 { 4, JPI$_WSSIZE },
83 { 0, 0 }
84 };
85
86int RAND_poll(void)
87 {
88 long pid, iosb[2];
89 int status = 0;
90 struct
91 {
92 short length, code;
93 long *buffer;
94 int *retlen;
95 } item[32], *pitem;
96 unsigned char data_buffer[256];
97 short total_length = 0;
98 struct items_data_st *pitems_data;
99
100 pitems_data = items_data;
101 pitem = item;
102
103 /* Setup */
104 while (pitems_data->length)
105 {
106 pitem->length = pitems_data->length;
107 pitem->code = pitems_data->code;
108 pitem->buffer = (long *)data_buffer[total_length];
109 pitem->retlen = 0;
110 total_length += pitems_data->length;
111 pitems_data++;
112 pitem++;
113 }
114 pitem->length = pitem->code = 0;
115
116 /*
117 * Scan through all the processes in the system and add entropy with
118 * results from the processes that were possible to look at.
119 * However, view the information as only half trustable.
120 */
121 pid = -1; /* search context */
122 while ((status = sys$getjpiw(0, &pid, 0, item, iosb, 0, 0))
123 != SS$_NOMOREPROC)
124 {
125 if (status == SS$_NORMAL)
126 {
127 RAND_add(data_buffer, total_length, total_length/2);
128 }
129 }
130 sys$gettim(iosb);
131 RAND_add((unsigned char *)iosb, sizeof(iosb), sizeof(iosb)/2);
132 return 1;
133}
134
135#endif
diff --git a/src/lib/libcrypto/rand/rand_win.c b/src/lib/libcrypto/rand/rand_win.c
new file mode 100644
index 0000000000..c1b955b06f
--- /dev/null
+++ b/src/lib/libcrypto/rand/rand_win.c
@@ -0,0 +1,693 @@
1/* crypto/rand/rand_win.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-2000 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 "cryptlib.h"
113#include <openssl/rand.h>
114#include "rand_lcl.h"
115
116#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32)
117#include <windows.h>
118#ifndef _WIN32_WINNT
119# define _WIN32_WINNT 0x0400
120#endif
121#include <wincrypt.h>
122#include <tlhelp32.h>
123
124/* Intel hardware RNG CSP -- available from
125 * http://developer.intel.com/design/security/rng/redist_license.htm
126 */
127#define PROV_INTEL_SEC 22
128#define INTEL_DEF_PROV "Intel Hardware Cryptographic Service Provider"
129
130static void readtimer(void);
131static void readscreen(void);
132
133/* It appears like CURSORINFO, PCURSORINFO and LPCURSORINFO are only defined
134 when WINVER is 0x0500 and up, which currently only happens on Win2000.
135 Unfortunately, those are typedefs, so they're a little bit difficult to
136 detect properly. On the other hand, the macro CURSOR_SHOWING is defined
137 within the same conditional, so it can be use to detect the absence of said
138 typedefs. */
139
140#ifndef CURSOR_SHOWING
141/*
142 * Information about the global cursor.
143 */
144typedef struct tagCURSORINFO
145{
146 DWORD cbSize;
147 DWORD flags;
148 HCURSOR hCursor;
149 POINT ptScreenPos;
150} CURSORINFO, *PCURSORINFO, *LPCURSORINFO;
151
152#define CURSOR_SHOWING 0x00000001
153#endif /* CURSOR_SHOWING */
154
155typedef BOOL (WINAPI *CRYPTACQUIRECONTEXT)(HCRYPTPROV *, LPCTSTR, LPCTSTR,
156 DWORD, DWORD);
157typedef BOOL (WINAPI *CRYPTGENRANDOM)(HCRYPTPROV, DWORD, BYTE *);
158typedef BOOL (WINAPI *CRYPTRELEASECONTEXT)(HCRYPTPROV, DWORD);
159
160typedef HWND (WINAPI *GETFOREGROUNDWINDOW)(VOID);
161typedef BOOL (WINAPI *GETCURSORINFO)(PCURSORINFO);
162typedef DWORD (WINAPI *GETQUEUESTATUS)(UINT);
163
164typedef HANDLE (WINAPI *CREATETOOLHELP32SNAPSHOT)(DWORD, DWORD);
165typedef BOOL (WINAPI *HEAP32FIRST)(LPHEAPENTRY32, DWORD, DWORD);
166typedef BOOL (WINAPI *HEAP32NEXT)(LPHEAPENTRY32);
167typedef BOOL (WINAPI *HEAP32LIST)(HANDLE, LPHEAPLIST32);
168typedef BOOL (WINAPI *PROCESS32)(HANDLE, LPPROCESSENTRY32);
169typedef BOOL (WINAPI *THREAD32)(HANDLE, LPTHREADENTRY32);
170typedef BOOL (WINAPI *MODULE32)(HANDLE, LPMODULEENTRY32);
171
172#include <lmcons.h>
173#include <lmstats.h>
174#if 1 /* The NET API is Unicode only. It requires the use of the UNICODE
175 * macro. When UNICODE is defined LPTSTR becomes LPWSTR. LMSTR was
176 * was added to the Platform SDK to allow the NET API to be used in
177 * non-Unicode applications provided that Unicode strings were still
178 * used for input. LMSTR is defined as LPWSTR.
179 */
180typedef NET_API_STATUS (NET_API_FUNCTION * NETSTATGET)
181 (LPWSTR, LPWSTR, DWORD, DWORD, LPBYTE*);
182typedef NET_API_STATUS (NET_API_FUNCTION * NETFREE)(LPBYTE);
183#endif /* 1 */
184
185int RAND_poll(void)
186{
187 MEMORYSTATUS m;
188 HCRYPTPROV hProvider = 0;
189 BYTE buf[64];
190 DWORD w;
191 HWND h;
192
193 HMODULE advapi, kernel, user, netapi;
194 CRYPTACQUIRECONTEXT acquire = 0;
195 CRYPTGENRANDOM gen = 0;
196 CRYPTRELEASECONTEXT release = 0;
197#if 1 /* There was previously a problem with NETSTATGET. Currently, this
198 * section is still experimental, but if all goes well, this conditional
199 * will be removed
200 */
201 NETSTATGET netstatget = 0;
202 NETFREE netfree = 0;
203#endif /* 1 */
204
205 /* Determine the OS version we are on so we can turn off things
206 * that do not work properly.
207 */
208 OSVERSIONINFO osverinfo ;
209 osverinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO) ;
210 GetVersionEx( &osverinfo ) ;
211
212 /* load functions dynamically - not available on all systems */
213 advapi = LoadLibrary("ADVAPI32.DLL");
214 kernel = LoadLibrary("KERNEL32.DLL");
215 user = LoadLibrary("USER32.DLL");
216 netapi = LoadLibrary("NETAPI32.DLL");
217
218#if 1 /* There was previously a problem with NETSTATGET. Currently, this
219 * section is still experimental, but if all goes well, this conditional
220 * will be removed
221 */
222 if (netapi)
223 {
224 netstatget = (NETSTATGET) GetProcAddress(netapi,"NetStatisticsGet");
225 netfree = (NETFREE) GetProcAddress(netapi,"NetApiBufferFree");
226 }
227
228 if (netstatget && netfree)
229 {
230 LPBYTE outbuf;
231 /* NetStatisticsGet() is a Unicode only function
232 * STAT_WORKSTATION_0 contains 45 fields and STAT_SERVER_0
233 * contains 17 fields. We treat each field as a source of
234 * one byte of entropy.
235 */
236
237 if (netstatget(NULL, L"LanmanWorkstation", 0, 0, &outbuf) == 0)
238 {
239 RAND_add(outbuf, sizeof(STAT_WORKSTATION_0), 45);
240 netfree(outbuf);
241 }
242 if (netstatget(NULL, L"LanmanServer", 0, 0, &outbuf) == 0)
243 {
244 RAND_add(outbuf, sizeof(STAT_SERVER_0), 17);
245 netfree(outbuf);
246 }
247 }
248
249 if (netapi)
250 FreeLibrary(netapi);
251#endif /* 1 */
252
253 /* It appears like this can cause an exception deep within ADVAPI32.DLL
254 * at random times on Windows 2000. Reported by Jeffrey Altman.
255 * Only use it on NT.
256 */
257 /* Wolfgang Marczy <WMarczy@topcall.co.at> reports that
258 * the RegQueryValueEx call below can hang on NT4.0 (SP6).
259 * So we don't use this at all for now. */
260#if 0
261 if ( osverinfo.dwPlatformId == VER_PLATFORM_WIN32_NT &&
262 osverinfo.dwMajorVersion < 5)
263 {
264 /* Read Performance Statistics from NT/2000 registry
265 * The size of the performance data can vary from call
266 * to call so we must guess the size of the buffer to use
267 * and increase its size if we get an ERROR_MORE_DATA
268 * return instead of ERROR_SUCCESS.
269 */
270 LONG rc=ERROR_MORE_DATA;
271 char * buf=NULL;
272 DWORD bufsz=0;
273 DWORD length;
274
275 while (rc == ERROR_MORE_DATA)
276 {
277 buf = realloc(buf,bufsz+8192);
278 if (!buf)
279 break;
280 bufsz += 8192;
281
282 length = bufsz;
283 rc = RegQueryValueEx(HKEY_PERFORMANCE_DATA, "Global",
284 NULL, NULL, buf, &length);
285 }
286 if (rc == ERROR_SUCCESS)
287 {
288 /* For entropy count assume only least significant
289 * byte of each DWORD is random.
290 */
291 RAND_add(&length, sizeof(length), 0);
292 RAND_add(buf, length, length / 4.0);
293 }
294 if (buf)
295 free(buf);
296 }
297#endif
298
299 if (advapi)
300 {
301 acquire = (CRYPTACQUIRECONTEXT) GetProcAddress(advapi,
302 "CryptAcquireContextA");
303 gen = (CRYPTGENRANDOM) GetProcAddress(advapi,
304 "CryptGenRandom");
305 release = (CRYPTRELEASECONTEXT) GetProcAddress(advapi,
306 "CryptReleaseContext");
307 }
308
309 if (acquire && gen && release)
310 {
311 /* poll the CryptoAPI PRNG */
312 /* The CryptoAPI returns sizeof(buf) bytes of randomness */
313 if (acquire(&hProvider, 0, 0, PROV_RSA_FULL,
314 CRYPT_VERIFYCONTEXT))
315 {
316 if (gen(hProvider, sizeof(buf), buf) != 0)
317 {
318 RAND_add(buf, sizeof(buf), 0);
319#if 0
320 printf("randomness from PROV_RSA_FULL\n");
321#endif
322 }
323 release(hProvider, 0);
324 }
325
326 /* poll the Pentium PRG with CryptoAPI */
327 if (acquire(&hProvider, 0, INTEL_DEF_PROV, PROV_INTEL_SEC, 0))
328 {
329 if (gen(hProvider, sizeof(buf), buf) != 0)
330 {
331 RAND_add(buf, sizeof(buf), sizeof(buf));
332#if 0
333 printf("randomness from PROV_INTEL_SEC\n");
334#endif
335 }
336 release(hProvider, 0);
337 }
338 }
339
340 if (advapi)
341 FreeLibrary(advapi);
342
343 /* timer data */
344 readtimer();
345
346 /* memory usage statistics */
347 GlobalMemoryStatus(&m);
348 RAND_add(&m, sizeof(m), 1);
349
350 /* process ID */
351 w = GetCurrentProcessId();
352 RAND_add(&w, sizeof(w), 1);
353
354 if (user)
355 {
356 GETCURSORINFO cursor;
357 GETFOREGROUNDWINDOW win;
358 GETQUEUESTATUS queue;
359
360 win = (GETFOREGROUNDWINDOW) GetProcAddress(user, "GetForegroundWindow");
361 cursor = (GETCURSORINFO) GetProcAddress(user, "GetCursorInfo");
362 queue = (GETQUEUESTATUS) GetProcAddress(user, "GetQueueStatus");
363
364 if (win)
365 {
366 /* window handle */
367 h = win();
368 RAND_add(&h, sizeof(h), 0);
369 }
370 if (cursor)
371 {
372 /* unfortunately, its not safe to call GetCursorInfo()
373 * on NT4 even though it exists in SP3 (or SP6) and
374 * higher.
375 */
376 if ( osverinfo.dwPlatformId == VER_PLATFORM_WIN32_NT &&
377 osverinfo.dwMajorVersion < 5)
378 cursor = 0;
379 }
380 if (cursor)
381 {
382 /* cursor position */
383 /* assume 2 bytes of entropy */
384 CURSORINFO ci;
385 ci.cbSize = sizeof(CURSORINFO);
386 if (cursor(&ci))
387 RAND_add(&ci, ci.cbSize, 2);
388 }
389
390 if (queue)
391 {
392 /* message queue status */
393 /* assume 1 byte of entropy */
394 w = queue(QS_ALLEVENTS);
395 RAND_add(&w, sizeof(w), 1);
396 }
397
398 FreeLibrary(user);
399 }
400
401 /* Toolhelp32 snapshot: enumerate processes, threads, modules and heap
402 * http://msdn.microsoft.com/library/psdk/winbase/toolhelp_5pfd.htm
403 * (Win 9x and 2000 only, not available on NT)
404 *
405 * This seeding method was proposed in Peter Gutmann, Software
406 * Generation of Practically Strong Random Numbers,
407 * http://www.usenix.org/publications/library/proceedings/sec98/gutmann.html
408 * revised version at http://www.cryptoengines.com/~peter/06_random.pdf
409 * (The assignment of entropy estimates below is arbitrary, but based
410 * on Peter's analysis the full poll appears to be safe. Additional
411 * interactive seeding is encouraged.)
412 */
413
414 if (kernel)
415 {
416 CREATETOOLHELP32SNAPSHOT snap;
417 HANDLE handle;
418
419 HEAP32FIRST heap_first;
420 HEAP32NEXT heap_next;
421 HEAP32LIST heaplist_first, heaplist_next;
422 PROCESS32 process_first, process_next;
423 THREAD32 thread_first, thread_next;
424 MODULE32 module_first, module_next;
425
426 HEAPLIST32 hlist;
427 HEAPENTRY32 hentry;
428 PROCESSENTRY32 p;
429 THREADENTRY32 t;
430 MODULEENTRY32 m;
431
432 snap = (CREATETOOLHELP32SNAPSHOT)
433 GetProcAddress(kernel, "CreateToolhelp32Snapshot");
434 heap_first = (HEAP32FIRST) GetProcAddress(kernel, "Heap32First");
435 heap_next = (HEAP32NEXT) GetProcAddress(kernel, "Heap32Next");
436 heaplist_first = (HEAP32LIST) GetProcAddress(kernel, "Heap32ListFirst");
437 heaplist_next = (HEAP32LIST) GetProcAddress(kernel, "Heap32ListNext");
438 process_first = (PROCESS32) GetProcAddress(kernel, "Process32First");
439 process_next = (PROCESS32) GetProcAddress(kernel, "Process32Next");
440 thread_first = (THREAD32) GetProcAddress(kernel, "Thread32First");
441 thread_next = (THREAD32) GetProcAddress(kernel, "Thread32Next");
442 module_first = (MODULE32) GetProcAddress(kernel, "Module32First");
443 module_next = (MODULE32) GetProcAddress(kernel, "Module32Next");
444
445 if (snap && heap_first && heap_next && heaplist_first &&
446 heaplist_next && process_first && process_next &&
447 thread_first && thread_next && module_first &&
448 module_next && (handle = snap(TH32CS_SNAPALL,0))
449 != NULL)
450 {
451 /* heap list and heap walking */
452 /* HEAPLIST32 contains 3 fields that will change with
453 * each entry. Consider each field a source of 1 byte
454 * of entropy.
455 * HEAPENTRY32 contains 5 fields that will change with
456 * each entry. Consider each field a source of 1 byte
457 * of entropy.
458 */
459 hlist.dwSize = sizeof(HEAPLIST32);
460 if (heaplist_first(handle, &hlist))
461 do
462 {
463 RAND_add(&hlist, hlist.dwSize, 3);
464 hentry.dwSize = sizeof(HEAPENTRY32);
465 if (heap_first(&hentry,
466 hlist.th32ProcessID,
467 hlist.th32HeapID))
468 {
469 int entrycnt = 80;
470 do
471 RAND_add(&hentry,
472 hentry.dwSize, 5);
473 while (heap_next(&hentry)
474 && --entrycnt > 0);
475 }
476 } while (heaplist_next(handle,
477 &hlist));
478
479 /* process walking */
480 /* PROCESSENTRY32 contains 9 fields that will change
481 * with each entry. Consider each field a source of
482 * 1 byte of entropy.
483 */
484 p.dwSize = sizeof(PROCESSENTRY32);
485 if (process_first(handle, &p))
486 do
487 RAND_add(&p, p.dwSize, 9);
488 while (process_next(handle, &p));
489
490 /* thread walking */
491 /* THREADENTRY32 contains 6 fields that will change
492 * with each entry. Consider each field a source of
493 * 1 byte of entropy.
494 */
495 t.dwSize = sizeof(THREADENTRY32);
496 if (thread_first(handle, &t))
497 do
498 RAND_add(&t, t.dwSize, 6);
499 while (thread_next(handle, &t));
500
501 /* module walking */
502 /* MODULEENTRY32 contains 9 fields that will change
503 * with each entry. Consider each field a source of
504 * 1 byte of entropy.
505 */
506 m.dwSize = sizeof(MODULEENTRY32);
507 if (module_first(handle, &m))
508 do
509 RAND_add(&m, m.dwSize, 9);
510 while (module_next(handle, &m));
511
512 CloseHandle(handle);
513 }
514
515 FreeLibrary(kernel);
516 }
517
518#if 0
519 printf("Exiting RAND_poll\n");
520#endif
521
522 return(1);
523}
524
525int RAND_event(UINT iMsg, WPARAM wParam, LPARAM lParam)
526 {
527 double add_entropy=0;
528
529 switch (iMsg)
530 {
531 case WM_KEYDOWN:
532 {
533 static WPARAM key;
534 if (key != wParam)
535 add_entropy = 0.05;
536 key = wParam;
537 }
538 break;
539 case WM_MOUSEMOVE:
540 {
541 static int lastx,lasty,lastdx,lastdy;
542 int x,y,dx,dy;
543
544 x=LOWORD(lParam);
545 y=HIWORD(lParam);
546 dx=lastx-x;
547 dy=lasty-y;
548 if (dx != 0 && dy != 0 && dx-lastdx != 0 && dy-lastdy != 0)
549 add_entropy=.2;
550 lastx=x, lasty=y;
551 lastdx=dx, lastdy=dy;
552 }
553 break;
554 }
555
556 readtimer();
557 RAND_add(&iMsg, sizeof(iMsg), add_entropy);
558 RAND_add(&wParam, sizeof(wParam), 0);
559 RAND_add(&lParam, sizeof(lParam), 0);
560
561 return (RAND_status());
562 }
563
564
565void RAND_screen(void) /* function available for backward compatibility */
566{
567 RAND_poll();
568 readscreen();
569}
570
571
572/* feed timing information to the PRNG */
573static void readtimer(void)
574{
575 DWORD w;
576 LARGE_INTEGER l;
577 static int have_perfc = 1;
578#ifdef _MSC_VER
579 static int have_tsc = 1;
580 DWORD cyclecount;
581
582 if (have_tsc) {
583 __try {
584 __asm {
585 _emit 0x0f
586 _emit 0x31
587 mov cyclecount, eax
588 }
589 RAND_add(&cyclecount, sizeof(cyclecount), 1);
590 } __except(EXCEPTION_EXECUTE_HANDLER) {
591 have_tsc = 0;
592 }
593 }
594#else
595# define have_tsc 0
596#endif
597
598 if (have_perfc) {
599 if (QueryPerformanceCounter(&l) == 0)
600 have_perfc = 0;
601 else
602 RAND_add(&l, sizeof(l), 0);
603 }
604
605 if (!have_tsc && !have_perfc) {
606 w = GetTickCount();
607 RAND_add(&w, sizeof(w), 0);
608 }
609}
610
611/* feed screen contents to PRNG */
612/*****************************************************************************
613 *
614 * Created 960901 by Gertjan van Oosten, gertjan@West.NL, West Consulting B.V.
615 *
616 * Code adapted from
617 * <URL:http://www.microsoft.com/kb/developr/win_dk/q97193.htm>;
618 * the original copyright message is:
619 *
620 * (C) Copyright Microsoft Corp. 1993. All rights reserved.
621 *
622 * You have a royalty-free right to use, modify, reproduce and
623 * distribute the Sample Files (and/or any modified version) in
624 * any way you find useful, provided that you agree that
625 * Microsoft has no warranty obligations or liability for any
626 * Sample Application Files which are modified.
627 */
628
629static void readscreen(void)
630{
631 HDC hScrDC; /* screen DC */
632 HDC hMemDC; /* memory DC */
633 HBITMAP hBitmap; /* handle for our bitmap */
634 HBITMAP hOldBitmap; /* handle for previous bitmap */
635 BITMAP bm; /* bitmap properties */
636 unsigned int size; /* size of bitmap */
637 char *bmbits; /* contents of bitmap */
638 int w; /* screen width */
639 int h; /* screen height */
640 int y; /* y-coordinate of screen lines to grab */
641 int n = 16; /* number of screen lines to grab at a time */
642
643 /* Create a screen DC and a memory DC compatible to screen DC */
644 hScrDC = CreateDC("DISPLAY", NULL, NULL, NULL);
645 hMemDC = CreateCompatibleDC(hScrDC);
646
647 /* Get screen resolution */
648 w = GetDeviceCaps(hScrDC, HORZRES);
649 h = GetDeviceCaps(hScrDC, VERTRES);
650
651 /* Create a bitmap compatible with the screen DC */
652 hBitmap = CreateCompatibleBitmap(hScrDC, w, n);
653
654 /* Select new bitmap into memory DC */
655 hOldBitmap = SelectObject(hMemDC, hBitmap);
656
657 /* Get bitmap properties */
658 GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&bm);
659 size = (unsigned int)bm.bmWidthBytes * bm.bmHeight * bm.bmPlanes;
660
661 bmbits = OPENSSL_malloc(size);
662 if (bmbits) {
663 /* Now go through the whole screen, repeatedly grabbing n lines */
664 for (y = 0; y < h-n; y += n)
665 {
666 unsigned char md[MD_DIGEST_LENGTH];
667
668 /* Bitblt screen DC to memory DC */
669 BitBlt(hMemDC, 0, 0, w, n, hScrDC, 0, y, SRCCOPY);
670
671 /* Copy bitmap bits from memory DC to bmbits */
672 GetBitmapBits(hBitmap, size, bmbits);
673
674 /* Get the hash of the bitmap */
675 MD(bmbits,size,md);
676
677 /* Seed the random generator with the hash value */
678 RAND_add(md, MD_DIGEST_LENGTH, 0);
679 }
680
681 OPENSSL_free(bmbits);
682 }
683
684 /* Select old bitmap back into memory DC */
685 hBitmap = SelectObject(hMemDC, hOldBitmap);
686
687 /* Clean up */
688 DeleteObject(hBitmap);
689 DeleteDC(hMemDC);
690 DeleteDC(hScrDC);
691}
692
693#endif
diff --git a/src/lib/libcrypto/rand/randfile.c b/src/lib/libcrypto/rand/randfile.c
index 41574768ab..311dd27a7b 100644
--- a/src/lib/libcrypto/rand/randfile.c
+++ b/src/lib/libcrypto/rand/randfile.c
@@ -106,6 +106,14 @@ int RAND_load_file(const char *file, long bytes)
106 106
107 in=fopen(file,"rb"); 107 in=fopen(file,"rb");
108 if (in == NULL) goto err; 108 if (in == NULL) goto err;
109 if (sb.st_mode & (S_IFBLK | S_IFCHR)) {
110 /* this file is a device. we don't want read an infinite number
111 * of bytes from a random device, nor do we want to use buffered
112 * I/O because we will waste system entropy.
113 */
114 bytes = (bytes == -1) ? 2048 : bytes; /* ok, is 2048 enough? */
115 setvbuf(in, NULL, _IONBF, 0); /* don't do buffered reads */
116 }
109 for (;;) 117 for (;;)
110 { 118 {
111 if (bytes > 0) 119 if (bytes > 0)
@@ -124,7 +132,7 @@ int RAND_load_file(const char *file, long bytes)
124 } 132 }
125 } 133 }
126 fclose(in); 134 fclose(in);
127 OPENSSL_cleanse(buf,BUFSIZE); 135 memset(buf,0,BUFSIZE);
128err: 136err:
129 return(ret); 137 return(ret);
130 } 138 }
@@ -135,7 +143,20 @@ int RAND_write_file(const char *file)
135 int i,ret=0,rand_err=0; 143 int i,ret=0,rand_err=0;
136 FILE *out = NULL; 144 FILE *out = NULL;
137 int n; 145 int n;
146 struct stat sb;
138 147
148 i=stat(file,&sb);
149 if (i != -1) {
150 if (sb.st_mode & (S_IFBLK | S_IFCHR)) {
151 /* this file is a device. we don't write back to it.
152 * we "succeed" on the assumption this is some sort
153 * of random device. Otherwise attempting to write to
154 * and chmod the device causes problems.
155 */
156 return(1);
157 }
158 }
159
139#if defined(O_CREAT) && !defined(OPENSSL_SYS_WIN32) 160#if defined(O_CREAT) && !defined(OPENSSL_SYS_WIN32)
140 /* For some reason Win32 can't write to files created this way */ 161 /* For some reason Win32 can't write to files created this way */
141 162
@@ -189,7 +210,7 @@ int RAND_write_file(const char *file)
189#endif /* OPENSSL_SYS_VMS */ 210#endif /* OPENSSL_SYS_VMS */
190 211
191 fclose(out); 212 fclose(out);
192 OPENSSL_cleanse(buf,BUFSIZE); 213 memset(buf,0,BUFSIZE);
193err: 214err:
194 return (rand_err ? -1 : ret); 215 return (rand_err ? -1 : ret);
195 } 216 }
@@ -197,20 +218,19 @@ err:
197const char *RAND_file_name(char *buf, size_t size) 218const char *RAND_file_name(char *buf, size_t size)
198 { 219 {
199 char *s=NULL; 220 char *s=NULL;
200 char *ret=NULL; 221 int ok = 0;
222 struct stat sb;
201 223
202 if (OPENSSL_issetugid() == 0) 224 if (issetugid() == 0)
203 s=getenv("RANDFILE"); 225 s=getenv("RANDFILE");
204 if (s != NULL) 226 if (s != NULL && *s && strlen(s) + 1 < size)
205 { 227 {
206 if(strlen(s) >= size) 228 strlcpy(buf,s,size);
207 return NULL; 229 ok = 1;
208 strcpy(buf,s);
209 ret=buf;
210 } 230 }
211 else 231 else
212 { 232 {
213 if (OPENSSL_issetugid() == 0) 233 if (issetugid() == 0)
214 s=getenv("HOME"); 234 s=getenv("HOME");
215#ifdef DEFAULT_HOME 235#ifdef DEFAULT_HOME
216 if (s == NULL) 236 if (s == NULL)
@@ -218,17 +238,36 @@ const char *RAND_file_name(char *buf, size_t size)
218 s = DEFAULT_HOME; 238 s = DEFAULT_HOME;
219 } 239 }
220#endif 240#endif
221 if (s != NULL && (strlen(s)+strlen(RFILE)+2 < size)) 241 if (s && *s && strlen(s)+strlen(RFILE)+2 < size)
222 { 242 {
223 strcpy(buf,s); 243 strlcpy(buf,s,size);
224#ifndef OPENSSL_SYS_VMS 244#ifndef OPENSSL_SYS_VMS
225 strcat(buf,"/"); 245 strlcat(buf,"/",size);
226#endif 246#endif
227 strcat(buf,RFILE); 247 strlcat(buf,RFILE,size);
228 ret=buf; 248 ok = 1;
229 } 249 }
230 else 250 else
231 buf[0] = '\0'; /* no file name */ 251 buf[0] = '\0'; /* no file name */
232 } 252 }
233 return(ret); 253
254#ifdef __OpenBSD__
255 /* given that all random loads just fail if the file can't be
256 * seen on a stat, we stat the file we're returning, if it
257 * fails, use /dev/arandom instead. this allows the user to
258 * use their own source for good random data, but defaults
259 * to something hopefully decent if that isn't available.
260 */
261
262 if (!ok)
263 if (strlcpy(buf,"/dev/arandom",size) >= size) {
264 return(NULL);
265 }
266 if (stat(buf,&sb) == -1)
267 if (strlcpy(buf,"/dev/arandom",size) >= size) {
268 return(NULL);
269 }
270
271#endif
272 return(buf);
234 } 273 }
diff --git a/src/lib/libcrypto/rand/randtest.c b/src/lib/libcrypto/rand/randtest.c
new file mode 100644
index 0000000000..b64de616db
--- /dev/null
+++ b/src/lib/libcrypto/rand/randtest.c
@@ -0,0 +1,214 @@
1/* crypto/rand/randtest.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <stdlib.h>
61#include <openssl/rand.h>
62
63/* some FIPS 140-1 random number test */
64/* some simple tests */
65
66int main()
67 {
68 unsigned char buf[2500];
69 int i,j,k,s,sign,nsign,err=0;
70 unsigned long n1;
71 unsigned long n2[16];
72 unsigned long runs[2][34];
73 /*double d; */
74 long d;
75
76 i = RAND_pseudo_bytes(buf,2500);
77 if (i < 0)
78 {
79 printf ("init failed, the rand method is not properly installed\n");
80 err++;
81 goto err;
82 }
83
84 n1=0;
85 for (i=0; i<16; i++) n2[i]=0;
86 for (i=0; i<34; i++) runs[0][i]=runs[1][i]=0;
87
88 /* test 1 and 2 */
89 sign=0;
90 nsign=0;
91 for (i=0; i<2500; i++)
92 {
93 j=buf[i];
94
95 n2[j&0x0f]++;
96 n2[(j>>4)&0x0f]++;
97
98 for (k=0; k<8; k++)
99 {
100 s=(j&0x01);
101 if (s == sign)
102 nsign++;
103 else
104 {
105 if (nsign > 34) nsign=34;
106 if (nsign != 0)
107 {
108 runs[sign][nsign-1]++;
109 if (nsign > 6)
110 runs[sign][5]++;
111 }
112 sign=s;
113 nsign=1;
114 }
115
116 if (s) n1++;
117 j>>=1;
118 }
119 }
120 if (nsign > 34) nsign=34;
121 if (nsign != 0) runs[sign][nsign-1]++;
122
123 /* test 1 */
124 if (!((9654 < n1) && (n1 < 10346)))
125 {
126 printf("test 1 failed, X=%lu\n",n1);
127 err++;
128 }
129 printf("test 1 done\n");
130
131 /* test 2 */
132#ifdef undef
133 d=0;
134 for (i=0; i<16; i++)
135 d+=n2[i]*n2[i];
136 d=d*16.0/5000.0-5000.0;
137 if (!((1.03 < d) && (d < 57.4)))
138 {
139 printf("test 2 failed, X=%.2f\n",d);
140 err++;
141 }
142#endif
143 d=0;
144 for (i=0; i<16; i++)
145 d+=n2[i]*n2[i];
146 d=(d*8)/25-500000;
147 if (!((103 < d) && (d < 5740)))
148 {
149 printf("test 2 failed, X=%ld.%02ld\n",d/100L,d%100L);
150 err++;
151 }
152 printf("test 2 done\n");
153
154 /* test 3 */
155 for (i=0; i<2; i++)
156 {
157 if (!((2267 < runs[i][0]) && (runs[i][0] < 2733)))
158 {
159 printf("test 3 failed, bit=%d run=%d num=%lu\n",
160 i,1,runs[i][0]);
161 err++;
162 }
163 if (!((1079 < runs[i][1]) && (runs[i][1] < 1421)))
164 {
165 printf("test 3 failed, bit=%d run=%d num=%lu\n",
166 i,2,runs[i][1]);
167 err++;
168 }
169 if (!(( 502 < runs[i][2]) && (runs[i][2] < 748)))
170 {
171 printf("test 3 failed, bit=%d run=%d num=%lu\n",
172 i,3,runs[i][2]);
173 err++;
174 }
175 if (!(( 223 < runs[i][3]) && (runs[i][3] < 402)))
176 {
177 printf("test 3 failed, bit=%d run=%d num=%lu\n",
178 i,4,runs[i][3]);
179 err++;
180 }
181 if (!(( 90 < runs[i][4]) && (runs[i][4] < 223)))
182 {
183 printf("test 3 failed, bit=%d run=%d num=%lu\n",
184 i,5,runs[i][4]);
185 err++;
186 }
187 if (!(( 90 < runs[i][5]) && (runs[i][5] < 223)))
188 {
189 printf("test 3 failed, bit=%d run=%d num=%lu\n",
190 i,6,runs[i][5]);
191 err++;
192 }
193 }
194 printf("test 3 done\n");
195
196 /* test 4 */
197 if (runs[0][33] != 0)
198 {
199 printf("test 4 failed, bit=%d run=%d num=%lu\n",
200 0,34,runs[0][33]);
201 err++;
202 }
203 if (runs[1][33] != 0)
204 {
205 printf("test 4 failed, bit=%d run=%d num=%lu\n",
206 1,34,runs[1][33]);
207 err++;
208 }
209 printf("test 4 done\n");
210 err:
211 err=((err)?1:0);
212 exit(err);
213 return(err);
214 }
diff --git a/src/lib/libcrypto/rc2/Makefile.ssl b/src/lib/libcrypto/rc2/Makefile.ssl
new file mode 100644
index 0000000000..88e41bb98e
--- /dev/null
+++ b/src/lib/libcrypto/rc2/Makefile.ssl
@@ -0,0 +1,91 @@
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/rc2speed.c b/src/lib/libcrypto/rc2/rc2speed.c
new file mode 100644
index 0000000000..47d34b444e
--- /dev/null
+++ b/src/lib/libcrypto/rc2/rc2speed.c
@@ -0,0 +1,274 @@
1/* crypto/rc2/rc2speed.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/* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */
60/* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */
61
62#if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX)
63#define TIMES
64#endif
65
66#include <stdio.h>
67
68#include <openssl/e_os2.h>
69#include OPENSSL_UNISTD_IO
70OPENSSL_DECLARE_EXIT
71
72#include <signal.h>
73#ifndef _IRIX
74#include <time.h>
75#endif
76#ifdef TIMES
77#include <sys/types.h>
78#include <sys/times.h>
79#endif
80
81/* Depending on the VMS version, the tms structure is perhaps defined.
82 The __TMS macro will show if it was. If it wasn't defined, we should
83 undefine TIMES, since that tells the rest of the program how things
84 should be handled. -- Richard Levitte */
85#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
86#undef TIMES
87#endif
88
89#ifndef TIMES
90#include <sys/timeb.h>
91#endif
92
93#if defined(sun) || defined(__ultrix)
94#define _POSIX_SOURCE
95#include <limits.h>
96#include <sys/param.h>
97#endif
98
99#include <openssl/rc2.h>
100
101/* The following if from times(3) man page. It may need to be changed */
102#ifndef HZ
103#ifndef CLK_TCK
104#define HZ 100.0
105#endif
106#else /* CLK_TCK */
107#define HZ ((double)CLK_TCK)
108#endif
109
110#define BUFSIZE ((long)1024)
111long run=0;
112
113double Time_F(int s);
114#ifdef SIGALRM
115#if defined(__STDC__) || defined(sgi) || defined(_AIX)
116#define SIGRETTYPE void
117#else
118#define SIGRETTYPE int
119#endif
120
121SIGRETTYPE sig_done(int sig);
122SIGRETTYPE sig_done(int sig)
123 {
124 signal(SIGALRM,sig_done);
125 run=0;
126#ifdef LINT
127 sig=sig;
128#endif
129 }
130#endif
131
132#define START 0
133#define STOP 1
134
135double Time_F(int s)
136 {
137 double ret;
138#ifdef TIMES
139 static struct tms tstart,tend;
140
141 if (s == START)
142 {
143 times(&tstart);
144 return(0);
145 }
146 else
147 {
148 times(&tend);
149 ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
150 return((ret == 0.0)?1e-6:ret);
151 }
152#else /* !times() */
153 static struct timeb tstart,tend;
154 long i;
155
156 if (s == START)
157 {
158 ftime(&tstart);
159 return(0);
160 }
161 else
162 {
163 ftime(&tend);
164 i=(long)tend.millitm-(long)tstart.millitm;
165 ret=((double)(tend.time-tstart.time))+((double)i)/1e3;
166 return((ret == 0.0)?1e-6:ret);
167 }
168#endif
169 }
170
171int main(int argc, char **argv)
172 {
173 long count;
174 static unsigned char buf[BUFSIZE];
175 static unsigned char key[] ={
176 0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
177 0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10,
178 };
179 RC2_KEY sch;
180 double a,b,c,d;
181#ifndef SIGALRM
182 long ca,cb,cc;
183#endif
184
185#ifndef TIMES
186 printf("To get the most accurate results, try to run this\n");
187 printf("program when this computer is idle.\n");
188#endif
189
190#ifndef SIGALRM
191 printf("First we calculate the approximate speed ...\n");
192 RC2_set_key(&sch,16,key,128);
193 count=10;
194 do {
195 long i;
196 unsigned long data[2];
197
198 count*=2;
199 Time_F(START);
200 for (i=count; i; i--)
201 RC2_encrypt(data,&sch);
202 d=Time_F(STOP);
203 } while (d < 3.0);
204 ca=count/512;
205 cb=count;
206 cc=count*8/BUFSIZE+1;
207 printf("Doing RC2_set_key %ld times\n",ca);
208#define COND(d) (count != (d))
209#define COUNT(d) (d)
210#else
211#define COND(c) (run)
212#define COUNT(d) (count)
213 signal(SIGALRM,sig_done);
214 printf("Doing RC2_set_key for 10 seconds\n");
215 alarm(10);
216#endif
217
218 Time_F(START);
219 for (count=0,run=1; COND(ca); count+=4)
220 {
221 RC2_set_key(&sch,16,key,128);
222 RC2_set_key(&sch,16,key,128);
223 RC2_set_key(&sch,16,key,128);
224 RC2_set_key(&sch,16,key,128);
225 }
226 d=Time_F(STOP);
227 printf("%ld RC2_set_key's in %.2f seconds\n",count,d);
228 a=((double)COUNT(ca))/d;
229
230#ifdef SIGALRM
231 printf("Doing RC2_encrypt's for 10 seconds\n");
232 alarm(10);
233#else
234 printf("Doing RC2_encrypt %ld times\n",cb);
235#endif
236 Time_F(START);
237 for (count=0,run=1; COND(cb); count+=4)
238 {
239 unsigned long data[2];
240
241 RC2_encrypt(data,&sch);
242 RC2_encrypt(data,&sch);
243 RC2_encrypt(data,&sch);
244 RC2_encrypt(data,&sch);
245 }
246 d=Time_F(STOP);
247 printf("%ld RC2_encrypt's in %.2f second\n",count,d);
248 b=((double)COUNT(cb)*8)/d;
249
250#ifdef SIGALRM
251 printf("Doing RC2_cbc_encrypt on %ld byte blocks for 10 seconds\n",
252 BUFSIZE);
253 alarm(10);
254#else
255 printf("Doing RC2_cbc_encrypt %ld times on %ld byte blocks\n",cc,
256 BUFSIZE);
257#endif
258 Time_F(START);
259 for (count=0,run=1; COND(cc); count++)
260 RC2_cbc_encrypt(buf,buf,BUFSIZE,&sch,
261 &(key[0]),RC2_ENCRYPT);
262 d=Time_F(STOP);
263 printf("%ld RC2_cbc_encrypt's of %ld byte blocks in %.2f second\n",
264 count,BUFSIZE,d);
265 c=((double)COUNT(cc)*BUFSIZE)/d;
266
267 printf("RC2 set_key per sec = %12.2f (%9.3fuS)\n",a,1.0e6/a);
268 printf("RC2 raw ecb bytes per sec = %12.2f (%9.3fuS)\n",b,8.0e6/b);
269 printf("RC2 cbc bytes per sec = %12.2f (%9.3fuS)\n",c,8.0e6/c);
270 exit(0);
271#if defined(LINT) || defined(OPENSSL_SYS_MSDOS)
272 return(0);
273#endif
274 }
diff --git a/src/lib/libcrypto/rc2/rc2test.c b/src/lib/libcrypto/rc2/rc2test.c
new file mode 100644
index 0000000000..d9a2a0a1cb
--- /dev/null
+++ b/src/lib/libcrypto/rc2/rc2test.c
@@ -0,0 +1,269 @@
1/* crypto/rc2/rc2test.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/* This has been a quickly hacked 'ideatest.c'. When I add tests for other
60 * RC2 modes, more of the code will be uncommented. */
61
62#include <stdio.h>
63#include <string.h>
64#include <stdlib.h>
65
66#ifdef OPENSSL_NO_RC2
67int main(int argc, char *argv[])
68{
69 printf("No RC2 support\n");
70 return(0);
71}
72#else
73#include <openssl/rc2.h>
74
75static unsigned char RC2key[4][16]={
76 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
77 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
78 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
79 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01},
80 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
81 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
82 {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
83 0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F},
84 };
85
86static unsigned char RC2plain[4][8]={
87 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
88 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
89 {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},
90 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
91 };
92
93static unsigned char RC2cipher[4][8]={
94 {0x1C,0x19,0x8A,0x83,0x8D,0xF0,0x28,0xB7},
95 {0x21,0x82,0x9C,0x78,0xA9,0xF9,0xC0,0x74},
96 {0x13,0xDB,0x35,0x17,0xD3,0x21,0x86,0x9E},
97 {0x50,0xDC,0x01,0x62,0xBD,0x75,0x7F,0x31},
98 };
99/************/
100#ifdef undef
101unsigned char k[16]={
102 0x00,0x01,0x00,0x02,0x00,0x03,0x00,0x04,
103 0x00,0x05,0x00,0x06,0x00,0x07,0x00,0x08};
104
105unsigned char in[8]={0x00,0x00,0x00,0x01,0x00,0x02,0x00,0x03};
106unsigned char c[8]={0x11,0xFB,0xED,0x2B,0x01,0x98,0x6D,0xE5};
107unsigned char out[80];
108
109char *text="Hello to all people out there";
110
111static unsigned char cfb_key[16]={
112 0xe1,0xf0,0xc3,0xd2,0xa5,0xb4,0x87,0x96,
113 0x69,0x78,0x4b,0x5a,0x2d,0x3c,0x0f,0x1e,
114 };
115static unsigned char cfb_iv[80]={0x34,0x12,0x78,0x56,0xab,0x90,0xef,0xcd};
116static unsigned char cfb_buf1[40],cfb_buf2[40],cfb_tmp[8];
117#define CFB_TEST_SIZE 24
118static unsigned char plain[CFB_TEST_SIZE]=
119 {
120 0x4e,0x6f,0x77,0x20,0x69,0x73,
121 0x20,0x74,0x68,0x65,0x20,0x74,
122 0x69,0x6d,0x65,0x20,0x66,0x6f,
123 0x72,0x20,0x61,0x6c,0x6c,0x20
124 };
125static unsigned char cfb_cipher64[CFB_TEST_SIZE]={
126 0x59,0xD8,0xE2,0x65,0x00,0x58,0x6C,0x3F,
127 0x2C,0x17,0x25,0xD0,0x1A,0x38,0xB7,0x2A,
128 0x39,0x61,0x37,0xDC,0x79,0xFB,0x9F,0x45
129
130/* 0xF9,0x78,0x32,0xB5,0x42,0x1A,0x6B,0x38,
131 0x9A,0x44,0xD6,0x04,0x19,0x43,0xC4,0xD9,
132 0x3D,0x1E,0xAE,0x47,0xFC,0xCF,0x29,0x0B,*/
133 };
134
135
136/*static int cfb64_test(unsigned char *cfb_cipher);*/
137static char *pt(unsigned char *p);
138#endif
139
140int main(int argc, char *argv[])
141 {
142 int i,n,err=0;
143 RC2_KEY key;
144 unsigned char buf[8],buf2[8];
145
146 for (n=0; n<4; n++)
147 {
148 RC2_set_key(&key,16,&(RC2key[n][0]),0 /* or 1024 */);
149
150 RC2_ecb_encrypt(&(RC2plain[n][0]),buf,&key,RC2_ENCRYPT);
151 if (memcmp(&(RC2cipher[n][0]),buf,8) != 0)
152 {
153 printf("ecb rc2 error encrypting\n");
154 printf("got :");
155 for (i=0; i<8; i++)
156 printf("%02X ",buf[i]);
157 printf("\n");
158 printf("expected:");
159 for (i=0; i<8; i++)
160 printf("%02X ",RC2cipher[n][i]);
161 err=20;
162 printf("\n");
163 }
164
165 RC2_ecb_encrypt(buf,buf2,&key,RC2_DECRYPT);
166 if (memcmp(&(RC2plain[n][0]),buf2,8) != 0)
167 {
168 printf("ecb RC2 error decrypting\n");
169 printf("got :");
170 for (i=0; i<8; i++)
171 printf("%02X ",buf[i]);
172 printf("\n");
173 printf("expected:");
174 for (i=0; i<8; i++)
175 printf("%02X ",RC2plain[n][i]);
176 printf("\n");
177 err=3;
178 }
179 }
180
181 if (err == 0) printf("ecb RC2 ok\n");
182#ifdef undef
183 memcpy(iv,k,8);
184 idea_cbc_encrypt((unsigned char *)text,out,strlen(text)+1,&key,iv,1);
185 memcpy(iv,k,8);
186 idea_cbc_encrypt(out,out,8,&dkey,iv,0);
187 idea_cbc_encrypt(&(out[8]),&(out[8]),strlen(text)+1-8,&dkey,iv,0);
188 if (memcmp(text,out,strlen(text)+1) != 0)
189 {
190 printf("cbc idea bad\n");
191 err=4;
192 }
193 else
194 printf("cbc idea ok\n");
195
196 printf("cfb64 idea ");
197 if (cfb64_test(cfb_cipher64))
198 {
199 printf("bad\n");
200 err=5;
201 }
202 else
203 printf("ok\n");
204#endif
205
206 exit(err);
207 return(err);
208 }
209
210#ifdef undef
211static int cfb64_test(unsigned char *cfb_cipher)
212 {
213 IDEA_KEY_SCHEDULE eks,dks;
214 int err=0,i,n;
215
216 idea_set_encrypt_key(cfb_key,&eks);
217 idea_set_decrypt_key(&eks,&dks);
218 memcpy(cfb_tmp,cfb_iv,8);
219 n=0;
220 idea_cfb64_encrypt(plain,cfb_buf1,(long)12,&eks,
221 cfb_tmp,&n,IDEA_ENCRYPT);
222 idea_cfb64_encrypt(&(plain[12]),&(cfb_buf1[12]),
223 (long)CFB_TEST_SIZE-12,&eks,
224 cfb_tmp,&n,IDEA_ENCRYPT);
225 if (memcmp(cfb_cipher,cfb_buf1,CFB_TEST_SIZE) != 0)
226 {
227 err=1;
228 printf("idea_cfb64_encrypt encrypt error\n");
229 for (i=0; i<CFB_TEST_SIZE; i+=8)
230 printf("%s\n",pt(&(cfb_buf1[i])));
231 }
232 memcpy(cfb_tmp,cfb_iv,8);
233 n=0;
234 idea_cfb64_encrypt(cfb_buf1,cfb_buf2,(long)17,&eks,
235 cfb_tmp,&n,IDEA_DECRYPT);
236 idea_cfb64_encrypt(&(cfb_buf1[17]),&(cfb_buf2[17]),
237 (long)CFB_TEST_SIZE-17,&dks,
238 cfb_tmp,&n,IDEA_DECRYPT);
239 if (memcmp(plain,cfb_buf2,CFB_TEST_SIZE) != 0)
240 {
241 err=1;
242 printf("idea_cfb_encrypt decrypt error\n");
243 for (i=0; i<24; i+=8)
244 printf("%s\n",pt(&(cfb_buf2[i])));
245 }
246 return(err);
247 }
248
249static char *pt(unsigned char *p)
250 {
251 static char bufs[10][20];
252 static int bnum=0;
253 char *ret;
254 int i;
255 static char *f="0123456789ABCDEF";
256
257 ret= &(bufs[bnum++][0]);
258 bnum%=10;
259 for (i=0; i<8; i++)
260 {
261 ret[i*2]=f[(p[i]>>4)&0xf];
262 ret[i*2+1]=f[p[i]&0xf];
263 }
264 ret[16]='\0';
265 return(ret);
266 }
267
268#endif
269#endif
diff --git a/src/lib/libcrypto/rc2/tab.c b/src/lib/libcrypto/rc2/tab.c
new file mode 100644
index 0000000000..25dc14eeba
--- /dev/null
+++ b/src/lib/libcrypto/rc2/tab.c
@@ -0,0 +1,86 @@
1#include <stdio.h>
2
3unsigned char ebits_to_num[256]={
4 0xbd,0x56,0xea,0xf2,0xa2,0xf1,0xac,0x2a,
5 0xb0,0x93,0xd1,0x9c,0x1b,0x33,0xfd,0xd0,
6 0x30,0x04,0xb6,0xdc,0x7d,0xdf,0x32,0x4b,
7 0xf7,0xcb,0x45,0x9b,0x31,0xbb,0x21,0x5a,
8 0x41,0x9f,0xe1,0xd9,0x4a,0x4d,0x9e,0xda,
9 0xa0,0x68,0x2c,0xc3,0x27,0x5f,0x80,0x36,
10 0x3e,0xee,0xfb,0x95,0x1a,0xfe,0xce,0xa8,
11 0x34,0xa9,0x13,0xf0,0xa6,0x3f,0xd8,0x0c,
12 0x78,0x24,0xaf,0x23,0x52,0xc1,0x67,0x17,
13 0xf5,0x66,0x90,0xe7,0xe8,0x07,0xb8,0x60,
14 0x48,0xe6,0x1e,0x53,0xf3,0x92,0xa4,0x72,
15 0x8c,0x08,0x15,0x6e,0x86,0x00,0x84,0xfa,
16 0xf4,0x7f,0x8a,0x42,0x19,0xf6,0xdb,0xcd,
17 0x14,0x8d,0x50,0x12,0xba,0x3c,0x06,0x4e,
18 0xec,0xb3,0x35,0x11,0xa1,0x88,0x8e,0x2b,
19 0x94,0x99,0xb7,0x71,0x74,0xd3,0xe4,0xbf,
20 0x3a,0xde,0x96,0x0e,0xbc,0x0a,0xed,0x77,
21 0xfc,0x37,0x6b,0x03,0x79,0x89,0x62,0xc6,
22 0xd7,0xc0,0xd2,0x7c,0x6a,0x8b,0x22,0xa3,
23 0x5b,0x05,0x5d,0x02,0x75,0xd5,0x61,0xe3,
24 0x18,0x8f,0x55,0x51,0xad,0x1f,0x0b,0x5e,
25 0x85,0xe5,0xc2,0x57,0x63,0xca,0x3d,0x6c,
26 0xb4,0xc5,0xcc,0x70,0xb2,0x91,0x59,0x0d,
27 0x47,0x20,0xc8,0x4f,0x58,0xe0,0x01,0xe2,
28 0x16,0x38,0xc4,0x6f,0x3b,0x0f,0x65,0x46,
29 0xbe,0x7e,0x2d,0x7b,0x82,0xf9,0x40,0xb5,
30 0x1d,0x73,0xf8,0xeb,0x26,0xc7,0x87,0x97,
31 0x25,0x54,0xb1,0x28,0xaa,0x98,0x9d,0xa5,
32 0x64,0x6d,0x7a,0xd4,0x10,0x81,0x44,0xef,
33 0x49,0xd6,0xae,0x2e,0xdd,0x76,0x5c,0x2f,
34 0xa7,0x1c,0xc9,0x09,0x69,0x9a,0x83,0xcf,
35 0x29,0x39,0xb9,0xe9,0x4c,0xff,0x43,0xab,
36 };
37
38unsigned char num_to_ebits[256]={
39 0x5d,0xbe,0x9b,0x8b,0x11,0x99,0x6e,0x4d,
40 0x59,0xf3,0x85,0xa6,0x3f,0xb7,0x83,0xc5,
41 0xe4,0x73,0x6b,0x3a,0x68,0x5a,0xc0,0x47,
42 0xa0,0x64,0x34,0x0c,0xf1,0xd0,0x52,0xa5,
43 0xb9,0x1e,0x96,0x43,0x41,0xd8,0xd4,0x2c,
44 0xdb,0xf8,0x07,0x77,0x2a,0xca,0xeb,0xef,
45 0x10,0x1c,0x16,0x0d,0x38,0x72,0x2f,0x89,
46 0xc1,0xf9,0x80,0xc4,0x6d,0xae,0x30,0x3d,
47 0xce,0x20,0x63,0xfe,0xe6,0x1a,0xc7,0xb8,
48 0x50,0xe8,0x24,0x17,0xfc,0x25,0x6f,0xbb,
49 0x6a,0xa3,0x44,0x53,0xd9,0xa2,0x01,0xab,
50 0xbc,0xb6,0x1f,0x98,0xee,0x9a,0xa7,0x2d,
51 0x4f,0x9e,0x8e,0xac,0xe0,0xc6,0x49,0x46,
52 0x29,0xf4,0x94,0x8a,0xaf,0xe1,0x5b,0xc3,
53 0xb3,0x7b,0x57,0xd1,0x7c,0x9c,0xed,0x87,
54 0x40,0x8c,0xe2,0xcb,0x93,0x14,0xc9,0x61,
55 0x2e,0xe5,0xcc,0xf6,0x5e,0xa8,0x5c,0xd6,
56 0x75,0x8d,0x62,0x95,0x58,0x69,0x76,0xa1,
57 0x4a,0xb5,0x55,0x09,0x78,0x33,0x82,0xd7,
58 0xdd,0x79,0xf5,0x1b,0x0b,0xde,0x26,0x21,
59 0x28,0x74,0x04,0x97,0x56,0xdf,0x3c,0xf0,
60 0x37,0x39,0xdc,0xff,0x06,0xa4,0xea,0x42,
61 0x08,0xda,0xb4,0x71,0xb0,0xcf,0x12,0x7a,
62 0x4e,0xfa,0x6c,0x1d,0x84,0x00,0xc8,0x7f,
63 0x91,0x45,0xaa,0x2b,0xc2,0xb1,0x8f,0xd5,
64 0xba,0xf2,0xad,0x19,0xb2,0x67,0x36,0xf7,
65 0x0f,0x0a,0x92,0x7d,0xe3,0x9d,0xe9,0x90,
66 0x3e,0x23,0x27,0x66,0x13,0xec,0x81,0x15,
67 0xbd,0x22,0xbf,0x9f,0x7e,0xa9,0x51,0x4b,
68 0x4c,0xfb,0x02,0xd3,0x70,0x86,0x31,0xe7,
69 0x3b,0x05,0x03,0x54,0x60,0x48,0x65,0x18,
70 0xd2,0xcd,0x5f,0x32,0x88,0x0e,0x35,0xfd,
71 };
72
73main()
74 {
75 int i,j;
76
77 for (i=0; i<256; i++)
78 {
79 for (j=0; j<256; j++)
80 if (ebits_to_num[j] == i)
81 {
82 printf("0x%02x,",j);
83 break;
84 }
85 }
86 }
diff --git a/src/lib/libcrypto/rc4/Makefile.ssl b/src/lib/libcrypto/rc4/Makefile.ssl
new file mode 100644
index 0000000000..6e5bbf9894
--- /dev/null
+++ b/src/lib/libcrypto/rc4/Makefile.ssl
@@ -0,0 +1,115 @@
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)
28
29GENERAL=Makefile
30TEST=rc4test.c
31APPS=
32
33LIB=$(TOP)/libcrypto.a
34LIBSRC=rc4_skey.c rc4_enc.c
35LIBOBJ=rc4_skey.o $(RC4_ENC)
36
37SRC= $(LIBSRC)
38
39EXHEADER= rc4.h
40HEADER= $(EXHEADER) rc4_locl.h
41
42ALL= $(GENERAL) $(SRC) $(HEADER)
43
44top:
45 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
46
47all: lib
48
49lib: $(LIBOBJ)
50 $(AR) $(LIB) $(LIBOBJ)
51 $(RANLIB) $(LIB) || echo Never mind.
52 @touch lib
53
54# elf
55asm/rx86-elf.o: asm/rx86unix.cpp
56 $(CPP) -DELF -x c asm/rx86unix.cpp | as -o asm/rx86-elf.o
57
58# solaris
59asm/rx86-sol.o: asm/rx86unix.cpp
60 $(CC) -E -DSOL asm/rx86unix.cpp | sed 's/^#.*//' > asm/rx86-sol.s
61 as -o asm/rx86-sol.o asm/rx86-sol.s
62 rm -f asm/rx86-sol.s
63
64# a.out
65asm/rx86-out.o: asm/rx86unix.cpp
66 $(CPP) -DOUT asm/rx86unix.cpp | as -o asm/rx86-out.o
67
68# bsdi
69asm/rx86bsdi.o: asm/rx86unix.cpp
70 $(CPP) -DBSDI asm/rx86unix.cpp | sed 's/ :/:/' | as -o asm/rx86bsdi.o
71
72asm/rx86unix.cpp: asm/rc4-586.pl ../perlasm/x86asm.pl
73 (cd asm; $(PERL) rc4-586.pl cpp >rx86unix.cpp)
74
75files:
76 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
77
78links:
79 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
80 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
81 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
82 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
83
84install:
85 @for i in $(EXHEADER) ; \
86 do \
87 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
88 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
89 done;
90
91tags:
92 ctags $(SRC)
93
94tests:
95
96lint:
97 lint -DLINT $(INCLUDES) $(SRC)>fluff
98
99depend:
100 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC)
101
102dclean:
103 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
104 mv -f Makefile.new $(MAKEFILE)
105
106clean:
107 rm -f asm/rx86unix.cpp *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff asm/*.o
108
109# DO NOT DELETE THIS LINE -- make depend depends on it.
110
111rc4_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/rc4.h
112rc4_enc.o: rc4_enc.c rc4_locl.h
113rc4_skey.o: ../../include/openssl/opensslconf.h
114rc4_skey.o: ../../include/openssl/opensslv.h ../../include/openssl/rc4.h
115rc4_skey.o: rc4_locl.h rc4_skey.c
diff --git a/src/lib/libcrypto/rc4/rc4.c b/src/lib/libcrypto/rc4/rc4.c
new file mode 100644
index 0000000000..c2165b0b75
--- /dev/null
+++ b/src/lib/libcrypto/rc4/rc4.c
@@ -0,0 +1,192 @@
1/* crypto/rc4/rc4.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <stdlib.h>
61#include <string.h>
62#include <openssl/rc4.h>
63
64char *usage[]={
65"usage: rc4 args\n",
66"\n",
67" -in arg - input file - default stdin\n",
68" -out arg - output file - default stdout\n",
69" -key key - password\n",
70NULL
71};
72
73int main(int argc, char *argv[])
74 {
75 FILE *in=NULL,*out=NULL;
76 char *infile=NULL,*outfile=NULL,*keystr=NULL;
77 RC4_KEY key;
78 char buf[BUFSIZ];
79 int badops=0,i;
80 char **pp;
81 unsigned char md[MD5_DIGEST_LENGTH];
82
83 argc--;
84 argv++;
85 while (argc >= 1)
86 {
87 if (strcmp(*argv,"-in") == 0)
88 {
89 if (--argc < 1) goto bad;
90 infile= *(++argv);
91 }
92 else if (strcmp(*argv,"-out") == 0)
93 {
94 if (--argc < 1) goto bad;
95 outfile= *(++argv);
96 }
97 else if (strcmp(*argv,"-key") == 0)
98 {
99 if (--argc < 1) goto bad;
100 keystr= *(++argv);
101 }
102 else
103 {
104 fprintf(stderr,"unknown option %s\n",*argv);
105 badops=1;
106 break;
107 }
108 argc--;
109 argv++;
110 }
111
112 if (badops)
113 {
114bad:
115 for (pp=usage; (*pp != NULL); pp++)
116 fprintf(stderr,"%s",*pp);
117 exit(1);
118 }
119
120 if (infile == NULL)
121 in=stdin;
122 else
123 {
124 in=fopen(infile,"r");
125 if (in == NULL)
126 {
127 perror("open");
128 exit(1);
129 }
130
131 }
132 if (outfile == NULL)
133 out=stdout;
134 else
135 {
136 out=fopen(outfile,"w");
137 if (out == NULL)
138 {
139 perror("open");
140 exit(1);
141 }
142 }
143
144#ifdef OPENSSL_SYS_MSDOS
145 /* This should set the file to binary mode. */
146 {
147#include <fcntl.h>
148 setmode(fileno(in),O_BINARY);
149 setmode(fileno(out),O_BINARY);
150 }
151#endif
152
153 if (keystr == NULL)
154 { /* get key */
155 i=EVP_read_pw_string(buf,BUFSIZ,"Enter RC4 password:",0);
156 if (i != 0)
157 {
158 memset(buf,0,BUFSIZ);
159 fprintf(stderr,"bad password read\n");
160 exit(1);
161 }
162 keystr=buf;
163 }
164
165 EVP_Digest((unsigned char *)keystr,(unsigned long)strlen(keystr),md,NULL,EVP_md5());
166 memset(keystr,0,strlen(keystr));
167 RC4_set_key(&key,MD5_DIGEST_LENGTH,md);
168
169 for(;;)
170 {
171 i=fread(buf,1,BUFSIZ,in);
172 if (i == 0) break;
173 if (i < 0)
174 {
175 perror("read");
176 exit(1);
177 }
178 RC4(&key,(unsigned int)i,(unsigned char *)buf,
179 (unsigned char *)buf);
180 i=fwrite(buf,(unsigned int)i,1,out);
181 if (i != 1)
182 {
183 perror("write");
184 exit(1);
185 }
186 }
187 fclose(out);
188 fclose(in);
189 exit(0);
190 return(1);
191 }
192
diff --git a/src/lib/libcrypto/rc4/rc4s.cpp b/src/lib/libcrypto/rc4/rc4s.cpp
new file mode 100644
index 0000000000..3814fde997
--- /dev/null
+++ b/src/lib/libcrypto/rc4/rc4s.cpp
@@ -0,0 +1,73 @@
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/rc4.h>
36
37void main(int argc,char *argv[])
38 {
39 unsigned char buffer[1024];
40 RC4_KEY ctx;
41 unsigned long s1,s2,e1,e2;
42 unsigned char k[16];
43 unsigned long data[2];
44 unsigned char iv[8];
45 int i,num=64,numm;
46 int j=0;
47
48 if (argc >= 2)
49 num=atoi(argv[1]);
50
51 if (num == 0) num=256;
52 if (num > 1024-16) num=1024-16;
53 numm=num+8;
54
55 for (j=0; j<6; j++)
56 {
57 for (i=0; i<10; i++) /**/
58 {
59 RC4(&ctx,numm,buffer,buffer);
60 GetTSC(s1);
61 RC4(&ctx,numm,buffer,buffer);
62 GetTSC(e1);
63 GetTSC(s2);
64 RC4(&ctx,num,buffer,buffer);
65 GetTSC(e2);
66 RC4(&ctx,num,buffer,buffer);
67 }
68
69 printf("RC4 (%d bytes) %d %d (%d) - 8 bytes\n",num,
70 e1-s1,e2-s2,(e1-s1)-(e2-s2));
71 }
72 }
73
diff --git a/src/lib/libcrypto/rc4/rc4speed.c b/src/lib/libcrypto/rc4/rc4speed.c
new file mode 100644
index 0000000000..ced98c52df
--- /dev/null
+++ b/src/lib/libcrypto/rc4/rc4speed.c
@@ -0,0 +1,250 @@
1/* crypto/rc4/rc4speed.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/* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */
60/* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */
61
62#if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX)
63#define TIMES
64#endif
65
66#include <stdio.h>
67
68#include <openssl/e_os2.h>
69#include OPENSSL_UNISTD_IO
70OPENSSL_DECLARE_EXIT
71
72#include <signal.h>
73#ifndef _IRIX
74#include <time.h>
75#endif
76#ifdef TIMES
77#include <sys/types.h>
78#include <sys/times.h>
79#endif
80
81/* Depending on the VMS version, the tms structure is perhaps defined.
82 The __TMS macro will show if it was. If it wasn't defined, we should
83 undefine TIMES, since that tells the rest of the program how things
84 should be handled. -- Richard Levitte */
85#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
86#undef TIMES
87#endif
88
89#ifndef TIMES
90#include <sys/timeb.h>
91#endif
92
93#if defined(sun) || defined(__ultrix)
94#define _POSIX_SOURCE
95#include <limits.h>
96#include <sys/param.h>
97#endif
98
99#include <openssl/rc4.h>
100
101/* The following if from times(3) man page. It may need to be changed */
102#ifndef HZ
103#ifndef CLK_TCK
104#define HZ 100.0
105#else /* CLK_TCK */
106#define HZ ((double)CLK_TCK)
107#endif
108#endif
109
110#define BUFSIZE ((long)1024)
111long run=0;
112
113double Time_F(int s);
114#ifdef SIGALRM
115#if defined(__STDC__) || defined(sgi) || defined(_AIX)
116#define SIGRETTYPE void
117#else
118#define SIGRETTYPE int
119#endif
120
121SIGRETTYPE sig_done(int sig);
122SIGRETTYPE sig_done(int sig)
123 {
124 signal(SIGALRM,sig_done);
125 run=0;
126#ifdef LINT
127 sig=sig;
128#endif
129 }
130#endif
131
132#define START 0
133#define STOP 1
134
135double Time_F(int s)
136 {
137 double ret;
138#ifdef TIMES
139 static struct tms tstart,tend;
140
141 if (s == START)
142 {
143 times(&tstart);
144 return(0);
145 }
146 else
147 {
148 times(&tend);
149 ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
150 return((ret == 0.0)?1e-6:ret);
151 }
152#else /* !times() */
153 static struct timeb tstart,tend;
154 long i;
155
156 if (s == START)
157 {
158 ftime(&tstart);
159 return(0);
160 }
161 else
162 {
163 ftime(&tend);
164 i=(long)tend.millitm-(long)tstart.millitm;
165 ret=((double)(tend.time-tstart.time))+((double)i)/1e3;
166 return((ret == 0.0)?1e-6:ret);
167 }
168#endif
169 }
170
171int main(int argc, char **argv)
172 {
173 long count;
174 static unsigned char buf[BUFSIZE];
175 static unsigned char key[] ={
176 0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
177 0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10,
178 };
179 RC4_KEY sch;
180 double a,b,c,d;
181#ifndef SIGALRM
182 long ca,cb,cc;
183#endif
184
185#ifndef TIMES
186 printf("To get the most accurate results, try to run this\n");
187 printf("program when this computer is idle.\n");
188#endif
189
190#ifndef SIGALRM
191 printf("First we calculate the approximate speed ...\n");
192 RC4_set_key(&sch,16,key);
193 count=10;
194 do {
195 long i;
196 unsigned long data[2];
197
198 count*=2;
199 Time_F(START);
200 for (i=count; i; i--)
201 RC4(&sch,8,buf,buf);
202 d=Time_F(STOP);
203 } while (d < 3.0);
204 ca=count/512;
205 cc=count*8/BUFSIZE+1;
206 printf("Doing RC4_set_key %ld times\n",ca);
207#define COND(d) (count != (d))
208#define COUNT(d) (d)
209#else
210#define COND(c) (run)
211#define COUNT(d) (count)
212 signal(SIGALRM,sig_done);
213 printf("Doing RC4_set_key for 10 seconds\n");
214 alarm(10);
215#endif
216
217 Time_F(START);
218 for (count=0,run=1; COND(ca); count+=4)
219 {
220 RC4_set_key(&sch,16,key);
221 RC4_set_key(&sch,16,key);
222 RC4_set_key(&sch,16,key);
223 RC4_set_key(&sch,16,key);
224 }
225 d=Time_F(STOP);
226 printf("%ld RC4_set_key's in %.2f seconds\n",count,d);
227 a=((double)COUNT(ca))/d;
228
229#ifdef SIGALRM
230 printf("Doing RC4 on %ld byte blocks for 10 seconds\n",BUFSIZE);
231 alarm(10);
232#else
233 printf("Doing RC4 %ld times on %ld byte blocks\n",cc,BUFSIZE);
234#endif
235 Time_F(START);
236 for (count=0,run=1; COND(cc); count++)
237 RC4(&sch,BUFSIZE,buf,buf);
238 d=Time_F(STOP);
239 printf("%ld RC4's of %ld byte blocks in %.2f second\n",
240 count,BUFSIZE,d);
241 c=((double)COUNT(cc)*BUFSIZE)/d;
242
243 printf("RC4 set_key per sec = %12.2f (%9.3fuS)\n",a,1.0e6/a);
244 printf("RC4 bytes per sec = %12.2f (%9.3fuS)\n",c,8.0e6/c);
245 exit(0);
246#if defined(LINT) || defined(OPENSSL_SYS_MSDOS)
247 return(0);
248#endif
249 }
250
diff --git a/src/lib/libcrypto/rc4/rc4test.c b/src/lib/libcrypto/rc4/rc4test.c
new file mode 100644
index 0000000000..a28d457c8d
--- /dev/null
+++ b/src/lib/libcrypto/rc4/rc4test.c
@@ -0,0 +1,201 @@
1/* crypto/rc4/rc4test.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <stdlib.h>
61#include <string.h>
62
63#ifdef OPENSSL_NO_RC4
64int main(int argc, char *argv[])
65{
66 printf("No RC4 support\n");
67 return(0);
68}
69#else
70#include <openssl/rc4.h>
71
72static unsigned char keys[7][30]={
73 {8,0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef},
74 {8,0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef},
75 {8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
76 {4,0xef,0x01,0x23,0x45},
77 {8,0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef},
78 {4,0xef,0x01,0x23,0x45},
79 };
80
81static unsigned char data_len[7]={8,8,8,20,28,10};
82static unsigned char data[7][30]={
83 {0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,0xff},
84 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff},
85 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff},
86 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
87 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
88 0x00,0x00,0x00,0x00,0xff},
89 {0x12,0x34,0x56,0x78,0x9A,0xBC,0xDE,0xF0,
90 0x12,0x34,0x56,0x78,0x9A,0xBC,0xDE,0xF0,
91 0x12,0x34,0x56,0x78,0x9A,0xBC,0xDE,0xF0,
92 0x12,0x34,0x56,0x78,0xff},
93 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff},
94 {0},
95 };
96
97static unsigned char output[7][30]={
98 {0x75,0xb7,0x87,0x80,0x99,0xe0,0xc5,0x96,0x00},
99 {0x74,0x94,0xc2,0xe7,0x10,0x4b,0x08,0x79,0x00},
100 {0xde,0x18,0x89,0x41,0xa3,0x37,0x5d,0x3a,0x00},
101 {0xd6,0xa1,0x41,0xa7,0xec,0x3c,0x38,0xdf,
102 0xbd,0x61,0x5a,0x11,0x62,0xe1,0xc7,0xba,
103 0x36,0xb6,0x78,0x58,0x00},
104 {0x66,0xa0,0x94,0x9f,0x8a,0xf7,0xd6,0x89,
105 0x1f,0x7f,0x83,0x2b,0xa8,0x33,0xc0,0x0c,
106 0x89,0x2e,0xbe,0x30,0x14,0x3c,0xe2,0x87,
107 0x40,0x01,0x1e,0xcf,0x00},
108 {0xd6,0xa1,0x41,0xa7,0xec,0x3c,0x38,0xdf,0xbd,0x61,0x00},
109 {0},
110 };
111
112int main(int argc, char *argv[])
113 {
114 int i,err=0;
115 int j;
116 unsigned char *p;
117 RC4_KEY key;
118 unsigned char buf[512],obuf[512];
119
120 for (i=0; i<512; i++) buf[i]=0x01;
121
122 for (i=0; i<6; i++)
123 {
124 RC4_set_key(&key,keys[i][0],&(keys[i][1]));
125 memset(obuf,0x00,sizeof(obuf));
126 RC4(&key,data_len[i],&(data[i][0]),obuf);
127 if (memcmp(obuf,output[i],data_len[i]+1) != 0)
128 {
129 printf("error calculating RC4\n");
130 printf("output:");
131 for (j=0; j<data_len[i]+1; j++)
132 printf(" %02x",obuf[j]);
133 printf("\n");
134 printf("expect:");
135 p= &(output[i][0]);
136 for (j=0; j<data_len[i]+1; j++)
137 printf(" %02x",*(p++));
138 printf("\n");
139 err++;
140 }
141 else
142 printf("test %d ok\n",i);
143 }
144 printf("test end processing ");
145 for (i=0; i<data_len[3]; i++)
146 {
147 RC4_set_key(&key,keys[3][0],&(keys[3][1]));
148 memset(obuf,0x00,sizeof(obuf));
149 RC4(&key,i,&(data[3][0]),obuf);
150 if ((memcmp(obuf,output[3],i) != 0) || (obuf[i] != 0))
151 {
152 printf("error in RC4 length processing\n");
153 printf("output:");
154 for (j=0; j<i+1; j++)
155 printf(" %02x",obuf[j]);
156 printf("\n");
157 printf("expect:");
158 p= &(output[3][0]);
159 for (j=0; j<i; j++)
160 printf(" %02x",*(p++));
161 printf(" 00\n");
162 err++;
163 }
164 else
165 {
166 printf(".");
167 fflush(stdout);
168 }
169 }
170 printf("done\n");
171 printf("test multi-call ");
172 for (i=0; i<data_len[3]; i++)
173 {
174 RC4_set_key(&key,keys[3][0],&(keys[3][1]));
175 memset(obuf,0x00,sizeof(obuf));
176 RC4(&key,i,&(data[3][0]),obuf);
177 RC4(&key,data_len[3]-i,&(data[3][i]),&(obuf[i]));
178 if (memcmp(obuf,output[3],data_len[3]+1) != 0)
179 {
180 printf("error in RC4 multi-call processing\n");
181 printf("output:");
182 for (j=0; j<data_len[3]+1; j++)
183 printf(" %02x",obuf[j]);
184 printf("\n");
185 printf("expect:");
186 p= &(output[3][0]);
187 for (j=0; j<data_len[3]+1; j++)
188 printf(" %02x",*(p++));
189 err++;
190 }
191 else
192 {
193 printf(".");
194 fflush(stdout);
195 }
196 }
197 printf("done\n");
198 exit(err);
199 return(0);
200 }
201#endif
diff --git a/src/lib/libcrypto/rc4/rrc4.doc b/src/lib/libcrypto/rc4/rrc4.doc
new file mode 100644
index 0000000000..2f9a953c12
--- /dev/null
+++ b/src/lib/libcrypto/rc4/rrc4.doc
@@ -0,0 +1,278 @@
1Newsgroups: sci.crypt,alt.security,comp.security.misc,alt.privacy
2Path: ghost.dsi.unimi.it!univ-lyon1.fr!jussieu.fr!zaphod.crihan.fr!warwick!clyde.open.ac.uk!strath-cs!bnr.co.uk!bt!pipex!howland.reston.ans.net!europa.eng.gtefsd.com!MathWorks.Com!yeshua.marcam.com!charnel.ecst.csuchico.edu!csusac!csus.edu!netcom.com!sterndark
3From: sterndark@netcom.com (David Sterndark)
4Subject: RC4 Algorithm revealed.
5Message-ID: <sternCvKL4B.Hyy@netcom.com>
6Sender: sterndark@netcom.com
7Organization: NETCOM On-line Communication Services (408 261-4700 guest)
8X-Newsreader: TIN [version 1.2 PL1]
9Date: Wed, 14 Sep 1994 06:35:31 GMT
10Lines: 263
11Xref: ghost.dsi.unimi.it sci.crypt:27332 alt.security:14732 comp.security.misc:11701 alt.privacy:16026
12
13I am shocked, shocked, I tell you, shocked, to discover
14that the cypherpunks have illegaly and criminally revealed
15a crucial RSA trade secret and harmed the security of
16America by reverse engineering the RC4 algorithm and
17publishing it to the world.
18
19On Saturday morning an anonymous cypherpunk wrote:
20
21
22 SUBJECT: RC4 Source Code
23
24
25 I've tested this. It is compatible with the RC4 object module
26 that comes in the various RSA toolkits.
27
28 /* rc4.h */
29 typedef struct rc4_key
30 {
31 unsigned char state[256];
32 unsigned char x;
33 unsigned char y;
34 } rc4_key;
35 void prepare_key(unsigned char *key_data_ptr,int key_data_len,
36 rc4_key *key);
37 void rc4(unsigned char *buffer_ptr,int buffer_len,rc4_key * key);
38
39
40 /*rc4.c */
41 #include "rc4.h"
42 static void swap_byte(unsigned char *a, unsigned char *b);
43 void prepare_key(unsigned char *key_data_ptr, int key_data_len,
44 rc4_key *key)
45 {
46 unsigned char swapByte;
47 unsigned char index1;
48 unsigned char index2;
49 unsigned char* state;
50 short counter;
51
52 state = &key->state[0];
53 for(counter = 0; counter < 256; counter++)
54 state[counter] = counter;
55 key->x = 0;
56 key->y = 0;
57 index1 = 0;
58 index2 = 0;
59 for(counter = 0; counter < 256; counter++)
60 {
61 index2 = (key_data_ptr[index1] + state[counter] +
62 index2) % 256;
63 swap_byte(&state[counter], &state[index2]);
64
65 index1 = (index1 + 1) % key_data_len;
66 }
67 }
68
69 void rc4(unsigned char *buffer_ptr, int buffer_len, rc4_key *key)
70 {
71 unsigned char x;
72 unsigned char y;
73 unsigned char* state;
74 unsigned char xorIndex;
75 short counter;
76
77 x = key->x;
78 y = key->y;
79
80 state = &key->state[0];
81 for(counter = 0; counter < buffer_len; counter ++)
82 {
83 x = (x + 1) % 256;
84 y = (state[x] + y) % 256;
85 swap_byte(&state[x], &state[y]);
86
87 xorIndex = (state[x] + state[y]) % 256;
88
89 buffer_ptr[counter] ^= state[xorIndex];
90 }
91 key->x = x;
92 key->y = y;
93 }
94
95 static void swap_byte(unsigned char *a, unsigned char *b)
96 {
97 unsigned char swapByte;
98
99 swapByte = *a;
100 *a = *b;
101 *b = swapByte;
102 }
103
104
105
106Another cypherpunk, this one not anonymous, tested the
107output from this algorithm against the output from
108official RC4 object code
109
110
111 Date: Tue, 13 Sep 94 18:37:56 PDT
112 From: ekr@eit.COM (Eric Rescorla)
113 Message-Id: <9409140137.AA17743@eitech.eit.com>
114 Subject: RC4 compatibility testing
115 Cc: cypherpunks@toad.com
116
117 One data point:
118
119 I can't say anything about the internals of RC4 versus the
120 algorithm that Bill Sommerfeld is rightly calling 'Alleged RC4',
121 since I don't know anything about RC4's internals.
122
123 However, I do have a (legitimately acquired) copy of BSAFE2 and
124 so I'm able to compare the output of this algorithm to the output
125 of genuine RC4 as found in BSAFE. I chose a set of test vectors
126 and ran them through both algorithms. The algorithms appear to
127 give identical results, at least with these key/plaintext pairs.
128
129 I note that this is the algorithm _without_ Hal Finney's
130 proposed modification
131
132 (see <199409130605.XAA24133@jobe.shell.portal.com>).
133
134 The vectors I used (together with the ciphertext they produce)
135 follow at the end of this message.
136
137 -Ekr
138
139 Disclaimer: This posting does not reflect the opinions of EIT.
140
141 --------------------results follow--------------
142 Test vector 0
143 Key: 0x01 0x23 0x45 0x67 0x89 0xab 0xcd 0xef
144 Input: 0x01 0x23 0x45 0x67 0x89 0xab 0xcd 0xef
145 0 Output: 0x75 0xb7 0x87 0x80 0x99 0xe0 0xc5 0x96
146
147 Test vector 1
148 Key: 0x01 0x23 0x45 0x67 0x89 0xab 0xcd 0xef
149 Input: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
150 0 Output: 0x74 0x94 0xc2 0xe7 0x10 0x4b 0x08 0x79
151
152 Test vector 2
153 Key: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
154 Input: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
155 0 Output: 0xde 0x18 0x89 0x41 0xa3 0x37 0x5d 0x3a
156
157 Test vector 3
158 Key: 0xef 0x01 0x23 0x45
159 Input: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
160 0 Output: 0xd6 0xa1 0x41 0xa7 0xec 0x3c 0x38 0xdf 0xbd 0x61
161
162 Test vector 4
163 Key: 0x01 0x23 0x45 0x67 0x89 0xab 0xcd 0xef
164 Input: 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
165 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
166 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
167 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
168 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
169 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
170 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
171 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
172 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
173 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
174 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
175 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
176 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
177 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
178 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
179 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
180 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
181 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
182 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
183 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
184 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
185 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
186 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
187 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
188 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
189 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
190 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
191 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
192 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
193 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
194 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
195 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
196 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
197 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
198 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
199 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
200 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
201 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
202 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
203 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
204 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
205 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
206 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
207 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
208 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
209 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
210 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
211 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
212 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
213 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
214 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
215 0x01
216 0 Output: 0x75 0x95 0xc3 0xe6 0x11 0x4a 0x09 0x78 0x0c 0x4a 0xd4
217 0x52 0x33 0x8e 0x1f 0xfd 0x9a 0x1b 0xe9 0x49 0x8f
218 0x81 0x3d 0x76 0x53 0x34 0x49 0xb6 0x77 0x8d 0xca
219 0xd8 0xc7 0x8a 0x8d 0x2b 0xa9 0xac 0x66 0x08 0x5d
220 0x0e 0x53 0xd5 0x9c 0x26 0xc2 0xd1 0xc4 0x90 0xc1
221 0xeb 0xbe 0x0c 0xe6 0x6d 0x1b 0x6b 0x1b 0x13 0xb6
222 0xb9 0x19 0xb8 0x47 0xc2 0x5a 0x91 0x44 0x7a 0x95
223 0xe7 0x5e 0x4e 0xf1 0x67 0x79 0xcd 0xe8 0xbf 0x0a
224 0x95 0x85 0x0e 0x32 0xaf 0x96 0x89 0x44 0x4f 0xd3
225 0x77 0x10 0x8f 0x98 0xfd 0xcb 0xd4 0xe7 0x26 0x56
226 0x75 0x00 0x99 0x0b 0xcc 0x7e 0x0c 0xa3 0xc4 0xaa
227 0xa3 0x04 0xa3 0x87 0xd2 0x0f 0x3b 0x8f 0xbb 0xcd
228 0x42 0xa1 0xbd 0x31 0x1d 0x7a 0x43 0x03 0xdd 0xa5
229 0xab 0x07 0x88 0x96 0xae 0x80 0xc1 0x8b 0x0a 0xf6
230 0x6d 0xff 0x31 0x96 0x16 0xeb 0x78 0x4e 0x49 0x5a
231 0xd2 0xce 0x90 0xd7 0xf7 0x72 0xa8 0x17 0x47 0xb6
232 0x5f 0x62 0x09 0x3b 0x1e 0x0d 0xb9 0xe5 0xba 0x53
233 0x2f 0xaf 0xec 0x47 0x50 0x83 0x23 0xe6 0x71 0x32
234 0x7d 0xf9 0x44 0x44 0x32 0xcb 0x73 0x67 0xce 0xc8
235 0x2f 0x5d 0x44 0xc0 0xd0 0x0b 0x67 0xd6 0x50 0xa0
236 0x75 0xcd 0x4b 0x70 0xde 0xdd 0x77 0xeb 0x9b 0x10
237 0x23 0x1b 0x6b 0x5b 0x74 0x13 0x47 0x39 0x6d 0x62
238 0x89 0x74 0x21 0xd4 0x3d 0xf9 0xb4 0x2e 0x44 0x6e
239 0x35 0x8e 0x9c 0x11 0xa9 0xb2 0x18 0x4e 0xcb 0xef
240 0x0c 0xd8 0xe7 0xa8 0x77 0xef 0x96 0x8f 0x13 0x90
241 0xec 0x9b 0x3d 0x35 0xa5 0x58 0x5c 0xb0 0x09 0x29
242 0x0e 0x2f 0xcd 0xe7 0xb5 0xec 0x66 0xd9 0x08 0x4b
243 0xe4 0x40 0x55 0xa6 0x19 0xd9 0xdd 0x7f 0xc3 0x16
244 0x6f 0x94 0x87 0xf7 0xcb 0x27 0x29 0x12 0x42 0x64
245 0x45 0x99 0x85 0x14 0xc1 0x5d 0x53 0xa1 0x8c 0x86
246 0x4c 0xe3 0xa2 0xb7 0x55 0x57 0x93 0x98 0x81 0x26
247 0x52 0x0e 0xac 0xf2 0xe3 0x06 0x6e 0x23 0x0c 0x91
248 0xbe 0xe4 0xdd 0x53 0x04 0xf5 0xfd 0x04 0x05 0xb3
249 0x5b 0xd9 0x9c 0x73 0x13 0x5d 0x3d 0x9b 0xc3 0x35
250 0xee 0x04 0x9e 0xf6 0x9b 0x38 0x67 0xbf 0x2d 0x7b
251 0xd1 0xea 0xa5 0x95 0xd8 0xbf 0xc0 0x06 0x6f 0xf8
252 0xd3 0x15 0x09 0xeb 0x0c 0x6c 0xaa 0x00 0x6c 0x80
253 0x7a 0x62 0x3e 0xf8 0x4c 0x3d 0x33 0xc1 0x95 0xd2
254 0x3e 0xe3 0x20 0xc4 0x0d 0xe0 0x55 0x81 0x57 0xc8
255 0x22 0xd4 0xb8 0xc5 0x69 0xd8 0x49 0xae 0xd5 0x9d
256 0x4e 0x0f 0xd7 0xf3 0x79 0x58 0x6b 0x4b 0x7f 0xf6
257 0x84 0xed 0x6a 0x18 0x9f 0x74 0x86 0xd4 0x9b 0x9c
258 0x4b 0xad 0x9b 0xa2 0x4b 0x96 0xab 0xf9 0x24 0x37
259 0x2c 0x8a 0x8f 0xff 0xb1 0x0d 0x55 0x35 0x49 0x00
260 0xa7 0x7a 0x3d 0xb5 0xf2 0x05 0xe1 0xb9 0x9f 0xcd
261 0x86 0x60 0x86 0x3a 0x15 0x9a 0xd4 0xab 0xe4 0x0f
262 0xa4 0x89 0x34 0x16 0x3d 0xdd 0xe5 0x42 0xa6 0x58
263 0x55 0x40 0xfd 0x68 0x3c 0xbf 0xd8 0xc0 0x0f 0x12
264 0x12 0x9a 0x28 0x4d 0xea 0xcc 0x4c 0xde 0xfe 0x58
265 0xbe 0x71 0x37 0x54 0x1c 0x04 0x71 0x26 0xc8 0xd4
266 0x9e 0x27 0x55 0xab 0x18 0x1a 0xb7 0xe9 0x40 0xb0
267 0xc0
268
269
270
271--
272 ---------------------------------------------------------------------
273We have the right to defend ourselves and our
274property, because of the kind of animals that we James A. Donald
275are. True law derives from this right, not from
276the arbitrary power of the omnipotent state. jamesd@netcom.com
277
278
diff --git a/src/lib/libcrypto/rc5/Makefile.ssl b/src/lib/libcrypto/rc5/Makefile.ssl
new file mode 100644
index 0000000000..ff31ab47a9
--- /dev/null
+++ b/src/lib/libcrypto/rc5/Makefile.ssl
@@ -0,0 +1,113 @@
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)
25
26GENERAL=Makefile
27TEST=rc5test.c
28APPS=
29
30LIB=$(TOP)/libcrypto.a
31LIBSRC=rc5_skey.c rc5_ecb.c rc5_enc.c rc5cfb64.c rc5ofb64.c
32LIBOBJ=rc5_skey.o rc5_ecb.o $(RC5_ENC) rc5cfb64.o rc5ofb64.o
33
34SRC= $(LIBSRC)
35
36EXHEADER= rc5.h
37HEADER= rc5_locl.h $(EXHEADER)
38
39ALL= $(GENERAL) $(SRC) $(HEADER)
40
41top:
42 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
43
44all: lib
45
46lib: $(LIBOBJ)
47 $(AR) $(LIB) $(LIBOBJ)
48 $(RANLIB) $(LIB) || echo Never mind.
49 @touch lib
50
51# elf
52asm/r586-elf.o: asm/r586unix.cpp
53 $(CPP) -DELF -x c asm/r586unix.cpp | as -o asm/r586-elf.o
54
55# solaris
56asm/r586-sol.o: asm/r586unix.cpp
57 $(CC) -E -DSOL asm/r586unix.cpp | sed 's/^#.*//' > asm/r586-sol.s
58 as -o asm/r586-sol.o asm/r586-sol.s
59 rm -f asm/r586-sol.s
60
61# a.out
62asm/r586-out.o: asm/r586unix.cpp
63 $(CPP) -DOUT asm/r586unix.cpp | as -o asm/r586-out.o
64
65# bsdi
66asm/r586bsdi.o: asm/r586unix.cpp
67 $(CPP) -DBSDI asm/r586unix.cpp | sed 's/ :/:/' | as -o asm/r586bsdi.o
68
69asm/r586unix.cpp: asm/rc5-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl
70 (cd asm; $(PERL) rc5-586.pl cpp >r586unix.cpp)
71
72files:
73 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
74
75links:
76 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
77 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
78 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
79 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
80
81install:
82 @for i in $(EXHEADER) ; \
83 do \
84 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
85 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
86 done;
87
88tags:
89 ctags $(SRC)
90
91tests:
92
93lint:
94 lint -DLINT $(INCLUDES) $(SRC)>fluff
95
96depend:
97 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC)
98
99dclean:
100 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
101 mv -f Makefile.new $(MAKEFILE)
102
103clean:
104 rm -f asm/r586unix.cpp *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
105
106# DO NOT DELETE THIS LINE -- make depend depends on it.
107
108rc5_ecb.o: ../../include/openssl/opensslv.h ../../include/openssl/rc5.h
109rc5_ecb.o: rc5_ecb.c rc5_locl.h
110rc5_enc.o: ../../include/openssl/rc5.h rc5_enc.c rc5_locl.h
111rc5_skey.o: ../../include/openssl/rc5.h rc5_locl.h rc5_skey.c
112rc5cfb64.o: ../../include/openssl/rc5.h rc5_locl.h rc5cfb64.c
113rc5ofb64.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
new file mode 100644
index 0000000000..4adfd2db5a
--- /dev/null
+++ b/src/lib/libcrypto/rc5/rc5.h
@@ -0,0 +1,116 @@
1/* crypto/rc5/rc5.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#ifndef HEADER_RC5_H
60#define HEADER_RC5_H
61
62#ifdef __cplusplus
63extern "C" {
64#endif
65
66#ifdef OPENSSL_NO_RC5
67#error RC5 is disabled.
68#endif
69
70#define RC5_ENCRYPT 1
71#define RC5_DECRYPT 0
72
73/* 32 bit. For Alpha, things may get weird */
74#define RC5_32_INT unsigned long
75
76#define RC5_32_BLOCK 8
77#define RC5_32_KEY_LENGTH 16 /* This is a default, max is 255 */
78
79/* This are the only values supported. Tweak the code if you want more
80 * The most supported modes will be
81 * RC5-32/12/16
82 * RC5-32/16/8
83 */
84#define RC5_8_ROUNDS 8
85#define RC5_12_ROUNDS 12
86#define RC5_16_ROUNDS 16
87
88typedef struct rc5_key_st
89 {
90 /* Number of rounds */
91 int rounds;
92 RC5_32_INT data[2*(RC5_16_ROUNDS+1)];
93 } RC5_32_KEY;
94
95
96void RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data,
97 int rounds);
98void RC5_32_ecb_encrypt(const unsigned char *in,unsigned char *out,RC5_32_KEY *key,
99 int enc);
100void RC5_32_encrypt(unsigned long *data,RC5_32_KEY *key);
101void RC5_32_decrypt(unsigned long *data,RC5_32_KEY *key);
102void RC5_32_cbc_encrypt(const unsigned char *in, unsigned char *out,
103 long length, RC5_32_KEY *ks, unsigned char *iv,
104 int enc);
105void RC5_32_cfb64_encrypt(const unsigned char *in, unsigned char *out,
106 long length, RC5_32_KEY *schedule,
107 unsigned char *ivec, int *num, int enc);
108void RC5_32_ofb64_encrypt(const unsigned char *in, unsigned char *out,
109 long length, RC5_32_KEY *schedule,
110 unsigned char *ivec, int *num);
111
112#ifdef __cplusplus
113}
114#endif
115
116#endif
diff --git a/src/lib/libcrypto/rijndael/Makefile.ssl b/src/lib/libcrypto/rijndael/Makefile.ssl
new file mode 100644
index 0000000000..6b098203b9
--- /dev/null
+++ b/src/lib/libcrypto/rijndael/Makefile.ssl
@@ -0,0 +1,89 @@
1#
2# crypto/rijndael/Makefile
3#
4
5DIR= rijndael
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
20RD_ENC= rd_enc.o
21# or use
22#DES_ENC= bx86-elf.o
23
24# CFLAGS= -mpentiumpro $(INCLUDES) $(CFLAG) -O3 -fexpensive-optimizations -funroll-loops -fforce-addr
25CFLAGS= $(INCLUDES) $(CFLAG)
26
27GENERAL=Makefile
28TEST=
29APPS=
30
31LIB=$(TOP)/libcrypto.a
32LIBSRC=rd_fst.c
33LIBOBJ=rd_fst.o
34
35SRC= $(LIBSRC)
36
37EXHEADER=rd_fst.h rijndael.h
38
39top:
40 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
41
42all: lib
43
44lib: $(LIBOBJ)
45 $(AR) $(LIB) $(LIBOBJ)
46 $(RANLIB) $(LIB)
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
89rd_fst.o: rd_fst.c rd_fst.h
diff --git a/src/lib/libcrypto/rijndael/README b/src/lib/libcrypto/rijndael/README
new file mode 100644
index 0000000000..1118ccbad8
--- /dev/null
+++ b/src/lib/libcrypto/rijndael/README
@@ -0,0 +1,80 @@
1Optimised ANSI C code for the Rijndael cipher (now AES)
2
3Authors:
4 Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be>
5 Antoon Bosselaers <antoon.bosselaers@esat.kuleuven.ac.be>
6 Paulo Barreto <paulo.barreto@terra.com.br>
7
8All code contained in this distributed is placed in the public domain.
9
10========================================================================
11
12Disclaimer:
13
14THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS
15OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
18LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
21BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
23OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
24EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
26========================================================================
27
28Acknowledgements:
29
30We are deeply indebted to the following people for their bug reports,
31fixes, and improvement suggestions to the API implementation. Though we
32tried to list all contributions, we apologise in advance for any
33missing reference:
34
35Andrew Bales <Andrew.Bales@Honeywell.com>
36Markus Friedl <markus.friedl@informatik.uni-erlangen.de>
37John Skodon <skodonj@webquill.com>
38
39========================================================================
40
41Description:
42
43This optimised implementation of Rijndael is noticeably faster than the
44previous versions on Intel processors under Win32 w/ MSVC 6.0. On the
45same processor under Linux w/ gcc-2.95.2, the key setup is also
46considerably faster, but normal encryption/decryption is only marginally
47faster.
48
49To enable full loop unrolling for encryption/decryption, define the
50conditional compilation directive FULL_UNROLL. This may help increase
51performance or not, depending on the platform.
52
53To compute the intermediate value tests, define the conditional
54compilation directive INTERMEDIATE_VALUE_KAT. It may be worthwhile to
55define the TRACE_KAT_MCT directive too, which provides useful progress
56information during the generation of the KAT and MCT sets.
57
58========================================================================
59
60Contents:
61
62README This file
63rijndael-alg-fst.c The algorithm implementation.
64rijndael-alg-fst.h The corresponding header file.
65rijndael-api-fst.c NIST's implementation.
66rijndael-api-fst.h The corresponding header file.
67rijndael-test-fst.c A simple program to generate test vectors.
68table.128 Data for the table tests and 128-bit keys.
69table.192 Data for the table tests and 192-bit keys.
70table.256 Data for the table tests and 256-bit keys.
71fips-test-vectors.txt Key schedule and ciphertext intermediate values
72 (reduced set proposed for FIPS inclusion).
73Makefile A sample makefile; may need some changes,
74 depending on the C compiler used.
75
76N.B. Both the API implementation and the provisional reduced set of
77test vectors are likely to change, according to NIST's final decision
78regarding modes of operation and the FIPS contents. They are therefore
79marked as "version 2.9" rather than "version 3.0".
80
diff --git a/src/lib/libcrypto/rijndael/rd_fst.c b/src/lib/libcrypto/rijndael/rd_fst.c
new file mode 100644
index 0000000000..f1597288f0
--- /dev/null
+++ b/src/lib/libcrypto/rijndael/rd_fst.c
@@ -0,0 +1,1400 @@
1/**
2 * rijndael-alg-fst.c
3 *
4 * @version 3.0 (December 2000)
5 *
6 * Optimised ANSI C code for the Rijndael cipher (now AES)
7 *
8 * @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be>
9 * @author Antoon Bosselaers <antoon.bosselaers@esat.kuleuven.ac.be>
10 * @author Paulo Barreto <paulo.barreto@terra.com.br>
11 *
12 * This code is hereby placed in the public domain.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS
15 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
18 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
21 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
23 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
24 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26#include <assert.h>
27#include <stdlib.h>
28
29#include "rd_fst.h"
30
31/*
32Te0[x] = S [x].[02, 01, 01, 03];
33Te1[x] = S [x].[03, 02, 01, 01];
34Te2[x] = S [x].[01, 03, 02, 01];
35Te3[x] = S [x].[01, 01, 03, 02];
36Te4[x] = S [x].[01, 01, 01, 01];
37
38Td0[x] = Si[x].[0e, 09, 0d, 0b];
39Td1[x] = Si[x].[0b, 0e, 09, 0d];
40Td2[x] = Si[x].[0d, 0b, 0e, 09];
41Td3[x] = Si[x].[09, 0d, 0b, 0e];
42Td4[x] = Si[x].[01, 01, 01, 01];
43*/
44
45static const u32 Te0[256] = {
46 0xc66363a5U, 0xf87c7c84U, 0xee777799U, 0xf67b7b8dU,
47 0xfff2f20dU, 0xd66b6bbdU, 0xde6f6fb1U, 0x91c5c554U,
48 0x60303050U, 0x02010103U, 0xce6767a9U, 0x562b2b7dU,
49 0xe7fefe19U, 0xb5d7d762U, 0x4dababe6U, 0xec76769aU,
50 0x8fcaca45U, 0x1f82829dU, 0x89c9c940U, 0xfa7d7d87U,
51 0xeffafa15U, 0xb25959ebU, 0x8e4747c9U, 0xfbf0f00bU,
52 0x41adadecU, 0xb3d4d467U, 0x5fa2a2fdU, 0x45afafeaU,
53 0x239c9cbfU, 0x53a4a4f7U, 0xe4727296U, 0x9bc0c05bU,
54 0x75b7b7c2U, 0xe1fdfd1cU, 0x3d9393aeU, 0x4c26266aU,
55 0x6c36365aU, 0x7e3f3f41U, 0xf5f7f702U, 0x83cccc4fU,
56 0x6834345cU, 0x51a5a5f4U, 0xd1e5e534U, 0xf9f1f108U,
57 0xe2717193U, 0xabd8d873U, 0x62313153U, 0x2a15153fU,
58 0x0804040cU, 0x95c7c752U, 0x46232365U, 0x9dc3c35eU,
59 0x30181828U, 0x379696a1U, 0x0a05050fU, 0x2f9a9ab5U,
60 0x0e070709U, 0x24121236U, 0x1b80809bU, 0xdfe2e23dU,
61 0xcdebeb26U, 0x4e272769U, 0x7fb2b2cdU, 0xea75759fU,
62 0x1209091bU, 0x1d83839eU, 0x582c2c74U, 0x341a1a2eU,
63 0x361b1b2dU, 0xdc6e6eb2U, 0xb45a5aeeU, 0x5ba0a0fbU,
64 0xa45252f6U, 0x763b3b4dU, 0xb7d6d661U, 0x7db3b3ceU,
65 0x5229297bU, 0xdde3e33eU, 0x5e2f2f71U, 0x13848497U,
66 0xa65353f5U, 0xb9d1d168U, 0x00000000U, 0xc1eded2cU,
67 0x40202060U, 0xe3fcfc1fU, 0x79b1b1c8U, 0xb65b5bedU,
68 0xd46a6abeU, 0x8dcbcb46U, 0x67bebed9U, 0x7239394bU,
69 0x944a4adeU, 0x984c4cd4U, 0xb05858e8U, 0x85cfcf4aU,
70 0xbbd0d06bU, 0xc5efef2aU, 0x4faaaae5U, 0xedfbfb16U,
71 0x864343c5U, 0x9a4d4dd7U, 0x66333355U, 0x11858594U,
72 0x8a4545cfU, 0xe9f9f910U, 0x04020206U, 0xfe7f7f81U,
73 0xa05050f0U, 0x783c3c44U, 0x259f9fbaU, 0x4ba8a8e3U,
74 0xa25151f3U, 0x5da3a3feU, 0x804040c0U, 0x058f8f8aU,
75 0x3f9292adU, 0x219d9dbcU, 0x70383848U, 0xf1f5f504U,
76 0x63bcbcdfU, 0x77b6b6c1U, 0xafdada75U, 0x42212163U,
77 0x20101030U, 0xe5ffff1aU, 0xfdf3f30eU, 0xbfd2d26dU,
78 0x81cdcd4cU, 0x180c0c14U, 0x26131335U, 0xc3ecec2fU,
79 0xbe5f5fe1U, 0x359797a2U, 0x884444ccU, 0x2e171739U,
80 0x93c4c457U, 0x55a7a7f2U, 0xfc7e7e82U, 0x7a3d3d47U,
81 0xc86464acU, 0xba5d5de7U, 0x3219192bU, 0xe6737395U,
82 0xc06060a0U, 0x19818198U, 0x9e4f4fd1U, 0xa3dcdc7fU,
83 0x44222266U, 0x542a2a7eU, 0x3b9090abU, 0x0b888883U,
84 0x8c4646caU, 0xc7eeee29U, 0x6bb8b8d3U, 0x2814143cU,
85 0xa7dede79U, 0xbc5e5ee2U, 0x160b0b1dU, 0xaddbdb76U,
86 0xdbe0e03bU, 0x64323256U, 0x743a3a4eU, 0x140a0a1eU,
87 0x924949dbU, 0x0c06060aU, 0x4824246cU, 0xb85c5ce4U,
88 0x9fc2c25dU, 0xbdd3d36eU, 0x43acacefU, 0xc46262a6U,
89 0x399191a8U, 0x319595a4U, 0xd3e4e437U, 0xf279798bU,
90 0xd5e7e732U, 0x8bc8c843U, 0x6e373759U, 0xda6d6db7U,
91 0x018d8d8cU, 0xb1d5d564U, 0x9c4e4ed2U, 0x49a9a9e0U,
92 0xd86c6cb4U, 0xac5656faU, 0xf3f4f407U, 0xcfeaea25U,
93 0xca6565afU, 0xf47a7a8eU, 0x47aeaee9U, 0x10080818U,
94 0x6fbabad5U, 0xf0787888U, 0x4a25256fU, 0x5c2e2e72U,
95 0x381c1c24U, 0x57a6a6f1U, 0x73b4b4c7U, 0x97c6c651U,
96 0xcbe8e823U, 0xa1dddd7cU, 0xe874749cU, 0x3e1f1f21U,
97 0x964b4bddU, 0x61bdbddcU, 0x0d8b8b86U, 0x0f8a8a85U,
98 0xe0707090U, 0x7c3e3e42U, 0x71b5b5c4U, 0xcc6666aaU,
99 0x904848d8U, 0x06030305U, 0xf7f6f601U, 0x1c0e0e12U,
100 0xc26161a3U, 0x6a35355fU, 0xae5757f9U, 0x69b9b9d0U,
101 0x17868691U, 0x99c1c158U, 0x3a1d1d27U, 0x279e9eb9U,
102 0xd9e1e138U, 0xebf8f813U, 0x2b9898b3U, 0x22111133U,
103 0xd26969bbU, 0xa9d9d970U, 0x078e8e89U, 0x339494a7U,
104 0x2d9b9bb6U, 0x3c1e1e22U, 0x15878792U, 0xc9e9e920U,
105 0x87cece49U, 0xaa5555ffU, 0x50282878U, 0xa5dfdf7aU,
106 0x038c8c8fU, 0x59a1a1f8U, 0x09898980U, 0x1a0d0d17U,
107 0x65bfbfdaU, 0xd7e6e631U, 0x844242c6U, 0xd06868b8U,
108 0x824141c3U, 0x299999b0U, 0x5a2d2d77U, 0x1e0f0f11U,
109 0x7bb0b0cbU, 0xa85454fcU, 0x6dbbbbd6U, 0x2c16163aU,
110};
111static const u32 Te1[256] = {
112 0xa5c66363U, 0x84f87c7cU, 0x99ee7777U, 0x8df67b7bU,
113 0x0dfff2f2U, 0xbdd66b6bU, 0xb1de6f6fU, 0x5491c5c5U,
114 0x50603030U, 0x03020101U, 0xa9ce6767U, 0x7d562b2bU,
115 0x19e7fefeU, 0x62b5d7d7U, 0xe64dababU, 0x9aec7676U,
116 0x458fcacaU, 0x9d1f8282U, 0x4089c9c9U, 0x87fa7d7dU,
117 0x15effafaU, 0xebb25959U, 0xc98e4747U, 0x0bfbf0f0U,
118 0xec41adadU, 0x67b3d4d4U, 0xfd5fa2a2U, 0xea45afafU,
119 0xbf239c9cU, 0xf753a4a4U, 0x96e47272U, 0x5b9bc0c0U,
120 0xc275b7b7U, 0x1ce1fdfdU, 0xae3d9393U, 0x6a4c2626U,
121 0x5a6c3636U, 0x417e3f3fU, 0x02f5f7f7U, 0x4f83ccccU,
122 0x5c683434U, 0xf451a5a5U, 0x34d1e5e5U, 0x08f9f1f1U,
123 0x93e27171U, 0x73abd8d8U, 0x53623131U, 0x3f2a1515U,
124 0x0c080404U, 0x5295c7c7U, 0x65462323U, 0x5e9dc3c3U,
125 0x28301818U, 0xa1379696U, 0x0f0a0505U, 0xb52f9a9aU,
126 0x090e0707U, 0x36241212U, 0x9b1b8080U, 0x3ddfe2e2U,
127 0x26cdebebU, 0x694e2727U, 0xcd7fb2b2U, 0x9fea7575U,
128 0x1b120909U, 0x9e1d8383U, 0x74582c2cU, 0x2e341a1aU,
129 0x2d361b1bU, 0xb2dc6e6eU, 0xeeb45a5aU, 0xfb5ba0a0U,
130 0xf6a45252U, 0x4d763b3bU, 0x61b7d6d6U, 0xce7db3b3U,
131 0x7b522929U, 0x3edde3e3U, 0x715e2f2fU, 0x97138484U,
132 0xf5a65353U, 0x68b9d1d1U, 0x00000000U, 0x2cc1ededU,
133 0x60402020U, 0x1fe3fcfcU, 0xc879b1b1U, 0xedb65b5bU,
134 0xbed46a6aU, 0x468dcbcbU, 0xd967bebeU, 0x4b723939U,
135 0xde944a4aU, 0xd4984c4cU, 0xe8b05858U, 0x4a85cfcfU,
136 0x6bbbd0d0U, 0x2ac5efefU, 0xe54faaaaU, 0x16edfbfbU,
137 0xc5864343U, 0xd79a4d4dU, 0x55663333U, 0x94118585U,
138 0xcf8a4545U, 0x10e9f9f9U, 0x06040202U, 0x81fe7f7fU,
139 0xf0a05050U, 0x44783c3cU, 0xba259f9fU, 0xe34ba8a8U,
140 0xf3a25151U, 0xfe5da3a3U, 0xc0804040U, 0x8a058f8fU,
141 0xad3f9292U, 0xbc219d9dU, 0x48703838U, 0x04f1f5f5U,
142 0xdf63bcbcU, 0xc177b6b6U, 0x75afdadaU, 0x63422121U,
143 0x30201010U, 0x1ae5ffffU, 0x0efdf3f3U, 0x6dbfd2d2U,
144 0x4c81cdcdU, 0x14180c0cU, 0x35261313U, 0x2fc3ececU,
145 0xe1be5f5fU, 0xa2359797U, 0xcc884444U, 0x392e1717U,
146 0x5793c4c4U, 0xf255a7a7U, 0x82fc7e7eU, 0x477a3d3dU,
147 0xacc86464U, 0xe7ba5d5dU, 0x2b321919U, 0x95e67373U,
148 0xa0c06060U, 0x98198181U, 0xd19e4f4fU, 0x7fa3dcdcU,
149 0x66442222U, 0x7e542a2aU, 0xab3b9090U, 0x830b8888U,
150 0xca8c4646U, 0x29c7eeeeU, 0xd36bb8b8U, 0x3c281414U,
151 0x79a7dedeU, 0xe2bc5e5eU, 0x1d160b0bU, 0x76addbdbU,
152 0x3bdbe0e0U, 0x56643232U, 0x4e743a3aU, 0x1e140a0aU,
153 0xdb924949U, 0x0a0c0606U, 0x6c482424U, 0xe4b85c5cU,
154 0x5d9fc2c2U, 0x6ebdd3d3U, 0xef43acacU, 0xa6c46262U,
155 0xa8399191U, 0xa4319595U, 0x37d3e4e4U, 0x8bf27979U,
156 0x32d5e7e7U, 0x438bc8c8U, 0x596e3737U, 0xb7da6d6dU,
157 0x8c018d8dU, 0x64b1d5d5U, 0xd29c4e4eU, 0xe049a9a9U,
158 0xb4d86c6cU, 0xfaac5656U, 0x07f3f4f4U, 0x25cfeaeaU,
159 0xafca6565U, 0x8ef47a7aU, 0xe947aeaeU, 0x18100808U,
160 0xd56fbabaU, 0x88f07878U, 0x6f4a2525U, 0x725c2e2eU,
161 0x24381c1cU, 0xf157a6a6U, 0xc773b4b4U, 0x5197c6c6U,
162 0x23cbe8e8U, 0x7ca1ddddU, 0x9ce87474U, 0x213e1f1fU,
163 0xdd964b4bU, 0xdc61bdbdU, 0x860d8b8bU, 0x850f8a8aU,
164 0x90e07070U, 0x427c3e3eU, 0xc471b5b5U, 0xaacc6666U,
165 0xd8904848U, 0x05060303U, 0x01f7f6f6U, 0x121c0e0eU,
166 0xa3c26161U, 0x5f6a3535U, 0xf9ae5757U, 0xd069b9b9U,
167 0x91178686U, 0x5899c1c1U, 0x273a1d1dU, 0xb9279e9eU,
168 0x38d9e1e1U, 0x13ebf8f8U, 0xb32b9898U, 0x33221111U,
169 0xbbd26969U, 0x70a9d9d9U, 0x89078e8eU, 0xa7339494U,
170 0xb62d9b9bU, 0x223c1e1eU, 0x92158787U, 0x20c9e9e9U,
171 0x4987ceceU, 0xffaa5555U, 0x78502828U, 0x7aa5dfdfU,
172 0x8f038c8cU, 0xf859a1a1U, 0x80098989U, 0x171a0d0dU,
173 0xda65bfbfU, 0x31d7e6e6U, 0xc6844242U, 0xb8d06868U,
174 0xc3824141U, 0xb0299999U, 0x775a2d2dU, 0x111e0f0fU,
175 0xcb7bb0b0U, 0xfca85454U, 0xd66dbbbbU, 0x3a2c1616U,
176};
177static const u32 Te2[256] = {
178 0x63a5c663U, 0x7c84f87cU, 0x7799ee77U, 0x7b8df67bU,
179 0xf20dfff2U, 0x6bbdd66bU, 0x6fb1de6fU, 0xc55491c5U,
180 0x30506030U, 0x01030201U, 0x67a9ce67U, 0x2b7d562bU,
181 0xfe19e7feU, 0xd762b5d7U, 0xabe64dabU, 0x769aec76U,
182 0xca458fcaU, 0x829d1f82U, 0xc94089c9U, 0x7d87fa7dU,
183 0xfa15effaU, 0x59ebb259U, 0x47c98e47U, 0xf00bfbf0U,
184 0xadec41adU, 0xd467b3d4U, 0xa2fd5fa2U, 0xafea45afU,
185 0x9cbf239cU, 0xa4f753a4U, 0x7296e472U, 0xc05b9bc0U,
186 0xb7c275b7U, 0xfd1ce1fdU, 0x93ae3d93U, 0x266a4c26U,
187 0x365a6c36U, 0x3f417e3fU, 0xf702f5f7U, 0xcc4f83ccU,
188 0x345c6834U, 0xa5f451a5U, 0xe534d1e5U, 0xf108f9f1U,
189 0x7193e271U, 0xd873abd8U, 0x31536231U, 0x153f2a15U,
190 0x040c0804U, 0xc75295c7U, 0x23654623U, 0xc35e9dc3U,
191 0x18283018U, 0x96a13796U, 0x050f0a05U, 0x9ab52f9aU,
192 0x07090e07U, 0x12362412U, 0x809b1b80U, 0xe23ddfe2U,
193 0xeb26cdebU, 0x27694e27U, 0xb2cd7fb2U, 0x759fea75U,
194 0x091b1209U, 0x839e1d83U, 0x2c74582cU, 0x1a2e341aU,
195 0x1b2d361bU, 0x6eb2dc6eU, 0x5aeeb45aU, 0xa0fb5ba0U,
196 0x52f6a452U, 0x3b4d763bU, 0xd661b7d6U, 0xb3ce7db3U,
197 0x297b5229U, 0xe33edde3U, 0x2f715e2fU, 0x84971384U,
198 0x53f5a653U, 0xd168b9d1U, 0x00000000U, 0xed2cc1edU,
199 0x20604020U, 0xfc1fe3fcU, 0xb1c879b1U, 0x5bedb65bU,
200 0x6abed46aU, 0xcb468dcbU, 0xbed967beU, 0x394b7239U,
201 0x4ade944aU, 0x4cd4984cU, 0x58e8b058U, 0xcf4a85cfU,
202 0xd06bbbd0U, 0xef2ac5efU, 0xaae54faaU, 0xfb16edfbU,
203 0x43c58643U, 0x4dd79a4dU, 0x33556633U, 0x85941185U,
204 0x45cf8a45U, 0xf910e9f9U, 0x02060402U, 0x7f81fe7fU,
205 0x50f0a050U, 0x3c44783cU, 0x9fba259fU, 0xa8e34ba8U,
206 0x51f3a251U, 0xa3fe5da3U, 0x40c08040U, 0x8f8a058fU,
207 0x92ad3f92U, 0x9dbc219dU, 0x38487038U, 0xf504f1f5U,
208 0xbcdf63bcU, 0xb6c177b6U, 0xda75afdaU, 0x21634221U,
209 0x10302010U, 0xff1ae5ffU, 0xf30efdf3U, 0xd26dbfd2U,
210 0xcd4c81cdU, 0x0c14180cU, 0x13352613U, 0xec2fc3ecU,
211 0x5fe1be5fU, 0x97a23597U, 0x44cc8844U, 0x17392e17U,
212 0xc45793c4U, 0xa7f255a7U, 0x7e82fc7eU, 0x3d477a3dU,
213 0x64acc864U, 0x5de7ba5dU, 0x192b3219U, 0x7395e673U,
214 0x60a0c060U, 0x81981981U, 0x4fd19e4fU, 0xdc7fa3dcU,
215 0x22664422U, 0x2a7e542aU, 0x90ab3b90U, 0x88830b88U,
216 0x46ca8c46U, 0xee29c7eeU, 0xb8d36bb8U, 0x143c2814U,
217 0xde79a7deU, 0x5ee2bc5eU, 0x0b1d160bU, 0xdb76addbU,
218 0xe03bdbe0U, 0x32566432U, 0x3a4e743aU, 0x0a1e140aU,
219 0x49db9249U, 0x060a0c06U, 0x246c4824U, 0x5ce4b85cU,
220 0xc25d9fc2U, 0xd36ebdd3U, 0xacef43acU, 0x62a6c462U,
221 0x91a83991U, 0x95a43195U, 0xe437d3e4U, 0x798bf279U,
222 0xe732d5e7U, 0xc8438bc8U, 0x37596e37U, 0x6db7da6dU,
223 0x8d8c018dU, 0xd564b1d5U, 0x4ed29c4eU, 0xa9e049a9U,
224 0x6cb4d86cU, 0x56faac56U, 0xf407f3f4U, 0xea25cfeaU,
225 0x65afca65U, 0x7a8ef47aU, 0xaee947aeU, 0x08181008U,
226 0xbad56fbaU, 0x7888f078U, 0x256f4a25U, 0x2e725c2eU,
227 0x1c24381cU, 0xa6f157a6U, 0xb4c773b4U, 0xc65197c6U,
228 0xe823cbe8U, 0xdd7ca1ddU, 0x749ce874U, 0x1f213e1fU,
229 0x4bdd964bU, 0xbddc61bdU, 0x8b860d8bU, 0x8a850f8aU,
230 0x7090e070U, 0x3e427c3eU, 0xb5c471b5U, 0x66aacc66U,
231 0x48d89048U, 0x03050603U, 0xf601f7f6U, 0x0e121c0eU,
232 0x61a3c261U, 0x355f6a35U, 0x57f9ae57U, 0xb9d069b9U,
233 0x86911786U, 0xc15899c1U, 0x1d273a1dU, 0x9eb9279eU,
234 0xe138d9e1U, 0xf813ebf8U, 0x98b32b98U, 0x11332211U,
235 0x69bbd269U, 0xd970a9d9U, 0x8e89078eU, 0x94a73394U,
236 0x9bb62d9bU, 0x1e223c1eU, 0x87921587U, 0xe920c9e9U,
237 0xce4987ceU, 0x55ffaa55U, 0x28785028U, 0xdf7aa5dfU,
238 0x8c8f038cU, 0xa1f859a1U, 0x89800989U, 0x0d171a0dU,
239 0xbfda65bfU, 0xe631d7e6U, 0x42c68442U, 0x68b8d068U,
240 0x41c38241U, 0x99b02999U, 0x2d775a2dU, 0x0f111e0fU,
241 0xb0cb7bb0U, 0x54fca854U, 0xbbd66dbbU, 0x163a2c16U,
242};
243static const u32 Te3[256] = {
244
245 0x6363a5c6U, 0x7c7c84f8U, 0x777799eeU, 0x7b7b8df6U,
246 0xf2f20dffU, 0x6b6bbdd6U, 0x6f6fb1deU, 0xc5c55491U,
247 0x30305060U, 0x01010302U, 0x6767a9ceU, 0x2b2b7d56U,
248 0xfefe19e7U, 0xd7d762b5U, 0xababe64dU, 0x76769aecU,
249 0xcaca458fU, 0x82829d1fU, 0xc9c94089U, 0x7d7d87faU,
250 0xfafa15efU, 0x5959ebb2U, 0x4747c98eU, 0xf0f00bfbU,
251 0xadadec41U, 0xd4d467b3U, 0xa2a2fd5fU, 0xafafea45U,
252 0x9c9cbf23U, 0xa4a4f753U, 0x727296e4U, 0xc0c05b9bU,
253 0xb7b7c275U, 0xfdfd1ce1U, 0x9393ae3dU, 0x26266a4cU,
254 0x36365a6cU, 0x3f3f417eU, 0xf7f702f5U, 0xcccc4f83U,
255 0x34345c68U, 0xa5a5f451U, 0xe5e534d1U, 0xf1f108f9U,
256 0x717193e2U, 0xd8d873abU, 0x31315362U, 0x15153f2aU,
257 0x04040c08U, 0xc7c75295U, 0x23236546U, 0xc3c35e9dU,
258 0x18182830U, 0x9696a137U, 0x05050f0aU, 0x9a9ab52fU,
259 0x0707090eU, 0x12123624U, 0x80809b1bU, 0xe2e23ddfU,
260 0xebeb26cdU, 0x2727694eU, 0xb2b2cd7fU, 0x75759feaU,
261 0x09091b12U, 0x83839e1dU, 0x2c2c7458U, 0x1a1a2e34U,
262 0x1b1b2d36U, 0x6e6eb2dcU, 0x5a5aeeb4U, 0xa0a0fb5bU,
263 0x5252f6a4U, 0x3b3b4d76U, 0xd6d661b7U, 0xb3b3ce7dU,
264 0x29297b52U, 0xe3e33eddU, 0x2f2f715eU, 0x84849713U,
265 0x5353f5a6U, 0xd1d168b9U, 0x00000000U, 0xeded2cc1U,
266 0x20206040U, 0xfcfc1fe3U, 0xb1b1c879U, 0x5b5bedb6U,
267 0x6a6abed4U, 0xcbcb468dU, 0xbebed967U, 0x39394b72U,
268 0x4a4ade94U, 0x4c4cd498U, 0x5858e8b0U, 0xcfcf4a85U,
269 0xd0d06bbbU, 0xefef2ac5U, 0xaaaae54fU, 0xfbfb16edU,
270 0x4343c586U, 0x4d4dd79aU, 0x33335566U, 0x85859411U,
271 0x4545cf8aU, 0xf9f910e9U, 0x02020604U, 0x7f7f81feU,
272 0x5050f0a0U, 0x3c3c4478U, 0x9f9fba25U, 0xa8a8e34bU,
273 0x5151f3a2U, 0xa3a3fe5dU, 0x4040c080U, 0x8f8f8a05U,
274 0x9292ad3fU, 0x9d9dbc21U, 0x38384870U, 0xf5f504f1U,
275 0xbcbcdf63U, 0xb6b6c177U, 0xdada75afU, 0x21216342U,
276 0x10103020U, 0xffff1ae5U, 0xf3f30efdU, 0xd2d26dbfU,
277 0xcdcd4c81U, 0x0c0c1418U, 0x13133526U, 0xecec2fc3U,
278 0x5f5fe1beU, 0x9797a235U, 0x4444cc88U, 0x1717392eU,
279 0xc4c45793U, 0xa7a7f255U, 0x7e7e82fcU, 0x3d3d477aU,
280 0x6464acc8U, 0x5d5de7baU, 0x19192b32U, 0x737395e6U,
281 0x6060a0c0U, 0x81819819U, 0x4f4fd19eU, 0xdcdc7fa3U,
282 0x22226644U, 0x2a2a7e54U, 0x9090ab3bU, 0x8888830bU,
283 0x4646ca8cU, 0xeeee29c7U, 0xb8b8d36bU, 0x14143c28U,
284 0xdede79a7U, 0x5e5ee2bcU, 0x0b0b1d16U, 0xdbdb76adU,
285 0xe0e03bdbU, 0x32325664U, 0x3a3a4e74U, 0x0a0a1e14U,
286 0x4949db92U, 0x06060a0cU, 0x24246c48U, 0x5c5ce4b8U,
287 0xc2c25d9fU, 0xd3d36ebdU, 0xacacef43U, 0x6262a6c4U,
288 0x9191a839U, 0x9595a431U, 0xe4e437d3U, 0x79798bf2U,
289 0xe7e732d5U, 0xc8c8438bU, 0x3737596eU, 0x6d6db7daU,
290 0x8d8d8c01U, 0xd5d564b1U, 0x4e4ed29cU, 0xa9a9e049U,
291 0x6c6cb4d8U, 0x5656faacU, 0xf4f407f3U, 0xeaea25cfU,
292 0x6565afcaU, 0x7a7a8ef4U, 0xaeaee947U, 0x08081810U,
293 0xbabad56fU, 0x787888f0U, 0x25256f4aU, 0x2e2e725cU,
294 0x1c1c2438U, 0xa6a6f157U, 0xb4b4c773U, 0xc6c65197U,
295 0xe8e823cbU, 0xdddd7ca1U, 0x74749ce8U, 0x1f1f213eU,
296 0x4b4bdd96U, 0xbdbddc61U, 0x8b8b860dU, 0x8a8a850fU,
297 0x707090e0U, 0x3e3e427cU, 0xb5b5c471U, 0x6666aaccU,
298 0x4848d890U, 0x03030506U, 0xf6f601f7U, 0x0e0e121cU,
299 0x6161a3c2U, 0x35355f6aU, 0x5757f9aeU, 0xb9b9d069U,
300 0x86869117U, 0xc1c15899U, 0x1d1d273aU, 0x9e9eb927U,
301 0xe1e138d9U, 0xf8f813ebU, 0x9898b32bU, 0x11113322U,
302 0x6969bbd2U, 0xd9d970a9U, 0x8e8e8907U, 0x9494a733U,
303 0x9b9bb62dU, 0x1e1e223cU, 0x87879215U, 0xe9e920c9U,
304 0xcece4987U, 0x5555ffaaU, 0x28287850U, 0xdfdf7aa5U,
305 0x8c8c8f03U, 0xa1a1f859U, 0x89898009U, 0x0d0d171aU,
306 0xbfbfda65U, 0xe6e631d7U, 0x4242c684U, 0x6868b8d0U,
307 0x4141c382U, 0x9999b029U, 0x2d2d775aU, 0x0f0f111eU,
308 0xb0b0cb7bU, 0x5454fca8U, 0xbbbbd66dU, 0x16163a2cU,
309};
310static const u32 Te4[256] = {
311 0x63636363U, 0x7c7c7c7cU, 0x77777777U, 0x7b7b7b7bU,
312 0xf2f2f2f2U, 0x6b6b6b6bU, 0x6f6f6f6fU, 0xc5c5c5c5U,
313 0x30303030U, 0x01010101U, 0x67676767U, 0x2b2b2b2bU,
314 0xfefefefeU, 0xd7d7d7d7U, 0xababababU, 0x76767676U,
315 0xcacacacaU, 0x82828282U, 0xc9c9c9c9U, 0x7d7d7d7dU,
316 0xfafafafaU, 0x59595959U, 0x47474747U, 0xf0f0f0f0U,
317 0xadadadadU, 0xd4d4d4d4U, 0xa2a2a2a2U, 0xafafafafU,
318 0x9c9c9c9cU, 0xa4a4a4a4U, 0x72727272U, 0xc0c0c0c0U,
319 0xb7b7b7b7U, 0xfdfdfdfdU, 0x93939393U, 0x26262626U,
320 0x36363636U, 0x3f3f3f3fU, 0xf7f7f7f7U, 0xccccccccU,
321 0x34343434U, 0xa5a5a5a5U, 0xe5e5e5e5U, 0xf1f1f1f1U,
322 0x71717171U, 0xd8d8d8d8U, 0x31313131U, 0x15151515U,
323 0x04040404U, 0xc7c7c7c7U, 0x23232323U, 0xc3c3c3c3U,
324 0x18181818U, 0x96969696U, 0x05050505U, 0x9a9a9a9aU,
325 0x07070707U, 0x12121212U, 0x80808080U, 0xe2e2e2e2U,
326 0xebebebebU, 0x27272727U, 0xb2b2b2b2U, 0x75757575U,
327 0x09090909U, 0x83838383U, 0x2c2c2c2cU, 0x1a1a1a1aU,
328 0x1b1b1b1bU, 0x6e6e6e6eU, 0x5a5a5a5aU, 0xa0a0a0a0U,
329 0x52525252U, 0x3b3b3b3bU, 0xd6d6d6d6U, 0xb3b3b3b3U,
330 0x29292929U, 0xe3e3e3e3U, 0x2f2f2f2fU, 0x84848484U,
331 0x53535353U, 0xd1d1d1d1U, 0x00000000U, 0xededededU,
332 0x20202020U, 0xfcfcfcfcU, 0xb1b1b1b1U, 0x5b5b5b5bU,
333 0x6a6a6a6aU, 0xcbcbcbcbU, 0xbebebebeU, 0x39393939U,
334 0x4a4a4a4aU, 0x4c4c4c4cU, 0x58585858U, 0xcfcfcfcfU,
335 0xd0d0d0d0U, 0xefefefefU, 0xaaaaaaaaU, 0xfbfbfbfbU,
336 0x43434343U, 0x4d4d4d4dU, 0x33333333U, 0x85858585U,
337 0x45454545U, 0xf9f9f9f9U, 0x02020202U, 0x7f7f7f7fU,
338 0x50505050U, 0x3c3c3c3cU, 0x9f9f9f9fU, 0xa8a8a8a8U,
339 0x51515151U, 0xa3a3a3a3U, 0x40404040U, 0x8f8f8f8fU,
340 0x92929292U, 0x9d9d9d9dU, 0x38383838U, 0xf5f5f5f5U,
341 0xbcbcbcbcU, 0xb6b6b6b6U, 0xdadadadaU, 0x21212121U,
342 0x10101010U, 0xffffffffU, 0xf3f3f3f3U, 0xd2d2d2d2U,
343 0xcdcdcdcdU, 0x0c0c0c0cU, 0x13131313U, 0xececececU,
344 0x5f5f5f5fU, 0x97979797U, 0x44444444U, 0x17171717U,
345 0xc4c4c4c4U, 0xa7a7a7a7U, 0x7e7e7e7eU, 0x3d3d3d3dU,
346 0x64646464U, 0x5d5d5d5dU, 0x19191919U, 0x73737373U,
347 0x60606060U, 0x81818181U, 0x4f4f4f4fU, 0xdcdcdcdcU,
348 0x22222222U, 0x2a2a2a2aU, 0x90909090U, 0x88888888U,
349 0x46464646U, 0xeeeeeeeeU, 0xb8b8b8b8U, 0x14141414U,
350 0xdedededeU, 0x5e5e5e5eU, 0x0b0b0b0bU, 0xdbdbdbdbU,
351 0xe0e0e0e0U, 0x32323232U, 0x3a3a3a3aU, 0x0a0a0a0aU,
352 0x49494949U, 0x06060606U, 0x24242424U, 0x5c5c5c5cU,
353 0xc2c2c2c2U, 0xd3d3d3d3U, 0xacacacacU, 0x62626262U,
354 0x91919191U, 0x95959595U, 0xe4e4e4e4U, 0x79797979U,
355 0xe7e7e7e7U, 0xc8c8c8c8U, 0x37373737U, 0x6d6d6d6dU,
356 0x8d8d8d8dU, 0xd5d5d5d5U, 0x4e4e4e4eU, 0xa9a9a9a9U,
357 0x6c6c6c6cU, 0x56565656U, 0xf4f4f4f4U, 0xeaeaeaeaU,
358 0x65656565U, 0x7a7a7a7aU, 0xaeaeaeaeU, 0x08080808U,
359 0xbabababaU, 0x78787878U, 0x25252525U, 0x2e2e2e2eU,
360 0x1c1c1c1cU, 0xa6a6a6a6U, 0xb4b4b4b4U, 0xc6c6c6c6U,
361 0xe8e8e8e8U, 0xddddddddU, 0x74747474U, 0x1f1f1f1fU,
362 0x4b4b4b4bU, 0xbdbdbdbdU, 0x8b8b8b8bU, 0x8a8a8a8aU,
363 0x70707070U, 0x3e3e3e3eU, 0xb5b5b5b5U, 0x66666666U,
364 0x48484848U, 0x03030303U, 0xf6f6f6f6U, 0x0e0e0e0eU,
365 0x61616161U, 0x35353535U, 0x57575757U, 0xb9b9b9b9U,
366 0x86868686U, 0xc1c1c1c1U, 0x1d1d1d1dU, 0x9e9e9e9eU,
367 0xe1e1e1e1U, 0xf8f8f8f8U, 0x98989898U, 0x11111111U,
368 0x69696969U, 0xd9d9d9d9U, 0x8e8e8e8eU, 0x94949494U,
369 0x9b9b9b9bU, 0x1e1e1e1eU, 0x87878787U, 0xe9e9e9e9U,
370 0xcecececeU, 0x55555555U, 0x28282828U, 0xdfdfdfdfU,
371 0x8c8c8c8cU, 0xa1a1a1a1U, 0x89898989U, 0x0d0d0d0dU,
372 0xbfbfbfbfU, 0xe6e6e6e6U, 0x42424242U, 0x68686868U,
373 0x41414141U, 0x99999999U, 0x2d2d2d2dU, 0x0f0f0f0fU,
374 0xb0b0b0b0U, 0x54545454U, 0xbbbbbbbbU, 0x16161616U,
375};
376static const u32 Td0[256] = {
377 0x51f4a750U, 0x7e416553U, 0x1a17a4c3U, 0x3a275e96U,
378 0x3bab6bcbU, 0x1f9d45f1U, 0xacfa58abU, 0x4be30393U,
379 0x2030fa55U, 0xad766df6U, 0x88cc7691U, 0xf5024c25U,
380 0x4fe5d7fcU, 0xc52acbd7U, 0x26354480U, 0xb562a38fU,
381 0xdeb15a49U, 0x25ba1b67U, 0x45ea0e98U, 0x5dfec0e1U,
382 0xc32f7502U, 0x814cf012U, 0x8d4697a3U, 0x6bd3f9c6U,
383 0x038f5fe7U, 0x15929c95U, 0xbf6d7aebU, 0x955259daU,
384 0xd4be832dU, 0x587421d3U, 0x49e06929U, 0x8ec9c844U,
385 0x75c2896aU, 0xf48e7978U, 0x99583e6bU, 0x27b971ddU,
386 0xbee14fb6U, 0xf088ad17U, 0xc920ac66U, 0x7dce3ab4U,
387 0x63df4a18U, 0xe51a3182U, 0x97513360U, 0x62537f45U,
388 0xb16477e0U, 0xbb6bae84U, 0xfe81a01cU, 0xf9082b94U,
389 0x70486858U, 0x8f45fd19U, 0x94de6c87U, 0x527bf8b7U,
390 0xab73d323U, 0x724b02e2U, 0xe31f8f57U, 0x6655ab2aU,
391 0xb2eb2807U, 0x2fb5c203U, 0x86c57b9aU, 0xd33708a5U,
392 0x302887f2U, 0x23bfa5b2U, 0x02036abaU, 0xed16825cU,
393 0x8acf1c2bU, 0xa779b492U, 0xf307f2f0U, 0x4e69e2a1U,
394 0x65daf4cdU, 0x0605bed5U, 0xd134621fU, 0xc4a6fe8aU,
395 0x342e539dU, 0xa2f355a0U, 0x058ae132U, 0xa4f6eb75U,
396 0x0b83ec39U, 0x4060efaaU, 0x5e719f06U, 0xbd6e1051U,
397 0x3e218af9U, 0x96dd063dU, 0xdd3e05aeU, 0x4de6bd46U,
398 0x91548db5U, 0x71c45d05U, 0x0406d46fU, 0x605015ffU,
399 0x1998fb24U, 0xd6bde997U, 0x894043ccU, 0x67d99e77U,
400 0xb0e842bdU, 0x07898b88U, 0xe7195b38U, 0x79c8eedbU,
401 0xa17c0a47U, 0x7c420fe9U, 0xf8841ec9U, 0x00000000U,
402 0x09808683U, 0x322bed48U, 0x1e1170acU, 0x6c5a724eU,
403 0xfd0efffbU, 0x0f853856U, 0x3daed51eU, 0x362d3927U,
404 0x0a0fd964U, 0x685ca621U, 0x9b5b54d1U, 0x24362e3aU,
405 0x0c0a67b1U, 0x9357e70fU, 0xb4ee96d2U, 0x1b9b919eU,
406 0x80c0c54fU, 0x61dc20a2U, 0x5a774b69U, 0x1c121a16U,
407 0xe293ba0aU, 0xc0a02ae5U, 0x3c22e043U, 0x121b171dU,
408 0x0e090d0bU, 0xf28bc7adU, 0x2db6a8b9U, 0x141ea9c8U,
409 0x57f11985U, 0xaf75074cU, 0xee99ddbbU, 0xa37f60fdU,
410 0xf701269fU, 0x5c72f5bcU, 0x44663bc5U, 0x5bfb7e34U,
411 0x8b432976U, 0xcb23c6dcU, 0xb6edfc68U, 0xb8e4f163U,
412 0xd731dccaU, 0x42638510U, 0x13972240U, 0x84c61120U,
413 0x854a247dU, 0xd2bb3df8U, 0xaef93211U, 0xc729a16dU,
414 0x1d9e2f4bU, 0xdcb230f3U, 0x0d8652ecU, 0x77c1e3d0U,
415 0x2bb3166cU, 0xa970b999U, 0x119448faU, 0x47e96422U,
416 0xa8fc8cc4U, 0xa0f03f1aU, 0x567d2cd8U, 0x223390efU,
417 0x87494ec7U, 0xd938d1c1U, 0x8ccaa2feU, 0x98d40b36U,
418 0xa6f581cfU, 0xa57ade28U, 0xdab78e26U, 0x3fadbfa4U,
419 0x2c3a9de4U, 0x5078920dU, 0x6a5fcc9bU, 0x547e4662U,
420 0xf68d13c2U, 0x90d8b8e8U, 0x2e39f75eU, 0x82c3aff5U,
421 0x9f5d80beU, 0x69d0937cU, 0x6fd52da9U, 0xcf2512b3U,
422 0xc8ac993bU, 0x10187da7U, 0xe89c636eU, 0xdb3bbb7bU,
423 0xcd267809U, 0x6e5918f4U, 0xec9ab701U, 0x834f9aa8U,
424 0xe6956e65U, 0xaaffe67eU, 0x21bccf08U, 0xef15e8e6U,
425 0xbae79bd9U, 0x4a6f36ceU, 0xea9f09d4U, 0x29b07cd6U,
426 0x31a4b2afU, 0x2a3f2331U, 0xc6a59430U, 0x35a266c0U,
427 0x744ebc37U, 0xfc82caa6U, 0xe090d0b0U, 0x33a7d815U,
428 0xf104984aU, 0x41ecdaf7U, 0x7fcd500eU, 0x1791f62fU,
429 0x764dd68dU, 0x43efb04dU, 0xccaa4d54U, 0xe49604dfU,
430 0x9ed1b5e3U, 0x4c6a881bU, 0xc12c1fb8U, 0x4665517fU,
431 0x9d5eea04U, 0x018c355dU, 0xfa877473U, 0xfb0b412eU,
432 0xb3671d5aU, 0x92dbd252U, 0xe9105633U, 0x6dd64713U,
433 0x9ad7618cU, 0x37a10c7aU, 0x59f8148eU, 0xeb133c89U,
434 0xcea927eeU, 0xb761c935U, 0xe11ce5edU, 0x7a47b13cU,
435 0x9cd2df59U, 0x55f2733fU, 0x1814ce79U, 0x73c737bfU,
436 0x53f7cdeaU, 0x5ffdaa5bU, 0xdf3d6f14U, 0x7844db86U,
437 0xcaaff381U, 0xb968c43eU, 0x3824342cU, 0xc2a3405fU,
438 0x161dc372U, 0xbce2250cU, 0x283c498bU, 0xff0d9541U,
439 0x39a80171U, 0x080cb3deU, 0xd8b4e49cU, 0x6456c190U,
440 0x7bcb8461U, 0xd532b670U, 0x486c5c74U, 0xd0b85742U,
441};
442static const u32 Td1[256] = {
443 0x5051f4a7U, 0x537e4165U, 0xc31a17a4U, 0x963a275eU,
444 0xcb3bab6bU, 0xf11f9d45U, 0xabacfa58U, 0x934be303U,
445 0x552030faU, 0xf6ad766dU, 0x9188cc76U, 0x25f5024cU,
446 0xfc4fe5d7U, 0xd7c52acbU, 0x80263544U, 0x8fb562a3U,
447 0x49deb15aU, 0x6725ba1bU, 0x9845ea0eU, 0xe15dfec0U,
448 0x02c32f75U, 0x12814cf0U, 0xa38d4697U, 0xc66bd3f9U,
449 0xe7038f5fU, 0x9515929cU, 0xebbf6d7aU, 0xda955259U,
450 0x2dd4be83U, 0xd3587421U, 0x2949e069U, 0x448ec9c8U,
451 0x6a75c289U, 0x78f48e79U, 0x6b99583eU, 0xdd27b971U,
452 0xb6bee14fU, 0x17f088adU, 0x66c920acU, 0xb47dce3aU,
453 0x1863df4aU, 0x82e51a31U, 0x60975133U, 0x4562537fU,
454 0xe0b16477U, 0x84bb6baeU, 0x1cfe81a0U, 0x94f9082bU,
455 0x58704868U, 0x198f45fdU, 0x8794de6cU, 0xb7527bf8U,
456 0x23ab73d3U, 0xe2724b02U, 0x57e31f8fU, 0x2a6655abU,
457 0x07b2eb28U, 0x032fb5c2U, 0x9a86c57bU, 0xa5d33708U,
458 0xf2302887U, 0xb223bfa5U, 0xba02036aU, 0x5ced1682U,
459 0x2b8acf1cU, 0x92a779b4U, 0xf0f307f2U, 0xa14e69e2U,
460 0xcd65daf4U, 0xd50605beU, 0x1fd13462U, 0x8ac4a6feU,
461 0x9d342e53U, 0xa0a2f355U, 0x32058ae1U, 0x75a4f6ebU,
462 0x390b83ecU, 0xaa4060efU, 0x065e719fU, 0x51bd6e10U,
463 0xf93e218aU, 0x3d96dd06U, 0xaedd3e05U, 0x464de6bdU,
464 0xb591548dU, 0x0571c45dU, 0x6f0406d4U, 0xff605015U,
465 0x241998fbU, 0x97d6bde9U, 0xcc894043U, 0x7767d99eU,
466 0xbdb0e842U, 0x8807898bU, 0x38e7195bU, 0xdb79c8eeU,
467 0x47a17c0aU, 0xe97c420fU, 0xc9f8841eU, 0x00000000U,
468 0x83098086U, 0x48322bedU, 0xac1e1170U, 0x4e6c5a72U,
469 0xfbfd0effU, 0x560f8538U, 0x1e3daed5U, 0x27362d39U,
470 0x640a0fd9U, 0x21685ca6U, 0xd19b5b54U, 0x3a24362eU,
471 0xb10c0a67U, 0x0f9357e7U, 0xd2b4ee96U, 0x9e1b9b91U,
472 0x4f80c0c5U, 0xa261dc20U, 0x695a774bU, 0x161c121aU,
473 0x0ae293baU, 0xe5c0a02aU, 0x433c22e0U, 0x1d121b17U,
474 0x0b0e090dU, 0xadf28bc7U, 0xb92db6a8U, 0xc8141ea9U,
475 0x8557f119U, 0x4caf7507U, 0xbbee99ddU, 0xfda37f60U,
476 0x9ff70126U, 0xbc5c72f5U, 0xc544663bU, 0x345bfb7eU,
477 0x768b4329U, 0xdccb23c6U, 0x68b6edfcU, 0x63b8e4f1U,
478 0xcad731dcU, 0x10426385U, 0x40139722U, 0x2084c611U,
479 0x7d854a24U, 0xf8d2bb3dU, 0x11aef932U, 0x6dc729a1U,
480 0x4b1d9e2fU, 0xf3dcb230U, 0xec0d8652U, 0xd077c1e3U,
481 0x6c2bb316U, 0x99a970b9U, 0xfa119448U, 0x2247e964U,
482 0xc4a8fc8cU, 0x1aa0f03fU, 0xd8567d2cU, 0xef223390U,
483 0xc787494eU, 0xc1d938d1U, 0xfe8ccaa2U, 0x3698d40bU,
484 0xcfa6f581U, 0x28a57adeU, 0x26dab78eU, 0xa43fadbfU,
485 0xe42c3a9dU, 0x0d507892U, 0x9b6a5fccU, 0x62547e46U,
486 0xc2f68d13U, 0xe890d8b8U, 0x5e2e39f7U, 0xf582c3afU,
487 0xbe9f5d80U, 0x7c69d093U, 0xa96fd52dU, 0xb3cf2512U,
488 0x3bc8ac99U, 0xa710187dU, 0x6ee89c63U, 0x7bdb3bbbU,
489 0x09cd2678U, 0xf46e5918U, 0x01ec9ab7U, 0xa8834f9aU,
490 0x65e6956eU, 0x7eaaffe6U, 0x0821bccfU, 0xe6ef15e8U,
491 0xd9bae79bU, 0xce4a6f36U, 0xd4ea9f09U, 0xd629b07cU,
492 0xaf31a4b2U, 0x312a3f23U, 0x30c6a594U, 0xc035a266U,
493 0x37744ebcU, 0xa6fc82caU, 0xb0e090d0U, 0x1533a7d8U,
494 0x4af10498U, 0xf741ecdaU, 0x0e7fcd50U, 0x2f1791f6U,
495 0x8d764dd6U, 0x4d43efb0U, 0x54ccaa4dU, 0xdfe49604U,
496 0xe39ed1b5U, 0x1b4c6a88U, 0xb8c12c1fU, 0x7f466551U,
497 0x049d5eeaU, 0x5d018c35U, 0x73fa8774U, 0x2efb0b41U,
498 0x5ab3671dU, 0x5292dbd2U, 0x33e91056U, 0x136dd647U,
499 0x8c9ad761U, 0x7a37a10cU, 0x8e59f814U, 0x89eb133cU,
500 0xeecea927U, 0x35b761c9U, 0xede11ce5U, 0x3c7a47b1U,
501 0x599cd2dfU, 0x3f55f273U, 0x791814ceU, 0xbf73c737U,
502 0xea53f7cdU, 0x5b5ffdaaU, 0x14df3d6fU, 0x867844dbU,
503 0x81caaff3U, 0x3eb968c4U, 0x2c382434U, 0x5fc2a340U,
504 0x72161dc3U, 0x0cbce225U, 0x8b283c49U, 0x41ff0d95U,
505 0x7139a801U, 0xde080cb3U, 0x9cd8b4e4U, 0x906456c1U,
506 0x617bcb84U, 0x70d532b6U, 0x74486c5cU, 0x42d0b857U,
507};
508static const u32 Td2[256] = {
509 0xa75051f4U, 0x65537e41U, 0xa4c31a17U, 0x5e963a27U,
510 0x6bcb3babU, 0x45f11f9dU, 0x58abacfaU, 0x03934be3U,
511 0xfa552030U, 0x6df6ad76U, 0x769188ccU, 0x4c25f502U,
512 0xd7fc4fe5U, 0xcbd7c52aU, 0x44802635U, 0xa38fb562U,
513 0x5a49deb1U, 0x1b6725baU, 0x0e9845eaU, 0xc0e15dfeU,
514 0x7502c32fU, 0xf012814cU, 0x97a38d46U, 0xf9c66bd3U,
515 0x5fe7038fU, 0x9c951592U, 0x7aebbf6dU, 0x59da9552U,
516 0x832dd4beU, 0x21d35874U, 0x692949e0U, 0xc8448ec9U,
517 0x896a75c2U, 0x7978f48eU, 0x3e6b9958U, 0x71dd27b9U,
518 0x4fb6bee1U, 0xad17f088U, 0xac66c920U, 0x3ab47dceU,
519 0x4a1863dfU, 0x3182e51aU, 0x33609751U, 0x7f456253U,
520 0x77e0b164U, 0xae84bb6bU, 0xa01cfe81U, 0x2b94f908U,
521 0x68587048U, 0xfd198f45U, 0x6c8794deU, 0xf8b7527bU,
522 0xd323ab73U, 0x02e2724bU, 0x8f57e31fU, 0xab2a6655U,
523 0x2807b2ebU, 0xc2032fb5U, 0x7b9a86c5U, 0x08a5d337U,
524 0x87f23028U, 0xa5b223bfU, 0x6aba0203U, 0x825ced16U,
525 0x1c2b8acfU, 0xb492a779U, 0xf2f0f307U, 0xe2a14e69U,
526 0xf4cd65daU, 0xbed50605U, 0x621fd134U, 0xfe8ac4a6U,
527 0x539d342eU, 0x55a0a2f3U, 0xe132058aU, 0xeb75a4f6U,
528 0xec390b83U, 0xefaa4060U, 0x9f065e71U, 0x1051bd6eU,
529
530 0x8af93e21U, 0x063d96ddU, 0x05aedd3eU, 0xbd464de6U,
531 0x8db59154U, 0x5d0571c4U, 0xd46f0406U, 0x15ff6050U,
532 0xfb241998U, 0xe997d6bdU, 0x43cc8940U, 0x9e7767d9U,
533 0x42bdb0e8U, 0x8b880789U, 0x5b38e719U, 0xeedb79c8U,
534 0x0a47a17cU, 0x0fe97c42U, 0x1ec9f884U, 0x00000000U,
535 0x86830980U, 0xed48322bU, 0x70ac1e11U, 0x724e6c5aU,
536 0xfffbfd0eU, 0x38560f85U, 0xd51e3daeU, 0x3927362dU,
537 0xd9640a0fU, 0xa621685cU, 0x54d19b5bU, 0x2e3a2436U,
538 0x67b10c0aU, 0xe70f9357U, 0x96d2b4eeU, 0x919e1b9bU,
539 0xc54f80c0U, 0x20a261dcU, 0x4b695a77U, 0x1a161c12U,
540 0xba0ae293U, 0x2ae5c0a0U, 0xe0433c22U, 0x171d121bU,
541 0x0d0b0e09U, 0xc7adf28bU, 0xa8b92db6U, 0xa9c8141eU,
542 0x198557f1U, 0x074caf75U, 0xddbbee99U, 0x60fda37fU,
543 0x269ff701U, 0xf5bc5c72U, 0x3bc54466U, 0x7e345bfbU,
544 0x29768b43U, 0xc6dccb23U, 0xfc68b6edU, 0xf163b8e4U,
545 0xdccad731U, 0x85104263U, 0x22401397U, 0x112084c6U,
546 0x247d854aU, 0x3df8d2bbU, 0x3211aef9U, 0xa16dc729U,
547 0x2f4b1d9eU, 0x30f3dcb2U, 0x52ec0d86U, 0xe3d077c1U,
548 0x166c2bb3U, 0xb999a970U, 0x48fa1194U, 0x642247e9U,
549 0x8cc4a8fcU, 0x3f1aa0f0U, 0x2cd8567dU, 0x90ef2233U,
550 0x4ec78749U, 0xd1c1d938U, 0xa2fe8ccaU, 0x0b3698d4U,
551 0x81cfa6f5U, 0xde28a57aU, 0x8e26dab7U, 0xbfa43fadU,
552 0x9de42c3aU, 0x920d5078U, 0xcc9b6a5fU, 0x4662547eU,
553 0x13c2f68dU, 0xb8e890d8U, 0xf75e2e39U, 0xaff582c3U,
554 0x80be9f5dU, 0x937c69d0U, 0x2da96fd5U, 0x12b3cf25U,
555 0x993bc8acU, 0x7da71018U, 0x636ee89cU, 0xbb7bdb3bU,
556 0x7809cd26U, 0x18f46e59U, 0xb701ec9aU, 0x9aa8834fU,
557 0x6e65e695U, 0xe67eaaffU, 0xcf0821bcU, 0xe8e6ef15U,
558 0x9bd9bae7U, 0x36ce4a6fU, 0x09d4ea9fU, 0x7cd629b0U,
559 0xb2af31a4U, 0x23312a3fU, 0x9430c6a5U, 0x66c035a2U,
560 0xbc37744eU, 0xcaa6fc82U, 0xd0b0e090U, 0xd81533a7U,
561 0x984af104U, 0xdaf741ecU, 0x500e7fcdU, 0xf62f1791U,
562 0xd68d764dU, 0xb04d43efU, 0x4d54ccaaU, 0x04dfe496U,
563 0xb5e39ed1U, 0x881b4c6aU, 0x1fb8c12cU, 0x517f4665U,
564 0xea049d5eU, 0x355d018cU, 0x7473fa87U, 0x412efb0bU,
565 0x1d5ab367U, 0xd25292dbU, 0x5633e910U, 0x47136dd6U,
566 0x618c9ad7U, 0x0c7a37a1U, 0x148e59f8U, 0x3c89eb13U,
567 0x27eecea9U, 0xc935b761U, 0xe5ede11cU, 0xb13c7a47U,
568 0xdf599cd2U, 0x733f55f2U, 0xce791814U, 0x37bf73c7U,
569 0xcdea53f7U, 0xaa5b5ffdU, 0x6f14df3dU, 0xdb867844U,
570 0xf381caafU, 0xc43eb968U, 0x342c3824U, 0x405fc2a3U,
571 0xc372161dU, 0x250cbce2U, 0x498b283cU, 0x9541ff0dU,
572 0x017139a8U, 0xb3de080cU, 0xe49cd8b4U, 0xc1906456U,
573 0x84617bcbU, 0xb670d532U, 0x5c74486cU, 0x5742d0b8U,
574};
575static const u32 Td3[256] = {
576 0xf4a75051U, 0x4165537eU, 0x17a4c31aU, 0x275e963aU,
577 0xab6bcb3bU, 0x9d45f11fU, 0xfa58abacU, 0xe303934bU,
578 0x30fa5520U, 0x766df6adU, 0xcc769188U, 0x024c25f5U,
579 0xe5d7fc4fU, 0x2acbd7c5U, 0x35448026U, 0x62a38fb5U,
580 0xb15a49deU, 0xba1b6725U, 0xea0e9845U, 0xfec0e15dU,
581 0x2f7502c3U, 0x4cf01281U, 0x4697a38dU, 0xd3f9c66bU,
582 0x8f5fe703U, 0x929c9515U, 0x6d7aebbfU, 0x5259da95U,
583 0xbe832dd4U, 0x7421d358U, 0xe0692949U, 0xc9c8448eU,
584 0xc2896a75U, 0x8e7978f4U, 0x583e6b99U, 0xb971dd27U,
585 0xe14fb6beU, 0x88ad17f0U, 0x20ac66c9U, 0xce3ab47dU,
586 0xdf4a1863U, 0x1a3182e5U, 0x51336097U, 0x537f4562U,
587 0x6477e0b1U, 0x6bae84bbU, 0x81a01cfeU, 0x082b94f9U,
588 0x48685870U, 0x45fd198fU, 0xde6c8794U, 0x7bf8b752U,
589 0x73d323abU, 0x4b02e272U, 0x1f8f57e3U, 0x55ab2a66U,
590 0xeb2807b2U, 0xb5c2032fU, 0xc57b9a86U, 0x3708a5d3U,
591 0x2887f230U, 0xbfa5b223U, 0x036aba02U, 0x16825cedU,
592 0xcf1c2b8aU, 0x79b492a7U, 0x07f2f0f3U, 0x69e2a14eU,
593 0xdaf4cd65U, 0x05bed506U, 0x34621fd1U, 0xa6fe8ac4U,
594 0x2e539d34U, 0xf355a0a2U, 0x8ae13205U, 0xf6eb75a4U,
595 0x83ec390bU, 0x60efaa40U, 0x719f065eU, 0x6e1051bdU,
596 0x218af93eU, 0xdd063d96U, 0x3e05aeddU, 0xe6bd464dU,
597 0x548db591U, 0xc45d0571U, 0x06d46f04U, 0x5015ff60U,
598 0x98fb2419U, 0xbde997d6U, 0x4043cc89U, 0xd99e7767U,
599 0xe842bdb0U, 0x898b8807U, 0x195b38e7U, 0xc8eedb79U,
600 0x7c0a47a1U, 0x420fe97cU, 0x841ec9f8U, 0x00000000U,
601 0x80868309U, 0x2bed4832U, 0x1170ac1eU, 0x5a724e6cU,
602 0x0efffbfdU, 0x8538560fU, 0xaed51e3dU, 0x2d392736U,
603 0x0fd9640aU, 0x5ca62168U, 0x5b54d19bU, 0x362e3a24U,
604 0x0a67b10cU, 0x57e70f93U, 0xee96d2b4U, 0x9b919e1bU,
605 0xc0c54f80U, 0xdc20a261U, 0x774b695aU, 0x121a161cU,
606 0x93ba0ae2U, 0xa02ae5c0U, 0x22e0433cU, 0x1b171d12U,
607 0x090d0b0eU, 0x8bc7adf2U, 0xb6a8b92dU, 0x1ea9c814U,
608 0xf1198557U, 0x75074cafU, 0x99ddbbeeU, 0x7f60fda3U,
609 0x01269ff7U, 0x72f5bc5cU, 0x663bc544U, 0xfb7e345bU,
610 0x4329768bU, 0x23c6dccbU, 0xedfc68b6U, 0xe4f163b8U,
611 0x31dccad7U, 0x63851042U, 0x97224013U, 0xc6112084U,
612 0x4a247d85U, 0xbb3df8d2U, 0xf93211aeU, 0x29a16dc7U,
613 0x9e2f4b1dU, 0xb230f3dcU, 0x8652ec0dU, 0xc1e3d077U,
614 0xb3166c2bU, 0x70b999a9U, 0x9448fa11U, 0xe9642247U,
615 0xfc8cc4a8U, 0xf03f1aa0U, 0x7d2cd856U, 0x3390ef22U,
616 0x494ec787U, 0x38d1c1d9U, 0xcaa2fe8cU, 0xd40b3698U,
617 0xf581cfa6U, 0x7ade28a5U, 0xb78e26daU, 0xadbfa43fU,
618 0x3a9de42cU, 0x78920d50U, 0x5fcc9b6aU, 0x7e466254U,
619 0x8d13c2f6U, 0xd8b8e890U, 0x39f75e2eU, 0xc3aff582U,
620 0x5d80be9fU, 0xd0937c69U, 0xd52da96fU, 0x2512b3cfU,
621 0xac993bc8U, 0x187da710U, 0x9c636ee8U, 0x3bbb7bdbU,
622 0x267809cdU, 0x5918f46eU, 0x9ab701ecU, 0x4f9aa883U,
623 0x956e65e6U, 0xffe67eaaU, 0xbccf0821U, 0x15e8e6efU,
624 0xe79bd9baU, 0x6f36ce4aU, 0x9f09d4eaU, 0xb07cd629U,
625 0xa4b2af31U, 0x3f23312aU, 0xa59430c6U, 0xa266c035U,
626 0x4ebc3774U, 0x82caa6fcU, 0x90d0b0e0U, 0xa7d81533U,
627 0x04984af1U, 0xecdaf741U, 0xcd500e7fU, 0x91f62f17U,
628 0x4dd68d76U, 0xefb04d43U, 0xaa4d54ccU, 0x9604dfe4U,
629 0xd1b5e39eU, 0x6a881b4cU, 0x2c1fb8c1U, 0x65517f46U,
630 0x5eea049dU, 0x8c355d01U, 0x877473faU, 0x0b412efbU,
631 0x671d5ab3U, 0xdbd25292U, 0x105633e9U, 0xd647136dU,
632 0xd7618c9aU, 0xa10c7a37U, 0xf8148e59U, 0x133c89ebU,
633 0xa927eeceU, 0x61c935b7U, 0x1ce5ede1U, 0x47b13c7aU,
634 0xd2df599cU, 0xf2733f55U, 0x14ce7918U, 0xc737bf73U,
635 0xf7cdea53U, 0xfdaa5b5fU, 0x3d6f14dfU, 0x44db8678U,
636 0xaff381caU, 0x68c43eb9U, 0x24342c38U, 0xa3405fc2U,
637 0x1dc37216U, 0xe2250cbcU, 0x3c498b28U, 0x0d9541ffU,
638 0xa8017139U, 0x0cb3de08U, 0xb4e49cd8U, 0x56c19064U,
639 0xcb84617bU, 0x32b670d5U, 0x6c5c7448U, 0xb85742d0U,
640};
641static const u32 Td4[256] = {
642 0x52525252U, 0x09090909U, 0x6a6a6a6aU, 0xd5d5d5d5U,
643 0x30303030U, 0x36363636U, 0xa5a5a5a5U, 0x38383838U,
644 0xbfbfbfbfU, 0x40404040U, 0xa3a3a3a3U, 0x9e9e9e9eU,
645 0x81818181U, 0xf3f3f3f3U, 0xd7d7d7d7U, 0xfbfbfbfbU,
646 0x7c7c7c7cU, 0xe3e3e3e3U, 0x39393939U, 0x82828282U,
647 0x9b9b9b9bU, 0x2f2f2f2fU, 0xffffffffU, 0x87878787U,
648 0x34343434U, 0x8e8e8e8eU, 0x43434343U, 0x44444444U,
649 0xc4c4c4c4U, 0xdedededeU, 0xe9e9e9e9U, 0xcbcbcbcbU,
650 0x54545454U, 0x7b7b7b7bU, 0x94949494U, 0x32323232U,
651 0xa6a6a6a6U, 0xc2c2c2c2U, 0x23232323U, 0x3d3d3d3dU,
652 0xeeeeeeeeU, 0x4c4c4c4cU, 0x95959595U, 0x0b0b0b0bU,
653 0x42424242U, 0xfafafafaU, 0xc3c3c3c3U, 0x4e4e4e4eU,
654 0x08080808U, 0x2e2e2e2eU, 0xa1a1a1a1U, 0x66666666U,
655 0x28282828U, 0xd9d9d9d9U, 0x24242424U, 0xb2b2b2b2U,
656 0x76767676U, 0x5b5b5b5bU, 0xa2a2a2a2U, 0x49494949U,
657 0x6d6d6d6dU, 0x8b8b8b8bU, 0xd1d1d1d1U, 0x25252525U,
658 0x72727272U, 0xf8f8f8f8U, 0xf6f6f6f6U, 0x64646464U,
659 0x86868686U, 0x68686868U, 0x98989898U, 0x16161616U,
660 0xd4d4d4d4U, 0xa4a4a4a4U, 0x5c5c5c5cU, 0xccccccccU,
661 0x5d5d5d5dU, 0x65656565U, 0xb6b6b6b6U, 0x92929292U,
662 0x6c6c6c6cU, 0x70707070U, 0x48484848U, 0x50505050U,
663 0xfdfdfdfdU, 0xededededU, 0xb9b9b9b9U, 0xdadadadaU,
664 0x5e5e5e5eU, 0x15151515U, 0x46464646U, 0x57575757U,
665 0xa7a7a7a7U, 0x8d8d8d8dU, 0x9d9d9d9dU, 0x84848484U,
666 0x90909090U, 0xd8d8d8d8U, 0xababababU, 0x00000000U,
667 0x8c8c8c8cU, 0xbcbcbcbcU, 0xd3d3d3d3U, 0x0a0a0a0aU,
668 0xf7f7f7f7U, 0xe4e4e4e4U, 0x58585858U, 0x05050505U,
669 0xb8b8b8b8U, 0xb3b3b3b3U, 0x45454545U, 0x06060606U,
670 0xd0d0d0d0U, 0x2c2c2c2cU, 0x1e1e1e1eU, 0x8f8f8f8fU,
671 0xcacacacaU, 0x3f3f3f3fU, 0x0f0f0f0fU, 0x02020202U,
672 0xc1c1c1c1U, 0xafafafafU, 0xbdbdbdbdU, 0x03030303U,
673 0x01010101U, 0x13131313U, 0x8a8a8a8aU, 0x6b6b6b6bU,
674 0x3a3a3a3aU, 0x91919191U, 0x11111111U, 0x41414141U,
675 0x4f4f4f4fU, 0x67676767U, 0xdcdcdcdcU, 0xeaeaeaeaU,
676 0x97979797U, 0xf2f2f2f2U, 0xcfcfcfcfU, 0xcecececeU,
677 0xf0f0f0f0U, 0xb4b4b4b4U, 0xe6e6e6e6U, 0x73737373U,
678 0x96969696U, 0xacacacacU, 0x74747474U, 0x22222222U,
679 0xe7e7e7e7U, 0xadadadadU, 0x35353535U, 0x85858585U,
680 0xe2e2e2e2U, 0xf9f9f9f9U, 0x37373737U, 0xe8e8e8e8U,
681 0x1c1c1c1cU, 0x75757575U, 0xdfdfdfdfU, 0x6e6e6e6eU,
682 0x47474747U, 0xf1f1f1f1U, 0x1a1a1a1aU, 0x71717171U,
683 0x1d1d1d1dU, 0x29292929U, 0xc5c5c5c5U, 0x89898989U,
684 0x6f6f6f6fU, 0xb7b7b7b7U, 0x62626262U, 0x0e0e0e0eU,
685 0xaaaaaaaaU, 0x18181818U, 0xbebebebeU, 0x1b1b1b1bU,
686 0xfcfcfcfcU, 0x56565656U, 0x3e3e3e3eU, 0x4b4b4b4bU,
687 0xc6c6c6c6U, 0xd2d2d2d2U, 0x79797979U, 0x20202020U,
688 0x9a9a9a9aU, 0xdbdbdbdbU, 0xc0c0c0c0U, 0xfefefefeU,
689 0x78787878U, 0xcdcdcdcdU, 0x5a5a5a5aU, 0xf4f4f4f4U,
690 0x1f1f1f1fU, 0xddddddddU, 0xa8a8a8a8U, 0x33333333U,
691 0x88888888U, 0x07070707U, 0xc7c7c7c7U, 0x31313131U,
692 0xb1b1b1b1U, 0x12121212U, 0x10101010U, 0x59595959U,
693 0x27272727U, 0x80808080U, 0xececececU, 0x5f5f5f5fU,
694 0x60606060U, 0x51515151U, 0x7f7f7f7fU, 0xa9a9a9a9U,
695 0x19191919U, 0xb5b5b5b5U, 0x4a4a4a4aU, 0x0d0d0d0dU,
696 0x2d2d2d2dU, 0xe5e5e5e5U, 0x7a7a7a7aU, 0x9f9f9f9fU,
697 0x93939393U, 0xc9c9c9c9U, 0x9c9c9c9cU, 0xefefefefU,
698 0xa0a0a0a0U, 0xe0e0e0e0U, 0x3b3b3b3bU, 0x4d4d4d4dU,
699 0xaeaeaeaeU, 0x2a2a2a2aU, 0xf5f5f5f5U, 0xb0b0b0b0U,
700 0xc8c8c8c8U, 0xebebebebU, 0xbbbbbbbbU, 0x3c3c3c3cU,
701 0x83838383U, 0x53535353U, 0x99999999U, 0x61616161U,
702 0x17171717U, 0x2b2b2b2bU, 0x04040404U, 0x7e7e7e7eU,
703 0xbabababaU, 0x77777777U, 0xd6d6d6d6U, 0x26262626U,
704 0xe1e1e1e1U, 0x69696969U, 0x14141414U, 0x63636363U,
705 0x55555555U, 0x21212121U, 0x0c0c0c0cU, 0x7d7d7d7dU,
706};
707static const u32 rcon[] = {
708 0x01000000, 0x02000000, 0x04000000, 0x08000000,
709 0x10000000, 0x20000000, 0x40000000, 0x80000000,
710 0x1B000000, 0x36000000, /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */
711};
712
713#define SWAP(x) (_lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00)
714
715#ifdef _MSC_VER
716#define GETU32(p) SWAP(*((u32 *)(p)))
717#define PUTU32(ct, st) { *((u32 *)(ct)) = SWAP((st)); }
718#else
719#define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ ((u32)(pt)[2] << 8) ^ ((u32)(pt)[3]))
720#define PUTU32(ct, st) { (ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); (ct)[2] = (u8)((st) >> 8); (ct)[3] = (u8)(st); }
721#endif
722
723/**
724 * Expand the cipher key into the encryption key schedule.
725 *
726 * @return the number of rounds for the given cipher key size.
727 */
728int rijndaelKeySetupEnc(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits) {
729 int i = 0;
730 u32 temp;
731
732 rk[0] = GETU32(cipherKey );
733 rk[1] = GETU32(cipherKey + 4);
734 rk[2] = GETU32(cipherKey + 8);
735 rk[3] = GETU32(cipherKey + 12);
736 if (keyBits == 128) {
737 for (;;) {
738 temp = rk[3];
739 rk[4] = rk[0] ^
740 (Te4[(temp >> 16) & 0xff] & 0xff000000) ^
741 (Te4[(temp >> 8) & 0xff] & 0x00ff0000) ^
742 (Te4[(temp ) & 0xff] & 0x0000ff00) ^
743 (Te4[(temp >> 24) ] & 0x000000ff) ^
744 rcon[i];
745 rk[5] = rk[1] ^ rk[4];
746 rk[6] = rk[2] ^ rk[5];
747 rk[7] = rk[3] ^ rk[6];
748 if (++i == 10) {
749 return 10;
750 }
751 rk += 4;
752 }
753 }
754 rk[4] = GETU32(cipherKey + 16);
755 rk[5] = GETU32(cipherKey + 20);
756 if (keyBits == 192) {
757 for (;;) {
758 temp = rk[ 5];
759 rk[ 6] = rk[ 0] ^
760 (Te4[(temp >> 16) & 0xff] & 0xff000000) ^
761 (Te4[(temp >> 8) & 0xff] & 0x00ff0000) ^
762 (Te4[(temp ) & 0xff] & 0x0000ff00) ^
763 (Te4[(temp >> 24) ] & 0x000000ff) ^
764 rcon[i];
765 rk[ 7] = rk[ 1] ^ rk[ 6];
766 rk[ 8] = rk[ 2] ^ rk[ 7];
767 rk[ 9] = rk[ 3] ^ rk[ 8];
768 if (++i == 8) {
769 return 12;
770 }
771 rk[10] = rk[ 4] ^ rk[ 9];
772 rk[11] = rk[ 5] ^ rk[10];
773 rk += 6;
774 }
775 }
776 rk[6] = GETU32(cipherKey + 24);
777 rk[7] = GETU32(cipherKey + 28);
778 if (keyBits == 256) {
779 for (;;) {
780 temp = rk[ 7];
781 rk[ 8] = rk[ 0] ^
782 (Te4[(temp >> 16) & 0xff] & 0xff000000) ^
783 (Te4[(temp >> 8) & 0xff] & 0x00ff0000) ^
784 (Te4[(temp ) & 0xff] & 0x0000ff00) ^
785 (Te4[(temp >> 24) ] & 0x000000ff) ^
786 rcon[i];
787 rk[ 9] = rk[ 1] ^ rk[ 8];
788 rk[10] = rk[ 2] ^ rk[ 9];
789 rk[11] = rk[ 3] ^ rk[10];
790 if (++i == 7) {
791 return 14;
792 }
793 temp = rk[11];
794 rk[12] = rk[ 4] ^
795 (Te4[(temp >> 24) ] & 0xff000000) ^
796 (Te4[(temp >> 16) & 0xff] & 0x00ff0000) ^
797 (Te4[(temp >> 8) & 0xff] & 0x0000ff00) ^
798 (Te4[(temp ) & 0xff] & 0x000000ff);
799 rk[13] = rk[ 5] ^ rk[12];
800 rk[14] = rk[ 6] ^ rk[13];
801 rk[15] = rk[ 7] ^ rk[14];
802
803 rk += 8;
804 }
805 }
806 return 0;
807}
808
809/**
810 * Expand the cipher key into the decryption key schedule.
811 *
812 * @return the number of rounds for the given cipher key size.
813 */
814int rijndaelKeySetupDec(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits) {
815 int Nr, i, j;
816 u32 temp;
817
818 /* expand the cipher key: */
819 Nr = rijndaelKeySetupEnc(rk, cipherKey, keyBits);
820 /* invert the order of the round keys: */
821 for (i = 0, j = 4*Nr; i < j; i += 4, j -= 4) {
822 temp = rk[i ]; rk[i ] = rk[j ]; rk[j ] = temp;
823 temp = rk[i + 1]; rk[i + 1] = rk[j + 1]; rk[j + 1] = temp;
824 temp = rk[i + 2]; rk[i + 2] = rk[j + 2]; rk[j + 2] = temp;
825 temp = rk[i + 3]; rk[i + 3] = rk[j + 3]; rk[j + 3] = temp;
826 }
827 /* apply the inverse MixColumn transform to all round keys but the first and the last: */
828 for (i = 1; i < Nr; i++) {
829 rk += 4;
830 rk[0] =
831 Td0[Te4[(rk[0] >> 24) ] & 0xff] ^
832 Td1[Te4[(rk[0] >> 16) & 0xff] & 0xff] ^
833 Td2[Te4[(rk[0] >> 8) & 0xff] & 0xff] ^
834 Td3[Te4[(rk[0] ) & 0xff] & 0xff];
835 rk[1] =
836 Td0[Te4[(rk[1] >> 24) ] & 0xff] ^
837 Td1[Te4[(rk[1] >> 16) & 0xff] & 0xff] ^
838 Td2[Te4[(rk[1] >> 8) & 0xff] & 0xff] ^
839 Td3[Te4[(rk[1] ) & 0xff] & 0xff];
840 rk[2] =
841 Td0[Te4[(rk[2] >> 24) ] & 0xff] ^
842 Td1[Te4[(rk[2] >> 16) & 0xff] & 0xff] ^
843 Td2[Te4[(rk[2] >> 8) & 0xff] & 0xff] ^
844 Td3[Te4[(rk[2] ) & 0xff] & 0xff];
845 rk[3] =
846 Td0[Te4[(rk[3] >> 24) ] & 0xff] ^
847 Td1[Te4[(rk[3] >> 16) & 0xff] & 0xff] ^
848 Td2[Te4[(rk[3] >> 8) & 0xff] & 0xff] ^
849 Td3[Te4[(rk[3] ) & 0xff] & 0xff];
850 }
851 return Nr;
852}
853
854void rijndaelEncrypt(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 pt[16], u8 ct[16]) {
855 u32 s0, s1, s2, s3, t0, t1, t2, t3;
856#ifndef FULL_UNROLL
857 int r;
858#endif /* ?FULL_UNROLL */
859
860 /*
861 * map byte array block to cipher state
862 * and add initial round key:
863 */
864 s0 = GETU32(pt ) ^ rk[0];
865 s1 = GETU32(pt + 4) ^ rk[1];
866 s2 = GETU32(pt + 8) ^ rk[2];
867 s3 = GETU32(pt + 12) ^ rk[3];
868#ifdef FULL_UNROLL
869 /* round 1: */
870 t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[ 4];
871 t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[ 5];
872 t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[ 6];
873 t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[ 7];
874 /* round 2: */
875 s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[ 8];
876 s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[ 9];
877 s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[10];
878 s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[11];
879 /* round 3: */
880 t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[12];
881 t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[13];
882 t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[14];
883 t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[15];
884 /* round 4: */
885 s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[16];
886 s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[17];
887 s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[18];
888 s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[19];
889 /* round 5: */
890 t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[20];
891 t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[21];
892 t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[22];
893 t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[23];
894 /* round 6: */
895 s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[24];
896 s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[25];
897 s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[26];
898 s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[27];
899 /* round 7: */
900 t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[28];
901 t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[29];
902 t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[30];
903 t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[31];
904 /* round 8: */
905 s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[32];
906 s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[33];
907 s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[34];
908 s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[35];
909 /* round 9: */
910 t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[36];
911 t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[37];
912 t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[38];
913 t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[39];
914 if (Nr > 10) {
915 /* round 10: */
916 s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[40];
917 s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[41];
918 s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[42];
919 s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[43];
920 /* round 11: */
921 t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[44];
922 t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[45];
923 t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[46];
924 t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[47];
925 if (Nr > 12) {
926 /* round 12: */
927 s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[48];
928 s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[49];
929 s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[50];
930 s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[51];
931 /* round 13: */
932 t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[52];
933 t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[53];
934 t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[54];
935 t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[55];
936 }
937 }
938 rk += Nr << 2;
939#else /* !FULL_UNROLL */
940 /*
941 * Nr - 1 full rounds:
942 */
943 r = Nr >> 1;
944 for (;;) {
945 t0 =
946 Te0[(s0 >> 24) ] ^
947 Te1[(s1 >> 16) & 0xff] ^
948 Te2[(s2 >> 8) & 0xff] ^
949 Te3[(s3 ) & 0xff] ^
950 rk[4];
951 t1 =
952 Te0[(s1 >> 24) ] ^
953 Te1[(s2 >> 16) & 0xff] ^
954 Te2[(s3 >> 8) & 0xff] ^
955 Te3[(s0 ) & 0xff] ^
956 rk[5];
957 t2 =
958 Te0[(s2 >> 24) ] ^
959 Te1[(s3 >> 16) & 0xff] ^
960 Te2[(s0 >> 8) & 0xff] ^
961 Te3[(s1 ) & 0xff] ^
962 rk[6];
963 t3 =
964 Te0[(s3 >> 24) ] ^
965 Te1[(s0 >> 16) & 0xff] ^
966 Te2[(s1 >> 8) & 0xff] ^
967 Te3[(s2 ) & 0xff] ^
968 rk[7];
969
970 rk += 8;
971 if (--r == 0) {
972 break;
973 }
974
975 s0 =
976 Te0[(t0 >> 24) ] ^
977 Te1[(t1 >> 16) & 0xff] ^
978 Te2[(t2 >> 8) & 0xff] ^
979 Te3[(t3 ) & 0xff] ^
980 rk[0];
981 s1 =
982 Te0[(t1 >> 24) ] ^
983 Te1[(t2 >> 16) & 0xff] ^
984 Te2[(t3 >> 8) & 0xff] ^
985 Te3[(t0 ) & 0xff] ^
986 rk[1];
987 s2 =
988 Te0[(t2 >> 24) ] ^
989 Te1[(t3 >> 16) & 0xff] ^
990 Te2[(t0 >> 8) & 0xff] ^
991 Te3[(t1 ) & 0xff] ^
992 rk[2];
993 s3 =
994 Te0[(t3 >> 24) ] ^
995 Te1[(t0 >> 16) & 0xff] ^
996 Te2[(t1 >> 8) & 0xff] ^
997 Te3[(t2 ) & 0xff] ^
998 rk[3];
999 }
1000#endif /* ?FULL_UNROLL */
1001 /*
1002 * apply last round and
1003 * map cipher state to byte array block:
1004 */
1005 s0 =
1006 (Te4[(t0 >> 24) ] & 0xff000000) ^
1007 (Te4[(t1 >> 16) & 0xff] & 0x00ff0000) ^
1008 (Te4[(t2 >> 8) & 0xff] & 0x0000ff00) ^
1009 (Te4[(t3 ) & 0xff] & 0x000000ff) ^
1010 rk[0];
1011 PUTU32(ct , s0);
1012 s1 =
1013 (Te4[(t1 >> 24) ] & 0xff000000) ^
1014 (Te4[(t2 >> 16) & 0xff] & 0x00ff0000) ^
1015 (Te4[(t3 >> 8) & 0xff] & 0x0000ff00) ^
1016 (Te4[(t0 ) & 0xff] & 0x000000ff) ^
1017 rk[1];
1018 PUTU32(ct + 4, s1);
1019 s2 =
1020 (Te4[(t2 >> 24) ] & 0xff000000) ^
1021 (Te4[(t3 >> 16) & 0xff] & 0x00ff0000) ^
1022 (Te4[(t0 >> 8) & 0xff] & 0x0000ff00) ^
1023 (Te4[(t1 ) & 0xff] & 0x000000ff) ^
1024 rk[2];
1025 PUTU32(ct + 8, s2);
1026 s3 =
1027 (Te4[(t3 >> 24) ] & 0xff000000) ^
1028 (Te4[(t0 >> 16) & 0xff] & 0x00ff0000) ^
1029 (Te4[(t1 >> 8) & 0xff] & 0x0000ff00) ^
1030 (Te4[(t2 ) & 0xff] & 0x000000ff) ^
1031 rk[3];
1032 PUTU32(ct + 12, s3);
1033}
1034
1035void rijndaelDecrypt(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 ct[16], u8 pt[16]) {
1036 u32 s0, s1, s2, s3, t0, t1, t2, t3;
1037#ifndef FULL_UNROLL
1038 int r;
1039#endif /* ?FULL_UNROLL */
1040
1041 /*
1042 * map byte array block to cipher state
1043 * and add initial round key:
1044 */
1045 s0 = GETU32(ct ) ^ rk[0];
1046 s1 = GETU32(ct + 4) ^ rk[1];
1047 s2 = GETU32(ct + 8) ^ rk[2];
1048 s3 = GETU32(ct + 12) ^ rk[3];
1049#ifdef FULL_UNROLL
1050 /* round 1: */
1051 t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[ 4];
1052 t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[ 5];
1053 t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[ 6];
1054 t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[ 7];
1055 /* round 2: */
1056 s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[ 8];
1057 s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[ 9];
1058 s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[10];
1059 s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[11];
1060 /* round 3: */
1061 t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[12];
1062 t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[13];
1063 t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[14];
1064 t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[15];
1065 /* round 4: */
1066 s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[16];
1067 s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[17];
1068 s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[18];
1069 s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[19];
1070 /* round 5: */
1071 t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[20];
1072 t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[21];
1073 t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[22];
1074 t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[23];
1075 /* round 6: */
1076 s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[24];
1077 s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[25];
1078 s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[26];
1079 s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[27];
1080 /* round 7: */
1081 t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[28];
1082 t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[29];
1083 t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[30];
1084 t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[31];
1085 /* round 8: */
1086 s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[32];
1087 s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[33];
1088 s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[34];
1089 s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[35];
1090 /* round 9: */
1091 t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[36];
1092 t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[37];
1093 t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[38];
1094 t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[39];
1095 if (Nr > 10) {
1096 /* round 10: */
1097 s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[40];
1098 s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[41];
1099 s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[42];
1100 s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[43];
1101 /* round 11: */
1102 t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[44];
1103 t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[45];
1104 t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[46];
1105 t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[47];
1106 if (Nr > 12) {
1107 /* round 12: */
1108 s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[48];
1109 s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[49];
1110 s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[50];
1111 s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[51];
1112 /* round 13: */
1113 t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[52];
1114 t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[53];
1115 t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[54];
1116 t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[55];
1117 }
1118 }
1119 rk += Nr << 2;
1120#else /* !FULL_UNROLL */
1121 /*
1122 * Nr - 1 full rounds:
1123 */
1124 r = Nr >> 1;
1125 for (;;) {
1126 t0 =
1127 Td0[(s0 >> 24) ] ^
1128 Td1[(s3 >> 16) & 0xff] ^
1129 Td2[(s2 >> 8) & 0xff] ^
1130 Td3[(s1 ) & 0xff] ^
1131 rk[4];
1132 t1 =
1133 Td0[(s1 >> 24) ] ^
1134 Td1[(s0 >> 16) & 0xff] ^
1135 Td2[(s3 >> 8) & 0xff] ^
1136 Td3[(s2 ) & 0xff] ^
1137 rk[5];
1138 t2 =
1139 Td0[(s2 >> 24) ] ^
1140 Td1[(s1 >> 16) & 0xff] ^
1141 Td2[(s0 >> 8) & 0xff] ^
1142 Td3[(s3 ) & 0xff] ^
1143 rk[6];
1144 t3 =
1145 Td0[(s3 >> 24) ] ^
1146 Td1[(s2 >> 16) & 0xff] ^
1147 Td2[(s1 >> 8) & 0xff] ^
1148 Td3[(s0 ) & 0xff] ^
1149 rk[7];
1150
1151 rk += 8;
1152 if (--r == 0) {
1153 break;
1154 }
1155
1156 s0 =
1157 Td0[(t0 >> 24) ] ^
1158 Td1[(t3 >> 16) & 0xff] ^
1159 Td2[(t2 >> 8) & 0xff] ^
1160 Td3[(t1 ) & 0xff] ^
1161 rk[0];
1162 s1 =
1163 Td0[(t1 >> 24) ] ^
1164 Td1[(t0 >> 16) & 0xff] ^
1165 Td2[(t3 >> 8) & 0xff] ^
1166 Td3[(t2 ) & 0xff] ^
1167 rk[1];
1168 s2 =
1169 Td0[(t2 >> 24) ] ^
1170 Td1[(t1 >> 16) & 0xff] ^
1171 Td2[(t0 >> 8) & 0xff] ^
1172 Td3[(t3 ) & 0xff] ^
1173 rk[2];
1174 s3 =
1175 Td0[(t3 >> 24) ] ^
1176 Td1[(t2 >> 16) & 0xff] ^
1177 Td2[(t1 >> 8) & 0xff] ^
1178 Td3[(t0 ) & 0xff] ^
1179 rk[3];
1180 }
1181#endif /* ?FULL_UNROLL */
1182 /*
1183 * apply last round and
1184 * map cipher state to byte array block:
1185 */
1186 s0 =
1187 (Td4[(t0 >> 24) ] & 0xff000000) ^
1188 (Td4[(t3 >> 16) & 0xff] & 0x00ff0000) ^
1189 (Td4[(t2 >> 8) & 0xff] & 0x0000ff00) ^
1190 (Td4[(t1 ) & 0xff] & 0x000000ff) ^
1191 rk[0];
1192 PUTU32(pt , s0);
1193 s1 =
1194 (Td4[(t1 >> 24) ] & 0xff000000) ^
1195 (Td4[(t0 >> 16) & 0xff] & 0x00ff0000) ^
1196 (Td4[(t3 >> 8) & 0xff] & 0x0000ff00) ^
1197 (Td4[(t2 ) & 0xff] & 0x000000ff) ^
1198 rk[1];
1199 PUTU32(pt + 4, s1);
1200 s2 =
1201 (Td4[(t2 >> 24) ] & 0xff000000) ^
1202 (Td4[(t1 >> 16) & 0xff] & 0x00ff0000) ^
1203 (Td4[(t0 >> 8) & 0xff] & 0x0000ff00) ^
1204 (Td4[(t3 ) & 0xff] & 0x000000ff) ^
1205 rk[2];
1206 PUTU32(pt + 8, s2);
1207 s3 =
1208 (Td4[(t3 >> 24) ] & 0xff000000) ^
1209 (Td4[(t2 >> 16) & 0xff] & 0x00ff0000) ^
1210 (Td4[(t1 >> 8) & 0xff] & 0x0000ff00) ^
1211 (Td4[(t0 ) & 0xff] & 0x000000ff) ^
1212 rk[3];
1213 PUTU32(pt + 12, s3);
1214}
1215
1216#ifdef INTERMEDIATE_VALUE_KAT
1217
1218void rijndaelEncryptRound(const u32 rk[/*4*(Nr + 1)*/], int Nr, u8 block[16], int rounds) {
1219 int r;
1220 u32 s0, s1, s2, s3, t0, t1, t2, t3;
1221
1222 /*
1223 * map byte array block to cipher state
1224 * and add initial round key:
1225 */
1226 s0 = GETU32(block ) ^ rk[0];
1227 s1 = GETU32(block + 4) ^ rk[1];
1228 s2 = GETU32(block + 8) ^ rk[2];
1229 s3 = GETU32(block + 12) ^ rk[3];
1230 rk += 4;
1231
1232 /*
1233 * Nr - 1 full rounds:
1234 */
1235 for (r = (rounds < Nr ? rounds : Nr - 1); r > 0; r--) {
1236 t0 =
1237 Te0[(s0 >> 24) ] ^
1238 Te1[(s1 >> 16) & 0xff] ^
1239 Te2[(s2 >> 8) & 0xff] ^
1240 Te3[(s3 ) & 0xff] ^
1241 rk[0];
1242 t1 =
1243 Te0[(s1 >> 24) ] ^
1244 Te1[(s2 >> 16) & 0xff] ^
1245 Te2[(s3 >> 8) & 0xff] ^
1246 Te3[(s0 ) & 0xff] ^
1247 rk[1];
1248 t2 =
1249 Te0[(s2 >> 24) ] ^
1250 Te1[(s3 >> 16) & 0xff] ^
1251 Te2[(s0 >> 8) & 0xff] ^
1252 Te3[(s1 ) & 0xff] ^
1253 rk[2];
1254 t3 =
1255 Te0[(s3 >> 24) ] ^
1256 Te1[(s0 >> 16) & 0xff] ^
1257 Te2[(s1 >> 8) & 0xff] ^
1258 Te3[(s2 ) & 0xff] ^
1259 rk[3];
1260
1261 s0 = t0;
1262 s1 = t1;
1263 s2 = t2;
1264 s3 = t3;
1265 rk += 4;
1266
1267 }
1268
1269 /*
1270 * apply last round and
1271 * map cipher state to byte array block:
1272 */
1273 if (rounds == Nr) {
1274 t0 =
1275 (Te4[(s0 >> 24) ] & 0xff000000) ^
1276 (Te4[(s1 >> 16) & 0xff] & 0x00ff0000) ^
1277 (Te4[(s2 >> 8) & 0xff] & 0x0000ff00) ^
1278 (Te4[(s3 ) & 0xff] & 0x000000ff) ^
1279 rk[0];
1280 t1 =
1281 (Te4[(s1 >> 24) ] & 0xff000000) ^
1282 (Te4[(s2 >> 16) & 0xff] & 0x00ff0000) ^
1283 (Te4[(s3 >> 8) & 0xff] & 0x0000ff00) ^
1284 (Te4[(s0 ) & 0xff] & 0x000000ff) ^
1285 rk[1];
1286 t2 =
1287 (Te4[(s2 >> 24) ] & 0xff000000) ^
1288 (Te4[(s3 >> 16) & 0xff] & 0x00ff0000) ^
1289 (Te4[(s0 >> 8) & 0xff] & 0x0000ff00) ^
1290 (Te4[(s1 ) & 0xff] & 0x000000ff) ^
1291 rk[2];
1292 t3 =
1293 (Te4[(s3 >> 24) ] & 0xff000000) ^
1294 (Te4[(s0 >> 16) & 0xff] & 0x00ff0000) ^
1295 (Te4[(s1 >> 8) & 0xff] & 0x0000ff00) ^
1296 (Te4[(s2 ) & 0xff] & 0x000000ff) ^
1297 rk[3];
1298
1299 s0 = t0;
1300 s1 = t1;
1301 s2 = t2;
1302 s3 = t3;
1303 }
1304
1305 PUTU32(block , s0);
1306 PUTU32(block + 4, s1);
1307 PUTU32(block + 8, s2);
1308 PUTU32(block + 12, s3);
1309}
1310
1311void rijndaelDecryptRound(const u32 rk[/*4*(Nr + 1)*/], int Nr, u8 block[16], int rounds) {
1312 int r;
1313 u32 s0, s1, s2, s3, t0, t1, t2, t3;
1314
1315 /*
1316 * map byte array block to cipher state
1317 * and add initial round key:
1318 */
1319 s0 = GETU32(block ) ^ rk[0];
1320 s1 = GETU32(block + 4) ^ rk[1];
1321 s2 = GETU32(block + 8) ^ rk[2];
1322 s3 = GETU32(block + 12) ^ rk[3];
1323 rk += 4;
1324
1325 /*
1326 * Nr - 1 full rounds:
1327 */
1328 for (r = (rounds < Nr ? rounds : Nr) - 1; r > 0; r--) {
1329 t0 =
1330 Td0[(s0 >> 24) ] ^
1331 Td1[(s3 >> 16) & 0xff] ^
1332 Td2[(s2 >> 8) & 0xff] ^
1333 Td3[(s1 ) & 0xff] ^
1334 rk[0];
1335 t1 =
1336 Td0[(s1 >> 24) ] ^
1337 Td1[(s0 >> 16) & 0xff] ^
1338 Td2[(s3 >> 8) & 0xff] ^
1339 Td3[(s2 ) & 0xff] ^
1340 rk[1];
1341 t2 =
1342 Td0[(s2 >> 24) ] ^
1343 Td1[(s1 >> 16) & 0xff] ^
1344 Td2[(s0 >> 8) & 0xff] ^
1345 Td3[(s3 ) & 0xff] ^
1346 rk[2];
1347 t3 =
1348 Td0[(s3 >> 24) ] ^
1349 Td1[(s2 >> 16) & 0xff] ^
1350 Td2[(s1 >> 8) & 0xff] ^
1351 Td3[(s0 ) & 0xff] ^
1352 rk[3];
1353
1354 s0 = t0;
1355 s1 = t1;
1356 s2 = t2;
1357 s3 = t3;
1358 rk += 4;
1359
1360 }
1361
1362 /*
1363 * complete the last round and
1364 * map cipher state to byte array block:
1365 */
1366 t0 =
1367 (Td4[(s0 >> 24) ] & 0xff000000) ^
1368 (Td4[(s3 >> 16) & 0xff] & 0x00ff0000) ^
1369 (Td4[(s2 >> 8) & 0xff] & 0x0000ff00) ^
1370 (Td4[(s1 ) & 0xff] & 0x000000ff);
1371 t1 =
1372 (Td4[(s1 >> 24) ] & 0xff000000) ^
1373 (Td4[(s0 >> 16) & 0xff] & 0x00ff0000) ^
1374 (Td4[(s3 >> 8) & 0xff] & 0x0000ff00) ^
1375 (Td4[(s2 ) & 0xff] & 0x000000ff);
1376 t2 =
1377 (Td4[(s2 >> 24) ] & 0xff000000) ^
1378 (Td4[(s1 >> 16) & 0xff] & 0x00ff0000) ^
1379 (Td4[(s0 >> 8) & 0xff] & 0x0000ff00) ^
1380 (Td4[(s3 ) & 0xff] & 0x000000ff);
1381 t3 =
1382 (Td4[(s3 >> 24) ] & 0xff000000) ^
1383 (Td4[(s2 >> 16) & 0xff] & 0x00ff0000) ^
1384 (Td4[(s1 >> 8) & 0xff] & 0x0000ff00) ^
1385 (Td4[(s0 ) & 0xff] & 0x000000ff);
1386
1387 if (rounds == Nr) {
1388 t0 ^= rk[0];
1389 t1 ^= rk[1];
1390 t2 ^= rk[2];
1391 t3 ^= rk[3];
1392 }
1393
1394 PUTU32(block , t0);
1395 PUTU32(block + 4, t1);
1396 PUTU32(block + 8, t2);
1397 PUTU32(block + 12, t3);
1398}
1399
1400#endif /* INTERMEDIATE_VALUE_KAT */
diff --git a/src/lib/libcrypto/rijndael/rd_fst.h b/src/lib/libcrypto/rijndael/rd_fst.h
new file mode 100644
index 0000000000..fcace29478
--- /dev/null
+++ b/src/lib/libcrypto/rijndael/rd_fst.h
@@ -0,0 +1,42 @@
1/**
2 * rijndael-alg-fst.h
3 *
4 * @version 3.0 (December 2000)
5 *
6 * Optimised ANSI C code for the Rijndael cipher (now AES)
7 *
8 * @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be>
9 * @author Antoon Bosselaers <antoon.bosselaers@esat.kuleuven.ac.be>
10 * @author Paulo Barreto <paulo.barreto@terra.com.br>
11 *
12 * This code is hereby placed in the public domain.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS
15 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
18 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
21 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
23 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
24 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26#ifndef __RIJNDAEL_ALG_FST_H
27#define __RIJNDAEL_ALG_FST_H
28
29#define MAXKC (256/32)
30#define MAXKB (256/8)
31#define MAXNR 14
32
33typedef unsigned char u8;
34typedef unsigned short u16;
35typedef unsigned int u32;
36
37int rijndaelKeySetupEnc(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits);
38int rijndaelKeySetupDec(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits);
39void rijndaelEncrypt(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 pt[16], u8 ct[16]);
40void rijndaelDecrypt(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 ct[16], u8 pt[16]);
41
42#endif /* __RIJNDAEL_ALG_FST_H */
diff --git a/src/lib/libcrypto/rijndael/rijndael.h b/src/lib/libcrypto/rijndael/rijndael.h
new file mode 100644
index 0000000000..72edcc2942
--- /dev/null
+++ b/src/lib/libcrypto/rijndael/rijndael.h
@@ -0,0 +1,7 @@
1#include "openssl/rd_fst.h"
2
3typedef struct
4 {
5 u32 rd_key[4 *(MAXNR + 1)];
6 int rounds;
7 } RIJNDAEL_KEY;
diff --git a/src/lib/libcrypto/ripemd/Makefile.ssl b/src/lib/libcrypto/ripemd/Makefile.ssl
new file mode 100644
index 0000000000..7ab5d2fc9e
--- /dev/null
+++ b/src/lib/libcrypto/ripemd/Makefile.ssl
@@ -0,0 +1,110 @@
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)
23
24GENERAL=Makefile
25TEST=rmdtest.c
26APPS=
27
28LIB=$(TOP)/libcrypto.a
29LIBSRC=rmd_dgst.c rmd_one.c
30LIBOBJ=rmd_dgst.o rmd_one.o $(RMD160_ASM_OBJ)
31
32SRC= $(LIBSRC)
33
34EXHEADER= ripemd.h
35HEADER= rmd_locl.h rmdconst.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# elf
50asm/rm86-elf.o: asm/rm86unix.cpp
51 $(CPP) -DELF -x c asm/rm86unix.cpp | as -o asm/rm86-elf.o
52
53# solaris
54asm/rm86-sol.o: asm/rm86unix.cpp
55 $(CC) -E -DSOL asm/rm86unix.cpp | sed 's/^#.*//' > asm/rm86-sol.s
56 as -o asm/rm86-sol.o asm/rm86-sol.s
57 rm -f asm/rm86-sol.s
58
59# a.out
60asm/rm86-out.o: asm/rm86unix.cpp
61 $(CPP) -DOUT asm/rm86unix.cpp | as -o asm/rm86-out.o
62
63# bsdi
64asm/rm86bsdi.o: asm/rm86unix.cpp
65 $(CPP) -DBSDI asm/rm86unix.cpp | sed 's/ :/:/' | as -o asm/rm86bsdi.o
66
67asm/rm86unix.cpp: asm/rmd-586.pl ../perlasm/x86asm.pl
68 (cd asm; $(PERL) rmd-586.pl cpp >rm86unix.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/rm86unix.cpp *.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
106rmd_dgst.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
107rmd_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/ripemd.h
108rmd_dgst.o: ../md32_common.h rmd_dgst.c rmd_locl.h rmdconst.h
109rmd_one.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
110rmd_one.o: ../../include/openssl/ripemd.h rmd_one.c
diff --git a/src/lib/libcrypto/ripemd/asm/rips.cpp b/src/lib/libcrypto/ripemd/asm/rips.cpp
new file mode 100644
index 0000000000..f7a13677a9
--- /dev/null
+++ b/src/lib/libcrypto/ripemd/asm/rips.cpp
@@ -0,0 +1,82 @@
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/ripemd.h>
36
37#define ripemd160_block_x86 ripemd160_block_asm_host_order
38
39extern "C" {
40void ripemd160_block_x86(RIPEMD160_CTX *ctx, unsigned char *buffer,int num);
41}
42
43void main(int argc,char *argv[])
44 {
45 unsigned char buffer[64*256];
46 RIPEMD160_CTX ctx;
47 unsigned long s1,s2,e1,e2;
48 unsigned char k[16];
49 unsigned long data[2];
50 unsigned char iv[8];
51 int i,num=0,numm;
52 int j=0;
53
54 if (argc >= 2)
55 num=atoi(argv[1]);
56
57 if (num == 0) num=16;
58 if (num > 250) num=16;
59 numm=num+2;
60#if 0
61 num*=64;
62 numm*=64;
63#endif
64
65 for (j=0; j<6; j++)
66 {
67 for (i=0; i<10; i++) /**/
68 {
69 ripemd160_block_x86(&ctx,buffer,numm);
70 GetTSC(s1);
71 ripemd160_block_x86(&ctx,buffer,numm);
72 GetTSC(e1);
73 GetTSC(s2);
74 ripemd160_block_x86(&ctx,buffer,num);
75 GetTSC(e2);
76 ripemd160_block_x86(&ctx,buffer,num);
77 }
78 printf("ripemd160 (%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/ripemd/rmd160.c b/src/lib/libcrypto/ripemd/rmd160.c
new file mode 100644
index 0000000000..4f8b88a18a
--- /dev/null
+++ b/src/lib/libcrypto/ripemd/rmd160.c
@@ -0,0 +1,127 @@
1/* crypto/ripemd/rmd160.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <stdlib.h>
61#include <openssl/ripemd.h>
62
63#define BUFSIZE 1024*16
64
65void do_fp(FILE *f);
66void pt(unsigned char *md);
67#ifndef _OSD_POSIX
68int read(int, void *, unsigned int);
69#endif
70
71int main(int argc, char **argv)
72 {
73 int i,err=0;
74 FILE *IN;
75
76 if (argc == 1)
77 {
78 do_fp(stdin);
79 }
80 else
81 {
82 for (i=1; i<argc; i++)
83 {
84 IN=fopen(argv[i],"r");
85 if (IN == NULL)
86 {
87 perror(argv[i]);
88 err++;
89 continue;
90 }
91 printf("RIPEMD160(%s)= ",argv[i]);
92 do_fp(IN);
93 fclose(IN);
94 }
95 }
96 exit(err);
97 }
98
99void do_fp(FILE *f)
100 {
101 RIPEMD160_CTX c;
102 unsigned char md[RIPEMD160_DIGEST_LENGTH];
103 int fd;
104 int i;
105 static unsigned char buf[BUFSIZE];
106
107 fd=fileno(f);
108 RIPEMD160_Init(&c);
109 for (;;)
110 {
111 i=read(fd,buf,BUFSIZE);
112 if (i <= 0) break;
113 RIPEMD160_Update(&c,buf,(unsigned long)i);
114 }
115 RIPEMD160_Final(&(md[0]),&c);
116 pt(md);
117 }
118
119void pt(unsigned char *md)
120 {
121 int i;
122
123 for (i=0; i<RIPEMD160_DIGEST_LENGTH; i++)
124 printf("%02x",md[i]);
125 printf("\n");
126 }
127
diff --git a/src/lib/libcrypto/ripemd/rmd_dgst.c b/src/lib/libcrypto/ripemd/rmd_dgst.c
index f351f00eea..a3170f7c8a 100644
--- a/src/lib/libcrypto/ripemd/rmd_dgst.c
+++ b/src/lib/libcrypto/ripemd/rmd_dgst.c
@@ -90,8 +90,8 @@ int RIPEMD160_Init(RIPEMD160_CTX *c)
90void ripemd160_block_host_order (RIPEMD160_CTX *ctx, const void *p, int num) 90void ripemd160_block_host_order (RIPEMD160_CTX *ctx, const void *p, int num)
91 { 91 {
92 const RIPEMD160_LONG *XX=p; 92 const RIPEMD160_LONG *XX=p;
93 register unsigned MD32_REG_T A,B,C,D,E; 93 register unsigned long A,B,C,D,E;
94 register unsigned MD32_REG_T a,b,c,d,e; 94 register unsigned long a,b,c,d,e;
95 95
96 for (;num--;XX+=HASH_LBLOCK) 96 for (;num--;XX+=HASH_LBLOCK)
97 { 97 {
@@ -290,12 +290,12 @@ void ripemd160_block_host_order (RIPEMD160_CTX *ctx, const void *p, int num)
290void ripemd160_block_data_order (RIPEMD160_CTX *ctx, const void *p, int num) 290void ripemd160_block_data_order (RIPEMD160_CTX *ctx, const void *p, int num)
291 { 291 {
292 const unsigned char *data=p; 292 const unsigned char *data=p;
293 register unsigned MD32_REG_T A,B,C,D,E; 293 register unsigned long A,B,C,D,E;
294 unsigned MD32_REG_T a,b,c,d,e,l; 294 unsigned long a,b,c,d,e,l;
295#ifndef MD32_XARRAY 295#ifndef MD32_XARRAY
296 /* See comment in crypto/sha/sha_locl.h for details. */ 296 /* See comment in crypto/sha/sha_locl.h for details. */
297 unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, 297 unsigned long XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
298 XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15; 298 XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15;
299# define X(i) XX##i 299# define X(i) XX##i
300#else 300#else
301 RIPEMD160_LONG XX[16]; 301 RIPEMD160_LONG XX[16];
diff --git a/src/lib/libcrypto/ripemd/rmd_one.c b/src/lib/libcrypto/ripemd/rmd_one.c
index f8b580c33a..efdf2dd6ef 100644
--- a/src/lib/libcrypto/ripemd/rmd_one.c
+++ b/src/lib/libcrypto/ripemd/rmd_one.c
@@ -59,7 +59,6 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <string.h> 60#include <string.h>
61#include <openssl/ripemd.h> 61#include <openssl/ripemd.h>
62#include <openssl/crypto.h>
63 62
64unsigned char *RIPEMD160(const unsigned char *d, unsigned long n, 63unsigned char *RIPEMD160(const unsigned char *d, unsigned long n,
65 unsigned char *md) 64 unsigned char *md)
@@ -71,7 +70,7 @@ unsigned char *RIPEMD160(const unsigned char *d, unsigned long n,
71 RIPEMD160_Init(&c); 70 RIPEMD160_Init(&c);
72 RIPEMD160_Update(&c,d,n); 71 RIPEMD160_Update(&c,d,n);
73 RIPEMD160_Final(md,&c); 72 RIPEMD160_Final(md,&c);
74 OPENSSL_cleanse(&c,sizeof(c)); /* security consideration */ 73 memset(&c,0,sizeof(c)); /* security consideration */
75 return(md); 74 return(md);
76 } 75 }
77 76
diff --git a/src/lib/libcrypto/ripemd/rmdtest.c b/src/lib/libcrypto/ripemd/rmdtest.c
new file mode 100644
index 0000000000..be1fb8b1f6
--- /dev/null
+++ b/src/lib/libcrypto/ripemd/rmdtest.c
@@ -0,0 +1,143 @@
1/* crypto/ripemd/rmdtest.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 <stdlib.h>
62
63#ifdef OPENSSL_NO_RIPEMD
64int main(int argc, char *argv[])
65{
66 printf("No ripemd support\n");
67 return(0);
68}
69#else
70#include <openssl/ripemd.h>
71#include <openssl/evp.h>
72
73#ifdef CHARSET_EBCDIC
74#include <openssl/ebcdic.h>
75#endif
76
77static char *test[]={
78 "",
79 "a",
80 "abc",
81 "message digest",
82 "abcdefghijklmnopqrstuvwxyz",
83 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
84 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
85 "12345678901234567890123456789012345678901234567890123456789012345678901234567890",
86 NULL,
87 };
88
89static char *ret[]={
90 "9c1185a5c5e9fc54612808977ee8f548b2258d31",
91 "0bdc9d2d256b3ee9daae347be6f4dc835a467ffe",
92 "8eb208f7e05d987a9b044a8e98c6b087f15a0bfc",
93 "5d0689ef49d2fae572b881b123a85ffa21595f36",
94 "f71c27109c692c1b56bbdceb5b9d2865b3708dbc",
95 "12a053384a9c0c88e405a06c27dcf49ada62eb2b",
96 "b0e20b6e3116640286ed3a87a5713079b21f5189",
97 "9b752e45573d4b39f4dbd3323cab82bf63326bfb",
98 };
99
100static char *pt(unsigned char *md);
101int main(int argc, char *argv[])
102 {
103 int i,err=0;
104 unsigned char **P,**R;
105 char *p;
106 unsigned char md[RIPEMD160_DIGEST_LENGTH];
107
108 P=(unsigned char **)test;
109 R=(unsigned char **)ret;
110 i=1;
111 while (*P != NULL)
112 {
113#ifdef CHARSET_EBCDIC
114 ebcdic2ascii((char *)*P, (char *)*P, strlen((char *)*P));
115#endif
116 EVP_Digest(&(P[0][0]),(unsigned long)strlen((char *)*P),md,NULL,EVP_ripemd160(), NULL);
117 p=pt(md);
118 if (strcmp(p,(char *)*R) != 0)
119 {
120 printf("error calculating RIPEMD160 on '%s'\n",*P);
121 printf("got %s instead of %s\n",p,*R);
122 err++;
123 }
124 else
125 printf("test %d ok\n",i);
126 i++;
127 R++;
128 P++;
129 }
130 exit(err);
131 return(0);
132 }
133
134static char *pt(unsigned char *md)
135 {
136 int i;
137 static char buf[80];
138
139 for (i=0; i<RIPEMD160_DIGEST_LENGTH; i++)
140 sprintf(&(buf[i*2]),"%02x",md[i]);
141 return(buf);
142 }
143#endif
diff --git a/src/lib/libcrypto/rsa/Makefile.ssl b/src/lib/libcrypto/rsa/Makefile.ssl
new file mode 100644
index 0000000000..8c44b7f142
--- /dev/null
+++ b/src/lib/libcrypto/rsa/Makefile.ssl
@@ -0,0 +1,243 @@
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/dh.h ../../include/openssl/dsa.h
108rsa_eay.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
109rsa_eay.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
110rsa_eay.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
111rsa_eay.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
112rsa_eay.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
113rsa_eay.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
114rsa_eay.o: ../../include/openssl/ui.h ../cryptlib.h rsa_eay.c
115rsa_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
116rsa_err.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
117rsa_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
118rsa_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
119rsa_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
120rsa_err.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
121rsa_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
122rsa_err.o: rsa_err.c
123rsa_gen.o: ../../e_os.h ../../include/openssl/asn1.h
124rsa_gen.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
125rsa_gen.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
126rsa_gen.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
127rsa_gen.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
128rsa_gen.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
129rsa_gen.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
130rsa_gen.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
131rsa_gen.o: ../cryptlib.h rsa_gen.c
132rsa_lib.o: ../../e_os.h ../../include/openssl/asn1.h
133rsa_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
134rsa_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
135rsa_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
136rsa_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
137rsa_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
138rsa_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
139rsa_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
140rsa_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
141rsa_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
142rsa_lib.o: ../../include/openssl/ui.h ../cryptlib.h rsa_lib.c
143rsa_none.o: ../../e_os.h ../../include/openssl/asn1.h
144rsa_none.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
145rsa_none.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
146rsa_none.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
147rsa_none.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
148rsa_none.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
149rsa_none.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
150rsa_none.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
151rsa_none.o: ../../include/openssl/symhacks.h ../cryptlib.h rsa_none.c
152rsa_null.o: ../../e_os.h ../../include/openssl/asn1.h
153rsa_null.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
154rsa_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
155rsa_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
156rsa_null.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
157rsa_null.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
158rsa_null.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
159rsa_null.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
160rsa_null.o: ../../include/openssl/symhacks.h ../cryptlib.h rsa_null.c
161rsa_oaep.o: ../../e_os.h ../../include/openssl/aes.h
162rsa_oaep.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
163rsa_oaep.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
164rsa_oaep.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
165rsa_oaep.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
166rsa_oaep.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
167rsa_oaep.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
168rsa_oaep.o: ../../include/openssl/err.h ../../include/openssl/evp.h
169rsa_oaep.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
170rsa_oaep.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
171rsa_oaep.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
172rsa_oaep.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
173rsa_oaep.o: ../../include/openssl/opensslconf.h
174rsa_oaep.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
175rsa_oaep.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
176rsa_oaep.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
177rsa_oaep.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
178rsa_oaep.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
179rsa_oaep.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
180rsa_oaep.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
181rsa_oaep.o: ../cryptlib.h rsa_oaep.c
182rsa_pk1.o: ../../e_os.h ../../include/openssl/asn1.h
183rsa_pk1.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
184rsa_pk1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
185rsa_pk1.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
186rsa_pk1.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
187rsa_pk1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
188rsa_pk1.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
189rsa_pk1.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
190rsa_pk1.o: ../../include/openssl/symhacks.h ../cryptlib.h rsa_pk1.c
191rsa_saos.o: ../../e_os.h ../../include/openssl/aes.h
192rsa_saos.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
193rsa_saos.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
194rsa_saos.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
195rsa_saos.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
196rsa_saos.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
197rsa_saos.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
198rsa_saos.o: ../../include/openssl/err.h ../../include/openssl/evp.h
199rsa_saos.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
200rsa_saos.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
201rsa_saos.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
202rsa_saos.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
203rsa_saos.o: ../../include/openssl/opensslconf.h
204rsa_saos.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
205rsa_saos.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
206rsa_saos.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
207rsa_saos.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
208rsa_saos.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
209rsa_saos.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
210rsa_saos.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
211rsa_saos.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
212rsa_saos.o: ../cryptlib.h rsa_saos.c
213rsa_sign.o: ../../e_os.h ../../include/openssl/aes.h
214rsa_sign.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
215rsa_sign.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
216rsa_sign.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
217rsa_sign.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
218rsa_sign.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
219rsa_sign.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
220rsa_sign.o: ../../include/openssl/engine.h ../../include/openssl/err.h
221rsa_sign.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
222rsa_sign.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
223rsa_sign.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
224rsa_sign.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
225rsa_sign.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
226rsa_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
227rsa_sign.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
228rsa_sign.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
229rsa_sign.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
230rsa_sign.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
231rsa_sign.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
232rsa_sign.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
233rsa_sign.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
234rsa_sign.o: ../../include/openssl/x509_vfy.h ../cryptlib.h rsa_sign.c
235rsa_ssl.o: ../../e_os.h ../../include/openssl/asn1.h
236rsa_ssl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
237rsa_ssl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
238rsa_ssl.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
239rsa_ssl.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
240rsa_ssl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
241rsa_ssl.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
242rsa_ssl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
243rsa_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 e26a68b482..98b3bd7cc5 100644
--- a/src/lib/libcrypto/rsa/rsa.h
+++ b/src/lib/libcrypto/rsa/rsa.h
@@ -158,11 +158,6 @@ struct rsa_st
158#define RSA_FLAG_CACHE_PUBLIC 0x02 158#define RSA_FLAG_CACHE_PUBLIC 0x02
159#define RSA_FLAG_CACHE_PRIVATE 0x04 159#define RSA_FLAG_CACHE_PRIVATE 0x04
160#define RSA_FLAG_BLINDING 0x08 160#define RSA_FLAG_BLINDING 0x08
161#define RSA_FLAG_NO_BLINDING 0x80 /* new with 0.9.6j and 0.9.7b; the built-in
162 * RSA implementation now uses blinding by
163 * default (ignoring RSA_FLAG_BLINDING),
164 * but other engines might not need it
165 */
166#define RSA_FLAG_THREAD_SAFE 0x10 161#define RSA_FLAG_THREAD_SAFE 0x10
167/* This flag means the private key operations will be handled by rsa_mod_exp 162/* This flag means the private key operations will be handled by rsa_mod_exp
168 * and that they do not depend on the private key components being present: 163 * and that they do not depend on the private key components being present:
@@ -175,15 +170,11 @@ struct rsa_st
175 */ 170 */
176#define RSA_FLAG_SIGN_VER 0x40 171#define RSA_FLAG_SIGN_VER 0x40
177 172
178#define RSA_FLAG_NO_BLINDING 0x80
179
180#define RSA_PKCS1_PADDING 1 173#define RSA_PKCS1_PADDING 1
181#define RSA_SSLV23_PADDING 2 174#define RSA_SSLV23_PADDING 2
182#define RSA_NO_PADDING 3 175#define RSA_NO_PADDING 3
183#define RSA_PKCS1_OAEP_PADDING 4 176#define RSA_PKCS1_OAEP_PADDING 4
184 177
185#define RSA_PKCS1_PADDING_SIZE 11
186
187#define RSA_set_app_data(s,arg) RSA_set_ex_data(s,0,arg) 178#define RSA_set_app_data(s,arg) RSA_set_ex_data(s,0,arg)
188#define RSA_get_app_data(s) RSA_get_ex_data(s,0) 179#define RSA_get_app_data(s) RSA_get_ex_data(s,0)
189 180
diff --git a/src/lib/libcrypto/rsa/rsa_eay.c b/src/lib/libcrypto/rsa/rsa_eay.c
index 027b4dc754..a3f549d8e6 100644
--- a/src/lib/libcrypto/rsa/rsa_eay.c
+++ b/src/lib/libcrypto/rsa/rsa_eay.c
@@ -61,6 +61,7 @@
61#include <openssl/bn.h> 61#include <openssl/bn.h>
62#include <openssl/rsa.h> 62#include <openssl/rsa.h>
63#include <openssl/rand.h> 63#include <openssl/rand.h>
64#include <openssl/engine.h>
64 65
65#ifndef RSA_NULL 66#ifndef RSA_NULL
66 67
@@ -186,7 +187,7 @@ err:
186 BN_clear_free(&ret); 187 BN_clear_free(&ret);
187 if (buf != NULL) 188 if (buf != NULL)
188 { 189 {
189 OPENSSL_cleanse(buf,num); 190 memset(buf,0,num);
190 OPENSSL_free(buf); 191 OPENSSL_free(buf);
191 } 192 }
192 return(r); 193 return(r);
@@ -205,46 +206,12 @@ static int rsa_eay_blinding(RSA *rsa, BN_CTX *ctx)
205 206
206#define BLINDING_HELPER(rsa, ctx, err_instr) \ 207#define BLINDING_HELPER(rsa, ctx, err_instr) \
207 do { \ 208 do { \
208 if((!((rsa)->flags & RSA_FLAG_NO_BLINDING)) && \ 209 if(((rsa)->flags & RSA_FLAG_BLINDING) && \
209 ((rsa)->blinding == NULL) && \ 210 ((rsa)->blinding == NULL) && \
210 !rsa_eay_blinding(rsa, ctx)) \ 211 !rsa_eay_blinding(rsa, ctx)) \
211 err_instr \ 212 err_instr \
212 } while(0) 213 } while(0)
213 214
214static BN_BLINDING *setup_blinding(RSA *rsa, BN_CTX *ctx)
215 {
216 BIGNUM *A, *Ai;
217 BN_BLINDING *ret = NULL;
218
219 /* added in OpenSSL 0.9.6j and 0.9.7b */
220
221 /* NB: similar code appears in RSA_blinding_on (rsa_lib.c);
222 * this should be placed in a new function of its own, but for reasons
223 * of binary compatibility can't */
224
225 BN_CTX_start(ctx);
226 A = BN_CTX_get(ctx);
227 if ((RAND_status() == 0) && rsa->d != NULL && rsa->d->d != NULL)
228 {
229 /* if PRNG is not properly seeded, resort to secret exponent as unpredictable seed */
230 RAND_add(rsa->d->d, rsa->d->dmax * sizeof rsa->d->d[0], 0);
231 if (!BN_pseudo_rand_range(A,rsa->n)) goto err;
232 }
233 else
234 {
235 if (!BN_rand_range(A,rsa->n)) goto err;
236 }
237 if ((Ai=BN_mod_inverse(NULL,A,rsa->n,ctx)) == NULL) goto err;
238
239 if (!rsa->meth->bn_mod_exp(A,A,rsa->e,rsa->n,ctx,rsa->_method_mod_n))
240 goto err;
241 ret = BN_BLINDING_new(A,Ai,rsa->n);
242 BN_free(Ai);
243err:
244 BN_CTX_end(ctx);
245 return ret;
246 }
247
248/* signing */ 215/* signing */
249static int RSA_eay_private_encrypt(int flen, const unsigned char *from, 216static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
250 unsigned char *to, RSA *rsa, int padding) 217 unsigned char *to, RSA *rsa, int padding)
@@ -253,8 +220,6 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
253 int i,j,k,num=0,r= -1; 220 int i,j,k,num=0,r= -1;
254 unsigned char *buf=NULL; 221 unsigned char *buf=NULL;
255 BN_CTX *ctx=NULL; 222 BN_CTX *ctx=NULL;
256 int local_blinding = 0;
257 BN_BLINDING *blinding = NULL;
258 223
259 BN_init(&f); 224 BN_init(&f);
260 BN_init(&ret); 225 BN_init(&ret);
@@ -292,38 +257,9 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
292 } 257 }
293 258
294 BLINDING_HELPER(rsa, ctx, goto err;); 259 BLINDING_HELPER(rsa, ctx, goto err;);
295 blinding = rsa->blinding;
296
297 /* Now unless blinding is disabled, 'blinding' is non-NULL.
298 * But the BN_BLINDING object may be owned by some other thread
299 * (we don't want to keep it constant and we don't want to use
300 * lots of locking to avoid race conditions, so only a single
301 * thread can use it; other threads have to use local blinding
302 * factors) */
303 if (!(rsa->flags & RSA_FLAG_NO_BLINDING))
304 {
305 if (blinding == NULL)
306 {
307 RSAerr(RSA_F_RSA_EAY_PRIVATE_ENCRYPT, ERR_R_INTERNAL_ERROR);
308 goto err;
309 }
310 }
311
312 if (blinding != NULL)
313 {
314 if (blinding->thread_id != CRYPTO_thread_id())
315 {
316 /* we need a local one-time blinding factor */
317
318 blinding = setup_blinding(rsa, ctx);
319 if (blinding == NULL)
320 goto err;
321 local_blinding = 1;
322 }
323 }
324 260
325 if (blinding) 261 if (rsa->flags & RSA_FLAG_BLINDING)
326 if (!BN_BLINDING_convert(&f, blinding, ctx)) goto err; 262 if (!BN_BLINDING_convert(&f,rsa->blinding,ctx)) goto err;
327 263
328 if ( (rsa->flags & RSA_FLAG_EXT_PKEY) || 264 if ( (rsa->flags & RSA_FLAG_EXT_PKEY) ||
329 ((rsa->p != NULL) && 265 ((rsa->p != NULL) &&
@@ -337,8 +273,8 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
337 if (!rsa->meth->bn_mod_exp(&ret,&f,rsa->d,rsa->n,ctx,NULL)) goto err; 273 if (!rsa->meth->bn_mod_exp(&ret,&f,rsa->d,rsa->n,ctx,NULL)) goto err;
338 } 274 }
339 275
340 if (blinding) 276 if (rsa->flags & RSA_FLAG_BLINDING)
341 if (!BN_BLINDING_invert(&ret, blinding, ctx)) goto err; 277 if (!BN_BLINDING_invert(&ret,rsa->blinding,ctx)) goto err;
342 278
343 /* put in leading 0 bytes if the number is less than the 279 /* put in leading 0 bytes if the number is less than the
344 * length of the modulus */ 280 * length of the modulus */
@@ -352,11 +288,9 @@ err:
352 if (ctx != NULL) BN_CTX_free(ctx); 288 if (ctx != NULL) BN_CTX_free(ctx);
353 BN_clear_free(&ret); 289 BN_clear_free(&ret);
354 BN_clear_free(&f); 290 BN_clear_free(&f);
355 if (local_blinding)
356 BN_BLINDING_free(blinding);
357 if (buf != NULL) 291 if (buf != NULL)
358 { 292 {
359 OPENSSL_cleanse(buf,num); 293 memset(buf,0,num);
360 OPENSSL_free(buf); 294 OPENSSL_free(buf);
361 } 295 }
362 return(r); 296 return(r);
@@ -370,8 +304,6 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from,
370 unsigned char *p; 304 unsigned char *p;
371 unsigned char *buf=NULL; 305 unsigned char *buf=NULL;
372 BN_CTX *ctx=NULL; 306 BN_CTX *ctx=NULL;
373 int local_blinding = 0;
374 BN_BLINDING *blinding = NULL;
375 307
376 BN_init(&f); 308 BN_init(&f);
377 BN_init(&ret); 309 BN_init(&ret);
@@ -404,38 +336,9 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from,
404 } 336 }
405 337
406 BLINDING_HELPER(rsa, ctx, goto err;); 338 BLINDING_HELPER(rsa, ctx, goto err;);
407 blinding = rsa->blinding;
408
409 /* Now unless blinding is disabled, 'blinding' is non-NULL.
410 * But the BN_BLINDING object may be owned by some other thread
411 * (we don't want to keep it constant and we don't want to use
412 * lots of locking to avoid race conditions, so only a single
413 * thread can use it; other threads have to use local blinding
414 * factors) */
415 if (!(rsa->flags & RSA_FLAG_NO_BLINDING))
416 {
417 if (blinding == NULL)
418 {
419 RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT, ERR_R_INTERNAL_ERROR);
420 goto err;
421 }
422 }
423
424 if (blinding != NULL)
425 {
426 if (blinding->thread_id != CRYPTO_thread_id())
427 {
428 /* we need a local one-time blinding factor */
429
430 blinding = setup_blinding(rsa, ctx);
431 if (blinding == NULL)
432 goto err;
433 local_blinding = 1;
434 }
435 }
436 339
437 if (blinding) 340 if (rsa->flags & RSA_FLAG_BLINDING)
438 if (!BN_BLINDING_convert(&f, blinding, ctx)) goto err; 341 if (!BN_BLINDING_convert(&f,rsa->blinding,ctx)) goto err;
439 342
440 /* do the decrypt */ 343 /* do the decrypt */
441 if ( (rsa->flags & RSA_FLAG_EXT_PKEY) || 344 if ( (rsa->flags & RSA_FLAG_EXT_PKEY) ||
@@ -451,8 +354,8 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from,
451 goto err; 354 goto err;
452 } 355 }
453 356
454 if (blinding) 357 if (rsa->flags & RSA_FLAG_BLINDING)
455 if (!BN_BLINDING_invert(&ret, blinding, ctx)) goto err; 358 if (!BN_BLINDING_invert(&ret,rsa->blinding,ctx)) goto err;
456 359
457 p=buf; 360 p=buf;
458 j=BN_bn2bin(&ret,p); /* j is only used with no-padding mode */ 361 j=BN_bn2bin(&ret,p); /* j is only used with no-padding mode */
@@ -486,7 +389,7 @@ err:
486 BN_clear_free(&ret); 389 BN_clear_free(&ret);
487 if (buf != NULL) 390 if (buf != NULL)
488 { 391 {
489 OPENSSL_cleanse(buf,num); 392 memset(buf,0,num);
490 OPENSSL_free(buf); 393 OPENSSL_free(buf);
491 } 394 }
492 return(r); 395 return(r);
@@ -583,7 +486,7 @@ err:
583 BN_clear_free(&ret); 486 BN_clear_free(&ret);
584 if (buf != NULL) 487 if (buf != NULL)
585 { 488 {
586 OPENSSL_cleanse(buf,num); 489 memset(buf,0,num);
587 OPENSSL_free(buf); 490 OPENSSL_free(buf);
588 } 491 }
589 return(r); 492 return(r);
diff --git a/src/lib/libcrypto/rsa/rsa_lib.c b/src/lib/libcrypto/rsa/rsa_lib.c
index 53c5092014..37fff8bce3 100644
--- a/src/lib/libcrypto/rsa/rsa_lib.c
+++ b/src/lib/libcrypto/rsa/rsa_lib.c
@@ -62,10 +62,7 @@
62#include <openssl/lhash.h> 62#include <openssl/lhash.h>
63#include <openssl/bn.h> 63#include <openssl/bn.h>
64#include <openssl/rsa.h> 64#include <openssl/rsa.h>
65#include <openssl/rand.h>
66#ifndef OPENSSL_NO_ENGINE
67#include <openssl/engine.h> 65#include <openssl/engine.h>
68#endif
69 66
70const char *RSA_version="RSA" OPENSSL_VERSION_PTEXT; 67const char *RSA_version="RSA" OPENSSL_VERSION_PTEXT;
71 68
@@ -75,6 +72,10 @@ RSA *RSA_new(void)
75 { 72 {
76 RSA *r=RSA_new_method(NULL); 73 RSA *r=RSA_new_method(NULL);
77 74
75#ifndef OPENSSL_NO_FORCE_RSA_BLINDING
76 r->flags|=RSA_FLAG_BLINDING;
77#endif
78
78 return r; 79 return r;
79 } 80 }
80 81
@@ -113,13 +114,11 @@ int RSA_set_method(RSA *rsa, const RSA_METHOD *meth)
113 const RSA_METHOD *mtmp; 114 const RSA_METHOD *mtmp;
114 mtmp = rsa->meth; 115 mtmp = rsa->meth;
115 if (mtmp->finish) mtmp->finish(rsa); 116 if (mtmp->finish) mtmp->finish(rsa);
116#ifndef OPENSSL_NO_ENGINE
117 if (rsa->engine) 117 if (rsa->engine)
118 { 118 {
119 ENGINE_finish(rsa->engine); 119 ENGINE_finish(rsa->engine);
120 rsa->engine = NULL; 120 rsa->engine = NULL;
121 } 121 }
122#endif
123 rsa->meth = meth; 122 rsa->meth = meth;
124 if (meth->init) meth->init(rsa); 123 if (meth->init) meth->init(rsa);
125 return 1; 124 return 1;
@@ -137,7 +136,6 @@ RSA *RSA_new_method(ENGINE *engine)
137 } 136 }
138 137
139 ret->meth = RSA_get_default_method(); 138 ret->meth = RSA_get_default_method();
140#ifndef OPENSSL_NO_ENGINE
141 if (engine) 139 if (engine)
142 { 140 {
143 if (!ENGINE_init(engine)) 141 if (!ENGINE_init(engine))
@@ -162,7 +160,6 @@ RSA *RSA_new_method(ENGINE *engine)
162 return NULL; 160 return NULL;
163 } 161 }
164 } 162 }
165#endif
166 163
167 ret->pad=0; 164 ret->pad=0;
168 ret->version=0; 165 ret->version=0;
@@ -184,10 +181,8 @@ RSA *RSA_new_method(ENGINE *engine)
184 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data); 181 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data);
185 if ((ret->meth->init != NULL) && !ret->meth->init(ret)) 182 if ((ret->meth->init != NULL) && !ret->meth->init(ret))
186 { 183 {
187#ifndef OPENSSL_NO_ENGINE
188 if (ret->engine) 184 if (ret->engine)
189 ENGINE_finish(ret->engine); 185 ENGINE_finish(ret->engine);
190#endif
191 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data); 186 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data);
192 OPENSSL_free(ret); 187 OPENSSL_free(ret);
193 ret=NULL; 188 ret=NULL;
@@ -216,10 +211,8 @@ void RSA_free(RSA *r)
216 211
217 if (r->meth->finish) 212 if (r->meth->finish)
218 r->meth->finish(r); 213 r->meth->finish(r);
219#ifndef OPENSSL_NO_ENGINE
220 if (r->engine) 214 if (r->engine)
221 ENGINE_finish(r->engine); 215 ENGINE_finish(r->engine);
222#endif
223 216
224 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, r, &r->ex_data); 217 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, r, &r->ex_data);
225 218
@@ -310,8 +303,7 @@ void RSA_blinding_off(RSA *rsa)
310 BN_BLINDING_free(rsa->blinding); 303 BN_BLINDING_free(rsa->blinding);
311 rsa->blinding=NULL; 304 rsa->blinding=NULL;
312 } 305 }
313 rsa->flags &= ~RSA_FLAG_BLINDING; 306 rsa->flags&= ~RSA_FLAG_BLINDING;
314 rsa->flags |= RSA_FLAG_NO_BLINDING;
315 } 307 }
316 308
317int RSA_blinding_on(RSA *rsa, BN_CTX *p_ctx) 309int RSA_blinding_on(RSA *rsa, BN_CTX *p_ctx)
@@ -330,32 +322,15 @@ int RSA_blinding_on(RSA *rsa, BN_CTX *p_ctx)
330 if (rsa->blinding != NULL) 322 if (rsa->blinding != NULL)
331 BN_BLINDING_free(rsa->blinding); 323 BN_BLINDING_free(rsa->blinding);
332 324
333 /* NB: similar code appears in setup_blinding (rsa_eay.c);
334 * this should be placed in a new function of its own, but for reasons
335 * of binary compatibility can't */
336
337 BN_CTX_start(ctx); 325 BN_CTX_start(ctx);
338 A = BN_CTX_get(ctx); 326 A = BN_CTX_get(ctx);
339 if ((RAND_status() == 0) && rsa->d != NULL && rsa->d->d != NULL) 327 if (!BN_rand_range(A,rsa->n)) goto err;
340 {
341 /* if PRNG is not properly seeded, resort to secret exponent as unpredictable seed */
342 RAND_add(rsa->d->d, rsa->d->dmax * sizeof rsa->d->d[0], 0);
343 if (!BN_pseudo_rand_range(A,rsa->n)) goto err;
344 }
345 else
346 {
347 if (!BN_rand_range(A,rsa->n)) goto err;
348 }
349 if ((Ai=BN_mod_inverse(NULL,A,rsa->n,ctx)) == NULL) goto err; 328 if ((Ai=BN_mod_inverse(NULL,A,rsa->n,ctx)) == NULL) goto err;
350 329
351 if (!rsa->meth->bn_mod_exp(A,A,rsa->e,rsa->n,ctx,rsa->_method_mod_n)) 330 if (!rsa->meth->bn_mod_exp(A,A,rsa->e,rsa->n,ctx,rsa->_method_mod_n))
352 goto err; 331 goto err;
353 if ((rsa->blinding=BN_BLINDING_new(A,Ai,rsa->n)) == NULL) goto err; 332 rsa->blinding=BN_BLINDING_new(A,Ai,rsa->n);
354 /* to make things thread-safe without excessive locking, 333 rsa->flags|=RSA_FLAG_BLINDING;
355 * rsa->blinding will be used just by the current thread: */
356 rsa->blinding->thread_id = CRYPTO_thread_id();
357 rsa->flags |= RSA_FLAG_BLINDING;
358 rsa->flags &= ~RSA_FLAG_NO_BLINDING;
359 BN_free(Ai); 334 BN_free(Ai);
360 ret=1; 335 ret=1;
361err: 336err:
diff --git a/src/lib/libcrypto/rsa/rsa_null.c b/src/lib/libcrypto/rsa/rsa_null.c
new file mode 100644
index 0000000000..64057fbdcf
--- /dev/null
+++ b/src/lib/libcrypto/rsa/rsa_null.c
@@ -0,0 +1,150 @@
1/* rsa_null.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
3 * project 1999.
4 */
5/* ====================================================================
6 * Copyright (c) 1999 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 "cryptlib.h"
61#include <openssl/bn.h>
62#include <openssl/rsa.h>
63#include <openssl/rand.h>
64
65/* This is a dummy RSA implementation that just returns errors when called.
66 * It is designed to allow some RSA functions to work while stopping those
67 * covered by the RSA patent. That is RSA, encryption, decryption, signing
68 * and verify is not allowed but RSA key generation, key checking and other
69 * operations (like storing RSA keys) are permitted.
70 */
71
72static int RSA_null_public_encrypt(int flen, const unsigned char *from,
73 unsigned char *to, RSA *rsa,int padding);
74static int RSA_null_private_encrypt(int flen, const unsigned char *from,
75 unsigned char *to, RSA *rsa,int padding);
76static int RSA_null_public_decrypt(int flen, const unsigned char *from,
77 unsigned char *to, RSA *rsa,int padding);
78static int RSA_null_private_decrypt(int flen, const unsigned char *from,
79 unsigned char *to, RSA *rsa,int padding);
80#if 0 /* not currently used */
81static int RSA_null_mod_exp(const BIGNUM *r0, const BIGNUM *i, RSA *rsa);
82#endif
83static int RSA_null_init(RSA *rsa);
84static int RSA_null_finish(RSA *rsa);
85static RSA_METHOD rsa_null_meth={
86 "Null RSA",
87 RSA_null_public_encrypt,
88 RSA_null_public_decrypt,
89 RSA_null_private_encrypt,
90 RSA_null_private_decrypt,
91 NULL,
92 NULL,
93 RSA_null_init,
94 RSA_null_finish,
95 0,
96 NULL,
97 };
98
99const RSA_METHOD *RSA_null_method(void)
100 {
101 return(&rsa_null_meth);
102 }
103
104static int RSA_null_public_encrypt(int flen, const unsigned char *from,
105 unsigned char *to, RSA *rsa, int padding)
106 {
107 RSAerr(RSA_F_RSA_NULL, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
108 return -1;
109 }
110
111static int RSA_null_private_encrypt(int flen, const unsigned char *from,
112 unsigned char *to, RSA *rsa, int padding)
113 {
114 RSAerr(RSA_F_RSA_NULL, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
115 return -1;
116 }
117
118static int RSA_null_private_decrypt(int flen, const unsigned char *from,
119 unsigned char *to, RSA *rsa, int padding)
120 {
121 RSAerr(RSA_F_RSA_NULL, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
122 return -1;
123 }
124
125static int RSA_null_public_decrypt(int flen, const unsigned char *from,
126 unsigned char *to, RSA *rsa, int padding)
127 {
128 RSAerr(RSA_F_RSA_NULL, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
129 return -1;
130 }
131
132#if 0 /* not currently used */
133static int RSA_null_mod_exp(BIGNUM *r0, BIGNUM *I, RSA *rsa)
134 {
135 RSAerr(RSA_F_RSA_NULL, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
136 return -1;
137 }
138#endif
139
140static int RSA_null_init(RSA *rsa)
141 {
142 return(1);
143 }
144
145static int RSA_null_finish(RSA *rsa)
146 {
147 return(1);
148 }
149
150
diff --git a/src/lib/libcrypto/rsa/rsa_pk1.c b/src/lib/libcrypto/rsa/rsa_pk1.c
index 8560755f1d..c1edd6764f 100644
--- a/src/lib/libcrypto/rsa/rsa_pk1.c
+++ b/src/lib/libcrypto/rsa/rsa_pk1.c
@@ -68,7 +68,7 @@ int RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen,
68 int j; 68 int j;
69 unsigned char *p; 69 unsigned char *p;
70 70
71 if (flen > (tlen-RSA_PKCS1_PADDING_SIZE)) 71 if (flen > (tlen-11))
72 { 72 {
73 RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1,RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE); 73 RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1,RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE);
74 return(0); 74 return(0);
diff --git a/src/lib/libcrypto/rsa/rsa_saos.c b/src/lib/libcrypto/rsa/rsa_saos.c
index f462716a57..85adacc08f 100644
--- a/src/lib/libcrypto/rsa/rsa_saos.c
+++ b/src/lib/libcrypto/rsa/rsa_saos.c
@@ -77,7 +77,7 @@ int RSA_sign_ASN1_OCTET_STRING(int type,
77 77
78 i=i2d_ASN1_OCTET_STRING(&sig,NULL); 78 i=i2d_ASN1_OCTET_STRING(&sig,NULL);
79 j=RSA_size(rsa); 79 j=RSA_size(rsa);
80 if (i > (j-RSA_PKCS1_PADDING_SIZE)) 80 if ((i-RSA_PKCS1_PADDING) > j)
81 { 81 {
82 RSAerr(RSA_F_RSA_SIGN_ASN1_OCTET_STRING,RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY); 82 RSAerr(RSA_F_RSA_SIGN_ASN1_OCTET_STRING,RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY);
83 return(0); 83 return(0);
@@ -96,7 +96,7 @@ int RSA_sign_ASN1_OCTET_STRING(int type,
96 else 96 else
97 *siglen=i; 97 *siglen=i;
98 98
99 OPENSSL_cleanse(s,(unsigned int)j+1); 99 memset(s,0,(unsigned int)j+1);
100 OPENSSL_free(s); 100 OPENSSL_free(s);
101 return(ret); 101 return(ret);
102 } 102 }
@@ -139,7 +139,7 @@ int RSA_verify_ASN1_OCTET_STRING(int dtype,
139 ret=1; 139 ret=1;
140err: 140err:
141 if (sig != NULL) M_ASN1_OCTET_STRING_free(sig); 141 if (sig != NULL) M_ASN1_OCTET_STRING_free(sig);
142 OPENSSL_cleanse(s,(unsigned int)siglen); 142 memset(s,0,(unsigned int)siglen);
143 OPENSSL_free(s); 143 OPENSSL_free(s);
144 return(ret); 144 return(ret);
145 } 145 }
diff --git a/src/lib/libcrypto/rsa/rsa_sign.c b/src/lib/libcrypto/rsa/rsa_sign.c
index 8a1e642183..2a440901de 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 <openssl/engine.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
@@ -76,11 +77,10 @@ int RSA_sign(int type, const unsigned char *m, unsigned int m_len,
76 const unsigned char *s = NULL; 77 const unsigned char *s = NULL;
77 X509_ALGOR algor; 78 X509_ALGOR algor;
78 ASN1_OCTET_STRING digest; 79 ASN1_OCTET_STRING digest;
79 if((rsa->flags & RSA_FLAG_SIGN_VER) && rsa->meth->rsa_sign) 80 if((rsa->flags & RSA_FLAG_SIGN_VER)
80 { 81 && ENGINE_get_RSA(rsa->engine)->rsa_sign)
81 return rsa->meth->rsa_sign(type, m, m_len, 82 return ENGINE_get_RSA(rsa->engine)->rsa_sign(type,
82 sigret, siglen, rsa); 83 m, m_len, sigret, siglen, rsa);
83 }
84 /* Special case: SSL signature, just check the length */ 84 /* Special case: SSL signature, just check the length */
85 if(type == NID_md5_sha1) { 85 if(type == NID_md5_sha1) {
86 if(m_len != SSL_SIG_LENGTH) { 86 if(m_len != SSL_SIG_LENGTH) {
@@ -113,7 +113,7 @@ int RSA_sign(int type, const unsigned char *m, unsigned int m_len,
113 i=i2d_X509_SIG(&sig,NULL); 113 i=i2d_X509_SIG(&sig,NULL);
114 } 114 }
115 j=RSA_size(rsa); 115 j=RSA_size(rsa);
116 if (i > (j-RSA_PKCS1_PADDING_SIZE)) 116 if ((i-RSA_PKCS1_PADDING) > j)
117 { 117 {
118 RSAerr(RSA_F_RSA_SIGN,RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY); 118 RSAerr(RSA_F_RSA_SIGN,RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY);
119 return(0); 119 return(0);
@@ -136,7 +136,7 @@ int RSA_sign(int type, const unsigned char *m, unsigned int m_len,
136 *siglen=i; 136 *siglen=i;
137 137
138 if(type != NID_md5_sha1) { 138 if(type != NID_md5_sha1) {
139 OPENSSL_cleanse(tmps,(unsigned int)j+1); 139 memset(tmps,0,(unsigned int)j+1);
140 OPENSSL_free(tmps); 140 OPENSSL_free(tmps);
141 } 141 }
142 return(ret); 142 return(ret);
@@ -155,11 +155,10 @@ int RSA_verify(int dtype, const unsigned char *m, unsigned int m_len,
155 return(0); 155 return(0);
156 } 156 }
157 157
158 if((rsa->flags & RSA_FLAG_SIGN_VER) && rsa->meth->rsa_verify) 158 if((rsa->flags & RSA_FLAG_SIGN_VER)
159 { 159 && ENGINE_get_RSA(rsa->engine)->rsa_verify)
160 return rsa->meth->rsa_verify(dtype, m, m_len, 160 return ENGINE_get_RSA(rsa->engine)->rsa_verify(dtype,
161 sigbuf, siglen, rsa); 161 m, m_len, sigbuf, siglen, rsa);
162 }
163 162
164 s=(unsigned char *)OPENSSL_malloc((unsigned int)siglen); 163 s=(unsigned char *)OPENSSL_malloc((unsigned int)siglen);
165 if (s == NULL) 164 if (s == NULL)
@@ -222,7 +221,7 @@ int RSA_verify(int dtype, const unsigned char *m, unsigned int m_len,
222 } 221 }
223err: 222err:
224 if (sig != NULL) X509_SIG_free(sig); 223 if (sig != NULL) X509_SIG_free(sig);
225 OPENSSL_cleanse(s,(unsigned int)siglen); 224 memset(s,0,(unsigned int)siglen);
226 OPENSSL_free(s); 225 OPENSSL_free(s);
227 return(ret); 226 return(ret);
228 } 227 }
diff --git a/src/lib/libcrypto/rsa/rsa_test.c b/src/lib/libcrypto/rsa/rsa_test.c
new file mode 100644
index 0000000000..b8b462d33b
--- /dev/null
+++ b/src/lib/libcrypto/rsa/rsa_test.c
@@ -0,0 +1,318 @@
1/* test vectors from p1ovect1.txt */
2
3#include <stdio.h>
4#include <string.h>
5
6#include "e_os.h"
7
8#include <openssl/crypto.h>
9#include <openssl/err.h>
10#include <openssl/rand.h>
11#ifdef OPENSSL_NO_RSA
12int main(int argc, char *argv[])
13{
14 printf("No RSA support\n");
15 return(0);
16}
17#else
18#include <openssl/rsa.h>
19#include <openssl/engine.h>
20
21#define SetKey \
22 key->n = BN_bin2bn(n, sizeof(n)-1, key->n); \
23 key->e = BN_bin2bn(e, sizeof(e)-1, key->e); \
24 key->d = BN_bin2bn(d, sizeof(d)-1, key->d); \
25 key->p = BN_bin2bn(p, sizeof(p)-1, key->p); \
26 key->q = BN_bin2bn(q, sizeof(q)-1, key->q); \
27 key->dmp1 = BN_bin2bn(dmp1, sizeof(dmp1)-1, key->dmp1); \
28 key->dmq1 = BN_bin2bn(dmq1, sizeof(dmq1)-1, key->dmq1); \
29 key->iqmp = BN_bin2bn(iqmp, sizeof(iqmp)-1, key->iqmp); \
30 memcpy(c, ctext_ex, sizeof(ctext_ex) - 1); \
31 return (sizeof(ctext_ex) - 1);
32
33static int key1(RSA *key, unsigned char *c)
34 {
35 static unsigned char n[] =
36"\x00\xAA\x36\xAB\xCE\x88\xAC\xFD\xFF\x55\x52\x3C\x7F\xC4\x52\x3F"
37"\x90\xEF\xA0\x0D\xF3\x77\x4A\x25\x9F\x2E\x62\xB4\xC5\xD9\x9C\xB5"
38"\xAD\xB3\x00\xA0\x28\x5E\x53\x01\x93\x0E\x0C\x70\xFB\x68\x76\x93"
39"\x9C\xE6\x16\xCE\x62\x4A\x11\xE0\x08\x6D\x34\x1E\xBC\xAC\xA0\xA1"
40"\xF5";
41
42 static unsigned char e[] = "\x11";
43
44 static unsigned char d[] =
45"\x0A\x03\x37\x48\x62\x64\x87\x69\x5F\x5F\x30\xBC\x38\xB9\x8B\x44"
46"\xC2\xCD\x2D\xFF\x43\x40\x98\xCD\x20\xD8\xA1\x38\xD0\x90\xBF\x64"
47"\x79\x7C\x3F\xA7\xA2\xCD\xCB\x3C\xD1\xE0\xBD\xBA\x26\x54\xB4\xF9"
48"\xDF\x8E\x8A\xE5\x9D\x73\x3D\x9F\x33\xB3\x01\x62\x4A\xFD\x1D\x51";
49
50 static unsigned char p[] =
51"\x00\xD8\x40\xB4\x16\x66\xB4\x2E\x92\xEA\x0D\xA3\xB4\x32\x04\xB5"
52"\xCF\xCE\x33\x52\x52\x4D\x04\x16\xA5\xA4\x41\xE7\x00\xAF\x46\x12"
53"\x0D";
54
55 static unsigned char q[] =
56"\x00\xC9\x7F\xB1\xF0\x27\xF4\x53\xF6\x34\x12\x33\xEA\xAA\xD1\xD9"
57"\x35\x3F\x6C\x42\xD0\x88\x66\xB1\xD0\x5A\x0F\x20\x35\x02\x8B\x9D"
58"\x89";
59
60 static unsigned char dmp1[] =
61"\x59\x0B\x95\x72\xA2\xC2\xA9\xC4\x06\x05\x9D\xC2\xAB\x2F\x1D\xAF"
62"\xEB\x7E\x8B\x4F\x10\xA7\x54\x9E\x8E\xED\xF5\xB4\xFC\xE0\x9E\x05";
63
64 static unsigned char dmq1[] =
65"\x00\x8E\x3C\x05\x21\xFE\x15\xE0\xEA\x06\xA3\x6F\xF0\xF1\x0C\x99"
66"\x52\xC3\x5B\x7A\x75\x14\xFD\x32\x38\xB8\x0A\xAD\x52\x98\x62\x8D"
67"\x51";
68
69 static unsigned char iqmp[] =
70"\x36\x3F\xF7\x18\x9D\xA8\xE9\x0B\x1D\x34\x1F\x71\xD0\x9B\x76\xA8"
71"\xA9\x43\xE1\x1D\x10\xB2\x4D\x24\x9F\x2D\xEA\xFE\xF8\x0C\x18\x26";
72
73 static unsigned char ctext_ex[] =
74"\x1b\x8f\x05\xf9\xca\x1a\x79\x52\x6e\x53\xf3\xcc\x51\x4f\xdb\x89"
75"\x2b\xfb\x91\x93\x23\x1e\x78\xb9\x92\xe6\x8d\x50\xa4\x80\xcb\x52"
76"\x33\x89\x5c\x74\x95\x8d\x5d\x02\xab\x8c\x0f\xd0\x40\xeb\x58\x44"
77"\xb0\x05\xc3\x9e\xd8\x27\x4a\x9d\xbf\xa8\x06\x71\x40\x94\x39\xd2";
78
79 SetKey;
80 }
81
82static int key2(RSA *key, unsigned char *c)
83 {
84 static unsigned char n[] =
85"\x00\xA3\x07\x9A\x90\xDF\x0D\xFD\x72\xAC\x09\x0C\xCC\x2A\x78\xB8"
86"\x74\x13\x13\x3E\x40\x75\x9C\x98\xFA\xF8\x20\x4F\x35\x8A\x0B\x26"
87"\x3C\x67\x70\xE7\x83\xA9\x3B\x69\x71\xB7\x37\x79\xD2\x71\x7B\xE8"
88"\x34\x77\xCF";
89
90 static unsigned char e[] = "\x3";
91
92 static unsigned char d[] =
93"\x6C\xAF\xBC\x60\x94\xB3\xFE\x4C\x72\xB0\xB3\x32\xC6\xFB\x25\xA2"
94"\xB7\x62\x29\x80\x4E\x68\x65\xFC\xA4\x5A\x74\xDF\x0F\x8F\xB8\x41"
95"\x3B\x52\xC0\xD0\xE5\x3D\x9B\x59\x0F\xF1\x9B\xE7\x9F\x49\xDD\x21"
96"\xE5\xEB";
97
98 static unsigned char p[] =
99"\x00\xCF\x20\x35\x02\x8B\x9D\x86\x98\x40\xB4\x16\x66\xB4\x2E\x92"
100"\xEA\x0D\xA3\xB4\x32\x04\xB5\xCF\xCE\x91";
101
102 static unsigned char q[] =
103"\x00\xC9\x7F\xB1\xF0\x27\xF4\x53\xF6\x34\x12\x33\xEA\xAA\xD1\xD9"
104"\x35\x3F\x6C\x42\xD0\x88\x66\xB1\xD0\x5F";
105
106 static unsigned char dmp1[] =
107"\x00\x8A\x15\x78\xAC\x5D\x13\xAF\x10\x2B\x22\xB9\x99\xCD\x74\x61"
108"\xF1\x5E\x6D\x22\xCC\x03\x23\xDF\xDF\x0B";
109
110 static unsigned char dmq1[] =
111"\x00\x86\x55\x21\x4A\xC5\x4D\x8D\x4E\xCD\x61\x77\xF1\xC7\x36\x90"
112"\xCE\x2A\x48\x2C\x8B\x05\x99\xCB\xE0\x3F";
113
114 static unsigned char iqmp[] =
115"\x00\x83\xEF\xEF\xB8\xA9\xA4\x0D\x1D\xB6\xED\x98\xAD\x84\xED\x13"
116"\x35\xDC\xC1\x08\xF3\x22\xD0\x57\xCF\x8D";
117
118 static unsigned char ctext_ex[] =
119"\x14\xbd\xdd\x28\xc9\x83\x35\x19\x23\x80\xe8\xe5\x49\xb1\x58\x2a"
120"\x8b\x40\xb4\x48\x6d\x03\xa6\xa5\x31\x1f\x1f\xd5\xf0\xa1\x80\xe4"
121"\x17\x53\x03\x29\xa9\x34\x90\x74\xb1\x52\x13\x54\x29\x08\x24\x52"
122"\x62\x51";
123
124 SetKey;
125 }
126
127static int key3(RSA *key, unsigned char *c)
128 {
129 static unsigned char n[] =
130"\x00\xBB\xF8\x2F\x09\x06\x82\xCE\x9C\x23\x38\xAC\x2B\x9D\xA8\x71"
131"\xF7\x36\x8D\x07\xEE\xD4\x10\x43\xA4\x40\xD6\xB6\xF0\x74\x54\xF5"
132"\x1F\xB8\xDF\xBA\xAF\x03\x5C\x02\xAB\x61\xEA\x48\xCE\xEB\x6F\xCD"
133"\x48\x76\xED\x52\x0D\x60\xE1\xEC\x46\x19\x71\x9D\x8A\x5B\x8B\x80"
134"\x7F\xAF\xB8\xE0\xA3\xDF\xC7\x37\x72\x3E\xE6\xB4\xB7\xD9\x3A\x25"
135"\x84\xEE\x6A\x64\x9D\x06\x09\x53\x74\x88\x34\xB2\x45\x45\x98\x39"
136"\x4E\xE0\xAA\xB1\x2D\x7B\x61\xA5\x1F\x52\x7A\x9A\x41\xF6\xC1\x68"
137"\x7F\xE2\x53\x72\x98\xCA\x2A\x8F\x59\x46\xF8\xE5\xFD\x09\x1D\xBD"
138"\xCB";
139
140 static unsigned char e[] = "\x11";
141
142 static unsigned char d[] =
143"\x00\xA5\xDA\xFC\x53\x41\xFA\xF2\x89\xC4\xB9\x88\xDB\x30\xC1\xCD"
144"\xF8\x3F\x31\x25\x1E\x06\x68\xB4\x27\x84\x81\x38\x01\x57\x96\x41"
145"\xB2\x94\x10\xB3\xC7\x99\x8D\x6B\xC4\x65\x74\x5E\x5C\x39\x26\x69"
146"\xD6\x87\x0D\xA2\xC0\x82\xA9\x39\xE3\x7F\xDC\xB8\x2E\xC9\x3E\xDA"
147"\xC9\x7F\xF3\xAD\x59\x50\xAC\xCF\xBC\x11\x1C\x76\xF1\xA9\x52\x94"
148"\x44\xE5\x6A\xAF\x68\xC5\x6C\x09\x2C\xD3\x8D\xC3\xBE\xF5\xD2\x0A"
149"\x93\x99\x26\xED\x4F\x74\xA1\x3E\xDD\xFB\xE1\xA1\xCE\xCC\x48\x94"
150"\xAF\x94\x28\xC2\xB7\xB8\x88\x3F\xE4\x46\x3A\x4B\xC8\x5B\x1C\xB3"
151"\xC1";
152
153 static unsigned char p[] =
154"\x00\xEE\xCF\xAE\x81\xB1\xB9\xB3\xC9\x08\x81\x0B\x10\xA1\xB5\x60"
155"\x01\x99\xEB\x9F\x44\xAE\xF4\xFD\xA4\x93\xB8\x1A\x9E\x3D\x84\xF6"
156"\x32\x12\x4E\xF0\x23\x6E\x5D\x1E\x3B\x7E\x28\xFA\xE7\xAA\x04\x0A"
157"\x2D\x5B\x25\x21\x76\x45\x9D\x1F\x39\x75\x41\xBA\x2A\x58\xFB\x65"
158"\x99";
159
160 static unsigned char q[] =
161"\x00\xC9\x7F\xB1\xF0\x27\xF4\x53\xF6\x34\x12\x33\xEA\xAA\xD1\xD9"
162"\x35\x3F\x6C\x42\xD0\x88\x66\xB1\xD0\x5A\x0F\x20\x35\x02\x8B\x9D"
163"\x86\x98\x40\xB4\x16\x66\xB4\x2E\x92\xEA\x0D\xA3\xB4\x32\x04\xB5"
164"\xCF\xCE\x33\x52\x52\x4D\x04\x16\xA5\xA4\x41\xE7\x00\xAF\x46\x15"
165"\x03";
166
167 static unsigned char dmp1[] =
168"\x54\x49\x4C\xA6\x3E\xBA\x03\x37\xE4\xE2\x40\x23\xFC\xD6\x9A\x5A"
169"\xEB\x07\xDD\xDC\x01\x83\xA4\xD0\xAC\x9B\x54\xB0\x51\xF2\xB1\x3E"
170"\xD9\x49\x09\x75\xEA\xB7\x74\x14\xFF\x59\xC1\xF7\x69\x2E\x9A\x2E"
171"\x20\x2B\x38\xFC\x91\x0A\x47\x41\x74\xAD\xC9\x3C\x1F\x67\xC9\x81";
172
173 static unsigned char dmq1[] =
174"\x47\x1E\x02\x90\xFF\x0A\xF0\x75\x03\x51\xB7\xF8\x78\x86\x4C\xA9"
175"\x61\xAD\xBD\x3A\x8A\x7E\x99\x1C\x5C\x05\x56\xA9\x4C\x31\x46\xA7"
176"\xF9\x80\x3F\x8F\x6F\x8A\xE3\x42\xE9\x31\xFD\x8A\xE4\x7A\x22\x0D"
177"\x1B\x99\xA4\x95\x84\x98\x07\xFE\x39\xF9\x24\x5A\x98\x36\xDA\x3D";
178
179 static unsigned char iqmp[] =
180"\x00\xB0\x6C\x4F\xDA\xBB\x63\x01\x19\x8D\x26\x5B\xDB\xAE\x94\x23"
181"\xB3\x80\xF2\x71\xF7\x34\x53\x88\x50\x93\x07\x7F\xCD\x39\xE2\x11"
182"\x9F\xC9\x86\x32\x15\x4F\x58\x83\xB1\x67\xA9\x67\xBF\x40\x2B\x4E"
183"\x9E\x2E\x0F\x96\x56\xE6\x98\xEA\x36\x66\xED\xFB\x25\x79\x80\x39"
184"\xF7";
185
186 static unsigned char ctext_ex[] =
187"\xb8\x24\x6b\x56\xa6\xed\x58\x81\xae\xb5\x85\xd9\xa2\x5b\x2a\xd7"
188"\x90\xc4\x17\xe0\x80\x68\x1b\xf1\xac\x2b\xc3\xde\xb6\x9d\x8b\xce"
189"\xf0\xc4\x36\x6f\xec\x40\x0a\xf0\x52\xa7\x2e\x9b\x0e\xff\xb5\xb3"
190"\xf2\xf1\x92\xdb\xea\xca\x03\xc1\x27\x40\x05\x71\x13\xbf\x1f\x06"
191"\x69\xac\x22\xe9\xf3\xa7\x85\x2e\x3c\x15\xd9\x13\xca\xb0\xb8\x86"
192"\x3a\x95\xc9\x92\x94\xce\x86\x74\x21\x49\x54\x61\x03\x46\xf4\xd4"
193"\x74\xb2\x6f\x7c\x48\xb4\x2e\xe6\x8e\x1f\x57\x2a\x1f\xc4\x02\x6a"
194"\xc4\x56\xb4\xf5\x9f\x7b\x62\x1e\xa1\xb9\xd8\x8f\x64\x20\x2f\xb1";
195
196 SetKey;
197 }
198
199static int pad_unknown(void)
200{
201 unsigned long l;
202 while ((l = ERR_get_error()) != 0)
203 if (ERR_GET_REASON(l) == RSA_R_UNKNOWN_PADDING_TYPE)
204 return(1);
205 return(0);
206}
207
208static const char rnd_seed[] = "string to make the random number generator think it has entropy";
209
210int main(int argc, char *argv[])
211 {
212 int err=0;
213 int v;
214 RSA *key;
215 unsigned char ptext[256];
216 unsigned char ctext[256];
217 static unsigned char ptext_ex[] = "\x54\x85\x9b\x34\x2c\x49\xea\x2a";
218 unsigned char ctext_ex[256];
219 int plen;
220 int clen = 0;
221 int num;
222
223 CRYPTO_malloc_debug_init();
224 CRYPTO_dbg_set_options(V_CRYPTO_MDEBUG_ALL);
225 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
226
227 RAND_seed(rnd_seed, sizeof rnd_seed); /* or OAEP may fail */
228
229 plen = sizeof(ptext_ex) - 1;
230
231 for (v = 0; v < 3; v++)
232 {
233 key = RSA_new();
234 switch (v) {
235 case 0:
236 clen = key1(key, ctext_ex);
237 break;
238 case 1:
239 clen = key2(key, ctext_ex);
240 break;
241 case 2:
242 clen = key3(key, ctext_ex);
243 break;
244 }
245
246 num = RSA_public_encrypt(plen, ptext_ex, ctext, key,
247 RSA_PKCS1_PADDING);
248 if (num != clen)
249 {
250 printf("PKCS#1 v1.5 encryption failed!\n");
251 err=1;
252 goto oaep;
253 }
254
255 num = RSA_private_decrypt(num, ctext, ptext, key,
256 RSA_PKCS1_PADDING);
257 if (num != plen || memcmp(ptext, ptext_ex, num) != 0)
258 {
259 printf("PKCS#1 v1.5 decryption failed!\n");
260 err=1;
261 }
262 else
263 printf("PKCS #1 v1.5 encryption/decryption ok\n");
264
265 oaep:
266 ERR_clear_error();
267 num = RSA_public_encrypt(plen, ptext_ex, ctext, key,
268 RSA_PKCS1_OAEP_PADDING);
269 if (num == -1 && pad_unknown())
270 {
271 printf("No OAEP support\n");
272 goto next;
273 }
274 if (num != clen)
275 {
276 printf("OAEP encryption failed!\n");
277 err=1;
278 goto next;
279 }
280
281 num = RSA_private_decrypt(num, ctext, ptext, key,
282 RSA_PKCS1_OAEP_PADDING);
283 if (num != plen || memcmp(ptext, ptext_ex, num) != 0)
284 {
285 printf("OAEP decryption (encrypted data) failed!\n");
286 err=1;
287 }
288 else if (memcmp(ctext, ctext_ex, num) == 0)
289 {
290 printf("OAEP test vector %d passed!\n", v);
291 goto next;
292 }
293
294 /* Different ciphertexts (rsa_oaep.c without -DPKCS_TESTVECT).
295 Try decrypting ctext_ex */
296
297 num = RSA_private_decrypt(clen, ctext_ex, ptext, key,
298 RSA_PKCS1_OAEP_PADDING);
299
300 if (num != plen || memcmp(ptext, ptext_ex, num) != 0)
301 {
302 printf("OAEP decryption (test vector data) failed!\n");
303 err=1;
304 }
305 else
306 printf("OAEP encryption/decryption ok\n");
307 next:
308 RSA_free(key);
309 }
310
311 CRYPTO_cleanup_all_ex_data();
312 ERR_remove_state(0);
313
314 CRYPTO_mem_leaks_fp(stderr);
315
316 return err;
317 }
318#endif
diff --git a/src/lib/libcrypto/sha/Makefile.ssl b/src/lib/libcrypto/sha/Makefile.ssl
new file mode 100644
index 0000000000..0aa678d6f4
--- /dev/null
+++ b/src/lib/libcrypto/sha/Makefile.ssl
@@ -0,0 +1,115 @@
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)
23
24GENERAL=Makefile
25TEST=shatest.c sha1test.c
26APPS=
27
28LIB=$(TOP)/libcrypto.a
29LIBSRC=sha_dgst.c sha1dgst.c sha_one.c sha1_one.c
30LIBOBJ=sha_dgst.o sha1dgst.o sha_one.o sha1_one.o $(SHA1_ASM_OBJ)
31
32SRC= $(LIBSRC)
33
34EXHEADER= sha.h
35HEADER= sha_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# elf
50asm/sx86-elf.o: asm/sx86unix.cpp
51 $(CPP) -DELF -x c asm/sx86unix.cpp | as -o asm/sx86-elf.o
52
53# solaris
54asm/sx86-sol.o: asm/sx86unix.cpp
55 $(CC) -E -DSOL asm/sx86unix.cpp | sed 's/^#.*//' > asm/sx86-sol.s
56 as -o asm/sx86-sol.o asm/sx86-sol.s
57 rm -f asm/sx86-sol.s
58
59# a.out
60asm/sx86-out.o: asm/sx86unix.cpp
61 $(CPP) -DOUT asm/sx86unix.cpp | as -o asm/sx86-out.o
62
63# bsdi
64asm/sx86bsdi.o: asm/sx86unix.cpp
65 $(CPP) -DBSDI asm/sx86unix.cpp | sed 's/ :/:/' | as -o asm/sx86bsdi.o
66
67asm/sx86unix.cpp: asm/sha1-586.pl ../perlasm/x86asm.pl
68 (cd asm; $(PERL) sha1-586.pl cpp $(PROCESSOR) >sx86unix.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/sx86unix.cpp *.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
106sha1_one.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
107sha1_one.o: ../../include/openssl/sha.h sha1_one.c
108sha1dgst.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
109sha1dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/sha.h
110sha1dgst.o: ../md32_common.h sha1dgst.c sha_locl.h
111sha_dgst.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
112sha_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/sha.h
113sha_dgst.o: ../md32_common.h sha_dgst.c sha_locl.h
114sha_one.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
115sha_one.o: ../../include/openssl/sha.h sha_one.c
diff --git a/src/lib/libcrypto/sha/asm/README b/src/lib/libcrypto/sha/asm/README
new file mode 100644
index 0000000000..b7e755765f
--- /dev/null
+++ b/src/lib/libcrypto/sha/asm/README
@@ -0,0 +1 @@
C2.pl works
diff --git a/src/lib/libcrypto/sha/sha.c b/src/lib/libcrypto/sha/sha.c
new file mode 100644
index 0000000000..42126551d1
--- /dev/null
+++ b/src/lib/libcrypto/sha/sha.c
@@ -0,0 +1,124 @@
1/* crypto/sha/sha.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <stdlib.h>
61#include <openssl/sha.h>
62
63#define BUFSIZE 1024*16
64
65void do_fp(FILE *f);
66void pt(unsigned char *md);
67int read(int, void *, unsigned int);
68int main(int argc, char **argv)
69 {
70 int i,err=0;
71 FILE *IN;
72
73 if (argc == 1)
74 {
75 do_fp(stdin);
76 }
77 else
78 {
79 for (i=1; i<argc; i++)
80 {
81 IN=fopen(argv[i],"r");
82 if (IN == NULL)
83 {
84 perror(argv[i]);
85 err++;
86 continue;
87 }
88 printf("SHA(%s)= ",argv[i]);
89 do_fp(IN);
90 fclose(IN);
91 }
92 }
93 exit(err);
94 }
95
96void do_fp(FILE *f)
97 {
98 SHA_CTX c;
99 unsigned char md[SHA_DIGEST_LENGTH];
100 int fd;
101 int i;
102 unsigned char buf[BUFSIZE];
103
104 fd=fileno(f);
105 SHA_Init(&c);
106 for (;;)
107 {
108 i=read(fd,buf,BUFSIZE);
109 if (i <= 0) break;
110 SHA_Update(&c,buf,(unsigned long)i);
111 }
112 SHA_Final(&(md[0]),&c);
113 pt(md);
114 }
115
116void pt(unsigned char *md)
117 {
118 int i;
119
120 for (i=0; i<SHA_DIGEST_LENGTH; i++)
121 printf("%02x",md[i]);
122 printf("\n");
123 }
124
diff --git a/src/lib/libcrypto/sha/sha1.c b/src/lib/libcrypto/sha/sha1.c
new file mode 100644
index 0000000000..d350c88ee4
--- /dev/null
+++ b/src/lib/libcrypto/sha/sha1.c
@@ -0,0 +1,127 @@
1/* crypto/sha/sha1.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <stdlib.h>
61#include <openssl/sha.h>
62
63#define BUFSIZE 1024*16
64
65void do_fp(FILE *f);
66void pt(unsigned char *md);
67#ifndef _OSD_POSIX
68int read(int, void *, unsigned int);
69#endif
70
71int main(int argc, char **argv)
72 {
73 int i,err=0;
74 FILE *IN;
75
76 if (argc == 1)
77 {
78 do_fp(stdin);
79 }
80 else
81 {
82 for (i=1; i<argc; i++)
83 {
84 IN=fopen(argv[i],"r");
85 if (IN == NULL)
86 {
87 perror(argv[i]);
88 err++;
89 continue;
90 }
91 printf("SHA1(%s)= ",argv[i]);
92 do_fp(IN);
93 fclose(IN);
94 }
95 }
96 exit(err);
97 }
98
99void do_fp(FILE *f)
100 {
101 SHA_CTX c;
102 unsigned char md[SHA_DIGEST_LENGTH];
103 int fd;
104 int i;
105 unsigned char buf[BUFSIZE];
106
107 fd=fileno(f);
108 SHA1_Init(&c);
109 for (;;)
110 {
111 i=read(fd,buf,BUFSIZE);
112 if (i <= 0) break;
113 SHA1_Update(&c,buf,(unsigned long)i);
114 }
115 SHA1_Final(&(md[0]),&c);
116 pt(md);
117 }
118
119void pt(unsigned char *md)
120 {
121 int i;
122
123 for (i=0; i<SHA_DIGEST_LENGTH; i++)
124 printf("%02x",md[i]);
125 printf("\n");
126 }
127
diff --git a/src/lib/libcrypto/sha/sha1_one.c b/src/lib/libcrypto/sha/sha1_one.c
index 20e660c71d..e6a24888ed 100644
--- a/src/lib/libcrypto/sha/sha1_one.c
+++ b/src/lib/libcrypto/sha/sha1_one.c
@@ -59,7 +59,6 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <string.h> 60#include <string.h>
61#include <openssl/sha.h> 61#include <openssl/sha.h>
62#include <openssl/crypto.h>
63 62
64#ifndef OPENSSL_NO_SHA1 63#ifndef OPENSSL_NO_SHA1
65unsigned char *SHA1(const unsigned char *d, unsigned long n, unsigned char *md) 64unsigned char *SHA1(const unsigned char *d, unsigned long n, unsigned char *md)
@@ -71,7 +70,7 @@ unsigned char *SHA1(const unsigned char *d, unsigned long n, unsigned char *md)
71 SHA1_Init(&c); 70 SHA1_Init(&c);
72 SHA1_Update(&c,d,n); 71 SHA1_Update(&c,d,n);
73 SHA1_Final(md,&c); 72 SHA1_Final(md,&c);
74 OPENSSL_cleanse(&c,sizeof(c)); 73 memset(&c,0,sizeof(c));
75 return(md); 74 return(md);
76 } 75 }
77#endif 76#endif
diff --git a/src/lib/libcrypto/sha/sha1s.cpp b/src/lib/libcrypto/sha/sha1s.cpp
new file mode 100644
index 0000000000..af23d1e0f2
--- /dev/null
+++ b/src/lib/libcrypto/sha/sha1s.cpp
@@ -0,0 +1,82 @@
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/sha1test.c b/src/lib/libcrypto/sha/sha1test.c
new file mode 100644
index 0000000000..499a1cf5af
--- /dev/null
+++ b/src/lib/libcrypto/sha/sha1test.c
@@ -0,0 +1,172 @@
1/* crypto/sha/sha1test.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 <stdlib.h>
62
63#ifdef OPENSSL_NO_SHA
64int main(int argc, char *argv[])
65{
66 printf("No SHA support\n");
67 return(0);
68}
69#else
70#include <openssl/evp.h>
71#include <openssl/sha.h>
72
73#ifdef CHARSET_EBCDIC
74#include <openssl/ebcdic.h>
75#endif
76
77#undef SHA_0 /* FIPS 180 */
78#define SHA_1 /* FIPS 180-1 */
79
80static char *test[]={
81 "abc",
82 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
83 NULL,
84 };
85
86#ifdef SHA_0
87static char *ret[]={
88 "0164b8a914cd2a5e74c4f7ff082c4d97f1edf880",
89 "d2516ee1acfa5baf33dfc1c471e438449ef134c8",
90 };
91static char *bigret=
92 "3232affa48628a26653b5aaa44541fd90d690603";
93#endif
94#ifdef SHA_1
95static char *ret[]={
96 "a9993e364706816aba3e25717850c26c9cd0d89d",
97 "84983e441c3bd26ebaae4aa1f95129e5e54670f1",
98 };
99static char *bigret=
100 "34aa973cd4c4daa4f61eeb2bdbad27316534016f";
101#endif
102
103static char *pt(unsigned char *md);
104int main(int argc, char *argv[])
105 {
106 int i,err=0;
107 unsigned char **P,**R;
108 static unsigned char buf[1000];
109 char *p,*r;
110 EVP_MD_CTX c;
111 unsigned char md[SHA_DIGEST_LENGTH];
112
113#ifdef CHARSET_EBCDIC
114 ebcdic2ascii(test[0], test[0], strlen(test[0]));
115 ebcdic2ascii(test[1], test[1], strlen(test[1]));
116#endif
117
118 EVP_MD_CTX_init(&c);
119 P=(unsigned char **)test;
120 R=(unsigned char **)ret;
121 i=1;
122 while (*P != NULL)
123 {
124 EVP_Digest(*P,(unsigned long)strlen((char *)*P),md,NULL,EVP_sha1(), NULL);
125 p=pt(md);
126 if (strcmp(p,(char *)*R) != 0)
127 {
128 printf("error calculating SHA1 on '%s'\n",*P);
129 printf("got %s instead of %s\n",p,*R);
130 err++;
131 }
132 else
133 printf("test %d ok\n",i);
134 i++;
135 R++;
136 P++;
137 }
138
139 memset(buf,'a',1000);
140#ifdef CHARSET_EBCDIC
141 ebcdic2ascii(buf, buf, 1000);
142#endif /*CHARSET_EBCDIC*/
143 EVP_DigestInit_ex(&c,EVP_sha1(), NULL);
144 for (i=0; i<1000; i++)
145 EVP_DigestUpdate(&c,buf,1000);
146 EVP_DigestFinal_ex(&c,md,NULL);
147 p=pt(md);
148
149 r=bigret;
150 if (strcmp(p,r) != 0)
151 {
152 printf("error calculating SHA1 on 'a' * 1000\n");
153 printf("got %s instead of %s\n",p,r);
154 err++;
155 }
156 else
157 printf("test 3 ok\n");
158 exit(err);
159 EVP_MD_CTX_cleanup(&c);
160 return(0);
161 }
162
163static char *pt(unsigned char *md)
164 {
165 int i;
166 static char buf[80];
167
168 for (i=0; i<SHA_DIGEST_LENGTH; i++)
169 sprintf(&(buf[i*2]),"%02x",md[i]);
170 return(buf);
171 }
172#endif
diff --git a/src/lib/libcrypto/sha/sha_dgst.c b/src/lib/libcrypto/sha/sha_dgst.c
new file mode 100644
index 0000000000..5a4b3ab204
--- /dev/null
+++ b/src/lib/libcrypto/sha/sha_dgst.c
@@ -0,0 +1,73 @@
1/* crypto/sha/sha1dgst.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#if !defined(OPENSSL_NO_SHA0) && !defined(OPENSSL_NO_SHA)
60
61#undef SHA_1
62#define SHA_0
63
64#include <openssl/opensslv.h>
65
66const char *SHA_version="SHA" OPENSSL_VERSION_PTEXT;
67
68/* The implementation is in ../md32_common.h */
69
70#include "sha_locl.h"
71
72#endif
73
diff --git a/src/lib/libcrypto/sha/sha_locl.h b/src/lib/libcrypto/sha/sha_locl.h
index 2dd63a62a6..471dfb9f8f 100644
--- a/src/lib/libcrypto/sha/sha_locl.h
+++ b/src/lib/libcrypto/sha/sha_locl.h
@@ -224,10 +224,10 @@ int HASH_INIT (SHA_CTX *c)
224void HASH_BLOCK_HOST_ORDER (SHA_CTX *c, const void *d, int num) 224void HASH_BLOCK_HOST_ORDER (SHA_CTX *c, const void *d, int num)
225 { 225 {
226 const SHA_LONG *W=d; 226 const SHA_LONG *W=d;
227 register unsigned MD32_REG_T A,B,C,D,E,T; 227 register unsigned long A,B,C,D,E,T;
228#ifndef MD32_XARRAY 228#ifndef MD32_XARRAY
229 unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, 229 unsigned long XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
230 XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15; 230 XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15;
231#else 231#else
232 SHA_LONG XX[16]; 232 SHA_LONG XX[16];
233#endif 233#endif
@@ -349,10 +349,10 @@ void HASH_BLOCK_HOST_ORDER (SHA_CTX *c, const void *d, int num)
349void HASH_BLOCK_DATA_ORDER (SHA_CTX *c, const void *p, int num) 349void HASH_BLOCK_DATA_ORDER (SHA_CTX *c, const void *p, int num)
350 { 350 {
351 const unsigned char *data=p; 351 const unsigned char *data=p;
352 register unsigned MD32_REG_T A,B,C,D,E,T,l; 352 register unsigned long A,B,C,D,E,T,l;
353#ifndef MD32_XARRAY 353#ifndef MD32_XARRAY
354 unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, 354 unsigned long XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
355 XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15; 355 XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15;
356#else 356#else
357 SHA_LONG XX[16]; 357 SHA_LONG XX[16];
358#endif 358#endif
diff --git a/src/lib/libcrypto/sha/sha_one.c b/src/lib/libcrypto/sha/sha_one.c
new file mode 100644
index 0000000000..5426faae4a
--- /dev/null
+++ b/src/lib/libcrypto/sha/sha_one.c
@@ -0,0 +1,76 @@
1/* crypto/sha/sha_one.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 <openssl/sha.h>
62
63#ifndef OPENSSL_NO_SHA0
64unsigned char *SHA(const unsigned char *d, unsigned long n, unsigned char *md)
65 {
66 SHA_CTX c;
67 static unsigned char m[SHA_DIGEST_LENGTH];
68
69 if (md == NULL) md=m;
70 SHA_Init(&c);
71 SHA_Update(&c,d,n);
72 SHA_Final(md,&c);
73 memset(&c,0,sizeof(c));
74 return(md);
75 }
76#endif
diff --git a/src/lib/libcrypto/sha/shatest.c b/src/lib/libcrypto/sha/shatest.c
new file mode 100644
index 0000000000..331294a74f
--- /dev/null
+++ b/src/lib/libcrypto/sha/shatest.c
@@ -0,0 +1,172 @@
1/* crypto/sha/shatest.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 <stdlib.h>
62
63#ifdef OPENSSL_NO_SHA
64int main(int argc, char *argv[])
65{
66 printf("No SHA support\n");
67 return(0);
68}
69#else
70#include <openssl/evp.h>
71#include <openssl/sha.h>
72
73#ifdef CHARSET_EBCDIC
74#include <openssl/ebcdic.h>
75#endif
76
77#define SHA_0 /* FIPS 180 */
78#undef SHA_1 /* FIPS 180-1 */
79
80static char *test[]={
81 "abc",
82 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
83 NULL,
84 };
85
86#ifdef SHA_0
87static char *ret[]={
88 "0164b8a914cd2a5e74c4f7ff082c4d97f1edf880",
89 "d2516ee1acfa5baf33dfc1c471e438449ef134c8",
90 };
91static char *bigret=
92 "3232affa48628a26653b5aaa44541fd90d690603";
93#endif
94#ifdef SHA_1
95static char *ret[]={
96 "a9993e364706816aba3e25717850c26c9cd0d89d",
97 "84983e441c3bd26ebaae4aa1f95129e5e54670f1",
98 };
99static char *bigret=
100 "34aa973cd4c4daa4f61eeb2bdbad27316534016f";
101#endif
102
103static char *pt(unsigned char *md);
104int main(int argc, char *argv[])
105 {
106 int i,err=0;
107 unsigned char **P,**R;
108 static unsigned char buf[1000];
109 char *p,*r;
110 EVP_MD_CTX c;
111 unsigned char md[SHA_DIGEST_LENGTH];
112
113#ifdef CHARSET_EBCDIC
114 ebcdic2ascii(test[0], test[0], strlen(test[0]));
115 ebcdic2ascii(test[1], test[1], strlen(test[1]));
116#endif
117
118 EVP_MD_CTX_init(&c);
119 P=(unsigned char **)test;
120 R=(unsigned char **)ret;
121 i=1;
122 while (*P != NULL)
123 {
124 EVP_Digest(*P,(unsigned long)strlen((char *)*P),md,NULL,EVP_sha(), NULL);
125 p=pt(md);
126 if (strcmp(p,(char *)*R) != 0)
127 {
128 printf("error calculating SHA on '%s'\n",*P);
129 printf("got %s instead of %s\n",p,*R);
130 err++;
131 }
132 else
133 printf("test %d ok\n",i);
134 i++;
135 R++;
136 P++;
137 }
138
139 memset(buf,'a',1000);
140#ifdef CHARSET_EBCDIC
141 ebcdic2ascii(buf, buf, 1000);
142#endif /*CHARSET_EBCDIC*/
143 EVP_DigestInit_ex(&c,EVP_sha(), NULL);
144 for (i=0; i<1000; i++)
145 EVP_DigestUpdate(&c,buf,1000);
146 EVP_DigestFinal_ex(&c,md,NULL);
147 p=pt(md);
148
149 r=bigret;
150 if (strcmp(p,r) != 0)
151 {
152 printf("error calculating SHA on '%s'\n",p);
153 printf("got %s instead of %s\n",p,r);
154 err++;
155 }
156 else
157 printf("test 3 ok\n");
158 EVP_MD_CTX_cleanup(&c);
159 exit(err);
160 return(0);
161 }
162
163static char *pt(unsigned char *md)
164 {
165 int i;
166 static char buf[80];
167
168 for (i=0; i<SHA_DIGEST_LENGTH; i++)
169 sprintf(&(buf[i*2]),"%02x",md[i]);
170 return(buf);
171 }
172#endif
diff --git a/src/lib/libcrypto/stack/Makefile.ssl b/src/lib/libcrypto/stack/Makefile.ssl
new file mode 100644
index 0000000000..8574739c76
--- /dev/null
+++ b/src/lib/libcrypto/stack/Makefile.ssl
@@ -0,0 +1,88 @@
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/symhacks.h b/src/lib/libcrypto/symhacks.h
new file mode 100644
index 0000000000..774162fec9
--- /dev/null
+++ b/src/lib/libcrypto/symhacks.h
@@ -0,0 +1,275 @@
1/* ====================================================================
2 * Copyright (c) 1999 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_SYMHACKS_H
56#define HEADER_SYMHACKS_H
57
58#include <openssl/e_os2.h>
59
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
62 VAX. */
63#ifdef OPENSSL_SYS_VMS
64
65/* Hack a long name in crypto/ex_data.c */
66#undef CRYPTO_get_ex_data_implementation
67#define CRYPTO_get_ex_data_implementation CRYPTO_get_ex_data_impl
68#undef CRYPTO_set_ex_data_implementation
69#define CRYPTO_set_ex_data_implementation CRYPTO_set_ex_data_impl
70
71/* Hack a long name in crypto/asn1/a_mbstr.c */
72#undef ASN1_STRING_set_default_mask_asc
73#define ASN1_STRING_set_default_mask_asc ASN1_STRING_set_def_mask_asc
74
75#if 0 /* No longer needed, since safestack macro magic does the job */
76/* Hack the names created with DECLARE_ASN1_SET_OF(PKCS7_SIGNER_INFO) */
77#undef i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO
78#define i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO i2d_ASN1_SET_OF_PKCS7_SIGINF
79#undef d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO
80#define d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO d2i_ASN1_SET_OF_PKCS7_SIGINF
81#endif
82
83#if 0 /* No longer needed, since safestack macro magic does the job */
84/* Hack the names created with DECLARE_ASN1_SET_OF(PKCS7_RECIP_INFO) */
85#undef i2d_ASN1_SET_OF_PKCS7_RECIP_INFO
86#define i2d_ASN1_SET_OF_PKCS7_RECIP_INFO i2d_ASN1_SET_OF_PKCS7_RECINF
87#undef d2i_ASN1_SET_OF_PKCS7_RECIP_INFO
88#define d2i_ASN1_SET_OF_PKCS7_RECIP_INFO d2i_ASN1_SET_OF_PKCS7_RECINF
89#endif
90
91#if 0 /* No longer needed, since safestack macro magic does the job */
92/* Hack the names created with DECLARE_ASN1_SET_OF(ACCESS_DESCRIPTION) */
93#undef i2d_ASN1_SET_OF_ACCESS_DESCRIPTION
94#define i2d_ASN1_SET_OF_ACCESS_DESCRIPTION i2d_ASN1_SET_OF_ACC_DESC
95#undef d2i_ASN1_SET_OF_ACCESS_DESCRIPTION
96#define d2i_ASN1_SET_OF_ACCESS_DESCRIPTION d2i_ASN1_SET_OF_ACC_DESC
97#endif
98
99/* Hack the names created with DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE) */
100#undef PEM_read_NETSCAPE_CERT_SEQUENCE
101#define PEM_read_NETSCAPE_CERT_SEQUENCE PEM_read_NS_CERT_SEQ
102#undef PEM_write_NETSCAPE_CERT_SEQUENCE
103#define PEM_write_NETSCAPE_CERT_SEQUENCE PEM_write_NS_CERT_SEQ
104#undef PEM_read_bio_NETSCAPE_CERT_SEQUENCE
105#define PEM_read_bio_NETSCAPE_CERT_SEQUENCE PEM_read_bio_NS_CERT_SEQ
106#undef PEM_write_bio_NETSCAPE_CERT_SEQUENCE
107#define PEM_write_bio_NETSCAPE_CERT_SEQUENCE PEM_write_bio_NS_CERT_SEQ
108#undef PEM_write_cb_bio_NETSCAPE_CERT_SEQUENCE
109#define PEM_write_cb_bio_NETSCAPE_CERT_SEQUENCE PEM_write_cb_bio_NS_CERT_SEQ
110
111/* Hack the names created with DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO) */
112#undef PEM_read_PKCS8_PRIV_KEY_INFO
113#define PEM_read_PKCS8_PRIV_KEY_INFO PEM_read_P8_PRIV_KEY_INFO
114#undef PEM_write_PKCS8_PRIV_KEY_INFO
115#define PEM_write_PKCS8_PRIV_KEY_INFO PEM_write_P8_PRIV_KEY_INFO
116#undef PEM_read_bio_PKCS8_PRIV_KEY_INFO
117#define PEM_read_bio_PKCS8_PRIV_KEY_INFO PEM_read_bio_P8_PRIV_KEY_INFO
118#undef PEM_write_bio_PKCS8_PRIV_KEY_INFO
119#define PEM_write_bio_PKCS8_PRIV_KEY_INFO PEM_write_bio_P8_PRIV_KEY_INFO
120#undef PEM_write_cb_bio_PKCS8_PRIV_KEY_INFO
121#define PEM_write_cb_bio_PKCS8_PRIV_KEY_INFO PEM_wrt_cb_bio_P8_PRIV_KEY_INFO
122
123/* Hack other PEM names */
124#undef PEM_write_bio_PKCS8PrivateKey_nid
125#define PEM_write_bio_PKCS8PrivateKey_nid PEM_write_bio_PKCS8PrivKey_nid
126
127/* Hack some long X509 names */
128#undef X509_REVOKED_get_ext_by_critical
129#define X509_REVOKED_get_ext_by_critical X509_REVOKED_get_ext_by_critic
130
131/* Hack some long CRYPTO names */
132#undef CRYPTO_set_dynlock_destroy_callback
133#define CRYPTO_set_dynlock_destroy_callback CRYPTO_set_dynlock_destroy_cb
134#undef CRYPTO_set_dynlock_create_callback
135#define CRYPTO_set_dynlock_create_callback CRYPTO_set_dynlock_create_cb
136#undef CRYPTO_set_dynlock_lock_callback
137#define CRYPTO_set_dynlock_lock_callback CRYPTO_set_dynlock_lock_cb
138#undef CRYPTO_get_dynlock_lock_callback
139#define CRYPTO_get_dynlock_lock_callback CRYPTO_get_dynlock_lock_cb
140#undef CRYPTO_get_dynlock_destroy_callback
141#define CRYPTO_get_dynlock_destroy_callback CRYPTO_get_dynlock_destroy_cb
142#undef CRYPTO_get_dynlock_create_callback
143#define CRYPTO_get_dynlock_create_callback CRYPTO_get_dynlock_create_cb
144#undef CRYPTO_set_locked_mem_ex_functions
145#define CRYPTO_set_locked_mem_ex_functions CRYPTO_set_locked_mem_ex_funcs
146#undef CRYPTO_get_locked_mem_ex_functions
147#define CRYPTO_get_locked_mem_ex_functions CRYPTO_get_locked_mem_ex_funcs
148
149/* Hack some long SSL names */
150#undef SSL_CTX_set_default_verify_paths
151#define SSL_CTX_set_default_verify_paths SSL_CTX_set_def_verify_paths
152#undef SSL_get_ex_data_X509_STORE_CTX_idx
153#define SSL_get_ex_data_X509_STORE_CTX_idx SSL_get_ex_d_X509_STORE_CTX_idx
154#undef SSL_add_file_cert_subjects_to_stack
155#define SSL_add_file_cert_subjects_to_stack SSL_add_file_cert_subjs_to_stk
156#if 0 /* This function is not defined i VMS. */
157#undef SSL_add_dir_cert_subjects_to_stack
158#define SSL_add_dir_cert_subjects_to_stack SSL_add_dir_cert_subjs_to_stk
159#endif
160#undef SSL_CTX_use_certificate_chain_file
161#define SSL_CTX_use_certificate_chain_file SSL_CTX_use_cert_chain_file
162#undef SSL_CTX_set_cert_verify_callback
163#define SSL_CTX_set_cert_verify_callback SSL_CTX_set_cert_verify_cb
164#undef SSL_CTX_set_default_passwd_cb_userdata
165#define SSL_CTX_set_default_passwd_cb_userdata SSL_CTX_set_def_passwd_cb_ud
166
167/* Hack some long ENGINE names */
168#undef ENGINE_get_default_BN_mod_exp_crt
169#define ENGINE_get_default_BN_mod_exp_crt ENGINE_get_def_BN_mod_exp_crt
170#undef ENGINE_set_default_BN_mod_exp_crt
171#define ENGINE_set_default_BN_mod_exp_crt ENGINE_set_def_BN_mod_exp_crt
172#undef ENGINE_set_load_privkey_function
173#define ENGINE_set_load_privkey_function ENGINE_set_load_privkey_fn
174#undef ENGINE_get_load_privkey_function
175#define ENGINE_get_load_privkey_function ENGINE_get_load_privkey_fn
176
177/* Hack some long OCSP names */
178#undef OCSP_REQUEST_get_ext_by_critical
179#define OCSP_REQUEST_get_ext_by_critical OCSP_REQUEST_get_ext_by_crit
180#undef OCSP_BASICRESP_get_ext_by_critical
181#define OCSP_BASICRESP_get_ext_by_critical OCSP_BASICRESP_get_ext_by_crit
182#undef OCSP_SINGLERESP_get_ext_by_critical
183#define OCSP_SINGLERESP_get_ext_by_critical OCSP_SINGLERESP_get_ext_by_crit
184
185/* Hack some long DES names */
186#undef _ossl_old_des_ede3_cfb64_encrypt
187#define _ossl_old_des_ede3_cfb64_encrypt _ossl_odes_ede3_cfb64_encrypt
188#undef _ossl_old_des_ede3_ofb64_encrypt
189#define _ossl_old_des_ede3_ofb64_encrypt _ossl_odes_ede3_ofb64_encrypt
190
191/* Hack some long EVP names */
192#undef OPENSSL_add_all_algorithms_noconf
193#define OPENSSL_add_all_algorithms_noconf OPENSSL_add_all_algo_noconf
194#undef OPENSSL_add_all_algorithms_conf
195#define OPENSSL_add_all_algorithms_conf OPENSSL_add_all_algo_conf
196
197/* Hack some long EC names */
198#undef EC_POINT_set_Jprojective_coordinates_GFp
199#define EC_POINT_set_Jprojective_coordinates_GFp \
200 EC_POINT_set_Jproj_coords_GFp
201#undef EC_POINT_get_Jprojective_coordinates_GFp
202#define EC_POINT_get_Jprojective_coordinates_GFp \
203 EC_POINT_get_Jproj_coords_GFp
204#undef EC_POINT_set_affine_coordinates_GFp
205#define EC_POINT_set_affine_coordinates_GFp EC_POINT_set_affine_coords_GFp
206#undef EC_POINT_get_affine_coordinates_GFp
207#define EC_POINT_get_affine_coordinates_GFp EC_POINT_get_affine_coords_GFp
208#undef EC_POINT_set_compressed_coordinates_GFp
209#define EC_POINT_set_compressed_coordinates_GFp EC_POINT_set_compr_coords_GFp
210#undef ec_GFp_simple_group_set_curve_GFp
211#define ec_GFp_simple_group_set_curve_GFp ec_GFp_simple_grp_set_curve_GFp
212#undef ec_GFp_simple_group_get_curve_GFp
213#define ec_GFp_simple_group_get_curve_GFp ec_GFp_simple_grp_get_curve_GFp
214#undef ec_GFp_simple_group_clear_finish
215#define ec_GFp_simple_group_clear_finish ec_GFp_simple_grp_clear_finish
216#undef ec_GFp_simple_group_set_generator
217#define ec_GFp_simple_group_set_generator ec_GFp_simple_grp_set_generator
218#undef ec_GFp_simple_group_get0_generator
219#define ec_GFp_simple_group_get0_generator ec_GFp_simple_grp_gt0_generator
220#undef ec_GFp_simple_group_get_cofactor
221#define ec_GFp_simple_group_get_cofactor ec_GFp_simple_grp_get_cofactor
222#undef ec_GFp_simple_point_clear_finish
223#define ec_GFp_simple_point_clear_finish ec_GFp_simple_pt_clear_finish
224#undef ec_GFp_simple_point_set_to_infinity
225#define ec_GFp_simple_point_set_to_infinity ec_GFp_simple_pt_set_to_inf
226#undef ec_GFp_simple_points_make_affine
227#define ec_GFp_simple_points_make_affine ec_GFp_simple_pts_make_affine
228#undef ec_GFp_simple_group_get_curve_GFp
229#define ec_GFp_simple_group_get_curve_GFp ec_GFp_simple_grp_get_curve_GFp
230#undef ec_GFp_simple_set_Jprojective_coordinates_GFp
231#define ec_GFp_simple_set_Jprojective_coordinates_GFp \
232 ec_GFp_smp_set_Jproj_coords_GFp
233#undef ec_GFp_simple_get_Jprojective_coordinates_GFp
234#define ec_GFp_simple_get_Jprojective_coordinates_GFp \
235 ec_GFp_smp_get_Jproj_coords_GFp
236#undef ec_GFp_simple_point_set_affine_coordinates_GFp
237#define ec_GFp_simple_point_set_affine_coordinates_GFp \
238 ec_GFp_smp_pt_set_af_coords_GFp
239#undef ec_GFp_simple_point_get_affine_coordinates_GFp
240#define ec_GFp_simple_point_get_affine_coordinates_GFp \
241 ec_GFp_smp_pt_get_af_coords_GFp
242#undef ec_GFp_simple_set_compressed_coordinates_GFp
243#define ec_GFp_simple_set_compressed_coordinates_GFp \
244 ec_GFp_smp_set_compr_coords_GFp
245
246#endif /* defined OPENSSL_SYS_VMS */
247
248
249/* Case insensiteve linking causes problems.... */
250#if defined(OPENSSL_SYS_WIN16) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2)
251#undef ERR_load_CRYPTO_strings
252#define ERR_load_CRYPTO_strings ERR_load_CRYPTOlib_strings
253#undef OCSP_crlID_new
254#define OCSP_crlID_new OCSP_crlID2_new
255
256/* These functions do not seem to exist! However, I'm paranoid...
257 Original command in x509v3.h:
258 These functions are being redefined in another directory,
259 and clash when the linker is case-insensitive, so let's
260 hide them a little, by giving them an extra 'o' at the
261 beginning of the name... */
262#undef X509v3_cleanup_extensions
263#define X509v3_cleanup_extensions oX509v3_cleanup_extensions
264#undef X509v3_add_extension
265#define X509v3_add_extension oX509v3_add_extension
266#undef X509v3_add_netscape_extensions
267#define X509v3_add_netscape_extensions oX509v3_add_netscape_extensions
268#undef X509v3_add_standard_extensions
269#define X509v3_add_standard_extensions oX509v3_add_standard_extensions
270
271
272#endif
273
274
275#endif /* ! defined HEADER_VMS_IDHACKS_H */
diff --git a/src/lib/libcrypto/threads/README b/src/lib/libcrypto/threads/README
new file mode 100644
index 0000000000..df6b26e146
--- /dev/null
+++ b/src/lib/libcrypto/threads/README
@@ -0,0 +1,14 @@
1Mutithreading testing area.
2
3Since this stuff is very very platorm specific, this is not part of the
4normal build. Have a read of doc/threads.doc.
5
6mttest will do some testing and will currently build under Windows NT/95,
7Solaris and Linux. The IRIX stuff is not finished.
8
9I have tested this program on a 12 CPU ultra sparc box (solaris 2.5.1)
10and things seem to work ok.
11
12The Linux pthreads package can be retrieved from
13http://www.mit.edu:8001/people/proven/pthreads.html
14
diff --git a/src/lib/libcrypto/threads/mttest.c b/src/lib/libcrypto/threads/mttest.c
new file mode 100644
index 0000000000..c474a63c74
--- /dev/null
+++ b/src/lib/libcrypto/threads/mttest.c
@@ -0,0 +1,1101 @@
1/* crypto/threads/mttest.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <stdlib.h>
61#include <string.h>
62#include <errno.h>
63#ifdef LINUX
64#include <typedefs.h>
65#endif
66#ifdef OPENSSL_SYS_WIN32
67#include <windows.h>
68#endif
69#ifdef SOLARIS
70#include <synch.h>
71#include <thread.h>
72#endif
73#ifdef IRIX
74#include <ulocks.h>
75#include <sys/prctl.h>
76#endif
77#ifdef PTHREADS
78#include <pthread.h>
79#endif
80#include <openssl/lhash.h>
81#include <openssl/crypto.h>
82#include <openssl/buffer.h>
83#include "../../e_os.h"
84#include <openssl/x509.h>
85#include <openssl/ssl.h>
86#include <openssl/err.h>
87#include <openssl/rand.h>
88
89#ifdef OPENSSL_NO_FP_API
90#define APPS_WIN16
91#include "../buffer/bss_file.c"
92#endif
93
94#define TEST_SERVER_CERT "../../apps/server.pem"
95#define TEST_CLIENT_CERT "../../apps/client.pem"
96
97#define MAX_THREAD_NUMBER 100
98
99int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *xs);
100void thread_setup(void);
101void thread_cleanup(void);
102void do_threads(SSL_CTX *s_ctx,SSL_CTX *c_ctx);
103
104void irix_locking_callback(int mode,int type,char *file,int line);
105void solaris_locking_callback(int mode,int type,char *file,int line);
106void win32_locking_callback(int mode,int type,char *file,int line);
107void pthreads_locking_callback(int mode,int type,char *file,int line);
108
109unsigned long irix_thread_id(void );
110unsigned long solaris_thread_id(void );
111unsigned long pthreads_thread_id(void );
112
113BIO *bio_err=NULL;
114BIO *bio_stdout=NULL;
115
116static char *cipher=NULL;
117int verbose=0;
118#ifdef FIONBIO
119static int s_nbio=0;
120#endif
121
122int thread_number=10;
123int number_of_loops=10;
124int reconnect=0;
125int cache_stats=0;
126
127static const char rnd_seed[] = "string to make the random number generator think it has entropy";
128
129int doit(char *ctx[4]);
130static void print_stats(FILE *fp, SSL_CTX *ctx)
131{
132 fprintf(fp,"%4ld items in the session cache\n",
133 SSL_CTX_sess_number(ctx));
134 fprintf(fp,"%4d client connects (SSL_connect())\n",
135 SSL_CTX_sess_connect(ctx));
136 fprintf(fp,"%4d client connects that finished\n",
137 SSL_CTX_sess_connect_good(ctx));
138 fprintf(fp,"%4d server connects (SSL_accept())\n",
139 SSL_CTX_sess_accept(ctx));
140 fprintf(fp,"%4d server connects that finished\n",
141 SSL_CTX_sess_accept_good(ctx));
142 fprintf(fp,"%4d session cache hits\n",SSL_CTX_sess_hits(ctx));
143 fprintf(fp,"%4d session cache misses\n",SSL_CTX_sess_misses(ctx));
144 fprintf(fp,"%4d session cache timeouts\n",SSL_CTX_sess_timeouts(ctx));
145 }
146
147static void sv_usage(void)
148 {
149 fprintf(stderr,"usage: ssltest [args ...]\n");
150 fprintf(stderr,"\n");
151 fprintf(stderr," -server_auth - check server certificate\n");
152 fprintf(stderr," -client_auth - do client authentication\n");
153 fprintf(stderr," -v - more output\n");
154 fprintf(stderr," -CApath arg - PEM format directory of CA's\n");
155 fprintf(stderr," -CAfile arg - PEM format file of CA's\n");
156 fprintf(stderr," -threads arg - number of threads\n");
157 fprintf(stderr," -loops arg - number of 'connections', per thread\n");
158 fprintf(stderr," -reconnect - reuse session-id's\n");
159 fprintf(stderr," -stats - server session-id cache stats\n");
160 fprintf(stderr," -cert arg - server certificate/key\n");
161 fprintf(stderr," -ccert arg - client certificate/key\n");
162 fprintf(stderr," -ssl3 - just SSLv3n\n");
163 }
164
165int main(int argc, char *argv[])
166 {
167 char *CApath=NULL,*CAfile=NULL;
168 int badop=0;
169 int ret=1;
170 int client_auth=0;
171 int server_auth=0;
172 SSL_CTX *s_ctx=NULL;
173 SSL_CTX *c_ctx=NULL;
174 char *scert=TEST_SERVER_CERT;
175 char *ccert=TEST_CLIENT_CERT;
176 SSL_METHOD *ssl_method=SSLv23_method();
177
178 RAND_seed(rnd_seed, sizeof rnd_seed);
179
180 if (bio_err == NULL)
181 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
182 if (bio_stdout == NULL)
183 bio_stdout=BIO_new_fp(stdout,BIO_NOCLOSE);
184 argc--;
185 argv++;
186
187 while (argc >= 1)
188 {
189 if (strcmp(*argv,"-server_auth") == 0)
190 server_auth=1;
191 else if (strcmp(*argv,"-client_auth") == 0)
192 client_auth=1;
193 else if (strcmp(*argv,"-reconnect") == 0)
194 reconnect=1;
195 else if (strcmp(*argv,"-stats") == 0)
196 cache_stats=1;
197 else if (strcmp(*argv,"-ssl3") == 0)
198 ssl_method=SSLv3_method();
199 else if (strcmp(*argv,"-ssl2") == 0)
200 ssl_method=SSLv2_method();
201 else if (strcmp(*argv,"-CApath") == 0)
202 {
203 if (--argc < 1) goto bad;
204 CApath= *(++argv);
205 }
206 else if (strcmp(*argv,"-CAfile") == 0)
207 {
208 if (--argc < 1) goto bad;
209 CAfile= *(++argv);
210 }
211 else if (strcmp(*argv,"-cert") == 0)
212 {
213 if (--argc < 1) goto bad;
214 scert= *(++argv);
215 }
216 else if (strcmp(*argv,"-ccert") == 0)
217 {
218 if (--argc < 1) goto bad;
219 ccert= *(++argv);
220 }
221 else if (strcmp(*argv,"-threads") == 0)
222 {
223 if (--argc < 1) goto bad;
224 thread_number= atoi(*(++argv));
225 if (thread_number == 0) thread_number=1;
226 if (thread_number > MAX_THREAD_NUMBER)
227 thread_number=MAX_THREAD_NUMBER;
228 }
229 else if (strcmp(*argv,"-loops") == 0)
230 {
231 if (--argc < 1) goto bad;
232 number_of_loops= atoi(*(++argv));
233 if (number_of_loops == 0) number_of_loops=1;
234 }
235 else
236 {
237 fprintf(stderr,"unknown option %s\n",*argv);
238 badop=1;
239 break;
240 }
241 argc--;
242 argv++;
243 }
244 if (badop)
245 {
246bad:
247 sv_usage();
248 goto end;
249 }
250
251 if (cipher == NULL && issetugid() == 0)
252 cipher=getenv("SSL_CIPHER");
253
254 SSL_load_error_strings();
255 OpenSSL_add_ssl_algorithms();
256
257 c_ctx=SSL_CTX_new(ssl_method);
258 s_ctx=SSL_CTX_new(ssl_method);
259 if ((c_ctx == NULL) || (s_ctx == NULL))
260 {
261 ERR_print_errors(bio_err);
262 goto end;
263 }
264
265 SSL_CTX_set_session_cache_mode(s_ctx,
266 SSL_SESS_CACHE_NO_AUTO_CLEAR|SSL_SESS_CACHE_SERVER);
267 SSL_CTX_set_session_cache_mode(c_ctx,
268 SSL_SESS_CACHE_NO_AUTO_CLEAR|SSL_SESS_CACHE_SERVER);
269
270 if (!SSL_CTX_use_certificate_file(s_ctx,scert,SSL_FILETYPE_PEM))
271 {
272 ERR_print_errors(bio_err);
273 }
274 else if (!SSL_CTX_use_RSAPrivateKey_file(s_ctx,scert,SSL_FILETYPE_PEM))
275 {
276 ERR_print_errors(bio_err);
277 goto end;
278 }
279
280 if (client_auth)
281 {
282 SSL_CTX_use_certificate_file(c_ctx,ccert,
283 SSL_FILETYPE_PEM);
284 SSL_CTX_use_RSAPrivateKey_file(c_ctx,ccert,
285 SSL_FILETYPE_PEM);
286 }
287
288 if ( (!SSL_CTX_load_verify_locations(s_ctx,CAfile,CApath)) ||
289 (!SSL_CTX_set_default_verify_paths(s_ctx)) ||
290 (!SSL_CTX_load_verify_locations(c_ctx,CAfile,CApath)) ||
291 (!SSL_CTX_set_default_verify_paths(c_ctx)))
292 {
293 fprintf(stderr,"SSL_load_verify_locations\n");
294 ERR_print_errors(bio_err);
295 goto end;
296 }
297
298 if (client_auth)
299 {
300 fprintf(stderr,"client authentication\n");
301 SSL_CTX_set_verify(s_ctx,
302 SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT,
303 verify_callback);
304 }
305 if (server_auth)
306 {
307 fprintf(stderr,"server authentication\n");
308 SSL_CTX_set_verify(c_ctx,SSL_VERIFY_PEER,
309 verify_callback);
310 }
311
312 thread_setup();
313 do_threads(s_ctx,c_ctx);
314 thread_cleanup();
315end:
316
317 if (c_ctx != NULL)
318 {
319 fprintf(stderr,"Client SSL_CTX stats then free it\n");
320 print_stats(stderr,c_ctx);
321 SSL_CTX_free(c_ctx);
322 }
323 if (s_ctx != NULL)
324 {
325 fprintf(stderr,"Server SSL_CTX stats then free it\n");
326 print_stats(stderr,s_ctx);
327 if (cache_stats)
328 {
329 fprintf(stderr,"-----\n");
330 lh_stats(SSL_CTX_sessions(s_ctx),stderr);
331 fprintf(stderr,"-----\n");
332 /* lh_node_stats(SSL_CTX_sessions(s_ctx),stderr);
333 fprintf(stderr,"-----\n"); */
334 lh_node_usage_stats(SSL_CTX_sessions(s_ctx),stderr);
335 fprintf(stderr,"-----\n");
336 }
337 SSL_CTX_free(s_ctx);
338 fprintf(stderr,"done free\n");
339 }
340 exit(ret);
341 return(0);
342 }
343
344#define W_READ 1
345#define W_WRITE 2
346#define C_DONE 1
347#define S_DONE 2
348
349int ndoit(SSL_CTX *ssl_ctx[2])
350 {
351 int i;
352 int ret;
353 char *ctx[4];
354
355 ctx[0]=(char *)ssl_ctx[0];
356 ctx[1]=(char *)ssl_ctx[1];
357
358 if (reconnect)
359 {
360 ctx[2]=(char *)SSL_new(ssl_ctx[0]);
361 ctx[3]=(char *)SSL_new(ssl_ctx[1]);
362 }
363 else
364 {
365 ctx[2]=NULL;
366 ctx[3]=NULL;
367 }
368
369 fprintf(stdout,"started thread %lu\n",CRYPTO_thread_id());
370 for (i=0; i<number_of_loops; i++)
371 {
372/* fprintf(stderr,"%4d %2d ctx->ref (%3d,%3d)\n",
373 CRYPTO_thread_id(),i,
374 ssl_ctx[0]->references,
375 ssl_ctx[1]->references); */
376 /* pthread_delay_np(&tm);*/
377
378 ret=doit(ctx);
379 if (ret != 0)
380 {
381 fprintf(stdout,"error[%d] %lu - %d\n",
382 i,CRYPTO_thread_id(),ret);
383 return(ret);
384 }
385 }
386 fprintf(stdout,"DONE %lu\n",CRYPTO_thread_id());
387 if (reconnect)
388 {
389 SSL_free((SSL *)ctx[2]);
390 SSL_free((SSL *)ctx[3]);
391 }
392 return(0);
393 }
394
395int doit(char *ctx[4])
396 {
397 SSL_CTX *s_ctx,*c_ctx;
398 static char cbuf[200],sbuf[200];
399 SSL *c_ssl=NULL;
400 SSL *s_ssl=NULL;
401 BIO *c_to_s=NULL;
402 BIO *s_to_c=NULL;
403 BIO *c_bio=NULL;
404 BIO *s_bio=NULL;
405 int c_r,c_w,s_r,s_w;
406 int c_want,s_want;
407 int i;
408 int done=0;
409 int c_write,s_write;
410 int do_server=0,do_client=0;
411
412 s_ctx=(SSL_CTX *)ctx[0];
413 c_ctx=(SSL_CTX *)ctx[1];
414
415 if (ctx[2] != NULL)
416 s_ssl=(SSL *)ctx[2];
417 else
418 s_ssl=SSL_new(s_ctx);
419
420 if (ctx[3] != NULL)
421 c_ssl=(SSL *)ctx[3];
422 else
423 c_ssl=SSL_new(c_ctx);
424
425 if ((s_ssl == NULL) || (c_ssl == NULL)) goto err;
426
427 c_to_s=BIO_new(BIO_s_mem());
428 s_to_c=BIO_new(BIO_s_mem());
429 if ((s_to_c == NULL) || (c_to_s == NULL)) goto err;
430
431 c_bio=BIO_new(BIO_f_ssl());
432 s_bio=BIO_new(BIO_f_ssl());
433 if ((c_bio == NULL) || (s_bio == NULL)) goto err;
434
435 SSL_set_connect_state(c_ssl);
436 SSL_set_bio(c_ssl,s_to_c,c_to_s);
437 BIO_set_ssl(c_bio,c_ssl,(ctx[2] == NULL)?BIO_CLOSE:BIO_NOCLOSE);
438
439 SSL_set_accept_state(s_ssl);
440 SSL_set_bio(s_ssl,c_to_s,s_to_c);
441 BIO_set_ssl(s_bio,s_ssl,(ctx[3] == NULL)?BIO_CLOSE:BIO_NOCLOSE);
442
443 c_r=0; s_r=1;
444 c_w=1; s_w=0;
445 c_want=W_WRITE;
446 s_want=0;
447 c_write=1,s_write=0;
448
449 /* We can always do writes */
450 for (;;)
451 {
452 do_server=0;
453 do_client=0;
454
455 i=(int)BIO_pending(s_bio);
456 if ((i && s_r) || s_w) do_server=1;
457
458 i=(int)BIO_pending(c_bio);
459 if ((i && c_r) || c_w) do_client=1;
460
461 if (do_server && verbose)
462 {
463 if (SSL_in_init(s_ssl))
464 printf("server waiting in SSL_accept - %s\n",
465 SSL_state_string_long(s_ssl));
466 else if (s_write)
467 printf("server:SSL_write()\n");
468 else
469 printf("server:SSL_read()\n");
470 }
471
472 if (do_client && verbose)
473 {
474 if (SSL_in_init(c_ssl))
475 printf("client waiting in SSL_connect - %s\n",
476 SSL_state_string_long(c_ssl));
477 else if (c_write)
478 printf("client:SSL_write()\n");
479 else
480 printf("client:SSL_read()\n");
481 }
482
483 if (!do_client && !do_server)
484 {
485 fprintf(stdout,"ERROR IN STARTUP\n");
486 break;
487 }
488 if (do_client && !(done & C_DONE))
489 {
490 if (c_write)
491 {
492 i=BIO_write(c_bio,"hello from client\n",18);
493 if (i < 0)
494 {
495 c_r=0;
496 c_w=0;
497 if (BIO_should_retry(c_bio))
498 {
499 if (BIO_should_read(c_bio))
500 c_r=1;
501 if (BIO_should_write(c_bio))
502 c_w=1;
503 }
504 else
505 {
506 fprintf(stderr,"ERROR in CLIENT\n");
507 ERR_print_errors_fp(stderr);
508 return(1);
509 }
510 }
511 else if (i == 0)
512 {
513 fprintf(stderr,"SSL CLIENT STARTUP FAILED\n");
514 return(1);
515 }
516 else
517 {
518 /* ok */
519 c_write=0;
520 }
521 }
522 else
523 {
524 i=BIO_read(c_bio,cbuf,100);
525 if (i < 0)
526 {
527 c_r=0;
528 c_w=0;
529 if (BIO_should_retry(c_bio))
530 {
531 if (BIO_should_read(c_bio))
532 c_r=1;
533 if (BIO_should_write(c_bio))
534 c_w=1;
535 }
536 else
537 {
538 fprintf(stderr,"ERROR in CLIENT\n");
539 ERR_print_errors_fp(stderr);
540 return(1);
541 }
542 }
543 else if (i == 0)
544 {
545 fprintf(stderr,"SSL CLIENT STARTUP FAILED\n");
546 return(1);
547 }
548 else
549 {
550 done|=C_DONE;
551#ifdef undef
552 fprintf(stdout,"CLIENT:from server:");
553 fwrite(cbuf,1,i,stdout);
554 fflush(stdout);
555#endif
556 }
557 }
558 }
559
560 if (do_server && !(done & S_DONE))
561 {
562 if (!s_write)
563 {
564 i=BIO_read(s_bio,sbuf,100);
565 if (i < 0)
566 {
567 s_r=0;
568 s_w=0;
569 if (BIO_should_retry(s_bio))
570 {
571 if (BIO_should_read(s_bio))
572 s_r=1;
573 if (BIO_should_write(s_bio))
574 s_w=1;
575 }
576 else
577 {
578 fprintf(stderr,"ERROR in SERVER\n");
579 ERR_print_errors_fp(stderr);
580 return(1);
581 }
582 }
583 else if (i == 0)
584 {
585 fprintf(stderr,"SSL SERVER STARTUP FAILED\n");
586 return(1);
587 }
588 else
589 {
590 s_write=1;
591 s_w=1;
592#ifdef undef
593 fprintf(stdout,"SERVER:from client:");
594 fwrite(sbuf,1,i,stdout);
595 fflush(stdout);
596#endif
597 }
598 }
599 else
600 {
601 i=BIO_write(s_bio,"hello from server\n",18);
602 if (i < 0)
603 {
604 s_r=0;
605 s_w=0;
606 if (BIO_should_retry(s_bio))
607 {
608 if (BIO_should_read(s_bio))
609 s_r=1;
610 if (BIO_should_write(s_bio))
611 s_w=1;
612 }
613 else
614 {
615 fprintf(stderr,"ERROR in SERVER\n");
616 ERR_print_errors_fp(stderr);
617 return(1);
618 }
619 }
620 else if (i == 0)
621 {
622 fprintf(stderr,"SSL SERVER STARTUP FAILED\n");
623 return(1);
624 }
625 else
626 {
627 s_write=0;
628 s_r=1;
629 done|=S_DONE;
630 }
631 }
632 }
633
634 if ((done & S_DONE) && (done & C_DONE)) break;
635 }
636
637 SSL_set_shutdown(c_ssl,SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN);
638 SSL_set_shutdown(s_ssl,SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN);
639
640#ifdef undef
641 fprintf(stdout,"DONE\n");
642#endif
643err:
644 /* We have to set the BIO's to NULL otherwise they will be
645 * free()ed twice. Once when th s_ssl is SSL_free()ed and
646 * again when c_ssl is SSL_free()ed.
647 * This is a hack required because s_ssl and c_ssl are sharing the same
648 * BIO structure and SSL_set_bio() and SSL_free() automatically
649 * BIO_free non NULL entries.
650 * You should not normally do this or be required to do this */
651
652 if (s_ssl != NULL)
653 {
654 s_ssl->rbio=NULL;
655 s_ssl->wbio=NULL;
656 }
657 if (c_ssl != NULL)
658 {
659 c_ssl->rbio=NULL;
660 c_ssl->wbio=NULL;
661 }
662
663 /* The SSL's are optionally freed in the following calls */
664 if (c_to_s != NULL) BIO_free(c_to_s);
665 if (s_to_c != NULL) BIO_free(s_to_c);
666
667 if (c_bio != NULL) BIO_free(c_bio);
668 if (s_bio != NULL) BIO_free(s_bio);
669 return(0);
670 }
671
672int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx)
673 {
674 char *s, buf[256];
675
676 if (verbose)
677 {
678 s=X509_NAME_oneline(X509_get_subject_name(ctx->current_cert),
679 buf,256);
680 if (s != NULL)
681 {
682 if (ok)
683 fprintf(stderr,"depth=%d %s\n",
684 ctx->error_depth,buf);
685 else
686 fprintf(stderr,"depth=%d error=%d %s\n",
687 ctx->error_depth,ctx->error,buf);
688 }
689 }
690 return(ok);
691 }
692
693#define THREAD_STACK_SIZE (16*1024)
694
695#ifdef OPENSSL_SYS_WIN32
696
697static HANDLE *lock_cs;
698
699void thread_setup(void)
700 {
701 int i;
702
703 lock_cs=OPENSSL_malloc(CRYPTO_num_locks() * sizeof(HANDLE));
704 for (i=0; i<CRYPTO_num_locks(); i++)
705 {
706 lock_cs[i]=CreateMutex(NULL,FALSE,NULL);
707 }
708
709 CRYPTO_set_locking_callback((void (*)(int,int,char *,int))win32_locking_callback);
710 /* id callback defined */
711 }
712
713void thread_cleanup(void)
714 {
715 int i;
716
717 CRYPTO_set_locking_callback(NULL);
718 for (i=0; i<CRYPTO_num_locks(); i++)
719 CloseHandle(lock_cs[i]);
720 OPENSSL_free(lock_cs);
721 }
722
723void win32_locking_callback(int mode, int type, char *file, int line)
724 {
725 if (mode & CRYPTO_LOCK)
726 {
727 WaitForSingleObject(lock_cs[type],INFINITE);
728 }
729 else
730 {
731 ReleaseMutex(lock_cs[type]);
732 }
733 }
734
735void do_threads(SSL_CTX *s_ctx, SSL_CTX *c_ctx)
736 {
737 double ret;
738 SSL_CTX *ssl_ctx[2];
739 DWORD thread_id[MAX_THREAD_NUMBER];
740 HANDLE thread_handle[MAX_THREAD_NUMBER];
741 int i;
742 SYSTEMTIME start,end;
743
744 ssl_ctx[0]=s_ctx;
745 ssl_ctx[1]=c_ctx;
746
747 GetSystemTime(&start);
748 for (i=0; i<thread_number; i++)
749 {
750 thread_handle[i]=CreateThread(NULL,
751 THREAD_STACK_SIZE,
752 (LPTHREAD_START_ROUTINE)ndoit,
753 (void *)ssl_ctx,
754 0L,
755 &(thread_id[i]));
756 }
757
758 printf("reaping\n");
759 for (i=0; i<thread_number; i+=50)
760 {
761 int j;
762
763 j=(thread_number < (i+50))?(thread_number-i):50;
764
765 if (WaitForMultipleObjects(j,
766 (CONST HANDLE *)&(thread_handle[i]),TRUE,INFINITE)
767 == WAIT_FAILED)
768 {
769 fprintf(stderr,"WaitForMultipleObjects failed:%d\n",GetLastError());
770 exit(1);
771 }
772 }
773 GetSystemTime(&end);
774
775 if (start.wDayOfWeek > end.wDayOfWeek) end.wDayOfWeek+=7;
776 ret=(end.wDayOfWeek-start.wDayOfWeek)*24;
777
778 ret=(ret+end.wHour-start.wHour)*60;
779 ret=(ret+end.wMinute-start.wMinute)*60;
780 ret=(ret+end.wSecond-start.wSecond);
781 ret+=(end.wMilliseconds-start.wMilliseconds)/1000.0;
782
783 printf("win32 threads done - %.3f seconds\n",ret);
784 }
785
786#endif /* OPENSSL_SYS_WIN32 */
787
788#ifdef SOLARIS
789
790static mutex_t *lock_cs;
791/*static rwlock_t *lock_cs; */
792static long *lock_count;
793
794void thread_setup(void)
795 {
796 int i;
797
798 lock_cs=OPENSSL_malloc(CRYPTO_num_locks() * sizeof(mutex_t));
799 lock_count=OPENSSL_malloc(CRYPTO_num_locks() * sizeof(long));
800 for (i=0; i<CRYPTO_num_locks(); i++)
801 {
802 lock_count[i]=0;
803 /* rwlock_init(&(lock_cs[i]),USYNC_THREAD,NULL); */
804 mutex_init(&(lock_cs[i]),USYNC_THREAD,NULL);
805 }
806
807 CRYPTO_set_id_callback((unsigned long (*)())solaris_thread_id);
808 CRYPTO_set_locking_callback((void (*)())solaris_locking_callback);
809 }
810
811void thread_cleanup(void)
812 {
813 int i;
814
815 CRYPTO_set_locking_callback(NULL);
816
817 fprintf(stderr,"cleanup\n");
818
819 for (i=0; i<CRYPTO_num_locks(); i++)
820 {
821 /* rwlock_destroy(&(lock_cs[i])); */
822 mutex_destroy(&(lock_cs[i]));
823 fprintf(stderr,"%8ld:%s\n",lock_count[i],CRYPTO_get_lock_name(i));
824 }
825 OPENSSL_free(lock_cs);
826 OPENSSL_free(lock_count);
827
828 fprintf(stderr,"done cleanup\n");
829
830 }
831
832void solaris_locking_callback(int mode, int type, char *file, int line)
833 {
834#ifdef undef
835 fprintf(stderr,"thread=%4d mode=%s lock=%s %s:%d\n",
836 CRYPTO_thread_id(),
837 (mode&CRYPTO_LOCK)?"l":"u",
838 (type&CRYPTO_READ)?"r":"w",file,line);
839#endif
840
841 /*
842 if (CRYPTO_LOCK_SSL_CERT == type)
843 fprintf(stderr,"(t,m,f,l) %ld %d %s %d\n",
844 CRYPTO_thread_id(),
845 mode,file,line);
846 */
847 if (mode & CRYPTO_LOCK)
848 {
849 /* if (mode & CRYPTO_READ)
850 rw_rdlock(&(lock_cs[type]));
851 else
852 rw_wrlock(&(lock_cs[type])); */
853
854 mutex_lock(&(lock_cs[type]));
855 lock_count[type]++;
856 }
857 else
858 {
859/* rw_unlock(&(lock_cs[type])); */
860 mutex_unlock(&(lock_cs[type]));
861 }
862 }
863
864void do_threads(SSL_CTX *s_ctx, SSL_CTX *c_ctx)
865 {
866 SSL_CTX *ssl_ctx[2];
867 thread_t thread_ctx[MAX_THREAD_NUMBER];
868 int i;
869
870 ssl_ctx[0]=s_ctx;
871 ssl_ctx[1]=c_ctx;
872
873 thr_setconcurrency(thread_number);
874 for (i=0; i<thread_number; i++)
875 {
876 thr_create(NULL, THREAD_STACK_SIZE,
877 (void *(*)())ndoit,
878 (void *)ssl_ctx,
879 0L,
880 &(thread_ctx[i]));
881 }
882
883 printf("reaping\n");
884 for (i=0; i<thread_number; i++)
885 {
886 thr_join(thread_ctx[i],NULL,NULL);
887 }
888
889 printf("solaris threads done (%d,%d)\n",
890 s_ctx->references,c_ctx->references);
891 }
892
893unsigned long solaris_thread_id(void)
894 {
895 unsigned long ret;
896
897 ret=(unsigned long)thr_self();
898 return(ret);
899 }
900#endif /* SOLARIS */
901
902#ifdef IRIX
903
904
905static usptr_t *arena;
906static usema_t **lock_cs;
907
908void thread_setup(void)
909 {
910 int i;
911 char filename[20];
912
913 strcpy(filename,"/tmp/mttest.XXXXXX");
914 mktemp(filename);
915
916 usconfig(CONF_STHREADIOOFF);
917 usconfig(CONF_STHREADMALLOCOFF);
918 usconfig(CONF_INITUSERS,100);
919 usconfig(CONF_LOCKTYPE,US_DEBUGPLUS);
920 arena=usinit(filename);
921 unlink(filename);
922
923 lock_cs=OPENSSL_malloc(CRYPTO_num_locks() * sizeof(usema_t *));
924 for (i=0; i<CRYPTO_num_locks(); i++)
925 {
926 lock_cs[i]=usnewsema(arena,1);
927 }
928
929 CRYPTO_set_id_callback((unsigned long (*)())irix_thread_id);
930 CRYPTO_set_locking_callback((void (*)())irix_locking_callback);
931 }
932
933void thread_cleanup(void)
934 {
935 int i;
936
937 CRYPTO_set_locking_callback(NULL);
938 for (i=0; i<CRYPTO_num_locks(); i++)
939 {
940 char buf[10];
941
942 sprintf(buf,"%2d:",i);
943 usdumpsema(lock_cs[i],stdout,buf);
944 usfreesema(lock_cs[i],arena);
945 }
946 OPENSSL_free(lock_cs);
947 }
948
949void irix_locking_callback(int mode, int type, char *file, int line)
950 {
951 if (mode & CRYPTO_LOCK)
952 {
953 printf("lock %d\n",type);
954 uspsema(lock_cs[type]);
955 }
956 else
957 {
958 printf("unlock %d\n",type);
959 usvsema(lock_cs[type]);
960 }
961 }
962
963void do_threads(SSL_CTX *s_ctx, SSL_CTX *c_ctx)
964 {
965 SSL_CTX *ssl_ctx[2];
966 int thread_ctx[MAX_THREAD_NUMBER];
967 int i;
968
969 ssl_ctx[0]=s_ctx;
970 ssl_ctx[1]=c_ctx;
971
972 for (i=0; i<thread_number; i++)
973 {
974 thread_ctx[i]=sproc((void (*)())ndoit,
975 PR_SADDR|PR_SFDS,(void *)ssl_ctx);
976 }
977
978 printf("reaping\n");
979 for (i=0; i<thread_number; i++)
980 {
981 wait(NULL);
982 }
983
984 printf("irix threads done (%d,%d)\n",
985 s_ctx->references,c_ctx->references);
986 }
987
988unsigned long irix_thread_id(void)
989 {
990 unsigned long ret;
991
992 ret=(unsigned long)getpid();
993 return(ret);
994 }
995#endif /* IRIX */
996
997#ifdef PTHREADS
998
999static pthread_mutex_t *lock_cs;
1000static long *lock_count;
1001
1002void thread_setup(void)
1003 {
1004 int i;
1005
1006 lock_cs=OPENSSL_malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t));
1007 lock_count=OPENSSL_malloc(CRYPTO_num_locks() * sizeof(long));
1008 for (i=0; i<CRYPTO_num_locks(); i++)
1009 {
1010 lock_count[i]=0;
1011 pthread_mutex_init(&(lock_cs[i]),NULL);
1012 }
1013
1014 CRYPTO_set_id_callback((unsigned long (*)())pthreads_thread_id);
1015 CRYPTO_set_locking_callback((void (*)())pthreads_locking_callback);
1016 }
1017
1018void thread_cleanup(void)
1019 {
1020 int i;
1021
1022 CRYPTO_set_locking_callback(NULL);
1023 fprintf(stderr,"cleanup\n");
1024 for (i=0; i<CRYPTO_num_locks(); i++)
1025 {
1026 pthread_mutex_destroy(&(lock_cs[i]));
1027 fprintf(stderr,"%8ld:%s\n",lock_count[i],
1028 CRYPTO_get_lock_name(i));
1029 }
1030 OPENSSL_free(lock_cs);
1031 OPENSSL_free(lock_count);
1032
1033 fprintf(stderr,"done cleanup\n");
1034 }
1035
1036void pthreads_locking_callback(int mode, int type, char *file,
1037 int line)
1038 {
1039#ifdef undef
1040 fprintf(stderr,"thread=%4d mode=%s lock=%s %s:%d\n",
1041 CRYPTO_thread_id(),
1042 (mode&CRYPTO_LOCK)?"l":"u",
1043 (type&CRYPTO_READ)?"r":"w",file,line);
1044#endif
1045/*
1046 if (CRYPTO_LOCK_SSL_CERT == type)
1047 fprintf(stderr,"(t,m,f,l) %ld %d %s %d\n",
1048 CRYPTO_thread_id(),
1049 mode,file,line);
1050*/
1051 if (mode & CRYPTO_LOCK)
1052 {
1053 pthread_mutex_lock(&(lock_cs[type]));
1054 lock_count[type]++;
1055 }
1056 else
1057 {
1058 pthread_mutex_unlock(&(lock_cs[type]));
1059 }
1060 }
1061
1062void do_threads(SSL_CTX *s_ctx, SSL_CTX *c_ctx)
1063 {
1064 SSL_CTX *ssl_ctx[2];
1065 pthread_t thread_ctx[MAX_THREAD_NUMBER];
1066 int i;
1067
1068 ssl_ctx[0]=s_ctx;
1069 ssl_ctx[1]=c_ctx;
1070
1071 /*
1072 thr_setconcurrency(thread_number);
1073 */
1074 for (i=0; i<thread_number; i++)
1075 {
1076 pthread_create(&(thread_ctx[i]), NULL,
1077 (void *(*)())ndoit, (void *)ssl_ctx);
1078 }
1079
1080 printf("reaping\n");
1081 for (i=0; i<thread_number; i++)
1082 {
1083 pthread_join(thread_ctx[i],NULL);
1084 }
1085
1086 printf("pthreads threads done (%d,%d)\n",
1087 s_ctx->references,c_ctx->references);
1088 }
1089
1090unsigned long pthreads_thread_id(void)
1091 {
1092 unsigned long ret;
1093
1094 ret=(unsigned long)pthread_self();
1095 return(ret);
1096 }
1097
1098#endif /* PTHREADS */
1099
1100
1101
diff --git a/src/lib/libcrypto/threads/profile.sh b/src/lib/libcrypto/threads/profile.sh
new file mode 100644
index 0000000000..6e3e342fc0
--- /dev/null
+++ b/src/lib/libcrypto/threads/profile.sh
@@ -0,0 +1,4 @@
1#!/bin/sh
2/bin/rm -f mttest
3cc -p -DSOLARIS -I../../include -g mttest.c -o mttest -L/usr/lib/libc -ldl -L../.. -lthread -lssl -lcrypto -lnsl -lsocket
4
diff --git a/src/lib/libcrypto/threads/ptest.bat b/src/lib/libcrypto/threads/ptest.bat
new file mode 100644
index 0000000000..4071b5ffea
--- /dev/null
+++ b/src/lib/libcrypto/threads/ptest.bat
@@ -0,0 +1,4 @@
1del mttest.exe
2
3purify cl /O2 -DWIN32 /MD -I..\..\out mttest.c /Femttest ..\..\out\ssl32.lib ..\..\out\crypt32.lib
4
diff --git a/src/lib/libcrypto/threads/pthread.sh b/src/lib/libcrypto/threads/pthread.sh
new file mode 100644
index 0000000000..f1c49821d2
--- /dev/null
+++ b/src/lib/libcrypto/threads/pthread.sh
@@ -0,0 +1,9 @@
1#!/bin/sh
2#
3# build using pthreads
4#
5# http://www.mit.edu:8001/people/proven/pthreads.html
6#
7/bin/rm -f mttest
8pgcc -DPTHREADS -I../../include -g mttest.c -o mttest -L../.. -lssl -lcrypto
9
diff --git a/src/lib/libcrypto/threads/pthread2.sh b/src/lib/libcrypto/threads/pthread2.sh
new file mode 100644
index 0000000000..41264c6a50
--- /dev/null
+++ b/src/lib/libcrypto/threads/pthread2.sh
@@ -0,0 +1,7 @@
1#!/bin/sh
2#
3# build using pthreads where it's already built into the system
4#
5/bin/rm -f mttest
6gcc -DPTHREADS -I../../include -g mttest.c -o mttest -L../.. -lssl -lcrypto -lpthread
7
diff --git a/src/lib/libcrypto/threads/pthreads-vms.com b/src/lib/libcrypto/threads/pthreads-vms.com
new file mode 100644
index 0000000000..63f5b8cc2e
--- /dev/null
+++ b/src/lib/libcrypto/threads/pthreads-vms.com
@@ -0,0 +1,9 @@
1$! To compile mttest on VMS.
2$!
3$! WARNING: only tested with DEC C so far.
4$
5$ arch := vax
6$ if f$getsyi("CPU") .ge. 128 then arch := axp
7$ define/user openssl [--.include.openssl]
8$ cc/def=PTHREADS mttest.c
9$ link mttest,[--.'arch'.exe.ssl]libssl/lib,[--.'arch'.exe.crypto]libcrypto/lib
diff --git a/src/lib/libcrypto/threads/purify.sh b/src/lib/libcrypto/threads/purify.sh
new file mode 100644
index 0000000000..6d44fe26b7
--- /dev/null
+++ b/src/lib/libcrypto/threads/purify.sh
@@ -0,0 +1,4 @@
1#!/bin/sh
2/bin/rm -f mttest
3purify cc -DSOLARIS -I../../include -g mttest.c -o mttest -L../.. -lthread -lssl -lcrypto -lnsl -lsocket
4
diff --git a/src/lib/libcrypto/threads/solaris.sh b/src/lib/libcrypto/threads/solaris.sh
new file mode 100644
index 0000000000..bc93094a27
--- /dev/null
+++ b/src/lib/libcrypto/threads/solaris.sh
@@ -0,0 +1,4 @@
1#!/bin/sh
2/bin/rm -f mttest
3cc -DSOLARIS -I../../include -g mttest.c -o mttest -L../.. -lthread -lssl -lcrypto -lnsl -lsocket
4
diff --git a/src/lib/libcrypto/threads/th-lock.c b/src/lib/libcrypto/threads/th-lock.c
new file mode 100644
index 0000000000..a6a79b9f45
--- /dev/null
+++ b/src/lib/libcrypto/threads/th-lock.c
@@ -0,0 +1,387 @@
1/* crypto/threads/th-lock.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <stdlib.h>
61#include <string.h>
62#include <errno.h>
63#ifdef LINUX
64#include <typedefs.h>
65#endif
66#ifdef OPENSSL_SYS_WIN32
67#include <windows.h>
68#endif
69#ifdef SOLARIS
70#include <synch.h>
71#include <thread.h>
72#endif
73#ifdef IRIX
74#include <ulocks.h>
75#include <sys/prctl.h>
76#endif
77#ifdef PTHREADS
78#include <pthread.h>
79#endif
80#include <openssl/lhash.h>
81#include <openssl/crypto.h>
82#include <openssl/buffer.h>
83#include <openssl/e_os.h>
84#include <openssl/x509.h>
85#include <openssl/ssl.h>
86#include <openssl/err.h>
87
88void CRYPTO_thread_setup(void);
89void CRYPTO_thread_cleanup(void);
90
91static void irix_locking_callback(int mode,int type,char *file,int line);
92static void solaris_locking_callback(int mode,int type,char *file,int line);
93static void win32_locking_callback(int mode,int type,char *file,int line);
94static void pthreads_locking_callback(int mode,int type,char *file,int line);
95
96static unsigned long irix_thread_id(void );
97static unsigned long solaris_thread_id(void );
98static unsigned long pthreads_thread_id(void );
99
100/* usage:
101 * CRYPTO_thread_setup();
102 * application code
103 * CRYPTO_thread_cleanup();
104 */
105
106#define THREAD_STACK_SIZE (16*1024)
107
108#ifdef OPENSSL_SYS_WIN32
109
110static HANDLE *lock_cs;
111
112void CRYPTO_thread_setup(void)
113 {
114 int i;
115
116 lock_cs=OPENSSL_malloc(CRYPTO_num_locks() * sizeof(HANDLE));
117 for (i=0; i<CRYPTO_num_locks(); i++)
118 {
119 lock_cs[i]=CreateMutex(NULL,FALSE,NULL);
120 }
121
122 CRYPTO_set_locking_callback((void (*)(int,int,char *,int))win32_locking_callback);
123 /* id callback defined */
124 return(1);
125 }
126
127static void CRYPTO_thread_cleanup(void)
128 {
129 int i;
130
131 CRYPTO_set_locking_callback(NULL);
132 for (i=0; i<CRYPTO_num_locks(); i++)
133 CloseHandle(lock_cs[i]);
134 OPENSSL_free(lock_cs);
135 }
136
137void win32_locking_callback(int mode, int type, char *file, int line)
138 {
139 if (mode & CRYPTO_LOCK)
140 {
141 WaitForSingleObject(lock_cs[type],INFINITE);
142 }
143 else
144 {
145 ReleaseMutex(lock_cs[type]);
146 }
147 }
148
149#endif /* OPENSSL_SYS_WIN32 */
150
151#ifdef SOLARIS
152
153#define USE_MUTEX
154
155#ifdef USE_MUTEX
156static mutex_t *lock_cs;
157#else
158static rwlock_t *lock_cs;
159#endif
160static long *lock_count;
161
162void CRYPTO_thread_setup(void)
163 {
164 int i;
165
166#ifdef USE_MUTEX
167 lock_cs=OPENSSL_malloc(CRYPTO_num_locks() * sizeof(mutex_t));
168#else
169 lock_cs=OPENSSL_malloc(CRYPTO_num_locks() * sizeof(rwlock_t));
170#endif
171 lock_count=OPENSSL_malloc(CRYPTO_num_locks() * sizeof(long));
172 for (i=0; i<CRYPTO_num_locks(); i++)
173 {
174 lock_count[i]=0;
175#ifdef USE_MUTEX
176 mutex_init(&(lock_cs[i]),USYNC_THREAD,NULL);
177#else
178 rwlock_init(&(lock_cs[i]),USYNC_THREAD,NULL);
179#endif
180 }
181
182 CRYPTO_set_id_callback((unsigned long (*)())solaris_thread_id);
183 CRYPTO_set_locking_callback((void (*)())solaris_locking_callback);
184 }
185
186void CRYPTO_thread_cleanup(void)
187 {
188 int i;
189
190 CRYPTO_set_locking_callback(NULL);
191 for (i=0; i<CRYPTO_num_locks(); i++)
192 {
193#ifdef USE_MUTEX
194 mutex_destroy(&(lock_cs[i]));
195#else
196 rwlock_destroy(&(lock_cs[i]));
197#endif
198 }
199 OPENSSL_free(lock_cs);
200 OPENSSL_free(lock_count);
201 }
202
203void solaris_locking_callback(int mode, int type, char *file, int line)
204 {
205#if 0
206 fprintf(stderr,"thread=%4d mode=%s lock=%s %s:%d\n",
207 CRYPTO_thread_id(),
208 (mode&CRYPTO_LOCK)?"l":"u",
209 (type&CRYPTO_READ)?"r":"w",file,line);
210#endif
211
212#if 0
213 if (CRYPTO_LOCK_SSL_CERT == type)
214 fprintf(stderr,"(t,m,f,l) %ld %d %s %d\n",
215 CRYPTO_thread_id(),
216 mode,file,line);
217#endif
218 if (mode & CRYPTO_LOCK)
219 {
220#ifdef USE_MUTEX
221 mutex_lock(&(lock_cs[type]));
222#else
223 if (mode & CRYPTO_READ)
224 rw_rdlock(&(lock_cs[type]));
225 else
226 rw_wrlock(&(lock_cs[type]));
227#endif
228 lock_count[type]++;
229 }
230 else
231 {
232#ifdef USE_MUTEX
233 mutex_unlock(&(lock_cs[type]));
234#else
235 rw_unlock(&(lock_cs[type]));
236#endif
237 }
238 }
239
240unsigned long solaris_thread_id(void)
241 {
242 unsigned long ret;
243
244 ret=(unsigned long)thr_self();
245 return(ret);
246 }
247#endif /* SOLARIS */
248
249#ifdef IRIX
250/* I don't think this works..... */
251
252static usptr_t *arena;
253static usema_t **lock_cs;
254
255void CRYPTO_thread_setup(void)
256 {
257 int i;
258 char filename[20];
259
260 strcpy(filename,"/tmp/mttest.XXXXXX");
261 mktemp(filename);
262
263 usconfig(CONF_STHREADIOOFF);
264 usconfig(CONF_STHREADMALLOCOFF);
265 usconfig(CONF_INITUSERS,100);
266 usconfig(CONF_LOCKTYPE,US_DEBUGPLUS);
267 arena=usinit(filename);
268 unlink(filename);
269
270 lock_cs=OPENSSL_malloc(CRYPTO_num_locks() * sizeof(usema_t *));
271 for (i=0; i<CRYPTO_num_locks(); i++)
272 {
273 lock_cs[i]=usnewsema(arena,1);
274 }
275
276 CRYPTO_set_id_callback((unsigned long (*)())irix_thread_id);
277 CRYPTO_set_locking_callback((void (*)())irix_locking_callback);
278 }
279
280void CRYPTO_thread_cleanup(void)
281 {
282 int i;
283
284 CRYPTO_set_locking_callback(NULL);
285 for (i=0; i<CRYPTO_num_locks(); i++)
286 {
287 char buf[10];
288
289 sprintf(buf,"%2d:",i);
290 usdumpsema(lock_cs[i],stdout,buf);
291 usfreesema(lock_cs[i],arena);
292 }
293 OPENSSL_free(lock_cs);
294 }
295
296void irix_locking_callback(int mode, int type, char *file, int line)
297 {
298 if (mode & CRYPTO_LOCK)
299 {
300 uspsema(lock_cs[type]);
301 }
302 else
303 {
304 usvsema(lock_cs[type]);
305 }
306 }
307
308unsigned long irix_thread_id(void)
309 {
310 unsigned long ret;
311
312 ret=(unsigned long)getpid();
313 return(ret);
314 }
315#endif /* IRIX */
316
317/* Linux and a few others */
318#ifdef PTHREADS
319
320static pthread_mutex_t *lock_cs;
321static long *lock_count;
322
323void CRYPTO_thread_setup(void)
324 {
325 int i;
326
327 lock_cs=OPENSSL_malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t));
328 lock_count=OPENSSL_malloc(CRYPTO_num_locks() * sizeof(long));
329 for (i=0; i<CRYPTO_num_locks(); i++)
330 {
331 lock_count[i]=0;
332 pthread_mutex_init(&(lock_cs[i]),NULL);
333 }
334
335 CRYPTO_set_id_callback((unsigned long (*)())pthreads_thread_id);
336 CRYPTO_set_locking_callback((void (*)())pthreads_locking_callback);
337 }
338
339void thread_cleanup(void)
340 {
341 int i;
342
343 CRYPTO_set_locking_callback(NULL);
344 for (i=0; i<CRYPTO_num_locks(); i++)
345 {
346 pthread_mutex_destroy(&(lock_cs[i]));
347 }
348 OPENSSL_free(lock_cs);
349 OPENSSL_free(lock_count);
350 }
351
352void pthreads_locking_callback(int mode, int type, char *file,
353 int line)
354 {
355#if 0
356 fprintf(stderr,"thread=%4d mode=%s lock=%s %s:%d\n",
357 CRYPTO_thread_id(),
358 (mode&CRYPTO_LOCK)?"l":"u",
359 (type&CRYPTO_READ)?"r":"w",file,line);
360#endif
361#if 0
362 if (CRYPTO_LOCK_SSL_CERT == type)
363 fprintf(stderr,"(t,m,f,l) %ld %d %s %d\n",
364 CRYPTO_thread_id(),
365 mode,file,line);
366#endif
367 if (mode & CRYPTO_LOCK)
368 {
369 pthread_mutex_lock(&(lock_cs[type]));
370 lock_count[type]++;
371 }
372 else
373 {
374 pthread_mutex_unlock(&(lock_cs[type]));
375 }
376 }
377
378unsigned long pthreads_thread_id(void)
379 {
380 unsigned long ret;
381
382 ret=(unsigned long)pthread_self();
383 return(ret);
384 }
385
386#endif /* PTHREADS */
387
diff --git a/src/lib/libcrypto/threads/win32.bat b/src/lib/libcrypto/threads/win32.bat
new file mode 100644
index 0000000000..ee6da80a07
--- /dev/null
+++ b/src/lib/libcrypto/threads/win32.bat
@@ -0,0 +1,4 @@
1del mttest.exe
2
3cl /O2 -DWIN32 /MD -I..\..\out mttest.c /Femttest ..\..\out\ssleay32.lib ..\..\out\libeay32.lib
4
diff --git a/src/lib/libcrypto/tmdiff.c b/src/lib/libcrypto/tmdiff.c
new file mode 100644
index 0000000000..7ebf2b202a
--- /dev/null
+++ b/src/lib/libcrypto/tmdiff.c
@@ -0,0 +1,241 @@
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
63#ifdef TIMEB
64#undef OPENSSL_SYS_WIN32
65#undef TIMES
66#endif
67
68#if !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN32) && !defined(OPENSSL_SYS_VMS) || defined(__DECC) && !defined(OPENSSL_SYS_MACOSX) && !defined(OPENSSL_SYS_VXWORKS)
69# define TIMES
70#endif
71
72#ifndef _IRIX
73# include <time.h>
74#endif
75#ifdef TIMES
76# include <sys/types.h>
77# include <sys/times.h>
78#endif
79
80/* Depending on the VMS version, the tms structure is perhaps defined.
81 The __TMS macro will show if it was. If it wasn't defined, we should
82 undefine TIMES, since that tells the rest of the program how things
83 should be handled. -- Richard Levitte */
84#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
85#undef TIMES
86#endif
87
88#if defined(sun) || defined(__ultrix)
89#define _POSIX_SOURCE
90#include <limits.h>
91#include <sys/param.h>
92#endif
93
94#if !defined(TIMES) && !defined(OPENSSL_SYS_VXWORKS)
95#include <sys/timeb.h>
96#endif
97
98#ifdef OPENSSL_SYS_WIN32
99#include <windows.h>
100#endif
101
102/* The following if from times(3) man page. It may need to be changed */
103#ifndef HZ
104# ifndef CLK_TCK
105# ifndef _BSD_CLK_TCK_ /* FreeBSD hack */
106# define HZ 100.0
107# else /* _BSD_CLK_TCK_ */
108# define HZ ((double)_BSD_CLK_TCK_)
109# endif
110# else /* CLK_TCK */
111# define HZ ((double)CLK_TCK)
112# endif
113#endif
114
115typedef struct ms_tm
116 {
117#ifdef TIMES
118 struct tms ms_tms;
119#else
120# ifdef OPENSSL_SYS_WIN32
121 HANDLE thread_id;
122 FILETIME ms_win32;
123# else
124# ifdef OPENSSL_SYS_VSWORKS
125 unsigned long ticks;
126# else
127 struct timeb ms_timeb;
128# endif
129# endif
130#endif
131 } MS_TM;
132
133char *ms_time_new(void)
134 {
135 MS_TM *ret;
136
137 ret=(MS_TM *)OPENSSL_malloc(sizeof(MS_TM));
138 if (ret == NULL)
139 return(NULL);
140 memset(ret,0,sizeof(MS_TM));
141#ifdef OPENSSL_SYS_WIN32
142 ret->thread_id=GetCurrentThread();
143#endif
144 return((char *)ret);
145 }
146
147void ms_time_free(char *a)
148 {
149 if (a != NULL)
150 OPENSSL_free(a);
151 }
152
153void ms_time_get(char *a)
154 {
155 MS_TM *tm=(MS_TM *)a;
156#ifdef OPENSSL_SYS_WIN32
157 FILETIME tmpa,tmpb,tmpc;
158#endif
159
160#ifdef TIMES
161 times(&tm->ms_tms);
162#else
163# ifdef OPENSSL_SYS_WIN32
164 GetThreadTimes(tm->thread_id,&tmpa,&tmpb,&tmpc,&(tm->ms_win32));
165# else
166# ifdef OPENSSL_SYS_VSWORKS
167 tm->ticks = tickGet();
168# else
169 ftime(&tm->ms_timeb);
170# endif
171# endif
172#endif
173 }
174
175double ms_time_diff(char *ap, char *bp)
176 {
177 MS_TM *a=(MS_TM *)ap;
178 MS_TM *b=(MS_TM *)bp;
179 double ret;
180
181#ifdef TIMES
182 ret=(b->ms_tms.tms_utime-a->ms_tms.tms_utime)/HZ;
183#else
184# ifdef OPENSSL_SYS_WIN32
185 {
186#ifdef __GNUC__
187 signed long long la,lb;
188#else
189 signed _int64 la,lb;
190#endif
191 la=a->ms_win32.dwHighDateTime;
192 lb=b->ms_win32.dwHighDateTime;
193 la<<=32;
194 lb<<=32;
195 la+=a->ms_win32.dwLowDateTime;
196 lb+=b->ms_win32.dwLowDateTime;
197 ret=((double)(lb-la))/1e7;
198 }
199# else
200# ifdef OPENSSL_SYS_VSWORKS
201 ret = (double)(b->ticks - a->ticks) / (double)sysClkRateGet();
202# else
203 ret= (double)(b->ms_timeb.time-a->ms_timeb.time)+
204 (((double)b->ms_timeb.millitm)-
205 ((double)a->ms_timeb.millitm))/1000.0;
206# endif
207# endif
208#endif
209 return((ret < 0.0000001)?0.0000001:ret);
210 }
211
212int ms_time_cmp(char *ap, char *bp)
213 {
214 MS_TM *a=(MS_TM *)ap,*b=(MS_TM *)bp;
215 double d;
216 int ret;
217
218#ifdef TIMES
219 d=(b->ms_tms.tms_utime-a->ms_tms.tms_utime)/HZ;
220#else
221# ifdef OPENSSL_SYS_WIN32
222 d =(b->ms_win32.dwHighDateTime&0x000fffff)*10+b->ms_win32.dwLowDateTime/1e7;
223 d-=(a->ms_win32.dwHighDateTime&0x000fffff)*10+a->ms_win32.dwLowDateTime/1e7;
224# else
225# ifdef OPENSSL_SYS_VSWORKS
226 d = (b->ticks - a->ticks);
227# else
228 d= (double)(b->ms_timeb.time-a->ms_timeb.time)+
229 (((double)b->ms_timeb.millitm)-(double)a->ms_timeb.millitm)/1000.0;
230# endif
231# endif
232#endif
233 if (d == 0.0)
234 ret=0;
235 else if (d < 0)
236 ret= -1;
237 else
238 ret=1;
239 return(ret);
240 }
241
diff --git a/src/lib/libcrypto/tmdiff.h b/src/lib/libcrypto/tmdiff.h
new file mode 100644
index 0000000000..41a8a1e0e0
--- /dev/null
+++ b/src/lib/libcrypto/tmdiff.h
@@ -0,0 +1,81 @@
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
63#ifndef HEADER_TMDIFF_H
64#define HEADER_TMDIFF_H
65
66#ifdef __cplusplus
67extern "C" {
68#endif
69
70char *ms_time_new(void );
71void ms_time_free(char *a);
72void ms_time_get(char *a);
73double ms_time_diff(char *start,char *end);
74int ms_time_cmp(char *ap,char *bp);
75
76#ifdef __cplusplus
77}
78#endif
79
80#endif
81
diff --git a/src/lib/libcrypto/txt_db/Makefile.ssl b/src/lib/libcrypto/txt_db/Makefile.ssl
new file mode 100644
index 0000000000..61ff361348
--- /dev/null
+++ b/src/lib/libcrypto/txt_db/Makefile.ssl
@@ -0,0 +1,88 @@
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 58b300b00b..9b186f2da5 100644
--- a/src/lib/libcrypto/txt_db/txt_db.c
+++ b/src/lib/libcrypto/txt_db/txt_db.c
@@ -108,7 +108,7 @@ TXT_DB *TXT_DB_read(BIO *in, int num)
108 if (offset != 0) 108 if (offset != 0)
109 { 109 {
110 size+=BUFSIZE; 110 size+=BUFSIZE;
111 if (!BUF_MEM_grow_clean(buf,size)) goto err; 111 if (!BUF_MEM_grow(buf,size)) goto err;
112 } 112 }
113 buf->data[offset]='\0'; 113 buf->data[offset]='\0';
114 BIO_gets(in,&(buf->data[offset]),size-offset); 114 BIO_gets(in,&(buf->data[offset]),size-offset);
@@ -268,7 +268,7 @@ long TXT_DB_write(BIO *out, TXT_DB *db)
268 if (pp[j] != NULL) 268 if (pp[j] != NULL)
269 l+=strlen(pp[j]); 269 l+=strlen(pp[j]);
270 } 270 }
271 if (!BUF_MEM_grow_clean(buf,(int)(l*2+nn))) goto err; 271 if (!BUF_MEM_grow(buf,(int)(l*2+nn))) goto err;
272 272
273 p=buf->data; 273 p=buf->data;
274 for (j=0; j<nn; j++) 274 for (j=0; j<nn; j++)
diff --git a/src/lib/libcrypto/ui/Makefile.ssl b/src/lib/libcrypto/ui/Makefile.ssl
new file mode 100644
index 0000000000..57b2e38335
--- /dev/null
+++ b/src/lib/libcrypto/ui/Makefile.ssl
@@ -0,0 +1,117 @@
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)
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: ../../include/openssl/bio.h ../../include/openssl/buffer.h
99ui_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
100ui_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
101ui_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
102ui_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
103ui_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h ui_lib.c
104ui_lib.o: 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_compat.c b/src/lib/libcrypto/ui/ui_compat.c
new file mode 100644
index 0000000000..13e0f70d90
--- /dev/null
+++ b/src/lib/libcrypto/ui/ui_compat.c
@@ -0,0 +1,67 @@
1/* crypto/ui/ui_compat.c -*- mode:C; c-file-style: "eay" -*- */
2/* ====================================================================
3 * Copyright (c) 2001-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#include <string.h>
57#include <openssl/ui_compat.h>
58
59int _ossl_old_des_read_pw_string(char *buf,int length,const char *prompt,int verify)
60 {
61 return UI_UTIL_read_pw_string(buf, length, prompt, verify);
62 }
63
64int _ossl_old_des_read_pw(char *buf,char *buff,int size,const char *prompt,int verify)
65 {
66 return UI_UTIL_read_pw(buf, buff, size, prompt, verify);
67 }
diff --git a/src/lib/libcrypto/ui/ui_lib.c b/src/lib/libcrypto/ui/ui_lib.c
index 13e5f20dcb..cce9075ac1 100644
--- a/src/lib/libcrypto/ui/ui_lib.c
+++ b/src/lib/libcrypto/ui/ui_lib.c
@@ -62,7 +62,6 @@
62#include <openssl/ui.h> 62#include <openssl/ui.h>
63#include <openssl/err.h> 63#include <openssl/err.h>
64#include "ui_locl.h" 64#include "ui_locl.h"
65#include "cryptlib.h"
66 65
67IMPLEMENT_STACK_OF(UI_STRING_ST) 66IMPLEMENT_STACK_OF(UI_STRING_ST)
68 67
@@ -145,8 +144,7 @@ static UI_STRING *general_allocate_prompt(UI *ui, const char *prompt,
145 { 144 {
146 UIerr(UI_F_GENERAL_ALLOCATE_PROMPT,ERR_R_PASSED_NULL_PARAMETER); 145 UIerr(UI_F_GENERAL_ALLOCATE_PROMPT,ERR_R_PASSED_NULL_PARAMETER);
147 } 146 }
148 else if ((type == UIT_PROMPT || type == UIT_VERIFY 147 else if (result_buf == NULL)
149 || type == UIT_BOOLEAN) && result_buf == NULL)
150 { 148 {
151 UIerr(UI_F_GENERAL_ALLOCATE_PROMPT,UI_R_NO_RESULT_BUFFER); 149 UIerr(UI_F_GENERAL_ALLOCATE_PROMPT,UI_R_NO_RESULT_BUFFER);
152 } 150 }
@@ -237,7 +235,7 @@ static int general_allocate_boolean(UI *ui,
237 return ret; 235 return ret;
238 } 236 }
239 237
240/* Returns the index to the place in the stack or -1 for error. Uses a 238/* Returns the index to the place in the stack or 0 for error. Uses a
241 direct reference to the prompt. */ 239 direct reference to the prompt. */
242int UI_add_input_string(UI *ui, const char *prompt, int flags, 240int UI_add_input_string(UI *ui, const char *prompt, int flags,
243 char *result_buf, int minsize, int maxsize) 241 char *result_buf, int minsize, int maxsize)
@@ -430,14 +428,14 @@ char *UI_construct_prompt(UI *ui, const char *object_desc,
430 len += sizeof(prompt3) - 1; 428 len += sizeof(prompt3) - 1;
431 429
432 prompt = (char *)OPENSSL_malloc(len + 1); 430 prompt = (char *)OPENSSL_malloc(len + 1);
433 strcpy(prompt, prompt1); 431 strlcpy(prompt, prompt1, len + 1);
434 strcat(prompt, object_desc); 432 strlcat(prompt, object_desc, len + 1);
435 if (object_name) 433 if (object_name)
436 { 434 {
437 strcat(prompt, prompt2); 435 strlcat(prompt, prompt2, len + 1);
438 strcat(prompt, object_name); 436 strlcat(prompt, object_name, len + 1);
439 } 437 }
440 strcat(prompt, prompt3); 438 strlcat(prompt, prompt3, len + 1);
441 } 439 }
442 return prompt; 440 return prompt;
443 } 441 }
@@ -833,8 +831,8 @@ int UI_set_result(UI *ui, UI_STRING *uis, const char *result)
833 case UIT_PROMPT: 831 case UIT_PROMPT:
834 case UIT_VERIFY: 832 case UIT_VERIFY:
835 { 833 {
836 char number1[DECIMAL_SIZE(uis->_.string_data.result_minsize)+1]; 834 char number1[20];
837 char number2[DECIMAL_SIZE(uis->_.string_data.result_maxsize)+1]; 835 char number2[20];
838 836
839 BIO_snprintf(number1, sizeof(number1), "%d", 837 BIO_snprintf(number1, sizeof(number1), "%d",
840 uis->_.string_data.result_minsize); 838 uis->_.string_data.result_minsize);
@@ -865,7 +863,8 @@ int UI_set_result(UI *ui, UI_STRING *uis, const char *result)
865 return -1; 863 return -1;
866 } 864 }
867 865
868 strcpy(uis->result_buf, result); 866 strlcpy(uis->result_buf, result,
867 uis->_.string_data.result_maxsize + 1);
869 break; 868 break;
870 case UIT_BOOLEAN: 869 case UIT_BOOLEAN:
871 { 870 {
diff --git a/src/lib/libcrypto/ui/ui_openssl.c b/src/lib/libcrypto/ui/ui_openssl.c
index 75318d48a1..f47ed31cb0 100644
--- a/src/lib/libcrypto/ui/ui_openssl.c
+++ b/src/lib/libcrypto/ui/ui_openssl.c
@@ -159,10 +159,8 @@
159 159
160#ifdef WIN_CONSOLE_BUG 160#ifdef WIN_CONSOLE_BUG
161# include <windows.h> 161# include <windows.h>
162#ifndef OPENSSL_SYS_WINCE
163# include <wincon.h> 162# include <wincon.h>
164#endif 163#endif
165#endif
166 164
167 165
168/* There are 5 types of terminal interface supported, 166/* There are 5 types of terminal interface supported,
@@ -193,7 +191,7 @@
193# define SGTTY 191# define SGTTY
194#endif 192#endif
195 193
196#if defined(OPENSSL_SYS_VXWORKS) 194#if defined(OPENSSL_SYS_VSWORKS)
197#undef TERMIOS 195#undef TERMIOS
198#undef TERMIO 196#undef TERMIO
199#undef SGTTY 197#undef SGTTY
@@ -223,7 +221,7 @@
223# define TTY_set(tty,data) ioctl(tty,TIOCSETP,data) 221# define TTY_set(tty,data) ioctl(tty,TIOCSETP,data)
224#endif 222#endif
225 223
226#if !defined(_LIBC) && !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_MACINTOSH_CLASSIC) && !defined(OPENSSL_SYS_SUNOS) 224#if !defined(_LIBC) && !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_MACINTOSH_CLASSIC)
227# include <sys/ioctl.h> 225# include <sys/ioctl.h>
228#endif 226#endif
229 227
@@ -243,10 +241,6 @@ struct IOSB {
243 }; 241 };
244#endif 242#endif
245 243
246#ifdef OPENSSL_SYS_SUNOS
247 typedef int sig_atomic_t;
248#endif
249
250#if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) || defined(MAC_OS_GUSI_SOURCE) 244#if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) || defined(MAC_OS_GUSI_SOURCE)
251/* 245/*
252 * This one needs work. As a matter of fact the code is unoperational 246 * This one needs work. As a matter of fact the code is unoperational
@@ -283,12 +277,10 @@ static FILE *tty_in, *tty_out;
283static int is_a_tty; 277static int is_a_tty;
284 278
285/* Declare static functions */ 279/* Declare static functions */
286#if !defined(OPENSSL_SYS_WIN16) && !defined(OPENSSL_SYS_WINCE)
287static void read_till_nl(FILE *); 280static void read_till_nl(FILE *);
288static void recsig(int); 281static void recsig(int);
289static void pushsig(void); 282static void pushsig(void);
290static void popsig(void); 283static void popsig(void);
291#endif
292#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN16) 284#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN16)
293static int noecho_fgets(char *buf, int size, FILE *tty); 285static int noecho_fgets(char *buf, int size, FILE *tty);
294#endif 286#endif
@@ -375,7 +367,6 @@ static int read_string(UI *ui, UI_STRING *uis)
375 } 367 }
376 368
377 369
378#if !defined(OPENSSL_SYS_WIN16) && !defined(OPENSSL_SYS_WINCE)
379/* Internal functions to read a string without echoing */ 370/* Internal functions to read a string without echoing */
380static void read_till_nl(FILE *in) 371static void read_till_nl(FILE *in)
381 { 372 {
@@ -388,7 +379,6 @@ static void read_till_nl(FILE *in)
388 } 379 }
389 380
390static volatile sig_atomic_t intr_signal; 381static volatile sig_atomic_t intr_signal;
391#endif
392 382
393static int read_string_inner(UI *ui, UI_STRING *uis, int echo, int strip_nl) 383static int read_string_inner(UI *ui, UI_STRING *uis, int echo, int strip_nl)
394 { 384 {
@@ -396,9 +386,9 @@ static int read_string_inner(UI *ui, UI_STRING *uis, int echo, int strip_nl)
396 int ok; 386 int ok;
397 char result[BUFSIZ]; 387 char result[BUFSIZ];
398 int maxsize = BUFSIZ-1; 388 int maxsize = BUFSIZ-1;
399#if !defined(OPENSSL_SYS_WIN16) && !defined(OPENSSL_SYS_WINCE)
400 char *p; 389 char *p;
401 390
391#ifndef OPENSSL_SYS_WIN16
402 intr_signal=0; 392 intr_signal=0;
403 ok=0; 393 ok=0;
404 ps=0; 394 ps=0;
@@ -449,7 +439,7 @@ error:
449 ok=1; 439 ok=1;
450#endif 440#endif
451 441
452 OPENSSL_cleanse(result,BUFSIZ); 442 memset(result,0,BUFSIZ);
453 return ok; 443 return ok;
454 } 444 }
455 445
@@ -460,7 +450,7 @@ static int open_console(UI *ui)
460 CRYPTO_w_lock(CRYPTO_LOCK_UI); 450 CRYPTO_w_lock(CRYPTO_LOCK_UI);
461 is_a_tty = 1; 451 is_a_tty = 1;
462 452
463#if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) || defined(OPENSSL_SYS_VXWORKS) 453#if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) || defined(OPENSSL_SYS_VSWORKS)
464 tty_in=stdin; 454 tty_in=stdin;
465 tty_out=stderr; 455 tty_out=stderr;
466#else 456#else
@@ -550,7 +540,7 @@ static int echo_console(UI *ui)
550 540
551static int close_console(UI *ui) 541static int close_console(UI *ui)
552 { 542 {
553 if (tty_in != stdin) fclose(tty_in); 543 if (tty_in != stderr) fclose(tty_in);
554 if (tty_out != stderr) fclose(tty_out); 544 if (tty_out != stderr) fclose(tty_out);
555#ifdef OPENSSL_SYS_VMS 545#ifdef OPENSSL_SYS_VMS
556 status = sys$dassgn(channel); 546 status = sys$dassgn(channel);
@@ -561,7 +551,6 @@ static int close_console(UI *ui)
561 } 551 }
562 552
563 553
564#if !defined(OPENSSL_SYS_WIN16) && !defined(OPENSSL_SYS_WINCE)
565/* Internal functions to handle signals and act on them */ 554/* Internal functions to handle signals and act on them */
566static void pushsig(void) 555static void pushsig(void)
567 { 556 {
@@ -625,10 +614,9 @@ static void recsig(int i)
625 { 614 {
626 intr_signal=i; 615 intr_signal=i;
627 } 616 }
628#endif
629 617
630/* Internal functions specific for Windows */ 618/* Internal functions specific for Windows */
631#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN16) && !defined(OPENSSL_SYS_WINCE) 619#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN16)
632static int noecho_fgets(char *buf, int size, FILE *tty) 620static int noecho_fgets(char *buf, int size, FILE *tty)
633 { 621 {
634 int i; 622 int i;
diff --git a/src/lib/libcrypto/ui/ui_util.c b/src/lib/libcrypto/ui/ui_util.c
index 46bc8c1a9a..f05573df33 100644
--- a/src/lib/libcrypto/ui/ui_util.c
+++ b/src/lib/libcrypto/ui/ui_util.c
@@ -62,7 +62,7 @@ int UI_UTIL_read_pw_string(char *buf,int length,const char *prompt,int verify)
62 int ret; 62 int ret;
63 63
64 ret=UI_UTIL_read_pw(buf,buff,(length>BUFSIZ)?BUFSIZ:length,prompt,verify); 64 ret=UI_UTIL_read_pw(buf,buff,(length>BUFSIZ)?BUFSIZ:length,prompt,verify);
65 OPENSSL_cleanse(buff,BUFSIZ); 65 memset(buff,0,BUFSIZ);
66 return(ret); 66 return(ret);
67 } 67 }
68 68
@@ -78,14 +78,12 @@ int UI_UTIL_read_pw(char *buf,char *buff,int size,const char *prompt,int verify)
78 if (ui) 78 if (ui)
79 { 79 {
80 ok = UI_add_input_string(ui,prompt,0,buf,0,size-1); 80 ok = UI_add_input_string(ui,prompt,0,buf,0,size-1);
81 if (ok >= 0 && verify) 81 if (ok == 0 && verify)
82 ok = UI_add_verify_string(ui,prompt,0,buff,0,size-1, 82 ok = UI_add_verify_string(ui,prompt,0,buff,0,size-1,
83 buf); 83 buf);
84 if (ok >= 0) 84 if (ok == 0)
85 ok=UI_process(ui); 85 ok=UI_process(ui);
86 UI_free(ui); 86 UI_free(ui);
87 } 87 }
88 if (ok > 0)
89 ok = 0;
90 return(ok); 88 return(ok);
91 } 89 }
diff --git a/src/lib/libcrypto/uid.c b/src/lib/libcrypto/uid.c
new file mode 100644
index 0000000000..d3d249c36f
--- /dev/null
+++ b/src/lib/libcrypto/uid.c
@@ -0,0 +1,89 @@
1/* crypto/uid.c */
2/* ====================================================================
3 * Copyright (c) 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 * 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 <openssl/crypto.h>
57#include <openssl/opensslconf.h>
58
59#if defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD__ > 2)
60
61#include OPENSSL_UNISTD
62
63int OPENSSL_issetugid(void)
64 {
65 return issetugid();
66 }
67
68#elif defined(OPENSSL_SYS_WIN32)
69
70int OPENSSL_issetugid(void)
71 {
72 return 0;
73 }
74
75#else
76
77#include OPENSSL_UNISTD
78#include <sys/types.h>
79
80int OPENSSL_issetugid(void)
81 {
82 if (getuid() != geteuid()) return 1;
83 if (getgid() != getegid()) return 1;
84 return 0;
85 }
86#endif
87
88
89
diff --git a/src/lib/libcrypto/util/FreeBSD.sh b/src/lib/libcrypto/util/FreeBSD.sh
new file mode 100644
index 0000000000..db8edfc6aa
--- /dev/null
+++ b/src/lib/libcrypto/util/FreeBSD.sh
@@ -0,0 +1,6 @@
1#!/bin/sh
2
3perl util/perlpath.pl /usr/bin
4perl util/ssldir.pl /usr/local
5perl util/mk1mf.pl FreeBSD >Makefile.FreeBSD
6perl Configure FreeBSD
diff --git a/src/lib/libcrypto/util/add_cr.pl b/src/lib/libcrypto/util/add_cr.pl
new file mode 100644
index 0000000000..c7b62c11ec
--- /dev/null
+++ b/src/lib/libcrypto/util/add_cr.pl
@@ -0,0 +1,123 @@
1#!/usr/local/bin/perl
2#
3# This adds a copyright message to a souce code file.
4# It also gets the file name correct.
5#
6# perl util/add_cr.pl *.[ch] */*.[ch] */*/*.[ch]
7#
8
9foreach (@ARGV)
10 {
11 &dofile($_);
12 }
13
14sub dofile
15 {
16 local($file)=@_;
17
18 open(IN,"<$file") || die "unable to open $file:$!\n";
19
20 print STDERR "doing $file\n";
21 @in=<IN>;
22
23 return(1) if ($in[0] =~ / NOCW /);
24
25 @out=();
26 open(OUT,">$file.out") || die "unable to open $file.$$:$!\n";
27 push(@out,"/* $file */\n");
28 if (($in[1] !~ /^\/\* Copyright \(C\) [0-9-]+ Eric Young \(eay\@cryptsoft.com\)/))
29 {
30 push(@out,&Copyright);
31 $i=2;
32 @a=grep(/ Copyright \(C\) /,@in);
33 if ($#a >= 0)
34 {
35 while (($i <= $#in) && ($in[$i] ne " */\n"))
36 { $i++; }
37 $i++ if ($in[$i] eq " */\n");
38
39 while (($i <= $#in) && ($in[$i] =~ /^\s*$/))
40 { $i++; }
41
42 push(@out,"\n");
43 for ( ; $i <= $#in; $i++)
44 { push(@out,$in[$i]); }
45 }
46 else
47 { push(@out,@in); }
48 }
49 else
50 {
51 shift(@in);
52 push(@out,@in);
53 }
54 print OUT @out;
55 close(IN);
56 close(OUT);
57 rename("$file","$file.orig") || die "unable to rename $file:$!\n";
58 rename("$file.out",$file) || die "unable to rename $file.out:$!\n";
59 }
60
61
62
63sub Copyright
64 {
65 return <<'EOF';
66/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
67 * All rights reserved.
68 *
69 * This package is an SSL implementation written
70 * by Eric Young (eay@cryptsoft.com).
71 * The implementation was written so as to conform with Netscapes SSL.
72 *
73 * This library is free for commercial and non-commercial use as long as
74 * the following conditions are aheared to. The following conditions
75 * apply to all code found in this distribution, be it the RC4, RSA,
76 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
77 * included with this distribution is covered by the same copyright terms
78 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
79 *
80 * Copyright remains Eric Young's, and as such any Copyright notices in
81 * the code are not to be removed.
82 * If this package is used in a product, Eric Young should be given attribution
83 * as the author of the parts of the library used.
84 * This can be in the form of a textual message at program startup or
85 * in documentation (online or textual) provided with the package.
86 *
87 * Redistribution and use in source and binary forms, with or without
88 * modification, are permitted provided that the following conditions
89 * are met:
90 * 1. Redistributions of source code must retain the copyright
91 * notice, this list of conditions and the following disclaimer.
92 * 2. Redistributions in binary form must reproduce the above copyright
93 * notice, this list of conditions and the following disclaimer in the
94 * documentation and/or other materials provided with the distribution.
95 * 3. All advertising materials mentioning features or use of this software
96 * must display the following acknowledgement:
97 * "This product includes cryptographic software written by
98 * Eric Young (eay@cryptsoft.com)"
99 * The word 'cryptographic' can be left out if the rouines from the library
100 * being used are not cryptographic related :-).
101 * 4. If you include any Windows specific code (or a derivative thereof) from
102 * the apps directory (application code) you must include an acknowledgement:
103 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
104 *
105 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
106 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
107 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
108 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
109 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
110 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
111 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
112 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
113 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
114 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
115 * SUCH DAMAGE.
116 *
117 * The licence and distribution terms for any publically available version or
118 * derivative of this code cannot be changed. i.e. this code cannot simply be
119 * copied and put under another distribution licence
120 * [including the GNU Public Licence.]
121 */
122EOF
123 }
diff --git a/src/lib/libcrypto/util/bat.sh b/src/lib/libcrypto/util/bat.sh
new file mode 100644
index 0000000000..c6f48e8a7b
--- /dev/null
+++ b/src/lib/libcrypto/util/bat.sh
@@ -0,0 +1,132 @@
1#!/usr/local/bin/perl
2
3$infile="/home/eay/ssl/SSLeay/MINFO";
4
5open(IN,"<$infile") || die "unable to open $infile:$!\n";
6$_=<IN>;
7for (;;)
8 {
9 chop;
10
11 ($key,$val)=/^([^=]+)=(.*)/;
12 if ($key eq "RELATIVE_DIRECTORY")
13 {
14 if ($lib ne "")
15 {
16 $uc=$lib;
17 $uc =~ s/^lib(.*)\.a/$1/;
18 $uc =~ tr/a-z/A-Z/;
19 $lib_nam{$uc}=$uc;
20 $lib_obj{$uc}.=$libobj." ";
21 }
22 last if ($val eq "FINISHED");
23 $lib="";
24 $libobj="";
25 $dir=$val;
26 }
27
28 if ($key eq "TEST")
29 { $test.=&var_add($dir,$val); }
30
31 if (($key eq "PROGS") || ($key eq "E_OBJ"))
32 { $e_exe.=&var_add($dir,$val); }
33
34 if ($key eq "LIB")
35 {
36 $lib=$val;
37 $lib =~ s/^.*\/([^\/]+)$/$1/;
38 }
39
40 if ($key eq "EXHEADER")
41 { $exheader.=&var_add($dir,$val); }
42
43 if ($key eq "HEADER")
44 { $header.=&var_add($dir,$val); }
45
46 if ($key eq "LIBSRC")
47 { $libsrc.=&var_add($dir,$val); }
48
49 if (!($_=<IN>))
50 { $_="RELATIVE_DIRECTORY=FINISHED\n"; }
51 }
52close(IN);
53
54@a=split(/\s+/,$libsrc);
55foreach (@a)
56 {
57 print "${_}.c\n";
58 }
59
60sub var_add
61 {
62 local($dir,$val)=@_;
63 local(@a,$_,$ret);
64
65 return("") if $no_idea && $dir =~ /\/idea/;
66 return("") if $no_rc2 && $dir =~ /\/rc2/;
67 return("") if $no_rc4 && $dir =~ /\/rc4/;
68 return("") if $no_rsa && $dir =~ /\/rsa/;
69 return("") if $no_rsa && $dir =~ /^rsaref/;
70 return("") if $no_dsa && $dir =~ /\/dsa/;
71 return("") if $no_dh && $dir =~ /\/dh/;
72 if ($no_des && $dir =~ /\/des/)
73 {
74 if ($val =~ /read_pwd/)
75 { return("$dir/read_pwd "); }
76 else
77 { return(""); }
78 }
79 return("") if $no_mdc2 && $dir =~ /\/mdc2/;
80 return("") if $no_sock && $dir =~ /\/proxy/;
81 return("") if $no_bf && $dir =~ /\/bf/;
82 return("") if $no_cast && $dir =~ /\/cast/;
83
84 $val =~ s/^\s*(.*)\s*$/$1/;
85 @a=split(/\s+/,$val);
86 grep(s/\.[och]$//,@a);
87
88 @a=grep(!/^e_.*_3d$/,@a) if $no_des;
89 @a=grep(!/^e_.*_d$/,@a) if $no_des;
90 @a=grep(!/^e_.*_i$/,@a) if $no_idea;
91 @a=grep(!/^e_.*_r2$/,@a) if $no_rc2;
92 @a=grep(!/^e_.*_bf$/,@a) if $no_bf;
93 @a=grep(!/^e_.*_c$/,@a) if $no_cast;
94 @a=grep(!/^e_rc4$/,@a) if $no_rc4;
95
96 @a=grep(!/(^s2_)|(^s23_)/,@a) if $no_ssl2;
97 @a=grep(!/(^s3_)|(^s23_)/,@a) if $no_ssl3;
98
99 @a=grep(!/(_sock$)|(_acpt$)|(_conn$)|(^pxy_)/,@a) if $no_sock;
100
101 @a=grep(!/(^md2)|(_md2$)/,@a) if $no_md2;
102 @a=grep(!/(^md5)|(_md5$)/,@a) if $no_md5;
103
104 @a=grep(!/(^d2i_r_)|(^i2d_r_)/,@a) if $no_rsa;
105 @a=grep(!/(^p_open$)|(^p_seal$)/,@a) if $no_rsa;
106 @a=grep(!/(^pem_seal$)/,@a) if $no_rsa;
107
108 @a=grep(!/(m_dss$)|(m_dss1$)/,@a) if $no_dsa;
109 @a=grep(!/(^d2i_s_)|(^i2d_s_)|(_dsap$)/,@a) if $no_dsa;
110
111 @a=grep(!/^n_pkey$/,@a) if $no_rsa || $no_rc4;
112
113 @a=grep(!/_dhp$/,@a) if $no_dh;
114
115 @a=grep(!/(^sha[^1])|(_sha$)|(m_dss$)/,@a) if $no_sha;
116 @a=grep(!/(^sha1)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1;
117 @a=grep(!/_mdc2$/,@a) if $no_mdc2;
118
119 @a=grep(!/(^rsa$)|(^genrsa$)|(^req$)|(^ca$)/,@a) if $no_rsa;
120 @a=grep(!/(^dsa$)|(^gendsa$)|(^dsaparam$)/,@a) if $no_dsa;
121 @a=grep(!/^gendsa$/,@a) if $no_sha1;
122 @a=grep(!/(^dh$)|(^gendh$)/,@a) if $no_dh;
123
124 @a=grep(!/(^dh)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1;
125
126 grep($_="$dir/$_",@a);
127 @a=grep(!/(^|\/)s_/,@a) if $no_sock;
128 @a=grep(!/(^|\/)bio_sock/,@a) if $no_sock;
129 $ret=join(' ',@a)." ";
130 return($ret);
131 }
132
diff --git a/src/lib/libcrypto/util/ck_errf.pl b/src/lib/libcrypto/util/ck_errf.pl
new file mode 100644
index 0000000000..7a24d6c5a2
--- /dev/null
+++ b/src/lib/libcrypto/util/ck_errf.pl
@@ -0,0 +1,45 @@
1#!/usr/local/bin/perl
2#
3# This is just a quick script to scan for cases where the 'error'
4# function name in a XXXerr() macro is wrong.
5#
6# Run in the top level by going
7# perl util/ck_errf.pl */*.c */*/*.c
8#
9
10foreach $file (@ARGV)
11 {
12 open(IN,"<$file") || die "unable to open $file\n";
13 $func="";
14 while (<IN>)
15 {
16 if (/^[a-zA-Z].+[\s*]([A-Za-z_0-9]+)\(.*\)/)
17 {
18 $func=$1;
19 $func =~ tr/A-Z/a-z/;
20 }
21 if (/([A-Z0-9]+)err\(([^,]+)/)
22 {
23 next if ($func eq "");
24 $errlib=$1;
25 $n=$2;
26 if ($n !~ /([^_]+)_F_(.+)$/)
27 {
28 # print "check -$file:$.:$func:$n\n";
29 next;
30 }
31 $lib=$1;
32 $n=$2;
33
34 if ($lib ne $errlib)
35 { print "$file:$.:$func:$n\n"; next; }
36
37 $n =~ tr/A-Z/a-z/;
38 if (($n ne $func) && ($errlib ne "SYS"))
39 { print "$file:$.:$func:$n\n"; next; }
40 # print "$func:$1\n";
41 }
42 }
43 close(IN);
44 }
45
diff --git a/src/lib/libcrypto/util/clean-depend.pl b/src/lib/libcrypto/util/clean-depend.pl
new file mode 100644
index 0000000000..6c485d1e2f
--- /dev/null
+++ b/src/lib/libcrypto/util/clean-depend.pl
@@ -0,0 +1,54 @@
1#!/usr/local/bin/perl -w
2# Clean the dependency list in a makefile of standard includes...
3# Written by Ben Laurie <ben@algroup.co.uk> 19 Jan 1999
4
5use strict;
6
7while(<STDIN>) {
8 print;
9 last if /^# DO NOT DELETE THIS LINE/;
10}
11
12my %files;
13
14my $thisfile="";
15while(<STDIN>) {
16 my ($dummy, $file,$deps)=/^((.*):)? (.*)$/;
17 my $origfile="";
18 $thisfile=$file if defined $file;
19 next if !defined $deps;
20 $origfile=$thisfile;
21 $origfile=~s/\.o$/.c/;
22 my @deps=split ' ',$deps;
23 @deps=grep(!/^\//,@deps);
24 @deps=grep(!/^\\$/,@deps);
25 @deps=grep(!/^$origfile$/,@deps);
26# pull out the kludged kerberos header (if present).
27 @deps=grep(!/^[.\/]+\/krb5.h/,@deps);
28 push @{$files{$thisfile}},@deps;
29}
30
31my $file;
32foreach $file (sort keys %files) {
33 my $len=0;
34 my $dep;
35 my $origfile=$file;
36 $origfile=~s/\.o$/.c/;
37 $file=~s/^\.\///;
38 push @{$files{$file}},$origfile;
39 my $prevdep="";
40 foreach $dep (sort @{$files{$file}}) {
41 $dep=~s/^\.\///;
42 next if $prevdep eq $dep; # to exterminate duplicates...
43 $prevdep = $dep;
44 $len=0 if $len+length($dep)+1 >= 80;
45 if($len == 0) {
46 print "\n$file:";
47 $len=length($file)+1;
48 }
49 print " $dep";
50 $len+=length($dep)+1;
51 }
52}
53
54print "\n";
diff --git a/src/lib/libcrypto/util/cygwin.sh b/src/lib/libcrypto/util/cygwin.sh
new file mode 100644
index 0000000000..b607399b02
--- /dev/null
+++ b/src/lib/libcrypto/util/cygwin.sh
@@ -0,0 +1,125 @@
1#!/bin/bash
2#
3# This script configures, builds and packs the binary package for
4# the Cygwin net distribution version of OpenSSL
5#
6
7# Uncomment when debugging
8#set -x
9
10CONFIG_OPTIONS="--prefix=/usr shared no-idea no-rc5 no-mdc2"
11INSTALL_PREFIX=/tmp/install
12
13VERSION=
14SUBVERSION=$1
15
16function cleanup()
17{
18 rm -rf ${INSTALL_PREFIX}/etc
19 rm -rf ${INSTALL_PREFIX}/usr
20}
21
22function get_openssl_version()
23{
24 eval `grep '^VERSION=' Makefile.ssl`
25 if [ -z "${VERSION}" ]
26 then
27 echo "Error: Couldn't retrieve OpenSSL version from Makefile.ssl."
28 echo " Check value of variable VERSION in Makefile.ssl."
29 exit 1
30 fi
31}
32
33function base_install()
34{
35 mkdir -p ${INSTALL_PREFIX}
36 cleanup
37 make install INSTALL_PREFIX="${INSTALL_PREFIX}"
38}
39
40function doc_install()
41{
42 DOC_DIR=${INSTALL_PREFIX}/usr/doc/openssl
43
44 mkdir -p ${DOC_DIR}
45 cp CHANGES CHANGES.SSLeay INSTALL LICENSE NEWS README ${DOC_DIR}
46
47 create_cygwin_readme
48}
49
50function create_cygwin_readme()
51{
52 README_DIR=${INSTALL_PREFIX}/usr/doc/Cygwin
53 README_FILE=${README_DIR}/openssl-${VERSION}.README
54
55 mkdir -p ${README_DIR}
56 cat > ${README_FILE} <<- EOF
57 The Cygwin version has been built using the following configure:
58
59 ./config ${CONFIG_OPTIONS}
60
61 The IDEA, RC5 and MDC2 algorithms are disabled due to patent and/or
62 licensing issues.
63 EOF
64}
65
66function create_profile_files()
67{
68 PROFILE_DIR=${INSTALL_PREFIX}/etc/profile.d
69
70 mkdir -p $PROFILE_DIR
71 cat > ${PROFILE_DIR}/openssl.sh <<- "EOF"
72 export MANPATH="${MANPATH}:/usr/ssl/man"
73 EOF
74 cat > ${PROFILE_DIR}/openssl.csh <<- "EOF"
75 if ( $?MANPATH ) then
76 setenv MANPATH "${MANPATH}:/usr/ssl/man"
77 else
78 setenv MANPATH ":/usr/ssl/man"
79 endif
80 EOF
81}
82
83if [ -z "${SUBVERSION}" ]
84then
85 echo "Usage: $0 subversion"
86 exit 1
87fi
88
89if [ ! -f config ]
90then
91 echo "You must start this script in the OpenSSL toplevel source dir."
92 exit 1
93fi
94
95./config ${CONFIG_OPTIONS}
96
97get_openssl_version
98
99make || exit 1
100
101base_install
102
103doc_install
104
105create_cygwin_readme
106
107create_profile_files
108
109cd ${INSTALL_PREFIX}
110strip usr/bin/*.exe usr/bin/*.dll
111
112# Runtime package
113find etc usr/bin usr/doc usr/ssl/certs usr/ssl/man/man[157] usr/ssl/misc \
114 usr/ssl/openssl.cnf usr/ssl/private -empty -o \! -type d |
115tar cjfT openssl-${VERSION}-${SUBVERSION}.tar.bz2 -
116# Development package
117find usr/include usr/lib usr/ssl/man/man3 -empty -o \! -type d |
118tar cjfT openssl-devel-${VERSION}-${SUBVERSION}.tar.bz2 -
119
120ls -l openssl-${VERSION}-${SUBVERSION}.tar.bz2
121ls -l openssl-devel-${VERSION}-${SUBVERSION}.tar.bz2
122
123cleanup
124
125exit 0
diff --git a/src/lib/libcrypto/util/deleof.pl b/src/lib/libcrypto/util/deleof.pl
new file mode 100644
index 0000000000..155acd88ff
--- /dev/null
+++ b/src/lib/libcrypto/util/deleof.pl
@@ -0,0 +1,7 @@
1#!/usr/local/bin/perl
2
3while (<>)
4 {
5 print
6 last if (/^# DO NOT DELETE THIS LINE/);
7 }
diff --git a/src/lib/libcrypto/util/dirname.pl b/src/lib/libcrypto/util/dirname.pl
new file mode 100644
index 0000000000..d7a66d96ac
--- /dev/null
+++ b/src/lib/libcrypto/util/dirname.pl
@@ -0,0 +1,18 @@
1#!/usr/local/bin/perl
2
3if ($#ARGV < 0) {
4 die "dirname.pl: too few arguments\n";
5} elsif ($#ARGV > 0) {
6 die "dirname.pl: too many arguments\n";
7}
8
9my $d = $ARGV[0];
10
11if ($d =~ m|.*/.*|) {
12 $d =~ s|/[^/]*$||;
13} else {
14 $d = ".";
15}
16
17print $d,"\n";
18exit(0);
diff --git a/src/lib/libcrypto/util/do_ms.sh b/src/lib/libcrypto/util/do_ms.sh
new file mode 100644
index 0000000000..515b074cff
--- /dev/null
+++ b/src/lib/libcrypto/util/do_ms.sh
@@ -0,0 +1,19 @@
1#!/bin/sh
2#
3# generate the Microsoft makefiles and .def files
4#
5
6PATH=util:../util:$PATH
7
8# perl util/mk1mf.pl no-sock VC-MSDOS >ms/msdos.mak
9# perl util/mk1mf.pl VC-W31-32 >ms/w31.mak
10perl util/mk1mf.pl dll VC-WIN16 >ms/w31dll.mak
11# perl util/mk1mf.pl VC-WIN32 >ms/nt.mak
12perl util/mk1mf.pl dll VC-WIN32 >ms/ntdll.mak
13perl util/mk1mf.pl Mingw32 >ms/mingw32.mak
14perl util/mk1mf.pl Mingw32-files >ms/mingw32f.mak
15
16perl util/mkdef.pl 16 libeay > ms/libeay16.def
17perl util/mkdef.pl 32 libeay > ms/libeay32.def
18perl util/mkdef.pl 16 ssleay > ms/ssleay16.def
19perl util/mkdef.pl 32 ssleay > ms/ssleay32.def
diff --git a/src/lib/libcrypto/util/domd b/src/lib/libcrypto/util/domd
new file mode 100644
index 0000000000..8cbe383c16
--- /dev/null
+++ b/src/lib/libcrypto/util/domd
@@ -0,0 +1,29 @@
1#!/bin/sh
2# Do a makedepend, only leave out the standard headers
3# Written by Ben Laurie <ben@algroup.co.uk> 19 Jan 1999
4
5TOP=$1
6shift
7if [ "$1" = "-MD" ]; then
8 shift
9 MAKEDEPEND=$1
10 shift
11fi
12if [ "$MAKEDEPEND" = "" ]; then MAKEDEPEND=makedepend; fi
13
14cp Makefile.ssl Makefile.save
15# fake the presence of Kerberos
16touch $TOP/krb5.h
17if [ "$MAKEDEPEND" = "gcc" ]; then
18 sed -e '/^# DO NOT DELETE.*/,$d' < Makefile.ssl > Makefile.tmp
19 echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' >> Makefile.tmp
20 gcc -D OPENSSL_DOING_MAKEDEPEND -M $@ >> Makefile.tmp
21 ${PERL} $TOP/util/clean-depend.pl < Makefile.tmp > Makefile.new
22 rm -f Makefile.tmp
23else
24 ${MAKEDEPEND} -D OPENSSL_DOING_MAKEDEPEND -f Makefile.ssl $@
25 ${PERL} $TOP/util/clean-depend.pl < Makefile.ssl > Makefile.new
26fi
27mv Makefile.new Makefile.ssl
28# unfake the presence of Kerberos
29rm $TOP/krb5.h
diff --git a/src/lib/libcrypto/util/err-ins.pl b/src/lib/libcrypto/util/err-ins.pl
new file mode 100644
index 0000000000..31b70df8d0
--- /dev/null
+++ b/src/lib/libcrypto/util/err-ins.pl
@@ -0,0 +1,33 @@
1#!/usr/local/bin/perl
2#
3# tack error codes onto the end of a file
4#
5
6open(ERR,$ARGV[0]) || die "unable to open error file '$ARGV[0]':$!\n";
7@err=<ERR>;
8close(ERR);
9
10open(IN,$ARGV[1]) || die "unable to open header file '$ARGV[1]':$!\n";
11
12@out="";
13while (<IN>)
14 {
15 push(@out,$_);
16 last if /BEGIN ERROR CODES/;
17 }
18close(IN);
19
20open(OUT,">$ARGV[1]") || die "unable to open header file '$ARGV[1]':$1\n";
21print OUT @out;
22print OUT @err;
23print OUT <<"EOF";
24
25#ifdef __cplusplus
26}
27#endif
28#endif
29
30EOF
31close(OUT);
32
33
diff --git a/src/lib/libcrypto/util/files.pl b/src/lib/libcrypto/util/files.pl
new file mode 100644
index 0000000000..41f033e3b9
--- /dev/null
+++ b/src/lib/libcrypto/util/files.pl
@@ -0,0 +1,61 @@
1#!/usr/local/bin/perl
2#
3# used to generate the file MINFO for use by util/mk1mf.pl
4# It is basically a list of all variables from the passed makefile
5#
6
7$s="";
8while (<>)
9 {
10 chop;
11 s/#.*//;
12 if (/^(\S+)\s*=\s*(.*)$/)
13 {
14 $o="";
15 ($s,$b)=($1,$2);
16 for (;;)
17 {
18 if ($b =~ /\\$/)
19 {
20 chop($b);
21 $o.=$b." ";
22 $b=<>;
23 chop($b);
24 }
25 else
26 {
27 $o.=$b." ";
28 last;
29 }
30 }
31 $o =~ s/^\s+//;
32 $o =~ s/\s+$//;
33 $o =~ s/\s+/ /g;
34
35 $o =~ s/\$[({]([^)}]+)[)}]/$sym{$1}/g;
36 $sym{$s}=$o;
37 }
38 }
39
40$pwd=`pwd`; chop($pwd);
41
42if ($sym{'TOP'} eq ".")
43 {
44 $n=0;
45 $dir=".";
46 }
47else {
48 $n=split(/\//,$sym{'TOP'});
49 @_=split(/\//,$pwd);
50 $z=$#_-$n+1;
51 foreach $i ($z .. $#_) { $dir.=$_[$i]."/"; }
52 chop($dir);
53 }
54
55print "RELATIVE_DIRECTORY=$dir\n";
56
57foreach (sort keys %sym)
58 {
59 print "$_=$sym{$_}\n";
60 }
61print "RELATIVE_DIRECTORY=\n";
diff --git a/src/lib/libcrypto/util/fixNT.sh b/src/lib/libcrypto/util/fixNT.sh
new file mode 100644
index 0000000000..ce4f19299b
--- /dev/null
+++ b/src/lib/libcrypto/util/fixNT.sh
@@ -0,0 +1,14 @@
1#!/bin/sh
2#
3# clean up the mess that NT makes of my source tree
4#
5
6if [ -f makefile.ssl -a ! -f Makefile.ssl ]; then
7 /bin/mv makefile.ssl Makefile.ssl
8fi
9chmod +x Configure util/*
10echo cleaning
11/bin/rm -f `find . -name '*.$$$' -print` 2>/dev/null >/dev/null
12echo 'removing those damn ^M'
13perl -pi -e 's/\015//' `find . -type 'f' -print |grep -v '.obj$' |grep -v '.der$' |grep -v '.gz'`
14make -f Makefile.ssl links
diff --git a/src/lib/libcrypto/util/install.sh b/src/lib/libcrypto/util/install.sh
new file mode 100644
index 0000000000..e1d0c982df
--- /dev/null
+++ b/src/lib/libcrypto/util/install.sh
@@ -0,0 +1,108 @@
1#!/bin/sh
2#
3# install - install a program, script, or datafile
4# This comes from X11R5; it is not part of GNU.
5#
6# $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $
7#
8# This script is compatible with the BSD install script, but was written
9# from scratch.
10#
11
12
13# set DOITPROG to echo to test this script
14
15doit="${DOITPROG:-}"
16
17
18# put in absolute paths if you don't have them in your path; or use env. vars.
19
20mvprog="${MVPROG:-mv}"
21cpprog="${CPPROG:-cp}"
22chmodprog="${CHMODPROG:-chmod}"
23chownprog="${CHOWNPROG:-chown}"
24chgrpprog="${CHGRPPROG:-chgrp}"
25stripprog="${STRIPPROG:-strip}"
26rmprog="${RMPROG:-rm}"
27
28instcmd="$mvprog"
29chmodcmd=""
30chowncmd=""
31chgrpcmd=""
32stripcmd=""
33rmcmd="$rmprog -f"
34src=""
35dst=""
36
37while [ x"$1" != x ]; do
38 case $1 in
39 -c) instcmd="$cpprog"
40 shift
41 continue;;
42
43 -m) chmodcmd="$chmodprog $2"
44 shift
45 shift
46 continue;;
47
48 -o) chowncmd="$chownprog $2"
49 shift
50 shift
51 continue;;
52
53 -g) chgrpcmd="$chgrpprog $2"
54 shift
55 shift
56 continue;;
57
58 -s) stripcmd="$stripprog"
59 shift
60 continue;;
61
62 *) if [ x"$src" = x ]
63 then
64 src=$1
65 else
66 dst=$1
67 fi
68 shift
69 continue;;
70 esac
71done
72
73if [ x"$src" = x ]
74then
75 echo "install: no input file specified"
76 exit 1
77fi
78
79if [ x"$dst" = x ]
80then
81 echo "install: no destination specified"
82 exit 1
83fi
84
85
86# if destination is a directory, append the input filename; if your system
87# does not like double slashes in filenames, you may need to add some logic
88
89if [ -d $dst ]
90then
91 dst="$dst"/`basename $src`
92fi
93
94
95# get rid of the old one and mode the new one in
96
97$doit $rmcmd $dst
98$doit $instcmd $src $dst
99
100
101# and set any options; do chmod last to preserve setuid bits
102
103if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; fi
104if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; fi
105if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; fi
106if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; fi
107
108exit 0
diff --git a/src/lib/libcrypto/util/libeay.num b/src/lib/libcrypto/util/libeay.num
new file mode 100644
index 0000000000..7e5728495f
--- /dev/null
+++ b/src/lib/libcrypto/util/libeay.num
@@ -0,0 +1,2795 @@
1SSLeay 1 EXIST::FUNCTION:
2SSLeay_version 2 EXIST::FUNCTION:
3ASN1_BIT_STRING_asn1_meth 3 EXIST::FUNCTION:
4ASN1_HEADER_free 4 EXIST::FUNCTION:
5ASN1_HEADER_new 5 EXIST::FUNCTION:
6ASN1_IA5STRING_asn1_meth 6 EXIST::FUNCTION:
7ASN1_INTEGER_get 7 EXIST::FUNCTION:
8ASN1_INTEGER_set 8 EXIST::FUNCTION:
9ASN1_INTEGER_to_BN 9 EXIST::FUNCTION:
10ASN1_OBJECT_create 10 EXIST::FUNCTION:
11ASN1_OBJECT_free 11 EXIST::FUNCTION:
12ASN1_OBJECT_new 12 EXIST::FUNCTION:
13ASN1_PRINTABLE_type 13 EXIST::FUNCTION:
14ASN1_STRING_cmp 14 EXIST::FUNCTION:
15ASN1_STRING_dup 15 EXIST::FUNCTION:
16ASN1_STRING_free 16 EXIST::FUNCTION:
17ASN1_STRING_new 17 EXIST::FUNCTION:
18ASN1_STRING_print 18 EXIST::FUNCTION:BIO
19ASN1_STRING_set 19 EXIST::FUNCTION:
20ASN1_STRING_type_new 20 EXIST::FUNCTION:
21ASN1_TYPE_free 21 EXIST::FUNCTION:
22ASN1_TYPE_new 22 EXIST::FUNCTION:
23ASN1_UNIVERSALSTRING_to_string 23 EXIST::FUNCTION:
24ASN1_UTCTIME_check 24 EXIST::FUNCTION:
25ASN1_UTCTIME_print 25 EXIST::FUNCTION:BIO
26ASN1_UTCTIME_set 26 EXIST::FUNCTION:
27ASN1_check_infinite_end 27 EXIST::FUNCTION:
28ASN1_d2i_bio 28 EXIST::FUNCTION:BIO
29ASN1_d2i_fp 29 EXIST::FUNCTION:FP_API
30ASN1_digest 30 EXIST::FUNCTION:EVP
31ASN1_dup 31 EXIST::FUNCTION:
32ASN1_get_object 32 EXIST::FUNCTION:
33ASN1_i2d_bio 33 EXIST::FUNCTION:BIO
34ASN1_i2d_fp 34 EXIST::FUNCTION:FP_API
35ASN1_object_size 35 EXIST::FUNCTION:
36ASN1_parse 36 EXIST::FUNCTION:BIO
37ASN1_put_object 37 EXIST::FUNCTION:
38ASN1_sign 38 EXIST::FUNCTION:EVP
39ASN1_verify 39 EXIST::FUNCTION:EVP
40BF_cbc_encrypt 40 EXIST::FUNCTION:BF
41BF_cfb64_encrypt 41 EXIST::FUNCTION:BF
42BF_ecb_encrypt 42 EXIST::FUNCTION:BF
43BF_encrypt 43 EXIST::FUNCTION:BF
44BF_ofb64_encrypt 44 EXIST::FUNCTION:BF
45BF_options 45 EXIST::FUNCTION:BF
46BF_set_key 46 EXIST::FUNCTION:BF
47BIO_CONNECT_free 47 NOEXIST::FUNCTION:
48BIO_CONNECT_new 48 NOEXIST::FUNCTION:
49BIO_accept 51 EXIST::FUNCTION:
50BIO_ctrl 52 EXIST::FUNCTION:
51BIO_int_ctrl 53 EXIST::FUNCTION:
52BIO_debug_callback 54 EXIST::FUNCTION:
53BIO_dump 55 EXIST::FUNCTION:
54BIO_dup_chain 56 EXIST::FUNCTION:
55BIO_f_base64 57 EXIST::FUNCTION:BIO
56BIO_f_buffer 58 EXIST::FUNCTION:
57BIO_f_cipher 59 EXIST::FUNCTION:BIO
58BIO_f_md 60 EXIST::FUNCTION:BIO
59BIO_f_null 61 EXIST::FUNCTION:
60BIO_f_proxy_server 62 NOEXIST::FUNCTION:
61BIO_fd_non_fatal_error 63 EXIST::FUNCTION:
62BIO_fd_should_retry 64 EXIST::FUNCTION:
63BIO_find_type 65 EXIST::FUNCTION:
64BIO_free 66 EXIST::FUNCTION:
65BIO_free_all 67 EXIST::FUNCTION:
66BIO_get_accept_socket 69 EXIST::FUNCTION:
67BIO_get_filter_bio 70 NOEXIST::FUNCTION:
68BIO_get_host_ip 71 EXIST::FUNCTION:
69BIO_get_port 72 EXIST::FUNCTION:
70BIO_get_retry_BIO 73 EXIST::FUNCTION:
71BIO_get_retry_reason 74 EXIST::FUNCTION:
72BIO_gethostbyname 75 EXIST::FUNCTION:
73BIO_gets 76 EXIST::FUNCTION:
74BIO_new 78 EXIST::FUNCTION:
75BIO_new_accept 79 EXIST::FUNCTION:
76BIO_new_connect 80 EXIST::FUNCTION:
77BIO_new_fd 81 EXIST::FUNCTION:
78BIO_new_file 82 EXIST:!WIN16:FUNCTION:FP_API
79BIO_new_fp 83 EXIST:!WIN16:FUNCTION:FP_API
80BIO_new_socket 84 EXIST::FUNCTION:
81BIO_pop 85 EXIST::FUNCTION:
82BIO_printf 86 EXIST::FUNCTION:
83BIO_push 87 EXIST::FUNCTION:
84BIO_puts 88 EXIST::FUNCTION:
85BIO_read 89 EXIST::FUNCTION:
86BIO_s_accept 90 EXIST::FUNCTION:
87BIO_s_connect 91 EXIST::FUNCTION:
88BIO_s_fd 92 EXIST::FUNCTION:
89BIO_s_file 93 EXIST:!WIN16:FUNCTION:FP_API
90BIO_s_mem 95 EXIST::FUNCTION:
91BIO_s_null 96 EXIST::FUNCTION:
92BIO_s_proxy_client 97 NOEXIST::FUNCTION:
93BIO_s_socket 98 EXIST::FUNCTION:
94BIO_set 100 EXIST::FUNCTION:
95BIO_set_cipher 101 EXIST::FUNCTION:BIO
96BIO_set_tcp_ndelay 102 EXIST::FUNCTION:
97BIO_sock_cleanup 103 EXIST::FUNCTION:
98BIO_sock_error 104 EXIST::FUNCTION:
99BIO_sock_init 105 EXIST::FUNCTION:
100BIO_sock_non_fatal_error 106 EXIST::FUNCTION:
101BIO_sock_should_retry 107 EXIST::FUNCTION:
102BIO_socket_ioctl 108 EXIST::FUNCTION:
103BIO_write 109 EXIST::FUNCTION:
104BN_CTX_free 110 EXIST::FUNCTION:
105BN_CTX_new 111 EXIST::FUNCTION:
106BN_MONT_CTX_free 112 EXIST::FUNCTION:
107BN_MONT_CTX_new 113 EXIST::FUNCTION:
108BN_MONT_CTX_set 114 EXIST::FUNCTION:
109BN_add 115 EXIST::FUNCTION:
110BN_add_word 116 EXIST::FUNCTION:
111BN_hex2bn 117 EXIST::FUNCTION:
112BN_bin2bn 118 EXIST::FUNCTION:
113BN_bn2hex 119 EXIST::FUNCTION:
114BN_bn2bin 120 EXIST::FUNCTION:
115BN_clear 121 EXIST::FUNCTION:
116BN_clear_bit 122 EXIST::FUNCTION:
117BN_clear_free 123 EXIST::FUNCTION:
118BN_cmp 124 EXIST::FUNCTION:
119BN_copy 125 EXIST::FUNCTION:
120BN_div 126 EXIST::FUNCTION:
121BN_div_word 127 EXIST::FUNCTION:
122BN_dup 128 EXIST::FUNCTION:
123BN_free 129 EXIST::FUNCTION:
124BN_from_montgomery 130 EXIST::FUNCTION:
125BN_gcd 131 EXIST::FUNCTION:
126BN_generate_prime 132 EXIST::FUNCTION:
127BN_get_word 133 EXIST::FUNCTION:
128BN_is_bit_set 134 EXIST::FUNCTION:
129BN_is_prime 135 EXIST::FUNCTION:
130BN_lshift 136 EXIST::FUNCTION:
131BN_lshift1 137 EXIST::FUNCTION:
132BN_mask_bits 138 EXIST::FUNCTION:
133BN_mod 139 NOEXIST::FUNCTION:
134BN_mod_exp 140 EXIST::FUNCTION:
135BN_mod_exp_mont 141 EXIST::FUNCTION:
136BN_mod_exp_simple 143 EXIST::FUNCTION:
137BN_mod_inverse 144 EXIST::FUNCTION:
138BN_mod_mul 145 EXIST::FUNCTION:
139BN_mod_mul_montgomery 146 EXIST::FUNCTION:
140BN_mod_word 148 EXIST::FUNCTION:
141BN_mul 149 EXIST::FUNCTION:
142BN_new 150 EXIST::FUNCTION:
143BN_num_bits 151 EXIST::FUNCTION:
144BN_num_bits_word 152 EXIST::FUNCTION:
145BN_options 153 EXIST::FUNCTION:
146BN_print 154 EXIST::FUNCTION:
147BN_print_fp 155 EXIST::FUNCTION:FP_API
148BN_rand 156 EXIST::FUNCTION:
149BN_reciprocal 157 EXIST::FUNCTION:
150BN_rshift 158 EXIST::FUNCTION:
151BN_rshift1 159 EXIST::FUNCTION:
152BN_set_bit 160 EXIST::FUNCTION:
153BN_set_word 161 EXIST::FUNCTION:
154BN_sqr 162 EXIST::FUNCTION:
155BN_sub 163 EXIST::FUNCTION:
156BN_to_ASN1_INTEGER 164 EXIST::FUNCTION:
157BN_ucmp 165 EXIST::FUNCTION:
158BN_value_one 166 EXIST::FUNCTION:
159BUF_MEM_free 167 EXIST::FUNCTION:
160BUF_MEM_grow 168 EXIST::FUNCTION:
161BUF_MEM_new 169 EXIST::FUNCTION:
162BUF_strdup 170 EXIST::FUNCTION:
163CONF_free 171 EXIST::FUNCTION:
164CONF_get_number 172 EXIST::FUNCTION:
165CONF_get_section 173 EXIST::FUNCTION:
166CONF_get_string 174 EXIST::FUNCTION:
167CONF_load 175 EXIST::FUNCTION:
168CRYPTO_add_lock 176 EXIST::FUNCTION:
169CRYPTO_dbg_free 177 EXIST::FUNCTION:
170CRYPTO_dbg_malloc 178 EXIST::FUNCTION:
171CRYPTO_dbg_realloc 179 EXIST::FUNCTION:
172CRYPTO_dbg_remalloc 180 NOEXIST::FUNCTION:
173CRYPTO_free 181 EXIST::FUNCTION:
174CRYPTO_get_add_lock_callback 182 EXIST::FUNCTION:
175CRYPTO_get_id_callback 183 EXIST::FUNCTION:
176CRYPTO_get_lock_name 184 EXIST::FUNCTION:
177CRYPTO_get_locking_callback 185 EXIST::FUNCTION:
178CRYPTO_get_mem_functions 186 EXIST::FUNCTION:
179CRYPTO_lock 187 EXIST::FUNCTION:
180CRYPTO_malloc 188 EXIST::FUNCTION:
181CRYPTO_mem_ctrl 189 EXIST::FUNCTION:
182CRYPTO_mem_leaks 190 EXIST::FUNCTION:
183CRYPTO_mem_leaks_cb 191 EXIST::FUNCTION:
184CRYPTO_mem_leaks_fp 192 EXIST::FUNCTION:FP_API
185CRYPTO_realloc 193 EXIST::FUNCTION:
186CRYPTO_remalloc 194 EXIST::FUNCTION:
187CRYPTO_set_add_lock_callback 195 EXIST::FUNCTION:
188CRYPTO_set_id_callback 196 EXIST::FUNCTION:
189CRYPTO_set_locking_callback 197 EXIST::FUNCTION:
190CRYPTO_set_mem_functions 198 EXIST::FUNCTION:
191CRYPTO_thread_id 199 EXIST::FUNCTION:
192DH_check 200 EXIST::FUNCTION:DH
193DH_compute_key 201 EXIST::FUNCTION:DH
194DH_free 202 EXIST::FUNCTION:DH
195DH_generate_key 203 EXIST::FUNCTION:DH
196DH_generate_parameters 204 EXIST::FUNCTION:DH
197DH_new 205 EXIST::FUNCTION:DH
198DH_size 206 EXIST::FUNCTION:DH
199DHparams_print 207 EXIST::FUNCTION:BIO,DH
200DHparams_print_fp 208 EXIST::FUNCTION:DH,FP_API
201DSA_free 209 EXIST::FUNCTION:DSA
202DSA_generate_key 210 EXIST::FUNCTION:DSA
203DSA_generate_parameters 211 EXIST::FUNCTION:DSA
204DSA_is_prime 212 NOEXIST::FUNCTION:
205DSA_new 213 EXIST::FUNCTION:DSA
206DSA_print 214 EXIST::FUNCTION:BIO,DSA
207DSA_print_fp 215 EXIST::FUNCTION:DSA,FP_API
208DSA_sign 216 EXIST::FUNCTION:DSA
209DSA_sign_setup 217 EXIST::FUNCTION:DSA
210DSA_size 218 EXIST::FUNCTION:DSA
211DSA_verify 219 EXIST::FUNCTION:DSA
212DSAparams_print 220 EXIST::FUNCTION:BIO,DSA
213DSAparams_print_fp 221 EXIST::FUNCTION:DSA,FP_API
214ERR_clear_error 222 EXIST::FUNCTION:
215ERR_error_string 223 EXIST::FUNCTION:
216ERR_free_strings 224 EXIST::FUNCTION:
217ERR_func_error_string 225 EXIST::FUNCTION:
218ERR_get_err_state_table 226 EXIST::FUNCTION:LHASH
219ERR_get_error 227 EXIST::FUNCTION:
220ERR_get_error_line 228 EXIST::FUNCTION:
221ERR_get_state 229 EXIST::FUNCTION:
222ERR_get_string_table 230 EXIST::FUNCTION:LHASH
223ERR_lib_error_string 231 EXIST::FUNCTION:
224ERR_load_ASN1_strings 232 EXIST::FUNCTION:
225ERR_load_BIO_strings 233 EXIST::FUNCTION:
226ERR_load_BN_strings 234 EXIST::FUNCTION:
227ERR_load_BUF_strings 235 EXIST::FUNCTION:
228ERR_load_CONF_strings 236 EXIST::FUNCTION:
229ERR_load_DH_strings 237 EXIST::FUNCTION:DH
230ERR_load_DSA_strings 238 EXIST::FUNCTION:DSA
231ERR_load_ERR_strings 239 EXIST::FUNCTION:
232ERR_load_EVP_strings 240 EXIST::FUNCTION:
233ERR_load_OBJ_strings 241 EXIST::FUNCTION:
234ERR_load_PEM_strings 242 EXIST::FUNCTION:
235ERR_load_PROXY_strings 243 NOEXIST::FUNCTION:
236ERR_load_RSA_strings 244 EXIST::FUNCTION:RSA
237ERR_load_X509_strings 245 EXIST::FUNCTION:
238ERR_load_crypto_strings 246 EXIST::FUNCTION:
239ERR_load_strings 247 EXIST::FUNCTION:
240ERR_peek_error 248 EXIST::FUNCTION:
241ERR_peek_error_line 249 EXIST::FUNCTION:
242ERR_print_errors 250 EXIST::FUNCTION:BIO
243ERR_print_errors_fp 251 EXIST::FUNCTION:FP_API
244ERR_put_error 252 EXIST::FUNCTION:
245ERR_reason_error_string 253 EXIST::FUNCTION:
246ERR_remove_state 254 EXIST::FUNCTION:
247EVP_BytesToKey 255 EXIST::FUNCTION:
248EVP_CIPHER_CTX_cleanup 256 EXIST::FUNCTION:
249EVP_CipherFinal 257 EXIST::FUNCTION:
250EVP_CipherInit 258 EXIST::FUNCTION:
251EVP_CipherUpdate 259 EXIST::FUNCTION:
252EVP_DecodeBlock 260 EXIST::FUNCTION:
253EVP_DecodeFinal 261 EXIST::FUNCTION:
254EVP_DecodeInit 262 EXIST::FUNCTION:
255EVP_DecodeUpdate 263 EXIST::FUNCTION:
256EVP_DecryptFinal 264 EXIST::FUNCTION:
257EVP_DecryptInit 265 EXIST::FUNCTION:
258EVP_DecryptUpdate 266 EXIST::FUNCTION:
259EVP_DigestFinal 267 EXIST::FUNCTION:
260EVP_DigestInit 268 EXIST::FUNCTION:
261EVP_DigestUpdate 269 EXIST::FUNCTION:
262EVP_EncodeBlock 270 EXIST::FUNCTION:
263EVP_EncodeFinal 271 EXIST::FUNCTION:
264EVP_EncodeInit 272 EXIST::FUNCTION:
265EVP_EncodeUpdate 273 EXIST::FUNCTION:
266EVP_EncryptFinal 274 EXIST::FUNCTION:
267EVP_EncryptInit 275 EXIST::FUNCTION:
268EVP_EncryptUpdate 276 EXIST::FUNCTION:
269EVP_OpenFinal 277 EXIST::FUNCTION:RSA
270EVP_OpenInit 278 EXIST::FUNCTION:RSA
271EVP_PKEY_assign 279 EXIST::FUNCTION:
272EVP_PKEY_copy_parameters 280 EXIST::FUNCTION:
273EVP_PKEY_free 281 EXIST::FUNCTION:
274EVP_PKEY_missing_parameters 282 EXIST::FUNCTION:
275EVP_PKEY_new 283 EXIST::FUNCTION:
276EVP_PKEY_save_parameters 284 EXIST::FUNCTION:
277EVP_PKEY_size 285 EXIST::FUNCTION:
278EVP_PKEY_type 286 EXIST::FUNCTION:
279EVP_SealFinal 287 EXIST::FUNCTION:RSA
280EVP_SealInit 288 EXIST::FUNCTION:RSA
281EVP_SignFinal 289 EXIST::FUNCTION:
282EVP_VerifyFinal 290 EXIST::FUNCTION:
283EVP_add_alias 291 NOEXIST::FUNCTION:
284EVP_add_cipher 292 EXIST::FUNCTION:
285EVP_add_digest 293 EXIST::FUNCTION:
286EVP_bf_cbc 294 EXIST::FUNCTION:BF
287EVP_bf_cfb 295 EXIST::FUNCTION:BF
288EVP_bf_ecb 296 EXIST::FUNCTION:BF
289EVP_bf_ofb 297 EXIST::FUNCTION:BF
290EVP_cleanup 298 EXIST::FUNCTION:
291EVP_des_cbc 299 EXIST::FUNCTION:DES
292EVP_des_cfb 300 EXIST::FUNCTION:DES
293EVP_des_ecb 301 EXIST::FUNCTION:DES
294EVP_des_ede 302 EXIST::FUNCTION:DES
295EVP_des_ede3 303 EXIST::FUNCTION:DES
296EVP_des_ede3_cbc 304 EXIST::FUNCTION:DES
297EVP_des_ede3_cfb 305 EXIST::FUNCTION:DES
298EVP_des_ede3_ofb 306 EXIST::FUNCTION:DES
299EVP_des_ede_cbc 307 EXIST::FUNCTION:DES
300EVP_des_ede_cfb 308 EXIST::FUNCTION:DES
301EVP_des_ede_ofb 309 EXIST::FUNCTION:DES
302EVP_des_ofb 310 EXIST::FUNCTION:DES
303EVP_desx_cbc 311 EXIST::FUNCTION:DES
304EVP_dss 312 EXIST::FUNCTION:DSA,SHA
305EVP_dss1 313 EXIST::FUNCTION:DSA,SHA
306EVP_enc_null 314 EXIST::FUNCTION:
307EVP_get_cipherbyname 315 EXIST::FUNCTION:
308EVP_get_digestbyname 316 EXIST::FUNCTION:
309EVP_get_pw_prompt 317 EXIST::FUNCTION:
310EVP_idea_cbc 318 EXIST::FUNCTION:IDEA
311EVP_idea_cfb 319 EXIST::FUNCTION:IDEA
312EVP_idea_ecb 320 EXIST::FUNCTION:IDEA
313EVP_idea_ofb 321 EXIST::FUNCTION:IDEA
314EVP_md2 322 EXIST::FUNCTION:MD2
315EVP_md5 323 EXIST::FUNCTION:MD5
316EVP_md_null 324 EXIST::FUNCTION:
317EVP_rc2_cbc 325 EXIST::FUNCTION:RC2
318EVP_rc2_cfb 326 EXIST::FUNCTION:RC2
319EVP_rc2_ecb 327 EXIST::FUNCTION:RC2
320EVP_rc2_ofb 328 EXIST::FUNCTION:RC2
321EVP_rc4 329 EXIST::FUNCTION:RC4
322EVP_read_pw_string 330 EXIST::FUNCTION:
323EVP_set_pw_prompt 331 EXIST::FUNCTION:
324EVP_sha 332 EXIST::FUNCTION:SHA
325EVP_sha1 333 EXIST::FUNCTION:SHA
326MD2 334 EXIST::FUNCTION:MD2
327MD2_Final 335 EXIST::FUNCTION:MD2
328MD2_Init 336 EXIST::FUNCTION:MD2
329MD2_Update 337 EXIST::FUNCTION:MD2
330MD2_options 338 EXIST::FUNCTION:MD2
331MD5 339 EXIST::FUNCTION:MD5
332MD5_Final 340 EXIST::FUNCTION:MD5
333MD5_Init 341 EXIST::FUNCTION:MD5
334MD5_Update 342 EXIST::FUNCTION:MD5
335MDC2 343 EXIST::FUNCTION:MDC2
336MDC2_Final 344 EXIST::FUNCTION:MDC2
337MDC2_Init 345 EXIST::FUNCTION:MDC2
338MDC2_Update 346 EXIST::FUNCTION:MDC2
339NETSCAPE_SPKAC_free 347 EXIST::FUNCTION:
340NETSCAPE_SPKAC_new 348 EXIST::FUNCTION:
341NETSCAPE_SPKI_free 349 EXIST::FUNCTION:
342NETSCAPE_SPKI_new 350 EXIST::FUNCTION:
343NETSCAPE_SPKI_sign 351 EXIST::FUNCTION:EVP
344NETSCAPE_SPKI_verify 352 EXIST::FUNCTION:EVP
345OBJ_add_object 353 EXIST::FUNCTION:
346OBJ_bsearch 354 EXIST::FUNCTION:
347OBJ_cleanup 355 EXIST::FUNCTION:
348OBJ_cmp 356 EXIST::FUNCTION:
349OBJ_create 357 EXIST::FUNCTION:
350OBJ_dup 358 EXIST::FUNCTION:
351OBJ_ln2nid 359 EXIST::FUNCTION:
352OBJ_new_nid 360 EXIST::FUNCTION:
353OBJ_nid2ln 361 EXIST::FUNCTION:
354OBJ_nid2obj 362 EXIST::FUNCTION:
355OBJ_nid2sn 363 EXIST::FUNCTION:
356OBJ_obj2nid 364 EXIST::FUNCTION:
357OBJ_sn2nid 365 EXIST::FUNCTION:
358OBJ_txt2nid 366 EXIST::FUNCTION:
359PEM_ASN1_read 367 EXIST:!WIN16:FUNCTION:
360PEM_ASN1_read_bio 368 EXIST::FUNCTION:BIO
361PEM_ASN1_write 369 EXIST:!WIN16:FUNCTION:
362PEM_ASN1_write_bio 370 EXIST::FUNCTION:BIO
363PEM_SealFinal 371 EXIST::FUNCTION:RSA
364PEM_SealInit 372 EXIST::FUNCTION:RSA
365PEM_SealUpdate 373 EXIST::FUNCTION:RSA
366PEM_SignFinal 374 EXIST::FUNCTION:
367PEM_SignInit 375 EXIST::FUNCTION:
368PEM_SignUpdate 376 EXIST::FUNCTION:
369PEM_X509_INFO_read 377 EXIST:!WIN16:FUNCTION:
370PEM_X509_INFO_read_bio 378 EXIST::FUNCTION:BIO
371PEM_X509_INFO_write_bio 379 EXIST::FUNCTION:BIO
372PEM_dek_info 380 EXIST::FUNCTION:
373PEM_do_header 381 EXIST::FUNCTION:
374PEM_get_EVP_CIPHER_INFO 382 EXIST::FUNCTION:
375PEM_proc_type 383 EXIST::FUNCTION:
376PEM_read 384 EXIST:!WIN16:FUNCTION:
377PEM_read_DHparams 385 EXIST:!WIN16:FUNCTION:DH
378PEM_read_DSAPrivateKey 386 EXIST:!WIN16:FUNCTION:DSA
379PEM_read_DSAparams 387 EXIST:!WIN16:FUNCTION:DSA
380PEM_read_PKCS7 388 EXIST:!WIN16:FUNCTION:
381PEM_read_PrivateKey 389 EXIST:!WIN16:FUNCTION:
382PEM_read_RSAPrivateKey 390 EXIST:!WIN16:FUNCTION:RSA
383PEM_read_X509 391 EXIST:!WIN16:FUNCTION:
384PEM_read_X509_CRL 392 EXIST:!WIN16:FUNCTION:
385PEM_read_X509_REQ 393 EXIST:!WIN16:FUNCTION:
386PEM_read_bio 394 EXIST::FUNCTION:BIO
387PEM_read_bio_DHparams 395 EXIST::FUNCTION:DH
388PEM_read_bio_DSAPrivateKey 396 EXIST::FUNCTION:DSA
389PEM_read_bio_DSAparams 397 EXIST::FUNCTION:DSA
390PEM_read_bio_PKCS7 398 EXIST::FUNCTION:
391PEM_read_bio_PrivateKey 399 EXIST::FUNCTION:
392PEM_read_bio_RSAPrivateKey 400 EXIST::FUNCTION:RSA
393PEM_read_bio_X509 401 EXIST::FUNCTION:
394PEM_read_bio_X509_CRL 402 EXIST::FUNCTION:
395PEM_read_bio_X509_REQ 403 EXIST::FUNCTION:
396PEM_write 404 EXIST:!WIN16:FUNCTION:
397PEM_write_DHparams 405 EXIST:!WIN16:FUNCTION:DH
398PEM_write_DSAPrivateKey 406 EXIST:!WIN16:FUNCTION:DSA
399PEM_write_DSAparams 407 EXIST:!WIN16:FUNCTION:DSA
400PEM_write_PKCS7 408 EXIST:!WIN16:FUNCTION:
401PEM_write_PrivateKey 409 EXIST:!WIN16:FUNCTION:
402PEM_write_RSAPrivateKey 410 EXIST:!WIN16:FUNCTION:RSA
403PEM_write_X509 411 EXIST:!WIN16:FUNCTION:
404PEM_write_X509_CRL 412 EXIST:!WIN16:FUNCTION:
405PEM_write_X509_REQ 413 EXIST:!WIN16:FUNCTION:
406PEM_write_bio 414 EXIST::FUNCTION:BIO
407PEM_write_bio_DHparams 415 EXIST::FUNCTION:DH
408PEM_write_bio_DSAPrivateKey 416 EXIST::FUNCTION:DSA
409PEM_write_bio_DSAparams 417 EXIST::FUNCTION:DSA
410PEM_write_bio_PKCS7 418 EXIST::FUNCTION:
411PEM_write_bio_PrivateKey 419 EXIST::FUNCTION:
412PEM_write_bio_RSAPrivateKey 420 EXIST::FUNCTION:RSA
413PEM_write_bio_X509 421 EXIST::FUNCTION:
414PEM_write_bio_X509_CRL 422 EXIST::FUNCTION:
415PEM_write_bio_X509_REQ 423 EXIST::FUNCTION:
416PKCS7_DIGEST_free 424 EXIST::FUNCTION:
417PKCS7_DIGEST_new 425 EXIST::FUNCTION:
418PKCS7_ENCRYPT_free 426 EXIST::FUNCTION:
419PKCS7_ENCRYPT_new 427 EXIST::FUNCTION:
420PKCS7_ENC_CONTENT_free 428 EXIST::FUNCTION:
421PKCS7_ENC_CONTENT_new 429 EXIST::FUNCTION:
422PKCS7_ENVELOPE_free 430 EXIST::FUNCTION:
423PKCS7_ENVELOPE_new 431 EXIST::FUNCTION:
424PKCS7_ISSUER_AND_SERIAL_digest 432 EXIST::FUNCTION:
425PKCS7_ISSUER_AND_SERIAL_free 433 EXIST::FUNCTION:
426PKCS7_ISSUER_AND_SERIAL_new 434 EXIST::FUNCTION:
427PKCS7_RECIP_INFO_free 435 EXIST::FUNCTION:
428PKCS7_RECIP_INFO_new 436 EXIST::FUNCTION:
429PKCS7_SIGNED_free 437 EXIST::FUNCTION:
430PKCS7_SIGNED_new 438 EXIST::FUNCTION:
431PKCS7_SIGNER_INFO_free 439 EXIST::FUNCTION:
432PKCS7_SIGNER_INFO_new 440 EXIST::FUNCTION:
433PKCS7_SIGN_ENVELOPE_free 441 EXIST::FUNCTION:
434PKCS7_SIGN_ENVELOPE_new 442 EXIST::FUNCTION:
435PKCS7_dup 443 EXIST::FUNCTION:
436PKCS7_free 444 EXIST::FUNCTION:
437PKCS7_new 445 EXIST::FUNCTION:
438PROXY_ENTRY_add_noproxy 446 NOEXIST::FUNCTION:
439PROXY_ENTRY_clear_noproxy 447 NOEXIST::FUNCTION:
440PROXY_ENTRY_free 448 NOEXIST::FUNCTION:
441PROXY_ENTRY_get_noproxy 449 NOEXIST::FUNCTION:
442PROXY_ENTRY_new 450 NOEXIST::FUNCTION:
443PROXY_ENTRY_set_server 451 NOEXIST::FUNCTION:
444PROXY_add_noproxy 452 NOEXIST::FUNCTION:
445PROXY_add_server 453 NOEXIST::FUNCTION:
446PROXY_check_by_host 454 NOEXIST::FUNCTION:
447PROXY_check_url 455 NOEXIST::FUNCTION:
448PROXY_clear_noproxy 456 NOEXIST::FUNCTION:
449PROXY_free 457 NOEXIST::FUNCTION:
450PROXY_get_noproxy 458 NOEXIST::FUNCTION:
451PROXY_get_proxies 459 NOEXIST::FUNCTION:
452PROXY_get_proxy_entry 460 NOEXIST::FUNCTION:
453PROXY_load_conf 461 NOEXIST::FUNCTION:
454PROXY_new 462 NOEXIST::FUNCTION:
455PROXY_print 463 NOEXIST::FUNCTION:
456RAND_bytes 464 EXIST::FUNCTION:
457RAND_cleanup 465 EXIST::FUNCTION:
458RAND_file_name 466 EXIST::FUNCTION:
459RAND_load_file 467 EXIST::FUNCTION:
460RAND_screen 468 EXIST:WIN32:FUNCTION:
461RAND_seed 469 EXIST::FUNCTION:
462RAND_write_file 470 EXIST::FUNCTION:
463RC2_cbc_encrypt 471 EXIST::FUNCTION:RC2
464RC2_cfb64_encrypt 472 EXIST::FUNCTION:RC2
465RC2_ecb_encrypt 473 EXIST::FUNCTION:RC2
466RC2_encrypt 474 EXIST::FUNCTION:RC2
467RC2_ofb64_encrypt 475 EXIST::FUNCTION:RC2
468RC2_set_key 476 EXIST::FUNCTION:RC2
469RC4 477 EXIST::FUNCTION:RC4
470RC4_options 478 EXIST::FUNCTION:RC4
471RC4_set_key 479 EXIST::FUNCTION:RC4
472RSAPrivateKey_asn1_meth 480 EXIST::FUNCTION:RSA
473RSAPrivateKey_dup 481 EXIST::FUNCTION:RSA
474RSAPublicKey_dup 482 EXIST::FUNCTION:RSA
475RSA_PKCS1_SSLeay 483 EXIST::FUNCTION:RSA
476RSA_free 484 EXIST::FUNCTION:RSA
477RSA_generate_key 485 EXIST::FUNCTION:RSA
478RSA_new 486 EXIST::FUNCTION:RSA
479RSA_new_method 487 EXIST::FUNCTION:RSA
480RSA_print 488 EXIST::FUNCTION:BIO,RSA
481RSA_print_fp 489 EXIST::FUNCTION:FP_API,RSA
482RSA_private_decrypt 490 EXIST::FUNCTION:RSA
483RSA_private_encrypt 491 EXIST::FUNCTION:RSA
484RSA_public_decrypt 492 EXIST::FUNCTION:RSA
485RSA_public_encrypt 493 EXIST::FUNCTION:RSA
486RSA_set_default_method 494 EXIST::FUNCTION:RSA
487RSA_sign 495 EXIST::FUNCTION:RSA
488RSA_sign_ASN1_OCTET_STRING 496 EXIST::FUNCTION:RSA
489RSA_size 497 EXIST::FUNCTION:RSA
490RSA_verify 498 EXIST::FUNCTION:RSA
491RSA_verify_ASN1_OCTET_STRING 499 EXIST::FUNCTION:RSA
492SHA 500 EXIST::FUNCTION:SHA,SHA0
493SHA1 501 EXIST::FUNCTION:SHA,SHA1
494SHA1_Final 502 EXIST::FUNCTION:SHA,SHA1
495SHA1_Init 503 EXIST::FUNCTION:SHA,SHA1
496SHA1_Update 504 EXIST::FUNCTION:SHA,SHA1
497SHA_Final 505 EXIST::FUNCTION:SHA,SHA0
498SHA_Init 506 EXIST::FUNCTION:SHA,SHA0
499SHA_Update 507 EXIST::FUNCTION:SHA,SHA0
500OpenSSL_add_all_algorithms 508 NOEXIST::FUNCTION:
501OpenSSL_add_all_ciphers 509 EXIST::FUNCTION:
502OpenSSL_add_all_digests 510 EXIST::FUNCTION:
503TXT_DB_create_index 511 EXIST::FUNCTION:
504TXT_DB_free 512 EXIST::FUNCTION:
505TXT_DB_get_by_index 513 EXIST::FUNCTION:
506TXT_DB_insert 514 EXIST::FUNCTION:
507TXT_DB_read 515 EXIST::FUNCTION:BIO
508TXT_DB_write 516 EXIST::FUNCTION:BIO
509X509_ALGOR_free 517 EXIST::FUNCTION:
510X509_ALGOR_new 518 EXIST::FUNCTION:
511X509_ATTRIBUTE_free 519 EXIST::FUNCTION:
512X509_ATTRIBUTE_new 520 EXIST::FUNCTION:
513X509_CINF_free 521 EXIST::FUNCTION:
514X509_CINF_new 522 EXIST::FUNCTION:
515X509_CRL_INFO_free 523 EXIST::FUNCTION:
516X509_CRL_INFO_new 524 EXIST::FUNCTION:
517X509_CRL_add_ext 525 EXIST::FUNCTION:
518X509_CRL_cmp 526 EXIST::FUNCTION:
519X509_CRL_delete_ext 527 EXIST::FUNCTION:
520X509_CRL_dup 528 EXIST::FUNCTION:
521X509_CRL_free 529 EXIST::FUNCTION:
522X509_CRL_get_ext 530 EXIST::FUNCTION:
523X509_CRL_get_ext_by_NID 531 EXIST::FUNCTION:
524X509_CRL_get_ext_by_OBJ 532 EXIST::FUNCTION:
525X509_CRL_get_ext_by_critical 533 EXIST::FUNCTION:
526X509_CRL_get_ext_count 534 EXIST::FUNCTION:
527X509_CRL_new 535 EXIST::FUNCTION:
528X509_CRL_sign 536 EXIST::FUNCTION:EVP
529X509_CRL_verify 537 EXIST::FUNCTION:EVP
530X509_EXTENSION_create_by_NID 538 EXIST::FUNCTION:
531X509_EXTENSION_create_by_OBJ 539 EXIST::FUNCTION:
532X509_EXTENSION_dup 540 EXIST::FUNCTION:
533X509_EXTENSION_free 541 EXIST::FUNCTION:
534X509_EXTENSION_get_critical 542 EXIST::FUNCTION:
535X509_EXTENSION_get_data 543 EXIST::FUNCTION:
536X509_EXTENSION_get_object 544 EXIST::FUNCTION:
537X509_EXTENSION_new 545 EXIST::FUNCTION:
538X509_EXTENSION_set_critical 546 EXIST::FUNCTION:
539X509_EXTENSION_set_data 547 EXIST::FUNCTION:
540X509_EXTENSION_set_object 548 EXIST::FUNCTION:
541X509_INFO_free 549 EXIST::FUNCTION:EVP
542X509_INFO_new 550 EXIST::FUNCTION:EVP
543X509_LOOKUP_by_alias 551 EXIST::FUNCTION:
544X509_LOOKUP_by_fingerprint 552 EXIST::FUNCTION:
545X509_LOOKUP_by_issuer_serial 553 EXIST::FUNCTION:
546X509_LOOKUP_by_subject 554 EXIST::FUNCTION:
547X509_LOOKUP_ctrl 555 EXIST::FUNCTION:
548X509_LOOKUP_file 556 EXIST::FUNCTION:
549X509_LOOKUP_free 557 EXIST::FUNCTION:
550X509_LOOKUP_hash_dir 558 EXIST::FUNCTION:
551X509_LOOKUP_init 559 EXIST::FUNCTION:
552X509_LOOKUP_new 560 EXIST::FUNCTION:
553X509_LOOKUP_shutdown 561 EXIST::FUNCTION:
554X509_NAME_ENTRY_create_by_NID 562 EXIST::FUNCTION:
555X509_NAME_ENTRY_create_by_OBJ 563 EXIST::FUNCTION:
556X509_NAME_ENTRY_dup 564 EXIST::FUNCTION:
557X509_NAME_ENTRY_free 565 EXIST::FUNCTION:
558X509_NAME_ENTRY_get_data 566 EXIST::FUNCTION:
559X509_NAME_ENTRY_get_object 567 EXIST::FUNCTION:
560X509_NAME_ENTRY_new 568 EXIST::FUNCTION:
561X509_NAME_ENTRY_set_data 569 EXIST::FUNCTION:
562X509_NAME_ENTRY_set_object 570 EXIST::FUNCTION:
563X509_NAME_add_entry 571 EXIST::FUNCTION:
564X509_NAME_cmp 572 EXIST::FUNCTION:
565X509_NAME_delete_entry 573 EXIST::FUNCTION:
566X509_NAME_digest 574 EXIST::FUNCTION:EVP
567X509_NAME_dup 575 EXIST::FUNCTION:
568X509_NAME_entry_count 576 EXIST::FUNCTION:
569X509_NAME_free 577 EXIST::FUNCTION:
570X509_NAME_get_entry 578 EXIST::FUNCTION:
571X509_NAME_get_index_by_NID 579 EXIST::FUNCTION:
572X509_NAME_get_index_by_OBJ 580 EXIST::FUNCTION:
573X509_NAME_get_text_by_NID 581 EXIST::FUNCTION:
574X509_NAME_get_text_by_OBJ 582 EXIST::FUNCTION:
575X509_NAME_hash 583 EXIST::FUNCTION:
576X509_NAME_new 584 EXIST::FUNCTION:
577X509_NAME_oneline 585 EXIST::FUNCTION:EVP
578X509_NAME_print 586 EXIST::FUNCTION:BIO
579X509_NAME_set 587 EXIST::FUNCTION:
580X509_OBJECT_free_contents 588 EXIST::FUNCTION:
581X509_OBJECT_retrieve_by_subject 589 EXIST::FUNCTION:
582X509_OBJECT_up_ref_count 590 EXIST::FUNCTION:
583X509_PKEY_free 591 EXIST::FUNCTION:
584X509_PKEY_new 592 EXIST::FUNCTION:
585X509_PUBKEY_free 593 EXIST::FUNCTION:
586X509_PUBKEY_get 594 EXIST::FUNCTION:
587X509_PUBKEY_new 595 EXIST::FUNCTION:
588X509_PUBKEY_set 596 EXIST::FUNCTION:
589X509_REQ_INFO_free 597 EXIST::FUNCTION:
590X509_REQ_INFO_new 598 EXIST::FUNCTION:
591X509_REQ_dup 599 EXIST::FUNCTION:
592X509_REQ_free 600 EXIST::FUNCTION:
593X509_REQ_get_pubkey 601 EXIST::FUNCTION:
594X509_REQ_new 602 EXIST::FUNCTION:
595X509_REQ_print 603 EXIST::FUNCTION:BIO
596X509_REQ_print_fp 604 EXIST::FUNCTION:FP_API
597X509_REQ_set_pubkey 605 EXIST::FUNCTION:
598X509_REQ_set_subject_name 606 EXIST::FUNCTION:
599X509_REQ_set_version 607 EXIST::FUNCTION:
600X509_REQ_sign 608 EXIST::FUNCTION:EVP
601X509_REQ_to_X509 609 EXIST::FUNCTION:
602X509_REQ_verify 610 EXIST::FUNCTION:EVP
603X509_REVOKED_add_ext 611 EXIST::FUNCTION:
604X509_REVOKED_delete_ext 612 EXIST::FUNCTION:
605X509_REVOKED_free 613 EXIST::FUNCTION:
606X509_REVOKED_get_ext 614 EXIST::FUNCTION:
607X509_REVOKED_get_ext_by_NID 615 EXIST::FUNCTION:
608X509_REVOKED_get_ext_by_OBJ 616 EXIST::FUNCTION:
609X509_REVOKED_get_ext_by_critical 617 EXIST:!VMS:FUNCTION:
610X509_REVOKED_get_ext_by_critic 617 EXIST:VMS:FUNCTION:
611X509_REVOKED_get_ext_count 618 EXIST::FUNCTION:
612X509_REVOKED_new 619 EXIST::FUNCTION:
613X509_SIG_free 620 EXIST::FUNCTION:
614X509_SIG_new 621 EXIST::FUNCTION:
615X509_STORE_CTX_cleanup 622 EXIST::FUNCTION:
616X509_STORE_CTX_init 623 EXIST::FUNCTION:
617X509_STORE_add_cert 624 EXIST::FUNCTION:
618X509_STORE_add_lookup 625 EXIST::FUNCTION:
619X509_STORE_free 626 EXIST::FUNCTION:
620X509_STORE_get_by_subject 627 EXIST::FUNCTION:
621X509_STORE_load_locations 628 EXIST::FUNCTION:STDIO
622X509_STORE_new 629 EXIST::FUNCTION:
623X509_STORE_set_default_paths 630 EXIST::FUNCTION:STDIO
624X509_VAL_free 631 EXIST::FUNCTION:
625X509_VAL_new 632 EXIST::FUNCTION:
626X509_add_ext 633 EXIST::FUNCTION:
627X509_asn1_meth 634 EXIST::FUNCTION:
628X509_certificate_type 635 EXIST::FUNCTION:
629X509_check_private_key 636 EXIST::FUNCTION:
630X509_cmp_current_time 637 EXIST::FUNCTION:
631X509_delete_ext 638 EXIST::FUNCTION:
632X509_digest 639 EXIST::FUNCTION:EVP
633X509_dup 640 EXIST::FUNCTION:
634X509_free 641 EXIST::FUNCTION:
635X509_get_default_cert_area 642 EXIST::FUNCTION:
636X509_get_default_cert_dir 643 EXIST::FUNCTION:
637X509_get_default_cert_dir_env 644 EXIST::FUNCTION:
638X509_get_default_cert_file 645 EXIST::FUNCTION:
639X509_get_default_cert_file_env 646 EXIST::FUNCTION:
640X509_get_default_private_dir 647 EXIST::FUNCTION:
641X509_get_ext 648 EXIST::FUNCTION:
642X509_get_ext_by_NID 649 EXIST::FUNCTION:
643X509_get_ext_by_OBJ 650 EXIST::FUNCTION:
644X509_get_ext_by_critical 651 EXIST::FUNCTION:
645X509_get_ext_count 652 EXIST::FUNCTION:
646X509_get_issuer_name 653 EXIST::FUNCTION:
647X509_get_pubkey 654 EXIST::FUNCTION:
648X509_get_pubkey_parameters 655 EXIST::FUNCTION:
649X509_get_serialNumber 656 EXIST::FUNCTION:
650X509_get_subject_name 657 EXIST::FUNCTION:
651X509_gmtime_adj 658 EXIST::FUNCTION:
652X509_issuer_and_serial_cmp 659 EXIST::FUNCTION:
653X509_issuer_and_serial_hash 660 EXIST::FUNCTION:
654X509_issuer_name_cmp 661 EXIST::FUNCTION:
655X509_issuer_name_hash 662 EXIST::FUNCTION:
656X509_load_cert_file 663 EXIST::FUNCTION:STDIO
657X509_new 664 EXIST::FUNCTION:
658X509_print 665 EXIST::FUNCTION:BIO
659X509_print_fp 666 EXIST::FUNCTION:FP_API
660X509_set_issuer_name 667 EXIST::FUNCTION:
661X509_set_notAfter 668 EXIST::FUNCTION:
662X509_set_notBefore 669 EXIST::FUNCTION:
663X509_set_pubkey 670 EXIST::FUNCTION:
664X509_set_serialNumber 671 EXIST::FUNCTION:
665X509_set_subject_name 672 EXIST::FUNCTION:
666X509_set_version 673 EXIST::FUNCTION:
667X509_sign 674 EXIST::FUNCTION:EVP
668X509_subject_name_cmp 675 EXIST::FUNCTION:
669X509_subject_name_hash 676 EXIST::FUNCTION:
670X509_to_X509_REQ 677 EXIST::FUNCTION:
671X509_verify 678 EXIST::FUNCTION:EVP
672X509_verify_cert 679 EXIST::FUNCTION:
673X509_verify_cert_error_string 680 EXIST::FUNCTION:
674X509v3_add_ext 681 EXIST::FUNCTION:
675X509v3_add_extension 682 NOEXIST::FUNCTION:
676X509v3_add_netscape_extensions 683 NOEXIST::FUNCTION:
677X509v3_add_standard_extensions 684 NOEXIST::FUNCTION:
678X509v3_cleanup_extensions 685 NOEXIST::FUNCTION:
679X509v3_data_type_by_NID 686 NOEXIST::FUNCTION:
680X509v3_data_type_by_OBJ 687 NOEXIST::FUNCTION:
681X509v3_delete_ext 688 EXIST::FUNCTION:
682X509v3_get_ext 689 EXIST::FUNCTION:
683X509v3_get_ext_by_NID 690 EXIST::FUNCTION:
684X509v3_get_ext_by_OBJ 691 EXIST::FUNCTION:
685X509v3_get_ext_by_critical 692 EXIST::FUNCTION:
686X509v3_get_ext_count 693 EXIST::FUNCTION:
687X509v3_pack_string 694 NOEXIST::FUNCTION:
688X509v3_pack_type_by_NID 695 NOEXIST::FUNCTION:
689X509v3_pack_type_by_OBJ 696 NOEXIST::FUNCTION:
690X509v3_unpack_string 697 NOEXIST::FUNCTION:
691_des_crypt 698 NOEXIST::FUNCTION:
692a2d_ASN1_OBJECT 699 EXIST::FUNCTION:
693a2i_ASN1_INTEGER 700 EXIST::FUNCTION:BIO
694a2i_ASN1_STRING 701 EXIST::FUNCTION:BIO
695asn1_Finish 702 EXIST::FUNCTION:
696asn1_GetSequence 703 EXIST::FUNCTION:
697bn_div_words 704 EXIST::FUNCTION:
698bn_expand2 705 EXIST::FUNCTION:
699bn_mul_add_words 706 EXIST::FUNCTION:
700bn_mul_words 707 EXIST::FUNCTION:
701BN_uadd 708 EXIST::FUNCTION:
702BN_usub 709 EXIST::FUNCTION:
703bn_sqr_words 710 EXIST::FUNCTION:
704_ossl_old_crypt 711 EXIST:!NeXT,!PERL5:FUNCTION:DES
705d2i_ASN1_BIT_STRING 712 EXIST::FUNCTION:
706d2i_ASN1_BOOLEAN 713 EXIST::FUNCTION:
707d2i_ASN1_HEADER 714 EXIST::FUNCTION:
708d2i_ASN1_IA5STRING 715 EXIST::FUNCTION:
709d2i_ASN1_INTEGER 716 EXIST::FUNCTION:
710d2i_ASN1_OBJECT 717 EXIST::FUNCTION:
711d2i_ASN1_OCTET_STRING 718 EXIST::FUNCTION:
712d2i_ASN1_PRINTABLE 719 EXIST::FUNCTION:
713d2i_ASN1_PRINTABLESTRING 720 EXIST::FUNCTION:
714d2i_ASN1_SET 721 EXIST::FUNCTION:
715d2i_ASN1_T61STRING 722 EXIST::FUNCTION:
716d2i_ASN1_TYPE 723 EXIST::FUNCTION:
717d2i_ASN1_UTCTIME 724 EXIST::FUNCTION:
718d2i_ASN1_bytes 725 EXIST::FUNCTION:
719d2i_ASN1_type_bytes 726 EXIST::FUNCTION:
720d2i_DHparams 727 EXIST::FUNCTION:DH
721d2i_DSAPrivateKey 728 EXIST::FUNCTION:DSA
722d2i_DSAPrivateKey_bio 729 EXIST::FUNCTION:BIO,DSA
723d2i_DSAPrivateKey_fp 730 EXIST::FUNCTION:DSA,FP_API
724d2i_DSAPublicKey 731 EXIST::FUNCTION:DSA
725d2i_DSAparams 732 EXIST::FUNCTION:DSA
726d2i_NETSCAPE_SPKAC 733 EXIST::FUNCTION:
727d2i_NETSCAPE_SPKI 734 EXIST::FUNCTION:
728d2i_Netscape_RSA 735 EXIST::FUNCTION:RSA
729d2i_PKCS7 736 EXIST::FUNCTION:
730d2i_PKCS7_DIGEST 737 EXIST::FUNCTION:
731d2i_PKCS7_ENCRYPT 738 EXIST::FUNCTION:
732d2i_PKCS7_ENC_CONTENT 739 EXIST::FUNCTION:
733d2i_PKCS7_ENVELOPE 740 EXIST::FUNCTION:
734d2i_PKCS7_ISSUER_AND_SERIAL 741 EXIST::FUNCTION:
735d2i_PKCS7_RECIP_INFO 742 EXIST::FUNCTION:
736d2i_PKCS7_SIGNED 743 EXIST::FUNCTION:
737d2i_PKCS7_SIGNER_INFO 744 EXIST::FUNCTION:
738d2i_PKCS7_SIGN_ENVELOPE 745 EXIST::FUNCTION:
739d2i_PKCS7_bio 746 EXIST::FUNCTION:
740d2i_PKCS7_fp 747 EXIST::FUNCTION:FP_API
741d2i_PrivateKey 748 EXIST::FUNCTION:
742d2i_PublicKey 749 EXIST::FUNCTION:
743d2i_RSAPrivateKey 750 EXIST::FUNCTION:RSA
744d2i_RSAPrivateKey_bio 751 EXIST::FUNCTION:BIO,RSA
745d2i_RSAPrivateKey_fp 752 EXIST::FUNCTION:FP_API,RSA
746d2i_RSAPublicKey 753 EXIST::FUNCTION:RSA
747d2i_X509 754 EXIST::FUNCTION:
748d2i_X509_ALGOR 755 EXIST::FUNCTION:
749d2i_X509_ATTRIBUTE 756 EXIST::FUNCTION:
750d2i_X509_CINF 757 EXIST::FUNCTION:
751d2i_X509_CRL 758 EXIST::FUNCTION:
752d2i_X509_CRL_INFO 759 EXIST::FUNCTION:
753d2i_X509_CRL_bio 760 EXIST::FUNCTION:BIO
754d2i_X509_CRL_fp 761 EXIST::FUNCTION:FP_API
755d2i_X509_EXTENSION 762 EXIST::FUNCTION:
756d2i_X509_NAME 763 EXIST::FUNCTION:
757d2i_X509_NAME_ENTRY 764 EXIST::FUNCTION:
758d2i_X509_PKEY 765 EXIST::FUNCTION:
759d2i_X509_PUBKEY 766 EXIST::FUNCTION:
760d2i_X509_REQ 767 EXIST::FUNCTION:
761d2i_X509_REQ_INFO 768 EXIST::FUNCTION:
762d2i_X509_REQ_bio 769 EXIST::FUNCTION:BIO
763d2i_X509_REQ_fp 770 EXIST::FUNCTION:FP_API
764d2i_X509_REVOKED 771 EXIST::FUNCTION:
765d2i_X509_SIG 772 EXIST::FUNCTION:
766d2i_X509_VAL 773 EXIST::FUNCTION:
767d2i_X509_bio 774 EXIST::FUNCTION:BIO
768d2i_X509_fp 775 EXIST::FUNCTION:FP_API
769DES_cbc_cksum 777 EXIST::FUNCTION:DES
770DES_cbc_encrypt 778 EXIST::FUNCTION:DES
771DES_cblock_print_file 779 NOEXIST::FUNCTION:
772DES_cfb64_encrypt 780 EXIST::FUNCTION:DES
773DES_cfb_encrypt 781 EXIST::FUNCTION:DES
774DES_decrypt3 782 EXIST::FUNCTION:DES
775DES_ecb3_encrypt 783 EXIST::FUNCTION:DES
776DES_ecb_encrypt 784 EXIST::FUNCTION:DES
777DES_ede3_cbc_encrypt 785 EXIST::FUNCTION:DES
778DES_ede3_cfb64_encrypt 786 EXIST::FUNCTION:DES
779DES_ede3_ofb64_encrypt 787 EXIST::FUNCTION:DES
780DES_enc_read 788 EXIST::FUNCTION:DES
781DES_enc_write 789 EXIST::FUNCTION:DES
782DES_encrypt1 790 EXIST::FUNCTION:DES
783DES_encrypt2 791 EXIST::FUNCTION:DES
784DES_encrypt3 792 EXIST::FUNCTION:DES
785DES_fcrypt 793 EXIST::FUNCTION:DES
786DES_is_weak_key 794 EXIST::FUNCTION:DES
787DES_key_sched 795 EXIST::FUNCTION:DES
788DES_ncbc_encrypt 796 EXIST::FUNCTION:DES
789DES_ofb64_encrypt 797 EXIST::FUNCTION:DES
790DES_ofb_encrypt 798 EXIST::FUNCTION:DES
791DES_options 799 EXIST::FUNCTION:DES
792DES_pcbc_encrypt 800 EXIST::FUNCTION:DES
793DES_quad_cksum 801 EXIST::FUNCTION:DES
794DES_random_key 802 EXIST::FUNCTION:DES
795_ossl_old_des_random_seed 803 EXIST::FUNCTION:DES
796_ossl_old_des_read_2passwords 804 EXIST::FUNCTION:DES
797_ossl_old_des_read_password 805 EXIST::FUNCTION:DES
798_ossl_old_des_read_pw 806 EXIST::FUNCTION:
799_ossl_old_des_read_pw_string 807 EXIST::FUNCTION:
800DES_set_key 808 EXIST::FUNCTION:DES
801DES_set_odd_parity 809 EXIST::FUNCTION:DES
802DES_string_to_2keys 810 EXIST::FUNCTION:DES
803DES_string_to_key 811 EXIST::FUNCTION:DES
804DES_xcbc_encrypt 812 EXIST::FUNCTION:DES
805DES_xwhite_in2out 813 EXIST::FUNCTION:DES
806fcrypt_body 814 NOEXIST::FUNCTION:
807i2a_ASN1_INTEGER 815 EXIST::FUNCTION:BIO
808i2a_ASN1_OBJECT 816 EXIST::FUNCTION:BIO
809i2a_ASN1_STRING 817 EXIST::FUNCTION:BIO
810i2d_ASN1_BIT_STRING 818 EXIST::FUNCTION:
811i2d_ASN1_BOOLEAN 819 EXIST::FUNCTION:
812i2d_ASN1_HEADER 820 EXIST::FUNCTION:
813i2d_ASN1_IA5STRING 821 EXIST::FUNCTION:
814i2d_ASN1_INTEGER 822 EXIST::FUNCTION:
815i2d_ASN1_OBJECT 823 EXIST::FUNCTION:
816i2d_ASN1_OCTET_STRING 824 EXIST::FUNCTION:
817i2d_ASN1_PRINTABLE 825 EXIST::FUNCTION:
818i2d_ASN1_SET 826 EXIST::FUNCTION:
819i2d_ASN1_TYPE 827 EXIST::FUNCTION:
820i2d_ASN1_UTCTIME 828 EXIST::FUNCTION:
821i2d_ASN1_bytes 829 EXIST::FUNCTION:
822i2d_DHparams 830 EXIST::FUNCTION:DH
823i2d_DSAPrivateKey 831 EXIST::FUNCTION:DSA
824i2d_DSAPrivateKey_bio 832 EXIST::FUNCTION:BIO,DSA
825i2d_DSAPrivateKey_fp 833 EXIST::FUNCTION:DSA,FP_API
826i2d_DSAPublicKey 834 EXIST::FUNCTION:DSA
827i2d_DSAparams 835 EXIST::FUNCTION:DSA
828i2d_NETSCAPE_SPKAC 836 EXIST::FUNCTION:
829i2d_NETSCAPE_SPKI 837 EXIST::FUNCTION:
830i2d_Netscape_RSA 838 EXIST::FUNCTION:RSA
831i2d_PKCS7 839 EXIST::FUNCTION:
832i2d_PKCS7_DIGEST 840 EXIST::FUNCTION:
833i2d_PKCS7_ENCRYPT 841 EXIST::FUNCTION:
834i2d_PKCS7_ENC_CONTENT 842 EXIST::FUNCTION:
835i2d_PKCS7_ENVELOPE 843 EXIST::FUNCTION:
836i2d_PKCS7_ISSUER_AND_SERIAL 844 EXIST::FUNCTION:
837i2d_PKCS7_RECIP_INFO 845 EXIST::FUNCTION:
838i2d_PKCS7_SIGNED 846 EXIST::FUNCTION:
839i2d_PKCS7_SIGNER_INFO 847 EXIST::FUNCTION:
840i2d_PKCS7_SIGN_ENVELOPE 848 EXIST::FUNCTION:
841i2d_PKCS7_bio 849 EXIST::FUNCTION:
842i2d_PKCS7_fp 850 EXIST::FUNCTION:FP_API
843i2d_PrivateKey 851 EXIST::FUNCTION:
844i2d_PublicKey 852 EXIST::FUNCTION:
845i2d_RSAPrivateKey 853 EXIST::FUNCTION:RSA
846i2d_RSAPrivateKey_bio 854 EXIST::FUNCTION:BIO,RSA
847i2d_RSAPrivateKey_fp 855 EXIST::FUNCTION:FP_API,RSA
848i2d_RSAPublicKey 856 EXIST::FUNCTION:RSA
849i2d_X509 857 EXIST::FUNCTION:
850i2d_X509_ALGOR 858 EXIST::FUNCTION:
851i2d_X509_ATTRIBUTE 859 EXIST::FUNCTION:
852i2d_X509_CINF 860 EXIST::FUNCTION:
853i2d_X509_CRL 861 EXIST::FUNCTION:
854i2d_X509_CRL_INFO 862 EXIST::FUNCTION:
855i2d_X509_CRL_bio 863 EXIST::FUNCTION:BIO
856i2d_X509_CRL_fp 864 EXIST::FUNCTION:FP_API
857i2d_X509_EXTENSION 865 EXIST::FUNCTION:
858i2d_X509_NAME 866 EXIST::FUNCTION:
859i2d_X509_NAME_ENTRY 867 EXIST::FUNCTION:
860i2d_X509_PKEY 868 EXIST::FUNCTION:
861i2d_X509_PUBKEY 869 EXIST::FUNCTION:
862i2d_X509_REQ 870 EXIST::FUNCTION:
863i2d_X509_REQ_INFO 871 EXIST::FUNCTION:
864i2d_X509_REQ_bio 872 EXIST::FUNCTION:BIO
865i2d_X509_REQ_fp 873 EXIST::FUNCTION:FP_API
866i2d_X509_REVOKED 874 EXIST::FUNCTION:
867i2d_X509_SIG 875 EXIST::FUNCTION:
868i2d_X509_VAL 876 EXIST::FUNCTION:
869i2d_X509_bio 877 EXIST::FUNCTION:BIO
870i2d_X509_fp 878 EXIST::FUNCTION:FP_API
871idea_cbc_encrypt 879 EXIST::FUNCTION:IDEA
872idea_cfb64_encrypt 880 EXIST::FUNCTION:IDEA
873idea_ecb_encrypt 881 EXIST::FUNCTION:IDEA
874idea_encrypt 882 EXIST::FUNCTION:IDEA
875idea_ofb64_encrypt 883 EXIST::FUNCTION:IDEA
876idea_options 884 EXIST::FUNCTION:IDEA
877idea_set_decrypt_key 885 EXIST::FUNCTION:IDEA
878idea_set_encrypt_key 886 EXIST::FUNCTION:IDEA
879lh_delete 887 EXIST::FUNCTION:
880lh_doall 888 EXIST::FUNCTION:
881lh_doall_arg 889 EXIST::FUNCTION:
882lh_free 890 EXIST::FUNCTION:
883lh_insert 891 EXIST::FUNCTION:
884lh_new 892 EXIST::FUNCTION:
885lh_node_stats 893 EXIST::FUNCTION:FP_API
886lh_node_stats_bio 894 EXIST::FUNCTION:BIO
887lh_node_usage_stats 895 EXIST::FUNCTION:FP_API
888lh_node_usage_stats_bio 896 EXIST::FUNCTION:BIO
889lh_retrieve 897 EXIST::FUNCTION:
890lh_stats 898 EXIST::FUNCTION:FP_API
891lh_stats_bio 899 EXIST::FUNCTION:BIO
892lh_strhash 900 EXIST::FUNCTION:
893sk_delete 901 EXIST::FUNCTION:
894sk_delete_ptr 902 EXIST::FUNCTION:
895sk_dup 903 EXIST::FUNCTION:
896sk_find 904 EXIST::FUNCTION:
897sk_free 905 EXIST::FUNCTION:
898sk_insert 906 EXIST::FUNCTION:
899sk_new 907 EXIST::FUNCTION:
900sk_pop 908 EXIST::FUNCTION:
901sk_pop_free 909 EXIST::FUNCTION:
902sk_push 910 EXIST::FUNCTION:
903sk_set_cmp_func 911 EXIST::FUNCTION:
904sk_shift 912 EXIST::FUNCTION:
905sk_unshift 913 EXIST::FUNCTION:
906sk_zero 914 EXIST::FUNCTION:
907BIO_f_nbio_test 915 EXIST::FUNCTION:
908ASN1_TYPE_get 916 EXIST::FUNCTION:
909ASN1_TYPE_set 917 EXIST::FUNCTION:
910PKCS7_content_free 918 NOEXIST::FUNCTION:
911ERR_load_PKCS7_strings 919 EXIST::FUNCTION:
912X509_find_by_issuer_and_serial 920 EXIST::FUNCTION:
913X509_find_by_subject 921 EXIST::FUNCTION:
914PKCS7_ctrl 927 EXIST::FUNCTION:
915PKCS7_set_type 928 EXIST::FUNCTION:
916PKCS7_set_content 929 EXIST::FUNCTION:
917PKCS7_SIGNER_INFO_set 930 EXIST::FUNCTION:
918PKCS7_add_signer 931 EXIST::FUNCTION:
919PKCS7_add_certificate 932 EXIST::FUNCTION:
920PKCS7_add_crl 933 EXIST::FUNCTION:
921PKCS7_content_new 934 EXIST::FUNCTION:
922PKCS7_dataSign 935 NOEXIST::FUNCTION:
923PKCS7_dataVerify 936 EXIST::FUNCTION:
924PKCS7_dataInit 937 EXIST::FUNCTION:
925PKCS7_add_signature 938 EXIST::FUNCTION:
926PKCS7_cert_from_signer_info 939 EXIST::FUNCTION:
927PKCS7_get_signer_info 940 EXIST::FUNCTION:
928EVP_delete_alias 941 NOEXIST::FUNCTION:
929EVP_mdc2 942 EXIST::FUNCTION:MDC2
930PEM_read_bio_RSAPublicKey 943 EXIST::FUNCTION:RSA
931PEM_write_bio_RSAPublicKey 944 EXIST::FUNCTION:RSA
932d2i_RSAPublicKey_bio 945 EXIST::FUNCTION:BIO,RSA
933i2d_RSAPublicKey_bio 946 EXIST::FUNCTION:BIO,RSA
934PEM_read_RSAPublicKey 947 EXIST:!WIN16:FUNCTION:RSA
935PEM_write_RSAPublicKey 949 EXIST:!WIN16:FUNCTION:RSA
936d2i_RSAPublicKey_fp 952 EXIST::FUNCTION:FP_API,RSA
937i2d_RSAPublicKey_fp 954 EXIST::FUNCTION:FP_API,RSA
938BIO_copy_next_retry 955 EXIST::FUNCTION:
939RSA_flags 956 EXIST::FUNCTION:RSA
940X509_STORE_add_crl 957 EXIST::FUNCTION:
941X509_load_crl_file 958 EXIST::FUNCTION:STDIO
942EVP_rc2_40_cbc 959 EXIST::FUNCTION:RC2
943EVP_rc4_40 960 EXIST::FUNCTION:RC4
944EVP_CIPHER_CTX_init 961 EXIST::FUNCTION:
945HMAC 962 EXIST::FUNCTION:HMAC
946HMAC_Init 963 EXIST::FUNCTION:HMAC
947HMAC_Update 964 EXIST::FUNCTION:HMAC
948HMAC_Final 965 EXIST::FUNCTION:HMAC
949ERR_get_next_error_library 966 EXIST::FUNCTION:
950EVP_PKEY_cmp_parameters 967 EXIST::FUNCTION:
951HMAC_cleanup 968 NOEXIST::FUNCTION:
952BIO_ptr_ctrl 969 EXIST::FUNCTION:
953BIO_new_file_internal 970 EXIST:WIN16:FUNCTION:FP_API
954BIO_new_fp_internal 971 EXIST:WIN16:FUNCTION:FP_API
955BIO_s_file_internal 972 EXIST:WIN16:FUNCTION:FP_API
956BN_BLINDING_convert 973 EXIST::FUNCTION:
957BN_BLINDING_invert 974 EXIST::FUNCTION:
958BN_BLINDING_update 975 EXIST::FUNCTION:
959RSA_blinding_on 977 EXIST::FUNCTION:RSA
960RSA_blinding_off 978 EXIST::FUNCTION:RSA
961i2t_ASN1_OBJECT 979 EXIST::FUNCTION:
962BN_BLINDING_new 980 EXIST::FUNCTION:
963BN_BLINDING_free 981 EXIST::FUNCTION:
964EVP_cast5_cbc 983 EXIST::FUNCTION:CAST
965EVP_cast5_cfb 984 EXIST::FUNCTION:CAST
966EVP_cast5_ecb 985 EXIST::FUNCTION:CAST
967EVP_cast5_ofb 986 EXIST::FUNCTION:CAST
968BF_decrypt 987 EXIST::FUNCTION:BF
969CAST_set_key 988 EXIST::FUNCTION:CAST
970CAST_encrypt 989 EXIST::FUNCTION:CAST
971CAST_decrypt 990 EXIST::FUNCTION:CAST
972CAST_ecb_encrypt 991 EXIST::FUNCTION:CAST
973CAST_cbc_encrypt 992 EXIST::FUNCTION:CAST
974CAST_cfb64_encrypt 993 EXIST::FUNCTION:CAST
975CAST_ofb64_encrypt 994 EXIST::FUNCTION:CAST
976RC2_decrypt 995 EXIST::FUNCTION:RC2
977OBJ_create_objects 997 EXIST::FUNCTION:
978BN_exp 998 EXIST::FUNCTION:
979BN_mul_word 999 EXIST::FUNCTION:
980BN_sub_word 1000 EXIST::FUNCTION:
981BN_dec2bn 1001 EXIST::FUNCTION:
982BN_bn2dec 1002 EXIST::FUNCTION:
983BIO_ghbn_ctrl 1003 EXIST::FUNCTION:
984CRYPTO_free_ex_data 1004 EXIST::FUNCTION:
985CRYPTO_get_ex_data 1005 EXIST::FUNCTION:
986CRYPTO_set_ex_data 1007 EXIST::FUNCTION:
987ERR_load_CRYPTO_strings 1009 EXIST:!OS2,!VMS,!WIN16:FUNCTION:
988ERR_load_CRYPTOlib_strings 1009 EXIST:OS2,VMS,WIN16:FUNCTION:
989EVP_PKEY_bits 1010 EXIST::FUNCTION:
990MD5_Transform 1011 EXIST::FUNCTION:MD5
991SHA1_Transform 1012 EXIST::FUNCTION:SHA,SHA1
992SHA_Transform 1013 EXIST::FUNCTION:SHA,SHA0
993X509_STORE_CTX_get_chain 1014 EXIST::FUNCTION:
994X509_STORE_CTX_get_current_cert 1015 EXIST::FUNCTION:
995X509_STORE_CTX_get_error 1016 EXIST::FUNCTION:
996X509_STORE_CTX_get_error_depth 1017 EXIST::FUNCTION:
997X509_STORE_CTX_get_ex_data 1018 EXIST::FUNCTION:
998X509_STORE_CTX_set_cert 1020 EXIST::FUNCTION:
999X509_STORE_CTX_set_chain 1021 EXIST::FUNCTION:
1000X509_STORE_CTX_set_error 1022 EXIST::FUNCTION:
1001X509_STORE_CTX_set_ex_data 1023 EXIST::FUNCTION:
1002CRYPTO_dup_ex_data 1025 EXIST::FUNCTION:
1003CRYPTO_get_new_lockid 1026 EXIST::FUNCTION:
1004CRYPTO_new_ex_data 1027 EXIST::FUNCTION:
1005RSA_set_ex_data 1028 EXIST::FUNCTION:RSA
1006RSA_get_ex_data 1029 EXIST::FUNCTION:RSA
1007RSA_get_ex_new_index 1030 EXIST::FUNCTION:RSA
1008RSA_padding_add_PKCS1_type_1 1031 EXIST::FUNCTION:RSA
1009RSA_padding_add_PKCS1_type_2 1032 EXIST::FUNCTION:RSA
1010RSA_padding_add_SSLv23 1033 EXIST::FUNCTION:RSA
1011RSA_padding_add_none 1034 EXIST::FUNCTION:RSA
1012RSA_padding_check_PKCS1_type_1 1035 EXIST::FUNCTION:RSA
1013RSA_padding_check_PKCS1_type_2 1036 EXIST::FUNCTION:RSA
1014RSA_padding_check_SSLv23 1037 EXIST::FUNCTION:RSA
1015RSA_padding_check_none 1038 EXIST::FUNCTION:RSA
1016bn_add_words 1039 EXIST::FUNCTION:
1017d2i_Netscape_RSA_2 1040 NOEXIST::FUNCTION:
1018CRYPTO_get_ex_new_index 1041 EXIST::FUNCTION:
1019RIPEMD160_Init 1042 EXIST::FUNCTION:RIPEMD
1020RIPEMD160_Update 1043 EXIST::FUNCTION:RIPEMD
1021RIPEMD160_Final 1044 EXIST::FUNCTION:RIPEMD
1022RIPEMD160 1045 EXIST::FUNCTION:RIPEMD
1023RIPEMD160_Transform 1046 EXIST::FUNCTION:RIPEMD
1024RC5_32_set_key 1047 EXIST::FUNCTION:RC5
1025RC5_32_ecb_encrypt 1048 EXIST::FUNCTION:RC5
1026RC5_32_encrypt 1049 EXIST::FUNCTION:RC5
1027RC5_32_decrypt 1050 EXIST::FUNCTION:RC5
1028RC5_32_cbc_encrypt 1051 EXIST::FUNCTION:RC5
1029RC5_32_cfb64_encrypt 1052 EXIST::FUNCTION:RC5
1030RC5_32_ofb64_encrypt 1053 EXIST::FUNCTION:RC5
1031BN_bn2mpi 1058 EXIST::FUNCTION:
1032BN_mpi2bn 1059 EXIST::FUNCTION:
1033ASN1_BIT_STRING_get_bit 1060 EXIST::FUNCTION:
1034ASN1_BIT_STRING_set_bit 1061 EXIST::FUNCTION:
1035BIO_get_ex_data 1062 EXIST::FUNCTION:
1036BIO_get_ex_new_index 1063 EXIST::FUNCTION:
1037BIO_set_ex_data 1064 EXIST::FUNCTION:
1038X509v3_get_key_usage 1066 NOEXIST::FUNCTION:
1039X509v3_set_key_usage 1067 NOEXIST::FUNCTION:
1040a2i_X509v3_key_usage 1068 NOEXIST::FUNCTION:
1041i2a_X509v3_key_usage 1069 NOEXIST::FUNCTION:
1042EVP_PKEY_decrypt 1070 EXIST::FUNCTION:
1043EVP_PKEY_encrypt 1071 EXIST::FUNCTION:
1044PKCS7_RECIP_INFO_set 1072 EXIST::FUNCTION:
1045PKCS7_add_recipient 1073 EXIST::FUNCTION:
1046PKCS7_add_recipient_info 1074 EXIST::FUNCTION:
1047PKCS7_set_cipher 1075 EXIST::FUNCTION:
1048ASN1_TYPE_get_int_octetstring 1076 EXIST::FUNCTION:
1049ASN1_TYPE_get_octetstring 1077 EXIST::FUNCTION:
1050ASN1_TYPE_set_int_octetstring 1078 EXIST::FUNCTION:
1051ASN1_TYPE_set_octetstring 1079 EXIST::FUNCTION:
1052ASN1_UTCTIME_set_string 1080 EXIST::FUNCTION:
1053ERR_add_error_data 1081 EXIST::FUNCTION:BIO
1054ERR_set_error_data 1082 EXIST::FUNCTION:
1055EVP_CIPHER_asn1_to_param 1083 EXIST::FUNCTION:
1056EVP_CIPHER_param_to_asn1 1084 EXIST::FUNCTION:
1057EVP_CIPHER_get_asn1_iv 1085 EXIST::FUNCTION:
1058EVP_CIPHER_set_asn1_iv 1086 EXIST::FUNCTION:
1059EVP_rc5_32_12_16_cbc 1087 EXIST::FUNCTION:RC5
1060EVP_rc5_32_12_16_cfb 1088 EXIST::FUNCTION:RC5
1061EVP_rc5_32_12_16_ecb 1089 EXIST::FUNCTION:RC5
1062EVP_rc5_32_12_16_ofb 1090 EXIST::FUNCTION:RC5
1063asn1_add_error 1091 EXIST::FUNCTION:
1064d2i_ASN1_BMPSTRING 1092 EXIST::FUNCTION:
1065i2d_ASN1_BMPSTRING 1093 EXIST::FUNCTION:
1066BIO_f_ber 1094 NOEXIST::FUNCTION:
1067BN_init 1095 EXIST::FUNCTION:
1068COMP_CTX_new 1096 EXIST::FUNCTION:
1069COMP_CTX_free 1097 EXIST::FUNCTION:
1070COMP_CTX_compress_block 1098 NOEXIST::FUNCTION:
1071COMP_CTX_expand_block 1099 NOEXIST::FUNCTION:
1072X509_STORE_CTX_get_ex_new_index 1100 EXIST::FUNCTION:
1073OBJ_NAME_add 1101 EXIST::FUNCTION:
1074BIO_socket_nbio 1102 EXIST::FUNCTION:
1075EVP_rc2_64_cbc 1103 EXIST::FUNCTION:RC2
1076OBJ_NAME_cleanup 1104 EXIST::FUNCTION:
1077OBJ_NAME_get 1105 EXIST::FUNCTION:
1078OBJ_NAME_init 1106 EXIST::FUNCTION:
1079OBJ_NAME_new_index 1107 EXIST::FUNCTION:
1080OBJ_NAME_remove 1108 EXIST::FUNCTION:
1081BN_MONT_CTX_copy 1109 EXIST::FUNCTION:
1082BIO_new_socks4a_connect 1110 NOEXIST::FUNCTION:
1083BIO_s_socks4a_connect 1111 NOEXIST::FUNCTION:
1084PROXY_set_connect_mode 1112 NOEXIST::FUNCTION:
1085RAND_SSLeay 1113 EXIST::FUNCTION:
1086RAND_set_rand_method 1114 EXIST::FUNCTION:
1087RSA_memory_lock 1115 EXIST::FUNCTION:RSA
1088bn_sub_words 1116 EXIST::FUNCTION:
1089bn_mul_normal 1117 NOEXIST::FUNCTION:
1090bn_mul_comba8 1118 NOEXIST::FUNCTION:
1091bn_mul_comba4 1119 NOEXIST::FUNCTION:
1092bn_sqr_normal 1120 NOEXIST::FUNCTION:
1093bn_sqr_comba8 1121 NOEXIST::FUNCTION:
1094bn_sqr_comba4 1122 NOEXIST::FUNCTION:
1095bn_cmp_words 1123 NOEXIST::FUNCTION:
1096bn_mul_recursive 1124 NOEXIST::FUNCTION:
1097bn_mul_part_recursive 1125 NOEXIST::FUNCTION:
1098bn_sqr_recursive 1126 NOEXIST::FUNCTION:
1099bn_mul_low_normal 1127 NOEXIST::FUNCTION:
1100BN_RECP_CTX_init 1128 EXIST::FUNCTION:
1101BN_RECP_CTX_new 1129 EXIST::FUNCTION:
1102BN_RECP_CTX_free 1130 EXIST::FUNCTION:
1103BN_RECP_CTX_set 1131 EXIST::FUNCTION:
1104BN_mod_mul_reciprocal 1132 EXIST::FUNCTION:
1105BN_mod_exp_recp 1133 EXIST::FUNCTION:
1106BN_div_recp 1134 EXIST::FUNCTION:
1107BN_CTX_init 1135 EXIST::FUNCTION:
1108BN_MONT_CTX_init 1136 EXIST::FUNCTION:
1109RAND_get_rand_method 1137 EXIST::FUNCTION:
1110PKCS7_add_attribute 1138 EXIST::FUNCTION:
1111PKCS7_add_signed_attribute 1139 EXIST::FUNCTION:
1112PKCS7_digest_from_attributes 1140 EXIST::FUNCTION:
1113PKCS7_get_attribute 1141 EXIST::FUNCTION:
1114PKCS7_get_issuer_and_serial 1142 EXIST::FUNCTION:
1115PKCS7_get_signed_attribute 1143 EXIST::FUNCTION:
1116COMP_compress_block 1144 EXIST::FUNCTION:
1117COMP_expand_block 1145 EXIST::FUNCTION:
1118COMP_rle 1146 EXIST::FUNCTION:
1119COMP_zlib 1147 EXIST::FUNCTION:
1120ms_time_diff 1148 EXIST::FUNCTION:
1121ms_time_new 1149 EXIST::FUNCTION:
1122ms_time_free 1150 EXIST::FUNCTION:
1123ms_time_cmp 1151 EXIST::FUNCTION:
1124ms_time_get 1152 EXIST::FUNCTION:
1125PKCS7_set_attributes 1153 EXIST::FUNCTION:
1126PKCS7_set_signed_attributes 1154 EXIST::FUNCTION:
1127X509_ATTRIBUTE_create 1155 EXIST::FUNCTION:
1128X509_ATTRIBUTE_dup 1156 EXIST::FUNCTION:
1129ASN1_GENERALIZEDTIME_check 1157 EXIST::FUNCTION:
1130ASN1_GENERALIZEDTIME_print 1158 EXIST::FUNCTION:BIO
1131ASN1_GENERALIZEDTIME_set 1159 EXIST::FUNCTION:
1132ASN1_GENERALIZEDTIME_set_string 1160 EXIST::FUNCTION:
1133ASN1_TIME_print 1161 EXIST::FUNCTION:BIO
1134BASIC_CONSTRAINTS_free 1162 EXIST::FUNCTION:
1135BASIC_CONSTRAINTS_new 1163 EXIST::FUNCTION:
1136ERR_load_X509V3_strings 1164 EXIST::FUNCTION:
1137NETSCAPE_CERT_SEQUENCE_free 1165 EXIST::FUNCTION:
1138NETSCAPE_CERT_SEQUENCE_new 1166 EXIST::FUNCTION:
1139OBJ_txt2obj 1167 EXIST::FUNCTION:
1140PEM_read_NETSCAPE_CERT_SEQUENCE 1168 EXIST:!VMS,!WIN16:FUNCTION:
1141PEM_read_NS_CERT_SEQ 1168 EXIST:VMS:FUNCTION:
1142PEM_read_bio_NETSCAPE_CERT_SEQUENCE 1169 EXIST:!VMS:FUNCTION:
1143PEM_read_bio_NS_CERT_SEQ 1169 EXIST:VMS:FUNCTION:
1144PEM_write_NETSCAPE_CERT_SEQUENCE 1170 EXIST:!VMS,!WIN16:FUNCTION:
1145PEM_write_NS_CERT_SEQ 1170 EXIST:VMS:FUNCTION:
1146PEM_write_bio_NETSCAPE_CERT_SEQUENCE 1171 EXIST:!VMS:FUNCTION:
1147PEM_write_bio_NS_CERT_SEQ 1171 EXIST:VMS:FUNCTION:
1148X509V3_EXT_add 1172 EXIST::FUNCTION:
1149X509V3_EXT_add_alias 1173 EXIST::FUNCTION:
1150X509V3_EXT_add_conf 1174 EXIST::FUNCTION:
1151X509V3_EXT_cleanup 1175 EXIST::FUNCTION:
1152X509V3_EXT_conf 1176 EXIST::FUNCTION:
1153X509V3_EXT_conf_nid 1177 EXIST::FUNCTION:
1154X509V3_EXT_get 1178 EXIST::FUNCTION:
1155X509V3_EXT_get_nid 1179 EXIST::FUNCTION:
1156X509V3_EXT_print 1180 EXIST::FUNCTION:
1157X509V3_EXT_print_fp 1181 EXIST::FUNCTION:
1158X509V3_add_standard_extensions 1182 EXIST::FUNCTION:
1159X509V3_add_value 1183 EXIST::FUNCTION:
1160X509V3_add_value_bool 1184 EXIST::FUNCTION:
1161X509V3_add_value_int 1185 EXIST::FUNCTION:
1162X509V3_conf_free 1186 EXIST::FUNCTION:
1163X509V3_get_value_bool 1187 EXIST::FUNCTION:
1164X509V3_get_value_int 1188 EXIST::FUNCTION:
1165X509V3_parse_list 1189 EXIST::FUNCTION:
1166d2i_ASN1_GENERALIZEDTIME 1190 EXIST::FUNCTION:
1167d2i_ASN1_TIME 1191 EXIST::FUNCTION:
1168d2i_BASIC_CONSTRAINTS 1192 EXIST::FUNCTION:
1169d2i_NETSCAPE_CERT_SEQUENCE 1193 EXIST::FUNCTION:
1170d2i_ext_ku 1194 NOEXIST::FUNCTION:
1171ext_ku_free 1195 NOEXIST::FUNCTION:
1172ext_ku_new 1196 NOEXIST::FUNCTION:
1173i2d_ASN1_GENERALIZEDTIME 1197 EXIST::FUNCTION:
1174i2d_ASN1_TIME 1198 EXIST::FUNCTION:
1175i2d_BASIC_CONSTRAINTS 1199 EXIST::FUNCTION:
1176i2d_NETSCAPE_CERT_SEQUENCE 1200 EXIST::FUNCTION:
1177i2d_ext_ku 1201 NOEXIST::FUNCTION:
1178EVP_MD_CTX_copy 1202 EXIST::FUNCTION:
1179i2d_ASN1_ENUMERATED 1203 EXIST::FUNCTION:
1180d2i_ASN1_ENUMERATED 1204 EXIST::FUNCTION:
1181ASN1_ENUMERATED_set 1205 EXIST::FUNCTION:
1182ASN1_ENUMERATED_get 1206 EXIST::FUNCTION:
1183BN_to_ASN1_ENUMERATED 1207 EXIST::FUNCTION:
1184ASN1_ENUMERATED_to_BN 1208 EXIST::FUNCTION:
1185i2a_ASN1_ENUMERATED 1209 EXIST::FUNCTION:BIO
1186a2i_ASN1_ENUMERATED 1210 EXIST::FUNCTION:BIO
1187i2d_GENERAL_NAME 1211 EXIST::FUNCTION:
1188d2i_GENERAL_NAME 1212 EXIST::FUNCTION:
1189GENERAL_NAME_new 1213 EXIST::FUNCTION:
1190GENERAL_NAME_free 1214 EXIST::FUNCTION:
1191GENERAL_NAMES_new 1215 EXIST::FUNCTION:
1192GENERAL_NAMES_free 1216 EXIST::FUNCTION:
1193d2i_GENERAL_NAMES 1217 EXIST::FUNCTION:
1194i2d_GENERAL_NAMES 1218 EXIST::FUNCTION:
1195i2v_GENERAL_NAMES 1219 EXIST::FUNCTION:
1196i2s_ASN1_OCTET_STRING 1220 EXIST::FUNCTION:
1197s2i_ASN1_OCTET_STRING 1221 EXIST::FUNCTION:
1198X509V3_EXT_check_conf 1222 NOEXIST::FUNCTION:
1199hex_to_string 1223 EXIST::FUNCTION:
1200string_to_hex 1224 EXIST::FUNCTION:
1201DES_ede3_cbcm_encrypt 1225 EXIST::FUNCTION:DES
1202RSA_padding_add_PKCS1_OAEP 1226 EXIST::FUNCTION:RSA
1203RSA_padding_check_PKCS1_OAEP 1227 EXIST::FUNCTION:RSA
1204X509_CRL_print_fp 1228 EXIST::FUNCTION:FP_API
1205X509_CRL_print 1229 EXIST::FUNCTION:BIO
1206i2v_GENERAL_NAME 1230 EXIST::FUNCTION:
1207v2i_GENERAL_NAME 1231 EXIST::FUNCTION:
1208i2d_PKEY_USAGE_PERIOD 1232 EXIST::FUNCTION:
1209d2i_PKEY_USAGE_PERIOD 1233 EXIST::FUNCTION:
1210PKEY_USAGE_PERIOD_new 1234 EXIST::FUNCTION:
1211PKEY_USAGE_PERIOD_free 1235 EXIST::FUNCTION:
1212v2i_GENERAL_NAMES 1236 EXIST::FUNCTION:
1213i2s_ASN1_INTEGER 1237 EXIST::FUNCTION:
1214X509V3_EXT_d2i 1238 EXIST::FUNCTION:
1215name_cmp 1239 EXIST::FUNCTION:
1216str_dup 1240 NOEXIST::FUNCTION:
1217i2s_ASN1_ENUMERATED 1241 EXIST::FUNCTION:
1218i2s_ASN1_ENUMERATED_TABLE 1242 EXIST::FUNCTION:
1219BIO_s_log 1243 EXIST:!OS2,!WIN16,!WIN32,!macintosh:FUNCTION:
1220BIO_f_reliable 1244 EXIST::FUNCTION:BIO
1221PKCS7_dataFinal 1245 EXIST::FUNCTION:
1222PKCS7_dataDecode 1246 EXIST::FUNCTION:
1223X509V3_EXT_CRL_add_conf 1247 EXIST::FUNCTION:
1224BN_set_params 1248 EXIST::FUNCTION:
1225BN_get_params 1249 EXIST::FUNCTION:
1226BIO_get_ex_num 1250 NOEXIST::FUNCTION:
1227BIO_set_ex_free_func 1251 NOEXIST::FUNCTION:
1228EVP_ripemd160 1252 EXIST::FUNCTION:RIPEMD
1229ASN1_TIME_set 1253 EXIST::FUNCTION:
1230i2d_AUTHORITY_KEYID 1254 EXIST::FUNCTION:
1231d2i_AUTHORITY_KEYID 1255 EXIST::FUNCTION:
1232AUTHORITY_KEYID_new 1256 EXIST::FUNCTION:
1233AUTHORITY_KEYID_free 1257 EXIST::FUNCTION:
1234ASN1_seq_unpack 1258 EXIST::FUNCTION:
1235ASN1_seq_pack 1259 EXIST::FUNCTION:
1236ASN1_unpack_string 1260 EXIST::FUNCTION:
1237ASN1_pack_string 1261 EXIST::FUNCTION:
1238PKCS12_pack_safebag 1262 NOEXIST::FUNCTION:
1239PKCS12_MAKE_KEYBAG 1263 EXIST::FUNCTION:
1240PKCS8_encrypt 1264 EXIST::FUNCTION:
1241PKCS12_MAKE_SHKEYBAG 1265 EXIST::FUNCTION:
1242PKCS12_pack_p7data 1266 EXIST::FUNCTION:
1243PKCS12_pack_p7encdata 1267 EXIST::FUNCTION:
1244PKCS12_add_localkeyid 1268 EXIST::FUNCTION:
1245PKCS12_add_friendlyname_asc 1269 EXIST::FUNCTION:
1246PKCS12_add_friendlyname_uni 1270 EXIST::FUNCTION:
1247PKCS12_get_friendlyname 1271 EXIST::FUNCTION:
1248PKCS12_pbe_crypt 1272 EXIST::FUNCTION:
1249PKCS12_decrypt_d2i 1273 NOEXIST::FUNCTION:
1250PKCS12_i2d_encrypt 1274 NOEXIST::FUNCTION:
1251PKCS12_init 1275 EXIST::FUNCTION:
1252PKCS12_key_gen_asc 1276 EXIST::FUNCTION:
1253PKCS12_key_gen_uni 1277 EXIST::FUNCTION:
1254PKCS12_gen_mac 1278 EXIST::FUNCTION:
1255PKCS12_verify_mac 1279 EXIST::FUNCTION:
1256PKCS12_set_mac 1280 EXIST::FUNCTION:
1257PKCS12_setup_mac 1281 EXIST::FUNCTION:
1258asc2uni 1282 EXIST::FUNCTION:
1259uni2asc 1283 EXIST::FUNCTION:
1260i2d_PKCS12_BAGS 1284 EXIST::FUNCTION:
1261PKCS12_BAGS_new 1285 EXIST::FUNCTION:
1262d2i_PKCS12_BAGS 1286 EXIST::FUNCTION:
1263PKCS12_BAGS_free 1287 EXIST::FUNCTION:
1264i2d_PKCS12 1288 EXIST::FUNCTION:
1265d2i_PKCS12 1289 EXIST::FUNCTION:
1266PKCS12_new 1290 EXIST::FUNCTION:
1267PKCS12_free 1291 EXIST::FUNCTION:
1268i2d_PKCS12_MAC_DATA 1292 EXIST::FUNCTION:
1269PKCS12_MAC_DATA_new 1293 EXIST::FUNCTION:
1270d2i_PKCS12_MAC_DATA 1294 EXIST::FUNCTION:
1271PKCS12_MAC_DATA_free 1295 EXIST::FUNCTION:
1272i2d_PKCS12_SAFEBAG 1296 EXIST::FUNCTION:
1273PKCS12_SAFEBAG_new 1297 EXIST::FUNCTION:
1274d2i_PKCS12_SAFEBAG 1298 EXIST::FUNCTION:
1275PKCS12_SAFEBAG_free 1299 EXIST::FUNCTION:
1276ERR_load_PKCS12_strings 1300 EXIST::FUNCTION:
1277PKCS12_PBE_add 1301 EXIST::FUNCTION:
1278PKCS8_add_keyusage 1302 EXIST::FUNCTION:
1279PKCS12_get_attr_gen 1303 EXIST::FUNCTION:
1280PKCS12_parse 1304 EXIST::FUNCTION:
1281PKCS12_create 1305 EXIST::FUNCTION:
1282i2d_PKCS12_bio 1306 EXIST::FUNCTION:
1283i2d_PKCS12_fp 1307 EXIST::FUNCTION:
1284d2i_PKCS12_bio 1308 EXIST::FUNCTION:
1285d2i_PKCS12_fp 1309 EXIST::FUNCTION:
1286i2d_PBEPARAM 1310 EXIST::FUNCTION:
1287PBEPARAM_new 1311 EXIST::FUNCTION:
1288d2i_PBEPARAM 1312 EXIST::FUNCTION:
1289PBEPARAM_free 1313 EXIST::FUNCTION:
1290i2d_PKCS8_PRIV_KEY_INFO 1314 EXIST::FUNCTION:
1291PKCS8_PRIV_KEY_INFO_new 1315 EXIST::FUNCTION:
1292d2i_PKCS8_PRIV_KEY_INFO 1316 EXIST::FUNCTION:
1293PKCS8_PRIV_KEY_INFO_free 1317 EXIST::FUNCTION:
1294EVP_PKCS82PKEY 1318 EXIST::FUNCTION:
1295EVP_PKEY2PKCS8 1319 EXIST::FUNCTION:
1296PKCS8_set_broken 1320 EXIST::FUNCTION:
1297EVP_PBE_ALGOR_CipherInit 1321 NOEXIST::FUNCTION:
1298EVP_PBE_alg_add 1322 EXIST::FUNCTION:
1299PKCS5_pbe_set 1323 EXIST::FUNCTION:
1300EVP_PBE_cleanup 1324 EXIST::FUNCTION:
1301i2d_SXNET 1325 EXIST::FUNCTION:
1302d2i_SXNET 1326 EXIST::FUNCTION:
1303SXNET_new 1327 EXIST::FUNCTION:
1304SXNET_free 1328 EXIST::FUNCTION:
1305i2d_SXNETID 1329 EXIST::FUNCTION:
1306d2i_SXNETID 1330 EXIST::FUNCTION:
1307SXNETID_new 1331 EXIST::FUNCTION:
1308SXNETID_free 1332 EXIST::FUNCTION:
1309DSA_SIG_new 1333 EXIST::FUNCTION:DSA
1310DSA_SIG_free 1334 EXIST::FUNCTION:DSA
1311DSA_do_sign 1335 EXIST::FUNCTION:DSA
1312DSA_do_verify 1336 EXIST::FUNCTION:DSA
1313d2i_DSA_SIG 1337 EXIST::FUNCTION:DSA
1314i2d_DSA_SIG 1338 EXIST::FUNCTION:DSA
1315i2d_ASN1_VISIBLESTRING 1339 EXIST::FUNCTION:
1316d2i_ASN1_VISIBLESTRING 1340 EXIST::FUNCTION:
1317i2d_ASN1_UTF8STRING 1341 EXIST::FUNCTION:
1318d2i_ASN1_UTF8STRING 1342 EXIST::FUNCTION:
1319i2d_DIRECTORYSTRING 1343 EXIST::FUNCTION:
1320d2i_DIRECTORYSTRING 1344 EXIST::FUNCTION:
1321i2d_DISPLAYTEXT 1345 EXIST::FUNCTION:
1322d2i_DISPLAYTEXT 1346 EXIST::FUNCTION:
1323d2i_ASN1_SET_OF_X509 1379 NOEXIST::FUNCTION:
1324i2d_ASN1_SET_OF_X509 1380 NOEXIST::FUNCTION:
1325i2d_PBKDF2PARAM 1397 EXIST::FUNCTION:
1326PBKDF2PARAM_new 1398 EXIST::FUNCTION:
1327d2i_PBKDF2PARAM 1399 EXIST::FUNCTION:
1328PBKDF2PARAM_free 1400 EXIST::FUNCTION:
1329i2d_PBE2PARAM 1401 EXIST::FUNCTION:
1330PBE2PARAM_new 1402 EXIST::FUNCTION:
1331d2i_PBE2PARAM 1403 EXIST::FUNCTION:
1332PBE2PARAM_free 1404 EXIST::FUNCTION:
1333d2i_ASN1_SET_OF_GENERAL_NAME 1421 NOEXIST::FUNCTION:
1334i2d_ASN1_SET_OF_GENERAL_NAME 1422 NOEXIST::FUNCTION:
1335d2i_ASN1_SET_OF_SXNETID 1439 NOEXIST::FUNCTION:
1336i2d_ASN1_SET_OF_SXNETID 1440 NOEXIST::FUNCTION:
1337d2i_ASN1_SET_OF_POLICYQUALINFO 1457 NOEXIST::FUNCTION:
1338i2d_ASN1_SET_OF_POLICYQUALINFO 1458 NOEXIST::FUNCTION:
1339d2i_ASN1_SET_OF_POLICYINFO 1475 NOEXIST::FUNCTION:
1340i2d_ASN1_SET_OF_POLICYINFO 1476 NOEXIST::FUNCTION:
1341SXNET_add_id_asc 1477 EXIST::FUNCTION:
1342SXNET_add_id_ulong 1478 EXIST::FUNCTION:
1343SXNET_add_id_INTEGER 1479 EXIST::FUNCTION:
1344SXNET_get_id_asc 1480 EXIST::FUNCTION:
1345SXNET_get_id_ulong 1481 EXIST::FUNCTION:
1346SXNET_get_id_INTEGER 1482 EXIST::FUNCTION:
1347X509V3_set_conf_lhash 1483 EXIST::FUNCTION:
1348i2d_CERTIFICATEPOLICIES 1484 EXIST::FUNCTION:
1349CERTIFICATEPOLICIES_new 1485 EXIST::FUNCTION:
1350CERTIFICATEPOLICIES_free 1486 EXIST::FUNCTION:
1351d2i_CERTIFICATEPOLICIES 1487 EXIST::FUNCTION:
1352i2d_POLICYINFO 1488 EXIST::FUNCTION:
1353POLICYINFO_new 1489 EXIST::FUNCTION:
1354d2i_POLICYINFO 1490 EXIST::FUNCTION:
1355POLICYINFO_free 1491 EXIST::FUNCTION:
1356i2d_POLICYQUALINFO 1492 EXIST::FUNCTION:
1357POLICYQUALINFO_new 1493 EXIST::FUNCTION:
1358d2i_POLICYQUALINFO 1494 EXIST::FUNCTION:
1359POLICYQUALINFO_free 1495 EXIST::FUNCTION:
1360i2d_USERNOTICE 1496 EXIST::FUNCTION:
1361USERNOTICE_new 1497 EXIST::FUNCTION:
1362d2i_USERNOTICE 1498 EXIST::FUNCTION:
1363USERNOTICE_free 1499 EXIST::FUNCTION:
1364i2d_NOTICEREF 1500 EXIST::FUNCTION:
1365NOTICEREF_new 1501 EXIST::FUNCTION:
1366d2i_NOTICEREF 1502 EXIST::FUNCTION:
1367NOTICEREF_free 1503 EXIST::FUNCTION:
1368X509V3_get_string 1504 EXIST::FUNCTION:
1369X509V3_get_section 1505 EXIST::FUNCTION:
1370X509V3_string_free 1506 EXIST::FUNCTION:
1371X509V3_section_free 1507 EXIST::FUNCTION:
1372X509V3_set_ctx 1508 EXIST::FUNCTION:
1373s2i_ASN1_INTEGER 1509 EXIST::FUNCTION:
1374CRYPTO_set_locked_mem_functions 1510 EXIST::FUNCTION:
1375CRYPTO_get_locked_mem_functions 1511 EXIST::FUNCTION:
1376CRYPTO_malloc_locked 1512 EXIST::FUNCTION:
1377CRYPTO_free_locked 1513 EXIST::FUNCTION:
1378BN_mod_exp2_mont 1514 EXIST::FUNCTION:
1379ERR_get_error_line_data 1515 EXIST::FUNCTION:
1380ERR_peek_error_line_data 1516 EXIST::FUNCTION:
1381PKCS12_PBE_keyivgen 1517 EXIST::FUNCTION:
1382X509_ALGOR_dup 1518 EXIST::FUNCTION:
1383d2i_ASN1_SET_OF_DIST_POINT 1535 NOEXIST::FUNCTION:
1384i2d_ASN1_SET_OF_DIST_POINT 1536 NOEXIST::FUNCTION:
1385i2d_CRL_DIST_POINTS 1537 EXIST::FUNCTION:
1386CRL_DIST_POINTS_new 1538 EXIST::FUNCTION:
1387CRL_DIST_POINTS_free 1539 EXIST::FUNCTION:
1388d2i_CRL_DIST_POINTS 1540 EXIST::FUNCTION:
1389i2d_DIST_POINT 1541 EXIST::FUNCTION:
1390DIST_POINT_new 1542 EXIST::FUNCTION:
1391d2i_DIST_POINT 1543 EXIST::FUNCTION:
1392DIST_POINT_free 1544 EXIST::FUNCTION:
1393i2d_DIST_POINT_NAME 1545 EXIST::FUNCTION:
1394DIST_POINT_NAME_new 1546 EXIST::FUNCTION:
1395DIST_POINT_NAME_free 1547 EXIST::FUNCTION:
1396d2i_DIST_POINT_NAME 1548 EXIST::FUNCTION:
1397X509V3_add_value_uchar 1549 EXIST::FUNCTION:
1398d2i_ASN1_SET_OF_X509_ATTRIBUTE 1555 NOEXIST::FUNCTION:
1399i2d_ASN1_SET_OF_ASN1_TYPE 1560 NOEXIST::FUNCTION:
1400d2i_ASN1_SET_OF_X509_EXTENSION 1567 NOEXIST::FUNCTION:
1401d2i_ASN1_SET_OF_X509_NAME_ENTRY 1574 NOEXIST::FUNCTION:
1402d2i_ASN1_SET_OF_ASN1_TYPE 1589 NOEXIST::FUNCTION:
1403i2d_ASN1_SET_OF_X509_ATTRIBUTE 1615 NOEXIST::FUNCTION:
1404i2d_ASN1_SET_OF_X509_EXTENSION 1624 NOEXIST::FUNCTION:
1405i2d_ASN1_SET_OF_X509_NAME_ENTRY 1633 NOEXIST::FUNCTION:
1406X509V3_EXT_i2d 1646 EXIST::FUNCTION:
1407X509V3_EXT_val_prn 1647 EXIST::FUNCTION:
1408X509V3_EXT_add_list 1648 EXIST::FUNCTION:
1409EVP_CIPHER_type 1649 EXIST::FUNCTION:
1410EVP_PBE_CipherInit 1650 EXIST::FUNCTION:
1411X509V3_add_value_bool_nf 1651 EXIST::FUNCTION:
1412d2i_ASN1_UINTEGER 1652 EXIST::FUNCTION:
1413sk_value 1653 EXIST::FUNCTION:
1414sk_num 1654 EXIST::FUNCTION:
1415sk_set 1655 EXIST::FUNCTION:
1416i2d_ASN1_SET_OF_X509_REVOKED 1661 NOEXIST::FUNCTION:
1417sk_sort 1671 EXIST::FUNCTION:
1418d2i_ASN1_SET_OF_X509_REVOKED 1674 NOEXIST::FUNCTION:
1419i2d_ASN1_SET_OF_X509_ALGOR 1682 NOEXIST::FUNCTION:
1420i2d_ASN1_SET_OF_X509_CRL 1685 NOEXIST::FUNCTION:
1421d2i_ASN1_SET_OF_X509_ALGOR 1696 NOEXIST::FUNCTION:
1422d2i_ASN1_SET_OF_X509_CRL 1702 NOEXIST::FUNCTION:
1423i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO 1723 NOEXIST::FUNCTION:
1424i2d_ASN1_SET_OF_PKCS7_RECIP_INFO 1738 NOEXIST::FUNCTION:
1425d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO 1748 NOEXIST::FUNCTION:
1426d2i_ASN1_SET_OF_PKCS7_RECIP_INFO 1753 NOEXIST::FUNCTION:
1427PKCS5_PBE_add 1775 EXIST::FUNCTION:
1428PEM_write_bio_PKCS8 1776 EXIST::FUNCTION:
1429i2d_PKCS8_fp 1777 EXIST::FUNCTION:FP_API
1430PEM_read_bio_PKCS8_PRIV_KEY_INFO 1778 EXIST:!VMS:FUNCTION:
1431PEM_read_bio_P8_PRIV_KEY_INFO 1778 EXIST:VMS:FUNCTION:
1432d2i_PKCS8_bio 1779 EXIST::FUNCTION:BIO
1433d2i_PKCS8_PRIV_KEY_INFO_fp 1780 EXIST::FUNCTION:FP_API
1434PEM_write_bio_PKCS8_PRIV_KEY_INFO 1781 EXIST:!VMS:FUNCTION:
1435PEM_write_bio_P8_PRIV_KEY_INFO 1781 EXIST:VMS:FUNCTION:
1436PEM_read_PKCS8 1782 EXIST:!WIN16:FUNCTION:
1437d2i_PKCS8_PRIV_KEY_INFO_bio 1783 EXIST::FUNCTION:BIO
1438d2i_PKCS8_fp 1784 EXIST::FUNCTION:FP_API
1439PEM_write_PKCS8 1785 EXIST:!WIN16:FUNCTION:
1440PEM_read_PKCS8_PRIV_KEY_INFO 1786 EXIST:!VMS,!WIN16:FUNCTION:
1441PEM_read_P8_PRIV_KEY_INFO 1786 EXIST:VMS:FUNCTION:
1442PEM_read_bio_PKCS8 1787 EXIST::FUNCTION:
1443PEM_write_PKCS8_PRIV_KEY_INFO 1788 EXIST:!VMS,!WIN16:FUNCTION:
1444PEM_write_P8_PRIV_KEY_INFO 1788 EXIST:VMS:FUNCTION:
1445PKCS5_PBE_keyivgen 1789 EXIST::FUNCTION:
1446i2d_PKCS8_bio 1790 EXIST::FUNCTION:BIO
1447i2d_PKCS8_PRIV_KEY_INFO_fp 1791 EXIST::FUNCTION:FP_API
1448i2d_PKCS8_PRIV_KEY_INFO_bio 1792 EXIST::FUNCTION:BIO
1449BIO_s_bio 1793 EXIST::FUNCTION:
1450PKCS5_pbe2_set 1794 EXIST::FUNCTION:
1451PKCS5_PBKDF2_HMAC_SHA1 1795 EXIST::FUNCTION:
1452PKCS5_v2_PBE_keyivgen 1796 EXIST::FUNCTION:
1453PEM_write_bio_PKCS8PrivateKey 1797 EXIST::FUNCTION:
1454PEM_write_PKCS8PrivateKey 1798 EXIST::FUNCTION:
1455BIO_ctrl_get_read_request 1799 EXIST::FUNCTION:
1456BIO_ctrl_pending 1800 EXIST::FUNCTION:
1457BIO_ctrl_wpending 1801 EXIST::FUNCTION:
1458BIO_new_bio_pair 1802 EXIST::FUNCTION:
1459BIO_ctrl_get_write_guarantee 1803 EXIST::FUNCTION:
1460CRYPTO_num_locks 1804 EXIST::FUNCTION:
1461CONF_load_bio 1805 EXIST::FUNCTION:
1462CONF_load_fp 1806 EXIST::FUNCTION:FP_API
1463i2d_ASN1_SET_OF_ASN1_OBJECT 1837 NOEXIST::FUNCTION:
1464d2i_ASN1_SET_OF_ASN1_OBJECT 1844 NOEXIST::FUNCTION:
1465PKCS7_signatureVerify 1845 EXIST::FUNCTION:
1466RSA_set_method 1846 EXIST::FUNCTION:RSA
1467RSA_get_method 1847 EXIST::FUNCTION:RSA
1468RSA_get_default_method 1848 EXIST::FUNCTION:RSA
1469RSA_check_key 1869 EXIST::FUNCTION:RSA
1470OBJ_obj2txt 1870 EXIST::FUNCTION:
1471DSA_dup_DH 1871 EXIST::FUNCTION:DH,DSA
1472X509_REQ_get_extensions 1872 EXIST::FUNCTION:
1473X509_REQ_set_extension_nids 1873 EXIST::FUNCTION:
1474BIO_nwrite 1874 EXIST::FUNCTION:
1475X509_REQ_extension_nid 1875 EXIST::FUNCTION:
1476BIO_nread 1876 EXIST::FUNCTION:
1477X509_REQ_get_extension_nids 1877 EXIST::FUNCTION:
1478BIO_nwrite0 1878 EXIST::FUNCTION:
1479X509_REQ_add_extensions_nid 1879 EXIST::FUNCTION:
1480BIO_nread0 1880 EXIST::FUNCTION:
1481X509_REQ_add_extensions 1881 EXIST::FUNCTION:
1482BIO_new_mem_buf 1882 EXIST::FUNCTION:
1483DH_set_ex_data 1883 EXIST::FUNCTION:DH
1484DH_set_method 1884 EXIST::FUNCTION:DH
1485DSA_OpenSSL 1885 EXIST::FUNCTION:DSA
1486DH_get_ex_data 1886 EXIST::FUNCTION:DH
1487DH_get_ex_new_index 1887 EXIST::FUNCTION:DH
1488DSA_new_method 1888 EXIST::FUNCTION:DSA
1489DH_new_method 1889 EXIST::FUNCTION:DH
1490DH_OpenSSL 1890 EXIST::FUNCTION:DH
1491DSA_get_ex_new_index 1891 EXIST::FUNCTION:DSA
1492DH_get_default_method 1892 EXIST::FUNCTION:DH
1493DSA_set_ex_data 1893 EXIST::FUNCTION:DSA
1494DH_set_default_method 1894 EXIST::FUNCTION:DH
1495DSA_get_ex_data 1895 EXIST::FUNCTION:DSA
1496X509V3_EXT_REQ_add_conf 1896 EXIST::FUNCTION:
1497NETSCAPE_SPKI_print 1897 EXIST::FUNCTION:EVP
1498NETSCAPE_SPKI_set_pubkey 1898 EXIST::FUNCTION:EVP
1499NETSCAPE_SPKI_b64_encode 1899 EXIST::FUNCTION:EVP
1500NETSCAPE_SPKI_get_pubkey 1900 EXIST::FUNCTION:EVP
1501NETSCAPE_SPKI_b64_decode 1901 EXIST::FUNCTION:EVP
1502UTF8_putc 1902 EXIST::FUNCTION:
1503UTF8_getc 1903 EXIST::FUNCTION:
1504RSA_null_method 1904 EXIST::FUNCTION:RSA
1505ASN1_tag2str 1905 EXIST::FUNCTION:
1506BIO_ctrl_reset_read_request 1906 EXIST::FUNCTION:
1507DISPLAYTEXT_new 1907 EXIST::FUNCTION:
1508ASN1_GENERALIZEDTIME_free 1908 EXIST::FUNCTION:
1509X509_REVOKED_get_ext_d2i 1909 EXIST::FUNCTION:
1510X509_set_ex_data 1910 EXIST::FUNCTION:
1511X509_reject_set_bit_asc 1911 NOEXIST::FUNCTION:
1512X509_NAME_add_entry_by_txt 1912 EXIST::FUNCTION:
1513X509_NAME_add_entry_by_NID 1914 EXIST::FUNCTION:
1514X509_PURPOSE_get0 1915 EXIST::FUNCTION:
1515PEM_read_X509_AUX 1917 EXIST:!WIN16:FUNCTION:
1516d2i_AUTHORITY_INFO_ACCESS 1918 EXIST::FUNCTION:
1517PEM_write_PUBKEY 1921 EXIST:!WIN16:FUNCTION:
1518ACCESS_DESCRIPTION_new 1925 EXIST::FUNCTION:
1519X509_CERT_AUX_free 1926 EXIST::FUNCTION:
1520d2i_ACCESS_DESCRIPTION 1927 EXIST::FUNCTION:
1521X509_trust_clear 1928 EXIST::FUNCTION:
1522X509_TRUST_add 1931 EXIST::FUNCTION:
1523ASN1_VISIBLESTRING_new 1932 EXIST::FUNCTION:
1524X509_alias_set1 1933 EXIST::FUNCTION:
1525ASN1_PRINTABLESTRING_free 1934 EXIST::FUNCTION:
1526EVP_PKEY_get1_DSA 1935 EXIST::FUNCTION:DSA
1527ASN1_BMPSTRING_new 1936 EXIST::FUNCTION:
1528ASN1_mbstring_copy 1937 EXIST::FUNCTION:
1529ASN1_UTF8STRING_new 1938 EXIST::FUNCTION:
1530DSA_get_default_method 1941 EXIST::FUNCTION:DSA
1531i2d_ASN1_SET_OF_ACCESS_DESCRIPTION 1945 NOEXIST::FUNCTION:
1532ASN1_T61STRING_free 1946 EXIST::FUNCTION:
1533DSA_set_method 1949 EXIST::FUNCTION:DSA
1534X509_get_ex_data 1950 EXIST::FUNCTION:
1535ASN1_STRING_type 1951 EXIST::FUNCTION:
1536X509_PURPOSE_get_by_sname 1952 EXIST::FUNCTION:
1537ASN1_TIME_free 1954 EXIST::FUNCTION:
1538ASN1_OCTET_STRING_cmp 1955 EXIST::FUNCTION:
1539ASN1_BIT_STRING_new 1957 EXIST::FUNCTION:
1540X509_get_ext_d2i 1958 EXIST::FUNCTION:
1541PEM_read_bio_X509_AUX 1959 EXIST::FUNCTION:
1542ASN1_STRING_set_default_mask_asc 1960 EXIST:!VMS:FUNCTION:
1543ASN1_STRING_set_def_mask_asc 1960 EXIST:VMS:FUNCTION:
1544PEM_write_bio_RSA_PUBKEY 1961 EXIST::FUNCTION:RSA
1545ASN1_INTEGER_cmp 1963 EXIST::FUNCTION:
1546d2i_RSA_PUBKEY_fp 1964 EXIST::FUNCTION:FP_API,RSA
1547X509_trust_set_bit_asc 1967 NOEXIST::FUNCTION:
1548PEM_write_bio_DSA_PUBKEY 1968 EXIST::FUNCTION:DSA
1549X509_STORE_CTX_free 1969 EXIST::FUNCTION:
1550EVP_PKEY_set1_DSA 1970 EXIST::FUNCTION:DSA
1551i2d_DSA_PUBKEY_fp 1971 EXIST::FUNCTION:DSA,FP_API
1552X509_load_cert_crl_file 1972 EXIST::FUNCTION:STDIO
1553ASN1_TIME_new 1973 EXIST::FUNCTION:
1554i2d_RSA_PUBKEY 1974 EXIST::FUNCTION:RSA
1555X509_STORE_CTX_purpose_inherit 1976 EXIST::FUNCTION:
1556PEM_read_RSA_PUBKEY 1977 EXIST:!WIN16:FUNCTION:RSA
1557d2i_X509_AUX 1980 EXIST::FUNCTION:
1558i2d_DSA_PUBKEY 1981 EXIST::FUNCTION:DSA
1559X509_CERT_AUX_print 1982 EXIST::FUNCTION:BIO
1560PEM_read_DSA_PUBKEY 1984 EXIST:!WIN16:FUNCTION:DSA
1561i2d_RSA_PUBKEY_bio 1985 EXIST::FUNCTION:BIO,RSA
1562ASN1_BIT_STRING_num_asc 1986 EXIST::FUNCTION:
1563i2d_PUBKEY 1987 EXIST::FUNCTION:
1564ASN1_UTCTIME_free 1988 EXIST::FUNCTION:
1565DSA_set_default_method 1989 EXIST::FUNCTION:DSA
1566X509_PURPOSE_get_by_id 1990 EXIST::FUNCTION:
1567ACCESS_DESCRIPTION_free 1994 EXIST::FUNCTION:
1568PEM_read_bio_PUBKEY 1995 EXIST::FUNCTION:
1569ASN1_STRING_set_by_NID 1996 EXIST::FUNCTION:
1570X509_PURPOSE_get_id 1997 EXIST::FUNCTION:
1571DISPLAYTEXT_free 1998 EXIST::FUNCTION:
1572OTHERNAME_new 1999 EXIST::FUNCTION:
1573X509_CERT_AUX_new 2001 EXIST::FUNCTION:
1574X509_TRUST_cleanup 2007 EXIST::FUNCTION:
1575X509_NAME_add_entry_by_OBJ 2008 EXIST::FUNCTION:
1576X509_CRL_get_ext_d2i 2009 EXIST::FUNCTION:
1577X509_PURPOSE_get0_name 2011 EXIST::FUNCTION:
1578PEM_read_PUBKEY 2012 EXIST:!WIN16:FUNCTION:
1579i2d_DSA_PUBKEY_bio 2014 EXIST::FUNCTION:BIO,DSA
1580i2d_OTHERNAME 2015 EXIST::FUNCTION:
1581ASN1_OCTET_STRING_free 2016 EXIST::FUNCTION:
1582ASN1_BIT_STRING_set_asc 2017 EXIST::FUNCTION:
1583X509_get_ex_new_index 2019 EXIST::FUNCTION:
1584ASN1_STRING_TABLE_cleanup 2020 EXIST::FUNCTION:
1585X509_TRUST_get_by_id 2021 EXIST::FUNCTION:
1586X509_PURPOSE_get_trust 2022 EXIST::FUNCTION:
1587ASN1_STRING_length 2023 EXIST::FUNCTION:
1588d2i_ASN1_SET_OF_ACCESS_DESCRIPTION 2024 NOEXIST::FUNCTION:
1589ASN1_PRINTABLESTRING_new 2025 EXIST::FUNCTION:
1590X509V3_get_d2i 2026 EXIST::FUNCTION:
1591ASN1_ENUMERATED_free 2027 EXIST::FUNCTION:
1592i2d_X509_CERT_AUX 2028 EXIST::FUNCTION:
1593X509_STORE_CTX_set_trust 2030 EXIST::FUNCTION:
1594ASN1_STRING_set_default_mask 2032 EXIST::FUNCTION:
1595X509_STORE_CTX_new 2033 EXIST::FUNCTION:
1596EVP_PKEY_get1_RSA 2034 EXIST::FUNCTION:RSA
1597DIRECTORYSTRING_free 2038 EXIST::FUNCTION:
1598PEM_write_X509_AUX 2039 EXIST:!WIN16:FUNCTION:
1599ASN1_OCTET_STRING_set 2040 EXIST::FUNCTION:
1600d2i_DSA_PUBKEY_fp 2041 EXIST::FUNCTION:DSA,FP_API
1601d2i_RSA_PUBKEY 2044 EXIST::FUNCTION:RSA
1602X509_TRUST_get0_name 2046 EXIST::FUNCTION:
1603X509_TRUST_get0 2047 EXIST::FUNCTION:
1604AUTHORITY_INFO_ACCESS_free 2048 EXIST::FUNCTION:
1605ASN1_IA5STRING_new 2049 EXIST::FUNCTION:
1606d2i_DSA_PUBKEY 2050 EXIST::FUNCTION:DSA
1607X509_check_purpose 2051 EXIST::FUNCTION:
1608ASN1_ENUMERATED_new 2052 EXIST::FUNCTION:
1609d2i_RSA_PUBKEY_bio 2053 EXIST::FUNCTION:BIO,RSA
1610d2i_PUBKEY 2054 EXIST::FUNCTION:
1611X509_TRUST_get_trust 2055 EXIST::FUNCTION:
1612X509_TRUST_get_flags 2056 EXIST::FUNCTION:
1613ASN1_BMPSTRING_free 2057 EXIST::FUNCTION:
1614ASN1_T61STRING_new 2058 EXIST::FUNCTION:
1615ASN1_UTCTIME_new 2060 EXIST::FUNCTION:
1616i2d_AUTHORITY_INFO_ACCESS 2062 EXIST::FUNCTION:
1617EVP_PKEY_set1_RSA 2063 EXIST::FUNCTION:RSA
1618X509_STORE_CTX_set_purpose 2064 EXIST::FUNCTION:
1619ASN1_IA5STRING_free 2065 EXIST::FUNCTION:
1620PEM_write_bio_X509_AUX 2066 EXIST::FUNCTION:
1621X509_PURPOSE_get_count 2067 EXIST::FUNCTION:
1622CRYPTO_add_info 2068 NOEXIST::FUNCTION:
1623X509_NAME_ENTRY_create_by_txt 2071 EXIST::FUNCTION:
1624ASN1_STRING_get_default_mask 2072 EXIST::FUNCTION:
1625X509_alias_get0 2074 EXIST::FUNCTION:
1626ASN1_STRING_data 2075 EXIST::FUNCTION:
1627i2d_ACCESS_DESCRIPTION 2077 EXIST::FUNCTION:
1628X509_trust_set_bit 2078 NOEXIST::FUNCTION:
1629ASN1_BIT_STRING_free 2080 EXIST::FUNCTION:
1630PEM_read_bio_RSA_PUBKEY 2081 EXIST::FUNCTION:RSA
1631X509_add1_reject_object 2082 EXIST::FUNCTION:
1632X509_check_trust 2083 EXIST::FUNCTION:
1633PEM_read_bio_DSA_PUBKEY 2088 EXIST::FUNCTION:DSA
1634X509_PURPOSE_add 2090 EXIST::FUNCTION:
1635ASN1_STRING_TABLE_get 2091 EXIST::FUNCTION:
1636ASN1_UTF8STRING_free 2092 EXIST::FUNCTION:
1637d2i_DSA_PUBKEY_bio 2093 EXIST::FUNCTION:BIO,DSA
1638PEM_write_RSA_PUBKEY 2095 EXIST:!WIN16:FUNCTION:RSA
1639d2i_OTHERNAME 2096 EXIST::FUNCTION:
1640X509_reject_set_bit 2098 NOEXIST::FUNCTION:
1641PEM_write_DSA_PUBKEY 2101 EXIST:!WIN16:FUNCTION:DSA
1642X509_PURPOSE_get0_sname 2105 EXIST::FUNCTION:
1643EVP_PKEY_set1_DH 2107 EXIST::FUNCTION:DH
1644ASN1_OCTET_STRING_dup 2108 EXIST::FUNCTION:
1645ASN1_BIT_STRING_set 2109 EXIST::FUNCTION:
1646X509_TRUST_get_count 2110 EXIST::FUNCTION:
1647ASN1_INTEGER_free 2111 EXIST::FUNCTION:
1648OTHERNAME_free 2112 EXIST::FUNCTION:
1649i2d_RSA_PUBKEY_fp 2113 EXIST::FUNCTION:FP_API,RSA
1650ASN1_INTEGER_dup 2114 EXIST::FUNCTION:
1651d2i_X509_CERT_AUX 2115 EXIST::FUNCTION:
1652PEM_write_bio_PUBKEY 2117 EXIST::FUNCTION:
1653ASN1_VISIBLESTRING_free 2118 EXIST::FUNCTION:
1654X509_PURPOSE_cleanup 2119 EXIST::FUNCTION:
1655ASN1_mbstring_ncopy 2123 EXIST::FUNCTION:
1656ASN1_GENERALIZEDTIME_new 2126 EXIST::FUNCTION:
1657EVP_PKEY_get1_DH 2128 EXIST::FUNCTION:DH
1658ASN1_OCTET_STRING_new 2130 EXIST::FUNCTION:
1659ASN1_INTEGER_new 2131 EXIST::FUNCTION:
1660i2d_X509_AUX 2132 EXIST::FUNCTION:
1661ASN1_BIT_STRING_name_print 2134 EXIST::FUNCTION:BIO
1662X509_cmp 2135 EXIST::FUNCTION:
1663ASN1_STRING_length_set 2136 EXIST::FUNCTION:
1664DIRECTORYSTRING_new 2137 EXIST::FUNCTION:
1665X509_add1_trust_object 2140 EXIST::FUNCTION:
1666PKCS12_newpass 2141 EXIST::FUNCTION:
1667SMIME_write_PKCS7 2142 EXIST::FUNCTION:
1668SMIME_read_PKCS7 2143 EXIST::FUNCTION:
1669DES_set_key_checked 2144 EXIST::FUNCTION:DES
1670PKCS7_verify 2145 EXIST::FUNCTION:
1671PKCS7_encrypt 2146 EXIST::FUNCTION:
1672DES_set_key_unchecked 2147 EXIST::FUNCTION:DES
1673SMIME_crlf_copy 2148 EXIST::FUNCTION:
1674i2d_ASN1_PRINTABLESTRING 2149 EXIST::FUNCTION:
1675PKCS7_get0_signers 2150 EXIST::FUNCTION:
1676PKCS7_decrypt 2151 EXIST::FUNCTION:
1677SMIME_text 2152 EXIST::FUNCTION:
1678PKCS7_simple_smimecap 2153 EXIST::FUNCTION:
1679PKCS7_get_smimecap 2154 EXIST::FUNCTION:
1680PKCS7_sign 2155 EXIST::FUNCTION:
1681PKCS7_add_attrib_smimecap 2156 EXIST::FUNCTION:
1682CRYPTO_dbg_set_options 2157 EXIST::FUNCTION:
1683CRYPTO_remove_all_info 2158 EXIST::FUNCTION:
1684CRYPTO_get_mem_debug_functions 2159 EXIST::FUNCTION:
1685CRYPTO_is_mem_check_on 2160 EXIST::FUNCTION:
1686CRYPTO_set_mem_debug_functions 2161 EXIST::FUNCTION:
1687CRYPTO_pop_info 2162 EXIST::FUNCTION:
1688CRYPTO_push_info_ 2163 EXIST::FUNCTION:
1689CRYPTO_set_mem_debug_options 2164 EXIST::FUNCTION:
1690PEM_write_PKCS8PrivateKey_nid 2165 EXIST::FUNCTION:
1691PEM_write_bio_PKCS8PrivateKey_nid 2166 EXIST:!VMS:FUNCTION:
1692PEM_write_bio_PKCS8PrivKey_nid 2166 EXIST:VMS:FUNCTION:
1693d2i_PKCS8PrivateKey_bio 2167 EXIST::FUNCTION:
1694ASN1_NULL_free 2168 EXIST::FUNCTION:
1695d2i_ASN1_NULL 2169 EXIST::FUNCTION:
1696ASN1_NULL_new 2170 EXIST::FUNCTION:
1697i2d_PKCS8PrivateKey_bio 2171 EXIST::FUNCTION:
1698i2d_PKCS8PrivateKey_fp 2172 EXIST::FUNCTION:
1699i2d_ASN1_NULL 2173 EXIST::FUNCTION:
1700i2d_PKCS8PrivateKey_nid_fp 2174 EXIST::FUNCTION:
1701d2i_PKCS8PrivateKey_fp 2175 EXIST::FUNCTION:
1702i2d_PKCS8PrivateKey_nid_bio 2176 EXIST::FUNCTION:
1703i2d_PKCS8PrivateKeyInfo_fp 2177 EXIST::FUNCTION:FP_API
1704i2d_PKCS8PrivateKeyInfo_bio 2178 EXIST::FUNCTION:BIO
1705PEM_cb 2179 NOEXIST::FUNCTION:
1706i2d_PrivateKey_fp 2180 EXIST::FUNCTION:FP_API
1707d2i_PrivateKey_bio 2181 EXIST::FUNCTION:BIO
1708d2i_PrivateKey_fp 2182 EXIST::FUNCTION:FP_API
1709i2d_PrivateKey_bio 2183 EXIST::FUNCTION:BIO
1710X509_reject_clear 2184 EXIST::FUNCTION:
1711X509_TRUST_set_default 2185 EXIST::FUNCTION:
1712d2i_AutoPrivateKey 2186 EXIST::FUNCTION:
1713X509_ATTRIBUTE_get0_type 2187 EXIST::FUNCTION:
1714X509_ATTRIBUTE_set1_data 2188 EXIST::FUNCTION:
1715X509at_get_attr 2189 EXIST::FUNCTION:
1716X509at_get_attr_count 2190 EXIST::FUNCTION:
1717X509_ATTRIBUTE_create_by_NID 2191 EXIST::FUNCTION:
1718X509_ATTRIBUTE_set1_object 2192 EXIST::FUNCTION:
1719X509_ATTRIBUTE_count 2193 EXIST::FUNCTION:
1720X509_ATTRIBUTE_create_by_OBJ 2194 EXIST::FUNCTION:
1721X509_ATTRIBUTE_get0_object 2195 EXIST::FUNCTION:
1722X509at_get_attr_by_NID 2196 EXIST::FUNCTION:
1723X509at_add1_attr 2197 EXIST::FUNCTION:
1724X509_ATTRIBUTE_get0_data 2198 EXIST::FUNCTION:
1725X509at_delete_attr 2199 EXIST::FUNCTION:
1726X509at_get_attr_by_OBJ 2200 EXIST::FUNCTION:
1727RAND_add 2201 EXIST::FUNCTION:
1728BIO_number_written 2202 EXIST::FUNCTION:
1729BIO_number_read 2203 EXIST::FUNCTION:
1730X509_STORE_CTX_get1_chain 2204 EXIST::FUNCTION:
1731ERR_load_RAND_strings 2205 EXIST::FUNCTION:
1732RAND_pseudo_bytes 2206 EXIST::FUNCTION:
1733X509_REQ_get_attr_by_NID 2207 EXIST::FUNCTION:
1734X509_REQ_get_attr 2208 EXIST::FUNCTION:
1735X509_REQ_add1_attr_by_NID 2209 EXIST::FUNCTION:
1736X509_REQ_get_attr_by_OBJ 2210 EXIST::FUNCTION:
1737X509at_add1_attr_by_NID 2211 EXIST::FUNCTION:
1738X509_REQ_add1_attr_by_OBJ 2212 EXIST::FUNCTION:
1739X509_REQ_get_attr_count 2213 EXIST::FUNCTION:
1740X509_REQ_add1_attr 2214 EXIST::FUNCTION:
1741X509_REQ_delete_attr 2215 EXIST::FUNCTION:
1742X509at_add1_attr_by_OBJ 2216 EXIST::FUNCTION:
1743X509_REQ_add1_attr_by_txt 2217 EXIST::FUNCTION:
1744X509_ATTRIBUTE_create_by_txt 2218 EXIST::FUNCTION:
1745X509at_add1_attr_by_txt 2219 EXIST::FUNCTION:
1746BN_pseudo_rand 2239 EXIST::FUNCTION:
1747BN_is_prime_fasttest 2240 EXIST::FUNCTION:
1748BN_CTX_end 2241 EXIST::FUNCTION:
1749BN_CTX_start 2242 EXIST::FUNCTION:
1750BN_CTX_get 2243 EXIST::FUNCTION:
1751EVP_PKEY2PKCS8_broken 2244 EXIST::FUNCTION:
1752ASN1_STRING_TABLE_add 2245 EXIST::FUNCTION:
1753CRYPTO_dbg_get_options 2246 EXIST::FUNCTION:
1754AUTHORITY_INFO_ACCESS_new 2247 EXIST::FUNCTION:
1755CRYPTO_get_mem_debug_options 2248 EXIST::FUNCTION:
1756DES_crypt 2249 EXIST::FUNCTION:DES
1757PEM_write_bio_X509_REQ_NEW 2250 EXIST::FUNCTION:
1758PEM_write_X509_REQ_NEW 2251 EXIST:!WIN16:FUNCTION:
1759BIO_callback_ctrl 2252 EXIST::FUNCTION:
1760RAND_egd 2253 EXIST::FUNCTION:
1761RAND_status 2254 EXIST::FUNCTION:
1762bn_dump1 2255 NOEXIST::FUNCTION:
1763DES_check_key_parity 2256 EXIST::FUNCTION:DES
1764lh_num_items 2257 EXIST::FUNCTION:
1765RAND_event 2258 EXIST:WIN32:FUNCTION:
1766DSO_new 2259 EXIST::FUNCTION:
1767DSO_new_method 2260 EXIST::FUNCTION:
1768DSO_free 2261 EXIST::FUNCTION:
1769DSO_flags 2262 EXIST::FUNCTION:
1770DSO_up 2263 NOEXIST::FUNCTION:
1771DSO_set_default_method 2264 EXIST::FUNCTION:
1772DSO_get_default_method 2265 EXIST::FUNCTION:
1773DSO_get_method 2266 EXIST::FUNCTION:
1774DSO_set_method 2267 EXIST::FUNCTION:
1775DSO_load 2268 EXIST::FUNCTION:
1776DSO_bind_var 2269 EXIST::FUNCTION:
1777DSO_METHOD_null 2270 EXIST::FUNCTION:
1778DSO_METHOD_openssl 2271 EXIST::FUNCTION:
1779DSO_METHOD_dlfcn 2272 EXIST::FUNCTION:
1780DSO_METHOD_win32 2273 EXIST::FUNCTION:
1781ERR_load_DSO_strings 2274 EXIST::FUNCTION:
1782DSO_METHOD_dl 2275 EXIST::FUNCTION:
1783NCONF_load 2276 EXIST::FUNCTION:
1784NCONF_load_fp 2278 EXIST::FUNCTION:FP_API
1785NCONF_new 2279 EXIST::FUNCTION:
1786NCONF_get_string 2280 EXIST::FUNCTION:
1787NCONF_free 2281 EXIST::FUNCTION:
1788NCONF_get_number 2282 NOEXIST::FUNCTION:
1789CONF_dump_fp 2283 EXIST::FUNCTION:
1790NCONF_load_bio 2284 EXIST::FUNCTION:
1791NCONF_dump_fp 2285 EXIST::FUNCTION:
1792NCONF_get_section 2286 EXIST::FUNCTION:
1793NCONF_dump_bio 2287 EXIST::FUNCTION:
1794CONF_dump_bio 2288 EXIST::FUNCTION:
1795NCONF_free_data 2289 EXIST::FUNCTION:
1796CONF_set_default_method 2290 EXIST::FUNCTION:
1797ERR_error_string_n 2291 EXIST::FUNCTION:
1798BIO_snprintf 2292 EXIST::FUNCTION:
1799DSO_ctrl 2293 EXIST::FUNCTION:
1800i2d_ASN1_SET_OF_ASN1_INTEGER 2317 NOEXIST::FUNCTION:
1801i2d_ASN1_SET_OF_PKCS12_SAFEBAG 2320 NOEXIST::FUNCTION:
1802i2d_ASN1_SET_OF_PKCS7 2328 NOEXIST::FUNCTION:
1803BIO_vfree 2334 EXIST::FUNCTION:
1804d2i_ASN1_SET_OF_ASN1_INTEGER 2339 NOEXIST::FUNCTION:
1805d2i_ASN1_SET_OF_PKCS12_SAFEBAG 2341 NOEXIST::FUNCTION:
1806ASN1_UTCTIME_get 2350 NOEXIST::FUNCTION:
1807X509_REQ_digest 2362 EXIST::FUNCTION:EVP
1808X509_CRL_digest 2391 EXIST::FUNCTION:EVP
1809d2i_ASN1_SET_OF_PKCS7 2397 NOEXIST::FUNCTION:
1810EVP_CIPHER_CTX_set_key_length 2399 EXIST::FUNCTION:
1811EVP_CIPHER_CTX_ctrl 2400 EXIST::FUNCTION:
1812BN_mod_exp_mont_word 2401 EXIST::FUNCTION:
1813RAND_egd_bytes 2402 EXIST::FUNCTION:
1814X509_REQ_get1_email 2403 EXIST::FUNCTION:
1815X509_get1_email 2404 EXIST::FUNCTION:
1816X509_email_free 2405 EXIST::FUNCTION:
1817i2d_RSA_NET 2406 EXIST::FUNCTION:RSA
1818d2i_RSA_NET_2 2407 NOEXIST::FUNCTION:
1819d2i_RSA_NET 2408 EXIST::FUNCTION:RSA
1820DSO_bind_func 2409 EXIST::FUNCTION:
1821CRYPTO_get_new_dynlockid 2410 EXIST::FUNCTION:
1822sk_new_null 2411 EXIST::FUNCTION:
1823CRYPTO_set_dynlock_destroy_callback 2412 EXIST:!VMS:FUNCTION:
1824CRYPTO_set_dynlock_destroy_cb 2412 EXIST:VMS:FUNCTION:
1825CRYPTO_destroy_dynlockid 2413 EXIST::FUNCTION:
1826CRYPTO_set_dynlock_size 2414 NOEXIST::FUNCTION:
1827CRYPTO_set_dynlock_create_callback 2415 EXIST:!VMS:FUNCTION:
1828CRYPTO_set_dynlock_create_cb 2415 EXIST:VMS:FUNCTION:
1829CRYPTO_set_dynlock_lock_callback 2416 EXIST:!VMS:FUNCTION:
1830CRYPTO_set_dynlock_lock_cb 2416 EXIST:VMS:FUNCTION:
1831CRYPTO_get_dynlock_lock_callback 2417 EXIST:!VMS:FUNCTION:
1832CRYPTO_get_dynlock_lock_cb 2417 EXIST:VMS:FUNCTION:
1833CRYPTO_get_dynlock_destroy_callback 2418 EXIST:!VMS:FUNCTION:
1834CRYPTO_get_dynlock_destroy_cb 2418 EXIST:VMS:FUNCTION:
1835CRYPTO_get_dynlock_value 2419 EXIST::FUNCTION:
1836CRYPTO_get_dynlock_create_callback 2420 EXIST:!VMS:FUNCTION:
1837CRYPTO_get_dynlock_create_cb 2420 EXIST:VMS:FUNCTION:
1838c2i_ASN1_BIT_STRING 2421 EXIST::FUNCTION:
1839i2c_ASN1_BIT_STRING 2422 EXIST::FUNCTION:
1840RAND_poll 2423 EXIST::FUNCTION:
1841c2i_ASN1_INTEGER 2424 EXIST::FUNCTION:
1842i2c_ASN1_INTEGER 2425 EXIST::FUNCTION:
1843BIO_dump_indent 2426 EXIST::FUNCTION:
1844ASN1_parse_dump 2427 EXIST::FUNCTION:BIO
1845c2i_ASN1_OBJECT 2428 EXIST::FUNCTION:
1846X509_NAME_print_ex_fp 2429 EXIST::FUNCTION:FP_API
1847ASN1_STRING_print_ex_fp 2430 EXIST::FUNCTION:FP_API
1848X509_NAME_print_ex 2431 EXIST::FUNCTION:BIO
1849ASN1_STRING_print_ex 2432 EXIST::FUNCTION:BIO
1850MD4 2433 EXIST::FUNCTION:MD4
1851MD4_Transform 2434 EXIST::FUNCTION:MD4
1852MD4_Final 2435 EXIST::FUNCTION:MD4
1853MD4_Update 2436 EXIST::FUNCTION:MD4
1854MD4_Init 2437 EXIST::FUNCTION:MD4
1855EVP_md4 2438 EXIST::FUNCTION:MD4
1856i2d_PUBKEY_bio 2439 EXIST::FUNCTION:BIO
1857i2d_PUBKEY_fp 2440 EXIST::FUNCTION:FP_API
1858d2i_PUBKEY_bio 2441 EXIST::FUNCTION:BIO
1859ASN1_STRING_to_UTF8 2442 EXIST::FUNCTION:
1860BIO_vprintf 2443 EXIST::FUNCTION:
1861BIO_vsnprintf 2444 EXIST::FUNCTION:
1862d2i_PUBKEY_fp 2445 EXIST::FUNCTION:FP_API
1863X509_cmp_time 2446 EXIST::FUNCTION:
1864X509_STORE_CTX_set_time 2447 EXIST::FUNCTION:
1865X509_STORE_CTX_get1_issuer 2448 EXIST::FUNCTION:
1866X509_OBJECT_retrieve_match 2449 EXIST::FUNCTION:
1867X509_OBJECT_idx_by_subject 2450 EXIST::FUNCTION:
1868X509_STORE_CTX_set_flags 2451 EXIST::FUNCTION:
1869X509_STORE_CTX_trusted_stack 2452 EXIST::FUNCTION:
1870X509_time_adj 2453 EXIST::FUNCTION:
1871X509_check_issued 2454 EXIST::FUNCTION:
1872ASN1_UTCTIME_cmp_time_t 2455 EXIST::FUNCTION:
1873DES_set_weak_key_flag 2456 NOEXIST::FUNCTION:
1874DES_check_key 2457 NOEXIST::FUNCTION:
1875DES_rw_mode 2458 NOEXIST::FUNCTION:
1876RSA_PKCS1_RSAref 2459 NOEXIST::FUNCTION:
1877X509_keyid_set1 2460 EXIST::FUNCTION:
1878BIO_next 2461 EXIST::FUNCTION:
1879DSO_METHOD_vms 2462 EXIST::FUNCTION:
1880BIO_f_linebuffer 2463 EXIST:VMS:FUNCTION:
1881BN_bntest_rand 2464 EXIST::FUNCTION:
1882OPENSSL_issetugid 2465 EXIST::FUNCTION:
1883BN_rand_range 2466 EXIST::FUNCTION:
1884ERR_load_ENGINE_strings 2467 EXIST::FUNCTION:
1885ENGINE_set_DSA 2468 EXIST::FUNCTION:
1886ENGINE_get_finish_function 2469 EXIST::FUNCTION:
1887ENGINE_get_default_RSA 2470 EXIST::FUNCTION:
1888ENGINE_get_BN_mod_exp 2471 NOEXIST::FUNCTION:
1889DSA_get_default_openssl_method 2472 NOEXIST::FUNCTION:
1890ENGINE_set_DH 2473 EXIST::FUNCTION:
1891ENGINE_set_def_BN_mod_exp_crt 2474 NOEXIST::FUNCTION:
1892ENGINE_set_default_BN_mod_exp_crt 2474 NOEXIST::FUNCTION:
1893ENGINE_init 2475 EXIST::FUNCTION:
1894DH_get_default_openssl_method 2476 NOEXIST::FUNCTION:
1895RSA_set_default_openssl_method 2477 NOEXIST::FUNCTION:
1896ENGINE_finish 2478 EXIST::FUNCTION:
1897ENGINE_load_public_key 2479 EXIST::FUNCTION:
1898ENGINE_get_DH 2480 EXIST::FUNCTION:
1899ENGINE_ctrl 2481 EXIST::FUNCTION:
1900ENGINE_get_init_function 2482 EXIST::FUNCTION:
1901ENGINE_set_init_function 2483 EXIST::FUNCTION:
1902ENGINE_set_default_DSA 2484 EXIST::FUNCTION:
1903ENGINE_get_name 2485 EXIST::FUNCTION:
1904ENGINE_get_last 2486 EXIST::FUNCTION:
1905ENGINE_get_prev 2487 EXIST::FUNCTION:
1906ENGINE_get_default_DH 2488 EXIST::FUNCTION:
1907ENGINE_get_RSA 2489 EXIST::FUNCTION:
1908ENGINE_set_default 2490 EXIST::FUNCTION:
1909ENGINE_get_RAND 2491 EXIST::FUNCTION:
1910ENGINE_get_first 2492 EXIST::FUNCTION:
1911ENGINE_by_id 2493 EXIST::FUNCTION:
1912ENGINE_set_finish_function 2494 EXIST::FUNCTION:
1913ENGINE_get_def_BN_mod_exp_crt 2495 NOEXIST::FUNCTION:
1914ENGINE_get_default_BN_mod_exp_crt 2495 NOEXIST::FUNCTION:
1915RSA_get_default_openssl_method 2496 NOEXIST::FUNCTION:
1916ENGINE_set_RSA 2497 EXIST::FUNCTION:
1917ENGINE_load_private_key 2498 EXIST::FUNCTION:
1918ENGINE_set_default_RAND 2499 EXIST::FUNCTION:
1919ENGINE_set_BN_mod_exp 2500 NOEXIST::FUNCTION:
1920ENGINE_remove 2501 EXIST::FUNCTION:
1921ENGINE_free 2502 EXIST::FUNCTION:
1922ENGINE_get_BN_mod_exp_crt 2503 NOEXIST::FUNCTION:
1923ENGINE_get_next 2504 EXIST::FUNCTION:
1924ENGINE_set_name 2505 EXIST::FUNCTION:
1925ENGINE_get_default_DSA 2506 EXIST::FUNCTION:
1926ENGINE_set_default_BN_mod_exp 2507 NOEXIST::FUNCTION:
1927ENGINE_set_default_RSA 2508 EXIST::FUNCTION:
1928ENGINE_get_default_RAND 2509 EXIST::FUNCTION:
1929ENGINE_get_default_BN_mod_exp 2510 NOEXIST::FUNCTION:
1930ENGINE_set_RAND 2511 EXIST::FUNCTION:
1931ENGINE_set_id 2512 EXIST::FUNCTION:
1932ENGINE_set_BN_mod_exp_crt 2513 NOEXIST::FUNCTION:
1933ENGINE_set_default_DH 2514 EXIST::FUNCTION:
1934ENGINE_new 2515 EXIST::FUNCTION:
1935ENGINE_get_id 2516 EXIST::FUNCTION:
1936DSA_set_default_openssl_method 2517 NOEXIST::FUNCTION:
1937ENGINE_add 2518 EXIST::FUNCTION:
1938DH_set_default_openssl_method 2519 NOEXIST::FUNCTION:
1939ENGINE_get_DSA 2520 EXIST::FUNCTION:
1940ENGINE_get_ctrl_function 2521 EXIST::FUNCTION:
1941ENGINE_set_ctrl_function 2522 EXIST::FUNCTION:
1942BN_pseudo_rand_range 2523 EXIST::FUNCTION:
1943X509_STORE_CTX_set_verify_cb 2524 EXIST::FUNCTION:
1944ERR_load_COMP_strings 2525 EXIST::FUNCTION:
1945PKCS12_item_decrypt_d2i 2526 EXIST::FUNCTION:
1946ASN1_UTF8STRING_it 2527 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
1947ASN1_UTF8STRING_it 2527 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
1948ENGINE_unregister_ciphers 2528 EXIST::FUNCTION:
1949ENGINE_get_ciphers 2529 EXIST::FUNCTION:
1950d2i_OCSP_BASICRESP 2530 EXIST::FUNCTION:
1951KRB5_CHECKSUM_it 2531 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
1952KRB5_CHECKSUM_it 2531 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
1953EC_POINT_add 2532 EXIST::FUNCTION:EC
1954ASN1_item_ex_i2d 2533 EXIST::FUNCTION:
1955OCSP_CERTID_it 2534 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
1956OCSP_CERTID_it 2534 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
1957d2i_OCSP_RESPBYTES 2535 EXIST::FUNCTION:
1958X509V3_add1_i2d 2536 EXIST::FUNCTION:
1959PKCS7_ENVELOPE_it 2537 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
1960PKCS7_ENVELOPE_it 2537 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
1961UI_add_input_boolean 2538 EXIST::FUNCTION:
1962ENGINE_unregister_RSA 2539 EXIST::FUNCTION:
1963X509V3_EXT_nconf 2540 EXIST::FUNCTION:
1964ASN1_GENERALSTRING_free 2541 EXIST::FUNCTION:
1965d2i_OCSP_CERTSTATUS 2542 EXIST::FUNCTION:
1966X509_REVOKED_set_serialNumber 2543 EXIST::FUNCTION:
1967X509_print_ex 2544 EXIST::FUNCTION:BIO
1968OCSP_ONEREQ_get1_ext_d2i 2545 EXIST::FUNCTION:
1969ENGINE_register_all_RAND 2546 EXIST::FUNCTION:
1970ENGINE_load_dynamic 2547 EXIST::FUNCTION:
1971PBKDF2PARAM_it 2548 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
1972PBKDF2PARAM_it 2548 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
1973EXTENDED_KEY_USAGE_new 2549 EXIST::FUNCTION:
1974EC_GROUP_clear_free 2550 EXIST::FUNCTION:EC
1975OCSP_sendreq_bio 2551 EXIST::FUNCTION:
1976ASN1_item_digest 2552 EXIST::FUNCTION:EVP
1977OCSP_BASICRESP_delete_ext 2553 EXIST::FUNCTION:
1978OCSP_SIGNATURE_it 2554 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
1979OCSP_SIGNATURE_it 2554 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
1980X509_CRL_it 2555 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
1981X509_CRL_it 2555 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
1982OCSP_BASICRESP_add_ext 2556 EXIST::FUNCTION:
1983KRB5_ENCKEY_it 2557 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
1984KRB5_ENCKEY_it 2557 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
1985UI_method_set_closer 2558 EXIST::FUNCTION:
1986X509_STORE_set_purpose 2559 EXIST::FUNCTION:
1987i2d_ASN1_GENERALSTRING 2560 EXIST::FUNCTION:
1988OCSP_response_status 2561 EXIST::FUNCTION:
1989i2d_OCSP_SERVICELOC 2562 EXIST::FUNCTION:
1990ENGINE_get_digest_engine 2563 EXIST::FUNCTION:
1991EC_GROUP_set_curve_GFp 2564 EXIST::FUNCTION:EC
1992OCSP_REQUEST_get_ext_by_OBJ 2565 EXIST::FUNCTION:
1993_ossl_old_des_random_key 2566 EXIST::FUNCTION:DES
1994ASN1_T61STRING_it 2567 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
1995ASN1_T61STRING_it 2567 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
1996EC_GROUP_method_of 2568 EXIST::FUNCTION:EC
1997i2d_KRB5_APREQ 2569 EXIST::FUNCTION:
1998_ossl_old_des_encrypt 2570 EXIST::FUNCTION:DES
1999ASN1_PRINTABLE_new 2571 EXIST::FUNCTION:
2000HMAC_Init_ex 2572 EXIST::FUNCTION:HMAC
2001d2i_KRB5_AUTHENT 2573 EXIST::FUNCTION:
2002OCSP_archive_cutoff_new 2574 EXIST::FUNCTION:
2003EC_POINT_set_Jprojective_coordinates_GFp 2575 EXIST:!VMS:FUNCTION:EC
2004EC_POINT_set_Jproj_coords_GFp 2575 EXIST:VMS:FUNCTION:EC
2005_ossl_old_des_is_weak_key 2576 EXIST::FUNCTION:DES
2006OCSP_BASICRESP_get_ext_by_OBJ 2577 EXIST::FUNCTION:
2007EC_POINT_oct2point 2578 EXIST::FUNCTION:EC
2008OCSP_SINGLERESP_get_ext_count 2579 EXIST::FUNCTION:
2009UI_ctrl 2580 EXIST::FUNCTION:
2010_shadow_DES_rw_mode 2581 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:DES
2011_shadow_DES_rw_mode 2581 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:DES
2012asn1_do_adb 2582 EXIST::FUNCTION:
2013ASN1_template_i2d 2583 EXIST::FUNCTION:
2014ENGINE_register_DH 2584 EXIST::FUNCTION:
2015UI_construct_prompt 2585 EXIST::FUNCTION:
2016X509_STORE_set_trust 2586 EXIST::FUNCTION:
2017UI_dup_input_string 2587 EXIST::FUNCTION:
2018d2i_KRB5_APREQ 2588 EXIST::FUNCTION:
2019EVP_MD_CTX_copy_ex 2589 EXIST::FUNCTION:
2020OCSP_request_is_signed 2590 EXIST::FUNCTION:
2021i2d_OCSP_REQINFO 2591 EXIST::FUNCTION:
2022KRB5_ENCKEY_free 2592 EXIST::FUNCTION:
2023OCSP_resp_get0 2593 EXIST::FUNCTION:
2024GENERAL_NAME_it 2594 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2025GENERAL_NAME_it 2594 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2026ASN1_GENERALIZEDTIME_it 2595 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2027ASN1_GENERALIZEDTIME_it 2595 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2028X509_STORE_set_flags 2596 EXIST::FUNCTION:
2029EC_POINT_set_compressed_coordinates_GFp 2597 EXIST:!VMS:FUNCTION:EC
2030EC_POINT_set_compr_coords_GFp 2597 EXIST:VMS:FUNCTION:EC
2031OCSP_response_status_str 2598 EXIST::FUNCTION:
2032d2i_OCSP_REVOKEDINFO 2599 EXIST::FUNCTION:
2033OCSP_basic_add1_cert 2600 EXIST::FUNCTION:
2034ERR_get_implementation 2601 EXIST::FUNCTION:
2035EVP_CipherFinal_ex 2602 EXIST::FUNCTION:
2036OCSP_CERTSTATUS_new 2603 EXIST::FUNCTION:
2037CRYPTO_cleanup_all_ex_data 2604 EXIST::FUNCTION:
2038OCSP_resp_find 2605 EXIST::FUNCTION:
2039BN_nnmod 2606 EXIST::FUNCTION:
2040X509_CRL_sort 2607 EXIST::FUNCTION:
2041X509_REVOKED_set_revocationDate 2608 EXIST::FUNCTION:
2042ENGINE_register_RAND 2609 EXIST::FUNCTION:
2043OCSP_SERVICELOC_new 2610 EXIST::FUNCTION:
2044EC_POINT_set_affine_coordinates_GFp 2611 EXIST:!VMS:FUNCTION:EC
2045EC_POINT_set_affine_coords_GFp 2611 EXIST:VMS:FUNCTION:EC
2046_ossl_old_des_options 2612 EXIST::FUNCTION:DES
2047SXNET_it 2613 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2048SXNET_it 2613 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2049UI_dup_input_boolean 2614 EXIST::FUNCTION:
2050PKCS12_add_CSPName_asc 2615 EXIST::FUNCTION:
2051EC_POINT_is_at_infinity 2616 EXIST::FUNCTION:EC
2052ENGINE_load_openbsd_dev_crypto 2617 EXIST::FUNCTION:
2053DSO_convert_filename 2618 EXIST::FUNCTION:
2054POLICYQUALINFO_it 2619 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2055POLICYQUALINFO_it 2619 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2056ENGINE_register_ciphers 2620 EXIST::FUNCTION:
2057BN_mod_lshift_quick 2621 EXIST::FUNCTION:
2058DSO_set_filename 2622 EXIST::FUNCTION:
2059ASN1_item_free 2623 EXIST::FUNCTION:
2060KRB5_TKTBODY_free 2624 EXIST::FUNCTION:
2061AUTHORITY_KEYID_it 2625 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2062AUTHORITY_KEYID_it 2625 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2063KRB5_APREQBODY_new 2626 EXIST::FUNCTION:
2064X509V3_EXT_REQ_add_nconf 2627 EXIST::FUNCTION:
2065ENGINE_ctrl_cmd_string 2628 EXIST::FUNCTION:
2066i2d_OCSP_RESPDATA 2629 EXIST::FUNCTION:
2067EVP_MD_CTX_init 2630 EXIST::FUNCTION:
2068EXTENDED_KEY_USAGE_free 2631 EXIST::FUNCTION:
2069PKCS7_ATTR_SIGN_it 2632 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2070PKCS7_ATTR_SIGN_it 2632 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2071UI_add_error_string 2633 EXIST::FUNCTION:
2072KRB5_CHECKSUM_free 2634 EXIST::FUNCTION:
2073OCSP_REQUEST_get_ext 2635 EXIST::FUNCTION:
2074ENGINE_load_ubsec 2636 EXIST::FUNCTION:
2075ENGINE_register_all_digests 2637 EXIST::FUNCTION:
2076PKEY_USAGE_PERIOD_it 2638 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2077PKEY_USAGE_PERIOD_it 2638 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2078PKCS12_unpack_authsafes 2639 EXIST::FUNCTION:
2079ASN1_item_unpack 2640 EXIST::FUNCTION:
2080NETSCAPE_SPKAC_it 2641 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2081NETSCAPE_SPKAC_it 2641 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2082X509_REVOKED_it 2642 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2083X509_REVOKED_it 2642 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2084ASN1_STRING_encode 2643 EXIST::FUNCTION:
2085EVP_aes_128_ecb 2644 EXIST::FUNCTION:AES
2086KRB5_AUTHENT_free 2645 EXIST::FUNCTION:
2087OCSP_BASICRESP_get_ext_by_critical 2646 EXIST:!VMS:FUNCTION:
2088OCSP_BASICRESP_get_ext_by_crit 2646 EXIST:VMS:FUNCTION:
2089OCSP_cert_status_str 2647 EXIST::FUNCTION:
2090d2i_OCSP_REQUEST 2648 EXIST::FUNCTION:
2091UI_dup_info_string 2649 EXIST::FUNCTION:
2092_ossl_old_des_xwhite_in2out 2650 EXIST::FUNCTION:DES
2093PKCS12_it 2651 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2094PKCS12_it 2651 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2095OCSP_SINGLERESP_get_ext_by_critical 2652 EXIST:!VMS:FUNCTION:
2096OCSP_SINGLERESP_get_ext_by_crit 2652 EXIST:VMS:FUNCTION:
2097OCSP_CERTSTATUS_free 2653 EXIST::FUNCTION:
2098_ossl_old_des_crypt 2654 EXIST::FUNCTION:DES
2099ASN1_item_i2d 2655 EXIST::FUNCTION:
2100EVP_DecryptFinal_ex 2656 EXIST::FUNCTION:
2101ENGINE_load_openssl 2657 EXIST::FUNCTION:
2102ENGINE_get_cmd_defns 2658 EXIST::FUNCTION:
2103ENGINE_set_load_privkey_function 2659 EXIST:!VMS:FUNCTION:
2104ENGINE_set_load_privkey_fn 2659 EXIST:VMS:FUNCTION:
2105EVP_EncryptFinal_ex 2660 EXIST::FUNCTION:
2106ENGINE_set_default_digests 2661 EXIST::FUNCTION:
2107X509_get0_pubkey_bitstr 2662 EXIST::FUNCTION:
2108asn1_ex_i2c 2663 EXIST::FUNCTION:
2109ENGINE_register_RSA 2664 EXIST::FUNCTION:
2110ENGINE_unregister_DSA 2665 EXIST::FUNCTION:
2111_ossl_old_des_key_sched 2666 EXIST::FUNCTION:DES
2112X509_EXTENSION_it 2667 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2113X509_EXTENSION_it 2667 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2114i2d_KRB5_AUTHENT 2668 EXIST::FUNCTION:
2115SXNETID_it 2669 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2116SXNETID_it 2669 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2117d2i_OCSP_SINGLERESP 2670 EXIST::FUNCTION:
2118EDIPARTYNAME_new 2671 EXIST::FUNCTION:
2119PKCS12_certbag2x509 2672 EXIST::FUNCTION:
2120_ossl_old_des_ofb64_encrypt 2673 EXIST::FUNCTION:DES
2121d2i_EXTENDED_KEY_USAGE 2674 EXIST::FUNCTION:
2122ERR_print_errors_cb 2675 EXIST::FUNCTION:
2123ENGINE_set_ciphers 2676 EXIST::FUNCTION:
2124d2i_KRB5_APREQBODY 2677 EXIST::FUNCTION:
2125UI_method_get_flusher 2678 EXIST::FUNCTION:
2126X509_PUBKEY_it 2679 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2127X509_PUBKEY_it 2679 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2128_ossl_old_des_enc_read 2680 EXIST::FUNCTION:DES
2129PKCS7_ENCRYPT_it 2681 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2130PKCS7_ENCRYPT_it 2681 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2131i2d_OCSP_RESPONSE 2682 EXIST::FUNCTION:
2132EC_GROUP_get_cofactor 2683 EXIST::FUNCTION:EC
2133PKCS12_unpack_p7data 2684 EXIST::FUNCTION:
2134d2i_KRB5_AUTHDATA 2685 EXIST::FUNCTION:
2135OCSP_copy_nonce 2686 EXIST::FUNCTION:
2136KRB5_AUTHDATA_new 2687 EXIST::FUNCTION:
2137OCSP_RESPDATA_new 2688 EXIST::FUNCTION:
2138EC_GFp_mont_method 2689 EXIST::FUNCTION:EC
2139OCSP_REVOKEDINFO_free 2690 EXIST::FUNCTION:
2140UI_get_ex_data 2691 EXIST::FUNCTION:
2141KRB5_APREQBODY_free 2692 EXIST::FUNCTION:
2142EC_GROUP_get0_generator 2693 EXIST::FUNCTION:EC
2143UI_get_default_method 2694 EXIST::FUNCTION:
2144X509V3_set_nconf 2695 EXIST::FUNCTION:
2145PKCS12_item_i2d_encrypt 2696 EXIST::FUNCTION:
2146X509_add1_ext_i2d 2697 EXIST::FUNCTION:
2147PKCS7_SIGNER_INFO_it 2698 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2148PKCS7_SIGNER_INFO_it 2698 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2149KRB5_PRINCNAME_new 2699 EXIST::FUNCTION:
2150PKCS12_SAFEBAG_it 2700 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2151PKCS12_SAFEBAG_it 2700 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2152EC_GROUP_get_order 2701 EXIST::FUNCTION:EC
2153d2i_OCSP_RESPID 2702 EXIST::FUNCTION:
2154OCSP_request_verify 2703 EXIST::FUNCTION:
2155NCONF_get_number_e 2704 EXIST::FUNCTION:
2156_ossl_old_des_decrypt3 2705 EXIST::FUNCTION:DES
2157X509_signature_print 2706 EXIST::FUNCTION:EVP
2158OCSP_SINGLERESP_free 2707 EXIST::FUNCTION:
2159ENGINE_load_builtin_engines 2708 EXIST::FUNCTION:
2160i2d_OCSP_ONEREQ 2709 EXIST::FUNCTION:
2161OCSP_REQUEST_add_ext 2710 EXIST::FUNCTION:
2162OCSP_RESPBYTES_new 2711 EXIST::FUNCTION:
2163EVP_MD_CTX_create 2712 EXIST::FUNCTION:
2164OCSP_resp_find_status 2713 EXIST::FUNCTION:
2165X509_ALGOR_it 2714 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2166X509_ALGOR_it 2714 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2167ASN1_TIME_it 2715 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2168ASN1_TIME_it 2715 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2169OCSP_request_set1_name 2716 EXIST::FUNCTION:
2170OCSP_ONEREQ_get_ext_count 2717 EXIST::FUNCTION:
2171UI_get0_result 2718 EXIST::FUNCTION:
2172PKCS12_AUTHSAFES_it 2719 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2173PKCS12_AUTHSAFES_it 2719 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2174EVP_aes_256_ecb 2720 EXIST::FUNCTION:AES
2175PKCS12_pack_authsafes 2721 EXIST::FUNCTION:
2176ASN1_IA5STRING_it 2722 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2177ASN1_IA5STRING_it 2722 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2178UI_get_input_flags 2723 EXIST::FUNCTION:
2179EC_GROUP_set_generator 2724 EXIST::FUNCTION:EC
2180_ossl_old_des_string_to_2keys 2725 EXIST::FUNCTION:DES
2181OCSP_CERTID_free 2726 EXIST::FUNCTION:
2182X509_CERT_AUX_it 2727 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2183X509_CERT_AUX_it 2727 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2184CERTIFICATEPOLICIES_it 2728 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2185CERTIFICATEPOLICIES_it 2728 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2186_ossl_old_des_ede3_cbc_encrypt 2729 EXIST::FUNCTION:DES
2187RAND_set_rand_engine 2730 EXIST::FUNCTION:
2188DSO_get_loaded_filename 2731 EXIST::FUNCTION:
2189X509_ATTRIBUTE_it 2732 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2190X509_ATTRIBUTE_it 2732 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2191OCSP_ONEREQ_get_ext_by_NID 2733 EXIST::FUNCTION:
2192PKCS12_decrypt_skey 2734 EXIST::FUNCTION:
2193KRB5_AUTHENT_it 2735 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2194KRB5_AUTHENT_it 2735 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2195UI_dup_error_string 2736 EXIST::FUNCTION:
2196RSAPublicKey_it 2737 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:RSA
2197RSAPublicKey_it 2737 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:RSA
2198i2d_OCSP_REQUEST 2738 EXIST::FUNCTION:
2199PKCS12_x509crl2certbag 2739 EXIST::FUNCTION:
2200OCSP_SERVICELOC_it 2740 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2201OCSP_SERVICELOC_it 2740 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2202ASN1_item_sign 2741 EXIST::FUNCTION:EVP
2203X509_CRL_set_issuer_name 2742 EXIST::FUNCTION:
2204OBJ_NAME_do_all_sorted 2743 EXIST::FUNCTION:
2205i2d_OCSP_BASICRESP 2744 EXIST::FUNCTION:
2206i2d_OCSP_RESPBYTES 2745 EXIST::FUNCTION:
2207PKCS12_unpack_p7encdata 2746 EXIST::FUNCTION:
2208HMAC_CTX_init 2747 EXIST::FUNCTION:HMAC
2209ENGINE_get_digest 2748 EXIST::FUNCTION:
2210OCSP_RESPONSE_print 2749 EXIST::FUNCTION:
2211KRB5_TKTBODY_it 2750 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2212KRB5_TKTBODY_it 2750 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2213ACCESS_DESCRIPTION_it 2751 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2214ACCESS_DESCRIPTION_it 2751 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2215PKCS7_ISSUER_AND_SERIAL_it 2752 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2216PKCS7_ISSUER_AND_SERIAL_it 2752 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2217PBE2PARAM_it 2753 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2218PBE2PARAM_it 2753 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2219PKCS12_certbag2x509crl 2754 EXIST::FUNCTION:
2220PKCS7_SIGNED_it 2755 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2221PKCS7_SIGNED_it 2755 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2222ENGINE_get_cipher 2756 EXIST::FUNCTION:
2223i2d_OCSP_CRLID 2757 EXIST::FUNCTION:
2224OCSP_SINGLERESP_new 2758 EXIST::FUNCTION:
2225ENGINE_cmd_is_executable 2759 EXIST::FUNCTION:
2226RSA_up_ref 2760 EXIST::FUNCTION:RSA
2227ASN1_GENERALSTRING_it 2761 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2228ASN1_GENERALSTRING_it 2761 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2229ENGINE_register_DSA 2762 EXIST::FUNCTION:
2230X509V3_EXT_add_nconf_sk 2763 EXIST::FUNCTION:
2231ENGINE_set_load_pubkey_function 2764 EXIST::FUNCTION:
2232PKCS8_decrypt 2765 EXIST::FUNCTION:
2233PEM_bytes_read_bio 2766 EXIST::FUNCTION:BIO
2234DIRECTORYSTRING_it 2767 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2235DIRECTORYSTRING_it 2767 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2236d2i_OCSP_CRLID 2768 EXIST::FUNCTION:
2237EC_POINT_is_on_curve 2769 EXIST::FUNCTION:EC
2238CRYPTO_set_locked_mem_ex_functions 2770 EXIST:!VMS:FUNCTION:
2239CRYPTO_set_locked_mem_ex_funcs 2770 EXIST:VMS:FUNCTION:
2240d2i_KRB5_CHECKSUM 2771 EXIST::FUNCTION:
2241ASN1_item_dup 2772 EXIST::FUNCTION:
2242X509_it 2773 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2243X509_it 2773 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2244BN_mod_add 2774 EXIST::FUNCTION:
2245KRB5_AUTHDATA_free 2775 EXIST::FUNCTION:
2246_ossl_old_des_cbc_cksum 2776 EXIST::FUNCTION:DES
2247ASN1_item_verify 2777 EXIST::FUNCTION:EVP
2248CRYPTO_set_mem_ex_functions 2778 EXIST::FUNCTION:
2249EC_POINT_get_Jprojective_coordinates_GFp 2779 EXIST:!VMS:FUNCTION:EC
2250EC_POINT_get_Jproj_coords_GFp 2779 EXIST:VMS:FUNCTION:EC
2251ZLONG_it 2780 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2252ZLONG_it 2780 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2253CRYPTO_get_locked_mem_ex_functions 2781 EXIST:!VMS:FUNCTION:
2254CRYPTO_get_locked_mem_ex_funcs 2781 EXIST:VMS:FUNCTION:
2255ASN1_TIME_check 2782 EXIST::FUNCTION:
2256UI_get0_user_data 2783 EXIST::FUNCTION:
2257HMAC_CTX_cleanup 2784 EXIST::FUNCTION:HMAC
2258DSA_up_ref 2785 EXIST::FUNCTION:DSA
2259_ossl_old_des_ede3_cfb64_encrypt 2786 EXIST:!VMS:FUNCTION:DES
2260_ossl_odes_ede3_cfb64_encrypt 2786 EXIST:VMS:FUNCTION:DES
2261ASN1_BMPSTRING_it 2787 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2262ASN1_BMPSTRING_it 2787 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2263ASN1_tag2bit 2788 EXIST::FUNCTION:
2264UI_method_set_flusher 2789 EXIST::FUNCTION:
2265X509_ocspid_print 2790 EXIST::FUNCTION:BIO
2266KRB5_ENCDATA_it 2791 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2267KRB5_ENCDATA_it 2791 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2268ENGINE_get_load_pubkey_function 2792 EXIST::FUNCTION:
2269UI_add_user_data 2793 EXIST::FUNCTION:
2270OCSP_REQUEST_delete_ext 2794 EXIST::FUNCTION:
2271UI_get_method 2795 EXIST::FUNCTION:
2272OCSP_ONEREQ_free 2796 EXIST::FUNCTION:
2273ASN1_PRINTABLESTRING_it 2797 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2274ASN1_PRINTABLESTRING_it 2797 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2275X509_CRL_set_nextUpdate 2798 EXIST::FUNCTION:
2276OCSP_REQUEST_it 2799 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2277OCSP_REQUEST_it 2799 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2278OCSP_BASICRESP_it 2800 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2279OCSP_BASICRESP_it 2800 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2280AES_ecb_encrypt 2801 EXIST::FUNCTION:AES
2281BN_mod_sqr 2802 EXIST::FUNCTION:
2282NETSCAPE_CERT_SEQUENCE_it 2803 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2283NETSCAPE_CERT_SEQUENCE_it 2803 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2284GENERAL_NAMES_it 2804 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2285GENERAL_NAMES_it 2804 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2286AUTHORITY_INFO_ACCESS_it 2805 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2287AUTHORITY_INFO_ACCESS_it 2805 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2288ASN1_FBOOLEAN_it 2806 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2289ASN1_FBOOLEAN_it 2806 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2290UI_set_ex_data 2807 EXIST::FUNCTION:
2291_ossl_old_des_string_to_key 2808 EXIST::FUNCTION:DES
2292ENGINE_register_all_RSA 2809 EXIST::FUNCTION:
2293d2i_KRB5_PRINCNAME 2810 EXIST::FUNCTION:
2294OCSP_RESPBYTES_it 2811 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2295OCSP_RESPBYTES_it 2811 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2296X509_CINF_it 2812 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2297X509_CINF_it 2812 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2298ENGINE_unregister_digests 2813 EXIST::FUNCTION:
2299d2i_EDIPARTYNAME 2814 EXIST::FUNCTION:
2300d2i_OCSP_SERVICELOC 2815 EXIST::FUNCTION:
2301ENGINE_get_digests 2816 EXIST::FUNCTION:
2302_ossl_old_des_set_odd_parity 2817 EXIST::FUNCTION:DES
2303OCSP_RESPDATA_free 2818 EXIST::FUNCTION:
2304d2i_KRB5_TICKET 2819 EXIST::FUNCTION:
2305OTHERNAME_it 2820 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2306OTHERNAME_it 2820 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2307EVP_MD_CTX_cleanup 2821 EXIST::FUNCTION:
2308d2i_ASN1_GENERALSTRING 2822 EXIST::FUNCTION:
2309X509_CRL_set_version 2823 EXIST::FUNCTION:
2310BN_mod_sub 2824 EXIST::FUNCTION:
2311OCSP_SINGLERESP_get_ext_by_NID 2825 EXIST::FUNCTION:
2312ENGINE_get_ex_new_index 2826 EXIST::FUNCTION:
2313OCSP_REQUEST_free 2827 EXIST::FUNCTION:
2314OCSP_REQUEST_add1_ext_i2d 2828 EXIST::FUNCTION:
2315X509_VAL_it 2829 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2316X509_VAL_it 2829 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2317EC_POINTs_make_affine 2830 EXIST::FUNCTION:EC
2318EC_POINT_mul 2831 EXIST::FUNCTION:EC
2319X509V3_EXT_add_nconf 2832 EXIST::FUNCTION:
2320X509_TRUST_set 2833 EXIST::FUNCTION:
2321X509_CRL_add1_ext_i2d 2834 EXIST::FUNCTION:
2322_ossl_old_des_fcrypt 2835 EXIST::FUNCTION:DES
2323DISPLAYTEXT_it 2836 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2324DISPLAYTEXT_it 2836 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2325X509_CRL_set_lastUpdate 2837 EXIST::FUNCTION:
2326OCSP_BASICRESP_free 2838 EXIST::FUNCTION:
2327OCSP_BASICRESP_add1_ext_i2d 2839 EXIST::FUNCTION:
2328d2i_KRB5_AUTHENTBODY 2840 EXIST::FUNCTION:
2329CRYPTO_set_ex_data_implementation 2841 EXIST:!VMS:FUNCTION:
2330CRYPTO_set_ex_data_impl 2841 EXIST:VMS:FUNCTION:
2331KRB5_ENCDATA_new 2842 EXIST::FUNCTION:
2332DSO_up_ref 2843 EXIST::FUNCTION:
2333OCSP_crl_reason_str 2844 EXIST::FUNCTION:
2334UI_get0_result_string 2845 EXIST::FUNCTION:
2335ASN1_GENERALSTRING_new 2846 EXIST::FUNCTION:
2336X509_SIG_it 2847 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2337X509_SIG_it 2847 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2338ERR_set_implementation 2848 EXIST::FUNCTION:
2339ERR_load_EC_strings 2849 EXIST::FUNCTION:EC
2340UI_get0_action_string 2850 EXIST::FUNCTION:
2341OCSP_ONEREQ_get_ext 2851 EXIST::FUNCTION:
2342EC_POINT_method_of 2852 EXIST::FUNCTION:EC
2343i2d_KRB5_APREQBODY 2853 EXIST::FUNCTION:
2344_ossl_old_des_ecb3_encrypt 2854 EXIST::FUNCTION:DES
2345CRYPTO_get_mem_ex_functions 2855 EXIST::FUNCTION:
2346ENGINE_get_ex_data 2856 EXIST::FUNCTION:
2347UI_destroy_method 2857 EXIST::FUNCTION:
2348ASN1_item_i2d_bio 2858 EXIST::FUNCTION:BIO
2349OCSP_ONEREQ_get_ext_by_OBJ 2859 EXIST::FUNCTION:
2350ASN1_primitive_new 2860 EXIST::FUNCTION:
2351ASN1_PRINTABLE_it 2861 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2352ASN1_PRINTABLE_it 2861 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2353EVP_aes_192_ecb 2862 EXIST::FUNCTION:AES
2354OCSP_SIGNATURE_new 2863 EXIST::FUNCTION:
2355LONG_it 2864 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2356LONG_it 2864 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2357ASN1_VISIBLESTRING_it 2865 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2358ASN1_VISIBLESTRING_it 2865 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2359OCSP_SINGLERESP_add1_ext_i2d 2866 EXIST::FUNCTION:
2360d2i_OCSP_CERTID 2867 EXIST::FUNCTION:
2361ASN1_item_d2i_fp 2868 EXIST::FUNCTION:FP_API
2362CRL_DIST_POINTS_it 2869 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2363CRL_DIST_POINTS_it 2869 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2364GENERAL_NAME_print 2870 EXIST::FUNCTION:
2365OCSP_SINGLERESP_delete_ext 2871 EXIST::FUNCTION:
2366PKCS12_SAFEBAGS_it 2872 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2367PKCS12_SAFEBAGS_it 2872 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2368d2i_OCSP_SIGNATURE 2873 EXIST::FUNCTION:
2369OCSP_request_add1_nonce 2874 EXIST::FUNCTION:
2370ENGINE_set_cmd_defns 2875 EXIST::FUNCTION:
2371OCSP_SERVICELOC_free 2876 EXIST::FUNCTION:
2372EC_GROUP_free 2877 EXIST::FUNCTION:EC
2373ASN1_BIT_STRING_it 2878 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2374ASN1_BIT_STRING_it 2878 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2375X509_REQ_it 2879 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2376X509_REQ_it 2879 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2377_ossl_old_des_cbc_encrypt 2880 EXIST::FUNCTION:DES
2378ERR_unload_strings 2881 EXIST::FUNCTION:
2379PKCS7_SIGN_ENVELOPE_it 2882 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2380PKCS7_SIGN_ENVELOPE_it 2882 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2381EDIPARTYNAME_free 2883 EXIST::FUNCTION:
2382OCSP_REQINFO_free 2884 EXIST::FUNCTION:
2383EC_GROUP_new_curve_GFp 2885 EXIST::FUNCTION:EC
2384OCSP_REQUEST_get1_ext_d2i 2886 EXIST::FUNCTION:
2385PKCS12_item_pack_safebag 2887 EXIST::FUNCTION:
2386asn1_ex_c2i 2888 EXIST::FUNCTION:
2387ENGINE_register_digests 2889 EXIST::FUNCTION:
2388i2d_OCSP_REVOKEDINFO 2890 EXIST::FUNCTION:
2389asn1_enc_restore 2891 EXIST::FUNCTION:
2390UI_free 2892 EXIST::FUNCTION:
2391UI_new_method 2893 EXIST::FUNCTION:
2392EVP_EncryptInit_ex 2894 EXIST::FUNCTION:
2393X509_pubkey_digest 2895 EXIST::FUNCTION:EVP
2394EC_POINT_invert 2896 EXIST::FUNCTION:EC
2395OCSP_basic_sign 2897 EXIST::FUNCTION:
2396i2d_OCSP_RESPID 2898 EXIST::FUNCTION:
2397OCSP_check_nonce 2899 EXIST::FUNCTION:
2398ENGINE_ctrl_cmd 2900 EXIST::FUNCTION:
2399d2i_KRB5_ENCKEY 2901 EXIST::FUNCTION:
2400OCSP_parse_url 2902 EXIST::FUNCTION:
2401OCSP_SINGLERESP_get_ext 2903 EXIST::FUNCTION:
2402OCSP_CRLID_free 2904 EXIST::FUNCTION:
2403OCSP_BASICRESP_get1_ext_d2i 2905 EXIST::FUNCTION:
2404RSAPrivateKey_it 2906 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:RSA
2405RSAPrivateKey_it 2906 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:RSA
2406ENGINE_register_all_DH 2907 EXIST::FUNCTION:
2407i2d_EDIPARTYNAME 2908 EXIST::FUNCTION:
2408EC_POINT_get_affine_coordinates_GFp 2909 EXIST:!VMS:FUNCTION:EC
2409EC_POINT_get_affine_coords_GFp 2909 EXIST:VMS:FUNCTION:EC
2410OCSP_CRLID_new 2910 EXIST::FUNCTION:
2411ENGINE_get_flags 2911 EXIST::FUNCTION:
2412OCSP_ONEREQ_it 2912 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2413OCSP_ONEREQ_it 2912 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2414UI_process 2913 EXIST::FUNCTION:
2415ASN1_INTEGER_it 2914 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2416ASN1_INTEGER_it 2914 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2417EVP_CipherInit_ex 2915 EXIST::FUNCTION:
2418UI_get_string_type 2916 EXIST::FUNCTION:
2419ENGINE_unregister_DH 2917 EXIST::FUNCTION:
2420ENGINE_register_all_DSA 2918 EXIST::FUNCTION:
2421OCSP_ONEREQ_get_ext_by_critical 2919 EXIST::FUNCTION:
2422bn_dup_expand 2920 EXIST::FUNCTION:
2423OCSP_cert_id_new 2921 EXIST::FUNCTION:
2424BASIC_CONSTRAINTS_it 2922 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2425BASIC_CONSTRAINTS_it 2922 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2426BN_mod_add_quick 2923 EXIST::FUNCTION:
2427EC_POINT_new 2924 EXIST::FUNCTION:EC
2428EVP_MD_CTX_destroy 2925 EXIST::FUNCTION:
2429OCSP_RESPBYTES_free 2926 EXIST::FUNCTION:
2430EVP_aes_128_cbc 2927 EXIST::FUNCTION:AES
2431OCSP_SINGLERESP_get1_ext_d2i 2928 EXIST::FUNCTION:
2432EC_POINT_free 2929 EXIST::FUNCTION:EC
2433DH_up_ref 2930 EXIST::FUNCTION:DH
2434X509_NAME_ENTRY_it 2931 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2435X509_NAME_ENTRY_it 2931 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2436UI_get_ex_new_index 2932 EXIST::FUNCTION:
2437BN_mod_sub_quick 2933 EXIST::FUNCTION:
2438OCSP_ONEREQ_add_ext 2934 EXIST::FUNCTION:
2439OCSP_request_sign 2935 EXIST::FUNCTION:
2440EVP_DigestFinal_ex 2936 EXIST::FUNCTION:
2441ENGINE_set_digests 2937 EXIST::FUNCTION:
2442OCSP_id_issuer_cmp 2938 EXIST::FUNCTION:
2443OBJ_NAME_do_all 2939 EXIST::FUNCTION:
2444EC_POINTs_mul 2940 EXIST::FUNCTION:EC
2445ENGINE_register_complete 2941 EXIST::FUNCTION:
2446X509V3_EXT_nconf_nid 2942 EXIST::FUNCTION:
2447ASN1_SEQUENCE_it 2943 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2448ASN1_SEQUENCE_it 2943 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2449UI_set_default_method 2944 EXIST::FUNCTION:
2450RAND_query_egd_bytes 2945 EXIST::FUNCTION:
2451UI_method_get_writer 2946 EXIST::FUNCTION:
2452UI_OpenSSL 2947 EXIST::FUNCTION:
2453PEM_def_callback 2948 EXIST::FUNCTION:
2454ENGINE_cleanup 2949 EXIST::FUNCTION:
2455DIST_POINT_it 2950 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2456DIST_POINT_it 2950 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2457OCSP_SINGLERESP_it 2951 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2458OCSP_SINGLERESP_it 2951 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2459d2i_KRB5_TKTBODY 2952 EXIST::FUNCTION:
2460EC_POINT_cmp 2953 EXIST::FUNCTION:EC
2461OCSP_REVOKEDINFO_new 2954 EXIST::FUNCTION:
2462i2d_OCSP_CERTSTATUS 2955 EXIST::FUNCTION:
2463OCSP_basic_add1_nonce 2956 EXIST::FUNCTION:
2464ASN1_item_ex_d2i 2957 EXIST::FUNCTION:
2465BN_mod_lshift1_quick 2958 EXIST::FUNCTION:
2466UI_set_method 2959 EXIST::FUNCTION:
2467OCSP_id_get0_info 2960 EXIST::FUNCTION:
2468BN_mod_sqrt 2961 EXIST::FUNCTION:
2469EC_GROUP_copy 2962 EXIST::FUNCTION:EC
2470KRB5_ENCDATA_free 2963 EXIST::FUNCTION:
2471_ossl_old_des_cfb_encrypt 2964 EXIST::FUNCTION:DES
2472OCSP_SINGLERESP_get_ext_by_OBJ 2965 EXIST::FUNCTION:
2473OCSP_cert_to_id 2966 EXIST::FUNCTION:
2474OCSP_RESPID_new 2967 EXIST::FUNCTION:
2475OCSP_RESPDATA_it 2968 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2476OCSP_RESPDATA_it 2968 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2477d2i_OCSP_RESPDATA 2969 EXIST::FUNCTION:
2478ENGINE_register_all_complete 2970 EXIST::FUNCTION:
2479OCSP_check_validity 2971 EXIST::FUNCTION:
2480PKCS12_BAGS_it 2972 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2481PKCS12_BAGS_it 2972 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2482OCSP_url_svcloc_new 2973 EXIST::FUNCTION:
2483ASN1_template_free 2974 EXIST::FUNCTION:
2484OCSP_SINGLERESP_add_ext 2975 EXIST::FUNCTION:
2485KRB5_AUTHENTBODY_it 2976 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2486KRB5_AUTHENTBODY_it 2976 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2487X509_supported_extension 2977 EXIST::FUNCTION:
2488i2d_KRB5_AUTHDATA 2978 EXIST::FUNCTION:
2489UI_method_get_opener 2979 EXIST::FUNCTION:
2490ENGINE_set_ex_data 2980 EXIST::FUNCTION:
2491OCSP_REQUEST_print 2981 EXIST::FUNCTION:
2492CBIGNUM_it 2982 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2493CBIGNUM_it 2982 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2494KRB5_TICKET_new 2983 EXIST::FUNCTION:
2495KRB5_APREQ_new 2984 EXIST::FUNCTION:
2496EC_GROUP_get_curve_GFp 2985 EXIST::FUNCTION:EC
2497KRB5_ENCKEY_new 2986 EXIST::FUNCTION:
2498ASN1_template_d2i 2987 EXIST::FUNCTION:
2499_ossl_old_des_quad_cksum 2988 EXIST::FUNCTION:DES
2500OCSP_single_get0_status 2989 EXIST::FUNCTION:
2501BN_swap 2990 EXIST::FUNCTION:
2502POLICYINFO_it 2991 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2503POLICYINFO_it 2991 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2504ENGINE_set_destroy_function 2992 EXIST::FUNCTION:
2505asn1_enc_free 2993 EXIST::FUNCTION:
2506OCSP_RESPID_it 2994 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2507OCSP_RESPID_it 2994 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2508EC_GROUP_new 2995 EXIST::FUNCTION:EC
2509EVP_aes_256_cbc 2996 EXIST::FUNCTION:AES
2510i2d_KRB5_PRINCNAME 2997 EXIST::FUNCTION:
2511_ossl_old_des_encrypt2 2998 EXIST::FUNCTION:DES
2512_ossl_old_des_encrypt3 2999 EXIST::FUNCTION:DES
2513PKCS8_PRIV_KEY_INFO_it 3000 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2514PKCS8_PRIV_KEY_INFO_it 3000 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2515OCSP_REQINFO_it 3001 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2516OCSP_REQINFO_it 3001 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2517PBEPARAM_it 3002 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2518PBEPARAM_it 3002 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2519KRB5_AUTHENTBODY_new 3003 EXIST::FUNCTION:
2520X509_CRL_add0_revoked 3004 EXIST::FUNCTION:
2521EDIPARTYNAME_it 3005 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2522EDIPARTYNAME_it 3005 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2523NETSCAPE_SPKI_it 3006 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2524NETSCAPE_SPKI_it 3006 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2525UI_get0_test_string 3007 EXIST::FUNCTION:
2526ENGINE_get_cipher_engine 3008 EXIST::FUNCTION:
2527ENGINE_register_all_ciphers 3009 EXIST::FUNCTION:
2528EC_POINT_copy 3010 EXIST::FUNCTION:EC
2529BN_kronecker 3011 EXIST::FUNCTION:
2530_ossl_old_des_ede3_ofb64_encrypt 3012 EXIST:!VMS:FUNCTION:DES
2531_ossl_odes_ede3_ofb64_encrypt 3012 EXIST:VMS:FUNCTION:DES
2532UI_method_get_reader 3013 EXIST::FUNCTION:
2533OCSP_BASICRESP_get_ext_count 3014 EXIST::FUNCTION:
2534ASN1_ENUMERATED_it 3015 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2535ASN1_ENUMERATED_it 3015 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2536UI_set_result 3016 EXIST::FUNCTION:
2537i2d_KRB5_TICKET 3017 EXIST::FUNCTION:
2538X509_print_ex_fp 3018 EXIST::FUNCTION:FP_API
2539EVP_CIPHER_CTX_set_padding 3019 EXIST::FUNCTION:
2540d2i_OCSP_RESPONSE 3020 EXIST::FUNCTION:
2541ASN1_UTCTIME_it 3021 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2542ASN1_UTCTIME_it 3021 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2543_ossl_old_des_enc_write 3022 EXIST::FUNCTION:DES
2544OCSP_RESPONSE_new 3023 EXIST::FUNCTION:
2545AES_set_encrypt_key 3024 EXIST::FUNCTION:AES
2546OCSP_resp_count 3025 EXIST::FUNCTION:
2547KRB5_CHECKSUM_new 3026 EXIST::FUNCTION:
2548ENGINE_load_cswift 3027 EXIST::FUNCTION:
2549OCSP_onereq_get0_id 3028 EXIST::FUNCTION:
2550ENGINE_set_default_ciphers 3029 EXIST::FUNCTION:
2551NOTICEREF_it 3030 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2552NOTICEREF_it 3030 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2553X509V3_EXT_CRL_add_nconf 3031 EXIST::FUNCTION:
2554OCSP_REVOKEDINFO_it 3032 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2555OCSP_REVOKEDINFO_it 3032 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2556AES_encrypt 3033 EXIST::FUNCTION:AES
2557OCSP_REQUEST_new 3034 EXIST::FUNCTION:
2558ASN1_ANY_it 3035 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2559ASN1_ANY_it 3035 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2560CRYPTO_ex_data_new_class 3036 EXIST::FUNCTION:
2561_ossl_old_des_ncbc_encrypt 3037 EXIST::FUNCTION:DES
2562i2d_KRB5_TKTBODY 3038 EXIST::FUNCTION:
2563EC_POINT_clear_free 3039 EXIST::FUNCTION:EC
2564AES_decrypt 3040 EXIST::FUNCTION:AES
2565asn1_enc_init 3041 EXIST::FUNCTION:
2566UI_get_result_maxsize 3042 EXIST::FUNCTION:
2567OCSP_CERTID_new 3043 EXIST::FUNCTION:
2568ENGINE_unregister_RAND 3044 EXIST::FUNCTION:
2569UI_method_get_closer 3045 EXIST::FUNCTION:
2570d2i_KRB5_ENCDATA 3046 EXIST::FUNCTION:
2571OCSP_request_onereq_count 3047 EXIST::FUNCTION:
2572OCSP_basic_verify 3048 EXIST::FUNCTION:
2573KRB5_AUTHENTBODY_free 3049 EXIST::FUNCTION:
2574ASN1_item_d2i 3050 EXIST::FUNCTION:
2575ASN1_primitive_free 3051 EXIST::FUNCTION:
2576i2d_EXTENDED_KEY_USAGE 3052 EXIST::FUNCTION:
2577i2d_OCSP_SIGNATURE 3053 EXIST::FUNCTION:
2578asn1_enc_save 3054 EXIST::FUNCTION:
2579ENGINE_load_nuron 3055 EXIST::FUNCTION:
2580_ossl_old_des_pcbc_encrypt 3056 EXIST::FUNCTION:DES
2581PKCS12_MAC_DATA_it 3057 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2582PKCS12_MAC_DATA_it 3057 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2583OCSP_accept_responses_new 3058 EXIST::FUNCTION:
2584asn1_do_lock 3059 EXIST::FUNCTION:
2585PKCS7_ATTR_VERIFY_it 3060 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2586PKCS7_ATTR_VERIFY_it 3060 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2587KRB5_APREQBODY_it 3061 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2588KRB5_APREQBODY_it 3061 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2589i2d_OCSP_SINGLERESP 3062 EXIST::FUNCTION:
2590ASN1_item_ex_new 3063 EXIST::FUNCTION:
2591UI_add_verify_string 3064 EXIST::FUNCTION:
2592_ossl_old_des_set_key 3065 EXIST::FUNCTION:DES
2593KRB5_PRINCNAME_it 3066 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2594KRB5_PRINCNAME_it 3066 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2595EVP_DecryptInit_ex 3067 EXIST::FUNCTION:
2596i2d_OCSP_CERTID 3068 EXIST::FUNCTION:
2597ASN1_item_d2i_bio 3069 EXIST::FUNCTION:BIO
2598EC_POINT_dbl 3070 EXIST::FUNCTION:EC
2599asn1_get_choice_selector 3071 EXIST::FUNCTION:
2600i2d_KRB5_CHECKSUM 3072 EXIST::FUNCTION:
2601ENGINE_set_table_flags 3073 EXIST::FUNCTION:
2602AES_options 3074 EXIST::FUNCTION:AES
2603ENGINE_load_chil 3075 EXIST::FUNCTION:
2604OCSP_id_cmp 3076 EXIST::FUNCTION:
2605OCSP_BASICRESP_new 3077 EXIST::FUNCTION:
2606OCSP_REQUEST_get_ext_by_NID 3078 EXIST::FUNCTION:
2607KRB5_APREQ_it 3079 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2608KRB5_APREQ_it 3079 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2609ENGINE_get_destroy_function 3080 EXIST::FUNCTION:
2610CONF_set_nconf 3081 EXIST::FUNCTION:
2611ASN1_PRINTABLE_free 3082 EXIST::FUNCTION:
2612OCSP_BASICRESP_get_ext_by_NID 3083 EXIST::FUNCTION:
2613DIST_POINT_NAME_it 3084 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2614DIST_POINT_NAME_it 3084 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2615X509V3_extensions_print 3085 EXIST::FUNCTION:
2616_ossl_old_des_cfb64_encrypt 3086 EXIST::FUNCTION:DES
2617X509_REVOKED_add1_ext_i2d 3087 EXIST::FUNCTION:
2618_ossl_old_des_ofb_encrypt 3088 EXIST::FUNCTION:DES
2619KRB5_TKTBODY_new 3089 EXIST::FUNCTION:
2620ASN1_OCTET_STRING_it 3090 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2621ASN1_OCTET_STRING_it 3090 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2622ERR_load_UI_strings 3091 EXIST::FUNCTION:
2623i2d_KRB5_ENCKEY 3092 EXIST::FUNCTION:
2624ASN1_template_new 3093 EXIST::FUNCTION:
2625OCSP_SIGNATURE_free 3094 EXIST::FUNCTION:
2626ASN1_item_i2d_fp 3095 EXIST::FUNCTION:FP_API
2627KRB5_PRINCNAME_free 3096 EXIST::FUNCTION:
2628PKCS7_RECIP_INFO_it 3097 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2629PKCS7_RECIP_INFO_it 3097 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2630EXTENDED_KEY_USAGE_it 3098 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2631EXTENDED_KEY_USAGE_it 3098 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2632EC_GFp_simple_method 3099 EXIST::FUNCTION:EC
2633EC_GROUP_precompute_mult 3100 EXIST::FUNCTION:EC
2634OCSP_request_onereq_get0 3101 EXIST::FUNCTION:
2635UI_method_set_writer 3102 EXIST::FUNCTION:
2636KRB5_AUTHENT_new 3103 EXIST::FUNCTION:
2637X509_CRL_INFO_it 3104 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2638X509_CRL_INFO_it 3104 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2639DSO_set_name_converter 3105 EXIST::FUNCTION:
2640AES_set_decrypt_key 3106 EXIST::FUNCTION:AES
2641PKCS7_DIGEST_it 3107 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2642PKCS7_DIGEST_it 3107 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2643PKCS12_x5092certbag 3108 EXIST::FUNCTION:
2644EVP_DigestInit_ex 3109 EXIST::FUNCTION:
2645i2a_ACCESS_DESCRIPTION 3110 EXIST::FUNCTION:
2646OCSP_RESPONSE_it 3111 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2647OCSP_RESPONSE_it 3111 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2648PKCS7_ENC_CONTENT_it 3112 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2649PKCS7_ENC_CONTENT_it 3112 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2650OCSP_request_add0_id 3113 EXIST::FUNCTION:
2651EC_POINT_make_affine 3114 EXIST::FUNCTION:EC
2652DSO_get_filename 3115 EXIST::FUNCTION:
2653OCSP_CERTSTATUS_it 3116 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2654OCSP_CERTSTATUS_it 3116 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2655OCSP_request_add1_cert 3117 EXIST::FUNCTION:
2656UI_get0_output_string 3118 EXIST::FUNCTION:
2657UI_dup_verify_string 3119 EXIST::FUNCTION:
2658BN_mod_lshift 3120 EXIST::FUNCTION:
2659KRB5_AUTHDATA_it 3121 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2660KRB5_AUTHDATA_it 3121 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2661asn1_set_choice_selector 3122 EXIST::FUNCTION:
2662OCSP_basic_add1_status 3123 EXIST::FUNCTION:
2663OCSP_RESPID_free 3124 EXIST::FUNCTION:
2664asn1_get_field_ptr 3125 EXIST::FUNCTION:
2665UI_add_input_string 3126 EXIST::FUNCTION:
2666OCSP_CRLID_it 3127 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2667OCSP_CRLID_it 3127 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2668i2d_KRB5_AUTHENTBODY 3128 EXIST::FUNCTION:
2669OCSP_REQUEST_get_ext_count 3129 EXIST::FUNCTION:
2670ENGINE_load_atalla 3130 EXIST::FUNCTION:
2671X509_NAME_it 3131 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2672X509_NAME_it 3131 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2673USERNOTICE_it 3132 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2674USERNOTICE_it 3132 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2675OCSP_REQINFO_new 3133 EXIST::FUNCTION:
2676OCSP_BASICRESP_get_ext 3134 EXIST::FUNCTION:
2677CRYPTO_get_ex_data_implementation 3135 EXIST:!VMS:FUNCTION:
2678CRYPTO_get_ex_data_impl 3135 EXIST:VMS:FUNCTION:
2679ASN1_item_pack 3136 EXIST::FUNCTION:
2680i2d_KRB5_ENCDATA 3137 EXIST::FUNCTION:
2681X509_PURPOSE_set 3138 EXIST::FUNCTION:
2682X509_REQ_INFO_it 3139 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2683X509_REQ_INFO_it 3139 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2684UI_method_set_opener 3140 EXIST::FUNCTION:
2685ASN1_item_ex_free 3141 EXIST::FUNCTION:
2686ASN1_BOOLEAN_it 3142 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2687ASN1_BOOLEAN_it 3142 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2688ENGINE_get_table_flags 3143 EXIST::FUNCTION:
2689UI_create_method 3144 EXIST::FUNCTION:
2690OCSP_ONEREQ_add1_ext_i2d 3145 EXIST::FUNCTION:
2691_shadow_DES_check_key 3146 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:DES
2692_shadow_DES_check_key 3146 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:DES
2693d2i_OCSP_REQINFO 3147 EXIST::FUNCTION:
2694UI_add_info_string 3148 EXIST::FUNCTION:
2695UI_get_result_minsize 3149 EXIST::FUNCTION:
2696ASN1_NULL_it 3150 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2697ASN1_NULL_it 3150 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2698BN_mod_lshift1 3151 EXIST::FUNCTION:
2699d2i_OCSP_ONEREQ 3152 EXIST::FUNCTION:
2700OCSP_ONEREQ_new 3153 EXIST::FUNCTION:
2701KRB5_TICKET_it 3154 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2702KRB5_TICKET_it 3154 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2703EVP_aes_192_cbc 3155 EXIST::FUNCTION:AES
2704KRB5_TICKET_free 3156 EXIST::FUNCTION:
2705UI_new 3157 EXIST::FUNCTION:
2706OCSP_response_create 3158 EXIST::FUNCTION:
2707_ossl_old_des_xcbc_encrypt 3159 EXIST::FUNCTION:DES
2708PKCS7_it 3160 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2709PKCS7_it 3160 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2710OCSP_REQUEST_get_ext_by_critical 3161 EXIST:!VMS:FUNCTION:
2711OCSP_REQUEST_get_ext_by_crit 3161 EXIST:VMS:FUNCTION:
2712ENGINE_set_flags 3162 EXIST::FUNCTION:
2713_ossl_old_des_ecb_encrypt 3163 EXIST::FUNCTION:DES
2714OCSP_response_get1_basic 3164 EXIST::FUNCTION:
2715EVP_Digest 3165 EXIST::FUNCTION:
2716OCSP_ONEREQ_delete_ext 3166 EXIST::FUNCTION:
2717ASN1_TBOOLEAN_it 3167 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2718ASN1_TBOOLEAN_it 3167 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2719ASN1_item_new 3168 EXIST::FUNCTION:
2720ASN1_TIME_to_generalizedtime 3169 EXIST::FUNCTION:
2721BIGNUM_it 3170 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2722BIGNUM_it 3170 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2723AES_cbc_encrypt 3171 EXIST::FUNCTION:AES
2724ENGINE_get_load_privkey_function 3172 EXIST:!VMS:FUNCTION:
2725ENGINE_get_load_privkey_fn 3172 EXIST:VMS:FUNCTION:
2726OCSP_RESPONSE_free 3173 EXIST::FUNCTION:
2727UI_method_set_reader 3174 EXIST::FUNCTION:
2728i2d_ASN1_T61STRING 3175 EXIST::FUNCTION:
2729EC_POINT_set_to_infinity 3176 EXIST::FUNCTION:EC
2730ERR_load_OCSP_strings 3177 EXIST::FUNCTION:
2731EC_POINT_point2oct 3178 EXIST::FUNCTION:EC
2732KRB5_APREQ_free 3179 EXIST::FUNCTION:
2733ASN1_OBJECT_it 3180 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2734ASN1_OBJECT_it 3180 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2735OCSP_crlID_new 3181 EXIST:!OS2,!VMS,!WIN16:FUNCTION:
2736OCSP_crlID2_new 3181 EXIST:OS2,VMS,WIN16:FUNCTION:
2737CONF_modules_load_file 3182 EXIST::FUNCTION:
2738CONF_imodule_set_usr_data 3183 EXIST::FUNCTION:
2739ENGINE_set_default_string 3184 EXIST::FUNCTION:
2740CONF_module_get_usr_data 3185 EXIST::FUNCTION:
2741ASN1_add_oid_module 3186 EXIST::FUNCTION:
2742CONF_modules_finish 3187 EXIST::FUNCTION:
2743OPENSSL_config 3188 EXIST::FUNCTION:
2744CONF_modules_unload 3189 EXIST::FUNCTION:
2745CONF_imodule_get_value 3190 EXIST::FUNCTION:
2746CONF_module_set_usr_data 3191 EXIST::FUNCTION:
2747CONF_parse_list 3192 EXIST::FUNCTION:
2748CONF_module_add 3193 EXIST::FUNCTION:
2749CONF_get1_default_config_file 3194 EXIST::FUNCTION:
2750CONF_imodule_get_flags 3195 EXIST::FUNCTION:
2751CONF_imodule_get_module 3196 EXIST::FUNCTION:
2752CONF_modules_load 3197 EXIST::FUNCTION:
2753CONF_imodule_get_name 3198 EXIST::FUNCTION:
2754ERR_peek_top_error 3199 NOEXIST::FUNCTION:
2755CONF_imodule_get_usr_data 3200 EXIST::FUNCTION:
2756CONF_imodule_set_flags 3201 EXIST::FUNCTION:
2757ENGINE_add_conf_module 3202 EXIST::FUNCTION:
2758ERR_peek_last_error_line 3203 EXIST::FUNCTION:
2759ERR_peek_last_error_line_data 3204 EXIST::FUNCTION:
2760ERR_peek_last_error 3205 EXIST::FUNCTION:
2761DES_read_2passwords 3206 EXIST::FUNCTION:DES
2762DES_read_password 3207 EXIST::FUNCTION:DES
2763UI_UTIL_read_pw 3208 EXIST::FUNCTION:
2764UI_UTIL_read_pw_string 3209 EXIST::FUNCTION:
2765ENGINE_load_aep 3210 EXIST::FUNCTION:
2766ENGINE_load_sureware 3211 EXIST::FUNCTION:
2767OPENSSL_add_all_algorithms_noconf 3212 EXIST:!VMS:FUNCTION:
2768OPENSSL_add_all_algo_noconf 3212 EXIST:VMS:FUNCTION:
2769OPENSSL_add_all_algorithms_conf 3213 EXIST:!VMS:FUNCTION:
2770OPENSSL_add_all_algo_conf 3213 EXIST:VMS:FUNCTION:
2771OPENSSL_load_builtin_modules 3214 EXIST::FUNCTION:
2772AES_ofb128_encrypt 3215 EXIST::FUNCTION:AES
2773AES_ctr128_encrypt 3216 EXIST::FUNCTION:AES
2774AES_cfb128_encrypt 3217 EXIST::FUNCTION:AES
2775ENGINE_load_4758cca 3218 EXIST::FUNCTION:
2776_ossl_096_des_random_seed 3219 EXIST::FUNCTION:DES
2777EVP_aes_256_ofb 3220 EXIST::FUNCTION:AES
2778EVP_aes_192_ofb 3221 EXIST::FUNCTION:AES
2779EVP_aes_128_cfb 3222 EXIST::FUNCTION:AES
2780EVP_aes_256_cfb 3223 EXIST::FUNCTION:AES
2781EVP_aes_128_ofb 3224 EXIST::FUNCTION:AES
2782EVP_aes_192_cfb 3225 EXIST::FUNCTION:AES
2783CONF_modules_free 3226 EXIST::FUNCTION:
2784NCONF_default 3227 EXIST::FUNCTION:
2785OPENSSL_no_config 3228 EXIST::FUNCTION:
2786NCONF_WIN32 3229 EXIST::FUNCTION:
2787ASN1_UNIVERSALSTRING_new 3230 EXIST::FUNCTION:
2788EVP_des_ede_ecb 3231 EXIST::FUNCTION:DES
2789i2d_ASN1_UNIVERSALSTRING 3232 EXIST::FUNCTION:
2790ASN1_UNIVERSALSTRING_free 3233 EXIST::FUNCTION:
2791ASN1_UNIVERSALSTRING_it 3234 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:
2792ASN1_UNIVERSALSTRING_it 3234 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:
2793d2i_ASN1_UNIVERSALSTRING 3235 EXIST::FUNCTION:
2794EVP_des_ede3_ecb 3236 EXIST::FUNCTION:DES
2795X509_REQ_print_ex 3237 EXIST::FUNCTION:BIO
diff --git a/src/lib/libcrypto/util/mk1mf.pl b/src/lib/libcrypto/util/mk1mf.pl
new file mode 100644
index 0000000000..c9271bbffe
--- /dev/null
+++ b/src/lib/libcrypto/util/mk1mf.pl
@@ -0,0 +1,907 @@
1#!/usr/local/bin/perl
2# A bit of an evil hack but it post processes the file ../MINFO which
3# is generated by `make files` in the top directory.
4# This script outputs one mega makefile that has no shell stuff or any
5# funny stuff
6#
7
8$INSTALLTOP="/usr/local/ssl";
9$OPTIONS="";
10$ssl_version="";
11$banner="\t\@echo Building OpenSSL";
12
13open(IN,"<Makefile.ssl") || die "unable to open Makefile.ssl!\n";
14while(<IN>) {
15 $ssl_version=$1 if (/^VERSION=(.*)$/);
16 $OPTIONS=$1 if (/^OPTIONS=(.*)$/);
17 $INSTALLTOP=$1 if (/^INSTALLTOP=(.*$)/);
18}
19close(IN);
20
21die "Makefile.ssl is not the toplevel Makefile!\n" if $ssl_version eq "";
22
23$infile="MINFO";
24
25%ops=(
26 "VC-WIN32", "Microsoft Visual C++ [4-6] - Windows NT or 9X",
27 "VC-NT", "Microsoft Visual C++ [4-6] - Windows NT ONLY",
28 "VC-W31-16", "Microsoft Visual C++ 1.52 - Windows 3.1 - 286",
29 "VC-WIN16", "Alias for VC-W31-32",
30 "VC-W31-32", "Microsoft Visual C++ 1.52 - Windows 3.1 - 386+",
31 "VC-MSDOS","Microsoft Visual C++ 1.52 - MSDOS",
32 "Mingw32", "GNU C++ - Windows NT or 9x",
33 "Mingw32-files", "Create files with DOS copy ...",
34 "BC-NT", "Borland C++ 4.5 - Windows NT",
35 "BC-W31", "Borland C++ 4.5 - Windows 3.1 - PROBABLY NOT WORKING",
36 "BC-MSDOS","Borland C++ 4.5 - MSDOS",
37 "linux-elf","Linux elf",
38 "ultrix-mips","DEC mips ultrix",
39 "FreeBSD","FreeBSD distribution",
40 "OS2-EMX", "EMX GCC OS/2",
41 "default","cc under unix",
42 );
43
44$platform="";
45foreach (@ARGV)
46 {
47 if (!&read_options && !defined($ops{$_}))
48 {
49 print STDERR "unknown option - $_\n";
50 print STDERR "usage: perl mk1mf.pl [options] [system]\n";
51 print STDERR "\nwhere [system] can be one of the following\n";
52 foreach $i (sort keys %ops)
53 { printf STDERR "\t%-10s\t%s\n",$i,$ops{$i}; }
54 print STDERR <<"EOF";
55and [options] can be one of
56 no-md2 no-md4 no-md5 no-sha no-mdc2 - Skip this digest
57 no-ripemd
58 no-rc2 no-rc4 no-rc5 no-idea no-des - Skip this symetric cipher
59 no-bf no-cast no-aes
60 no-rsa no-dsa no-dh - Skip this public key cipher
61 no-ssl2 no-ssl3 - Skip this version of SSL
62 just-ssl - remove all non-ssl keys/digest
63 no-asm - No x86 asm
64 no-krb5 - No KRB5
65 no-ec - No EC
66 nasm - Use NASM for x86 asm
67 gaswin - Use GNU as with Mingw32
68 no-socks - No socket code
69 no-err - No error strings
70 dll/shlib - Build shared libraries (MS)
71 debug - Debug build
72 profile - Profiling build
73 gcc - Use Gcc (unix)
74
75Values that can be set
76TMP=tmpdir OUT=outdir SRC=srcdir BIN=binpath INC=header-outdir CC=C-compiler
77
78-L<ex_lib_path> -l<ex_lib> - extra library flags (unix)
79-<ex_cc_flags> - extra 'cc' flags,
80 added (MS), or replace (unix)
81EOF
82 exit(1);
83 }
84 $platform=$_;
85 }
86foreach (grep(!/^$/, split(/ /, $OPTIONS)))
87 {
88 print STDERR "unknown option - $_\n" if !&read_options;
89 }
90
91$no_mdc2=1 if ($no_des);
92
93$no_ssl3=1 if ($no_md5 || $no_sha);
94$no_ssl3=1 if ($no_rsa && $no_dh);
95
96$no_ssl2=1 if ($no_md5);
97$no_ssl2=1 if ($no_rsa);
98
99$out_def="out";
100$inc_def="outinc";
101$tmp_def="tmp";
102
103$mkdir="-mkdir";
104
105($ssl,$crypto)=("ssl","crypto");
106$ranlib="echo ranlib";
107
108$cc=(defined($VARS{'CC'}))?$VARS{'CC'}:'cc';
109$src_dir=(defined($VARS{'SRC'}))?$VARS{'SRC'}:'.';
110$bin_dir=(defined($VARS{'BIN'}))?$VARS{'BIN'}:'';
111
112# $bin_dir.=$o causes a core dump on my sparc :-(
113
114$NT=0;
115
116push(@INC,"util/pl","pl");
117if ($platform eq "VC-MSDOS")
118 {
119 $asmbits=16;
120 $msdos=1;
121 require 'VC-16.pl';
122 }
123elsif ($platform eq "VC-W31-16")
124 {
125 $asmbits=16;
126 $msdos=1; $win16=1;
127 require 'VC-16.pl';
128 }
129elsif (($platform eq "VC-W31-32") || ($platform eq "VC-WIN16"))
130 {
131 $asmbits=32;
132 $msdos=1; $win16=1;
133 require 'VC-16.pl';
134 }
135elsif (($platform eq "VC-WIN32") || ($platform eq "VC-NT"))
136 {
137 $NT = 1 if $platform eq "VC-NT";
138 require 'VC-32.pl';
139 }
140elsif ($platform eq "Mingw32")
141 {
142 require 'Mingw32.pl';
143 }
144elsif ($platform eq "Mingw32-files")
145 {
146 require 'Mingw32f.pl';
147 }
148elsif ($platform eq "BC-NT")
149 {
150 $bc=1;
151 require 'BC-32.pl';
152 }
153elsif ($platform eq "BC-W31")
154 {
155 $bc=1;
156 $msdos=1; $w16=1;
157 require 'BC-16.pl';
158 }
159elsif ($platform eq "BC-Q16")
160 {
161 $msdos=1; $w16=1; $shlib=0; $qw=1;
162 require 'BC-16.pl';
163 }
164elsif ($platform eq "BC-MSDOS")
165 {
166 $asmbits=16;
167 $msdos=1;
168 require 'BC-16.pl';
169 }
170elsif ($platform eq "FreeBSD")
171 {
172 require 'unix.pl';
173 $cflags='-DTERMIO -D_ANSI_SOURCE -O2 -fomit-frame-pointer';
174 }
175elsif ($platform eq "linux-elf")
176 {
177 require "unix.pl";
178 require "linux.pl";
179 $unix=1;
180 }
181elsif ($platform eq "ultrix-mips")
182 {
183 require "unix.pl";
184 require "ultrix.pl";
185 $unix=1;
186 }
187elsif ($platform eq "OS2-EMX")
188 {
189 $wc=1;
190 require 'OS2-EMX.pl';
191 }
192else
193 {
194 require "unix.pl";
195
196 $unix=1;
197 $cflags.=' -DTERMIO';
198 }
199
200$out_dir=(defined($VARS{'OUT'}))?$VARS{'OUT'}:$out_def.($debug?".dbg":"");
201$tmp_dir=(defined($VARS{'TMP'}))?$VARS{'TMP'}:$tmp_def.($debug?".dbg":"");
202$inc_dir=(defined($VARS{'INC'}))?$VARS{'INC'}:$inc_def;
203
204$bin_dir=$bin_dir.$o unless ((substr($bin_dir,-1,1) eq $o) || ($bin_dir eq ''));
205
206$cflags.=" -DOPENSSL_NO_IDEA" if $no_idea;
207$cflags.=" -DOPENSSL_NO_AES" if $no_aes;
208$cflags.=" -DOPENSSL_NO_RC2" if $no_rc2;
209$cflags.=" -DOPENSSL_NO_RC4" if $no_rc4;
210$cflags.=" -DOPENSSL_NO_RC5" if $no_rc5;
211$cflags.=" -DOPENSSL_NO_MD2" if $no_md2;
212$cflags.=" -DOPENSSL_NO_MD4" if $no_md4;
213$cflags.=" -DOPENSSL_NO_MD5" if $no_md5;
214$cflags.=" -DOPENSSL_NO_SHA" if $no_sha;
215$cflags.=" -DOPENSSL_NO_SHA1" if $no_sha1;
216$cflags.=" -DOPENSSL_NO_RIPEMD" if $no_rmd160;
217$cflags.=" -DOPENSSL_NO_MDC2" if $no_mdc2;
218$cflags.=" -DOPENSSL_NO_BF" if $no_bf;
219$cflags.=" -DOPENSSL_NO_CAST" if $no_cast;
220$cflags.=" -DOPENSSL_NO_DES" if $no_des;
221$cflags.=" -DOPENSSL_NO_RSA" if $no_rsa;
222$cflags.=" -DOPENSSL_NO_DSA" if $no_dsa;
223$cflags.=" -DOPENSSL_NO_DH" if $no_dh;
224$cflags.=" -DOPENSSL_NO_SOCK" if $no_sock;
225$cflags.=" -DOPENSSL_NO_SSL2" if $no_ssl2;
226$cflags.=" -DOPENSSL_NO_SSL3" if $no_ssl3;
227$cflags.=" -DOPENSSL_NO_ERR" if $no_err;
228$cflags.=" -DOPENSSL_NO_KRB5" if $no_krb5;
229$cflags.=" -DOPENSSL_NO_EC" if $no_ec;
230#$cflags.=" -DRSAref" if $rsaref ne "";
231
232## if ($unix)
233## { $cflags="$c_flags" if ($c_flags ne ""); }
234##else
235 { $cflags="$c_flags$cflags" if ($c_flags ne ""); }
236
237$ex_libs="$l_flags$ex_libs" if ($l_flags ne "");
238
239%shlib_ex_cflags=("SSL" => " -DOPENSSL_BUILD_SHLIBSSL",
240 "CRYPTO" => " -DOPENSSL_BUILD_SHLIBCRYPTO");
241
242if ($msdos)
243 {
244 $banner ="\t\@echo Make sure you have run 'perl Configure $platform' in the\n";
245 $banner.="\t\@echo top level directory, if you don't have perl, you will\n";
246 $banner.="\t\@echo need to probably edit crypto/bn/bn.h, check the\n";
247 $banner.="\t\@echo documentation for details.\n";
248 }
249
250# have to do this to allow $(CC) under unix
251$link="$bin_dir$link" if ($link !~ /^\$/);
252
253$INSTALLTOP =~ s|/|$o|g;
254
255$defs= <<"EOF";
256# This makefile has been automatically generated from the OpenSSL distribution.
257# This single makefile will build the complete OpenSSL distribution and
258# by default leave the 'intertesting' output files in .${o}out and the stuff
259# that needs deleting in .${o}tmp.
260# The file was generated by running 'make makefile.one', which
261# does a 'make files', which writes all the environment variables from all
262# the makefiles to the file call MINFO. This file is used by
263# util${o}mk1mf.pl to generate makefile.one.
264# The 'makefile per directory' system suites me when developing this
265# library and also so I can 'distribute' indervidual library sections.
266# The one monster makefile better suits building in non-unix
267# environments.
268
269INSTALLTOP=$INSTALLTOP
270
271# Set your compiler options
272PLATFORM=$platform
273CC=$bin_dir${cc}
274CFLAG=$cflags
275APP_CFLAG=$app_cflag
276LIB_CFLAG=$lib_cflag
277SHLIB_CFLAG=$shl_cflag
278APP_EX_OBJ=$app_ex_obj
279SHLIB_EX_OBJ=$shlib_ex_obj
280# add extra libraries to this define, for solaris -lsocket -lnsl would
281# be added
282EX_LIBS=$ex_libs
283
284# The OpenSSL directory
285SRC_D=$src_dir
286
287LINK=$link
288LFLAGS=$lflags
289
290BN_ASM_OBJ=$bn_asm_obj
291BN_ASM_SRC=$bn_asm_src
292BNCO_ASM_OBJ=$bnco_asm_obj
293BNCO_ASM_SRC=$bnco_asm_src
294DES_ENC_OBJ=$des_enc_obj
295DES_ENC_SRC=$des_enc_src
296BF_ENC_OBJ=$bf_enc_obj
297BF_ENC_SRC=$bf_enc_src
298CAST_ENC_OBJ=$cast_enc_obj
299CAST_ENC_SRC=$cast_enc_src
300RC4_ENC_OBJ=$rc4_enc_obj
301RC4_ENC_SRC=$rc4_enc_src
302RC5_ENC_OBJ=$rc5_enc_obj
303RC5_ENC_SRC=$rc5_enc_src
304MD5_ASM_OBJ=$md5_asm_obj
305MD5_ASM_SRC=$md5_asm_src
306SHA1_ASM_OBJ=$sha1_asm_obj
307SHA1_ASM_SRC=$sha1_asm_src
308RMD160_ASM_OBJ=$rmd160_asm_obj
309RMD160_ASM_SRC=$rmd160_asm_src
310
311# The output directory for everything intersting
312OUT_D=$out_dir
313# The output directory for all the temporary muck
314TMP_D=$tmp_dir
315# The output directory for the header files
316INC_D=$inc_dir
317INCO_D=$inc_dir${o}openssl
318
319CP=$cp
320RM=$rm
321RANLIB=$ranlib
322MKDIR=$mkdir
323MKLIB=$bin_dir$mklib
324MLFLAGS=$mlflags
325ASM=$bin_dir$asm
326
327######################################################
328# You should not need to touch anything below this point
329######################################################
330
331E_EXE=openssl
332SSL=$ssl
333CRYPTO=$crypto
334
335# BIN_D - Binary output directory
336# TEST_D - Binary test file output directory
337# LIB_D - library output directory
338# Note: if you change these point to different directories then uncomment out
339# the lines around the 'NB' comment below.
340#
341BIN_D=\$(OUT_D)
342TEST_D=\$(OUT_D)
343LIB_D=\$(OUT_D)
344
345# INCL_D - local library directory
346# OBJ_D - temp object file directory
347OBJ_D=\$(TMP_D)
348INCL_D=\$(TMP_D)
349
350O_SSL= \$(LIB_D)$o$plib\$(SSL)$shlibp
351O_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$shlibp
352SO_SSL= $plib\$(SSL)$so_shlibp
353SO_CRYPTO= $plib\$(CRYPTO)$so_shlibp
354L_SSL= \$(LIB_D)$o$plib\$(SSL)$libp
355L_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$libp
356
357L_LIBS= \$(L_SSL) \$(L_CRYPTO)
358
359######################################################
360# Don't touch anything below this point
361######################################################
362
363INC=-I\$(INC_D) -I\$(INCL_D)
364APP_CFLAGS=\$(INC) \$(CFLAG) \$(APP_CFLAG)
365LIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG)
366SHLIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) \$(SHLIB_CFLAG)
367LIBS_DEP=\$(O_CRYPTO) \$(O_SSL)
368
369#############################################
370EOF
371
372$rules=<<"EOF";
373all: banner \$(TMP_D) \$(BIN_D) \$(TEST_D) \$(LIB_D) \$(INCO_D) headers lib exe
374
375banner:
376$banner
377
378\$(TMP_D):
379 \$(MKDIR) \$(TMP_D)
380# NB: uncomment out these lines if BIN_D, TEST_D and LIB_D are different
381#\$(BIN_D):
382# \$(MKDIR) \$(BIN_D)
383#
384#\$(TEST_D):
385# \$(MKDIR) \$(TEST_D)
386
387\$(LIB_D):
388 \$(MKDIR) \$(LIB_D)
389
390\$(INCO_D): \$(INC_D)
391 \$(MKDIR) \$(INCO_D)
392
393\$(INC_D):
394 \$(MKDIR) \$(INC_D)
395
396headers: \$(HEADER) \$(EXHEADER)
397 @
398
399lib: \$(LIBS_DEP)
400
401exe: \$(T_EXE) \$(BIN_D)$o\$(E_EXE)$exep
402
403install:
404 \$(MKDIR) \$(INSTALLTOP)
405 \$(MKDIR) \$(INSTALLTOP)${o}bin
406 \$(MKDIR) \$(INSTALLTOP)${o}include
407 \$(MKDIR) \$(INSTALLTOP)${o}include${o}openssl
408 \$(MKDIR) \$(INSTALLTOP)${o}lib
409 \$(CP) \$(INCO_D)${o}*.\[ch\] \$(INSTALLTOP)${o}include${o}openssl
410 \$(CP) \$(BIN_D)$o\$(E_EXE)$exep \$(INSTALLTOP)${o}bin
411 \$(CP) \$(O_SSL) \$(INSTALLTOP)${o}lib
412 \$(CP) \$(O_CRYPTO) \$(INSTALLTOP)${o}lib
413
414clean:
415 \$(RM) \$(TMP_D)$o*.*
416
417vclean:
418 \$(RM) \$(TMP_D)$o*.*
419 \$(RM) \$(OUT_D)$o*.*
420
421EOF
422
423my $platform_cpp_symbol = "MK1MF_PLATFORM_$platform";
424$platform_cpp_symbol =~ s/-/_/g;
425if (open(IN,"crypto/buildinf.h"))
426 {
427 # Remove entry for this platform in existing file buildinf.h.
428
429 my $old_buildinf_h = "";
430 while (<IN>)
431 {
432 if (/^\#ifdef $platform_cpp_symbol$/)
433 {
434 while (<IN>) { last if (/^\#endif/); }
435 }
436 else
437 {
438 $old_buildinf_h .= $_;
439 }
440 }
441 close(IN);
442
443 open(OUT,">crypto/buildinf.h") || die "Can't open buildinf.h";
444 print OUT $old_buildinf_h;
445 close(OUT);
446 }
447
448open (OUT,">>crypto/buildinf.h") || die "Can't open buildinf.h";
449printf OUT <<EOF;
450#ifdef $platform_cpp_symbol
451 /* auto-generated/updated by util/mk1mf.pl for crypto/cversion.c */
452 #define CFLAGS "$cc $cflags"
453 #define PLATFORM "$platform"
454EOF
455printf OUT " #define DATE \"%s\"\n", scalar gmtime();
456printf OUT "#endif\n";
457close(OUT);
458
459#############################################
460# We parse in input file and 'store' info for later printing.
461open(IN,"<$infile") || die "unable to open $infile:$!\n";
462$_=<IN>;
463for (;;)
464 {
465 chop;
466
467 ($key,$val)=/^([^=]+)=(.*)/;
468 if ($key eq "RELATIVE_DIRECTORY")
469 {
470 if ($lib ne "")
471 {
472 $uc=$lib;
473 $uc =~ s/^lib(.*)\.a/$1/;
474 $uc =~ tr/a-z/A-Z/;
475 $lib_nam{$uc}=$uc;
476 $lib_obj{$uc}.=$libobj." ";
477 }
478 last if ($val eq "FINISHED");
479 $lib="";
480 $libobj="";
481 $dir=$val;
482 }
483
484 if ($key eq "TEST")
485 { $test.=&var_add($dir,$val); }
486
487 if (($key eq "PROGS") || ($key eq "E_OBJ"))
488 { $e_exe.=&var_add($dir,$val); }
489
490 if ($key eq "LIB")
491 {
492 $lib=$val;
493 $lib =~ s/^.*\/([^\/]+)$/$1/;
494 }
495
496 if ($key eq "EXHEADER")
497 { $exheader.=&var_add($dir,$val); }
498
499 if ($key eq "HEADER")
500 { $header.=&var_add($dir,$val); }
501
502 if ($key eq "LIBOBJ")
503 { $libobj=&var_add($dir,$val); }
504
505 if (!($_=<IN>))
506 { $_="RELATIVE_DIRECTORY=FINISHED\n"; }
507 }
508close(IN);
509
510# Strip of trailing ' '
511foreach (keys %lib_obj) { $lib_obj{$_}=&clean_up_ws($lib_obj{$_}); }
512$test=&clean_up_ws($test);
513$e_exe=&clean_up_ws($e_exe);
514$exheader=&clean_up_ws($exheader);
515$header=&clean_up_ws($header);
516
517# First we strip the exheaders from the headers list
518foreach (split(/\s+/,$exheader)){ $h{$_}=1; }
519foreach (split(/\s+/,$header)) { $h.=$_." " unless $h{$_}; }
520chop($h); $header=$h;
521
522$defs.=&do_defs("HEADER",$header,"\$(INCL_D)",".h");
523$rules.=&do_copy_rule("\$(INCL_D)",$header,".h");
524
525$defs.=&do_defs("EXHEADER",$exheader,"\$(INCO_D)",".h");
526$rules.=&do_copy_rule("\$(INCO_D)",$exheader,".h");
527
528$defs.=&do_defs("T_OBJ",$test,"\$(OBJ_D)",$obj);
529$rules.=&do_compile_rule("\$(OBJ_D)",$test,"\$(APP_CFLAGS)");
530
531$defs.=&do_defs("E_OBJ",$e_exe,"\$(OBJ_D)",$obj);
532$rules.=&do_compile_rule("\$(OBJ_D)",$e_exe,'-DMONOLITH $(APP_CFLAGS)');
533
534foreach (values %lib_nam)
535 {
536 $lib_obj=$lib_obj{$_};
537 local($slib)=$shlib;
538
539 if (($_ eq "SSL") && $no_ssl2 && $no_ssl3)
540 {
541 $rules.="\$(O_SSL):\n\n";
542 next;
543 }
544
545 if (($bn_asm_obj ne "") && ($_ eq "CRYPTO"))
546 {
547 $lib_obj =~ s/\s\S*\/bn_asm\S*/ \$(BN_ASM_OBJ)/;
548 $rules.=&do_asm_rule($bn_asm_obj,$bn_asm_src);
549 }
550 if (($bnco_asm_obj ne "") && ($_ eq "CRYPTO"))
551 {
552 $lib_obj .= "\$(BNCO_ASM_OBJ)";
553 $rules.=&do_asm_rule($bnco_asm_obj,$bnco_asm_src);
554 }
555 if (($des_enc_obj ne "") && ($_ eq "CRYPTO"))
556 {
557 $lib_obj =~ s/\s\S*des_enc\S*/ \$(DES_ENC_OBJ)/;
558 $lib_obj =~ s/\s\S*\/fcrypt_b\S*\s*/ /;
559 $rules.=&do_asm_rule($des_enc_obj,$des_enc_src);
560 }
561 if (($bf_enc_obj ne "") && ($_ eq "CRYPTO"))
562 {
563 $lib_obj =~ s/\s\S*\/bf_enc\S*/ \$(BF_ENC_OBJ)/;
564 $rules.=&do_asm_rule($bf_enc_obj,$bf_enc_src);
565 }
566 if (($cast_enc_obj ne "") && ($_ eq "CRYPTO"))
567 {
568 $lib_obj =~ s/(\s\S*\/c_enc\S*)/ \$(CAST_ENC_OBJ)/;
569 $rules.=&do_asm_rule($cast_enc_obj,$cast_enc_src);
570 }
571 if (($rc4_enc_obj ne "") && ($_ eq "CRYPTO"))
572 {
573 $lib_obj =~ s/\s\S*\/rc4_enc\S*/ \$(RC4_ENC_OBJ)/;
574 $rules.=&do_asm_rule($rc4_enc_obj,$rc4_enc_src);
575 }
576 if (($rc5_enc_obj ne "") && ($_ eq "CRYPTO"))
577 {
578 $lib_obj =~ s/\s\S*\/rc5_enc\S*/ \$(RC5_ENC_OBJ)/;
579 $rules.=&do_asm_rule($rc5_enc_obj,$rc5_enc_src);
580 }
581 if (($md5_asm_obj ne "") && ($_ eq "CRYPTO"))
582 {
583 $lib_obj =~ s/\s(\S*\/md5_dgst\S*)/ $1 \$(MD5_ASM_OBJ)/;
584 $rules.=&do_asm_rule($md5_asm_obj,$md5_asm_src);
585 }
586 if (($sha1_asm_obj ne "") && ($_ eq "CRYPTO"))
587 {
588 $lib_obj =~ s/\s(\S*\/sha1dgst\S*)/ $1 \$(SHA1_ASM_OBJ)/;
589 $rules.=&do_asm_rule($sha1_asm_obj,$sha1_asm_src);
590 }
591 if (($rmd160_asm_obj ne "") && ($_ eq "CRYPTO"))
592 {
593 $lib_obj =~ s/\s(\S*\/rmd_dgst\S*)/ $1 \$(RMD160_ASM_OBJ)/;
594 $rules.=&do_asm_rule($rmd160_asm_obj,$rmd160_asm_src);
595 }
596 $defs.=&do_defs(${_}."OBJ",$lib_obj,"\$(OBJ_D)",$obj);
597 $lib=($slib)?" \$(SHLIB_CFLAGS)".$shlib_ex_cflags{$_}:" \$(LIB_CFLAGS)";
598 $rules.=&do_compile_rule("\$(OBJ_D)",$lib_obj{$_},$lib);
599 }
600
601$defs.=&do_defs("T_EXE",$test,"\$(TEST_D)",$exep);
602foreach (split(/\s+/,$test))
603 {
604 $t=&bname($_);
605 $tt="\$(OBJ_D)${o}$t${obj}";
606 $rules.=&do_link_rule("\$(TEST_D)$o$t$exep",$tt,"\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)");
607 }
608
609$rules.= &do_lib_rule("\$(SSLOBJ)","\$(O_SSL)",$ssl,$shlib,"\$(SO_SSL)");
610$rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib,"\$(SO_CRYPTO)");
611
612$rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)");
613
614print $defs;
615
616if ($platform eq "linux-elf") {
617 print <<"EOF";
618# Generate perlasm output files
619%.cpp:
620 (cd \$(\@D)/..; PERL=perl make -f Makefile.ssl asm/\$(\@F))
621EOF
622}
623print "###################################################################\n";
624print $rules;
625
626###############################################
627# strip off any trailing .[och] and append the relative directory
628# also remembering to do nothing if we are in one of the dropped
629# directories
630sub var_add
631 {
632 local($dir,$val)=@_;
633 local(@a,$_,$ret);
634
635 return("") if $no_idea && $dir =~ /\/idea/;
636 return("") if $no_aes && $dir =~ /\/aes/;
637 return("") if $no_rc2 && $dir =~ /\/rc2/;
638 return("") if $no_rc4 && $dir =~ /\/rc4/;
639 return("") if $no_rc5 && $dir =~ /\/rc5/;
640 return("") if $no_rsa && $dir =~ /\/rsa/;
641 return("") if $no_rsa && $dir =~ /^rsaref/;
642 return("") if $no_dsa && $dir =~ /\/dsa/;
643 return("") if $no_dh && $dir =~ /\/dh/;
644 if ($no_des && $dir =~ /\/des/)
645 {
646 if ($val =~ /read_pwd/)
647 { return("$dir/read_pwd "); }
648 else
649 { return(""); }
650 }
651 return("") if $no_mdc2 && $dir =~ /\/mdc2/;
652 return("") if $no_sock && $dir =~ /\/proxy/;
653 return("") if $no_bf && $dir =~ /\/bf/;
654 return("") if $no_cast && $dir =~ /\/cast/;
655
656 $val =~ s/^\s*(.*)\s*$/$1/;
657 @a=split(/\s+/,$val);
658 grep(s/\.[och]$//,@a);
659
660 @a=grep(!/^e_.*_3d$/,@a) if $no_des;
661 @a=grep(!/^e_.*_d$/,@a) if $no_des;
662 @a=grep(!/^e_.*_ae$/,@a) if $no_idea;
663 @a=grep(!/^e_.*_i$/,@a) if $no_aes;
664 @a=grep(!/^e_.*_r2$/,@a) if $no_rc2;
665 @a=grep(!/^e_.*_r5$/,@a) if $no_rc5;
666 @a=grep(!/^e_.*_bf$/,@a) if $no_bf;
667 @a=grep(!/^e_.*_c$/,@a) if $no_cast;
668 @a=grep(!/^e_rc4$/,@a) if $no_rc4;
669
670 @a=grep(!/(^s2_)|(^s23_)/,@a) if $no_ssl2;
671 @a=grep(!/(^s3_)|(^s23_)/,@a) if $no_ssl3;
672
673 @a=grep(!/(_sock$)|(_acpt$)|(_conn$)|(^pxy_)/,@a) if $no_sock;
674
675 @a=grep(!/(^md2)|(_md2$)/,@a) if $no_md2;
676 @a=grep(!/(^md4)|(_md4$)/,@a) if $no_md4;
677 @a=grep(!/(^md5)|(_md5$)/,@a) if $no_md5;
678 @a=grep(!/(rmd)|(ripemd)/,@a) if $no_rmd160;
679
680 @a=grep(!/(^d2i_r_)|(^i2d_r_)/,@a) if $no_rsa;
681 @a=grep(!/(^p_open$)|(^p_seal$)/,@a) if $no_rsa;
682 @a=grep(!/(^pem_seal$)/,@a) if $no_rsa;
683
684 @a=grep(!/(m_dss$)|(m_dss1$)/,@a) if $no_dsa;
685 @a=grep(!/(^d2i_s_)|(^i2d_s_)|(_dsap$)/,@a) if $no_dsa;
686
687 @a=grep(!/^n_pkey$/,@a) if $no_rsa || $no_rc4;
688
689 @a=grep(!/_dhp$/,@a) if $no_dh;
690
691 @a=grep(!/(^sha[^1])|(_sha$)|(m_dss$)/,@a) if $no_sha;
692 @a=grep(!/(^sha1)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1;
693 @a=grep(!/_mdc2$/,@a) if $no_mdc2;
694
695 @a=grep(!/(^rsa$)|(^genrsa$)/,@a) if $no_rsa;
696 @a=grep(!/(^dsa$)|(^gendsa$)|(^dsaparam$)/,@a) if $no_dsa;
697 @a=grep(!/^gendsa$/,@a) if $no_sha1;
698 @a=grep(!/(^dh$)|(^gendh$)/,@a) if $no_dh;
699
700 @a=grep(!/(^dh)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1;
701
702 grep($_="$dir/$_",@a);
703 @a=grep(!/(^|\/)s_/,@a) if $no_sock;
704 @a=grep(!/(^|\/)bio_sock/,@a) if $no_sock;
705 $ret=join(' ',@a)." ";
706 return($ret);
707 }
708
709# change things so that each 'token' is only separated by one space
710sub clean_up_ws
711 {
712 local($w)=@_;
713
714 $w =~ s/^\s*(.*)\s*$/$1/;
715 $w =~ s/\s+/ /g;
716 return($w);
717 }
718
719sub do_defs
720 {
721 local($var,$files,$location,$postfix)=@_;
722 local($_,$ret,$pf);
723 local(*OUT,$tmp,$t);
724
725 $files =~ s/\//$o/g if $o ne '/';
726 $ret="$var=";
727 $n=1;
728 $Vars{$var}.="";
729 foreach (split(/ /,$files))
730 {
731 $orig=$_;
732 $_=&bname($_) unless /^\$/;
733 if ($n++ == 2)
734 {
735 $n=0;
736 $ret.="\\\n\t";
737 }
738 if (($_ =~ /bss_file/) && ($postfix eq ".h"))
739 { $pf=".c"; }
740 else { $pf=$postfix; }
741 if ($_ =~ /BN_ASM/) { $t="$_ "; }
742 elsif ($_ =~ /BNCO_ASM/){ $t="$_ "; }
743 elsif ($_ =~ /DES_ENC/) { $t="$_ "; }
744 elsif ($_ =~ /BF_ENC/) { $t="$_ "; }
745 elsif ($_ =~ /CAST_ENC/){ $t="$_ "; }
746 elsif ($_ =~ /RC4_ENC/) { $t="$_ "; }
747 elsif ($_ =~ /RC5_ENC/) { $t="$_ "; }
748 elsif ($_ =~ /MD5_ASM/) { $t="$_ "; }
749 elsif ($_ =~ /SHA1_ASM/){ $t="$_ "; }
750 elsif ($_ =~ /RMD160_ASM/){ $t="$_ "; }
751 else { $t="$location${o}$_$pf "; }
752
753 $Vars{$var}.="$t ";
754 $ret.=$t;
755 }
756 chop($ret);
757 $ret.="\n\n";
758 return($ret);
759 }
760
761# return the name with the leading path removed
762sub bname
763 {
764 local($ret)=@_;
765 $ret =~ s/^.*[\\\/]([^\\\/]+)$/$1/;
766 return($ret);
767 }
768
769
770##############################################################
771# do a rule for each file that says 'compile' to new direcory
772# compile the files in '$files' into $to
773sub do_compile_rule
774 {
775 local($to,$files,$ex)=@_;
776 local($ret,$_,$n);
777
778 $files =~ s/\//$o/g if $o ne '/';
779 foreach (split(/\s+/,$files))
780 {
781 $n=&bname($_);
782 $ret.=&cc_compile_target("$to${o}$n$obj","${_}.c",$ex)
783 }
784 return($ret);
785 }
786
787##############################################################
788# do a rule for each file that says 'compile' to new direcory
789sub cc_compile_target
790 {
791 local($target,$source,$ex_flags)=@_;
792 local($ret);
793
794 $ex_flags.=" -DMK1MF_BUILD -D$platform_cpp_symbol" if ($source =~ /cversion/);
795 $target =~ s/\//$o/g if $o ne "/";
796 $source =~ s/\//$o/g if $o ne "/";
797 $ret ="$target: \$(SRC_D)$o$source\n\t";
798 $ret.="\$(CC) ${ofile}$target $ex_flags -c \$(SRC_D)$o$source\n\n";
799 return($ret);
800 }
801
802##############################################################
803sub do_asm_rule
804 {
805 local($target,$src)=@_;
806 local($ret,@s,@t,$i);
807
808 $target =~ s/\//$o/g if $o ne "/";
809 $src =~ s/\//$o/g if $o ne "/";
810
811 @s=split(/\s+/,$src);
812 @t=split(/\s+/,$target);
813
814 for ($i=0; $i<=$#s; $i++)
815 {
816 $ret.="$t[$i]: $s[$i]\n";
817 $ret.="\t\$(ASM) $afile$t[$i] \$(SRC_D)$o$s[$i]\n\n";
818 }
819 return($ret);
820 }
821
822sub do_shlib_rule
823 {
824 local($n,$def)=@_;
825 local($ret,$nn);
826 local($t);
827
828 ($nn=$n) =~ tr/a-z/A-Z/;
829 $ret.="$n.dll: \$(${nn}OBJ)\n";
830 if ($vc && $w32)
831 {
832 $ret.="\t\$(MKSHLIB) $efile$n.dll $def @<<\n \$(${nn}OBJ_F)\n<<\n";
833 }
834 $ret.="\n";
835 return($ret);
836 }
837
838# do a rule for each file that says 'copy' to new direcory on change
839sub do_copy_rule
840 {
841 local($to,$files,$p)=@_;
842 local($ret,$_,$n,$pp);
843
844 $files =~ s/\//$o/g if $o ne '/';
845 foreach (split(/\s+/,$files))
846 {
847 $n=&bname($_);
848 if ($n =~ /bss_file/)
849 { $pp=".c"; }
850 else { $pp=$p; }
851 $ret.="$to${o}$n$pp: \$(SRC_D)$o$_$pp\n\t\$(CP) \$(SRC_D)$o$_$pp $to${o}$n$pp\n\n";
852 }
853 return($ret);
854 }
855
856sub read_options
857 {
858 if (/^no-rc2$/) { $no_rc2=1; }
859 elsif (/^no-rc4$/) { $no_rc4=1; }
860 elsif (/^no-rc5$/) { $no_rc5=1; }
861 elsif (/^no-idea$/) { $no_idea=1; }
862 elsif (/^no-aes$/) { $no_aes=1; }
863 elsif (/^no-des$/) { $no_des=1; }
864 elsif (/^no-bf$/) { $no_bf=1; }
865 elsif (/^no-cast$/) { $no_cast=1; }
866 elsif (/^no-md2$/) { $no_md2=1; }
867 elsif (/^no-md4$/) { $no_md4=1; }
868 elsif (/^no-md5$/) { $no_md5=1; }
869 elsif (/^no-sha$/) { $no_sha=1; }
870 elsif (/^no-sha1$/) { $no_sha1=1; }
871 elsif (/^no-ripemd$/) { $no_ripemd=1; }
872 elsif (/^no-mdc2$/) { $no_mdc2=1; }
873 elsif (/^no-patents$/) { $no_rc2=$no_rc4=$no_rc5=$no_idea=$no_rsa=1; }
874 elsif (/^no-rsa$/) { $no_rsa=1; }
875 elsif (/^no-dsa$/) { $no_dsa=1; }
876 elsif (/^no-dh$/) { $no_dh=1; }
877 elsif (/^no-hmac$/) { $no_hmac=1; }
878 elsif (/^no-aes$/) { $no_aes=1; }
879 elsif (/^no-asm$/) { $no_asm=1; }
880 elsif (/^nasm$/) { $nasm=1; }
881 elsif (/^gaswin$/) { $gaswin=1; }
882 elsif (/^no-ssl2$/) { $no_ssl2=1; }
883 elsif (/^no-ssl3$/) { $no_ssl3=1; }
884 elsif (/^no-err$/) { $no_err=1; }
885 elsif (/^no-sock$/) { $no_sock=1; }
886 elsif (/^no-krb5$/) { $no_krb5=1; }
887 elsif (/^no-ec$/) { $no_ec=1; }
888
889 elsif (/^just-ssl$/) { $no_rc2=$no_idea=$no_des=$no_bf=$no_cast=1;
890 $no_md2=$no_sha=$no_mdc2=$no_dsa=$no_dh=1;
891 $no_ssl2=$no_err=$no_rmd160=$no_rc5=1;
892 $no_aes=1; }
893
894 elsif (/^rsaref$/) { }
895 elsif (/^gcc$/) { $gcc=1; }
896 elsif (/^debug$/) { $debug=1; }
897 elsif (/^profile$/) { $profile=1; }
898 elsif (/^shlib$/) { $shlib=1; }
899 elsif (/^dll$/) { $shlib=1; }
900 elsif (/^shared$/) { } # We just need to ignore it for now...
901 elsif (/^([^=]*)=(.*)$/){ $VARS{$1}=$2; }
902 elsif (/^-[lL].*$/) { $l_flags.="$_ "; }
903 elsif ((!/^-help/) && (!/^-h/) && (!/^-\?/) && /^-.*$/)
904 { $c_flags.="$_ "; }
905 else { return(0); }
906 return(1);
907 }
diff --git a/src/lib/libcrypto/util/mkcerts.sh b/src/lib/libcrypto/util/mkcerts.sh
new file mode 100644
index 0000000000..5f8a1dae73
--- /dev/null
+++ b/src/lib/libcrypto/util/mkcerts.sh
@@ -0,0 +1,220 @@
1#!bin/sh
2
3# This script will re-make all the required certs.
4# cd apps
5# sh ../util/mkcerts.sh
6# mv ca-cert.pem pca-cert.pem ../certs
7# cd ..
8# cat certs/*.pem >>apps/server.pem
9# cat certs/*.pem >>apps/server2.pem
10# SSLEAY=`pwd`/apps/ssleay; export SSLEAY
11# sh tools/c_rehash certs
12#
13
14CAbits=1024
15SSLEAY="../apps/ssleay"
16CONF="-config ../apps/ssleay.cnf"
17
18# create pca request.
19echo creating $CAbits bit PCA cert request
20$SSLEAY req $CONF \
21 -new -md5 -newkey $CAbits \
22 -keyout pca-key.pem \
23 -out pca-req.pem -nodes >/dev/null <<EOF
24AU
25Queensland
26.
27CryptSoft Pty Ltd
28.
29Test PCA (1024 bit)
30
31
32
33EOF
34
35if [ $? != 0 ]; then
36 echo problems generating PCA request
37 exit 1
38fi
39
40#sign it.
41echo
42echo self signing PCA
43$SSLEAY x509 -md5 -days 1461 \
44 -req -signkey pca-key.pem \
45 -CAcreateserial -CAserial pca-cert.srl \
46 -in pca-req.pem -out pca-cert.pem
47
48if [ $? != 0 ]; then
49 echo problems self signing PCA cert
50 exit 1
51fi
52echo
53
54# create ca request.
55echo creating $CAbits bit CA cert request
56$SSLEAY req $CONF \
57 -new -md5 -newkey $CAbits \
58 -keyout ca-key.pem \
59 -out ca-req.pem -nodes >/dev/null <<EOF
60AU
61Queensland
62.
63CryptSoft Pty Ltd
64.
65Test CA (1024 bit)
66
67
68
69EOF
70
71if [ $? != 0 ]; then
72 echo problems generating CA request
73 exit 1
74fi
75
76#sign it.
77echo
78echo signing CA
79$SSLEAY x509 -md5 -days 1461 \
80 -req \
81 -CAcreateserial -CAserial pca-cert.srl \
82 -CA pca-cert.pem -CAkey pca-key.pem \
83 -in ca-req.pem -out ca-cert.pem
84
85if [ $? != 0 ]; then
86 echo problems signing CA cert
87 exit 1
88fi
89echo
90
91# create server request.
92echo creating 512 bit server cert request
93$SSLEAY req $CONF \
94 -new -md5 -newkey 512 \
95 -keyout s512-key.pem \
96 -out s512-req.pem -nodes >/dev/null <<EOF
97AU
98Queensland
99.
100CryptSoft Pty Ltd
101.
102Server test cert (512 bit)
103
104
105
106EOF
107
108if [ $? != 0 ]; then
109 echo problems generating 512 bit server cert request
110 exit 1
111fi
112
113#sign it.
114echo
115echo signing 512 bit server cert
116$SSLEAY x509 -md5 -days 365 \
117 -req \
118 -CAcreateserial -CAserial ca-cert.srl \
119 -CA ca-cert.pem -CAkey ca-key.pem \
120 -in s512-req.pem -out server.pem
121
122if [ $? != 0 ]; then
123 echo problems signing 512 bit server cert
124 exit 1
125fi
126echo
127
128# create 1024 bit server request.
129echo creating 1024 bit server cert request
130$SSLEAY req $CONF \
131 -new -md5 -newkey 1024 \
132 -keyout s1024key.pem \
133 -out s1024req.pem -nodes >/dev/null <<EOF
134AU
135Queensland
136.
137CryptSoft Pty Ltd
138.
139Server test cert (1024 bit)
140
141
142
143EOF
144
145if [ $? != 0 ]; then
146 echo problems generating 1024 bit server cert request
147 exit 1
148fi
149
150#sign it.
151echo
152echo signing 1024 bit server cert
153$SSLEAY x509 -md5 -days 365 \
154 -req \
155 -CAcreateserial -CAserial ca-cert.srl \
156 -CA ca-cert.pem -CAkey ca-key.pem \
157 -in s1024req.pem -out server2.pem
158
159if [ $? != 0 ]; then
160 echo problems signing 1024 bit server cert
161 exit 1
162fi
163echo
164
165# create 512 bit client request.
166echo creating 512 bit client cert request
167$SSLEAY req $CONF \
168 -new -md5 -newkey 512 \
169 -keyout c512-key.pem \
170 -out c512-req.pem -nodes >/dev/null <<EOF
171AU
172Queensland
173.
174CryptSoft Pty Ltd
175.
176Client test cert (512 bit)
177
178
179
180EOF
181
182if [ $? != 0 ]; then
183 echo problems generating 512 bit client cert request
184 exit 1
185fi
186
187#sign it.
188echo
189echo signing 512 bit client cert
190$SSLEAY x509 -md5 -days 365 \
191 -req \
192 -CAcreateserial -CAserial ca-cert.srl \
193 -CA ca-cert.pem -CAkey ca-key.pem \
194 -in c512-req.pem -out client.pem
195
196if [ $? != 0 ]; then
197 echo problems signing 512 bit client cert
198 exit 1
199fi
200
201echo cleanup
202
203cat pca-key.pem >> pca-cert.pem
204cat ca-key.pem >> ca-cert.pem
205cat s512-key.pem >> server.pem
206cat s1024key.pem >> server2.pem
207cat c512-key.pem >> client.pem
208
209for i in pca-cert.pem ca-cert.pem server.pem server2.pem client.pem
210do
211$SSLEAY x509 -issuer -subject -in $i -noout >$$
212cat $$
213/bin/cat $i >>$$
214/bin/mv $$ $i
215done
216
217#/bin/rm -f *key.pem *req.pem *.srl
218
219echo Finished
220
diff --git a/src/lib/libcrypto/util/mkdef.pl b/src/lib/libcrypto/util/mkdef.pl
new file mode 100644
index 0000000000..adfd447dd3
--- /dev/null
+++ b/src/lib/libcrypto/util/mkdef.pl
@@ -0,0 +1,1360 @@
1#!/usr/local/bin/perl -w
2#
3# generate a .def file
4#
5# It does this by parsing the header files and looking for the
6# prototyped functions: it then prunes the output.
7#
8# Intermediary files are created, call libeay.num and ssleay.num,...
9# Previously, they had the following format:
10#
11# routine-name nnnn
12#
13# But that isn't enough for a number of reasons, the first on being that
14# this format is (needlessly) very Win32-centric, and even then...
15# One of the biggest problems is that there's no information about what
16# routines should actually be used, which varies with what crypto algorithms
17# are disabled. Also, some operating systems (for example VMS with VAX C)
18# need to keep track of the global variables as well as the functions.
19#
20# So, a remake of this script is done so as to include information on the
21# kind of symbol it is (function or variable) and what algorithms they're
22# part of. This will allow easy translating to .def files or the corresponding
23# file in other operating systems (a .opt file for VMS, possibly with a .mar
24# file).
25#
26# The format now becomes:
27#
28# routine-name nnnn info
29#
30# and the "info" part is actually a colon-separated string of fields with
31# the following meaning:
32#
33# existence:platform:kind:algorithms
34#
35# - "existence" can be "EXIST" or "NOEXIST" depending on if the symbol is
36# found somewhere in the source,
37# - "platforms" is empty if it exists on all platforms, otherwise it contains
38# comma-separated list of the platform, just as they are if the symbol exists
39# for those platforms, or prepended with a "!" if not. This helps resolve
40# symbol name variants for platforms where the names are too long for the
41# compiler or linker, or if the systems is case insensitive and there is a
42# clash, or the symbol is implemented differently (see
43# EXPORT_VAR_AS_FUNCTION). This script assumes renaming of symbols is found
44# in the file crypto/symhacks.h.
45# The semantics for the platforms is that every item is checked against the
46# environment. For the negative items ("!FOO"), if any of them is false
47# (i.e. "FOO" is true) in the environment, the corresponding symbol can't be
48# used. For the positive itms, if all of them are false in the environment,
49# the corresponding symbol can't be used. Any combination of positive and
50# negative items are possible, and of course leave room for some redundancy.
51# - "kind" is "FUNCTION" or "VARIABLE". The meaning of that is obvious.
52# - "algorithms" is a comma-separated list of algorithm names. This helps
53# exclude symbols that are part of an algorithm that some user wants to
54# exclude.
55#
56
57my $debug=0;
58
59my $crypto_num= "util/libeay.num";
60my $ssl_num= "util/ssleay.num";
61my $libname;
62
63my $do_update = 0;
64my $do_rewrite = 1;
65my $do_crypto = 0;
66my $do_ssl = 0;
67my $do_ctest = 0;
68my $do_ctestall = 0;
69my $do_checkexist = 0;
70
71my $VMSVAX=0;
72my $VMSAlpha=0;
73my $VMS=0;
74my $W32=0;
75my $W16=0;
76my $NT=0;
77my $OS2=0;
78# Set this to make typesafe STACK definitions appear in DEF
79my $safe_stack_def = 0;
80
81my @known_platforms = ( "__FreeBSD__", "PERL5", "NeXT",
82 "EXPORT_VAR_AS_FUNCTION" );
83my @known_ossl_platforms = ( "VMS", "WIN16", "WIN32", "WINNT", "OS2" );
84my @known_algorithms = ( "RC2", "RC4", "RC5", "IDEA", "DES", "BF",
85 "CAST", "MD2", "MD4", "MD5", "SHA", "SHA0", "SHA1",
86 "RIPEMD",
87 "MDC2", "RSA", "DSA", "DH", "EC", "HMAC", "AES",
88 # Envelope "algorithms"
89 "EVP", "X509", "ASN1_TYPEDEFS",
90 # Helper "algorithms"
91 "BIO", "COMP", "BUFFER", "LHASH", "STACK", "ERR",
92 "LOCKING",
93 # External "algorithms"
94 "FP_API", "STDIO", "SOCK", "KRB5" );
95
96my $options="";
97open(IN,"<Makefile.ssl") || die "unable to open Makefile.ssl!\n";
98while(<IN>) {
99 $options=$1 if (/^OPTIONS=(.*)$/);
100}
101close(IN);
102
103# The following ciphers may be excluded (by Configure). This means functions
104# defined with ifndef(NO_XXX) are not included in the .def file, and everything
105# in directory xxx is ignored.
106my $no_rc2; my $no_rc4; my $no_rc5; my $no_idea; my $no_des; my $no_bf;
107my $no_cast;
108my $no_md2; my $no_md4; my $no_md5; my $no_sha; my $no_ripemd; my $no_mdc2;
109my $no_rsa; my $no_dsa; my $no_dh; my $no_hmac=0; my $no_aes; my $no_krb5;
110my $no_ec;
111my $no_fp_api;
112
113foreach (@ARGV, split(/ /, $options))
114 {
115 $debug=1 if $_ eq "debug";
116 $W32=1 if $_ eq "32";
117 $W16=1 if $_ eq "16";
118 if($_ eq "NT") {
119 $W32 = 1;
120 $NT = 1;
121 }
122 if ($_ eq "VMS-VAX") {
123 $VMS=1;
124 $VMSVAX=1;
125 }
126 if ($_ eq "VMS-Alpha") {
127 $VMS=1;
128 $VMSAlpha=1;
129 }
130 $VMS=1 if $_ eq "VMS";
131 $OS2=1 if $_ eq "OS2";
132
133 $do_ssl=1 if $_ eq "ssleay";
134 if ($_ eq "ssl") {
135 $do_ssl=1;
136 $libname=$_
137 }
138 $do_crypto=1 if $_ eq "libeay";
139 if ($_ eq "crypto") {
140 $do_crypto=1;
141 $libname=$_;
142 }
143 $do_update=1 if $_ eq "update";
144 $do_rewrite=1 if $_ eq "rewrite";
145 $do_ctest=1 if $_ eq "ctest";
146 $do_ctestall=1 if $_ eq "ctestall";
147 $do_checkexist=1 if $_ eq "exist";
148 #$safe_stack_def=1 if $_ eq "-DDEBUG_SAFESTACK";
149
150 if (/^no-rc2$/) { $no_rc2=1; }
151 elsif (/^no-rc4$/) { $no_rc4=1; }
152 elsif (/^no-rc5$/) { $no_rc5=1; }
153 elsif (/^no-idea$/) { $no_idea=1; }
154 elsif (/^no-des$/) { $no_des=1; $no_mdc2=1; }
155 elsif (/^no-bf$/) { $no_bf=1; }
156 elsif (/^no-cast$/) { $no_cast=1; }
157 elsif (/^no-md2$/) { $no_md2=1; }
158 elsif (/^no-md4$/) { $no_md4=1; }
159 elsif (/^no-md5$/) { $no_md5=1; }
160 elsif (/^no-sha$/) { $no_sha=1; }
161 elsif (/^no-ripemd$/) { $no_ripemd=1; }
162 elsif (/^no-mdc2$/) { $no_mdc2=1; }
163 elsif (/^no-rsa$/) { $no_rsa=1; }
164 elsif (/^no-dsa$/) { $no_dsa=1; }
165 elsif (/^no-dh$/) { $no_dh=1; }
166 elsif (/^no-ec$/) { $no_ec=1; }
167 elsif (/^no-hmac$/) { $no_hmac=1; }
168 elsif (/^no-aes$/) { $no_aes=1; }
169 elsif (/^no-evp$/) { $no_evp=1; }
170 elsif (/^no-lhash$/) { $no_lhash=1; }
171 elsif (/^no-stack$/) { $no_stack=1; }
172 elsif (/^no-err$/) { $no_err=1; }
173 elsif (/^no-buffer$/) { $no_buffer=1; }
174 elsif (/^no-bio$/) { $no_bio=1; }
175 #elsif (/^no-locking$/) { $no_locking=1; }
176 elsif (/^no-comp$/) { $no_comp=1; }
177 elsif (/^no-dso$/) { $no_dso=1; }
178 elsif (/^no-krb5$/) { $no_krb5=1; }
179 }
180
181
182if (!$libname) {
183 if ($do_ssl) {
184 $libname="SSLEAY";
185 }
186 if ($do_crypto) {
187 $libname="LIBEAY";
188 }
189}
190
191# If no platform is given, assume WIN32
192if ($W32 + $W16 + $VMS + $OS2 == 0) {
193 $W32 = 1;
194}
195
196# Add extra knowledge
197if ($W16) {
198 $no_fp_api=1;
199}
200
201if (!$do_ssl && !$do_crypto)
202 {
203 print STDERR "usage: $0 ( ssl | crypto ) [ 16 | 32 | NT | OS2 ]\n";
204 exit(1);
205 }
206
207%ssl_list=&load_numbers($ssl_num);
208$max_ssl = $max_num;
209%crypto_list=&load_numbers($crypto_num);
210$max_crypto = $max_num;
211
212my $ssl="ssl/ssl.h";
213$ssl.=" ssl/kssl.h";
214
215my $crypto ="crypto/crypto.h";
216$crypto.=" crypto/des/des.h crypto/des/des_old.h" ; # unless $no_des;
217$crypto.=" crypto/idea/idea.h" ; # unless $no_idea;
218$crypto.=" crypto/rc4/rc4.h" ; # unless $no_rc4;
219$crypto.=" crypto/rc5/rc5.h" ; # unless $no_rc5;
220$crypto.=" crypto/rc2/rc2.h" ; # unless $no_rc2;
221$crypto.=" crypto/bf/blowfish.h" ; # unless $no_bf;
222$crypto.=" crypto/cast/cast.h" ; # unless $no_cast;
223$crypto.=" crypto/md2/md2.h" ; # unless $no_md2;
224$crypto.=" crypto/md4/md4.h" ; # unless $no_md4;
225$crypto.=" crypto/md5/md5.h" ; # unless $no_md5;
226$crypto.=" crypto/mdc2/mdc2.h" ; # unless $no_mdc2;
227$crypto.=" crypto/sha/sha.h" ; # unless $no_sha;
228$crypto.=" crypto/ripemd/ripemd.h" ; # unless $no_ripemd;
229$crypto.=" crypto/aes/aes.h" ; # unless $no_aes;
230
231$crypto.=" crypto/bn/bn.h";
232$crypto.=" crypto/rsa/rsa.h" ; # unless $no_rsa;
233$crypto.=" crypto/dsa/dsa.h" ; # unless $no_dsa;
234$crypto.=" crypto/dh/dh.h" ; # unless $no_dh;
235$crypto.=" crypto/ec/ec.h" ; # unless $no_ec;
236$crypto.=" crypto/hmac/hmac.h" ; # unless $no_hmac;
237
238$crypto.=" crypto/engine/engine.h";
239$crypto.=" crypto/stack/stack.h" ; # unless $no_stack;
240$crypto.=" crypto/buffer/buffer.h" ; # unless $no_buffer;
241$crypto.=" crypto/bio/bio.h" ; # unless $no_bio;
242$crypto.=" crypto/dso/dso.h" ; # unless $no_dso;
243$crypto.=" crypto/lhash/lhash.h" ; # unless $no_lhash;
244$crypto.=" crypto/conf/conf.h";
245$crypto.=" crypto/txt_db/txt_db.h";
246
247$crypto.=" crypto/evp/evp.h" ; # unless $no_evp;
248$crypto.=" crypto/objects/objects.h";
249$crypto.=" crypto/pem/pem.h";
250#$crypto.=" crypto/meth/meth.h";
251$crypto.=" crypto/asn1/asn1.h";
252$crypto.=" crypto/asn1/asn1t.h";
253$crypto.=" crypto/asn1/asn1_mac.h";
254$crypto.=" crypto/err/err.h" ; # unless $no_err;
255$crypto.=" crypto/pkcs7/pkcs7.h";
256$crypto.=" crypto/pkcs12/pkcs12.h";
257$crypto.=" crypto/x509/x509.h";
258$crypto.=" crypto/x509/x509_vfy.h";
259$crypto.=" crypto/x509v3/x509v3.h";
260$crypto.=" crypto/rand/rand.h";
261$crypto.=" crypto/comp/comp.h" ; # unless $no_comp;
262$crypto.=" crypto/ocsp/ocsp.h";
263$crypto.=" crypto/ui/ui.h crypto/ui/ui_compat.h";
264$crypto.=" crypto/krb5/krb5_asn.h";
265$crypto.=" crypto/tmdiff.h";
266
267my $symhacks="crypto/symhacks.h";
268
269my @ssl_symbols = &do_defs("SSLEAY", $ssl, $symhacks);
270my @crypto_symbols = &do_defs("LIBEAY", $crypto, $symhacks);
271
272if ($do_update) {
273
274if ($do_ssl == 1) {
275
276 &maybe_add_info("SSLEAY",*ssl_list,@ssl_symbols);
277 if ($do_rewrite == 1) {
278 open(OUT, ">$ssl_num");
279 &rewrite_numbers(*OUT,"SSLEAY",*ssl_list,@ssl_symbols);
280 } else {
281 open(OUT, ">>$ssl_num");
282 }
283 &update_numbers(*OUT,"SSLEAY",*ssl_list,$max_ssl,@ssl_symbols);
284 close OUT;
285}
286
287if($do_crypto == 1) {
288
289 &maybe_add_info("LIBEAY",*crypto_list,@crypto_symbols);
290 if ($do_rewrite == 1) {
291 open(OUT, ">$crypto_num");
292 &rewrite_numbers(*OUT,"LIBEAY",*crypto_list,@crypto_symbols);
293 } else {
294 open(OUT, ">>$crypto_num");
295 }
296 &update_numbers(*OUT,"LIBEAY",*crypto_list,$max_crypto,@crypto_symbols);
297 close OUT;
298}
299
300} elsif ($do_checkexist) {
301 &check_existing(*ssl_list, @ssl_symbols)
302 if $do_ssl == 1;
303 &check_existing(*crypto_list, @crypto_symbols)
304 if $do_crypto == 1;
305} elsif ($do_ctest || $do_ctestall) {
306
307 print <<"EOF";
308
309/* Test file to check all DEF file symbols are present by trying
310 * to link to all of them. This is *not* intended to be run!
311 */
312
313int main()
314{
315EOF
316 &print_test_file(*STDOUT,"SSLEAY",*ssl_list,$do_ctestall,@ssl_symbols)
317 if $do_ssl == 1;
318
319 &print_test_file(*STDOUT,"LIBEAY",*crypto_list,$do_ctestall,@crypto_symbols)
320 if $do_crypto == 1;
321
322 print "}\n";
323
324} else {
325
326 &print_def_file(*STDOUT,$libname,*ssl_list,@ssl_symbols)
327 if $do_ssl == 1;
328
329 &print_def_file(*STDOUT,$libname,*crypto_list,@crypto_symbols)
330 if $do_crypto == 1;
331
332}
333
334
335sub do_defs
336{
337 my($name,$files,$symhacksfile)=@_;
338 my $file;
339 my @ret;
340 my %syms;
341 my %platform; # For anything undefined, we assume ""
342 my %kind; # For anything undefined, we assume "FUNCTION"
343 my %algorithm; # For anything undefined, we assume ""
344 my %variant;
345 my %variant_cnt; # To be able to allocate "name{n}" if "name"
346 # is the same name as the original.
347 my $cpp;
348 my %unknown_algorithms = ();
349
350 foreach $file (split(/\s+/,$symhacksfile." ".$files))
351 {
352 print STDERR "DEBUG: starting on $file:\n" if $debug;
353 open(IN,"<$file") || die "unable to open $file:$!\n";
354 my $line = "", my $def= "";
355 my %tag = (
356 (map { $_ => 0 } @known_platforms),
357 (map { "OPENSSL_SYS_".$_ => 0 } @known_ossl_platforms),
358 (map { "OPENSSL_NO_".$_ => 0 } @known_algorithms),
359 NOPROTO => 0,
360 PERL5 => 0,
361 _WINDLL => 0,
362 CONST_STRICT => 0,
363 TRUE => 1,
364 );
365 my $symhacking = $file eq $symhacksfile;
366 my @current_platforms = ();
367 my @current_algorithms = ();
368
369 # params: symbol, alias, platforms, kind
370 # The reason to put this subroutine in a variable is that
371 # it will otherwise create it's own, unshared, version of
372 # %tag and %variant...
373 my $make_variant = sub
374 {
375 my ($s, $a, $p, $k) = @_;
376 my ($a1, $a2);
377
378 print STDERR "DEBUG: make_variant: Entered with ",$s,", ",$a,", ",(defined($p)?$p:""),", ",(defined($k)?$k:""),"\n" if $debug;
379 if (defined($p))
380 {
381 $a1 = join(",",$p,
382 grep(!/^$/,
383 map { $tag{$_} == 1 ? $_ : "" }
384 @known_platforms));
385 }
386 else
387 {
388 $a1 = join(",",
389 grep(!/^$/,
390 map { $tag{$_} == 1 ? $_ : "" }
391 @known_platforms));
392 }
393 $a2 = join(",",
394 grep(!/^$/,
395 map { $tag{"OPENSSL_SYS_".$_} == 1 ? $_ : "" }
396 @known_ossl_platforms));
397 print STDERR "DEBUG: make_variant: a1 = $a1; a2 = $a2\n" if $debug;
398 if ($a1 eq "") { $a1 = $a2; }
399 elsif ($a1 ne "" && $a2 ne "") { $a1 .= ",".$a2; }
400 if ($a eq $s)
401 {
402 if (!defined($variant_cnt{$s}))
403 {
404 $variant_cnt{$s} = 0;
405 }
406 $variant_cnt{$s}++;
407 $a .= "{$variant_cnt{$s}}";
408 }
409 my $toadd = $a.":".$a1.(defined($k)?":".$k:"");
410 my $togrep = $s.'(\{[0-9]+\})?:'.$a1.(defined($k)?":".$k:"");
411 if (!grep(/^$togrep$/,
412 split(/;/, defined($variant{$s})?$variant{$s}:""))) {
413 if (defined($variant{$s})) { $variant{$s} .= ";"; }
414 $variant{$s} .= $toadd;
415 }
416 print STDERR "DEBUG: make_variant: Exit with variant of ",$s," = ",$variant{$s},"\n" if $debug;
417 };
418
419 print STDERR "DEBUG: parsing ----------\n" if $debug;
420 while(<IN>) {
421 last if (/\/\* Error codes for the \w+ functions\. \*\//);
422 if ($line ne '') {
423 $_ = $line . $_;
424 $line = '';
425 }
426
427 if (/\\$/) {
428 chomp; # remove eol
429 chop; # remove ending backslash
430 $line = $_;
431 next;
432 }
433
434 $cpp = 1 if /^\#.*ifdef.*cplusplus/;
435 if ($cpp) {
436 $cpp = 0 if /^\#.*endif/;
437 next;
438 }
439
440 s/\/\*.*?\*\///gs; # ignore comments
441 s/{[^{}]*}//gs; # ignore {} blocks
442 print STDERR "DEBUG: \$_=\"$_\"\n" if $debug;
443 if (/^\#\s*ifndef\s+(.*)/) {
444 push(@tag,"-");
445 push(@tag,$1);
446 $tag{$1}=-1;
447 print STDERR "DEBUG: $file: found tag $1 = -1\n" if $debug;
448 } elsif (/^\#\s*if\s+!defined\(([^\)]+)\)/) {
449 push(@tag,"-");
450 if (/^\#\s*if\s+(!defined\(([^\)]+)\)(\s+\&\&\s+!defined\(([^\)]+)\))*)$/) {
451 my $tmp_1 = $1;
452 my $tmp_;
453 foreach $tmp_ (split '\&\&',$tmp_1) {
454 $tmp_ =~ /!defined\(([^\)]+)\)/;
455 print STDERR "DEBUG: $file: found tag $1 = -1\n" if $debug;
456 push(@tag,$1);
457 $tag{$1}=-1;
458 }
459 } else {
460 print STDERR "Warning: $file: complicated expression: $_" if $debug; # because it is O...
461 print STDERR "DEBUG: $file: found tag $1 = -1\n" if $debug;
462 push(@tag,$1);
463 $tag{$1}=-1;
464 }
465 } elsif (/^\#\s*ifdef\s+(.*)/) {
466 push(@tag,"-");
467 push(@tag,$1);
468 $tag{$1}=1;
469 print STDERR "DEBUG: $file: found tag $1 = 1\n" if $debug;
470 } elsif (/^\#\s*if\s+defined\(([^\)]+)\)/) {
471 push(@tag,"-");
472 if (/^\#\s*if\s+(defined\(([^\)]+)\)(\s+\|\|\s+defined\(([^\)]+)\))*)$/) {
473 my $tmp_1 = $1;
474 my $tmp_;
475 foreach $tmp_ (split '\|\|',$tmp_1) {
476 $tmp_ =~ /defined\(([^\)]+)\)/;
477 print STDERR "DEBUG: $file: found tag $1 = 1\n" if $debug;
478 push(@tag,$1);
479 $tag{$1}=1;
480 }
481 } else {
482 print STDERR "Warning: $file: complicated expression: $_\n" if $debug; # because it is O...
483 print STDERR "DEBUG: $file: found tag $1 = 1\n" if $debug;
484 push(@tag,$1);
485 $tag{$1}=1;
486 }
487 } elsif (/^\#\s*error\s+(\w+) is disabled\./) {
488 my $tag_i = $#tag;
489 while($tag[$tag_i] ne "-") {
490 if ($tag[$tag_i] eq "OPENSSL_NO_".$1) {
491 $tag{$tag[$tag_i]}=2;
492 print STDERR "DEBUG: $file: chaged tag $1 = 2\n" if $debug;
493 }
494 $tag_i--;
495 }
496 } elsif (/^\#\s*endif/) {
497 my $tag_i = $#tag;
498 while($tag[$tag_i] ne "-") {
499 my $t=$tag[$tag_i];
500 print STDERR "DEBUG: \$t=\"$t\"\n" if $debug;
501 if ($tag{$t}==2) {
502 $tag{$t}=-1;
503 } else {
504 $tag{$t}=0;
505 }
506 print STDERR "DEBUG: $file: changed tag ",$t," = ",$tag{$t},"\n" if $debug;
507 pop(@tag);
508 if ($t =~ /^OPENSSL_NO_([A-Z0-9_]+)$/) {
509 $t=$1;
510 } else {
511 $t="";
512 }
513 if ($t ne ""
514 && !grep(/^$t$/, @known_algorithms)) {
515 $unknown_algorithms{$t} = 1;
516 #print STDERR "DEBUG: Added as unknown algorithm: $t\n" if $debug;
517 }
518 $tag_i--;
519 }
520 pop(@tag);
521 } elsif (/^\#\s*else/) {
522 my $tag_i = $#tag;
523 while($tag[$tag_i] ne "-") {
524 my $t=$tag[$tag_i];
525 $tag{$t}= -$tag{$t};
526 print STDERR "DEBUG: $file: changed tag ",$t," = ",$tag{$t},"\n" if $debug;
527 $tag_i--;
528 }
529 } elsif (/^\#\s*if\s+1/) {
530 push(@tag,"-");
531 # Dummy tag
532 push(@tag,"TRUE");
533 $tag{"TRUE"}=1;
534 print STDERR "DEBUG: $file: found 1\n" if $debug;
535 } elsif (/^\#\s*if\s+0/) {
536 push(@tag,"-");
537 # Dummy tag
538 push(@tag,"TRUE");
539 $tag{"TRUE"}=-1;
540 print STDERR "DEBUG: $file: found 0\n" if $debug;
541 } elsif (/^\#\s*define\s+(\w+)\s+(\w+)/
542 && $symhacking && $tag{'TRUE'} != -1) {
543 # This is for aliasing. When we find an alias,
544 # we have to invert
545 &$make_variant($1,$2);
546 print STDERR "DEBUG: $file: defined $1 = $2\n" if $debug;
547 }
548 if (/^\#/) {
549 @current_platforms =
550 grep(!/^$/,
551 map { $tag{$_} == 1 ? $_ :
552 $tag{$_} == -1 ? "!".$_ : "" }
553 @known_platforms);
554 push @current_platforms
555 , grep(!/^$/,
556 map { $tag{"OPENSSL_SYS_".$_} == 1 ? $_ :
557 $tag{"OPENSSL_SYS_".$_} == -1 ? "!".$_ : "" }
558 @known_ossl_platforms);
559 @current_algorithms =
560 grep(!/^$/,
561 map { $tag{"OPENSSL_NO_".$_} == -1 ? $_ : "" }
562 @known_algorithms);
563 $def .=
564 "#INFO:"
565 .join(',',@current_platforms).":"
566 .join(',',@current_algorithms).";";
567 next;
568 }
569 if ($tag{'TRUE'} != -1) {
570 if (/^\s*DECLARE_STACK_OF\s*\(\s*(\w*)\s*\)/) {
571 next;
572 } elsif (/^\s*DECLARE_ASN1_ENCODE_FUNCTIONS\s*\(\s*(\w*)\s*,\s*(\w*)\s*,\s*(\w*)\s*\)/) {
573 $def .= "int d2i_$3(void);";
574 $def .= "int i2d_$3(void);";
575 # Variant for platforms that do not
576 # have to access globale variables
577 # in shared libraries through functions
578 $def .=
579 "#INFO:"
580 .join(',',"!EXPORT_VAR_AS_FUNCTION",@current_platforms).":"
581 .join(',',@current_algorithms).";";
582 $def .= "OPENSSL_EXTERN int $2_it;";
583 $def .=
584 "#INFO:"
585 .join(',',@current_platforms).":"
586 .join(',',@current_algorithms).";";
587 # Variant for platforms that have to
588 # access globale variables in shared
589 # libraries through functions
590 &$make_variant("$2_it","$2_it",
591 "EXPORT_VAR_AS_FUNCTION",
592 "FUNCTION");
593 next;
594 } elsif (/^\s*DECLARE_ASN1_FUNCTIONS_fname\s*\(\s*(\w*)\s*,\s*(\w*)\s*,\s*(\w*)\s*\)/) {
595 $def .= "int d2i_$3(void);";
596 $def .= "int i2d_$3(void);";
597 $def .= "int $3_free(void);";
598 $def .= "int $3_new(void);";
599 # Variant for platforms that do not
600 # have to access globale variables
601 # in shared libraries through functions
602 $def .=
603 "#INFO:"
604 .join(',',"!EXPORT_VAR_AS_FUNCTION",@current_platforms).":"
605 .join(',',@current_algorithms).";";
606 $def .= "OPENSSL_EXTERN int $2_it;";
607 $def .=
608 "#INFO:"
609 .join(',',@current_platforms).":"
610 .join(',',@current_algorithms).";";
611 # Variant for platforms that have to
612 # access globale variables in shared
613 # libraries through functions
614 &$make_variant("$2_it","$2_it",
615 "EXPORT_VAR_AS_FUNCTION",
616 "FUNCTION");
617 next;
618 } elsif (/^\s*DECLARE_ASN1_FUNCTIONS\s*\(\s*(\w*)\s*\)/ ||
619 /^\s*DECLARE_ASN1_FUNCTIONS_const\s*\(\s*(\w*)\s*\)/) {
620 $def .= "int d2i_$1(void);";
621 $def .= "int i2d_$1(void);";
622 $def .= "int $1_free(void);";
623 $def .= "int $1_new(void);";
624 # Variant for platforms that do not
625 # have to access globale variables
626 # in shared libraries through functions
627 $def .=
628 "#INFO:"
629 .join(',',"!EXPORT_VAR_AS_FUNCTION",@current_platforms).":"
630 .join(',',@current_algorithms).";";
631 $def .= "OPENSSL_EXTERN int $1_it;";
632 $def .=
633 "#INFO:"
634 .join(',',@current_platforms).":"
635 .join(',',@current_algorithms).";";
636 # Variant for platforms that have to
637 # access globale variables in shared
638 # libraries through functions
639 &$make_variant("$1_it","$1_it",
640 "EXPORT_VAR_AS_FUNCTION",
641 "FUNCTION");
642 next;
643 } elsif (/^\s*DECLARE_ASN1_ENCODE_FUNCTIONS_const\s*\(\s*(\w*)\s*,\s*(\w*)\s*\)/) {
644 $def .= "int d2i_$2(void);";
645 $def .= "int i2d_$2(void);";
646 # Variant for platforms that do not
647 # have to access globale variables
648 # in shared libraries through functions
649 $def .=
650 "#INFO:"
651 .join(',',"!EXPORT_VAR_AS_FUNCTION",@current_platforms).":"
652 .join(',',@current_algorithms).";";
653 $def .= "OPENSSL_EXTERN int $2_it;";
654 $def .=
655 "#INFO:"
656 .join(',',@current_platforms).":"
657 .join(',',@current_algorithms).";";
658 # Variant for platforms that have to
659 # access globale variables in shared
660 # libraries through functions
661 &$make_variant("$2_it","$2_it",
662 "EXPORT_VAR_AS_FUNCTION",
663 "FUNCTION");
664 next;
665 } elsif (/^\s*DECLARE_ASN1_FUNCTIONS_name\s*\(\s*(\w*)\s*,\s*(\w*)\s*\)/) {
666 $def .= "int d2i_$2(void);";
667 $def .= "int i2d_$2(void);";
668 $def .= "int $2_free(void);";
669 $def .= "int $2_new(void);";
670 # Variant for platforms that do not
671 # have to access globale variables
672 # in shared libraries through functions
673 $def .=
674 "#INFO:"
675 .join(',',"!EXPORT_VAR_AS_FUNCTION",@current_platforms).":"
676 .join(',',@current_algorithms).";";
677 $def .= "OPENSSL_EXTERN int $2_it;";
678 $def .=
679 "#INFO:"
680 .join(',',@current_platforms).":"
681 .join(',',@current_algorithms).";";
682 # Variant for platforms that have to
683 # access globale variables in shared
684 # libraries through functions
685 &$make_variant("$2_it","$2_it",
686 "EXPORT_VAR_AS_FUNCTION",
687 "FUNCTION");
688 next;
689 } elsif (/^\s*DECLARE_ASN1_ITEM\s*\(\s*(\w*)\s*\)/) {
690 # Variant for platforms that do not
691 # have to access globale variables
692 # in shared libraries through functions
693 $def .=
694 "#INFO:"
695 .join(',',"!EXPORT_VAR_AS_FUNCTION",@current_platforms).":"
696 .join(',',@current_algorithms).";";
697 $def .= "OPENSSL_EXTERN int $1_it;";
698 $def .=
699 "#INFO:"
700 .join(',',@current_platforms).":"
701 .join(',',@current_algorithms).";";
702 # Variant for platforms that have to
703 # access globale variables in shared
704 # libraries through functions
705 &$make_variant("$1_it","$1_it",
706 "EXPORT_VAR_AS_FUNCTION",
707 "FUNCTION");
708 next;
709 } elsif (/^\s*DECLARE_ASN1_SET_OF\s*\(\s*(\w*)\s*\)/) {
710 next;
711 } elsif (/^\s*DECLARE_PKCS12_STACK_OF\s*\(\s*(\w*)\s*\)/) {
712 next;
713 } elsif (/^DECLARE_PEM_rw\s*\(\s*(\w*)\s*,/ ||
714 /^DECLARE_PEM_rw_cb\s*\(\s*(\w*)\s*,/ ) {
715 # Things not in Win16
716 $def .=
717 "#INFO:"
718 .join(',',"!WIN16",@current_platforms).":"
719 .join(',',@current_algorithms).";";
720 $def .= "int PEM_read_$1(void);";
721 $def .= "int PEM_write_$1(void);";
722 $def .=
723 "#INFO:"
724 .join(',',@current_platforms).":"
725 .join(',',@current_algorithms).";";
726 # Things that are everywhere
727 $def .= "int PEM_read_bio_$1(void);";
728 $def .= "int PEM_write_bio_$1(void);";
729 next;
730 } elsif (/^DECLARE_PEM_write\s*\(\s*(\w*)\s*,/ ||
731 /^DECLARE_PEM_write_cb\s*\(\s*(\w*)\s*,/ ) {
732 # Things not in Win16
733 $def .=
734 "#INFO:"
735 .join(',',"!WIN16",@current_platforms).":"
736 .join(',',@current_algorithms).";";
737 $def .= "int PEM_write_$1(void);";
738 $def .=
739 "#INFO:"
740 .join(',',@current_platforms).":"
741 .join(',',@current_algorithms).";";
742 # Things that are everywhere
743 $def .= "int PEM_write_bio_$1(void);";
744 next;
745 } elsif (/^DECLARE_PEM_read\s*\(\s*(\w*)\s*,/ ||
746 /^DECLARE_PEM_read_cb\s*\(\s*(\w*)\s*,/ ) {
747 # Things not in Win16
748 $def .=
749 "#INFO:"
750 .join(',',"!WIN16",@current_platforms).":"
751 .join(',',@current_algorithms).";";
752 $def .= "int PEM_read_$1(void);";
753 $def .=
754 "#INFO:"
755 .join(',',@current_platforms).":"
756 .join(',',@current_algorithms).";";
757 # Things that are everywhere
758 $def .= "int PEM_read_bio_$1(void);";
759 next;
760 } elsif (/^OPENSSL_DECLARE_GLOBAL\s*\(\s*(\w*)\s*,\s*(\w*)\s*\)/) {
761 # Variant for platforms that do not
762 # have to access globale variables
763 # in shared libraries through functions
764 $def .=
765 "#INFO:"
766 .join(',',"!EXPORT_VAR_AS_FUNCTION",@current_platforms).":"
767 .join(',',@current_algorithms).";";
768 $def .= "OPENSSL_EXTERN int _shadow_$2;";
769 $def .=
770 "#INFO:"
771 .join(',',@current_platforms).":"
772 .join(',',@current_algorithms).";";
773 # Variant for platforms that have to
774 # access globale variables in shared
775 # libraries through functions
776 &$make_variant("_shadow_$2","_shadow_$2",
777 "EXPORT_VAR_AS_FUNCTION",
778 "FUNCTION");
779 } elsif ($tag{'CONST_STRICT'} != 1) {
780 if (/\{|\/\*|\([^\)]*$/) {
781 $line = $_;
782 } else {
783 $def .= $_;
784 }
785 }
786 }
787 }
788 close(IN);
789
790 my $algs;
791 my $plays;
792
793 print STDERR "DEBUG: postprocessing ----------\n" if $debug;
794 foreach (split /;/, $def) {
795 my $s; my $k = "FUNCTION"; my $p; my $a;
796 s/^[\n\s]*//g;
797 s/[\n\s]*$//g;
798 next if(/\#undef/);
799 next if(/typedef\W/);
800 next if(/\#define/);
801
802 print STDERR "DEBUG: \$_ = \"$_\"\n" if $debug;
803 if (/^\#INFO:([^:]*):(.*)$/) {
804 $plats = $1;
805 $algs = $2;
806 print STDERR "DEBUG: found info on platforms ($plats) and algorithms ($algs)\n" if $debug;
807 next;
808 } elsif (/^\s*OPENSSL_EXTERN\s.*?(\w+(\{[0-9]+\})?)(\[[0-9]*\])*\s*$/) {
809 $s = $1;
810 $k = "VARIABLE";
811 print STDERR "DEBUG: found external variable $s\n" if $debug;
812 } elsif (/\(\*(\w*(\{[0-9]+\})?)\([^\)]+/) {
813 $s = $1;
814 print STDERR "DEBUG: found ANSI C function $s\n" if $debug;
815 } elsif (/\w+\W+(\w+)\W*\(\s*\)$/s) {
816 # K&R C
817 print STDERR "DEBUG: found K&R C function $s\n" if $debug;
818 next;
819 } elsif (/\w+\W+\w+(\{[0-9]+\})?\W*\(.*\)$/s) {
820 while (not /\(\)$/s) {
821 s/[^\(\)]*\)$/\)/s;
822 s/\([^\(\)]*\)\)$/\)/s;
823 }
824 s/\(void\)//;
825 /(\w+(\{[0-9]+\})?)\W*\(\)/s;
826 $s = $1;
827 print STDERR "DEBUG: found function $s\n" if $debug;
828 } elsif (/\(/ and not (/=/)) {
829 print STDERR "File $file: cannot parse: $_;\n";
830 next;
831 } else {
832 next;
833 }
834
835 $syms{$s} = 1;
836 $kind{$s} = $k;
837
838 $p = $plats;
839 $a = $algs;
840 $a .= ",BF" if($s =~ /EVP_bf/);
841 $a .= ",CAST" if($s =~ /EVP_cast/);
842 $a .= ",DES" if($s =~ /EVP_des/);
843 $a .= ",DSA" if($s =~ /EVP_dss/);
844 $a .= ",IDEA" if($s =~ /EVP_idea/);
845 $a .= ",MD2" if($s =~ /EVP_md2/);
846 $a .= ",MD4" if($s =~ /EVP_md4/);
847 $a .= ",MD5" if($s =~ /EVP_md5/);
848 $a .= ",RC2" if($s =~ /EVP_rc2/);
849 $a .= ",RC4" if($s =~ /EVP_rc4/);
850 $a .= ",RC5" if($s =~ /EVP_rc5/);
851 $a .= ",RIPEMD" if($s =~ /EVP_ripemd/);
852 $a .= ",SHA" if($s =~ /EVP_sha/);
853 $a .= ",RSA" if($s =~ /EVP_(Open|Seal)(Final|Init)/);
854 $a .= ",RSA" if($s =~ /PEM_Seal(Final|Init|Update)/);
855 $a .= ",RSA" if($s =~ /RSAPrivateKey/);
856 $a .= ",RSA" if($s =~ /SSLv23?_((client|server)_)?method/);
857
858 $platform{$s} =
859 &reduce_platforms((defined($platform{$s})?$platform{$s}.',':"").$p);
860 $algorithm{$s} .= ','.$a;
861
862 if (defined($variant{$s})) {
863 foreach $v (split /;/,$variant{$s}) {
864 (my $r, my $p, my $k) = split(/:/,$v);
865 my $ip = join ',',map({ /^!(.*)$/ ? $1 : "!".$_ } split /,/, $p);
866 $syms{$r} = 1;
867 if (!defined($k)) { $k = $kind{$s}; }
868 $kind{$r} = $k."(".$s.")";
869 $algorithm{$r} = $algorithm{$s};
870 $platform{$r} = &reduce_platforms($platform{$s}.",".$p.",".$p);
871 $platform{$s} = &reduce_platforms($platform{$s}.','.$ip.','.$ip);
872 print STDERR "DEBUG: \$variant{\"$s\"} = ",$v,"; \$r = $r; \$p = ",$platform{$r},"; \$a = ",$algorithm{$r},"; \$kind = ",$kind{$r},"\n" if $debug;
873 }
874 }
875 print STDERR "DEBUG: \$s = $s; \$p = ",$platform{$s},"; \$a = ",$algorithm{$s},"; \$kind = ",$kind{$s},"\n" if $debug;
876 }
877 }
878
879 # Prune the returned symbols
880
881 delete $syms{"bn_dump1"};
882 $platform{"BIO_s_log"} .= ",!WIN32,!WIN16,!macintosh";
883
884 $platform{"PEM_read_NS_CERT_SEQ"} = "VMS";
885 $platform{"PEM_write_NS_CERT_SEQ"} = "VMS";
886 $platform{"PEM_read_P8_PRIV_KEY_INFO"} = "VMS";
887 $platform{"PEM_write_P8_PRIV_KEY_INFO"} = "VMS";
888
889 # Info we know about
890
891 push @ret, map { $_."\\".&info_string($_,"EXIST",
892 $platform{$_},
893 $kind{$_},
894 $algorithm{$_}) } keys %syms;
895
896 if (keys %unknown_algorithms) {
897 print STDERR "WARNING: mkdef.pl doesn't know the following algorithms:\n";
898 print STDERR "\t",join("\n\t",keys %unknown_algorithms),"\n";
899 }
900 return(@ret);
901}
902
903# Param: string of comma-separated platform-specs.
904sub reduce_platforms
905{
906 my ($platforms) = @_;
907 my $pl = defined($platforms) ? $platforms : "";
908 my %p = map { $_ => 0 } split /,/, $pl;
909 my $ret;
910
911 print STDERR "DEBUG: Entered reduce_platforms with \"$platforms\"\n"
912 if $debug;
913 # We do this, because if there's code like the following, it really
914 # means the function exists in all cases and should therefore be
915 # everywhere. By increasing and decreasing, we may attain 0:
916 #
917 # ifndef WIN16
918 # int foo();
919 # else
920 # int _fat foo();
921 # endif
922 foreach $platform (split /,/, $pl) {
923 if ($platform =~ /^!(.*)$/) {
924 $p{$1}--;
925 } else {
926 $p{$platform}++;
927 }
928 }
929 foreach $platform (keys %p) {
930 if ($p{$platform} == 0) { delete $p{$platform}; }
931 }
932
933 delete $p{""};
934
935 $ret = join(',',sort(map { $p{$_} < 0 ? "!".$_ : $_ } keys %p));
936 print STDERR "DEBUG: Exiting reduce_platforms with \"$ret\"\n"
937 if $debug;
938 return $ret;
939}
940
941sub info_string {
942 (my $symbol, my $exist, my $platforms, my $kind, my $algorithms) = @_;
943
944 my %a = defined($algorithms) ?
945 map { $_ => 1 } split /,/, $algorithms : ();
946 my $k = defined($kind) ? $kind : "FUNCTION";
947 my $ret;
948 my $p = &reduce_platforms($platforms);
949
950 delete $a{""};
951
952 $ret = $exist;
953 $ret .= ":".$p;
954 $ret .= ":".$k;
955 $ret .= ":".join(',',sort keys %a);
956 return $ret;
957}
958
959sub maybe_add_info {
960 (my $name, *nums, my @symbols) = @_;
961 my $sym;
962 my $new_info = 0;
963 my %syms=();
964
965 print STDERR "Updating $name info\n";
966 foreach $sym (@symbols) {
967 (my $s, my $i) = split /\\/, $sym;
968 if (defined($nums{$s})) {
969 $i =~ s/^(.*?:.*?:\w+)(\(\w+\))?/$1/;
970 (my $n, my $dummy) = split /\\/, $nums{$s};
971 if (!defined($dummy) || $i ne $dummy) {
972 $nums{$s} = $n."\\".$i;
973 $new_info++;
974 print STDERR "DEBUG: maybe_add_info for $s: \"$dummy\" => \"$i\"\n" if $debug;
975 }
976 }
977 $syms{$s} = 1;
978 }
979
980 my @s=sort { &parse_number($nums{$a},"n") <=> &parse_number($nums{$b},"n") } keys %nums;
981 foreach $sym (@s) {
982 (my $n, my $i) = split /\\/, $nums{$sym};
983 if (!defined($syms{$sym}) && $i !~ /^NOEXIST:/) {
984 $new_info++;
985 print STDERR "DEBUG: maybe_add_info for $sym: -> undefined\n" if $debug;
986 }
987 }
988 if ($new_info) {
989 print STDERR "$new_info old symbols got an info update\n";
990 if (!$do_rewrite) {
991 print STDERR "You should do a rewrite to fix this.\n";
992 }
993 } else {
994 print STDERR "No old symbols needed info update\n";
995 }
996}
997
998# Param: string of comma-separated keywords, each possibly prefixed with a "!"
999sub is_valid
1000{
1001 my ($keywords_txt,$platforms) = @_;
1002 my (@keywords) = split /,/,$keywords_txt;
1003 my ($falsesum, $truesum) = (0, !grep(/^[^!]/,@keywords));
1004
1005 # Param: one keyword
1006 sub recognise
1007 {
1008 my ($keyword,$platforms) = @_;
1009
1010 if ($platforms) {
1011 # platforms
1012 if ($keyword eq "VMS" && $VMS) { return 1; }
1013 if ($keyword eq "WIN32" && $W32) { return 1; }
1014 if ($keyword eq "WIN16" && $W16) { return 1; }
1015 if ($keyword eq "WINNT" && $NT) { return 1; }
1016 if ($keyword eq "OS2" && $OS2) { return 1; }
1017 # Special platforms:
1018 # EXPORT_VAR_AS_FUNCTION means that global variables
1019 # will be represented as functions. This currently
1020 # only happens on VMS-VAX.
1021 if ($keyword eq "EXPORT_VAR_AS_FUNCTION" && ($VMSVAX || $W32 || $W16)) {
1022 return 1;
1023 }
1024 return 0;
1025 } else {
1026 # algorithms
1027 if ($keyword eq "RC2" && $no_rc2) { return 0; }
1028 if ($keyword eq "RC4" && $no_rc4) { return 0; }
1029 if ($keyword eq "RC5" && $no_rc5) { return 0; }
1030 if ($keyword eq "IDEA" && $no_idea) { return 0; }
1031 if ($keyword eq "DES" && $no_des) { return 0; }
1032 if ($keyword eq "BF" && $no_bf) { return 0; }
1033 if ($keyword eq "CAST" && $no_cast) { return 0; }
1034 if ($keyword eq "MD2" && $no_md2) { return 0; }
1035 if ($keyword eq "MD4" && $no_md4) { return 0; }
1036 if ($keyword eq "MD5" && $no_md5) { return 0; }
1037 if ($keyword eq "SHA" && $no_sha) { return 0; }
1038 if ($keyword eq "RIPEMD" && $no_ripemd) { return 0; }
1039 if ($keyword eq "MDC2" && $no_mdc2) { return 0; }
1040 if ($keyword eq "RSA" && $no_rsa) { return 0; }
1041 if ($keyword eq "DSA" && $no_dsa) { return 0; }
1042 if ($keyword eq "DH" && $no_dh) { return 0; }
1043 if ($keyword eq "EC" && $no_ec) { return 0; }
1044 if ($keyword eq "HMAC" && $no_hmac) { return 0; }
1045 if ($keyword eq "AES" && $no_aes) { return 0; }
1046 if ($keyword eq "EVP" && $no_evp) { return 0; }
1047 if ($keyword eq "LHASH" && $no_lhash) { return 0; }
1048 if ($keyword eq "STACK" && $no_stack) { return 0; }
1049 if ($keyword eq "ERR" && $no_err) { return 0; }
1050 if ($keyword eq "BUFFER" && $no_buffer) { return 0; }
1051 if ($keyword eq "BIO" && $no_bio) { return 0; }
1052 if ($keyword eq "COMP" && $no_comp) { return 0; }
1053 if ($keyword eq "DSO" && $no_dso) { return 0; }
1054 if ($keyword eq "KRB5" && $no_krb5) { return 0; }
1055 if ($keyword eq "FP_API" && $no_fp_api) { return 0; }
1056
1057 # Nothing recognise as true
1058 return 1;
1059 }
1060 }
1061
1062 foreach $k (@keywords) {
1063 if ($k =~ /^!(.*)$/) {
1064 $falsesum += &recognise($1,$platforms);
1065 } else {
1066 $truesum += &recognise($k,$platforms);
1067 }
1068 }
1069 print STDERR "DEBUG: [",$#keywords,",",$#keywords < 0,"] is_valid($keywords_txt) => (\!$falsesum) && $truesum = ",(!$falsesum) && $truesum,"\n" if $debug;
1070 return (!$falsesum) && $truesum;
1071}
1072
1073sub print_test_file
1074{
1075 (*OUT,my $name,*nums,my $testall,my @symbols)=@_;
1076 my $n = 1; my @e; my @r;
1077 my $sym; my $prev = ""; my $prefSSLeay;
1078
1079 (@e)=grep(/^SSLeay(\{[0-9]+\})?\\.*?:.*?:.*/,@symbols);
1080 (@r)=grep(/^\w+(\{[0-9]+\})?\\.*?:.*?:.*/ && !/^SSLeay(\{[0-9]+\})?\\.*?:.*?:.*/,@symbols);
1081 @symbols=((sort @e),(sort @r));
1082
1083 foreach $sym (@symbols) {
1084 (my $s, my $i) = $sym =~ /^(.*?)\\(.*)$/;
1085 my $v = 0;
1086 $v = 1 if $i=~ /^.*?:.*?:VARIABLE/;
1087 my $p = ($i =~ /^[^:]*:([^:]*):/,$1);
1088 my $a = ($i =~ /^[^:]*:[^:]*:[^:]*:([^:]*)/,$1);
1089 if (!defined($nums{$s})) {
1090 print STDERR "Warning: $s does not have a number assigned\n"
1091 if(!$do_update);
1092 } elsif (is_valid($p,1) && is_valid($a,0)) {
1093 my $s2 = ($s =~ /^(.*?)(\{[0-9]+\})?$/, $1);
1094 if ($prev eq $s2) {
1095 print OUT "\t/* The following has already appeared previously */\n";
1096 print STDERR "Warning: Symbol '",$s2,"' redefined. old=",($nums{$prev} =~ /^(.*?)\\/,$1),", new=",($nums{$s2} =~ /^(.*?)\\/,$1),"\n";
1097 }
1098 $prev = $s2; # To warn about duplicates...
1099
1100 ($nn,$ni)=($nums{$s2} =~ /^(.*?)\\(.*)$/);
1101 if ($v) {
1102 print OUT "\textern int $s2; /* type unknown */ /* $nn $ni */\n";
1103 } else {
1104 print OUT "\textern int $s2(); /* type unknown */ /* $nn $ni */\n";
1105 }
1106 }
1107 }
1108}
1109
1110sub print_def_file
1111{
1112 (*OUT,my $name,*nums,my @symbols)=@_;
1113 my $n = 1; my @e; my @r; my @v; my $prev="";
1114 my $liboptions="";
1115
1116 if ($W32)
1117 { $name.="32"; }
1118 elsif ($W16)
1119 { $name.="16"; }
1120 elsif ($OS2)
1121 { $liboptions = "INITINSTANCE\nDATA NONSHARED"; }
1122
1123 print OUT <<"EOF";
1124;
1125; Definition file for the DLL version of the $name library from OpenSSL
1126;
1127
1128LIBRARY $name $liboptions
1129
1130DESCRIPTION 'OpenSSL $name - http://www.openssl.org/'
1131
1132EOF
1133
1134 if ($W16) {
1135 print <<"EOF";
1136CODE PRELOAD MOVEABLE
1137DATA PRELOAD MOVEABLE SINGLE
1138
1139EXETYPE WINDOWS
1140
1141HEAPSIZE 4096
1142STACKSIZE 8192
1143
1144EOF
1145 }
1146
1147 print "EXPORTS\n";
1148
1149 (@e)=grep(/^SSLeay(\{[0-9]+\})?\\.*?:.*?:FUNCTION/,@symbols);
1150 (@r)=grep(/^\w+(\{[0-9]+\})?\\.*?:.*?:FUNCTION/ && !/^SSLeay(\{[0-9]+\})?\\.*?:.*?:FUNCTION/,@symbols);
1151 (@v)=grep(/^\w+(\{[0-9]+\})?\\.*?:.*?:VARIABLE/,@symbols);
1152 @symbols=((sort @e),(sort @r), (sort @v));
1153
1154
1155 foreach $sym (@symbols) {
1156 (my $s, my $i) = $sym =~ /^(.*?)\\(.*)$/;
1157 my $v = 0;
1158 $v = 1 if $i =~ /^.*?:.*?:VARIABLE/;
1159 if (!defined($nums{$s})) {
1160 printf STDERR "Warning: $s does not have a number assigned\n"
1161 if(!$do_update);
1162 } else {
1163 (my $n, my $dummy) = split /\\/, $nums{$s};
1164 my %pf = ();
1165 my $p = ($i =~ /^[^:]*:([^:]*):/,$1);
1166 my $a = ($i =~ /^[^:]*:[^:]*:[^:]*:([^:]*)/,$1);
1167 if (is_valid($p,1) && is_valid($a,0)) {
1168 my $s2 = ($s =~ /^(.*?)(\{[0-9]+\})?$/, $1);
1169 if ($prev eq $s2) {
1170 print STDERR "Warning: Symbol '",$s2,"' redefined. old=",($nums{$prev} =~ /^(.*?)\\/,$1),", new=",($nums{$s2} =~ /^(.*?)\\/,$1),"\n";
1171 }
1172 $prev = $s2; # To warn about duplicates...
1173 if($v && !$OS2) {
1174 printf OUT " %s%-39s @%-8d DATA\n",($W32)?"":"_",$s2,$n;
1175 } else {
1176 printf OUT " %s%-39s @%d\n",($W32||$OS2)?"":"_",$s2,$n;
1177 }
1178 }
1179 }
1180 }
1181 printf OUT "\n";
1182}
1183
1184sub load_numbers
1185{
1186 my($name)=@_;
1187 my(@a,%ret);
1188
1189 $max_num = 0;
1190 $num_noinfo = 0;
1191 $prev = "";
1192 $prev_cnt = 0;
1193
1194 open(IN,"<$name") || die "unable to open $name:$!\n";
1195 while (<IN>) {
1196 chop;
1197 s/#.*$//;
1198 next if /^\s*$/;
1199 @a=split;
1200 if (defined $ret{$a[0]}) {
1201 # This is actually perfectly OK
1202 #print STDERR "Warning: Symbol '",$a[0],"' redefined. old=",$ret{$a[0]},", new=",$a[1],"\n";
1203 }
1204 if ($max_num > $a[1]) {
1205 print STDERR "Warning: Number decreased from ",$max_num," to ",$a[1],"\n";
1206 }
1207 elsif ($max_num == $a[1]) {
1208 # This is actually perfectly OK
1209 #print STDERR "Warning: Symbol ",$a[0]," has same number as previous ",$prev,": ",$a[1],"\n";
1210 if ($a[0] eq $prev) {
1211 $prev_cnt++;
1212 $a[0] .= "{$prev_cnt}";
1213 }
1214 }
1215 else {
1216 $prev_cnt = 0;
1217 }
1218 if ($#a < 2) {
1219 # Existence will be proven later, in do_defs
1220 $ret{$a[0]}=$a[1];
1221 $num_noinfo++;
1222 } else {
1223 $ret{$a[0]}=$a[1]."\\".$a[2]; # \\ is a special marker
1224 }
1225 $max_num = $a[1] if $a[1] > $max_num;
1226 $prev=$a[0];
1227 }
1228 if ($num_noinfo) {
1229 print STDERR "Warning: $num_noinfo symbols were without info.";
1230 if ($do_rewrite) {
1231 printf STDERR " The rewrite will fix this.\n";
1232 } else {
1233 printf STDERR " You should do a rewrite to fix this.\n";
1234 }
1235 }
1236 close(IN);
1237 return(%ret);
1238}
1239
1240sub parse_number
1241{
1242 (my $str, my $what) = @_;
1243 (my $n, my $i) = split(/\\/,$str);
1244 if ($what eq "n") {
1245 return $n;
1246 } else {
1247 return $i;
1248 }
1249}
1250
1251sub rewrite_numbers
1252{
1253 (*OUT,$name,*nums,@symbols)=@_;
1254 my $thing;
1255
1256 print STDERR "Rewriting $name\n";
1257
1258 my @r = grep(/^\w+(\{[0-9]+\})?\\.*?:.*?:\w+\(\w+\)/,@symbols);
1259 my $r; my %r; my %rsyms;
1260 foreach $r (@r) {
1261 (my $s, my $i) = split /\\/, $r;
1262 my $a = $1 if $i =~ /^.*?:.*?:\w+\((\w+)\)/;
1263 $i =~ s/^(.*?:.*?:\w+)\(\w+\)/$1/;
1264 $r{$a} = $s."\\".$i;
1265 $rsyms{$s} = 1;
1266 }
1267
1268 my %syms = ();
1269 foreach $_ (@symbols) {
1270 (my $n, my $i) = split /\\/;
1271 $syms{$n} = 1;
1272 }
1273
1274 my @s=sort {
1275 &parse_number($nums{$a},"n") <=> &parse_number($nums{$b},"n")
1276 || $a cmp $b
1277 } keys %nums;
1278 foreach $sym (@s) {
1279 (my $n, my $i) = split /\\/, $nums{$sym};
1280 next if defined($i) && $i =~ /^.*?:.*?:\w+\(\w+\)/;
1281 next if defined($rsyms{$sym});
1282 print STDERR "DEBUG: rewrite_numbers for sym = ",$sym,": i = ",$i,", n = ",$n,", rsym{sym} = ",$rsyms{$sym},"syms{sym} = ",$syms{$sym},"\n" if $debug;
1283 $i="NOEXIST::FUNCTION:"
1284 if !defined($i) || $i eq "" || !defined($syms{$sym});
1285 my $s2 = $sym;
1286 $s2 =~ s/\{[0-9]+\}$//;
1287 printf OUT "%s%-39s %d\t%s\n","",$s2,$n,$i;
1288 if (exists $r{$sym}) {
1289 (my $s, $i) = split /\\/,$r{$sym};
1290 my $s2 = $s;
1291 $s2 =~ s/\{[0-9]+\}$//;
1292 printf OUT "%s%-39s %d\t%s\n","",$s2,$n,$i;
1293 }
1294 }
1295}
1296
1297sub update_numbers
1298{
1299 (*OUT,$name,*nums,my $start_num, my @symbols)=@_;
1300 my $new_syms = 0;
1301
1302 print STDERR "Updating $name numbers\n";
1303
1304 my @r = grep(/^\w+(\{[0-9]+\})?\\.*?:.*?:\w+\(\w+\)/,@symbols);
1305 my $r; my %r; my %rsyms;
1306 foreach $r (@r) {
1307 (my $s, my $i) = split /\\/, $r;
1308 my $a = $1 if $i =~ /^.*?:.*?:\w+\((\w+)\)/;
1309 $i =~ s/^(.*?:.*?:\w+)\(\w+\)/$1/;
1310 $r{$a} = $s."\\".$i;
1311 $rsyms{$s} = 1;
1312 }
1313
1314 foreach $sym (@symbols) {
1315 (my $s, my $i) = $sym =~ /^(.*?)\\(.*)$/;
1316 next if $i =~ /^.*?:.*?:\w+\(\w+\)/;
1317 next if defined($rsyms{$sym});
1318 die "ERROR: Symbol $sym had no info attached to it."
1319 if $i eq "";
1320 if (!exists $nums{$s}) {
1321 $new_syms++;
1322 my $s2 = $s;
1323 $s2 =~ s/\{[0-9]+\}$//;
1324 printf OUT "%s%-39s %d\t%s\n","",$s2, ++$start_num,$i;
1325 if (exists $r{$s}) {
1326 ($s, $i) = split /\\/,$r{$s};
1327 $s =~ s/\{[0-9]+\}$//;
1328 printf OUT "%s%-39s %d\t%s\n","",$s, $start_num,$i;
1329 }
1330 }
1331 }
1332 if($new_syms) {
1333 print STDERR "$new_syms New symbols added\n";
1334 } else {
1335 print STDERR "No New symbols Added\n";
1336 }
1337}
1338
1339sub check_existing
1340{
1341 (*nums, my @symbols)=@_;
1342 my %existing; my @remaining;
1343 @remaining=();
1344 foreach $sym (@symbols) {
1345 (my $s, my $i) = $sym =~ /^(.*?)\\(.*)$/;
1346 $existing{$s}=1;
1347 }
1348 foreach $sym (keys %nums) {
1349 if (!exists $existing{$sym}) {
1350 push @remaining, $sym;
1351 }
1352 }
1353 if(@remaining) {
1354 print STDERR "The following symbols do not seem to exist:\n";
1355 foreach $sym (@remaining) {
1356 print STDERR "\t",$sym,"\n";
1357 }
1358 }
1359}
1360
diff --git a/src/lib/libcrypto/util/mkdir-p.pl b/src/lib/libcrypto/util/mkdir-p.pl
new file mode 100644
index 0000000000..6c69c2daa4
--- /dev/null
+++ b/src/lib/libcrypto/util/mkdir-p.pl
@@ -0,0 +1,33 @@
1#!/usr/local/bin/perl
2
3# mkdir-p.pl
4
5# On some systems, the -p option to mkdir (= also create any missing parent
6# directories) is not available.
7
8my $arg;
9
10foreach $arg (@ARGV) {
11 &do_mkdir_p($arg);
12}
13
14
15sub do_mkdir_p {
16 local($dir) = @_;
17
18 $dir =~ s|/*\Z(?!\n)||s;
19
20 if (-d $dir) {
21 return;
22 }
23
24 if ($dir =~ m|[^/]/|s) {
25 local($parent) = $dir;
26 $parent =~ s|[^/]*\Z(?!\n)||s;
27
28 do_mkdir_p($parent);
29 }
30
31 mkdir($dir, 0777) || die "Cannot create directory $dir: $!\n";
32 print "created directory `$dir'\n";
33}
diff --git a/src/lib/libcrypto/util/mkerr.pl b/src/lib/libcrypto/util/mkerr.pl
index 1b2915c767..4105047b21 100644
--- a/src/lib/libcrypto/util/mkerr.pl
+++ b/src/lib/libcrypto/util/mkerr.pl
@@ -132,16 +132,16 @@ while (($hdr, $lib) = each %libinc)
132 my $name = $1; 132 my $name = $1;
133 $name =~ tr/[a-z]/[A-Z]/; 133 $name =~ tr/[a-z]/[A-Z]/;
134 $ftrans{$name} = $1; 134 $ftrans{$name} = $1;
135 } elsif (/\w+\W+(\w+)\W*\(\s*\)(\s*__attribute__\(.*\)\s*)?$/s){ 135 } elsif (/\w+\W+(\w+)\W*\(\s*\)$/s){
136 # K&R C 136 # K&R C
137 next ; 137 next ;
138 } elsif (/\w+\W+\w+\W*\(.*\)(\s*__attribute__\(.*\)\s*)?$/s) { 138 } elsif (/\w+\W+\w+\W*\(.*\)$/s) {
139 while (not /\(\)(\s*__attribute__\(.*\)\s*)?$/s) { 139 while (not /\(\)$/s) {
140 s/[^\(\)]*\)(\s*__attribute__\(.*\)\s*)?$/\)/s; 140 s/[^\(\)]*\)$/\)/s;
141 s/\([^\(\)]*\)\)(\s*__attribute__\(.*\)\s*)?$/\)/s; 141 s/\([^\(\)]*\)\)$/\)/s;
142 } 142 }
143 s/\(void\)//; 143 s/\(void\)//;
144 /(\w+(\{[0-9]+\})?)\W*\(\)/s; 144 /(\w+)\W*\(\)/s;
145 my $name = $1; 145 my $name = $1;
146 $name =~ tr/[a-z]/[A-Z]/; 146 $name =~ tr/[a-z]/[A-Z]/;
147 $ftrans{$name} = $1; 147 $ftrans{$name} = $1;
@@ -262,7 +262,7 @@ foreach $lib (keys %csrc)
262 } else { 262 } else {
263 push @out, 263 push @out,
264"/* ====================================================================\n", 264"/* ====================================================================\n",
265" * Copyright (c) 2001-2003 The OpenSSL Project. All rights reserved.\n", 265" * Copyright (c) 2001-2002 The OpenSSL Project. All rights reserved.\n",
266" *\n", 266" *\n",
267" * Redistribution and use in source and binary forms, with or without\n", 267" * Redistribution and use in source and binary forms, with or without\n",
268" * modification, are permitted provided that the following conditions\n", 268" * modification, are permitted provided that the following conditions\n",
@@ -404,7 +404,7 @@ EOF
404 print OUT <<"EOF"; 404 print OUT <<"EOF";
405/* $cfile */ 405/* $cfile */
406/* ==================================================================== 406/* ====================================================================
407 * Copyright (c) 1999-2003 The OpenSSL Project. All rights reserved. 407 * Copyright (c) 1999-2002 The OpenSSL Project. All rights reserved.
408 * 408 *
409 * Redistribution and use in source and binary forms, with or without 409 * Redistribution and use in source and binary forms, with or without
410 * modification, are permitted provided that the following conditions 410 * modification, are permitted provided that the following conditions
diff --git a/src/lib/libcrypto/util/mkfiles.pl b/src/lib/libcrypto/util/mkfiles.pl
new file mode 100644
index 0000000000..29e1404c69
--- /dev/null
+++ b/src/lib/libcrypto/util/mkfiles.pl
@@ -0,0 +1,117 @@
1#!/usr/local/bin/perl
2#
3# This is a hacked version of files.pl for systems that can't do a 'make files'.
4# Do a perl util/mkminfo.pl >MINFO to build MINFO
5# Written by Steve Henson 1999.
6
7# List of directories to process
8
9my @dirs = (
10".",
11"crypto",
12"crypto/md2",
13"crypto/md4",
14"crypto/md5",
15"crypto/sha",
16"crypto/mdc2",
17"crypto/hmac",
18"crypto/ripemd",
19"crypto/des",
20"crypto/rc2",
21"crypto/rc4",
22"crypto/rc5",
23"crypto/idea",
24"crypto/bf",
25"crypto/cast",
26"crypto/aes",
27"crypto/bn",
28"crypto/rsa",
29"crypto/dsa",
30"crypto/dso",
31"crypto/dh",
32"crypto/ec",
33"crypto/buffer",
34"crypto/bio",
35"crypto/stack",
36"crypto/lhash",
37"crypto/rand",
38"crypto/err",
39"crypto/objects",
40"crypto/evp",
41"crypto/asn1",
42"crypto/pem",
43"crypto/x509",
44"crypto/x509v3",
45"crypto/conf",
46"crypto/txt_db",
47"crypto/pkcs7",
48"crypto/pkcs12",
49"crypto/comp",
50"crypto/engine",
51"crypto/ocsp",
52"crypto/ui",
53"crypto/krb5",
54"ssl",
55"apps",
56"test",
57"tools"
58);
59
60foreach (@dirs) {
61 &files_dir ($_, "Makefile.ssl");
62}
63
64exit(0);
65
66sub files_dir
67{
68my ($dir, $makefile) = @_;
69
70my %sym;
71
72open (IN, "$dir/$makefile") || die "Can't open $dir/$makefile";
73
74my $s="";
75
76while (<IN>)
77 {
78 chop;
79 s/#.*//;
80 if (/^(\S+)\s*=\s*(.*)$/)
81 {
82 $o="";
83 ($s,$b)=($1,$2);
84 for (;;)
85 {
86 if ($b =~ /\\$/)
87 {
88 chop($b);
89 $o.=$b." ";
90 $b=<IN>;
91 chop($b);
92 }
93 else
94 {
95 $o.=$b." ";
96 last;
97 }
98 }
99 $o =~ s/^\s+//;
100 $o =~ s/\s+$//;
101 $o =~ s/\s+/ /g;
102
103 $o =~ s/\$[({]([^)}]+)[)}]/$sym{$1}/g;
104 $sym{$s}=$o;
105 }
106 }
107
108print "RELATIVE_DIRECTORY=$dir\n";
109
110foreach (sort keys %sym)
111 {
112 print "$_=$sym{$_}\n";
113 }
114print "RELATIVE_DIRECTORY=\n";
115
116close (IN);
117}
diff --git a/src/lib/libcrypto/util/mklink.pl b/src/lib/libcrypto/util/mklink.pl
new file mode 100644
index 0000000000..9386da7aa4
--- /dev/null
+++ b/src/lib/libcrypto/util/mklink.pl
@@ -0,0 +1,69 @@
1#!/usr/local/bin/perl
2
3# mklink.pl
4
5# The first command line argument is a non-empty relative path
6# specifying the "from" directory.
7# Each other argument is a file name not containing / and
8# names a file in the current directory.
9#
10# For each of these files, we create in the "from" directory a link
11# of the same name pointing to the local file.
12#
13# We assume that the directory structure is a tree, i.e. that it does
14# not contain symbolic links and that the parent of / is never referenced.
15# Apart from this, this script should be able to handle even the most
16# pathological cases.
17
18my $from = shift;
19my @files = @ARGV;
20
21my @from_path = split(/[\\\/]/, $from);
22my $pwd = `pwd`;
23chop($pwd);
24my @pwd_path = split(/[\\\/]/, $pwd);
25
26my @to_path = ();
27
28my $dirname;
29foreach $dirname (@from_path) {
30
31 # In this loop, @to_path always is a relative path from
32 # @pwd_path (interpreted is an absolute path) to the original pwd.
33
34 # At the end, @from_path (as a relative path from the original pwd)
35 # designates the same directory as the absolute path @pwd_path,
36 # which means that @to_path then is a path from there to the original pwd.
37
38 next if ($dirname eq "" || $dirname eq ".");
39
40 if ($dirname eq "..") {
41 @to_path = (pop(@pwd_path), @to_path);
42 } else {
43 @to_path = ("..", @to_path);
44 push(@pwd_path, $dirname);
45 }
46}
47
48my $to = join('/', @to_path);
49
50my $file;
51$symlink_exists=eval {symlink("",""); 1};
52foreach $file (@files) {
53 my $err = "";
54 if ($symlink_exists) {
55 symlink("$to/$file", "$from/$file") or $err = " [$!]";
56 } else {
57 unlink "$from/$file";
58 open (OLD, "<$file") or die "Can't open $file: $!";
59 open (NEW, ">$from/$file") or die "Can't open $from/$file: $!";
60 binmode(OLD);
61 binmode(NEW);
62 while (<OLD>) {
63 print NEW $_;
64 }
65 close (OLD) or die "Can't close $file: $!";
66 close (NEW) or die "Can't close $from/$file: $!";
67 }
68 print $file . " => $from/$file$err\n";
69}
diff --git a/src/lib/libcrypto/util/perlpath.pl b/src/lib/libcrypto/util/perlpath.pl
new file mode 100644
index 0000000000..a1f236bd98
--- /dev/null
+++ b/src/lib/libcrypto/util/perlpath.pl
@@ -0,0 +1,35 @@
1#!/usr/local/bin/perl
2#
3# modify the '#!/usr/local/bin/perl'
4# line in all scripts that rely on perl.
5#
6
7require "find.pl";
8
9$#ARGV == 0 || print STDERR "usage: perlpath newpath (eg /usr/bin)\n";
10&find(".");
11
12sub wanted
13 {
14 return unless /\.pl$/ || /^[Cc]onfigur/;
15
16 open(IN,"<$_") || die "unable to open $dir/$_:$!\n";
17 @a=<IN>;
18 close(IN);
19
20 if (-d $ARGV[0]) {
21 $a[0]="#!$ARGV[0]/perl\n";
22 }
23 else {
24 $a[0]="#!$ARGV[0]\n";
25 }
26
27 # Playing it safe...
28 $new="$_.new";
29 open(OUT,">$new") || die "unable to open $dir/$new:$!\n";
30 print OUT @a;
31 close(OUT);
32
33 rename($new,$_) || die "unable to rename $dir/$new:$!\n";
34 chmod(0755,$_) || die "unable to chmod $dir/$new:$!\n";
35 }
diff --git a/src/lib/libcrypto/util/pl/BC-16.pl b/src/lib/libcrypto/util/pl/BC-16.pl
new file mode 100644
index 0000000000..2033f524ca
--- /dev/null
+++ b/src/lib/libcrypto/util/pl/BC-16.pl
@@ -0,0 +1,146 @@
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)
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)=@_;
123 local($ret,$f,$_,@f);
124
125 $file =~ s/\//$o/g if $o ne '/';
126 $n=&bname($targer);
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\n";
143 return($ret);
144 }
145
1461;
diff --git a/src/lib/libcrypto/util/pl/BC-32.pl b/src/lib/libcrypto/util/pl/BC-32.pl
new file mode 100644
index 0000000000..bd7a9d9301
--- /dev/null
+++ b/src/lib/libcrypto/util/pl/BC-32.pl
@@ -0,0 +1,135 @@
1#!/usr/local/bin/perl
2# Borland C++ builder 3 and 4 -- Janez Jere <jj@void.si>
3#
4
5$ssl= "ssleay32";
6$crypto="libeay32";
7
8$o='\\';
9$cp='copy';
10$rm='del';
11
12# C compiler stuff
13$cc='bcc32';
14$lflags="-ap -Tpe -x -Gn ";
15$mlflags='';
16
17$out_def="out32";
18$tmp_def="tmp32";
19$inc_def="inc32";
20#enable max error messages, disable most common warnings
21$cflags="-DWIN32_LEAN_AND_MEAN -q -w-aus -w-par -w-inl -c -tWC -tWM -DOPENSSL_SYSNAME_WIN32 -DL_ENDIAN -DDSO_WIN32 -D_stricmp=stricmp ";
22if ($debug)
23{
24 $cflags.="-Od -y -v -vi- -D_DEBUG";
25 $mlflags.=' ';
26}
27else
28{
29 $cflags.="-O2 -ff -fp";
30}
31
32$obj='.obj';
33$ofile="-o";
34
35# EXE linking stuff
36$link="ilink32";
37$efile="";
38$exep='.exe';
39if ($no_sock)
40 { $ex_libs=""; }
41else { $ex_libs="cw32mt.lib import32.lib"; }
42
43# static library stuff
44$mklib='tlib /P64';
45$ranlib='';
46$plib="";
47$libp=".lib";
48$shlibp=($shlib)?".dll":".lib";
49$lfile='';
50
51$shlib_ex_obj="";
52$app_ex_obj="c0x32.obj";
53
54$asm='nasmw';
55$asm.=" /Zi" if $debug;
56$afile='-f obj -o';
57
58$bn_mulw_obj='';
59$bn_mulw_src='';
60$des_enc_obj='';
61$des_enc_src='';
62$bf_enc_obj='';
63$bf_enc_src='';
64
65if (!$no_asm)
66 {
67 $bn_mulw_obj='crypto\bn\asm\bn_win32.obj';
68 $bn_mulw_src='crypto\bn\asm\bn_win32.asm';
69 $des_enc_obj='crypto\des\asm\d_win32.obj crypto\des\asm\y_win32.obj';
70 $des_enc_src='crypto\des\asm\d_win32.asm crypto\des\asm\y_win32.asm';
71 $bf_enc_obj='crypto\bf\asm\b_win32.obj';
72 $bf_enc_src='crypto\bf\asm\b_win32.asm';
73 $cast_enc_obj='crypto\cast\asm\c_win32.obj';
74 $cast_enc_src='crypto\cast\asm\c_win32.asm';
75 $rc4_enc_obj='crypto\rc4\asm\r4_win32.obj';
76 $rc4_enc_src='crypto\rc4\asm\r4_win32.asm';
77 $rc5_enc_obj='crypto\rc5\asm\r5_win32.obj';
78 $rc5_enc_src='crypto\rc5\asm\r5_win32.asm';
79 $md5_asm_obj='crypto\md5\asm\m5_win32.obj';
80 $md5_asm_src='crypto\md5\asm\m5_win32.asm';
81 $sha1_asm_obj='crypto\sha\asm\s1_win32.obj';
82 $sha1_asm_src='crypto\sha\asm\s1_win32.asm';
83 $rmd160_asm_obj='crypto\ripemd\asm\rm_win32.obj';
84 $rmd160_asm_src='crypto\ripemd\asm\rm_win32.asm';
85 $cflags.=" -DBN_ASM -DMD5_ASM -DSHA1_ASM -DRMD160_ASM";
86 }
87
88if ($shlib)
89 {
90 $mlflags.=" $lflags /dll";
91# $cflags =~ s| /MD| /MT|;
92 $lib_cflag=" /GD -D_WINDLL -D_DLL";
93 $out_def="out32dll";
94 $tmp_def="tmp32dll";
95 }
96
97sub do_lib_rule
98 {
99 local($objs,$target,$name,$shlib)=@_;
100 local($ret,$Name);
101
102 $taget =~ s/\//$o/g if $o ne '/';
103 ($Name=$name) =~ tr/a-z/A-Z/;
104
105# $target="\$(LIB_D)$o$target";
106 $ret.="$target: $objs\n";
107 if (!$shlib)
108 {
109 # $ret.="\t\$(RM) \$(O_$Name)\n";
110 $ret.="\techo LIB $<\n";
111 $ret.="\t&\$(MKLIB) $lfile$target -+\$**\n";
112 }
113 else
114 {
115 local($ex)=($target =~ /O_SSL/)?' $(L_CRYPTO)':'';
116 $ex.=' wsock32.lib gdi32.lib';
117 $ret.="\t\$(LINK) \$(MLFLAGS) $efile$target /def:ms/${Name}.def @<<\n \$(SHLIB_EX_OBJ) $objs $ex\n<<\n";
118 }
119 $ret.="\n";
120 return($ret);
121 }
122
123sub do_link_rule
124 {
125 local($target,$files,$dep_libs,$libs)=@_;
126 local($ret,$_);
127
128 $file =~ s/\//$o/g if $o ne '/';
129 $n=&bname($targer);
130 $ret.="$target: $files $dep_libs\n";
131 $ret.="\t\$(LINK) \$(LFLAGS) $files \$(APP_EX_OBJ), $target,, $libs\n\n";
132 return($ret);
133 }
134
1351;
diff --git a/src/lib/libcrypto/util/pl/Mingw32.pl b/src/lib/libcrypto/util/pl/Mingw32.pl
new file mode 100644
index 0000000000..45ab685974
--- /dev/null
+++ b/src/lib/libcrypto/util/pl/Mingw32.pl
@@ -0,0 +1,104 @@
1#!/usr/local/bin/perl
2#
3# Mingw32.pl -- Mingw32 with GNU cp (Mingw32f.pl uses DOS tools)
4#
5
6$o='/';
7$cp='cp';
8$rm='rem'; # use 'rm -f' if using GNU file utilities
9$mkdir='gmkdir';
10
11# gcc wouldn't accept backslashes in paths
12#$o='\\';
13#$cp='copy';
14#$rm='del';
15
16# C compiler stuff
17
18$cc='gcc';
19if ($debug)
20 { $cflags="-DL_ENDIAN -DDSO_WIN32 -g2 -ggdb"; }
21else
22 { $cflags="-DL_ENDIAN -DDSO_WIN32 -fomit-frame-pointer -O3 -m486 -Wall"; }
23
24if ($gaswin and !$no_asm)
25 {
26 $bn_asm_obj='$(OBJ_D)/bn-win32.o';
27 $bn_asm_src='crypto/bn/asm/bn-win32.s';
28 $bnco_asm_obj='$(OBJ_D)/co-win32.o';
29 $bnco_asm_src='crypto/bn/asm/co-win32.s';
30 $des_enc_obj='$(OBJ_D)/d-win32.o $(OBJ_D)/y-win32.o';
31 $des_enc_src='crypto/des/asm/d-win32.s crypto/des/asm/y-win32.s';
32 $bf_enc_obj='$(OBJ_D)/b-win32.o';
33 $bf_enc_src='crypto/bf/asm/b-win32.s';
34# $cast_enc_obj='$(OBJ_D)/c-win32.o';
35# $cast_enc_src='crypto/cast/asm/c-win32.s';
36 $rc4_enc_obj='$(OBJ_D)/r4-win32.o';
37 $rc4_enc_src='crypto/rc4/asm/r4-win32.s';
38 $rc5_enc_obj='$(OBJ_D)/r5-win32.o';
39 $rc5_enc_src='crypto/rc5/asm/r5-win32.s';
40 $md5_asm_obj='$(OBJ_D)/m5-win32.o';
41 $md5_asm_src='crypto/md5/asm/m5-win32.s';
42 $rmd160_asm_obj='$(OBJ_D)/rm-win32.o';
43 $rmd160_asm_src='crypto/ripemd/asm/rm-win32.s';
44 $sha1_asm_obj='$(OBJ_D)/s1-win32.o';
45 $sha1_asm_src='crypto/sha/asm/s1-win32.s';
46 $cflags.=" -DBN_ASM -DMD5_ASM -DSHA1_ASM";
47 }
48
49
50$obj='.o';
51$ofile='-o ';
52
53# EXE linking stuff
54$link='${CC}';
55$lflags='${CFLAGS}';
56$efile='-o ';
57$exep='';
58$ex_libs="-lwsock32 -lgdi32";
59
60# static library stuff
61$mklib='ar r';
62$mlflags='';
63$ranlib='ranlib';
64$plib='lib';
65$libp=".a";
66$shlibp=".a";
67$lfile='';
68
69$asm='as';
70$afile='-o ';
71#$bn_asm_obj="";
72#$bn_asm_src="";
73#$des_enc_obj="";
74#$des_enc_src="";
75#$bf_enc_obj="";
76#$bf_enc_src="";
77
78sub do_lib_rule
79 {
80 local($obj,$target,$name,$shlib)=@_;
81 local($ret,$_,$Name);
82
83 $target =~ s/\//$o/g if $o ne '/';
84 $target="$target";
85 ($Name=$name) =~ tr/a-z/A-Z/;
86
87 $ret.="$target: \$(${Name}OBJ)\n";
88 $ret.="\t\$(RM) $target\n";
89 $ret.="\t\$(MKLIB) $target \$(${Name}OBJ)\n";
90 $ret.="\t\$(RANLIB) $target\n\n";
91 }
92
93sub do_link_rule
94 {
95 local($target,$files,$dep_libs,$libs)=@_;
96 local($ret,$_);
97
98 $file =~ s/\//$o/g if $o ne '/';
99 $n=&bname($target);
100 $ret.="$target: $files $dep_libs\n";
101 $ret.="\t\$(LINK) ${efile}$target \$(LFLAGS) $files $libs\n\n";
102 return($ret);
103 }
1041;
diff --git a/src/lib/libcrypto/util/pl/Mingw32f.pl b/src/lib/libcrypto/util/pl/Mingw32f.pl
new file mode 100644
index 0000000000..44f5673d7a
--- /dev/null
+++ b/src/lib/libcrypto/util/pl/Mingw32f.pl
@@ -0,0 +1,73 @@
1#!/usr/local/bin/perl
2#
3# Mingw32f.pl -- copy files; Mingw32.pl is needed to do the compiling.
4#
5
6$o='\\';
7$cp='copy';
8$rm='del';
9
10# C compiler stuff
11
12$cc='gcc';
13if ($debug)
14 { $cflags="-g2 -ggdb -DDSO_WIN32"; }
15else
16 { $cflags="-O3 -fomit-frame-pointer -DDSO_WIN32"; }
17
18$obj='.o';
19$ofile='-o ';
20
21# EXE linking stuff
22$link='${CC}';
23$lflags='${CFLAGS}';
24$efile='-o ';
25$exep='';
26$ex_libs="-lwsock32 -lgdi32";
27
28# static library stuff
29$mklib='ar r';
30$mlflags='';
31$ranlib='ranlib';
32$plib='lib';
33$libp=".a";
34$shlibp=".a";
35$lfile='';
36
37$asm='as';
38$afile='-o ';
39$bn_asm_obj="";
40$bn_asm_src="";
41$des_enc_obj="";
42$des_enc_src="";
43$bf_enc_obj="";
44$bf_enc_src="";
45
46sub do_lib_rule
47 {
48 local($obj,$target,$name,$shlib)=@_;
49 local($ret,$_,$Name);
50
51 $target =~ s/\//$o/g if $o ne '/';
52 $target="$target";
53 ($Name=$name) =~ tr/a-z/A-Z/;
54
55 $ret.="$target: \$(${Name}OBJ)\n";
56 $ret.="\t\$(RM) $target\n";
57 $ret.="\t\$(MKLIB) $target \$(${Name}OBJ)\n";
58 $ret.="\t\$(RANLIB) $target\n\n";
59 }
60
61sub do_link_rule
62 {
63 local($target,$files,$dep_libs,$libs)=@_;
64 local($ret,$_);
65
66 $file =~ s/\//$o/g if $o ne '/';
67 $n=&bname($target);
68 $ret.="$target: $files $dep_libs\n";
69 $ret.="\t\$(LINK) ${efile}$target \$(LFLAGS) $files $libs\n\n";
70 return($ret);
71 }
721;
73
diff --git a/src/lib/libcrypto/util/pl/OS2-EMX.pl b/src/lib/libcrypto/util/pl/OS2-EMX.pl
new file mode 100644
index 0000000000..d695dda623
--- /dev/null
+++ b/src/lib/libcrypto/util/pl/OS2-EMX.pl
@@ -0,0 +1,117 @@
1#!/usr/local/bin/perl
2#
3# OS2-EMX.pl - for EMX GCC on OS/2
4#
5
6$o='\\';
7$cp='copy';
8$rm='rm -f';
9
10# C compiler stuff
11
12$cc='gcc';
13$cflags="-DL_ENDIAN -O3 -fomit-frame-pointer -m486 -Zmtd -Wall ";
14$cflags.="-Zomf " if $shlib;
15$shl_cflag="-Zdll";
16
17if ($debug) {
18 $cflags.="-g ";
19}
20
21$obj=$shlib ? '.obj' : '.o';
22$ofile='-o ';
23
24# EXE linking stuff
25$link='${CC}';
26$lflags='${CFLAGS} -Zbsd-signals -s';
27$efile='-o ';
28$exep='.exe';
29$ex_libs="-lsocket";
30
31# static library stuff
32$mklib='ar r';
33$mlflags='';
34$ranlib="ar s";
35$plib='';
36$libp=$shlib ? ".lib" : ".a";
37$shlibp=$shlib ? ".dll" : ".a";
38$lfile='';
39
40$asm=$shlib ? 'as -Zomf' : 'as';
41$afile='-o ';
42$bn_asm_obj="";
43$bn_asm_src="";
44$des_enc_obj="";
45$des_enc_src="";
46$bf_enc_obj="";
47$bf_enc_src="";
48
49if (!$no_asm)
50 {
51 $bn_asm_obj="crypto\\bn\\asm\\bn-os2$obj crypto\\bn\\asm\\co-os2$obj";
52 $bn_asm_src="crypto\\bn\\asm\\bn-os2.asm crypto\\bn\\asm\\co-os2.asm";
53 $des_enc_obj="crypto\\des\\asm\\d-os2$obj crypto\\des\\asm\\y-os2$obj";
54 $des_enc_src="crypto\\des\\asm\\d-os2.asm crypto\\des\\asm\\y-os2.asm";
55 $bf_enc_obj="crypto\\bf\\asm\\b-os2$obj";
56 $bf_enc_src="crypto\\bf\\asm\\b-os2.asm";
57 $cast_enc_obj="crypto\\cast\\asm\\c-os2$obj";
58 $cast_enc_src="crypto\\cast\\asm\\c-os2.asm";
59 $rc4_enc_obj="crypto\\rc4\\asm\\r4-os2$obj";
60 $rc4_enc_src="crypto\\rc4\\asm\\r4-os2.asm";
61 $rc5_enc_obj="crypto\\rc5\\asm\\r5-os2$obj";
62 $rc5_enc_src="crypto\\rc5\\asm\\r5-os2.asm";
63 $md5_asm_obj="crypto\\md5\\asm\\m5-os2$obj";
64 $md5_asm_src="crypto\\md5\\asm\\m5-os2.asm";
65 $sha1_asm_obj="crypto\\sha\\asm\\s1-os2$obj";
66 $sha1_asm_src="crypto\\sha\\asm\\s1-os2.asm";
67 $rmd160_asm_obj="crypto\\ripemd\\asm\\rm-os2$obj";
68 $rmd160_asm_src="crypto\\ripemd\\asm\\rm-os2.asm";
69 }
70
71if ($shlib)
72 {
73 $mlflags.=" $lflags -Zdll";
74 $lib_cflag=" -D_DLL";
75 $out_def="out_dll";
76 $tmp_def="tmp_dll";
77 }
78
79sub do_lib_rule
80 {
81 local($obj,$target,$name,$shlib)=@_;
82 local($ret,$_,$Name);
83
84 $target =~ s/\//$o/g if $o ne '/';
85 $target="$target";
86 ($Name=$name) =~ tr/a-z/A-Z/;
87
88 $ret.="$target: \$(${Name}OBJ)\n";
89 if (!$shlib)
90 {
91 $ret.="\t\$(RM) $target\n";
92 $ret.="\t\$(MKLIB) $target \$(${Name}OBJ)\n";
93 $ret.="\t\$(RANLIB) $target\n\n";
94 }
95 else
96 {
97 local($ex)=($target =~ /O_SSL/)?' $(L_CRYPTO)':'';
98 $ex.=' -lsocket';
99 $ret.="\t\$(LINK) \$(SHLIB_CFLAGS) \$(MLFLAGS) $efile$target \$(SHLIB_EX_OBJ) \$(${Name}OBJ) $ex os2/${Name}.def\n";
100 $ret.="\temximp -o $out_def/$name.a os2/${Name}.def\n";
101 $ret.="\temximp -o $out_def/$name.lib os2/${Name}.def\n\n";
102 }
103 }
104
105sub do_link_rule
106 {
107 local($target,$files,$dep_libs,$libs)=@_;
108 local($ret,$_);
109
110 $file =~ s/\//$o/g if $o ne '/';
111 $n=&bname($target);
112 $ret.="$target: $files $dep_libs\n";
113 $ret.="\t\$(LINK) ${efile}$target \$(CFLAG) \$(LFLAGS) $files $libs\n\n";
114 return($ret);
115 }
116
1171;
diff --git a/src/lib/libcrypto/util/pl/VC-16.pl b/src/lib/libcrypto/util/pl/VC-16.pl
new file mode 100644
index 0000000000..7cda5e67a9
--- /dev/null
+++ b/src/lib/libcrypto/util/pl/VC-16.pl
@@ -0,0 +1,172 @@
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="setargv.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)
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)=@_;
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\n";
169 return($ret);
170 }
171
1721;
diff --git a/src/lib/libcrypto/util/pl/VC-32.pl b/src/lib/libcrypto/util/pl/VC-32.pl
new file mode 100644
index 0000000000..d6e3a11530
--- /dev/null
+++ b/src/lib/libcrypto/util/pl/VC-32.pl
@@ -0,0 +1,140 @@
1#!/usr/local/bin/perl
2# VCw32lib.pl - the file for Visual C++ 4.[01] for windows NT, static libraries
3#
4
5$ssl= "ssleay32";
6$crypto="libeay32";
7
8$o='\\';
9$cp='copy nul+'; # Timestamps get stuffed otherwise
10$rm='del';
11
12# C compiler stuff
13$cc='cl';
14$cflags=' /MD /W3 /WX /G5 /Ox /O2 /Ob2 /Gs0 /GF /Gy /nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32';
15$lflags="/nologo /subsystem:console /machine:I386 /opt:ref";
16$mlflags='';
17
18$out_def="out32";
19$tmp_def="tmp32";
20$inc_def="inc32";
21
22if ($debug)
23 {
24 $cflags=" /MDd /W3 /WX /Zi /Yd /Od /nologo -DOPENSSL_SYSNAME_WIN32 -D_DEBUG -DL_ENDIAN -DWIN32_LEAN_AND_MEAN -DDEBUG -DDSO_WIN32";
25 $lflags.=" /debug";
26 $mlflags.=' /debug';
27 }
28$cflags .= " -DOPENSSL_SYSNAME_WINNT" if $NT == 1;
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="wsock32.lib user32.lib gdi32.lib"; }
40
41# static library stuff
42$mklib='lib';
43$ranlib='';
44$plib="";
45$libp=".lib";
46$shlibp=($shlib)?".dll":".lib";
47$lfile='/out:';
48
49$shlib_ex_obj="";
50$app_ex_obj="setargv.obj";
51if ($nasm) {
52 $asm='nasmw -f win32';
53 $afile='-o ';
54} else {
55 $asm='ml /Cp /coff /c /Cx';
56 $asm.=" /Zi" if $debug;
57 $afile='/Fo';
58}
59
60$bn_asm_obj='';
61$bn_asm_src='';
62$des_enc_obj='';
63$des_enc_src='';
64$bf_enc_obj='';
65$bf_enc_src='';
66
67if (!$no_asm)
68 {
69 $bn_asm_obj='crypto\bn\asm\bn_win32.obj';
70 $bn_asm_src='crypto\bn\asm\bn_win32.asm';
71 $des_enc_obj='crypto\des\asm\d_win32.obj crypto\des\asm\y_win32.obj';
72 $des_enc_src='crypto\des\asm\d_win32.asm crypto\des\asm\y_win32.asm';
73 $bf_enc_obj='crypto\bf\asm\b_win32.obj';
74 $bf_enc_src='crypto\bf\asm\b_win32.asm';
75 $cast_enc_obj='crypto\cast\asm\c_win32.obj';
76 $cast_enc_src='crypto\cast\asm\c_win32.asm';
77 $rc4_enc_obj='crypto\rc4\asm\r4_win32.obj';
78 $rc4_enc_src='crypto\rc4\asm\r4_win32.asm';
79 $rc5_enc_obj='crypto\rc5\asm\r5_win32.obj';
80 $rc5_enc_src='crypto\rc5\asm\r5_win32.asm';
81 $md5_asm_obj='crypto\md5\asm\m5_win32.obj';
82 $md5_asm_src='crypto\md5\asm\m5_win32.asm';
83 $sha1_asm_obj='crypto\sha\asm\s1_win32.obj';
84 $sha1_asm_src='crypto\sha\asm\s1_win32.asm';
85 $rmd160_asm_obj='crypto\ripemd\asm\rm_win32.obj';
86 $rmd160_asm_src='crypto\ripemd\asm\rm_win32.asm';
87 $cflags.=" -DBN_ASM -DMD5_ASM -DSHA1_ASM -DRMD160_ASM";
88 }
89
90if ($shlib)
91 {
92 $mlflags.=" $lflags /dll";
93# $cflags =~ s| /MD| /MT|;
94 $lib_cflag=" -D_WINDLL -D_DLL";
95 $out_def="out32dll";
96 $tmp_def="tmp32dll";
97 }
98
99$cflags.=" /Fd$out_def";
100
101sub do_lib_rule
102 {
103 local($objs,$target,$name,$shlib)=@_;
104 local($ret,$Name);
105
106 $taget =~ s/\//$o/g if $o ne '/';
107 ($Name=$name) =~ tr/a-z/A-Z/;
108
109# $target="\$(LIB_D)$o$target";
110 $ret.="$target: $objs\n";
111 if (!$shlib)
112 {
113# $ret.="\t\$(RM) \$(O_$Name)\n";
114 $ex =' advapi32.lib';
115 $ret.="\t\$(MKLIB) $lfile$target @<<\n $objs $ex\n<<\n";
116 }
117 else
118 {
119 local($ex)=($target =~ /O_SSL/)?' $(L_CRYPTO)':'';
120 $ex.=' wsock32.lib gdi32.lib advapi32.lib';
121 $ret.="\t\$(LINK) \$(MLFLAGS) $efile$target /def:ms/${Name}.def @<<\n \$(SHLIB_EX_OBJ) $objs $ex\n<<\n";
122 }
123 $ret.="\n";
124 return($ret);
125 }
126
127sub do_link_rule
128 {
129 local($target,$files,$dep_libs,$libs)=@_;
130 local($ret,$_);
131
132 $file =~ s/\//$o/g if $o ne '/';
133 $n=&bname($targer);
134 $ret.="$target: $files $dep_libs\n";
135 $ret.=" \$(LINK) \$(LFLAGS) $efile$target @<<\n";
136 $ret.=" \$(APP_EX_OBJ) $files $libs\n<<\n\n";
137 return($ret);
138 }
139
1401;
diff --git a/src/lib/libcrypto/util/pl/linux.pl b/src/lib/libcrypto/util/pl/linux.pl
new file mode 100644
index 0000000000..8924ed5480
--- /dev/null
+++ b/src/lib/libcrypto/util/pl/linux.pl
@@ -0,0 +1,104 @@
1#!/usr/local/bin/perl
2#
3# linux.pl - the standard unix makefile stuff.
4#
5
6$o='/';
7$cp='/bin/cp';
8$rm='/bin/rm -f';
9
10# C compiler stuff
11
12$cc='gcc';
13if ($debug)
14 { $cflags="-g2 -ggdb -DREF_CHECK -DCRYPTO_MDEBUG"; }
15elsif ($profile)
16 { $cflags="-pg -O3"; }
17else
18 { $cflags="-O3 -fomit-frame-pointer"; }
19
20if (!$no_asm)
21 {
22 $bn_asm_obj='$(OBJ_D)/bn86-elf.o';
23 $bn_asm_src='crypto/bn/asm/bn86unix.cpp';
24 $bnco_asm_obj='$(OBJ_D)/co86-elf.o';
25 $bnco_asm_src='crypto/bn/asm/co86unix.cpp';
26 $des_enc_obj='$(OBJ_D)/dx86-elf.o $(OBJ_D)/yx86-elf.o';
27 $des_enc_src='crypto/des/asm/dx86unix.cpp crypto/des/asm/yx86unix.cpp';
28 $bf_enc_obj='$(OBJ_D)/bx86-elf.o';
29 $bf_enc_src='crypto/bf/asm/bx86unix.cpp';
30 $cast_enc_obj='$(OBJ_D)/cx86-elf.o';
31 $cast_enc_src='crypto/cast/asm/cx86unix.cpp';
32 $rc4_enc_obj='$(OBJ_D)/rx86-elf.o';
33 $rc4_enc_src='crypto/rc4/asm/rx86unix.cpp';
34 $rc5_enc_obj='$(OBJ_D)/r586-elf.o';
35 $rc5_enc_src='crypto/rc5/asm/r586unix.cpp';
36 $md5_asm_obj='$(OBJ_D)/mx86-elf.o';
37 $md5_asm_src='crypto/md5/asm/mx86unix.cpp';
38 $rmd160_asm_obj='$(OBJ_D)/rm86-elf.o';
39 $rmd160_asm_src='crypto/ripemd/asm/rm86unix.cpp';
40 $sha1_asm_obj='$(OBJ_D)/sx86-elf.o';
41 $sha1_asm_src='crypto/sha/asm/sx86unix.cpp';
42 $cflags.=" -DBN_ASM -DMD5_ASM -DSHA1_ASM";
43 }
44
45$cflags.=" -DTERMIO -DL_ENDIAN -m486 -Wall";
46
47if ($shlib)
48 {
49 $shl_cflag=" -DPIC -fpic";
50 $shlibp=".so.$ssl_version";
51 $so_shlibp=".so";
52 }
53
54sub do_shlib_rule
55 {
56 local($obj,$target,$name,$shlib,$so_name)=@_;
57 local($ret,$_,$Name);
58
59 $target =~ s/\//$o/g if $o ne '/';
60 ($Name=$name) =~ tr/a-z/A-Z/;
61
62 $ret.="$target: \$(${Name}OBJ)\n";
63 $ret.="\t\$(RM) target\n";
64 $ret.="\tgcc \${CFLAGS} -shared -Wl,-soname,$target -o $target \$(${Name}OBJ)\n";
65 ($t=$target) =~ s/(^.*)\/[^\/]*$/$1/;
66 if ($so_name ne "")
67 {
68 $ret.="\t\$(RM) \$(LIB_D)$o$so_name\n";
69 $ret.="\tln -s $target \$(LIB_D)$o$so_name\n\n";
70 }
71 }
72
73sub do_link_rule
74 {
75 local($target,$files,$dep_libs,$libs)=@_;
76 local($ret,$_);
77
78 $file =~ s/\//$o/g if $o ne '/';
79 $n=&bname($target);
80 $ret.="$target: $files $dep_libs\n";
81 $ret.="\t\$(LINK) ${efile}$target \$(LFLAGS) $files $libs\n\n";
82 return($ret);
83 }
84
85sub do_asm_rule
86 {
87 local($target,$src)=@_;
88 local($ret,@s,@t,$i);
89
90 $target =~ s/\//$o/g if $o ne "/";
91 $src =~ s/\//$o/g if $o ne "/";
92
93 @s=split(/\s+/,$src);
94 @t=split(/\s+/,$target);
95
96 for ($i=0; $i<=$#s; $i++)
97 {
98 $ret.="$t[$i]: $s[$i]\n";
99 $ret.="\tgcc -E -DELF \$(SRC_D)$o$s[$i]|\$(AS) $afile$t[$i]\n\n";
100 }
101 return($ret);
102 }
103
1041;
diff --git a/src/lib/libcrypto/util/pl/ultrix.pl b/src/lib/libcrypto/util/pl/ultrix.pl
new file mode 100644
index 0000000000..ea370c71f9
--- /dev/null
+++ b/src/lib/libcrypto/util/pl/ultrix.pl
@@ -0,0 +1,38 @@
1#!/usr/local/bin/perl
2#
3# linux.pl - the standard unix makefile stuff.
4#
5
6$o='/';
7$cp='/bin/cp';
8$rm='/bin/rm -f';
9
10# C compiler stuff
11
12$cc='cc';
13if ($debug)
14 { $cflags="-g -DREF_CHECK -DCRYPTO_MDEBUG"; }
15else
16 { $cflags="-O2"; }
17
18$cflags.=" -std1 -DL_ENDIAN";
19
20if (!$no_asm)
21 {
22 $bn_asm_obj='$(OBJ_D)/mips1.o';
23 $bn_asm_src='crypto/bn/asm/mips1.s';
24 }
25
26sub do_link_rule
27 {
28 local($target,$files,$dep_libs,$libs)=@_;
29 local($ret,$_);
30
31 $file =~ s/\//$o/g if $o ne '/';
32 $n=&bname($target);
33 $ret.="$target: $files $dep_libs\n";
34 $ret.="\t\$(LINK) ${efile}$target \$(LFLAGS) $files $libs\n\n";
35 return($ret);
36 }
37
381;
diff --git a/src/lib/libcrypto/util/pl/unix.pl b/src/lib/libcrypto/util/pl/unix.pl
new file mode 100644
index 0000000000..146611ad99
--- /dev/null
+++ b/src/lib/libcrypto/util/pl/unix.pl
@@ -0,0 +1,96 @@
1#!/usr/local/bin/perl
2#
3# unix.pl - the standard unix makefile stuff.
4#
5
6$o='/';
7$cp='/bin/cp';
8$rm='/bin/rm -f';
9
10# C compiler stuff
11
12if ($gcc)
13 {
14 $cc='gcc';
15 if ($debug)
16 { $cflags="-g2 -ggdb"; }
17 else
18 { $cflags="-O3 -fomit-frame-pointer"; }
19 }
20else
21 {
22 $cc='cc';
23 if ($debug)
24 { $cflags="-g"; }
25 else
26 { $cflags="-O"; }
27 }
28$obj='.o';
29$ofile='-o ';
30
31# EXE linking stuff
32$link='${CC}';
33$lflags='${CFLAGS}';
34$efile='-o ';
35$exep='';
36$ex_libs="";
37
38# static library stuff
39$mklib='ar r';
40$mlflags='';
41$ranlib=&which("ranlib") or $ranlib="true";
42$plib='lib';
43$libp=".a";
44$shlibp=".a";
45$lfile='';
46
47$asm='as';
48$afile='-o ';
49$bn_asm_obj="";
50$bn_asm_src="";
51$des_enc_obj="";
52$des_enc_src="";
53$bf_enc_obj="";
54$bf_enc_src="";
55
56sub do_lib_rule
57 {
58 local($obj,$target,$name,$shlib)=@_;
59 local($ret,$_,$Name);
60
61 $target =~ s/\//$o/g if $o ne '/';
62 $target="$target";
63 ($Name=$name) =~ tr/a-z/A-Z/;
64
65 $ret.="$target: \$(${Name}OBJ)\n";
66 $ret.="\t\$(RM) $target\n";
67 $ret.="\t\$(MKLIB) $target \$(${Name}OBJ)\n";
68 $ret.="\t\$(RANLIB) $target\n\n";
69 }
70
71sub do_link_rule
72 {
73 local($target,$files,$dep_libs,$libs)=@_;
74 local($ret,$_);
75
76 $file =~ s/\//$o/g if $o ne '/';
77 $n=&bname($target);
78 $ret.="$target: $files $dep_libs\n";
79 $ret.="\t\$(LINK) ${efile}$target \$(LFLAGS) $files $libs\n\n";
80 return($ret);
81 }
82
83sub which
84 {
85 my ($name)=@_;
86 my $path;
87 foreach $path (split /:/, $ENV{PATH})
88 {
89 if (-x "$path/$name")
90 {
91 return "$path/$name";
92 }
93 }
94 }
95
961;
diff --git a/src/lib/libcrypto/util/pod2man.pl b/src/lib/libcrypto/util/pod2man.pl
new file mode 100644
index 0000000000..657e4e264e
--- /dev/null
+++ b/src/lib/libcrypto/util/pod2man.pl
@@ -0,0 +1,1183 @@
1: #!/usr/bin/perl-5.005
2 eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
3 if $running_under_some_shell;
4
5$DEF_PM_SECTION = '3pm' || '3';
6
7=head1 NAME
8
9pod2man - translate embedded Perl pod directives into man pages
10
11=head1 SYNOPSIS
12
13B<pod2man>
14[ B<--section=>I<manext> ]
15[ B<--release=>I<relpatch> ]
16[ B<--center=>I<string> ]
17[ B<--date=>I<string> ]
18[ B<--fixed=>I<font> ]
19[ B<--official> ]
20[ B<--lax> ]
21I<inputfile>
22
23=head1 DESCRIPTION
24
25B<pod2man> converts its input file containing embedded pod directives (see
26L<perlpod>) into nroff source suitable for viewing with nroff(1) or
27troff(1) using the man(7) macro set.
28
29Besides the obvious pod conversions, B<pod2man> also takes care of
30func(), func(n), and simple variable references like $foo or @bar so
31you don't have to use code escapes for them; complex expressions like
32C<$fred{'stuff'}> will still need to be escaped, though. Other nagging
33little roffish things that it catches include translating the minus in
34something like foo-bar, making a long dash--like this--into a real em
35dash, fixing up "paired quotes", putting a little space after the
36parens in something like func(), making C++ and PI look right, making
37double underbars have a little tiny space between them, making ALLCAPS
38a teeny bit smaller in troff(1), and escaping backslashes so you don't
39have to.
40
41=head1 OPTIONS
42
43=over 8
44
45=item center
46
47Set the centered header to a specific string. The default is
48"User Contributed Perl Documentation", unless the C<--official> flag is
49given, in which case the default is "Perl Programmers Reference Guide".
50
51=item date
52
53Set the left-hand footer string to this value. By default,
54the modification date of the input file will be used.
55
56=item fixed
57
58The fixed font to use for code refs. Defaults to CW.
59
60=item official
61
62Set the default header to indicate that this page is of
63the standard release in case C<--center> is not given.
64
65=item release
66
67Set the centered footer. By default, this is the current
68perl release.
69
70=item section
71
72Set the section for the C<.TH> macro. The standard conventions on
73sections are to use 1 for user commands, 2 for system calls, 3 for
74functions, 4 for devices, 5 for file formats, 6 for games, 7 for
75miscellaneous information, and 8 for administrator commands. This works
76best if you put your Perl man pages in a separate tree, like
77F</usr/local/perl/man/>. By default, section 1 will be used
78unless the file ends in F<.pm> in which case section 3 will be selected.
79
80=item lax
81
82Don't complain when required sections aren't present.
83
84=back
85
86=head1 Anatomy of a Proper Man Page
87
88For those not sure of the proper layout of a man page, here's
89an example of the skeleton of a proper man page. Head of the
90major headers should be setout as a C<=head1> directive, and
91are historically written in the rather startling ALL UPPER CASE
92format, although this is not mandatory.
93Minor headers may be included using C<=head2>, and are
94typically in mixed case.
95
96=over 10
97
98=item NAME
99
100Mandatory section; should be a comma-separated list of programs or
101functions documented by this podpage, such as:
102
103 foo, bar - programs to do something
104
105=item SYNOPSIS
106
107A short usage summary for programs and functions, which
108may someday be deemed mandatory.
109
110=item DESCRIPTION
111
112Long drawn out discussion of the program. It's a good idea to break this
113up into subsections using the C<=head2> directives, like
114
115 =head2 A Sample Subection
116
117 =head2 Yet Another Sample Subection
118
119=item OPTIONS
120
121Some people make this separate from the description.
122
123=item RETURN VALUE
124
125What the program or function returns if successful.
126
127=item ERRORS
128
129Exceptions, return codes, exit stati, and errno settings.
130
131=item EXAMPLES
132
133Give some example uses of the program.
134
135=item ENVIRONMENT
136
137Envariables this program might care about.
138
139=item FILES
140
141All files used by the program. You should probably use the FE<lt>E<gt>
142for these.
143
144=item SEE ALSO
145
146Other man pages to check out, like man(1), man(7), makewhatis(8), or catman(8).
147
148=item NOTES
149
150Miscellaneous commentary.
151
152=item CAVEATS
153
154Things to take special care with; sometimes called WARNINGS.
155
156=item DIAGNOSTICS
157
158All possible messages the program can print out--and
159what they mean.
160
161=item BUGS
162
163Things that are broken or just don't work quite right.
164
165=item RESTRICTIONS
166
167Bugs you don't plan to fix :-)
168
169=item AUTHOR
170
171Who wrote it (or AUTHORS if multiple).
172
173=item HISTORY
174
175Programs derived from other sources sometimes have this, or
176you might keep a modification log here.
177
178=back
179
180=head1 EXAMPLES
181
182 pod2man program > program.1
183 pod2man some_module.pm > /usr/perl/man/man3/some_module.3
184 pod2man --section=7 note.pod > note.7
185
186=head1 DIAGNOSTICS
187
188The following diagnostics are generated by B<pod2man>. Items
189marked "(W)" are non-fatal, whereas the "(F)" errors will cause
190B<pod2man> to immediately exit with a non-zero status.
191
192=over 4
193
194=item bad option in paragraph %d of %s: ``%s'' should be [%s]<%s>
195
196(W) If you start include an option, you should set it off
197as bold, italic, or code.
198
199=item can't open %s: %s
200
201(F) The input file wasn't available for the given reason.
202
203=item Improper man page - no dash in NAME header in paragraph %d of %s
204
205(W) The NAME header did not have an isolated dash in it. This is
206considered important.
207
208=item Invalid man page - no NAME line in %s
209
210(F) You did not include a NAME header, which is essential.
211
212=item roff font should be 1 or 2 chars, not `%s' (F)
213
214(F) The font specified with the C<--fixed> option was not
215a one- or two-digit roff font.
216
217=item %s is missing required section: %s
218
219(W) Required sections include NAME, DESCRIPTION, and if you're
220using a section starting with a 3, also a SYNOPSIS. Actually,
221not having a NAME is a fatal.
222
223=item Unknown escape: %s in %s
224
225(W) An unknown HTML entity (probably for an 8-bit character) was given via
226a C<EE<lt>E<gt>> directive. Besides amp, lt, gt, and quot, recognized
227entities are Aacute, aacute, Acirc, acirc, AElig, aelig, Agrave, agrave,
228Aring, aring, Atilde, atilde, Auml, auml, Ccedil, ccedil, Eacute, eacute,
229Ecirc, ecirc, Egrave, egrave, ETH, eth, Euml, euml, Iacute, iacute, Icirc,
230icirc, Igrave, igrave, Iuml, iuml, Ntilde, ntilde, Oacute, oacute, Ocirc,
231ocirc, Ograve, ograve, Oslash, oslash, Otilde, otilde, Ouml, ouml, szlig,
232THORN, thorn, Uacute, uacute, Ucirc, ucirc, Ugrave, ugrave, Uuml, uuml,
233Yacute, yacute, and yuml.
234
235=item Unmatched =back
236
237(W) You have a C<=back> without a corresponding C<=over>.
238
239=item Unrecognized pod directive: %s
240
241(W) You specified a pod directive that isn't in the known list of
242C<=head1>, C<=head2>, C<=item>, C<=over>, C<=back>, or C<=cut>.
243
244
245=back
246
247=head1 NOTES
248
249If you would like to print out a lot of man page continuously, you
250probably want to set the C and D registers to set contiguous page
251numbering and even/odd paging, at least on some versions of man(7).
252Settting the F register will get you some additional experimental
253indexing:
254
255 troff -man -rC1 -rD1 -rF1 perl.1 perldata.1 perlsyn.1 ...
256
257The indexing merely outputs messages via C<.tm> for each
258major page, section, subsection, item, and any C<XE<lt>E<gt>>
259directives.
260
261
262=head1 RESTRICTIONS
263
264None at this time.
265
266=head1 BUGS
267
268The =over and =back directives don't really work right. They
269take absolute positions instead of offsets, don't nest well, and
270making people count is suboptimal in any event.
271
272=head1 AUTHORS
273
274Original prototype by Larry Wall, but so massively hacked over by
275Tom Christiansen such that Larry probably doesn't recognize it anymore.
276
277=cut
278
279$/ = "";
280$cutting = 1;
281@Indices = ();
282
283# We try first to get the version number from a local binary, in case we're
284# running an installed version of Perl to produce documentation from an
285# uninstalled newer version's pod files.
286if ($^O ne 'plan9' and $^O ne 'dos' and $^O ne 'os2' and $^O ne 'MSWin32') {
287 my $perl = (-x './perl' && -f './perl' ) ?
288 './perl' :
289 ((-x '../perl' && -f '../perl') ?
290 '../perl' :
291 '');
292 ($version,$patch) = `$perl -e 'print $]'` =~ /^(\d\.\d{3})(\d{2})?/ if $perl;
293}
294# No luck; we'll just go with the running Perl's version
295($version,$patch) = $] =~ /^(.{5})(\d{2})?/ unless $version;
296$DEF_RELEASE = "perl $version";
297$DEF_RELEASE .= ", patch $patch" if $patch;
298
299
300sub makedate {
301 my $secs = shift;
302 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($secs);
303 my $mname = (qw{Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec})[$mon];
304 $year += 1900;
305 return "$mday/$mname/$year";
306}
307
308use Getopt::Long;
309
310$DEF_SECTION = 1;
311$DEF_CENTER = "User Contributed Perl Documentation";
312$STD_CENTER = "Perl Programmers Reference Guide";
313$DEF_FIXED = 'CW';
314$DEF_LAX = 0;
315
316sub usage {
317 warn "$0: @_\n" if @_;
318 die <<EOF;
319usage: $0 [options] podpage
320Options are:
321 --section=manext (default "$DEF_SECTION")
322 --release=relpatch (default "$DEF_RELEASE")
323 --center=string (default "$DEF_CENTER")
324 --date=string (default "$DEF_DATE")
325 --fixed=font (default "$DEF_FIXED")
326 --official (default NOT)
327 --lax (default NOT)
328EOF
329}
330
331$uok = GetOptions( qw(
332 section=s
333 release=s
334 center=s
335 date=s
336 fixed=s
337 official
338 lax
339 help));
340
341$DEF_DATE = makedate((stat($ARGV[0]))[9] || time());
342
343usage("Usage error!") unless $uok;
344usage() if $opt_help;
345usage("Need one and only one podpage argument") unless @ARGV == 1;
346
347$section = $opt_section || ($ARGV[0] =~ /\.pm$/
348 ? $DEF_PM_SECTION : $DEF_SECTION);
349$RP = $opt_release || $DEF_RELEASE;
350$center = $opt_center || ($opt_official ? $STD_CENTER : $DEF_CENTER);
351$lax = $opt_lax || $DEF_LAX;
352
353$CFont = $opt_fixed || $DEF_FIXED;
354
355if (length($CFont) == 2) {
356 $CFont_embed = "\\f($CFont";
357}
358elsif (length($CFont) == 1) {
359 $CFont_embed = "\\f$CFont";
360}
361else {
362 die "roff font should be 1 or 2 chars, not `$CFont_embed'";
363}
364
365$date = $opt_date || $DEF_DATE;
366
367for (qw{NAME DESCRIPTION}) {
368# for (qw{NAME DESCRIPTION AUTHOR}) {
369 $wanna_see{$_}++;
370}
371$wanna_see{SYNOPSIS}++ if $section =~ /^3/;
372
373
374$name = @ARGV ? $ARGV[0] : "<STDIN>";
375$Filename = $name;
376if ($section =~ /^1/) {
377 require File::Basename;
378 $name = uc File::Basename::basename($name);
379}
380$name =~ s/\.(pod|p[lm])$//i;
381
382# Lose everything up to the first of
383# */lib/*perl* standard or site_perl module
384# */*perl*/lib from -D prefix=/opt/perl
385# */*perl*/ random module hierarchy
386# which works.
387$name =~ s-//+-/-g;
388if ($name =~ s-^.*?/lib/[^/]*perl[^/]*/--i
389 or $name =~ s-^.*?/[^/]*perl[^/]*/lib/--i
390 or $name =~ s-^.*?/[^/]*perl[^/]*/--i) {
391 # Lose ^site(_perl)?/.
392 $name =~ s-^site(_perl)?/--;
393 # Lose ^arch/. (XXX should we use Config? Just for archname?)
394 $name =~ s~^(.*-$^O|$^O-.*)/~~o;
395 # Lose ^version/.
396 $name =~ s-^\d+\.\d+/--;
397}
398
399# Translate Getopt/Long to Getopt::Long, etc.
400$name =~ s(/)(::)g;
401
402if ($name ne 'something') {
403 FCHECK: {
404 open(F, "< $ARGV[0]") || die "can't open $ARGV[0]: $!";
405 while (<F>) {
406 next unless /^=\b/;
407 if (/^=head1\s+NAME\s*$/) { # an /m would forgive mistakes
408 $_ = <F>;
409 unless (/\s*-+\s+/) {
410 $oops++;
411 warn "$0: Improper man page - no dash in NAME header in paragraph $. of $ARGV[0]\n"
412 } else {
413 my @n = split /\s+-+\s+/;
414 if (@n != 2) {
415 $oops++;
416 warn "$0: Improper man page - malformed NAME header in paragraph $. of $ARGV[0]\n"
417 }
418 else {
419 $n[0] =~ s/\n/ /g;
420 $n[1] =~ s/\n/ /g;
421 %namedesc = @n;
422 }
423 }
424 last FCHECK;
425 }
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
428 die "$0: Invalid man page - 1st pod line is not NAME in $ARGV[0]\n" unless $lax;
429 }
430 die "$0: Invalid man page - no documentation in $ARGV[0]\n" unless $lax;
431 }
432 close F;
433}
434
435print <<"END";
436.rn '' }`
437''' \$RCSfile\$\$Revision\$\$Date\$
438'''
439''' \$Log\$
440'''
441.de Sh
442.br
443.if t .Sp
444.ne 5
445.PP
446\\fB\\\\\$1\\fR
447.PP
448..
449.de Sp
450.if t .sp .5v
451.if n .sp
452..
453.de Ip
454.br
455.ie \\\\n(.\$>=3 .ne \\\\\$3
456.el .ne 3
457.IP "\\\\\$1" \\\\\$2
458..
459.de Vb
460.ft $CFont
461.nf
462.ne \\\\\$1
463..
464.de Ve
465.ft R
466
467.fi
468..
469'''
470'''
471''' Set up \\*(-- to give an unbreakable dash;
472''' string Tr holds user defined translation string.
473''' Bell System Logo is used as a dummy character.
474'''
475.tr \\(*W-|\\(bv\\*(Tr
476.ie n \\{\\
477.ds -- \\(*W-
478.ds PI pi
479.if (\\n(.H=4u)&(1m=24u) .ds -- \\(*W\\h'-12u'\\(*W\\h'-12u'-\\" diablo 10 pitch
480.if (\\n(.H=4u)&(1m=20u) .ds -- \\(*W\\h'-12u'\\(*W\\h'-8u'-\\" diablo 12 pitch
481.ds L" ""
482.ds R" ""
483''' \\*(M", \\*(S", \\*(N" and \\*(T" are the equivalent of
484''' \\*(L" and \\*(R", except that they are used on ".xx" lines,
485''' such as .IP and .SH, which do another additional levels of
486''' double-quote interpretation
487.ds M" """
488.ds S" """
489.ds N" """""
490.ds T" """""
491.ds L' '
492.ds R' '
493.ds M' '
494.ds S' '
495.ds N' '
496.ds T' '
497'br\\}
498.el\\{\\
499.ds -- \\(em\\|
500.tr \\*(Tr
501.ds L" ``
502.ds R" ''
503.ds M" ``
504.ds S" ''
505.ds N" ``
506.ds T" ''
507.ds L' `
508.ds R' '
509.ds M' `
510.ds S' '
511.ds N' `
512.ds T' '
513.ds PI \\(*p
514'br\\}
515END
516
517print <<'END';
518.\" If the F register is turned on, we'll generate
519.\" index entries out stderr for the following things:
520.\" TH Title
521.\" SH Header
522.\" Sh Subsection
523.\" Ip Item
524.\" X<> Xref (embedded
525.\" Of course, you have to process the output yourself
526.\" in some meaninful fashion.
527.if \nF \{
528.de IX
529.tm Index:\\$1\t\\n%\t"\\$2"
530..
531.nr % 0
532.rr F
533.\}
534END
535
536print <<"END";
537.TH $name $section "$RP" "$date" "$center"
538.UC
539END
540
541push(@Indices, qq{.IX Title "$name $section"});
542
543while (($name, $desc) = each %namedesc) {
544 for ($name, $desc) { s/^\s+//; s/\s+$//; }
545 push(@Indices, qq(.IX Name "$name - $desc"\n));
546}
547
548print <<'END';
549.if n .hy 0
550.if n .na
551.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
552.de CQ \" put $1 in typewriter font
553END
554print ".ft $CFont\n";
555print <<'END';
556'if n "\c
557'if t \\&\\$1\c
558'if n \\&\\$1\c
559'if n \&"
560\\&\\$2 \\$3 \\$4 \\$5 \\$6 \\$7
561'.ft R
562..
563.\" @(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2
564. \" AM - accent mark definitions
565.bd B 3
566. \" fudge factors for nroff and troff
567.if n \{\
568. ds #H 0
569. ds #V .8m
570. ds #F .3m
571. ds #[ \f1
572. ds #] \fP
573.\}
574.if t \{\
575. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
576. ds #V .6m
577. ds #F 0
578. ds #[ \&
579. ds #] \&
580.\}
581. \" simple accents for nroff and troff
582.if n \{\
583. ds ' \&
584. ds ` \&
585. ds ^ \&
586. ds , \&
587. ds ~ ~
588. ds ? ?
589. ds ! !
590. ds /
591. ds q
592.\}
593.if t \{\
594. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
595. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
596. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
597. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
598. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
599. ds ? \s-2c\h'-\w'c'u*7/10'\u\h'\*(#H'\zi\d\s+2\h'\w'c'u*8/10'
600. ds ! \s-2\(or\s+2\h'-\w'\(or'u'\v'-.8m'.\v'.8m'
601. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
602. ds q o\h'-\w'o'u*8/10'\s-4\v'.4m'\z\(*i\v'-.4m'\s+4\h'\w'o'u*8/10'
603.\}
604. \" troff and (daisy-wheel) nroff accents
605.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
606.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
607.ds v \\k:\h'-(\\n(.wu*9/10-\*(#H)'\v'-\*(#V'\*(#[\s-4v\s0\v'\*(#V'\h'|\\n:u'\*(#]
608.ds _ \\k:\h'-(\\n(.wu*9/10-\*(#H+(\*(#F*2/3))'\v'-.4m'\z\(hy\v'.4m'\h'|\\n:u'
609.ds . \\k:\h'-(\\n(.wu*8/10)'\v'\*(#V*4/10'\z.\v'-\*(#V*4/10'\h'|\\n:u'
610.ds 3 \*(#[\v'.2m'\s-2\&3\s0\v'-.2m'\*(#]
611.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
612.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
613.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
614.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
615.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
616.ds ae a\h'-(\w'a'u*4/10)'e
617.ds Ae A\h'-(\w'A'u*4/10)'E
618.ds oe o\h'-(\w'o'u*4/10)'e
619.ds Oe O\h'-(\w'O'u*4/10)'E
620. \" corrections for vroff
621.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
622.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
623. \" for low resolution devices (crt and lpr)
624.if \n(.H>23 .if \n(.V>19 \
625\{\
626. ds : e
627. ds 8 ss
628. ds v \h'-1'\o'\(aa\(ga'
629. ds _ \h'-1'^
630. ds . \h'-1'.
631. ds 3 3
632. ds o a
633. ds d- d\h'-1'\(ga
634. ds D- D\h'-1'\(hy
635. ds th \o'bp'
636. ds Th \o'LP'
637. ds ae ae
638. ds Ae AE
639. ds oe oe
640. ds Oe OE
641.\}
642.rm #[ #] #H #V #F C
643END
644
645$indent = 0;
646
647$begun = "";
648
649# Unrolling [^A-Z>]|[A-Z](?!<) gives: // MRE pp 165.
650my $nonest = '(?:[^A-Z>]*(?:[A-Z](?!<)[^A-Z>]*)*)';
651
652while (<>) {
653 if ($cutting) {
654 next unless /^=/;
655 $cutting = 0;
656 }
657 if ($begun) {
658 if (/^=end\s+$begun/) {
659 $begun = "";
660 }
661 elsif ($begun =~ /^(roff|man)$/) {
662 print STDOUT $_;
663 }
664 next;
665 }
666 chomp;
667
668 # Translate verbatim paragraph
669
670 if (/^\s/) {
671 @lines = split(/\n/);
672 for (@lines) {
673 1 while s
674 {^( [^\t]* ) \t ( \t* ) }
675 { $1 . ' ' x (8 - (length($1)%8) + 8 * (length($2))) }ex;
676 s/\\/\\e/g;
677 s/\A/\\&/s;
678 }
679 $lines = @lines;
680 makespace() unless $verbatim++;
681 print ".Vb $lines\n";
682 print join("\n", @lines), "\n";
683 print ".Ve\n";
684 $needspace = 0;
685 next;
686 }
687
688 $verbatim = 0;
689
690 if (/^=for\s+(\S+)\s*/s) {
691 if ($1 eq "man" or $1 eq "roff") {
692 print STDOUT $',"\n\n";
693 } else {
694 # ignore unknown for
695 }
696 next;
697 }
698 elsif (/^=begin\s+(\S+)\s*/s) {
699 $begun = $1;
700 if ($1 eq "man" or $1 eq "roff") {
701 print STDOUT $'."\n\n";
702 }
703 next;
704 }
705
706 # check for things that'll hosed our noremap scheme; affects $_
707 init_noremap();
708
709 if (!/^=item/) {
710
711 # trofficate backslashes; must do it before what happens below
712 s/\\/noremap('\\e')/ge;
713
714 # protect leading periods and quotes against *roff
715 # mistaking them for directives
716 s/^(?:[A-Z]<)?[.']/\\&$&/gm;
717
718 # first hide the escapes in case we need to
719 # intuit something and get it wrong due to fmting
720
721 1 while s/([A-Z]<$nonest>)/noremap($1)/ge;
722
723 # func() is a reference to a perl function
724 s{
725 \b
726 (
727 [:\w]+ \(\)
728 )
729 } {I<$1>}gx;
730
731 # func(n) is a reference to a perl function or a man page
732 s{
733 ([:\w]+)
734 (
735 \( [^\051]+ \)
736 )
737 } {I<$1>\\|$2}gx;
738
739 # convert simple variable references
740 s/(\s+)([\$\@%][\w:]+)(?!\()/${1}C<$2>/g;
741
742 if (m{ (
743 [\-\w]+
744 \(
745 [^\051]*?
746 [\@\$,]
747 [^\051]*?
748 \)
749 )
750 }x && $` !~ /([LCI]<[^<>]*|-)$/ && !/^=\w/)
751 {
752 warn "$0: bad option in paragraph $. of $ARGV: ``$1'' should be [LCI]<$1>\n";
753 $oops++;
754 }
755
756 while (/(-[a-zA-Z])\b/g && $` !~ /[\w\-]$/) {
757 warn "$0: bad option in paragraph $. of $ARGV: ``$1'' should be [CB]<$1>\n";
758 $oops++;
759 }
760
761 # put it back so we get the <> processed again;
762 clear_noremap(0); # 0 means leave the E's
763
764 } else {
765 # trofficate backslashes
766 s/\\/noremap('\\e')/ge;
767
768 }
769
770 # need to hide E<> first; they're processed in clear_noremap
771 s/(E<[^<>]+>)/noremap($1)/ge;
772
773
774 $maxnest = 10;
775 while ($maxnest-- && /[A-Z]</) {
776
777 # can't do C font here
778 s/([BI])<($nonest)>/font($1) . $2 . font('R')/eg;
779
780 # files and filelike refs in italics
781 s/F<($nonest)>/I<$1>/g;
782
783 # no break -- usually we want C<> for this
784 s/S<($nonest)>/nobreak($1)/eg;
785
786 # LREF: a la HREF L<show this text|man/section>
787 s:L<([^|>]+)\|[^>]+>:$1:g;
788
789 # LREF: a manpage(3f)
790 s:L<([a-zA-Z][^\s\/]+)(\([^\)]+\))?>:the I<$1>$2 manpage:g;
791
792 # LREF: an =item on another manpage
793 s{
794 L<
795 ([^/]+)
796 /
797 (
798 [:\w]+
799 (\(\))?
800 )
801 >
802 } {the C<$2> entry in the I<$1> manpage}gx;
803
804 # LREF: an =item on this manpage
805 s{
806 ((?:
807 L<
808 /
809 (
810 [:\w]+
811 (\(\))?
812 )
813 >
814 (,?\s+(and\s+)?)?
815 )+)
816 } { internal_lrefs($1) }gex;
817
818 # LREF: a =head2 (head1?), maybe on a manpage, maybe right here
819 # the "func" can disambiguate
820 s{
821 L<
822 (?:
823 ([a-zA-Z]\S+?) /
824 )?
825 "?(.*?)"?
826 >
827 }{
828 do {
829 $1 # if no $1, assume it means on this page.
830 ? "the section on I<$2> in the I<$1> manpage"
831 : "the section on I<$2>"
832 }
833 }gesx; # s in case it goes over multiple lines, so . matches \n
834
835 s/Z<>/\\&/g;
836
837 # comes last because not subject to reprocessing
838 s/C<($nonest)>/noremap("${CFont_embed}${1}\\fR")/eg;
839 }
840
841 if (s/^=//) {
842 $needspace = 0; # Assume this.
843
844 s/\n/ /g;
845
846 ($Cmd, $_) = split(' ', $_, 2);
847
848 $dotlevel = 1;
849 if ($Cmd eq 'head1') {
850 $dotlevel = 1;
851 }
852 elsif ($Cmd eq 'head2') {
853 $dotlevel = 1;
854 }
855 elsif ($Cmd eq 'item') {
856 $dotlevel = 2;
857 }
858
859 if (defined $_) {
860 &escapes($dotlevel);
861 s/"/""/g;
862 }
863
864 clear_noremap(1);
865
866 if ($Cmd eq 'cut') {
867 $cutting = 1;
868 }
869 elsif ($Cmd eq 'head1') {
870 s/\s+$//;
871 delete $wanna_see{$_} if exists $wanna_see{$_};
872 print qq{.SH "$_"\n};
873 push(@Indices, qq{.IX Header "$_"\n});
874 }
875 elsif ($Cmd eq 'head2') {
876 print qq{.Sh "$_"\n};
877 push(@Indices, qq{.IX Subsection "$_"\n});
878 }
879 elsif ($Cmd eq 'over') {
880 push(@indent,$indent);
881 $indent += ($_ + 0) || 5;
882 }
883 elsif ($Cmd eq 'back') {
884 $indent = pop(@indent);
885 warn "$0: Unmatched =back in paragraph $. of $ARGV\n" unless defined $indent;
886 $needspace = 1;
887 }
888 elsif ($Cmd eq 'item') {
889 s/^\*( |$)/\\(bu$1/g;
890 # if you know how to get ":s please do
891 s/\\\*\(L"([^"]+?)\\\*\(R"/'$1'/g;
892 s/\\\*\(L"([^"]+?)""/'$1'/g;
893 s/[^"]""([^"]+?)""[^"]/'$1'/g;
894 # here do something about the $" in perlvar?
895 print STDOUT qq{.Ip "$_" $indent\n};
896 push(@Indices, qq{.IX Item "$_"\n});
897 }
898 elsif ($Cmd eq 'pod') {
899 # this is just a comment
900 }
901 else {
902 warn "$0: Unrecognized pod directive in paragraph $. of $ARGV: $Cmd\n";
903 }
904 }
905 else {
906 if ($needspace) {
907 &makespace;
908 }
909 &escapes(0);
910 clear_noremap(1);
911 print $_, "\n";
912 $needspace = 1;
913 }
914}
915
916print <<"END";
917
918.rn }` ''
919END
920
921if (%wanna_see && !$lax) {
922 @missing = keys %wanna_see;
923 warn "$0: $Filename is missing required section"
924 . (@missing > 1 && "s")
925 . ": @missing\n";
926 $oops++;
927}
928
929foreach (@Indices) { print "$_\n"; }
930
931exit;
932#exit ($oops != 0);
933
934#########################################################################
935
936sub nobreak {
937 my $string = shift;
938 $string =~ s/ /\\ /g;
939 $string;
940}
941
942sub escapes {
943 my $indot = shift;
944
945 s/X<(.*?)>/mkindex($1)/ge;
946
947 # translate the minus in foo-bar into foo\-bar for roff
948 s/([^0-9a-z-])-([^-])/$1\\-$2/g;
949
950 # make -- into the string version \*(-- (defined above)
951 s/\b--\b/\\*(--/g;
952 s/"--([^"])/"\\*(--$1/g; # should be a better way
953 s/([^"])--"/$1\\*(--"/g;
954
955 # fix up quotes; this is somewhat tricky
956 my $dotmacroL = 'L';
957 my $dotmacroR = 'R';
958 if ( $indot == 1 ) {
959 $dotmacroL = 'M';
960 $dotmacroR = 'S';
961 }
962 elsif ( $indot >= 2 ) {
963 $dotmacroL = 'N';
964 $dotmacroR = 'T';
965 }
966 if (!/""/) {
967 s/(^|\s)(['"])/noremap("$1\\*($dotmacroL$2")/ge;
968 s/(['"])($|[\-\s,;\\!?.])/noremap("\\*($dotmacroR$1$2")/ge;
969 }
970
971 #s/(?!")(?:.)--(?!")(?:.)/\\*(--/g;
972 #s/(?:(?!")(?:.)--(?:"))|(?:(?:")--(?!")(?:.))/\\*(--/g;
973
974
975 # make sure that func() keeps a bit a space tween the parens
976 ### s/\b\(\)/\\|()/g;
977 ### s/\b\(\)/(\\|)/g;
978
979 # make C++ into \*C+, which is a squinched version (defined above)
980 s/\bC\+\+/\\*(C+/g;
981
982 # make double underbars have a little tiny space between them
983 s/__/_\\|_/g;
984
985 # PI goes to \*(PI (defined above)
986 s/\bPI\b/noremap('\\*(PI')/ge;
987
988 # make all caps a teeny bit smaller, but don't muck with embedded code literals
989 my $hidCFont = font('C');
990 if ($Cmd !~ /^head1/) { # SH already makes smaller
991 # /g isn't enough; 1 while or we'll be off
992
993# 1 while s{
994# (?!$hidCFont)(..|^.|^)
995# \b
996# (
997# [A-Z][\/A-Z+:\-\d_$.]+
998# )
999# (s?)
1000# \b
1001# } {$1\\s-1$2\\s0}gmox;
1002
1003 1 while s{
1004 (?!$hidCFont)(..|^.|^)
1005 (
1006 \b[A-Z]{2,}[\/A-Z+:\-\d_\$]*\b
1007 )
1008 } {
1009 $1 . noremap( '\\s-1' . $2 . '\\s0' )
1010 }egmox;
1011
1012 }
1013}
1014
1015# make troff just be normal, but make small nroff get quoted
1016# decided to just put the quotes in the text; sigh;
1017sub ccvt {
1018 local($_,$prev) = @_;
1019 noremap(qq{.CQ "$_" \n\\&});
1020}
1021
1022sub makespace {
1023 if ($indent) {
1024 print ".Sp\n";
1025 }
1026 else {
1027 print ".PP\n";
1028 }
1029}
1030
1031sub mkindex {
1032 my ($entry) = @_;
1033 my @entries = split m:\s*/\s*:, $entry;
1034 push @Indices, ".IX Xref " . join ' ', map {qq("$_")} @entries;
1035 return '';
1036}
1037
1038sub font {
1039 local($font) = shift;
1040 return '\\f' . noremap($font);
1041}
1042
1043sub noremap {
1044 local($thing_to_hide) = shift;
1045 $thing_to_hide =~ tr/\000-\177/\200-\377/;
1046 return $thing_to_hide;
1047}
1048
1049sub init_noremap {
1050 # escape high bit characters in input stream
1051 s/([\200-\377])/"E<".ord($1).">"/ge;
1052}
1053
1054sub clear_noremap {
1055 my $ready_to_print = $_[0];
1056
1057 tr/\200-\377/\000-\177/;
1058
1059 # trofficate backslashes
1060 # s/(?!\\e)(?:..|^.|^)\\/\\e/g;
1061
1062 # now for the E<>s, which have been hidden until now
1063 # otherwise the interative \w<> processing would have
1064 # been hosed by the E<gt>
1065 s {
1066 E<
1067 (
1068 ( \d + )
1069 | ( [A-Za-z]+ )
1070 )
1071 >
1072 } {
1073 do {
1074 defined $2
1075 ? chr($2)
1076 :
1077 exists $HTML_Escapes{$3}
1078 ? do { $HTML_Escapes{$3} }
1079 : do {
1080 warn "$0: Unknown escape in paragraph $. of $ARGV: ``$&''\n";
1081 "E<$1>";
1082 }
1083 }
1084 }egx if $ready_to_print;
1085}
1086
1087sub internal_lrefs {
1088 local($_) = shift;
1089 local $trailing_and = s/and\s+$// ? "and " : "";
1090
1091 s{L</([^>]+)>}{$1}g;
1092 my(@items) = split( /(?:,?\s+(?:and\s+)?)/ );
1093 my $retstr = "the ";
1094 my $i;
1095 for ($i = 0; $i <= $#items; $i++) {
1096 $retstr .= "C<$items[$i]>";
1097 $retstr .= ", " if @items > 2 && $i != $#items;
1098 $retstr .= " and " if $i+2 == @items;
1099 }
1100
1101 $retstr .= " entr" . ( @items > 1 ? "ies" : "y" )
1102 . " elsewhere in this document";
1103 # terminal space to avoid words running together (pattern used
1104 # strips terminal spaces)
1105 $retstr .= " " if length $trailing_and;
1106 $retstr .= $trailing_and;
1107
1108 return $retstr;
1109
1110}
1111
1112BEGIN {
1113%HTML_Escapes = (
1114 'amp' => '&', # ampersand
1115 'lt' => '<', # left chevron, less-than
1116 'gt' => '>', # right chevron, greater-than
1117 'quot' => '"', # double quote
1118
1119 "Aacute" => "A\\*'", # capital A, acute accent
1120 "aacute" => "a\\*'", # small a, acute accent
1121 "Acirc" => "A\\*^", # capital A, circumflex accent
1122 "acirc" => "a\\*^", # small a, circumflex accent
1123 "AElig" => '\*(AE', # capital AE diphthong (ligature)
1124 "aelig" => '\*(ae', # small ae diphthong (ligature)
1125 "Agrave" => "A\\*`", # capital A, grave accent
1126 "agrave" => "A\\*`", # small a, grave accent
1127 "Aring" => 'A\\*o', # capital A, ring
1128 "aring" => 'a\\*o', # small a, ring
1129 "Atilde" => 'A\\*~', # capital A, tilde
1130 "atilde" => 'a\\*~', # small a, tilde
1131 "Auml" => 'A\\*:', # capital A, dieresis or umlaut mark
1132 "auml" => 'a\\*:', # small a, dieresis or umlaut mark
1133 "Ccedil" => 'C\\*,', # capital C, cedilla
1134 "ccedil" => 'c\\*,', # small c, cedilla
1135 "Eacute" => "E\\*'", # capital E, acute accent
1136 "eacute" => "e\\*'", # small e, acute accent
1137 "Ecirc" => "E\\*^", # capital E, circumflex accent
1138 "ecirc" => "e\\*^", # small e, circumflex accent
1139 "Egrave" => "E\\*`", # capital E, grave accent
1140 "egrave" => "e\\*`", # small e, grave accent
1141 "ETH" => '\\*(D-', # capital Eth, Icelandic
1142 "eth" => '\\*(d-', # small eth, Icelandic
1143 "Euml" => "E\\*:", # capital E, dieresis or umlaut mark
1144 "euml" => "e\\*:", # small e, dieresis or umlaut mark
1145 "Iacute" => "I\\*'", # capital I, acute accent
1146 "iacute" => "i\\*'", # small i, acute accent
1147 "Icirc" => "I\\*^", # capital I, circumflex accent
1148 "icirc" => "i\\*^", # small i, circumflex accent
1149 "Igrave" => "I\\*`", # capital I, grave accent
1150 "igrave" => "i\\*`", # small i, grave accent
1151 "Iuml" => "I\\*:", # capital I, dieresis or umlaut mark
1152 "iuml" => "i\\*:", # small i, dieresis or umlaut mark
1153 "Ntilde" => 'N\*~', # capital N, tilde
1154 "ntilde" => 'n\*~', # small n, tilde
1155 "Oacute" => "O\\*'", # capital O, acute accent
1156 "oacute" => "o\\*'", # small o, acute accent
1157 "Ocirc" => "O\\*^", # capital O, circumflex accent
1158 "ocirc" => "o\\*^", # small o, circumflex accent
1159 "Ograve" => "O\\*`", # capital O, grave accent
1160 "ograve" => "o\\*`", # small o, grave accent
1161 "Oslash" => "O\\*/", # capital O, slash
1162 "oslash" => "o\\*/", # small o, slash
1163 "Otilde" => "O\\*~", # capital O, tilde
1164 "otilde" => "o\\*~", # small o, tilde
1165 "Ouml" => "O\\*:", # capital O, dieresis or umlaut mark
1166 "ouml" => "o\\*:", # small o, dieresis or umlaut mark
1167 "szlig" => '\*8', # small sharp s, German (sz ligature)
1168 "THORN" => '\\*(Th', # capital THORN, Icelandic
1169 "thorn" => '\\*(th',, # small thorn, Icelandic
1170 "Uacute" => "U\\*'", # capital U, acute accent
1171 "uacute" => "u\\*'", # small u, acute accent
1172 "Ucirc" => "U\\*^", # capital U, circumflex accent
1173 "ucirc" => "u\\*^", # small u, circumflex accent
1174 "Ugrave" => "U\\*`", # capital U, grave accent
1175 "ugrave" => "u\\*`", # small u, grave accent
1176 "Uuml" => "U\\*:", # capital U, dieresis or umlaut mark
1177 "uuml" => "u\\*:", # small u, dieresis or umlaut mark
1178 "Yacute" => "Y\\*'", # capital Y, acute accent
1179 "yacute" => "y\\*'", # small y, acute accent
1180 "yuml" => "y\\*:", # small y, dieresis or umlaut mark
1181);
1182}
1183
diff --git a/src/lib/libcrypto/util/pod2mantest b/src/lib/libcrypto/util/pod2mantest
new file mode 100644
index 0000000000..412ca8d6d8
--- /dev/null
+++ b/src/lib/libcrypto/util/pod2mantest
@@ -0,0 +1,58 @@
1#!/bin/sh
2
3# This script is used by test/Makefile.ssl to check whether a sane 'pod2man'
4# is installed.
5# ('make install' should not try to run 'pod2man' if it does not exist or if
6# it is a broken 'pod2man' version that is known to cause trouble. if we find
7# the system 'pod2man' to be broken, we use our own copy instead)
8#
9# In any case, output an appropriate command line for running (or not
10# running) pod2man.
11
12
13IFS=:
14if test "$OSTYPE" = "msdosdjgpp"; then IFS=";"; fi
15
16try_without_dir=true
17# First we try "pod2man", then "$dir/pod2man" for each item in $PATH.
18for dir in dummy${IFS}$PATH; do
19 if [ "$try_without_dir" = true ]; then
20 # first iteration
21 pod2man=pod2man
22 try_without_dir=false
23 else
24 # second and later iterations
25 pod2man="$dir/pod2man"
26 if [ ! -f "$pod2man" ]; then # '-x' is not available on Ultrix
27 pod2man=''
28 fi
29 fi
30
31 if [ ! "$pod2man" = '' ]; then
32 failure=none
33
34 if "$pod2man" --section=1 --center=OpenSSL --release=dev pod2mantest.pod | fgrep OpenSSL >/dev/null; then
35 :
36 else
37 failure=BasicTest
38 fi
39
40 if [ "$failure" = none ]; then
41 if "$pod2man" --section=1 --center=OpenSSL --release=dev pod2mantest.pod | grep '^MARKER - ' >/dev/null; then
42 failure=MultilineTest
43 fi
44 fi
45
46
47 if [ "$failure" = none ]; then
48 echo "$pod2man"
49 exit 0
50 fi
51
52 echo "$pod2man does not work properly ('$failure' failed). Looking for another pod2man ..." >&2
53 fi
54done
55
56echo "No working pod2man found. Consider installing a new version." >&2
57echo "As a workaround, we'll use a bundled old copy of pod2man.pl." >&2
58echo "$1 ../../util/pod2man.pl"
diff --git a/src/lib/libcrypto/util/pod2mantest.pod b/src/lib/libcrypto/util/pod2mantest.pod
new file mode 100644
index 0000000000..5d2539a17f
--- /dev/null
+++ b/src/lib/libcrypto/util/pod2mantest.pod
@@ -0,0 +1,15 @@
1=pod
2
3=head1 NAME
4
5foo, bar,
6MARKER - test of multiline name section
7
8=head1 DESCRIPTION
9
10This is a test .pod file to see if we have a buggy pod2man or not.
11If we have a buggy implementation, we will get a line matching the
12regular expression "^ +MARKER - test of multiline name section *$"
13at the end of the resulting document.
14
15=cut
diff --git a/src/lib/libcrypto/util/point.sh b/src/lib/libcrypto/util/point.sh
new file mode 100644
index 0000000000..ce7dcc56df
--- /dev/null
+++ b/src/lib/libcrypto/util/point.sh
@@ -0,0 +1,10 @@
1#!/bin/sh
2
3rm -f $2
4if test "$OSTYPE" = msdosdjgpp; then
5 cp $1 $2
6else
7 ln -s $1 $2
8fi
9echo "$2 => $1"
10
diff --git a/src/lib/libcrypto/util/selftest.pl b/src/lib/libcrypto/util/selftest.pl
new file mode 100644
index 0000000000..276b81183d
--- /dev/null
+++ b/src/lib/libcrypto/util/selftest.pl
@@ -0,0 +1,195 @@
1#!/usr/local/bin/perl -w
2#
3# Run the test suite and generate a report
4#
5
6if (! -f "Configure") {
7 print "Please run perl util/selftest.pl in the OpenSSL directory.\n";
8 exit 1;
9}
10
11my $report="testlog";
12my $os="??";
13my $version="??";
14my $platform0="??";
15my $platform="??";
16my $options="??";
17my $last="??";
18my $ok=0;
19my $cc="cc";
20my $cversion="??";
21my $sep="-----------------------------------------------------------------------------\n";
22my $not_our_fault="\nPlease ask your system administrator/vendor for more information.\n[Problems with your operating system setup should not be reported\nto the OpenSSL project.]\n";
23
24open(OUT,">$report") or die;
25
26print OUT "OpenSSL self-test report:\n\n";
27
28$uname=`uname -a`;
29$uname="??\n" if $uname eq "";
30
31$c=`sh config -t`;
32foreach $_ (split("\n",$c)) {
33 $os=$1 if (/Operating system: (.*)$/);
34 $platform0=$1 if (/Configuring for (.*)$/);
35}
36
37system "sh config" if (! -f "Makefile.ssl");
38
39if (open(IN,"<Makefile.ssl")) {
40 while (<IN>) {
41 $version=$1 if (/^VERSION=(.*)$/);
42 $platform=$1 if (/^PLATFORM=(.*)$/);
43 $options=$1 if (/^OPTIONS=(.*)$/);
44 $cc=$1 if (/^CC= *(.*)$/);
45 }
46 close(IN);
47} else {
48 print OUT "Error running config!\n";
49}
50
51$cversion=`$cc -v 2>&1`;
52$cversion=`$cc -V 2>&1` if $cversion =~ "usage";
53$cversion=`$cc -V |head -1` if $cversion =~ "Error";
54$cversion=`$cc --version` if $cversion eq "";
55$cversion =~ s/Reading specs.*\n//;
56$cversion =~ s/usage.*\n//;
57chomp $cversion;
58
59if (open(IN,"<CHANGES")) {
60 while(<IN>) {
61 if (/\*\) (.{0,55})/ && !/applies to/) {
62 $last=$1;
63 last;
64 }
65 }
66 close(IN);
67}
68
69print OUT "OpenSSL version: $version\n";
70print OUT "Last change: $last...\n";
71print OUT "Options: $options\n" if $options ne "";
72print OUT "OS (uname): $uname";
73print OUT "OS (config): $os\n";
74print OUT "Target (default): $platform0\n";
75print OUT "Target: $platform\n";
76print OUT "Compiler: $cversion\n";
77print OUT "\n";
78
79print "Checking compiler...\n";
80if (open(TEST,">cctest.c")) {
81 print TEST "#include <stdio.h>\n#include <errno.h>\nmain(){printf(\"Hello world\\n\");}\n";
82 close(TEST);
83 system("$cc -o cctest cctest.c");
84 if (`./cctest` !~ /Hello world/) {
85 print OUT "Compiler doesn't work.\n";
86 print OUT $not_our_fault;
87 goto err;
88 }
89 system("ar r cctest.a /dev/null");
90 if (not -f "cctest.a") {
91 print OUT "Check your archive tool (ar).\n";
92 print OUT $not_our_fault;
93 goto err;
94 }
95} else {
96 print OUT "Can't create cctest.c\n";
97}
98if (open(TEST,">cctest.c")) {
99 print TEST "#include <openssl/opensslv.h>\nmain(){printf(OPENSSL_VERSION_TEXT);}\n";
100 close(TEST);
101 system("$cc -o cctest -Iinclude cctest.c");
102 $cctest = `./cctest`;
103 if ($cctest !~ /OpenSSL $version/) {
104 if ($cctest =~ /OpenSSL/) {
105 print OUT "#include uses headers from different OpenSSL version!\n";
106 } else {
107 print OUT "Can't compile test program!\n";
108 }
109 print OUT $not_our_fault;
110 goto err;
111 }
112} else {
113 print OUT "Can't create cctest.c\n";
114}
115
116print "Running make...\n";
117if (system("make 2>&1 | tee make.log") > 255) {
118
119 print OUT "make failed!\n";
120 if (open(IN,"<make.log")) {
121 print OUT $sep;
122 while (<IN>) {
123 print OUT;
124 }
125 close(IN);
126 print OUT $sep;
127 } else {
128 print OUT "make.log not found!\n";
129 }
130 goto err;
131}
132
133$_=$options;
134s/no-asm//;
135s/no-shared//;
136s/no-krb5//;
137if (/no-/)
138{
139 print OUT "Test skipped.\n";
140 goto err;
141}
142
143print "Running make test...\n";
144if (system("make test 2>&1 | tee maketest.log") > 255)
145 {
146 print OUT "make test failed!\n";
147} else {
148 $ok=1;
149}
150
151if ($ok and open(IN,"<maketest.log")) {
152 while (<IN>) {
153 $ok=2 if /^platform: $platform/;
154 }
155 close(IN);
156}
157
158if ($ok != 2) {
159 print OUT "Failure!\n";
160 if (open(IN,"<make.log")) {
161 print OUT $sep;
162 while (<IN>) {
163 print OUT;
164 }
165 close(IN);
166 print OUT $sep;
167 } else {
168 print OUT "make.log not found!\n";
169 }
170 if (open(IN,"<maketest.log")) {
171 while (<IN>) {
172 print OUT;
173 }
174 close(IN);
175 print OUT $sep;
176 } else {
177 print OUT "maketest.log not found!\n";
178 }
179} else {
180 print OUT "Test passed.\n";
181}
182err:
183close(OUT);
184
185print "\n";
186open(IN,"<$report") or die;
187while (<IN>) {
188 if (/$sep/) {
189 print "[...]\n";
190 last;
191 }
192 print;
193}
194print "\nTest report in file $report\n";
195
diff --git a/src/lib/libcrypto/util/sp-diff.pl b/src/lib/libcrypto/util/sp-diff.pl
new file mode 100644
index 0000000000..9d6c60387f
--- /dev/null
+++ b/src/lib/libcrypto/util/sp-diff.pl
@@ -0,0 +1,80 @@
1#!/usr/local/bin/perl
2#
3# This file takes as input, the files that have been output from
4# ssleay speed.
5# It prints a table of the relative differences with %100 being 'no difference'
6#
7
8($#ARGV == 1) || die "$0 speedout1 speedout2\n";
9
10%one=&loadfile($ARGV[0]);
11%two=&loadfile($ARGV[1]);
12
13$line=0;
14foreach $a ("md2","md4","md5","sha","sha1","rc4","des cfb","des cbc","des ede3",
15 "idea cfb","idea cbc","rc2 cfb","rc2 cbc","blowfish cbc","cast cbc")
16 {
17 if (defined($one{$a,8}) && defined($two{$a,8}))
18 {
19 print "type 8 byte% 64 byte% 256 byte% 1024 byte% 8192 byte%\n"
20 unless $line;
21 $line++;
22 printf "%-12s ",$a;
23 foreach $b (8,64,256,1024,8192)
24 {
25 $r=$two{$a,$b}/$one{$a,$b}*100;
26 printf "%12.2f",$r;
27 }
28 print "\n";
29 }
30 }
31
32foreach $a (
33 "rsa 512","rsa 1024","rsa 2048","rsa 4096",
34 "dsa 512","dsa 1024","dsa 2048",
35 )
36 {
37 if (defined($one{$a,1}) && defined($two{$a,1}))
38 {
39 $r1=($one{$a,1}/$two{$a,1})*100;
40 $r2=($one{$a,2}/$two{$a,2})*100;
41 printf "$a bits %% %6.2f %% %6.2f\n",$r1,$r2;
42 }
43 }
44
45sub loadfile
46 {
47 local($file)=@_;
48 local($_,%ret);
49
50 open(IN,"<$file") || die "unable to open '$file' for input\n";
51 $header=1;
52 while (<IN>)
53 {
54 $header=0 if /^[dr]sa/;
55 if (/^type/) { $header=0; next; }
56 next if $header;
57 chop;
58 @a=split;
59 if ($a[0] =~ /^[dr]sa$/)
60 {
61 ($n,$t1,$t2)=($_ =~ /^([dr]sa\s+\d+)\s+bits\s+([.\d]+)s\s+([.\d]+)/);
62 $ret{$n,1}=$t1;
63 $ret{$n,2}=$t2;
64 }
65 else
66 {
67 $n=join(' ',grep(/[^k]$/,@a));
68 @k=grep(s/k$//,@a);
69
70 $ret{$n, 8}=$k[0];
71 $ret{$n, 64}=$k[1];
72 $ret{$n, 256}=$k[2];
73 $ret{$n,1024}=$k[3];
74 $ret{$n,8192}=$k[4];
75 }
76 }
77 close(IN);
78 return(%ret);
79 }
80
diff --git a/src/lib/libcrypto/util/speed.sh b/src/lib/libcrypto/util/speed.sh
new file mode 100644
index 0000000000..f489706197
--- /dev/null
+++ b/src/lib/libcrypto/util/speed.sh
@@ -0,0 +1,39 @@
1#!/bin/sh
2
3#
4# This is a ugly script use, in conjuction with editing the 'b'
5# configuration in the $(TOP)/Configure script which will
6# output when finished a file called speed.log which is the
7# timings of SSLeay with various options turned on or off.
8#
9# from the $(TOP) directory
10# Edit Configure, modifying things to do with the b/bl-4c-2c etc
11# configurations.
12#
13
14make clean
15perl Configure b
16make
17apps/ssleay version -v -b -f >speed.1
18apps/ssleay speed >speed.1l
19
20perl Configure bl-4c-2c
21/bin/rm -f crypto/rc4/*.o crypto/bn/bn*.o crypto/md2/md2_dgst.o
22make
23apps/ssleay speed rc4 rsa md2 >speed.2l
24
25perl Configure bl-4c-ri
26/bin/rm -f crypto/rc4/rc4*.o
27make
28apps/ssleay speed rc4 >speed.3l
29
30perl Configure b2-is-ri-dp
31/bin/rm -f crypto/idea/i_*.o crypto/rc4/*.o crypto/des/ecb_enc.o crypto/bn/bn*.o
32apps/ssleay speed rsa rc4 idea des >speed.4l
33
34cat speed.1 >speed.log
35cat speed.1l >>speed.log
36perl util/sp-diff.pl speed.1l speed.2l >>speed.log
37perl util/sp-diff.pl speed.1l speed.3l >>speed.log
38perl util/sp-diff.pl speed.1l speed.4l >>speed.log
39
diff --git a/src/lib/libcrypto/util/src-dep.pl b/src/lib/libcrypto/util/src-dep.pl
new file mode 100644
index 0000000000..ad997e4746
--- /dev/null
+++ b/src/lib/libcrypto/util/src-dep.pl
@@ -0,0 +1,147 @@
1#!/usr/local/bin/perl
2
3# we make up an array of
4# $file{function_name}=filename;
5# $unres{filename}="func1 func2 ...."
6$debug=1;
7#$nm_func="parse_linux";
8$nm_func="parse_solaris";
9
10foreach (@ARGV)
11 {
12 &$nm_func($_);
13 }
14
15foreach $file (sort keys %unres)
16 {
17 @a=split(/\s+/,$unres{$file});
18 %ff=();
19 foreach $func (@a)
20 {
21 $f=$file{$func};
22 $ff{$f}=1 if $f ne "";
23 }
24
25 foreach $a (keys %ff)
26 { $we_need{$file}.="$a "; }
27 }
28
29foreach $file (sort keys %we_need)
30 {
31# print " $file $we_need{$file}\n";
32 foreach $bit (split(/\s+/,$we_need{$file}))
33 { push(@final,&walk($bit)); }
34
35 foreach (@final) { $fin{$_}=1; }
36 @final="";
37 foreach (sort keys %fin)
38 { push(@final,$_); }
39
40 print "$file: @final\n";
41 }
42
43sub walk
44 {
45 local($f)=@_;
46 local(@a,%seen,@ret,$r);
47
48 @ret="";
49 $f =~ s/^\s+//;
50 $f =~ s/\s+$//;
51 return "" if ($f =~ "^\s*$");
52
53 return(split(/\s/,$done{$f})) if defined ($done{$f});
54
55 return if $in{$f} > 0;
56 $in{$f}++;
57 push(@ret,$f);
58 foreach $r (split(/\s+/,$we_need{$f}))
59 {
60 push(@ret,&walk($r));
61 }
62 $in{$f}--;
63 $done{$f}=join(" ",@ret);
64 return(@ret);
65 }
66
67sub parse_linux
68 {
69 local($name)=@_;
70
71 open(IN,"nm $name|") || die "unable to run 'nn $name':$!\n";
72 while (<IN>)
73 {
74 chop;
75 next if /^\s*$/;
76 if (/^[^[](.*):$/)
77 {
78 $file=$1;
79 $file="$1.c" if /\[(.*).o\]/;
80 print STDERR "$file\n";
81 $we_need{$file}=" ";
82 next;
83 }
84
85 @a=split(/\s*\|\s*/);
86 next unless $#a == 7;
87 next unless $a[4] eq "GLOB";
88 if ($a[6] eq "UNDEF")
89 {
90 $unres{$file}.=$a[7]." ";
91 }
92 else
93 {
94 if ($file{$a[7]} ne "")
95 {
96 print STDERR "duplicate definition of $a[7],\n$file{$a[7]} and $file \n";
97 }
98 else
99 {
100 $file{$a[7]}=$file;
101 }
102 }
103 }
104 close(IN);
105 }
106
107sub parse_solaris
108 {
109 local($name)=@_;
110
111 open(IN,"nm $name|") || die "unable to run 'nn $name':$!\n";
112 while (<IN>)
113 {
114 chop;
115 next if /^\s*$/;
116 if (/^(\S+):$/)
117 {
118 $file=$1;
119 #$file="$1.c" if $file =~ /^(.*).o$/;
120 print STDERR "$file\n";
121 $we_need{$file}=" ";
122 next;
123 }
124 @a=split(/\s*\|\s*/);
125 next unless $#a == 7;
126 next unless $a[4] eq "GLOB";
127 if ($a[6] eq "UNDEF")
128 {
129 $unres{$file}.=$a[7]." ";
130 print STDERR "$file needs $a[7]\n" if $debug;
131 }
132 else
133 {
134 if ($file{$a[7]} ne "")
135 {
136 print STDERR "duplicate definition of $a[7],\n$file{$a[7]} and $file \n";
137 }
138 else
139 {
140 $file{$a[7]}=$file;
141 print STDERR "$file has $a[7]\n" if $debug;
142 }
143 }
144 }
145 close(IN);
146 }
147
diff --git a/src/lib/libcrypto/util/ssleay.num b/src/lib/libcrypto/util/ssleay.num
new file mode 100644
index 0000000000..fdea47205d
--- /dev/null
+++ b/src/lib/libcrypto/util/ssleay.num
@@ -0,0 +1,217 @@
1ERR_load_SSL_strings 1 EXIST::FUNCTION:
2SSL_CIPHER_description 2 EXIST::FUNCTION:
3SSL_CTX_add_client_CA 3 EXIST::FUNCTION:
4SSL_CTX_add_session 4 EXIST::FUNCTION:
5SSL_CTX_check_private_key 5 EXIST::FUNCTION:
6SSL_CTX_ctrl 6 EXIST::FUNCTION:
7SSL_CTX_flush_sessions 7 EXIST::FUNCTION:
8SSL_CTX_free 8 EXIST::FUNCTION:
9SSL_CTX_get_client_CA_list 9 EXIST::FUNCTION:
10SSL_CTX_get_verify_callback 10 EXIST::FUNCTION:
11SSL_CTX_get_verify_mode 11 EXIST::FUNCTION:
12SSL_CTX_new 12 EXIST::FUNCTION:
13SSL_CTX_remove_session 13 EXIST::FUNCTION:
14SSL_CTX_set_cipher_list 15 EXIST::FUNCTION:
15SSL_CTX_set_client_CA_list 16 EXIST::FUNCTION:
16SSL_CTX_set_default_passwd_cb 17 EXIST::FUNCTION:
17SSL_CTX_set_ssl_version 19 EXIST::FUNCTION:
18SSL_CTX_set_verify 21 EXIST::FUNCTION:
19SSL_CTX_use_PrivateKey 22 EXIST::FUNCTION:
20SSL_CTX_use_PrivateKey_ASN1 23 EXIST::FUNCTION:
21SSL_CTX_use_PrivateKey_file 24 EXIST::FUNCTION:STDIO
22SSL_CTX_use_RSAPrivateKey 25 EXIST::FUNCTION:RSA
23SSL_CTX_use_RSAPrivateKey_ASN1 26 EXIST::FUNCTION:RSA
24SSL_CTX_use_RSAPrivateKey_file 27 EXIST::FUNCTION:RSA,STDIO
25SSL_CTX_use_certificate 28 EXIST::FUNCTION:
26SSL_CTX_use_certificate_ASN1 29 EXIST::FUNCTION:
27SSL_CTX_use_certificate_file 30 EXIST::FUNCTION:STDIO
28SSL_SESSION_free 31 EXIST::FUNCTION:
29SSL_SESSION_new 32 EXIST::FUNCTION:
30SSL_SESSION_print 33 EXIST::FUNCTION:BIO
31SSL_SESSION_print_fp 34 EXIST::FUNCTION:FP_API
32SSL_accept 35 EXIST::FUNCTION:
33SSL_add_client_CA 36 EXIST::FUNCTION:
34SSL_alert_desc_string 37 EXIST::FUNCTION:
35SSL_alert_desc_string_long 38 EXIST::FUNCTION:
36SSL_alert_type_string 39 EXIST::FUNCTION:
37SSL_alert_type_string_long 40 EXIST::FUNCTION:
38SSL_check_private_key 41 EXIST::FUNCTION:
39SSL_clear 42 EXIST::FUNCTION:
40SSL_connect 43 EXIST::FUNCTION:
41SSL_copy_session_id 44 EXIST::FUNCTION:
42SSL_ctrl 45 EXIST::FUNCTION:
43SSL_dup 46 EXIST::FUNCTION:
44SSL_dup_CA_list 47 EXIST::FUNCTION:
45SSL_free 48 EXIST::FUNCTION:
46SSL_get_certificate 49 EXIST::FUNCTION:
47SSL_get_cipher_list 52 EXIST::FUNCTION:
48SSL_get_ciphers 55 EXIST::FUNCTION:
49SSL_get_client_CA_list 56 EXIST::FUNCTION:
50SSL_get_default_timeout 57 EXIST::FUNCTION:
51SSL_get_error 58 EXIST::FUNCTION:
52SSL_get_fd 59 EXIST::FUNCTION:
53SSL_get_peer_cert_chain 60 EXIST::FUNCTION:
54SSL_get_peer_certificate 61 EXIST::FUNCTION:
55SSL_get_rbio 63 EXIST::FUNCTION:BIO
56SSL_get_read_ahead 64 EXIST::FUNCTION:
57SSL_get_shared_ciphers 65 EXIST::FUNCTION:
58SSL_get_ssl_method 66 EXIST::FUNCTION:
59SSL_get_verify_callback 69 EXIST::FUNCTION:
60SSL_get_verify_mode 70 EXIST::FUNCTION:
61SSL_get_version 71 EXIST::FUNCTION:
62SSL_get_wbio 72 EXIST::FUNCTION:BIO
63SSL_load_client_CA_file 73 EXIST::FUNCTION:STDIO
64SSL_load_error_strings 74 EXIST::FUNCTION:
65SSL_new 75 EXIST::FUNCTION:
66SSL_peek 76 EXIST::FUNCTION:
67SSL_pending 77 EXIST::FUNCTION:
68SSL_read 78 EXIST::FUNCTION:
69SSL_renegotiate 79 EXIST::FUNCTION:
70SSL_rstate_string 80 EXIST::FUNCTION:
71SSL_rstate_string_long 81 EXIST::FUNCTION:
72SSL_set_accept_state 82 EXIST::FUNCTION:
73SSL_set_bio 83 EXIST::FUNCTION:BIO
74SSL_set_cipher_list 84 EXIST::FUNCTION:
75SSL_set_client_CA_list 85 EXIST::FUNCTION:
76SSL_set_connect_state 86 EXIST::FUNCTION:
77SSL_set_fd 87 EXIST::FUNCTION:SOCK
78SSL_set_read_ahead 88 EXIST::FUNCTION:
79SSL_set_rfd 89 EXIST::FUNCTION:SOCK
80SSL_set_session 90 EXIST::FUNCTION:
81SSL_set_ssl_method 91 EXIST::FUNCTION:
82SSL_set_verify 94 EXIST::FUNCTION:
83SSL_set_wfd 95 EXIST::FUNCTION:SOCK
84SSL_shutdown 96 EXIST::FUNCTION:
85SSL_state_string 97 EXIST::FUNCTION:
86SSL_state_string_long 98 EXIST::FUNCTION:
87SSL_use_PrivateKey 99 EXIST::FUNCTION:
88SSL_use_PrivateKey_ASN1 100 EXIST::FUNCTION:
89SSL_use_PrivateKey_file 101 EXIST::FUNCTION:STDIO
90SSL_use_RSAPrivateKey 102 EXIST::FUNCTION:RSA
91SSL_use_RSAPrivateKey_ASN1 103 EXIST::FUNCTION:RSA
92SSL_use_RSAPrivateKey_file 104 EXIST::FUNCTION:RSA,STDIO
93SSL_use_certificate 105 EXIST::FUNCTION:
94SSL_use_certificate_ASN1 106 EXIST::FUNCTION:
95SSL_use_certificate_file 107 EXIST::FUNCTION:STDIO
96SSL_write 108 EXIST::FUNCTION:
97SSLeay_add_ssl_algorithms 109 NOEXIST::FUNCTION:
98SSLv23_client_method 110 EXIST::FUNCTION:RSA
99SSLv23_method 111 EXIST::FUNCTION:RSA
100SSLv23_server_method 112 EXIST::FUNCTION:RSA
101SSLv2_client_method 113 EXIST::FUNCTION:RSA
102SSLv2_method 114 EXIST::FUNCTION:RSA
103SSLv2_server_method 115 EXIST::FUNCTION:RSA
104SSLv3_client_method 116 EXIST::FUNCTION:
105SSLv3_method 117 EXIST::FUNCTION:
106SSLv3_server_method 118 EXIST::FUNCTION:
107d2i_SSL_SESSION 119 EXIST::FUNCTION:
108i2d_SSL_SESSION 120 EXIST::FUNCTION:
109BIO_f_ssl 121 EXIST::FUNCTION:BIO
110BIO_new_ssl 122 EXIST::FUNCTION:BIO
111BIO_proxy_ssl_copy_session_id 123 NOEXIST::FUNCTION:
112BIO_ssl_copy_session_id 124 EXIST::FUNCTION:BIO
113SSL_do_handshake 125 EXIST::FUNCTION:
114SSL_get_privatekey 126 EXIST::FUNCTION:
115SSL_get_current_cipher 127 EXIST::FUNCTION:
116SSL_CIPHER_get_bits 128 EXIST::FUNCTION:
117SSL_CIPHER_get_version 129 EXIST::FUNCTION:
118SSL_CIPHER_get_name 130 EXIST::FUNCTION:
119BIO_ssl_shutdown 131 EXIST::FUNCTION:BIO
120SSL_SESSION_cmp 132 EXIST::FUNCTION:
121SSL_SESSION_hash 133 EXIST::FUNCTION:
122SSL_SESSION_get_time 134 EXIST::FUNCTION:
123SSL_SESSION_set_time 135 EXIST::FUNCTION:
124SSL_SESSION_get_timeout 136 EXIST::FUNCTION:
125SSL_SESSION_set_timeout 137 EXIST::FUNCTION:
126SSL_CTX_get_ex_data 138 EXIST::FUNCTION:
127SSL_CTX_get_quiet_shutdown 140 EXIST::FUNCTION:
128SSL_CTX_load_verify_locations 141 EXIST::FUNCTION:
129SSL_CTX_set_default_verify_paths 142 EXIST:!VMS:FUNCTION:
130SSL_CTX_set_def_verify_paths 142 EXIST:VMS:FUNCTION:
131SSL_CTX_set_ex_data 143 EXIST::FUNCTION:
132SSL_CTX_set_quiet_shutdown 145 EXIST::FUNCTION:
133SSL_SESSION_get_ex_data 146 EXIST::FUNCTION:
134SSL_SESSION_set_ex_data 148 EXIST::FUNCTION:
135SSL_get_SSL_CTX 150 EXIST::FUNCTION:
136SSL_get_ex_data 151 EXIST::FUNCTION:
137SSL_get_quiet_shutdown 153 EXIST::FUNCTION:
138SSL_get_session 154 EXIST::FUNCTION:
139SSL_get_shutdown 155 EXIST::FUNCTION:
140SSL_get_verify_result 157 EXIST::FUNCTION:
141SSL_set_ex_data 158 EXIST::FUNCTION:
142SSL_set_info_callback 160 EXIST::FUNCTION:
143SSL_set_quiet_shutdown 161 EXIST::FUNCTION:
144SSL_set_shutdown 162 EXIST::FUNCTION:
145SSL_set_verify_result 163 EXIST::FUNCTION:
146SSL_version 164 EXIST::FUNCTION:
147SSL_get_info_callback 165 EXIST::FUNCTION:
148SSL_state 166 EXIST::FUNCTION:
149SSL_CTX_get_ex_new_index 167 EXIST::FUNCTION:
150SSL_SESSION_get_ex_new_index 168 EXIST::FUNCTION:
151SSL_get_ex_new_index 169 EXIST::FUNCTION:
152TLSv1_method 170 EXIST::FUNCTION:
153TLSv1_server_method 171 EXIST::FUNCTION:
154TLSv1_client_method 172 EXIST::FUNCTION:
155BIO_new_buffer_ssl_connect 173 EXIST::FUNCTION:BIO
156BIO_new_ssl_connect 174 EXIST::FUNCTION:BIO
157SSL_get_ex_data_X509_STORE_CTX_idx 175 EXIST:!VMS:FUNCTION:
158SSL_get_ex_d_X509_STORE_CTX_idx 175 EXIST:VMS:FUNCTION:
159SSL_CTX_set_tmp_dh_callback 176 EXIST::FUNCTION:DH
160SSL_CTX_set_tmp_rsa_callback 177 EXIST::FUNCTION:RSA
161SSL_CTX_set_timeout 178 EXIST::FUNCTION:
162SSL_CTX_get_timeout 179 EXIST::FUNCTION:
163SSL_CTX_get_cert_store 180 EXIST::FUNCTION:
164SSL_CTX_set_cert_store 181 EXIST::FUNCTION:
165SSL_want 182 EXIST::FUNCTION:
166SSL_library_init 183 EXIST::FUNCTION:
167SSL_COMP_add_compression_method 184 EXIST::FUNCTION:COMP
168SSL_add_file_cert_subjects_to_stack 185 EXIST:!VMS:FUNCTION:STDIO
169SSL_add_file_cert_subjs_to_stk 185 EXIST:VMS:FUNCTION:STDIO
170SSL_set_tmp_rsa_callback 186 EXIST::FUNCTION:RSA
171SSL_set_tmp_dh_callback 187 EXIST::FUNCTION:DH
172SSL_add_dir_cert_subjects_to_stack 188 EXIST:!VMS,!WIN32:FUNCTION:STDIO
173SSL_add_dir_cert_subjs_to_stk 188 NOEXIST::FUNCTION:
174SSL_set_session_id_context 189 EXIST::FUNCTION:
175SSL_CTX_use_certificate_chain_file 222 EXIST:!VMS:FUNCTION:STDIO
176SSL_CTX_use_cert_chain_file 222 EXIST:VMS:FUNCTION:STDIO
177SSL_CTX_set_verify_depth 225 EXIST::FUNCTION:
178SSL_set_verify_depth 226 EXIST::FUNCTION:
179SSL_CTX_get_verify_depth 228 EXIST::FUNCTION:
180SSL_get_verify_depth 229 EXIST::FUNCTION:
181SSL_CTX_set_session_id_context 231 EXIST::FUNCTION:
182SSL_CTX_set_cert_verify_callback 232 EXIST:!VMS:FUNCTION:
183SSL_CTX_set_cert_verify_cb 232 EXIST:VMS:FUNCTION:
184SSL_CTX_set_default_passwd_cb_userdata 235 EXIST:!VMS:FUNCTION:
185SSL_CTX_set_def_passwd_cb_ud 235 EXIST:VMS:FUNCTION:
186SSL_set_purpose 236 EXIST::FUNCTION:
187SSL_CTX_set_trust 237 EXIST::FUNCTION:
188SSL_CTX_set_purpose 238 EXIST::FUNCTION:
189SSL_set_trust 239 EXIST::FUNCTION:
190SSL_get_finished 240 EXIST::FUNCTION:
191SSL_get_peer_finished 241 EXIST::FUNCTION:
192SSL_get1_session 242 EXIST::FUNCTION:
193SSL_CTX_callback_ctrl 243 EXIST::FUNCTION:
194SSL_callback_ctrl 244 EXIST::FUNCTION:
195SSL_CTX_sessions 245 EXIST::FUNCTION:
196SSL_get_rfd 246 EXIST::FUNCTION:
197SSL_get_wfd 247 EXIST::FUNCTION:
198kssl_cget_tkt 248 EXIST::FUNCTION:KRB5
199SSL_has_matching_session_id 249 EXIST::FUNCTION:
200kssl_err_set 250 EXIST::FUNCTION:KRB5
201kssl_ctx_show 251 EXIST::FUNCTION:KRB5
202kssl_validate_times 252 EXIST::FUNCTION:KRB5
203kssl_check_authent 253 EXIST::FUNCTION:KRB5
204kssl_ctx_new 254 EXIST::FUNCTION:KRB5
205kssl_build_principal_2 255 EXIST::FUNCTION:KRB5
206kssl_skip_confound 256 EXIST::FUNCTION:KRB5
207kssl_sget_tkt 257 EXIST::FUNCTION:KRB5
208SSL_set_generate_session_id 258 EXIST::FUNCTION:
209kssl_ctx_setkey 259 EXIST::FUNCTION:KRB5
210kssl_ctx_setprinc 260 EXIST::FUNCTION:KRB5
211kssl_ctx_free 261 EXIST::FUNCTION:KRB5
212kssl_krb5_free_data_contents 262 EXIST::FUNCTION:KRB5
213kssl_ctx_setstring 263 EXIST::FUNCTION:KRB5
214SSL_CTX_set_generate_session_id 264 EXIST::FUNCTION:
215SSL_renegotiate_pending 265 EXIST::FUNCTION:
216SSL_CTX_set_msg_callback 266 EXIST::FUNCTION:
217SSL_set_msg_callback 267 EXIST::FUNCTION:
diff --git a/src/lib/libcrypto/util/tab_num.pl b/src/lib/libcrypto/util/tab_num.pl
new file mode 100644
index 0000000000..a81ed0edc2
--- /dev/null
+++ b/src/lib/libcrypto/util/tab_num.pl
@@ -0,0 +1,17 @@
1#!/usr/local/bin/perl
2
3$num=1;
4$width=40;
5
6while (<>)
7 {
8 chop;
9
10 $i=length($_);
11
12 $n=$width-$i;
13 $i=int(($n+7)/8);
14 print $_.("\t" x $i).$num."\n";
15 $num++;
16 }
17
diff --git a/src/lib/libcrypto/util/x86asm.sh b/src/lib/libcrypto/util/x86asm.sh
new file mode 100644
index 0000000000..d2090a9849
--- /dev/null
+++ b/src/lib/libcrypto/util/x86asm.sh
@@ -0,0 +1,42 @@
1#!/bin/sh
2
3echo Generating x86 assember
4echo Bignum
5(cd crypto/bn/asm; perl x86.pl cpp > bn86unix.cpp)
6(cd crypto/bn/asm; perl x86.pl win32 > bn-win32.asm)
7
8echo DES
9(cd crypto/des/asm; perl des-586.pl cpp > dx86unix.cpp)
10(cd crypto/des/asm; perl des-586.pl win32 > d-win32.asm)
11
12echo "crypt(3)"
13(cd crypto/des/asm; perl crypt586.pl cpp > yx86unix.cpp)
14(cd crypto/des/asm; perl crypt586.pl win32 > y-win32.asm)
15
16echo Blowfish
17(cd crypto/bf/asm; perl bf-586.pl cpp > bx86unix.cpp)
18(cd crypto/bf/asm; perl bf-586.pl win32 > b-win32.asm)
19
20echo CAST5
21(cd crypto/cast/asm; perl cast-586.pl cpp > cx86unix.cpp)
22(cd crypto/cast/asm; perl cast-586.pl win32 > c-win32.asm)
23
24echo RC4
25(cd crypto/rc4/asm; perl rc4-586.pl cpp > rx86unix.cpp)
26(cd crypto/rc4/asm; perl rc4-586.pl win32 > r4-win32.asm)
27
28echo MD5
29(cd crypto/md5/asm; perl md5-586.pl cpp > mx86unix.cpp)
30(cd crypto/md5/asm; perl md5-586.pl win32 > m5-win32.asm)
31
32echo SHA1
33(cd crypto/sha/asm; perl sha1-586.pl cpp > sx86unix.cpp)
34(cd crypto/sha/asm; perl sha1-586.pl win32 > s1-win32.asm)
35
36echo RIPEMD160
37(cd crypto/ripemd/asm; perl rmd-586.pl cpp > rm86unix.cpp)
38(cd crypto/ripemd/asm; perl rmd-586.pl win32 > rm-win32.asm)
39
40echo RC5/32
41(cd crypto/rc5/asm; perl rc5-586.pl cpp > r586unix.cpp)
42(cd crypto/rc5/asm; perl rc5-586.pl win32 > r5-win32.asm)
diff --git a/src/lib/libcrypto/x509/Makefile.ssl b/src/lib/libcrypto/x509/Makefile.ssl
new file mode 100644
index 0000000000..ee53294699
--- /dev/null
+++ b/src/lib/libcrypto/x509/Makefile.ssl
@@ -0,0 +1,594 @@
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 448bd7e69c..a5c306f1fd 100644
--- a/src/lib/libcrypto/x509/by_dir.c
+++ b/src/lib/libcrypto/x509/by_dir.c
@@ -302,8 +302,8 @@ static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name,
302 k=0; 302 k=0;
303 for (;;) 303 for (;;)
304 { 304 {
305 sprintf(b->data,"%s/%08lx.%s%d",ctx->dirs[i],h, 305 snprintf(b->data,b->max,"%s/%08lx.%s%d",ctx->dirs[i],h,
306 postfix,k); 306 postfix,k);
307 k++; 307 k++;
308 if (stat(b->data,&st) < 0) 308 if (stat(b->data,&st) < 0)
309 break; 309 break;
diff --git a/src/lib/libcrypto/x509/by_file.c b/src/lib/libcrypto/x509/by_file.c
index b4b04183d0..92e00d2d73 100644
--- a/src/lib/libcrypto/x509/by_file.c
+++ b/src/lib/libcrypto/x509/by_file.c
@@ -100,19 +100,18 @@ 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 ok = (X509_load_cert_crl_file(ctx,X509_get_default_cert_file(),
104 if (file) 104 X509_FILETYPE_PEM) != 0);
105 ok = (X509_load_cert_crl_file(ctx,file,
106 X509_FILETYPE_PEM) != 0);
107
108 else
109 ok = (X509_load_cert_crl_file(ctx,X509_get_default_cert_file(),
110 X509_FILETYPE_PEM) != 0);
111
112 if (!ok) 105 if (!ok)
113 { 106 {
114 X509err(X509_F_BY_FILE_CTRL,X509_R_LOADING_DEFAULTS); 107 X509err(X509_F_BY_FILE_CTRL,X509_R_LOADING_DEFAULTS);
115 } 108 }
109 else
110 {
111 file=(char *)Getenv(X509_get_default_cert_file_env());
112 ok = (X509_load_cert_crl_file(ctx,file,
113 X509_FILETYPE_PEM) != 0);
114 }
116 } 115 }
117 else 116 else
118 { 117 {
@@ -285,8 +284,7 @@ int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type)
285 if(itmp->x509) { 284 if(itmp->x509) {
286 X509_STORE_add_cert(ctx->store_ctx, itmp->x509); 285 X509_STORE_add_cert(ctx->store_ctx, itmp->x509);
287 count++; 286 count++;
288 } 287 } else if(itmp->crl) {
289 if(itmp->crl) {
290 X509_STORE_add_crl(ctx->store_ctx, itmp->crl); 288 X509_STORE_add_crl(ctx->store_ctx, itmp->crl);
291 count++; 289 count++;
292 } 290 }
diff --git a/src/lib/libcrypto/x509/x509.h b/src/lib/libcrypto/x509/x509.h
index eaad5685a8..7095440d36 100644
--- a/src/lib/libcrypto/x509/x509.h
+++ b/src/lib/libcrypto/x509/x509.h
@@ -87,6 +87,7 @@
87#ifndef OPENSSL_NO_SHA 87#ifndef OPENSSL_NO_SHA
88#include <openssl/sha.h> 88#include <openssl/sha.h>
89#endif 89#endif
90#include <openssl/evp.h>
90#include <openssl/e_os2.h> 91#include <openssl/e_os2.h>
91#include <openssl/ossl_typ.h> 92#include <openssl/ossl_typ.h>
92 93
@@ -486,12 +487,10 @@ typedef struct Netscape_certificate_sequence
486 STACK_OF(X509) *certs; 487 STACK_OF(X509) *certs;
487 } NETSCAPE_CERT_SEQUENCE; 488 } NETSCAPE_CERT_SEQUENCE;
488 489
489/* Unused (and iv length is wrong)
490typedef struct CBCParameter_st 490typedef struct CBCParameter_st
491 { 491 {
492 unsigned char iv[8]; 492 unsigned char iv[8];
493 } CBC_PARAM; 493 } CBC_PARAM;
494*/
495 494
496/* Password based encryption structure */ 495/* Password based encryption structure */
497 496
diff --git a/src/lib/libcrypto/x509/x509_cmp.c b/src/lib/libcrypto/x509/x509_cmp.c
index f460102f49..cd20b6d66f 100644
--- a/src/lib/libcrypto/x509/x509_cmp.c
+++ b/src/lib/libcrypto/x509/x509_cmp.c
@@ -57,7 +57,6 @@
57 */ 57 */
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <ctype.h>
61#include "cryptlib.h" 60#include "cryptlib.h"
62#include <openssl/asn1.h> 61#include <openssl/asn1.h>
63#include <openssl/objects.h> 62#include <openssl/objects.h>
@@ -82,14 +81,13 @@ unsigned long X509_issuer_and_serial_hash(X509 *a)
82 unsigned long ret=0; 81 unsigned long ret=0;
83 EVP_MD_CTX ctx; 82 EVP_MD_CTX ctx;
84 unsigned char md[16]; 83 unsigned char md[16];
85 char *f; 84 char str[256];
86 85
87 EVP_MD_CTX_init(&ctx); 86 EVP_MD_CTX_init(&ctx);
88 f=X509_NAME_oneline(a->cert_info->issuer,NULL,0); 87 X509_NAME_oneline(a->cert_info->issuer,str,256);
89 ret=strlen(f); 88 ret=strlen(str);
90 EVP_DigestInit_ex(&ctx, EVP_md5(), NULL); 89 EVP_DigestInit_ex(&ctx, EVP_md5(), NULL);
91 EVP_DigestUpdate(&ctx,(unsigned char *)f,ret); 90 EVP_DigestUpdate(&ctx,(unsigned char *)str,ret);
92 OPENSSL_free(f);
93 EVP_DigestUpdate(&ctx,(unsigned char *)a->cert_info->serialNumber->data, 91 EVP_DigestUpdate(&ctx,(unsigned char *)a->cert_info->serialNumber->data,
94 (unsigned long)a->cert_info->serialNumber->length); 92 (unsigned long)a->cert_info->serialNumber->length);
95 EVP_DigestFinal_ex(&ctx,&(md[0]),NULL); 93 EVP_DigestFinal_ex(&ctx,&(md[0]),NULL);
@@ -161,99 +159,6 @@ int X509_cmp(const X509 *a, const X509 *b)
161} 159}
162#endif 160#endif
163 161
164
165/* Case insensitive string comparision */
166static int nocase_cmp(const ASN1_STRING *a, const ASN1_STRING *b)
167{
168 int i;
169
170 if (a->length != b->length)
171 return (a->length - b->length);
172
173 for (i=0; i<a->length; i++)
174 {
175 int ca, cb;
176
177 ca = tolower(a->data[i]);
178 cb = tolower(b->data[i]);
179
180 if (ca != cb)
181 return(ca-cb);
182 }
183 return 0;
184}
185
186/* Case insensitive string comparision with space normalization
187 * Space normalization - ignore leading, trailing spaces,
188 * multiple spaces between characters are replaced by single space
189 */
190static int nocase_spacenorm_cmp(const ASN1_STRING *a, const ASN1_STRING *b)
191{
192 unsigned char *pa = NULL, *pb = NULL;
193 int la, lb;
194
195 la = a->length;
196 lb = b->length;
197 pa = a->data;
198 pb = b->data;
199
200 /* skip leading spaces */
201 while (la > 0 && isspace(*pa))
202 {
203 la--;
204 pa++;
205 }
206 while (lb > 0 && isspace(*pb))
207 {
208 lb--;
209 pb++;
210 }
211
212 /* skip trailing spaces */
213 while (la > 0 && isspace(pa[la-1]))
214 la--;
215 while (lb > 0 && isspace(pb[lb-1]))
216 lb--;
217
218 /* compare strings with space normalization */
219 while (la > 0 && lb > 0)
220 {
221 int ca, cb;
222
223 /* compare character */
224 ca = tolower(*pa);
225 cb = tolower(*pb);
226 if (ca != cb)
227 return (ca - cb);
228
229 pa++; pb++;
230 la--; lb--;
231
232 if (la <= 0 || lb <= 0)
233 break;
234
235 /* is white space next character ? */
236 if (isspace(*pa) && isspace(*pb))
237 {
238 /* skip remaining white spaces */
239 while (la > 0 && isspace(*pa))
240 {
241 la--;
242 pa++;
243 }
244 while (lb > 0 && isspace(*pb))
245 {
246 lb--;
247 pb++;
248 }
249 }
250 }
251 if (la > 0 || lb > 0)
252 return la - lb;
253
254 return 0;
255}
256
257int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b) 162int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b)
258 { 163 {
259 int i,j; 164 int i,j;
@@ -267,20 +172,10 @@ int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b)
267 { 172 {
268 na=sk_X509_NAME_ENTRY_value(a->entries,i); 173 na=sk_X509_NAME_ENTRY_value(a->entries,i);
269 nb=sk_X509_NAME_ENTRY_value(b->entries,i); 174 nb=sk_X509_NAME_ENTRY_value(b->entries,i);
270 j=na->value->type-nb->value->type; 175 j=na->value->length-nb->value->length;
271 if (j) return(j); 176 if (j) return(j);
272 if (na->value->type == V_ASN1_PRINTABLESTRING) 177 j=memcmp(na->value->data,nb->value->data,
273 j=nocase_spacenorm_cmp(na->value, nb->value); 178 na->value->length);
274 else if (na->value->type == V_ASN1_IA5STRING
275 && OBJ_obj2nid(na->object) == NID_pkcs9_emailAddress)
276 j=nocase_cmp(na->value, nb->value);
277 else
278 {
279 j=na->value->length-nb->value->length;
280 if (j) return(j);
281 j=memcmp(na->value->data,nb->value->data,
282 na->value->length);
283 }
284 if (j) return(j); 179 if (j) return(j);
285 j=na->set-nb->set; 180 j=na->set-nb->set;
286 if (j) return(j); 181 if (j) return(j);
diff --git a/src/lib/libcrypto/x509/x509_txt.c b/src/lib/libcrypto/x509/x509_txt.c
index 4f83db8ba2..9d09ae17e8 100644
--- a/src/lib/libcrypto/x509/x509_txt.c
+++ b/src/lib/libcrypto/x509/x509_txt.c
@@ -148,7 +148,7 @@ const char *X509_verify_cert_error_string(long n)
148 return("unhandled critical extension"); 148 return("unhandled critical extension");
149 149
150 default: 150 default:
151 sprintf(buf,"error number %ld",n); 151 snprintf(buf,sizeof buf,"error number %ld",n);
152 return(buf); 152 return(buf);
153 } 153 }
154 } 154 }
diff --git a/src/lib/libcrypto/x509/x509_v3.c b/src/lib/libcrypto/x509/x509_v3.c
index 67b1796a92..b5f7daa2e5 100644
--- a/src/lib/libcrypto/x509/x509_v3.c
+++ b/src/lib/libcrypto/x509/x509_v3.c
@@ -116,7 +116,7 @@ int X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *sk, int crit,
116 { 116 {
117 ex=sk_X509_EXTENSION_value(sk,lastpos); 117 ex=sk_X509_EXTENSION_value(sk,lastpos);
118 if ( ((ex->critical > 0) && crit) || 118 if ( ((ex->critical > 0) && crit) ||
119 ((ex->critical <= 0) && !crit)) 119 (!(ex->critical <= 0) && !crit))
120 return(lastpos); 120 return(lastpos);
121 } 121 }
122 return(-1); 122 return(-1);
diff --git a/src/lib/libcrypto/x509/x509_vfy.c b/src/lib/libcrypto/x509/x509_vfy.c
index 552d1e7251..db12f7bd35 100644
--- a/src/lib/libcrypto/x509/x509_vfy.c
+++ b/src/lib/libcrypto/x509/x509_vfy.c
@@ -756,7 +756,7 @@ int X509_cmp_time(ASN1_TIME *ctm, time_t *cmp_time)
756 { 756 {
757 char *str; 757 char *str;
758 ASN1_TIME atm; 758 ASN1_TIME atm;
759 long offset; 759 time_t offset;
760 char buff1[24],buff2[24],*p; 760 char buff1[24],buff2[24],*p;
761 int i,j; 761 int i,j;
762 762
diff --git a/src/lib/libcrypto/x509v3/Makefile.ssl b/src/lib/libcrypto/x509v3/Makefile.ssl
new file mode 100644
index 0000000000..3534e8b236
--- /dev/null
+++ b/src/lib/libcrypto/x509v3/Makefile.ssl
@@ -0,0 +1,603 @@
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 5442480595..2fb97d8925 100644
--- a/src/lib/libcrypto/x509v3/ext_dat.h
+++ b/src/lib/libcrypto/x509v3/ext_dat.h
@@ -90,23 +90,17 @@ static X509V3_EXT_METHOD *standard_exts[] = {
90&v3_crld, 90&v3_crld,
91&v3_ext_ku, 91&v3_ext_ku,
92&v3_crl_reason, 92&v3_crl_reason,
93#ifndef OPENSSL_NO_OCSP
94&v3_crl_invdate, 93&v3_crl_invdate,
95#endif
96&v3_sxnet, 94&v3_sxnet,
97&v3_info, 95&v3_info,
98#ifndef OPENSSL_NO_OCSP
99&v3_ocsp_nonce, 96&v3_ocsp_nonce,
100&v3_ocsp_crlid, 97&v3_ocsp_crlid,
101&v3_ocsp_accresp, 98&v3_ocsp_accresp,
102&v3_ocsp_nocheck, 99&v3_ocsp_nocheck,
103&v3_ocsp_acutoff, 100&v3_ocsp_acutoff,
104&v3_ocsp_serviceloc, 101&v3_ocsp_serviceloc,
105#endif
106&v3_sinfo, 102&v3_sinfo,
107#ifndef OPENSSL_NO_OCSP
108&v3_crl_hold 103&v3_crl_hold
109#endif
110}; 104};
111 105
112/* Number of standard extensions */ 106/* Number of standard extensions */
diff --git a/src/lib/libcrypto/x509v3/tabtest.c b/src/lib/libcrypto/x509v3/tabtest.c
new file mode 100644
index 0000000000..dad0d38dd5
--- /dev/null
+++ b/src/lib/libcrypto/x509v3/tabtest.c
@@ -0,0 +1,88 @@
1/* tabtest.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
3 * project 1999.
4 */
5/* ====================================================================
6 * Copyright (c) 1999 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/* Simple program to check the ext_dat.h is correct and print out
60 * problems if it is not.
61 */
62
63#include <stdio.h>
64
65#include <openssl/x509v3.h>
66
67#include "ext_dat.h"
68
69main()
70{
71 int i, prev = -1, bad = 0;
72 X509V3_EXT_METHOD **tmp;
73 i = sizeof(standard_exts) / sizeof(X509V3_EXT_METHOD *);
74 if(i != STANDARD_EXTENSION_COUNT)
75 fprintf(stderr, "Extension number invalid expecting %d\n", i);
76 tmp = standard_exts;
77 for(i = 0; i < STANDARD_EXTENSION_COUNT; i++, tmp++) {
78 if((*tmp)->ext_nid < prev) bad = 1;
79 prev = (*tmp)->ext_nid;
80
81 }
82 if(bad) {
83 tmp = standard_exts;
84 fprintf(stderr, "Extensions out of order!\n");
85 for(i = 0; i < STANDARD_EXTENSION_COUNT; i++, tmp++)
86 printf("%d : %s\n", (*tmp)->ext_nid, OBJ_nid2sn((*tmp)->ext_nid));
87 } else fprintf(stderr, "Order OK\n");
88}
diff --git a/src/lib/libcrypto/x509v3/v3_alt.c b/src/lib/libcrypto/x509v3/v3_alt.c
index 0e9e7dcb4f..0fae31a3a6 100644
--- a/src/lib/libcrypto/x509v3/v3_alt.c
+++ b/src/lib/libcrypto/x509v3/v3_alt.c
@@ -137,7 +137,8 @@ STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method,
137 X509V3_add_value("IP Address","<invalid>", &ret); 137 X509V3_add_value("IP Address","<invalid>", &ret);
138 break; 138 break;
139 } 139 }
140 sprintf(oline, "%d.%d.%d.%d", p[0], p[1], p[2], p[3]); 140 snprintf(oline, sizeof oline, "%d.%d.%d.%d", p[0], p[1], p[2],
141 p[3]);
141 X509V3_add_value("IP Address",oline, &ret); 142 X509V3_add_value("IP Address",oline, &ret);
142 break; 143 break;
143 144
diff --git a/src/lib/libcrypto/x509v3/v3_info.c b/src/lib/libcrypto/x509v3/v3_info.c
index e269df1373..92b9316b02 100644
--- a/src/lib/libcrypto/x509v3/v3_info.c
+++ b/src/lib/libcrypto/x509v3/v3_info.c
@@ -105,7 +105,7 @@ static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *method
105 STACK_OF(CONF_VALUE) *ret) 105 STACK_OF(CONF_VALUE) *ret)
106{ 106{
107 ACCESS_DESCRIPTION *desc; 107 ACCESS_DESCRIPTION *desc;
108 int i; 108 int i,nlen;
109 char objtmp[80], *ntmp; 109 char objtmp[80], *ntmp;
110 CONF_VALUE *vtmp; 110 CONF_VALUE *vtmp;
111 for(i = 0; i < sk_ACCESS_DESCRIPTION_num(ainfo); i++) { 111 for(i = 0; i < sk_ACCESS_DESCRIPTION_num(ainfo); i++) {
@@ -113,16 +113,17 @@ static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *method
113 ret = i2v_GENERAL_NAME(method, desc->location, ret); 113 ret = i2v_GENERAL_NAME(method, desc->location, ret);
114 if(!ret) break; 114 if(!ret) break;
115 vtmp = sk_CONF_VALUE_value(ret, i); 115 vtmp = sk_CONF_VALUE_value(ret, i);
116 i2t_ASN1_OBJECT(objtmp, sizeof objtmp, desc->method); 116 i2t_ASN1_OBJECT(objtmp, 80, desc->method);
117 ntmp = OPENSSL_malloc(strlen(objtmp) + strlen(vtmp->name) + 5); 117 nlen = strlen(objtmp) + strlen(vtmp->name) + 4;
118 ntmp = OPENSSL_malloc(nlen);
118 if(!ntmp) { 119 if(!ntmp) {
119 X509V3err(X509V3_F_I2V_AUTHORITY_INFO_ACCESS, 120 X509V3err(X509V3_F_I2V_AUTHORITY_INFO_ACCESS,
120 ERR_R_MALLOC_FAILURE); 121 ERR_R_MALLOC_FAILURE);
121 return NULL; 122 return NULL;
122 } 123 }
123 strcpy(ntmp, objtmp); 124 strlcpy(ntmp, objtmp, nlen);
124 strcat(ntmp, " - "); 125 strlcat(ntmp, " - ", nlen);
125 strcat(ntmp, vtmp->name); 126 strlcat(ntmp, vtmp->name, nlen);
126 OPENSSL_free(vtmp->name); 127 OPENSSL_free(vtmp->name);
127 vtmp->name = ntmp; 128 vtmp->name = ntmp;
128 129
diff --git a/src/lib/libcrypto/x509v3/v3_ocsp.c b/src/lib/libcrypto/x509v3/v3_ocsp.c
index 21badc13f9..083112314e 100644
--- a/src/lib/libcrypto/x509v3/v3_ocsp.c
+++ b/src/lib/libcrypto/x509v3/v3_ocsp.c
@@ -56,8 +56,6 @@
56 * 56 *
57 */ 57 */
58 58
59#ifndef OPENSSL_NO_OCSP
60
61#include <stdio.h> 59#include <stdio.h>
62#include "cryptlib.h" 60#include "cryptlib.h"
63#include <openssl/conf.h> 61#include <openssl/conf.h>
@@ -272,4 +270,3 @@ static int i2r_ocsp_serviceloc(X509V3_EXT_METHOD *method, void *in, BIO *bp, int
272err: 270err:
273 return 0; 271 return 0;
274 } 272 }
275#endif
diff --git a/src/lib/libcrypto/x509v3/v3_prn.c b/src/lib/libcrypto/x509v3/v3_prn.c
index 754808b625..aeaf6170fe 100644
--- a/src/lib/libcrypto/x509v3/v3_prn.c
+++ b/src/lib/libcrypto/x509v3/v3_prn.c
@@ -178,7 +178,7 @@ int X509V3_extensions_print(BIO *bp, char *title, STACK_OF(X509_EXTENSION) *exts
178 ASN1_OBJECT *obj; 178 ASN1_OBJECT *obj;
179 X509_EXTENSION *ex; 179 X509_EXTENSION *ex;
180 ex=sk_X509_EXTENSION_value(exts, i); 180 ex=sk_X509_EXTENSION_value(exts, i);
181 if (indent && BIO_printf(bp,"%*s",indent, "") <= 0) return 0; 181 if (BIO_printf(bp,"%*s",indent, "") <= 0) return 0;
182 obj=X509_EXTENSION_get_object(ex); 182 obj=X509_EXTENSION_get_object(ex);
183 i2a_ASN1_OBJECT(bp,obj); 183 i2a_ASN1_OBJECT(bp,obj);
184 j=X509_EXTENSION_get_critical(ex); 184 j=X509_EXTENSION_get_critical(ex);
diff --git a/src/lib/libcrypto/x509v3/v3_purp.c b/src/lib/libcrypto/x509v3/v3_purp.c
index 4d145f71fd..b739e4fd83 100644
--- a/src/lib/libcrypto/x509v3/v3_purp.c
+++ b/src/lib/libcrypto/x509v3/v3_purp.c
@@ -378,10 +378,6 @@ static void x509v3_cache_extensions(X509 *x)
378 case NID_time_stamp: 378 case NID_time_stamp:
379 x->ex_xkusage |= XKU_TIMESTAMP; 379 x->ex_xkusage |= XKU_TIMESTAMP;
380 break; 380 break;
381
382 case NID_dvcs:
383 x->ex_xkusage |= XKU_DVCS;
384 break;
385 } 381 }
386 } 382 }
387 sk_ASN1_OBJECT_pop_free(extusage, ASN1_OBJECT_free); 383 sk_ASN1_OBJECT_pop_free(extusage, ASN1_OBJECT_free);
diff --git a/src/lib/libcrypto/x509v3/v3_utl.c b/src/lib/libcrypto/x509v3/v3_utl.c
index 34ac2998de..283e943e46 100644
--- a/src/lib/libcrypto/x509v3/v3_utl.c
+++ b/src/lib/libcrypto/x509v3/v3_utl.c
@@ -491,7 +491,7 @@ static STACK *get_email(X509_NAME *name, GENERAL_NAMES *gens)
491 i = -1; 491 i = -1;
492 /* First supplied X509_NAME */ 492 /* First supplied X509_NAME */
493 while((i = X509_NAME_get_index_by_NID(name, 493 while((i = X509_NAME_get_index_by_NID(name,
494 NID_pkcs9_emailAddress, i)) >= 0) { 494 NID_pkcs9_emailAddress, i)) > 0) {
495 ne = X509_NAME_get_entry(name, i); 495 ne = X509_NAME_get_entry(name, i);
496 email = X509_NAME_ENTRY_get_data(ne); 496 email = X509_NAME_ENTRY_get_data(ne);
497 if(!append_ia5(&ret, email)) return NULL; 497 if(!append_ia5(&ret, email)) return NULL;
diff --git a/src/lib/libcrypto/x509v3/v3conf.c b/src/lib/libcrypto/x509v3/v3conf.c
new file mode 100644
index 0000000000..67ee14f334
--- /dev/null
+++ b/src/lib/libcrypto/x509v3/v3conf.c
@@ -0,0 +1,127 @@
1/* v3conf.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
3 * project 1999.
4 */
5/* ====================================================================
6 * Copyright (c) 1999 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
60#include <stdio.h>
61#include "cryptlib.h"
62#include <openssl/asn1.h>
63#include <openssl/conf.h>
64#include <openssl/x509.h>
65#include <openssl/x509v3.h>
66
67/* Test application to add extensions from a config file */
68
69int main(int argc, char **argv)
70{
71 LHASH *conf;
72 X509 *cert;
73 FILE *inf;
74 char *conf_file;
75 int i;
76 int count;
77 X509_EXTENSION *ext;
78 X509V3_add_standard_extensions();
79 ERR_load_crypto_strings();
80 if(!argv[1]) {
81 fprintf(stderr, "Usage: v3conf cert.pem [file.cnf]\n");
82 exit(1);
83 }
84 conf_file = argv[2];
85 if(!conf_file) conf_file = "test.cnf";
86 conf = CONF_load(NULL, "test.cnf", NULL);
87 if(!conf) {
88 fprintf(stderr, "Error opening Config file %s\n", conf_file);
89 ERR_print_errors_fp(stderr);
90 exit(1);
91 }
92
93 inf = fopen(argv[1], "r");
94 if(!inf) {
95 fprintf(stderr, "Can't open certificate file %s\n", argv[1]);
96 exit(1);
97 }
98 cert = PEM_read_X509(inf, NULL, NULL);
99 if(!cert) {
100 fprintf(stderr, "Error reading certificate file %s\n", argv[1]);
101 exit(1);
102 }
103 fclose(inf);
104
105 sk_pop_free(cert->cert_info->extensions, X509_EXTENSION_free);
106 cert->cert_info->extensions = NULL;
107
108 if(!X509V3_EXT_add_conf(conf, NULL, "test_section", cert)) {
109 fprintf(stderr, "Error adding extensions\n");
110 ERR_print_errors_fp(stderr);
111 exit(1);
112 }
113
114 count = X509_get_ext_count(cert);
115 printf("%d extensions\n", count);
116 for(i = 0; i < count; i++) {
117 ext = X509_get_ext(cert, i);
118 printf("%s", OBJ_nid2ln(OBJ_obj2nid(ext->object)));
119 if(ext->critical) printf(",critical:\n");
120 else printf(":\n");
121 X509V3_EXT_print_fp(stdout, ext, 0);
122 printf("\n");
123
124 }
125 return 0;
126}
127
diff --git a/src/lib/libcrypto/x509v3/v3prin.c b/src/lib/libcrypto/x509v3/v3prin.c
new file mode 100644
index 0000000000..b529814319
--- /dev/null
+++ b/src/lib/libcrypto/x509v3/v3prin.c
@@ -0,0 +1,99 @@
1/* v3prin.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
3 * project 1999.
4 */
5/* ====================================================================
6 * Copyright (c) 1999 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
60
61#include <stdio.h>
62#include <openssl/asn1.h>
63#include <openssl/conf.h>
64#include <openssl/x509.h>
65#include <openssl/x509v3.h>
66
67int main(int argc, char **argv)
68{
69 X509 *cert;
70 FILE *inf;
71 int i, count;
72 X509_EXTENSION *ext;
73 X509V3_add_standard_extensions();
74 ERR_load_crypto_strings();
75 if(!argv[1]) {
76 fprintf(stderr, "Usage v3prin cert.pem\n");
77 exit(1);
78 }
79 if(!(inf = fopen(argv[1], "r"))) {
80 fprintf(stderr, "Can't open %s\n", argv[1]);
81 exit(1);
82 }
83 if(!(cert = PEM_read_X509(inf, NULL, NULL))) {
84 fprintf(stderr, "Can't read certificate %s\n", argv[1]);
85 ERR_print_errors_fp(stderr);
86 exit(1);
87 }
88 fclose(inf);
89 count = X509_get_ext_count(cert);
90 printf("%d extensions\n", count);
91 for(i = 0; i < count; i++) {
92 ext = X509_get_ext(cert, i);
93 printf("%s\n", OBJ_nid2ln(OBJ_obj2nid(ext->object)));
94 if(!X509V3_EXT_print_fp(stdout, ext, 0, 0)) ERR_print_errors_fp(stderr);
95 printf("\n");
96
97 }
98 return 0;
99}
diff --git a/src/lib/libcrypto/x509v3/x509v3.h b/src/lib/libcrypto/x509v3/x509v3.h
index fb07a19016..daecc55271 100644
--- a/src/lib/libcrypto/x509v3/x509v3.h
+++ b/src/lib/libcrypto/x509v3/x509v3.h
@@ -352,7 +352,6 @@ DECLARE_ASN1_SET_OF(POLICYINFO)
352#define XKU_SGC 0x10 352#define XKU_SGC 0x10
353#define XKU_OCSP_SIGN 0x20 353#define XKU_OCSP_SIGN 0x20
354#define XKU_TIMESTAMP 0x40 354#define XKU_TIMESTAMP 0x40
355#define XKU_DVCS 0x80
356 355
357#define X509_PURPOSE_DYNAMIC 0x1 356#define X509_PURPOSE_DYNAMIC 0x1
358#define X509_PURPOSE_DYNAMIC_NAME 0x2 357#define X509_PURPOSE_DYNAMIC_NAME 0x2