summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto')
-rw-r--r--src/lib/libcrypto/Makefile.ssl139
-rw-r--r--src/lib/libcrypto/aes/Makefile.ssl103
-rw-r--r--src/lib/libcrypto/aes/README3
-rw-r--r--src/lib/libcrypto/aes/aes.h109
-rw-r--r--src/lib/libcrypto/aes/aes_cbc.c89
-rw-r--r--src/lib/libcrypto/aes/aes_cfb.c151
-rw-r--r--src/lib/libcrypto/aes/aes_core.c1251
-rw-r--r--src/lib/libcrypto/aes/aes_ctr.c117
-rw-r--r--src/lib/libcrypto/aes/aes_ecb.c67
-rw-r--r--src/lib/libcrypto/aes/aes_locl.h88
-rw-r--r--src/lib/libcrypto/aes/aes_misc.c64
-rw-r--r--src/lib/libcrypto/aes/aes_ofb.c136
-rw-r--r--src/lib/libcrypto/asn1/Makefile.ssl1752
-rw-r--r--src/lib/libcrypto/asn1/a_bitstr.c53
-rw-r--r--src/lib/libcrypto/asn1/a_bool.c4
-rw-r--r--src/lib/libcrypto/asn1/a_bytes.c15
-rw-r--r--src/lib/libcrypto/asn1/a_d2i_fp.c69
-rw-r--r--src/lib/libcrypto/asn1/a_digest.c24
-rw-r--r--src/lib/libcrypto/asn1/a_dup.c28
-rw-r--r--src/lib/libcrypto/asn1/a_enum.c58
-rw-r--r--src/lib/libcrypto/asn1/a_gentm.c35
-rw-r--r--src/lib/libcrypto/asn1/a_i2d_fp.c54
-rw-r--r--src/lib/libcrypto/asn1/a_int.c64
-rw-r--r--src/lib/libcrypto/asn1/a_object.c2
-rw-r--r--src/lib/libcrypto/asn1/a_octet.c24
-rw-r--r--src/lib/libcrypto/asn1/a_print.c70
-rw-r--r--src/lib/libcrypto/asn1/a_set.c3
-rw-r--r--src/lib/libcrypto/asn1/a_sign.c152
-rw-r--r--src/lib/libcrypto/asn1/a_strex.c32
-rw-r--r--src/lib/libcrypto/asn1/a_strnid.c8
-rw-r--r--src/lib/libcrypto/asn1/a_time.c79
-rw-r--r--src/lib/libcrypto/asn1/a_type.c275
-rw-r--r--src/lib/libcrypto/asn1/a_utctm.c70
-rw-r--r--src/lib/libcrypto/asn1/a_utf8.c27
-rw-r--r--src/lib/libcrypto/asn1/a_verify.c58
-rw-r--r--src/lib/libcrypto/asn1/asn1.h770
-rw-r--r--src/lib/libcrypto/asn1/asn1_err.c206
-rw-r--r--src/lib/libcrypto/asn1/asn1_lib.c3
-rw-r--r--src/lib/libcrypto/asn1/asn1_mac.h35
-rw-r--r--src/lib/libcrypto/asn1/asn1t.h846
-rw-r--r--src/lib/libcrypto/asn1/asn_moid.c95
-rw-r--r--src/lib/libcrypto/asn1/asn_pack.c48
-rw-r--r--src/lib/libcrypto/asn1/d2i_pr.c16
-rw-r--r--src/lib/libcrypto/asn1/d2i_pu.c16
-rw-r--r--src/lib/libcrypto/asn1/f_int.c8
-rw-r--r--src/lib/libcrypto/asn1/i2d_pr.c10
-rw-r--r--src/lib/libcrypto/asn1/i2d_pu.c10
-rw-r--r--src/lib/libcrypto/asn1/n_pkey.c305
-rw-r--r--src/lib/libcrypto/asn1/nsseq.c64
-rw-r--r--src/lib/libcrypto/asn1/p5_pbe.c47
-rw-r--r--src/lib/libcrypto/asn1/p5_pbev2.c109
-rw-r--r--src/lib/libcrypto/asn1/p8_pkey.c79
-rw-r--r--src/lib/libcrypto/asn1/t_crl.c49
-rw-r--r--src/lib/libcrypto/asn1/t_pkey.c44
-rw-r--r--src/lib/libcrypto/asn1/t_req.c50
-rw-r--r--src/lib/libcrypto/asn1/t_spki.c6
-rw-r--r--src/lib/libcrypto/asn1/t_x509.c295
-rw-r--r--src/lib/libcrypto/asn1/t_x509a.c2
-rw-r--r--src/lib/libcrypto/asn1/tasn_dec.c958
-rw-r--r--src/lib/libcrypto/asn1/tasn_enc.c497
-rw-r--r--src/lib/libcrypto/asn1/tasn_fre.c226
-rw-r--r--src/lib/libcrypto/asn1/tasn_new.c348
-rw-r--r--src/lib/libcrypto/asn1/tasn_prn.c198
-rw-r--r--src/lib/libcrypto/asn1/tasn_typ.c133
-rw-r--r--src/lib/libcrypto/asn1/tasn_utl.c253
-rw-r--r--src/lib/libcrypto/asn1/x_algor.c165
-rw-r--r--src/lib/libcrypto/asn1/x_attrib.c111
-rw-r--r--src/lib/libcrypto/asn1/x_bignum.c137
-rw-r--r--src/lib/libcrypto/asn1/x_crl.c330
-rw-r--r--src/lib/libcrypto/asn1/x_exten.c190
-rw-r--r--src/lib/libcrypto/asn1/x_info.c2
-rw-r--r--src/lib/libcrypto/asn1/x_long.c169
-rw-r--r--src/lib/libcrypto/asn1/x_name.c343
-rw-r--r--src/lib/libcrypto/asn1/x_pubkey.c80
-rw-r--r--src/lib/libcrypto/asn1/x_req.c231
-rw-r--r--src/lib/libcrypto/asn1/x_sig.c53
-rw-r--r--src/lib/libcrypto/asn1/x_spki.c109
-rw-r--r--src/lib/libcrypto/asn1/x_val.c52
-rw-r--r--src/lib/libcrypto/asn1/x_x509.c155
-rw-r--r--src/lib/libcrypto/asn1/x_x509a.c75
-rw-r--r--src/lib/libcrypto/bf/Makefile.ssl27
-rw-r--r--src/lib/libcrypto/bf/bf_opts.c6
-rw-r--r--src/lib/libcrypto/bf/bf_skey.c2
-rw-r--r--src/lib/libcrypto/bf/bfspeed.c6
-rw-r--r--src/lib/libcrypto/bf/bftest.c2
-rw-r--r--src/lib/libcrypto/bf/blowfish.h8
-rw-r--r--src/lib/libcrypto/bio/Makefile.ssl174
-rw-r--r--src/lib/libcrypto/bio/b_print.c6
-rw-r--r--src/lib/libcrypto/bio/b_sock.c66
-rw-r--r--src/lib/libcrypto/bio/bf_buff.c1
-rw-r--r--src/lib/libcrypto/bio/bf_lbuf.c12
-rw-r--r--src/lib/libcrypto/bio/bf_nbio.c1
-rw-r--r--src/lib/libcrypto/bio/bf_null.c1
-rw-r--r--src/lib/libcrypto/bio/bio.h33
-rw-r--r--src/lib/libcrypto/bio/bio_cb.c2
-rw-r--r--src/lib/libcrypto/bio/bio_err.c5
-rw-r--r--src/lib/libcrypto/bio/bio_lib.c19
-rw-r--r--src/lib/libcrypto/bio/bss_acpt.c18
-rw-r--r--src/lib/libcrypto/bio/bss_bio.c10
-rw-r--r--src/lib/libcrypto/bio/bss_conn.c15
-rw-r--r--src/lib/libcrypto/bio/bss_fd.c226
-rw-r--r--src/lib/libcrypto/bio/bss_file.c18
-rw-r--r--src/lib/libcrypto/bio/bss_log.c19
-rw-r--r--src/lib/libcrypto/bio/bss_sock.c131
-rw-r--r--src/lib/libcrypto/bn/Makefile.ssl276
-rw-r--r--src/lib/libcrypto/bn/asm/README4
-rw-r--r--src/lib/libcrypto/bn/asm/bn-586.pl213
-rw-r--r--src/lib/libcrypto/bn/asm/ia64.S1498
-rw-r--r--src/lib/libcrypto/bn/asm/vms.mar697
-rw-r--r--src/lib/libcrypto/bn/bn.h177
-rw-r--r--src/lib/libcrypto/bn/bn_add.c12
-rw-r--r--src/lib/libcrypto/bn/bn_asm.c22
-rw-r--r--src/lib/libcrypto/bn/bn_ctx.c13
-rw-r--r--src/lib/libcrypto/bn/bn_div.c66
-rw-r--r--src/lib/libcrypto/bn/bn_err.c11
-rw-r--r--src/lib/libcrypto/bn/bn_exp.c149
-rw-r--r--src/lib/libcrypto/bn/bn_exp2.c27
-rw-r--r--src/lib/libcrypto/bn/bn_gcd.c338
-rw-r--r--src/lib/libcrypto/bn/bn_kron.c182
-rw-r--r--src/lib/libcrypto/bn/bn_lcl.h39
-rw-r--r--src/lib/libcrypto/bn/bn_lib.c336
-rw-r--r--src/lib/libcrypto/bn/bn_mod.c296
-rw-r--r--src/lib/libcrypto/bn/bn_mont.c63
-rw-r--r--src/lib/libcrypto/bn/bn_mpi.c2
-rw-r--r--src/lib/libcrypto/bn/bn_mul.c503
-rw-r--r--src/lib/libcrypto/bn/bn_prime.c29
-rw-r--r--src/lib/libcrypto/bn/bn_print.c6
-rw-r--r--src/lib/libcrypto/bn/bn_rand.c94
-rw-r--r--src/lib/libcrypto/bn/bn_recp.c48
-rw-r--r--src/lib/libcrypto/bn/bn_shift.c8
-rw-r--r--src/lib/libcrypto/bn/bn_sqr.c18
-rw-r--r--src/lib/libcrypto/bn/bn_sqrt.c387
-rw-r--r--src/lib/libcrypto/bn/bnspeed.c4
-rw-r--r--src/lib/libcrypto/bn/bntest.c261
-rw-r--r--src/lib/libcrypto/bn/expspeed.c176
-rw-r--r--src/lib/libcrypto/bn/exptest.c2
-rw-r--r--src/lib/libcrypto/bn/vms-helper.c2
-rw-r--r--src/lib/libcrypto/buffer/Makefile.ssl21
-rw-r--r--src/lib/libcrypto/buffer/buf_err.c4
-rw-r--r--src/lib/libcrypto/buffer/buffer.c3
-rw-r--r--src/lib/libcrypto/buffer/buffer.h4
-rw-r--r--src/lib/libcrypto/cast/Makefile.ssl26
-rw-r--r--src/lib/libcrypto/cast/cast.h2
-rw-r--r--src/lib/libcrypto/cast/cast_lcl.h12
-rw-r--r--src/lib/libcrypto/cast/cast_spd.c6
-rw-r--r--src/lib/libcrypto/cast/castopts.c6
-rw-r--r--src/lib/libcrypto/cast/casttest.c2
-rw-r--r--src/lib/libcrypto/comp/Makefile.ssl46
-rw-r--r--src/lib/libcrypto/comp/c_rle.c1
-rw-r--r--src/lib/libcrypto/comp/c_zlib.c141
-rw-r--r--src/lib/libcrypto/comp/comp.h4
-rw-r--r--src/lib/libcrypto/comp/comp_err.c4
-rw-r--r--src/lib/libcrypto/conf/Makefile.ssl90
-rw-r--r--src/lib/libcrypto/conf/README78
-rw-r--r--src/lib/libcrypto/conf/cnf_save.c7
-rw-r--r--src/lib/libcrypto/conf/conf.c730
-rw-r--r--src/lib/libcrypto/conf/conf.h111
-rw-r--r--src/lib/libcrypto/conf/conf_api.c49
-rw-r--r--src/lib/libcrypto/conf/conf_api.h12
-rw-r--r--src/lib/libcrypto/conf/conf_def.c62
-rw-r--r--src/lib/libcrypto/conf/conf_def.h143
-rw-r--r--src/lib/libcrypto/conf/conf_err.c18
-rw-r--r--src/lib/libcrypto/conf/conf_lib.c158
-rw-r--r--src/lib/libcrypto/conf/conf_mall.c76
-rw-r--r--src/lib/libcrypto/conf/conf_mod.c616
-rw-r--r--src/lib/libcrypto/conf/conf_sap.c107
-rw-r--r--src/lib/libcrypto/conf/keysets.pl62
-rw-r--r--src/lib/libcrypto/cpt_err.c9
-rw-r--r--src/lib/libcrypto/cryptlib.c19
-rw-r--r--src/lib/libcrypto/cryptlib.h4
-rw-r--r--src/lib/libcrypto/crypto-lib.com115
-rw-r--r--src/lib/libcrypto/crypto.h110
-rw-r--r--src/lib/libcrypto/cversion.c8
-rw-r--r--src/lib/libcrypto/des/Makefile.ssl267
-rw-r--r--src/lib/libcrypto/des/asm/crypt586.pl8
-rw-r--r--src/lib/libcrypto/des/asm/des-586.pl26
-rw-r--r--src/lib/libcrypto/des/asm/des686.pl20
-rw-r--r--src/lib/libcrypto/des/asm/desboth.pl8
-rw-r--r--src/lib/libcrypto/des/cbc3_enc.c52
-rw-r--r--src/lib/libcrypto/des/cbc_cksm.c8
-rw-r--r--src/lib/libcrypto/des/cfb64ede.c17
-rw-r--r--src/lib/libcrypto/des/cfb64enc.c10
-rw-r--r--src/lib/libcrypto/des/cfb_enc.c8
-rw-r--r--src/lib/libcrypto/des/des-lib.com4
-rw-r--r--src/lib/libcrypto/des/des.c112
-rw-r--r--src/lib/libcrypto/des/des.h290
-rw-r--r--src/lib/libcrypto/des/des_enc.c53
-rw-r--r--src/lib/libcrypto/des/des_locl.h79
-rw-r--r--src/lib/libcrypto/des/des_old.c271
-rw-r--r--src/lib/libcrypto/des/des_old.h437
-rw-r--r--src/lib/libcrypto/des/des_old2.c82
-rw-r--r--src/lib/libcrypto/des/des_opts.c212
-rw-r--r--src/lib/libcrypto/des/des_ver.h6
-rw-r--r--src/lib/libcrypto/des/destest.c103
-rw-r--r--src/lib/libcrypto/des/ecb3_enc.c9
-rw-r--r--src/lib/libcrypto/des/ecb_enc.c10
-rw-r--r--src/lib/libcrypto/des/ede_cbcm_enc.c24
-rw-r--r--src/lib/libcrypto/des/enc_read.c28
-rw-r--r--src/lib/libcrypto/des/enc_writ.c16
-rw-r--r--src/lib/libcrypto/des/fcrypt.c81
-rw-r--r--src/lib/libcrypto/des/fcrypt_b.c6
-rw-r--r--src/lib/libcrypto/des/ncbc_enc.c20
-rw-r--r--src/lib/libcrypto/des/ofb64ede.c21
-rw-r--r--src/lib/libcrypto/des/ofb64enc.c10
-rw-r--r--src/lib/libcrypto/des/ofb_enc.c7
-rw-r--r--src/lib/libcrypto/des/pcbc_enc.c9
-rw-r--r--src/lib/libcrypto/des/qud_cksm.c4
-rw-r--r--src/lib/libcrypto/des/rand_key.c13
-rw-r--r--src/lib/libcrypto/des/read2pwd.c69
-rw-r--r--src/lib/libcrypto/des/read_pwd.c62
-rw-r--r--src/lib/libcrypto/des/rpc_enc.c12
-rw-r--r--src/lib/libcrypto/des/rpw.c2
-rw-r--r--src/lib/libcrypto/des/set_key.c43
-rw-r--r--src/lib/libcrypto/des/speed.c54
-rw-r--r--src/lib/libcrypto/des/spr.h2
-rw-r--r--src/lib/libcrypto/des/str2key.c54
-rw-r--r--src/lib/libcrypto/des/xcbc_enc.c19
-rw-r--r--src/lib/libcrypto/dh/Makefile.ssl109
-rw-r--r--src/lib/libcrypto/dh/dh.h60
-rw-r--r--src/lib/libcrypto/dh/dh_asn1.c87
-rw-r--r--src/lib/libcrypto/dh/dh_check.c2
-rw-r--r--src/lib/libcrypto/dh/dh_err.c9
-rw-r--r--src/lib/libcrypto/dh/dh_gen.c32
-rw-r--r--src/lib/libcrypto/dh/dh_key.c59
-rw-r--r--src/lib/libcrypto/dh/dh_lib.c150
-rw-r--r--src/lib/libcrypto/dh/dhtest.c30
-rw-r--r--src/lib/libcrypto/doc/DH_set_method.pod4
-rw-r--r--src/lib/libcrypto/doc/DSA_set_method.pod2
-rw-r--r--src/lib/libcrypto/doc/ERR_get_error.pod29
-rw-r--r--src/lib/libcrypto/doc/EVP_BytesToKey.pod67
-rw-r--r--src/lib/libcrypto/doc/EVP_DigestInit.pod119
-rw-r--r--src/lib/libcrypto/doc/EVP_EncryptInit.pod289
-rw-r--r--src/lib/libcrypto/doc/EVP_SignInit.pod39
-rw-r--r--src/lib/libcrypto/doc/EVP_VerifyInit.pod36
-rw-r--r--src/lib/libcrypto/doc/OPENSSL_VERSION_NUMBER.pod29
-rw-r--r--src/lib/libcrypto/doc/RSA_generate_key.pod2
-rw-r--r--src/lib/libcrypto/doc/RSA_public_encrypt.pod4
-rw-r--r--src/lib/libcrypto/doc/RSA_set_method.pod26
-rw-r--r--src/lib/libcrypto/doc/bn.pod17
-rw-r--r--src/lib/libcrypto/doc/rsa.pod1
-rw-r--r--src/lib/libcrypto/dsa/Makefile.ssl167
-rw-r--r--src/lib/libcrypto/dsa/dsa.h85
-rw-r--r--src/lib/libcrypto/dsa/dsa_asn1.c200
-rw-r--r--src/lib/libcrypto/dsa/dsa_err.c7
-rw-r--r--src/lib/libcrypto/dsa/dsa_gen.c18
-rw-r--r--src/lib/libcrypto/dsa/dsa_key.c3
-rw-r--r--src/lib/libcrypto/dsa/dsa_lib.c151
-rw-r--r--src/lib/libcrypto/dsa/dsa_ossl.c11
-rw-r--r--src/lib/libcrypto/dsa/dsa_sign.c4
-rw-r--r--src/lib/libcrypto/dsa/dsa_vrf.c4
-rw-r--r--src/lib/libcrypto/dsa/dsatest.c17
-rw-r--r--src/lib/libcrypto/dso/Makefile.ssl71
-rw-r--r--src/lib/libcrypto/dso/README24
-rw-r--r--src/lib/libcrypto/dso/dso.h168
-rw-r--r--src/lib/libcrypto/dso/dso_dl.c112
-rw-r--r--src/lib/libcrypto/dso/dso_dlfcn.c97
-rw-r--r--src/lib/libcrypto/dso/dso_err.c23
-rw-r--r--src/lib/libcrypto/dso/dso_lib.c179
-rw-r--r--src/lib/libcrypto/dso/dso_vms.c82
-rw-r--r--src/lib/libcrypto/dso/dso_win32.c112
-rw-r--r--src/lib/libcrypto/ebcdic.c3
-rw-r--r--src/lib/libcrypto/ec/Makefile.ssl128
-rw-r--r--src/lib/libcrypto/ec/ec.h245
-rw-r--r--src/lib/libcrypto/ec/ec_cvt.c80
-rw-r--r--src/lib/libcrypto/ec/ec_err.c151
-rw-r--r--src/lib/libcrypto/ec/ec_lcl.h277
-rw-r--r--src/lib/libcrypto/ec/ec_lib.c646
-rw-r--r--src/lib/libcrypto/ec/ec_mult.c473
-rw-r--r--src/lib/libcrypto/ec/ecp_mont.c304
-rw-r--r--src/lib/libcrypto/ec/ecp_nist.c134
-rw-r--r--src/lib/libcrypto/ec/ecp_recp.c133
-rw-r--r--src/lib/libcrypto/ec/ecp_smpl.c1717
-rw-r--r--src/lib/libcrypto/ec/ectest.c634
-rw-r--r--src/lib/libcrypto/engine/Makefile.ssl507
-rw-r--r--src/lib/libcrypto/engine/README483
-rw-r--r--src/lib/libcrypto/engine/eng_all.c118
-rw-r--r--src/lib/libcrypto/engine/eng_cnf.c242
-rw-r--r--src/lib/libcrypto/engine/eng_ctrl.c387
-rw-r--r--src/lib/libcrypto/engine/eng_dyn.c446
-rw-r--r--src/lib/libcrypto/engine/eng_err.c165
-rw-r--r--src/lib/libcrypto/engine/eng_fat.c148
-rw-r--r--src/lib/libcrypto/engine/eng_init.c158
-rw-r--r--src/lib/libcrypto/engine/eng_int.h185
-rw-r--r--src/lib/libcrypto/engine/eng_lib.c321
-rw-r--r--src/lib/libcrypto/engine/eng_list.c383
-rw-r--r--src/lib/libcrypto/engine/eng_openssl.c347
-rw-r--r--src/lib/libcrypto/engine/eng_pkey.c157
-rw-r--r--src/lib/libcrypto/engine/eng_table.c361
-rw-r--r--src/lib/libcrypto/engine/engine.h653
-rw-r--r--src/lib/libcrypto/engine/enginetest.c45
-rw-r--r--src/lib/libcrypto/engine/hw.ec8
-rw-r--r--src/lib/libcrypto/engine/hw_4758_cca.c950
-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.c1101
-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.c283
-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.c926
-rw-r--r--src/lib/libcrypto/engine/hw_cswift.c322
-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.c662
-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.c399
-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.c1041
-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.c145
-rw-r--r--src/lib/libcrypto/engine/tb_dh.c120
-rw-r--r--src/lib/libcrypto/engine/tb_digest.c145
-rw-r--r--src/lib/libcrypto/engine/tb_dsa.c120
-rw-r--r--src/lib/libcrypto/engine/tb_rand.c120
-rw-r--r--src/lib/libcrypto/engine/tb_rsa.c120
-rw-r--r--src/lib/libcrypto/engine/vendor_defns/aep.h178
-rw-r--r--src/lib/libcrypto/engine/vendor_defns/atalla.h13
-rw-r--r--src/lib/libcrypto/engine/vendor_defns/cswift.h45
-rw-r--r--src/lib/libcrypto/engine/vendor_defns/hw_4758_cca.h149
-rw-r--r--src/lib/libcrypto/err/Makefile.ssl57
-rw-r--r--src/lib/libcrypto/err/err.c615
-rw-r--r--src/lib/libcrypto/err/err.h183
-rw-r--r--src/lib/libcrypto/err/err_all.c49
-rw-r--r--src/lib/libcrypto/err/err_prn.c46
-rw-r--r--src/lib/libcrypto/err/openssl.ec31
-rw-r--r--src/lib/libcrypto/evp/Makefile.ssl1129
-rw-r--r--src/lib/libcrypto/evp/bio_b64.c5
-rw-r--r--src/lib/libcrypto/evp/bio_enc.c20
-rw-r--r--src/lib/libcrypto/evp/bio_md.c30
-rw-r--r--src/lib/libcrypto/evp/bio_ok.c52
-rw-r--r--src/lib/libcrypto/evp/c_all.c12
-rw-r--r--src/lib/libcrypto/evp/c_allc.c30
-rw-r--r--src/lib/libcrypto/evp/c_alld.c18
-rw-r--r--src/lib/libcrypto/evp/digest.c254
-rw-r--r--src/lib/libcrypto/evp/e_aes.c99
-rw-r--r--src/lib/libcrypto/evp/e_bf.c14
-rw-r--r--src/lib/libcrypto/evp/e_cast.c16
-rw-r--r--src/lib/libcrypto/evp/e_des.c21
-rw-r--r--src/lib/libcrypto/evp/e_des3.c88
-rw-r--r--src/lib/libcrypto/evp/e_idea.c22
-rw-r--r--src/lib/libcrypto/evp/e_null.c6
-rw-r--r--src/lib/libcrypto/evp/e_rc2.c67
-rw-r--r--src/lib/libcrypto/evp/e_rc4.c37
-rw-r--r--src/lib/libcrypto/evp/e_rc5.c65
-rw-r--r--src/lib/libcrypto/evp/e_xcbc_d.c39
-rw-r--r--src/lib/libcrypto/evp/encode.c7
-rw-r--r--src/lib/libcrypto/evp/evp.h502
-rw-r--r--src/lib/libcrypto/evp/evp_acnf.c74
-rw-r--r--src/lib/libcrypto/evp/evp_enc.c290
-rw-r--r--src/lib/libcrypto/evp/evp_err.c11
-rw-r--r--src/lib/libcrypto/evp/evp_key.c39
-rw-r--r--src/lib/libcrypto/evp/evp_locl.h125
-rw-r--r--src/lib/libcrypto/evp/evp_pbe.c6
-rw-r--r--src/lib/libcrypto/evp/evp_pkey.c24
-rw-r--r--src/lib/libcrypto/evp/evp_test.c365
-rw-r--r--src/lib/libcrypto/evp/evptests.txt82
-rw-r--r--src/lib/libcrypto/evp/m_dss.c24
-rw-r--r--src/lib/libcrypto/evp/m_dss1.c24
-rw-r--r--src/lib/libcrypto/evp/m_md2.c25
-rw-r--r--src/lib/libcrypto/evp/m_md4.c27
-rw-r--r--src/lib/libcrypto/evp/m_md5.c25
-rw-r--r--src/lib/libcrypto/evp/m_mdc2.c25
-rw-r--r--src/lib/libcrypto/evp/m_null.c25
-rw-r--r--src/lib/libcrypto/evp/m_ripemd.c24
-rw-r--r--src/lib/libcrypto/evp/m_sha.c24
-rw-r--r--src/lib/libcrypto/evp/m_sha1.c24
-rw-r--r--src/lib/libcrypto/evp/names.c4
-rw-r--r--src/lib/libcrypto/evp/openbsd_hw.c446
-rw-r--r--src/lib/libcrypto/evp/p5_crpt.c40
-rw-r--r--src/lib/libcrypto/evp/p5_crpt2.c14
-rw-r--r--src/lib/libcrypto/evp/p_dec.c6
-rw-r--r--src/lib/libcrypto/evp/p_enc.c6
-rw-r--r--src/lib/libcrypto/evp/p_lib.c46
-rw-r--r--src/lib/libcrypto/evp/p_open.c14
-rw-r--r--src/lib/libcrypto/evp/p_seal.c17
-rw-r--r--src/lib/libcrypto/evp/p_sign.c8
-rw-r--r--src/lib/libcrypto/evp/p_verify.c6
-rw-r--r--src/lib/libcrypto/ex_data.c615
-rw-r--r--src/lib/libcrypto/hmac/Makefile.ssl25
-rw-r--r--src/lib/libcrypto/hmac/hmac.c51
-rw-r--r--src/lib/libcrypto/hmac/hmac.h12
-rw-r--r--src/lib/libcrypto/hmac/hmactest.c3
-rw-r--r--src/lib/libcrypto/idea/Makefile.ssl16
-rw-r--r--src/lib/libcrypto/idea/idea.h2
-rw-r--r--src/lib/libcrypto/install.com17
-rw-r--r--src/lib/libcrypto/krb5/Makefile.ssl90
-rw-r--r--src/lib/libcrypto/krb5/krb5_asn.c167
-rw-r--r--src/lib/libcrypto/krb5/krb5_asn.h256
-rw-r--r--src/lib/libcrypto/lhash/Makefile.ssl17
-rw-r--r--src/lib/libcrypto/lhash/lh_stats.c22
-rw-r--r--src/lib/libcrypto/lhash/lh_test.c1
-rw-r--r--src/lib/libcrypto/lhash/lhash.c63
-rw-r--r--src/lib/libcrypto/lhash/lhash.h92
-rw-r--r--src/lib/libcrypto/md2/Makefile.ssl16
-rw-r--r--src/lib/libcrypto/md2/md2.h8
-rw-r--r--src/lib/libcrypto/md2/md2_dgst.c13
-rw-r--r--src/lib/libcrypto/md2/md2test.c9
-rw-r--r--src/lib/libcrypto/md32_common.h22
-rw-r--r--src/lib/libcrypto/md4/Makefile.ssl15
-rw-r--r--src/lib/libcrypto/md4/md4.h14
-rw-r--r--src/lib/libcrypto/md4/md4_dgst.c3
-rw-r--r--src/lib/libcrypto/md4/md4_locl.h2
-rw-r--r--src/lib/libcrypto/md4/md4test.c7
-rw-r--r--src/lib/libcrypto/md5/Makefile.ssl11
-rw-r--r--src/lib/libcrypto/md5/asm/md5-sparcv9.S8
-rw-r--r--src/lib/libcrypto/md5/md5.h12
-rw-r--r--src/lib/libcrypto/md5/md5_dgst.c3
-rw-r--r--src/lib/libcrypto/md5/md5_locl.h6
-rw-r--r--src/lib/libcrypto/md5/md5test.c7
-rw-r--r--src/lib/libcrypto/mdc2/Makefile.ssl27
-rw-r--r--src/lib/libcrypto/mdc2/mdc2.h10
-rw-r--r--src/lib/libcrypto/mem.c127
-rw-r--r--src/lib/libcrypto/mem_dbg.c80
-rw-r--r--src/lib/libcrypto/o_time.c203
-rw-r--r--src/lib/libcrypto/o_time.h66
-rw-r--r--src/lib/libcrypto/objects/Makefile.ssl57
-rw-r--r--src/lib/libcrypto/objects/o_names.c147
-rw-r--r--src/lib/libcrypto/objects/obj_dat.c46
-rw-r--r--src/lib/libcrypto/objects/obj_dat.h2842
-rw-r--r--src/lib/libcrypto/objects/obj_dat.pl13
-rw-r--r--src/lib/libcrypto/objects/obj_err.c4
-rw-r--r--src/lib/libcrypto/objects/obj_lib.c7
-rw-r--r--src/lib/libcrypto/objects/obj_mac.h593
-rw-r--r--src/lib/libcrypto/objects/obj_mac.num121
-rw-r--r--src/lib/libcrypto/objects/objects.h64
-rw-r--r--src/lib/libcrypto/objects/objects.pl17
-rw-r--r--src/lib/libcrypto/objects/objects.txt211
-rw-r--r--src/lib/libcrypto/ocsp/Makefile.ssl221
-rw-r--r--src/lib/libcrypto/ocsp/ocsp.h619
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_asn.c182
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_cl.c370
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_err.c139
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_ext.c528
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_ht.c164
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_lib.c261
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_prn.c291
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_srv.c264
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_vfy.c444
-rw-r--r--src/lib/libcrypto/opensslconf.h.in7
-rw-r--r--src/lib/libcrypto/opensslv.h22
-rw-r--r--src/lib/libcrypto/ossl_typ.h120
-rw-r--r--src/lib/libcrypto/pem/Makefile.ssl268
-rw-r--r--src/lib/libcrypto/pem/pem.h33
-rw-r--r--src/lib/libcrypto/pem/pem_all.c23
-rw-r--r--src/lib/libcrypto/pem/pem_err.c4
-rw-r--r--src/lib/libcrypto/pem/pem_info.c14
-rw-r--r--src/lib/libcrypto/pem/pem_lib.c278
-rw-r--r--src/lib/libcrypto/pem/pem_oth.c85
-rw-r--r--src/lib/libcrypto/pem/pem_pk8.c243
-rw-r--r--src/lib/libcrypto/pem/pem_pkey.c139
-rw-r--r--src/lib/libcrypto/pem/pem_seal.c31
-rw-r--r--src/lib/libcrypto/pem/pem_sign.c2
-rw-r--r--src/lib/libcrypto/pem/pem_x509.c69
-rw-r--r--src/lib/libcrypto/pem/pem_xaux.c68
-rw-r--r--src/lib/libcrypto/perlasm/x86unix.pl83
-rw-r--r--src/lib/libcrypto/pkcs12/Makefile.ssl477
-rw-r--r--src/lib/libcrypto/pkcs12/p12_add.c87
-rw-r--r--src/lib/libcrypto/pkcs12/p12_asn.c125
-rw-r--r--src/lib/libcrypto/pkcs12/p12_attr.c155
-rw-r--r--src/lib/libcrypto/pkcs12/p12_crpt.c10
-rw-r--r--src/lib/libcrypto/pkcs12/p12_crt.c6
-rw-r--r--src/lib/libcrypto/pkcs12/p12_decr.c69
-rw-r--r--src/lib/libcrypto/pkcs12/p12_init.c8
-rw-r--r--src/lib/libcrypto/pkcs12/p12_key.c16
-rw-r--r--src/lib/libcrypto/pkcs12/p12_kiss.c10
-rw-r--r--src/lib/libcrypto/pkcs12/p12_mutl.c15
-rw-r--r--src/lib/libcrypto/pkcs12/p12_npas.c10
-rw-r--r--src/lib/libcrypto/pkcs12/p12_p8d.c68
-rw-r--r--src/lib/libcrypto/pkcs12/p12_p8e.c97
-rw-r--r--src/lib/libcrypto/pkcs12/p12_utl.c40
-rw-r--r--src/lib/libcrypto/pkcs12/pk12err.c4
-rw-r--r--src/lib/libcrypto/pkcs12/pkcs12.h125
-rw-r--r--src/lib/libcrypto/pkcs7/Makefile.ssl199
-rw-r--r--src/lib/libcrypto/pkcs7/bio_ber.c6
-rw-r--r--src/lib/libcrypto/pkcs7/enc.c2
-rw-r--r--src/lib/libcrypto/pkcs7/example.c1
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_asn1.c213
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_attr.c60
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_doit.c161
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_lib.c22
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_smime.c25
-rw-r--r--src/lib/libcrypto/pkcs7/pkcs7.h104
-rw-r--r--src/lib/libcrypto/pkcs7/pkcs7err.c5
-rw-r--r--src/lib/libcrypto/pkcs7/sign.c8
-rw-r--r--src/lib/libcrypto/pkcs7/verify.c8
-rw-r--r--src/lib/libcrypto/rand/Makefile.ssl118
-rw-r--r--src/lib/libcrypto/rand/md_rand.c53
-rw-r--r--src/lib/libcrypto/rand/rand.h30
-rw-r--r--src/lib/libcrypto/rand/rand_egd.c240
-rw-r--r--src/lib/libcrypto/rand/rand_err.c5
-rw-r--r--src/lib/libcrypto/rand/rand_lcl.h60
-rw-r--r--src/lib/libcrypto/rand/rand_lib.c82
-rw-r--r--src/lib/libcrypto/rand/rand_os2.c147
-rw-r--r--src/lib/libcrypto/rand/rand_unix.c274
-rw-r--r--src/lib/libcrypto/rand/rand_vms.c135
-rw-r--r--src/lib/libcrypto/rand/rand_win.c63
-rw-r--r--src/lib/libcrypto/rand/randfile.c26
-rw-r--r--src/lib/libcrypto/rand/randtest.c9
-rw-r--r--src/lib/libcrypto/rc2/Makefile.ssl16
-rw-r--r--src/lib/libcrypto/rc2/rc2.h2
-rw-r--r--src/lib/libcrypto/rc2/rc2speed.c6
-rw-r--r--src/lib/libcrypto/rc2/rc2test.c2
-rw-r--r--src/lib/libcrypto/rc4/Makefile.ssl10
-rw-r--r--src/lib/libcrypto/rc4/rc4.c4
-rw-r--r--src/lib/libcrypto/rc4/rc4.h2
-rw-r--r--src/lib/libcrypto/rc4/rc4speed.c6
-rw-r--r--src/lib/libcrypto/rc4/rc4test.c2
-rw-r--r--src/lib/libcrypto/rc5/Makefile.ssl16
-rw-r--r--src/lib/libcrypto/rc5/rc5.h2
-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.ssl13
-rw-r--r--src/lib/libcrypto/ripemd/ripemd.h14
-rw-r--r--src/lib/libcrypto/ripemd/rmd_dgst.c3
-rw-r--r--src/lib/libcrypto/ripemd/rmd_locl.h4
-rw-r--r--src/lib/libcrypto/ripemd/rmdtest.c9
-rw-r--r--src/lib/libcrypto/rsa/Makefile.ssl224
-rw-r--r--src/lib/libcrypto/rsa/rsa.h150
-rw-r--r--src/lib/libcrypto/rsa/rsa_asn1.c121
-rw-r--r--src/lib/libcrypto/rsa/rsa_chk.c2
-rw-r--r--src/lib/libcrypto/rsa/rsa_eay.c114
-rw-r--r--src/lib/libcrypto/rsa/rsa_err.c5
-rw-r--r--src/lib/libcrypto/rsa/rsa_lib.c175
-rw-r--r--src/lib/libcrypto/rsa/rsa_none.c8
-rw-r--r--src/lib/libcrypto/rsa/rsa_null.c23
-rw-r--r--src/lib/libcrypto/rsa/rsa_oaep.c300
-rw-r--r--src/lib/libcrypto/rsa/rsa_pk1.c12
-rw-r--r--src/lib/libcrypto/rsa/rsa_saos.c14
-rw-r--r--src/lib/libcrypto/rsa/rsa_sign.c30
-rw-r--r--src/lib/libcrypto/rsa/rsa_ssl.c10
-rw-r--r--src/lib/libcrypto/rsa/rsa_test.c14
-rw-r--r--src/lib/libcrypto/sha/Makefile.ssl20
-rw-r--r--src/lib/libcrypto/sha/sha.h24
-rw-r--r--src/lib/libcrypto/sha/sha1_one.c2
-rw-r--r--src/lib/libcrypto/sha/sha1dgst.c2
-rw-r--r--src/lib/libcrypto/sha/sha1test.c16
-rw-r--r--src/lib/libcrypto/sha/sha_dgst.c2
-rw-r--r--src/lib/libcrypto/sha/sha_locl.h5
-rw-r--r--src/lib/libcrypto/sha/sha_one.c2
-rw-r--r--src/lib/libcrypto/sha/shatest.c16
-rw-r--r--src/lib/libcrypto/stack/Makefile.ssl12
-rw-r--r--src/lib/libcrypto/stack/safestack.h378
-rw-r--r--src/lib/libcrypto/stack/stack.c14
-rw-r--r--src/lib/libcrypto/symhacks.h131
-rw-r--r--src/lib/libcrypto/threads/mttest.c8
-rw-r--r--src/lib/libcrypto/threads/th-lock.c6
-rw-r--r--src/lib/libcrypto/tmdiff.c44
-rw-r--r--src/lib/libcrypto/txt_db/Makefile.ssl12
-rw-r--r--src/lib/libcrypto/txt_db/txt_db.c8
-rw-r--r--src/lib/libcrypto/txt_db/txt_db.h6
-rw-r--r--src/lib/libcrypto/ui/Makefile.ssl117
-rw-r--r--src/lib/libcrypto/ui/ui.h387
-rw-r--r--src/lib/libcrypto/ui/ui_compat.c67
-rw-r--r--src/lib/libcrypto/ui/ui_compat.h83
-rw-r--r--src/lib/libcrypto/ui/ui_err.c111
-rw-r--r--src/lib/libcrypto/ui/ui_lib.c899
-rw-r--r--src/lib/libcrypto/ui/ui_locl.h148
-rw-r--r--src/lib/libcrypto/ui/ui_openssl.c661
-rw-r--r--src/lib/libcrypto/ui/ui_util.c86
-rw-r--r--src/lib/libcrypto/uid.c7
-rw-r--r--src/lib/libcrypto/util/clean-depend.pl20
-rw-r--r--src/lib/libcrypto/util/cygwin.sh125
-rw-r--r--src/lib/libcrypto/util/domd22
-rw-r--r--src/lib/libcrypto/util/libeay.num1271
-rw-r--r--src/lib/libcrypto/util/mk1mf.pl98
-rw-r--r--src/lib/libcrypto/util/mkdef.pl980
-rw-r--r--src/lib/libcrypto/util/mkerr.pl200
-rw-r--r--src/lib/libcrypto/util/mkfiles.pl6
-rw-r--r--src/lib/libcrypto/util/mkstack.pl2
-rw-r--r--src/lib/libcrypto/util/pl/BC-16.pl4
-rw-r--r--src/lib/libcrypto/util/pl/BC-32.pl3
-rw-r--r--src/lib/libcrypto/util/pl/OS2-EMX.pl96
-rw-r--r--src/lib/libcrypto/util/pl/VC-16.pl3
-rw-r--r--src/lib/libcrypto/util/pl/VC-32.pl9
-rw-r--r--src/lib/libcrypto/util/selftest.pl12
-rw-r--r--src/lib/libcrypto/util/ssleay.num76
-rw-r--r--src/lib/libcrypto/x509/Makefile.ssl647
-rw-r--r--src/lib/libcrypto/x509/by_file.c4
-rw-r--r--src/lib/libcrypto/x509/x509.h321
-rw-r--r--src/lib/libcrypto/x509/x509_att.c26
-rw-r--r--src/lib/libcrypto/x509/x509_cmp.c37
-rw-r--r--src/lib/libcrypto/x509/x509_d2.c2
-rw-r--r--src/lib/libcrypto/x509/x509_err.c8
-rw-r--r--src/lib/libcrypto/x509/x509_ext.c19
-rw-r--r--src/lib/libcrypto/x509/x509_lu.c40
-rw-r--r--src/lib/libcrypto/x509/x509_obj.c1
-rw-r--r--src/lib/libcrypto/x509/x509_req.c16
-rw-r--r--src/lib/libcrypto/x509/x509_trs.c29
-rw-r--r--src/lib/libcrypto/x509/x509_txt.c10
-rw-r--r--src/lib/libcrypto/x509/x509_v3.c9
-rw-r--r--src/lib/libcrypto/x509/x509_vfy.c347
-rw-r--r--src/lib/libcrypto/x509/x509_vfy.h67
-rw-r--r--src/lib/libcrypto/x509/x509cset.c169
-rw-r--r--src/lib/libcrypto/x509/x509spki.c1
-rw-r--r--src/lib/libcrypto/x509/x_all.c203
-rw-r--r--src/lib/libcrypto/x509v3/Makefile.ssl602
-rw-r--r--src/lib/libcrypto/x509v3/ext_dat.h16
-rw-r--r--src/lib/libcrypto/x509v3/v3_akey.c71
-rw-r--r--src/lib/libcrypto/x509v3/v3_akeya.c72
-rw-r--r--src/lib/libcrypto/x509v3/v3_alt.c112
-rw-r--r--src/lib/libcrypto/x509v3/v3_bcons.c58
-rw-r--r--src/lib/libcrypto/x509v3/v3_bitst.c1
-rw-r--r--src/lib/libcrypto/x509v3/v3_conf.c395
-rw-r--r--src/lib/libcrypto/x509v3/v3_cpols.c328
-rw-r--r--src/lib/libcrypto/x509v3/v3_crld.c181
-rw-r--r--src/lib/libcrypto/x509v3/v3_enum.c12
-rw-r--r--src/lib/libcrypto/x509v3/v3_extku.c132
-rw-r--r--src/lib/libcrypto/x509v3/v3_genn.c264
-rw-r--r--src/lib/libcrypto/x509v3/v3_info.c126
-rw-r--r--src/lib/libcrypto/x509v3/v3_int.c11
-rw-r--r--src/lib/libcrypto/x509v3/v3_lib.c80
-rw-r--r--src/lib/libcrypto/x509v3/v3_ocsp.c272
-rw-r--r--src/lib/libcrypto/x509v3/v3_pku.c61
-rw-r--r--src/lib/libcrypto/x509v3/v3_prn.c80
-rw-r--r--src/lib/libcrypto/x509v3/v3_purp.c104
-rw-r--r--src/lib/libcrypto/x509v3/v3_skey.c15
-rw-r--r--src/lib/libcrypto/x509v3/v3_sxnet.c112
-rw-r--r--src/lib/libcrypto/x509v3/v3_utl.c45
-rw-r--r--src/lib/libcrypto/x509v3/v3conf.c1
-rw-r--r--src/lib/libcrypto/x509v3/v3err.c9
-rw-r--r--src/lib/libcrypto/x509v3/v3prin.c2
-rw-r--r--src/lib/libcrypto/x509v3/x509v3.h274
632 files changed, 65035 insertions, 17104 deletions
diff --git a/src/lib/libcrypto/Makefile.ssl b/src/lib/libcrypto/Makefile.ssl
index 6759b2e4d0..9d1a180571 100644
--- a/src/lib/libcrypto/Makefile.ssl
+++ b/src/lib/libcrypto/Makefile.ssl
@@ -5,14 +5,15 @@
5DIR= crypto 5DIR= crypto
6TOP= .. 6TOP= ..
7CC= cc 7CC= cc
8INCLUDE= -I. -I../include 8INCLUDE= -I. -I$(TOP) -I../include
9INCLUDES= -I.. -I../../include 9INCLUDES= -I.. -I../.. -I../../include
10CFLAG= -g 10CFLAG= -g
11INSTALL_PREFIX= 11INSTALL_PREFIX=
12OPENSSLDIR= /usr/local/ssl 12OPENSSLDIR= /usr/local/ssl
13INSTALLTOP= /usr/local/ssl 13INSTALLTOP= /usr/local/ssl
14MAKE= make -f Makefile.ssl 14MAKE= make -f Makefile.ssl
15MAKEDEPEND= $(TOP)/util/domd $(TOP) 15MAKEDEPPROG= makedepend
16MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl 17MAKEFILE= Makefile.ssl
17RM= rm -f 18RM= rm -f
18AR= ar r 19AR= ar r
@@ -27,34 +28,36 @@ LIBS=
27 28
28SDIRS= md2 md5 sha mdc2 hmac ripemd \ 29SDIRS= md2 md5 sha mdc2 hmac ripemd \
29 des rc2 rc4 rc5 idea bf cast \ 30 des rc2 rc4 rc5 idea bf cast \
30 bn rsa dsa dh dso engine \ 31 bn ec rsa dsa dh dso engine aes \
31 buffer bio stack lhash rand err objects \ 32 buffer bio stack lhash rand err objects \
32 evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp 33 evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5
33 34
34GENERAL=Makefile README crypto-lib.com install.com 35GENERAL=Makefile README crypto-lib.com install.com
35 36
36LIB= $(TOP)/libcrypto.a 37LIB= $(TOP)/libcrypto.a
37LIBSRC= cryptlib.c mem.c mem_dbg.c cversion.c ex_data.c tmdiff.c cpt_err.c ebcdic.c uid.c 38SHARED_LIB= libcrypto$(SHLIB_EXT)
38LIBOBJ= cryptlib.o mem.o mem_dbg.o cversion.o ex_data.o tmdiff.o cpt_err.o ebcdic.o uid.o 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
39 41
40SRC= $(LIBSRC) 42SRC= $(LIBSRC)
41 43
42EXHEADER= crypto.h tmdiff.h opensslv.h opensslconf.h ebcdic.h symhacks.h 44EXHEADER= crypto.h tmdiff.h opensslv.h opensslconf.h ebcdic.h symhacks.h \
43HEADER= cryptlib.h buildinf.h md32_common.h $(EXHEADER) 45 ossl_typ.h
46HEADER= cryptlib.h buildinf.h md32_common.h o_time.h $(EXHEADER)
44 47
45ALL= $(GENERAL) $(SRC) $(HEADER) 48ALL= $(GENERAL) $(SRC) $(HEADER)
46 49
47top: 50top:
48 @(cd ..; $(MAKE) DIRS=$(DIR) all) 51 @(cd ..; $(MAKE) DIRS=$(DIR) all)
49 52
50all: buildinf.h lib subdirs 53all: buildinf.h lib subdirs shared
51 54
52buildinf.h: ../Makefile.ssl 55buildinf.h: ../Makefile.ssl
53 ( echo "#ifndef MK1MF_BUILD"; \ 56 ( echo "#ifndef MK1MF_BUILD"; \
54 echo " /* auto-generated by crypto/Makefile.ssl for crypto/cversion.c */"; \ 57 echo " /* auto-generated by crypto/Makefile.ssl for crypto/cversion.c */"; \
55 echo " #define CFLAGS \"$(CC) $(CFLAG)\""; \ 58 echo " #define CFLAGS \"$(CC) $(CFLAG)\""; \
56 echo " #define PLATFORM \"$(PLATFORM)\""; \ 59 echo " #define PLATFORM \"$(PLATFORM)\""; \
57 echo " #define DATE \"`date`\""; \ 60 echo " #define DATE \"`LC_ALL=C LC_TIME=C date`\""; \
58 echo "#endif" ) >buildinf.h 61 echo "#endif" ) >buildinf.h
59 62
60testapps: 63testapps:
@@ -73,7 +76,7 @@ files:
73 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO 76 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
74 @for i in $(SDIRS) ;\ 77 @for i in $(SDIRS) ;\
75 do \ 78 do \
76 (cd $$i; echo "making 'files' in crypto/$$i..."; \ 79 (cd $$i && echo "making 'files' in crypto/$$i..." && \
77 $(MAKE) PERL='${PERL}' files ); \ 80 $(MAKE) PERL='${PERL}' files ); \
78 done; 81 done;
79 82
@@ -84,27 +87,31 @@ links:
84 @$(PERL) $(TOP)/util/mklink.pl ../apps $(APPS) 87 @$(PERL) $(TOP)/util/mklink.pl ../apps $(APPS)
85 @$(SHELL) $(TOP)/util/point.sh Makefile.ssl Makefile 88 @$(SHELL) $(TOP)/util/point.sh Makefile.ssl Makefile
86 @for i in $(SDIRS); do \ 89 @for i in $(SDIRS); do \
87 (cd $$i; echo "making links in crypto/$$i..."; \ 90 (cd $$i && echo "making links in crypto/$$i..." && \
88 $(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 ); \ 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 ); \
89 done; 92 done;
90 93
91lib: $(LIBOBJ) 94lib: $(LIBOBJ)
92 $(AR) $(LIB) $(LIBOBJ) 95 $(AR) $(LIB) $(LIBOBJ)
93 @echo You may get an error following this line. Please ignore. 96 $(RANLIB) $(LIB) || echo Never mind.
94 - $(RANLIB) $(LIB)
95 @touch lib 97 @touch lib
96 98
99shared:
100 if [ -n "$(SHARED_LIBS)" ]; then \
101 (cd ..; make $(SHARED_LIB)); \
102 fi
103
97libs: 104libs:
98 @for i in $(SDIRS) ;\ 105 @for i in $(SDIRS) ;\
99 do \ 106 do \
100 (cd $$i; echo "making libs in crypto/$$i..."; \ 107 (cd $$i && echo "making libs in crypto/$$i..." && \
101 $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALL_PREFIX='${INSTALL_PREFIX}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' AR='${AR}' lib ); \ 108 $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALL_PREFIX='${INSTALL_PREFIX}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' AR='${AR}' lib ); \
102 done; 109 done;
103 110
104tests: 111tests:
105 @for i in $(SDIRS) ;\ 112 @for i in $(SDIRS) ;\
106 do \ 113 do \
107 (cd $$i; echo "making tests in crypto/$$i..."; \ 114 (cd $$i && echo "making tests in crypto/$$i..." && \
108 $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' AR='${AR}' tests ); \ 115 $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' AR='${AR}' tests ); \
109 done; 116 done;
110 117
@@ -116,14 +123,14 @@ install:
116 done; 123 done;
117 @for i in $(SDIRS) ;\ 124 @for i in $(SDIRS) ;\
118 do \ 125 do \
119 (cd $$i; echo "making install in crypto/$$i..."; \ 126 (cd $$i && echo "making install in crypto/$$i..." && \
120 $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALL_PREFIX='${INSTALL_PREFIX}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' install ); \ 127 $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALL_PREFIX='${INSTALL_PREFIX}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' install ); \
121 done; 128 done;
122 129
123lint: 130lint:
124 @for i in $(SDIRS) ;\ 131 @for i in $(SDIRS) ;\
125 do \ 132 do \
126 (cd $$i; echo "making lint in crypto/$$i..."; \ 133 (cd $$i && echo "making lint in crypto/$$i..." && \
127 $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' lint ); \ 134 $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' lint ); \
128 done; 135 done;
129 136
@@ -133,7 +140,7 @@ depend:
133 if [ ! -s buildinf.h ]; then rm buildinf.h; fi 140 if [ ! -s buildinf.h ]; then rm buildinf.h; fi
134 @for i in $(SDIRS) ;\ 141 @for i in $(SDIRS) ;\
135 do \ 142 do \
136 (cd $$i; echo "making depend in crypto/$$i..."; \ 143 (cd $$i && echo "making depend in crypto/$$i..." && \
137 $(MAKE) MAKEFILE='${MAKEFILE}' INCLUDES='${INCLUDES}' DEPFLAG='${DEPFLAG}' depend ); \ 144 $(MAKE) MAKEFILE='${MAKEFILE}' INCLUDES='${INCLUDES}' DEPFLAG='${DEPFLAG}' depend ); \
138 done; 145 done;
139 146
@@ -141,7 +148,7 @@ clean:
141 rm -f buildinf.h *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff 148 rm -f buildinf.h *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
142 @for i in $(SDIRS) ;\ 149 @for i in $(SDIRS) ;\
143 do \ 150 do \
144 (cd $$i; echo "making clean in crypto/$$i..."; \ 151 (cd $$i && echo "making clean in crypto/$$i..." && \
145 $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' clean ); \ 152 $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' clean ); \
146 done; 153 done;
147 154
@@ -150,54 +157,58 @@ dclean:
150 mv -f Makefile.new $(MAKEFILE) 157 mv -f Makefile.new $(MAKEFILE)
151 @for i in $(SDIRS) ;\ 158 @for i in $(SDIRS) ;\
152 do \ 159 do \
153 (cd $$i; echo "making dclean in crypto/$$i..."; \ 160 (cd $$i && echo "making dclean in crypto/$$i..." && \
154 $(MAKE) PERL='${PERL}' CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' dclean ); \ 161 $(MAKE) PERL='${PERL}' CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' dclean ); \
155 done; 162 done;
156 163
157# DO NOT DELETE THIS LINE -- make depend depends on it. 164# DO NOT DELETE THIS LINE -- make depend depends on it.
158 165
159cpt_err.o: ../include/openssl/bio.h ../include/openssl/crypto.h 166cpt_err.o: ../include/openssl/bio.h ../include/openssl/crypto.h
160cpt_err.o: ../include/openssl/err.h ../include/openssl/lhash.h 167cpt_err.o: ../include/openssl/e_os2.h ../include/openssl/err.h
168cpt_err.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
161cpt_err.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h 169cpt_err.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h
162cpt_err.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 170cpt_err.o: ../include/openssl/stack.h ../include/openssl/symhacks.h cpt_err.c
163cryptlib.o: ../include/openssl/bio.h ../include/openssl/buffer.h 171cryptlib.o: ../e_os.h ../include/openssl/bio.h ../include/openssl/buffer.h
164cryptlib.o: ../include/openssl/crypto.h ../include/openssl/e_os.h 172cryptlib.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
165cryptlib.o: ../include/openssl/e_os2.h ../include/openssl/err.h 173cryptlib.o: ../include/openssl/err.h ../include/openssl/lhash.h
166cryptlib.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h 174cryptlib.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
167cryptlib.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h 175cryptlib.o: ../include/openssl/safestack.h ../include/openssl/stack.h
168cryptlib.o: ../include/openssl/stack.h ../include/openssl/symhacks.h cryptlib.h 176cryptlib.o: ../include/openssl/symhacks.h cryptlib.c cryptlib.h
169cversion.o: ../include/openssl/bio.h ../include/openssl/buffer.h 177cversion.o: ../e_os.h ../include/openssl/bio.h ../include/openssl/buffer.h
170cversion.o: ../include/openssl/crypto.h ../include/openssl/e_os.h 178cversion.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
171cversion.o: ../include/openssl/e_os2.h ../include/openssl/err.h 179cversion.o: ../include/openssl/err.h ../include/openssl/lhash.h
172cversion.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h 180cversion.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
173cversion.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h 181cversion.o: ../include/openssl/safestack.h ../include/openssl/stack.h
174cversion.o: ../include/openssl/stack.h ../include/openssl/symhacks.h buildinf.h 182cversion.o: ../include/openssl/symhacks.h buildinf.h cryptlib.h cversion.c
175cversion.o: cryptlib.h 183ebcdic.o: ../include/openssl/opensslconf.h ebcdic.c
176ex_data.o: ../include/openssl/bio.h ../include/openssl/buffer.h 184ex_data.o: ../e_os.h ../include/openssl/bio.h ../include/openssl/buffer.h
177ex_data.o: ../include/openssl/crypto.h ../include/openssl/e_os.h 185ex_data.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
178ex_data.o: ../include/openssl/e_os2.h ../include/openssl/err.h 186ex_data.o: ../include/openssl/err.h ../include/openssl/lhash.h
179ex_data.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h 187ex_data.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
180ex_data.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h 188ex_data.o: ../include/openssl/safestack.h ../include/openssl/stack.h
181ex_data.o: ../include/openssl/stack.h ../include/openssl/symhacks.h cryptlib.h 189ex_data.o: ../include/openssl/symhacks.h cryptlib.h ex_data.c
182mem.o: ../include/openssl/bio.h ../include/openssl/buffer.h 190mem.o: ../e_os.h ../include/openssl/bio.h ../include/openssl/buffer.h
183mem.o: ../include/openssl/crypto.h ../include/openssl/e_os.h 191mem.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
184mem.o: ../include/openssl/e_os2.h ../include/openssl/err.h 192mem.o: ../include/openssl/err.h ../include/openssl/lhash.h
185mem.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h 193mem.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
186mem.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h 194mem.o: ../include/openssl/safestack.h ../include/openssl/stack.h
187mem.o: ../include/openssl/stack.h ../include/openssl/symhacks.h cryptlib.h 195mem.o: ../include/openssl/symhacks.h cryptlib.h mem.c
188mem_dbg.o: ../include/openssl/bio.h ../include/openssl/buffer.h 196mem_dbg.o: ../e_os.h ../include/openssl/bio.h ../include/openssl/buffer.h
189mem_dbg.o: ../include/openssl/crypto.h ../include/openssl/e_os.h 197mem_dbg.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
190mem_dbg.o: ../include/openssl/e_os2.h ../include/openssl/err.h 198mem_dbg.o: ../include/openssl/err.h ../include/openssl/lhash.h
191mem_dbg.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h 199mem_dbg.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
192mem_dbg.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h 200mem_dbg.o: ../include/openssl/safestack.h ../include/openssl/stack.h
193mem_dbg.o: ../include/openssl/stack.h ../include/openssl/symhacks.h cryptlib.h 201mem_dbg.o: ../include/openssl/symhacks.h cryptlib.h mem_dbg.c
194tmdiff.o: ../include/openssl/bio.h ../include/openssl/buffer.h 202o_time.o: ../include/openssl/e_os2.h ../include/openssl/opensslconf.h o_time.c
195tmdiff.o: ../include/openssl/crypto.h ../include/openssl/e_os.h 203o_time.o: o_time.h
196tmdiff.o: ../include/openssl/e_os2.h ../include/openssl/err.h 204tmdiff.o: ../e_os.h ../include/openssl/bio.h ../include/openssl/buffer.h
197tmdiff.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h 205tmdiff.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
198tmdiff.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h 206tmdiff.o: ../include/openssl/err.h ../include/openssl/lhash.h
199tmdiff.o: ../include/openssl/stack.h ../include/openssl/symhacks.h 207tmdiff.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
200tmdiff.o: ../include/openssl/tmdiff.h cryptlib.h 208tmdiff.o: ../include/openssl/safestack.h ../include/openssl/stack.h
201uid.o: ../include/openssl/crypto.h ../include/openssl/opensslv.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
202uid.o: ../include/openssl/safestack.h ../include/openssl/stack.h 213uid.o: ../include/openssl/safestack.h ../include/openssl/stack.h
203uid.o: ../include/openssl/symhacks.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..c189ce0824
--- /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 @$(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) $(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/README b/src/lib/libcrypto/aes/README
new file mode 100644
index 0000000000..0f9620a80e
--- /dev/null
+++ b/src/lib/libcrypto/aes/README
@@ -0,0 +1,3 @@
1This is an OpenSSL-compatible version of AES (also called Rijndael).
2aes_core.c is basically the same as rijndael-alg-fst.c but with an
3API that looks like the rest of the OpenSSL symmetric cipher suite.
diff --git a/src/lib/libcrypto/aes/aes.h b/src/lib/libcrypto/aes/aes.h
new file mode 100644
index 0000000000..e8da921ec5
--- /dev/null
+++ b/src/lib/libcrypto/aes/aes.h
@@ -0,0 +1,109 @@
1/* crypto/aes/aes.h -*- mode:C; c-file-style: "eay" -*- */
2/* ====================================================================
3 * Copyright (c) 1998-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 */
51
52#ifndef HEADER_AES_H
53#define HEADER_AES_H
54
55#ifdef OPENSSL_NO_AES
56#error AES is disabled.
57#endif
58
59static const int AES_DECRYPT = 0;
60static const int AES_ENCRYPT = 1;
61/* Because array size can't be a const in C, the following two are macros.
62 Both sizes are in bytes. */
63#define AES_MAXNR 14
64#define AES_BLOCK_SIZE 16
65
66#ifdef __cplusplus
67extern "C" {
68#endif
69
70/* This should be a hidden type, but EVP requires that the size be known */
71struct aes_key_st {
72 unsigned long rd_key[4 *(AES_MAXNR + 1)];
73 int rounds;
74};
75typedef struct aes_key_st AES_KEY;
76
77const char *AES_options(void);
78
79int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
80 AES_KEY *key);
81int AES_set_decrypt_key(const unsigned char *userKey, const int bits,
82 AES_KEY *key);
83
84void AES_encrypt(const unsigned char *in, unsigned char *out,
85 const AES_KEY *key);
86void AES_decrypt(const unsigned char *in, unsigned char *out,
87 const AES_KEY *key);
88
89void AES_ecb_encrypt(const unsigned char *in, unsigned char *out,
90 const AES_KEY *key, const int enc);
91void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
92 const unsigned long length, const AES_KEY *key,
93 unsigned char *ivec, const int enc);
94void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out,
95 const unsigned long length, const AES_KEY *key,
96 unsigned char *ivec, int *num, const int enc);
97void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out,
98 const unsigned long length, const AES_KEY *key,
99 unsigned char *ivec, int *num);
100void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out,
101 const unsigned long length, const AES_KEY *key,
102 unsigned char *counter, unsigned int *num);
103
104
105#ifdef __cplusplus
106}
107#endif
108
109#endif /* !HEADER_AES_H */
diff --git a/src/lib/libcrypto/aes/aes_cbc.c b/src/lib/libcrypto/aes/aes_cbc.c
new file mode 100644
index 0000000000..3dfd7aba2a
--- /dev/null
+++ b/src/lib/libcrypto/aes/aes_cbc.c
@@ -0,0 +1,89 @@
1/* crypto/aes/aes_cbc.c -*- mode:C; c-file-style: "eay" -*- */
2/* ====================================================================
3 * Copyright (c) 1998-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 */
51
52#include <assert.h>
53#include <openssl/aes.h>
54#include "aes_locl.h"
55
56void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
57 const unsigned long length, const AES_KEY *key,
58 unsigned char *ivec, const int enc) {
59
60 int n;
61 unsigned long len = length;
62 unsigned char tmp[16];
63
64 assert(in && out && key && ivec);
65 assert(length % AES_BLOCK_SIZE == 0);
66 assert((AES_ENCRYPT == enc)||(AES_DECRYPT == enc));
67
68 if (AES_ENCRYPT == enc)
69 while (len > 0) {
70 for(n=0; n < 16; ++n)
71 tmp[n] = in[n] ^ ivec[n];
72 AES_encrypt(tmp, out, key);
73 memcpy(ivec, out, 16);
74 len -= 16;
75 in += 16;
76 out += 16;
77 }
78 else
79 while (len > 0) {
80 memcpy(tmp, in, 16);
81 AES_decrypt(in, out, key);
82 for(n=0; n < 16; ++n)
83 out[n] ^= ivec[n];
84 memcpy(ivec, tmp, 16);
85 len -= 16;
86 in += 16;
87 out += 16;
88 }
89}
diff --git a/src/lib/libcrypto/aes/aes_cfb.c b/src/lib/libcrypto/aes/aes_cfb.c
new file mode 100644
index 0000000000..9b2917298a
--- /dev/null
+++ b/src/lib/libcrypto/aes/aes_cfb.c
@@ -0,0 +1,151 @@
1/* crypto/aes/aes_cfb.c -*- mode:C; c-file-style: "eay" -*- */
2/* ====================================================================
3 * Copyright (c) 1998-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 */
51/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
52 * All rights reserved.
53 *
54 * This package is an SSL implementation written
55 * by Eric Young (eay@cryptsoft.com).
56 * The implementation was written so as to conform with Netscapes SSL.
57 *
58 * This library is free for commercial and non-commercial use as long as
59 * the following conditions are aheared to. The following conditions
60 * apply to all code found in this distribution, be it the RC4, RSA,
61 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
62 * included with this distribution is covered by the same copyright terms
63 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
64 *
65 * Copyright remains Eric Young's, and as such any Copyright notices in
66 * the code are not to be removed.
67 * If this package is used in a product, Eric Young should be given attribution
68 * as the author of the parts of the library used.
69 * This can be in the form of a textual message at program startup or
70 * in documentation (online or textual) provided with the package.
71 *
72 * Redistribution and use in source and binary forms, with or without
73 * modification, are permitted provided that the following conditions
74 * are met:
75 * 1. Redistributions of source code must retain the copyright
76 * notice, this list of conditions and the following disclaimer.
77 * 2. Redistributions in binary form must reproduce the above copyright
78 * notice, this list of conditions and the following disclaimer in the
79 * documentation and/or other materials provided with the distribution.
80 * 3. All advertising materials mentioning features or use of this software
81 * must display the following acknowledgement:
82 * "This product includes cryptographic software written by
83 * Eric Young (eay@cryptsoft.com)"
84 * The word 'cryptographic' can be left out if the rouines from the library
85 * being used are not cryptographic related :-).
86 * 4. If you include any Windows specific code (or a derivative thereof) from
87 * the apps directory (application code) you must include an acknowledgement:
88 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
89 *
90 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
91 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
92 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
93 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
94 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
95 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
96 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
97 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
98 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
99 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
100 * SUCH DAMAGE.
101 *
102 * The licence and distribution terms for any publically available version or
103 * derivative of this code cannot be changed. i.e. this code cannot simply be
104 * copied and put under another distribution licence
105 * [including the GNU Public Licence.]
106 */
107
108#include <assert.h>
109#include <openssl/aes.h>
110#include "aes_locl.h"
111
112/* The input and output encrypted as though 128bit cfb mode is being
113 * used. The extra state information to record how much of the
114 * 128bit block we have used is contained in *num;
115 */
116
117void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out,
118 const unsigned long length, const AES_KEY *key,
119 unsigned char *ivec, int *num, const int enc) {
120
121 unsigned int n;
122 unsigned long l = length;
123 unsigned char c;
124
125 assert(in && out && key && ivec && num);
126
127 n = *num;
128
129 if (enc) {
130 while (l--) {
131 if (n == 0) {
132 AES_encrypt(ivec, ivec, key);
133 }
134 ivec[n] = *(out++) = *(in++) ^ ivec[n];
135 n = (n+1) % AES_BLOCK_SIZE;
136 }
137 } else {
138 while (l--) {
139 if (n == 0) {
140 AES_decrypt(ivec, ivec, key);
141 }
142 c = *(in);
143 *(out++) = *(in++) ^ ivec[n];
144 ivec[n] = c;
145 n = (n+1) % AES_BLOCK_SIZE;
146 }
147 }
148
149 *num=n;
150}
151
diff --git a/src/lib/libcrypto/aes/aes_core.c b/src/lib/libcrypto/aes/aes_core.c
new file mode 100644
index 0000000000..937988dd8c
--- /dev/null
+++ b/src/lib/libcrypto/aes/aes_core.c
@@ -0,0 +1,1251 @@
1/* crypto/aes/aes_core.c -*- mode:C; c-file-style: "eay" -*- */
2/**
3 * rijndael-alg-fst.c
4 *
5 * @version 3.0 (December 2000)
6 *
7 * Optimised ANSI C code for the Rijndael cipher (now AES)
8 *
9 * @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be>
10 * @author Antoon Bosselaers <antoon.bosselaers@esat.kuleuven.ac.be>
11 * @author Paulo Barreto <paulo.barreto@terra.com.br>
12 *
13 * This code is hereby placed in the public domain.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS
16 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
22 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
24 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
25 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28/* Note: rewritten a little bit to provide error control and an OpenSSL-
29 compatible API */
30
31#include <assert.h>
32#include <stdlib.h>
33#include <openssl/aes.h>
34#include "aes_locl.h"
35
36/*
37Te0[x] = S [x].[02, 01, 01, 03];
38Te1[x] = S [x].[03, 02, 01, 01];
39Te2[x] = S [x].[01, 03, 02, 01];
40Te3[x] = S [x].[01, 01, 03, 02];
41Te4[x] = S [x].[01, 01, 01, 01];
42
43Td0[x] = Si[x].[0e, 09, 0d, 0b];
44Td1[x] = Si[x].[0b, 0e, 09, 0d];
45Td2[x] = Si[x].[0d, 0b, 0e, 09];
46Td3[x] = Si[x].[09, 0d, 0b, 0e];
47Td4[x] = Si[x].[01, 01, 01, 01];
48*/
49
50static const u32 Te0[256] = {
51 0xc66363a5U, 0xf87c7c84U, 0xee777799U, 0xf67b7b8dU,
52 0xfff2f20dU, 0xd66b6bbdU, 0xde6f6fb1U, 0x91c5c554U,
53 0x60303050U, 0x02010103U, 0xce6767a9U, 0x562b2b7dU,
54 0xe7fefe19U, 0xb5d7d762U, 0x4dababe6U, 0xec76769aU,
55 0x8fcaca45U, 0x1f82829dU, 0x89c9c940U, 0xfa7d7d87U,
56 0xeffafa15U, 0xb25959ebU, 0x8e4747c9U, 0xfbf0f00bU,
57 0x41adadecU, 0xb3d4d467U, 0x5fa2a2fdU, 0x45afafeaU,
58 0x239c9cbfU, 0x53a4a4f7U, 0xe4727296U, 0x9bc0c05bU,
59 0x75b7b7c2U, 0xe1fdfd1cU, 0x3d9393aeU, 0x4c26266aU,
60 0x6c36365aU, 0x7e3f3f41U, 0xf5f7f702U, 0x83cccc4fU,
61 0x6834345cU, 0x51a5a5f4U, 0xd1e5e534U, 0xf9f1f108U,
62 0xe2717193U, 0xabd8d873U, 0x62313153U, 0x2a15153fU,
63 0x0804040cU, 0x95c7c752U, 0x46232365U, 0x9dc3c35eU,
64 0x30181828U, 0x379696a1U, 0x0a05050fU, 0x2f9a9ab5U,
65 0x0e070709U, 0x24121236U, 0x1b80809bU, 0xdfe2e23dU,
66 0xcdebeb26U, 0x4e272769U, 0x7fb2b2cdU, 0xea75759fU,
67 0x1209091bU, 0x1d83839eU, 0x582c2c74U, 0x341a1a2eU,
68 0x361b1b2dU, 0xdc6e6eb2U, 0xb45a5aeeU, 0x5ba0a0fbU,
69 0xa45252f6U, 0x763b3b4dU, 0xb7d6d661U, 0x7db3b3ceU,
70 0x5229297bU, 0xdde3e33eU, 0x5e2f2f71U, 0x13848497U,
71 0xa65353f5U, 0xb9d1d168U, 0x00000000U, 0xc1eded2cU,
72 0x40202060U, 0xe3fcfc1fU, 0x79b1b1c8U, 0xb65b5bedU,
73 0xd46a6abeU, 0x8dcbcb46U, 0x67bebed9U, 0x7239394bU,
74 0x944a4adeU, 0x984c4cd4U, 0xb05858e8U, 0x85cfcf4aU,
75 0xbbd0d06bU, 0xc5efef2aU, 0x4faaaae5U, 0xedfbfb16U,
76 0x864343c5U, 0x9a4d4dd7U, 0x66333355U, 0x11858594U,
77 0x8a4545cfU, 0xe9f9f910U, 0x04020206U, 0xfe7f7f81U,
78 0xa05050f0U, 0x783c3c44U, 0x259f9fbaU, 0x4ba8a8e3U,
79 0xa25151f3U, 0x5da3a3feU, 0x804040c0U, 0x058f8f8aU,
80 0x3f9292adU, 0x219d9dbcU, 0x70383848U, 0xf1f5f504U,
81 0x63bcbcdfU, 0x77b6b6c1U, 0xafdada75U, 0x42212163U,
82 0x20101030U, 0xe5ffff1aU, 0xfdf3f30eU, 0xbfd2d26dU,
83 0x81cdcd4cU, 0x180c0c14U, 0x26131335U, 0xc3ecec2fU,
84 0xbe5f5fe1U, 0x359797a2U, 0x884444ccU, 0x2e171739U,
85 0x93c4c457U, 0x55a7a7f2U, 0xfc7e7e82U, 0x7a3d3d47U,
86 0xc86464acU, 0xba5d5de7U, 0x3219192bU, 0xe6737395U,
87 0xc06060a0U, 0x19818198U, 0x9e4f4fd1U, 0xa3dcdc7fU,
88 0x44222266U, 0x542a2a7eU, 0x3b9090abU, 0x0b888883U,
89 0x8c4646caU, 0xc7eeee29U, 0x6bb8b8d3U, 0x2814143cU,
90 0xa7dede79U, 0xbc5e5ee2U, 0x160b0b1dU, 0xaddbdb76U,
91 0xdbe0e03bU, 0x64323256U, 0x743a3a4eU, 0x140a0a1eU,
92 0x924949dbU, 0x0c06060aU, 0x4824246cU, 0xb85c5ce4U,
93 0x9fc2c25dU, 0xbdd3d36eU, 0x43acacefU, 0xc46262a6U,
94 0x399191a8U, 0x319595a4U, 0xd3e4e437U, 0xf279798bU,
95 0xd5e7e732U, 0x8bc8c843U, 0x6e373759U, 0xda6d6db7U,
96 0x018d8d8cU, 0xb1d5d564U, 0x9c4e4ed2U, 0x49a9a9e0U,
97 0xd86c6cb4U, 0xac5656faU, 0xf3f4f407U, 0xcfeaea25U,
98 0xca6565afU, 0xf47a7a8eU, 0x47aeaee9U, 0x10080818U,
99 0x6fbabad5U, 0xf0787888U, 0x4a25256fU, 0x5c2e2e72U,
100 0x381c1c24U, 0x57a6a6f1U, 0x73b4b4c7U, 0x97c6c651U,
101 0xcbe8e823U, 0xa1dddd7cU, 0xe874749cU, 0x3e1f1f21U,
102 0x964b4bddU, 0x61bdbddcU, 0x0d8b8b86U, 0x0f8a8a85U,
103 0xe0707090U, 0x7c3e3e42U, 0x71b5b5c4U, 0xcc6666aaU,
104 0x904848d8U, 0x06030305U, 0xf7f6f601U, 0x1c0e0e12U,
105 0xc26161a3U, 0x6a35355fU, 0xae5757f9U, 0x69b9b9d0U,
106 0x17868691U, 0x99c1c158U, 0x3a1d1d27U, 0x279e9eb9U,
107 0xd9e1e138U, 0xebf8f813U, 0x2b9898b3U, 0x22111133U,
108 0xd26969bbU, 0xa9d9d970U, 0x078e8e89U, 0x339494a7U,
109 0x2d9b9bb6U, 0x3c1e1e22U, 0x15878792U, 0xc9e9e920U,
110 0x87cece49U, 0xaa5555ffU, 0x50282878U, 0xa5dfdf7aU,
111 0x038c8c8fU, 0x59a1a1f8U, 0x09898980U, 0x1a0d0d17U,
112 0x65bfbfdaU, 0xd7e6e631U, 0x844242c6U, 0xd06868b8U,
113 0x824141c3U, 0x299999b0U, 0x5a2d2d77U, 0x1e0f0f11U,
114 0x7bb0b0cbU, 0xa85454fcU, 0x6dbbbbd6U, 0x2c16163aU,
115};
116static const u32 Te1[256] = {
117 0xa5c66363U, 0x84f87c7cU, 0x99ee7777U, 0x8df67b7bU,
118 0x0dfff2f2U, 0xbdd66b6bU, 0xb1de6f6fU, 0x5491c5c5U,
119 0x50603030U, 0x03020101U, 0xa9ce6767U, 0x7d562b2bU,
120 0x19e7fefeU, 0x62b5d7d7U, 0xe64dababU, 0x9aec7676U,
121 0x458fcacaU, 0x9d1f8282U, 0x4089c9c9U, 0x87fa7d7dU,
122 0x15effafaU, 0xebb25959U, 0xc98e4747U, 0x0bfbf0f0U,
123 0xec41adadU, 0x67b3d4d4U, 0xfd5fa2a2U, 0xea45afafU,
124 0xbf239c9cU, 0xf753a4a4U, 0x96e47272U, 0x5b9bc0c0U,
125 0xc275b7b7U, 0x1ce1fdfdU, 0xae3d9393U, 0x6a4c2626U,
126 0x5a6c3636U, 0x417e3f3fU, 0x02f5f7f7U, 0x4f83ccccU,
127 0x5c683434U, 0xf451a5a5U, 0x34d1e5e5U, 0x08f9f1f1U,
128 0x93e27171U, 0x73abd8d8U, 0x53623131U, 0x3f2a1515U,
129 0x0c080404U, 0x5295c7c7U, 0x65462323U, 0x5e9dc3c3U,
130 0x28301818U, 0xa1379696U, 0x0f0a0505U, 0xb52f9a9aU,
131 0x090e0707U, 0x36241212U, 0x9b1b8080U, 0x3ddfe2e2U,
132 0x26cdebebU, 0x694e2727U, 0xcd7fb2b2U, 0x9fea7575U,
133 0x1b120909U, 0x9e1d8383U, 0x74582c2cU, 0x2e341a1aU,
134 0x2d361b1bU, 0xb2dc6e6eU, 0xeeb45a5aU, 0xfb5ba0a0U,
135 0xf6a45252U, 0x4d763b3bU, 0x61b7d6d6U, 0xce7db3b3U,
136 0x7b522929U, 0x3edde3e3U, 0x715e2f2fU, 0x97138484U,
137 0xf5a65353U, 0x68b9d1d1U, 0x00000000U, 0x2cc1ededU,
138 0x60402020U, 0x1fe3fcfcU, 0xc879b1b1U, 0xedb65b5bU,
139 0xbed46a6aU, 0x468dcbcbU, 0xd967bebeU, 0x4b723939U,
140 0xde944a4aU, 0xd4984c4cU, 0xe8b05858U, 0x4a85cfcfU,
141 0x6bbbd0d0U, 0x2ac5efefU, 0xe54faaaaU, 0x16edfbfbU,
142 0xc5864343U, 0xd79a4d4dU, 0x55663333U, 0x94118585U,
143 0xcf8a4545U, 0x10e9f9f9U, 0x06040202U, 0x81fe7f7fU,
144 0xf0a05050U, 0x44783c3cU, 0xba259f9fU, 0xe34ba8a8U,
145 0xf3a25151U, 0xfe5da3a3U, 0xc0804040U, 0x8a058f8fU,
146 0xad3f9292U, 0xbc219d9dU, 0x48703838U, 0x04f1f5f5U,
147 0xdf63bcbcU, 0xc177b6b6U, 0x75afdadaU, 0x63422121U,
148 0x30201010U, 0x1ae5ffffU, 0x0efdf3f3U, 0x6dbfd2d2U,
149 0x4c81cdcdU, 0x14180c0cU, 0x35261313U, 0x2fc3ececU,
150 0xe1be5f5fU, 0xa2359797U, 0xcc884444U, 0x392e1717U,
151 0x5793c4c4U, 0xf255a7a7U, 0x82fc7e7eU, 0x477a3d3dU,
152 0xacc86464U, 0xe7ba5d5dU, 0x2b321919U, 0x95e67373U,
153 0xa0c06060U, 0x98198181U, 0xd19e4f4fU, 0x7fa3dcdcU,
154 0x66442222U, 0x7e542a2aU, 0xab3b9090U, 0x830b8888U,
155 0xca8c4646U, 0x29c7eeeeU, 0xd36bb8b8U, 0x3c281414U,
156 0x79a7dedeU, 0xe2bc5e5eU, 0x1d160b0bU, 0x76addbdbU,
157 0x3bdbe0e0U, 0x56643232U, 0x4e743a3aU, 0x1e140a0aU,
158 0xdb924949U, 0x0a0c0606U, 0x6c482424U, 0xe4b85c5cU,
159 0x5d9fc2c2U, 0x6ebdd3d3U, 0xef43acacU, 0xa6c46262U,
160 0xa8399191U, 0xa4319595U, 0x37d3e4e4U, 0x8bf27979U,
161 0x32d5e7e7U, 0x438bc8c8U, 0x596e3737U, 0xb7da6d6dU,
162 0x8c018d8dU, 0x64b1d5d5U, 0xd29c4e4eU, 0xe049a9a9U,
163 0xb4d86c6cU, 0xfaac5656U, 0x07f3f4f4U, 0x25cfeaeaU,
164 0xafca6565U, 0x8ef47a7aU, 0xe947aeaeU, 0x18100808U,
165 0xd56fbabaU, 0x88f07878U, 0x6f4a2525U, 0x725c2e2eU,
166 0x24381c1cU, 0xf157a6a6U, 0xc773b4b4U, 0x5197c6c6U,
167 0x23cbe8e8U, 0x7ca1ddddU, 0x9ce87474U, 0x213e1f1fU,
168 0xdd964b4bU, 0xdc61bdbdU, 0x860d8b8bU, 0x850f8a8aU,
169 0x90e07070U, 0x427c3e3eU, 0xc471b5b5U, 0xaacc6666U,
170 0xd8904848U, 0x05060303U, 0x01f7f6f6U, 0x121c0e0eU,
171 0xa3c26161U, 0x5f6a3535U, 0xf9ae5757U, 0xd069b9b9U,
172 0x91178686U, 0x5899c1c1U, 0x273a1d1dU, 0xb9279e9eU,
173 0x38d9e1e1U, 0x13ebf8f8U, 0xb32b9898U, 0x33221111U,
174 0xbbd26969U, 0x70a9d9d9U, 0x89078e8eU, 0xa7339494U,
175 0xb62d9b9bU, 0x223c1e1eU, 0x92158787U, 0x20c9e9e9U,
176 0x4987ceceU, 0xffaa5555U, 0x78502828U, 0x7aa5dfdfU,
177 0x8f038c8cU, 0xf859a1a1U, 0x80098989U, 0x171a0d0dU,
178 0xda65bfbfU, 0x31d7e6e6U, 0xc6844242U, 0xb8d06868U,
179 0xc3824141U, 0xb0299999U, 0x775a2d2dU, 0x111e0f0fU,
180 0xcb7bb0b0U, 0xfca85454U, 0xd66dbbbbU, 0x3a2c1616U,
181};
182static const u32 Te2[256] = {
183 0x63a5c663U, 0x7c84f87cU, 0x7799ee77U, 0x7b8df67bU,
184 0xf20dfff2U, 0x6bbdd66bU, 0x6fb1de6fU, 0xc55491c5U,
185 0x30506030U, 0x01030201U, 0x67a9ce67U, 0x2b7d562bU,
186 0xfe19e7feU, 0xd762b5d7U, 0xabe64dabU, 0x769aec76U,
187 0xca458fcaU, 0x829d1f82U, 0xc94089c9U, 0x7d87fa7dU,
188 0xfa15effaU, 0x59ebb259U, 0x47c98e47U, 0xf00bfbf0U,
189 0xadec41adU, 0xd467b3d4U, 0xa2fd5fa2U, 0xafea45afU,
190 0x9cbf239cU, 0xa4f753a4U, 0x7296e472U, 0xc05b9bc0U,
191 0xb7c275b7U, 0xfd1ce1fdU, 0x93ae3d93U, 0x266a4c26U,
192 0x365a6c36U, 0x3f417e3fU, 0xf702f5f7U, 0xcc4f83ccU,
193 0x345c6834U, 0xa5f451a5U, 0xe534d1e5U, 0xf108f9f1U,
194 0x7193e271U, 0xd873abd8U, 0x31536231U, 0x153f2a15U,
195 0x040c0804U, 0xc75295c7U, 0x23654623U, 0xc35e9dc3U,
196 0x18283018U, 0x96a13796U, 0x050f0a05U, 0x9ab52f9aU,
197 0x07090e07U, 0x12362412U, 0x809b1b80U, 0xe23ddfe2U,
198 0xeb26cdebU, 0x27694e27U, 0xb2cd7fb2U, 0x759fea75U,
199 0x091b1209U, 0x839e1d83U, 0x2c74582cU, 0x1a2e341aU,
200 0x1b2d361bU, 0x6eb2dc6eU, 0x5aeeb45aU, 0xa0fb5ba0U,
201 0x52f6a452U, 0x3b4d763bU, 0xd661b7d6U, 0xb3ce7db3U,
202 0x297b5229U, 0xe33edde3U, 0x2f715e2fU, 0x84971384U,
203 0x53f5a653U, 0xd168b9d1U, 0x00000000U, 0xed2cc1edU,
204 0x20604020U, 0xfc1fe3fcU, 0xb1c879b1U, 0x5bedb65bU,
205 0x6abed46aU, 0xcb468dcbU, 0xbed967beU, 0x394b7239U,
206 0x4ade944aU, 0x4cd4984cU, 0x58e8b058U, 0xcf4a85cfU,
207 0xd06bbbd0U, 0xef2ac5efU, 0xaae54faaU, 0xfb16edfbU,
208 0x43c58643U, 0x4dd79a4dU, 0x33556633U, 0x85941185U,
209 0x45cf8a45U, 0xf910e9f9U, 0x02060402U, 0x7f81fe7fU,
210 0x50f0a050U, 0x3c44783cU, 0x9fba259fU, 0xa8e34ba8U,
211 0x51f3a251U, 0xa3fe5da3U, 0x40c08040U, 0x8f8a058fU,
212 0x92ad3f92U, 0x9dbc219dU, 0x38487038U, 0xf504f1f5U,
213 0xbcdf63bcU, 0xb6c177b6U, 0xda75afdaU, 0x21634221U,
214 0x10302010U, 0xff1ae5ffU, 0xf30efdf3U, 0xd26dbfd2U,
215 0xcd4c81cdU, 0x0c14180cU, 0x13352613U, 0xec2fc3ecU,
216 0x5fe1be5fU, 0x97a23597U, 0x44cc8844U, 0x17392e17U,
217 0xc45793c4U, 0xa7f255a7U, 0x7e82fc7eU, 0x3d477a3dU,
218 0x64acc864U, 0x5de7ba5dU, 0x192b3219U, 0x7395e673U,
219 0x60a0c060U, 0x81981981U, 0x4fd19e4fU, 0xdc7fa3dcU,
220 0x22664422U, 0x2a7e542aU, 0x90ab3b90U, 0x88830b88U,
221 0x46ca8c46U, 0xee29c7eeU, 0xb8d36bb8U, 0x143c2814U,
222 0xde79a7deU, 0x5ee2bc5eU, 0x0b1d160bU, 0xdb76addbU,
223 0xe03bdbe0U, 0x32566432U, 0x3a4e743aU, 0x0a1e140aU,
224 0x49db9249U, 0x060a0c06U, 0x246c4824U, 0x5ce4b85cU,
225 0xc25d9fc2U, 0xd36ebdd3U, 0xacef43acU, 0x62a6c462U,
226 0x91a83991U, 0x95a43195U, 0xe437d3e4U, 0x798bf279U,
227 0xe732d5e7U, 0xc8438bc8U, 0x37596e37U, 0x6db7da6dU,
228 0x8d8c018dU, 0xd564b1d5U, 0x4ed29c4eU, 0xa9e049a9U,
229 0x6cb4d86cU, 0x56faac56U, 0xf407f3f4U, 0xea25cfeaU,
230 0x65afca65U, 0x7a8ef47aU, 0xaee947aeU, 0x08181008U,
231 0xbad56fbaU, 0x7888f078U, 0x256f4a25U, 0x2e725c2eU,
232 0x1c24381cU, 0xa6f157a6U, 0xb4c773b4U, 0xc65197c6U,
233 0xe823cbe8U, 0xdd7ca1ddU, 0x749ce874U, 0x1f213e1fU,
234 0x4bdd964bU, 0xbddc61bdU, 0x8b860d8bU, 0x8a850f8aU,
235 0x7090e070U, 0x3e427c3eU, 0xb5c471b5U, 0x66aacc66U,
236 0x48d89048U, 0x03050603U, 0xf601f7f6U, 0x0e121c0eU,
237 0x61a3c261U, 0x355f6a35U, 0x57f9ae57U, 0xb9d069b9U,
238 0x86911786U, 0xc15899c1U, 0x1d273a1dU, 0x9eb9279eU,
239 0xe138d9e1U, 0xf813ebf8U, 0x98b32b98U, 0x11332211U,
240 0x69bbd269U, 0xd970a9d9U, 0x8e89078eU, 0x94a73394U,
241 0x9bb62d9bU, 0x1e223c1eU, 0x87921587U, 0xe920c9e9U,
242 0xce4987ceU, 0x55ffaa55U, 0x28785028U, 0xdf7aa5dfU,
243 0x8c8f038cU, 0xa1f859a1U, 0x89800989U, 0x0d171a0dU,
244 0xbfda65bfU, 0xe631d7e6U, 0x42c68442U, 0x68b8d068U,
245 0x41c38241U, 0x99b02999U, 0x2d775a2dU, 0x0f111e0fU,
246 0xb0cb7bb0U, 0x54fca854U, 0xbbd66dbbU, 0x163a2c16U,
247};
248static const u32 Te3[256] = {
249
250 0x6363a5c6U, 0x7c7c84f8U, 0x777799eeU, 0x7b7b8df6U,
251 0xf2f20dffU, 0x6b6bbdd6U, 0x6f6fb1deU, 0xc5c55491U,
252 0x30305060U, 0x01010302U, 0x6767a9ceU, 0x2b2b7d56U,
253 0xfefe19e7U, 0xd7d762b5U, 0xababe64dU, 0x76769aecU,
254 0xcaca458fU, 0x82829d1fU, 0xc9c94089U, 0x7d7d87faU,
255 0xfafa15efU, 0x5959ebb2U, 0x4747c98eU, 0xf0f00bfbU,
256 0xadadec41U, 0xd4d467b3U, 0xa2a2fd5fU, 0xafafea45U,
257 0x9c9cbf23U, 0xa4a4f753U, 0x727296e4U, 0xc0c05b9bU,
258 0xb7b7c275U, 0xfdfd1ce1U, 0x9393ae3dU, 0x26266a4cU,
259 0x36365a6cU, 0x3f3f417eU, 0xf7f702f5U, 0xcccc4f83U,
260 0x34345c68U, 0xa5a5f451U, 0xe5e534d1U, 0xf1f108f9U,
261 0x717193e2U, 0xd8d873abU, 0x31315362U, 0x15153f2aU,
262 0x04040c08U, 0xc7c75295U, 0x23236546U, 0xc3c35e9dU,
263 0x18182830U, 0x9696a137U, 0x05050f0aU, 0x9a9ab52fU,
264 0x0707090eU, 0x12123624U, 0x80809b1bU, 0xe2e23ddfU,
265 0xebeb26cdU, 0x2727694eU, 0xb2b2cd7fU, 0x75759feaU,
266 0x09091b12U, 0x83839e1dU, 0x2c2c7458U, 0x1a1a2e34U,
267 0x1b1b2d36U, 0x6e6eb2dcU, 0x5a5aeeb4U, 0xa0a0fb5bU,
268 0x5252f6a4U, 0x3b3b4d76U, 0xd6d661b7U, 0xb3b3ce7dU,
269 0x29297b52U, 0xe3e33eddU, 0x2f2f715eU, 0x84849713U,
270 0x5353f5a6U, 0xd1d168b9U, 0x00000000U, 0xeded2cc1U,
271 0x20206040U, 0xfcfc1fe3U, 0xb1b1c879U, 0x5b5bedb6U,
272 0x6a6abed4U, 0xcbcb468dU, 0xbebed967U, 0x39394b72U,
273 0x4a4ade94U, 0x4c4cd498U, 0x5858e8b0U, 0xcfcf4a85U,
274 0xd0d06bbbU, 0xefef2ac5U, 0xaaaae54fU, 0xfbfb16edU,
275 0x4343c586U, 0x4d4dd79aU, 0x33335566U, 0x85859411U,
276 0x4545cf8aU, 0xf9f910e9U, 0x02020604U, 0x7f7f81feU,
277 0x5050f0a0U, 0x3c3c4478U, 0x9f9fba25U, 0xa8a8e34bU,
278 0x5151f3a2U, 0xa3a3fe5dU, 0x4040c080U, 0x8f8f8a05U,
279 0x9292ad3fU, 0x9d9dbc21U, 0x38384870U, 0xf5f504f1U,
280 0xbcbcdf63U, 0xb6b6c177U, 0xdada75afU, 0x21216342U,
281 0x10103020U, 0xffff1ae5U, 0xf3f30efdU, 0xd2d26dbfU,
282 0xcdcd4c81U, 0x0c0c1418U, 0x13133526U, 0xecec2fc3U,
283 0x5f5fe1beU, 0x9797a235U, 0x4444cc88U, 0x1717392eU,
284 0xc4c45793U, 0xa7a7f255U, 0x7e7e82fcU, 0x3d3d477aU,
285 0x6464acc8U, 0x5d5de7baU, 0x19192b32U, 0x737395e6U,
286 0x6060a0c0U, 0x81819819U, 0x4f4fd19eU, 0xdcdc7fa3U,
287 0x22226644U, 0x2a2a7e54U, 0x9090ab3bU, 0x8888830bU,
288 0x4646ca8cU, 0xeeee29c7U, 0xb8b8d36bU, 0x14143c28U,
289 0xdede79a7U, 0x5e5ee2bcU, 0x0b0b1d16U, 0xdbdb76adU,
290 0xe0e03bdbU, 0x32325664U, 0x3a3a4e74U, 0x0a0a1e14U,
291 0x4949db92U, 0x06060a0cU, 0x24246c48U, 0x5c5ce4b8U,
292 0xc2c25d9fU, 0xd3d36ebdU, 0xacacef43U, 0x6262a6c4U,
293 0x9191a839U, 0x9595a431U, 0xe4e437d3U, 0x79798bf2U,
294 0xe7e732d5U, 0xc8c8438bU, 0x3737596eU, 0x6d6db7daU,
295 0x8d8d8c01U, 0xd5d564b1U, 0x4e4ed29cU, 0xa9a9e049U,
296 0x6c6cb4d8U, 0x5656faacU, 0xf4f407f3U, 0xeaea25cfU,
297 0x6565afcaU, 0x7a7a8ef4U, 0xaeaee947U, 0x08081810U,
298 0xbabad56fU, 0x787888f0U, 0x25256f4aU, 0x2e2e725cU,
299 0x1c1c2438U, 0xa6a6f157U, 0xb4b4c773U, 0xc6c65197U,
300 0xe8e823cbU, 0xdddd7ca1U, 0x74749ce8U, 0x1f1f213eU,
301 0x4b4bdd96U, 0xbdbddc61U, 0x8b8b860dU, 0x8a8a850fU,
302 0x707090e0U, 0x3e3e427cU, 0xb5b5c471U, 0x6666aaccU,
303 0x4848d890U, 0x03030506U, 0xf6f601f7U, 0x0e0e121cU,
304 0x6161a3c2U, 0x35355f6aU, 0x5757f9aeU, 0xb9b9d069U,
305 0x86869117U, 0xc1c15899U, 0x1d1d273aU, 0x9e9eb927U,
306 0xe1e138d9U, 0xf8f813ebU, 0x9898b32bU, 0x11113322U,
307 0x6969bbd2U, 0xd9d970a9U, 0x8e8e8907U, 0x9494a733U,
308 0x9b9bb62dU, 0x1e1e223cU, 0x87879215U, 0xe9e920c9U,
309 0xcece4987U, 0x5555ffaaU, 0x28287850U, 0xdfdf7aa5U,
310 0x8c8c8f03U, 0xa1a1f859U, 0x89898009U, 0x0d0d171aU,
311 0xbfbfda65U, 0xe6e631d7U, 0x4242c684U, 0x6868b8d0U,
312 0x4141c382U, 0x9999b029U, 0x2d2d775aU, 0x0f0f111eU,
313 0xb0b0cb7bU, 0x5454fca8U, 0xbbbbd66dU, 0x16163a2cU,
314};
315static const u32 Te4[256] = {
316 0x63636363U, 0x7c7c7c7cU, 0x77777777U, 0x7b7b7b7bU,
317 0xf2f2f2f2U, 0x6b6b6b6bU, 0x6f6f6f6fU, 0xc5c5c5c5U,
318 0x30303030U, 0x01010101U, 0x67676767U, 0x2b2b2b2bU,
319 0xfefefefeU, 0xd7d7d7d7U, 0xababababU, 0x76767676U,
320 0xcacacacaU, 0x82828282U, 0xc9c9c9c9U, 0x7d7d7d7dU,
321 0xfafafafaU, 0x59595959U, 0x47474747U, 0xf0f0f0f0U,
322 0xadadadadU, 0xd4d4d4d4U, 0xa2a2a2a2U, 0xafafafafU,
323 0x9c9c9c9cU, 0xa4a4a4a4U, 0x72727272U, 0xc0c0c0c0U,
324 0xb7b7b7b7U, 0xfdfdfdfdU, 0x93939393U, 0x26262626U,
325 0x36363636U, 0x3f3f3f3fU, 0xf7f7f7f7U, 0xccccccccU,
326 0x34343434U, 0xa5a5a5a5U, 0xe5e5e5e5U, 0xf1f1f1f1U,
327 0x71717171U, 0xd8d8d8d8U, 0x31313131U, 0x15151515U,
328 0x04040404U, 0xc7c7c7c7U, 0x23232323U, 0xc3c3c3c3U,
329 0x18181818U, 0x96969696U, 0x05050505U, 0x9a9a9a9aU,
330 0x07070707U, 0x12121212U, 0x80808080U, 0xe2e2e2e2U,
331 0xebebebebU, 0x27272727U, 0xb2b2b2b2U, 0x75757575U,
332 0x09090909U, 0x83838383U, 0x2c2c2c2cU, 0x1a1a1a1aU,
333 0x1b1b1b1bU, 0x6e6e6e6eU, 0x5a5a5a5aU, 0xa0a0a0a0U,
334 0x52525252U, 0x3b3b3b3bU, 0xd6d6d6d6U, 0xb3b3b3b3U,
335 0x29292929U, 0xe3e3e3e3U, 0x2f2f2f2fU, 0x84848484U,
336 0x53535353U, 0xd1d1d1d1U, 0x00000000U, 0xededededU,
337 0x20202020U, 0xfcfcfcfcU, 0xb1b1b1b1U, 0x5b5b5b5bU,
338 0x6a6a6a6aU, 0xcbcbcbcbU, 0xbebebebeU, 0x39393939U,
339 0x4a4a4a4aU, 0x4c4c4c4cU, 0x58585858U, 0xcfcfcfcfU,
340 0xd0d0d0d0U, 0xefefefefU, 0xaaaaaaaaU, 0xfbfbfbfbU,
341 0x43434343U, 0x4d4d4d4dU, 0x33333333U, 0x85858585U,
342 0x45454545U, 0xf9f9f9f9U, 0x02020202U, 0x7f7f7f7fU,
343 0x50505050U, 0x3c3c3c3cU, 0x9f9f9f9fU, 0xa8a8a8a8U,
344 0x51515151U, 0xa3a3a3a3U, 0x40404040U, 0x8f8f8f8fU,
345 0x92929292U, 0x9d9d9d9dU, 0x38383838U, 0xf5f5f5f5U,
346 0xbcbcbcbcU, 0xb6b6b6b6U, 0xdadadadaU, 0x21212121U,
347 0x10101010U, 0xffffffffU, 0xf3f3f3f3U, 0xd2d2d2d2U,
348 0xcdcdcdcdU, 0x0c0c0c0cU, 0x13131313U, 0xececececU,
349 0x5f5f5f5fU, 0x97979797U, 0x44444444U, 0x17171717U,
350 0xc4c4c4c4U, 0xa7a7a7a7U, 0x7e7e7e7eU, 0x3d3d3d3dU,
351 0x64646464U, 0x5d5d5d5dU, 0x19191919U, 0x73737373U,
352 0x60606060U, 0x81818181U, 0x4f4f4f4fU, 0xdcdcdcdcU,
353 0x22222222U, 0x2a2a2a2aU, 0x90909090U, 0x88888888U,
354 0x46464646U, 0xeeeeeeeeU, 0xb8b8b8b8U, 0x14141414U,
355 0xdedededeU, 0x5e5e5e5eU, 0x0b0b0b0bU, 0xdbdbdbdbU,
356 0xe0e0e0e0U, 0x32323232U, 0x3a3a3a3aU, 0x0a0a0a0aU,
357 0x49494949U, 0x06060606U, 0x24242424U, 0x5c5c5c5cU,
358 0xc2c2c2c2U, 0xd3d3d3d3U, 0xacacacacU, 0x62626262U,
359 0x91919191U, 0x95959595U, 0xe4e4e4e4U, 0x79797979U,
360 0xe7e7e7e7U, 0xc8c8c8c8U, 0x37373737U, 0x6d6d6d6dU,
361 0x8d8d8d8dU, 0xd5d5d5d5U, 0x4e4e4e4eU, 0xa9a9a9a9U,
362 0x6c6c6c6cU, 0x56565656U, 0xf4f4f4f4U, 0xeaeaeaeaU,
363 0x65656565U, 0x7a7a7a7aU, 0xaeaeaeaeU, 0x08080808U,
364 0xbabababaU, 0x78787878U, 0x25252525U, 0x2e2e2e2eU,
365 0x1c1c1c1cU, 0xa6a6a6a6U, 0xb4b4b4b4U, 0xc6c6c6c6U,
366 0xe8e8e8e8U, 0xddddddddU, 0x74747474U, 0x1f1f1f1fU,
367 0x4b4b4b4bU, 0xbdbdbdbdU, 0x8b8b8b8bU, 0x8a8a8a8aU,
368 0x70707070U, 0x3e3e3e3eU, 0xb5b5b5b5U, 0x66666666U,
369 0x48484848U, 0x03030303U, 0xf6f6f6f6U, 0x0e0e0e0eU,
370 0x61616161U, 0x35353535U, 0x57575757U, 0xb9b9b9b9U,
371 0x86868686U, 0xc1c1c1c1U, 0x1d1d1d1dU, 0x9e9e9e9eU,
372 0xe1e1e1e1U, 0xf8f8f8f8U, 0x98989898U, 0x11111111U,
373 0x69696969U, 0xd9d9d9d9U, 0x8e8e8e8eU, 0x94949494U,
374 0x9b9b9b9bU, 0x1e1e1e1eU, 0x87878787U, 0xe9e9e9e9U,
375 0xcecececeU, 0x55555555U, 0x28282828U, 0xdfdfdfdfU,
376 0x8c8c8c8cU, 0xa1a1a1a1U, 0x89898989U, 0x0d0d0d0dU,
377 0xbfbfbfbfU, 0xe6e6e6e6U, 0x42424242U, 0x68686868U,
378 0x41414141U, 0x99999999U, 0x2d2d2d2dU, 0x0f0f0f0fU,
379 0xb0b0b0b0U, 0x54545454U, 0xbbbbbbbbU, 0x16161616U,
380};
381static const u32 Td0[256] = {
382 0x51f4a750U, 0x7e416553U, 0x1a17a4c3U, 0x3a275e96U,
383 0x3bab6bcbU, 0x1f9d45f1U, 0xacfa58abU, 0x4be30393U,
384 0x2030fa55U, 0xad766df6U, 0x88cc7691U, 0xf5024c25U,
385 0x4fe5d7fcU, 0xc52acbd7U, 0x26354480U, 0xb562a38fU,
386 0xdeb15a49U, 0x25ba1b67U, 0x45ea0e98U, 0x5dfec0e1U,
387 0xc32f7502U, 0x814cf012U, 0x8d4697a3U, 0x6bd3f9c6U,
388 0x038f5fe7U, 0x15929c95U, 0xbf6d7aebU, 0x955259daU,
389 0xd4be832dU, 0x587421d3U, 0x49e06929U, 0x8ec9c844U,
390 0x75c2896aU, 0xf48e7978U, 0x99583e6bU, 0x27b971ddU,
391 0xbee14fb6U, 0xf088ad17U, 0xc920ac66U, 0x7dce3ab4U,
392 0x63df4a18U, 0xe51a3182U, 0x97513360U, 0x62537f45U,
393 0xb16477e0U, 0xbb6bae84U, 0xfe81a01cU, 0xf9082b94U,
394 0x70486858U, 0x8f45fd19U, 0x94de6c87U, 0x527bf8b7U,
395 0xab73d323U, 0x724b02e2U, 0xe31f8f57U, 0x6655ab2aU,
396 0xb2eb2807U, 0x2fb5c203U, 0x86c57b9aU, 0xd33708a5U,
397 0x302887f2U, 0x23bfa5b2U, 0x02036abaU, 0xed16825cU,
398 0x8acf1c2bU, 0xa779b492U, 0xf307f2f0U, 0x4e69e2a1U,
399 0x65daf4cdU, 0x0605bed5U, 0xd134621fU, 0xc4a6fe8aU,
400 0x342e539dU, 0xa2f355a0U, 0x058ae132U, 0xa4f6eb75U,
401 0x0b83ec39U, 0x4060efaaU, 0x5e719f06U, 0xbd6e1051U,
402 0x3e218af9U, 0x96dd063dU, 0xdd3e05aeU, 0x4de6bd46U,
403 0x91548db5U, 0x71c45d05U, 0x0406d46fU, 0x605015ffU,
404 0x1998fb24U, 0xd6bde997U, 0x894043ccU, 0x67d99e77U,
405 0xb0e842bdU, 0x07898b88U, 0xe7195b38U, 0x79c8eedbU,
406 0xa17c0a47U, 0x7c420fe9U, 0xf8841ec9U, 0x00000000U,
407 0x09808683U, 0x322bed48U, 0x1e1170acU, 0x6c5a724eU,
408 0xfd0efffbU, 0x0f853856U, 0x3daed51eU, 0x362d3927U,
409 0x0a0fd964U, 0x685ca621U, 0x9b5b54d1U, 0x24362e3aU,
410 0x0c0a67b1U, 0x9357e70fU, 0xb4ee96d2U, 0x1b9b919eU,
411 0x80c0c54fU, 0x61dc20a2U, 0x5a774b69U, 0x1c121a16U,
412 0xe293ba0aU, 0xc0a02ae5U, 0x3c22e043U, 0x121b171dU,
413 0x0e090d0bU, 0xf28bc7adU, 0x2db6a8b9U, 0x141ea9c8U,
414 0x57f11985U, 0xaf75074cU, 0xee99ddbbU, 0xa37f60fdU,
415 0xf701269fU, 0x5c72f5bcU, 0x44663bc5U, 0x5bfb7e34U,
416 0x8b432976U, 0xcb23c6dcU, 0xb6edfc68U, 0xb8e4f163U,
417 0xd731dccaU, 0x42638510U, 0x13972240U, 0x84c61120U,
418 0x854a247dU, 0xd2bb3df8U, 0xaef93211U, 0xc729a16dU,
419 0x1d9e2f4bU, 0xdcb230f3U, 0x0d8652ecU, 0x77c1e3d0U,
420 0x2bb3166cU, 0xa970b999U, 0x119448faU, 0x47e96422U,
421 0xa8fc8cc4U, 0xa0f03f1aU, 0x567d2cd8U, 0x223390efU,
422 0x87494ec7U, 0xd938d1c1U, 0x8ccaa2feU, 0x98d40b36U,
423 0xa6f581cfU, 0xa57ade28U, 0xdab78e26U, 0x3fadbfa4U,
424 0x2c3a9de4U, 0x5078920dU, 0x6a5fcc9bU, 0x547e4662U,
425 0xf68d13c2U, 0x90d8b8e8U, 0x2e39f75eU, 0x82c3aff5U,
426 0x9f5d80beU, 0x69d0937cU, 0x6fd52da9U, 0xcf2512b3U,
427 0xc8ac993bU, 0x10187da7U, 0xe89c636eU, 0xdb3bbb7bU,
428 0xcd267809U, 0x6e5918f4U, 0xec9ab701U, 0x834f9aa8U,
429 0xe6956e65U, 0xaaffe67eU, 0x21bccf08U, 0xef15e8e6U,
430 0xbae79bd9U, 0x4a6f36ceU, 0xea9f09d4U, 0x29b07cd6U,
431 0x31a4b2afU, 0x2a3f2331U, 0xc6a59430U, 0x35a266c0U,
432 0x744ebc37U, 0xfc82caa6U, 0xe090d0b0U, 0x33a7d815U,
433 0xf104984aU, 0x41ecdaf7U, 0x7fcd500eU, 0x1791f62fU,
434 0x764dd68dU, 0x43efb04dU, 0xccaa4d54U, 0xe49604dfU,
435 0x9ed1b5e3U, 0x4c6a881bU, 0xc12c1fb8U, 0x4665517fU,
436 0x9d5eea04U, 0x018c355dU, 0xfa877473U, 0xfb0b412eU,
437 0xb3671d5aU, 0x92dbd252U, 0xe9105633U, 0x6dd64713U,
438 0x9ad7618cU, 0x37a10c7aU, 0x59f8148eU, 0xeb133c89U,
439 0xcea927eeU, 0xb761c935U, 0xe11ce5edU, 0x7a47b13cU,
440 0x9cd2df59U, 0x55f2733fU, 0x1814ce79U, 0x73c737bfU,
441 0x53f7cdeaU, 0x5ffdaa5bU, 0xdf3d6f14U, 0x7844db86U,
442 0xcaaff381U, 0xb968c43eU, 0x3824342cU, 0xc2a3405fU,
443 0x161dc372U, 0xbce2250cU, 0x283c498bU, 0xff0d9541U,
444 0x39a80171U, 0x080cb3deU, 0xd8b4e49cU, 0x6456c190U,
445 0x7bcb8461U, 0xd532b670U, 0x486c5c74U, 0xd0b85742U,
446};
447static const u32 Td1[256] = {
448 0x5051f4a7U, 0x537e4165U, 0xc31a17a4U, 0x963a275eU,
449 0xcb3bab6bU, 0xf11f9d45U, 0xabacfa58U, 0x934be303U,
450 0x552030faU, 0xf6ad766dU, 0x9188cc76U, 0x25f5024cU,
451 0xfc4fe5d7U, 0xd7c52acbU, 0x80263544U, 0x8fb562a3U,
452 0x49deb15aU, 0x6725ba1bU, 0x9845ea0eU, 0xe15dfec0U,
453 0x02c32f75U, 0x12814cf0U, 0xa38d4697U, 0xc66bd3f9U,
454 0xe7038f5fU, 0x9515929cU, 0xebbf6d7aU, 0xda955259U,
455 0x2dd4be83U, 0xd3587421U, 0x2949e069U, 0x448ec9c8U,
456 0x6a75c289U, 0x78f48e79U, 0x6b99583eU, 0xdd27b971U,
457 0xb6bee14fU, 0x17f088adU, 0x66c920acU, 0xb47dce3aU,
458 0x1863df4aU, 0x82e51a31U, 0x60975133U, 0x4562537fU,
459 0xe0b16477U, 0x84bb6baeU, 0x1cfe81a0U, 0x94f9082bU,
460 0x58704868U, 0x198f45fdU, 0x8794de6cU, 0xb7527bf8U,
461 0x23ab73d3U, 0xe2724b02U, 0x57e31f8fU, 0x2a6655abU,
462 0x07b2eb28U, 0x032fb5c2U, 0x9a86c57bU, 0xa5d33708U,
463 0xf2302887U, 0xb223bfa5U, 0xba02036aU, 0x5ced1682U,
464 0x2b8acf1cU, 0x92a779b4U, 0xf0f307f2U, 0xa14e69e2U,
465 0xcd65daf4U, 0xd50605beU, 0x1fd13462U, 0x8ac4a6feU,
466 0x9d342e53U, 0xa0a2f355U, 0x32058ae1U, 0x75a4f6ebU,
467 0x390b83ecU, 0xaa4060efU, 0x065e719fU, 0x51bd6e10U,
468 0xf93e218aU, 0x3d96dd06U, 0xaedd3e05U, 0x464de6bdU,
469 0xb591548dU, 0x0571c45dU, 0x6f0406d4U, 0xff605015U,
470 0x241998fbU, 0x97d6bde9U, 0xcc894043U, 0x7767d99eU,
471 0xbdb0e842U, 0x8807898bU, 0x38e7195bU, 0xdb79c8eeU,
472 0x47a17c0aU, 0xe97c420fU, 0xc9f8841eU, 0x00000000U,
473 0x83098086U, 0x48322bedU, 0xac1e1170U, 0x4e6c5a72U,
474 0xfbfd0effU, 0x560f8538U, 0x1e3daed5U, 0x27362d39U,
475 0x640a0fd9U, 0x21685ca6U, 0xd19b5b54U, 0x3a24362eU,
476 0xb10c0a67U, 0x0f9357e7U, 0xd2b4ee96U, 0x9e1b9b91U,
477 0x4f80c0c5U, 0xa261dc20U, 0x695a774bU, 0x161c121aU,
478 0x0ae293baU, 0xe5c0a02aU, 0x433c22e0U, 0x1d121b17U,
479 0x0b0e090dU, 0xadf28bc7U, 0xb92db6a8U, 0xc8141ea9U,
480 0x8557f119U, 0x4caf7507U, 0xbbee99ddU, 0xfda37f60U,
481 0x9ff70126U, 0xbc5c72f5U, 0xc544663bU, 0x345bfb7eU,
482 0x768b4329U, 0xdccb23c6U, 0x68b6edfcU, 0x63b8e4f1U,
483 0xcad731dcU, 0x10426385U, 0x40139722U, 0x2084c611U,
484 0x7d854a24U, 0xf8d2bb3dU, 0x11aef932U, 0x6dc729a1U,
485 0x4b1d9e2fU, 0xf3dcb230U, 0xec0d8652U, 0xd077c1e3U,
486 0x6c2bb316U, 0x99a970b9U, 0xfa119448U, 0x2247e964U,
487 0xc4a8fc8cU, 0x1aa0f03fU, 0xd8567d2cU, 0xef223390U,
488 0xc787494eU, 0xc1d938d1U, 0xfe8ccaa2U, 0x3698d40bU,
489 0xcfa6f581U, 0x28a57adeU, 0x26dab78eU, 0xa43fadbfU,
490 0xe42c3a9dU, 0x0d507892U, 0x9b6a5fccU, 0x62547e46U,
491 0xc2f68d13U, 0xe890d8b8U, 0x5e2e39f7U, 0xf582c3afU,
492 0xbe9f5d80U, 0x7c69d093U, 0xa96fd52dU, 0xb3cf2512U,
493 0x3bc8ac99U, 0xa710187dU, 0x6ee89c63U, 0x7bdb3bbbU,
494 0x09cd2678U, 0xf46e5918U, 0x01ec9ab7U, 0xa8834f9aU,
495 0x65e6956eU, 0x7eaaffe6U, 0x0821bccfU, 0xe6ef15e8U,
496 0xd9bae79bU, 0xce4a6f36U, 0xd4ea9f09U, 0xd629b07cU,
497 0xaf31a4b2U, 0x312a3f23U, 0x30c6a594U, 0xc035a266U,
498 0x37744ebcU, 0xa6fc82caU, 0xb0e090d0U, 0x1533a7d8U,
499 0x4af10498U, 0xf741ecdaU, 0x0e7fcd50U, 0x2f1791f6U,
500 0x8d764dd6U, 0x4d43efb0U, 0x54ccaa4dU, 0xdfe49604U,
501 0xe39ed1b5U, 0x1b4c6a88U, 0xb8c12c1fU, 0x7f466551U,
502 0x049d5eeaU, 0x5d018c35U, 0x73fa8774U, 0x2efb0b41U,
503 0x5ab3671dU, 0x5292dbd2U, 0x33e91056U, 0x136dd647U,
504 0x8c9ad761U, 0x7a37a10cU, 0x8e59f814U, 0x89eb133cU,
505 0xeecea927U, 0x35b761c9U, 0xede11ce5U, 0x3c7a47b1U,
506 0x599cd2dfU, 0x3f55f273U, 0x791814ceU, 0xbf73c737U,
507 0xea53f7cdU, 0x5b5ffdaaU, 0x14df3d6fU, 0x867844dbU,
508 0x81caaff3U, 0x3eb968c4U, 0x2c382434U, 0x5fc2a340U,
509 0x72161dc3U, 0x0cbce225U, 0x8b283c49U, 0x41ff0d95U,
510 0x7139a801U, 0xde080cb3U, 0x9cd8b4e4U, 0x906456c1U,
511 0x617bcb84U, 0x70d532b6U, 0x74486c5cU, 0x42d0b857U,
512};
513static const u32 Td2[256] = {
514 0xa75051f4U, 0x65537e41U, 0xa4c31a17U, 0x5e963a27U,
515 0x6bcb3babU, 0x45f11f9dU, 0x58abacfaU, 0x03934be3U,
516 0xfa552030U, 0x6df6ad76U, 0x769188ccU, 0x4c25f502U,
517 0xd7fc4fe5U, 0xcbd7c52aU, 0x44802635U, 0xa38fb562U,
518 0x5a49deb1U, 0x1b6725baU, 0x0e9845eaU, 0xc0e15dfeU,
519 0x7502c32fU, 0xf012814cU, 0x97a38d46U, 0xf9c66bd3U,
520 0x5fe7038fU, 0x9c951592U, 0x7aebbf6dU, 0x59da9552U,
521 0x832dd4beU, 0x21d35874U, 0x692949e0U, 0xc8448ec9U,
522 0x896a75c2U, 0x7978f48eU, 0x3e6b9958U, 0x71dd27b9U,
523 0x4fb6bee1U, 0xad17f088U, 0xac66c920U, 0x3ab47dceU,
524 0x4a1863dfU, 0x3182e51aU, 0x33609751U, 0x7f456253U,
525 0x77e0b164U, 0xae84bb6bU, 0xa01cfe81U, 0x2b94f908U,
526 0x68587048U, 0xfd198f45U, 0x6c8794deU, 0xf8b7527bU,
527 0xd323ab73U, 0x02e2724bU, 0x8f57e31fU, 0xab2a6655U,
528 0x2807b2ebU, 0xc2032fb5U, 0x7b9a86c5U, 0x08a5d337U,
529 0x87f23028U, 0xa5b223bfU, 0x6aba0203U, 0x825ced16U,
530 0x1c2b8acfU, 0xb492a779U, 0xf2f0f307U, 0xe2a14e69U,
531 0xf4cd65daU, 0xbed50605U, 0x621fd134U, 0xfe8ac4a6U,
532 0x539d342eU, 0x55a0a2f3U, 0xe132058aU, 0xeb75a4f6U,
533 0xec390b83U, 0xefaa4060U, 0x9f065e71U, 0x1051bd6eU,
534
535 0x8af93e21U, 0x063d96ddU, 0x05aedd3eU, 0xbd464de6U,
536 0x8db59154U, 0x5d0571c4U, 0xd46f0406U, 0x15ff6050U,
537 0xfb241998U, 0xe997d6bdU, 0x43cc8940U, 0x9e7767d9U,
538 0x42bdb0e8U, 0x8b880789U, 0x5b38e719U, 0xeedb79c8U,
539 0x0a47a17cU, 0x0fe97c42U, 0x1ec9f884U, 0x00000000U,
540 0x86830980U, 0xed48322bU, 0x70ac1e11U, 0x724e6c5aU,
541 0xfffbfd0eU, 0x38560f85U, 0xd51e3daeU, 0x3927362dU,
542 0xd9640a0fU, 0xa621685cU, 0x54d19b5bU, 0x2e3a2436U,
543 0x67b10c0aU, 0xe70f9357U, 0x96d2b4eeU, 0x919e1b9bU,
544 0xc54f80c0U, 0x20a261dcU, 0x4b695a77U, 0x1a161c12U,
545 0xba0ae293U, 0x2ae5c0a0U, 0xe0433c22U, 0x171d121bU,
546 0x0d0b0e09U, 0xc7adf28bU, 0xa8b92db6U, 0xa9c8141eU,
547 0x198557f1U, 0x074caf75U, 0xddbbee99U, 0x60fda37fU,
548 0x269ff701U, 0xf5bc5c72U, 0x3bc54466U, 0x7e345bfbU,
549 0x29768b43U, 0xc6dccb23U, 0xfc68b6edU, 0xf163b8e4U,
550 0xdccad731U, 0x85104263U, 0x22401397U, 0x112084c6U,
551 0x247d854aU, 0x3df8d2bbU, 0x3211aef9U, 0xa16dc729U,
552 0x2f4b1d9eU, 0x30f3dcb2U, 0x52ec0d86U, 0xe3d077c1U,
553 0x166c2bb3U, 0xb999a970U, 0x48fa1194U, 0x642247e9U,
554 0x8cc4a8fcU, 0x3f1aa0f0U, 0x2cd8567dU, 0x90ef2233U,
555 0x4ec78749U, 0xd1c1d938U, 0xa2fe8ccaU, 0x0b3698d4U,
556 0x81cfa6f5U, 0xde28a57aU, 0x8e26dab7U, 0xbfa43fadU,
557 0x9de42c3aU, 0x920d5078U, 0xcc9b6a5fU, 0x4662547eU,
558 0x13c2f68dU, 0xb8e890d8U, 0xf75e2e39U, 0xaff582c3U,
559 0x80be9f5dU, 0x937c69d0U, 0x2da96fd5U, 0x12b3cf25U,
560 0x993bc8acU, 0x7da71018U, 0x636ee89cU, 0xbb7bdb3bU,
561 0x7809cd26U, 0x18f46e59U, 0xb701ec9aU, 0x9aa8834fU,
562 0x6e65e695U, 0xe67eaaffU, 0xcf0821bcU, 0xe8e6ef15U,
563 0x9bd9bae7U, 0x36ce4a6fU, 0x09d4ea9fU, 0x7cd629b0U,
564 0xb2af31a4U, 0x23312a3fU, 0x9430c6a5U, 0x66c035a2U,
565 0xbc37744eU, 0xcaa6fc82U, 0xd0b0e090U, 0xd81533a7U,
566 0x984af104U, 0xdaf741ecU, 0x500e7fcdU, 0xf62f1791U,
567 0xd68d764dU, 0xb04d43efU, 0x4d54ccaaU, 0x04dfe496U,
568 0xb5e39ed1U, 0x881b4c6aU, 0x1fb8c12cU, 0x517f4665U,
569 0xea049d5eU, 0x355d018cU, 0x7473fa87U, 0x412efb0bU,
570 0x1d5ab367U, 0xd25292dbU, 0x5633e910U, 0x47136dd6U,
571 0x618c9ad7U, 0x0c7a37a1U, 0x148e59f8U, 0x3c89eb13U,
572 0x27eecea9U, 0xc935b761U, 0xe5ede11cU, 0xb13c7a47U,
573 0xdf599cd2U, 0x733f55f2U, 0xce791814U, 0x37bf73c7U,
574 0xcdea53f7U, 0xaa5b5ffdU, 0x6f14df3dU, 0xdb867844U,
575 0xf381caafU, 0xc43eb968U, 0x342c3824U, 0x405fc2a3U,
576 0xc372161dU, 0x250cbce2U, 0x498b283cU, 0x9541ff0dU,
577 0x017139a8U, 0xb3de080cU, 0xe49cd8b4U, 0xc1906456U,
578 0x84617bcbU, 0xb670d532U, 0x5c74486cU, 0x5742d0b8U,
579};
580static const u32 Td3[256] = {
581 0xf4a75051U, 0x4165537eU, 0x17a4c31aU, 0x275e963aU,
582 0xab6bcb3bU, 0x9d45f11fU, 0xfa58abacU, 0xe303934bU,
583 0x30fa5520U, 0x766df6adU, 0xcc769188U, 0x024c25f5U,
584 0xe5d7fc4fU, 0x2acbd7c5U, 0x35448026U, 0x62a38fb5U,
585 0xb15a49deU, 0xba1b6725U, 0xea0e9845U, 0xfec0e15dU,
586 0x2f7502c3U, 0x4cf01281U, 0x4697a38dU, 0xd3f9c66bU,
587 0x8f5fe703U, 0x929c9515U, 0x6d7aebbfU, 0x5259da95U,
588 0xbe832dd4U, 0x7421d358U, 0xe0692949U, 0xc9c8448eU,
589 0xc2896a75U, 0x8e7978f4U, 0x583e6b99U, 0xb971dd27U,
590 0xe14fb6beU, 0x88ad17f0U, 0x20ac66c9U, 0xce3ab47dU,
591 0xdf4a1863U, 0x1a3182e5U, 0x51336097U, 0x537f4562U,
592 0x6477e0b1U, 0x6bae84bbU, 0x81a01cfeU, 0x082b94f9U,
593 0x48685870U, 0x45fd198fU, 0xde6c8794U, 0x7bf8b752U,
594 0x73d323abU, 0x4b02e272U, 0x1f8f57e3U, 0x55ab2a66U,
595 0xeb2807b2U, 0xb5c2032fU, 0xc57b9a86U, 0x3708a5d3U,
596 0x2887f230U, 0xbfa5b223U, 0x036aba02U, 0x16825cedU,
597 0xcf1c2b8aU, 0x79b492a7U, 0x07f2f0f3U, 0x69e2a14eU,
598 0xdaf4cd65U, 0x05bed506U, 0x34621fd1U, 0xa6fe8ac4U,
599 0x2e539d34U, 0xf355a0a2U, 0x8ae13205U, 0xf6eb75a4U,
600 0x83ec390bU, 0x60efaa40U, 0x719f065eU, 0x6e1051bdU,
601 0x218af93eU, 0xdd063d96U, 0x3e05aeddU, 0xe6bd464dU,
602 0x548db591U, 0xc45d0571U, 0x06d46f04U, 0x5015ff60U,
603 0x98fb2419U, 0xbde997d6U, 0x4043cc89U, 0xd99e7767U,
604 0xe842bdb0U, 0x898b8807U, 0x195b38e7U, 0xc8eedb79U,
605 0x7c0a47a1U, 0x420fe97cU, 0x841ec9f8U, 0x00000000U,
606 0x80868309U, 0x2bed4832U, 0x1170ac1eU, 0x5a724e6cU,
607 0x0efffbfdU, 0x8538560fU, 0xaed51e3dU, 0x2d392736U,
608 0x0fd9640aU, 0x5ca62168U, 0x5b54d19bU, 0x362e3a24U,
609 0x0a67b10cU, 0x57e70f93U, 0xee96d2b4U, 0x9b919e1bU,
610 0xc0c54f80U, 0xdc20a261U, 0x774b695aU, 0x121a161cU,
611 0x93ba0ae2U, 0xa02ae5c0U, 0x22e0433cU, 0x1b171d12U,
612 0x090d0b0eU, 0x8bc7adf2U, 0xb6a8b92dU, 0x1ea9c814U,
613 0xf1198557U, 0x75074cafU, 0x99ddbbeeU, 0x7f60fda3U,
614 0x01269ff7U, 0x72f5bc5cU, 0x663bc544U, 0xfb7e345bU,
615 0x4329768bU, 0x23c6dccbU, 0xedfc68b6U, 0xe4f163b8U,
616 0x31dccad7U, 0x63851042U, 0x97224013U, 0xc6112084U,
617 0x4a247d85U, 0xbb3df8d2U, 0xf93211aeU, 0x29a16dc7U,
618 0x9e2f4b1dU, 0xb230f3dcU, 0x8652ec0dU, 0xc1e3d077U,
619 0xb3166c2bU, 0x70b999a9U, 0x9448fa11U, 0xe9642247U,
620 0xfc8cc4a8U, 0xf03f1aa0U, 0x7d2cd856U, 0x3390ef22U,
621 0x494ec787U, 0x38d1c1d9U, 0xcaa2fe8cU, 0xd40b3698U,
622 0xf581cfa6U, 0x7ade28a5U, 0xb78e26daU, 0xadbfa43fU,
623 0x3a9de42cU, 0x78920d50U, 0x5fcc9b6aU, 0x7e466254U,
624 0x8d13c2f6U, 0xd8b8e890U, 0x39f75e2eU, 0xc3aff582U,
625 0x5d80be9fU, 0xd0937c69U, 0xd52da96fU, 0x2512b3cfU,
626 0xac993bc8U, 0x187da710U, 0x9c636ee8U, 0x3bbb7bdbU,
627 0x267809cdU, 0x5918f46eU, 0x9ab701ecU, 0x4f9aa883U,
628 0x956e65e6U, 0xffe67eaaU, 0xbccf0821U, 0x15e8e6efU,
629 0xe79bd9baU, 0x6f36ce4aU, 0x9f09d4eaU, 0xb07cd629U,
630 0xa4b2af31U, 0x3f23312aU, 0xa59430c6U, 0xa266c035U,
631 0x4ebc3774U, 0x82caa6fcU, 0x90d0b0e0U, 0xa7d81533U,
632 0x04984af1U, 0xecdaf741U, 0xcd500e7fU, 0x91f62f17U,
633 0x4dd68d76U, 0xefb04d43U, 0xaa4d54ccU, 0x9604dfe4U,
634 0xd1b5e39eU, 0x6a881b4cU, 0x2c1fb8c1U, 0x65517f46U,
635 0x5eea049dU, 0x8c355d01U, 0x877473faU, 0x0b412efbU,
636 0x671d5ab3U, 0xdbd25292U, 0x105633e9U, 0xd647136dU,
637 0xd7618c9aU, 0xa10c7a37U, 0xf8148e59U, 0x133c89ebU,
638 0xa927eeceU, 0x61c935b7U, 0x1ce5ede1U, 0x47b13c7aU,
639 0xd2df599cU, 0xf2733f55U, 0x14ce7918U, 0xc737bf73U,
640 0xf7cdea53U, 0xfdaa5b5fU, 0x3d6f14dfU, 0x44db8678U,
641 0xaff381caU, 0x68c43eb9U, 0x24342c38U, 0xa3405fc2U,
642 0x1dc37216U, 0xe2250cbcU, 0x3c498b28U, 0x0d9541ffU,
643 0xa8017139U, 0x0cb3de08U, 0xb4e49cd8U, 0x56c19064U,
644 0xcb84617bU, 0x32b670d5U, 0x6c5c7448U, 0xb85742d0U,
645};
646static const u32 Td4[256] = {
647 0x52525252U, 0x09090909U, 0x6a6a6a6aU, 0xd5d5d5d5U,
648 0x30303030U, 0x36363636U, 0xa5a5a5a5U, 0x38383838U,
649 0xbfbfbfbfU, 0x40404040U, 0xa3a3a3a3U, 0x9e9e9e9eU,
650 0x81818181U, 0xf3f3f3f3U, 0xd7d7d7d7U, 0xfbfbfbfbU,
651 0x7c7c7c7cU, 0xe3e3e3e3U, 0x39393939U, 0x82828282U,
652 0x9b9b9b9bU, 0x2f2f2f2fU, 0xffffffffU, 0x87878787U,
653 0x34343434U, 0x8e8e8e8eU, 0x43434343U, 0x44444444U,
654 0xc4c4c4c4U, 0xdedededeU, 0xe9e9e9e9U, 0xcbcbcbcbU,
655 0x54545454U, 0x7b7b7b7bU, 0x94949494U, 0x32323232U,
656 0xa6a6a6a6U, 0xc2c2c2c2U, 0x23232323U, 0x3d3d3d3dU,
657 0xeeeeeeeeU, 0x4c4c4c4cU, 0x95959595U, 0x0b0b0b0bU,
658 0x42424242U, 0xfafafafaU, 0xc3c3c3c3U, 0x4e4e4e4eU,
659 0x08080808U, 0x2e2e2e2eU, 0xa1a1a1a1U, 0x66666666U,
660 0x28282828U, 0xd9d9d9d9U, 0x24242424U, 0xb2b2b2b2U,
661 0x76767676U, 0x5b5b5b5bU, 0xa2a2a2a2U, 0x49494949U,
662 0x6d6d6d6dU, 0x8b8b8b8bU, 0xd1d1d1d1U, 0x25252525U,
663 0x72727272U, 0xf8f8f8f8U, 0xf6f6f6f6U, 0x64646464U,
664 0x86868686U, 0x68686868U, 0x98989898U, 0x16161616U,
665 0xd4d4d4d4U, 0xa4a4a4a4U, 0x5c5c5c5cU, 0xccccccccU,
666 0x5d5d5d5dU, 0x65656565U, 0xb6b6b6b6U, 0x92929292U,
667 0x6c6c6c6cU, 0x70707070U, 0x48484848U, 0x50505050U,
668 0xfdfdfdfdU, 0xededededU, 0xb9b9b9b9U, 0xdadadadaU,
669 0x5e5e5e5eU, 0x15151515U, 0x46464646U, 0x57575757U,
670 0xa7a7a7a7U, 0x8d8d8d8dU, 0x9d9d9d9dU, 0x84848484U,
671 0x90909090U, 0xd8d8d8d8U, 0xababababU, 0x00000000U,
672 0x8c8c8c8cU, 0xbcbcbcbcU, 0xd3d3d3d3U, 0x0a0a0a0aU,
673 0xf7f7f7f7U, 0xe4e4e4e4U, 0x58585858U, 0x05050505U,
674 0xb8b8b8b8U, 0xb3b3b3b3U, 0x45454545U, 0x06060606U,
675 0xd0d0d0d0U, 0x2c2c2c2cU, 0x1e1e1e1eU, 0x8f8f8f8fU,
676 0xcacacacaU, 0x3f3f3f3fU, 0x0f0f0f0fU, 0x02020202U,
677 0xc1c1c1c1U, 0xafafafafU, 0xbdbdbdbdU, 0x03030303U,
678 0x01010101U, 0x13131313U, 0x8a8a8a8aU, 0x6b6b6b6bU,
679 0x3a3a3a3aU, 0x91919191U, 0x11111111U, 0x41414141U,
680 0x4f4f4f4fU, 0x67676767U, 0xdcdcdcdcU, 0xeaeaeaeaU,
681 0x97979797U, 0xf2f2f2f2U, 0xcfcfcfcfU, 0xcecececeU,
682 0xf0f0f0f0U, 0xb4b4b4b4U, 0xe6e6e6e6U, 0x73737373U,
683 0x96969696U, 0xacacacacU, 0x74747474U, 0x22222222U,
684 0xe7e7e7e7U, 0xadadadadU, 0x35353535U, 0x85858585U,
685 0xe2e2e2e2U, 0xf9f9f9f9U, 0x37373737U, 0xe8e8e8e8U,
686 0x1c1c1c1cU, 0x75757575U, 0xdfdfdfdfU, 0x6e6e6e6eU,
687 0x47474747U, 0xf1f1f1f1U, 0x1a1a1a1aU, 0x71717171U,
688 0x1d1d1d1dU, 0x29292929U, 0xc5c5c5c5U, 0x89898989U,
689 0x6f6f6f6fU, 0xb7b7b7b7U, 0x62626262U, 0x0e0e0e0eU,
690 0xaaaaaaaaU, 0x18181818U, 0xbebebebeU, 0x1b1b1b1bU,
691 0xfcfcfcfcU, 0x56565656U, 0x3e3e3e3eU, 0x4b4b4b4bU,
692 0xc6c6c6c6U, 0xd2d2d2d2U, 0x79797979U, 0x20202020U,
693 0x9a9a9a9aU, 0xdbdbdbdbU, 0xc0c0c0c0U, 0xfefefefeU,
694 0x78787878U, 0xcdcdcdcdU, 0x5a5a5a5aU, 0xf4f4f4f4U,
695 0x1f1f1f1fU, 0xddddddddU, 0xa8a8a8a8U, 0x33333333U,
696 0x88888888U, 0x07070707U, 0xc7c7c7c7U, 0x31313131U,
697 0xb1b1b1b1U, 0x12121212U, 0x10101010U, 0x59595959U,
698 0x27272727U, 0x80808080U, 0xececececU, 0x5f5f5f5fU,
699 0x60606060U, 0x51515151U, 0x7f7f7f7fU, 0xa9a9a9a9U,
700 0x19191919U, 0xb5b5b5b5U, 0x4a4a4a4aU, 0x0d0d0d0dU,
701 0x2d2d2d2dU, 0xe5e5e5e5U, 0x7a7a7a7aU, 0x9f9f9f9fU,
702 0x93939393U, 0xc9c9c9c9U, 0x9c9c9c9cU, 0xefefefefU,
703 0xa0a0a0a0U, 0xe0e0e0e0U, 0x3b3b3b3bU, 0x4d4d4d4dU,
704 0xaeaeaeaeU, 0x2a2a2a2aU, 0xf5f5f5f5U, 0xb0b0b0b0U,
705 0xc8c8c8c8U, 0xebebebebU, 0xbbbbbbbbU, 0x3c3c3c3cU,
706 0x83838383U, 0x53535353U, 0x99999999U, 0x61616161U,
707 0x17171717U, 0x2b2b2b2bU, 0x04040404U, 0x7e7e7e7eU,
708 0xbabababaU, 0x77777777U, 0xd6d6d6d6U, 0x26262626U,
709 0xe1e1e1e1U, 0x69696969U, 0x14141414U, 0x63636363U,
710 0x55555555U, 0x21212121U, 0x0c0c0c0cU, 0x7d7d7d7dU,
711};
712static const u32 rcon[] = {
713 0x01000000, 0x02000000, 0x04000000, 0x08000000,
714 0x10000000, 0x20000000, 0x40000000, 0x80000000,
715 0x1B000000, 0x36000000, /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */
716};
717
718/**
719 * Expand the cipher key into the encryption key schedule.
720 */
721int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
722 AES_KEY *key) {
723
724 u32 *rk;
725 int i = 0;
726 u32 temp;
727
728 if (!userKey || !key)
729 return -1;
730 if (bits != 128 && bits != 192 && bits != 256)
731 return -2;
732
733 rk = key->rd_key;
734
735 if (bits==128)
736 key->rounds = 10;
737 else if (bits==192)
738 key->rounds = 12;
739 else
740 key->rounds = 14;
741
742 rk[0] = GETU32(userKey );
743 rk[1] = GETU32(userKey + 4);
744 rk[2] = GETU32(userKey + 8);
745 rk[3] = GETU32(userKey + 12);
746 if (bits == 128) {
747 for (;;) {
748 temp = rk[3];
749 rk[4] = rk[0] ^
750 (Te4[(temp >> 16) & 0xff] & 0xff000000) ^
751 (Te4[(temp >> 8) & 0xff] & 0x00ff0000) ^
752 (Te4[(temp ) & 0xff] & 0x0000ff00) ^
753 (Te4[(temp >> 24) ] & 0x000000ff) ^
754 rcon[i];
755 rk[5] = rk[1] ^ rk[4];
756 rk[6] = rk[2] ^ rk[5];
757 rk[7] = rk[3] ^ rk[6];
758 if (++i == 10) {
759 return 0;
760 }
761 rk += 4;
762 }
763 }
764 rk[4] = GETU32(userKey + 16);
765 rk[5] = GETU32(userKey + 20);
766 if (bits == 192) {
767 for (;;) {
768 temp = rk[ 5];
769 rk[ 6] = rk[ 0] ^
770 (Te4[(temp >> 16) & 0xff] & 0xff000000) ^
771 (Te4[(temp >> 8) & 0xff] & 0x00ff0000) ^
772 (Te4[(temp ) & 0xff] & 0x0000ff00) ^
773 (Te4[(temp >> 24) ] & 0x000000ff) ^
774 rcon[i];
775 rk[ 7] = rk[ 1] ^ rk[ 6];
776 rk[ 8] = rk[ 2] ^ rk[ 7];
777 rk[ 9] = rk[ 3] ^ rk[ 8];
778 if (++i == 8) {
779 return 0;
780 }
781 rk[10] = rk[ 4] ^ rk[ 9];
782 rk[11] = rk[ 5] ^ rk[10];
783 rk += 6;
784 }
785 }
786 rk[6] = GETU32(userKey + 24);
787 rk[7] = GETU32(userKey + 28);
788 if (bits == 256) {
789 for (;;) {
790 temp = rk[ 7];
791 rk[ 8] = rk[ 0] ^
792 (Te4[(temp >> 16) & 0xff] & 0xff000000) ^
793 (Te4[(temp >> 8) & 0xff] & 0x00ff0000) ^
794 (Te4[(temp ) & 0xff] & 0x0000ff00) ^
795 (Te4[(temp >> 24) ] & 0x000000ff) ^
796 rcon[i];
797 rk[ 9] = rk[ 1] ^ rk[ 8];
798 rk[10] = rk[ 2] ^ rk[ 9];
799 rk[11] = rk[ 3] ^ rk[10];
800 if (++i == 7) {
801 return 0;
802 }
803 temp = rk[11];
804 rk[12] = rk[ 4] ^
805 (Te4[(temp >> 24) ] & 0xff000000) ^
806 (Te4[(temp >> 16) & 0xff] & 0x00ff0000) ^
807 (Te4[(temp >> 8) & 0xff] & 0x0000ff00) ^
808 (Te4[(temp ) & 0xff] & 0x000000ff);
809 rk[13] = rk[ 5] ^ rk[12];
810 rk[14] = rk[ 6] ^ rk[13];
811 rk[15] = rk[ 7] ^ rk[14];
812
813 rk += 8;
814 }
815 }
816 return 0;
817}
818
819/**
820 * Expand the cipher key into the decryption key schedule.
821 */
822int AES_set_decrypt_key(const unsigned char *userKey, const int bits,
823 AES_KEY *key) {
824
825 u32 *rk;
826 int i, j, status;
827 u32 temp;
828
829 /* first, start with an encryption schedule */
830 status = AES_set_encrypt_key(userKey, bits, key);
831 if (status < 0)
832 return status;
833
834 rk = key->rd_key;
835
836 /* invert the order of the round keys: */
837 for (i = 0, j = 4*(key->rounds); i < j; i += 4, j -= 4) {
838 temp = rk[i ]; rk[i ] = rk[j ]; rk[j ] = temp;
839 temp = rk[i + 1]; rk[i + 1] = rk[j + 1]; rk[j + 1] = temp;
840 temp = rk[i + 2]; rk[i + 2] = rk[j + 2]; rk[j + 2] = temp;
841 temp = rk[i + 3]; rk[i + 3] = rk[j + 3]; rk[j + 3] = temp;
842 }
843 /* apply the inverse MixColumn transform to all round keys but the first and the last: */
844 for (i = 1; i < (key->rounds); i++) {
845 rk += 4;
846 rk[0] =
847 Td0[Te4[(rk[0] >> 24) ] & 0xff] ^
848 Td1[Te4[(rk[0] >> 16) & 0xff] & 0xff] ^
849 Td2[Te4[(rk[0] >> 8) & 0xff] & 0xff] ^
850 Td3[Te4[(rk[0] ) & 0xff] & 0xff];
851 rk[1] =
852 Td0[Te4[(rk[1] >> 24) ] & 0xff] ^
853 Td1[Te4[(rk[1] >> 16) & 0xff] & 0xff] ^
854 Td2[Te4[(rk[1] >> 8) & 0xff] & 0xff] ^
855 Td3[Te4[(rk[1] ) & 0xff] & 0xff];
856 rk[2] =
857 Td0[Te4[(rk[2] >> 24) ] & 0xff] ^
858 Td1[Te4[(rk[2] >> 16) & 0xff] & 0xff] ^
859 Td2[Te4[(rk[2] >> 8) & 0xff] & 0xff] ^
860 Td3[Te4[(rk[2] ) & 0xff] & 0xff];
861 rk[3] =
862 Td0[Te4[(rk[3] >> 24) ] & 0xff] ^
863 Td1[Te4[(rk[3] >> 16) & 0xff] & 0xff] ^
864 Td2[Te4[(rk[3] >> 8) & 0xff] & 0xff] ^
865 Td3[Te4[(rk[3] ) & 0xff] & 0xff];
866 }
867 return 0;
868}
869
870/*
871 * Encrypt a single block
872 * in and out can overlap
873 */
874void AES_encrypt(const unsigned char *in, unsigned char *out,
875 const AES_KEY *key) {
876
877 const u32 *rk;
878 u32 s0, s1, s2, s3, t0, t1, t2, t3;
879#ifndef FULL_UNROLL
880 int r;
881#endif /* ?FULL_UNROLL */
882
883 assert(in && out && key);
884 rk = key->rd_key;
885
886 /*
887 * map byte array block to cipher state
888 * and add initial round key:
889 */
890 s0 = GETU32(in ) ^ rk[0];
891 s1 = GETU32(in + 4) ^ rk[1];
892 s2 = GETU32(in + 8) ^ rk[2];
893 s3 = GETU32(in + 12) ^ rk[3];
894#ifdef FULL_UNROLL
895 /* round 1: */
896 t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[ 4];
897 t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[ 5];
898 t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[ 6];
899 t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[ 7];
900 /* round 2: */
901 s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[ 8];
902 s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[ 9];
903 s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[10];
904 s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[11];
905 /* round 3: */
906 t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[12];
907 t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[13];
908 t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[14];
909 t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[15];
910 /* round 4: */
911 s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[16];
912 s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[17];
913 s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[18];
914 s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[19];
915 /* round 5: */
916 t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[20];
917 t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[21];
918 t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[22];
919 t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[23];
920 /* round 6: */
921 s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[24];
922 s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[25];
923 s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[26];
924 s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[27];
925 /* round 7: */
926 t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[28];
927 t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[29];
928 t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[30];
929 t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[31];
930 /* round 8: */
931 s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[32];
932 s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[33];
933 s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[34];
934 s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[35];
935 /* round 9: */
936 t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[36];
937 t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[37];
938 t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[38];
939 t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[39];
940 if (key->rounds > 10) {
941 /* round 10: */
942 s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[40];
943 s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[41];
944 s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[42];
945 s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[43];
946 /* round 11: */
947 t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[44];
948 t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[45];
949 t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[46];
950 t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[47];
951 if (key->rounds > 12) {
952 /* round 12: */
953 s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[48];
954 s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[49];
955 s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[50];
956 s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[51];
957 /* round 13: */
958 t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[52];
959 t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[53];
960 t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[54];
961 t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[55];
962 }
963 }
964 rk += key->rounds << 2;
965#else /* !FULL_UNROLL */
966 /*
967 * Nr - 1 full rounds:
968 */
969 r = key->rounds >> 1;
970 for (;;) {
971 t0 =
972 Te0[(s0 >> 24) ] ^
973 Te1[(s1 >> 16) & 0xff] ^
974 Te2[(s2 >> 8) & 0xff] ^
975 Te3[(s3 ) & 0xff] ^
976 rk[4];
977 t1 =
978 Te0[(s1 >> 24) ] ^
979 Te1[(s2 >> 16) & 0xff] ^
980 Te2[(s3 >> 8) & 0xff] ^
981 Te3[(s0 ) & 0xff] ^
982 rk[5];
983 t2 =
984 Te0[(s2 >> 24) ] ^
985 Te1[(s3 >> 16) & 0xff] ^
986 Te2[(s0 >> 8) & 0xff] ^
987 Te3[(s1 ) & 0xff] ^
988 rk[6];
989 t3 =
990 Te0[(s3 >> 24) ] ^
991 Te1[(s0 >> 16) & 0xff] ^
992 Te2[(s1 >> 8) & 0xff] ^
993 Te3[(s2 ) & 0xff] ^
994 rk[7];
995
996 rk += 8;
997 if (--r == 0) {
998 break;
999 }
1000
1001 s0 =
1002 Te0[(t0 >> 24) ] ^
1003 Te1[(t1 >> 16) & 0xff] ^
1004 Te2[(t2 >> 8) & 0xff] ^
1005 Te3[(t3 ) & 0xff] ^
1006 rk[0];
1007 s1 =
1008 Te0[(t1 >> 24) ] ^
1009 Te1[(t2 >> 16) & 0xff] ^
1010 Te2[(t3 >> 8) & 0xff] ^
1011 Te3[(t0 ) & 0xff] ^
1012 rk[1];
1013 s2 =
1014 Te0[(t2 >> 24) ] ^
1015 Te1[(t3 >> 16) & 0xff] ^
1016 Te2[(t0 >> 8) & 0xff] ^
1017 Te3[(t1 ) & 0xff] ^
1018 rk[2];
1019 s3 =
1020 Te0[(t3 >> 24) ] ^
1021 Te1[(t0 >> 16) & 0xff] ^
1022 Te2[(t1 >> 8) & 0xff] ^
1023 Te3[(t2 ) & 0xff] ^
1024 rk[3];
1025 }
1026#endif /* ?FULL_UNROLL */
1027 /*
1028 * apply last round and
1029 * map cipher state to byte array block:
1030 */
1031 s0 =
1032 (Te4[(t0 >> 24) ] & 0xff000000) ^
1033 (Te4[(t1 >> 16) & 0xff] & 0x00ff0000) ^
1034 (Te4[(t2 >> 8) & 0xff] & 0x0000ff00) ^
1035 (Te4[(t3 ) & 0xff] & 0x000000ff) ^
1036 rk[0];
1037 PUTU32(out , s0);
1038 s1 =
1039 (Te4[(t1 >> 24) ] & 0xff000000) ^
1040 (Te4[(t2 >> 16) & 0xff] & 0x00ff0000) ^
1041 (Te4[(t3 >> 8) & 0xff] & 0x0000ff00) ^
1042 (Te4[(t0 ) & 0xff] & 0x000000ff) ^
1043 rk[1];
1044 PUTU32(out + 4, s1);
1045 s2 =
1046 (Te4[(t2 >> 24) ] & 0xff000000) ^
1047 (Te4[(t3 >> 16) & 0xff] & 0x00ff0000) ^
1048 (Te4[(t0 >> 8) & 0xff] & 0x0000ff00) ^
1049 (Te4[(t1 ) & 0xff] & 0x000000ff) ^
1050 rk[2];
1051 PUTU32(out + 8, s2);
1052 s3 =
1053 (Te4[(t3 >> 24) ] & 0xff000000) ^
1054 (Te4[(t0 >> 16) & 0xff] & 0x00ff0000) ^
1055 (Te4[(t1 >> 8) & 0xff] & 0x0000ff00) ^
1056 (Te4[(t2 ) & 0xff] & 0x000000ff) ^
1057 rk[3];
1058 PUTU32(out + 12, s3);
1059}
1060
1061/*
1062 * Decrypt a single block
1063 * in and out can overlap
1064 */
1065void AES_decrypt(const unsigned char *in, unsigned char *out,
1066 const AES_KEY *key) {
1067
1068 const u32 *rk;
1069 u32 s0, s1, s2, s3, t0, t1, t2, t3;
1070#ifndef FULL_UNROLL
1071 int r;
1072#endif /* ?FULL_UNROLL */
1073
1074 assert(in && out && key);
1075 rk = key->rd_key;
1076
1077 /*
1078 * map byte array block to cipher state
1079 * and add initial round key:
1080 */
1081 s0 = GETU32(in ) ^ rk[0];
1082 s1 = GETU32(in + 4) ^ rk[1];
1083 s2 = GETU32(in + 8) ^ rk[2];
1084 s3 = GETU32(in + 12) ^ rk[3];
1085#ifdef FULL_UNROLL
1086 /* round 1: */
1087 t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[ 4];
1088 t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[ 5];
1089 t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[ 6];
1090 t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[ 7];
1091 /* round 2: */
1092 s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[ 8];
1093 s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[ 9];
1094 s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[10];
1095 s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[11];
1096 /* round 3: */
1097 t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[12];
1098 t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[13];
1099 t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[14];
1100 t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[15];
1101 /* round 4: */
1102 s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[16];
1103 s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[17];
1104 s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[18];
1105 s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[19];
1106 /* round 5: */
1107 t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[20];
1108 t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[21];
1109 t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[22];
1110 t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[23];
1111 /* round 6: */
1112 s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[24];
1113 s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[25];
1114 s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[26];
1115 s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[27];
1116 /* round 7: */
1117 t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[28];
1118 t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[29];
1119 t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[30];
1120 t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[31];
1121 /* round 8: */
1122 s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[32];
1123 s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[33];
1124 s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[34];
1125 s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[35];
1126 /* round 9: */
1127 t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[36];
1128 t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[37];
1129 t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[38];
1130 t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[39];
1131 if (key->rounds > 10) {
1132 /* round 10: */
1133 s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[40];
1134 s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[41];
1135 s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[42];
1136 s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[43];
1137 /* round 11: */
1138 t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[44];
1139 t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[45];
1140 t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[46];
1141 t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[47];
1142 if (key->rounds > 12) {
1143 /* round 12: */
1144 s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[48];
1145 s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[49];
1146 s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[50];
1147 s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[51];
1148 /* round 13: */
1149 t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[52];
1150 t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[53];
1151 t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[54];
1152 t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[55];
1153 }
1154 }
1155 rk += key->rounds << 2;
1156#else /* !FULL_UNROLL */
1157 /*
1158 * Nr - 1 full rounds:
1159 */
1160 r = key->rounds >> 1;
1161 for (;;) {
1162 t0 =
1163 Td0[(s0 >> 24) ] ^
1164 Td1[(s3 >> 16) & 0xff] ^
1165 Td2[(s2 >> 8) & 0xff] ^
1166 Td3[(s1 ) & 0xff] ^
1167 rk[4];
1168 t1 =
1169 Td0[(s1 >> 24) ] ^
1170 Td1[(s0 >> 16) & 0xff] ^
1171 Td2[(s3 >> 8) & 0xff] ^
1172 Td3[(s2 ) & 0xff] ^
1173 rk[5];
1174 t2 =
1175 Td0[(s2 >> 24) ] ^
1176 Td1[(s1 >> 16) & 0xff] ^
1177 Td2[(s0 >> 8) & 0xff] ^
1178 Td3[(s3 ) & 0xff] ^
1179 rk[6];
1180 t3 =
1181 Td0[(s3 >> 24) ] ^
1182 Td1[(s2 >> 16) & 0xff] ^
1183 Td2[(s1 >> 8) & 0xff] ^
1184 Td3[(s0 ) & 0xff] ^
1185 rk[7];
1186
1187 rk += 8;
1188 if (--r == 0) {
1189 break;
1190 }
1191
1192 s0 =
1193 Td0[(t0 >> 24) ] ^
1194 Td1[(t3 >> 16) & 0xff] ^
1195 Td2[(t2 >> 8) & 0xff] ^
1196 Td3[(t1 ) & 0xff] ^
1197 rk[0];
1198 s1 =
1199 Td0[(t1 >> 24) ] ^
1200 Td1[(t0 >> 16) & 0xff] ^
1201 Td2[(t3 >> 8) & 0xff] ^
1202 Td3[(t2 ) & 0xff] ^
1203 rk[1];
1204 s2 =
1205 Td0[(t2 >> 24) ] ^
1206 Td1[(t1 >> 16) & 0xff] ^
1207 Td2[(t0 >> 8) & 0xff] ^
1208 Td3[(t3 ) & 0xff] ^
1209 rk[2];
1210 s3 =
1211 Td0[(t3 >> 24) ] ^
1212 Td1[(t2 >> 16) & 0xff] ^
1213 Td2[(t1 >> 8) & 0xff] ^
1214 Td3[(t0 ) & 0xff] ^
1215 rk[3];
1216 }
1217#endif /* ?FULL_UNROLL */
1218 /*
1219 * apply last round and
1220 * map cipher state to byte array block:
1221 */
1222 s0 =
1223 (Td4[(t0 >> 24) ] & 0xff000000) ^
1224 (Td4[(t3 >> 16) & 0xff] & 0x00ff0000) ^
1225 (Td4[(t2 >> 8) & 0xff] & 0x0000ff00) ^
1226 (Td4[(t1 ) & 0xff] & 0x000000ff) ^
1227 rk[0];
1228 PUTU32(out , s0);
1229 s1 =
1230 (Td4[(t1 >> 24) ] & 0xff000000) ^
1231 (Td4[(t0 >> 16) & 0xff] & 0x00ff0000) ^
1232 (Td4[(t3 >> 8) & 0xff] & 0x0000ff00) ^
1233 (Td4[(t2 ) & 0xff] & 0x000000ff) ^
1234 rk[1];
1235 PUTU32(out + 4, s1);
1236 s2 =
1237 (Td4[(t2 >> 24) ] & 0xff000000) ^
1238 (Td4[(t1 >> 16) & 0xff] & 0x00ff0000) ^
1239 (Td4[(t0 >> 8) & 0xff] & 0x0000ff00) ^
1240 (Td4[(t3 ) & 0xff] & 0x000000ff) ^
1241 rk[2];
1242 PUTU32(out + 8, s2);
1243 s3 =
1244 (Td4[(t3 >> 24) ] & 0xff000000) ^
1245 (Td4[(t2 >> 16) & 0xff] & 0x00ff0000) ^
1246 (Td4[(t1 >> 8) & 0xff] & 0x0000ff00) ^
1247 (Td4[(t0 ) & 0xff] & 0x000000ff) ^
1248 rk[3];
1249 PUTU32(out + 12, s3);
1250}
1251
diff --git a/src/lib/libcrypto/aes/aes_ctr.c b/src/lib/libcrypto/aes/aes_ctr.c
new file mode 100644
index 0000000000..8e800481de
--- /dev/null
+++ b/src/lib/libcrypto/aes/aes_ctr.c
@@ -0,0 +1,117 @@
1/* crypto/aes/aes_ctr.c -*- mode:C; c-file-style: "eay" -*- */
2/* ====================================================================
3 * Copyright (c) 1998-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 */
51
52#include <assert.h>
53#include <openssl/aes.h>
54#include "aes_locl.h"
55
56/* NOTE: CTR mode is big-endian. The rest of the AES code
57 * is endian-neutral. */
58
59/* increment counter (128-bit int) by 2^64 */
60static void AES_ctr128_inc(unsigned char *counter) {
61 unsigned long c;
62
63 /* Grab 3rd dword of counter and increment */
64#ifdef L_ENDIAN
65 c = GETU32(counter + 8);
66 c++;
67 PUTU32(counter + 8, c);
68#else
69 c = GETU32(counter + 4);
70 c++;
71 PUTU32(counter + 4, c);
72#endif
73
74 /* if no overflow, we're done */
75 if (c)
76 return;
77
78 /* Grab top dword of counter and increment */
79#ifdef L_ENDIAN
80 c = GETU32(counter + 12);
81 c++;
82 PUTU32(counter + 12, c);
83#else
84 c = GETU32(counter + 0);
85 c++;
86 PUTU32(counter + 0, c);
87#endif
88
89}
90
91/* The input encrypted as though 128bit counter mode is being
92 * used. The extra state information to record how much of the
93 * 128bit block we have used is contained in *num;
94 */
95void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out,
96 const unsigned long length, const AES_KEY *key,
97 unsigned char *counter, unsigned int *num) {
98
99 unsigned int n;
100 unsigned long l=length;
101 unsigned char tmp[AES_BLOCK_SIZE];
102
103 assert(in && out && key && counter && num);
104
105 n = *num;
106
107 while (l--) {
108 if (n == 0) {
109 AES_ctr128_inc(counter);
110 AES_encrypt(counter, tmp, key);
111 }
112 *(out++) = *(in++) ^ tmp[n];
113 n = (n+1) % AES_BLOCK_SIZE;
114 }
115
116 *num=n;
117}
diff --git a/src/lib/libcrypto/aes/aes_ecb.c b/src/lib/libcrypto/aes/aes_ecb.c
new file mode 100644
index 0000000000..1cb2e07d3d
--- /dev/null
+++ b/src/lib/libcrypto/aes/aes_ecb.c
@@ -0,0 +1,67 @@
1/* crypto/aes/aes_ecb.c -*- mode:C; c-file-style: "eay" -*- */
2/* ====================================================================
3 * Copyright (c) 1998-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 */
51
52#include <assert.h>
53#include <openssl/aes.h>
54#include "aes_locl.h"
55
56void AES_ecb_encrypt(const unsigned char *in, unsigned char *out,
57 const AES_KEY *key, const int enc) {
58
59 assert(in && out && key);
60 assert((AES_ENCRYPT == enc)||(AES_DECRYPT == enc));
61
62 if (AES_ENCRYPT == enc)
63 AES_encrypt(in, out, key);
64 else
65 AES_decrypt(in, out, key);
66}
67
diff --git a/src/lib/libcrypto/aes/aes_locl.h b/src/lib/libcrypto/aes/aes_locl.h
new file mode 100644
index 0000000000..541d1d6e84
--- /dev/null
+++ b/src/lib/libcrypto/aes/aes_locl.h
@@ -0,0 +1,88 @@
1/* crypto/aes/aes.h -*- mode:C; c-file-style: "eay" -*- */
2/* ====================================================================
3 * Copyright (c) 1998-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 */
51
52#ifndef HEADER_AES_LOCL_H
53#define HEADER_AES_LOCL_H
54
55#include <openssl/e_os2.h>
56
57#ifdef OPENSSL_NO_AES
58#error AES is disabled.
59#endif
60
61#include <stdio.h>
62#include <stdlib.h>
63
64#if defined(__STDC__) || defined(OPENSSL_SYS_VMS) || defined(M_XENIX) || defined(OPENSSL_SYS_MSDOS)
65#include <string.h>
66#endif
67
68#ifdef _MSC_VER
69# define SWAP(x) (_lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00)
70# define GETU32(p) SWAP(*((u32 *)(p)))
71# define PUTU32(ct, st) { *((u32 *)(ct)) = SWAP((st)); }
72#else
73# define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ ((u32)(pt)[2] << 8) ^ ((u32)(pt)[3]))
74# define PUTU32(ct, st) { (ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); (ct)[2] = (u8)((st) >> 8); (ct)[3] = (u8)(st); }
75#endif
76
77typedef unsigned long u32;
78typedef unsigned short u16;
79typedef unsigned char u8;
80
81#define MAXKC (256/32)
82#define MAXKB (256/8)
83#define MAXNR 14
84
85/* This controls loop-unrolling in aes_core.c */
86#undef FULL_UNROLL
87
88#endif /* !HEADER_AES_LOCL_H */
diff --git a/src/lib/libcrypto/aes/aes_misc.c b/src/lib/libcrypto/aes/aes_misc.c
new file mode 100644
index 0000000000..090def25d5
--- /dev/null
+++ b/src/lib/libcrypto/aes/aes_misc.c
@@ -0,0 +1,64 @@
1/* crypto/aes/aes_misc.c -*- mode:C; c-file-style: "eay" -*- */
2/* ====================================================================
3 * Copyright (c) 1998-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 */
51
52#include <openssl/opensslv.h>
53#include <openssl/aes.h>
54#include "aes_locl.h"
55
56const char *AES_version="AES" OPENSSL_VERSION_PTEXT;
57
58const char *AES_options(void) {
59#ifdef FULL_UNROLL
60 return "aes(full)";
61#else
62 return "aes(partial)";
63#endif
64}
diff --git a/src/lib/libcrypto/aes/aes_ofb.c b/src/lib/libcrypto/aes/aes_ofb.c
new file mode 100644
index 0000000000..e33bdaea28
--- /dev/null
+++ b/src/lib/libcrypto/aes/aes_ofb.c
@@ -0,0 +1,136 @@
1/* crypto/aes/aes_ofb.c -*- mode:C; c-file-style: "eay" -*- */
2/* ====================================================================
3 * Copyright (c) 1998-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 */
51/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
52 * All rights reserved.
53 *
54 * This package is an SSL implementation written
55 * by Eric Young (eay@cryptsoft.com).
56 * The implementation was written so as to conform with Netscapes SSL.
57 *
58 * This library is free for commercial and non-commercial use as long as
59 * the following conditions are aheared to. The following conditions
60 * apply to all code found in this distribution, be it the RC4, RSA,
61 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
62 * included with this distribution is covered by the same copyright terms
63 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
64 *
65 * Copyright remains Eric Young's, and as such any Copyright notices in
66 * the code are not to be removed.
67 * If this package is used in a product, Eric Young should be given attribution
68 * as the author of the parts of the library used.
69 * This can be in the form of a textual message at program startup or
70 * in documentation (online or textual) provided with the package.
71 *
72 * Redistribution and use in source and binary forms, with or without
73 * modification, are permitted provided that the following conditions
74 * are met:
75 * 1. Redistributions of source code must retain the copyright
76 * notice, this list of conditions and the following disclaimer.
77 * 2. Redistributions in binary form must reproduce the above copyright
78 * notice, this list of conditions and the following disclaimer in the
79 * documentation and/or other materials provided with the distribution.
80 * 3. All advertising materials mentioning features or use of this software
81 * must display the following acknowledgement:
82 * "This product includes cryptographic software written by
83 * Eric Young (eay@cryptsoft.com)"
84 * The word 'cryptographic' can be left out if the rouines from the library
85 * being used are not cryptographic related :-).
86 * 4. If you include any Windows specific code (or a derivative thereof) from
87 * the apps directory (application code) you must include an acknowledgement:
88 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
89 *
90 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
91 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
92 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
93 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
94 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
95 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
96 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
97 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
98 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
99 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
100 * SUCH DAMAGE.
101 *
102 * The licence and distribution terms for any publically available version or
103 * derivative of this code cannot be changed. i.e. this code cannot simply be
104 * copied and put under another distribution licence
105 * [including the GNU Public Licence.]
106 */
107
108#include <assert.h>
109#include <openssl/aes.h>
110#include "aes_locl.h"
111
112/* The input and output encrypted as though 128bit ofb mode is being
113 * used. The extra state information to record how much of the
114 * 128bit block we have used is contained in *num;
115 */
116void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out,
117 const unsigned long length, const AES_KEY *key,
118 unsigned char *ivec, int *num) {
119
120 unsigned int n;
121 unsigned long l=length;
122
123 assert(in && out && key && ivec && num);
124
125 n = *num;
126
127 while (l--) {
128 if (n == 0) {
129 AES_encrypt(ivec, ivec, key);
130 }
131 *(out++) = *(in++) ^ ivec[n];
132 n = (n+1) % AES_BLOCK_SIZE;
133 }
134
135 *num=n;
136}
diff --git a/src/lib/libcrypto/asn1/Makefile.ssl b/src/lib/libcrypto/asn1/Makefile.ssl
index dace5be2bc..b423419ba3 100644
--- a/src/lib/libcrypto/asn1/Makefile.ssl
+++ b/src/lib/libcrypto/asn1/Makefile.ssl
@@ -5,13 +5,14 @@
5DIR= asn1 5DIR= asn1
6TOP= ../.. 6TOP= ../..
7CC= cc 7CC= cc
8INCLUDES= -I.. -I../../include 8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g 9CFLAG=-g
10INSTALL_PREFIX= 10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl 11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl 12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl 13MAKE= make -f Makefile.ssl
14MAKEDEPEND= $(TOP)/util/domd $(TOP) 14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
15MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
16AR= ar r 17AR= ar r
17 18
@@ -23,39 +24,33 @@ APPS=
23 24
24LIB=$(TOP)/libcrypto.a 25LIB=$(TOP)/libcrypto.a
25LIBSRC= a_object.c a_bitstr.c a_utctm.c a_gentm.c a_time.c a_int.c a_octet.c \ 26LIBSRC= a_object.c a_bitstr.c a_utctm.c a_gentm.c a_time.c a_int.c a_octet.c \
26 a_null.c a_print.c a_type.c a_set.c a_dup.c a_d2i_fp.c a_i2d_fp.c a_bmp.c \ 27 a_print.c a_type.c a_set.c a_dup.c a_d2i_fp.c a_i2d_fp.c \
27 a_enum.c a_vis.c a_utf8.c a_sign.c a_digest.c a_verify.c a_mbstr.c a_strex.c \ 28 a_enum.c a_utf8.c a_sign.c a_digest.c a_verify.c a_mbstr.c a_strex.c \
28 x_algor.c x_val.c x_pubkey.c x_sig.c x_req.c x_attrib.c \ 29 x_algor.c x_val.c x_pubkey.c x_sig.c x_req.c x_attrib.c x_bignum.c \
29 x_name.c x_cinf.c x_x509.c x_x509a.c x_crl.c x_info.c x_spki.c nsseq.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 \
30 d2i_r_pr.c i2d_r_pr.c d2i_r_pu.c i2d_r_pu.c \
31 d2i_s_pr.c i2d_s_pr.c d2i_s_pu.c i2d_s_pu.c \
32 d2i_pu.c d2i_pr.c i2d_pu.c i2d_pr.c\ 31 d2i_pu.c d2i_pr.c i2d_pu.c i2d_pr.c\
33 t_req.c t_x509.c t_x509a.c t_crl.c t_pkey.c t_spki.c t_bitst.c \ 32 t_req.c t_x509.c t_x509a.c t_crl.c t_pkey.c t_spki.c t_bitst.c \
34 p7_i_s.c p7_signi.c p7_signd.c p7_recip.c p7_enc_c.c p7_evp.c \ 33 tasn_new.c tasn_fre.c tasn_enc.c tasn_dec.c tasn_utl.c tasn_typ.c \
35 p7_dgst.c p7_s_e.c p7_enc.c p7_lib.c \ 34 f_int.c f_string.c n_pkey.c \
36 f_int.c f_string.c i2d_dhp.c i2d_dsap.c d2i_dhp.c d2i_dsap.c n_pkey.c \
37 f_enum.c a_hdr.c x_pkey.c a_bool.c x_exten.c \ 35 f_enum.c a_hdr.c x_pkey.c a_bool.c x_exten.c \
38 asn1_par.c asn1_lib.c asn1_err.c a_meth.c a_bytes.c a_strnid.c \ 36 asn1_par.c asn1_lib.c asn1_err.c a_meth.c a_bytes.c a_strnid.c \
39 evp_asn1.c asn_pack.c p5_pbe.c p5_pbev2.c p8_pkey.c 37 evp_asn1.c asn_pack.c p5_pbe.c p5_pbev2.c p8_pkey.c asn_moid.c
40LIBOBJ= a_object.o a_bitstr.o a_utctm.o a_gentm.o a_time.o a_int.o a_octet.o \ 38LIBOBJ= a_object.o a_bitstr.o a_utctm.o a_gentm.o a_time.o a_int.o a_octet.o \
41 a_null.o a_print.o a_type.o a_set.o a_dup.o a_d2i_fp.o a_i2d_fp.o a_bmp.o \ 39 a_print.o a_type.o a_set.o a_dup.o a_d2i_fp.o a_i2d_fp.o \
42 a_enum.o a_vis.o a_utf8.o a_sign.o a_digest.o a_verify.o a_mbstr.o a_strex.o \ 40 a_enum.o a_utf8.o a_sign.o a_digest.o a_verify.o a_mbstr.o a_strex.o \
43 x_algor.o x_val.o x_pubkey.o x_sig.o x_req.o x_attrib.o \ 41 x_algor.o x_val.o x_pubkey.o x_sig.o x_req.o x_attrib.o x_bignum.o \
44 x_name.o x_cinf.o x_x509.o x_x509a.o x_crl.o x_info.o x_spki.o nsseq.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 \
45 d2i_r_pr.o i2d_r_pr.o d2i_r_pu.o i2d_r_pu.o \
46 d2i_s_pr.o i2d_s_pr.o d2i_s_pu.o i2d_s_pu.o \
47 d2i_pu.o d2i_pr.o i2d_pu.o i2d_pr.o \ 43 d2i_pu.o d2i_pr.o i2d_pu.o i2d_pr.o \
48 t_req.o t_x509.o t_x509a.o t_crl.o t_pkey.o t_spki.o t_bitst.o \ 44 t_req.o t_x509.o t_x509a.o t_crl.o t_pkey.o t_spki.o t_bitst.o \
49 p7_i_s.o p7_signi.o p7_signd.o p7_recip.o p7_enc_c.o p7_evp.o \ 45 tasn_new.o tasn_fre.o tasn_enc.o tasn_dec.o tasn_utl.o tasn_typ.o \
50 p7_dgst.o p7_s_e.o p7_enc.o p7_lib.o \ 46 f_int.o f_string.o n_pkey.o \
51 f_int.o f_string.o i2d_dhp.o i2d_dsap.o d2i_dhp.o d2i_dsap.o n_pkey.o \
52 f_enum.o a_hdr.o x_pkey.o a_bool.o x_exten.o \ 47 f_enum.o a_hdr.o x_pkey.o a_bool.o x_exten.o \
53 asn1_par.o asn1_lib.o asn1_err.o a_meth.o a_bytes.o a_strnid.o \ 48 asn1_par.o asn1_lib.o asn1_err.o a_meth.o a_bytes.o a_strnid.o \
54 evp_asn1.o asn_pack.o p5_pbe.o p5_pbev2.o p8_pkey.o 49 evp_asn1.o asn_pack.o p5_pbe.o p5_pbev2.o p8_pkey.o asn_moid.o
55 50
56SRC= $(LIBSRC) 51SRC= $(LIBSRC)
57 52
58EXHEADER= asn1.h asn1_mac.h 53EXHEADER= asn1.h asn1_mac.h asn1t.h
59HEADER= $(EXHEADER) 54HEADER= $(EXHEADER)
60 55
61ALL= $(GENERAL) $(SRC) $(HEADER) 56ALL= $(GENERAL) $(SRC) $(HEADER)
@@ -75,8 +70,7 @@ all: lib
75 70
76lib: $(LIBOBJ) 71lib: $(LIBOBJ)
77 $(AR) $(LIB) $(LIBOBJ) 72 $(AR) $(LIB) $(LIBOBJ)
78 @echo You may get an error following this line. Please ignore. 73 $(RANLIB) $(LIB) || echo Never mind.
79 - $(RANLIB) $(LIB)
80 @touch lib 74 @touch lib
81 75
82files: 76files:
@@ -116,1231 +110,777 @@ clean:
116 110
117# DO NOT DELETE THIS LINE -- make depend depends on it. 111# DO NOT DELETE THIS LINE -- make depend depends on it.
118 112
119a_bitstr.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 113a_bitstr.o: ../../e_os.h ../../include/openssl/asn1.h
120a_bitstr.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 114a_bitstr.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
121a_bitstr.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 115a_bitstr.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
122a_bitstr.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 116a_bitstr.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
123a_bitstr.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 117a_bitstr.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
124a_bitstr.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 118a_bitstr.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
125a_bitstr.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 119a_bitstr.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
126a_bitstr.o: ../cryptlib.h 120a_bitstr.o: ../../include/openssl/symhacks.h ../cryptlib.h a_bitstr.c
127a_bmp.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 121a_bool.o: ../../e_os.h ../../include/openssl/asn1.h
128a_bmp.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 122a_bool.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
129a_bmp.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
130a_bmp.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
131a_bmp.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
132a_bmp.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
133a_bmp.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
134a_bmp.o: ../cryptlib.h
135a_bool.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
136a_bool.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 123a_bool.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
137a_bool.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 124a_bool.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
138a_bool.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 125a_bool.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
139a_bool.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 126a_bool.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
140a_bool.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 127a_bool.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
141a_bool.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 128a_bool.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
142a_bool.o: ../cryptlib.h 129a_bool.o: ../cryptlib.h a_bool.c
143a_bytes.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 130a_bytes.o: ../../e_os.h ../../include/openssl/asn1.h
144a_bytes.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 131a_bytes.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
145a_bytes.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 132a_bytes.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
146a_bytes.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 133a_bytes.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
147a_bytes.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 134a_bytes.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
148a_bytes.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 135a_bytes.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
149a_bytes.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 136a_bytes.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
150a_bytes.o: ../../include/openssl/symhacks.h ../cryptlib.h 137a_bytes.o: ../../include/openssl/symhacks.h ../cryptlib.h a_bytes.c
151a_d2i_fp.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 138a_d2i_fp.o: ../../e_os.h ../../include/openssl/asn1.h
152a_d2i_fp.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 139a_d2i_fp.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h
153a_d2i_fp.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 140a_d2i_fp.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
154a_d2i_fp.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 141a_d2i_fp.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
155a_d2i_fp.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 142a_d2i_fp.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
156a_d2i_fp.o: ../../include/openssl/opensslconf.h 143a_d2i_fp.o: ../../include/openssl/opensslconf.h
157a_d2i_fp.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 144a_d2i_fp.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
158a_d2i_fp.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 145a_d2i_fp.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
159a_d2i_fp.o: ../cryptlib.h 146a_d2i_fp.o: ../../include/openssl/symhacks.h ../cryptlib.h a_d2i_fp.c
160a_digest.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 147a_digest.o: ../../e_os.h ../../include/openssl/asn1.h
161a_digest.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 148a_digest.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
162a_digest.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 149a_digest.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
163a_digest.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
164a_digest.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 150a_digest.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
165a_digest.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 151a_digest.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
166a_digest.o: ../../include/openssl/err.h ../../include/openssl/evp.h 152a_digest.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
167a_digest.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
168a_digest.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
169a_digest.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
170a_digest.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 153a_digest.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
171a_digest.o: ../../include/openssl/opensslconf.h 154a_digest.o: ../../include/openssl/opensslconf.h
172a_digest.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 155a_digest.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
173a_digest.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 156a_digest.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
174a_digest.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 157a_digest.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
175a_digest.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 158a_digest.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
176a_digest.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 159a_digest.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
177a_digest.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 160a_digest.o: ../cryptlib.h a_digest.c
178a_digest.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 161a_dup.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
179a_dup.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 162a_dup.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
180a_dup.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 163a_dup.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
181a_dup.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
182a_dup.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
183a_dup.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 164a_dup.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
184a_dup.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 165a_dup.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
185a_dup.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 166a_dup.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
186a_dup.o: ../../include/openssl/symhacks.h ../cryptlib.h 167a_dup.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
187a_enum.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 168a_dup.o: ../cryptlib.h a_dup.c
169a_enum.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
188a_enum.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 170a_enum.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
189a_enum.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 171a_enum.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
190a_enum.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 172a_enum.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
191a_enum.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 173a_enum.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
192a_enum.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 174a_enum.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
193a_enum.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 175a_enum.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
194a_enum.o: ../cryptlib.h 176a_enum.o: ../cryptlib.h a_enum.c
195a_gentm.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 177a_gentm.o: ../../e_os.h ../../include/openssl/asn1.h
196a_gentm.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 178a_gentm.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
197a_gentm.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 179a_gentm.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
198a_gentm.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 180a_gentm.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
199a_gentm.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 181a_gentm.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
200a_gentm.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 182a_gentm.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
201a_gentm.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 183a_gentm.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
202a_gentm.o: ../cryptlib.h 184a_gentm.o: ../../include/openssl/symhacks.h ../cryptlib.h ../o_time.h a_gentm.c
203a_hdr.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 185a_hdr.o: ../../e_os.h ../../include/openssl/asn1.h
204a_hdr.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 186a_hdr.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h
205a_hdr.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 187a_hdr.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
206a_hdr.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 188a_hdr.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
207a_hdr.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 189a_hdr.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
208a_hdr.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 190a_hdr.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
209a_hdr.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 191a_hdr.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
210a_hdr.o: ../../include/openssl/symhacks.h ../cryptlib.h 192a_hdr.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
211a_i2d_fp.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 193a_hdr.o: ../cryptlib.h a_hdr.c
194a_i2d_fp.o: ../../e_os.h ../../include/openssl/asn1.h
212a_i2d_fp.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 195a_i2d_fp.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
213a_i2d_fp.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 196a_i2d_fp.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
214a_i2d_fp.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 197a_i2d_fp.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
215a_i2d_fp.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 198a_i2d_fp.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
216a_i2d_fp.o: ../../include/openssl/opensslconf.h 199a_i2d_fp.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
217a_i2d_fp.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 200a_i2d_fp.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
218a_i2d_fp.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 201a_i2d_fp.o: ../../include/openssl/symhacks.h ../cryptlib.h a_i2d_fp.c
219a_i2d_fp.o: ../cryptlib.h 202a_int.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
220a_int.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
221a_int.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 203a_int.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
222a_int.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 204a_int.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
223a_int.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 205a_int.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
224a_int.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 206a_int.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
225a_int.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 207a_int.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
226a_int.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 208a_int.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
227a_int.o: ../cryptlib.h 209a_int.o: ../cryptlib.h a_int.c
228a_mbstr.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 210a_mbstr.o: ../../e_os.h ../../include/openssl/asn1.h
229a_mbstr.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 211a_mbstr.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
230a_mbstr.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 212a_mbstr.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
231a_mbstr.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 213a_mbstr.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
232a_mbstr.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 214a_mbstr.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
233a_mbstr.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 215a_mbstr.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
234a_mbstr.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 216a_mbstr.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
235a_mbstr.o: ../cryptlib.h 217a_mbstr.o: ../../include/openssl/symhacks.h ../cryptlib.h a_mbstr.c
236a_meth.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 218a_meth.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
237a_meth.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 219a_meth.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
238a_meth.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 220a_meth.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
239a_meth.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 221a_meth.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
240a_meth.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 222a_meth.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
241a_meth.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 223a_meth.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
242a_meth.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 224a_meth.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
243a_meth.o: ../cryptlib.h 225a_meth.o: ../cryptlib.h a_meth.c
244a_null.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 226a_object.o: ../../e_os.h ../../include/openssl/asn1.h
245a_null.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 227a_object.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
246a_null.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 228a_object.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
247a_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
248a_null.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
249a_null.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
250a_null.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
251a_null.o: ../cryptlib.h
252a_object.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
253a_object.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
254a_object.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
255a_object.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 229a_object.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
256a_object.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 230a_object.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
257a_object.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 231a_object.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
258a_object.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 232a_object.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
259a_object.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 233a_object.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
260a_object.o: ../cryptlib.h 234a_object.o: ../../include/openssl/symhacks.h ../cryptlib.h a_object.c
261a_octet.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 235a_octet.o: ../../e_os.h ../../include/openssl/asn1.h
262a_octet.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 236a_octet.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
263a_octet.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 237a_octet.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
264a_octet.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 238a_octet.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
265a_octet.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 239a_octet.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
266a_octet.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 240a_octet.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
267a_octet.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 241a_octet.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
268a_octet.o: ../cryptlib.h 242a_octet.o: ../../include/openssl/symhacks.h ../cryptlib.h a_octet.c
269a_print.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 243a_print.o: ../../e_os.h ../../include/openssl/asn1.h
270a_print.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 244a_print.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
271a_print.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 245a_print.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
272a_print.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 246a_print.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
273a_print.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 247a_print.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
274a_print.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 248a_print.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
275a_print.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 249a_print.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
276a_print.o: ../cryptlib.h 250a_print.o: ../../include/openssl/symhacks.h ../cryptlib.h a_print.c
277a_set.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 251a_set.o: ../../e_os.h ../../include/openssl/asn1.h
278a_set.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 252a_set.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h
279a_set.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 253a_set.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
280a_set.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 254a_set.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
281a_set.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 255a_set.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
282a_set.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 256a_set.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
283a_set.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 257a_set.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
284a_set.o: ../../include/openssl/symhacks.h ../cryptlib.h 258a_set.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
285a_sign.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 259a_set.o: ../cryptlib.h a_set.c
286a_sign.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 260a_sign.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
287a_sign.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 261a_sign.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
288a_sign.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 262a_sign.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
289a_sign.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 263a_sign.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
290a_sign.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
291a_sign.o: ../../include/openssl/err.h ../../include/openssl/evp.h 264a_sign.o: ../../include/openssl/err.h ../../include/openssl/evp.h
292a_sign.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 265a_sign.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
293a_sign.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 266a_sign.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
294a_sign.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 267a_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
295a_sign.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 268a_sign.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
296a_sign.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
297a_sign.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
298a_sign.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
299a_sign.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
300a_sign.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 269a_sign.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
301a_sign.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 270a_sign.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
302a_sign.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 271a_sign.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
303a_sign.o: ../cryptlib.h 272a_sign.o: ../cryptlib.h a_sign.c
304a_strex.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 273a_strex.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
305a_strex.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 274a_strex.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
306a_strex.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 275a_strex.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
307a_strex.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 276a_strex.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
308a_strex.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 277a_strex.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
309a_strex.o: ../../include/openssl/e_os2.h ../../include/openssl/evp.h
310a_strex.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
311a_strex.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
312a_strex.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
313a_strex.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 278a_strex.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
314a_strex.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 279a_strex.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
315a_strex.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h 280a_strex.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
316a_strex.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 281a_strex.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
317a_strex.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 282a_strex.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
318a_strex.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 283a_strex.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
319a_strex.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 284a_strex.o: ../../include/openssl/x509_vfy.h a_strex.c charmap.h
320a_strex.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 285a_strnid.o: ../../e_os.h ../../include/openssl/asn1.h
321a_strex.o: charmap.h 286a_strnid.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
322a_strnid.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 287a_strnid.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
323a_strnid.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
324a_strnid.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
325a_strnid.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 288a_strnid.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
326a_strnid.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 289a_strnid.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
327a_strnid.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 290a_strnid.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
328a_strnid.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 291a_strnid.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
329a_strnid.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 292a_strnid.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
330a_strnid.o: ../cryptlib.h 293a_strnid.o: ../../include/openssl/symhacks.h ../cryptlib.h a_strnid.c
331a_time.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 294a_time.o: ../../e_os.h ../../include/openssl/asn1.h
295a_time.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
332a_time.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 296a_time.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
333a_time.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 297a_time.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
334a_time.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 298a_time.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
335a_time.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 299a_time.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
336a_time.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 300a_time.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
337a_time.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 301a_time.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
338a_time.o: ../cryptlib.h 302a_time.o: ../cryptlib.h ../o_time.h a_time.c
339a_type.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 303a_type.o: ../../e_os.h ../../include/openssl/asn1.h
340a_type.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 304a_type.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
341a_type.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 305a_type.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
342a_type.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 306a_type.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
343a_type.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 307a_type.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
344a_type.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 308a_type.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
345a_type.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 309a_type.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
346a_type.o: ../../include/openssl/symhacks.h ../cryptlib.h 310a_type.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
347a_utctm.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 311a_type.o: ../cryptlib.h a_type.c
348a_utctm.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 312a_utctm.o: ../../e_os.h ../../include/openssl/asn1.h
349a_utctm.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 313a_utctm.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
314a_utctm.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
350a_utctm.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 315a_utctm.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
351a_utctm.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 316a_utctm.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
352a_utctm.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 317a_utctm.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
353a_utctm.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 318a_utctm.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
354a_utctm.o: ../cryptlib.h 319a_utctm.o: ../../include/openssl/symhacks.h ../cryptlib.h ../o_time.h a_utctm.c
355a_utf8.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 320a_utf8.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
356a_utf8.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 321a_utf8.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
357a_utf8.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 322a_utf8.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
358a_utf8.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 323a_utf8.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
359a_utf8.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 324a_utf8.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
360a_utf8.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 325a_utf8.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
361a_utf8.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 326a_utf8.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
362a_utf8.o: ../cryptlib.h 327a_utf8.o: ../cryptlib.h a_utf8.c
363a_verify.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 328a_verify.o: ../../e_os.h ../../include/openssl/asn1.h
364a_verify.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 329a_verify.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
365a_verify.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 330a_verify.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
366a_verify.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
367a_verify.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 331a_verify.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
368a_verify.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 332a_verify.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
369a_verify.o: ../../include/openssl/err.h ../../include/openssl/evp.h 333a_verify.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
370a_verify.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
371a_verify.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
372a_verify.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
373a_verify.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 334a_verify.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
374a_verify.o: ../../include/openssl/opensslconf.h 335a_verify.o: ../../include/openssl/opensslconf.h
375a_verify.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 336a_verify.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
376a_verify.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 337a_verify.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
377a_verify.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 338a_verify.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
378a_verify.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 339a_verify.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
379a_verify.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 340a_verify.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
380a_verify.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 341a_verify.o: ../cryptlib.h a_verify.c
381a_verify.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
382a_vis.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
383a_vis.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
384a_vis.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
385a_vis.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
386a_vis.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
387a_vis.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
388a_vis.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
389a_vis.o: ../cryptlib.h
390asn1_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 342asn1_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
391asn1_err.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h 343asn1_err.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
392asn1_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 344asn1_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
393asn1_err.o: ../../include/openssl/opensslconf.h 345asn1_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
394asn1_err.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 346asn1_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
395asn1_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 347asn1_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
396asn1_lib.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 348asn1_err.o: ../../include/openssl/symhacks.h asn1_err.c
349asn1_lib.o: ../../e_os.h ../../include/openssl/asn1.h
397asn1_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 350asn1_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
398asn1_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 351asn1_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
399asn1_lib.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 352asn1_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
400asn1_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 353asn1_lib.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
401asn1_lib.o: ../../include/openssl/opensslconf.h 354asn1_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
402asn1_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 355asn1_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
403asn1_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 356asn1_lib.o: ../../include/openssl/symhacks.h ../cryptlib.h asn1_lib.c
404asn1_lib.o: ../cryptlib.h 357asn1_par.o: ../../e_os.h ../../include/openssl/asn1.h
405asn1_par.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 358asn1_par.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
406asn1_par.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 359asn1_par.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
407asn1_par.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
408asn1_par.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 360asn1_par.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
409asn1_par.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 361asn1_par.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
410asn1_par.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 362asn1_par.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
411asn1_par.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 363asn1_par.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
412asn1_par.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 364asn1_par.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
413asn1_par.o: ../cryptlib.h 365asn1_par.o: ../../include/openssl/symhacks.h ../cryptlib.h asn1_par.c
414asn_pack.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 366asn_moid.o: ../../e_os.h ../../include/openssl/asn1.h
415asn_pack.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 367asn_moid.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
416asn_pack.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 368asn_moid.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
369asn_moid.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
370asn_moid.o: ../../include/openssl/dsa.h ../../include/openssl/dso.h
371asn_moid.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
372asn_moid.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
373asn_moid.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
374asn_moid.o: ../../include/openssl/opensslconf.h
375asn_moid.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
376asn_moid.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
377asn_moid.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
378asn_moid.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
379asn_moid.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
380asn_moid.o: ../cryptlib.h asn_moid.c
381asn_pack.o: ../../e_os.h ../../include/openssl/asn1.h
382asn_pack.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
383asn_pack.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
417asn_pack.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 384asn_pack.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
418asn_pack.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 385asn_pack.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
419asn_pack.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 386asn_pack.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
420asn_pack.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 387asn_pack.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
421asn_pack.o: ../cryptlib.h 388asn_pack.o: ../../include/openssl/symhacks.h ../cryptlib.h asn_pack.c
422d2i_dhp.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 389d2i_pr.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
423d2i_dhp.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 390d2i_pr.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
424d2i_dhp.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 391d2i_pr.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
425d2i_dhp.o: ../../include/openssl/dh.h ../../include/openssl/e_os.h 392d2i_pr.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
426d2i_dhp.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
427d2i_dhp.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
428d2i_dhp.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
429d2i_dhp.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
430d2i_dhp.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
431d2i_dhp.o: ../cryptlib.h
432d2i_dsap.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
433d2i_dsap.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
434d2i_dsap.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
435d2i_dsap.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
436d2i_dsap.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
437d2i_dsap.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
438d2i_dsap.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
439d2i_dsap.o: ../../include/openssl/opensslconf.h
440d2i_dsap.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
441d2i_dsap.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
442d2i_dsap.o: ../cryptlib.h
443d2i_pr.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
444d2i_pr.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
445d2i_pr.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
446d2i_pr.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
447d2i_pr.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
448d2i_pr.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
449d2i_pr.o: ../../include/openssl/err.h ../../include/openssl/evp.h 393d2i_pr.o: ../../include/openssl/err.h ../../include/openssl/evp.h
450d2i_pr.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 394d2i_pr.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
451d2i_pr.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 395d2i_pr.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
452d2i_pr.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 396d2i_pr.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
453d2i_pr.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
454d2i_pr.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
455d2i_pr.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
456d2i_pr.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
457d2i_pr.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 397d2i_pr.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
458d2i_pr.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 398d2i_pr.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
459d2i_pr.o: ../../include/openssl/symhacks.h ../cryptlib.h 399d2i_pr.o: ../cryptlib.h d2i_pr.c
460d2i_pu.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 400d2i_pu.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
461d2i_pu.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 401d2i_pu.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
462d2i_pu.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 402d2i_pu.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
463d2i_pu.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 403d2i_pu.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
464d2i_pu.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
465d2i_pu.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
466d2i_pu.o: ../../include/openssl/err.h ../../include/openssl/evp.h 404d2i_pu.o: ../../include/openssl/err.h ../../include/openssl/evp.h
467d2i_pu.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 405d2i_pu.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
468d2i_pu.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 406d2i_pu.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
469d2i_pu.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 407d2i_pu.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
470d2i_pu.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
471d2i_pu.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
472d2i_pu.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
473d2i_pu.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
474d2i_pu.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 408d2i_pu.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
475d2i_pu.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 409d2i_pu.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
476d2i_pu.o: ../../include/openssl/symhacks.h ../cryptlib.h 410d2i_pu.o: ../cryptlib.h d2i_pu.c
477d2i_r_pr.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 411evp_asn1.o: ../../e_os.h ../../include/openssl/asn1.h
478d2i_r_pr.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 412evp_asn1.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h
479d2i_r_pr.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 413evp_asn1.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
480d2i_r_pr.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 414evp_asn1.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
481d2i_r_pr.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
482d2i_r_pr.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
483d2i_r_pr.o: ../../include/openssl/opensslconf.h
484d2i_r_pr.o: ../../include/openssl/opensslv.h ../../include/openssl/rsa.h
485d2i_r_pr.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
486d2i_r_pr.o: ../../include/openssl/symhacks.h ../cryptlib.h
487d2i_r_pu.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
488d2i_r_pu.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
489d2i_r_pu.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
490d2i_r_pu.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
491d2i_r_pu.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
492d2i_r_pu.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
493d2i_r_pu.o: ../../include/openssl/opensslconf.h
494d2i_r_pu.o: ../../include/openssl/opensslv.h ../../include/openssl/rsa.h
495d2i_r_pu.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
496d2i_r_pu.o: ../../include/openssl/symhacks.h ../cryptlib.h
497d2i_s_pr.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
498d2i_s_pr.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
499d2i_s_pr.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
500d2i_s_pr.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
501d2i_s_pr.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
502d2i_s_pr.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
503d2i_s_pr.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
504d2i_s_pr.o: ../../include/openssl/opensslconf.h
505d2i_s_pr.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
506d2i_s_pr.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
507d2i_s_pr.o: ../cryptlib.h
508d2i_s_pu.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
509d2i_s_pu.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
510d2i_s_pu.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
511d2i_s_pu.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
512d2i_s_pu.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
513d2i_s_pu.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
514d2i_s_pu.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
515d2i_s_pu.o: ../../include/openssl/opensslconf.h
516d2i_s_pu.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
517d2i_s_pu.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
518d2i_s_pu.o: ../cryptlib.h
519evp_asn1.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
520evp_asn1.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
521evp_asn1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
522evp_asn1.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
523evp_asn1.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 415evp_asn1.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
524evp_asn1.o: ../../include/openssl/opensslconf.h 416evp_asn1.o: ../../include/openssl/opensslconf.h
525evp_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 417evp_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
526evp_asn1.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 418evp_asn1.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
527evp_asn1.o: ../cryptlib.h 419evp_asn1.o: ../../include/openssl/symhacks.h ../cryptlib.h evp_asn1.c
528f_enum.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 420f_enum.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
529f_enum.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 421f_enum.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
530f_enum.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 422f_enum.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
531f_enum.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 423f_enum.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
532f_enum.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 424f_enum.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
533f_enum.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 425f_enum.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
534f_enum.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 426f_enum.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
535f_enum.o: ../cryptlib.h 427f_enum.o: ../cryptlib.h f_enum.c
536f_int.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 428f_int.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
537f_int.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 429f_int.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
538f_int.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 430f_int.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
539f_int.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 431f_int.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
540f_int.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 432f_int.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
541f_int.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 433f_int.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
542f_int.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 434f_int.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
543f_int.o: ../cryptlib.h 435f_int.o: ../cryptlib.h f_int.c
544f_string.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 436f_string.o: ../../e_os.h ../../include/openssl/asn1.h
545f_string.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 437f_string.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
546f_string.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 438f_string.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
547f_string.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 439f_string.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
548f_string.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 440f_string.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
549f_string.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 441f_string.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
550f_string.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 442f_string.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
551f_string.o: ../cryptlib.h 443f_string.o: ../../include/openssl/symhacks.h ../cryptlib.h f_string.c
552i2d_dhp.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 444i2d_pr.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
553i2d_dhp.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 445i2d_pr.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
554i2d_dhp.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 446i2d_pr.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
555i2d_dhp.o: ../../include/openssl/dh.h ../../include/openssl/e_os.h 447i2d_pr.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
556i2d_dhp.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
557i2d_dhp.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
558i2d_dhp.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
559i2d_dhp.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
560i2d_dhp.o: ../cryptlib.h
561i2d_dsap.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
562i2d_dsap.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
563i2d_dsap.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
564i2d_dsap.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
565i2d_dsap.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
566i2d_dsap.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
567i2d_dsap.o: ../../include/openssl/opensslconf.h
568i2d_dsap.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
569i2d_dsap.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
570i2d_dsap.o: ../cryptlib.h
571i2d_pr.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
572i2d_pr.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
573i2d_pr.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
574i2d_pr.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
575i2d_pr.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
576i2d_pr.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
577i2d_pr.o: ../../include/openssl/err.h ../../include/openssl/evp.h 448i2d_pr.o: ../../include/openssl/err.h ../../include/openssl/evp.h
578i2d_pr.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 449i2d_pr.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
579i2d_pr.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 450i2d_pr.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
580i2d_pr.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 451i2d_pr.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
581i2d_pr.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
582i2d_pr.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
583i2d_pr.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
584i2d_pr.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
585i2d_pr.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 452i2d_pr.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
586i2d_pr.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 453i2d_pr.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
587i2d_pr.o: ../../include/openssl/symhacks.h ../cryptlib.h 454i2d_pr.o: ../cryptlib.h i2d_pr.c
588i2d_pu.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 455i2d_pu.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
589i2d_pu.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 456i2d_pu.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
590i2d_pu.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 457i2d_pu.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
591i2d_pu.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 458i2d_pu.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
592i2d_pu.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
593i2d_pu.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
594i2d_pu.o: ../../include/openssl/err.h ../../include/openssl/evp.h 459i2d_pu.o: ../../include/openssl/err.h ../../include/openssl/evp.h
595i2d_pu.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 460i2d_pu.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
596i2d_pu.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 461i2d_pu.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
597i2d_pu.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 462i2d_pu.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
598i2d_pu.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
599i2d_pu.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
600i2d_pu.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
601i2d_pu.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
602i2d_pu.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 463i2d_pu.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
603i2d_pu.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 464i2d_pu.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
604i2d_pu.o: ../../include/openssl/symhacks.h ../cryptlib.h 465i2d_pu.o: ../cryptlib.h i2d_pu.c
605i2d_r_pr.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 466n_pkey.o: ../../e_os.h ../../include/openssl/asn1.h
606i2d_r_pr.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 467n_pkey.o: ../../include/openssl/asn1_mac.h ../../include/openssl/asn1t.h
607i2d_r_pr.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 468n_pkey.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
608i2d_r_pr.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 469n_pkey.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
609i2d_r_pr.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 470n_pkey.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
610i2d_r_pr.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
611i2d_r_pr.o: ../../include/openssl/opensslconf.h
612i2d_r_pr.o: ../../include/openssl/opensslv.h ../../include/openssl/rsa.h
613i2d_r_pr.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
614i2d_r_pr.o: ../../include/openssl/symhacks.h ../cryptlib.h
615i2d_r_pu.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
616i2d_r_pu.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
617i2d_r_pu.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
618i2d_r_pu.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
619i2d_r_pu.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
620i2d_r_pu.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
621i2d_r_pu.o: ../../include/openssl/opensslconf.h
622i2d_r_pu.o: ../../include/openssl/opensslv.h ../../include/openssl/rsa.h
623i2d_r_pu.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
624i2d_r_pu.o: ../../include/openssl/symhacks.h ../cryptlib.h
625i2d_s_pr.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
626i2d_s_pr.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
627i2d_s_pr.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
628i2d_s_pr.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
629i2d_s_pr.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
630i2d_s_pr.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
631i2d_s_pr.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
632i2d_s_pr.o: ../../include/openssl/opensslconf.h
633i2d_s_pr.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
634i2d_s_pr.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
635i2d_s_pr.o: ../cryptlib.h
636i2d_s_pu.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
637i2d_s_pu.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
638i2d_s_pu.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
639i2d_s_pu.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
640i2d_s_pu.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
641i2d_s_pu.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
642i2d_s_pu.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
643i2d_s_pu.o: ../../include/openssl/opensslconf.h
644i2d_s_pu.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
645i2d_s_pu.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
646i2d_s_pu.o: ../cryptlib.h
647n_pkey.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
648n_pkey.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
649n_pkey.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
650n_pkey.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
651n_pkey.o: ../../include/openssl/des.h ../../include/openssl/dh.h
652n_pkey.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
653n_pkey.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 471n_pkey.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
654n_pkey.o: ../../include/openssl/evp.h ../../include/openssl/idea.h 472n_pkey.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
655n_pkey.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h 473n_pkey.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
656n_pkey.o: ../../include/openssl/md4.h ../../include/openssl/md5.h 474n_pkey.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
657n_pkey.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h 475n_pkey.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
658n_pkey.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
659n_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
660n_pkey.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
661n_pkey.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
662n_pkey.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 476n_pkey.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
663n_pkey.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 477n_pkey.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
664n_pkey.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 478n_pkey.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
665n_pkey.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 479n_pkey.o: ../../include/openssl/x509_vfy.h ../cryptlib.h n_pkey.c
666nsseq.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 480nsseq.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
667nsseq.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h 481nsseq.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
668nsseq.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 482nsseq.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
669nsseq.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h 483nsseq.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
670nsseq.o: ../../include/openssl/des.h ../../include/openssl/dh.h 484nsseq.o: ../../include/openssl/e_os2.h ../../include/openssl/evp.h
671nsseq.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h 485nsseq.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
672nsseq.o: ../../include/openssl/err.h ../../include/openssl/evp.h 486nsseq.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
673nsseq.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 487nsseq.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
674nsseq.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 488nsseq.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
675nsseq.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
676nsseq.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
677nsseq.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
678nsseq.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
679nsseq.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
680nsseq.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
681nsseq.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 489nsseq.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
682nsseq.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 490nsseq.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
683nsseq.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 491nsseq.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h nsseq.c
684p5_pbe.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 492p5_pbe.o: ../../e_os.h ../../include/openssl/asn1.h
685p5_pbe.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h 493p5_pbe.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
686p5_pbe.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 494p5_pbe.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
687p5_pbe.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h 495p5_pbe.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
688p5_pbe.o: ../../include/openssl/des.h ../../include/openssl/dh.h 496p5_pbe.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
689p5_pbe.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h 497p5_pbe.o: ../../include/openssl/err.h ../../include/openssl/evp.h
690p5_pbe.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 498p5_pbe.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
691p5_pbe.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
692p5_pbe.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
693p5_pbe.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
694p5_pbe.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
695p5_pbe.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 499p5_pbe.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
696p5_pbe.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 500p5_pbe.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
697p5_pbe.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h 501p5_pbe.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
698p5_pbe.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 502p5_pbe.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
699p5_pbe.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 503p5_pbe.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
700p5_pbe.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 504p5_pbe.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
701p5_pbe.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 505p5_pbe.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p5_pbe.c
702p5_pbe.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 506p5_pbev2.o: ../../e_os.h ../../include/openssl/asn1.h
703p5_pbe.o: ../cryptlib.h 507p5_pbev2.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
704p5_pbev2.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
705p5_pbev2.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
706p5_pbev2.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 508p5_pbev2.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
707p5_pbev2.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h 509p5_pbev2.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
708p5_pbev2.o: ../../include/openssl/des.h ../../include/openssl/dh.h 510p5_pbev2.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
709p5_pbev2.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h 511p5_pbev2.o: ../../include/openssl/err.h ../../include/openssl/evp.h
710p5_pbev2.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 512p5_pbev2.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
711p5_pbev2.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
712p5_pbev2.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
713p5_pbev2.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
714p5_pbev2.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
715p5_pbev2.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 513p5_pbev2.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
716p5_pbev2.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 514p5_pbev2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
717p5_pbev2.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h 515p5_pbev2.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
718p5_pbev2.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 516p5_pbev2.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
719p5_pbev2.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 517p5_pbev2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
720p5_pbev2.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 518p5_pbev2.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
721p5_pbev2.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 519p5_pbev2.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p5_pbev2.c
722p5_pbev2.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 520p8_pkey.o: ../../e_os.h ../../include/openssl/asn1.h
723p5_pbev2.o: ../cryptlib.h 521p8_pkey.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
724p7_dgst.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
725p7_dgst.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
726p7_dgst.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
727p7_dgst.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
728p7_dgst.o: ../../include/openssl/des.h ../../include/openssl/dh.h
729p7_dgst.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
730p7_dgst.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
731p7_dgst.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
732p7_dgst.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
733p7_dgst.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
734p7_dgst.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
735p7_dgst.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
736p7_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
737p7_dgst.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
738p7_dgst.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
739p7_dgst.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
740p7_dgst.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
741p7_dgst.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
742p7_dgst.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
743p7_enc.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
744p7_enc.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
745p7_enc.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
746p7_enc.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
747p7_enc.o: ../../include/openssl/des.h ../../include/openssl/dh.h
748p7_enc.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
749p7_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
750p7_enc.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
751p7_enc.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
752p7_enc.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
753p7_enc.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
754p7_enc.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
755p7_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
756p7_enc.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
757p7_enc.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
758p7_enc.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
759p7_enc.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
760p7_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
761p7_enc.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
762p7_enc_c.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
763p7_enc_c.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
764p7_enc_c.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
765p7_enc_c.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
766p7_enc_c.o: ../../include/openssl/des.h ../../include/openssl/dh.h
767p7_enc_c.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
768p7_enc_c.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
769p7_enc_c.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
770p7_enc_c.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
771p7_enc_c.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
772p7_enc_c.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
773p7_enc_c.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
774p7_enc_c.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
775p7_enc_c.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
776p7_enc_c.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
777p7_enc_c.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
778p7_enc_c.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
779p7_enc_c.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
780p7_enc_c.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
781p7_evp.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
782p7_evp.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
783p7_evp.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
784p7_evp.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
785p7_evp.o: ../../include/openssl/des.h ../../include/openssl/dh.h
786p7_evp.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
787p7_evp.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
788p7_evp.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
789p7_evp.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
790p7_evp.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
791p7_evp.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
792p7_evp.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
793p7_evp.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
794p7_evp.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
795p7_evp.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
796p7_evp.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
797p7_evp.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
798p7_evp.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
799p7_evp.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
800p7_i_s.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
801p7_i_s.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
802p7_i_s.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
803p7_i_s.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
804p7_i_s.o: ../../include/openssl/des.h ../../include/openssl/dh.h
805p7_i_s.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
806p7_i_s.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
807p7_i_s.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
808p7_i_s.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
809p7_i_s.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
810p7_i_s.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
811p7_i_s.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
812p7_i_s.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
813p7_i_s.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
814p7_i_s.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
815p7_i_s.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
816p7_i_s.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
817p7_i_s.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
818p7_i_s.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
819p7_lib.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
820p7_lib.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
821p7_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
822p7_lib.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
823p7_lib.o: ../../include/openssl/des.h ../../include/openssl/dh.h
824p7_lib.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
825p7_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
826p7_lib.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
827p7_lib.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
828p7_lib.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
829p7_lib.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
830p7_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
831p7_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
832p7_lib.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
833p7_lib.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
834p7_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
835p7_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
836p7_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
837p7_lib.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
838p7_recip.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
839p7_recip.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
840p7_recip.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
841p7_recip.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
842p7_recip.o: ../../include/openssl/des.h ../../include/openssl/dh.h
843p7_recip.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
844p7_recip.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
845p7_recip.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
846p7_recip.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
847p7_recip.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
848p7_recip.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
849p7_recip.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
850p7_recip.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
851p7_recip.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
852p7_recip.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
853p7_recip.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
854p7_recip.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
855p7_recip.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
856p7_recip.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
857p7_s_e.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
858p7_s_e.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
859p7_s_e.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
860p7_s_e.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
861p7_s_e.o: ../../include/openssl/des.h ../../include/openssl/dh.h
862p7_s_e.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
863p7_s_e.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
864p7_s_e.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
865p7_s_e.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
866p7_s_e.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
867p7_s_e.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
868p7_s_e.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
869p7_s_e.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
870p7_s_e.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
871p7_s_e.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
872p7_s_e.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
873p7_s_e.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
874p7_s_e.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
875p7_s_e.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
876p7_signd.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
877p7_signd.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
878p7_signd.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
879p7_signd.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
880p7_signd.o: ../../include/openssl/des.h ../../include/openssl/dh.h
881p7_signd.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
882p7_signd.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
883p7_signd.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
884p7_signd.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
885p7_signd.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
886p7_signd.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
887p7_signd.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
888p7_signd.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
889p7_signd.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
890p7_signd.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
891p7_signd.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
892p7_signd.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
893p7_signd.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
894p7_signd.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
895p7_signi.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
896p7_signi.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
897p7_signi.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
898p7_signi.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
899p7_signi.o: ../../include/openssl/des.h ../../include/openssl/dh.h
900p7_signi.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
901p7_signi.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
902p7_signi.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
903p7_signi.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
904p7_signi.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
905p7_signi.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
906p7_signi.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
907p7_signi.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
908p7_signi.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
909p7_signi.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
910p7_signi.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
911p7_signi.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
912p7_signi.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
913p7_signi.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
914p8_pkey.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
915p8_pkey.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
916p8_pkey.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 522p8_pkey.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
917p8_pkey.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h 523p8_pkey.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
918p8_pkey.o: ../../include/openssl/des.h ../../include/openssl/dh.h 524p8_pkey.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
919p8_pkey.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h 525p8_pkey.o: ../../include/openssl/err.h ../../include/openssl/evp.h
920p8_pkey.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 526p8_pkey.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
921p8_pkey.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
922p8_pkey.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
923p8_pkey.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
924p8_pkey.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
925p8_pkey.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 527p8_pkey.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
926p8_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 528p8_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
927p8_pkey.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 529p8_pkey.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
928p8_pkey.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 530p8_pkey.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
929p8_pkey.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 531p8_pkey.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
930p8_pkey.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 532p8_pkey.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
931p8_pkey.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 533p8_pkey.o: ../cryptlib.h p8_pkey.c
932p8_pkey.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 534t_bitst.o: ../../e_os.h ../../include/openssl/asn1.h
933t_bitst.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 535t_bitst.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
934t_bitst.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 536t_bitst.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
935t_bitst.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 537t_bitst.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
936t_bitst.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h 538t_bitst.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
937t_bitst.o: ../../include/openssl/des.h ../../include/openssl/dh.h
938t_bitst.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
939t_bitst.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
940t_bitst.o: ../../include/openssl/err.h ../../include/openssl/evp.h 539t_bitst.o: ../../include/openssl/err.h ../../include/openssl/evp.h
941t_bitst.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 540t_bitst.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
942t_bitst.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 541t_bitst.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
943t_bitst.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 542t_bitst.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
944t_bitst.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 543t_bitst.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
945t_bitst.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
946t_bitst.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
947t_bitst.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
948t_bitst.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
949t_bitst.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 544t_bitst.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
950t_bitst.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 545t_bitst.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
951t_bitst.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 546t_bitst.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
952t_bitst.o: ../../include/openssl/x509v3.h ../cryptlib.h 547t_bitst.o: ../../include/openssl/x509v3.h ../cryptlib.h t_bitst.c
953t_crl.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 548t_crl.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
954t_crl.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 549t_crl.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
955t_crl.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
956t_crl.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h 550t_crl.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
957t_crl.o: ../../include/openssl/des.h ../../include/openssl/dh.h 551t_crl.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
958t_crl.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h 552t_crl.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
959t_crl.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 553t_crl.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
960t_crl.o: ../../include/openssl/err.h ../../include/openssl/evp.h
961t_crl.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
962t_crl.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
963t_crl.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
964t_crl.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 554t_crl.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
965t_crl.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 555t_crl.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
966t_crl.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h 556t_crl.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
967t_crl.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 557t_crl.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
968t_crl.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 558t_crl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
969t_crl.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 559t_crl.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
970t_crl.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 560t_crl.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
971t_crl.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 561t_crl.o: ../cryptlib.h t_crl.c
972t_crl.o: ../../include/openssl/x509v3.h ../cryptlib.h 562t_pkey.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
973t_pkey.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 563t_pkey.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
974t_pkey.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 564t_pkey.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
975t_pkey.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 565t_pkey.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
976t_pkey.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
977t_pkey.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 566t_pkey.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
978t_pkey.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 567t_pkey.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
979t_pkey.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 568t_pkey.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rsa.h
980t_pkey.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 569t_pkey.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
981t_pkey.o: ../cryptlib.h 570t_pkey.o: ../../include/openssl/symhacks.h ../cryptlib.h t_pkey.c
982t_req.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 571t_req.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
983t_req.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 572t_req.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
984t_req.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
985t_req.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h 573t_req.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
986t_req.o: ../../include/openssl/des.h ../../include/openssl/dh.h 574t_req.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
987t_req.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h 575t_req.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
988t_req.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 576t_req.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
989t_req.o: ../../include/openssl/err.h ../../include/openssl/evp.h
990t_req.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
991t_req.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
992t_req.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
993t_req.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 577t_req.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
994t_req.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 578t_req.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
995t_req.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h 579t_req.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
996t_req.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 580t_req.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
997t_req.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 581t_req.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
998t_req.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 582t_req.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
999t_req.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 583t_req.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
1000t_req.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 584t_req.o: ../cryptlib.h t_req.c
1001t_req.o: ../../include/openssl/x509v3.h ../cryptlib.h 585t_spki.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
1002t_spki.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
1003t_spki.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
1004t_spki.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 586t_spki.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
1005t_spki.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h 587t_spki.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
1006t_spki.o: ../../include/openssl/des.h ../../include/openssl/dh.h 588t_spki.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
1007t_spki.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h 589t_spki.o: ../../include/openssl/err.h ../../include/openssl/evp.h
1008t_spki.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 590t_spki.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
1009t_spki.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
1010t_spki.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
1011t_spki.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
1012t_spki.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
1013t_spki.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 591t_spki.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
1014t_spki.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 592t_spki.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
1015t_spki.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 593t_spki.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
1016t_spki.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 594t_spki.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
1017t_spki.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 595t_spki.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
1018t_spki.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 596t_spki.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
1019t_spki.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 597t_spki.o: ../cryptlib.h t_spki.c
1020t_spki.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 598t_x509.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
1021t_x509.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 599t_x509.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
1022t_x509.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
1023t_x509.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
1024t_x509.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h 600t_x509.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
1025t_x509.o: ../../include/openssl/des.h ../../include/openssl/dh.h 601t_x509.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
1026t_x509.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h 602t_x509.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
1027t_x509.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 603t_x509.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
1028t_x509.o: ../../include/openssl/err.h ../../include/openssl/evp.h
1029t_x509.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
1030t_x509.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
1031t_x509.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
1032t_x509.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 604t_x509.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
1033t_x509.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 605t_x509.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
1034t_x509.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h 606t_x509.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
1035t_x509.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 607t_x509.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
1036t_x509.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 608t_x509.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
1037t_x509.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 609t_x509.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
1038t_x509.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 610t_x509.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
1039t_x509.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 611t_x509.o: ../cryptlib.h t_x509.c
1040t_x509.o: ../../include/openssl/x509v3.h ../cryptlib.h 612t_x509a.o: ../../e_os.h ../../include/openssl/asn1.h
1041t_x509a.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 613t_x509a.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
1042t_x509a.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h 614t_x509a.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
1043t_x509a.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 615t_x509a.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
1044t_x509a.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
1045t_x509a.o: ../../include/openssl/des.h ../../include/openssl/dh.h
1046t_x509a.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
1047t_x509a.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 616t_x509a.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
1048t_x509a.o: ../../include/openssl/evp.h ../../include/openssl/idea.h 617t_x509a.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
1049t_x509a.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h 618t_x509a.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
1050t_x509a.o: ../../include/openssl/md4.h ../../include/openssl/md5.h 619t_x509a.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
1051t_x509a.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h 620t_x509a.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
1052t_x509a.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
1053t_x509a.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
1054t_x509a.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
1055t_x509a.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
1056t_x509a.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 621t_x509a.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
1057t_x509a.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 622t_x509a.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
1058t_x509a.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 623t_x509a.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
1059t_x509a.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 624t_x509a.o: ../../include/openssl/x509_vfy.h ../cryptlib.h t_x509a.c
1060x_algor.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 625tasn_dec.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
1061x_algor.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h 626tasn_dec.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
1062x_algor.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 627tasn_dec.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
1063x_algor.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h 628tasn_dec.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
1064x_algor.o: ../../include/openssl/des.h ../../include/openssl/dh.h 629tasn_dec.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
1065x_algor.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h 630tasn_dec.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
1066x_algor.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 631tasn_dec.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
1067x_algor.o: ../../include/openssl/evp.h ../../include/openssl/idea.h 632tasn_dec.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
1068x_algor.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h 633tasn_dec.o: ../../include/openssl/symhacks.h tasn_dec.c
1069x_algor.o: ../../include/openssl/md4.h ../../include/openssl/md5.h 634tasn_enc.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
1070x_algor.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h 635tasn_enc.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
636tasn_enc.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
637tasn_enc.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
638tasn_enc.o: ../../include/openssl/opensslconf.h
639tasn_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
640tasn_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
641tasn_enc.o: ../../include/openssl/symhacks.h tasn_enc.c
642tasn_fre.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
643tasn_fre.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
644tasn_fre.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
645tasn_fre.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
646tasn_fre.o: ../../include/openssl/opensslconf.h
647tasn_fre.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
648tasn_fre.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
649tasn_fre.o: ../../include/openssl/symhacks.h tasn_fre.c
650tasn_new.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
651tasn_new.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
652tasn_new.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
653tasn_new.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
654tasn_new.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
655tasn_new.o: ../../include/openssl/opensslconf.h
656tasn_new.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
657tasn_new.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
658tasn_new.o: ../../include/openssl/symhacks.h tasn_new.c
659tasn_typ.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
660tasn_typ.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
661tasn_typ.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
662tasn_typ.o: ../../include/openssl/opensslconf.h
663tasn_typ.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
664tasn_typ.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
665tasn_typ.o: ../../include/openssl/symhacks.h tasn_typ.c
666tasn_utl.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
667tasn_utl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
668tasn_utl.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
669tasn_utl.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
670tasn_utl.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
671tasn_utl.o: ../../include/openssl/opensslconf.h
672tasn_utl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
673tasn_utl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
674tasn_utl.o: ../../include/openssl/symhacks.h tasn_utl.c
675x_algor.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
676x_algor.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
677x_algor.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
678x_algor.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
679x_algor.o: ../../include/openssl/e_os2.h ../../include/openssl/evp.h
680x_algor.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
1071x_algor.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 681x_algor.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
1072x_algor.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 682x_algor.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
1073x_algor.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 683x_algor.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
1074x_algor.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 684x_algor.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
1075x_algor.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 685x_algor.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
1076x_algor.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 686x_algor.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
1077x_algor.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 687x_algor.o: x_algor.c
1078x_algor.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 688x_attrib.o: ../../e_os.h ../../include/openssl/asn1.h
1079x_attrib.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 689x_attrib.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
1080x_attrib.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
1081x_attrib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 690x_attrib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
1082x_attrib.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h 691x_attrib.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
1083x_attrib.o: ../../include/openssl/des.h ../../include/openssl/dh.h 692x_attrib.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
1084x_attrib.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h 693x_attrib.o: ../../include/openssl/err.h ../../include/openssl/evp.h
1085x_attrib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 694x_attrib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
1086x_attrib.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
1087x_attrib.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
1088x_attrib.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
1089x_attrib.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
1090x_attrib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 695x_attrib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
1091x_attrib.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 696x_attrib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
1092x_attrib.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 697x_attrib.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
1093x_attrib.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 698x_attrib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
1094x_attrib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 699x_attrib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
1095x_attrib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 700x_attrib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
1096x_attrib.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 701x_attrib.o: ../cryptlib.h x_attrib.c
1097x_attrib.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 702x_bignum.o: ../../e_os.h ../../include/openssl/asn1.h
1098x_cinf.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 703x_bignum.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
1099x_cinf.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h 704x_bignum.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
1100x_cinf.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 705x_bignum.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
1101x_cinf.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h 706x_bignum.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
1102x_cinf.o: ../../include/openssl/des.h ../../include/openssl/dh.h 707x_bignum.o: ../../include/openssl/opensslconf.h
1103x_cinf.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h 708x_bignum.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
1104x_cinf.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 709x_bignum.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
1105x_cinf.o: ../../include/openssl/evp.h ../../include/openssl/idea.h 710x_bignum.o: ../../include/openssl/symhacks.h ../cryptlib.h x_bignum.c
1106x_cinf.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h 711x_crl.o: ../../e_os.h ../../include/openssl/asn1.h
1107x_cinf.o: ../../include/openssl/md4.h ../../include/openssl/md5.h 712x_crl.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
1108x_cinf.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
1109x_cinf.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
1110x_cinf.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
1111x_cinf.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
1112x_cinf.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
1113x_cinf.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
1114x_cinf.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
1115x_cinf.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
1116x_cinf.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
1117x_crl.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
1118x_crl.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
1119x_crl.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 713x_crl.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
1120x_crl.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h 714x_crl.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
1121x_crl.o: ../../include/openssl/des.h ../../include/openssl/dh.h 715x_crl.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
1122x_crl.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h 716x_crl.o: ../../include/openssl/err.h ../../include/openssl/evp.h
1123x_crl.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 717x_crl.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
1124x_crl.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
1125x_crl.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
1126x_crl.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
1127x_crl.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
1128x_crl.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 718x_crl.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
1129x_crl.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 719x_crl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
1130x_crl.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 720x_crl.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
1131x_crl.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 721x_crl.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
1132x_crl.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 722x_crl.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
1133x_crl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 723x_crl.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
1134x_crl.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 724x_crl.o: ../cryptlib.h x_crl.c
1135x_crl.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 725x_exten.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
1136x_exten.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 726x_exten.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
1137x_exten.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h 727x_exten.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
1138x_exten.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 728x_exten.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
1139x_exten.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h 729x_exten.o: ../../include/openssl/e_os2.h ../../include/openssl/evp.h
1140x_exten.o: ../../include/openssl/des.h ../../include/openssl/dh.h 730x_exten.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
1141x_exten.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
1142x_exten.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
1143x_exten.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
1144x_exten.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
1145x_exten.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
1146x_exten.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
1147x_exten.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 731x_exten.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
1148x_exten.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 732x_exten.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
1149x_exten.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 733x_exten.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
1150x_exten.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 734x_exten.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
1151x_exten.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 735x_exten.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
1152x_exten.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 736x_exten.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
1153x_exten.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 737x_exten.o: x_exten.c
1154x_exten.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 738x_info.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
1155x_info.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
1156x_info.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
1157x_info.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 739x_info.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
1158x_info.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h 740x_info.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
1159x_info.o: ../../include/openssl/des.h ../../include/openssl/dh.h 741x_info.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
1160x_info.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h 742x_info.o: ../../include/openssl/err.h ../../include/openssl/evp.h
1161x_info.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 743x_info.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
1162x_info.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
1163x_info.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
1164x_info.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
1165x_info.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
1166x_info.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 744x_info.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
1167x_info.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 745x_info.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
1168x_info.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 746x_info.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
1169x_info.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 747x_info.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
1170x_info.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 748x_info.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
1171x_info.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 749x_info.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
1172x_info.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 750x_info.o: ../cryptlib.h x_info.c
1173x_info.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 751x_long.o: ../../e_os.h ../../include/openssl/asn1.h
1174x_name.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 752x_long.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
1175x_name.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h 753x_long.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
754x_long.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
755x_long.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
756x_long.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
757x_long.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
758x_long.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
759x_long.o: ../cryptlib.h x_long.c
760x_name.o: ../../e_os.h ../../include/openssl/asn1.h
761x_name.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
1176x_name.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 762x_name.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
1177x_name.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h 763x_name.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
1178x_name.o: ../../include/openssl/des.h ../../include/openssl/dh.h 764x_name.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
1179x_name.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h 765x_name.o: ../../include/openssl/err.h ../../include/openssl/evp.h
1180x_name.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 766x_name.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
1181x_name.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
1182x_name.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
1183x_name.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
1184x_name.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
1185x_name.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 767x_name.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
1186x_name.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 768x_name.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
1187x_name.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 769x_name.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
1188x_name.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 770x_name.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
1189x_name.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 771x_name.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
1190x_name.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 772x_name.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
1191x_name.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 773x_name.o: ../cryptlib.h x_name.c
1192x_name.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 774x_pkey.o: ../../e_os.h ../../include/openssl/asn1.h
1193x_pkey.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 775x_pkey.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h
1194x_pkey.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
1195x_pkey.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 776x_pkey.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
1196x_pkey.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h 777x_pkey.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
1197x_pkey.o: ../../include/openssl/des.h ../../include/openssl/dh.h 778x_pkey.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
1198x_pkey.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h 779x_pkey.o: ../../include/openssl/err.h ../../include/openssl/evp.h
1199x_pkey.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 780x_pkey.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
1200x_pkey.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
1201x_pkey.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
1202x_pkey.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
1203x_pkey.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
1204x_pkey.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 781x_pkey.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
1205x_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 782x_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
1206x_pkey.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 783x_pkey.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
1207x_pkey.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 784x_pkey.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
1208x_pkey.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 785x_pkey.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
1209x_pkey.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 786x_pkey.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
1210x_pkey.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 787x_pkey.o: ../cryptlib.h x_pkey.c
1211x_pkey.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 788x_pubkey.o: ../../e_os.h ../../include/openssl/asn1.h
1212x_pubkey.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 789x_pubkey.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
1213x_pubkey.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
1214x_pubkey.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 790x_pubkey.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
1215x_pubkey.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h 791x_pubkey.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
1216x_pubkey.o: ../../include/openssl/des.h ../../include/openssl/dh.h 792x_pubkey.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
1217x_pubkey.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h 793x_pubkey.o: ../../include/openssl/err.h ../../include/openssl/evp.h
1218x_pubkey.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 794x_pubkey.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
1219x_pubkey.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
1220x_pubkey.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
1221x_pubkey.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
1222x_pubkey.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
1223x_pubkey.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 795x_pubkey.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
1224x_pubkey.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 796x_pubkey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
1225x_pubkey.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 797x_pubkey.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
1226x_pubkey.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 798x_pubkey.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
1227x_pubkey.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 799x_pubkey.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
1228x_pubkey.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 800x_pubkey.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
1229x_pubkey.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 801x_pubkey.o: ../cryptlib.h x_pubkey.c
1230x_pubkey.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 802x_req.o: ../../e_os.h ../../include/openssl/asn1.h
1231x_req.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 803x_req.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
1232x_req.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
1233x_req.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 804x_req.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
1234x_req.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h 805x_req.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
1235x_req.o: ../../include/openssl/des.h ../../include/openssl/dh.h 806x_req.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
1236x_req.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h 807x_req.o: ../../include/openssl/err.h ../../include/openssl/evp.h
1237x_req.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 808x_req.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
1238x_req.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
1239x_req.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
1240x_req.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
1241x_req.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
1242x_req.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 809x_req.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
1243x_req.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 810x_req.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
1244x_req.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 811x_req.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
1245x_req.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 812x_req.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
1246x_req.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 813x_req.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
1247x_req.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 814x_req.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
1248x_req.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 815x_req.o: ../cryptlib.h x_req.c
1249x_req.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 816x_sig.o: ../../e_os.h ../../include/openssl/asn1.h
1250x_sig.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 817x_sig.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
1251x_sig.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
1252x_sig.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 818x_sig.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
1253x_sig.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h 819x_sig.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
1254x_sig.o: ../../include/openssl/des.h ../../include/openssl/dh.h 820x_sig.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
1255x_sig.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h 821x_sig.o: ../../include/openssl/err.h ../../include/openssl/evp.h
1256x_sig.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 822x_sig.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
1257x_sig.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
1258x_sig.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
1259x_sig.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
1260x_sig.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
1261x_sig.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 823x_sig.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
1262x_sig.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 824x_sig.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
1263x_sig.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 825x_sig.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
1264x_sig.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 826x_sig.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
1265x_sig.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 827x_sig.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
1266x_sig.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 828x_sig.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
1267x_sig.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 829x_sig.o: ../cryptlib.h x_sig.c
1268x_sig.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 830x_spki.o: ../../e_os.h ../../include/openssl/asn1.h
1269x_spki.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 831x_spki.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
1270x_spki.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
1271x_spki.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 832x_spki.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
1272x_spki.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h 833x_spki.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
1273x_spki.o: ../../include/openssl/des.h ../../include/openssl/dh.h 834x_spki.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
1274x_spki.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h 835x_spki.o: ../../include/openssl/err.h ../../include/openssl/evp.h
1275x_spki.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 836x_spki.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
1276x_spki.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
1277x_spki.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
1278x_spki.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
1279x_spki.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
1280x_spki.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 837x_spki.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
1281x_spki.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 838x_spki.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
1282x_spki.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 839x_spki.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
1283x_spki.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 840x_spki.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
1284x_spki.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 841x_spki.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
1285x_spki.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 842x_spki.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
1286x_spki.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 843x_spki.o: ../cryptlib.h x_spki.c
1287x_spki.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 844x_val.o: ../../e_os.h ../../include/openssl/asn1.h
1288x_val.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 845x_val.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
1289x_val.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
1290x_val.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 846x_val.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
1291x_val.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h 847x_val.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
1292x_val.o: ../../include/openssl/des.h ../../include/openssl/dh.h 848x_val.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
1293x_val.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h 849x_val.o: ../../include/openssl/err.h ../../include/openssl/evp.h
1294x_val.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 850x_val.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
1295x_val.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
1296x_val.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
1297x_val.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
1298x_val.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
1299x_val.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 851x_val.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
1300x_val.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 852x_val.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
1301x_val.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 853x_val.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
1302x_val.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 854x_val.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
1303x_val.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 855x_val.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
1304x_val.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 856x_val.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
1305x_val.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 857x_val.o: ../cryptlib.h x_val.c
1306x_val.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 858x_x509.o: ../../e_os.h ../../include/openssl/asn1.h
1307x_x509.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 859x_x509.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
1308x_x509.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
1309x_x509.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 860x_x509.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
1310x_x509.o: ../../include/openssl/cast.h ../../include/openssl/conf.h 861x_x509.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
1311x_x509.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
1312x_x509.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 862x_x509.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
1313x_x509.o: ../../include/openssl/e_os.h ../../include/openssl/e_os.h
1314x_x509.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 863x_x509.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
1315x_x509.o: ../../include/openssl/evp.h ../../include/openssl/idea.h 864x_x509.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
1316x_x509.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h 865x_x509.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
1317x_x509.o: ../../include/openssl/md4.h ../../include/openssl/md5.h 866x_x509.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
1318x_x509.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h 867x_x509.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
1319x_x509.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
1320x_x509.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
1321x_x509.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
1322x_x509.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
1323x_x509.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 868x_x509.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
1324x_x509.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 869x_x509.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
1325x_x509.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 870x_x509.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
1326x_x509.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h 871x_x509.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
1327x_x509.o: ../cryptlib.h 872x_x509.o: ../cryptlib.h x_x509.c
1328x_x509a.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 873x_x509a.o: ../../e_os.h ../../include/openssl/asn1.h
1329x_x509a.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h 874x_x509a.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
1330x_x509a.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 875x_x509a.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
1331x_x509a.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h 876x_x509a.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
1332x_x509a.o: ../../include/openssl/des.h ../../include/openssl/dh.h 877x_x509a.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
1333x_x509a.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h 878x_x509a.o: ../../include/openssl/err.h ../../include/openssl/evp.h
1334x_x509a.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 879x_x509a.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
1335x_x509a.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
1336x_x509a.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
1337x_x509a.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
1338x_x509a.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
1339x_x509a.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 880x_x509a.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
1340x_x509a.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 881x_x509a.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
1341x_x509a.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 882x_x509a.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
1342x_x509a.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 883x_x509a.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
1343x_x509a.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 884x_x509a.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
1344x_x509a.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 885x_x509a.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
1345x_x509a.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 886x_x509a.o: ../cryptlib.h x_x509a.c
1346x_x509a.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
diff --git a/src/lib/libcrypto/asn1/a_bitstr.c b/src/lib/libcrypto/asn1/a_bitstr.c
index 7013a407ad..c36817c1ee 100644
--- a/src/lib/libcrypto/asn1/a_bitstr.c
+++ b/src/lib/libcrypto/asn1/a_bitstr.c
@@ -60,27 +60,9 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/asn1.h> 61#include <openssl/asn1.h>
62 62
63ASN1_BIT_STRING *ASN1_BIT_STRING_new(void)
64{ return M_ASN1_BIT_STRING_new(); }
65
66void ASN1_BIT_STRING_free(ASN1_BIT_STRING *x)
67{ M_ASN1_BIT_STRING_free(x); }
68
69int ASN1_BIT_STRING_set(ASN1_BIT_STRING *x, unsigned char *d, int len) 63int ASN1_BIT_STRING_set(ASN1_BIT_STRING *x, unsigned char *d, int len)
70{ return M_ASN1_BIT_STRING_set(x, d, len); } 64{ return M_ASN1_BIT_STRING_set(x, d, len); }
71 65
72int i2d_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp)
73{
74 int len, ret;
75 len = i2c_ASN1_BIT_STRING(a, NULL);
76 ret=ASN1_object_size(0,len,V_ASN1_BIT_STRING);
77 if(pp) {
78 ASN1_put_object(pp,0,len,V_ASN1_BIT_STRING,V_ASN1_UNIVERSAL);
79 i2c_ASN1_BIT_STRING(a, pp);
80 }
81 return ret;
82}
83
84int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp) 66int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp)
85 { 67 {
86 int ret,j,bits,len; 68 int ret,j,bits,len;
@@ -129,40 +111,6 @@ int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp)
129 return(ret); 111 return(ret);
130 } 112 }
131 113
132
133/* Convert DER encoded ASN1 BIT_STRING to ASN1_BIT_STRING structure */
134ASN1_BIT_STRING *d2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, unsigned char **pp,
135 long length)
136{
137 unsigned char *p;
138 long len;
139 int i;
140 int inf,tag,xclass;
141 ASN1_BIT_STRING *ret;
142
143 p= *pp;
144 inf=ASN1_get_object(&p,&len,&tag,&xclass,length);
145 if (inf & 0x80)
146 {
147 i=ASN1_R_BAD_OBJECT_HEADER;
148 goto err;
149 }
150
151 if (tag != V_ASN1_BIT_STRING)
152 {
153 i=ASN1_R_EXPECTING_A_BIT_STRING;
154 goto err;
155 }
156 if (len < 1) { i=ASN1_R_STRING_TOO_SHORT; goto err; }
157 ret = c2i_ASN1_BIT_STRING(a, &p, len);
158 if(ret) *pp = p;
159 return ret;
160err:
161 ASN1err(ASN1_F_D2I_ASN1_BIT_STRING,i);
162 return(NULL);
163
164}
165
166ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, unsigned char **pp, 114ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, unsigned char **pp,
167 long len) 115 long len)
168 { 116 {
@@ -224,6 +172,7 @@ int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value)
224 w=n/8; 172 w=n/8;
225 v=1<<(7-(n&0x07)); 173 v=1<<(7-(n&0x07));
226 iv= ~v; 174 iv= ~v;
175 if (!value) v=0;
227 176
228 a->flags&= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07); /* clear, set on write */ 177 a->flags&= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07); /* clear, set on write */
229 178
diff --git a/src/lib/libcrypto/asn1/a_bool.c b/src/lib/libcrypto/asn1/a_bool.c
index 18fa61840b..24333ea4d5 100644
--- a/src/lib/libcrypto/asn1/a_bool.c
+++ b/src/lib/libcrypto/asn1/a_bool.c
@@ -58,7 +58,7 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/asn1.h> 61#include <openssl/asn1t.h>
62 62
63int i2d_ASN1_BOOLEAN(int a, unsigned char **pp) 63int i2d_ASN1_BOOLEAN(int a, unsigned char **pp)
64 { 64 {
@@ -110,3 +110,5 @@ err:
110 ASN1err(ASN1_F_D2I_ASN1_BOOLEAN,i); 110 ASN1err(ASN1_F_D2I_ASN1_BOOLEAN,i);
111 return(ret); 111 return(ret);
112 } 112 }
113
114
diff --git a/src/lib/libcrypto/asn1/a_bytes.c b/src/lib/libcrypto/asn1/a_bytes.c
index 3a0c0c7835..bb88660f58 100644
--- a/src/lib/libcrypto/asn1/a_bytes.c
+++ b/src/lib/libcrypto/asn1/a_bytes.c
@@ -58,18 +58,7 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/asn1_mac.h> 61#include <openssl/asn1.h>
62
63static unsigned long tag2bit[32]={
640, 0, 0, B_ASN1_BIT_STRING, /* tags 0 - 3 */
65B_ASN1_OCTET_STRING, 0, 0, B_ASN1_UNKNOWN,/* tags 4- 7 */
66B_ASN1_UNKNOWN, B_ASN1_UNKNOWN, B_ASN1_UNKNOWN, B_ASN1_UNKNOWN,/* tags 8-11 */
67B_ASN1_UTF8STRING,B_ASN1_UNKNOWN,B_ASN1_UNKNOWN,B_ASN1_UNKNOWN,/* tags 12-15 */
680, 0, B_ASN1_NUMERICSTRING,B_ASN1_PRINTABLESTRING,
69B_ASN1_T61STRING,B_ASN1_VIDEOTEXSTRING,B_ASN1_IA5STRING,0,
700,B_ASN1_GRAPHICSTRING,B_ASN1_ISO64STRING,B_ASN1_GENERALSTRING,
71B_ASN1_UNIVERSALSTRING,B_ASN1_UNKNOWN,B_ASN1_BMPSTRING,B_ASN1_UNKNOWN,
72 };
73 62
74static int asn1_collate_primitive(ASN1_STRING *a, ASN1_CTX *c); 63static int asn1_collate_primitive(ASN1_STRING *a, ASN1_CTX *c);
75/* type is a 'bitmap' of acceptable string types. 64/* type is a 'bitmap' of acceptable string types.
@@ -92,7 +81,7 @@ ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, unsigned char **pp,
92 i=ASN1_R_TAG_VALUE_TOO_HIGH;; 81 i=ASN1_R_TAG_VALUE_TOO_HIGH;;
93 goto err; 82 goto err;
94 } 83 }
95 if (!(tag2bit[tag] & type)) 84 if (!(ASN1_tag2bit(tag) & type))
96 { 85 {
97 i=ASN1_R_WRONG_TYPE; 86 i=ASN1_R_WRONG_TYPE;
98 goto err; 87 goto err;
diff --git a/src/lib/libcrypto/asn1/a_d2i_fp.c b/src/lib/libcrypto/asn1/a_d2i_fp.c
index a49d1cb289..a80fbe9ff7 100644
--- a/src/lib/libcrypto/asn1/a_d2i_fp.c
+++ b/src/lib/libcrypto/asn1/a_d2i_fp.c
@@ -61,9 +61,11 @@
61#include <openssl/buffer.h> 61#include <openssl/buffer.h>
62#include <openssl/asn1_mac.h> 62#include <openssl/asn1_mac.h>
63 63
64#define HEADER_SIZE 8 64static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb);
65
66#ifndef NO_OLD_ASN1
67#ifndef OPENSSL_NO_FP_API
65 68
66#ifndef NO_FP_API
67char *ASN1_d2i_fp(char *(*xnew)(), char *(*d2i)(), FILE *in, 69char *ASN1_d2i_fp(char *(*xnew)(), char *(*d2i)(), FILE *in,
68 unsigned char **x) 70 unsigned char **x)
69 { 71 {
@@ -85,10 +87,65 @@ char *ASN1_d2i_fp(char *(*xnew)(), char *(*d2i)(), FILE *in,
85char *ASN1_d2i_bio(char *(*xnew)(), char *(*d2i)(), BIO *in, 87char *ASN1_d2i_bio(char *(*xnew)(), char *(*d2i)(), BIO *in,
86 unsigned char **x) 88 unsigned char **x)
87 { 89 {
90 BUF_MEM *b = NULL;
91 unsigned char *p;
92 char *ret=NULL;
93 int len;
94
95 len = asn1_d2i_read_bio(in, &b);
96 if(len < 0) goto err;
97
98 p=(unsigned char *)b->data;
99 ret=d2i(x,&p,len);
100err:
101 if (b != NULL) BUF_MEM_free(b);
102 return(ret);
103 }
104
105#endif
106
107void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x)
108 {
109 BUF_MEM *b = NULL;
110 unsigned char *p;
111 void *ret=NULL;
112 int len;
113
114 len = asn1_d2i_read_bio(in, &b);
115 if(len < 0) goto err;
116
117 p=(unsigned char *)b->data;
118 ret=ASN1_item_d2i(x,&p,len, it);
119err:
120 if (b != NULL) BUF_MEM_free(b);
121 return(ret);
122 }
123
124#ifndef OPENSSL_NO_FP_API
125void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x)
126 {
127 BIO *b;
128 char *ret;
129
130 if ((b=BIO_new(BIO_s_file())) == NULL)
131 {
132 ASN1err(ASN1_F_ASN1_D2I_FP,ERR_R_BUF_LIB);
133 return(NULL);
134 }
135 BIO_set_fp(b,in,BIO_NOCLOSE);
136 ret=ASN1_item_d2i_bio(it,b,x);
137 BIO_free(b);
138 return(ret);
139 }
140#endif
141
142#define HEADER_SIZE 8
143static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
144 {
88 BUF_MEM *b; 145 BUF_MEM *b;
89 unsigned char *p; 146 unsigned char *p;
90 int i; 147 int i;
91 char *ret=NULL; 148 int ret=-1;
92 ASN1_CTX c; 149 ASN1_CTX c;
93 int want=HEADER_SIZE; 150 int want=HEADER_SIZE;
94 int eos=0; 151 int eos=0;
@@ -99,7 +156,7 @@ char *ASN1_d2i_bio(char *(*xnew)(), char *(*d2i)(), BIO *in,
99 if (b == NULL) 156 if (b == NULL)
100 { 157 {
101 ASN1err(ASN1_F_ASN1_D2I_BIO,ERR_R_MALLOC_FAILURE); 158 ASN1err(ASN1_F_ASN1_D2I_BIO,ERR_R_MALLOC_FAILURE);
102 return(NULL); 159 return -1;
103 } 160 }
104 161
105 ERR_clear_error(); 162 ERR_clear_error();
@@ -187,8 +244,8 @@ char *ASN1_d2i_bio(char *(*xnew)(), char *(*d2i)(), BIO *in,
187 } 244 }
188 } 245 }
189 246
190 p=(unsigned char *)b->data; 247 *pb = b;
191 ret=d2i(x,&p,off); 248 return off;
192err: 249err:
193 if (b != NULL) BUF_MEM_free(b); 250 if (b != NULL) BUF_MEM_free(b);
194 return(ret); 251 return(ret);
diff --git a/src/lib/libcrypto/asn1/a_digest.c b/src/lib/libcrypto/asn1/a_digest.c
index 8257b8639e..4931e222a0 100644
--- a/src/lib/libcrypto/asn1/a_digest.c
+++ b/src/lib/libcrypto/asn1/a_digest.c
@@ -69,10 +69,11 @@
69#include <openssl/buffer.h> 69#include <openssl/buffer.h>
70#include <openssl/x509.h> 70#include <openssl/x509.h>
71 71
72#ifndef NO_ASN1_OLD
73
72int ASN1_digest(int (*i2d)(), const EVP_MD *type, char *data, 74int ASN1_digest(int (*i2d)(), const EVP_MD *type, char *data,
73 unsigned char *md, unsigned int *len) 75 unsigned char *md, unsigned int *len)
74 { 76 {
75 EVP_MD_CTX ctx;
76 int i; 77 int i;
77 unsigned char *str,*p; 78 unsigned char *str,*p;
78 79
@@ -81,9 +82,24 @@ int ASN1_digest(int (*i2d)(), const EVP_MD *type, char *data,
81 p=str; 82 p=str;
82 i2d(data,&p); 83 i2d(data,&p);
83 84
84 EVP_DigestInit(&ctx,type); 85 EVP_Digest(str, i, md, len, type, NULL);
85 EVP_DigestUpdate(&ctx,str,i); 86 OPENSSL_free(str);
86 EVP_DigestFinal(&ctx,md,len); 87 return(1);
88 }
89
90#endif
91
92
93int ASN1_item_digest(const ASN1_ITEM *it, const EVP_MD *type, void *asn,
94 unsigned char *md, unsigned int *len)
95 {
96 int i;
97 unsigned char *str = NULL;
98
99 i=ASN1_item_i2d(asn,&str, it);
100 if (!str) return(0);
101
102 EVP_Digest(str, i, md, len, type, NULL);
87 OPENSSL_free(str); 103 OPENSSL_free(str);
88 return(1); 104 return(1);
89 } 105 }
diff --git a/src/lib/libcrypto/asn1/a_dup.c b/src/lib/libcrypto/asn1/a_dup.c
index c3bda58a5d..58a017884c 100644
--- a/src/lib/libcrypto/asn1/a_dup.c
+++ b/src/lib/libcrypto/asn1/a_dup.c
@@ -58,9 +58,9 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/asn1_mac.h> 61#include <openssl/asn1.h>
62 62
63#define READ_CHUNK 2048 63#ifndef NO_OLD_ASN1
64 64
65char *ASN1_dup(int (*i2d)(), char *(*d2i)(), char *x) 65char *ASN1_dup(int (*i2d)(), char *(*d2i)(), char *x)
66 { 66 {
@@ -81,3 +81,27 @@ char *ASN1_dup(int (*i2d)(), char *(*d2i)(), char *x)
81 OPENSSL_free(b); 81 OPENSSL_free(b);
82 return(ret); 82 return(ret);
83 } 83 }
84
85#endif
86
87/* ASN1_ITEM version of dup: this follows the model above except we don't need
88 * to allocate the buffer. At some point this could be rewritten to directly dup
89 * the underlying structure instead of doing and encode and decode.
90 */
91
92void *ASN1_item_dup(const ASN1_ITEM *it, void *x)
93 {
94 unsigned char *b = NULL, *p;
95 long i;
96 void *ret;
97
98 if (x == NULL) return(NULL);
99
100 i=ASN1_item_i2d(x,&b,it);
101 if (b == NULL)
102 { ASN1err(ASN1_F_ASN1_DUP,ERR_R_MALLOC_FAILURE); return(NULL); }
103 p= b;
104 ret=ASN1_item_d2i(NULL,&p,i, it);
105 OPENSSL_free(b);
106 return(ret);
107 }
diff --git a/src/lib/libcrypto/asn1/a_enum.c b/src/lib/libcrypto/asn1/a_enum.c
index 1428d1df7a..8a315fa371 100644
--- a/src/lib/libcrypto/asn1/a_enum.c
+++ b/src/lib/libcrypto/asn1/a_enum.c
@@ -65,60 +65,6 @@
65 * for comments on encoding see a_int.c 65 * for comments on encoding see a_int.c
66 */ 66 */
67 67
68ASN1_ENUMERATED *ASN1_ENUMERATED_new(void)
69{ return M_ASN1_ENUMERATED_new(); }
70
71void ASN1_ENUMERATED_free(ASN1_ENUMERATED *x)
72{ M_ASN1_ENUMERATED_free(x); }
73
74
75int i2d_ASN1_ENUMERATED(ASN1_ENUMERATED *a, unsigned char **pp)
76{
77 int len, ret;
78 if(!a) return 0;
79 len = i2c_ASN1_INTEGER(a, NULL);
80 ret=ASN1_object_size(0,len,V_ASN1_ENUMERATED);
81 if(pp) {
82 ASN1_put_object(pp,0,len,V_ASN1_ENUMERATED,V_ASN1_UNIVERSAL);
83 i2c_ASN1_INTEGER(a, pp);
84 }
85 return ret;
86}
87
88ASN1_ENUMERATED *d2i_ASN1_ENUMERATED(ASN1_ENUMERATED **a, unsigned char **pp,
89 long length)
90{
91 unsigned char *p;
92 long len;
93 int i;
94 int inf,tag,xclass;
95 ASN1_ENUMERATED *ret;
96
97 p= *pp;
98 inf=ASN1_get_object(&p,&len,&tag,&xclass,length);
99 if (inf & 0x80)
100 {
101 i=ASN1_R_BAD_OBJECT_HEADER;
102 goto err;
103 }
104
105 if (tag != V_ASN1_ENUMERATED)
106 {
107 i=ASN1_R_EXPECTING_AN_ENUMERATED;
108 goto err;
109 }
110 ret = c2i_ASN1_INTEGER(a, &p, len);
111 if(ret) {
112 ret->type = (V_ASN1_NEG & ret->type) | V_ASN1_ENUMERATED;
113 *pp = p;
114 }
115 return ret;
116err:
117 ASN1err(ASN1_F_D2I_ASN1_ENUMERATED,i);
118 return(NULL);
119
120}
121
122int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v) 68int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v)
123 { 69 {
124 int i,j,k; 70 int i,j,k;
@@ -168,7 +114,7 @@ long ASN1_ENUMERATED_get(ASN1_ENUMERATED *a)
168 if (i == V_ASN1_NEG_ENUMERATED) 114 if (i == V_ASN1_NEG_ENUMERATED)
169 neg=1; 115 neg=1;
170 else if (i != V_ASN1_ENUMERATED) 116 else if (i != V_ASN1_ENUMERATED)
171 return(0); 117 return -1;
172 118
173 if (a->length > sizeof(long)) 119 if (a->length > sizeof(long))
174 { 120 {
@@ -176,7 +122,7 @@ long ASN1_ENUMERATED_get(ASN1_ENUMERATED *a)
176 return(0xffffffffL); 122 return(0xffffffffL);
177 } 123 }
178 if (a->data == NULL) 124 if (a->data == NULL)
179 return(0); 125 return 0;
180 126
181 for (i=0; i<a->length; i++) 127 for (i=0; i<a->length; i++)
182 { 128 {
diff --git a/src/lib/libcrypto/asn1/a_gentm.c b/src/lib/libcrypto/asn1/a_gentm.c
index 314479a03d..cd09f68b38 100644
--- a/src/lib/libcrypto/asn1/a_gentm.c
+++ b/src/lib/libcrypto/asn1/a_gentm.c
@@ -61,13 +61,10 @@
61#include <stdio.h> 61#include <stdio.h>
62#include <time.h> 62#include <time.h>
63#include "cryptlib.h" 63#include "cryptlib.h"
64#include "o_time.h"
64#include <openssl/asn1.h> 65#include <openssl/asn1.h>
65 66
66ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_new(void) 67#if 0
67{ return M_ASN1_GENERALIZEDTIME_new(); }
68
69void ASN1_GENERALIZEDTIME_free(ASN1_GENERALIZEDTIME *x)
70{ M_ASN1_GENERALIZEDTIME_free(x); }
71 68
72int i2d_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME *a, unsigned char **pp) 69int i2d_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME *a, unsigned char **pp)
73 { 70 {
@@ -116,6 +113,8 @@ err:
116 return(NULL); 113 return(NULL);
117 } 114 }
118 115
116#endif
117
119int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *d) 118int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *d)
120 { 119 {
121 static int min[9]={ 0, 0, 1, 1, 0, 0, 0, 0, 0}; 120 static int min[9]={ 0, 0, 1, 1, 0, 0, 0, 0, 0};
@@ -147,6 +146,19 @@ int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *d)
147 146
148 if ((n < min[i]) || (n > max[i])) goto err; 147 if ((n < min[i]) || (n > max[i])) goto err;
149 } 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
150 if (a[o] == 'Z') 162 if (a[o] == 'Z')
151 o++; 163 o++;
152 else if ((a[o] == '+') || (a[o] == '-')) 164 else if ((a[o] == '+') || (a[o] == '-'))
@@ -182,6 +194,7 @@ int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, char *str)
182 { 194 {
183 ASN1_STRING_set((ASN1_STRING *)s, 195 ASN1_STRING_set((ASN1_STRING *)s,
184 (unsigned char *)str,t.length); 196 (unsigned char *)str,t.length);
197 s->type=V_ASN1_GENERALIZEDTIME;
185 } 198 }
186 return(1); 199 return(1);
187 } 200 }
@@ -194,21 +207,17 @@ ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,
194 { 207 {
195 char *p; 208 char *p;
196 struct tm *ts; 209 struct tm *ts;
197#if defined(THREADS) && !defined(WIN32)
198 struct tm data; 210 struct tm data;
199#endif
200 211
201 if (s == NULL) 212 if (s == NULL)
202 s=M_ASN1_GENERALIZEDTIME_new(); 213 s=M_ASN1_GENERALIZEDTIME_new();
203 if (s == NULL) 214 if (s == NULL)
204 return(NULL); 215 return(NULL);
205 216
206#if defined(THREADS) && !defined(WIN32) 217 ts=OPENSSL_gmtime(&t, &data);
207 gmtime_r(&t,&data); /* should return &data, but doesn't on some systems, so we don't even look at the return value */ 218 if (ts == NULL)
208 ts=&data; 219 return(NULL);
209#else 220
210 ts=gmtime(&t);
211#endif
212 p=(char *)s->data; 221 p=(char *)s->data;
213 if ((p == NULL) || (s->length < 16)) 222 if ((p == NULL) || (s->length < 16))
214 { 223 {
diff --git a/src/lib/libcrypto/asn1/a_i2d_fp.c b/src/lib/libcrypto/asn1/a_i2d_fp.c
index aee29a7790..f4f1b73ebe 100644
--- a/src/lib/libcrypto/asn1/a_i2d_fp.c
+++ b/src/lib/libcrypto/asn1/a_i2d_fp.c
@@ -59,9 +59,11 @@
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/buffer.h> 61#include <openssl/buffer.h>
62#include <openssl/asn1_mac.h> 62#include <openssl/asn1.h>
63 63
64#ifndef NO_FP_API 64#ifndef NO_OLD_ASN1
65
66#ifndef OPENSSL_NO_FP_API
65int ASN1_i2d_fp(int (*i2d)(), FILE *out, unsigned char *x) 67int ASN1_i2d_fp(int (*i2d)(), FILE *out, unsigned char *x)
66 { 68 {
67 BIO *b; 69 BIO *b;
@@ -111,3 +113,51 @@ int ASN1_i2d_bio(int (*i2d)(), BIO *out, unsigned char *x)
111 OPENSSL_free(b); 113 OPENSSL_free(b);
112 return(ret); 114 return(ret);
113 } 115 }
116
117#endif
118
119#ifndef OPENSSL_NO_FP_API
120int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x)
121 {
122 BIO *b;
123 int ret;
124
125 if ((b=BIO_new(BIO_s_file())) == NULL)
126 {
127 ASN1err(ASN1_F_ASN1_I2D_FP,ERR_R_BUF_LIB);
128 return(0);
129 }
130 BIO_set_fp(b,out,BIO_NOCLOSE);
131 ret=ASN1_item_i2d_bio(it,b,x);
132 BIO_free(b);
133 return(ret);
134 }
135#endif
136
137int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x)
138 {
139 unsigned char *b = NULL;
140 int i,j=0,n,ret=1;
141
142 n = ASN1_item_i2d(x, &b, it);
143 if (b == NULL)
144 {
145 ASN1err(ASN1_F_ASN1_I2D_BIO,ERR_R_MALLOC_FAILURE);
146 return(0);
147 }
148
149 for (;;)
150 {
151 i=BIO_write(out,&(b[j]),n);
152 if (i == n) break;
153 if (i <= 0)
154 {
155 ret=0;
156 break;
157 }
158 j+=i;
159 n-=i;
160 }
161 OPENSSL_free(b);
162 return(ret);
163 }
diff --git a/src/lib/libcrypto/asn1/a_int.c b/src/lib/libcrypto/asn1/a_int.c
index 6f0413f885..496704b9a5 100644
--- a/src/lib/libcrypto/asn1/a_int.c
+++ b/src/lib/libcrypto/asn1/a_int.c
@@ -60,33 +60,12 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/asn1.h> 61#include <openssl/asn1.h>
62 62
63ASN1_INTEGER *ASN1_INTEGER_new(void)
64{ return M_ASN1_INTEGER_new();}
65
66void ASN1_INTEGER_free(ASN1_INTEGER *x)
67{ M_ASN1_INTEGER_free(x);}
68
69ASN1_INTEGER *ASN1_INTEGER_dup(ASN1_INTEGER *x) 63ASN1_INTEGER *ASN1_INTEGER_dup(ASN1_INTEGER *x)
70{ return M_ASN1_INTEGER_dup(x);} 64{ return M_ASN1_INTEGER_dup(x);}
71 65
72int ASN1_INTEGER_cmp(ASN1_INTEGER *x, ASN1_INTEGER *y) 66int ASN1_INTEGER_cmp(ASN1_INTEGER *x, ASN1_INTEGER *y)
73{ return M_ASN1_INTEGER_cmp(x,y);} 67{ return M_ASN1_INTEGER_cmp(x,y);}
74 68
75/* Output ASN1 INTEGER including tag+length */
76
77int i2d_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp)
78{
79 int len, ret;
80 if(!a) return 0;
81 len = i2c_ASN1_INTEGER(a, NULL);
82 ret=ASN1_object_size(0,len,V_ASN1_INTEGER);
83 if(pp) {
84 ASN1_put_object(pp,0,len,V_ASN1_INTEGER,V_ASN1_UNIVERSAL);
85 i2c_ASN1_INTEGER(a, pp);
86 }
87 return ret;
88}
89
90/* 69/*
91 * This converts an ASN1 INTEGER into its content encoding. 70 * This converts an ASN1 INTEGER into its content encoding.
92 * The internal representation is an ASN1_STRING whose data is a big endian 71 * The internal representation is an ASN1_STRING whose data is a big endian
@@ -174,39 +153,6 @@ int i2c_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp)
174 return(ret); 153 return(ret);
175 } 154 }
176 155
177/* Convert DER encoded ASN1 INTEGER to ASN1_INTEGER structure */
178ASN1_INTEGER *d2i_ASN1_INTEGER(ASN1_INTEGER **a, unsigned char **pp,
179 long length)
180{
181 unsigned char *p;
182 long len;
183 int i;
184 int inf,tag,xclass;
185 ASN1_INTEGER *ret;
186
187 p= *pp;
188 inf=ASN1_get_object(&p,&len,&tag,&xclass,length);
189 if (inf & 0x80)
190 {
191 i=ASN1_R_BAD_OBJECT_HEADER;
192 goto err;
193 }
194
195 if (tag != V_ASN1_INTEGER)
196 {
197 i=ASN1_R_EXPECTING_AN_INTEGER;
198 goto err;
199 }
200 ret = c2i_ASN1_INTEGER(a, &p, len);
201 if(ret) *pp = p;
202 return ret;
203err:
204 ASN1err(ASN1_F_D2I_ASN1_INTEGER,i);
205 return(NULL);
206
207}
208
209
210/* Convert just ASN1 INTEGER content octets to ASN1_INTEGER structure */ 156/* Convert just ASN1 INTEGER content octets to ASN1_INTEGER structure */
211 157
212ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, unsigned char **pp, 158ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, unsigned char **pp,
@@ -414,7 +360,7 @@ long ASN1_INTEGER_get(ASN1_INTEGER *a)
414 if (i == V_ASN1_NEG_INTEGER) 360 if (i == V_ASN1_NEG_INTEGER)
415 neg=1; 361 neg=1;
416 else if (i != V_ASN1_INTEGER) 362 else if (i != V_ASN1_INTEGER)
417 return(0); 363 return -1;
418 364
419 if (a->length > sizeof(long)) 365 if (a->length > sizeof(long))
420 { 366 {
@@ -422,7 +368,7 @@ long ASN1_INTEGER_get(ASN1_INTEGER *a)
422 return(0xffffffffL); 368 return(0xffffffffL);
423 } 369 }
424 if (a->data == NULL) 370 if (a->data == NULL)
425 return(0); 371 return 0;
426 372
427 for (i=0; i<a->length; i++) 373 for (i=0; i<a->length; i++)
428 { 374 {
@@ -453,6 +399,12 @@ ASN1_INTEGER *BN_to_ASN1_INTEGER(BIGNUM *bn, ASN1_INTEGER *ai)
453 len=((j == 0)?0:((j/8)+1)); 399 len=((j == 0)?0:((j/8)+1));
454 ret->data=(unsigned char *)OPENSSL_malloc(len+4); 400 ret->data=(unsigned char *)OPENSSL_malloc(len+4);
455 ret->length=BN_bn2bin(bn,ret->data); 401 ret->length=BN_bn2bin(bn,ret->data);
402 /* Correct zero case */
403 if(!ret->length)
404 {
405 ret->data[0] = 0;
406 ret->length = 1;
407 }
456 return(ret); 408 return(ret);
457err: 409err:
458 if (ret != ai) M_ASN1_INTEGER_free(ret); 410 if (ret != ai) M_ASN1_INTEGER_free(ret);
diff --git a/src/lib/libcrypto/asn1/a_object.c b/src/lib/libcrypto/asn1/a_object.c
index 20caa2d3bd..71ce7c3896 100644
--- a/src/lib/libcrypto/asn1/a_object.c
+++ b/src/lib/libcrypto/asn1/a_object.c
@@ -302,7 +302,7 @@ void ASN1_OBJECT_free(ASN1_OBJECT *a)
302 } 302 }
303 303
304ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, int len, 304ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, int len,
305 char *sn, char *ln) 305 const char *sn, const char *ln)
306 { 306 {
307 ASN1_OBJECT o; 307 ASN1_OBJECT o;
308 308
diff --git a/src/lib/libcrypto/asn1/a_octet.c b/src/lib/libcrypto/asn1/a_octet.c
index 2586f4327d..9690bae0f1 100644
--- a/src/lib/libcrypto/asn1/a_octet.c
+++ b/src/lib/libcrypto/asn1/a_octet.c
@@ -60,12 +60,6 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/asn1.h> 61#include <openssl/asn1.h>
62 62
63ASN1_OCTET_STRING *ASN1_OCTET_STRING_new(void)
64{ return M_ASN1_OCTET_STRING_new(); }
65
66void ASN1_OCTET_STRING_free(ASN1_OCTET_STRING *x)
67{ M_ASN1_OCTET_STRING_free(x); }
68
69ASN1_OCTET_STRING *ASN1_OCTET_STRING_dup(ASN1_OCTET_STRING *x) 63ASN1_OCTET_STRING *ASN1_OCTET_STRING_dup(ASN1_OCTET_STRING *x)
70{ return M_ASN1_OCTET_STRING_dup(x); } 64{ return M_ASN1_OCTET_STRING_dup(x); }
71 65
@@ -75,21 +69,3 @@ int ASN1_OCTET_STRING_cmp(ASN1_OCTET_STRING *a, ASN1_OCTET_STRING *b)
75int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *x, unsigned char *d, int len) 69int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *x, unsigned char *d, int len)
76{ return M_ASN1_OCTET_STRING_set(x, d, len); } 70{ return M_ASN1_OCTET_STRING_set(x, d, len); }
77 71
78int i2d_ASN1_OCTET_STRING(ASN1_OCTET_STRING *a, unsigned char **pp)
79{ return M_i2d_ASN1_OCTET_STRING(a, pp); }
80
81ASN1_OCTET_STRING *d2i_ASN1_OCTET_STRING(ASN1_OCTET_STRING **a,
82 unsigned char **pp, long length)
83 {
84 ASN1_OCTET_STRING *ret=NULL;
85
86 ret=(ASN1_OCTET_STRING *)d2i_ASN1_bytes((ASN1_STRING **)a,
87 pp,length,V_ASN1_OCTET_STRING,V_ASN1_UNIVERSAL);
88 if (ret == NULL)
89 {
90 ASN1err(ASN1_F_D2I_ASN1_OCTET_STRING,ERR_R_NESTED_ASN1_ERROR);
91 return(NULL);
92 }
93 return(ret);
94 }
95
diff --git a/src/lib/libcrypto/asn1/a_print.c b/src/lib/libcrypto/asn1/a_print.c
index b7bd2bd18a..8035513f04 100644
--- a/src/lib/libcrypto/asn1/a_print.c
+++ b/src/lib/libcrypto/asn1/a_print.c
@@ -60,50 +60,6 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/asn1.h> 61#include <openssl/asn1.h>
62 62
63ASN1_IA5STRING *ASN1_IA5STRING_new(void)
64{ return M_ASN1_IA5STRING_new();}
65
66void ASN1_IA5STRING_free(ASN1_IA5STRING *x)
67{ M_ASN1_IA5STRING_free(x);}
68
69int i2d_ASN1_IA5STRING(ASN1_IA5STRING *a, unsigned char **pp)
70 { return(M_i2d_ASN1_IA5STRING(a,pp)); }
71
72ASN1_IA5STRING *d2i_ASN1_IA5STRING(ASN1_IA5STRING **a, unsigned char **pp,
73 long l)
74 { return(M_d2i_ASN1_IA5STRING(a,pp,l)); }
75
76ASN1_T61STRING *ASN1_T61STRING_new(void)
77{ return M_ASN1_T61STRING_new();}
78
79void ASN1_T61STRING_free(ASN1_T61STRING *x)
80{ M_ASN1_T61STRING_free(x);}
81
82ASN1_T61STRING *d2i_ASN1_T61STRING(ASN1_T61STRING **a, unsigned char **pp,
83 long l)
84 { return(M_d2i_ASN1_T61STRING(a,pp,l)); }
85
86ASN1_PRINTABLESTRING *ASN1_PRINTABLESTRING_new(void)
87{ return M_ASN1_PRINTABLESTRING_new();}
88
89void ASN1_PRINTABLESTRING_free(ASN1_PRINTABLESTRING *x)
90{ M_ASN1_PRINTABLESTRING_free(x);}
91
92ASN1_PRINTABLESTRING *d2i_ASN1_PRINTABLESTRING(ASN1_PRINTABLESTRING **a,
93 unsigned char **pp, long l)
94 { return(M_d2i_ASN1_PRINTABLESTRING(a,pp,
95 l)); }
96
97int i2d_ASN1_PRINTABLESTRING(ASN1_PRINTABLESTRING *a, unsigned char **pp)
98 { return(M_i2d_ASN1_PRINTABLESTRING(a,pp)); }
99
100int i2d_ASN1_PRINTABLE(ASN1_STRING *a, unsigned char **pp)
101 { return(M_i2d_ASN1_PRINTABLE(a,pp)); }
102
103ASN1_STRING *d2i_ASN1_PRINTABLE(ASN1_STRING **a, unsigned char **pp,
104 long l)
105 { return(M_d2i_ASN1_PRINTABLE(a,pp,l)); }
106
107int ASN1_PRINTABLE_type(unsigned char *s, int len) 63int ASN1_PRINTABLE_type(unsigned char *s, int len)
108 { 64 {
109 int c; 65 int c;
@@ -169,29 +125,3 @@ int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s)
169 s->type=ASN1_PRINTABLE_type(s->data,s->length); 125 s->type=ASN1_PRINTABLE_type(s->data,s->length);
170 return(1); 126 return(1);
171 } 127 }
172
173ASN1_STRING *DIRECTORYSTRING_new(void)
174{ return M_DIRECTORYSTRING_new();}
175
176void DIRECTORYSTRING_free(ASN1_STRING *x)
177{ M_DIRECTORYSTRING_free(x);}
178
179int i2d_DIRECTORYSTRING(ASN1_STRING *a, unsigned char **pp)
180 { return(M_i2d_DIRECTORYSTRING(a,pp)); }
181
182ASN1_STRING *d2i_DIRECTORYSTRING(ASN1_STRING **a, unsigned char **pp,
183 long l)
184 { return(M_d2i_DIRECTORYSTRING(a,pp,l)); }
185
186ASN1_STRING *DISPLAYTEXT_new(void)
187{ return M_DISPLAYTEXT_new();}
188
189void DISPLAYTEXT_free(ASN1_STRING *x)
190{ M_DISPLAYTEXT_free(x);}
191
192int i2d_DISPLAYTEXT(ASN1_STRING *a, unsigned char **pp)
193 { return(M_i2d_DISPLAYTEXT(a,pp)); }
194
195ASN1_STRING *d2i_DISPLAYTEXT(ASN1_STRING **a, unsigned char **pp,
196 long l)
197 { return(M_d2i_DISPLAYTEXT(a,pp,l)); }
diff --git a/src/lib/libcrypto/asn1/a_set.c b/src/lib/libcrypto/asn1/a_set.c
index caf5a1419c..19bb60fca8 100644
--- a/src/lib/libcrypto/asn1/a_set.c
+++ b/src/lib/libcrypto/asn1/a_set.c
@@ -60,6 +60,8 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/asn1_mac.h> 61#include <openssl/asn1_mac.h>
62 62
63#ifndef NO_ASN1_OLD
64
63typedef struct 65typedef struct
64 { 66 {
65 unsigned char *pbData; 67 unsigned char *pbData;
@@ -215,3 +217,4 @@ err:
215 return(NULL); 217 return(NULL);
216 } 218 }
217 219
220#endif
diff --git a/src/lib/libcrypto/asn1/a_sign.c b/src/lib/libcrypto/asn1/a_sign.c
index 4c651706d2..de53b44144 100644
--- a/src/lib/libcrypto/asn1/a_sign.c
+++ b/src/lib/libcrypto/asn1/a_sign.c
@@ -55,6 +55,59 @@
55 * copied and put under another distribution licence 55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58/* ====================================================================
59 * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
60 *
61 * Redistribution and use in source and binary forms, with or without
62 * modification, are permitted provided that the following conditions
63 * are met:
64 *
65 * 1. Redistributions of source code must retain the above copyright
66 * notice, this list of conditions and the following disclaimer.
67 *
68 * 2. Redistributions in binary form must reproduce the above copyright
69 * notice, this list of conditions and the following disclaimer in
70 * the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3. All advertising materials mentioning features or use of this
74 * software must display the following acknowledgment:
75 * "This product includes software developed by the OpenSSL Project
76 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
77 *
78 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
79 * endorse or promote products derived from this software without
80 * prior written permission. For written permission, please contact
81 * openssl-core@openssl.org.
82 *
83 * 5. Products derived from this software may not be called "OpenSSL"
84 * nor may "OpenSSL" appear in their names without prior written
85 * permission of the OpenSSL Project.
86 *
87 * 6. Redistributions of any form whatsoever must retain the following
88 * acknowledgment:
89 * "This product includes software developed by the OpenSSL Project
90 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
91 *
92 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
93 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
94 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
95 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
96 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
97 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
98 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
99 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
100 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
101 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
102 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
103 * OF THE POSSIBILITY OF SUCH DAMAGE.
104 * ====================================================================
105 *
106 * This product includes cryptographic software written by Eric Young
107 * (eay@cryptsoft.com). This product includes software written by Tim
108 * Hudson (tjh@cryptsoft.com).
109 *
110 */
58 111
59#include <stdio.h> 112#include <stdio.h>
60#include <time.h> 113#include <time.h>
@@ -71,6 +124,8 @@
71#include <openssl/objects.h> 124#include <openssl/objects.h>
72#include <openssl/buffer.h> 125#include <openssl/buffer.h>
73 126
127#ifndef NO_ASN1_OLD
128
74int ASN1_sign(int (*i2d)(), X509_ALGOR *algor1, X509_ALGOR *algor2, 129int ASN1_sign(int (*i2d)(), X509_ALGOR *algor1, X509_ALGOR *algor2,
75 ASN1_BIT_STRING *signature, char *data, EVP_PKEY *pkey, 130 ASN1_BIT_STRING *signature, char *data, EVP_PKEY *pkey,
76 const EVP_MD *type) 131 const EVP_MD *type)
@@ -80,6 +135,7 @@ int ASN1_sign(int (*i2d)(), X509_ALGOR *algor1, X509_ALGOR *algor2,
80 int i,inl=0,outl=0,outll=0; 135 int i,inl=0,outl=0,outll=0;
81 X509_ALGOR *a; 136 X509_ALGOR *a;
82 137
138 EVP_MD_CTX_init(&ctx);
83 for (i=0; i<2; i++) 139 for (i=0; i<2; i++)
84 { 140 {
85 if (i == 0) 141 if (i == 0)
@@ -87,7 +143,14 @@ int ASN1_sign(int (*i2d)(), X509_ALGOR *algor1, X509_ALGOR *algor2,
87 else 143 else
88 a=algor2; 144 a=algor2;
89 if (a == NULL) continue; 145 if (a == NULL) continue;
90 if ( (a->parameter == NULL) || 146 if (type->pkey_type == NID_dsaWithSHA1)
147 {
148 /* special case: RFC 2459 tells us to omit 'parameters'
149 * with id-dsa-with-sha1 */
150 ASN1_TYPE_free(a->parameter);
151 a->parameter = NULL;
152 }
153 else if ((a->parameter == NULL) ||
91 (a->parameter->type != V_ASN1_NULL)) 154 (a->parameter->type != V_ASN1_NULL))
92 { 155 {
93 ASN1_TYPE_free(a->parameter); 156 ASN1_TYPE_free(a->parameter);
@@ -120,7 +183,90 @@ int ASN1_sign(int (*i2d)(), X509_ALGOR *algor1, X509_ALGOR *algor2,
120 p=buf_in; 183 p=buf_in;
121 184
122 i2d(data,&p); 185 i2d(data,&p);
123 EVP_SignInit(&ctx,type); 186 EVP_SignInit_ex(&ctx,type, NULL);
187 EVP_SignUpdate(&ctx,(unsigned char *)buf_in,inl);
188 if (!EVP_SignFinal(&ctx,(unsigned char *)buf_out,
189 (unsigned int *)&outl,pkey))
190 {
191 outl=0;
192 ASN1err(ASN1_F_ASN1_SIGN,ERR_R_EVP_LIB);
193 goto err;
194 }
195 if (signature->data != NULL) OPENSSL_free(signature->data);
196 signature->data=buf_out;
197 buf_out=NULL;
198 signature->length=outl;
199 /* In the interests of compatibility, I'll make sure that
200 * the bit string has a 'not-used bits' value of 0
201 */
202 signature->flags&= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07);
203 signature->flags|=ASN1_STRING_FLAG_BITS_LEFT;
204err:
205 EVP_MD_CTX_cleanup(&ctx);
206 if (buf_in != NULL)
207 { memset((char *)buf_in,0,(unsigned int)inl); OPENSSL_free(buf_in); }
208 if (buf_out != NULL)
209 { memset((char *)buf_out,0,outll); OPENSSL_free(buf_out); }
210 return(outl);
211 }
212
213#endif
214
215int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2,
216 ASN1_BIT_STRING *signature, void *asn, EVP_PKEY *pkey,
217 const EVP_MD *type)
218 {
219 EVP_MD_CTX ctx;
220 unsigned char *buf_in=NULL,*buf_out=NULL;
221 int i,inl=0,outl=0,outll=0;
222 X509_ALGOR *a;
223
224 EVP_MD_CTX_init(&ctx);
225 for (i=0; i<2; i++)
226 {
227 if (i == 0)
228 a=algor1;
229 else
230 a=algor2;
231 if (a == NULL) continue;
232 if (type->pkey_type == NID_dsaWithSHA1)
233 {
234 /* special case: RFC 2459 tells us to omit 'parameters'
235 * with id-dsa-with-sha1 */
236 ASN1_TYPE_free(a->parameter);
237 a->parameter = NULL;
238 }
239 else if ((a->parameter == NULL) ||
240 (a->parameter->type != V_ASN1_NULL))
241 {
242 ASN1_TYPE_free(a->parameter);
243 if ((a->parameter=ASN1_TYPE_new()) == NULL) goto err;
244 a->parameter->type=V_ASN1_NULL;
245 }
246 ASN1_OBJECT_free(a->algorithm);
247 a->algorithm=OBJ_nid2obj(type->pkey_type);
248 if (a->algorithm == NULL)
249 {
250 ASN1err(ASN1_F_ASN1_SIGN,ASN1_R_UNKNOWN_OBJECT_TYPE);
251 goto err;
252 }
253 if (a->algorithm->length == 0)
254 {
255 ASN1err(ASN1_F_ASN1_SIGN,ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD);
256 goto err;
257 }
258 }
259 inl=ASN1_item_i2d(asn,&buf_in, it);
260 outll=outl=EVP_PKEY_size(pkey);
261 buf_out=(unsigned char *)OPENSSL_malloc((unsigned int)outl);
262 if ((buf_in == NULL) || (buf_out == NULL))
263 {
264 outl=0;
265 ASN1err(ASN1_F_ASN1_SIGN,ERR_R_MALLOC_FAILURE);
266 goto err;
267 }
268
269 EVP_SignInit_ex(&ctx,type, NULL);
124 EVP_SignUpdate(&ctx,(unsigned char *)buf_in,inl); 270 EVP_SignUpdate(&ctx,(unsigned char *)buf_in,inl);
125 if (!EVP_SignFinal(&ctx,(unsigned char *)buf_out, 271 if (!EVP_SignFinal(&ctx,(unsigned char *)buf_out,
126 (unsigned int *)&outl,pkey)) 272 (unsigned int *)&outl,pkey))
@@ -139,7 +285,7 @@ int ASN1_sign(int (*i2d)(), X509_ALGOR *algor1, X509_ALGOR *algor2,
139 signature->flags&= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07); 285 signature->flags&= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07);
140 signature->flags|=ASN1_STRING_FLAG_BITS_LEFT; 286 signature->flags|=ASN1_STRING_FLAG_BITS_LEFT;
141err: 287err:
142 memset(&ctx,0,sizeof(ctx)); 288 EVP_MD_CTX_cleanup(&ctx);
143 if (buf_in != NULL) 289 if (buf_in != NULL)
144 { memset((char *)buf_in,0,(unsigned int)inl); OPENSSL_free(buf_in); } 290 { memset((char *)buf_in,0,(unsigned int)inl); OPENSSL_free(buf_in); }
145 if (buf_out != NULL) 291 if (buf_out != NULL)
diff --git a/src/lib/libcrypto/asn1/a_strex.c b/src/lib/libcrypto/asn1/a_strex.c
index 569b811998..128aa7e772 100644
--- a/src/lib/libcrypto/asn1/a_strex.c
+++ b/src/lib/libcrypto/asn1/a_strex.c
@@ -371,6 +371,8 @@ static int do_indent(char_io *io_ch, void *arg, int indent)
371 return 1; 371 return 1;
372} 372}
373 373
374#define FN_WIDTH_LN 25
375#define FN_WIDTH_SN 10
374 376
375static int do_name_ex(char_io *io_ch, void *arg, X509_NAME *n, 377static int do_name_ex(char_io *io_ch, void *arg, X509_NAME *n,
376 int indent, unsigned long flags) 378 int indent, unsigned long flags)
@@ -456,19 +458,29 @@ static int do_name_ex(char_io *io_ch, void *arg, X509_NAME *n,
456 val = X509_NAME_ENTRY_get_data(ent); 458 val = X509_NAME_ENTRY_get_data(ent);
457 fn_nid = OBJ_obj2nid(fn); 459 fn_nid = OBJ_obj2nid(fn);
458 if(fn_opt != XN_FLAG_FN_NONE) { 460 if(fn_opt != XN_FLAG_FN_NONE) {
459 int objlen; 461 int objlen, fld_len;
460 if((fn_opt == XN_FLAG_FN_OID) || (fn_nid==NID_undef) ) { 462 if((fn_opt == XN_FLAG_FN_OID) || (fn_nid==NID_undef) ) {
461 OBJ_obj2txt(objtmp, 80, fn, 1); 463 OBJ_obj2txt(objtmp, 80, fn, 1);
464 fld_len = 0; /* XXX: what should this be? */
462 objbuf = objtmp; 465 objbuf = objtmp;
463 } else { 466 } else {
464 if(fn_opt == XN_FLAG_FN_SN) 467 if(fn_opt == XN_FLAG_FN_SN) {
468 fld_len = FN_WIDTH_SN;
465 objbuf = OBJ_nid2sn(fn_nid); 469 objbuf = OBJ_nid2sn(fn_nid);
466 else if(fn_opt == XN_FLAG_FN_LN) 470 } else if(fn_opt == XN_FLAG_FN_LN) {
471 fld_len = FN_WIDTH_LN;
467 objbuf = OBJ_nid2ln(fn_nid); 472 objbuf = OBJ_nid2ln(fn_nid);
468 else objbuf = ""; 473 } else {
474 fld_len = 0; /* XXX: what should this be? */
475 objbuf = "";
476 }
469 } 477 }
470 objlen = strlen(objbuf); 478 objlen = strlen(objbuf);
471 if(!io_ch(arg, objbuf, objlen)) return -1; 479 if(!io_ch(arg, objbuf, objlen)) return -1;
480 if ((objlen < fld_len) && (flags & XN_FLAG_FN_ALIGN)) {
481 if (!do_indent(io_ch, arg, fld_len - objlen)) return -1;
482 outlen += fld_len - objlen;
483 }
472 if(!io_ch(arg, sep_eq, sep_eq_len)) return -1; 484 if(!io_ch(arg, sep_eq, sep_eq_len)) return -1;
473 outlen += objlen + sep_eq_len; 485 outlen += objlen + sep_eq_len;
474 } 486 }
@@ -491,12 +503,24 @@ static int do_name_ex(char_io *io_ch, void *arg, X509_NAME *n,
491 503
492int X509_NAME_print_ex(BIO *out, X509_NAME *nm, int indent, unsigned long flags) 504int X509_NAME_print_ex(BIO *out, X509_NAME *nm, int indent, unsigned long flags)
493{ 505{
506 if(flags == XN_FLAG_COMPAT)
507 return X509_NAME_print(out, nm, indent);
494 return do_name_ex(send_bio_chars, out, nm, indent, flags); 508 return do_name_ex(send_bio_chars, out, nm, indent, flags);
495} 509}
496 510
497 511
498int X509_NAME_print_ex_fp(FILE *fp, X509_NAME *nm, int indent, unsigned long flags) 512int X509_NAME_print_ex_fp(FILE *fp, X509_NAME *nm, int indent, unsigned long flags)
499{ 513{
514 if(flags == XN_FLAG_COMPAT)
515 {
516 BIO *btmp;
517 int ret;
518 btmp = BIO_new_fp(fp, BIO_NOCLOSE);
519 if(!btmp) return -1;
520 ret = X509_NAME_print(btmp, nm, indent);
521 BIO_free(btmp);
522 return ret;
523 }
500 return do_name_ex(send_fp_chars, fp, nm, indent, flags); 524 return do_name_ex(send_fp_chars, fp, nm, indent, flags);
501} 525}
502 526
diff --git a/src/lib/libcrypto/asn1/a_strnid.c b/src/lib/libcrypto/asn1/a_strnid.c
index 732e68fe46..04789d1c63 100644
--- a/src/lib/libcrypto/asn1/a_strnid.c
+++ b/src/lib/libcrypto/asn1/a_strnid.c
@@ -105,9 +105,9 @@ int ASN1_STRING_set_default_mask_asc(char *p)
105 mask = strtoul(p + 5, &end, 0); 105 mask = strtoul(p + 5, &end, 0);
106 if(*end) return 0; 106 if(*end) return 0;
107 } else if(!strcmp(p, "nombstr")) 107 } else if(!strcmp(p, "nombstr"))
108 mask = ~(B_ASN1_BMPSTRING|B_ASN1_UTF8STRING); 108 mask = ~((unsigned long)(B_ASN1_BMPSTRING|B_ASN1_UTF8STRING));
109 else if(!strcmp(p, "pkix")) 109 else if(!strcmp(p, "pkix"))
110 mask = ~B_ASN1_T61STRING; 110 mask = ~((unsigned long)B_ASN1_T61STRING);
111 else if(!strcmp(p, "utf8only")) mask = B_ASN1_UTF8STRING; 111 else if(!strcmp(p, "utf8only")) mask = B_ASN1_UTF8STRING;
112 else if(!strcmp(p, "default")) 112 else if(!strcmp(p, "default"))
113 mask = 0xFFFFFFFFL; 113 mask = 0xFFFFFFFFL;
@@ -170,8 +170,10 @@ static ASN1_STRING_TABLE tbl_standard[] = {
170{NID_givenName, 1, ub_name, DIRSTRING_TYPE, 0}, 170{NID_givenName, 1, ub_name, DIRSTRING_TYPE, 0},
171{NID_surname, 1, ub_name, DIRSTRING_TYPE, 0}, 171{NID_surname, 1, ub_name, DIRSTRING_TYPE, 0},
172{NID_initials, 1, ub_name, DIRSTRING_TYPE, 0}, 172{NID_initials, 1, ub_name, DIRSTRING_TYPE, 0},
173{NID_friendlyName, -1, -1, B_ASN1_BMPSTRING, STABLE_NO_MASK},
173{NID_name, 1, ub_name, DIRSTRING_TYPE, 0}, 174{NID_name, 1, ub_name, DIRSTRING_TYPE, 0},
174{NID_dnQualifier, -1, -1, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK} 175{NID_dnQualifier, -1, -1, B_ASN1_PRINTABLESTRING, STABLE_NO_MASK},
176{NID_ms_csp_name, -1, -1, B_ASN1_BMPSTRING, STABLE_NO_MASK}
175}; 177};
176 178
177static int sk_table_cmp(const ASN1_STRING_TABLE * const *a, 179static int sk_table_cmp(const ASN1_STRING_TABLE * const *a,
diff --git a/src/lib/libcrypto/asn1/a_time.c b/src/lib/libcrypto/asn1/a_time.c
index 8c0ddee4ac..27ddd30899 100644
--- a/src/lib/libcrypto/asn1/a_time.c
+++ b/src/lib/libcrypto/asn1/a_time.c
@@ -64,14 +64,14 @@
64#include <stdio.h> 64#include <stdio.h>
65#include <time.h> 65#include <time.h>
66#include "cryptlib.h" 66#include "cryptlib.h"
67#include <openssl/asn1.h> 67#include "o_time.h"
68#include <openssl/asn1t.h>
68 69
69ASN1_TIME *ASN1_TIME_new(void) 70IMPLEMENT_ASN1_MSTRING(ASN1_TIME, B_ASN1_TIME)
70{ return M_ASN1_TIME_new(); }
71 71
72void ASN1_TIME_free(ASN1_TIME *x) 72IMPLEMENT_ASN1_FUNCTIONS(ASN1_TIME)
73{ M_ASN1_TIME_free(x); }
74 73
74#if 0
75int i2d_ASN1_TIME(ASN1_TIME *a, unsigned char **pp) 75int i2d_ASN1_TIME(ASN1_TIME *a, unsigned char **pp)
76 { 76 {
77#ifdef CHARSET_EBCDIC 77#ifdef CHARSET_EBCDIC
@@ -95,33 +95,64 @@ int i2d_ASN1_TIME(ASN1_TIME *a, unsigned char **pp)
95 ASN1err(ASN1_F_I2D_ASN1_TIME,ASN1_R_EXPECTING_A_TIME); 95 ASN1err(ASN1_F_I2D_ASN1_TIME,ASN1_R_EXPECTING_A_TIME);
96 return -1; 96 return -1;
97 } 97 }
98 98#endif
99
100ASN1_TIME *d2i_ASN1_TIME(ASN1_TIME **a, unsigned char **pp, long length)
101 {
102 unsigned char tag;
103 tag = **pp & ~V_ASN1_CONSTRUCTED;
104 if(tag == (V_ASN1_UTCTIME|V_ASN1_UNIVERSAL))
105 return d2i_ASN1_UTCTIME(a, pp, length);
106 if(tag == (V_ASN1_GENERALIZEDTIME|V_ASN1_UNIVERSAL))
107 return d2i_ASN1_GENERALIZEDTIME(a, pp, length);
108 ASN1err(ASN1_F_D2I_ASN1_TIME,ASN1_R_EXPECTING_A_TIME);
109 return(NULL);
110 }
111 99
112 100
113ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t) 101ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t)
114 { 102 {
115 struct tm *ts; 103 struct tm *ts;
116#if defined(THREADS) && !defined(WIN32) && !defined(__CYGWIN32__)
117 struct tm data; 104 struct tm data;
118 105
119 gmtime_r(&t,&data); 106 ts=OPENSSL_gmtime(&t,&data);
120 ts=&data; /* should return &data, but doesn't on some systems, so we don't even look at the return value */ 107 if (ts == NULL)
121#else 108 return NULL;
122 ts=gmtime(&t);
123#endif
124 if((ts->tm_year >= 50) && (ts->tm_year < 150)) 109 if((ts->tm_year >= 50) && (ts->tm_year < 150))
125 return ASN1_UTCTIME_set(s, t); 110 return ASN1_UTCTIME_set(s, t);
126 return ASN1_GENERALIZEDTIME_set(s,t); 111 return ASN1_GENERALIZEDTIME_set(s,t);
127 } 112 }
113
114int ASN1_TIME_check(ASN1_TIME *t)
115 {
116 if (t->type == V_ASN1_GENERALIZEDTIME)
117 return ASN1_GENERALIZEDTIME_check(t);
118 else if (t->type == V_ASN1_UTCTIME)
119 return ASN1_UTCTIME_check(t);
120 return 0;
121 }
122
123/* Convert an ASN1_TIME structure to GeneralizedTime */
124ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME **out)
125 {
126 ASN1_GENERALIZEDTIME *ret;
127 char *str;
128
129 if (!ASN1_TIME_check(t)) return NULL;
130
131 if (!out || !*out)
132 {
133 if (!(ret = ASN1_GENERALIZEDTIME_new ()))
134 return NULL;
135 if (out) *out = ret;
136 }
137 else ret = *out;
138
139 /* If already GeneralizedTime just copy across */
140 if (t->type == V_ASN1_GENERALIZEDTIME)
141 {
142 if(!ASN1_STRING_set(ret, t->data, t->length))
143 return NULL;
144 return ret;
145 }
146
147 /* grow the string */
148 if (!ASN1_STRING_set(ret, NULL, t->length + 2))
149 return NULL;
150 str = (char *)ret->data;
151 /* Work out the century and prepend */
152 if (t->data[0] >= '5') strcpy(str, "19");
153 else strcpy(str, "20");
154
155 strcat(str, (char *)t->data);
156
157 return ret;
158 }
diff --git a/src/lib/libcrypto/asn1/a_type.c b/src/lib/libcrypto/asn1/a_type.c
index e72a6b29e0..96e111cf23 100644
--- a/src/lib/libcrypto/asn1/a_type.c
+++ b/src/lib/libcrypto/asn1/a_type.c
@@ -57,236 +57,8 @@
57 */ 57 */
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <openssl/asn1t.h>
60#include "cryptlib.h" 61#include "cryptlib.h"
61#include <openssl/asn1_mac.h>
62
63static void ASN1_TYPE_component_free(ASN1_TYPE *a);
64int i2d_ASN1_TYPE(ASN1_TYPE *a, unsigned char **pp)
65 {
66 int r=0;
67
68 if (a == NULL) return(0);
69
70 switch (a->type)
71 {
72 case V_ASN1_NULL:
73 if (pp != NULL)
74 ASN1_put_object(pp,0,0,V_ASN1_NULL,V_ASN1_UNIVERSAL);
75 r=2;
76 break;
77 case V_ASN1_INTEGER:
78 case V_ASN1_NEG_INTEGER:
79 r=i2d_ASN1_INTEGER(a->value.integer,pp);
80 break;
81 case V_ASN1_ENUMERATED:
82 case V_ASN1_NEG_ENUMERATED:
83 r=i2d_ASN1_ENUMERATED(a->value.enumerated,pp);
84 break;
85 case V_ASN1_BIT_STRING:
86 r=i2d_ASN1_BIT_STRING(a->value.bit_string,pp);
87 break;
88 case V_ASN1_OCTET_STRING:
89 r=i2d_ASN1_OCTET_STRING(a->value.octet_string,pp);
90 break;
91 case V_ASN1_OBJECT:
92 r=i2d_ASN1_OBJECT(a->value.object,pp);
93 break;
94 case V_ASN1_PRINTABLESTRING:
95 r=M_i2d_ASN1_PRINTABLESTRING(a->value.printablestring,pp);
96 break;
97 case V_ASN1_T61STRING:
98 r=M_i2d_ASN1_T61STRING(a->value.t61string,pp);
99 break;
100 case V_ASN1_IA5STRING:
101 r=M_i2d_ASN1_IA5STRING(a->value.ia5string,pp);
102 break;
103 case V_ASN1_GENERALSTRING:
104 r=M_i2d_ASN1_GENERALSTRING(a->value.generalstring,pp);
105 break;
106 case V_ASN1_UNIVERSALSTRING:
107 r=M_i2d_ASN1_UNIVERSALSTRING(a->value.universalstring,pp);
108 break;
109 case V_ASN1_UTF8STRING:
110 r=M_i2d_ASN1_UTF8STRING(a->value.utf8string,pp);
111 break;
112 case V_ASN1_VISIBLESTRING:
113 r=M_i2d_ASN1_VISIBLESTRING(a->value.visiblestring,pp);
114 break;
115 case V_ASN1_BMPSTRING:
116 r=M_i2d_ASN1_BMPSTRING(a->value.bmpstring,pp);
117 break;
118 case V_ASN1_UTCTIME:
119 r=i2d_ASN1_UTCTIME(a->value.utctime,pp);
120 break;
121 case V_ASN1_GENERALIZEDTIME:
122 r=i2d_ASN1_GENERALIZEDTIME(a->value.generalizedtime,pp);
123 break;
124 case V_ASN1_SET:
125 case V_ASN1_SEQUENCE:
126 case V_ASN1_OTHER:
127 default:
128 if (a->value.set == NULL)
129 r=0;
130 else
131 {
132 r=a->value.set->length;
133 if (pp != NULL)
134 {
135 memcpy(*pp,a->value.set->data,r);
136 *pp+=r;
137 }
138 }
139 break;
140 }
141 return(r);
142 }
143
144ASN1_TYPE *d2i_ASN1_TYPE(ASN1_TYPE **a, unsigned char **pp, long length)
145 {
146 ASN1_TYPE *ret=NULL;
147 unsigned char *q,*p,*max;
148 int inf,tag,xclass;
149 long len;
150
151 if ((a == NULL) || ((*a) == NULL))
152 {
153 if ((ret=ASN1_TYPE_new()) == NULL) goto err;
154 }
155 else
156 ret=(*a);
157
158 p= *pp;
159 q=p;
160 max=(p+length);
161
162 inf=ASN1_get_object(&q,&len,&tag,&xclass,length);
163 if (inf & 0x80) goto err;
164 /* If not universal tag we've no idea what it is */
165 if(xclass != V_ASN1_UNIVERSAL) tag = V_ASN1_OTHER;
166
167 ASN1_TYPE_component_free(ret);
168
169 switch (tag)
170 {
171 case V_ASN1_NULL:
172 p=q;
173 ret->value.ptr=NULL;
174 break;
175 case V_ASN1_INTEGER:
176 if ((ret->value.integer=
177 d2i_ASN1_INTEGER(NULL,&p,max-p)) == NULL)
178 goto err;
179 break;
180 case V_ASN1_ENUMERATED:
181 if ((ret->value.enumerated=
182 d2i_ASN1_ENUMERATED(NULL,&p,max-p)) == NULL)
183 goto err;
184 break;
185 case V_ASN1_BIT_STRING:
186 if ((ret->value.bit_string=
187 d2i_ASN1_BIT_STRING(NULL,&p,max-p)) == NULL)
188 goto err;
189 break;
190 case V_ASN1_OCTET_STRING:
191 if ((ret->value.octet_string=
192 d2i_ASN1_OCTET_STRING(NULL,&p,max-p)) == NULL)
193 goto err;
194 break;
195 case V_ASN1_VISIBLESTRING:
196 if ((ret->value.visiblestring=
197 d2i_ASN1_VISIBLESTRING(NULL,&p,max-p)) == NULL)
198 goto err;
199 break;
200 case V_ASN1_UTF8STRING:
201 if ((ret->value.utf8string=
202 d2i_ASN1_UTF8STRING(NULL,&p,max-p)) == NULL)
203 goto err;
204 break;
205 case V_ASN1_OBJECT:
206 if ((ret->value.object=
207 d2i_ASN1_OBJECT(NULL,&p,max-p)) == NULL)
208 goto err;
209 break;
210 case V_ASN1_PRINTABLESTRING:
211 if ((ret->value.printablestring=
212 d2i_ASN1_PRINTABLESTRING(NULL,&p,max-p)) == NULL)
213 goto err;
214 break;
215 case V_ASN1_T61STRING:
216 if ((ret->value.t61string=
217 M_d2i_ASN1_T61STRING(NULL,&p,max-p)) == NULL)
218 goto err;
219 break;
220 case V_ASN1_IA5STRING:
221 if ((ret->value.ia5string=
222 M_d2i_ASN1_IA5STRING(NULL,&p,max-p)) == NULL)
223 goto err;
224 break;
225 case V_ASN1_GENERALSTRING:
226 if ((ret->value.generalstring=
227 M_d2i_ASN1_GENERALSTRING(NULL,&p,max-p)) == NULL)
228 goto err;
229 break;
230 case V_ASN1_UNIVERSALSTRING:
231 if ((ret->value.universalstring=
232 M_d2i_ASN1_UNIVERSALSTRING(NULL,&p,max-p)) == NULL)
233 goto err;
234 break;
235 case V_ASN1_BMPSTRING:
236 if ((ret->value.bmpstring=
237 M_d2i_ASN1_BMPSTRING(NULL,&p,max-p)) == NULL)
238 goto err;
239 break;
240 case V_ASN1_UTCTIME:
241 if ((ret->value.utctime=
242 d2i_ASN1_UTCTIME(NULL,&p,max-p)) == NULL)
243 goto err;
244 break;
245 case V_ASN1_GENERALIZEDTIME:
246 if ((ret->value.generalizedtime=
247 d2i_ASN1_GENERALIZEDTIME(NULL,&p,max-p)) == NULL)
248 goto err;
249 break;
250 case V_ASN1_SET:
251 case V_ASN1_SEQUENCE:
252 case V_ASN1_OTHER:
253 default:
254 /* Sets and sequences are left complete */
255 if ((ret->value.set=ASN1_STRING_new()) == NULL) goto err;
256 ret->value.set->type=tag;
257 len+=(q-p);
258 if (!ASN1_STRING_set(ret->value.set,p,(int)len)) goto err;
259 p+=len;
260 break;
261 }
262
263 ret->type=tag;
264 if (a != NULL) (*a)=ret;
265 *pp=p;
266 return(ret);
267err:
268 if ((ret != NULL) && ((a == NULL) || (*a != ret))) ASN1_TYPE_free(ret);
269 return(NULL);
270 }
271
272ASN1_TYPE *ASN1_TYPE_new(void)
273 {
274 ASN1_TYPE *ret=NULL;
275 ASN1_CTX c;
276
277 M_ASN1_New_Malloc(ret,ASN1_TYPE);
278 ret->type= -1;
279 ret->value.ptr=NULL;
280 return(ret);
281 M_ASN1_New_Error(ASN1_F_ASN1_TYPE_NEW);
282 }
283
284void ASN1_TYPE_free(ASN1_TYPE *a)
285 {
286 if (a == NULL) return;
287 ASN1_TYPE_component_free(a);
288 OPENSSL_free(a);
289 }
290 62
291int ASN1_TYPE_get(ASN1_TYPE *a) 63int ASN1_TYPE_get(ASN1_TYPE *a)
292 { 64 {
@@ -299,54 +71,11 @@ int ASN1_TYPE_get(ASN1_TYPE *a)
299void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value) 71void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value)
300 { 72 {
301 if (a->value.ptr != NULL) 73 if (a->value.ptr != NULL)
302 ASN1_TYPE_component_free(a); 74 ASN1_primitive_free((ASN1_VALUE **)&a, NULL);
303 a->type=type; 75 a->type=type;
304 a->value.ptr=value; 76 a->value.ptr=value;
305 } 77 }
306 78
307static void ASN1_TYPE_component_free(ASN1_TYPE *a)
308 {
309 if (a == NULL) return;
310
311 if (a->value.ptr != NULL)
312 {
313 switch (a->type)
314 {
315 case V_ASN1_OBJECT:
316 ASN1_OBJECT_free(a->value.object);
317 break;
318 case V_ASN1_NULL:
319 break;
320 case V_ASN1_INTEGER:
321 case V_ASN1_NEG_INTEGER:
322 case V_ASN1_ENUMERATED:
323 case V_ASN1_NEG_ENUMERATED:
324 case V_ASN1_BIT_STRING:
325 case V_ASN1_OCTET_STRING:
326 case V_ASN1_SEQUENCE:
327 case V_ASN1_SET:
328 case V_ASN1_NUMERICSTRING:
329 case V_ASN1_PRINTABLESTRING:
330 case V_ASN1_T61STRING:
331 case V_ASN1_VIDEOTEXSTRING:
332 case V_ASN1_IA5STRING:
333 case V_ASN1_UTCTIME:
334 case V_ASN1_GENERALIZEDTIME:
335 case V_ASN1_GRAPHICSTRING:
336 case V_ASN1_VISIBLESTRING:
337 case V_ASN1_GENERALSTRING:
338 case V_ASN1_UNIVERSALSTRING:
339 case V_ASN1_BMPSTRING:
340 case V_ASN1_UTF8STRING:
341 case V_ASN1_OTHER:
342 default:
343 ASN1_STRING_free((ASN1_STRING *)a->value.ptr);
344 break;
345 }
346 a->type=0;
347 a->value.ptr=NULL;
348 }
349 }
350 79
351IMPLEMENT_STACK_OF(ASN1_TYPE) 80IMPLEMENT_STACK_OF(ASN1_TYPE)
352IMPLEMENT_ASN1_SET_OF(ASN1_TYPE) 81IMPLEMENT_ASN1_SET_OF(ASN1_TYPE)
diff --git a/src/lib/libcrypto/asn1/a_utctm.c b/src/lib/libcrypto/asn1/a_utctm.c
index d381c9e0d1..ed2d827db2 100644
--- a/src/lib/libcrypto/asn1/a_utctm.c
+++ b/src/lib/libcrypto/asn1/a_utctm.c
@@ -58,20 +58,11 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <time.h> 60#include <time.h>
61#ifdef VMS
62#include <descrip.h>
63#include <lnmdef.h>
64#include <starlet.h>
65#endif
66#include "cryptlib.h" 61#include "cryptlib.h"
62#include "o_time.h"
67#include <openssl/asn1.h> 63#include <openssl/asn1.h>
68 64
69ASN1_UTCTIME *ASN1_UTCTIME_new(void) 65#if 0
70{ return M_ASN1_UTCTIME_new(); }
71
72void ASN1_UTCTIME_free(ASN1_UTCTIME *x)
73{ M_ASN1_UTCTIME_free(x); }
74
75int i2d_ASN1_UTCTIME(ASN1_UTCTIME *a, unsigned char **pp) 66int i2d_ASN1_UTCTIME(ASN1_UTCTIME *a, unsigned char **pp)
76 { 67 {
77#ifndef CHARSET_EBCDIC 68#ifndef CHARSET_EBCDIC
@@ -119,6 +110,8 @@ err:
119 return(NULL); 110 return(NULL);
120 } 111 }
121 112
113#endif
114
122int ASN1_UTCTIME_check(ASN1_UTCTIME *d) 115int ASN1_UTCTIME_check(ASN1_UTCTIME *d)
123 { 116 {
124 static int min[8]={ 0, 1, 1, 0, 0, 0, 0, 0}; 117 static int min[8]={ 0, 1, 1, 0, 0, 0, 0, 0};
@@ -182,6 +175,7 @@ int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, char *str)
182 { 175 {
183 ASN1_STRING_set((ASN1_STRING *)s, 176 ASN1_STRING_set((ASN1_STRING *)s,
184 (unsigned char *)str,t.length); 177 (unsigned char *)str,t.length);
178 s->type = V_ASN1_UTCTIME;
185 } 179 }
186 return(1); 180 return(1);
187 } 181 }
@@ -193,59 +187,17 @@ ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t)
193 { 187 {
194 char *p; 188 char *p;
195 struct tm *ts; 189 struct tm *ts;
196#if defined(THREADS) && !defined(WIN32) && !defined(__CYGWIN32__)
197
198 struct tm data; 190 struct tm data;
199#endif
200 191
201 if (s == NULL) 192 if (s == NULL)
202 s=M_ASN1_UTCTIME_new(); 193 s=M_ASN1_UTCTIME_new();
203 if (s == NULL) 194 if (s == NULL)
204 return(NULL); 195 return(NULL);
205 196
206#if defined(THREADS) && !defined(WIN32) && !defined(__CYGWIN32__) 197 ts=OPENSSL_gmtime(&t, &data);
207 gmtime_r(&t,&data); /* should return &data, but doesn't on some systems, so we don't even look at the return value */
208 ts=&data;
209#else
210 ts=gmtime(&t);
211#endif
212#ifdef VMS
213 if (ts == NULL) 198 if (ts == NULL)
214 { 199 return(NULL);
215 static $DESCRIPTOR(tabnam,"LNM$DCL_LOGICAL"); 200
216 static $DESCRIPTOR(lognam,"SYS$TIMEZONE_DIFFERENTIAL");
217 char result[256];
218 unsigned int reslen = 0;
219 struct {
220 short buflen;
221 short code;
222 void *bufaddr;
223 unsigned int *reslen;
224 } itemlist[] = {
225 { 0, LNM$_STRING, 0, 0 },
226 { 0, 0, 0, 0 },
227 };
228 int status;
229
230 /* Get the value for SYS$TIMEZONE_DIFFERENTIAL */
231 itemlist[0].buflen = sizeof(result);
232 itemlist[0].bufaddr = result;
233 itemlist[0].reslen = &reslen;
234 status = sys$trnlnm(0, &tabnam, &lognam, 0, itemlist);
235 if (!(status & 1))
236 return NULL;
237 result[reslen] = '\0';
238
239 /* Get the numerical value of the equivalence string */
240 status = atoi(result);
241
242 /* and use it to move time to GMT */
243 t -= status;
244
245 /* then convert the result to the time structure */
246 ts=(struct tm *)localtime(&t);
247 }
248#endif
249 p=(char *)s->data; 201 p=(char *)s->data;
250 if ((p == NULL) || (s->length < 14)) 202 if ((p == NULL) || (s->length < 14))
251 { 203 {
@@ -286,11 +238,7 @@ int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t)
286 238
287 t -= offset*60; /* FIXME: may overflow in extreme cases */ 239 t -= offset*60; /* FIXME: may overflow in extreme cases */
288 240
289#if defined(THREADS) && !defined(WIN32) && !defined(__CYGWIN32__) 241 { struct tm data; tm = OPENSSL_gmtime(&t, &data); }
290 { struct tm data; gmtime_r(&t, &data); tm = &data; }
291#else
292 tm = gmtime(&t);
293#endif
294 242
295#define return_cmp(a,b) if ((a)<(b)) return -1; else if ((a)>(b)) return 1 243#define return_cmp(a,b) if ((a)<(b)) return -1; else if ((a)>(b)) return 1
296 year = g2(s->data); 244 year = g2(s->data);
diff --git a/src/lib/libcrypto/asn1/a_utf8.c b/src/lib/libcrypto/asn1/a_utf8.c
index 854278f136..508e11e527 100644
--- a/src/lib/libcrypto/asn1/a_utf8.c
+++ b/src/lib/libcrypto/asn1/a_utf8.c
@@ -60,33 +60,6 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/asn1.h> 61#include <openssl/asn1.h>
62 62
63ASN1_UTF8STRING *ASN1_UTF8STRING_new(void)
64{ return M_ASN1_UTF8STRING_new();}
65
66void ASN1_UTF8STRING_free(ASN1_UTF8STRING *x)
67{ M_ASN1_UTF8STRING_free(x);}
68
69int i2d_ASN1_UTF8STRING(ASN1_UTF8STRING *a, unsigned char **pp)
70 {
71 return(i2d_ASN1_bytes((ASN1_STRING *)a,pp,
72 V_ASN1_UTF8STRING,V_ASN1_UNIVERSAL));
73 }
74
75ASN1_UTF8STRING *d2i_ASN1_UTF8STRING(ASN1_UTF8STRING **a, unsigned char **pp,
76 long length)
77 {
78 ASN1_UTF8STRING *ret=NULL;
79
80 ret=(ASN1_UTF8STRING *)d2i_ASN1_bytes((ASN1_STRING **)a,
81 pp,length,V_ASN1_UTF8STRING,V_ASN1_UNIVERSAL);
82 if (ret == NULL)
83 {
84 ASN1err(ASN1_F_D2I_ASN1_UTF8STRING,ERR_R_NESTED_ASN1_ERROR);
85 return(NULL);
86 }
87 return(ret);
88 }
89
90 63
91/* UTF8 utilities */ 64/* UTF8 utilities */
92 65
diff --git a/src/lib/libcrypto/asn1/a_verify.c b/src/lib/libcrypto/asn1/a_verify.c
index 2a11927e5c..bf41de5146 100644
--- a/src/lib/libcrypto/asn1/a_verify.c
+++ b/src/lib/libcrypto/asn1/a_verify.c
@@ -71,6 +71,8 @@
71#include <openssl/buffer.h> 71#include <openssl/buffer.h>
72#include <openssl/evp.h> 72#include <openssl/evp.h>
73 73
74#ifndef NO_ASN1_OLD
75
74int ASN1_verify(int (*i2d)(), X509_ALGOR *a, ASN1_BIT_STRING *signature, 76int ASN1_verify(int (*i2d)(), X509_ALGOR *a, ASN1_BIT_STRING *signature,
75 char *data, EVP_PKEY *pkey) 77 char *data, EVP_PKEY *pkey)
76 { 78 {
@@ -79,6 +81,7 @@ int ASN1_verify(int (*i2d)(), X509_ALGOR *a, ASN1_BIT_STRING *signature,
79 unsigned char *p,*buf_in=NULL; 81 unsigned char *p,*buf_in=NULL;
80 int ret= -1,i,inl; 82 int ret= -1,i,inl;
81 83
84 EVP_MD_CTX_init(&ctx);
82 i=OBJ_obj2nid(a->algorithm); 85 i=OBJ_obj2nid(a->algorithm);
83 type=EVP_get_digestbyname(OBJ_nid2sn(i)); 86 type=EVP_get_digestbyname(OBJ_nid2sn(i));
84 if (type == NULL) 87 if (type == NULL)
@@ -97,7 +100,57 @@ int ASN1_verify(int (*i2d)(), X509_ALGOR *a, ASN1_BIT_STRING *signature,
97 p=buf_in; 100 p=buf_in;
98 101
99 i2d(data,&p); 102 i2d(data,&p);
100 EVP_VerifyInit(&ctx,type); 103 EVP_VerifyInit_ex(&ctx,type, NULL);
104 EVP_VerifyUpdate(&ctx,(unsigned char *)buf_in,inl);
105
106 memset(buf_in,0,(unsigned int)inl);
107 OPENSSL_free(buf_in);
108
109 if (EVP_VerifyFinal(&ctx,(unsigned char *)signature->data,
110 (unsigned int)signature->length,pkey) <= 0)
111 {
112 ASN1err(ASN1_F_ASN1_VERIFY,ERR_R_EVP_LIB);
113 ret=0;
114 goto err;
115 }
116 /* we don't need to zero the 'ctx' because we just checked
117 * public information */
118 /* memset(&ctx,0,sizeof(ctx)); */
119 ret=1;
120err:
121 EVP_MD_CTX_cleanup(&ctx);
122 return(ret);
123 }
124
125#endif
126
127
128int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *a, ASN1_BIT_STRING *signature,
129 void *asn, EVP_PKEY *pkey)
130 {
131 EVP_MD_CTX ctx;
132 const EVP_MD *type;
133 unsigned char *buf_in=NULL;
134 int ret= -1,i,inl;
135
136 EVP_MD_CTX_init(&ctx);
137 i=OBJ_obj2nid(a->algorithm);
138 type=EVP_get_digestbyname(OBJ_nid2sn(i));
139 if (type == NULL)
140 {
141 ASN1err(ASN1_F_ASN1_VERIFY,ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM);
142 goto err;
143 }
144
145 inl = ASN1_item_i2d(asn, &buf_in, it);
146
147 if (buf_in == NULL)
148 {
149 ASN1err(ASN1_F_ASN1_VERIFY,ERR_R_MALLOC_FAILURE);
150 goto err;
151 }
152
153 EVP_VerifyInit_ex(&ctx,type, NULL);
101 EVP_VerifyUpdate(&ctx,(unsigned char *)buf_in,inl); 154 EVP_VerifyUpdate(&ctx,(unsigned char *)buf_in,inl);
102 155
103 memset(buf_in,0,(unsigned int)inl); 156 memset(buf_in,0,(unsigned int)inl);
@@ -115,5 +168,8 @@ int ASN1_verify(int (*i2d)(), X509_ALGOR *a, ASN1_BIT_STRING *signature,
115 /* memset(&ctx,0,sizeof(ctx)); */ 168 /* memset(&ctx,0,sizeof(ctx)); */
116 ret=1; 169 ret=1;
117err: 170err:
171 EVP_MD_CTX_cleanup(&ctx);
118 return(ret); 172 return(ret);
119 } 173 }
174
175
diff --git a/src/lib/libcrypto/asn1/asn1.h b/src/lib/libcrypto/asn1/asn1.h
index 6f956b1963..0d1713f8dd 100644
--- a/src/lib/libcrypto/asn1/asn1.h
+++ b/src/lib/libcrypto/asn1/asn1.h
@@ -60,15 +60,24 @@
60#define HEADER_ASN1_H 60#define HEADER_ASN1_H
61 61
62#include <time.h> 62#include <time.h>
63#ifndef NO_BIO 63#ifndef OPENSSL_NO_BIO
64#include <openssl/bio.h> 64#include <openssl/bio.h>
65#endif 65#endif
66#include <openssl/e_os2.h>
66#include <openssl/bn.h> 67#include <openssl/bn.h>
67#include <openssl/stack.h> 68#include <openssl/stack.h>
68#include <openssl/safestack.h> 69#include <openssl/safestack.h>
69 70
70#include <openssl/symhacks.h> 71#include <openssl/symhacks.h>
71 72
73#include <openssl/e_os2.h>
74#include <openssl/ossl_typ.h>
75
76#ifdef OPENSSL_BUILD_SHLIBCRYPTO
77# undef OPENSSL_EXTERN
78# define OPENSSL_EXTERN OPENSSL_EXPORT
79#endif
80
72#ifdef __cplusplus 81#ifdef __cplusplus
73extern "C" { 82extern "C" {
74#endif 83#endif
@@ -84,6 +93,7 @@ extern "C" {
84 93
85#define V_ASN1_APP_CHOOSE -2 /* let the recipient choose */ 94#define V_ASN1_APP_CHOOSE -2 /* let the recipient choose */
86#define V_ASN1_OTHER -3 /* used in ASN1_TYPE */ 95#define V_ASN1_OTHER -3 /* used in ASN1_TYPE */
96#define V_ASN1_ANY -4 /* used in ASN1 template code */
87 97
88#define V_ASN1_NEG 0x100 /* negative flag */ 98#define V_ASN1_NEG 0x100 /* negative flag */
89 99
@@ -136,6 +146,8 @@ extern "C" {
136#define B_ASN1_BMPSTRING 0x0800 146#define B_ASN1_BMPSTRING 0x0800
137#define B_ASN1_UNKNOWN 0x1000 147#define B_ASN1_UNKNOWN 0x1000
138#define B_ASN1_UTF8STRING 0x2000 148#define B_ASN1_UTF8STRING 0x2000
149#define B_ASN1_UTCTIME 0x4000
150#define B_ASN1_GENERALIZEDTIME 0x8000
139 151
140/* For use with ASN1_mbstring_copy() */ 152/* For use with ASN1_mbstring_copy() */
141#define MBSTRING_FLAG 0x1000 153#define MBSTRING_FLAG 0x1000
@@ -193,6 +205,21 @@ typedef struct asn1_string_st
193 long flags; 205 long flags;
194 } ASN1_STRING; 206 } ASN1_STRING;
195 207
208/* ASN1_ENCODING structure: this is used to save the received
209 * encoding of an ASN1 type. This is useful to get round
210 * problems with invalid encodings which can break signatures.
211 */
212
213typedef struct ASN1_ENCODING_st
214 {
215 unsigned char *enc; /* DER encoding */
216 long len; /* Length of encoding */
217 int modified; /* set to 1 if 'enc' is invalid */
218 } ASN1_ENCODING;
219
220/* Used with ASN1 LONG type: if a long is set to this it is omitted */
221#define ASN1_LONG_UNDEF 0x7fffffffL
222
196#define STABLE_FLAGS_MALLOC 0x01 223#define STABLE_FLAGS_MALLOC 0x01
197#define STABLE_NO_MASK 0x02 224#define STABLE_NO_MASK 0x02
198#define DIRSTRING_TYPE \ 225#define DIRSTRING_TYPE \
@@ -220,43 +247,116 @@ DECLARE_STACK_OF(ASN1_STRING_TABLE)
220#define ub_title 64 247#define ub_title 64
221#define ub_email_address 128 248#define ub_email_address 128
222 249
223#ifdef NO_ASN1_TYPEDEFS 250/* Declarations for template structures: for full definitions
224#define ASN1_INTEGER ASN1_STRING 251 * see asn1t.h
225#define ASN1_ENUMERATED ASN1_STRING 252 */
226#define ASN1_BIT_STRING ASN1_STRING 253typedef struct ASN1_TEMPLATE_st ASN1_TEMPLATE;
227#define ASN1_OCTET_STRING ASN1_STRING 254typedef struct ASN1_ITEM_st ASN1_ITEM;
228#define ASN1_PRINTABLESTRING ASN1_STRING 255typedef struct ASN1_TLC_st ASN1_TLC;
229#define ASN1_T61STRING ASN1_STRING 256/* This is just an opaque pointer */
230#define ASN1_IA5STRING ASN1_STRING 257typedef struct ASN1_VALUE_st ASN1_VALUE;
231#define ASN1_UTCTIME ASN1_STRING 258
232#define ASN1_GENERALIZEDTIME ASN1_STRING 259/* Declare ASN1 functions: the implement macro in in asn1t.h */
233#define ASN1_TIME ASN1_STRING 260
234#define ASN1_GENERALSTRING ASN1_STRING 261#define DECLARE_ASN1_FUNCTIONS(type) DECLARE_ASN1_FUNCTIONS_name(type, type)
235#define ASN1_UNIVERSALSTRING ASN1_STRING 262
236#define ASN1_BMPSTRING ASN1_STRING 263#define DECLARE_ASN1_FUNCTIONS_name(type, name) \
237#define ASN1_VISIBLESTRING ASN1_STRING 264 type *name##_new(void); \
238#define ASN1_UTF8STRING ASN1_STRING 265 void name##_free(type *a); \
239#define ASN1_BOOLEAN int 266 DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name)
267
268#define DECLARE_ASN1_FUNCTIONS_fname(type, itname, name) \
269 type *name##_new(void); \
270 void name##_free(type *a); \
271 DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name)
272
273#define DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) \
274 type *d2i_##name(type **a, unsigned char **in, long len); \
275 int i2d_##name(type *a, unsigned char **out); \
276 DECLARE_ASN1_ITEM(itname)
277
278#define DECLARE_ASN1_ENCODE_FUNCTIONS_const(type, name) \
279 type *d2i_##name(type **a, const unsigned char **in, long len); \
280 int i2d_##name(const type *a, unsigned char **out); \
281 DECLARE_ASN1_ITEM(name)
282
283#define DECLARE_ASN1_FUNCTIONS_const(name) \
284 name *name##_new(void); \
285 void name##_free(name *a);
286
287
288/* The following macros and typedefs allow an ASN1_ITEM
289 * to be embedded in a structure and referenced. Since
290 * the ASN1_ITEM pointers need to be globally accessible
291 * (possibly from shared libraries) they may exist in
292 * different forms. On platforms that support it the
293 * ASN1_ITEM structure itself will be globally exported.
294 * Other platforms will export a function that returns
295 * an ASN1_ITEM pointer.
296 *
297 * To handle both cases transparently the macros below
298 * should be used instead of hard coding an ASN1_ITEM
299 * pointer in a structure.
300 *
301 * The structure will look like this:
302 *
303 * typedef struct SOMETHING_st {
304 * ...
305 * ASN1_ITEM_EXP *iptr;
306 * ...
307 * } SOMETHING;
308 *
309 * It would be initialised as e.g.:
310 *
311 * SOMETHING somevar = {...,ASN1_ITEM_ref(X509),...};
312 *
313 * and the actual pointer extracted with:
314 *
315 * const ASN1_ITEM *it = ASN1_ITEM_ptr(somevar.iptr);
316 *
317 * Finally an ASN1_ITEM pointer can be extracted from an
318 * appropriate reference with: ASN1_ITEM_rptr(X509). This
319 * would be used when a function takes an ASN1_ITEM * argument.
320 *
321 */
322
323#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION
324
325/* ASN1_ITEM pointer exported type */
326typedef const ASN1_ITEM ASN1_ITEM_EXP;
327
328/* Macro to obtain ASN1_ITEM pointer from exported type */
329#define ASN1_ITEM_ptr(iptr) (iptr)
330
331/* Macro to include ASN1_ITEM pointer from base type */
332#define ASN1_ITEM_ref(iptr) (&(iptr##_it))
333
334#define ASN1_ITEM_rptr(ref) (&(ref##_it))
335
336#define DECLARE_ASN1_ITEM(name) \
337 OPENSSL_EXTERN const ASN1_ITEM name##_it;
338
240#else 339#else
241typedef struct asn1_string_st ASN1_INTEGER;
242typedef struct asn1_string_st ASN1_ENUMERATED;
243typedef struct asn1_string_st ASN1_BIT_STRING;
244typedef struct asn1_string_st ASN1_OCTET_STRING;
245typedef struct asn1_string_st ASN1_PRINTABLESTRING;
246typedef struct asn1_string_st ASN1_T61STRING;
247typedef struct asn1_string_st ASN1_IA5STRING;
248typedef struct asn1_string_st ASN1_GENERALSTRING;
249typedef struct asn1_string_st ASN1_UNIVERSALSTRING;
250typedef struct asn1_string_st ASN1_BMPSTRING;
251typedef struct asn1_string_st ASN1_UTCTIME;
252typedef struct asn1_string_st ASN1_TIME;
253typedef struct asn1_string_st ASN1_GENERALIZEDTIME;
254typedef struct asn1_string_st ASN1_VISIBLESTRING;
255typedef struct asn1_string_st ASN1_UTF8STRING;
256typedef int ASN1_BOOLEAN;
257#endif
258 340
259typedef int ASN1_NULL; 341/* Platforms that can't easily handle shared global variables are declared
342 * as functions returning ASN1_ITEM pointers.
343 */
344
345/* ASN1_ITEM pointer exported type */
346typedef const ASN1_ITEM * ASN1_ITEM_EXP(void);
347
348/* Macro to obtain ASN1_ITEM pointer from exported type */
349#define ASN1_ITEM_ptr(iptr) (iptr())
350
351/* Macro to include ASN1_ITEM pointer from base type */
352#define ASN1_ITEM_ref(iptr) (iptr##_it)
353
354#define ASN1_ITEM_rptr(ref) (ref##_it())
355
356#define DECLARE_ASN1_ITEM(name) \
357 const ASN1_ITEM * name##_it(void);
358
359#endif
260 360
261/* Parameters used by ASN1_STRING_print_ex() */ 361/* Parameters used by ASN1_STRING_print_ex() */
262 362
@@ -340,6 +440,8 @@ typedef int ASN1_NULL;
340DECLARE_STACK_OF(ASN1_INTEGER) 440DECLARE_STACK_OF(ASN1_INTEGER)
341DECLARE_ASN1_SET_OF(ASN1_INTEGER) 441DECLARE_ASN1_SET_OF(ASN1_INTEGER)
342 442
443DECLARE_STACK_OF(ASN1_GENERALSTRING)
444
343typedef struct asn1_type_st 445typedef struct asn1_type_st
344 { 446 {
345 int type; 447 int type;
@@ -438,12 +540,11 @@ typedef struct BIT_STRING_BITNAME_st {
438 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_OCTET_STRING,\ 540 i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_OCTET_STRING,\
439 V_ASN1_UNIVERSAL) 541 V_ASN1_UNIVERSAL)
440 542
441#define M_ASN1_PRINTABLE_new() ASN1_STRING_type_new(V_ASN1_T61STRING) 543#define B_ASN1_TIME \
442#define M_ASN1_PRINTABLE_free(a) ASN1_STRING_free((ASN1_STRING *)a) 544 B_ASN1_UTCTIME | \
443#define M_i2d_ASN1_PRINTABLE(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\ 545 B_ASN1_GENERALIZEDTIME
444 pp,a->type,V_ASN1_UNIVERSAL) 546
445#define M_d2i_ASN1_PRINTABLE(a,pp,l) \ 547#define B_ASN1_PRINTABLE \
446 d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \
447 B_ASN1_PRINTABLESTRING| \ 548 B_ASN1_PRINTABLESTRING| \
448 B_ASN1_T61STRING| \ 549 B_ASN1_T61STRING| \
449 B_ASN1_IA5STRING| \ 550 B_ASN1_IA5STRING| \
@@ -451,7 +552,28 @@ typedef struct BIT_STRING_BITNAME_st {
451 B_ASN1_UNIVERSALSTRING|\ 552 B_ASN1_UNIVERSALSTRING|\
452 B_ASN1_BMPSTRING|\ 553 B_ASN1_BMPSTRING|\
453 B_ASN1_UTF8STRING|\ 554 B_ASN1_UTF8STRING|\
454 B_ASN1_UNKNOWN) 555 B_ASN1_UNKNOWN
556
557#define B_ASN1_DIRECTORYSTRING \
558 B_ASN1_PRINTABLESTRING| \
559 B_ASN1_TELETEXSTRING|\
560 B_ASN1_BMPSTRING|\
561 B_ASN1_UNIVERSALSTRING|\
562 B_ASN1_UTF8STRING
563
564#define B_ASN1_DISPLAYTEXT \
565 B_ASN1_IA5STRING| \
566 B_ASN1_VISIBLESTRING| \
567 B_ASN1_BMPSTRING|\
568 B_ASN1_UTF8STRING
569
570#define M_ASN1_PRINTABLE_new() ASN1_STRING_type_new(V_ASN1_T61STRING)
571#define M_ASN1_PRINTABLE_free(a) ASN1_STRING_free((ASN1_STRING *)a)
572#define M_i2d_ASN1_PRINTABLE(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\
573 pp,a->type,V_ASN1_UNIVERSAL)
574#define M_d2i_ASN1_PRINTABLE(a,pp,l) \
575 d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \
576 B_ASN1_PRINTABLE)
455 577
456#define M_DIRECTORYSTRING_new() ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING) 578#define M_DIRECTORYSTRING_new() ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING)
457#define M_DIRECTORYSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a) 579#define M_DIRECTORYSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)
@@ -459,11 +581,7 @@ typedef struct BIT_STRING_BITNAME_st {
459 pp,a->type,V_ASN1_UNIVERSAL) 581 pp,a->type,V_ASN1_UNIVERSAL)
460#define M_d2i_DIRECTORYSTRING(a,pp,l) \ 582#define M_d2i_DIRECTORYSTRING(a,pp,l) \
461 d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \ 583 d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \
462 B_ASN1_PRINTABLESTRING| \ 584 B_ASN1_DIRECTORYSTRING)
463 B_ASN1_TELETEXSTRING|\
464 B_ASN1_BMPSTRING|\
465 B_ASN1_UNIVERSALSTRING|\
466 B_ASN1_UTF8STRING)
467 585
468#define M_DISPLAYTEXT_new() ASN1_STRING_type_new(V_ASN1_VISIBLESTRING) 586#define M_DISPLAYTEXT_new() ASN1_STRING_type_new(V_ASN1_VISIBLESTRING)
469#define M_DISPLAYTEXT_free(a) ASN1_STRING_free((ASN1_STRING *)a) 587#define M_DISPLAYTEXT_free(a) ASN1_STRING_free((ASN1_STRING *)a)
@@ -471,9 +589,7 @@ typedef struct BIT_STRING_BITNAME_st {
471 pp,a->type,V_ASN1_UNIVERSAL) 589 pp,a->type,V_ASN1_UNIVERSAL)
472#define M_d2i_DISPLAYTEXT(a,pp,l) \ 590#define M_d2i_DISPLAYTEXT(a,pp,l) \
473 d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \ 591 d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \
474 B_ASN1_VISIBLESTRING| \ 592 B_ASN1_DISPLAYTEXT)
475 B_ASN1_BMPSTRING|\
476 B_ASN1_UTF8STRING)
477 593
478#define M_ASN1_PRINTABLESTRING_new() (ASN1_PRINTABLESTRING *)\ 594#define M_ASN1_PRINTABLESTRING_new() (ASN1_PRINTABLESTRING *)\
479 ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING) 595 ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING)
@@ -577,10 +693,8 @@ typedef struct BIT_STRING_BITNAME_st {
577#define IS_SEQUENCE 0 693#define IS_SEQUENCE 0
578#define IS_SET 1 694#define IS_SET 1
579 695
580ASN1_TYPE * ASN1_TYPE_new(void ); 696DECLARE_ASN1_FUNCTIONS_fname(ASN1_TYPE, ASN1_ANY, ASN1_TYPE)
581void ASN1_TYPE_free(ASN1_TYPE *a); 697
582int i2d_ASN1_TYPE(ASN1_TYPE *a,unsigned char **pp);
583ASN1_TYPE * d2i_ASN1_TYPE(ASN1_TYPE **a,unsigned char **pp,long length);
584int ASN1_TYPE_get(ASN1_TYPE *a); 698int ASN1_TYPE_get(ASN1_TYPE *a);
585void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value); 699void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value);
586 700
@@ -592,6 +706,8 @@ ASN1_OBJECT * c2i_ASN1_OBJECT(ASN1_OBJECT **a,unsigned char **pp,
592ASN1_OBJECT * d2i_ASN1_OBJECT(ASN1_OBJECT **a,unsigned char **pp, 706ASN1_OBJECT * d2i_ASN1_OBJECT(ASN1_OBJECT **a,unsigned char **pp,
593 long length); 707 long length);
594 708
709DECLARE_ASN1_ITEM(ASN1_OBJECT)
710
595DECLARE_STACK_OF(ASN1_OBJECT) 711DECLARE_STACK_OF(ASN1_OBJECT)
596DECLARE_ASN1_SET_OF(ASN1_OBJECT) 712DECLARE_ASN1_SET_OF(ASN1_OBJECT)
597 713
@@ -608,12 +724,8 @@ void ASN1_STRING_length_set(ASN1_STRING *x, int n);
608int ASN1_STRING_type(ASN1_STRING *x); 724int ASN1_STRING_type(ASN1_STRING *x);
609unsigned char * ASN1_STRING_data(ASN1_STRING *x); 725unsigned char * ASN1_STRING_data(ASN1_STRING *x);
610 726
611ASN1_BIT_STRING * ASN1_BIT_STRING_new(void); 727DECLARE_ASN1_FUNCTIONS(ASN1_BIT_STRING)
612void ASN1_BIT_STRING_free(ASN1_BIT_STRING *a);
613int i2d_ASN1_BIT_STRING(ASN1_BIT_STRING *a,unsigned char **pp);
614int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a,unsigned char **pp); 728int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a,unsigned char **pp);
615ASN1_BIT_STRING *d2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,unsigned char **pp,
616 long length);
617ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,unsigned char **pp, 729ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,unsigned char **pp,
618 long length); 730 long length);
619int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d, 731int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d,
@@ -621,7 +733,7 @@ int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d,
621int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value); 733int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value);
622int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n); 734int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n);
623 735
624#ifndef NO_BIO 736#ifndef OPENSSL_NO_BIO
625int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs, 737int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,
626 BIT_STRING_BITNAME *tbl, int indent); 738 BIT_STRING_BITNAME *tbl, int indent);
627#endif 739#endif
@@ -632,12 +744,8 @@ int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value,
632int i2d_ASN1_BOOLEAN(int a,unsigned char **pp); 744int i2d_ASN1_BOOLEAN(int a,unsigned char **pp);
633int d2i_ASN1_BOOLEAN(int *a,unsigned char **pp,long length); 745int d2i_ASN1_BOOLEAN(int *a,unsigned char **pp,long length);
634 746
635ASN1_INTEGER * ASN1_INTEGER_new(void); 747DECLARE_ASN1_FUNCTIONS(ASN1_INTEGER)
636void ASN1_INTEGER_free(ASN1_INTEGER *a);
637int i2d_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp);
638int i2c_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp); 748int i2c_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp);
639ASN1_INTEGER *d2i_ASN1_INTEGER(ASN1_INTEGER **a,unsigned char **pp,
640 long length);
641ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a,unsigned char **pp, 749ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a,unsigned char **pp,
642 long length); 750 long length);
643ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a,unsigned char **pp, 751ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a,unsigned char **pp,
@@ -645,11 +753,7 @@ ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a,unsigned char **pp,
645ASN1_INTEGER * ASN1_INTEGER_dup(ASN1_INTEGER *x); 753ASN1_INTEGER * ASN1_INTEGER_dup(ASN1_INTEGER *x);
646int ASN1_INTEGER_cmp(ASN1_INTEGER *x, ASN1_INTEGER *y); 754int ASN1_INTEGER_cmp(ASN1_INTEGER *x, ASN1_INTEGER *y);
647 755
648ASN1_ENUMERATED * ASN1_ENUMERATED_new(void); 756DECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED)
649void ASN1_ENUMERATED_free(ASN1_ENUMERATED *a);
650int i2d_ASN1_ENUMERATED(ASN1_ENUMERATED *a,unsigned char **pp);
651ASN1_ENUMERATED *d2i_ASN1_ENUMERATED(ASN1_ENUMERATED **a,unsigned char **pp,
652 long length);
653 757
654int ASN1_UTCTIME_check(ASN1_UTCTIME *a); 758int ASN1_UTCTIME_check(ASN1_UTCTIME *a);
655ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s,time_t t); 759ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s,time_t t);
@@ -663,91 +767,34 @@ int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *a);
663ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,time_t t); 767ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,time_t t);
664int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, char *str); 768int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, char *str);
665 769
666ASN1_OCTET_STRING * ASN1_OCTET_STRING_new(void); 770DECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING)
667void ASN1_OCTET_STRING_free(ASN1_OCTET_STRING *a);
668int i2d_ASN1_OCTET_STRING(ASN1_OCTET_STRING *a,unsigned char **pp);
669ASN1_OCTET_STRING *d2i_ASN1_OCTET_STRING(ASN1_OCTET_STRING **a,
670 unsigned char **pp,long length);
671ASN1_OCTET_STRING * ASN1_OCTET_STRING_dup(ASN1_OCTET_STRING *a); 771ASN1_OCTET_STRING * ASN1_OCTET_STRING_dup(ASN1_OCTET_STRING *a);
672int ASN1_OCTET_STRING_cmp(ASN1_OCTET_STRING *a, ASN1_OCTET_STRING *b); 772int ASN1_OCTET_STRING_cmp(ASN1_OCTET_STRING *a, ASN1_OCTET_STRING *b);
673int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, unsigned char *data, int len); 773int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, unsigned char *data, int len);
674 774
675ASN1_VISIBLESTRING * ASN1_VISIBLESTRING_new(void); 775DECLARE_ASN1_FUNCTIONS(ASN1_VISIBLESTRING)
676void ASN1_VISIBLESTRING_free(ASN1_VISIBLESTRING *a); 776DECLARE_ASN1_FUNCTIONS(ASN1_UTF8STRING)
677int i2d_ASN1_VISIBLESTRING(ASN1_VISIBLESTRING *a,unsigned char **pp); 777DECLARE_ASN1_FUNCTIONS(ASN1_NULL)
678ASN1_VISIBLESTRING *d2i_ASN1_VISIBLESTRING(ASN1_VISIBLESTRING **a, 778DECLARE_ASN1_FUNCTIONS(ASN1_BMPSTRING)
679 unsigned char **pp,long length);
680
681ASN1_UTF8STRING * ASN1_UTF8STRING_new(void);
682void ASN1_UTF8STRING_free(ASN1_UTF8STRING *a);
683int i2d_ASN1_UTF8STRING(ASN1_UTF8STRING *a,unsigned char **pp);
684ASN1_UTF8STRING *d2i_ASN1_UTF8STRING(ASN1_UTF8STRING **a,
685 unsigned char **pp,long length);
686
687ASN1_NULL * ASN1_NULL_new(void);
688void ASN1_NULL_free(ASN1_NULL *a);
689int i2d_ASN1_NULL(ASN1_NULL *a,unsigned char **pp);
690ASN1_NULL *d2i_ASN1_NULL(ASN1_NULL **a, unsigned char **pp,long length);
691
692ASN1_BMPSTRING * ASN1_BMPSTRING_new(void);
693void ASN1_BMPSTRING_free(ASN1_BMPSTRING *a);
694int i2d_ASN1_BMPSTRING(ASN1_BMPSTRING *a, unsigned char **pp);
695ASN1_BMPSTRING *d2i_ASN1_BMPSTRING(ASN1_BMPSTRING **a, unsigned char **pp,
696 long length);
697
698 779
699int UTF8_getc(const unsigned char *str, int len, unsigned long *val); 780int UTF8_getc(const unsigned char *str, int len, unsigned long *val);
700int UTF8_putc(unsigned char *str, int len, unsigned long value); 781int UTF8_putc(unsigned char *str, int len, unsigned long value);
701 782
702int i2d_ASN1_PRINTABLE(ASN1_STRING *a,unsigned char **pp); 783DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, ASN1_PRINTABLE)
703ASN1_STRING *d2i_ASN1_PRINTABLE(ASN1_STRING **a,
704 unsigned char **pp, long l);
705
706ASN1_PRINTABLESTRING * ASN1_PRINTABLESTRING_new(void);
707void ASN1_PRINTABLESTRING_free(ASN1_PRINTABLESTRING *a);
708ASN1_PRINTABLESTRING *d2i_ASN1_PRINTABLESTRING(ASN1_PRINTABLESTRING **a,
709 unsigned char **pp, long l);
710int i2d_ASN1_PRINTABLESTRING(ASN1_PRINTABLESTRING *a, unsigned char **pp);
711
712ASN1_STRING * DIRECTORYSTRING_new(void);
713void DIRECTORYSTRING_free(ASN1_STRING *a);
714int i2d_DIRECTORYSTRING(ASN1_STRING *a,unsigned char **pp);
715ASN1_STRING *d2i_DIRECTORYSTRING(ASN1_STRING **a, unsigned char **pp,
716 long length);
717
718ASN1_STRING * DISPLAYTEXT_new(void);
719void DISPLAYTEXT_free(ASN1_STRING *a);
720int i2d_DISPLAYTEXT(ASN1_STRING *a,unsigned char **pp);
721ASN1_STRING *d2i_DISPLAYTEXT(ASN1_STRING **a, unsigned char **pp, long length);
722
723ASN1_T61STRING * ASN1_T61STRING_new(void);
724void ASN1_T61STRING_free(ASN1_IA5STRING *a);
725ASN1_T61STRING *d2i_ASN1_T61STRING(ASN1_T61STRING **a,
726 unsigned char **pp, long l);
727
728ASN1_IA5STRING * ASN1_IA5STRING_new(void);
729void ASN1_IA5STRING_free(ASN1_IA5STRING *a);
730int i2d_ASN1_IA5STRING(ASN1_IA5STRING *a,unsigned char **pp);
731ASN1_IA5STRING *d2i_ASN1_IA5STRING(ASN1_IA5STRING **a,
732 unsigned char **pp, long l);
733
734ASN1_UTCTIME * ASN1_UTCTIME_new(void);
735void ASN1_UTCTIME_free(ASN1_UTCTIME *a);
736int i2d_ASN1_UTCTIME(ASN1_UTCTIME *a,unsigned char **pp);
737ASN1_UTCTIME * d2i_ASN1_UTCTIME(ASN1_UTCTIME **a,unsigned char **pp,
738 long length);
739 784
740ASN1_GENERALIZEDTIME * ASN1_GENERALIZEDTIME_new(void); 785DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DIRECTORYSTRING)
741void ASN1_GENERALIZEDTIME_free(ASN1_GENERALIZEDTIME *a); 786DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DISPLAYTEXT)
742int i2d_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME *a,unsigned char **pp); 787DECLARE_ASN1_FUNCTIONS(ASN1_PRINTABLESTRING)
743ASN1_GENERALIZEDTIME * d2i_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME **a,unsigned char **pp, 788DECLARE_ASN1_FUNCTIONS(ASN1_T61STRING)
744 long length); 789DECLARE_ASN1_FUNCTIONS(ASN1_IA5STRING)
790DECLARE_ASN1_FUNCTIONS(ASN1_GENERALSTRING)
791DECLARE_ASN1_FUNCTIONS(ASN1_UTCTIME)
792DECLARE_ASN1_FUNCTIONS(ASN1_GENERALIZEDTIME)
793DECLARE_ASN1_FUNCTIONS(ASN1_TIME)
745 794
746ASN1_TIME * ASN1_TIME_new(void);
747void ASN1_TIME_free(ASN1_TIME *a);
748int i2d_ASN1_TIME(ASN1_TIME *a,unsigned char **pp);
749ASN1_TIME * d2i_ASN1_TIME(ASN1_TIME **a,unsigned char **pp, long length);
750ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s,time_t t); 795ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s,time_t t);
796int ASN1_TIME_check(ASN1_TIME *t);
797ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME **out);
751 798
752int i2d_ASN1_SET(STACK *a, unsigned char **pp, 799int i2d_ASN1_SET(STACK *a, unsigned char **pp,
753 int (*func)(), int ex_tag, int ex_class, int is_set); 800 int (*func)(), int ex_tag, int ex_class, int is_set);
@@ -755,7 +802,7 @@ STACK * d2i_ASN1_SET(STACK **a, unsigned char **pp, long length,
755 char *(*func)(), void (*free_func)(void *), 802 char *(*func)(), void (*free_func)(void *),
756 int ex_tag, int ex_class); 803 int ex_tag, int ex_class);
757 804
758#ifndef NO_BIO 805#ifndef OPENSSL_NO_BIO
759int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a); 806int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a);
760int a2i_ASN1_INTEGER(BIO *bp,ASN1_INTEGER *bs,char *buf,int size); 807int a2i_ASN1_INTEGER(BIO *bp,ASN1_INTEGER *bs,char *buf,int size);
761int i2a_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *a); 808int i2a_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *a);
@@ -768,7 +815,7 @@ int i2t_ASN1_OBJECT(char *buf,int buf_len,ASN1_OBJECT *a);
768 815
769int a2d_ASN1_OBJECT(unsigned char *out,int olen, const char *buf, int num); 816int a2d_ASN1_OBJECT(unsigned char *out,int olen, const char *buf, int num);
770ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data,int len, 817ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data,int len,
771 char *sn, char *ln); 818 const char *sn, const char *ln);
772 819
773int ASN1_INTEGER_set(ASN1_INTEGER *a, long v); 820int ASN1_INTEGER_set(ASN1_INTEGER *a, long v);
774long ASN1_INTEGER_get(ASN1_INTEGER *a); 821long ASN1_INTEGER_get(ASN1_INTEGER *a);
@@ -787,6 +834,7 @@ int ASN1_PRINTABLE_type(unsigned char *s, int max);
787int i2d_ASN1_bytes(ASN1_STRING *a, unsigned char **pp, int tag, int xclass); 834int i2d_ASN1_bytes(ASN1_STRING *a, unsigned char **pp, int tag, int xclass);
788ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, unsigned char **pp, 835ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, unsigned char **pp,
789 long length, int Ptag, int Pclass); 836 long length, int Ptag, int Pclass);
837unsigned long ASN1_tag2bit(int tag);
790/* type is one or more of the B_ASN1_ values. */ 838/* type is one or more of the B_ASN1_ values. */
791ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a,unsigned char **pp, 839ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a,unsigned char **pp,
792 long length,int type); 840 long length,int type);
@@ -805,17 +853,23 @@ int ASN1_object_size(int constructed, int length, int tag);
805/* Used to implement other functions */ 853/* Used to implement other functions */
806char *ASN1_dup(int (*i2d)(),char *(*d2i)(),char *x); 854char *ASN1_dup(int (*i2d)(),char *(*d2i)(),char *x);
807 855
808#ifndef NO_FP_API 856void *ASN1_item_dup(const ASN1_ITEM *it, void *x);
857
858#ifndef OPENSSL_NO_FP_API
809char *ASN1_d2i_fp(char *(*xnew)(),char *(*d2i)(),FILE *fp,unsigned char **x); 859char *ASN1_d2i_fp(char *(*xnew)(),char *(*d2i)(),FILE *fp,unsigned char **x);
860void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x);
810int ASN1_i2d_fp(int (*i2d)(),FILE *out,unsigned char *x); 861int ASN1_i2d_fp(int (*i2d)(),FILE *out,unsigned char *x);
862int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x);
811int ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags); 863int ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags);
812#endif 864#endif
813 865
814int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in); 866int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in);
815 867
816#ifndef NO_BIO 868#ifndef OPENSSL_NO_BIO
817char *ASN1_d2i_bio(char *(*xnew)(),char *(*d2i)(),BIO *bp,unsigned char **x); 869char *ASN1_d2i_bio(char *(*xnew)(),char *(*d2i)(),BIO *bp,unsigned char **x);
870void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x);
818int ASN1_i2d_bio(int (*i2d)(),BIO *out,unsigned char *x); 871int ASN1_i2d_bio(int (*i2d)(),BIO *out,unsigned char *x);
872int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x);
819int ASN1_UTCTIME_print(BIO *fp,ASN1_UTCTIME *a); 873int ASN1_UTCTIME_print(BIO *fp,ASN1_UTCTIME *a);
820int ASN1_GENERALIZEDTIME_print(BIO *fp,ASN1_GENERALIZEDTIME *a); 874int ASN1_GENERALIZEDTIME_print(BIO *fp,ASN1_GENERALIZEDTIME *a);
821int ASN1_TIME_print(BIO *fp,ASN1_TIME *a); 875int ASN1_TIME_print(BIO *fp,ASN1_TIME *a);
@@ -834,8 +888,6 @@ void ASN1_HEADER_free(ASN1_HEADER *a);
834 888
835int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s); 889int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s);
836 890
837void ERR_load_ASN1_strings(void);
838
839/* Not used that much at this point, except for the first two */ 891/* Not used that much at this point, except for the first two */
840ASN1_METHOD *X509_asn1_meth(void); 892ASN1_METHOD *X509_asn1_meth(void);
841ASN1_METHOD *RSAPrivateKey_asn1_meth(void); 893ASN1_METHOD *RSAPrivateKey_asn1_meth(void);
@@ -856,7 +908,9 @@ STACK *ASN1_seq_unpack(unsigned char *buf, int len, char *(*d2i)(),
856unsigned char *ASN1_seq_pack(STACK *safes, int (*i2d)(), unsigned char **buf, 908unsigned char *ASN1_seq_pack(STACK *safes, int (*i2d)(), unsigned char **buf,
857 int *len ); 909 int *len );
858void *ASN1_unpack_string(ASN1_STRING *oct, char *(*d2i)()); 910void *ASN1_unpack_string(ASN1_STRING *oct, char *(*d2i)());
911void *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it);
859ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct); 912ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
913ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_OCTET_STRING **oct);
860 914
861void ASN1_STRING_set_default_mask(unsigned long mask); 915void ASN1_STRING_set_default_mask(unsigned long mask);
862int ASN1_STRING_set_default_mask_asc(char *p); 916int ASN1_STRING_set_default_mask_asc(char *p);
@@ -873,279 +927,177 @@ ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid);
873int ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long); 927int ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long);
874void ASN1_STRING_TABLE_cleanup(void); 928void ASN1_STRING_TABLE_cleanup(void);
875 929
930/* ASN1 template functions */
931
932/* Old API compatible functions */
933ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it);
934void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it);
935ASN1_VALUE * ASN1_item_d2i(ASN1_VALUE **val, unsigned char **in, long len, const ASN1_ITEM *it);
936int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it);
937
938void ASN1_add_oid_module(void);
939
876/* BEGIN ERROR CODES */ 940/* BEGIN ERROR CODES */
877/* The following lines are auto generated by the script mkerr.pl. Any changes 941/* The following lines are auto generated by the script mkerr.pl. Any changes
878 * made after this point may be overwritten when the script is next run. 942 * made after this point may be overwritten when the script is next run.
879 */ 943 */
944void ERR_load_ASN1_strings(void);
880 945
881/* Error codes for the ASN1 functions. */ 946/* Error codes for the ASN1 functions. */
882 947
883/* Function codes. */ 948/* Function codes. */
884#define ASN1_F_A2D_ASN1_OBJECT 100 949#define ASN1_F_A2D_ASN1_OBJECT 100
885#define ASN1_F_A2I_ASN1_ENUMERATED 236 950#define ASN1_F_A2I_ASN1_ENUMERATED 101
886#define ASN1_F_A2I_ASN1_INTEGER 101 951#define ASN1_F_A2I_ASN1_INTEGER 102
887#define ASN1_F_A2I_ASN1_STRING 102 952#define ASN1_F_A2I_ASN1_STRING 103
888#define ASN1_F_ACCESS_DESCRIPTION_NEW 291 953#define ASN1_F_ASN1_CHECK_TLEN 104
889#define ASN1_F_ASN1_COLLATE_PRIMITIVE 103 954#define ASN1_F_ASN1_COLLATE_PRIMITIVE 105
890#define ASN1_F_ASN1_D2I_BIO 104 955#define ASN1_F_ASN1_COLLECT 106
891#define ASN1_F_ASN1_D2I_FP 105 956#define ASN1_F_ASN1_D2I_BIO 107
892#define ASN1_F_ASN1_DUP 106 957#define ASN1_F_ASN1_D2I_EX_PRIMITIVE 108
893#define ASN1_F_ASN1_ENUMERATED_SET 232 958#define ASN1_F_ASN1_D2I_FP 109
894#define ASN1_F_ASN1_ENUMERATED_TO_BN 233 959#define ASN1_F_ASN1_DO_ADB 110
895#define ASN1_F_ASN1_GENERALIZEDTIME_NEW 222 960#define ASN1_F_ASN1_DUP 111
896#define ASN1_F_ASN1_GET_OBJECT 107 961#define ASN1_F_ASN1_ENUMERATED_SET 112
897#define ASN1_F_ASN1_HEADER_NEW 108 962#define ASN1_F_ASN1_ENUMERATED_TO_BN 113
898#define ASN1_F_ASN1_I2D_BIO 109 963#define ASN1_F_ASN1_GET_OBJECT 114
899#define ASN1_F_ASN1_I2D_FP 110 964#define ASN1_F_ASN1_HEADER_NEW 115
900#define ASN1_F_ASN1_INTEGER_SET 111 965#define ASN1_F_ASN1_I2D_BIO 116
901#define ASN1_F_ASN1_INTEGER_TO_BN 112 966#define ASN1_F_ASN1_I2D_FP 117
902#define ASN1_F_ASN1_MBSTRING_COPY 282 967#define ASN1_F_ASN1_INTEGER_SET 118
903#define ASN1_F_ASN1_OBJECT_NEW 113 968#define ASN1_F_ASN1_INTEGER_TO_BN 119
904#define ASN1_F_ASN1_PACK_STRING 245 969#define ASN1_F_ASN1_ITEM_EX_D2I 120
905#define ASN1_F_ASN1_PBE_SET 253 970#define ASN1_F_ASN1_ITEM_NEW 121
906#define ASN1_F_ASN1_SEQ_PACK 246 971#define ASN1_F_ASN1_MBSTRING_COPY 122
907#define ASN1_F_ASN1_SEQ_UNPACK 247 972#define ASN1_F_ASN1_OBJECT_NEW 123
908#define ASN1_F_ASN1_SIGN 114 973#define ASN1_F_ASN1_PACK_STRING 124
909#define ASN1_F_ASN1_STRING_NEW 115 974#define ASN1_F_ASN1_PBE_SET 125
910#define ASN1_F_ASN1_STRING_TABLE_ADD 283 975#define ASN1_F_ASN1_SEQ_PACK 126
911#define ASN1_F_ASN1_STRING_TYPE_NEW 116 976#define ASN1_F_ASN1_SEQ_UNPACK 127
912#define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 117 977#define ASN1_F_ASN1_SIGN 128
913#define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 118 978#define ASN1_F_ASN1_STRING_TABLE_ADD 129
914#define ASN1_F_ASN1_TYPE_NEW 119 979#define ASN1_F_ASN1_STRING_TYPE_NEW 130
915#define ASN1_F_ASN1_UNPACK_STRING 248 980#define ASN1_F_ASN1_TEMPLATE_D2I 131
916#define ASN1_F_ASN1_UTCTIME_NEW 120 981#define ASN1_F_ASN1_TEMPLATE_EX_D2I 132
917#define ASN1_F_ASN1_VERIFY 121 982#define ASN1_F_ASN1_TEMPLATE_NEW 133
918#define ASN1_F_AUTHORITY_KEYID_NEW 237 983#define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 134
919#define ASN1_F_BASIC_CONSTRAINTS_NEW 226 984#define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 135
920#define ASN1_F_BN_TO_ASN1_ENUMERATED 234 985#define ASN1_F_ASN1_UNPACK_STRING 136
921#define ASN1_F_BN_TO_ASN1_INTEGER 122 986#define ASN1_F_ASN1_VERIFY 137
922#define ASN1_F_D2I_ACCESS_DESCRIPTION 284 987#define ASN1_F_BN_TO_ASN1_ENUMERATED 138
923#define ASN1_F_D2I_ASN1_BIT_STRING 123 988#define ASN1_F_BN_TO_ASN1_INTEGER 139
924#define ASN1_F_D2I_ASN1_BMPSTRING 124 989#define ASN1_F_COLLECT_DATA 140
925#define ASN1_F_D2I_ASN1_BOOLEAN 125 990#define ASN1_F_D2I_ASN1_BIT_STRING 141
926#define ASN1_F_D2I_ASN1_BYTES 126 991#define ASN1_F_D2I_ASN1_BOOLEAN 142
927#define ASN1_F_D2I_ASN1_ENUMERATED 235 992#define ASN1_F_D2I_ASN1_BYTES 143
928#define ASN1_F_D2I_ASN1_GENERALIZEDTIME 223 993#define ASN1_F_D2I_ASN1_GENERALIZEDTIME 144
929#define ASN1_F_D2I_ASN1_HEADER 127 994#define ASN1_F_D2I_ASN1_HEADER 145
930#define ASN1_F_D2I_ASN1_INTEGER 128 995#define ASN1_F_D2I_ASN1_INTEGER 146
931#define ASN1_F_D2I_ASN1_NULL 292 996#define ASN1_F_D2I_ASN1_OBJECT 147
932#define ASN1_F_D2I_ASN1_OBJECT 129 997#define ASN1_F_D2I_ASN1_SET 148
933#define ASN1_F_D2I_ASN1_OCTET_STRING 130 998#define ASN1_F_D2I_ASN1_TYPE_BYTES 149
934#define ASN1_F_D2I_ASN1_PRINT_TYPE 131 999#define ASN1_F_D2I_ASN1_UINTEGER 150
935#define ASN1_F_D2I_ASN1_SET 132 1000#define ASN1_F_D2I_ASN1_UTCTIME 151
936#define ASN1_F_D2I_ASN1_TIME 224 1001#define ASN1_F_D2I_NETSCAPE_RSA 152
937#define ASN1_F_D2I_ASN1_TYPE 133 1002#define ASN1_F_D2I_NETSCAPE_RSA_2 153
938#define ASN1_F_D2I_ASN1_TYPE_BYTES 134 1003#define ASN1_F_D2I_PRIVATEKEY 154
939#define ASN1_F_D2I_ASN1_UINTEGER 280 1004#define ASN1_F_D2I_PUBLICKEY 155
940#define ASN1_F_D2I_ASN1_UTCTIME 135 1005#define ASN1_F_D2I_X509 156
941#define ASN1_F_D2I_ASN1_UTF8STRING 266 1006#define ASN1_F_D2I_X509_CINF 157
942#define ASN1_F_D2I_ASN1_VISIBLESTRING 267 1007#define ASN1_F_D2I_X509_NAME 158
943#define ASN1_F_D2I_AUTHORITY_KEYID 238 1008#define ASN1_F_D2I_X509_PKEY 159
944#define ASN1_F_D2I_BASIC_CONSTRAINTS 227 1009#define ASN1_F_I2D_ASN1_TIME 160
945#define ASN1_F_D2I_DHPARAMS 136 1010#define ASN1_F_I2D_DSA_PUBKEY 161
946#define ASN1_F_D2I_DIST_POINT 276 1011#define ASN1_F_I2D_NETSCAPE_RSA 162
947#define ASN1_F_D2I_DIST_POINT_NAME 277 1012#define ASN1_F_I2D_PRIVATEKEY 163
948#define ASN1_F_D2I_DSAPARAMS 137 1013#define ASN1_F_I2D_PUBLICKEY 164
949#define ASN1_F_D2I_DSAPRIVATEKEY 138 1014#define ASN1_F_I2D_RSA_PUBKEY 165
950#define ASN1_F_D2I_DSAPUBLICKEY 139 1015#define ASN1_F_LONG_C2I 166
951#define ASN1_F_D2I_GENERAL_NAME 230 1016#define ASN1_F_OID_MODULE_INIT 174
952#define ASN1_F_D2I_NETSCAPE_CERT_SEQUENCE 228 1017#define ASN1_F_PKCS5_PBE2_SET 167
953#define ASN1_F_D2I_NETSCAPE_PKEY 140 1018#define ASN1_F_X509_CINF_NEW 168
954#define ASN1_F_D2I_NETSCAPE_RSA 141 1019#define ASN1_F_X509_CRL_ADD0_REVOKED 169
955#define ASN1_F_D2I_NETSCAPE_RSA_2 142 1020#define ASN1_F_X509_INFO_NEW 170
956#define ASN1_F_D2I_NETSCAPE_SPKAC 143 1021#define ASN1_F_X509_NAME_NEW 171
957#define ASN1_F_D2I_NETSCAPE_SPKI 144 1022#define ASN1_F_X509_NEW 172
958#define ASN1_F_D2I_NOTICEREF 268 1023#define ASN1_F_X509_PKEY_NEW 173
959#define ASN1_F_D2I_OTHERNAME 287
960#define ASN1_F_D2I_PBE2PARAM 262
961#define ASN1_F_D2I_PBEPARAM 249
962#define ASN1_F_D2I_PBKDF2PARAM 263
963#define ASN1_F_D2I_PKCS12 254
964#define ASN1_F_D2I_PKCS12_BAGS 255
965#define ASN1_F_D2I_PKCS12_MAC_DATA 256
966#define ASN1_F_D2I_PKCS12_SAFEBAG 257
967#define ASN1_F_D2I_PKCS7 145
968#define ASN1_F_D2I_PKCS7_DIGEST 146
969#define ASN1_F_D2I_PKCS7_ENCRYPT 147
970#define ASN1_F_D2I_PKCS7_ENC_CONTENT 148
971#define ASN1_F_D2I_PKCS7_ENVELOPE 149
972#define ASN1_F_D2I_PKCS7_ISSUER_AND_SERIAL 150
973#define ASN1_F_D2I_PKCS7_RECIP_INFO 151
974#define ASN1_F_D2I_PKCS7_SIGNED 152
975#define ASN1_F_D2I_PKCS7_SIGNER_INFO 153
976#define ASN1_F_D2I_PKCS7_SIGN_ENVELOPE 154
977#define ASN1_F_D2I_PKCS8_PRIV_KEY_INFO 250
978#define ASN1_F_D2I_PKEY_USAGE_PERIOD 239
979#define ASN1_F_D2I_POLICYINFO 269
980#define ASN1_F_D2I_POLICYQUALINFO 270
981#define ASN1_F_D2I_PRIVATEKEY 155
982#define ASN1_F_D2I_PUBLICKEY 156
983#define ASN1_F_D2I_RSAPRIVATEKEY 157
984#define ASN1_F_D2I_RSAPUBLICKEY 158
985#define ASN1_F_D2I_SXNET 241
986#define ASN1_F_D2I_SXNETID 243
987#define ASN1_F_D2I_USERNOTICE 271
988#define ASN1_F_D2I_X509 159
989#define ASN1_F_D2I_X509_ALGOR 160
990#define ASN1_F_D2I_X509_ATTRIBUTE 161
991#define ASN1_F_D2I_X509_CERT_AUX 285
992#define ASN1_F_D2I_X509_CINF 162
993#define ASN1_F_D2I_X509_CRL 163
994#define ASN1_F_D2I_X509_CRL_INFO 164
995#define ASN1_F_D2I_X509_EXTENSION 165
996#define ASN1_F_D2I_X509_KEY 166
997#define ASN1_F_D2I_X509_NAME 167
998#define ASN1_F_D2I_X509_NAME_ENTRY 168
999#define ASN1_F_D2I_X509_PKEY 169
1000#define ASN1_F_D2I_X509_PUBKEY 170
1001#define ASN1_F_D2I_X509_REQ 171
1002#define ASN1_F_D2I_X509_REQ_INFO 172
1003#define ASN1_F_D2I_X509_REVOKED 173
1004#define ASN1_F_D2I_X509_SIG 174
1005#define ASN1_F_D2I_X509_VAL 175
1006#define ASN1_F_DIST_POINT_NAME_NEW 278
1007#define ASN1_F_DIST_POINT_NEW 279
1008#define ASN1_F_GENERAL_NAME_NEW 231
1009#define ASN1_F_I2D_ASN1_HEADER 176
1010#define ASN1_F_I2D_ASN1_TIME 225
1011#define ASN1_F_I2D_DHPARAMS 177
1012#define ASN1_F_I2D_DSAPARAMS 178
1013#define ASN1_F_I2D_DSAPRIVATEKEY 179
1014#define ASN1_F_I2D_DSAPUBLICKEY 180
1015#define ASN1_F_I2D_DSA_PUBKEY 290
1016#define ASN1_F_I2D_NETSCAPE_RSA 181
1017#define ASN1_F_I2D_PKCS7 182
1018#define ASN1_F_I2D_PRIVATEKEY 183
1019#define ASN1_F_I2D_PUBLICKEY 184
1020#define ASN1_F_I2D_RSAPRIVATEKEY 185
1021#define ASN1_F_I2D_RSAPUBLICKEY 186
1022#define ASN1_F_I2D_RSA_PUBKEY 289
1023#define ASN1_F_I2D_X509_ATTRIBUTE 187
1024#define ASN1_F_I2T_ASN1_OBJECT 188
1025#define ASN1_F_NETSCAPE_CERT_SEQUENCE_NEW 229
1026#define ASN1_F_NETSCAPE_PKEY_NEW 189
1027#define ASN1_F_NETSCAPE_SPKAC_NEW 190
1028#define ASN1_F_NETSCAPE_SPKI_NEW 191
1029#define ASN1_F_NOTICEREF_NEW 272
1030#define ASN1_F_OTHERNAME_NEW 288
1031#define ASN1_F_PBE2PARAM_NEW 264
1032#define ASN1_F_PBEPARAM_NEW 251
1033#define ASN1_F_PBKDF2PARAM_NEW 265
1034#define ASN1_F_PKCS12_BAGS_NEW 258
1035#define ASN1_F_PKCS12_MAC_DATA_NEW 259
1036#define ASN1_F_PKCS12_NEW 260
1037#define ASN1_F_PKCS12_SAFEBAG_NEW 261
1038#define ASN1_F_PKCS5_PBE2_SET 281
1039#define ASN1_F_PKCS7_DIGEST_NEW 192
1040#define ASN1_F_PKCS7_ENCRYPT_NEW 193
1041#define ASN1_F_PKCS7_ENC_CONTENT_NEW 194
1042#define ASN1_F_PKCS7_ENVELOPE_NEW 195
1043#define ASN1_F_PKCS7_ISSUER_AND_SERIAL_NEW 196
1044#define ASN1_F_PKCS7_NEW 197
1045#define ASN1_F_PKCS7_RECIP_INFO_NEW 198
1046#define ASN1_F_PKCS7_SIGNED_NEW 199
1047#define ASN1_F_PKCS7_SIGNER_INFO_NEW 200
1048#define ASN1_F_PKCS7_SIGN_ENVELOPE_NEW 201
1049#define ASN1_F_PKCS8_PRIV_KEY_INFO_NEW 252
1050#define ASN1_F_PKEY_USAGE_PERIOD_NEW 240
1051#define ASN1_F_POLICYINFO_NEW 273
1052#define ASN1_F_POLICYQUALINFO_NEW 274
1053#define ASN1_F_SXNETID_NEW 244
1054#define ASN1_F_SXNET_NEW 242
1055#define ASN1_F_USERNOTICE_NEW 275
1056#define ASN1_F_X509_ALGOR_NEW 202
1057#define ASN1_F_X509_ATTRIBUTE_NEW 203
1058#define ASN1_F_X509_CERT_AUX_NEW 286
1059#define ASN1_F_X509_CINF_NEW 204
1060#define ASN1_F_X509_CRL_INFO_NEW 205
1061#define ASN1_F_X509_CRL_NEW 206
1062#define ASN1_F_X509_DHPARAMS_NEW 207
1063#define ASN1_F_X509_EXTENSION_NEW 208
1064#define ASN1_F_X509_INFO_NEW 209
1065#define ASN1_F_X509_KEY_NEW 210
1066#define ASN1_F_X509_NAME_ENTRY_NEW 211
1067#define ASN1_F_X509_NAME_NEW 212
1068#define ASN1_F_X509_NEW 213
1069#define ASN1_F_X509_PKEY_NEW 214
1070#define ASN1_F_X509_PUBKEY_NEW 215
1071#define ASN1_F_X509_REQ_INFO_NEW 216
1072#define ASN1_F_X509_REQ_NEW 217
1073#define ASN1_F_X509_REVOKED_NEW 218
1074#define ASN1_F_X509_SIG_NEW 219
1075#define ASN1_F_X509_VAL_FREE 220
1076#define ASN1_F_X509_VAL_NEW 221
1077 1024
1078/* Reason codes. */ 1025/* Reason codes. */
1079#define ASN1_R_BAD_CLASS 100 1026#define ASN1_R_ADDING_OBJECT 171
1080#define ASN1_R_BAD_OBJECT_HEADER 101 1027#define ASN1_R_AUX_ERROR 100
1081#define ASN1_R_BAD_PASSWORD_READ 102 1028#define ASN1_R_BAD_CLASS 101
1082#define ASN1_R_BAD_PKCS7_CONTENT 103 1029#define ASN1_R_BAD_OBJECT_HEADER 102
1083#define ASN1_R_BAD_PKCS7_TYPE 104 1030#define ASN1_R_BAD_PASSWORD_READ 103
1084#define ASN1_R_BAD_TAG 105 1031#define ASN1_R_BAD_TAG 104
1085#define ASN1_R_BAD_TYPE 106 1032#define ASN1_R_BN_LIB 105
1086#define ASN1_R_BN_LIB 107 1033#define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 106
1087#define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 108 1034#define ASN1_R_BUFFER_TOO_SMALL 107
1088#define ASN1_R_BUFFER_TOO_SMALL 109 1035#define ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 108
1089#define ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 166 1036#define ASN1_R_DATA_IS_WRONG 109
1090#define ASN1_R_DATA_IS_WRONG 110 1037#define ASN1_R_DECODE_ERROR 110
1091#define ASN1_R_DECODE_ERROR 155
1092#define ASN1_R_DECODING_ERROR 111 1038#define ASN1_R_DECODING_ERROR 111
1093#define ASN1_R_ENCODE_ERROR 156 1039#define ASN1_R_ENCODE_ERROR 112
1094#define ASN1_R_ERROR_PARSING_SET_ELEMENT 112 1040#define ASN1_R_ERROR_LOADING_SECTION 172
1095#define ASN1_R_ERROR_SETTING_CIPHER_PARAMS 157 1041#define ASN1_R_ERROR_PARSING_SET_ELEMENT 113
1096#define ASN1_R_EXPECTING_AN_ENUMERATED 154 1042#define ASN1_R_ERROR_SETTING_CIPHER_PARAMS 114
1097#define ASN1_R_EXPECTING_AN_INTEGER 113 1043#define ASN1_R_EXPECTING_AN_INTEGER 115
1098#define ASN1_R_EXPECTING_AN_OBJECT 114 1044#define ASN1_R_EXPECTING_AN_OBJECT 116
1099#define ASN1_R_EXPECTING_AN_OCTET_STRING 115
1100#define ASN1_R_EXPECTING_A_BIT_STRING 116
1101#define ASN1_R_EXPECTING_A_BOOLEAN 117 1045#define ASN1_R_EXPECTING_A_BOOLEAN 117
1102#define ASN1_R_EXPECTING_A_GENERALIZEDTIME 151 1046#define ASN1_R_EXPECTING_A_TIME 118
1103#define ASN1_R_EXPECTING_A_NULL 164 1047#define ASN1_R_EXPLICIT_LENGTH_MISMATCH 119
1104#define ASN1_R_EXPECTING_A_TIME 152 1048#define ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED 120
1105#define ASN1_R_EXPECTING_A_UTCTIME 118 1049#define ASN1_R_FIELD_MISSING 121
1106#define ASN1_R_FIRST_NUM_TOO_LARGE 119 1050#define ASN1_R_FIRST_NUM_TOO_LARGE 122
1107#define ASN1_R_GENERALIZEDTIME_TOO_LONG 153 1051#define ASN1_R_HEADER_TOO_LONG 123
1108#define ASN1_R_HEADER_TOO_LONG 120 1052#define ASN1_R_ILLEGAL_CHARACTERS 124
1109#define ASN1_R_ILLEGAL_CHARACTERS 158 1053#define ASN1_R_ILLEGAL_NULL 125
1110#define ASN1_R_INVALID_BMPSTRING_LENGTH 159 1054#define ASN1_R_ILLEGAL_OPTIONAL_ANY 126
1111#define ASN1_R_INVALID_DIGIT 121 1055#define ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE 170
1112#define ASN1_R_INVALID_SEPARATOR 122 1056#define ASN1_R_ILLEGAL_TAGGED_ANY 127
1113#define ASN1_R_INVALID_TIME_FORMAT 123 1057#define ASN1_R_INTEGER_TOO_LARGE_FOR_LONG 128
1114#define ASN1_R_INVALID_UNIVERSALSTRING_LENGTH 160 1058#define ASN1_R_INVALID_BMPSTRING_LENGTH 129
1115#define ASN1_R_INVALID_UTF8STRING 161 1059#define ASN1_R_INVALID_DIGIT 130
1116#define ASN1_R_IV_TOO_LARGE 124 1060#define ASN1_R_INVALID_SEPARATOR 131
1117#define ASN1_R_LENGTH_ERROR 125 1061#define ASN1_R_INVALID_TIME_FORMAT 132
1118#define ASN1_R_MISSING_SECOND_NUMBER 126 1062#define ASN1_R_INVALID_UNIVERSALSTRING_LENGTH 133
1119#define ASN1_R_NON_HEX_CHARACTERS 127 1063#define ASN1_R_INVALID_UTF8STRING 134
1120#define ASN1_R_NOT_ENOUGH_DATA 128 1064#define ASN1_R_IV_TOO_LARGE 135
1121#define ASN1_R_NULL_IS_WRONG_LENGTH 165 1065#define ASN1_R_LENGTH_ERROR 136
1122#define ASN1_R_ODD_NUMBER_OF_CHARS 129 1066#define ASN1_R_MISSING_EOC 137
1123#define ASN1_R_PARSING 130 1067#define ASN1_R_MISSING_SECOND_NUMBER 138
1124#define ASN1_R_PRIVATE_KEY_HEADER_MISSING 131 1068#define ASN1_R_MSTRING_NOT_UNIVERSAL 139
1125#define ASN1_R_SECOND_NUMBER_TOO_LARGE 132 1069#define ASN1_R_MSTRING_WRONG_TAG 140
1126#define ASN1_R_SHORT_LINE 133 1070#define ASN1_R_NON_HEX_CHARACTERS 141
1127#define ASN1_R_STRING_TOO_LONG 163 1071#define ASN1_R_NOT_ENOUGH_DATA 142
1128#define ASN1_R_STRING_TOO_SHORT 134 1072#define ASN1_R_NO_MATCHING_CHOICE_TYPE 143
1129#define ASN1_R_TAG_VALUE_TOO_HIGH 135 1073#define ASN1_R_NULL_IS_WRONG_LENGTH 144
1130#define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 136 1074#define ASN1_R_ODD_NUMBER_OF_CHARS 145
1131#define ASN1_R_TOO_LONG 137 1075#define ASN1_R_PRIVATE_KEY_HEADER_MISSING 146
1132#define ASN1_R_UNABLE_TO_DECODE_RSA_KEY 138 1076#define ASN1_R_SECOND_NUMBER_TOO_LARGE 147
1133#define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY 139 1077#define ASN1_R_SEQUENCE_LENGTH_MISMATCH 148
1134#define ASN1_R_UNKNOWN_ATTRIBUTE_TYPE 140 1078#define ASN1_R_SEQUENCE_NOT_CONSTRUCTED 149
1135#define ASN1_R_UNKNOWN_FORMAT 162 1079#define ASN1_R_SHORT_LINE 150
1136#define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 141 1080#define ASN1_R_STRING_TOO_LONG 151
1137#define ASN1_R_UNKNOWN_OBJECT_TYPE 142 1081#define ASN1_R_STRING_TOO_SHORT 152
1138#define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE 143 1082#define ASN1_R_TAG_VALUE_TOO_HIGH 153
1139#define ASN1_R_UNSUPPORTED_CIPHER 144 1083#define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 154
1140#define ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM 145 1084#define ASN1_R_TOO_LONG 155
1141#define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE 146 1085#define ASN1_R_TYPE_NOT_CONSTRUCTED 156
1142#define ASN1_R_UTCTIME_TOO_LONG 147 1086#define ASN1_R_UNABLE_TO_DECODE_RSA_KEY 157
1143#define ASN1_R_WRONG_PRINTABLE_TYPE 148 1087#define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY 158
1144#define ASN1_R_WRONG_TAG 149 1088#define ASN1_R_UNEXPECTED_EOC 159
1145#define ASN1_R_WRONG_TYPE 150 1089#define ASN1_R_UNKNOWN_FORMAT 160
1090#define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 161
1091#define ASN1_R_UNKNOWN_OBJECT_TYPE 162
1092#define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE 163
1093#define ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE 164
1094#define ASN1_R_UNSUPPORTED_CIPHER 165
1095#define ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM 166
1096#define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE 167
1097#define ASN1_R_WRONG_TAG 168
1098#define ASN1_R_WRONG_TYPE 169
1146 1099
1147#ifdef __cplusplus 1100#ifdef __cplusplus
1148} 1101}
1149#endif 1102#endif
1150#endif 1103#endif
1151
diff --git a/src/lib/libcrypto/asn1/asn1_err.c b/src/lib/libcrypto/asn1/asn1_err.c
index cecd555c88..c4c3d2a91d 100644
--- a/src/lib/libcrypto/asn1/asn1_err.c
+++ b/src/lib/libcrypto/asn1/asn1_err.c
@@ -63,27 +63,31 @@
63#include <openssl/asn1.h> 63#include <openssl/asn1.h>
64 64
65/* BEGIN ERROR CODES */ 65/* BEGIN ERROR CODES */
66#ifndef NO_ERR 66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA ASN1_str_functs[]= 67static ERR_STRING_DATA ASN1_str_functs[]=
68 { 68 {
69{ERR_PACK(0,ASN1_F_A2D_ASN1_OBJECT,0), "a2d_ASN1_OBJECT"}, 69{ERR_PACK(0,ASN1_F_A2D_ASN1_OBJECT,0), "a2d_ASN1_OBJECT"},
70{ERR_PACK(0,ASN1_F_A2I_ASN1_ENUMERATED,0), "a2i_ASN1_ENUMERATED"}, 70{ERR_PACK(0,ASN1_F_A2I_ASN1_ENUMERATED,0), "a2i_ASN1_ENUMERATED"},
71{ERR_PACK(0,ASN1_F_A2I_ASN1_INTEGER,0), "a2i_ASN1_INTEGER"}, 71{ERR_PACK(0,ASN1_F_A2I_ASN1_INTEGER,0), "a2i_ASN1_INTEGER"},
72{ERR_PACK(0,ASN1_F_A2I_ASN1_STRING,0), "a2i_ASN1_STRING"}, 72{ERR_PACK(0,ASN1_F_A2I_ASN1_STRING,0), "a2i_ASN1_STRING"},
73{ERR_PACK(0,ASN1_F_ACCESS_DESCRIPTION_NEW,0), "ACCESS_DESCRIPTION_new"}, 73{ERR_PACK(0,ASN1_F_ASN1_CHECK_TLEN,0), "ASN1_CHECK_TLEN"},
74{ERR_PACK(0,ASN1_F_ASN1_COLLATE_PRIMITIVE,0), "ASN1_COLLATE_PRIMITIVE"}, 74{ERR_PACK(0,ASN1_F_ASN1_COLLATE_PRIMITIVE,0), "ASN1_COLLATE_PRIMITIVE"},
75{ERR_PACK(0,ASN1_F_ASN1_COLLECT,0), "ASN1_COLLECT"},
75{ERR_PACK(0,ASN1_F_ASN1_D2I_BIO,0), "ASN1_d2i_bio"}, 76{ERR_PACK(0,ASN1_F_ASN1_D2I_BIO,0), "ASN1_d2i_bio"},
77{ERR_PACK(0,ASN1_F_ASN1_D2I_EX_PRIMITIVE,0), "ASN1_D2I_EX_PRIMITIVE"},
76{ERR_PACK(0,ASN1_F_ASN1_D2I_FP,0), "ASN1_d2i_fp"}, 78{ERR_PACK(0,ASN1_F_ASN1_D2I_FP,0), "ASN1_d2i_fp"},
79{ERR_PACK(0,ASN1_F_ASN1_DO_ADB,0), "ASN1_DO_ADB"},
77{ERR_PACK(0,ASN1_F_ASN1_DUP,0), "ASN1_dup"}, 80{ERR_PACK(0,ASN1_F_ASN1_DUP,0), "ASN1_dup"},
78{ERR_PACK(0,ASN1_F_ASN1_ENUMERATED_SET,0), "ASN1_ENUMERATED_set"}, 81{ERR_PACK(0,ASN1_F_ASN1_ENUMERATED_SET,0), "ASN1_ENUMERATED_set"},
79{ERR_PACK(0,ASN1_F_ASN1_ENUMERATED_TO_BN,0), "ASN1_ENUMERATED_to_BN"}, 82{ERR_PACK(0,ASN1_F_ASN1_ENUMERATED_TO_BN,0), "ASN1_ENUMERATED_to_BN"},
80{ERR_PACK(0,ASN1_F_ASN1_GENERALIZEDTIME_NEW,0), "ASN1_GENERALIZEDTIME_new"},
81{ERR_PACK(0,ASN1_F_ASN1_GET_OBJECT,0), "ASN1_get_object"}, 83{ERR_PACK(0,ASN1_F_ASN1_GET_OBJECT,0), "ASN1_get_object"},
82{ERR_PACK(0,ASN1_F_ASN1_HEADER_NEW,0), "ASN1_HEADER_new"}, 84{ERR_PACK(0,ASN1_F_ASN1_HEADER_NEW,0), "ASN1_HEADER_new"},
83{ERR_PACK(0,ASN1_F_ASN1_I2D_BIO,0), "ASN1_i2d_bio"}, 85{ERR_PACK(0,ASN1_F_ASN1_I2D_BIO,0), "ASN1_i2d_bio"},
84{ERR_PACK(0,ASN1_F_ASN1_I2D_FP,0), "ASN1_i2d_fp"}, 86{ERR_PACK(0,ASN1_F_ASN1_I2D_FP,0), "ASN1_i2d_fp"},
85{ERR_PACK(0,ASN1_F_ASN1_INTEGER_SET,0), "ASN1_INTEGER_set"}, 87{ERR_PACK(0,ASN1_F_ASN1_INTEGER_SET,0), "ASN1_INTEGER_set"},
86{ERR_PACK(0,ASN1_F_ASN1_INTEGER_TO_BN,0), "ASN1_INTEGER_to_BN"}, 88{ERR_PACK(0,ASN1_F_ASN1_INTEGER_TO_BN,0), "ASN1_INTEGER_to_BN"},
89{ERR_PACK(0,ASN1_F_ASN1_ITEM_EX_D2I,0), "ASN1_ITEM_EX_D2I"},
90{ERR_PACK(0,ASN1_F_ASN1_ITEM_NEW,0), "ASN1_item_new"},
87{ERR_PACK(0,ASN1_F_ASN1_MBSTRING_COPY,0), "ASN1_mbstring_copy"}, 91{ERR_PACK(0,ASN1_F_ASN1_MBSTRING_COPY,0), "ASN1_mbstring_copy"},
88{ERR_PACK(0,ASN1_F_ASN1_OBJECT_NEW,0), "ASN1_OBJECT_new"}, 92{ERR_PACK(0,ASN1_F_ASN1_OBJECT_NEW,0), "ASN1_OBJECT_new"},
89{ERR_PACK(0,ASN1_F_ASN1_PACK_STRING,0), "ASN1_pack_string"}, 93{ERR_PACK(0,ASN1_F_ASN1_PACK_STRING,0), "ASN1_pack_string"},
@@ -91,186 +95,63 @@ static ERR_STRING_DATA ASN1_str_functs[]=
91{ERR_PACK(0,ASN1_F_ASN1_SEQ_PACK,0), "ASN1_seq_pack"}, 95{ERR_PACK(0,ASN1_F_ASN1_SEQ_PACK,0), "ASN1_seq_pack"},
92{ERR_PACK(0,ASN1_F_ASN1_SEQ_UNPACK,0), "ASN1_seq_unpack"}, 96{ERR_PACK(0,ASN1_F_ASN1_SEQ_UNPACK,0), "ASN1_seq_unpack"},
93{ERR_PACK(0,ASN1_F_ASN1_SIGN,0), "ASN1_sign"}, 97{ERR_PACK(0,ASN1_F_ASN1_SIGN,0), "ASN1_sign"},
94{ERR_PACK(0,ASN1_F_ASN1_STRING_NEW,0), "ASN1_STRING_new"},
95{ERR_PACK(0,ASN1_F_ASN1_STRING_TABLE_ADD,0), "ASN1_STRING_TABLE_add"}, 98{ERR_PACK(0,ASN1_F_ASN1_STRING_TABLE_ADD,0), "ASN1_STRING_TABLE_add"},
96{ERR_PACK(0,ASN1_F_ASN1_STRING_TYPE_NEW,0), "ASN1_STRING_type_new"}, 99{ERR_PACK(0,ASN1_F_ASN1_STRING_TYPE_NEW,0), "ASN1_STRING_type_new"},
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"},
102{ERR_PACK(0,ASN1_F_ASN1_TEMPLATE_NEW,0), "ASN1_TEMPLATE_NEW"},
97{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"},
98{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"},
99{ERR_PACK(0,ASN1_F_ASN1_TYPE_NEW,0), "ASN1_TYPE_new"},
100{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"},
101{ERR_PACK(0,ASN1_F_ASN1_UTCTIME_NEW,0), "ASN1_UTCTIME_new"},
102{ERR_PACK(0,ASN1_F_ASN1_VERIFY,0), "ASN1_verify"}, 106{ERR_PACK(0,ASN1_F_ASN1_VERIFY,0), "ASN1_verify"},
103{ERR_PACK(0,ASN1_F_AUTHORITY_KEYID_NEW,0), "AUTHORITY_KEYID_new"},
104{ERR_PACK(0,ASN1_F_BASIC_CONSTRAINTS_NEW,0), "BASIC_CONSTRAINTS_new"},
105{ERR_PACK(0,ASN1_F_BN_TO_ASN1_ENUMERATED,0), "BN_to_ASN1_ENUMERATED"}, 107{ERR_PACK(0,ASN1_F_BN_TO_ASN1_ENUMERATED,0), "BN_to_ASN1_ENUMERATED"},
106{ERR_PACK(0,ASN1_F_BN_TO_ASN1_INTEGER,0), "BN_to_ASN1_INTEGER"}, 108{ERR_PACK(0,ASN1_F_BN_TO_ASN1_INTEGER,0), "BN_to_ASN1_INTEGER"},
107{ERR_PACK(0,ASN1_F_D2I_ACCESS_DESCRIPTION,0), "d2i_ACCESS_DESCRIPTION"}, 109{ERR_PACK(0,ASN1_F_COLLECT_DATA,0), "COLLECT_DATA"},
108{ERR_PACK(0,ASN1_F_D2I_ASN1_BIT_STRING,0), "d2i_ASN1_BIT_STRING"}, 110{ERR_PACK(0,ASN1_F_D2I_ASN1_BIT_STRING,0), "D2I_ASN1_BIT_STRING"},
109{ERR_PACK(0,ASN1_F_D2I_ASN1_BMPSTRING,0), "d2i_ASN1_BMPSTRING"},
110{ERR_PACK(0,ASN1_F_D2I_ASN1_BOOLEAN,0), "d2i_ASN1_BOOLEAN"}, 111{ERR_PACK(0,ASN1_F_D2I_ASN1_BOOLEAN,0), "d2i_ASN1_BOOLEAN"},
111{ERR_PACK(0,ASN1_F_D2I_ASN1_BYTES,0), "d2i_ASN1_bytes"}, 112{ERR_PACK(0,ASN1_F_D2I_ASN1_BYTES,0), "d2i_ASN1_bytes"},
112{ERR_PACK(0,ASN1_F_D2I_ASN1_ENUMERATED,0), "d2i_ASN1_ENUMERATED"}, 113{ERR_PACK(0,ASN1_F_D2I_ASN1_GENERALIZEDTIME,0), "D2I_ASN1_GENERALIZEDTIME"},
113{ERR_PACK(0,ASN1_F_D2I_ASN1_GENERALIZEDTIME,0), "d2i_ASN1_GENERALIZEDTIME"},
114{ERR_PACK(0,ASN1_F_D2I_ASN1_HEADER,0), "d2i_ASN1_HEADER"}, 114{ERR_PACK(0,ASN1_F_D2I_ASN1_HEADER,0), "d2i_ASN1_HEADER"},
115{ERR_PACK(0,ASN1_F_D2I_ASN1_INTEGER,0), "d2i_ASN1_INTEGER"}, 115{ERR_PACK(0,ASN1_F_D2I_ASN1_INTEGER,0), "D2I_ASN1_INTEGER"},
116{ERR_PACK(0,ASN1_F_D2I_ASN1_NULL,0), "d2i_ASN1_NULL"},
117{ERR_PACK(0,ASN1_F_D2I_ASN1_OBJECT,0), "d2i_ASN1_OBJECT"}, 116{ERR_PACK(0,ASN1_F_D2I_ASN1_OBJECT,0), "d2i_ASN1_OBJECT"},
118{ERR_PACK(0,ASN1_F_D2I_ASN1_OCTET_STRING,0), "d2i_ASN1_OCTET_STRING"},
119{ERR_PACK(0,ASN1_F_D2I_ASN1_PRINT_TYPE,0), "D2I_ASN1_PRINT_TYPE"},
120{ERR_PACK(0,ASN1_F_D2I_ASN1_SET,0), "d2i_ASN1_SET"}, 117{ERR_PACK(0,ASN1_F_D2I_ASN1_SET,0), "d2i_ASN1_SET"},
121{ERR_PACK(0,ASN1_F_D2I_ASN1_TIME,0), "d2i_ASN1_TIME"},
122{ERR_PACK(0,ASN1_F_D2I_ASN1_TYPE,0), "d2i_ASN1_TYPE"},
123{ERR_PACK(0,ASN1_F_D2I_ASN1_TYPE_BYTES,0), "d2i_ASN1_type_bytes"}, 118{ERR_PACK(0,ASN1_F_D2I_ASN1_TYPE_BYTES,0), "d2i_ASN1_type_bytes"},
124{ERR_PACK(0,ASN1_F_D2I_ASN1_UINTEGER,0), "d2i_ASN1_UINTEGER"}, 119{ERR_PACK(0,ASN1_F_D2I_ASN1_UINTEGER,0), "d2i_ASN1_UINTEGER"},
125{ERR_PACK(0,ASN1_F_D2I_ASN1_UTCTIME,0), "d2i_ASN1_UTCTIME"}, 120{ERR_PACK(0,ASN1_F_D2I_ASN1_UTCTIME,0), "D2I_ASN1_UTCTIME"},
126{ERR_PACK(0,ASN1_F_D2I_ASN1_UTF8STRING,0), "d2i_ASN1_UTF8STRING"},
127{ERR_PACK(0,ASN1_F_D2I_ASN1_VISIBLESTRING,0), "d2i_ASN1_VISIBLESTRING"},
128{ERR_PACK(0,ASN1_F_D2I_AUTHORITY_KEYID,0), "d2i_AUTHORITY_KEYID"},
129{ERR_PACK(0,ASN1_F_D2I_BASIC_CONSTRAINTS,0), "d2i_BASIC_CONSTRAINTS"},
130{ERR_PACK(0,ASN1_F_D2I_DHPARAMS,0), "d2i_DHparams"},
131{ERR_PACK(0,ASN1_F_D2I_DIST_POINT,0), "d2i_DIST_POINT"},
132{ERR_PACK(0,ASN1_F_D2I_DIST_POINT_NAME,0), "d2i_DIST_POINT_NAME"},
133{ERR_PACK(0,ASN1_F_D2I_DSAPARAMS,0), "d2i_DSAparams"},
134{ERR_PACK(0,ASN1_F_D2I_DSAPRIVATEKEY,0), "d2i_DSAPrivateKey"},
135{ERR_PACK(0,ASN1_F_D2I_DSAPUBLICKEY,0), "d2i_DSAPublicKey"},
136{ERR_PACK(0,ASN1_F_D2I_GENERAL_NAME,0), "d2i_GENERAL_NAME"},
137{ERR_PACK(0,ASN1_F_D2I_NETSCAPE_CERT_SEQUENCE,0), "d2i_NETSCAPE_CERT_SEQUENCE"},
138{ERR_PACK(0,ASN1_F_D2I_NETSCAPE_PKEY,0), "D2I_NETSCAPE_PKEY"},
139{ERR_PACK(0,ASN1_F_D2I_NETSCAPE_RSA,0), "d2i_Netscape_RSA"}, 121{ERR_PACK(0,ASN1_F_D2I_NETSCAPE_RSA,0), "d2i_Netscape_RSA"},
140{ERR_PACK(0,ASN1_F_D2I_NETSCAPE_RSA_2,0), "d2i_Netscape_RSA_2"}, 122{ERR_PACK(0,ASN1_F_D2I_NETSCAPE_RSA_2,0), "D2I_NETSCAPE_RSA_2"},
141{ERR_PACK(0,ASN1_F_D2I_NETSCAPE_SPKAC,0), "d2i_NETSCAPE_SPKAC"},
142{ERR_PACK(0,ASN1_F_D2I_NETSCAPE_SPKI,0), "d2i_NETSCAPE_SPKI"},
143{ERR_PACK(0,ASN1_F_D2I_NOTICEREF,0), "d2i_NOTICEREF"},
144{ERR_PACK(0,ASN1_F_D2I_OTHERNAME,0), "d2i_OTHERNAME"},
145{ERR_PACK(0,ASN1_F_D2I_PBE2PARAM,0), "d2i_PBE2PARAM"},
146{ERR_PACK(0,ASN1_F_D2I_PBEPARAM,0), "d2i_PBEPARAM"},
147{ERR_PACK(0,ASN1_F_D2I_PBKDF2PARAM,0), "d2i_PBKDF2PARAM"},
148{ERR_PACK(0,ASN1_F_D2I_PKCS12,0), "d2i_PKCS12"},
149{ERR_PACK(0,ASN1_F_D2I_PKCS12_BAGS,0), "d2i_PKCS12_BAGS"},
150{ERR_PACK(0,ASN1_F_D2I_PKCS12_MAC_DATA,0), "d2i_PKCS12_MAC_DATA"},
151{ERR_PACK(0,ASN1_F_D2I_PKCS12_SAFEBAG,0), "d2i_PKCS12_SAFEBAG"},
152{ERR_PACK(0,ASN1_F_D2I_PKCS7,0), "d2i_PKCS7"},
153{ERR_PACK(0,ASN1_F_D2I_PKCS7_DIGEST,0), "d2i_PKCS7_DIGEST"},
154{ERR_PACK(0,ASN1_F_D2I_PKCS7_ENCRYPT,0), "d2i_PKCS7_ENCRYPT"},
155{ERR_PACK(0,ASN1_F_D2I_PKCS7_ENC_CONTENT,0), "d2i_PKCS7_ENC_CONTENT"},
156{ERR_PACK(0,ASN1_F_D2I_PKCS7_ENVELOPE,0), "d2i_PKCS7_ENVELOPE"},
157{ERR_PACK(0,ASN1_F_D2I_PKCS7_ISSUER_AND_SERIAL,0), "d2i_PKCS7_ISSUER_AND_SERIAL"},
158{ERR_PACK(0,ASN1_F_D2I_PKCS7_RECIP_INFO,0), "d2i_PKCS7_RECIP_INFO"},
159{ERR_PACK(0,ASN1_F_D2I_PKCS7_SIGNED,0), "d2i_PKCS7_SIGNED"},
160{ERR_PACK(0,ASN1_F_D2I_PKCS7_SIGNER_INFO,0), "d2i_PKCS7_SIGNER_INFO"},
161{ERR_PACK(0,ASN1_F_D2I_PKCS7_SIGN_ENVELOPE,0), "d2i_PKCS7_SIGN_ENVELOPE"},
162{ERR_PACK(0,ASN1_F_D2I_PKCS8_PRIV_KEY_INFO,0), "d2i_PKCS8_PRIV_KEY_INFO"},
163{ERR_PACK(0,ASN1_F_D2I_PKEY_USAGE_PERIOD,0), "d2i_PKEY_USAGE_PERIOD"},
164{ERR_PACK(0,ASN1_F_D2I_POLICYINFO,0), "d2i_POLICYINFO"},
165{ERR_PACK(0,ASN1_F_D2I_POLICYQUALINFO,0), "d2i_POLICYQUALINFO"},
166{ERR_PACK(0,ASN1_F_D2I_PRIVATEKEY,0), "d2i_PrivateKey"}, 123{ERR_PACK(0,ASN1_F_D2I_PRIVATEKEY,0), "d2i_PrivateKey"},
167{ERR_PACK(0,ASN1_F_D2I_PUBLICKEY,0), "d2i_PublicKey"}, 124{ERR_PACK(0,ASN1_F_D2I_PUBLICKEY,0), "d2i_PublicKey"},
168{ERR_PACK(0,ASN1_F_D2I_RSAPRIVATEKEY,0), "d2i_RSAPrivateKey"}, 125{ERR_PACK(0,ASN1_F_D2I_X509,0), "D2I_X509"},
169{ERR_PACK(0,ASN1_F_D2I_RSAPUBLICKEY,0), "d2i_RSAPublicKey"}, 126{ERR_PACK(0,ASN1_F_D2I_X509_CINF,0), "D2I_X509_CINF"},
170{ERR_PACK(0,ASN1_F_D2I_SXNET,0), "d2i_SXNET"}, 127{ERR_PACK(0,ASN1_F_D2I_X509_NAME,0), "D2I_X509_NAME"},
171{ERR_PACK(0,ASN1_F_D2I_SXNETID,0), "d2i_SXNETID"},
172{ERR_PACK(0,ASN1_F_D2I_USERNOTICE,0), "d2i_USERNOTICE"},
173{ERR_PACK(0,ASN1_F_D2I_X509,0), "d2i_X509"},
174{ERR_PACK(0,ASN1_F_D2I_X509_ALGOR,0), "d2i_X509_ALGOR"},
175{ERR_PACK(0,ASN1_F_D2I_X509_ATTRIBUTE,0), "d2i_X509_ATTRIBUTE"},
176{ERR_PACK(0,ASN1_F_D2I_X509_CERT_AUX,0), "d2i_X509_CERT_AUX"},
177{ERR_PACK(0,ASN1_F_D2I_X509_CINF,0), "d2i_X509_CINF"},
178{ERR_PACK(0,ASN1_F_D2I_X509_CRL,0), "d2i_X509_CRL"},
179{ERR_PACK(0,ASN1_F_D2I_X509_CRL_INFO,0), "d2i_X509_CRL_INFO"},
180{ERR_PACK(0,ASN1_F_D2I_X509_EXTENSION,0), "d2i_X509_EXTENSION"},
181{ERR_PACK(0,ASN1_F_D2I_X509_KEY,0), "D2I_X509_KEY"},
182{ERR_PACK(0,ASN1_F_D2I_X509_NAME,0), "d2i_X509_NAME"},
183{ERR_PACK(0,ASN1_F_D2I_X509_NAME_ENTRY,0), "d2i_X509_NAME_ENTRY"},
184{ERR_PACK(0,ASN1_F_D2I_X509_PKEY,0), "d2i_X509_PKEY"}, 128{ERR_PACK(0,ASN1_F_D2I_X509_PKEY,0), "d2i_X509_PKEY"},
185{ERR_PACK(0,ASN1_F_D2I_X509_PUBKEY,0), "d2i_X509_PUBKEY"}, 129{ERR_PACK(0,ASN1_F_I2D_ASN1_TIME,0), "I2D_ASN1_TIME"},
186{ERR_PACK(0,ASN1_F_D2I_X509_REQ,0), "d2i_X509_REQ"},
187{ERR_PACK(0,ASN1_F_D2I_X509_REQ_INFO,0), "d2i_X509_REQ_INFO"},
188{ERR_PACK(0,ASN1_F_D2I_X509_REVOKED,0), "d2i_X509_REVOKED"},
189{ERR_PACK(0,ASN1_F_D2I_X509_SIG,0), "d2i_X509_SIG"},
190{ERR_PACK(0,ASN1_F_D2I_X509_VAL,0), "d2i_X509_VAL"},
191{ERR_PACK(0,ASN1_F_DIST_POINT_NAME_NEW,0), "DIST_POINT_NAME_new"},
192{ERR_PACK(0,ASN1_F_DIST_POINT_NEW,0), "DIST_POINT_new"},
193{ERR_PACK(0,ASN1_F_GENERAL_NAME_NEW,0), "GENERAL_NAME_new"},
194{ERR_PACK(0,ASN1_F_I2D_ASN1_HEADER,0), "i2d_ASN1_HEADER"},
195{ERR_PACK(0,ASN1_F_I2D_ASN1_TIME,0), "i2d_ASN1_TIME"},
196{ERR_PACK(0,ASN1_F_I2D_DHPARAMS,0), "i2d_DHparams"},
197{ERR_PACK(0,ASN1_F_I2D_DSAPARAMS,0), "i2d_DSAparams"},
198{ERR_PACK(0,ASN1_F_I2D_DSAPRIVATEKEY,0), "i2d_DSAPrivateKey"},
199{ERR_PACK(0,ASN1_F_I2D_DSAPUBLICKEY,0), "i2d_DSAPublicKey"},
200{ERR_PACK(0,ASN1_F_I2D_DSA_PUBKEY,0), "i2d_DSA_PUBKEY"}, 130{ERR_PACK(0,ASN1_F_I2D_DSA_PUBKEY,0), "i2d_DSA_PUBKEY"},
201{ERR_PACK(0,ASN1_F_I2D_NETSCAPE_RSA,0), "i2d_Netscape_RSA"}, 131{ERR_PACK(0,ASN1_F_I2D_NETSCAPE_RSA,0), "i2d_Netscape_RSA"},
202{ERR_PACK(0,ASN1_F_I2D_PKCS7,0), "i2d_PKCS7"},
203{ERR_PACK(0,ASN1_F_I2D_PRIVATEKEY,0), "i2d_PrivateKey"}, 132{ERR_PACK(0,ASN1_F_I2D_PRIVATEKEY,0), "i2d_PrivateKey"},
204{ERR_PACK(0,ASN1_F_I2D_PUBLICKEY,0), "i2d_PublicKey"}, 133{ERR_PACK(0,ASN1_F_I2D_PUBLICKEY,0), "i2d_PublicKey"},
205{ERR_PACK(0,ASN1_F_I2D_RSAPRIVATEKEY,0), "i2d_RSAPrivateKey"},
206{ERR_PACK(0,ASN1_F_I2D_RSAPUBLICKEY,0), "i2d_RSAPublicKey"},
207{ERR_PACK(0,ASN1_F_I2D_RSA_PUBKEY,0), "i2d_RSA_PUBKEY"}, 134{ERR_PACK(0,ASN1_F_I2D_RSA_PUBKEY,0), "i2d_RSA_PUBKEY"},
208{ERR_PACK(0,ASN1_F_I2D_X509_ATTRIBUTE,0), "i2d_X509_ATTRIBUTE"}, 135{ERR_PACK(0,ASN1_F_LONG_C2I,0), "LONG_C2I"},
209{ERR_PACK(0,ASN1_F_I2T_ASN1_OBJECT,0), "i2t_ASN1_OBJECT"}, 136{ERR_PACK(0,ASN1_F_OID_MODULE_INIT,0), "OID_MODULE_INIT"},
210{ERR_PACK(0,ASN1_F_NETSCAPE_CERT_SEQUENCE_NEW,0), "NETSCAPE_CERT_SEQUENCE_new"},
211{ERR_PACK(0,ASN1_F_NETSCAPE_PKEY_NEW,0), "NETSCAPE_PKEY_NEW"},
212{ERR_PACK(0,ASN1_F_NETSCAPE_SPKAC_NEW,0), "NETSCAPE_SPKAC_new"},
213{ERR_PACK(0,ASN1_F_NETSCAPE_SPKI_NEW,0), "NETSCAPE_SPKI_new"},
214{ERR_PACK(0,ASN1_F_NOTICEREF_NEW,0), "NOTICEREF_new"},
215{ERR_PACK(0,ASN1_F_OTHERNAME_NEW,0), "OTHERNAME_new"},
216{ERR_PACK(0,ASN1_F_PBE2PARAM_NEW,0), "PBE2PARAM_new"},
217{ERR_PACK(0,ASN1_F_PBEPARAM_NEW,0), "PBEPARAM_new"},
218{ERR_PACK(0,ASN1_F_PBKDF2PARAM_NEW,0), "PBKDF2PARAM_new"},
219{ERR_PACK(0,ASN1_F_PKCS12_BAGS_NEW,0), "PKCS12_BAGS_new"},
220{ERR_PACK(0,ASN1_F_PKCS12_MAC_DATA_NEW,0), "PKCS12_MAC_DATA_new"},
221{ERR_PACK(0,ASN1_F_PKCS12_NEW,0), "PKCS12_new"},
222{ERR_PACK(0,ASN1_F_PKCS12_SAFEBAG_NEW,0), "PKCS12_SAFEBAG_new"},
223{ERR_PACK(0,ASN1_F_PKCS5_PBE2_SET,0), "PKCS5_pbe2_set"}, 137{ERR_PACK(0,ASN1_F_PKCS5_PBE2_SET,0), "PKCS5_pbe2_set"},
224{ERR_PACK(0,ASN1_F_PKCS7_DIGEST_NEW,0), "PKCS7_DIGEST_new"}, 138{ERR_PACK(0,ASN1_F_X509_CINF_NEW,0), "X509_CINF_NEW"},
225{ERR_PACK(0,ASN1_F_PKCS7_ENCRYPT_NEW,0), "PKCS7_ENCRYPT_new"}, 139{ERR_PACK(0,ASN1_F_X509_CRL_ADD0_REVOKED,0), "X509_CRL_add0_revoked"},
226{ERR_PACK(0,ASN1_F_PKCS7_ENC_CONTENT_NEW,0), "PKCS7_ENC_CONTENT_new"},
227{ERR_PACK(0,ASN1_F_PKCS7_ENVELOPE_NEW,0), "PKCS7_ENVELOPE_new"},
228{ERR_PACK(0,ASN1_F_PKCS7_ISSUER_AND_SERIAL_NEW,0), "PKCS7_ISSUER_AND_SERIAL_new"},
229{ERR_PACK(0,ASN1_F_PKCS7_NEW,0), "PKCS7_new"},
230{ERR_PACK(0,ASN1_F_PKCS7_RECIP_INFO_NEW,0), "PKCS7_RECIP_INFO_new"},
231{ERR_PACK(0,ASN1_F_PKCS7_SIGNED_NEW,0), "PKCS7_SIGNED_new"},
232{ERR_PACK(0,ASN1_F_PKCS7_SIGNER_INFO_NEW,0), "PKCS7_SIGNER_INFO_new"},
233{ERR_PACK(0,ASN1_F_PKCS7_SIGN_ENVELOPE_NEW,0), "PKCS7_SIGN_ENVELOPE_new"},
234{ERR_PACK(0,ASN1_F_PKCS8_PRIV_KEY_INFO_NEW,0), "PKCS8_PRIV_KEY_INFO_new"},
235{ERR_PACK(0,ASN1_F_PKEY_USAGE_PERIOD_NEW,0), "PKEY_USAGE_PERIOD_new"},
236{ERR_PACK(0,ASN1_F_POLICYINFO_NEW,0), "POLICYINFO_new"},
237{ERR_PACK(0,ASN1_F_POLICYQUALINFO_NEW,0), "POLICYQUALINFO_new"},
238{ERR_PACK(0,ASN1_F_SXNETID_NEW,0), "SXNETID_new"},
239{ERR_PACK(0,ASN1_F_SXNET_NEW,0), "SXNET_new"},
240{ERR_PACK(0,ASN1_F_USERNOTICE_NEW,0), "USERNOTICE_new"},
241{ERR_PACK(0,ASN1_F_X509_ALGOR_NEW,0), "X509_ALGOR_new"},
242{ERR_PACK(0,ASN1_F_X509_ATTRIBUTE_NEW,0), "X509_ATTRIBUTE_new"},
243{ERR_PACK(0,ASN1_F_X509_CERT_AUX_NEW,0), "X509_CERT_AUX_new"},
244{ERR_PACK(0,ASN1_F_X509_CINF_NEW,0), "X509_CINF_new"},
245{ERR_PACK(0,ASN1_F_X509_CRL_INFO_NEW,0), "X509_CRL_INFO_new"},
246{ERR_PACK(0,ASN1_F_X509_CRL_NEW,0), "X509_CRL_new"},
247{ERR_PACK(0,ASN1_F_X509_DHPARAMS_NEW,0), "X509_DHPARAMS_NEW"},
248{ERR_PACK(0,ASN1_F_X509_EXTENSION_NEW,0), "X509_EXTENSION_new"},
249{ERR_PACK(0,ASN1_F_X509_INFO_NEW,0), "X509_INFO_new"}, 140{ERR_PACK(0,ASN1_F_X509_INFO_NEW,0), "X509_INFO_new"},
250{ERR_PACK(0,ASN1_F_X509_KEY_NEW,0), "X509_KEY_NEW"}, 141{ERR_PACK(0,ASN1_F_X509_NAME_NEW,0), "X509_NAME_NEW"},
251{ERR_PACK(0,ASN1_F_X509_NAME_ENTRY_NEW,0), "X509_NAME_ENTRY_new"}, 142{ERR_PACK(0,ASN1_F_X509_NEW,0), "X509_NEW"},
252{ERR_PACK(0,ASN1_F_X509_NAME_NEW,0), "X509_NAME_new"},
253{ERR_PACK(0,ASN1_F_X509_NEW,0), "X509_new"},
254{ERR_PACK(0,ASN1_F_X509_PKEY_NEW,0), "X509_PKEY_new"}, 143{ERR_PACK(0,ASN1_F_X509_PKEY_NEW,0), "X509_PKEY_new"},
255{ERR_PACK(0,ASN1_F_X509_PUBKEY_NEW,0), "X509_PUBKEY_new"},
256{ERR_PACK(0,ASN1_F_X509_REQ_INFO_NEW,0), "X509_REQ_INFO_new"},
257{ERR_PACK(0,ASN1_F_X509_REQ_NEW,0), "X509_REQ_new"},
258{ERR_PACK(0,ASN1_F_X509_REVOKED_NEW,0), "X509_REVOKED_new"},
259{ERR_PACK(0,ASN1_F_X509_SIG_NEW,0), "X509_SIG_new"},
260{ERR_PACK(0,ASN1_F_X509_VAL_FREE,0), "X509_VAL_free"},
261{ERR_PACK(0,ASN1_F_X509_VAL_NEW,0), "X509_VAL_new"},
262{0,NULL} 144{0,NULL}
263 }; 145 };
264 146
265static ERR_STRING_DATA ASN1_str_reasons[]= 147static ERR_STRING_DATA ASN1_str_reasons[]=
266 { 148 {
149{ASN1_R_ADDING_OBJECT ,"adding object"},
150{ASN1_R_AUX_ERROR ,"aux error"},
267{ASN1_R_BAD_CLASS ,"bad class"}, 151{ASN1_R_BAD_CLASS ,"bad class"},
268{ASN1_R_BAD_OBJECT_HEADER ,"bad object header"}, 152{ASN1_R_BAD_OBJECT_HEADER ,"bad object header"},
269{ASN1_R_BAD_PASSWORD_READ ,"bad password read"}, 153{ASN1_R_BAD_PASSWORD_READ ,"bad password read"},
270{ASN1_R_BAD_PKCS7_CONTENT ,"bad pkcs7 content"},
271{ASN1_R_BAD_PKCS7_TYPE ,"bad pkcs7 type"},
272{ASN1_R_BAD_TAG ,"bad tag"}, 154{ASN1_R_BAD_TAG ,"bad tag"},
273{ASN1_R_BAD_TYPE ,"bad type"},
274{ASN1_R_BN_LIB ,"bn lib"}, 155{ASN1_R_BN_LIB ,"bn lib"},
275{ASN1_R_BOOLEAN_IS_WRONG_LENGTH ,"boolean is wrong length"}, 156{ASN1_R_BOOLEAN_IS_WRONG_LENGTH ,"boolean is wrong length"},
276{ASN1_R_BUFFER_TOO_SMALL ,"buffer too small"}, 157{ASN1_R_BUFFER_TOO_SMALL ,"buffer too small"},
@@ -279,22 +160,24 @@ static ERR_STRING_DATA ASN1_str_reasons[]=
279{ASN1_R_DECODE_ERROR ,"decode error"}, 160{ASN1_R_DECODE_ERROR ,"decode error"},
280{ASN1_R_DECODING_ERROR ,"decoding error"}, 161{ASN1_R_DECODING_ERROR ,"decoding error"},
281{ASN1_R_ENCODE_ERROR ,"encode error"}, 162{ASN1_R_ENCODE_ERROR ,"encode error"},
163{ASN1_R_ERROR_LOADING_SECTION ,"error loading section"},
282{ASN1_R_ERROR_PARSING_SET_ELEMENT ,"error parsing set element"}, 164{ASN1_R_ERROR_PARSING_SET_ELEMENT ,"error parsing set element"},
283{ASN1_R_ERROR_SETTING_CIPHER_PARAMS ,"error setting cipher params"}, 165{ASN1_R_ERROR_SETTING_CIPHER_PARAMS ,"error setting cipher params"},
284{ASN1_R_EXPECTING_AN_ENUMERATED ,"expecting an enumerated"},
285{ASN1_R_EXPECTING_AN_INTEGER ,"expecting an integer"}, 166{ASN1_R_EXPECTING_AN_INTEGER ,"expecting an integer"},
286{ASN1_R_EXPECTING_AN_OBJECT ,"expecting an object"}, 167{ASN1_R_EXPECTING_AN_OBJECT ,"expecting an object"},
287{ASN1_R_EXPECTING_AN_OCTET_STRING ,"expecting an octet string"},
288{ASN1_R_EXPECTING_A_BIT_STRING ,"expecting a bit string"},
289{ASN1_R_EXPECTING_A_BOOLEAN ,"expecting a boolean"}, 168{ASN1_R_EXPECTING_A_BOOLEAN ,"expecting a boolean"},
290{ASN1_R_EXPECTING_A_GENERALIZEDTIME ,"expecting a generalizedtime"},
291{ASN1_R_EXPECTING_A_NULL ,"expecting a null"},
292{ASN1_R_EXPECTING_A_TIME ,"expecting a time"}, 169{ASN1_R_EXPECTING_A_TIME ,"expecting a time"},
293{ASN1_R_EXPECTING_A_UTCTIME ,"expecting a utctime"}, 170{ASN1_R_EXPLICIT_LENGTH_MISMATCH ,"explicit length mismatch"},
171{ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED ,"explicit tag not constructed"},
172{ASN1_R_FIELD_MISSING ,"field missing"},
294{ASN1_R_FIRST_NUM_TOO_LARGE ,"first num too large"}, 173{ASN1_R_FIRST_NUM_TOO_LARGE ,"first num too large"},
295{ASN1_R_GENERALIZEDTIME_TOO_LONG ,"generalizedtime too long"},
296{ASN1_R_HEADER_TOO_LONG ,"header too long"}, 174{ASN1_R_HEADER_TOO_LONG ,"header too long"},
297{ASN1_R_ILLEGAL_CHARACTERS ,"illegal characters"}, 175{ASN1_R_ILLEGAL_CHARACTERS ,"illegal characters"},
176{ASN1_R_ILLEGAL_NULL ,"illegal null"},
177{ASN1_R_ILLEGAL_OPTIONAL_ANY ,"illegal optional any"},
178{ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE ,"illegal options on item template"},
179{ASN1_R_ILLEGAL_TAGGED_ANY ,"illegal tagged any"},
180{ASN1_R_INTEGER_TOO_LARGE_FOR_LONG ,"integer too large for long"},
298{ASN1_R_INVALID_BMPSTRING_LENGTH ,"invalid bmpstring length"}, 181{ASN1_R_INVALID_BMPSTRING_LENGTH ,"invalid bmpstring length"},
299{ASN1_R_INVALID_DIGIT ,"invalid digit"}, 182{ASN1_R_INVALID_DIGIT ,"invalid digit"},
300{ASN1_R_INVALID_SEPARATOR ,"invalid separator"}, 183{ASN1_R_INVALID_SEPARATOR ,"invalid separator"},
@@ -303,32 +186,37 @@ static ERR_STRING_DATA ASN1_str_reasons[]=
303{ASN1_R_INVALID_UTF8STRING ,"invalid utf8string"}, 186{ASN1_R_INVALID_UTF8STRING ,"invalid utf8string"},
304{ASN1_R_IV_TOO_LARGE ,"iv too large"}, 187{ASN1_R_IV_TOO_LARGE ,"iv too large"},
305{ASN1_R_LENGTH_ERROR ,"length error"}, 188{ASN1_R_LENGTH_ERROR ,"length error"},
189{ASN1_R_MISSING_EOC ,"missing eoc"},
306{ASN1_R_MISSING_SECOND_NUMBER ,"missing second number"}, 190{ASN1_R_MISSING_SECOND_NUMBER ,"missing second number"},
191{ASN1_R_MSTRING_NOT_UNIVERSAL ,"mstring not universal"},
192{ASN1_R_MSTRING_WRONG_TAG ,"mstring wrong tag"},
307{ASN1_R_NON_HEX_CHARACTERS ,"non hex characters"}, 193{ASN1_R_NON_HEX_CHARACTERS ,"non hex characters"},
308{ASN1_R_NOT_ENOUGH_DATA ,"not enough data"}, 194{ASN1_R_NOT_ENOUGH_DATA ,"not enough data"},
195{ASN1_R_NO_MATCHING_CHOICE_TYPE ,"no matching choice type"},
309{ASN1_R_NULL_IS_WRONG_LENGTH ,"null is wrong length"}, 196{ASN1_R_NULL_IS_WRONG_LENGTH ,"null is wrong length"},
310{ASN1_R_ODD_NUMBER_OF_CHARS ,"odd number of chars"}, 197{ASN1_R_ODD_NUMBER_OF_CHARS ,"odd number of chars"},
311{ASN1_R_PARSING ,"parsing"},
312{ASN1_R_PRIVATE_KEY_HEADER_MISSING ,"private key header missing"}, 198{ASN1_R_PRIVATE_KEY_HEADER_MISSING ,"private key header missing"},
313{ASN1_R_SECOND_NUMBER_TOO_LARGE ,"second number too large"}, 199{ASN1_R_SECOND_NUMBER_TOO_LARGE ,"second number too large"},
200{ASN1_R_SEQUENCE_LENGTH_MISMATCH ,"sequence length mismatch"},
201{ASN1_R_SEQUENCE_NOT_CONSTRUCTED ,"sequence not constructed"},
314{ASN1_R_SHORT_LINE ,"short line"}, 202{ASN1_R_SHORT_LINE ,"short line"},
315{ASN1_R_STRING_TOO_LONG ,"string too long"}, 203{ASN1_R_STRING_TOO_LONG ,"string too long"},
316{ASN1_R_STRING_TOO_SHORT ,"string too short"}, 204{ASN1_R_STRING_TOO_SHORT ,"string too short"},
317{ASN1_R_TAG_VALUE_TOO_HIGH ,"tag value too high"}, 205{ASN1_R_TAG_VALUE_TOO_HIGH ,"tag value too high"},
318{ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD,"the asn1 object identifier is not known for this md"}, 206{ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD,"the asn1 object identifier is not known for this md"},
319{ASN1_R_TOO_LONG ,"too long"}, 207{ASN1_R_TOO_LONG ,"too long"},
208{ASN1_R_TYPE_NOT_CONSTRUCTED ,"type not constructed"},
320{ASN1_R_UNABLE_TO_DECODE_RSA_KEY ,"unable to decode rsa key"}, 209{ASN1_R_UNABLE_TO_DECODE_RSA_KEY ,"unable to decode rsa key"},
321{ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY ,"unable to decode rsa private key"}, 210{ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY ,"unable to decode rsa private key"},
322{ASN1_R_UNKNOWN_ATTRIBUTE_TYPE ,"unknown attribute type"}, 211{ASN1_R_UNEXPECTED_EOC ,"unexpected eoc"},
323{ASN1_R_UNKNOWN_FORMAT ,"unknown format"}, 212{ASN1_R_UNKNOWN_FORMAT ,"unknown format"},
324{ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM ,"unknown message digest algorithm"}, 213{ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM ,"unknown message digest algorithm"},
325{ASN1_R_UNKNOWN_OBJECT_TYPE ,"unknown object type"}, 214{ASN1_R_UNKNOWN_OBJECT_TYPE ,"unknown object type"},
326{ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE ,"unknown public key type"}, 215{ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE ,"unknown public key type"},
216{ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE ,"unsupported any defined by type"},
327{ASN1_R_UNSUPPORTED_CIPHER ,"unsupported cipher"}, 217{ASN1_R_UNSUPPORTED_CIPHER ,"unsupported cipher"},
328{ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM ,"unsupported encryption algorithm"}, 218{ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM ,"unsupported encryption algorithm"},
329{ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE ,"unsupported public key type"}, 219{ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE ,"unsupported public key type"},
330{ASN1_R_UTCTIME_TOO_LONG ,"utctime too long"},
331{ASN1_R_WRONG_PRINTABLE_TYPE ,"wrong printable type"},
332{ASN1_R_WRONG_TAG ,"wrong tag"}, 220{ASN1_R_WRONG_TAG ,"wrong tag"},
333{ASN1_R_WRONG_TYPE ,"wrong type"}, 221{ASN1_R_WRONG_TYPE ,"wrong type"},
334{0,NULL} 222{0,NULL}
@@ -343,7 +231,7 @@ void ERR_load_ASN1_strings(void)
343 if (init) 231 if (init)
344 { 232 {
345 init=0; 233 init=0;
346#ifndef NO_ERR 234#ifndef OPENSSL_NO_ERR
347 ERR_load_strings(ERR_LIB_ASN1,ASN1_str_functs); 235 ERR_load_strings(ERR_LIB_ASN1,ASN1_str_functs);
348 ERR_load_strings(ERR_LIB_ASN1,ASN1_str_reasons); 236 ERR_load_strings(ERR_LIB_ASN1,ASN1_str_reasons);
349#endif 237#endif
diff --git a/src/lib/libcrypto/asn1/asn1_lib.c b/src/lib/libcrypto/asn1/asn1_lib.c
index a8b651e54e..830ff2af3c 100644
--- a/src/lib/libcrypto/asn1/asn1_lib.c
+++ b/src/lib/libcrypto/asn1/asn1_lib.c
@@ -59,7 +59,6 @@
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/asn1.h> 61#include <openssl/asn1.h>
62#include <openssl/asn1_mac.h>
63 62
64static int asn1_get_length(unsigned char **pp,int *inf,long *rl,int max); 63static int asn1_get_length(unsigned char **pp,int *inf,long *rl,int max);
65static void asn1_put_length(unsigned char **pp, int length); 64static void asn1_put_length(unsigned char **pp, int length);
@@ -301,7 +300,7 @@ int asn1_GetSequence(ASN1_CTX *c, long *length)
301 return(0); 300 return(0);
302 } 301 }
303 if (c->inf == (1|V_ASN1_CONSTRUCTED)) 302 if (c->inf == (1|V_ASN1_CONSTRUCTED))
304 c->slen= *length; 303 c->slen= *length+ *(c->pp)-c->p;
305 c->eos=0; 304 c->eos=0;
306 return(1); 305 return(1);
307 } 306 }
diff --git a/src/lib/libcrypto/asn1/asn1_mac.h b/src/lib/libcrypto/asn1/asn1_mac.h
index af0e664b2d..a48649ceeb 100644
--- a/src/lib/libcrypto/asn1/asn1_mac.h
+++ b/src/lib/libcrypto/asn1/asn1_mac.h
@@ -70,14 +70,14 @@ extern "C" {
70#endif 70#endif
71 71
72#define ASN1_MAC_H_err(f,r,line) \ 72#define ASN1_MAC_H_err(f,r,line) \
73 ERR_PUT_error(ASN1_MAC_ERR_LIB,(f),(r),ERR_file_name,(line)) 73 ERR_PUT_error(ASN1_MAC_ERR_LIB,(f),(r),__FILE__,(line))
74 74
75#define M_ASN1_D2I_vars(a,type,func) \ 75#define M_ASN1_D2I_vars(a,type,func) \
76 ASN1_CTX c; \ 76 ASN1_CTX c; \
77 type ret=NULL; \ 77 type ret=NULL; \
78 \ 78 \
79 c.pp=pp; \ 79 c.pp=(unsigned char **)pp; \
80 c.q= *pp; \ 80 c.q= *(unsigned char **)pp; \
81 c.error=ERR_R_NESTED_ASN1_ERROR; \ 81 c.error=ERR_R_NESTED_ASN1_ERROR; \
82 if ((a == NULL) || ((*a) == NULL)) \ 82 if ((a == NULL) || ((*a) == NULL)) \
83 { if ((ret=(type)func()) == NULL) \ 83 { if ((ret=(type)func()) == NULL) \
@@ -85,13 +85,13 @@ extern "C" {
85 else ret=(*a); 85 else ret=(*a);
86 86
87#define M_ASN1_D2I_Init() \ 87#define M_ASN1_D2I_Init() \
88 c.p= *pp; \ 88 c.p= *(unsigned char **)pp; \
89 c.max=(length == 0)?0:(c.p+length); 89 c.max=(length == 0)?0:(c.p+length);
90 90
91#define M_ASN1_D2I_Finish_2(a) \ 91#define M_ASN1_D2I_Finish_2(a) \
92 if (!asn1_Finish(&c)) \ 92 if (!asn1_Finish(&c)) \
93 { c.line=__LINE__; goto err; } \ 93 { c.line=__LINE__; goto err; } \
94 *pp=c.p; \ 94 *(unsigned char **)pp=c.p; \
95 if (a != NULL) (*a)=ret; \ 95 if (a != NULL) (*a)=ret; \
96 return(ret); 96 return(ret);
97 97
@@ -99,7 +99,7 @@ extern "C" {
99 M_ASN1_D2I_Finish_2(a); \ 99 M_ASN1_D2I_Finish_2(a); \
100err:\ 100err:\
101 ASN1_MAC_H_err((e),c.error,c.line); \ 101 ASN1_MAC_H_err((e),c.error,c.line); \
102 asn1_add_error(*pp,(int)(c.q- *pp)); \ 102 asn1_add_error(*(unsigned char **)pp,(int)(c.q- *pp)); \
103 if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \ 103 if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \
104 return(NULL) 104 return(NULL)
105 105
@@ -196,9 +196,6 @@ err:\
196 if ((a != NULL) && (sk_##type##_num(a) != 0)) \ 196 if ((a != NULL) && (sk_##type##_num(a) != 0)) \
197 M_ASN1_I2D_put_SEQUENCE_type(type,a,f); 197 M_ASN1_I2D_put_SEQUENCE_type(type,a,f);
198 198
199#define M_ASN1_I2D_put_SEQUENCE_opt_ex_type(type,a,f) \
200 if (a) M_ASN1_I2D_put_SEQUENCE_type(type,a,f);
201
202#define M_ASN1_D2I_get_IMP_set_opt(b,func,free_func,tag) \ 199#define M_ASN1_D2I_get_IMP_set_opt(b,func,free_func,tag) \
203 if ((c.slen != 0) && \ 200 if ((c.slen != 0) && \
204 (M_ASN1_next == \ 201 (M_ASN1_next == \
@@ -392,9 +389,6 @@ err:\
392 if ((a != NULL) && (sk_##type##_num(a) != 0)) \ 389 if ((a != NULL) && (sk_##type##_num(a) != 0)) \
393 M_ASN1_I2D_len_SEQUENCE_type(type,a,f); 390 M_ASN1_I2D_len_SEQUENCE_type(type,a,f);
394 391
395#define M_ASN1_I2D_len_SEQUENCE_opt_ex_type(type,a,f) \
396 if (a) M_ASN1_I2D_len_SEQUENCE_type(type,a,f);
397
398#define M_ASN1_I2D_len_IMP_SET(a,f,x) \ 392#define M_ASN1_I2D_len_IMP_SET(a,f,x) \
399 ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC,IS_SET); 393 ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC,IS_SET);
400 394
@@ -458,15 +452,6 @@ err:\
458 ret+=ASN1_object_size(1,v,mtag); \ 452 ret+=ASN1_object_size(1,v,mtag); \
459 } 453 }
460 454
461#define M_ASN1_I2D_len_EXP_SEQUENCE_opt_ex_type(type,a,f,mtag,tag,v) \
462 if (a)\
463 { \
464 v=i2d_ASN1_SET_OF_##type(a,NULL,f,tag, \
465 V_ASN1_UNIVERSAL, \
466 IS_SEQUENCE); \
467 ret+=ASN1_object_size(1,v,mtag); \
468 }
469
470/* Put Macros */ 455/* Put Macros */
471#define M_ASN1_I2D_put(a,f) f(a,&p) 456#define M_ASN1_I2D_put(a,f) f(a,&p)
472 457
@@ -551,14 +536,6 @@ err:\
551 IS_SEQUENCE); \ 536 IS_SEQUENCE); \
552 } 537 }
553 538
554#define M_ASN1_I2D_put_EXP_SEQUENCE_opt_ex_type(type,a,f,mtag,tag,v) \
555 if (a) \
556 { \
557 ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \
558 i2d_ASN1_SET_OF_##type(a,&p,f,tag,V_ASN1_UNIVERSAL, \
559 IS_SEQUENCE); \
560 }
561
562#define M_ASN1_I2D_seq_total() \ 539#define M_ASN1_I2D_seq_total() \
563 r=ASN1_object_size(1,ret,V_ASN1_SEQUENCE); \ 540 r=ASN1_object_size(1,ret,V_ASN1_SEQUENCE); \
564 if (pp == NULL) return(r); \ 541 if (pp == NULL) return(r); \
diff --git a/src/lib/libcrypto/asn1/asn1t.h b/src/lib/libcrypto/asn1/asn1t.h
new file mode 100644
index 0000000000..ed372f8554
--- /dev/null
+++ b/src/lib/libcrypto/asn1/asn1t.h
@@ -0,0 +1,846 @@
1/* asn1t.h */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) 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#ifndef HEADER_ASN1T_H
59#define HEADER_ASN1T_H
60
61#include <stddef.h>
62#include <openssl/e_os2.h>
63#include <openssl/asn1.h>
64
65#ifdef OPENSSL_BUILD_SHLIBCRYPTO
66# undef OPENSSL_EXTERN
67# define OPENSSL_EXTERN OPENSSL_EXPORT
68#endif
69
70/* ASN1 template defines, structures and functions */
71
72#ifdef __cplusplus
73extern "C" {
74#endif
75
76
77#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION
78
79/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */
80#define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr))
81
82
83/* Macros for start and end of ASN1_ITEM definition */
84
85#define ASN1_ITEM_start(itname) \
86 OPENSSL_GLOBAL const ASN1_ITEM itname##_it = {
87
88#define ASN1_ITEM_end(itname) \
89 };
90
91#else
92
93/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */
94#define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr()))
95
96
97/* Macros for start and end of ASN1_ITEM definition */
98
99#define ASN1_ITEM_start(itname) \
100 const ASN1_ITEM * itname##_it(void) \
101 { \
102 static const ASN1_ITEM local_it = { \
103
104#define ASN1_ITEM_end(itname) \
105 }; \
106 return &local_it; \
107 }
108
109#endif
110
111
112/* Macros to aid ASN1 template writing */
113
114#define ASN1_ITEM_TEMPLATE(tname) \
115 const static ASN1_TEMPLATE tname##_item_tt
116
117#define ASN1_ITEM_TEMPLATE_END(tname) \
118 ;\
119 ASN1_ITEM_start(tname) \
120 ASN1_ITYPE_PRIMITIVE,\
121 -1,\
122 &tname##_item_tt,\
123 0,\
124 NULL,\
125 0,\
126 #tname \
127 ASN1_ITEM_end(tname)
128
129
130/* This is a ASN1 type which just embeds a template */
131
132/* This pair helps declare a SEQUENCE. We can do:
133 *
134 * ASN1_SEQUENCE(stname) = {
135 * ... SEQUENCE components ...
136 * } ASN1_SEQUENCE_END(stname)
137 *
138 * This will produce an ASN1_ITEM called stname_it
139 * for a structure called stname.
140 *
141 * If you want the same structure but a different
142 * name then use:
143 *
144 * ASN1_SEQUENCE(itname) = {
145 * ... SEQUENCE components ...
146 * } ASN1_SEQUENCE_END_name(stname, itname)
147 *
148 * This will create an item called itname_it using
149 * a structure called stname.
150 */
151
152#define ASN1_SEQUENCE(tname) \
153 const static ASN1_TEMPLATE tname##_seq_tt[]
154
155#define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname)
156
157#define ASN1_SEQUENCE_END_name(stname, tname) \
158 ;\
159 ASN1_ITEM_start(tname) \
160 ASN1_ITYPE_SEQUENCE,\
161 V_ASN1_SEQUENCE,\
162 tname##_seq_tt,\
163 sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
164 NULL,\
165 sizeof(stname),\
166 #stname \
167 ASN1_ITEM_end(tname)
168
169#define ASN1_SEQUENCE_cb(tname, cb) \
170 const static ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \
171 ASN1_SEQUENCE(tname)
172
173#define ASN1_BROKEN_SEQUENCE(tname) \
174 const static ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_BROKEN, 0, 0, 0, 0}; \
175 ASN1_SEQUENCE(tname)
176
177#define ASN1_SEQUENCE_ref(tname, cb, lck) \
178 const static ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_REFCOUNT, offsetof(tname, references), lck, cb, 0}; \
179 ASN1_SEQUENCE(tname)
180
181#define ASN1_SEQUENCE_enc(tname, enc, cb) \
182 const static ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_ENCODING, 0, 0, cb, offsetof(tname, enc)}; \
183 ASN1_SEQUENCE(tname)
184
185#define ASN1_BROKEN_SEQUENCE_END(stname) ASN1_SEQUENCE_END_ref(stname, stname)
186
187#define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)
188
189#define ASN1_SEQUENCE_END_cb(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)
190
191#define ASN1_SEQUENCE_END_ref(stname, tname) \
192 ;\
193 ASN1_ITEM_start(tname) \
194 ASN1_ITYPE_SEQUENCE,\
195 V_ASN1_SEQUENCE,\
196 tname##_seq_tt,\
197 sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
198 &tname##_aux,\
199 sizeof(stname),\
200 #stname \
201 ASN1_ITEM_end(tname)
202
203
204/* This pair helps declare a CHOICE type. We can do:
205 *
206 * ASN1_CHOICE(chname) = {
207 * ... CHOICE options ...
208 * ASN1_CHOICE_END(chname)
209 *
210 * This will produce an ASN1_ITEM called chname_it
211 * for a structure called chname. The structure
212 * definition must look like this:
213 * typedef struct {
214 * int type;
215 * union {
216 * ASN1_SOMETHING *opt1;
217 * ASN1_SOMEOTHER *opt2;
218 * } value;
219 * } chname;
220 *
221 * the name of the selector must be 'type'.
222 * to use an alternative selector name use the
223 * ASN1_CHOICE_END_selector() version.
224 */
225
226#define ASN1_CHOICE(tname) \
227 const static ASN1_TEMPLATE tname##_ch_tt[]
228
229#define ASN1_CHOICE_cb(tname, cb) \
230 const static ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \
231 ASN1_CHOICE(tname)
232
233#define ASN1_CHOICE_END(stname) ASN1_CHOICE_END_name(stname, stname)
234
235#define ASN1_CHOICE_END_name(stname, tname) ASN1_CHOICE_END_selector(stname, tname, type)
236
237#define ASN1_CHOICE_END_selector(stname, tname, selname) \
238 ;\
239 ASN1_ITEM_start(tname) \
240 ASN1_ITYPE_CHOICE,\
241 offsetof(stname,selname) ,\
242 tname##_ch_tt,\
243 sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\
244 NULL,\
245 sizeof(stname),\
246 #stname \
247 ASN1_ITEM_end(tname)
248
249#define ASN1_CHOICE_END_cb(stname, tname, selname) \
250 ;\
251 ASN1_ITEM_start(tname) \
252 ASN1_ITYPE_CHOICE,\
253 offsetof(stname,selname) ,\
254 tname##_ch_tt,\
255 sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\
256 &tname##_aux,\
257 sizeof(stname),\
258 #stname \
259 ASN1_ITEM_end(tname)
260
261/* This helps with the template wrapper form of ASN1_ITEM */
262
263#define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type) { \
264 (flags), (tag), 0,\
265 #name, ASN1_ITEM_ref(type) }
266
267/* These help with SEQUENCE or CHOICE components */
268
269/* used to declare other types */
270
271#define ASN1_EX_TYPE(flags, tag, stname, field, type) { \
272 (flags), (tag), offsetof(stname, field),\
273 #field, ASN1_ITEM_ref(type) }
274
275/* used when the structure is combined with the parent */
276
277#define ASN1_EX_COMBINE(flags, tag, type) { \
278 (flags)|ASN1_TFLG_COMBINE, (tag), 0, NULL, ASN1_ITEM_ref(type) }
279
280/* implicit and explicit helper macros */
281
282#define ASN1_IMP_EX(stname, field, type, tag, ex) \
283 ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | ex, tag, stname, field, type)
284
285#define ASN1_EXP_EX(stname, field, type, tag, ex) \
286 ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | ex, tag, stname, field, type)
287
288/* Any defined by macros: the field used is in the table itself */
289
290#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION
291#define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }
292#define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }
293#else
294#define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, tblname##_adb }
295#define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, tblname##_adb }
296#endif
297/* Plain simple type */
298#define ASN1_SIMPLE(stname, field, type) ASN1_EX_TYPE(0,0, stname, field, type)
299
300/* OPTIONAL simple type */
301#define ASN1_OPT(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL, 0, stname, field, type)
302
303/* IMPLICIT tagged simple type */
304#define ASN1_IMP(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, 0)
305
306/* IMPLICIT tagged OPTIONAL simple type */
307#define ASN1_IMP_OPT(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)
308
309/* Same as above but EXPLICIT */
310
311#define ASN1_EXP(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, 0)
312#define ASN1_EXP_OPT(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)
313
314/* SEQUENCE OF type */
315#define ASN1_SEQUENCE_OF(stname, field, type) \
316 ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type)
317
318/* OPTIONAL SEQUENCE OF */
319#define ASN1_SEQUENCE_OF_OPT(stname, field, type) \
320 ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type)
321
322/* Same as above but for SET OF */
323
324#define ASN1_SET_OF(stname, field, type) \
325 ASN1_EX_TYPE(ASN1_TFLG_SET_OF, 0, stname, field, type)
326
327#define ASN1_SET_OF_OPT(stname, field, type) \
328 ASN1_EX_TYPE(ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type)
329
330/* Finally compound types of SEQUENCE, SET, IMPLICIT, EXPLICIT and OPTIONAL */
331
332#define ASN1_IMP_SET_OF(stname, field, type, tag) \
333 ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)
334
335#define ASN1_EXP_SET_OF(stname, field, type, tag) \
336 ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)
337
338#define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) \
339 ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL)
340
341#define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) \
342 ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL)
343
344#define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) \
345 ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)
346
347#define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) \
348 ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)
349
350#define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) \
351 ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)
352
353#define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \
354 ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)
355
356/* Macros for the ASN1_ADB structure */
357
358#define ASN1_ADB(name) \
359 const static ASN1_ADB_TABLE name##_adbtbl[]
360
361#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION
362
363#define ASN1_ADB_END(name, flags, field, app_table, def, none) \
364 ;\
365 const static ASN1_ADB name##_adb = {\
366 flags,\
367 offsetof(name, field),\
368 app_table,\
369 name##_adbtbl,\
370 sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\
371 def,\
372 none\
373 }
374
375#else
376
377#define ASN1_ADB_END(name, flags, field, app_table, def, none) \
378 ;\
379 const static ASN1_ITEM *name##_adb(void) \
380 { \
381 const static ASN1_ADB internal_adb = \
382 {\
383 flags,\
384 offsetof(name, field),\
385 app_table,\
386 name##_adbtbl,\
387 sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\
388 def,\
389 none\
390 }; \
391 return (const ASN1_ITEM *) &internal_adb; \
392 } \
393 void dummy_function(void)
394
395#endif
396
397#define ADB_ENTRY(val, template) {val, template}
398
399#define ASN1_ADB_TEMPLATE(name) \
400 const static ASN1_TEMPLATE name##_tt
401
402/* This is the ASN1 template structure that defines
403 * a wrapper round the actual type. It determines the
404 * actual position of the field in the value structure,
405 * various flags such as OPTIONAL and the field name.
406 */
407
408struct ASN1_TEMPLATE_st {
409unsigned long flags; /* Various flags */
410long tag; /* tag, not used if no tagging */
411unsigned long offset; /* Offset of this field in structure */
412#ifndef NO_ASN1_FIELD_NAMES
413char *field_name; /* Field name */
414#endif
415ASN1_ITEM_EXP *item; /* Relevant ASN1_ITEM or ASN1_ADB */
416};
417
418/* Macro to extract ASN1_ITEM and ASN1_ADB pointer from ASN1_TEMPLATE */
419
420#define ASN1_TEMPLATE_item(t) (t->item_ptr)
421#define ASN1_TEMPLATE_adb(t) (t->item_ptr)
422
423typedef struct ASN1_ADB_TABLE_st ASN1_ADB_TABLE;
424typedef struct ASN1_ADB_st ASN1_ADB;
425
426struct ASN1_ADB_st {
427 unsigned long flags; /* Various flags */
428 unsigned long offset; /* Offset of selector field */
429 STACK_OF(ASN1_ADB_TABLE) **app_items; /* Application defined items */
430 const ASN1_ADB_TABLE *tbl; /* Table of possible types */
431 long tblcount; /* Number of entries in tbl */
432 const ASN1_TEMPLATE *default_tt; /* Type to use if no match */
433 const ASN1_TEMPLATE *null_tt; /* Type to use if selector is NULL */
434};
435
436struct ASN1_ADB_TABLE_st {
437 long value; /* NID for an object or value for an int */
438 const ASN1_TEMPLATE tt; /* item for this value */
439};
440
441/* template flags */
442
443/* Field is optional */
444#define ASN1_TFLG_OPTIONAL (0x1)
445
446/* Field is a SET OF */
447#define ASN1_TFLG_SET_OF (0x1 << 1)
448
449/* Field is a SEQUENCE OF */
450#define ASN1_TFLG_SEQUENCE_OF (0x2 << 1)
451
452/* Special case: this refers to a SET OF that
453 * will be sorted into DER order when encoded *and*
454 * the corresponding STACK will be modified to match
455 * the new order.
456 */
457#define ASN1_TFLG_SET_ORDER (0x3 << 1)
458
459/* Mask for SET OF or SEQUENCE OF */
460#define ASN1_TFLG_SK_MASK (0x3 << 1)
461
462/* These flags mean the tag should be taken from the
463 * tag field. If EXPLICIT then the underlying type
464 * is used for the inner tag.
465 */
466
467/* IMPLICIT tagging */
468#define ASN1_TFLG_IMPTAG (0x1 << 3)
469
470
471/* EXPLICIT tagging, inner tag from underlying type */
472#define ASN1_TFLG_EXPTAG (0x2 << 3)
473
474#define ASN1_TFLG_TAG_MASK (0x3 << 3)
475
476/* context specific IMPLICIT */
477#define ASN1_TFLG_IMPLICIT ASN1_TFLG_IMPTAG|ASN1_TFLG_CONTEXT
478
479/* context specific EXPLICIT */
480#define ASN1_TFLG_EXPLICIT ASN1_TFLG_EXPTAG|ASN1_TFLG_CONTEXT
481
482/* If tagging is in force these determine the
483 * type of tag to use. Otherwise the tag is
484 * determined by the underlying type. These
485 * values reflect the actual octet format.
486 */
487
488/* Universal tag */
489#define ASN1_TFLG_UNIVERSAL (0x0<<6)
490/* Application tag */
491#define ASN1_TFLG_APPLICATION (0x1<<6)
492/* Context specific tag */
493#define ASN1_TFLG_CONTEXT (0x2<<6)
494/* Private tag */
495#define ASN1_TFLG_PRIVATE (0x3<<6)
496
497#define ASN1_TFLG_TAG_CLASS (0x3<<6)
498
499/* These are for ANY DEFINED BY type. In this case
500 * the 'item' field points to an ASN1_ADB structure
501 * which contains a table of values to decode the
502 * relevant type
503 */
504
505#define ASN1_TFLG_ADB_MASK (0x3<<8)
506
507#define ASN1_TFLG_ADB_OID (0x1<<8)
508
509#define ASN1_TFLG_ADB_INT (0x1<<9)
510
511/* This flag means a parent structure is passed
512 * instead of the field: this is useful is a
513 * SEQUENCE is being combined with a CHOICE for
514 * example. Since this means the structure and
515 * item name will differ we need to use the
516 * ASN1_CHOICE_END_name() macro for example.
517 */
518
519#define ASN1_TFLG_COMBINE (0x1<<10)
520
521/* This is the actual ASN1 item itself */
522
523struct ASN1_ITEM_st {
524char itype; /* The item type, primitive, SEQUENCE, CHOICE or extern */
525long utype; /* underlying type */
526const ASN1_TEMPLATE *templates; /* If SEQUENCE or CHOICE this contains the contents */
527long tcount; /* Number of templates if SEQUENCE or CHOICE */
528const void *funcs; /* functions that handle this type */
529long size; /* Structure size (usually)*/
530#ifndef NO_ASN1_FIELD_NAMES
531const char *sname; /* Structure name */
532#endif
533};
534
535/* These are values for the itype field and
536 * determine how the type is interpreted.
537 *
538 * For PRIMITIVE types the underlying type
539 * determines the behaviour if items is NULL.
540 *
541 * Otherwise templates must contain a single
542 * template and the type is treated in the
543 * same way as the type specified in the template.
544 *
545 * For SEQUENCE types the templates field points
546 * to the members, the size field is the
547 * structure size.
548 *
549 * For CHOICE types the templates field points
550 * to each possible member (typically a union)
551 * and the 'size' field is the offset of the
552 * selector.
553 *
554 * The 'funcs' field is used for application
555 * specific functions.
556 *
557 * For COMPAT types the funcs field gives a
558 * set of functions that handle this type, this
559 * supports the old d2i, i2d convention.
560 *
561 * The EXTERN type uses a new style d2i/i2d.
562 * The new style should be used where possible
563 * because it avoids things like the d2i IMPLICIT
564 * hack.
565 *
566 * MSTRING is a multiple string type, it is used
567 * for a CHOICE of character strings where the
568 * actual strings all occupy an ASN1_STRING
569 * structure. In this case the 'utype' field
570 * has a special meaning, it is used as a mask
571 * of acceptable types using the B_ASN1 constants.
572 *
573 */
574
575#define ASN1_ITYPE_PRIMITIVE 0x0
576
577#define ASN1_ITYPE_SEQUENCE 0x1
578
579#define ASN1_ITYPE_CHOICE 0x2
580
581#define ASN1_ITYPE_COMPAT 0x3
582
583#define ASN1_ITYPE_EXTERN 0x4
584
585#define ASN1_ITYPE_MSTRING 0x5
586
587/* Cache for ASN1 tag and length, so we
588 * don't keep re-reading it for things
589 * like CHOICE
590 */
591
592struct ASN1_TLC_st{
593 char valid; /* Values below are valid */
594 int ret; /* return value */
595 long plen; /* length */
596 int ptag; /* class value */
597 int pclass; /* class value */
598 int hdrlen; /* header length */
599};
600
601/* Typedefs for ASN1 function pointers */
602
603typedef ASN1_VALUE * ASN1_new_func(void);
604typedef void ASN1_free_func(ASN1_VALUE *a);
605typedef ASN1_VALUE * ASN1_d2i_func(ASN1_VALUE **a, unsigned char ** in, long length);
606typedef int ASN1_i2d_func(ASN1_VALUE * a, unsigned char **in);
607
608typedef int ASN1_ex_d2i(ASN1_VALUE **pval, unsigned char **in, long len, const ASN1_ITEM *it,
609 int tag, int aclass, char opt, ASN1_TLC *ctx);
610
611typedef int ASN1_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass);
612typedef int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it);
613typedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it);
614
615typedef int ASN1_primitive_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it);
616typedef int ASN1_primitive_c2i(ASN1_VALUE **pval, unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it);
617
618typedef struct ASN1_COMPAT_FUNCS_st {
619 ASN1_new_func *asn1_new;
620 ASN1_free_func *asn1_free;
621 ASN1_d2i_func *asn1_d2i;
622 ASN1_i2d_func *asn1_i2d;
623} ASN1_COMPAT_FUNCS;
624
625typedef struct ASN1_EXTERN_FUNCS_st {
626 void *app_data;
627 ASN1_ex_new_func *asn1_ex_new;
628 ASN1_ex_free_func *asn1_ex_free;
629 ASN1_ex_free_func *asn1_ex_clear;
630 ASN1_ex_d2i *asn1_ex_d2i;
631 ASN1_ex_i2d *asn1_ex_i2d;
632} ASN1_EXTERN_FUNCS;
633
634typedef struct ASN1_PRIMITIVE_FUNCS_st {
635 void *app_data;
636 unsigned long flags;
637 ASN1_ex_new_func *prim_new;
638 ASN1_ex_free_func *prim_free;
639 ASN1_ex_free_func *prim_clear;
640 ASN1_primitive_c2i *prim_c2i;
641 ASN1_primitive_i2c *prim_i2c;
642} ASN1_PRIMITIVE_FUNCS;
643
644/* This is the ASN1_AUX structure: it handles various
645 * miscellaneous requirements. For example the use of
646 * reference counts and an informational callback.
647 *
648 * The "informational callback" is called at various
649 * points during the ASN1 encoding and decoding. It can
650 * be used to provide minor customisation of the structures
651 * used. This is most useful where the supplied routines
652 * *almost* do the right thing but need some extra help
653 * at a few points. If the callback returns zero then
654 * it is assumed a fatal error has occurred and the
655 * main operation should be abandoned.
656 *
657 * If major changes in the default behaviour are required
658 * then an external type is more appropriate.
659 */
660
661typedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it);
662
663typedef struct ASN1_AUX_st {
664 void *app_data;
665 int flags;
666 int ref_offset; /* Offset of reference value */
667 int ref_lock; /* Lock type to use */
668 ASN1_aux_cb *asn1_cb;
669 int enc_offset; /* Offset of ASN1_ENCODING structure */
670} ASN1_AUX;
671
672/* Flags in ASN1_AUX */
673
674/* Use a reference count */
675#define ASN1_AFLG_REFCOUNT 1
676/* Save the encoding of structure (useful for signatures) */
677#define ASN1_AFLG_ENCODING 2
678/* The Sequence length is invalid */
679#define ASN1_AFLG_BROKEN 4
680
681/* operation values for asn1_cb */
682
683#define ASN1_OP_NEW_PRE 0
684#define ASN1_OP_NEW_POST 1
685#define ASN1_OP_FREE_PRE 2
686#define ASN1_OP_FREE_POST 3
687#define ASN1_OP_D2I_PRE 4
688#define ASN1_OP_D2I_POST 5
689#define ASN1_OP_I2D_PRE 6
690#define ASN1_OP_I2D_POST 7
691
692/* Macro to implement a primitive type */
693#define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0)
694#define IMPLEMENT_ASN1_TYPE_ex(itname, vname, ex) \
695 ASN1_ITEM_start(itname) \
696 ASN1_ITYPE_PRIMITIVE, V_##vname, NULL, 0, NULL, ex, #itname \
697 ASN1_ITEM_end(itname)
698
699/* Macro to implement a multi string type */
700#define IMPLEMENT_ASN1_MSTRING(itname, mask) \
701 ASN1_ITEM_start(itname) \
702 ASN1_ITYPE_MSTRING, mask, NULL, 0, NULL, sizeof(ASN1_STRING), #itname \
703 ASN1_ITEM_end(itname)
704
705/* Macro to implement an ASN1_ITEM in terms of old style funcs */
706
707#define IMPLEMENT_COMPAT_ASN1(sname) IMPLEMENT_COMPAT_ASN1_type(sname, V_ASN1_SEQUENCE)
708
709#define IMPLEMENT_COMPAT_ASN1_type(sname, tag) \
710 static const ASN1_COMPAT_FUNCS sname##_ff = { \
711 (ASN1_new_func *)sname##_new, \
712 (ASN1_free_func *)sname##_free, \
713 (ASN1_d2i_func *)d2i_##sname, \
714 (ASN1_i2d_func *)i2d_##sname, \
715 }; \
716 ASN1_ITEM_start(sname) \
717 ASN1_ITYPE_COMPAT, \
718 tag, \
719 NULL, \
720 0, \
721 &sname##_ff, \
722 0, \
723 #sname \
724 ASN1_ITEM_end(sname)
725
726#define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \
727 ASN1_ITEM_start(sname) \
728 ASN1_ITYPE_EXTERN, \
729 tag, \
730 NULL, \
731 0, \
732 &fptrs, \
733 0, \
734 #sname \
735 ASN1_ITEM_end(sname)
736
737/* Macro to implement standard functions in terms of ASN1_ITEM structures */
738
739#define IMPLEMENT_ASN1_FUNCTIONS(stname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, stname, stname)
740
741#define IMPLEMENT_ASN1_FUNCTIONS_name(stname, itname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, itname)
742
743#define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \
744 IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname)
745
746#define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \
747 stname *fname##_new(void) \
748 { \
749 return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \
750 } \
751 void fname##_free(stname *a) \
752 { \
753 ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \
754 }
755
756#define IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, fname) \
757 IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \
758 IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname)
759
760#define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \
761 stname *d2i_##fname(stname **a, unsigned char **in, long len) \
762 { \
763 return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\
764 } \
765 int i2d_##fname(stname *a, unsigned char **out) \
766 { \
767 return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\
768 }
769
770/* This includes evil casts to remove const: they will go away when full
771 * ASN1 constification is done.
772 */
773#define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \
774 stname *d2i_##fname(stname **a, const unsigned char **in, long len) \
775 { \
776 return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, (unsigned char **)in, len, ASN1_ITEM_rptr(itname));\
777 } \
778 int i2d_##fname(const stname *a, unsigned char **out) \
779 { \
780 return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\
781 }
782
783#define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \
784 stname * stname##_dup(stname *x) \
785 { \
786 return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \
787 }
788
789#define IMPLEMENT_ASN1_FUNCTIONS_const(name) \
790 IMPLEMENT_ASN1_FUNCTIONS_const_fname(name, name, name)
791
792#define IMPLEMENT_ASN1_FUNCTIONS_const_fname(stname, itname, fname) \
793 IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \
794 IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname)
795
796/* external definitions for primitive types */
797
798DECLARE_ASN1_ITEM(ASN1_BOOLEAN)
799DECLARE_ASN1_ITEM(ASN1_TBOOLEAN)
800DECLARE_ASN1_ITEM(ASN1_FBOOLEAN)
801DECLARE_ASN1_ITEM(ASN1_ANY)
802DECLARE_ASN1_ITEM(ASN1_SEQUENCE)
803DECLARE_ASN1_ITEM(CBIGNUM)
804DECLARE_ASN1_ITEM(BIGNUM)
805DECLARE_ASN1_ITEM(LONG)
806DECLARE_ASN1_ITEM(ZLONG)
807
808DECLARE_STACK_OF(ASN1_VALUE)
809
810/* Functions used internally by the ASN1 code */
811
812int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it);
813void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
814int ASN1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);
815int ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it);
816
817void ASN1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);
818int ASN1_template_d2i(ASN1_VALUE **pval, unsigned char **in, long len, const ASN1_TEMPLATE *tt);
819int ASN1_item_ex_d2i(ASN1_VALUE **pval, unsigned char **in, long len, const ASN1_ITEM *it,
820 int tag, int aclass, char opt, ASN1_TLC *ctx);
821
822int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass);
823int ASN1_template_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_TEMPLATE *tt);
824void ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
825
826int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it);
827int asn1_ex_c2i(ASN1_VALUE **pval, unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it);
828
829int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it);
830int asn1_set_choice_selector(ASN1_VALUE **pval, int value, const ASN1_ITEM *it);
831
832ASN1_VALUE ** asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);
833
834const ASN1_TEMPLATE *asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt, int nullerr);
835
836int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it);
837
838void asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it);
839void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
840int asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval, const ASN1_ITEM *it);
841int asn1_enc_save(ASN1_VALUE **pval, unsigned char *in, int inlen, const ASN1_ITEM *it);
842
843#ifdef __cplusplus
844}
845#endif
846#endif
diff --git a/src/lib/libcrypto/asn1/asn_moid.c b/src/lib/libcrypto/asn1/asn_moid.c
new file mode 100644
index 0000000000..be20db4bad
--- /dev/null
+++ b/src/lib/libcrypto/asn1/asn_moid.c
@@ -0,0 +1,95 @@
1/* asn_moid.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 <stdio.h>
60#include <openssl/crypto.h>
61#include "cryptlib.h"
62#include <openssl/conf.h>
63#include <openssl/dso.h>
64#include <openssl/x509.h>
65
66/* Simple ASN1 OID module: add all objects in a given section */
67
68static int oid_module_init(CONF_IMODULE *md, const CONF *cnf)
69 {
70 int i;
71 const char *oid_section;
72 STACK_OF(CONF_VALUE) *sktmp;
73 CONF_VALUE *oval;
74 oid_section = CONF_imodule_get_value(md);
75 if(!(sktmp = NCONF_get_section(cnf, oid_section)))
76 {
77 ASN1err(ASN1_F_OID_MODULE_INIT, ASN1_R_ERROR_LOADING_SECTION);
78 return 0;
79 }
80 for(i = 0; i < sk_CONF_VALUE_num(sktmp); i++)
81 {
82 oval = sk_CONF_VALUE_value(sktmp, i);
83 if(OBJ_create(oval->value, oval->name, oval->name) == NID_undef)
84 {
85 ASN1err(ASN1_F_OID_MODULE_INIT, ASN1_R_ADDING_OBJECT);
86 return 0;
87 }
88 }
89 return 1;
90}
91
92void ASN1_add_oid_module(void)
93 {
94 CONF_module_add("oid_section", oid_module_init, 0);
95 }
diff --git a/src/lib/libcrypto/asn1/asn_pack.c b/src/lib/libcrypto/asn1/asn_pack.c
index bdf5f130b3..e6051db2dc 100644
--- a/src/lib/libcrypto/asn1/asn_pack.c
+++ b/src/lib/libcrypto/asn1/asn_pack.c
@@ -60,6 +60,8 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/asn1.h> 61#include <openssl/asn1.h>
62 62
63#ifndef NO_ASN1_OLD
64
63/* ASN1 packing and unpacking functions */ 65/* ASN1 packing and unpacking functions */
64 66
65/* Turn an ASN1 encoded SEQUENCE OF into a STACK of structures */ 67/* Turn an ASN1 encoded SEQUENCE OF into a STACK of structures */
@@ -117,7 +119,7 @@ void *ASN1_unpack_string (ASN1_STRING *oct, char *(*d2i)())
117 119
118/* Pack an ASN1 object into an ASN1_STRING */ 120/* Pack an ASN1 object into an ASN1_STRING */
119 121
120ASN1_STRING *ASN1_pack_string (void *obj, int (*i2d)(), ASN1_STRING **oct) 122ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_STRING **oct)
121{ 123{
122 unsigned char *p; 124 unsigned char *p;
123 ASN1_STRING *octmp; 125 ASN1_STRING *octmp;
@@ -143,3 +145,47 @@ ASN1_STRING *ASN1_pack_string (void *obj, int (*i2d)(), ASN1_STRING **oct)
143 return octmp; 145 return octmp;
144} 146}
145 147
148#endif
149
150/* ASN1_ITEM versions of the above */
151
152ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_STRING **oct)
153{
154 ASN1_STRING *octmp;
155
156 if (!oct || !*oct) {
157 if (!(octmp = ASN1_STRING_new ())) {
158 ASN1err(ASN1_F_ASN1_PACK_STRING,ERR_R_MALLOC_FAILURE);
159 return NULL;
160 }
161 if (oct) *oct = octmp;
162 } else octmp = *oct;
163
164 if(octmp->data) {
165 OPENSSL_free(octmp->data);
166 octmp->data = NULL;
167 }
168
169 if (!(octmp->length = ASN1_item_i2d(obj, &octmp->data, it))) {
170 ASN1err(ASN1_F_ASN1_PACK_STRING,ASN1_R_ENCODE_ERROR);
171 return NULL;
172 }
173 if (!octmp->data) {
174 ASN1err(ASN1_F_ASN1_PACK_STRING,ERR_R_MALLOC_FAILURE);
175 return NULL;
176 }
177 return octmp;
178}
179
180/* Extract an ASN1 object from an ASN1_STRING */
181
182void *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it)
183{
184 unsigned char *p;
185 void *ret;
186
187 p = oct->data;
188 if(!(ret = ASN1_item_d2i(NULL, &p, oct->length, it)))
189 ASN1err(ASN1_F_ASN1_UNPACK_STRING,ASN1_R_DECODE_ERROR);
190 return ret;
191}
diff --git a/src/lib/libcrypto/asn1/d2i_pr.c b/src/lib/libcrypto/asn1/d2i_pr.c
index c92b8325d8..2e7d96af90 100644
--- a/src/lib/libcrypto/asn1/d2i_pr.c
+++ b/src/lib/libcrypto/asn1/d2i_pr.c
@@ -62,6 +62,12 @@
62#include <openssl/evp.h> 62#include <openssl/evp.h>
63#include <openssl/objects.h> 63#include <openssl/objects.h>
64#include <openssl/asn1.h> 64#include <openssl/asn1.h>
65#ifndef OPENSSL_NO_RSA
66#include <openssl/rsa.h>
67#endif
68#ifndef OPENSSL_NO_DSA
69#include <openssl/dsa.h>
70#endif
65 71
66EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, unsigned char **pp, 72EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, unsigned char **pp,
67 long length) 73 long length)
@@ -82,18 +88,20 @@ EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, unsigned char **pp,
82 ret->type=EVP_PKEY_type(type); 88 ret->type=EVP_PKEY_type(type);
83 switch (ret->type) 89 switch (ret->type)
84 { 90 {
85#ifndef NO_RSA 91#ifndef OPENSSL_NO_RSA
86 case EVP_PKEY_RSA: 92 case EVP_PKEY_RSA:
87 if ((ret->pkey.rsa=d2i_RSAPrivateKey(NULL,pp,length)) == NULL) 93 if ((ret->pkey.rsa=d2i_RSAPrivateKey(NULL,
94 (const unsigned char **)pp,length)) == NULL) /* TMP UGLY CAST */
88 { 95 {
89 ASN1err(ASN1_F_D2I_PRIVATEKEY,ERR_R_ASN1_LIB); 96 ASN1err(ASN1_F_D2I_PRIVATEKEY,ERR_R_ASN1_LIB);
90 goto err; 97 goto err;
91 } 98 }
92 break; 99 break;
93#endif 100#endif
94#ifndef NO_DSA 101#ifndef OPENSSL_NO_DSA
95 case EVP_PKEY_DSA: 102 case EVP_PKEY_DSA:
96 if ((ret->pkey.dsa=d2i_DSAPrivateKey(NULL,pp,length)) == NULL) 103 if ((ret->pkey.dsa=d2i_DSAPrivateKey(NULL,
104 (const unsigned char **)pp,length)) == NULL) /* TMP UGLY CAST */
97 { 105 {
98 ASN1err(ASN1_F_D2I_PRIVATEKEY,ERR_R_ASN1_LIB); 106 ASN1err(ASN1_F_D2I_PRIVATEKEY,ERR_R_ASN1_LIB);
99 goto err; 107 goto err;
diff --git a/src/lib/libcrypto/asn1/d2i_pu.c b/src/lib/libcrypto/asn1/d2i_pu.c
index e0d203cef7..71f2eb361b 100644
--- a/src/lib/libcrypto/asn1/d2i_pu.c
+++ b/src/lib/libcrypto/asn1/d2i_pu.c
@@ -62,6 +62,12 @@
62#include <openssl/evp.h> 62#include <openssl/evp.h>
63#include <openssl/objects.h> 63#include <openssl/objects.h>
64#include <openssl/asn1.h> 64#include <openssl/asn1.h>
65#ifndef OPENSSL_NO_RSA
66#include <openssl/rsa.h>
67#endif
68#ifndef OPENSSL_NO_DSA
69#include <openssl/dsa.h>
70#endif
65 71
66EVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, unsigned char **pp, 72EVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, unsigned char **pp,
67 long length) 73 long length)
@@ -82,18 +88,20 @@ EVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, unsigned char **pp,
82 ret->type=EVP_PKEY_type(type); 88 ret->type=EVP_PKEY_type(type);
83 switch (ret->type) 89 switch (ret->type)
84 { 90 {
85#ifndef NO_RSA 91#ifndef OPENSSL_NO_RSA
86 case EVP_PKEY_RSA: 92 case EVP_PKEY_RSA:
87 if ((ret->pkey.rsa=d2i_RSAPublicKey(NULL,pp,length)) == NULL) 93 if ((ret->pkey.rsa=d2i_RSAPublicKey(NULL,
94 (const unsigned char **)pp,length)) == NULL) /* TMP UGLY CAST */
88 { 95 {
89 ASN1err(ASN1_F_D2I_PUBLICKEY,ERR_R_ASN1_LIB); 96 ASN1err(ASN1_F_D2I_PUBLICKEY,ERR_R_ASN1_LIB);
90 goto err; 97 goto err;
91 } 98 }
92 break; 99 break;
93#endif 100#endif
94#ifndef NO_DSA 101#ifndef OPENSSL_NO_DSA
95 case EVP_PKEY_DSA: 102 case EVP_PKEY_DSA:
96 if ((ret->pkey.dsa=d2i_DSAPublicKey(NULL,pp,length)) == NULL) 103 if ((ret->pkey.dsa=d2i_DSAPublicKey(NULL,
104 (const unsigned char **)pp,length)) == NULL) /* TMP UGLY CAST */
97 { 105 {
98 ASN1err(ASN1_F_D2I_PUBLICKEY,ERR_R_ASN1_LIB); 106 ASN1err(ASN1_F_D2I_PUBLICKEY,ERR_R_ASN1_LIB);
99 goto err; 107 goto err;
diff --git a/src/lib/libcrypto/asn1/f_int.c b/src/lib/libcrypto/asn1/f_int.c
index 6b090f6740..48cc3bfb90 100644
--- a/src/lib/libcrypto/asn1/f_int.c
+++ b/src/lib/libcrypto/asn1/f_int.c
@@ -69,10 +69,16 @@ int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a)
69 69
70 if (a == NULL) return(0); 70 if (a == NULL) return(0);
71 71
72 if (a->type & V_ASN1_NEG)
73 {
74 if (BIO_write(bp, "-", 1) != 1) goto err;
75 n = 1;
76 }
77
72 if (a->length == 0) 78 if (a->length == 0)
73 { 79 {
74 if (BIO_write(bp,"00",2) != 2) goto err; 80 if (BIO_write(bp,"00",2) != 2) goto err;
75 n=2; 81 n += 2;
76 } 82 }
77 else 83 else
78 { 84 {
diff --git a/src/lib/libcrypto/asn1/i2d_pr.c b/src/lib/libcrypto/asn1/i2d_pr.c
index 71d6910204..1e951ae01d 100644
--- a/src/lib/libcrypto/asn1/i2d_pr.c
+++ b/src/lib/libcrypto/asn1/i2d_pr.c
@@ -61,17 +61,23 @@
61#include <openssl/bn.h> 61#include <openssl/bn.h>
62#include <openssl/evp.h> 62#include <openssl/evp.h>
63#include <openssl/objects.h> 63#include <openssl/objects.h>
64#ifndef OPENSSL_NO_RSA
65#include <openssl/rsa.h>
66#endif
67#ifndef OPENSSL_NO_DSA
68#include <openssl/dsa.h>
69#endif
64 70
65int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp) 71int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp)
66 { 72 {
67#ifndef NO_RSA 73#ifndef OPENSSL_NO_RSA
68 if (a->type == EVP_PKEY_RSA) 74 if (a->type == EVP_PKEY_RSA)
69 { 75 {
70 return(i2d_RSAPrivateKey(a->pkey.rsa,pp)); 76 return(i2d_RSAPrivateKey(a->pkey.rsa,pp));
71 } 77 }
72 else 78 else
73#endif 79#endif
74#ifndef NO_DSA 80#ifndef OPENSSL_NO_DSA
75 if (a->type == EVP_PKEY_DSA) 81 if (a->type == EVP_PKEY_DSA)
76 { 82 {
77 return(i2d_DSAPrivateKey(a->pkey.dsa,pp)); 83 return(i2d_DSAPrivateKey(a->pkey.dsa,pp));
diff --git a/src/lib/libcrypto/asn1/i2d_pu.c b/src/lib/libcrypto/asn1/i2d_pu.c
index 8f73d37d03..013d19bbf4 100644
--- a/src/lib/libcrypto/asn1/i2d_pu.c
+++ b/src/lib/libcrypto/asn1/i2d_pu.c
@@ -61,16 +61,22 @@
61#include <openssl/bn.h> 61#include <openssl/bn.h>
62#include <openssl/evp.h> 62#include <openssl/evp.h>
63#include <openssl/objects.h> 63#include <openssl/objects.h>
64#ifndef OPENSSL_NO_RSA
65#include <openssl/rsa.h>
66#endif
67#ifndef OPENSSL_NO_DSA
68#include <openssl/dsa.h>
69#endif
64 70
65int i2d_PublicKey(EVP_PKEY *a, unsigned char **pp) 71int i2d_PublicKey(EVP_PKEY *a, unsigned char **pp)
66 { 72 {
67 switch (a->type) 73 switch (a->type)
68 { 74 {
69#ifndef NO_RSA 75#ifndef OPENSSL_NO_RSA
70 case EVP_PKEY_RSA: 76 case EVP_PKEY_RSA:
71 return(i2d_RSAPublicKey(a->pkey.rsa,pp)); 77 return(i2d_RSAPublicKey(a->pkey.rsa,pp));
72#endif 78#endif
73#ifndef NO_DSA 79#ifndef OPENSSL_NO_DSA
74 case EVP_PKEY_DSA: 80 case EVP_PKEY_DSA:
75 return(i2d_DSAPublicKey(a->pkey.dsa,pp)); 81 return(i2d_DSAPublicKey(a->pkey.dsa,pp));
76#endif 82#endif
diff --git a/src/lib/libcrypto/asn1/n_pkey.c b/src/lib/libcrypto/asn1/n_pkey.c
index 9840193538..49f80fffd2 100644
--- a/src/lib/libcrypto/asn1/n_pkey.c
+++ b/src/lib/libcrypto/asn1/n_pkey.c
@@ -56,110 +56,134 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_RSA 59#ifndef OPENSSL_NO_RSA
60#include <stdio.h> 60#include <stdio.h>
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/rsa.h> 62#include <openssl/rsa.h>
63#include <openssl/objects.h> 63#include <openssl/objects.h>
64#include <openssl/asn1t.h>
64#include <openssl/asn1_mac.h> 65#include <openssl/asn1_mac.h>
65#include <openssl/evp.h> 66#include <openssl/evp.h>
66#include <openssl/x509.h> 67#include <openssl/x509.h>
67 68
68 69
69#ifndef NO_RC4 70#ifndef OPENSSL_NO_RC4
70 71
71typedef struct netscape_pkey_st 72typedef struct netscape_pkey_st
72 { 73 {
73 ASN1_INTEGER *version; 74 long version;
74 X509_ALGOR *algor; 75 X509_ALGOR *algor;
75 ASN1_OCTET_STRING *private_key; 76 ASN1_OCTET_STRING *private_key;
76 } NETSCAPE_PKEY; 77 } NETSCAPE_PKEY;
77 78
78static int i2d_NETSCAPE_PKEY(NETSCAPE_PKEY *a, unsigned char **pp); 79typedef struct netscape_encrypted_pkey_st
79static NETSCAPE_PKEY *d2i_NETSCAPE_PKEY(NETSCAPE_PKEY **a,unsigned char **pp, long length); 80 {
80static NETSCAPE_PKEY *NETSCAPE_PKEY_new(void); 81 ASN1_OCTET_STRING *os;
81static void NETSCAPE_PKEY_free(NETSCAPE_PKEY *); 82 /* This is the same structure as DigestInfo so use it:
83 * although this isn't really anything to do with
84 * digests.
85 */
86 X509_SIG *enckey;
87 } NETSCAPE_ENCRYPTED_PKEY;
88
89
90ASN1_BROKEN_SEQUENCE(NETSCAPE_ENCRYPTED_PKEY) = {
91 ASN1_SIMPLE(NETSCAPE_ENCRYPTED_PKEY, os, ASN1_OCTET_STRING),
92 ASN1_SIMPLE(NETSCAPE_ENCRYPTED_PKEY, enckey, X509_SIG)
93} ASN1_BROKEN_SEQUENCE_END(NETSCAPE_ENCRYPTED_PKEY)
94
95IMPLEMENT_ASN1_FUNCTIONS_const(NETSCAPE_ENCRYPTED_PKEY)
82 96
83int i2d_Netscape_RSA(RSA *a, unsigned char **pp, int (*cb)()) 97ASN1_SEQUENCE(NETSCAPE_PKEY) = {
98 ASN1_SIMPLE(NETSCAPE_PKEY, version, LONG),
99 ASN1_SIMPLE(NETSCAPE_PKEY, algor, X509_ALGOR),
100 ASN1_SIMPLE(NETSCAPE_PKEY, private_key, ASN1_OCTET_STRING)
101} ASN1_SEQUENCE_END(NETSCAPE_PKEY)
102
103IMPLEMENT_ASN1_FUNCTIONS_const(NETSCAPE_PKEY)
104
105static RSA *d2i_RSA_NET_2(RSA **a, ASN1_OCTET_STRING *os,
106 int (*cb)(), int sgckey);
107
108int i2d_Netscape_RSA(const RSA *a, unsigned char **pp, int (*cb)())
84{ 109{
85 return i2d_RSA_NET(a, pp, cb, 0); 110 return i2d_RSA_NET(a, pp, cb, 0);
86} 111}
87 112
88int i2d_RSA_NET(RSA *a, unsigned char **pp, int (*cb)(), int sgckey) 113int i2d_RSA_NET(const RSA *a, unsigned char **pp, int (*cb)(), int sgckey)
89 { 114 {
90 int i,j,l[6]; 115 int i, j, ret = 0;
91 NETSCAPE_PKEY *pkey; 116 int rsalen, pkeylen, olen;
117 NETSCAPE_PKEY *pkey = NULL;
118 NETSCAPE_ENCRYPTED_PKEY *enckey = NULL;
92 unsigned char buf[256],*zz; 119 unsigned char buf[256],*zz;
93 unsigned char key[EVP_MAX_KEY_LENGTH]; 120 unsigned char key[EVP_MAX_KEY_LENGTH];
94 EVP_CIPHER_CTX ctx; 121 EVP_CIPHER_CTX ctx;
95 X509_ALGOR *alg=NULL;
96 ASN1_OCTET_STRING os,os2;
97 M_ASN1_I2D_vars(a);
98 122
99 if (a == NULL) return(0); 123 if (a == NULL) return(0);
100 124
101#ifdef WIN32
102 r=r; /* shut the damn compiler up :-) */
103#endif
104
105 os.data=os2.data=NULL;
106 if ((pkey=NETSCAPE_PKEY_new()) == NULL) goto err; 125 if ((pkey=NETSCAPE_PKEY_new()) == NULL) goto err;
107 if (!ASN1_INTEGER_set(pkey->version,0)) goto err; 126 if ((enckey=NETSCAPE_ENCRYPTED_PKEY_new()) == NULL) goto err;
127 pkey->version = 0;
108 128
109 if (pkey->algor->algorithm != NULL)
110 ASN1_OBJECT_free(pkey->algor->algorithm);
111 pkey->algor->algorithm=OBJ_nid2obj(NID_rsaEncryption); 129 pkey->algor->algorithm=OBJ_nid2obj(NID_rsaEncryption);
112 if ((pkey->algor->parameter=ASN1_TYPE_new()) == NULL) goto err; 130 if ((pkey->algor->parameter=ASN1_TYPE_new()) == NULL) goto err;
113 pkey->algor->parameter->type=V_ASN1_NULL; 131 pkey->algor->parameter->type=V_ASN1_NULL;
114 132
115 l[0]=i2d_RSAPrivateKey(a,NULL); 133 rsalen = i2d_RSAPrivateKey(a, NULL);
116 pkey->private_key->length=l[0];
117 134
118 os2.length=i2d_NETSCAPE_PKEY(pkey,NULL); 135 /* Fake some octet strings just for the initial length
119 l[1]=i2d_ASN1_OCTET_STRING(&os2,NULL); 136 * calculation.
137 */
120 138
121 if ((alg=X509_ALGOR_new()) == NULL) goto err; 139 pkey->private_key->length=rsalen;
122 if (alg->algorithm != NULL)
123 ASN1_OBJECT_free(alg->algorithm);
124 alg->algorithm=OBJ_nid2obj(NID_rc4);
125 if ((alg->parameter=ASN1_TYPE_new()) == NULL) goto err;
126 alg->parameter->type=V_ASN1_NULL;
127 140
128 l[2]=i2d_X509_ALGOR(alg,NULL); 141 pkeylen=i2d_NETSCAPE_PKEY(pkey,NULL);
129 l[3]=ASN1_object_size(1,l[2]+l[1],V_ASN1_SEQUENCE);
130 142
131#ifndef CONST_STRICT 143 enckey->enckey->digest->length = pkeylen;
132 os.data=(unsigned char *)"private-key";
133#endif
134 os.length=11;
135 l[4]=i2d_ASN1_OCTET_STRING(&os,NULL);
136 144
137 l[5]=ASN1_object_size(1,l[4]+l[3],V_ASN1_SEQUENCE); 145 enckey->os->length = 11; /* "private-key" */
146
147 enckey->enckey->algor->algorithm=OBJ_nid2obj(NID_rc4);
148 if ((enckey->enckey->algor->parameter=ASN1_TYPE_new()) == NULL) goto err;
149 enckey->enckey->algor->parameter->type=V_ASN1_NULL;
138 150
139 if (pp == NULL) 151 if (pp == NULL)
140 { 152 {
141 if (pkey != NULL) NETSCAPE_PKEY_free(pkey); 153 olen = i2d_NETSCAPE_ENCRYPTED_PKEY(enckey, NULL);
142 if (alg != NULL) X509_ALGOR_free(alg); 154 NETSCAPE_PKEY_free(pkey);
143 return(l[5]); 155 NETSCAPE_ENCRYPTED_PKEY_free(enckey);
156 return olen;
144 } 157 }
145 158
146 if (pkey->private_key->data != NULL) 159
147 OPENSSL_free(pkey->private_key->data); 160 /* Since its RC4 encrypted length is actual length */
148 if ((pkey->private_key->data=(unsigned char *)OPENSSL_malloc(l[0])) == NULL) 161 if ((zz=(unsigned char *)OPENSSL_malloc(rsalen)) == NULL)
149 { 162 {
150 ASN1err(ASN1_F_I2D_NETSCAPE_RSA,ERR_R_MALLOC_FAILURE); 163 ASN1err(ASN1_F_I2D_NETSCAPE_RSA,ERR_R_MALLOC_FAILURE);
151 goto err; 164 goto err;
152 } 165 }
153 zz=pkey->private_key->data; 166
167 pkey->private_key->data = zz;
168 /* Write out private key encoding */
154 i2d_RSAPrivateKey(a,&zz); 169 i2d_RSAPrivateKey(a,&zz);
155 170
156 if ((os2.data=(unsigned char *)OPENSSL_malloc(os2.length)) == NULL) 171 if ((zz=OPENSSL_malloc(pkeylen)) == NULL)
157 { 172 {
158 ASN1err(ASN1_F_I2D_NETSCAPE_RSA,ERR_R_MALLOC_FAILURE); 173 ASN1err(ASN1_F_I2D_NETSCAPE_RSA,ERR_R_MALLOC_FAILURE);
159 goto err; 174 goto err;
160 } 175 }
161 zz=os2.data; 176
177 if (!ASN1_STRING_set(enckey->os, "private-key", -1))
178 {
179 ASN1err(ASN1_F_I2D_NETSCAPE_RSA,ERR_R_MALLOC_FAILURE);
180 goto err;
181 }
182 enckey->enckey->digest->data = zz;
162 i2d_NETSCAPE_PKEY(pkey,&zz); 183 i2d_NETSCAPE_PKEY(pkey,&zz);
184
185 /* Wipe the private key encoding */
186 memset(pkey->private_key->data, 0, rsalen);
163 187
164 if (cb == NULL) 188 if (cb == NULL)
165 cb=EVP_read_pw_string; 189 cb=EVP_read_pw_string;
@@ -171,109 +195,86 @@ int i2d_RSA_NET(RSA *a, unsigned char **pp, int (*cb)(), int sgckey)
171 } 195 }
172 i = strlen((char *)buf); 196 i = strlen((char *)buf);
173 /* If the key is used for SGC the algorithm is modified a little. */ 197 /* If the key is used for SGC the algorithm is modified a little. */
174 if(sgckey){ 198 if(sgckey) {
175 EVP_MD_CTX mctx; 199 EVP_Digest(buf, i, buf, NULL, EVP_md5(), NULL);
176 EVP_DigestInit(&mctx, EVP_md5());
177 EVP_DigestUpdate(&mctx, buf, i);
178 EVP_DigestFinal(&mctx, buf, NULL);
179 memcpy(buf + 16, "SGCKEYSALT", 10); 200 memcpy(buf + 16, "SGCKEYSALT", 10);
180 i = 26; 201 i = 26;
181 } 202 }
182 203
183 EVP_BytesToKey(EVP_rc4(),EVP_md5(),NULL,buf,i,1,key,NULL); 204 EVP_BytesToKey(EVP_rc4(),EVP_md5(),NULL,buf,i,1,key,NULL);
184 memset(buf,0,256); 205 memset(buf,0,256);
185 206
207 /* Encrypt private key in place */
208 zz = enckey->enckey->digest->data;
186 EVP_CIPHER_CTX_init(&ctx); 209 EVP_CIPHER_CTX_init(&ctx);
187 EVP_EncryptInit(&ctx,EVP_rc4(),key,NULL); 210 EVP_EncryptInit_ex(&ctx,EVP_rc4(),NULL,key,NULL);
188 EVP_EncryptUpdate(&ctx,os2.data,&i,os2.data,os2.length); 211 EVP_EncryptUpdate(&ctx,zz,&i,zz,pkeylen);
189 EVP_EncryptFinal(&ctx,&(os2.data[i]),&j); 212 EVP_EncryptFinal_ex(&ctx,zz + i,&j);
190 EVP_CIPHER_CTX_cleanup(&ctx); 213 EVP_CIPHER_CTX_cleanup(&ctx);
191 214
192 p= *pp; 215 ret = i2d_NETSCAPE_ENCRYPTED_PKEY(enckey, pp);
193 ASN1_put_object(&p,1,l[4]+l[3],V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);
194 i2d_ASN1_OCTET_STRING(&os,&p);
195 ASN1_put_object(&p,1,l[2]+l[1],V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);
196 i2d_X509_ALGOR(alg,&p);
197 i2d_ASN1_OCTET_STRING(&os2,&p);
198 ret=l[5];
199err: 216err:
200 if (os2.data != NULL) OPENSSL_free(os2.data); 217 NETSCAPE_ENCRYPTED_PKEY_free(enckey);
201 if (alg != NULL) X509_ALGOR_free(alg); 218 NETSCAPE_PKEY_free(pkey);
202 if (pkey != NULL) NETSCAPE_PKEY_free(pkey);
203 r=r;
204 return(ret); 219 return(ret);
205 } 220 }
206 221
207 222
208RSA *d2i_Netscape_RSA(RSA **a, unsigned char **pp, long length, int (*cb)()) 223RSA *d2i_Netscape_RSA(RSA **a, const unsigned char **pp, long length, int (*cb)())
209{ 224{
210 return d2i_RSA_NET(a, pp, length, cb, 0); 225 return d2i_RSA_NET(a, pp, length, cb, 0);
211} 226}
212 227
213RSA *d2i_RSA_NET(RSA **a, unsigned char **pp, long length, int (*cb)(), int sgckey) 228RSA *d2i_RSA_NET(RSA **a, const unsigned char **pp, long length, int (*cb)(), int sgckey)
214 { 229 {
215 RSA *ret=NULL; 230 RSA *ret=NULL;
216 ASN1_OCTET_STRING *os=NULL; 231 const unsigned char *p, *kp;
217 ASN1_CTX c; 232 NETSCAPE_ENCRYPTED_PKEY *enckey = NULL;
233
234 p = *pp;
218 235
219 c.pp=pp; 236 enckey = d2i_NETSCAPE_ENCRYPTED_PKEY(NULL, &p, length);
220 c.error=ASN1_R_DECODING_ERROR; 237 if(!enckey) {
238 ASN1err(ASN1_F_D2I_NETSCAPE_RSA,ASN1_R_DECODING_ERROR);
239 return NULL;
240 }
221 241
222 M_ASN1_D2I_Init(); 242 if ((enckey->os->length != 11) || (strncmp("private-key",
223 M_ASN1_D2I_start_sequence(); 243 (char *)enckey->os->data,11) != 0))
224 M_ASN1_D2I_get(os,d2i_ASN1_OCTET_STRING);
225 if ((os->length != 11) || (strncmp("private-key",
226 (char *)os->data,os->length) != 0))
227 { 244 {
228 ASN1err(ASN1_F_D2I_NETSCAPE_RSA,ASN1_R_PRIVATE_KEY_HEADER_MISSING); 245 ASN1err(ASN1_F_D2I_NETSCAPE_RSA,ASN1_R_PRIVATE_KEY_HEADER_MISSING);
229 M_ASN1_BIT_STRING_free(os); 246 NETSCAPE_ENCRYPTED_PKEY_free(enckey);
230 goto err; 247 return NULL;
231 } 248 }
232 M_ASN1_BIT_STRING_free(os); 249 if (OBJ_obj2nid(enckey->enckey->algor->algorithm) != NID_rc4)
233 c.q=c.p; 250 {
234 if ((ret=d2i_RSA_NET_2(a,&c.p,c.slen,cb, sgckey)) == NULL) goto err; 251 ASN1err(ASN1_F_D2I_NETSCAPE_RSA_2,ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM);
235 /* Note: some versions of IIS key files use length values that are 252 goto err;
236 * too small for the surrounding SEQUENCEs. This following line
237 * effectively disable length checking.
238 */
239 c.slen = 0;
240
241 M_ASN1_D2I_Finish(a,RSA_free,ASN1_F_D2I_NETSCAPE_RSA);
242 } 253 }
254 kp = enckey->enckey->digest->data;
255 if (cb == NULL)
256 cb=EVP_read_pw_string;
257 if ((ret=d2i_RSA_NET_2(a, enckey->enckey->digest,cb, sgckey)) == NULL) goto err;
243 258
244RSA *d2i_Netscape_RSA_2(RSA **a, unsigned char **pp, long length, 259 *pp = p;
245 int (*cb)())
246{
247 return d2i_RSA_NET_2(a, pp, length, cb, 0);
248}
249 260
250RSA *d2i_RSA_NET_2(RSA **a, unsigned char **pp, long length, 261 err:
262 NETSCAPE_ENCRYPTED_PKEY_free(enckey);
263 return ret;
264
265 }
266
267static RSA *d2i_RSA_NET_2(RSA **a, ASN1_OCTET_STRING *os,
251 int (*cb)(), int sgckey) 268 int (*cb)(), int sgckey)
252 { 269 {
253 NETSCAPE_PKEY *pkey=NULL; 270 NETSCAPE_PKEY *pkey=NULL;
254 RSA *ret=NULL; 271 RSA *ret=NULL;
255 int i,j; 272 int i,j;
256 unsigned char buf[256],*zz; 273 unsigned char buf[256];
274 const unsigned char *zz;
257 unsigned char key[EVP_MAX_KEY_LENGTH]; 275 unsigned char key[EVP_MAX_KEY_LENGTH];
258 EVP_CIPHER_CTX ctx; 276 EVP_CIPHER_CTX ctx;
259 X509_ALGOR *alg=NULL;
260 ASN1_OCTET_STRING *os=NULL;
261 ASN1_CTX c;
262 277
263 c.error=ERR_R_NESTED_ASN1_ERROR;
264 c.pp=pp;
265
266 M_ASN1_D2I_Init();
267 M_ASN1_D2I_start_sequence();
268 M_ASN1_D2I_get(alg,d2i_X509_ALGOR);
269 if (OBJ_obj2nid(alg->algorithm) != NID_rc4)
270 {
271 ASN1err(ASN1_F_D2I_NETSCAPE_RSA_2,ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM);
272 goto err;
273 }
274 M_ASN1_D2I_get(os,d2i_ASN1_OCTET_STRING);
275 if (cb == NULL)
276 cb=EVP_read_pw_string;
277 i=cb(buf,256,"Enter Private Key password:",0); 278 i=cb(buf,256,"Enter Private Key password:",0);
278 if (i != 0) 279 if (i != 0)
279 { 280 {
@@ -283,10 +284,7 @@ RSA *d2i_RSA_NET_2(RSA **a, unsigned char **pp, long length,
283 284
284 i = strlen((char *)buf); 285 i = strlen((char *)buf);
285 if(sgckey){ 286 if(sgckey){
286 EVP_MD_CTX mctx; 287 EVP_Digest(buf, i, buf, NULL, EVP_md5(), NULL);
287 EVP_DigestInit(&mctx, EVP_md5());
288 EVP_DigestUpdate(&mctx, buf, i);
289 EVP_DigestFinal(&mctx, buf, NULL);
290 memcpy(buf + 16, "SGCKEYSALT", 10); 288 memcpy(buf + 16, "SGCKEYSALT", 10);
291 i = 26; 289 i = 26;
292 } 290 }
@@ -295,9 +293,9 @@ RSA *d2i_RSA_NET_2(RSA **a, unsigned char **pp, long length,
295 memset(buf,0,256); 293 memset(buf,0,256);
296 294
297 EVP_CIPHER_CTX_init(&ctx); 295 EVP_CIPHER_CTX_init(&ctx);
298 EVP_DecryptInit(&ctx,EVP_rc4(),key,NULL); 296 EVP_DecryptInit_ex(&ctx,EVP_rc4(),NULL, key,NULL);
299 EVP_DecryptUpdate(&ctx,os->data,&i,os->data,os->length); 297 EVP_DecryptUpdate(&ctx,os->data,&i,os->data,os->length);
300 EVP_DecryptFinal(&ctx,&(os->data[i]),&j); 298 EVP_DecryptFinal_ex(&ctx,&(os->data[i]),&j);
301 EVP_CIPHER_CTX_cleanup(&ctx); 299 EVP_CIPHER_CTX_cleanup(&ctx);
302 os->length=i+j; 300 os->length=i+j;
303 301
@@ -315,71 +313,14 @@ RSA *d2i_RSA_NET_2(RSA **a, unsigned char **pp, long length,
315 ASN1err(ASN1_F_D2I_NETSCAPE_RSA_2,ASN1_R_UNABLE_TO_DECODE_RSA_KEY); 313 ASN1err(ASN1_F_D2I_NETSCAPE_RSA_2,ASN1_R_UNABLE_TO_DECODE_RSA_KEY);
316 goto err; 314 goto err;
317 } 315 }
318 if (!asn1_Finish(&c)) goto err;
319 *pp=c.p;
320err: 316err:
321 if (pkey != NULL) NETSCAPE_PKEY_free(pkey); 317 NETSCAPE_PKEY_free(pkey);
322 if (os != NULL) M_ASN1_BIT_STRING_free(os);
323 if (alg != NULL) X509_ALGOR_free(alg);
324 return(ret); 318 return(ret);
325 } 319 }
326 320
327static int i2d_NETSCAPE_PKEY(NETSCAPE_PKEY *a, unsigned char **pp) 321#endif /* OPENSSL_NO_RC4 */
328 {
329 M_ASN1_I2D_vars(a);
330
331
332 M_ASN1_I2D_len(a->version, i2d_ASN1_INTEGER);
333 M_ASN1_I2D_len(a->algor, i2d_X509_ALGOR);
334 M_ASN1_I2D_len(a->private_key, i2d_ASN1_OCTET_STRING);
335
336 M_ASN1_I2D_seq_total();
337
338 M_ASN1_I2D_put(a->version, i2d_ASN1_INTEGER);
339 M_ASN1_I2D_put(a->algor, i2d_X509_ALGOR);
340 M_ASN1_I2D_put(a->private_key, i2d_ASN1_OCTET_STRING);
341
342 M_ASN1_I2D_finish();
343 }
344
345static NETSCAPE_PKEY *d2i_NETSCAPE_PKEY(NETSCAPE_PKEY **a, unsigned char **pp,
346 long length)
347 {
348 M_ASN1_D2I_vars(a,NETSCAPE_PKEY *,NETSCAPE_PKEY_new);
349
350 M_ASN1_D2I_Init();
351 M_ASN1_D2I_start_sequence();
352 M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER);
353 M_ASN1_D2I_get(ret->algor,d2i_X509_ALGOR);
354 M_ASN1_D2I_get(ret->private_key,d2i_ASN1_OCTET_STRING);
355 M_ASN1_D2I_Finish(a,NETSCAPE_PKEY_free,ASN1_F_D2I_NETSCAPE_PKEY);
356 }
357
358static NETSCAPE_PKEY *NETSCAPE_PKEY_new(void)
359 {
360 NETSCAPE_PKEY *ret=NULL;
361 ASN1_CTX c;
362
363 M_ASN1_New_Malloc(ret,NETSCAPE_PKEY);
364 M_ASN1_New(ret->version,M_ASN1_INTEGER_new);
365 M_ASN1_New(ret->algor,X509_ALGOR_new);
366 M_ASN1_New(ret->private_key,M_ASN1_OCTET_STRING_new);
367 return(ret);
368 M_ASN1_New_Error(ASN1_F_NETSCAPE_PKEY_NEW);
369 }
370
371static void NETSCAPE_PKEY_free(NETSCAPE_PKEY *a)
372 {
373 if (a == NULL) return;
374 M_ASN1_INTEGER_free(a->version);
375 X509_ALGOR_free(a->algor);
376 M_ASN1_OCTET_STRING_free(a->private_key);
377 OPENSSL_free(a);
378 }
379
380#endif /* NO_RC4 */
381 322
382#else /* !NO_RSA */ 323#else /* !OPENSSL_NO_RSA */
383 324
384# if PEDANTIC 325# if PEDANTIC
385static void *dummy=&dummy; 326static void *dummy=&dummy;
diff --git a/src/lib/libcrypto/asn1/nsseq.c b/src/lib/libcrypto/asn1/nsseq.c
index 6e7f09ba23..50e2d4d07a 100644
--- a/src/lib/libcrypto/asn1/nsseq.c
+++ b/src/lib/libcrypto/asn1/nsseq.c
@@ -58,61 +58,25 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <stdlib.h> 60#include <stdlib.h>
61#include <openssl/asn1_mac.h> 61#include <openssl/asn1t.h>
62#include <openssl/err.h>
63#include <openssl/x509.h> 62#include <openssl/x509.h>
64#include <openssl/objects.h> 63#include <openssl/objects.h>
65 64
66/* Netscape certificate sequence structure */ 65static int nsseq_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it)
67
68int i2d_NETSCAPE_CERT_SEQUENCE(NETSCAPE_CERT_SEQUENCE *a, unsigned char **pp)
69{ 66{
70 int v = 0; 67 if(operation == ASN1_OP_NEW_POST) {
71 M_ASN1_I2D_vars(a); 68 NETSCAPE_CERT_SEQUENCE *nsseq;
72 M_ASN1_I2D_len (a->type, i2d_ASN1_OBJECT); 69 nsseq = (NETSCAPE_CERT_SEQUENCE *)*pval;
73 M_ASN1_I2D_len_EXP_SEQUENCE_opt_type(X509,a->certs,i2d_X509,0, 70 nsseq->type = OBJ_nid2obj(NID_netscape_cert_sequence);
74 V_ASN1_SEQUENCE,v); 71 }
75 72 return 1;
76 M_ASN1_I2D_seq_total();
77
78 M_ASN1_I2D_put (a->type, i2d_ASN1_OBJECT);
79 M_ASN1_I2D_put_EXP_SEQUENCE_opt_type(X509,a->certs,i2d_X509,0,
80 V_ASN1_SEQUENCE,v);
81
82 M_ASN1_I2D_finish();
83} 73}
84 74
85NETSCAPE_CERT_SEQUENCE *NETSCAPE_CERT_SEQUENCE_new(void) 75/* Netscape certificate sequence structure */
86{
87 NETSCAPE_CERT_SEQUENCE *ret=NULL;
88 ASN1_CTX c;
89 M_ASN1_New_Malloc(ret, NETSCAPE_CERT_SEQUENCE);
90 /* Note hardcoded object type */
91 ret->type = OBJ_nid2obj(NID_netscape_cert_sequence);
92 ret->certs = NULL;
93 return (ret);
94 M_ASN1_New_Error(ASN1_F_NETSCAPE_CERT_SEQUENCE_NEW);
95}
96 76
97NETSCAPE_CERT_SEQUENCE *d2i_NETSCAPE_CERT_SEQUENCE(NETSCAPE_CERT_SEQUENCE **a, 77ASN1_SEQUENCE_cb(NETSCAPE_CERT_SEQUENCE, nsseq_cb) = {
98 unsigned char **pp, long length) 78 ASN1_SIMPLE(NETSCAPE_CERT_SEQUENCE, type, ASN1_OBJECT),
99{ 79 ASN1_EXP_SEQUENCE_OF_OPT(NETSCAPE_CERT_SEQUENCE, certs, X509, 0)
100 M_ASN1_D2I_vars(a,NETSCAPE_CERT_SEQUENCE *, 80} ASN1_SEQUENCE_END_cb(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE)
101 NETSCAPE_CERT_SEQUENCE_new);
102 M_ASN1_D2I_Init();
103 M_ASN1_D2I_start_sequence();
104 M_ASN1_D2I_get (ret->type, d2i_ASN1_OBJECT);
105 M_ASN1_D2I_get_EXP_set_opt_type(X509,ret->certs,d2i_X509,X509_free,0,
106 V_ASN1_SEQUENCE);
107 M_ASN1_D2I_Finish(a, NETSCAPE_CERT_SEQUENCE_free,
108 ASN1_F_D2I_NETSCAPE_CERT_SEQUENCE);
109}
110 81
111void NETSCAPE_CERT_SEQUENCE_free (NETSCAPE_CERT_SEQUENCE *a) 82IMPLEMENT_ASN1_FUNCTIONS(NETSCAPE_CERT_SEQUENCE)
112{
113 if (a == NULL) return;
114 ASN1_OBJECT_free(a->type);
115 if(a->certs)
116 sk_X509_pop_free(a->certs, X509_free);
117 OPENSSL_free (a);
118}
diff --git a/src/lib/libcrypto/asn1/p5_pbe.c b/src/lib/libcrypto/asn1/p5_pbe.c
index b7ed538eb2..891150638e 100644
--- a/src/lib/libcrypto/asn1/p5_pbe.c
+++ b/src/lib/libcrypto/asn1/p5_pbe.c
@@ -58,53 +58,18 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/asn1_mac.h> 61#include <openssl/asn1t.h>
62#include <openssl/x509.h> 62#include <openssl/x509.h>
63#include <openssl/rand.h> 63#include <openssl/rand.h>
64 64
65/* PKCS#5 password based encryption structure */ 65/* PKCS#5 password based encryption structure */
66 66
67int i2d_PBEPARAM(PBEPARAM *a, unsigned char **pp) 67ASN1_SEQUENCE(PBEPARAM) = {
68{ 68 ASN1_SIMPLE(PBEPARAM, salt, ASN1_OCTET_STRING),
69 M_ASN1_I2D_vars(a); 69 ASN1_SIMPLE(PBEPARAM, iter, ASN1_INTEGER)
70 M_ASN1_I2D_len (a->salt, i2d_ASN1_OCTET_STRING); 70} ASN1_SEQUENCE_END(PBEPARAM)
71 M_ASN1_I2D_len (a->iter, i2d_ASN1_INTEGER);
72
73 M_ASN1_I2D_seq_total ();
74
75 M_ASN1_I2D_put (a->salt, i2d_ASN1_OCTET_STRING);
76 M_ASN1_I2D_put (a->iter, i2d_ASN1_INTEGER);
77 M_ASN1_I2D_finish();
78}
79
80PBEPARAM *PBEPARAM_new(void)
81{
82 PBEPARAM *ret=NULL;
83 ASN1_CTX c;
84 M_ASN1_New_Malloc(ret, PBEPARAM);
85 M_ASN1_New(ret->iter,M_ASN1_INTEGER_new);
86 M_ASN1_New(ret->salt,M_ASN1_OCTET_STRING_new);
87 return (ret);
88 M_ASN1_New_Error(ASN1_F_PBEPARAM_NEW);
89}
90
91PBEPARAM *d2i_PBEPARAM(PBEPARAM **a, unsigned char **pp, long length)
92{
93 M_ASN1_D2I_vars(a,PBEPARAM *,PBEPARAM_new);
94 M_ASN1_D2I_Init();
95 M_ASN1_D2I_start_sequence();
96 M_ASN1_D2I_get (ret->salt, d2i_ASN1_OCTET_STRING);
97 M_ASN1_D2I_get (ret->iter, d2i_ASN1_INTEGER);
98 M_ASN1_D2I_Finish(a, PBEPARAM_free, ASN1_F_D2I_PBEPARAM);
99}
100 71
101void PBEPARAM_free (PBEPARAM *a) 72IMPLEMENT_ASN1_FUNCTIONS(PBEPARAM)
102{
103 if(a==NULL) return;
104 M_ASN1_OCTET_STRING_free(a->salt);
105 M_ASN1_INTEGER_free (a->iter);
106 OPENSSL_free (a);
107}
108 73
109/* Return an algorithm identifier for a PKCS#5 PBE algorithm */ 74/* Return an algorithm identifier for a PKCS#5 PBE algorithm */
110 75
diff --git a/src/lib/libcrypto/asn1/p5_pbev2.c b/src/lib/libcrypto/asn1/p5_pbev2.c
index 6a7b578c0e..43dfe09479 100644
--- a/src/lib/libcrypto/asn1/p5_pbev2.c
+++ b/src/lib/libcrypto/asn1/p5_pbev2.c
@@ -58,108 +58,27 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/asn1_mac.h> 61#include <openssl/asn1t.h>
62#include <openssl/x509.h> 62#include <openssl/x509.h>
63#include <openssl/rand.h> 63#include <openssl/rand.h>
64 64
65/* PKCS#5 v2.0 password based encryption structures */ 65/* PKCS#5 v2.0 password based encryption structures */
66 66
67int i2d_PBE2PARAM(PBE2PARAM *a, unsigned char **pp) 67ASN1_SEQUENCE(PBE2PARAM) = {
68{ 68 ASN1_SIMPLE(PBE2PARAM, keyfunc, X509_ALGOR),
69 M_ASN1_I2D_vars(a); 69 ASN1_SIMPLE(PBE2PARAM, encryption, X509_ALGOR)
70 M_ASN1_I2D_len (a->keyfunc, i2d_X509_ALGOR); 70} ASN1_SEQUENCE_END(PBE2PARAM)
71 M_ASN1_I2D_len (a->encryption, i2d_X509_ALGOR);
72
73 M_ASN1_I2D_seq_total ();
74
75 M_ASN1_I2D_put (a->keyfunc, i2d_X509_ALGOR);
76 M_ASN1_I2D_put (a->encryption, i2d_X509_ALGOR);
77
78 M_ASN1_I2D_finish();
79}
80
81PBE2PARAM *PBE2PARAM_new(void)
82{
83 PBE2PARAM *ret=NULL;
84 ASN1_CTX c;
85 M_ASN1_New_Malloc(ret, PBE2PARAM);
86 M_ASN1_New(ret->keyfunc,X509_ALGOR_new);
87 M_ASN1_New(ret->encryption,X509_ALGOR_new);
88 return (ret);
89 M_ASN1_New_Error(ASN1_F_PBE2PARAM_NEW);
90}
91
92PBE2PARAM *d2i_PBE2PARAM(PBE2PARAM **a, unsigned char **pp, long length)
93{
94 M_ASN1_D2I_vars(a,PBE2PARAM *,PBE2PARAM_new);
95 M_ASN1_D2I_Init();
96 M_ASN1_D2I_start_sequence();
97 M_ASN1_D2I_get (ret->keyfunc, d2i_X509_ALGOR);
98 M_ASN1_D2I_get (ret->encryption, d2i_X509_ALGOR);
99 M_ASN1_D2I_Finish(a, PBE2PARAM_free, ASN1_F_D2I_PBE2PARAM);
100}
101
102void PBE2PARAM_free (PBE2PARAM *a)
103{
104 if(a==NULL) return;
105 X509_ALGOR_free(a->keyfunc);
106 X509_ALGOR_free(a->encryption);
107 OPENSSL_free (a);
108}
109
110int i2d_PBKDF2PARAM(PBKDF2PARAM *a, unsigned char **pp)
111{
112 M_ASN1_I2D_vars(a);
113 M_ASN1_I2D_len (a->salt, i2d_ASN1_TYPE);
114 M_ASN1_I2D_len (a->iter, i2d_ASN1_INTEGER);
115 M_ASN1_I2D_len (a->keylength, i2d_ASN1_INTEGER);
116 M_ASN1_I2D_len (a->prf, i2d_X509_ALGOR);
117 71
118 M_ASN1_I2D_seq_total (); 72IMPLEMENT_ASN1_FUNCTIONS(PBE2PARAM)
119 73
120 M_ASN1_I2D_put (a->salt, i2d_ASN1_TYPE); 74ASN1_SEQUENCE(PBKDF2PARAM) = {
121 M_ASN1_I2D_put (a->iter, i2d_ASN1_INTEGER); 75 ASN1_SIMPLE(PBKDF2PARAM, salt, ASN1_ANY),
122 M_ASN1_I2D_put (a->keylength, i2d_ASN1_INTEGER); 76 ASN1_SIMPLE(PBKDF2PARAM, iter, ASN1_INTEGER),
123 M_ASN1_I2D_put (a->prf, i2d_X509_ALGOR); 77 ASN1_OPT(PBKDF2PARAM, keylength, ASN1_INTEGER),
78 ASN1_OPT(PBKDF2PARAM, prf, X509_ALGOR)
79} ASN1_SEQUENCE_END(PBKDF2PARAM)
124 80
125 M_ASN1_I2D_finish(); 81IMPLEMENT_ASN1_FUNCTIONS(PBKDF2PARAM)
126}
127
128PBKDF2PARAM *PBKDF2PARAM_new(void)
129{
130 PBKDF2PARAM *ret=NULL;
131 ASN1_CTX c;
132 M_ASN1_New_Malloc(ret, PBKDF2PARAM);
133 M_ASN1_New(ret->salt, ASN1_TYPE_new);
134 M_ASN1_New(ret->iter, M_ASN1_INTEGER_new);
135 ret->keylength = NULL;
136 ret->prf = NULL;
137 return (ret);
138 M_ASN1_New_Error(ASN1_F_PBKDF2PARAM_NEW);
139}
140
141PBKDF2PARAM *d2i_PBKDF2PARAM(PBKDF2PARAM **a, unsigned char **pp,
142 long length)
143{
144 M_ASN1_D2I_vars(a,PBKDF2PARAM *,PBKDF2PARAM_new);
145 M_ASN1_D2I_Init();
146 M_ASN1_D2I_start_sequence();
147 M_ASN1_D2I_get (ret->salt, d2i_ASN1_TYPE);
148 M_ASN1_D2I_get (ret->iter, d2i_ASN1_INTEGER);
149 M_ASN1_D2I_get_opt (ret->keylength, d2i_ASN1_INTEGER, V_ASN1_INTEGER);
150 M_ASN1_D2I_get_opt (ret->prf, d2i_X509_ALGOR, V_ASN1_SEQUENCE);
151 M_ASN1_D2I_Finish(a, PBKDF2PARAM_free, ASN1_F_D2I_PBKDF2PARAM);
152}
153
154void PBKDF2PARAM_free (PBKDF2PARAM *a)
155{
156 if(a==NULL) return;
157 ASN1_TYPE_free(a->salt);
158 M_ASN1_INTEGER_free(a->iter);
159 M_ASN1_INTEGER_free(a->keylength);
160 X509_ALGOR_free(a->prf);
161 OPENSSL_free (a);
162}
163 82
164/* Return an algorithm identifier for a PKCS#5 v2.0 PBE algorithm: 83/* Return an algorithm identifier for a PKCS#5 v2.0 PBE algorithm:
165 * yes I know this is horrible! 84 * yes I know this is horrible!
@@ -198,7 +117,7 @@ X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
198 goto err; 117 goto err;
199 118
200 /* Dummy cipherinit to just setup the IV */ 119 /* Dummy cipherinit to just setup the IV */
201 EVP_CipherInit(&ctx, cipher, NULL, iv, 0); 120 EVP_CipherInit_ex(&ctx, cipher, NULL, NULL, iv, 0);
202 if(EVP_CIPHER_param_to_asn1(&ctx, scheme->parameter) < 0) { 121 if(EVP_CIPHER_param_to_asn1(&ctx, scheme->parameter) < 0) {
203 ASN1err(ASN1_F_PKCS5_PBE2_SET, 122 ASN1err(ASN1_F_PKCS5_PBE2_SET,
204 ASN1_R_ERROR_SETTING_CIPHER_PARAMS); 123 ASN1_R_ERROR_SETTING_CIPHER_PARAMS);
diff --git a/src/lib/libcrypto/asn1/p8_pkey.c b/src/lib/libcrypto/asn1/p8_pkey.c
index fa6cbfb6f8..b634d5bc85 100644
--- a/src/lib/libcrypto/asn1/p8_pkey.c
+++ b/src/lib/libcrypto/asn1/p8_pkey.c
@@ -58,70 +58,27 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/asn1_mac.h> 61#include <openssl/asn1t.h>
62#include <openssl/x509.h> 62#include <openssl/x509.h>
63 63
64int i2d_PKCS8_PRIV_KEY_INFO (PKCS8_PRIV_KEY_INFO *a, unsigned char **pp) 64/* Minor tweak to operation: zero private key data */
65static int pkey_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it)
65{ 66{
66 67 /* Since the structure must still be valid use ASN1_OP_FREE_PRE */
67 M_ASN1_I2D_vars(a); 68 if(operation == ASN1_OP_FREE_PRE) {
68 69 PKCS8_PRIV_KEY_INFO *key = (PKCS8_PRIV_KEY_INFO *)*pval;
69 M_ASN1_I2D_len (a->version, i2d_ASN1_INTEGER); 70 if (key->pkey->value.octet_string)
70 M_ASN1_I2D_len (a->pkeyalg, i2d_X509_ALGOR); 71 memset(key->pkey->value.octet_string->data,
71 M_ASN1_I2D_len (a->pkey, i2d_ASN1_TYPE); 72 0, key->pkey->value.octet_string->length);
72 M_ASN1_I2D_len_IMP_SET_opt_type (X509_ATTRIBUTE, a->attributes, 73 }
73 i2d_X509_ATTRIBUTE, 0); 74 return 1;
74
75 M_ASN1_I2D_seq_total ();
76
77 M_ASN1_I2D_put (a->version, i2d_ASN1_INTEGER);
78 M_ASN1_I2D_put (a->pkeyalg, i2d_X509_ALGOR);
79 M_ASN1_I2D_put (a->pkey, i2d_ASN1_TYPE);
80 M_ASN1_I2D_put_IMP_SET_opt_type (X509_ATTRIBUTE, a->attributes,
81 i2d_X509_ATTRIBUTE, 0);
82
83 M_ASN1_I2D_finish();
84} 75}
85 76
86PKCS8_PRIV_KEY_INFO *PKCS8_PRIV_KEY_INFO_new(void) 77ASN1_SEQUENCE_cb(PKCS8_PRIV_KEY_INFO, pkey_cb) = {
87{ 78 ASN1_SIMPLE(PKCS8_PRIV_KEY_INFO, version, ASN1_INTEGER),
88 PKCS8_PRIV_KEY_INFO *ret=NULL; 79 ASN1_SIMPLE(PKCS8_PRIV_KEY_INFO, pkeyalg, X509_ALGOR),
89 ASN1_CTX c; 80 ASN1_SIMPLE(PKCS8_PRIV_KEY_INFO, pkey, ASN1_ANY),
90 M_ASN1_New_Malloc(ret, PKCS8_PRIV_KEY_INFO); 81 ASN1_IMP_SET_OF_OPT(PKCS8_PRIV_KEY_INFO, attributes, X509_ATTRIBUTE, 0)
91 M_ASN1_New (ret->version, M_ASN1_INTEGER_new); 82} ASN1_SEQUENCE_END_cb(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO)
92 M_ASN1_New (ret->pkeyalg, X509_ALGOR_new);
93 M_ASN1_New (ret->pkey, ASN1_TYPE_new);
94 ret->attributes = NULL;
95 ret->broken = PKCS8_OK;
96 return (ret);
97 M_ASN1_New_Error(ASN1_F_PKCS8_PRIV_KEY_INFO_NEW);
98}
99 83
100PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO(PKCS8_PRIV_KEY_INFO **a, 84IMPLEMENT_ASN1_FUNCTIONS(PKCS8_PRIV_KEY_INFO)
101 unsigned char **pp, long length)
102{
103 M_ASN1_D2I_vars(a,PKCS8_PRIV_KEY_INFO *,PKCS8_PRIV_KEY_INFO_new);
104 M_ASN1_D2I_Init();
105 M_ASN1_D2I_start_sequence();
106 M_ASN1_D2I_get (ret->version, d2i_ASN1_INTEGER);
107 M_ASN1_D2I_get (ret->pkeyalg, d2i_X509_ALGOR);
108 M_ASN1_D2I_get (ret->pkey, d2i_ASN1_TYPE);
109 M_ASN1_D2I_get_IMP_set_opt_type(X509_ATTRIBUTE, ret->attributes,
110 d2i_X509_ATTRIBUTE,
111 X509_ATTRIBUTE_free, 0);
112 M_ASN1_D2I_Finish(a, PKCS8_PRIV_KEY_INFO_free, ASN1_F_D2I_PKCS8_PRIV_KEY_INFO);
113}
114
115void PKCS8_PRIV_KEY_INFO_free (PKCS8_PRIV_KEY_INFO *a)
116{
117 if (a == NULL) return;
118 M_ASN1_INTEGER_free (a->version);
119 X509_ALGOR_free(a->pkeyalg);
120 /* Clear sensitive data */
121 if (a->pkey->value.octet_string)
122 memset (a->pkey->value.octet_string->data,
123 0, a->pkey->value.octet_string->length);
124 ASN1_TYPE_free (a->pkey);
125 sk_X509_ATTRIBUTE_pop_free (a->attributes, X509_ATTRIBUTE_free);
126 OPENSSL_free (a);
127}
diff --git a/src/lib/libcrypto/asn1/t_crl.c b/src/lib/libcrypto/asn1/t_crl.c
index d78e4a8f88..60db305756 100644
--- a/src/lib/libcrypto/asn1/t_crl.c
+++ b/src/lib/libcrypto/asn1/t_crl.c
@@ -64,8 +64,7 @@
64#include <openssl/x509.h> 64#include <openssl/x509.h>
65#include <openssl/x509v3.h> 65#include <openssl/x509v3.h>
66 66
67static void ext_print(BIO *out, X509_EXTENSION *ex); 67#ifndef OPENSSL_NO_FP_API
68#ifndef NO_FP_API
69int X509_CRL_print_fp(FILE *fp, X509_CRL *x) 68int X509_CRL_print_fp(FILE *fp, X509_CRL *x)
70 { 69 {
71 BIO *b; 70 BIO *b;
@@ -86,11 +85,10 @@ int X509_CRL_print_fp(FILE *fp, X509_CRL *x)
86int X509_CRL_print(BIO *out, X509_CRL *x) 85int X509_CRL_print(BIO *out, X509_CRL *x)
87{ 86{
88 char buf[256]; 87 char buf[256];
89 unsigned char *s;
90 STACK_OF(X509_REVOKED) *rev; 88 STACK_OF(X509_REVOKED) *rev;
91 X509_REVOKED *r; 89 X509_REVOKED *r;
92 long l; 90 long l;
93 int i, j, n; 91 int i, n;
94 92
95 BIO_printf(out, "Certificate Revocation List (CRL):\n"); 93 BIO_printf(out, "Certificate Revocation List (CRL):\n");
96 l = X509_CRL_get_version(x); 94 l = X509_CRL_get_version(x);
@@ -109,15 +107,12 @@ int X509_CRL_print(BIO *out, X509_CRL *x)
109 BIO_printf(out,"\n"); 107 BIO_printf(out,"\n");
110 108
111 n=X509_CRL_get_ext_count(x); 109 n=X509_CRL_get_ext_count(x);
112 if (n > 0) { 110 X509V3_extensions_print(out, "CRL extensions",
113 BIO_printf(out,"%8sCRL extensions:\n",""); 111 x->crl->extensions, 0, 8);
114 for (i=0; i<n; i++) ext_print(out, X509_CRL_get_ext(x, i));
115 }
116
117 112
118 rev = X509_CRL_get_REVOKED(x); 113 rev = X509_CRL_get_REVOKED(x);
119 114
120 if(sk_X509_REVOKED_num(rev)) 115 if(sk_X509_REVOKED_num(rev) > 0)
121 BIO_printf(out, "Revoked Certificates:\n"); 116 BIO_printf(out, "Revoked Certificates:\n");
122 else BIO_printf(out, "No Revoked Certificates.\n"); 117 else BIO_printf(out, "No Revoked Certificates.\n");
123 118
@@ -128,39 +123,11 @@ int X509_CRL_print(BIO *out, X509_CRL *x)
128 BIO_printf(out,"\n Revocation Date: ",""); 123 BIO_printf(out,"\n Revocation Date: ","");
129 ASN1_TIME_print(out,r->revocationDate); 124 ASN1_TIME_print(out,r->revocationDate);
130 BIO_printf(out,"\n"); 125 BIO_printf(out,"\n");
131 for(j = 0; j < X509_REVOKED_get_ext_count(r); j++) 126 X509V3_extensions_print(out, "CRL entry extensions",
132 ext_print(out, X509_REVOKED_get_ext(r, j)); 127 r->extensions, 0, 8);
133 }
134
135 i=OBJ_obj2nid(x->sig_alg->algorithm);
136 BIO_printf(out," Signature Algorithm: %s",
137 (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i));
138
139 s = x->signature->data;
140 n = x->signature->length;
141 for (i=0; i<n; i++, s++)
142 {
143 if ((i%18) == 0) BIO_write(out,"\n ",9);
144 BIO_printf(out,"%02x%s",*s, ((i+1) == n)?"":":");
145 } 128 }
146 BIO_write(out,"\n",1); 129 X509_signature_print(out, x->sig_alg, x->signature);
147 130
148 return 1; 131 return 1;
149 132
150} 133}
151
152static void ext_print(BIO *out, X509_EXTENSION *ex)
153{
154 ASN1_OBJECT *obj;
155 int j;
156 BIO_printf(out,"%12s","");
157 obj=X509_EXTENSION_get_object(ex);
158 i2a_ASN1_OBJECT(out,obj);
159 j=X509_EXTENSION_get_critical(ex);
160 BIO_printf(out, ": %s\n", j ? "critical":"","");
161 if(!X509V3_EXT_print(out, ex, 0, 16)) {
162 BIO_printf(out, "%16s", "");
163 M_ASN1_OCTET_STRING_print(out,ex->value);
164 }
165 BIO_write(out,"\n",1);
166}
diff --git a/src/lib/libcrypto/asn1/t_pkey.c b/src/lib/libcrypto/asn1/t_pkey.c
index ae18da96e3..8060115202 100644
--- a/src/lib/libcrypto/asn1/t_pkey.c
+++ b/src/lib/libcrypto/asn1/t_pkey.c
@@ -60,21 +60,21 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/buffer.h> 61#include <openssl/buffer.h>
62#include <openssl/bn.h> 62#include <openssl/bn.h>
63#ifndef NO_RSA 63#ifndef OPENSSL_NO_RSA
64#include <openssl/rsa.h> 64#include <openssl/rsa.h>
65#endif 65#endif
66#ifndef NO_DH 66#ifndef OPENSSL_NO_DH
67#include <openssl/dh.h> 67#include <openssl/dh.h>
68#endif 68#endif
69#ifndef NO_DSA 69#ifndef OPENSSL_NO_DSA
70#include <openssl/dsa.h> 70#include <openssl/dsa.h>
71#endif 71#endif
72 72
73static int print(BIO *fp,const char *str,BIGNUM *num, 73static int print(BIO *fp,const char *str,BIGNUM *num,
74 unsigned char *buf,int off); 74 unsigned char *buf,int off);
75#ifndef NO_RSA 75#ifndef OPENSSL_NO_RSA
76#ifndef NO_FP_API 76#ifndef OPENSSL_NO_FP_API
77int RSA_print_fp(FILE *fp, RSA *x, int off) 77int RSA_print_fp(FILE *fp, const RSA *x, int off)
78 { 78 {
79 BIO *b; 79 BIO *b;
80 int ret; 80 int ret;
@@ -91,7 +91,7 @@ int RSA_print_fp(FILE *fp, RSA *x, int off)
91 } 91 }
92#endif 92#endif
93 93
94int RSA_print(BIO *bp, RSA *x, int off) 94int RSA_print(BIO *bp, const RSA *x, int off)
95 { 95 {
96 char str[128]; 96 char str[128];
97 const char *s; 97 const char *s;
@@ -136,11 +136,11 @@ err:
136 if (m != NULL) OPENSSL_free(m); 136 if (m != NULL) OPENSSL_free(m);
137 return(ret); 137 return(ret);
138 } 138 }
139#endif /* NO_RSA */ 139#endif /* OPENSSL_NO_RSA */
140 140
141#ifndef NO_DSA 141#ifndef OPENSSL_NO_DSA
142#ifndef NO_FP_API 142#ifndef OPENSSL_NO_FP_API
143int DSA_print_fp(FILE *fp, DSA *x, int off) 143int DSA_print_fp(FILE *fp, const DSA *x, int off)
144 { 144 {
145 BIO *b; 145 BIO *b;
146 int ret; 146 int ret;
@@ -157,7 +157,7 @@ int DSA_print_fp(FILE *fp, DSA *x, int off)
157 } 157 }
158#endif 158#endif
159 159
160int DSA_print(BIO *bp, DSA *x, int off) 160int DSA_print(BIO *bp, const DSA *x, int off)
161 { 161 {
162 char str[128]; 162 char str[128];
163 unsigned char *m=NULL; 163 unsigned char *m=NULL;
@@ -207,7 +207,7 @@ err:
207 if (m != NULL) OPENSSL_free(m); 207 if (m != NULL) OPENSSL_free(m);
208 return(ret); 208 return(ret);
209 } 209 }
210#endif /* !NO_DSA */ 210#endif /* !OPENSSL_NO_DSA */
211 211
212static int print(BIO *bp, const char *number, BIGNUM *num, unsigned char *buf, 212static int print(BIO *bp, const char *number, BIGNUM *num, unsigned char *buf,
213 int off) 213 int off)
@@ -259,9 +259,9 @@ static int print(BIO *bp, const char *number, BIGNUM *num, unsigned char *buf,
259 return(1); 259 return(1);
260 } 260 }
261 261
262#ifndef NO_DH 262#ifndef OPENSSL_NO_DH
263#ifndef NO_FP_API 263#ifndef OPENSSL_NO_FP_API
264int DHparams_print_fp(FILE *fp, DH *x) 264int DHparams_print_fp(FILE *fp, const DH *x)
265 { 265 {
266 BIO *b; 266 BIO *b;
267 int ret; 267 int ret;
@@ -278,7 +278,7 @@ int DHparams_print_fp(FILE *fp, DH *x)
278 } 278 }
279#endif 279#endif
280 280
281int DHparams_print(BIO *bp, DH *x) 281int DHparams_print(BIO *bp, const DH *x)
282 { 282 {
283 unsigned char *m=NULL; 283 unsigned char *m=NULL;
284 int reason=ERR_R_BUF_LIB,i,ret=0; 284 int reason=ERR_R_BUF_LIB,i,ret=0;
@@ -312,9 +312,9 @@ err:
312 } 312 }
313#endif 313#endif
314 314
315#ifndef NO_DSA 315#ifndef OPENSSL_NO_DSA
316#ifndef NO_FP_API 316#ifndef OPENSSL_NO_FP_API
317int DSAparams_print_fp(FILE *fp, DSA *x) 317int DSAparams_print_fp(FILE *fp, const DSA *x)
318 { 318 {
319 BIO *b; 319 BIO *b;
320 int ret; 320 int ret;
@@ -331,7 +331,7 @@ int DSAparams_print_fp(FILE *fp, DSA *x)
331 } 331 }
332#endif 332#endif
333 333
334int DSAparams_print(BIO *bp, DSA *x) 334int DSAparams_print(BIO *bp, const DSA *x)
335 { 335 {
336 unsigned char *m=NULL; 336 unsigned char *m=NULL;
337 int reason=ERR_R_BUF_LIB,i,ret=0; 337 int reason=ERR_R_BUF_LIB,i,ret=0;
@@ -357,5 +357,5 @@ err:
357 return(ret); 357 return(ret);
358 } 358 }
359 359
360#endif /* !NO_DSA */ 360#endif /* !OPENSSL_NO_DSA */
361 361
diff --git a/src/lib/libcrypto/asn1/t_req.c b/src/lib/libcrypto/asn1/t_req.c
index ea1af092db..848c29a2dd 100644
--- a/src/lib/libcrypto/asn1/t_req.c
+++ b/src/lib/libcrypto/asn1/t_req.c
@@ -64,7 +64,7 @@
64#include <openssl/x509.h> 64#include <openssl/x509.h>
65#include <openssl/x509v3.h> 65#include <openssl/x509v3.h>
66 66
67#ifndef NO_FP_API 67#ifndef OPENSSL_NO_FP_API
68int X509_REQ_print_fp(FILE *fp, X509_REQ *x) 68int X509_REQ_print_fp(FILE *fp, X509_REQ *x)
69 { 69 {
70 BIO *b; 70 BIO *b;
@@ -85,8 +85,7 @@ int X509_REQ_print_fp(FILE *fp, X509_REQ *x)
85int X509_REQ_print(BIO *bp, X509_REQ *x) 85int X509_REQ_print(BIO *bp, X509_REQ *x)
86 { 86 {
87 unsigned long l; 87 unsigned long l;
88 int i,n; 88 int i;
89 char *s;
90 const char *neg; 89 const char *neg;
91 X509_REQ_INFO *ri; 90 X509_REQ_INFO *ri;
92 EVP_PKEY *pkey; 91 EVP_PKEY *pkey;
@@ -118,7 +117,7 @@ int X509_REQ_print(BIO *bp, X509_REQ *x)
118 if (BIO_puts(bp,str) <= 0) goto err; 117 if (BIO_puts(bp,str) <= 0) goto err;
119 118
120 pkey=X509_REQ_get_pubkey(x); 119 pkey=X509_REQ_get_pubkey(x);
121#ifndef NO_RSA 120#ifndef OPENSSL_NO_RSA
122 if (pkey != NULL && pkey->type == EVP_PKEY_RSA) 121 if (pkey != NULL && pkey->type == EVP_PKEY_RSA)
123 { 122 {
124 BIO_printf(bp,"%12sRSA Public Key: (%d bit)\n","", 123 BIO_printf(bp,"%12sRSA Public Key: (%d bit)\n","",
@@ -127,7 +126,7 @@ int X509_REQ_print(BIO *bp, X509_REQ *x)
127 } 126 }
128 else 127 else
129#endif 128#endif
130#ifndef NO_DSA 129#ifndef OPENSSL_NO_DSA
131 if (pkey != NULL && pkey->type == EVP_PKEY_DSA) 130 if (pkey != NULL && pkey->type == EVP_PKEY_DSA)
132 { 131 {
133 BIO_printf(bp,"%12sDSA Public Key:\n",""); 132 BIO_printf(bp,"%12sDSA Public Key:\n","");
@@ -145,13 +144,10 @@ int X509_REQ_print(BIO *bp, X509_REQ *x)
145 if (BIO_puts(bp,str) <= 0) goto err; 144 if (BIO_puts(bp,str) <= 0) goto err;
146 145
147 sk=x->req_info->attributes; 146 sk=x->req_info->attributes;
148 if ((sk == NULL) || (sk_X509_ATTRIBUTE_num(sk) == 0)) 147 if (sk_X509_ATTRIBUTE_num(sk) == 0)
149 { 148 {
150 if (!x->req_info->req_kludge) 149 sprintf(str,"%12sa0:00\n","");
151 { 150 if (BIO_puts(bp,str) <= 0) goto err;
152 sprintf(str,"%12sa0:00\n","");
153 if (BIO_puts(bp,str) <= 0) goto err;
154 }
155 } 151 }
156 else 152 else
157 { 153 {
@@ -170,7 +166,13 @@ int X509_REQ_print(BIO *bp, X509_REQ *x)
170 if (BIO_puts(bp,str) <= 0) goto err; 166 if (BIO_puts(bp,str) <= 0) goto err;
171 if ((j=i2a_ASN1_OBJECT(bp,a->object)) > 0) 167 if ((j=i2a_ASN1_OBJECT(bp,a->object)) > 0)
172 { 168 {
173 if (a->set) 169 if (a->single)
170 {
171 t=a->value.single;
172 type=t->type;
173 bs=t->value.bit_string;
174 }
175 else
174 { 176 {
175 ii=0; 177 ii=0;
176 count=sk_ASN1_TYPE_num(a->value.set); 178 count=sk_ASN1_TYPE_num(a->value.set);
@@ -179,12 +181,6 @@ get_next:
179 type=at->type; 181 type=at->type;
180 bs=at->value.asn1_string; 182 bs=at->value.asn1_string;
181 } 183 }
182 else
183 {
184 t=a->value.single;
185 type=t->type;
186 bs=t->value.bit_string;
187 }
188 } 184 }
189 for (j=25-j; j>0; j--) 185 for (j=25-j; j>0; j--)
190 if (BIO_write(bp," ",1) != 1) goto err; 186 if (BIO_write(bp," ",1) != 1) goto err;
@@ -229,24 +225,8 @@ get_next:
229 sk_X509_EXTENSION_pop_free(exts, X509_EXTENSION_free); 225 sk_X509_EXTENSION_pop_free(exts, X509_EXTENSION_free);
230 } 226 }
231 227
232 i=OBJ_obj2nid(x->sig_alg->algorithm); 228 if(!X509_signature_print(bp, x->sig_alg, x->signature)) goto err;
233 sprintf(str,"%4sSignature Algorithm: %s","",
234 (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i));
235 if (BIO_puts(bp,str) <= 0) goto err;
236 229
237 n=x->signature->length;
238 s=(char *)x->signature->data;
239 for (i=0; i<n; i++)
240 {
241 if ((i%18) == 0)
242 {
243 sprintf(str,"\n%8s","");
244 if (BIO_puts(bp,str) <= 0) goto err;
245 }
246 sprintf(str,"%02x%s",(unsigned char)s[i],((i+1) == n)?"":":");
247 if (BIO_puts(bp,str) <= 0) goto err;
248 }
249 if (BIO_puts(bp,"\n") <= 0) goto err;
250 return(1); 230 return(1);
251err: 231err:
252 X509err(X509_F_X509_REQ_PRINT,ERR_R_BUF_LIB); 232 X509err(X509_F_X509_REQ_PRINT,ERR_R_BUF_LIB);
diff --git a/src/lib/libcrypto/asn1/t_spki.c b/src/lib/libcrypto/asn1/t_spki.c
index d708434fca..5abfbc815e 100644
--- a/src/lib/libcrypto/asn1/t_spki.c
+++ b/src/lib/libcrypto/asn1/t_spki.c
@@ -59,7 +59,7 @@
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/x509.h> 61#include <openssl/x509.h>
62#include <openssl/asn1_mac.h> 62#include <openssl/asn1.h>
63 63
64/* Print out an SPKI */ 64/* Print out an SPKI */
65 65
@@ -76,7 +76,7 @@ int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki)
76 pkey = X509_PUBKEY_get(spki->spkac->pubkey); 76 pkey = X509_PUBKEY_get(spki->spkac->pubkey);
77 if(!pkey) BIO_printf(out, " Unable to load public key\n"); 77 if(!pkey) BIO_printf(out, " Unable to load public key\n");
78 else { 78 else {
79#ifndef NO_RSA 79#ifndef OPENSSL_NO_RSA
80 if (pkey->type == EVP_PKEY_RSA) 80 if (pkey->type == EVP_PKEY_RSA)
81 { 81 {
82 BIO_printf(out," RSA Public Key: (%d bit)\n", 82 BIO_printf(out," RSA Public Key: (%d bit)\n",
@@ -85,7 +85,7 @@ int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki)
85 } 85 }
86 else 86 else
87#endif 87#endif
88#ifndef NO_DSA 88#ifndef OPENSSL_NO_DSA
89 if (pkey->type == EVP_PKEY_DSA) 89 if (pkey->type == EVP_PKEY_DSA)
90 { 90 {
91 BIO_printf(out," DSA Public Key:\n"); 91 BIO_printf(out," DSA Public Key:\n");
diff --git a/src/lib/libcrypto/asn1/t_x509.c b/src/lib/libcrypto/asn1/t_x509.c
index 89ae73a6de..5de4833ed0 100644
--- a/src/lib/libcrypto/asn1/t_x509.c
+++ b/src/lib/libcrypto/asn1/t_x509.c
@@ -60,18 +60,23 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/buffer.h> 61#include <openssl/buffer.h>
62#include <openssl/bn.h> 62#include <openssl/bn.h>
63#ifndef NO_RSA 63#ifndef OPENSSL_NO_RSA
64#include <openssl/rsa.h> 64#include <openssl/rsa.h>
65#endif 65#endif
66#ifndef NO_DSA 66#ifndef OPENSSL_NO_DSA
67#include <openssl/dsa.h> 67#include <openssl/dsa.h>
68#endif 68#endif
69#include <openssl/objects.h> 69#include <openssl/objects.h>
70#include <openssl/x509.h> 70#include <openssl/x509.h>
71#include <openssl/x509v3.h> 71#include <openssl/x509v3.h>
72 72
73#ifndef NO_FP_API 73#ifndef OPENSSL_NO_FP_API
74int X509_print_fp(FILE *fp, X509 *x) 74int X509_print_fp(FILE *fp, X509 *x)
75 {
76 return X509_print_ex_fp(fp, x, XN_FLAG_COMPAT, X509_FLAG_COMPAT);
77 }
78
79int X509_print_ex_fp(FILE *fp, X509 *x, unsigned long nmflag, unsigned long cflag)
75 { 80 {
76 BIO *b; 81 BIO *b;
77 int ret; 82 int ret;
@@ -82,144 +87,165 @@ int X509_print_fp(FILE *fp, X509 *x)
82 return(0); 87 return(0);
83 } 88 }
84 BIO_set_fp(b,fp,BIO_NOCLOSE); 89 BIO_set_fp(b,fp,BIO_NOCLOSE);
85 ret=X509_print(b, x); 90 ret=X509_print_ex(b, x, nmflag, cflag);
86 BIO_free(b); 91 BIO_free(b);
87 return(ret); 92 return(ret);
88 } 93 }
89#endif 94#endif
90 95
91int X509_print(BIO *bp, X509 *x) 96int X509_print(BIO *bp, X509 *x)
97{
98 return X509_print_ex(bp, x, XN_FLAG_COMPAT, X509_FLAG_COMPAT);
99}
100
101int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag)
92 { 102 {
93 long l; 103 long l;
94 int ret=0,i,j,n; 104 int ret=0,i;
95 char *m=NULL,*s; 105 char *m=NULL,mlch = ' ';
106 int nmindent = 0;
96 X509_CINF *ci; 107 X509_CINF *ci;
97 ASN1_INTEGER *bs; 108 ASN1_INTEGER *bs;
98 EVP_PKEY *pkey=NULL; 109 EVP_PKEY *pkey=NULL;
99 const char *neg; 110 const char *neg;
100 X509_EXTENSION *ex;
101 ASN1_STRING *str=NULL; 111 ASN1_STRING *str=NULL;
102 112
113 if((nmflags & XN_FLAG_SEP_MASK) == XN_FLAG_SEP_MULTILINE) {
114 mlch = '\n';
115 nmindent = 12;
116 }
117
118 if(nmflags == X509_FLAG_COMPAT)
119 nmindent = 16;
120
103 ci=x->cert_info; 121 ci=x->cert_info;
104 if (BIO_write(bp,"Certificate:\n",13) <= 0) goto err; 122 if(!(cflag & X509_FLAG_NO_HEADER))
105 if (BIO_write(bp," Data:\n",10) <= 0) goto err;
106 l=X509_get_version(x);
107 if (BIO_printf(bp,"%8sVersion: %lu (0x%lx)\n","",l+1,l) <= 0) goto err;
108 if (BIO_write(bp," Serial Number:",22) <= 0) goto err;
109
110 bs=X509_get_serialNumber(x);
111 if (bs->length <= 4)
112 { 123 {
113 l=ASN1_INTEGER_get(bs); 124 if (BIO_write(bp,"Certificate:\n",13) <= 0) goto err;
114 if (l < 0) 125 if (BIO_write(bp," Data:\n",10) <= 0) goto err;
115 {
116 l= -l;
117 neg="-";
118 }
119 else
120 neg="";
121 if (BIO_printf(bp," %s%lu (%s0x%lx)\n",neg,l,neg,l) <= 0)
122 goto err;
123 } 126 }
124 else 127 if(!(cflag & X509_FLAG_NO_VERSION))
128 {
129 l=X509_get_version(x);
130 if (BIO_printf(bp,"%8sVersion: %lu (0x%lx)\n","",l+1,l) <= 0) goto err;
131 }
132 if(!(cflag & X509_FLAG_NO_SERIAL))
125 { 133 {
126 neg=(bs->type == V_ASN1_NEG_INTEGER)?" (Negative)":"";
127 if (BIO_printf(bp,"\n%12s%s","",neg) <= 0) goto err;
128 134
129 for (i=0; i<bs->length; i++) 135 if (BIO_write(bp," Serial Number:",22) <= 0) goto err;
136
137 bs=X509_get_serialNumber(x);
138 if (bs->length <= 4)
130 { 139 {
131 if (BIO_printf(bp,"%02x%c",bs->data[i], 140 l=ASN1_INTEGER_get(bs);
132 ((i+1 == bs->length)?'\n':':')) <= 0) 141 if (l < 0)
142 {
143 l= -l;
144 neg="-";
145 }
146 else
147 neg="";
148 if (BIO_printf(bp," %s%lu (%s0x%lx)\n",neg,l,neg,l) <= 0)
133 goto err; 149 goto err;
134 } 150 }
135 } 151 else
152 {
153 neg=(bs->type == V_ASN1_NEG_INTEGER)?" (Negative)":"";
154 if (BIO_printf(bp,"\n%12s%s","",neg) <= 0) goto err;
136 155
137 i=OBJ_obj2nid(ci->signature->algorithm); 156 for (i=0; i<bs->length; i++)
138 if (BIO_printf(bp,"%8sSignature Algorithm: %s\n","", 157 {
139 (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i)) <= 0) 158 if (BIO_printf(bp,"%02x%c",bs->data[i],
140 goto err; 159 ((i+1 == bs->length)?'\n':':')) <= 0)
160 goto err;
161 }
162 }
141 163
142 if (BIO_write(bp," Issuer: ",16) <= 0) goto err; 164 }
143 if (!X509_NAME_print(bp,X509_get_issuer_name(x),16)) goto err;
144 if (BIO_write(bp,"\n Validity\n",18) <= 0) goto err;
145 if (BIO_write(bp," Not Before: ",24) <= 0) goto err;
146 if (!ASN1_TIME_print(bp,X509_get_notBefore(x))) goto err;
147 if (BIO_write(bp,"\n Not After : ",25) <= 0) goto err;
148 if (!ASN1_TIME_print(bp,X509_get_notAfter(x))) goto err;
149 if (BIO_write(bp,"\n Subject: ",18) <= 0) goto err;
150 if (!X509_NAME_print(bp,X509_get_subject_name(x),16)) goto err;
151 if (BIO_write(bp,"\n Subject Public Key Info:\n",34) <= 0)
152 goto err;
153 i=OBJ_obj2nid(ci->key->algor->algorithm);
154 if (BIO_printf(bp,"%12sPublic Key Algorithm: %s\n","",
155 (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i)) <= 0) goto err;
156 165
157 pkey=X509_get_pubkey(x); 166 if(!(cflag & X509_FLAG_NO_SIGNAME))
158 if (pkey == NULL)
159 { 167 {
160 BIO_printf(bp,"%12sUnable to load Public Key\n",""); 168 if (BIO_printf(bp,"%8sSignature Algorithm: ","") <= 0)
161 ERR_print_errors(bp); 169 goto err;
170 if (i2a_ASN1_OBJECT(bp, ci->signature->algorithm) <= 0)
171 goto err;
172 if (BIO_puts(bp, "\n") <= 0)
173 goto err;
162 } 174 }
163 else 175
164#ifndef NO_RSA 176 if(!(cflag & X509_FLAG_NO_ISSUER))
165 if (pkey->type == EVP_PKEY_RSA)
166 { 177 {
167 BIO_printf(bp,"%12sRSA Public Key: (%d bit)\n","", 178 if (BIO_printf(bp," Issuer:%c",mlch) <= 0) goto err;
168 BN_num_bits(pkey->pkey.rsa->n)); 179 if (X509_NAME_print_ex(bp,X509_get_issuer_name(x),nmindent, nmflags) < 0) goto err;
169 RSA_print(bp,pkey->pkey.rsa,16); 180 if (BIO_write(bp,"\n",1) <= 0) goto err;
170 } 181 }
171 else 182 if(!(cflag & X509_FLAG_NO_VALIDITY))
172#endif
173#ifndef NO_DSA
174 if (pkey->type == EVP_PKEY_DSA)
175 { 183 {
176 BIO_printf(bp,"%12sDSA Public Key:\n",""); 184 if (BIO_write(bp," Validity\n",17) <= 0) goto err;
177 DSA_print(bp,pkey->pkey.dsa,16); 185 if (BIO_write(bp," Not Before: ",24) <= 0) goto err;
186 if (!ASN1_TIME_print(bp,X509_get_notBefore(x))) goto err;
187 if (BIO_write(bp,"\n Not After : ",25) <= 0) goto err;
188 if (!ASN1_TIME_print(bp,X509_get_notAfter(x))) goto err;
189 if (BIO_write(bp,"\n",1) <= 0) goto err;
178 } 190 }
179 else 191 if(!(cflag & X509_FLAG_NO_SUBJECT))
180#endif
181 BIO_printf(bp,"%12sUnknown Public Key:\n","");
182
183 EVP_PKEY_free(pkey);
184
185 n=X509_get_ext_count(x);
186 if (n > 0)
187 { 192 {
188 BIO_printf(bp,"%8sX509v3 extensions:\n",""); 193 if (BIO_printf(bp," Subject:%c",mlch) <= 0) goto err;
189 for (i=0; i<n; i++) 194 if (X509_NAME_print_ex(bp,X509_get_subject_name(x),nmindent, nmflags) < 0) goto err;
195 if (BIO_write(bp,"\n",1) <= 0) goto err;
196 }
197 if(!(cflag & X509_FLAG_NO_PUBKEY))
198 {
199 if (BIO_write(bp," Subject Public Key Info:\n",33) <= 0)
200 goto err;
201 if (BIO_printf(bp,"%12sPublic Key Algorithm: ","") <= 0)
202 goto err;
203 if (i2a_ASN1_OBJECT(bp, ci->key->algor->algorithm) <= 0)
204 goto err;
205 if (BIO_puts(bp, "\n") <= 0)
206 goto err;
207
208 pkey=X509_get_pubkey(x);
209 if (pkey == NULL)
190 { 210 {
191 ASN1_OBJECT *obj; 211 BIO_printf(bp,"%12sUnable to load Public Key\n","");
192 ex=X509_get_ext(x,i); 212 ERR_print_errors(bp);
193 if (BIO_printf(bp,"%12s","") <= 0) goto err; 213 }
194 obj=X509_EXTENSION_get_object(ex); 214 else
195 i2a_ASN1_OBJECT(bp,obj); 215#ifndef OPENSSL_NO_RSA
196 j=X509_EXTENSION_get_critical(ex); 216 if (pkey->type == EVP_PKEY_RSA)
197 if (BIO_printf(bp,": %s\n",j?"critical":"","") <= 0) 217 {
198 goto err; 218 BIO_printf(bp,"%12sRSA Public Key: (%d bit)\n","",
199 if(!X509V3_EXT_print(bp, ex, 0, 16)) 219 BN_num_bits(pkey->pkey.rsa->n));
200 { 220 RSA_print(bp,pkey->pkey.rsa,16);
201 BIO_printf(bp, "%16s", ""); 221 }
202 M_ASN1_OCTET_STRING_print(bp,ex->value); 222 else
203 } 223#endif
204 if (BIO_write(bp,"\n",1) <= 0) goto err; 224#ifndef OPENSSL_NO_DSA
225 if (pkey->type == EVP_PKEY_DSA)
226 {
227 BIO_printf(bp,"%12sDSA Public Key:\n","");
228 DSA_print(bp,pkey->pkey.dsa,16);
205 } 229 }
230 else
231#endif
232 BIO_printf(bp,"%12sUnknown Public Key:\n","");
233
234 EVP_PKEY_free(pkey);
206 } 235 }
207 236
208 i=OBJ_obj2nid(x->sig_alg->algorithm); 237 if (!(cflag & X509_FLAG_NO_EXTENSIONS))
209 if (BIO_printf(bp,"%4sSignature Algorithm: %s","", 238 X509V3_extensions_print(bp, "X509v3 extensions",
210 (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i)) <= 0) goto err; 239 ci->extensions, cflag, 8);
211 240
212 n=x->signature->length; 241 if(!(cflag & X509_FLAG_NO_SIGDUMP))
213 s=(char *)x->signature->data;
214 for (i=0; i<n; i++)
215 { 242 {
216 if ((i%18) == 0) 243 if(X509_signature_print(bp, x->sig_alg, x->signature) <= 0) goto err;
217 if (BIO_write(bp,"\n ",9) <= 0) goto err; 244 }
218 if (BIO_printf(bp,"%02x%s",(unsigned char)s[i], 245 if(!(cflag & X509_FLAG_NO_AUX))
219 ((i+1) == n)?"":":") <= 0) goto err; 246 {
247 if (!X509_CERT_AUX_print(bp, x->aux, 0)) goto err;
220 } 248 }
221 if (BIO_write(bp,"\n",1) != 1) goto err;
222 if (!X509_CERT_AUX_print(bp, x->aux, 0)) goto err;
223 ret=1; 249 ret=1;
224err: 250err:
225 if (str != NULL) ASN1_STRING_free(str); 251 if (str != NULL) ASN1_STRING_free(str);
@@ -227,6 +253,71 @@ err:
227 return(ret); 253 return(ret);
228 } 254 }
229 255
256int X509_ocspid_print (BIO *bp, X509 *x)
257 {
258 unsigned char *der=NULL ;
259 unsigned char *dertmp;
260 int derlen;
261 int i;
262 unsigned char SHA1md[SHA_DIGEST_LENGTH];
263
264 /* display the hash of the subject as it would appear
265 in OCSP requests */
266 if (BIO_printf(bp," Subject OCSP hash: ") <= 0)
267 goto err;
268 derlen = i2d_X509_NAME(x->cert_info->subject, NULL);
269 if ((der = dertmp = (unsigned char *)OPENSSL_malloc (derlen)) == NULL)
270 goto err;
271 i2d_X509_NAME(x->cert_info->subject, &dertmp);
272
273 EVP_Digest(der, derlen, SHA1md, NULL, EVP_sha1(), NULL);
274 for (i=0; i < SHA_DIGEST_LENGTH; i++)
275 {
276 if (BIO_printf(bp,"%02X",SHA1md[i]) <= 0) goto err;
277 }
278 OPENSSL_free (der);
279 der=NULL;
280
281 /* display the hash of the public key as it would appear
282 in OCSP requests */
283 if (BIO_printf(bp,"\n Public key OCSP hash: ") <= 0)
284 goto err;
285
286 EVP_Digest(x->cert_info->key->public_key->data,
287 x->cert_info->key->public_key->length, SHA1md, NULL, EVP_sha1(), NULL);
288 for (i=0; i < SHA_DIGEST_LENGTH; i++)
289 {
290 if (BIO_printf(bp,"%02X",SHA1md[i]) <= 0)
291 goto err;
292 }
293 BIO_printf(bp,"\n");
294
295 return (1);
296err:
297 if (der != NULL) OPENSSL_free(der);
298 return(0);
299 }
300
301int X509_signature_print(BIO *bp, X509_ALGOR *sigalg, ASN1_STRING *sig)
302{
303 unsigned char *s;
304 int i, n;
305 if (BIO_puts(bp," Signature Algorithm: ") <= 0) return 0;
306 if (i2a_ASN1_OBJECT(bp, sigalg->algorithm) <= 0) return 0;
307
308 n=sig->length;
309 s=sig->data;
310 for (i=0; i<n; i++)
311 {
312 if ((i%18) == 0)
313 if (BIO_write(bp,"\n ",9) <= 0) return 0;
314 if (BIO_printf(bp,"%02x%s",s[i],
315 ((i+1) == n)?"":":") <= 0) return 0;
316 }
317 if (BIO_write(bp,"\n",1) != 1) return 0;
318 return 1;
319}
320
230int ASN1_STRING_print(BIO *bp, ASN1_STRING *v) 321int ASN1_STRING_print(BIO *bp, ASN1_STRING *v)
231 { 322 {
232 int i,n; 323 int i,n;
diff --git a/src/lib/libcrypto/asn1/t_x509a.c b/src/lib/libcrypto/asn1/t_x509a.c
index f06af5b576..7d4a6e6084 100644
--- a/src/lib/libcrypto/asn1/t_x509a.c
+++ b/src/lib/libcrypto/asn1/t_x509a.c
@@ -59,7 +59,7 @@
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/evp.h> 61#include <openssl/evp.h>
62#include <openssl/asn1_mac.h> 62#include <openssl/asn1.h>
63#include <openssl/x509.h> 63#include <openssl/x509.h>
64 64
65/* X509_CERT_AUX and string set routines 65/* X509_CERT_AUX and string set routines
diff --git a/src/lib/libcrypto/asn1/tasn_dec.c b/src/lib/libcrypto/asn1/tasn_dec.c
new file mode 100644
index 0000000000..0fc1f421e2
--- /dev/null
+++ b/src/lib/libcrypto/asn1/tasn_dec.c
@@ -0,0 +1,958 @@
1/* tasn_dec.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) 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
60#include <stddef.h>
61#include <string.h>
62#include <openssl/asn1.h>
63#include <openssl/asn1t.h>
64#include <openssl/objects.h>
65#include <openssl/buffer.h>
66#include <openssl/err.h>
67
68static int asn1_check_eoc(unsigned char **in, long len);
69static int asn1_collect(BUF_MEM *buf, unsigned char **in, long len, char inf, int tag, int aclass);
70static int collect_data(BUF_MEM *buf, unsigned char **p, long plen);
71static int asn1_check_tlen(long *olen, int *otag, unsigned char *oclass, char *inf, char *cst,
72 unsigned char **in, long len, int exptag, int expclass, char opt, ASN1_TLC *ctx);
73static int asn1_template_ex_d2i(ASN1_VALUE **pval, unsigned char **in, long len, const ASN1_TEMPLATE *tt, char opt, ASN1_TLC *ctx);
74static int asn1_template_noexp_d2i(ASN1_VALUE **val, unsigned char **in, long len, const ASN1_TEMPLATE *tt, char opt, ASN1_TLC *ctx);
75static int asn1_d2i_ex_primitive(ASN1_VALUE **pval, unsigned char **in, long len,
76 const ASN1_ITEM *it, int tag, int aclass, char opt, ASN1_TLC *ctx);
77
78/* Table to convert tags to bit values, used for MSTRING type */
79static unsigned long tag2bit[32]={
800, 0, 0, B_ASN1_BIT_STRING, /* tags 0 - 3 */
81B_ASN1_OCTET_STRING, 0, 0, B_ASN1_UNKNOWN,/* tags 4- 7 */
82B_ASN1_UNKNOWN, B_ASN1_UNKNOWN, B_ASN1_UNKNOWN, B_ASN1_UNKNOWN,/* tags 8-11 */
83B_ASN1_UTF8STRING,B_ASN1_UNKNOWN,B_ASN1_UNKNOWN,B_ASN1_UNKNOWN,/* tags 12-15 */
840, 0, B_ASN1_NUMERICSTRING,B_ASN1_PRINTABLESTRING, /* tags 16-19 */
85B_ASN1_T61STRING,B_ASN1_VIDEOTEXSTRING,B_ASN1_IA5STRING, /* tags 20-22 */
86B_ASN1_UTCTIME, B_ASN1_GENERALIZEDTIME, /* tags 23-24 */
87B_ASN1_GRAPHICSTRING,B_ASN1_ISO64STRING,B_ASN1_GENERALSTRING, /* tags 25-27 */
88B_ASN1_UNIVERSALSTRING,B_ASN1_UNKNOWN,B_ASN1_BMPSTRING,B_ASN1_UNKNOWN, /* tags 28-31 */
89 };
90
91unsigned long ASN1_tag2bit(int tag)
92{
93 if((tag < 0) || (tag > 30)) return 0;
94 return tag2bit[tag];
95}
96
97/* Macro to initialize and invalidate the cache */
98
99#define asn1_tlc_clear(c) if(c) (c)->valid = 0
100
101/* Decode an ASN1 item, this currently behaves just
102 * like a standard 'd2i' function. 'in' points to
103 * a buffer to read the data from, in future we will
104 * have more advanced versions that can input data
105 * a piece at a time and this will simply be a special
106 * case.
107 */
108
109ASN1_VALUE *ASN1_item_d2i(ASN1_VALUE **pval, unsigned char **in, long len, const ASN1_ITEM *it)
110{
111 ASN1_TLC c;
112 ASN1_VALUE *ptmpval = NULL;
113 if(!pval) pval = &ptmpval;
114 asn1_tlc_clear(&c);
115 if(ASN1_item_ex_d2i(pval, in, len, it, -1, 0, 0, &c) > 0)
116 return *pval;
117 return NULL;
118}
119
120int ASN1_template_d2i(ASN1_VALUE **pval, unsigned char **in, long len, const ASN1_TEMPLATE *tt)
121{
122 ASN1_TLC c;
123 asn1_tlc_clear(&c);
124 return asn1_template_ex_d2i(pval, in, len, tt, 0, &c);
125}
126
127
128/* Decode an item, taking care of IMPLICIT tagging, if any.
129 * If 'opt' set and tag mismatch return -1 to handle OPTIONAL
130 */
131
132int ASN1_item_ex_d2i(ASN1_VALUE **pval, unsigned char **in, long len, const ASN1_ITEM *it,
133 int tag, int aclass, char opt, ASN1_TLC *ctx)
134{
135 const ASN1_TEMPLATE *tt, *errtt = NULL;
136 const ASN1_COMPAT_FUNCS *cf;
137 const ASN1_EXTERN_FUNCS *ef;
138 const ASN1_AUX *aux = it->funcs;
139 ASN1_aux_cb *asn1_cb;
140 unsigned char *p, *q, imphack = 0, oclass;
141 char seq_eoc, seq_nolen, cst, isopt;
142 long tmplen;
143 int i;
144 int otag;
145 int ret = 0;
146 ASN1_VALUE *pchval, **pchptr, *ptmpval;
147 if(!pval) return 0;
148 if(aux && aux->asn1_cb) asn1_cb = aux->asn1_cb;
149 else asn1_cb = 0;
150
151 switch(it->itype) {
152
153 case ASN1_ITYPE_PRIMITIVE:
154 if(it->templates) {
155 /* tagging or OPTIONAL is currently illegal on an item template
156 * because the flags can't get passed down. In practice this isn't
157 * a problem: we include the relevant flags from the item template
158 * in the template itself.
159 */
160 if ((tag != -1) || opt) {
161 ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE);
162 goto err;
163 }
164 return asn1_template_ex_d2i(pval, in, len, it->templates, opt, ctx);
165 }
166 return asn1_d2i_ex_primitive(pval, in, len, it, tag, aclass, opt, ctx);
167 break;
168
169 case ASN1_ITYPE_MSTRING:
170 p = *in;
171 /* Just read in tag and class */
172 ret = asn1_check_tlen(NULL, &otag, &oclass, NULL, NULL, &p, len, -1, 0, 1, ctx);
173 if(!ret) {
174 ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ERR_R_NESTED_ASN1_ERROR);
175 goto err;
176 }
177 /* Must be UNIVERSAL class */
178 if(oclass != V_ASN1_UNIVERSAL) {
179 /* If OPTIONAL, assume this is OK */
180 if(opt) return -1;
181 ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ASN1_R_MSTRING_NOT_UNIVERSAL);
182 goto err;
183 }
184 /* Check tag matches bit map */
185 if(!(ASN1_tag2bit(otag) & it->utype)) {
186 /* If OPTIONAL, assume this is OK */
187 if(opt) return -1;
188 ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ASN1_R_MSTRING_WRONG_TAG);
189 goto err;
190 }
191 return asn1_d2i_ex_primitive(pval, in, len, it, otag, 0, 0, ctx);
192
193 case ASN1_ITYPE_EXTERN:
194 /* Use new style d2i */
195 ef = it->funcs;
196 return ef->asn1_ex_d2i(pval, in, len, it, tag, aclass, opt, ctx);
197
198 case ASN1_ITYPE_COMPAT:
199 /* we must resort to old style evil hackery */
200 cf = it->funcs;
201
202 /* If OPTIONAL see if it is there */
203 if(opt) {
204 int exptag;
205 p = *in;
206 if(tag == -1) exptag = it->utype;
207 else exptag = tag;
208 /* Don't care about anything other than presence of expected tag */
209 ret = asn1_check_tlen(NULL, NULL, NULL, NULL, NULL, &p, len, exptag, aclass, 1, ctx);
210 if(!ret) {
211 ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ERR_R_NESTED_ASN1_ERROR);
212 goto err;
213 }
214 if(ret == -1) return -1;
215 }
216 /* This is the old style evil hack IMPLICIT handling:
217 * since the underlying code is expecting a tag and
218 * class other than the one present we change the
219 * buffer temporarily then change it back afterwards.
220 * This doesn't and never did work for tags > 30.
221 *
222 * Yes this is *horrible* but it is only needed for
223 * old style d2i which will hopefully not be around
224 * for much longer.
225 * FIXME: should copy the buffer then modify it so
226 * the input buffer can be const: we should *always*
227 * copy because the old style d2i might modify the
228 * buffer.
229 */
230
231 if(tag != -1) {
232 p = *in;
233 imphack = *p;
234 *p = (unsigned char)((*p & V_ASN1_CONSTRUCTED) | it->utype);
235 }
236
237 ptmpval = cf->asn1_d2i(pval, in, len);
238
239 if(tag != -1) *p = imphack;
240
241 if(ptmpval) return 1;
242 ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ERR_R_NESTED_ASN1_ERROR);
243 goto err;
244
245
246 case ASN1_ITYPE_CHOICE:
247 if(asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it))
248 goto auxerr;
249
250 /* Allocate structure */
251 if(!*pval) {
252 if(!ASN1_item_ex_new(pval, it)) {
253 ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ERR_R_NESTED_ASN1_ERROR);
254 goto err;
255 }
256 }
257 /* CHOICE type, try each possibility in turn */
258 pchval = NULL;
259 p = *in;
260 for(i = 0, tt=it->templates; i < it->tcount; i++, tt++) {
261 pchptr = asn1_get_field_ptr(pval, tt);
262 /* We mark field as OPTIONAL so its absence
263 * can be recognised.
264 */
265 ret = asn1_template_ex_d2i(pchptr, &p, len, tt, 1, ctx);
266 /* If field not present, try the next one */
267 if(ret == -1) continue;
268 /* If positive return, read OK, break loop */
269 if(ret > 0) break;
270 /* Otherwise must be an ASN1 parsing error */
271 errtt = tt;
272 ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ERR_R_NESTED_ASN1_ERROR);
273 goto err;
274 }
275 /* Did we fall off the end without reading anything? */
276 if(i == it->tcount) {
277 /* If OPTIONAL, this is OK */
278 if(opt) {
279 /* Free and zero it */
280 ASN1_item_ex_free(pval, it);
281 return -1;
282 }
283 ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ASN1_R_NO_MATCHING_CHOICE_TYPE);
284 goto err;
285 }
286 asn1_set_choice_selector(pval, i, it);
287 *in = p;
288 if(asn1_cb && !asn1_cb(ASN1_OP_D2I_POST, pval, it))
289 goto auxerr;
290 return 1;
291
292 case ASN1_ITYPE_SEQUENCE:
293 p = *in;
294 tmplen = len;
295
296 /* If no IMPLICIT tagging set to SEQUENCE, UNIVERSAL */
297 if(tag == -1) {
298 tag = V_ASN1_SEQUENCE;
299 aclass = V_ASN1_UNIVERSAL;
300 }
301 /* Get SEQUENCE length and update len, p */
302 ret = asn1_check_tlen(&len, NULL, NULL, &seq_eoc, &cst, &p, len, tag, aclass, opt, ctx);
303 if(!ret) {
304 ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ERR_R_NESTED_ASN1_ERROR);
305 goto err;
306 } else if(ret == -1) return -1;
307 if(aux && (aux->flags & ASN1_AFLG_BROKEN)) {
308 len = tmplen - (p - *in);
309 seq_nolen = 1;
310 } else seq_nolen = seq_eoc; /* If indefinite we don't do a length check */
311 if(!cst) {
312 ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ASN1_R_SEQUENCE_NOT_CONSTRUCTED);
313 goto err;
314 }
315
316 if(!*pval) {
317 if(!ASN1_item_ex_new(pval, it)) {
318 ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ERR_R_NESTED_ASN1_ERROR);
319 goto err;
320 }
321 }
322 if(asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it))
323 goto auxerr;
324
325 /* Get each field entry */
326 for(i = 0, tt = it->templates; i < it->tcount; i++, tt++) {
327 const ASN1_TEMPLATE *seqtt;
328 ASN1_VALUE **pseqval;
329 seqtt = asn1_do_adb(pval, tt, 1);
330 if(!seqtt) goto err;
331 pseqval = asn1_get_field_ptr(pval, seqtt);
332 /* Have we ran out of data? */
333 if(!len) break;
334 q = p;
335 if(asn1_check_eoc(&p, len)) {
336 if(!seq_eoc) {
337 ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ASN1_R_UNEXPECTED_EOC);
338 goto err;
339 }
340 len -= p - q;
341 seq_eoc = 0;
342 q = p;
343 break;
344 }
345 /* This determines the OPTIONAL flag value. The field cannot
346 * be omitted if it is the last of a SEQUENCE and there is
347 * still data to be read. This isn't strictly necessary but
348 * it increases efficiency in some cases.
349 */
350 if(i == (it->tcount - 1)) isopt = 0;
351 else isopt = (char)(seqtt->flags & ASN1_TFLG_OPTIONAL);
352 /* attempt to read in field, allowing each to be OPTIONAL */
353 ret = asn1_template_ex_d2i(pseqval, &p, len, seqtt, isopt, ctx);
354 if(!ret) {
355 errtt = seqtt;
356 goto err;
357 } else if(ret == -1) {
358 /* OPTIONAL component absent. Free and zero the field
359 */
360 ASN1_template_free(pseqval, seqtt);
361 continue;
362 }
363 /* Update length */
364 len -= p - q;
365 }
366 /* Check for EOC if expecting one */
367 if(seq_eoc && !asn1_check_eoc(&p, len)) {
368 ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ASN1_R_MISSING_EOC);
369 goto err;
370 }
371 /* Check all data read */
372 if(!seq_nolen && len) {
373 ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ASN1_R_SEQUENCE_LENGTH_MISMATCH);
374 goto err;
375 }
376
377 /* If we get here we've got no more data in the SEQUENCE,
378 * however we may not have read all fields so check all
379 * remaining are OPTIONAL and clear any that are.
380 */
381 for(; i < it->tcount; tt++, i++) {
382 const ASN1_TEMPLATE *seqtt;
383 seqtt = asn1_do_adb(pval, tt, 1);
384 if(!seqtt) goto err;
385 if(seqtt->flags & ASN1_TFLG_OPTIONAL) {
386 ASN1_VALUE **pseqval;
387 pseqval = asn1_get_field_ptr(pval, seqtt);
388 ASN1_template_free(pseqval, seqtt);
389 } else {
390 errtt = seqtt;
391 ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ASN1_R_FIELD_MISSING);
392 goto err;
393 }
394 }
395 /* Save encoding */
396 if(!asn1_enc_save(pval, *in, p - *in, it)) goto auxerr;
397 *in = p;
398 if(asn1_cb && !asn1_cb(ASN1_OP_D2I_POST, pval, it))
399 goto auxerr;
400 return 1;
401
402 default:
403 return 0;
404 }
405 auxerr:
406 ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ASN1_R_AUX_ERROR);
407 err:
408 ASN1_item_ex_free(pval, it);
409 if(errtt) ERR_add_error_data(4, "Field=", errtt->field_name, ", Type=", it->sname);
410 else ERR_add_error_data(2, "Type=", it->sname);
411 return 0;
412}
413
414/* Templates are handled with two separate functions. One handles any EXPLICIT tag and the other handles the
415 * rest.
416 */
417
418static int asn1_template_ex_d2i(ASN1_VALUE **val, unsigned char **in, long inlen, const ASN1_TEMPLATE *tt, char opt, ASN1_TLC *ctx)
419{
420 int flags, aclass;
421 int ret;
422 long len;
423 unsigned char *p, *q;
424 char exp_eoc;
425 if(!val) return 0;
426 flags = tt->flags;
427 aclass = flags & ASN1_TFLG_TAG_CLASS;
428
429 p = *in;
430
431 /* Check if EXPLICIT tag expected */
432 if(flags & ASN1_TFLG_EXPTAG) {
433 char cst;
434 /* Need to work out amount of data available to the inner content and where it
435 * starts: so read in EXPLICIT header to get the info.
436 */
437 ret = asn1_check_tlen(&len, NULL, NULL, &exp_eoc, &cst, &p, inlen, tt->tag, aclass, opt, ctx);
438 q = p;
439 if(!ret) {
440 ASN1err(ASN1_F_ASN1_TEMPLATE_EX_D2I, ERR_R_NESTED_ASN1_ERROR);
441 return 0;
442 } else if(ret == -1) return -1;
443 if(!cst) {
444 ASN1err(ASN1_F_ASN1_TEMPLATE_EX_D2I, ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED);
445 return 0;
446 }
447 /* We've found the field so it can't be OPTIONAL now */
448 ret = asn1_template_noexp_d2i(val, &p, len, tt, 0, ctx);
449 if(!ret) {
450 ASN1err(ASN1_F_ASN1_TEMPLATE_EX_D2I, ERR_R_NESTED_ASN1_ERROR);
451 return 0;
452 }
453 /* We read the field in OK so update length */
454 len -= p - q;
455 if(exp_eoc) {
456 /* If NDEF we must have an EOC here */
457 if(!asn1_check_eoc(&p, len)) {
458 ASN1err(ASN1_F_ASN1_TEMPLATE_D2I, ASN1_R_MISSING_EOC);
459 goto err;
460 }
461 } else {
462 /* Otherwise we must hit the EXPLICIT tag end or its an error */
463 if(len) {
464 ASN1err(ASN1_F_ASN1_TEMPLATE_D2I, ASN1_R_EXPLICIT_LENGTH_MISMATCH);
465 goto err;
466 }
467 }
468 } else
469 return asn1_template_noexp_d2i(val, in, inlen, tt, opt, ctx);
470
471 *in = p;
472 return 1;
473
474 err:
475 ASN1_template_free(val, tt);
476 *val = NULL;
477 return 0;
478}
479
480static int asn1_template_noexp_d2i(ASN1_VALUE **val, unsigned char **in, long len, const ASN1_TEMPLATE *tt, char opt, ASN1_TLC *ctx)
481{
482 int flags, aclass;
483 int ret;
484 unsigned char *p, *q;
485 if(!val) return 0;
486 flags = tt->flags;
487 aclass = flags & ASN1_TFLG_TAG_CLASS;
488
489 p = *in;
490 q = p;
491
492 if(flags & ASN1_TFLG_SK_MASK) {
493 /* SET OF, SEQUENCE OF */
494 int sktag, skaclass;
495 char sk_eoc;
496 /* First work out expected inner tag value */
497 if(flags & ASN1_TFLG_IMPTAG) {
498 sktag = tt->tag;
499 skaclass = aclass;
500 } else {
501 skaclass = V_ASN1_UNIVERSAL;
502 if(flags & ASN1_TFLG_SET_OF) sktag = V_ASN1_SET;
503 else sktag = V_ASN1_SEQUENCE;
504 }
505 /* Get the tag */
506 ret = asn1_check_tlen(&len, NULL, NULL, &sk_eoc, NULL, &p, len, sktag, skaclass, opt, ctx);
507 if(!ret) {
508 ASN1err(ASN1_F_ASN1_TEMPLATE_EX_D2I, ERR_R_NESTED_ASN1_ERROR);
509 return 0;
510 } else if(ret == -1) return -1;
511 if(!*val) *val = (ASN1_VALUE *)sk_new_null();
512 else {
513 /* We've got a valid STACK: free up any items present */
514 STACK *sktmp = (STACK *)*val;
515 ASN1_VALUE *vtmp;
516 while(sk_num(sktmp) > 0) {
517 vtmp = (ASN1_VALUE *)sk_pop(sktmp);
518 ASN1_item_ex_free(&vtmp, ASN1_ITEM_ptr(tt->item));
519 }
520 }
521
522 if(!*val) {
523 ASN1err(ASN1_F_ASN1_TEMPLATE_EX_D2I, ERR_R_MALLOC_FAILURE);
524 goto err;
525 }
526 /* Read as many items as we can */
527 while(len > 0) {
528 ASN1_VALUE *skfield;
529 q = p;
530 /* See if EOC found */
531 if(asn1_check_eoc(&p, len)) {
532 if(!sk_eoc) {
533 ASN1err(ASN1_F_ASN1_TEMPLATE_D2I, ASN1_R_UNEXPECTED_EOC);
534 goto err;
535 }
536 len -= p - q;
537 sk_eoc = 0;
538 break;
539 }
540 skfield = NULL;
541 if(!ASN1_item_ex_d2i(&skfield, &p, len, ASN1_ITEM_ptr(tt->item), -1, 0, 0, ctx)) {
542 ASN1err(ASN1_F_ASN1_TEMPLATE_D2I, ERR_R_NESTED_ASN1_ERROR);
543 goto err;
544 }
545 len -= p - q;
546 if(!sk_push((STACK *)*val, (char *)skfield)) {
547 ASN1err(ASN1_F_ASN1_TEMPLATE_D2I, ERR_R_MALLOC_FAILURE);
548 goto err;
549 }
550 }
551 if(sk_eoc) {
552 ASN1err(ASN1_F_ASN1_TEMPLATE_D2I, ASN1_R_MISSING_EOC);
553 goto err;
554 }
555 } else if(flags & ASN1_TFLG_IMPTAG) {
556 /* IMPLICIT tagging */
557 ret = ASN1_item_ex_d2i(val, &p, len, ASN1_ITEM_ptr(tt->item), tt->tag, aclass, opt, ctx);
558 if(!ret) {
559 ASN1err(ASN1_F_ASN1_TEMPLATE_D2I, ERR_R_NESTED_ASN1_ERROR);
560 goto err;
561 } else if(ret == -1) return -1;
562 } else {
563 /* Nothing special */
564 ret = ASN1_item_ex_d2i(val, &p, len, ASN1_ITEM_ptr(tt->item), -1, 0, opt, ctx);
565 if(!ret) {
566 ASN1err(ASN1_F_ASN1_TEMPLATE_D2I, ERR_R_NESTED_ASN1_ERROR);
567 goto err;
568 } else if(ret == -1) return -1;
569 }
570
571 *in = p;
572 return 1;
573
574 err:
575 ASN1_template_free(val, tt);
576 *val = NULL;
577 return 0;
578}
579
580static int asn1_d2i_ex_primitive(ASN1_VALUE **pval, unsigned char **in, long inlen,
581 const ASN1_ITEM *it,
582 int tag, int aclass, char opt, ASN1_TLC *ctx)
583{
584 int ret = 0, utype;
585 long plen;
586 char cst, inf, free_cont = 0;
587 unsigned char *p;
588 BUF_MEM buf;
589 unsigned char *cont = NULL;
590 long len;
591 if(!pval) {
592 ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ASN1_R_ILLEGAL_NULL);
593 return 0; /* Should never happen */
594 }
595
596 if(it->itype == ASN1_ITYPE_MSTRING) {
597 utype = tag;
598 tag = -1;
599 } else utype = it->utype;
600
601 if(utype == V_ASN1_ANY) {
602 /* If type is ANY need to figure out type from tag */
603 unsigned char oclass;
604 if(tag >= 0) {
605 ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ASN1_R_ILLEGAL_TAGGED_ANY);
606 return 0;
607 }
608 if(opt) {
609 ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ASN1_R_ILLEGAL_OPTIONAL_ANY);
610 return 0;
611 }
612 p = *in;
613 ret = asn1_check_tlen(NULL, &utype, &oclass, NULL, NULL, &p, inlen, -1, 0, 0, ctx);
614 if(!ret) {
615 ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ERR_R_NESTED_ASN1_ERROR);
616 return 0;
617 }
618 if(oclass != V_ASN1_UNIVERSAL) utype = V_ASN1_OTHER;
619 }
620 if(tag == -1) {
621 tag = utype;
622 aclass = V_ASN1_UNIVERSAL;
623 }
624 p = *in;
625 /* Check header */
626 ret = asn1_check_tlen(&plen, NULL, NULL, &inf, &cst, &p, inlen, tag, aclass, opt, ctx);
627 if(!ret) {
628 ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ERR_R_NESTED_ASN1_ERROR);
629 return 0;
630 } else if(ret == -1) return -1;
631 /* SEQUENCE, SET and "OTHER" are left in encoded form */
632 if((utype == V_ASN1_SEQUENCE) || (utype == V_ASN1_SET) || (utype == V_ASN1_OTHER)) {
633 /* Clear context cache for type OTHER because the auto clear when
634 * we have a exact match wont work
635 */
636 if(utype == V_ASN1_OTHER) {
637 asn1_tlc_clear(ctx);
638 /* SEQUENCE and SET must be constructed */
639 } else if(!cst) {
640 ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ASN1_R_TYPE_NOT_CONSTRUCTED);
641 return 0;
642 }
643
644 cont = *in;
645 /* If indefinite length constructed find the real end */
646 if(inf) {
647 if(!asn1_collect(NULL, &p, plen, inf, -1, -1)) goto err;
648 len = p - cont;
649 } else {
650 len = p - cont + plen;
651 p += plen;
652 buf.data = NULL;
653 }
654 } else if(cst) {
655 buf.length = 0;
656 buf.max = 0;
657 buf.data = NULL;
658 /* Should really check the internal tags are correct but
659 * some things may get this wrong. The relevant specs
660 * say that constructed string types should be OCTET STRINGs
661 * internally irrespective of the type. So instead just check
662 * for UNIVERSAL class and ignore the tag.
663 */
664 if(!asn1_collect(&buf, &p, plen, inf, -1, V_ASN1_UNIVERSAL)) goto err;
665 len = buf.length;
666 /* Append a final null to string */
667 if(!BUF_MEM_grow(&buf, len + 1)) {
668 ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ERR_R_MALLOC_FAILURE);
669 return 0;
670 }
671 buf.data[len] = 0;
672 cont = (unsigned char *)buf.data;
673 free_cont = 1;
674 } else {
675 cont = p;
676 len = plen;
677 p += plen;
678 }
679
680 /* We now have content length and type: translate into a structure */
681 if(!asn1_ex_c2i(pval, cont, len, utype, &free_cont, it)) goto err;
682
683 *in = p;
684 ret = 1;
685 err:
686 if(free_cont && buf.data) OPENSSL_free(buf.data);
687 return ret;
688}
689
690/* Translate ASN1 content octets into a structure */
691
692int asn1_ex_c2i(ASN1_VALUE **pval, unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it)
693{
694 ASN1_STRING *stmp;
695 ASN1_TYPE *typ = NULL;
696 int ret = 0;
697 const ASN1_PRIMITIVE_FUNCS *pf;
698 ASN1_INTEGER **tint;
699 pf = it->funcs;
700 if(pf && pf->prim_c2i) return pf->prim_c2i(pval, cont, len, utype, free_cont, it);
701 /* If ANY type clear type and set pointer to internal value */
702 if(it->utype == V_ASN1_ANY) {
703 if(!*pval) {
704 typ = ASN1_TYPE_new();
705 *pval = (ASN1_VALUE *)typ;
706 } else typ = (ASN1_TYPE *)*pval;
707 if(utype != typ->type) ASN1_TYPE_set(typ, utype, NULL);
708 pval = (ASN1_VALUE **)&typ->value.ptr;
709 }
710 switch(utype) {
711 case V_ASN1_OBJECT:
712 if(!c2i_ASN1_OBJECT((ASN1_OBJECT **)pval, &cont, len)) goto err;
713 break;
714
715 case V_ASN1_NULL:
716 if(len) {
717 ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ASN1_R_NULL_IS_WRONG_LENGTH);
718 goto err;
719 }
720 *pval = (ASN1_VALUE *)1;
721 break;
722
723 case V_ASN1_BOOLEAN:
724 if(len != 1) {
725 ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ASN1_R_BOOLEAN_IS_WRONG_LENGTH);
726 goto err;
727 } else {
728 ASN1_BOOLEAN *tbool;
729 tbool = (ASN1_BOOLEAN *)pval;
730 *tbool = *cont;
731 }
732 break;
733
734 case V_ASN1_BIT_STRING:
735 if(!c2i_ASN1_BIT_STRING((ASN1_BIT_STRING **)pval, &cont, len)) goto err;
736 break;
737
738 case V_ASN1_INTEGER:
739 case V_ASN1_NEG_INTEGER:
740 case V_ASN1_ENUMERATED:
741 case V_ASN1_NEG_ENUMERATED:
742 tint = (ASN1_INTEGER **)pval;
743 if(!c2i_ASN1_INTEGER(tint, &cont, len)) goto err;
744 /* Fixup type to match the expected form */
745 (*tint)->type = utype | ((*tint)->type & V_ASN1_NEG);
746 break;
747
748 case V_ASN1_OCTET_STRING:
749 case V_ASN1_NUMERICSTRING:
750 case V_ASN1_PRINTABLESTRING:
751 case V_ASN1_T61STRING:
752 case V_ASN1_VIDEOTEXSTRING:
753 case V_ASN1_IA5STRING:
754 case V_ASN1_UTCTIME:
755 case V_ASN1_GENERALIZEDTIME:
756 case V_ASN1_GRAPHICSTRING:
757 case V_ASN1_VISIBLESTRING:
758 case V_ASN1_GENERALSTRING:
759 case V_ASN1_UNIVERSALSTRING:
760 case V_ASN1_BMPSTRING:
761 case V_ASN1_UTF8STRING:
762 case V_ASN1_OTHER:
763 case V_ASN1_SET:
764 case V_ASN1_SEQUENCE:
765 default:
766 /* All based on ASN1_STRING and handled the same */
767 if(!*pval) {
768 stmp = ASN1_STRING_type_new(utype);
769 if(!stmp) {
770 ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ERR_R_MALLOC_FAILURE);
771 goto err;
772 }
773 *pval = (ASN1_VALUE *)stmp;
774 } else {
775 stmp = (ASN1_STRING *)*pval;
776 stmp->type = utype;
777 }
778 /* If we've already allocated a buffer use it */
779 if(*free_cont) {
780 if(stmp->data) OPENSSL_free(stmp->data);
781 stmp->data = cont;
782 stmp->length = len;
783 *free_cont = 0;
784 } else {
785 if(!ASN1_STRING_set(stmp, cont, len)) {
786 ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ERR_R_MALLOC_FAILURE);
787 ASN1_STRING_free(stmp);
788 *pval = NULL;
789 goto err;
790 }
791 }
792 break;
793 }
794 /* If ASN1_ANY and NULL type fix up value */
795 if(typ && utype==V_ASN1_NULL) typ->value.ptr = NULL;
796
797 ret = 1;
798 err:
799 if(!ret) ASN1_TYPE_free(typ);
800 return ret;
801}
802
803/* This function collects the asn1 data from a constructred string
804 * type into a buffer. The values of 'in' and 'len' should refer
805 * to the contents of the constructed type and 'inf' should be set
806 * if it is indefinite length. If 'buf' is NULL then we just want
807 * to find the end of the current structure: useful for indefinite
808 * length constructed stuff.
809 */
810
811static int asn1_collect(BUF_MEM *buf, unsigned char **in, long len, char inf, int tag, int aclass)
812{
813 unsigned char *p, *q;
814 long plen;
815 char cst, ininf;
816 p = *in;
817 inf &= 1;
818 /* If no buffer and not indefinite length constructed just pass over the encoded data */
819 if(!buf && !inf) {
820 *in += len;
821 return 1;
822 }
823 while(len > 0) {
824 q = p;
825 /* Check for EOC */
826 if(asn1_check_eoc(&p, len)) {
827 /* EOC is illegal outside indefinite length constructed form */
828 if(!inf) {
829 ASN1err(ASN1_F_ASN1_COLLECT, ASN1_R_UNEXPECTED_EOC);
830 return 0;
831 }
832 inf = 0;
833 break;
834 }
835 if(!asn1_check_tlen(&plen, NULL, NULL, &ininf, &cst, &p, len, tag, aclass, 0, NULL)) {
836 ASN1err(ASN1_F_ASN1_COLLECT, ERR_R_NESTED_ASN1_ERROR);
837 return 0;
838 }
839 /* If indefinite length constructed update max length */
840 if(cst) {
841 if(!asn1_collect(buf, &p, plen, ininf, tag, aclass)) return 0;
842 } else {
843 if(!collect_data(buf, &p, plen)) return 0;
844 }
845 len -= p - q;
846 }
847 if(inf) {
848 ASN1err(ASN1_F_ASN1_COLLECT, ASN1_R_MISSING_EOC);
849 return 0;
850 }
851 *in = p;
852 return 1;
853}
854
855static int collect_data(BUF_MEM *buf, unsigned char **p, long plen)
856{
857 int len;
858 if(buf) {
859 len = buf->length;
860 if(!BUF_MEM_grow(buf, len + plen)) {
861 ASN1err(ASN1_F_COLLECT_DATA, ERR_R_MALLOC_FAILURE);
862 return 0;
863 }
864 memcpy(buf->data + len, *p, plen);
865 }
866 *p += plen;
867 return 1;
868}
869
870/* Check for ASN1 EOC and swallow it if found */
871
872static int asn1_check_eoc(unsigned char **in, long len)
873{
874 unsigned char *p;
875 if(len < 2) return 0;
876 p = *in;
877 if(!p[0] && !p[1]) {
878 *in += 2;
879 return 1;
880 }
881 return 0;
882}
883
884/* Check an ASN1 tag and length: a bit like ASN1_get_object
885 * but it sets the length for indefinite length constructed
886 * form, we don't know the exact length but we can set an
887 * upper bound to the amount of data available minus the
888 * header length just read.
889 */
890
891static int asn1_check_tlen(long *olen, int *otag, unsigned char *oclass, char *inf, char *cst,
892 unsigned char **in, long len, int exptag, int expclass, char opt, ASN1_TLC *ctx)
893{
894 int i;
895 int ptag, pclass;
896 long plen;
897 unsigned char *p, *q;
898 p = *in;
899 q = p;
900
901 if(ctx && ctx->valid) {
902 i = ctx->ret;
903 plen = ctx->plen;
904 pclass = ctx->pclass;
905 ptag = ctx->ptag;
906 p += ctx->hdrlen;
907 } else {
908 i = ASN1_get_object(&p, &plen, &ptag, &pclass, len);
909 if(ctx) {
910 ctx->ret = i;
911 ctx->plen = plen;
912 ctx->pclass = pclass;
913 ctx->ptag = ptag;
914 ctx->hdrlen = p - q;
915 ctx->valid = 1;
916 /* If definite length, length + header can't exceed total
917 * amount of data available.
918 */
919 if(!(i & 1) && ((plen + ctx->hdrlen) > len)) {
920 ASN1err(ASN1_F_ASN1_CHECK_TLEN, ASN1_R_TOO_LONG);
921 asn1_tlc_clear(ctx);
922 return 0;
923 }
924 }
925 }
926
927 if(i & 0x80) {
928 ASN1err(ASN1_F_ASN1_CHECK_TLEN, ASN1_R_BAD_OBJECT_HEADER);
929 asn1_tlc_clear(ctx);
930 return 0;
931 }
932 if(exptag >= 0) {
933 if((exptag != ptag) || (expclass != pclass)) {
934 /* If type is OPTIONAL, not an error, but indicate missing
935 * type.
936 */
937 if(opt) return -1;
938 asn1_tlc_clear(ctx);
939 ASN1err(ASN1_F_ASN1_CHECK_TLEN, ASN1_R_WRONG_TAG);
940 return 0;
941 }
942 /* We have a tag and class match, so assume we are going to do something with it */
943 asn1_tlc_clear(ctx);
944 }
945
946 if(i & 1) plen = len - (p - q);
947
948 if(inf) *inf = i & 1;
949
950 if(cst) *cst = i & V_ASN1_CONSTRUCTED;
951
952 if(olen) *olen = plen;
953 if(oclass) *oclass = pclass;
954 if(otag) *otag = ptag;
955
956 *in = p;
957 return 1;
958}
diff --git a/src/lib/libcrypto/asn1/tasn_enc.c b/src/lib/libcrypto/asn1/tasn_enc.c
new file mode 100644
index 0000000000..f6c8ddef0a
--- /dev/null
+++ b/src/lib/libcrypto/asn1/tasn_enc.c
@@ -0,0 +1,497 @@
1/* tasn_enc.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) 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
60#include <stddef.h>
61#include <string.h>
62#include <openssl/asn1.h>
63#include <openssl/asn1t.h>
64#include <openssl/objects.h>
65
66static int asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass);
67static int asn1_set_seq_out(STACK_OF(ASN1_VALUE) *seq, unsigned char **out, int skcontlen, const ASN1_ITEM *item, int isset);
68
69/* Encode an ASN1 item, this is compatible with the
70 * standard 'i2d' function. 'out' points to
71 * a buffer to output the data to, in future we will
72 * have more advanced versions that can output data
73 * a piece at a time and this will simply be a special
74 * case.
75 *
76 * The new i2d has one additional feature. If the output
77 * buffer is NULL (i.e. *out == NULL) then a buffer is
78 * allocated and populated with the encoding.
79 */
80
81
82int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it)
83{
84 if(out && !*out) {
85 unsigned char *p, *buf;
86 int len;
87 len = ASN1_item_ex_i2d(&val, NULL, it, -1, 0);
88 if(len <= 0) return len;
89 buf = OPENSSL_malloc(len);
90 if(!buf) return -1;
91 p = buf;
92 ASN1_item_ex_i2d(&val, &p, it, -1, 0);
93 *out = buf;
94 return len;
95 }
96
97 return ASN1_item_ex_i2d(&val, out, it, -1, 0);
98}
99
100/* Encode an item, taking care of IMPLICIT tagging (if any).
101 * This function performs the normal item handling: it can be
102 * used in external types.
103 */
104
105int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass)
106{
107 const ASN1_TEMPLATE *tt = NULL;
108 unsigned char *p = NULL;
109 int i, seqcontlen, seqlen;
110 ASN1_STRING *strtmp;
111 const ASN1_COMPAT_FUNCS *cf;
112 const ASN1_EXTERN_FUNCS *ef;
113 const ASN1_AUX *aux = it->funcs;
114 ASN1_aux_cb *asn1_cb;
115 if((it->itype != ASN1_ITYPE_PRIMITIVE) && !*pval) return 0;
116 if(aux && aux->asn1_cb) asn1_cb = aux->asn1_cb;
117 else asn1_cb = 0;
118
119 switch(it->itype) {
120
121 case ASN1_ITYPE_PRIMITIVE:
122 if(it->templates)
123 return ASN1_template_i2d(pval, out, it->templates);
124 return asn1_i2d_ex_primitive(pval, out, it, tag, aclass);
125 break;
126
127 case ASN1_ITYPE_MSTRING:
128 strtmp = (ASN1_STRING *)*pval;
129 return asn1_i2d_ex_primitive(pval, out, it, -1, 0);
130
131 case ASN1_ITYPE_CHOICE:
132 if(asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it))
133 return 0;
134 i = asn1_get_choice_selector(pval, it);
135 if((i >= 0) && (i < it->tcount)) {
136 ASN1_VALUE **pchval;
137 const ASN1_TEMPLATE *chtt;
138 chtt = it->templates + i;
139 pchval = asn1_get_field_ptr(pval, chtt);
140 return ASN1_template_i2d(pchval, out, chtt);
141 }
142 /* Fixme: error condition if selector out of range */
143 if(asn1_cb && !asn1_cb(ASN1_OP_I2D_POST, pval, it))
144 return 0;
145 break;
146
147 case ASN1_ITYPE_EXTERN:
148 /* If new style i2d it does all the work */
149 ef = it->funcs;
150 return ef->asn1_ex_i2d(pval, out, it, tag, aclass);
151
152 case ASN1_ITYPE_COMPAT:
153 /* old style hackery... */
154 cf = it->funcs;
155 if(out) p = *out;
156 i = cf->asn1_i2d(*pval, out);
157 /* Fixup for IMPLICIT tag: note this messes up for tags > 30,
158 * but so did the old code. Tags > 30 are very rare anyway.
159 */
160 if(out && (tag != -1))
161 *p = aclass | tag | (*p & V_ASN1_CONSTRUCTED);
162 return i;
163
164 case ASN1_ITYPE_SEQUENCE:
165 i = asn1_enc_restore(&seqcontlen, out, pval, it);
166 /* An error occurred */
167 if(i < 0) return 0;
168 /* We have a valid cached encoding... */
169 if(i > 0) return seqcontlen;
170 /* Otherwise carry on */
171 seqcontlen = 0;
172 /* If no IMPLICIT tagging set to SEQUENCE, UNIVERSAL */
173 if(tag == -1) {
174 tag = V_ASN1_SEQUENCE;
175 aclass = V_ASN1_UNIVERSAL;
176 }
177 if(asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it))
178 return 0;
179 /* First work out sequence content length */
180 for(i = 0, tt = it->templates; i < it->tcount; tt++, i++) {
181 const ASN1_TEMPLATE *seqtt;
182 ASN1_VALUE **pseqval;
183 seqtt = asn1_do_adb(pval, tt, 1);
184 if(!seqtt) return 0;
185 pseqval = asn1_get_field_ptr(pval, seqtt);
186 /* FIXME: check for errors in enhanced version */
187 /* FIXME: special handling of indefinite length encoding */
188 seqcontlen += ASN1_template_i2d(pseqval, NULL, seqtt);
189 }
190 seqlen = ASN1_object_size(1, seqcontlen, tag);
191 if(!out) return seqlen;
192 /* Output SEQUENCE header */
193 ASN1_put_object(out, 1, seqcontlen, tag, aclass);
194 for(i = 0, tt = it->templates; i < it->tcount; tt++, i++) {
195 const ASN1_TEMPLATE *seqtt;
196 ASN1_VALUE **pseqval;
197 seqtt = asn1_do_adb(pval, tt, 1);
198 if(!seqtt) return 0;
199 pseqval = asn1_get_field_ptr(pval, seqtt);
200 /* FIXME: check for errors in enhanced version */
201 ASN1_template_i2d(pseqval, out, seqtt);
202 }
203 if(asn1_cb && !asn1_cb(ASN1_OP_I2D_POST, pval, it))
204 return 0;
205 return seqlen;
206
207 default:
208 return 0;
209 }
210 return 0;
211}
212
213int ASN1_template_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_TEMPLATE *tt)
214{
215 int i, ret, flags, aclass;
216 flags = tt->flags;
217 aclass = flags & ASN1_TFLG_TAG_CLASS;
218 if(flags & ASN1_TFLG_SK_MASK) {
219 /* SET OF, SEQUENCE OF */
220 STACK_OF(ASN1_VALUE) *sk = (STACK_OF(ASN1_VALUE) *)*pval;
221 int isset, sktag, skaclass;
222 int skcontlen, sklen;
223 ASN1_VALUE *skitem;
224 if(!*pval) return 0;
225 if(flags & ASN1_TFLG_SET_OF) {
226 isset = 1;
227 /* 2 means we reorder */
228 if(flags & ASN1_TFLG_SEQUENCE_OF) isset = 2;
229 } else isset = 0;
230 /* First work out inner tag value */
231 if(flags & ASN1_TFLG_IMPTAG) {
232 sktag = tt->tag;
233 skaclass = aclass;
234 } else {
235 skaclass = V_ASN1_UNIVERSAL;
236 if(isset) sktag = V_ASN1_SET;
237 else sktag = V_ASN1_SEQUENCE;
238 }
239 /* Now work out length of items */
240 skcontlen = 0;
241 for(i = 0; i < sk_ASN1_VALUE_num(sk); i++) {
242 skitem = sk_ASN1_VALUE_value(sk, i);
243 skcontlen += ASN1_item_ex_i2d(&skitem, NULL, ASN1_ITEM_ptr(tt->item), -1, 0);
244 }
245 sklen = ASN1_object_size(1, skcontlen, sktag);
246 /* If EXPLICIT need length of surrounding tag */
247 if(flags & ASN1_TFLG_EXPTAG)
248 ret = ASN1_object_size(1, sklen, tt->tag);
249 else ret = sklen;
250
251 if(!out) return ret;
252
253 /* Now encode this lot... */
254 /* EXPLICIT tag */
255 if(flags & ASN1_TFLG_EXPTAG)
256 ASN1_put_object(out, 1, sklen, tt->tag, aclass);
257 /* SET or SEQUENCE and IMPLICIT tag */
258 ASN1_put_object(out, 1, skcontlen, sktag, skaclass);
259 /* And finally the stuff itself */
260 asn1_set_seq_out(sk, out, skcontlen, ASN1_ITEM_ptr(tt->item), isset);
261
262 return ret;
263 }
264
265 if(flags & ASN1_TFLG_EXPTAG) {
266 /* EXPLICIT tagging */
267 /* Find length of tagged item */
268 i = ASN1_item_ex_i2d(pval, NULL, ASN1_ITEM_ptr(tt->item), -1, 0);
269 if(!i) return 0;
270 /* Find length of EXPLICIT tag */
271 ret = ASN1_object_size(1, i, tt->tag);
272 if(out) {
273 /* Output tag and item */
274 ASN1_put_object(out, 1, i, tt->tag, aclass);
275 ASN1_item_ex_i2d(pval, out, ASN1_ITEM_ptr(tt->item), -1, 0);
276 }
277 return ret;
278 }
279 if(flags & ASN1_TFLG_IMPTAG) {
280 /* IMPLICIT tagging */
281 return ASN1_item_ex_i2d(pval, out, ASN1_ITEM_ptr(tt->item), tt->tag, aclass);
282 }
283 /* Nothing special: treat as normal */
284 return ASN1_item_ex_i2d(pval, out, ASN1_ITEM_ptr(tt->item), -1, 0);
285}
286
287/* Temporary structure used to hold DER encoding of items for SET OF */
288
289typedef struct {
290 unsigned char *data;
291 int length;
292 ASN1_VALUE *field;
293} DER_ENC;
294
295static int der_cmp(const void *a, const void *b)
296{
297 const DER_ENC *d1 = a, *d2 = b;
298 int cmplen, i;
299 cmplen = (d1->length < d2->length) ? d1->length : d2->length;
300 i = memcmp(d1->data, d2->data, cmplen);
301 if(i) return i;
302 return d1->length - d2->length;
303}
304
305/* Output the content octets of SET OF or SEQUENCE OF */
306
307static int asn1_set_seq_out(STACK_OF(ASN1_VALUE) *sk, unsigned char **out, int skcontlen, const ASN1_ITEM *item, int do_sort)
308{
309 int i;
310 ASN1_VALUE *skitem;
311 unsigned char *tmpdat = NULL, *p = NULL;
312 DER_ENC *derlst = NULL, *tder;
313 if(do_sort) {
314 /* Don't need to sort less than 2 items */
315 if(sk_ASN1_VALUE_num(sk) < 2) do_sort = 0;
316 else {
317 derlst = OPENSSL_malloc(sk_ASN1_VALUE_num(sk) * sizeof(*derlst));
318 tmpdat = OPENSSL_malloc(skcontlen);
319 if(!derlst || !tmpdat) return 0;
320 }
321 }
322 /* If not sorting just output each item */
323 if(!do_sort) {
324 for(i = 0; i < sk_ASN1_VALUE_num(sk); i++) {
325 skitem = sk_ASN1_VALUE_value(sk, i);
326 ASN1_item_i2d(skitem, out, item);
327 }
328 return 1;
329 }
330 p = tmpdat;
331 /* Doing sort: build up a list of each member's DER encoding */
332 for(i = 0, tder = derlst; i < sk_ASN1_VALUE_num(sk); i++, tder++) {
333 skitem = sk_ASN1_VALUE_value(sk, i);
334 tder->data = p;
335 tder->length = ASN1_item_i2d(skitem, &p, item);
336 tder->field = skitem;
337 }
338 /* Now sort them */
339 qsort(derlst, sk_ASN1_VALUE_num(sk), sizeof(*derlst), der_cmp);
340 /* Output sorted DER encoding */
341 p = *out;
342 for(i = 0, tder = derlst; i < sk_ASN1_VALUE_num(sk); i++, tder++) {
343 memcpy(p, tder->data, tder->length);
344 p += tder->length;
345 }
346 *out = p;
347 /* If do_sort is 2 then reorder the STACK */
348 if(do_sort == 2) {
349 for(i = 0, tder = derlst; i < sk_ASN1_VALUE_num(sk); i++, tder++)
350 sk_ASN1_VALUE_set(sk, i, tder->field);
351 }
352 OPENSSL_free(derlst);
353 OPENSSL_free(tmpdat);
354 return 1;
355}
356
357static int asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass)
358{
359 int len;
360 int utype;
361 int usetag;
362
363 utype = it->utype;
364
365 /* Get length of content octets and maybe find
366 * out the underlying type.
367 */
368
369 len = asn1_ex_i2c(pval, NULL, &utype, it);
370
371 /* If SEQUENCE, SET or OTHER then header is
372 * included in pseudo content octets so don't
373 * include tag+length. We need to check here
374 * because the call to asn1_ex_i2c() could change
375 * utype.
376 */
377 if((utype == V_ASN1_SEQUENCE) || (utype == V_ASN1_SET) ||
378 (utype == V_ASN1_OTHER))
379 usetag = 0;
380 else usetag = 1;
381
382 /* -1 means omit type */
383
384 if(len == -1) return 0;
385
386 /* If not implicitly tagged get tag from underlying type */
387 if(tag == -1) tag = utype;
388
389 /* Output tag+length followed by content octets */
390 if(out) {
391 if(usetag) ASN1_put_object(out, 0, len, tag, aclass);
392 asn1_ex_i2c(pval, *out, &utype, it);
393 *out += len;
394 }
395
396 if(usetag) return ASN1_object_size(0, len, tag);
397 return len;
398}
399
400/* Produce content octets from a structure */
401
402int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *putype, const ASN1_ITEM *it)
403{
404 ASN1_BOOLEAN *tbool = NULL;
405 ASN1_STRING *strtmp;
406 ASN1_OBJECT *otmp;
407 int utype;
408 unsigned char *cont, c;
409 int len;
410 const ASN1_PRIMITIVE_FUNCS *pf;
411 pf = it->funcs;
412 if(pf && pf->prim_i2c) return pf->prim_i2c(pval, cout, putype, it);
413
414 /* Should type be omitted? */
415 if((it->itype != ASN1_ITYPE_PRIMITIVE) || (it->utype != V_ASN1_BOOLEAN)) {
416 if(!*pval) return -1;
417 }
418
419 if(it->itype == ASN1_ITYPE_MSTRING) {
420 /* If MSTRING type set the underlying type */
421 strtmp = (ASN1_STRING *)*pval;
422 utype = strtmp->type;
423 *putype = utype;
424 } else if(it->utype == V_ASN1_ANY) {
425 /* If ANY set type and pointer to value */
426 ASN1_TYPE *typ;
427 typ = (ASN1_TYPE *)*pval;
428 utype = typ->type;
429 *putype = utype;
430 pval = (ASN1_VALUE **)&typ->value.ptr;
431 } else utype = *putype;
432
433 switch(utype) {
434 case V_ASN1_OBJECT:
435 otmp = (ASN1_OBJECT *)*pval;
436 cont = otmp->data;
437 len = otmp->length;
438 break;
439
440 case V_ASN1_NULL:
441 cont = NULL;
442 len = 0;
443 break;
444
445 case V_ASN1_BOOLEAN:
446 tbool = (ASN1_BOOLEAN *)pval;
447 if(*tbool == -1) return -1;
448 /* Default handling if value == size field then omit */
449 if(*tbool && (it->size > 0)) return -1;
450 if(!*tbool && !it->size) return -1;
451 c = (unsigned char)*tbool;
452 cont = &c;
453 len = 1;
454 break;
455
456 case V_ASN1_BIT_STRING:
457 return i2c_ASN1_BIT_STRING((ASN1_BIT_STRING *)*pval, cout ? &cout : NULL);
458 break;
459
460 case V_ASN1_INTEGER:
461 case V_ASN1_NEG_INTEGER:
462 case V_ASN1_ENUMERATED:
463 case V_ASN1_NEG_ENUMERATED:
464 /* These are all have the same content format
465 * as ASN1_INTEGER
466 */
467 return i2c_ASN1_INTEGER((ASN1_INTEGER *)*pval, cout ? &cout : NULL);
468 break;
469
470 case V_ASN1_OCTET_STRING:
471 case V_ASN1_NUMERICSTRING:
472 case V_ASN1_PRINTABLESTRING:
473 case V_ASN1_T61STRING:
474 case V_ASN1_VIDEOTEXSTRING:
475 case V_ASN1_IA5STRING:
476 case V_ASN1_UTCTIME:
477 case V_ASN1_GENERALIZEDTIME:
478 case V_ASN1_GRAPHICSTRING:
479 case V_ASN1_VISIBLESTRING:
480 case V_ASN1_GENERALSTRING:
481 case V_ASN1_UNIVERSALSTRING:
482 case V_ASN1_BMPSTRING:
483 case V_ASN1_UTF8STRING:
484 case V_ASN1_SEQUENCE:
485 case V_ASN1_SET:
486 default:
487 /* All based on ASN1_STRING and handled the same */
488 strtmp = (ASN1_STRING *)*pval;
489 cont = strtmp->data;
490 len = strtmp->length;
491
492 break;
493
494 }
495 if(cout && len) memcpy(cout, cont, len);
496 return len;
497}
diff --git a/src/lib/libcrypto/asn1/tasn_fre.c b/src/lib/libcrypto/asn1/tasn_fre.c
new file mode 100644
index 0000000000..c7610776f2
--- /dev/null
+++ b/src/lib/libcrypto/asn1/tasn_fre.c
@@ -0,0 +1,226 @@
1/* tasn_fre.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) 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
60#include <stddef.h>
61#include <openssl/asn1.h>
62#include <openssl/asn1t.h>
63#include <openssl/objects.h>
64
65static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int combine);
66
67/* Free up an ASN1 structure */
68
69void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it)
70{
71 asn1_item_combine_free(&val, it, 0);
72}
73
74void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
75{
76 asn1_item_combine_free(pval, it, 0);
77}
78
79static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int combine)
80{
81 const ASN1_TEMPLATE *tt = NULL, *seqtt;
82 const ASN1_EXTERN_FUNCS *ef;
83 const ASN1_COMPAT_FUNCS *cf;
84 const ASN1_AUX *aux = it->funcs;
85 ASN1_aux_cb *asn1_cb;
86 int i;
87 if(!pval) return;
88 if((it->itype != ASN1_ITYPE_PRIMITIVE) && !*pval) return;
89 if(aux && aux->asn1_cb) asn1_cb = aux->asn1_cb;
90 else asn1_cb = 0;
91
92 switch(it->itype) {
93
94 case ASN1_ITYPE_PRIMITIVE:
95 if(it->templates) ASN1_template_free(pval, it->templates);
96 else ASN1_primitive_free(pval, it);
97 break;
98
99 case ASN1_ITYPE_MSTRING:
100 ASN1_primitive_free(pval, it);
101 break;
102
103 case ASN1_ITYPE_CHOICE:
104 if(asn1_cb) {
105 i = asn1_cb(ASN1_OP_FREE_PRE, pval, it);
106 if(i == 2) return;
107 }
108 i = asn1_get_choice_selector(pval, it);
109 if(asn1_cb) asn1_cb(ASN1_OP_FREE_PRE, pval, it);
110 if((i >= 0) && (i < it->tcount)) {
111 ASN1_VALUE **pchval;
112 tt = it->templates + i;
113 pchval = asn1_get_field_ptr(pval, tt);
114 ASN1_template_free(pchval, tt);
115 }
116 if(asn1_cb) asn1_cb(ASN1_OP_FREE_POST, pval, it);
117 if(!combine) {
118 OPENSSL_free(*pval);
119 *pval = NULL;
120 }
121 break;
122
123 case ASN1_ITYPE_COMPAT:
124 cf = it->funcs;
125 if(cf && cf->asn1_free) cf->asn1_free(*pval);
126 break;
127
128 case ASN1_ITYPE_EXTERN:
129 ef = it->funcs;
130 if(ef && ef->asn1_ex_free) ef->asn1_ex_free(pval, it);
131 break;
132
133 case ASN1_ITYPE_SEQUENCE:
134 if(asn1_do_lock(pval, -1, it) > 0) return;
135 if(asn1_cb) {
136 i = asn1_cb(ASN1_OP_FREE_PRE, pval, it);
137 if(i == 2) return;
138 }
139 asn1_enc_free(pval, it);
140 /* If we free up as normal we will invalidate any
141 * ANY DEFINED BY field and we wont be able to
142 * determine the type of the field it defines. So
143 * free up in reverse order.
144 */
145 tt = it->templates + it->tcount - 1;
146 for(i = 0; i < it->tcount; tt--, i++) {
147 ASN1_VALUE **pseqval;
148 seqtt = asn1_do_adb(pval, tt, 0);
149 if(!seqtt) continue;
150 pseqval = asn1_get_field_ptr(pval, seqtt);
151 ASN1_template_free(pseqval, seqtt);
152 }
153 if(asn1_cb) asn1_cb(ASN1_OP_FREE_POST, pval, it);
154 if(!combine) {
155 OPENSSL_free(*pval);
156 *pval = NULL;
157 }
158 break;
159 }
160}
161
162void ASN1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt)
163{
164 int i;
165 if(tt->flags & ASN1_TFLG_SK_MASK) {
166 STACK_OF(ASN1_VALUE) *sk = (STACK_OF(ASN1_VALUE) *)*pval;
167 for(i = 0; i < sk_ASN1_VALUE_num(sk); i++) {
168 ASN1_VALUE *vtmp;
169 vtmp = sk_ASN1_VALUE_value(sk, i);
170 asn1_item_combine_free(&vtmp, ASN1_ITEM_ptr(tt->item), 0);
171 }
172 sk_ASN1_VALUE_free(sk);
173 *pval = NULL;
174 } else asn1_item_combine_free(pval, ASN1_ITEM_ptr(tt->item),
175 tt->flags & ASN1_TFLG_COMBINE);
176}
177
178void ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
179{
180 int utype;
181 if(it) {
182 const ASN1_PRIMITIVE_FUNCS *pf;
183 pf = it->funcs;
184 if(pf && pf->prim_free) {
185 pf->prim_free(pval, it);
186 return;
187 }
188 }
189 /* Special case: if 'it' is NULL free contents of ASN1_TYPE */
190 if(!it) {
191 ASN1_TYPE *typ = (ASN1_TYPE *)*pval;
192 utype = typ->type;
193 pval = (ASN1_VALUE **)&typ->value.ptr;
194 if(!*pval) return;
195 } else if(it->itype == ASN1_ITYPE_MSTRING) {
196 utype = -1;
197 if(!*pval) return;
198 } else {
199 utype = it->utype;
200 if((utype != V_ASN1_BOOLEAN) && !*pval) return;
201 }
202
203 switch(utype) {
204 case V_ASN1_OBJECT:
205 ASN1_OBJECT_free((ASN1_OBJECT *)*pval);
206 break;
207
208 case V_ASN1_BOOLEAN:
209 *(ASN1_BOOLEAN *)pval = it->size;
210 return;
211
212 case V_ASN1_NULL:
213 break;
214
215 case V_ASN1_ANY:
216 ASN1_primitive_free(pval, NULL);
217 OPENSSL_free(*pval);
218 break;
219
220 default:
221 ASN1_STRING_free((ASN1_STRING *)*pval);
222 *pval = NULL;
223 break;
224 }
225 *pval = NULL;
226}
diff --git a/src/lib/libcrypto/asn1/tasn_new.c b/src/lib/libcrypto/asn1/tasn_new.c
new file mode 100644
index 0000000000..e33861f864
--- /dev/null
+++ b/src/lib/libcrypto/asn1/tasn_new.c
@@ -0,0 +1,348 @@
1/* tasn_new.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) 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
60#include <stddef.h>
61#include <openssl/asn1.h>
62#include <openssl/objects.h>
63#include <openssl/err.h>
64#include <openssl/asn1t.h>
65#include <string.h>
66
67static int asn1_item_ex_combine_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int combine);
68static void asn1_item_clear(ASN1_VALUE **pval, const ASN1_ITEM *it);
69static void asn1_template_clear(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);
70void asn1_primitive_clear(ASN1_VALUE **pval, const ASN1_ITEM *it);
71
72ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it)
73{
74 ASN1_VALUE *ret = NULL;
75 if(ASN1_item_ex_new(&ret, it) > 0) return ret;
76 return NULL;
77}
78
79/* Allocate an ASN1 structure */
80
81int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it)
82{
83 return asn1_item_ex_combine_new(pval, it, 0);
84}
85
86static int asn1_item_ex_combine_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int combine)
87{
88 const ASN1_TEMPLATE *tt = NULL;
89 const ASN1_COMPAT_FUNCS *cf;
90 const ASN1_EXTERN_FUNCS *ef;
91 const ASN1_AUX *aux = it->funcs;
92 ASN1_aux_cb *asn1_cb;
93 ASN1_VALUE **pseqval;
94 int i;
95 if(aux && aux->asn1_cb) asn1_cb = aux->asn1_cb;
96 else asn1_cb = 0;
97
98 if(!combine) *pval = NULL;
99
100#ifdef CRYPTO_MDEBUG
101 if(it->sname) CRYPTO_push_info(it->sname);
102#endif
103
104 switch(it->itype) {
105
106 case ASN1_ITYPE_EXTERN:
107 ef = it->funcs;
108 if(ef && ef->asn1_ex_new) {
109 if(!ef->asn1_ex_new(pval, it))
110 goto memerr;
111 }
112 break;
113
114 case ASN1_ITYPE_COMPAT:
115 cf = it->funcs;
116 if(cf && cf->asn1_new) {
117 *pval = cf->asn1_new();
118 if(!*pval) goto memerr;
119 }
120 break;
121
122 case ASN1_ITYPE_PRIMITIVE:
123 if(it->templates) {
124 if(!ASN1_template_new(pval, it->templates))
125 goto memerr;
126 } else {
127 if(!ASN1_primitive_new(pval, it))
128 goto memerr;
129 }
130 break;
131
132 case ASN1_ITYPE_MSTRING:
133 if(!ASN1_primitive_new(pval, it))
134 goto memerr;
135 break;
136
137 case ASN1_ITYPE_CHOICE:
138 if(asn1_cb) {
139 i = asn1_cb(ASN1_OP_NEW_PRE, pval, it);
140 if(!i) goto auxerr;
141 if(i==2) {
142#ifdef CRYPTO_MDEBUG
143 if(it->sname) CRYPTO_pop_info();
144#endif
145 return 1;
146 }
147 }
148 if(!combine) {
149 *pval = OPENSSL_malloc(it->size);
150 if(!*pval) goto memerr;
151 memset(*pval, 0, it->size);
152 }
153 asn1_set_choice_selector(pval, -1, it);
154 if(asn1_cb && !asn1_cb(ASN1_OP_NEW_POST, pval, it))
155 goto auxerr;
156 break;
157
158 case ASN1_ITYPE_SEQUENCE:
159 if(asn1_cb) {
160 i = asn1_cb(ASN1_OP_NEW_PRE, pval, it);
161 if(!i) goto auxerr;
162 if(i==2) {
163#ifdef CRYPTO_MDEBUG
164 if(it->sname) CRYPTO_pop_info();
165#endif
166 return 1;
167 }
168 }
169 if(!combine) {
170 *pval = OPENSSL_malloc(it->size);
171 if(!*pval) goto memerr;
172 memset(*pval, 0, it->size);
173 asn1_do_lock(pval, 0, it);
174 asn1_enc_init(pval, it);
175 }
176 for(i = 0, tt = it->templates; i < it->tcount; tt++, i++) {
177 pseqval = asn1_get_field_ptr(pval, tt);
178 if(!ASN1_template_new(pseqval, tt)) goto memerr;
179 }
180 if(asn1_cb && !asn1_cb(ASN1_OP_NEW_POST, pval, it))
181 goto auxerr;
182 break;
183 }
184#ifdef CRYPTO_MDEBUG
185 if(it->sname) CRYPTO_pop_info();
186#endif
187 return 1;
188
189 memerr:
190 ASN1err(ASN1_F_ASN1_ITEM_NEW, ERR_R_MALLOC_FAILURE);
191#ifdef CRYPTO_MDEBUG
192 if(it->sname) CRYPTO_pop_info();
193#endif
194 return 0;
195
196 auxerr:
197 ASN1err(ASN1_F_ASN1_ITEM_NEW, ASN1_R_AUX_ERROR);
198 ASN1_item_ex_free(pval, it);
199#ifdef CRYPTO_MDEBUG
200 if(it->sname) CRYPTO_pop_info();
201#endif
202 return 0;
203
204}
205
206static void asn1_item_clear(ASN1_VALUE **pval, const ASN1_ITEM *it)
207{
208 const ASN1_EXTERN_FUNCS *ef;
209
210 switch(it->itype) {
211
212 case ASN1_ITYPE_EXTERN:
213 ef = it->funcs;
214 if(ef && ef->asn1_ex_clear)
215 ef->asn1_ex_clear(pval, it);
216 else *pval = NULL;
217 break;
218
219
220 case ASN1_ITYPE_PRIMITIVE:
221 if(it->templates)
222 asn1_template_clear(pval, it->templates);
223 else
224 asn1_primitive_clear(pval, it);
225 break;
226
227 case ASN1_ITYPE_MSTRING:
228 asn1_primitive_clear(pval, it);
229 break;
230
231 case ASN1_ITYPE_COMPAT:
232 case ASN1_ITYPE_CHOICE:
233 case ASN1_ITYPE_SEQUENCE:
234 *pval = NULL;
235 break;
236 }
237}
238
239
240int ASN1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt)
241{
242 const ASN1_ITEM *it = ASN1_ITEM_ptr(tt->item);
243 int ret;
244 if(tt->flags & ASN1_TFLG_OPTIONAL) {
245 asn1_template_clear(pval, tt);
246 return 1;
247 }
248 /* If ANY DEFINED BY nothing to do */
249
250 if(tt->flags & ASN1_TFLG_ADB_MASK) {
251 *pval = NULL;
252 return 1;
253 }
254#ifdef CRYPTO_MDEBUG
255 if(tt->field_name) CRYPTO_push_info(tt->field_name);
256#endif
257 /* If SET OF or SEQUENCE OF, its a STACK */
258 if(tt->flags & ASN1_TFLG_SK_MASK) {
259 STACK_OF(ASN1_VALUE) *skval;
260 skval = sk_ASN1_VALUE_new_null();
261 if(!skval) {
262 ASN1err(ASN1_F_ASN1_TEMPLATE_NEW, ERR_R_MALLOC_FAILURE);
263 ret = 0;
264 goto done;
265 }
266 *pval = (ASN1_VALUE *)skval;
267 ret = 1;
268 goto done;
269 }
270 /* Otherwise pass it back to the item routine */
271 ret = asn1_item_ex_combine_new(pval, it, tt->flags & ASN1_TFLG_COMBINE);
272 done:
273#ifdef CRYPTO_MDEBUG
274 if(it->sname) CRYPTO_pop_info();
275#endif
276 return ret;
277}
278
279static void asn1_template_clear(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt)
280{
281 /* If ADB or STACK just NULL the field */
282 if(tt->flags & (ASN1_TFLG_ADB_MASK|ASN1_TFLG_SK_MASK))
283 *pval = NULL;
284 else
285 asn1_item_clear(pval, ASN1_ITEM_ptr(tt->item));
286}
287
288
289/* NB: could probably combine most of the real XXX_new() behaviour and junk all the old
290 * functions.
291 */
292
293int ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it)
294{
295 ASN1_TYPE *typ;
296 int utype;
297 const ASN1_PRIMITIVE_FUNCS *pf;
298 pf = it->funcs;
299 if(pf && pf->prim_new) return pf->prim_new(pval, it);
300 if(!it || (it->itype == ASN1_ITYPE_MSTRING)) utype = -1;
301 else utype = it->utype;
302 switch(utype) {
303 case V_ASN1_OBJECT:
304 *pval = (ASN1_VALUE *)OBJ_nid2obj(NID_undef);
305 return 1;
306
307 case V_ASN1_BOOLEAN:
308 *(ASN1_BOOLEAN *)pval = it->size;
309 return 1;
310
311 case V_ASN1_NULL:
312 *pval = (ASN1_VALUE *)1;
313 return 1;
314
315 case V_ASN1_ANY:
316 typ = OPENSSL_malloc(sizeof(ASN1_TYPE));
317 if(!typ) return 0;
318 typ->value.ptr = NULL;
319 typ->type = -1;
320 *pval = (ASN1_VALUE *)typ;
321 break;
322
323 default:
324 *pval = (ASN1_VALUE *)ASN1_STRING_type_new(utype);
325 break;
326 }
327 if(*pval) return 1;
328 return 0;
329}
330
331void asn1_primitive_clear(ASN1_VALUE **pval, const ASN1_ITEM *it)
332{
333 int utype;
334 const ASN1_PRIMITIVE_FUNCS *pf;
335 pf = it->funcs;
336 if(pf) {
337 if(pf->prim_clear)
338 pf->prim_clear(pval, it);
339 else
340 *pval = NULL;
341 return;
342 }
343 if(!it || (it->itype == ASN1_ITYPE_MSTRING)) utype = -1;
344 else utype = it->utype;
345 if(utype == V_ASN1_BOOLEAN)
346 *(ASN1_BOOLEAN *)pval = it->size;
347 else *pval = NULL;
348}
diff --git a/src/lib/libcrypto/asn1/tasn_prn.c b/src/lib/libcrypto/asn1/tasn_prn.c
new file mode 100644
index 0000000000..fab67ae5ac
--- /dev/null
+++ b/src/lib/libcrypto/asn1/tasn_prn.c
@@ -0,0 +1,198 @@
1/* tasn_prn.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) 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
60#include <stddef.h>
61#include <openssl/asn1.h>
62#include <openssl/objects.h>
63#include <openssl/buffer.h>
64#include <openssl/err.h>
65#include <openssl/nasn.h>
66
67/* Print routines. Print out a whole structure from a template.
68 */
69
70static int asn1_item_print_nm(BIO *out, void *fld, int indent, const ASN1_ITEM *it, const char *name);
71
72int ASN1_item_print(BIO *out, void *fld, int indent, const ASN1_ITEM *it)
73{
74 return asn1_item_print_nm(out, fld, indent, it, it->sname);
75}
76
77static int asn1_item_print_nm(BIO *out, void *fld, int indent, const ASN1_ITEM *it, const char *name)
78{
79 ASN1_STRING *str;
80 const ASN1_TEMPLATE *tt;
81 void *tmpfld;
82 int i;
83 if(!fld) {
84 BIO_printf(out, "%*s%s ABSENT\n", indent, "", name);
85 return 1;
86 }
87 switch(it->itype) {
88
89 case ASN1_ITYPE_PRIMITIVE:
90 if(it->templates)
91 return ASN1_template_print(out, fld, indent, it->templates);
92 return asn1_primitive_print(out, fld, it->utype, indent, name);
93 break;
94
95 case ASN1_ITYPE_MSTRING:
96 str = fld;
97 return asn1_primitive_print(out, fld, str->type, indent, name);
98
99 case ASN1_ITYPE_EXTERN:
100 BIO_printf(out, "%*s%s:EXTERNAL TYPE %s %s\n", indent, "", name, it->sname, fld ? "" : "ABSENT");
101 return 1;
102 case ASN1_ITYPE_COMPAT:
103 BIO_printf(out, "%*s%s:COMPATIBLE TYPE %s %s\n", indent, "", name, it->sname, fld ? "" : "ABSENT");
104 return 1;
105
106
107 case ASN1_ITYPE_CHOICE:
108 /* CHOICE type, get selector */
109 i = asn1_get_choice_selector(fld, it);
110 /* This should never happen... */
111 if((i < 0) || (i >= it->tcount)) {
112 BIO_printf(out, "%s selector [%d] out of range\n", it->sname, i);
113 return 1;
114 }
115 tt = it->templates + i;
116 tmpfld = asn1_get_field(fld, tt);
117 return ASN1_template_print(out, tmpfld, indent, tt);
118
119 case ASN1_ITYPE_SEQUENCE:
120 BIO_printf(out, "%*s%s {\n", indent, "", name);
121 /* Get each field entry */
122 for(i = 0, tt = it->templates; i < it->tcount; i++, tt++) {
123 tmpfld = asn1_get_field(fld, tt);
124 ASN1_template_print(out, tmpfld, indent + 2, tt);
125 }
126 BIO_printf(out, "%*s}\n", indent, "");
127 return 1;
128
129 default:
130 return 0;
131 }
132}
133
134int ASN1_template_print(BIO *out, void *fld, int indent, const ASN1_TEMPLATE *tt)
135{
136 int i, flags;
137#if 0
138 if(!fld) return 0;
139#endif
140 flags = tt->flags;
141 if(flags & ASN1_TFLG_SK_MASK) {
142 char *tname;
143 void *skitem;
144 /* SET OF, SEQUENCE OF */
145 if(flags & ASN1_TFLG_SET_OF) tname = "SET";
146 else tname = "SEQUENCE";
147 if(fld) {
148 BIO_printf(out, "%*s%s OF %s {\n", indent, "", tname, tt->field_name);
149 for(i = 0; i < sk_num(fld); i++) {
150 skitem = sk_value(fld, i);
151 asn1_item_print_nm(out, skitem, indent + 2, tt->item, "");
152 }
153 BIO_printf(out, "%*s}\n", indent, "");
154 } else
155 BIO_printf(out, "%*s%s OF %s ABSENT\n", indent, "", tname, tt->field_name);
156 return 1;
157 }
158 return asn1_item_print_nm(out, fld, indent, tt->item, tt->field_name);
159}
160
161static int asn1_primitive_print(BIO *out, void *fld, long utype, int indent, const char *name)
162{
163 ASN1_STRING *str = fld;
164 if(fld) {
165 if(utype == V_ASN1_BOOLEAN) {
166 int *bool = fld;
167if(*bool == -1) printf("BOOL MISSING\n");
168 BIO_printf(out, "%*s%s:%s", indent, "", "BOOLEAN", *bool ? "TRUE" : "FALSE");
169 } else if((utype == V_ASN1_INTEGER)
170 || (utype == V_ASN1_ENUMERATED)) {
171 char *s, *nm;
172 s = i2s_ASN1_INTEGER(NULL, fld);
173 if(utype == V_ASN1_INTEGER) nm = "INTEGER";
174 else nm = "ENUMERATED";
175 BIO_printf(out, "%*s%s:%s", indent, "", nm, s);
176 OPENSSL_free(s);
177 } else if(utype == V_ASN1_NULL) {
178 BIO_printf(out, "%*s%s", indent, "", "NULL");
179 } else if(utype == V_ASN1_UTCTIME) {
180 BIO_printf(out, "%*s%s:%s:", indent, "", name, "UTCTIME");
181 ASN1_UTCTIME_print(out, str);
182 } else if(utype == V_ASN1_GENERALIZEDTIME) {
183 BIO_printf(out, "%*s%s:%s:", indent, "", name, "GENERALIZEDTIME");
184 ASN1_GENERALIZEDTIME_print(out, str);
185 } else if(utype == V_ASN1_OBJECT) {
186 char objbuf[80], *ln;
187 ln = OBJ_nid2ln(OBJ_obj2nid(fld));
188 if(!ln) ln = "";
189 OBJ_obj2txt(objbuf, 80, fld, 1);
190 BIO_printf(out, "%*s%s:%s (%s)", indent, "", "OBJECT", ln, objbuf);
191 } else {
192 BIO_printf(out, "%*s%s:", indent, "", name);
193 ASN1_STRING_print_ex(out, str, ASN1_STRFLGS_DUMP_UNKNOWN|ASN1_STRFLGS_SHOW_TYPE);
194 }
195 BIO_printf(out, "\n");
196 } else BIO_printf(out, "%*s%s [ABSENT]\n", indent, "", name);
197 return 1;
198}
diff --git a/src/lib/libcrypto/asn1/tasn_typ.c b/src/lib/libcrypto/asn1/tasn_typ.c
new file mode 100644
index 0000000000..804d2eeba2
--- /dev/null
+++ b/src/lib/libcrypto/asn1/tasn_typ.c
@@ -0,0 +1,133 @@
1/* tasn_typ.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) 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#include <stdio.h>
59#include <openssl/asn1.h>
60#include <openssl/asn1t.h>
61
62/* Declarations for string types */
63
64
65IMPLEMENT_ASN1_TYPE(ASN1_INTEGER)
66IMPLEMENT_ASN1_FUNCTIONS(ASN1_INTEGER)
67
68IMPLEMENT_ASN1_TYPE(ASN1_ENUMERATED)
69IMPLEMENT_ASN1_FUNCTIONS(ASN1_ENUMERATED)
70
71IMPLEMENT_ASN1_TYPE(ASN1_BIT_STRING)
72IMPLEMENT_ASN1_FUNCTIONS(ASN1_BIT_STRING)
73
74IMPLEMENT_ASN1_TYPE(ASN1_OCTET_STRING)
75IMPLEMENT_ASN1_FUNCTIONS(ASN1_OCTET_STRING)
76
77IMPLEMENT_ASN1_TYPE(ASN1_NULL)
78IMPLEMENT_ASN1_FUNCTIONS(ASN1_NULL)
79
80IMPLEMENT_ASN1_TYPE(ASN1_OBJECT)
81
82IMPLEMENT_ASN1_TYPE(ASN1_UTF8STRING)
83IMPLEMENT_ASN1_FUNCTIONS(ASN1_UTF8STRING)
84
85IMPLEMENT_ASN1_TYPE(ASN1_PRINTABLESTRING)
86IMPLEMENT_ASN1_FUNCTIONS(ASN1_PRINTABLESTRING)
87
88IMPLEMENT_ASN1_TYPE(ASN1_T61STRING)
89IMPLEMENT_ASN1_FUNCTIONS(ASN1_T61STRING)
90
91IMPLEMENT_ASN1_TYPE(ASN1_IA5STRING)
92IMPLEMENT_ASN1_FUNCTIONS(ASN1_IA5STRING)
93
94IMPLEMENT_ASN1_TYPE(ASN1_GENERALSTRING)
95IMPLEMENT_ASN1_FUNCTIONS(ASN1_GENERALSTRING)
96
97IMPLEMENT_ASN1_TYPE(ASN1_UTCTIME)
98IMPLEMENT_ASN1_FUNCTIONS(ASN1_UTCTIME)
99
100IMPLEMENT_ASN1_TYPE(ASN1_GENERALIZEDTIME)
101IMPLEMENT_ASN1_FUNCTIONS(ASN1_GENERALIZEDTIME)
102
103IMPLEMENT_ASN1_TYPE(ASN1_VISIBLESTRING)
104IMPLEMENT_ASN1_FUNCTIONS(ASN1_VISIBLESTRING)
105
106IMPLEMENT_ASN1_TYPE(ASN1_UNIVERSALSTRING)
107IMPLEMENT_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING)
108
109IMPLEMENT_ASN1_TYPE(ASN1_BMPSTRING)
110IMPLEMENT_ASN1_FUNCTIONS(ASN1_BMPSTRING)
111
112IMPLEMENT_ASN1_TYPE(ASN1_ANY)
113
114/* Just swallow an ASN1_SEQUENCE in an ASN1_STRING */
115IMPLEMENT_ASN1_TYPE(ASN1_SEQUENCE)
116
117IMPLEMENT_ASN1_FUNCTIONS_fname(ASN1_TYPE, ASN1_ANY, ASN1_TYPE)
118
119/* Multistring types */
120
121IMPLEMENT_ASN1_MSTRING(ASN1_PRINTABLE, B_ASN1_PRINTABLE)
122IMPLEMENT_ASN1_FUNCTIONS_name(ASN1_STRING, ASN1_PRINTABLE)
123
124IMPLEMENT_ASN1_MSTRING(DISPLAYTEXT, B_ASN1_DISPLAYTEXT)
125IMPLEMENT_ASN1_FUNCTIONS_name(ASN1_STRING, DISPLAYTEXT)
126
127IMPLEMENT_ASN1_MSTRING(DIRECTORYSTRING, B_ASN1_DIRECTORYSTRING)
128IMPLEMENT_ASN1_FUNCTIONS_name(ASN1_STRING, DIRECTORYSTRING)
129
130/* Three separate BOOLEAN type: normal, DEFAULT TRUE and DEFAULT FALSE */
131IMPLEMENT_ASN1_TYPE_ex(ASN1_BOOLEAN, ASN1_BOOLEAN, -1)
132IMPLEMENT_ASN1_TYPE_ex(ASN1_TBOOLEAN, ASN1_BOOLEAN, 1)
133IMPLEMENT_ASN1_TYPE_ex(ASN1_FBOOLEAN, ASN1_BOOLEAN, 0)
diff --git a/src/lib/libcrypto/asn1/tasn_utl.c b/src/lib/libcrypto/asn1/tasn_utl.c
new file mode 100644
index 0000000000..8996ce8c13
--- /dev/null
+++ b/src/lib/libcrypto/asn1/tasn_utl.c
@@ -0,0 +1,253 @@
1/* tasn_utl.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) 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
60#include <stddef.h>
61#include <string.h>
62#include <openssl/asn1.h>
63#include <openssl/asn1t.h>
64#include <openssl/objects.h>
65#include <openssl/err.h>
66
67/* Utility functions for manipulating fields and offsets */
68
69/* Add 'offset' to 'addr' */
70#define offset2ptr(addr, offset) (void *)(((char *) addr) + offset)
71
72/* Given an ASN1_ITEM CHOICE type return
73 * the selector value
74 */
75
76int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it)
77{
78 int *sel = offset2ptr(*pval, it->utype);
79 return *sel;
80}
81
82/* Given an ASN1_ITEM CHOICE type set
83 * the selector value, return old value.
84 */
85
86int asn1_set_choice_selector(ASN1_VALUE **pval, int value, const ASN1_ITEM *it)
87{
88 int *sel, ret;
89 sel = offset2ptr(*pval, it->utype);
90 ret = *sel;
91 *sel = value;
92 return ret;
93}
94
95/* Do reference counting. The value 'op' decides what to do.
96 * if it is +1 then the count is incremented. If op is 0 count is
97 * set to 1. If op is -1 count is decremented and the return value
98 * is the current refrence count or 0 if no reference count exists.
99 */
100
101int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it)
102{
103 const ASN1_AUX *aux;
104 int *lck, ret;
105 if(it->itype != ASN1_ITYPE_SEQUENCE) return 0;
106 aux = it->funcs;
107 if(!aux || !(aux->flags & ASN1_AFLG_REFCOUNT)) return 0;
108 lck = offset2ptr(*pval, aux->ref_offset);
109 if(op == 0) {
110 *lck = 1;
111 return 1;
112 }
113 ret = CRYPTO_add(lck, op, aux->ref_lock);
114#ifdef REF_PRINT
115 fprintf(stderr, "%s: Reference Count: %d\n", it->sname, *lck);
116#endif
117#ifdef REF_CHECK
118 if(ret < 0)
119 fprintf(stderr, "%s, bad reference count\n", it->sname);
120#endif
121 return ret;
122}
123
124static ASN1_ENCODING *asn1_get_enc_ptr(ASN1_VALUE **pval, const ASN1_ITEM *it)
125{
126 const ASN1_AUX *aux;
127 if(!pval || !*pval) return NULL;
128 aux = it->funcs;
129 if(!aux || !(aux->flags & ASN1_AFLG_ENCODING)) return NULL;
130 return offset2ptr(*pval, aux->enc_offset);
131}
132
133void asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it)
134{
135 ASN1_ENCODING *enc;
136 enc = asn1_get_enc_ptr(pval, it);
137 if(enc) {
138 enc->enc = NULL;
139 enc->len = 0;
140 enc->modified = 1;
141 }
142}
143
144void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
145{
146 ASN1_ENCODING *enc;
147 enc = asn1_get_enc_ptr(pval, it);
148 if(enc) {
149 if(enc->enc) OPENSSL_free(enc->enc);
150 enc->enc = NULL;
151 enc->len = 0;
152 enc->modified = 1;
153 }
154}
155
156int asn1_enc_save(ASN1_VALUE **pval, unsigned char *in, int inlen, const ASN1_ITEM *it)
157{
158 ASN1_ENCODING *enc;
159 enc = asn1_get_enc_ptr(pval, it);
160 if(!enc) return 1;
161
162 if(enc->enc) OPENSSL_free(enc->enc);
163 enc->enc = OPENSSL_malloc(inlen);
164 if(!enc->enc) return 0;
165 memcpy(enc->enc, in, inlen);
166 enc->len = inlen;
167 enc->modified = 0;
168
169 return 1;
170}
171
172int asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval, const ASN1_ITEM *it)
173{
174 ASN1_ENCODING *enc;
175 enc = asn1_get_enc_ptr(pval, it);
176 if(!enc || enc->modified) return 0;
177 if(out) {
178 memcpy(*out, enc->enc, enc->len);
179 *out += enc->len;
180 }
181 if(len) *len = enc->len;
182 return 1;
183}
184
185/* Given an ASN1_TEMPLATE get a pointer to a field */
186ASN1_VALUE ** asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt)
187{
188 ASN1_VALUE **pvaltmp;
189 if(tt->flags & ASN1_TFLG_COMBINE) return pval;
190 pvaltmp = offset2ptr(*pval, tt->offset);
191 /* NOTE for BOOLEAN types the field is just a plain
192 * int so we can't return int **, so settle for
193 * (int *).
194 */
195 return pvaltmp;
196}
197
198/* Handle ANY DEFINED BY template, find the selector, look up
199 * the relevant ASN1_TEMPLATE in the table and return it.
200 */
201
202const ASN1_TEMPLATE *asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt, int nullerr)
203{
204 const ASN1_ADB *adb;
205 const ASN1_ADB_TABLE *atbl;
206 long selector;
207 ASN1_VALUE **sfld;
208 int i;
209 if(!(tt->flags & ASN1_TFLG_ADB_MASK)) return tt;
210
211 /* Else ANY DEFINED BY ... get the table */
212 adb = ASN1_ADB_ptr(tt->item);
213
214 /* Get the selector field */
215 sfld = offset2ptr(*pval, adb->offset);
216
217 /* Check if NULL */
218 if(!sfld) {
219 if(!adb->null_tt) goto err;
220 return adb->null_tt;
221 }
222
223 /* Convert type to a long:
224 * NB: don't check for NID_undef here because it
225 * might be a legitimate value in the table
226 */
227 if(tt->flags & ASN1_TFLG_ADB_OID)
228 selector = OBJ_obj2nid((ASN1_OBJECT *)*sfld);
229 else
230 selector = ASN1_INTEGER_get((ASN1_INTEGER *)*sfld);
231
232 /* Try to find matching entry in table
233 * Maybe should check application types first to
234 * allow application override? Might also be useful
235 * to have a flag which indicates table is sorted and
236 * we can do a binary search. For now stick to a
237 * linear search.
238 */
239
240 for(atbl = adb->tbl, i = 0; i < adb->tblcount; i++, atbl++)
241 if(atbl->value == selector) return &atbl->tt;
242
243 /* FIXME: need to search application table too */
244
245 /* No match, return default type */
246 if(!adb->default_tt) goto err;
247 return adb->default_tt;
248
249 err:
250 /* FIXME: should log the value or OID of unsupported type */
251 if(nullerr) ASN1err(ASN1_F_ASN1_DO_ADB, ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE);
252 return NULL;
253}
diff --git a/src/lib/libcrypto/asn1/x_algor.c b/src/lib/libcrypto/asn1/x_algor.c
index 853a8dfeef..00b9ea54a1 100644
--- a/src/lib/libcrypto/asn1/x_algor.c
+++ b/src/lib/libcrypto/asn1/x_algor.c
@@ -1,118 +1,73 @@
1/* crypto/asn1/x_algor.c */ 1/* x_algor.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
3 * All rights reserved. 3 * project 2000.
4 */
5/* ====================================================================
6 * Copyright (c) 2000 The OpenSSL Project. All rights reserved.
4 * 7 *
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 8 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
25 * are met: 10 * are met:
26 * 1. Redistributions of source code must retain the copyright 11 *
27 * notice, this list of conditions and the following disclaimer. 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
28 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the 16 * notice, this list of conditions and the following disclaimer in
30 * documentation and/or other materials provided with the distribution. 17 * the documentation and/or other materials provided with the
31 * 3. All advertising materials mentioning features or use of this software 18 * distribution.
32 * must display the following acknowledgement: 19 *
33 * "This product includes cryptographic software written by 20 * 3. All advertising materials mentioning features or use of this
34 * Eric Young (eay@cryptsoft.com)" 21 * software must display the following acknowledgment:
35 * The word 'cryptographic' can be left out if the rouines from the library 22 * "This product includes software developed by the OpenSSL Project
36 * being used are not cryptographic related :-). 23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
37 * 4. If you include any Windows specific code (or a derivative thereof) from 24 *
38 * the apps directory (application code) you must include an acknowledgement: 25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 26 * endorse or promote products derived from this software without
40 * 27 * prior written permission. For written permission, please contact
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 28 * licensing@OpenSSL.org.
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 *
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30 * 5. Products derived from this software may not be called "OpenSSL"
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 31 * nor may "OpenSSL" appear in their names without prior written
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 * permission of the OpenSSL Project.
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 33 *
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 * 6. Redistributions of any form whatsoever must retain the following
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 * acknowledgment:
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 * "This product includes software developed by the OpenSSL Project
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
51 * SUCH DAMAGE. 38 *
52 * 39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
53 * The licence and distribution terms for any publically available version or 40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
54 * derivative of this code cannot be changed. i.e. this code cannot simply be 41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
55 * copied and put under another distribution licence 42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
56 * [including the GNU Public Licence.] 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 */ 57 */
58 58
59#include <stdio.h> 59#include <stddef.h>
60#include "cryptlib.h"
61#include <openssl/asn1_mac.h>
62#include <openssl/x509.h> 60#include <openssl/x509.h>
61#include <openssl/asn1.h>
62#include <openssl/asn1t.h>
63 63
64int i2d_X509_ALGOR(X509_ALGOR *a, unsigned char **pp) 64ASN1_SEQUENCE(X509_ALGOR) = {
65 { 65 ASN1_SIMPLE(X509_ALGOR, algorithm, ASN1_OBJECT),
66 M_ASN1_I2D_vars(a); 66 ASN1_OPT(X509_ALGOR, parameter, ASN1_ANY)
67 67} ASN1_SEQUENCE_END(X509_ALGOR)
68 M_ASN1_I2D_len(a->algorithm,i2d_ASN1_OBJECT);
69 if (a->parameter != NULL)
70 { M_ASN1_I2D_len(a->parameter,i2d_ASN1_TYPE); }
71
72 M_ASN1_I2D_seq_total();
73 M_ASN1_I2D_put(a->algorithm,i2d_ASN1_OBJECT);
74 if (a->parameter != NULL)
75 { M_ASN1_I2D_put(a->parameter,i2d_ASN1_TYPE); }
76
77 M_ASN1_I2D_finish();
78 }
79
80X509_ALGOR *d2i_X509_ALGOR(X509_ALGOR **a, unsigned char **pp, long length)
81 {
82 M_ASN1_D2I_vars(a,X509_ALGOR *,X509_ALGOR_new);
83
84 M_ASN1_D2I_Init();
85 M_ASN1_D2I_start_sequence();
86 M_ASN1_D2I_get(ret->algorithm,d2i_ASN1_OBJECT);
87 if (!M_ASN1_D2I_end_sequence())
88 { M_ASN1_D2I_get(ret->parameter,d2i_ASN1_TYPE); }
89 else
90 {
91 ASN1_TYPE_free(ret->parameter);
92 ret->parameter=NULL;
93 }
94 M_ASN1_D2I_Finish(a,X509_ALGOR_free,ASN1_F_D2I_X509_ALGOR);
95 }
96
97X509_ALGOR *X509_ALGOR_new(void)
98 {
99 X509_ALGOR *ret=NULL;
100 ASN1_CTX c;
101
102 M_ASN1_New_Malloc(ret,X509_ALGOR);
103 ret->algorithm=OBJ_nid2obj(NID_undef);
104 ret->parameter=NULL;
105 return(ret);
106 M_ASN1_New_Error(ASN1_F_X509_ALGOR_NEW);
107 }
108 68
109void X509_ALGOR_free(X509_ALGOR *a) 69IMPLEMENT_ASN1_FUNCTIONS(X509_ALGOR)
110 { 70IMPLEMENT_ASN1_DUP_FUNCTION(X509_ALGOR)
111 if (a == NULL) return;
112 ASN1_OBJECT_free(a->algorithm);
113 ASN1_TYPE_free(a->parameter);
114 OPENSSL_free(a);
115 }
116 71
117IMPLEMENT_STACK_OF(X509_ALGOR) 72IMPLEMENT_STACK_OF(X509_ALGOR)
118IMPLEMENT_ASN1_SET_OF(X509_ALGOR) 73IMPLEMENT_ASN1_SET_OF(X509_ALGOR)
diff --git a/src/lib/libcrypto/asn1/x_attrib.c b/src/lib/libcrypto/asn1/x_attrib.c
index 14e5ea27aa..1e3713f18f 100644
--- a/src/lib/libcrypto/asn1/x_attrib.c
+++ b/src/lib/libcrypto/asn1/x_attrib.c
@@ -59,64 +59,42 @@
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/objects.h> 61#include <openssl/objects.h>
62#include <openssl/asn1_mac.h> 62#include <openssl/asn1t.h>
63#include <openssl/x509.h> 63#include <openssl/x509.h>
64 64
65/* sequence */ 65/* X509_ATTRIBUTE: this has the following form:
66int i2d_X509_ATTRIBUTE(X509_ATTRIBUTE *a, unsigned char **pp) 66 *
67 { 67 * typedef struct x509_attributes_st
68 int k=0; 68 * {
69 int r=0,ret=0; 69 * ASN1_OBJECT *object;
70 unsigned char **p=NULL; 70 * int single;
71 71 * union {
72 if (a == NULL) return(0); 72 * char *ptr;
73 73 * STACK_OF(ASN1_TYPE) *set;
74 p=NULL; 74 * ASN1_TYPE *single;
75 for (;;) 75 * } value;
76 { 76 * } X509_ATTRIBUTE;
77 if (k) 77 *
78 { 78 * this needs some extra thought because the CHOICE type is
79 r=ASN1_object_size(1,ret,V_ASN1_SEQUENCE); 79 * merged with the main structure and because the value can
80 if (pp == NULL) return(r); 80 * be anything at all we *must* try the SET OF first because
81 p=pp; 81 * the ASN1_ANY type will swallow anything including the whole
82 ASN1_put_object(p,1,ret,V_ASN1_SEQUENCE, 82 * SET OF structure.
83 V_ASN1_UNIVERSAL); 83 */
84 }
85
86 ret+=i2d_ASN1_OBJECT(a->object,p);
87 if (a->set)
88 ret+=i2d_ASN1_SET_OF_ASN1_TYPE(a->value.set,p,i2d_ASN1_TYPE,
89 V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET);
90 else
91 ret+=i2d_ASN1_TYPE(a->value.single,p);
92 if (k++) return(r);
93 }
94 }
95
96X509_ATTRIBUTE *d2i_X509_ATTRIBUTE(X509_ATTRIBUTE **a, unsigned char **pp,
97 long length)
98 {
99 M_ASN1_D2I_vars(a,X509_ATTRIBUTE *,X509_ATTRIBUTE_new);
100 84
101 M_ASN1_D2I_Init(); 85ASN1_CHOICE(X509_ATTRIBUTE_SET) = {
102 M_ASN1_D2I_start_sequence(); 86 ASN1_SET_OF(X509_ATTRIBUTE, value.set, ASN1_ANY),
103 M_ASN1_D2I_get(ret->object,d2i_ASN1_OBJECT); 87 ASN1_SIMPLE(X509_ATTRIBUTE, value.single, ASN1_ANY)
88} ASN1_CHOICE_END_selector(X509_ATTRIBUTE, X509_ATTRIBUTE_SET, single)
104 89
105 if ((c.slen != 0) && 90ASN1_SEQUENCE(X509_ATTRIBUTE) = {
106 (M_ASN1_next == (V_ASN1_CONSTRUCTED|V_ASN1_UNIVERSAL|V_ASN1_SET))) 91 ASN1_SIMPLE(X509_ATTRIBUTE, object, ASN1_OBJECT),
107 { 92 /* CHOICE type merged with parent */
108 ret->set=1; 93 ASN1_EX_COMBINE(0, 0, X509_ATTRIBUTE_SET)
109 M_ASN1_D2I_get_set_type(ASN1_TYPE,ret->value.set,d2i_ASN1_TYPE, 94} ASN1_SEQUENCE_END(X509_ATTRIBUTE)
110 ASN1_TYPE_free);
111 }
112 else
113 {
114 ret->set=0;
115 M_ASN1_D2I_get(ret->value.single,d2i_ASN1_TYPE);
116 }
117 95
118 M_ASN1_D2I_Finish(a,X509_ATTRIBUTE_free,ASN1_F_D2I_X509_ATTRIBUTE); 96IMPLEMENT_ASN1_FUNCTIONS(X509_ATTRIBUTE)
119 } 97IMPLEMENT_ASN1_DUP_FUNCTION(X509_ATTRIBUTE)
120 98
121X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value) 99X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value)
122 { 100 {
@@ -126,7 +104,7 @@ X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value)
126 if ((ret=X509_ATTRIBUTE_new()) == NULL) 104 if ((ret=X509_ATTRIBUTE_new()) == NULL)
127 return(NULL); 105 return(NULL);
128 ret->object=OBJ_nid2obj(nid); 106 ret->object=OBJ_nid2obj(nid);
129 ret->set=1; 107 ret->single=0;
130 if ((ret->value.set=sk_ASN1_TYPE_new_null()) == NULL) goto err; 108 if ((ret->value.set=sk_ASN1_TYPE_new_null()) == NULL) goto err;
131 if ((val=ASN1_TYPE_new()) == NULL) goto err; 109 if ((val=ASN1_TYPE_new()) == NULL) goto err;
132 if (!sk_ASN1_TYPE_push(ret->value.set,val)) goto err; 110 if (!sk_ASN1_TYPE_push(ret->value.set,val)) goto err;
@@ -138,28 +116,3 @@ err:
138 if (val != NULL) ASN1_TYPE_free(val); 116 if (val != NULL) ASN1_TYPE_free(val);
139 return(NULL); 117 return(NULL);
140 } 118 }
141
142X509_ATTRIBUTE *X509_ATTRIBUTE_new(void)
143 {
144 X509_ATTRIBUTE *ret=NULL;
145 ASN1_CTX c;
146
147 M_ASN1_New_Malloc(ret,X509_ATTRIBUTE);
148 ret->object=OBJ_nid2obj(NID_undef);
149 ret->set=0;
150 ret->value.ptr=NULL;
151 return(ret);
152 M_ASN1_New_Error(ASN1_F_X509_ATTRIBUTE_NEW);
153 }
154
155void X509_ATTRIBUTE_free(X509_ATTRIBUTE *a)
156 {
157 if (a == NULL) return;
158 ASN1_OBJECT_free(a->object);
159 if (a->set)
160 sk_ASN1_TYPE_pop_free(a->value.set,ASN1_TYPE_free);
161 else
162 ASN1_TYPE_free(a->value.single);
163 OPENSSL_free(a);
164 }
165
diff --git a/src/lib/libcrypto/asn1/x_bignum.c b/src/lib/libcrypto/asn1/x_bignum.c
new file mode 100644
index 0000000000..848c7a0877
--- /dev/null
+++ b/src/lib/libcrypto/asn1/x_bignum.c
@@ -0,0 +1,137 @@
1/* x_bignum.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) 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/asn1t.h>
62
63/* Custom primitive type for BIGNUM handling. This reads in an ASN1_INTEGER as a
64 * BIGNUM directly. Currently it ignores the sign which isn't a problem since all
65 * BIGNUMs used are non negative and anything that looks negative is normally due
66 * to an encoding error.
67 */
68
69#define BN_SENSITIVE 1
70
71static int bn_new(ASN1_VALUE **pval, const ASN1_ITEM *it);
72static void bn_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
73
74static int bn_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it);
75static int bn_c2i(ASN1_VALUE **pval, unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it);
76
77static ASN1_PRIMITIVE_FUNCS bignum_pf = {
78 NULL, 0,
79 bn_new,
80 bn_free,
81 0,
82 bn_c2i,
83 bn_i2c
84};
85
86ASN1_ITEM_start(BIGNUM)
87 ASN1_ITYPE_PRIMITIVE, V_ASN1_INTEGER, NULL, 0, &bignum_pf, 0, "BIGNUM"
88ASN1_ITEM_end(BIGNUM)
89
90ASN1_ITEM_start(CBIGNUM)
91 ASN1_ITYPE_PRIMITIVE, V_ASN1_INTEGER, NULL, 0, &bignum_pf, BN_SENSITIVE, "BIGNUM"
92ASN1_ITEM_end(CBIGNUM)
93
94static int bn_new(ASN1_VALUE **pval, const ASN1_ITEM *it)
95{
96 *pval = (ASN1_VALUE *)BN_new();
97 if(*pval) return 1;
98 else return 0;
99}
100
101static void bn_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
102{
103 if(!*pval) return;
104 if(it->size & BN_SENSITIVE) BN_clear_free((BIGNUM *)*pval);
105 else BN_free((BIGNUM *)*pval);
106 *pval = NULL;
107}
108
109static int bn_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it)
110{
111 BIGNUM *bn;
112 int pad;
113 if(!*pval) return -1;
114 bn = (BIGNUM *)*pval;
115 /* If MSB set in an octet we need a padding byte */
116 if(BN_num_bits(bn) & 0x7) pad = 0;
117 else pad = 1;
118 if(cont) {
119 if(pad) *cont++ = 0;
120 BN_bn2bin(bn, cont);
121 }
122 return pad + BN_num_bytes(bn);
123}
124
125static int bn_c2i(ASN1_VALUE **pval, unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it)
126{
127 BIGNUM *bn;
128 if(!*pval) bn_new(pval, it);
129 bn = (BIGNUM *)*pval;
130 if(!BN_bin2bn(cont, len, bn)) {
131 bn_free(pval, it);
132 return 0;
133 }
134 return 1;
135}
136
137
diff --git a/src/lib/libcrypto/asn1/x_crl.c b/src/lib/libcrypto/asn1/x_crl.c
index 51518cdf35..11fce96825 100644
--- a/src/lib/libcrypto/asn1/x_crl.c
+++ b/src/lib/libcrypto/asn1/x_crl.c
@@ -58,275 +58,76 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/asn1_mac.h> 61#include <openssl/asn1t.h>
62#include <openssl/x509.h> 62#include <openssl/x509.h>
63 63
64static int X509_REVOKED_cmp(const X509_REVOKED * const *a, 64static int X509_REVOKED_cmp(const X509_REVOKED * const *a,
65 const X509_REVOKED * const *b); 65 const X509_REVOKED * const *b);
66static int X509_REVOKED_seq_cmp(const X509_REVOKED * const *a, 66static int X509_REVOKED_seq_cmp(const X509_REVOKED * const *a,
67 const X509_REVOKED * const *b); 67 const X509_REVOKED * const *b);
68int i2d_X509_REVOKED(X509_REVOKED *a, unsigned char **pp)
69 {
70 M_ASN1_I2D_vars(a);
71
72 M_ASN1_I2D_len(a->serialNumber,i2d_ASN1_INTEGER);
73 M_ASN1_I2D_len(a->revocationDate,i2d_ASN1_TIME);
74 M_ASN1_I2D_len_SEQUENCE_opt_ex_type(X509_EXTENSION,a->extensions,
75 i2d_X509_EXTENSION);
76
77 M_ASN1_I2D_seq_total();
78 68
79 M_ASN1_I2D_put(a->serialNumber,i2d_ASN1_INTEGER); 69ASN1_SEQUENCE(X509_REVOKED) = {
80 M_ASN1_I2D_put(a->revocationDate,i2d_ASN1_TIME); 70 ASN1_SIMPLE(X509_REVOKED,serialNumber, ASN1_INTEGER),
81 M_ASN1_I2D_put_SEQUENCE_opt_ex_type(X509_EXTENSION,a->extensions, 71 ASN1_SIMPLE(X509_REVOKED,revocationDate, ASN1_TIME),
82 i2d_X509_EXTENSION); 72 ASN1_SEQUENCE_OF_OPT(X509_REVOKED,extensions, X509_EXTENSION)
83 73} ASN1_SEQUENCE_END(X509_REVOKED)
84 M_ASN1_I2D_finish(); 74
85 } 75/* The X509_CRL_INFO structure needs a bit of customisation. This is actually
86 76 * mirroring the old behaviour: its purpose is to allow the use of
87X509_REVOKED *d2i_X509_REVOKED(X509_REVOKED **a, unsigned char **pp, 77 * sk_X509_REVOKED_find to lookup revoked certificates. Unfortunately
88 long length) 78 * this will zap the original order and the signature so we keep a copy
89 { 79 * of the original positions and reorder appropriately before encoding.
90 M_ASN1_D2I_vars(a,X509_REVOKED *,X509_REVOKED_new); 80 *
91 81 * Might want to see if there's a better way of doing this later...
92 M_ASN1_D2I_Init(); 82 */
93 M_ASN1_D2I_start_sequence(); 83static int crl_inf_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it)
94 M_ASN1_D2I_get(ret->serialNumber,d2i_ASN1_INTEGER); 84{
95 M_ASN1_D2I_get(ret->revocationDate,d2i_ASN1_TIME); 85 X509_CRL_INFO *a = (X509_CRL_INFO *)*pval;
96 M_ASN1_D2I_get_seq_opt_type(X509_EXTENSION,ret->extensions, 86 int i;
97 d2i_X509_EXTENSION,X509_EXTENSION_free);
98 M_ASN1_D2I_Finish(a,X509_REVOKED_free,ASN1_F_D2I_X509_REVOKED);
99 }
100
101int i2d_X509_CRL_INFO(X509_CRL_INFO *a, unsigned char **pp)
102 {
103 int v1=0;
104 long l=0;
105 int (*old_cmp)(const X509_REVOKED * const *, 87 int (*old_cmp)(const X509_REVOKED * const *,
106 const X509_REVOKED * const *); 88 const X509_REVOKED * const *);
107 M_ASN1_I2D_vars(a);
108
109 old_cmp=sk_X509_REVOKED_set_cmp_func(a->revoked,X509_REVOKED_seq_cmp);
110 sk_X509_REVOKED_sort(a->revoked);
111 sk_X509_REVOKED_set_cmp_func(a->revoked,old_cmp);
112
113 if ((a->version != NULL) && ((l=ASN1_INTEGER_get(a->version)) != 0))
114 {
115 M_ASN1_I2D_len(a->version,i2d_ASN1_INTEGER);
116 }
117 M_ASN1_I2D_len(a->sig_alg,i2d_X509_ALGOR);
118 M_ASN1_I2D_len(a->issuer,i2d_X509_NAME);
119 M_ASN1_I2D_len(a->lastUpdate,i2d_ASN1_TIME);
120 if (a->nextUpdate != NULL)
121 { M_ASN1_I2D_len(a->nextUpdate,i2d_ASN1_TIME); }
122 M_ASN1_I2D_len_SEQUENCE_opt_type(X509_REVOKED,a->revoked,
123 i2d_X509_REVOKED);
124 M_ASN1_I2D_len_EXP_SEQUENCE_opt_ex_type(X509_EXTENSION,a->extensions,
125 i2d_X509_EXTENSION,0,
126 V_ASN1_SEQUENCE,v1);
127
128 M_ASN1_I2D_seq_total();
129
130 if ((a->version != NULL) && (l != 0))
131 {
132 M_ASN1_I2D_put(a->version,i2d_ASN1_INTEGER);
133 }
134 M_ASN1_I2D_put(a->sig_alg,i2d_X509_ALGOR);
135 M_ASN1_I2D_put(a->issuer,i2d_X509_NAME);
136 M_ASN1_I2D_put(a->lastUpdate,i2d_ASN1_TIME);
137 if (a->nextUpdate != NULL)
138 { M_ASN1_I2D_put(a->nextUpdate,i2d_ASN1_TIME); }
139 M_ASN1_I2D_put_SEQUENCE_opt_type(X509_REVOKED,a->revoked,
140 i2d_X509_REVOKED);
141 M_ASN1_I2D_put_EXP_SEQUENCE_opt_ex_type(X509_EXTENSION,a->extensions,
142 i2d_X509_EXTENSION,0,
143 V_ASN1_SEQUENCE,v1);
144 89
145 M_ASN1_I2D_finish(); 90 if(!a || !a->revoked) return 1;
146 } 91 switch(operation) {
147 92
148X509_CRL_INFO *d2i_X509_CRL_INFO(X509_CRL_INFO **a, unsigned char **pp, 93 /* Save original order */
149 long length) 94 case ASN1_OP_D2I_POST:
150 { 95 for (i=0; i<sk_X509_REVOKED_num(a->revoked); i++)
151 int i,ver=0; 96 sk_X509_REVOKED_value(a->revoked,i)->sequence=i;
152 M_ASN1_D2I_vars(a,X509_CRL_INFO *,X509_CRL_INFO_new); 97 sk_X509_REVOKED_set_cmp_func(a->revoked,X509_REVOKED_cmp);
153 98 break;
154 99
155 M_ASN1_D2I_Init(); 100 /* Restore original order */
156 M_ASN1_D2I_start_sequence(); 101 case ASN1_OP_I2D_PRE:
157 M_ASN1_D2I_get_opt(ret->version,d2i_ASN1_INTEGER,V_ASN1_INTEGER); 102 old_cmp=sk_X509_REVOKED_set_cmp_func(a->revoked,X509_REVOKED_seq_cmp);
158 if (ret->version != NULL) 103 sk_X509_REVOKED_sort(a->revoked);
159 ver=ret->version->data[0]; 104 sk_X509_REVOKED_set_cmp_func(a->revoked,old_cmp);
160 105 break;
161 if ((ver == 0) && (ret->version != NULL))
162 {
163 M_ASN1_INTEGER_free(ret->version);
164 ret->version=NULL;
165 }
166 M_ASN1_D2I_get(ret->sig_alg,d2i_X509_ALGOR);
167 M_ASN1_D2I_get(ret->issuer,d2i_X509_NAME);
168 M_ASN1_D2I_get(ret->lastUpdate,d2i_ASN1_TIME);
169 /* Manually handle the OPTIONAL ASN1_TIME stuff */
170 /* First try UTCTime */
171 M_ASN1_D2I_get_opt(ret->nextUpdate,d2i_ASN1_UTCTIME, V_ASN1_UTCTIME);
172 /* If that doesn't work try GeneralizedTime */
173 if(!ret->nextUpdate)
174 M_ASN1_D2I_get_opt(ret->nextUpdate,d2i_ASN1_GENERALIZEDTIME,
175 V_ASN1_GENERALIZEDTIME);
176 if (ret->revoked != NULL)
177 {
178 while (sk_X509_REVOKED_num(ret->revoked))
179 X509_REVOKED_free(sk_X509_REVOKED_pop(ret->revoked));
180 }
181 M_ASN1_D2I_get_seq_opt_type(X509_REVOKED,ret->revoked,d2i_X509_REVOKED,
182 X509_REVOKED_free);
183
184 if (ret->revoked != NULL)
185 {
186 for (i=0; i<sk_X509_REVOKED_num(ret->revoked); i++)
187 {
188 sk_X509_REVOKED_value(ret->revoked,i)->sequence=i;
189 }
190 }
191
192 if (ret->extensions != NULL)
193 {
194 while (sk_X509_EXTENSION_num(ret->extensions))
195 X509_EXTENSION_free(
196 sk_X509_EXTENSION_pop(ret->extensions));
197 }
198
199 M_ASN1_D2I_get_EXP_set_opt_type(X509_EXTENSION,ret->extensions,
200 d2i_X509_EXTENSION,
201 X509_EXTENSION_free,0,
202 V_ASN1_SEQUENCE);
203
204 M_ASN1_D2I_Finish(a,X509_CRL_INFO_free,ASN1_F_D2I_X509_CRL_INFO);
205 }
206
207int i2d_X509_CRL(X509_CRL *a, unsigned char **pp)
208 {
209 M_ASN1_I2D_vars(a);
210
211 M_ASN1_I2D_len(a->crl,i2d_X509_CRL_INFO);
212 M_ASN1_I2D_len(a->sig_alg,i2d_X509_ALGOR);
213 M_ASN1_I2D_len(a->signature,i2d_ASN1_BIT_STRING);
214
215 M_ASN1_I2D_seq_total();
216
217 M_ASN1_I2D_put(a->crl,i2d_X509_CRL_INFO);
218 M_ASN1_I2D_put(a->sig_alg,i2d_X509_ALGOR);
219 M_ASN1_I2D_put(a->signature,i2d_ASN1_BIT_STRING);
220
221 M_ASN1_I2D_finish();
222 }
223
224X509_CRL *d2i_X509_CRL(X509_CRL **a, unsigned char **pp, long length)
225 {
226 M_ASN1_D2I_vars(a,X509_CRL *,X509_CRL_new);
227
228 M_ASN1_D2I_Init();
229 M_ASN1_D2I_start_sequence();
230 M_ASN1_D2I_get(ret->crl,d2i_X509_CRL_INFO);
231 M_ASN1_D2I_get(ret->sig_alg,d2i_X509_ALGOR);
232 M_ASN1_D2I_get(ret->signature,d2i_ASN1_BIT_STRING);
233
234 M_ASN1_D2I_Finish(a,X509_CRL_free,ASN1_F_D2I_X509_CRL);
235 }
236
237
238X509_REVOKED *X509_REVOKED_new(void)
239 {
240 X509_REVOKED *ret=NULL;
241 ASN1_CTX c;
242
243 M_ASN1_New_Malloc(ret,X509_REVOKED);
244 M_ASN1_New(ret->serialNumber,M_ASN1_INTEGER_new);
245 M_ASN1_New(ret->revocationDate,M_ASN1_UTCTIME_new);
246 ret->extensions=NULL;
247 return(ret);
248 M_ASN1_New_Error(ASN1_F_X509_REVOKED_NEW);
249 }
250
251X509_CRL_INFO *X509_CRL_INFO_new(void)
252 {
253 X509_CRL_INFO *ret=NULL;
254 ASN1_CTX c;
255
256 M_ASN1_New_Malloc(ret,X509_CRL_INFO);
257 ret->version=NULL;
258 M_ASN1_New(ret->sig_alg,X509_ALGOR_new);
259 M_ASN1_New(ret->issuer,X509_NAME_new);
260 M_ASN1_New(ret->lastUpdate,M_ASN1_UTCTIME_new);
261 ret->nextUpdate=NULL;
262 M_ASN1_New(ret->revoked,sk_X509_REVOKED_new_null);
263 ret->extensions = NULL;
264 sk_X509_REVOKED_set_cmp_func(ret->revoked,X509_REVOKED_cmp);
265 return(ret);
266 M_ASN1_New_Error(ASN1_F_X509_CRL_INFO_NEW);
267 }
268
269X509_CRL *X509_CRL_new(void)
270 {
271 X509_CRL *ret=NULL;
272 ASN1_CTX c;
273
274 M_ASN1_New_Malloc(ret,X509_CRL);
275 ret->references=1;
276 M_ASN1_New(ret->crl,X509_CRL_INFO_new);
277 M_ASN1_New(ret->sig_alg,X509_ALGOR_new);
278 M_ASN1_New(ret->signature,M_ASN1_BIT_STRING_new);
279 return(ret);
280 M_ASN1_New_Error(ASN1_F_X509_CRL_NEW);
281 }
282
283void X509_REVOKED_free(X509_REVOKED *a)
284 {
285 if (a == NULL) return;
286 M_ASN1_INTEGER_free(a->serialNumber);
287 M_ASN1_UTCTIME_free(a->revocationDate);
288 sk_X509_EXTENSION_pop_free(a->extensions,X509_EXTENSION_free);
289 OPENSSL_free(a);
290 }
291
292void X509_CRL_INFO_free(X509_CRL_INFO *a)
293 {
294 if (a == NULL) return;
295 M_ASN1_INTEGER_free(a->version);
296 X509_ALGOR_free(a->sig_alg);
297 X509_NAME_free(a->issuer);
298 M_ASN1_UTCTIME_free(a->lastUpdate);
299 if (a->nextUpdate)
300 M_ASN1_UTCTIME_free(a->nextUpdate);
301 sk_X509_REVOKED_pop_free(a->revoked,X509_REVOKED_free);
302 sk_X509_EXTENSION_pop_free(a->extensions,X509_EXTENSION_free);
303 OPENSSL_free(a);
304 }
305
306void X509_CRL_free(X509_CRL *a)
307 {
308 int i;
309
310 if (a == NULL) return;
311
312 i=CRYPTO_add(&a->references,-1,CRYPTO_LOCK_X509_CRL);
313#ifdef REF_PRINT
314 REF_PRINT("X509_CRL",a);
315#endif
316 if (i > 0) return;
317#ifdef REF_CHECK
318 if (i < 0)
319 {
320 fprintf(stderr,"X509_CRL_free, bad reference count\n");
321 abort();
322 }
323#endif
324
325 X509_CRL_INFO_free(a->crl);
326 X509_ALGOR_free(a->sig_alg);
327 M_ASN1_BIT_STRING_free(a->signature);
328 OPENSSL_free(a);
329 } 106 }
107 return 1;
108}
109
110
111ASN1_SEQUENCE_cb(X509_CRL_INFO, crl_inf_cb) = {
112 ASN1_OPT(X509_CRL_INFO, version, ASN1_INTEGER),
113 ASN1_SIMPLE(X509_CRL_INFO, sig_alg, X509_ALGOR),
114 ASN1_SIMPLE(X509_CRL_INFO, issuer, X509_NAME),
115 ASN1_SIMPLE(X509_CRL_INFO, lastUpdate, ASN1_TIME),
116 ASN1_OPT(X509_CRL_INFO, nextUpdate, ASN1_TIME),
117 ASN1_SEQUENCE_OF_OPT(X509_CRL_INFO, revoked, X509_REVOKED),
118 ASN1_EXP_SEQUENCE_OF_OPT(X509_CRL_INFO, extensions, X509_EXTENSION, 0)
119} ASN1_SEQUENCE_END_cb(X509_CRL_INFO, X509_CRL_INFO)
120
121ASN1_SEQUENCE_ref(X509_CRL, 0, CRYPTO_LOCK_X509_CRL) = {
122 ASN1_SIMPLE(X509_CRL, crl, X509_CRL_INFO),
123 ASN1_SIMPLE(X509_CRL, sig_alg, X509_ALGOR),
124 ASN1_SIMPLE(X509_CRL, signature, ASN1_BIT_STRING)
125} ASN1_SEQUENCE_END_ref(X509_CRL, X509_CRL)
126
127IMPLEMENT_ASN1_FUNCTIONS(X509_REVOKED)
128IMPLEMENT_ASN1_FUNCTIONS(X509_CRL_INFO)
129IMPLEMENT_ASN1_FUNCTIONS(X509_CRL)
130IMPLEMENT_ASN1_DUP_FUNCTION(X509_CRL)
330 131
331static int X509_REVOKED_cmp(const X509_REVOKED * const *a, 132static int X509_REVOKED_cmp(const X509_REVOKED * const *a,
332 const X509_REVOKED * const *b) 133 const X509_REVOKED * const *b)
@@ -342,6 +143,19 @@ static int X509_REVOKED_seq_cmp(const X509_REVOKED * const *a,
342 return((*a)->sequence-(*b)->sequence); 143 return((*a)->sequence-(*b)->sequence);
343 } 144 }
344 145
146int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev)
147{
148 X509_CRL_INFO *inf;
149 inf = crl->crl;
150 if(!inf->revoked)
151 inf->revoked = sk_X509_REVOKED_new(X509_REVOKED_cmp);
152 if(!inf->revoked || !sk_X509_REVOKED_push(inf->revoked, rev)) {
153 ASN1err(ASN1_F_X509_CRL_ADD0_REVOKED, ERR_R_MALLOC_FAILURE);
154 return 0;
155 }
156 return 1;
157}
158
345IMPLEMENT_STACK_OF(X509_REVOKED) 159IMPLEMENT_STACK_OF(X509_REVOKED)
346IMPLEMENT_ASN1_SET_OF(X509_REVOKED) 160IMPLEMENT_ASN1_SET_OF(X509_REVOKED)
347IMPLEMENT_STACK_OF(X509_CRL) 161IMPLEMENT_STACK_OF(X509_CRL)
diff --git a/src/lib/libcrypto/asn1/x_exten.c b/src/lib/libcrypto/asn1/x_exten.c
index fbfd963b40..702421b6c8 100644
--- a/src/lib/libcrypto/asn1/x_exten.c
+++ b/src/lib/libcrypto/asn1/x_exten.c
@@ -1,139 +1,71 @@
1/* crypto/asn1/x_exten.c */ 1/* x_exten.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
3 * All rights reserved. 3 * project 2000.
4 */
5/* ====================================================================
6 * Copyright (c) 2000 The OpenSSL Project. All rights reserved.
4 * 7 *
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 8 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
25 * are met: 10 * are met:
26 * 1. Redistributions of source code must retain the copyright 11 *
27 * notice, this list of conditions and the following disclaimer. 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
28 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the 16 * notice, this list of conditions and the following disclaimer in
30 * documentation and/or other materials provided with the distribution. 17 * the documentation and/or other materials provided with the
31 * 3. All advertising materials mentioning features or use of this software 18 * distribution.
32 * must display the following acknowledgement: 19 *
33 * "This product includes cryptographic software written by 20 * 3. All advertising materials mentioning features or use of this
34 * Eric Young (eay@cryptsoft.com)" 21 * software must display the following acknowledgment:
35 * The word 'cryptographic' can be left out if the rouines from the library 22 * "This product includes software developed by the OpenSSL Project
36 * being used are not cryptographic related :-). 23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
37 * 4. If you include any Windows specific code (or a derivative thereof) from 24 *
38 * the apps directory (application code) you must include an acknowledgement: 25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 26 * endorse or promote products derived from this software without
40 * 27 * prior written permission. For written permission, please contact
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 28 * licensing@OpenSSL.org.
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 *
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30 * 5. Products derived from this software may not be called "OpenSSL"
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 31 * nor may "OpenSSL" appear in their names without prior written
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 * permission of the OpenSSL Project.
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 33 *
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 * 6. Redistributions of any form whatsoever must retain the following
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 * acknowledgment:
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 * "This product includes software developed by the OpenSSL Project
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
51 * SUCH DAMAGE. 38 *
52 * 39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
53 * The licence and distribution terms for any publically available version or 40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
54 * derivative of this code cannot be changed. i.e. this code cannot simply be 41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
55 * copied and put under another distribution licence 42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
56 * [including the GNU Public Licence.] 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 */ 57 */
58 58
59#include <stdio.h> 59#include <stddef.h>
60#include "cryptlib.h"
61#include <openssl/objects.h>
62#include <openssl/asn1_mac.h>
63#include <openssl/x509.h> 60#include <openssl/x509.h>
61#include <openssl/asn1.h>
62#include <openssl/asn1t.h>
64 63
65int i2d_X509_EXTENSION(X509_EXTENSION *a, unsigned char **pp) 64ASN1_SEQUENCE(X509_EXTENSION) = {
66 { 65 ASN1_SIMPLE(X509_EXTENSION, object, ASN1_OBJECT),
67 int k=0; 66 ASN1_OPT(X509_EXTENSION, critical, ASN1_BOOLEAN),
68 int r=0,ret=0; 67 ASN1_SIMPLE(X509_EXTENSION, value, ASN1_OCTET_STRING)
69 unsigned char **p=NULL; 68} ASN1_SEQUENCE_END(X509_EXTENSION)
70
71 if (a == NULL) return(0);
72
73 p=NULL;
74 for (;;)
75 {
76 if (k)
77 {
78 r=ASN1_object_size(1,ret,V_ASN1_SEQUENCE);
79 if (pp == NULL) return(r);
80 p=pp;
81 ASN1_put_object(p,1,ret,V_ASN1_SEQUENCE,
82 V_ASN1_UNIVERSAL);
83 }
84
85 ret+=i2d_ASN1_OBJECT(a->object,p);
86 if ((a->critical) || a->netscape_hack)
87 ret+=i2d_ASN1_BOOLEAN(a->critical,p);
88 ret+=i2d_ASN1_OCTET_STRING(a->value,p);
89 if (k++) return(r);
90 }
91 }
92
93X509_EXTENSION *d2i_X509_EXTENSION(X509_EXTENSION **a, unsigned char **pp,
94 long length)
95 {
96 int i;
97 M_ASN1_D2I_vars(a,X509_EXTENSION *,X509_EXTENSION_new);
98
99 M_ASN1_D2I_Init();
100 M_ASN1_D2I_start_sequence();
101 M_ASN1_D2I_get(ret->object,d2i_ASN1_OBJECT);
102
103 ret->netscape_hack=0;
104 if ((c.slen != 0) &&
105 (M_ASN1_next == (V_ASN1_UNIVERSAL|V_ASN1_BOOLEAN)))
106 {
107 c.q=c.p;
108 if (d2i_ASN1_BOOLEAN(&i,&c.p,c.slen) < 0) goto err;
109 ret->critical=i;
110 c.slen-=(c.p-c.q);
111 if (ret->critical == 0) ret->netscape_hack=1;
112 }
113 M_ASN1_D2I_get(ret->value,d2i_ASN1_OCTET_STRING);
114
115 M_ASN1_D2I_Finish(a,X509_EXTENSION_free,ASN1_F_D2I_X509_EXTENSION);
116 }
117
118X509_EXTENSION *X509_EXTENSION_new(void)
119 {
120 X509_EXTENSION *ret=NULL;
121 ASN1_CTX c;
122
123 M_ASN1_New_Malloc(ret,X509_EXTENSION);
124 ret->object=OBJ_nid2obj(NID_undef);
125 M_ASN1_New(ret->value,M_ASN1_OCTET_STRING_new);
126 ret->critical=0;
127 ret->netscape_hack=0;
128 return(ret);
129 M_ASN1_New_Error(ASN1_F_X509_EXTENSION_NEW);
130 }
131
132void X509_EXTENSION_free(X509_EXTENSION *a)
133 {
134 if (a == NULL) return;
135 ASN1_OBJECT_free(a->object);
136 M_ASN1_OCTET_STRING_free(a->value);
137 OPENSSL_free(a);
138 }
139 69
70IMPLEMENT_ASN1_FUNCTIONS(X509_EXTENSION)
71IMPLEMENT_ASN1_DUP_FUNCTION(X509_EXTENSION)
diff --git a/src/lib/libcrypto/asn1/x_info.c b/src/lib/libcrypto/asn1/x_info.c
index 5e62fc2f6f..d44f6cdb01 100644
--- a/src/lib/libcrypto/asn1/x_info.c
+++ b/src/lib/libcrypto/asn1/x_info.c
@@ -59,7 +59,7 @@
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/evp.h> 61#include <openssl/evp.h>
62#include <openssl/asn1_mac.h> 62#include <openssl/asn1.h>
63#include <openssl/x509.h> 63#include <openssl/x509.h>
64 64
65X509_INFO *X509_INFO_new(void) 65X509_INFO *X509_INFO_new(void)
diff --git a/src/lib/libcrypto/asn1/x_long.c b/src/lib/libcrypto/asn1/x_long.c
new file mode 100644
index 0000000000..c5f25956cb
--- /dev/null
+++ b/src/lib/libcrypto/asn1/x_long.c
@@ -0,0 +1,169 @@
1/* x_long.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) 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/asn1t.h>
62
63/* Custom primitive type for long handling. This converts between an ASN1_INTEGER
64 * and a long directly.
65 */
66
67
68static int long_new(ASN1_VALUE **pval, const ASN1_ITEM *it);
69static void long_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
70
71static int long_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it);
72static int long_c2i(ASN1_VALUE **pval, unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it);
73
74static ASN1_PRIMITIVE_FUNCS long_pf = {
75 NULL, 0,
76 long_new,
77 long_free,
78 long_free, /* Clear should set to initial value */
79 long_c2i,
80 long_i2c
81};
82
83ASN1_ITEM_start(LONG)
84 ASN1_ITYPE_PRIMITIVE, V_ASN1_INTEGER, NULL, 0, &long_pf, ASN1_LONG_UNDEF, "LONG"
85ASN1_ITEM_end(LONG)
86
87ASN1_ITEM_start(ZLONG)
88 ASN1_ITYPE_PRIMITIVE, V_ASN1_INTEGER, NULL, 0, &long_pf, 0, "ZLONG"
89ASN1_ITEM_end(ZLONG)
90
91static int long_new(ASN1_VALUE **pval, const ASN1_ITEM *it)
92{
93 *(long *)pval = it->size;
94 return 1;
95}
96
97static void long_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
98{
99 *(long *)pval = it->size;
100}
101
102static int long_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it)
103{
104 long ltmp;
105 unsigned long utmp;
106 int clen, pad, i;
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
113 if(ltmp == it->size) return -1;
114 /* Convert the long to positive: we subtract one if negative so
115 * we can cleanly handle the padding if only the MSB of the leading
116 * octet is set.
117 */
118 if(ltmp < 0) utmp = -ltmp - 1;
119 else utmp = ltmp;
120 clen = BN_num_bits_word(utmp);
121 /* If MSB of leading octet set we need to pad */
122 if(!(clen & 0x7)) pad = 1;
123 else pad = 0;
124
125 /* Convert number of bits to number of octets */
126 clen = (clen + 7) >> 3;
127
128 if(cont) {
129 if(pad) *cont++ = (ltmp < 0) ? 0xff : 0;
130 for(i = clen - 1; i >= 0; i--) {
131 cont[i] = (unsigned char)(utmp & 0xff);
132 if(ltmp < 0) cont[i] ^= 0xff;
133 utmp >>= 8;
134 }
135 }
136 return clen + pad;
137}
138
139static int long_c2i(ASN1_VALUE **pval, unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it)
140{
141 int neg, i;
142 long ltmp;
143 unsigned long utmp = 0;
144 char *cp = (char *)pval;
145 if(len > sizeof(long)) {
146 ASN1err(ASN1_F_LONG_C2I, ASN1_R_INTEGER_TOO_LARGE_FOR_LONG);
147 return 0;
148 }
149 /* Is it negative? */
150 if(len && (cont[0] & 0x80)) neg = 1;
151 else neg = 0;
152 utmp = 0;
153 for(i = 0; i < len; i++) {
154 utmp <<= 8;
155 if(neg) utmp |= cont[i] ^ 0xff;
156 else utmp |= cont[i];
157 }
158 ltmp = (long)utmp;
159 if(neg) {
160 ltmp++;
161 ltmp = -ltmp;
162 }
163 if(ltmp == it->size) {
164 ASN1err(ASN1_F_LONG_C2I, ASN1_R_INTEGER_TOO_LARGE_FOR_LONG);
165 return 0;
166 }
167 memcpy(cp, &ltmp, sizeof(long));
168 return 1;
169}
diff --git a/src/lib/libcrypto/asn1/x_name.c b/src/lib/libcrypto/asn1/x_name.c
index 1885d699ef..caece0f158 100644
--- a/src/lib/libcrypto/asn1/x_name.c
+++ b/src/lib/libcrypto/asn1/x_name.c
@@ -58,212 +58,203 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/objects.h> 61#include <openssl/asn1t.h>
62#include <openssl/asn1_mac.h>
63#include <openssl/x509.h> 62#include <openssl/x509.h>
64 63
65static int i2d_X509_NAME_entries(X509_NAME *a); 64static int x509_name_ex_d2i(ASN1_VALUE **val, unsigned char **in, long len, const ASN1_ITEM *it,
66int i2d_X509_NAME_ENTRY(X509_NAME_ENTRY *a, unsigned char **pp) 65 int tag, int aclass, char opt, ASN1_TLC *ctx);
67 {
68 M_ASN1_I2D_vars(a);
69 66
70 M_ASN1_I2D_len(a->object,i2d_ASN1_OBJECT); 67static int x509_name_ex_i2d(ASN1_VALUE **val, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass);
71 M_ASN1_I2D_len(a->value,i2d_ASN1_PRINTABLE); 68static int x509_name_ex_new(ASN1_VALUE **val, const ASN1_ITEM *it);
69static void x509_name_ex_free(ASN1_VALUE **val, const ASN1_ITEM *it);
72 70
73 M_ASN1_I2D_seq_total(); 71static int x509_name_encode(X509_NAME *a);
74 72
75 M_ASN1_I2D_put(a->object,i2d_ASN1_OBJECT); 73ASN1_SEQUENCE(X509_NAME_ENTRY) = {
76 M_ASN1_I2D_put(a->value,i2d_ASN1_PRINTABLE); 74 ASN1_SIMPLE(X509_NAME_ENTRY, object, ASN1_OBJECT),
75 ASN1_SIMPLE(X509_NAME_ENTRY, value, ASN1_PRINTABLE)
76} ASN1_SEQUENCE_END(X509_NAME_ENTRY)
77 77
78 M_ASN1_I2D_finish(); 78IMPLEMENT_ASN1_FUNCTIONS(X509_NAME_ENTRY)
79 } 79IMPLEMENT_ASN1_DUP_FUNCTION(X509_NAME_ENTRY)
80 80
81X509_NAME_ENTRY *d2i_X509_NAME_ENTRY(X509_NAME_ENTRY **a, unsigned char **pp, 81/* For the "Name" type we need a SEQUENCE OF { SET OF X509_NAME_ENTRY }
82 long length) 82 * so declare two template wrappers for this
83 { 83 */
84 M_ASN1_D2I_vars(a,X509_NAME_ENTRY *,X509_NAME_ENTRY_new);
85 84
86 M_ASN1_D2I_Init(); 85ASN1_ITEM_TEMPLATE(X509_NAME_ENTRIES) =
87 M_ASN1_D2I_start_sequence(); 86 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SET_OF, 0, RDNS, X509_NAME_ENTRY)
88 M_ASN1_D2I_get(ret->object,d2i_ASN1_OBJECT); 87ASN1_ITEM_TEMPLATE_END(X509_NAME_ENTRIES)
89 M_ASN1_D2I_get(ret->value,d2i_ASN1_PRINTABLE);
90 ret->set=0;
91 M_ASN1_D2I_Finish(a,X509_NAME_ENTRY_free,ASN1_F_D2I_X509_NAME_ENTRY);
92 }
93 88
94int i2d_X509_NAME(X509_NAME *a, unsigned char **pp) 89ASN1_ITEM_TEMPLATE(X509_NAME_INTERNAL) =
95 { 90 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, Name, X509_NAME_ENTRIES)
96 int ret; 91ASN1_ITEM_TEMPLATE_END(X509_NAME_INTERNAL)
97 92
98 if (a == NULL) return(0); 93/* Normally that's where it would end: we'd have two nested STACK structures
99 if (a->modified) 94 * representing the ASN1. Unfortunately X509_NAME uses a completely different
100 { 95 * form and caches encodings so we have to process the internal form and convert
101 ret=i2d_X509_NAME_entries(a); 96 * to the external form.
102 if (ret < 0) return(ret); 97 */
103 }
104
105 ret=a->bytes->length;
106 if (pp != NULL)
107 {
108 memcpy(*pp,a->bytes->data,ret);
109 *pp+=ret;
110 }
111 return(ret);
112 }
113
114static int i2d_X509_NAME_entries(X509_NAME *a)
115 {
116 X509_NAME_ENTRY *ne,*fe=NULL;
117 STACK_OF(X509_NAME_ENTRY) *sk;
118 BUF_MEM *buf=NULL;
119 int set=0,r,ret=0;
120 int i;
121 unsigned char *p;
122 int size=0;
123 98
124 sk=a->entries; 99const ASN1_EXTERN_FUNCS x509_name_ff = {
125 for (i=0; i<sk_X509_NAME_ENTRY_num(sk); i++) 100 NULL,
126 { 101 x509_name_ex_new,
127 ne=sk_X509_NAME_ENTRY_value(sk,i); 102 x509_name_ex_free,
128 if (fe == NULL) 103 0, /* Default clear behaviour is OK */
129 { 104 x509_name_ex_d2i,
130 fe=ne; 105 x509_name_ex_i2d
131 size=0; 106};
132 } 107
108IMPLEMENT_EXTERN_ASN1(X509_NAME, V_ASN1_SEQUENCE, x509_name_ff)
109
110IMPLEMENT_ASN1_FUNCTIONS(X509_NAME)
111IMPLEMENT_ASN1_DUP_FUNCTION(X509_NAME)
112
113static int x509_name_ex_new(ASN1_VALUE **val, const ASN1_ITEM *it)
114{
115 X509_NAME *ret = NULL;
116 ret = OPENSSL_malloc(sizeof(X509_NAME));
117 if(!ret) goto memerr;
118 if ((ret->entries=sk_X509_NAME_ENTRY_new_null()) == NULL)
119 goto memerr;
120 if((ret->bytes = BUF_MEM_new()) == NULL) goto memerr;
121 ret->modified=1;
122 *val = (ASN1_VALUE *)ret;
123 return 1;
133 124
134 if (ne->set != set) 125 memerr:
135 { 126 ASN1err(ASN1_F_X509_NAME_NEW, ERR_R_MALLOC_FAILURE);
136 ret+=ASN1_object_size(1,size,V_ASN1_SET); 127 if (ret)
137 fe->size=size;
138 fe=ne;
139 size=0;
140 set=ne->set;
141 }
142 size+=i2d_X509_NAME_ENTRY(ne,NULL);
143 }
144 if (fe != NULL)
145 { 128 {
146 /* SET OF needed only if entries is non empty */ 129 if (ret->entries)
147 ret+=ASN1_object_size(1,size,V_ASN1_SET); 130 sk_X509_NAME_ENTRY_free(ret->entries);
148 fe->size=size; 131 OPENSSL_free(ret);
149 } 132 }
133 return 0;
134}
150 135
151 r=ASN1_object_size(1,ret,V_ASN1_SEQUENCE); 136static void x509_name_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
152 137{
153 buf=a->bytes; 138 X509_NAME *a;
154 if (!BUF_MEM_grow(buf,r)) goto err; 139 if(!pval || !*pval)
155 p=(unsigned char *)buf->data; 140 return;
156 141 a = (X509_NAME *)*pval;
157 ASN1_put_object(&p,1,ret,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);
158
159 set= -1;
160 for (i=0; i<sk_X509_NAME_ENTRY_num(sk); i++)
161 {
162 ne=sk_X509_NAME_ENTRY_value(sk,i);
163 if (set != ne->set)
164 {
165 set=ne->set;
166 ASN1_put_object(&p,1,ne->size,
167 V_ASN1_SET,V_ASN1_UNIVERSAL);
168 }
169 i2d_X509_NAME_ENTRY(ne,&p);
170 }
171 a->modified=0;
172 return(r);
173err:
174 return(-1);
175 }
176 142
177X509_NAME *d2i_X509_NAME(X509_NAME **a, unsigned char **pp, long length) 143 BUF_MEM_free(a->bytes);
178 { 144 sk_X509_NAME_ENTRY_pop_free(a->entries,X509_NAME_ENTRY_free);
179 int set=0,i; 145 OPENSSL_free(a);
180 int idx=0; 146 *pval = NULL;
181 unsigned char *orig; 147}
182 M_ASN1_D2I_vars(a,X509_NAME *,X509_NAME_new);
183 148
184 orig= *pp; 149/* Used with sk_pop_free() to free up the internal representation.
185 if (sk_X509_NAME_ENTRY_num(ret->entries) > 0) 150 * NB: we only free the STACK and not its contents because it is
186 { 151 * already present in the X509_NAME structure.
187 while (sk_X509_NAME_ENTRY_num(ret->entries) > 0) 152 */
188 X509_NAME_ENTRY_free(
189 sk_X509_NAME_ENTRY_pop(ret->entries));
190 }
191 153
192 M_ASN1_D2I_Init(); 154static void sk_internal_free(void *a)
193 M_ASN1_D2I_start_sequence(); 155{
194 for (;;) 156 sk_free(a);
195 { 157}
196 if (M_ASN1_D2I_end_sequence()) break; 158
197 M_ASN1_D2I_get_set_type(X509_NAME_ENTRY,ret->entries, 159static int x509_name_ex_d2i(ASN1_VALUE **val, unsigned char **in, long len, const ASN1_ITEM *it,
198 d2i_X509_NAME_ENTRY, 160 int tag, int aclass, char opt, ASN1_TLC *ctx)
199 X509_NAME_ENTRY_free); 161{
200 for (; idx < sk_X509_NAME_ENTRY_num(ret->entries); idx++) 162 unsigned char *p = *in, *q;
201 { 163 STACK *intname = NULL;
202 sk_X509_NAME_ENTRY_value(ret->entries,idx)->set=set; 164 int i, j, ret;
203 } 165 X509_NAME *nm = NULL;
204 set++; 166 STACK_OF(X509_NAME_ENTRY) *entries;
167 X509_NAME_ENTRY *entry;
168 q = p;
169
170 /* Get internal representation of Name */
171 ret = ASN1_item_ex_d2i((ASN1_VALUE **)&intname, &p, len, ASN1_ITEM_rptr(X509_NAME_INTERNAL),
172 tag, aclass, opt, ctx);
173
174 if(ret <= 0) return ret;
175
176 if(*val) x509_name_ex_free(val, NULL);
177 if(!x509_name_ex_new((ASN1_VALUE **)&nm, NULL)) goto err;
178 /* We've decoded it: now cache encoding */
179 if(!BUF_MEM_grow(nm->bytes, p - q)) goto err;
180 memcpy(nm->bytes->data, q, p - q);
181
182 /* Convert internal representation to X509_NAME structure */
183 for(i = 0; i < sk_num(intname); i++) {
184 entries = (STACK_OF(X509_NAME_ENTRY) *)sk_value(intname, i);
185 for(j = 0; j < sk_X509_NAME_ENTRY_num(entries); j++) {
186 entry = sk_X509_NAME_ENTRY_value(entries, j);
187 entry->set = i;
188 if(!sk_X509_NAME_ENTRY_push(nm->entries, entry))
189 goto err;
205 } 190 }
206 191 sk_X509_NAME_ENTRY_free(entries);
207 i=(int)(c.p-orig);
208 if (!BUF_MEM_grow(ret->bytes,i)) goto err;
209 memcpy(ret->bytes->data,orig,i);
210 ret->bytes->length=i;
211 ret->modified=0;
212
213 M_ASN1_D2I_Finish(a,X509_NAME_free,ASN1_F_D2I_X509_NAME);
214 } 192 }
215 193 sk_free(intname);
216X509_NAME *X509_NAME_new(void) 194 nm->modified = 0;
217 { 195 *val = (ASN1_VALUE *)nm;
218 X509_NAME *ret=NULL; 196 *in = p;
219 ASN1_CTX c; 197 return ret;
220 198 err:
221 M_ASN1_New_Malloc(ret,X509_NAME); 199 ASN1err(ASN1_F_D2I_X509_NAME, ERR_R_NESTED_ASN1_ERROR);
222 if ((ret->entries=sk_X509_NAME_ENTRY_new_null()) == NULL) 200 return 0;
223 { c.line=__LINE__; goto err2; } 201}
224 M_ASN1_New(ret->bytes,BUF_MEM_new); 202
225 ret->modified=1; 203static int x509_name_ex_i2d(ASN1_VALUE **val, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass)
226 return(ret); 204{
227 M_ASN1_New_Error(ASN1_F_X509_NAME_NEW); 205 int ret;
206 X509_NAME *a = (X509_NAME *)*val;
207 if(a->modified) {
208 ret = x509_name_encode((X509_NAME *)a);
209 if(ret < 0) return ret;
228 } 210 }
229 211 ret = a->bytes->length;
230X509_NAME_ENTRY *X509_NAME_ENTRY_new(void) 212 if(out != NULL) {
231 { 213 memcpy(*out,a->bytes->data,ret);
232 X509_NAME_ENTRY *ret=NULL; 214 *out+=ret;
233 ASN1_CTX c;
234
235 M_ASN1_New_Malloc(ret,X509_NAME_ENTRY);
236/* M_ASN1_New(ret->object,ASN1_OBJECT_new);*/
237 ret->object=NULL;
238 ret->set=0;
239 M_ASN1_New(ret->value,ASN1_STRING_new);
240 return(ret);
241 M_ASN1_New_Error(ASN1_F_X509_NAME_ENTRY_NEW);
242 } 215 }
216 return ret;
217}
243 218
244void X509_NAME_free(X509_NAME *a) 219static int x509_name_encode(X509_NAME *a)
245 { 220{
246 if(a == NULL) 221 STACK *intname = NULL;
247 return; 222 int len;
248 223 unsigned char *p;
249 BUF_MEM_free(a->bytes); 224 STACK_OF(X509_NAME_ENTRY) *entries = NULL;
250 sk_X509_NAME_ENTRY_pop_free(a->entries,X509_NAME_ENTRY_free); 225 X509_NAME_ENTRY *entry;
251 OPENSSL_free(a); 226 int i, set = -1;
227 intname = sk_new_null();
228 if(!intname) goto memerr;
229 for(i = 0; i < sk_X509_NAME_ENTRY_num(a->entries); i++) {
230 entry = sk_X509_NAME_ENTRY_value(a->entries, i);
231 if(entry->set != set) {
232 entries = sk_X509_NAME_ENTRY_new_null();
233 if(!entries) goto memerr;
234 if(!sk_push(intname, (char *)entries)) goto memerr;
235 set = entry->set;
236 }
237 if(!sk_X509_NAME_ENTRY_push(entries, entry)) goto memerr;
252 } 238 }
239 len = ASN1_item_ex_i2d((ASN1_VALUE **)&intname, NULL, ASN1_ITEM_rptr(X509_NAME_INTERNAL), -1, -1);
240 if (!BUF_MEM_grow(a->bytes,len)) goto memerr;
241 p=(unsigned char *)a->bytes->data;
242 ASN1_item_ex_i2d((ASN1_VALUE **)&intname, &p, ASN1_ITEM_rptr(X509_NAME_INTERNAL), -1, -1);
243 sk_pop_free(intname, sk_internal_free);
244 a->modified = 0;
245 return len;
246 memerr:
247 sk_pop_free(intname, sk_internal_free);
248 ASN1err(ASN1_F_D2I_X509_NAME, ERR_R_MALLOC_FAILURE);
249 return -1;
250}
253 251
254void X509_NAME_ENTRY_free(X509_NAME_ENTRY *a)
255 {
256 if (a == NULL) return;
257 ASN1_OBJECT_free(a->object);
258 M_ASN1_BIT_STRING_free(a->value);
259 OPENSSL_free(a);
260 }
261 252
262int X509_NAME_set(X509_NAME **xn, X509_NAME *name) 253int X509_NAME_set(X509_NAME **xn, X509_NAME *name)
263 { 254 {
264 X509_NAME *in; 255 X509_NAME *in;
265 256
266 if (*xn == NULL) return(0); 257 if (!xn || !name) return(0);
267 258
268 if (*xn != name) 259 if (*xn != name)
269 { 260 {
diff --git a/src/lib/libcrypto/asn1/x_pubkey.c b/src/lib/libcrypto/asn1/x_pubkey.c
index 4397a404b5..55630294b6 100644
--- a/src/lib/libcrypto/asn1/x_pubkey.c
+++ b/src/lib/libcrypto/asn1/x_pubkey.c
@@ -58,62 +58,25 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/asn1_mac.h> 61#include <openssl/asn1t.h>
62#include <openssl/x509.h> 62#include <openssl/x509.h>
63 63
64int i2d_X509_PUBKEY(X509_PUBKEY *a, unsigned char **pp) 64/* Minor tweak to operation: free up EVP_PKEY */
65 { 65static int pubkey_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it)
66 M_ASN1_I2D_vars(a); 66{
67 67 if(operation == ASN1_OP_FREE_POST) {
68 M_ASN1_I2D_len(a->algor, i2d_X509_ALGOR); 68 X509_PUBKEY *pubkey = (X509_PUBKEY *)*pval;
69 M_ASN1_I2D_len(a->public_key, i2d_ASN1_BIT_STRING); 69 EVP_PKEY_free(pubkey->pkey);
70
71 M_ASN1_I2D_seq_total();
72
73 M_ASN1_I2D_put(a->algor, i2d_X509_ALGOR);
74 M_ASN1_I2D_put(a->public_key, i2d_ASN1_BIT_STRING);
75
76 M_ASN1_I2D_finish();
77 }
78
79X509_PUBKEY *d2i_X509_PUBKEY(X509_PUBKEY **a, unsigned char **pp,
80 long length)
81 {
82 M_ASN1_D2I_vars(a,X509_PUBKEY *,X509_PUBKEY_new);
83
84 M_ASN1_D2I_Init();
85 M_ASN1_D2I_start_sequence();
86 M_ASN1_D2I_get(ret->algor,d2i_X509_ALGOR);
87 M_ASN1_D2I_get(ret->public_key,d2i_ASN1_BIT_STRING);
88 if (ret->pkey != NULL)
89 {
90 EVP_PKEY_free(ret->pkey);
91 ret->pkey=NULL;
92 }
93 M_ASN1_D2I_Finish(a,X509_PUBKEY_free,ASN1_F_D2I_X509_PUBKEY);
94 } 70 }
71 return 1;
72}
95 73
96X509_PUBKEY *X509_PUBKEY_new(void) 74ASN1_SEQUENCE_cb(X509_PUBKEY, pubkey_cb) = {
97 { 75 ASN1_SIMPLE(X509_PUBKEY, algor, X509_ALGOR),
98 X509_PUBKEY *ret=NULL; 76 ASN1_SIMPLE(X509_PUBKEY, public_key, ASN1_BIT_STRING)
99 ASN1_CTX c; 77} ASN1_SEQUENCE_END_cb(X509_PUBKEY, X509_PUBKEY)
100
101 M_ASN1_New_Malloc(ret,X509_PUBKEY);
102 M_ASN1_New(ret->algor,X509_ALGOR_new);
103 M_ASN1_New(ret->public_key,M_ASN1_BIT_STRING_new);
104 ret->pkey=NULL;
105 return(ret);
106 M_ASN1_New_Error(ASN1_F_X509_PUBKEY_NEW);
107 }
108 78
109void X509_PUBKEY_free(X509_PUBKEY *a) 79IMPLEMENT_ASN1_FUNCTIONS(X509_PUBKEY)
110 {
111 if (a == NULL) return;
112 X509_ALGOR_free(a->algor);
113 M_ASN1_BIT_STRING_free(a->public_key);
114 if (a->pkey != NULL) EVP_PKEY_free(a->pkey);
115 OPENSSL_free(a);
116 }
117 80
118int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey) 81int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey)
119 { 82 {
@@ -146,7 +109,7 @@ int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey)
146 } 109 }
147 } 110 }
148 else 111 else
149#ifndef NO_DSA 112#ifndef OPENSSL_NO_DSA
150 if (pkey->type == EVP_PKEY_DSA) 113 if (pkey->type == EVP_PKEY_DSA)
151 { 114 {
152 unsigned char *pp; 115 unsigned char *pp;
@@ -206,7 +169,8 @@ EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key)
206 long j; 169 long j;
207 int type; 170 int type;
208 unsigned char *p; 171 unsigned char *p;
209#ifndef NO_DSA 172#ifndef OPENSSL_NO_DSA
173 const unsigned char *cp;
210 X509_ALGOR *a; 174 X509_ALGOR *a;
211#endif 175#endif
212 176
@@ -230,16 +194,16 @@ EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key)
230 } 194 }
231 ret->save_parameters=0; 195 ret->save_parameters=0;
232 196
233#ifndef NO_DSA 197#ifndef OPENSSL_NO_DSA
234 a=key->algor; 198 a=key->algor;
235 if (ret->type == EVP_PKEY_DSA) 199 if (ret->type == EVP_PKEY_DSA)
236 { 200 {
237 if (a->parameter && (a->parameter->type == V_ASN1_SEQUENCE)) 201 if (a->parameter && (a->parameter->type == V_ASN1_SEQUENCE))
238 { 202 {
239 ret->pkey.dsa->write_params=0; 203 ret->pkey.dsa->write_params=0;
240 p=a->parameter->value.sequence->data; 204 cp=p=a->parameter->value.sequence->data;
241 j=a->parameter->value.sequence->length; 205 j=a->parameter->value.sequence->length;
242 if (!d2i_DSAparams(&ret->pkey.dsa,&p,(long)j)) 206 if (!d2i_DSAparams(&ret->pkey.dsa,&cp,(long)j))
243 goto err; 207 goto err;
244 } 208 }
245 ret->save_parameters=1; 209 ret->save_parameters=1;
@@ -289,7 +253,7 @@ int i2d_PUBKEY(EVP_PKEY *a, unsigned char **pp)
289/* The following are equivalents but which return RSA and DSA 253/* The following are equivalents but which return RSA and DSA
290 * keys 254 * keys
291 */ 255 */
292#ifndef NO_RSA 256#ifndef OPENSSL_NO_RSA
293RSA *d2i_RSA_PUBKEY(RSA **a, unsigned char **pp, 257RSA *d2i_RSA_PUBKEY(RSA **a, unsigned char **pp,
294 long length) 258 long length)
295{ 259{
@@ -327,7 +291,7 @@ int i2d_RSA_PUBKEY(RSA *a, unsigned char **pp)
327} 291}
328#endif 292#endif
329 293
330#ifndef NO_DSA 294#ifndef OPENSSL_NO_DSA
331DSA *d2i_DSA_PUBKEY(DSA **a, unsigned char **pp, 295DSA *d2i_DSA_PUBKEY(DSA **a, unsigned char **pp,
332 long length) 296 long length)
333{ 297{
diff --git a/src/lib/libcrypto/asn1/x_req.c b/src/lib/libcrypto/asn1/x_req.c
index 6dddd4f653..b3f18ebc12 100644
--- a/src/lib/libcrypto/asn1/x_req.c
+++ b/src/lib/libcrypto/asn1/x_req.c
@@ -58,200 +58,55 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/asn1_mac.h> 61#include <openssl/asn1t.h>
62#include <openssl/x509.h> 62#include <openssl/x509.h>
63 63
64int i2d_X509_REQ_INFO(X509_REQ_INFO *a, unsigned char **pp) 64/* X509_REQ_INFO is handled in an unusual way to get round
65 { 65 * invalid encodings. Some broken certificate requests don't
66 M_ASN1_I2D_vars(a); 66 * encode the attributes field if it is empty. This is in
67 67 * violation of PKCS#10 but we need to tolerate it. We do
68 if(a->asn1) { 68 * this by making the attributes field OPTIONAL then using
69 if(pp) { 69 * the callback to initialise it to an empty STACK.
70 memcpy(*pp, a->asn1, a->length); 70 *
71 *pp += a->length; 71 * This means that the field will be correctly encoded unless
72 } 72 * we NULL out the field.
73 return a->length; 73 *
74 } 74 * As a result we no longer need the req_kludge field because
75 75 * the information is now contained in the attributes field:
76 M_ASN1_I2D_len(a->version, i2d_ASN1_INTEGER); 76 * 1. If it is NULL then it's the invalid omission.
77 M_ASN1_I2D_len(a->subject, i2d_X509_NAME); 77 * 2. If it is empty it is the correct encoding.
78 M_ASN1_I2D_len(a->pubkey, i2d_X509_PUBKEY); 78 * 3. If it is not empty then some attributes are present.
79 79 *
80 /* this is a *nasty* hack reported to be required to 80 */
81 * allow some CA Software to accept the cert request.
82 * It is not following the PKCS standards ...
83 * PKCS#10 pg 5
84 * attributes [0] IMPLICIT Attributes
85 * NOTE: no OPTIONAL ... so it *must* be there
86 */
87 if (a->req_kludge)
88 {
89 M_ASN1_I2D_len_IMP_SET_opt_type(X509_ATTRIBUTE,a->attributes,i2d_X509_ATTRIBUTE,0);
90 }
91 else
92 {
93 M_ASN1_I2D_len_IMP_SET_type(X509_ATTRIBUTE,a->attributes,
94 i2d_X509_ATTRIBUTE,0);
95 }
96
97 M_ASN1_I2D_seq_total();
98 M_ASN1_I2D_put(a->version, i2d_ASN1_INTEGER);
99 M_ASN1_I2D_put(a->subject, i2d_X509_NAME);
100 M_ASN1_I2D_put(a->pubkey, i2d_X509_PUBKEY);
101 81
102 /* this is a *nasty* hack reported to be required by some CA's. 82static int rinf_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it)
103 * It is not following the PKCS standards ... 83{
104 * PKCS#10 pg 5 84 X509_REQ_INFO *rinf = (X509_REQ_INFO *)*pval;
105 * attributes [0] IMPLICIT Attributes
106 * NOTE: no OPTIONAL ... so it *must* be there
107 */
108 if (a->req_kludge)
109 {
110 M_ASN1_I2D_put_IMP_SET_opt_type(X509_ATTRIBUTE,a->attributes,
111 i2d_X509_ATTRIBUTE,0);
112 }
113 else
114 {
115 M_ASN1_I2D_put_IMP_SET_type(X509_ATTRIBUTE,a->attributes,
116 i2d_X509_ATTRIBUTE,0);
117 }
118 85
119 M_ASN1_I2D_finish(); 86 if(operation == ASN1_OP_NEW_POST) {
87 rinf->attributes = sk_X509_ATTRIBUTE_new_null();
88 if(!rinf->attributes) return 0;
120 } 89 }
121 90 return 1;
122X509_REQ_INFO *d2i_X509_REQ_INFO(X509_REQ_INFO **a, unsigned char **pp, 91}
123 long length) 92
124 { 93ASN1_SEQUENCE_enc(X509_REQ_INFO, enc, rinf_cb) = {
125 M_ASN1_D2I_vars(a,X509_REQ_INFO *,X509_REQ_INFO_new); 94 ASN1_SIMPLE(X509_REQ_INFO, version, ASN1_INTEGER),
126 95 ASN1_SIMPLE(X509_REQ_INFO, subject, X509_NAME),
127 M_ASN1_D2I_Init(); 96 ASN1_SIMPLE(X509_REQ_INFO, pubkey, X509_PUBKEY),
128 M_ASN1_D2I_start_sequence(); 97 /* This isn't really OPTIONAL but it gets round invalid
129 M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER); 98 * encodings
130 M_ASN1_D2I_get(ret->subject,d2i_X509_NAME);
131 M_ASN1_D2I_get(ret->pubkey,d2i_X509_PUBKEY);
132
133 /* this is a *nasty* hack to allow for some CA's that
134 * have been reported as requiring it.
135 * It is not following the PKCS standards ...
136 * PKCS#10 pg 5
137 * attributes [0] IMPLICIT Attributes
138 * NOTE: no OPTIONAL ... so it *must* be there
139 */ 99 */
140 if (asn1_Finish(&c)) 100 ASN1_IMP_SET_OF_OPT(X509_REQ_INFO, attributes, X509_ATTRIBUTE, 0)
141 ret->req_kludge=1; 101} ASN1_SEQUENCE_END_enc(X509_REQ_INFO, X509_REQ_INFO)
142 else
143 {
144 M_ASN1_D2I_get_IMP_set_type(X509_ATTRIBUTE,ret->attributes,
145 d2i_X509_ATTRIBUTE,
146 X509_ATTRIBUTE_free,0);
147 }
148
149 M_ASN1_D2I_Finish(a,X509_REQ_INFO_free,ASN1_F_D2I_X509_REQ_INFO);
150 }
151
152X509_REQ_INFO *X509_REQ_INFO_new(void)
153 {
154 X509_REQ_INFO *ret=NULL;
155 ASN1_CTX c;
156
157 M_ASN1_New_Malloc(ret,X509_REQ_INFO);
158 M_ASN1_New(ret->version,M_ASN1_INTEGER_new);
159 M_ASN1_New(ret->subject,X509_NAME_new);
160 M_ASN1_New(ret->pubkey,X509_PUBKEY_new);
161 M_ASN1_New(ret->attributes,sk_X509_ATTRIBUTE_new_null);
162 ret->req_kludge=0;
163 ret->asn1 = NULL;
164 return(ret);
165 M_ASN1_New_Error(ASN1_F_X509_REQ_INFO_NEW);
166 }
167
168void X509_REQ_INFO_free(X509_REQ_INFO *a)
169 {
170 if (a == NULL) return;
171 if(a->asn1) OPENSSL_free(a->asn1);
172 M_ASN1_INTEGER_free(a->version);
173 X509_NAME_free(a->subject);
174 X509_PUBKEY_free(a->pubkey);
175 sk_X509_ATTRIBUTE_pop_free(a->attributes,X509_ATTRIBUTE_free);
176 OPENSSL_free(a);
177 }
178 102
179int i2d_X509_REQ(X509_REQ *a, unsigned char **pp) 103IMPLEMENT_ASN1_FUNCTIONS(X509_REQ_INFO)
180 {
181 M_ASN1_I2D_vars(a);
182 M_ASN1_I2D_len(a->req_info, i2d_X509_REQ_INFO);
183 M_ASN1_I2D_len(a->sig_alg, i2d_X509_ALGOR);
184 M_ASN1_I2D_len(a->signature, i2d_ASN1_BIT_STRING);
185
186 M_ASN1_I2D_seq_total();
187
188 M_ASN1_I2D_put(a->req_info, i2d_X509_REQ_INFO);
189 M_ASN1_I2D_put(a->sig_alg, i2d_X509_ALGOR);
190 M_ASN1_I2D_put(a->signature, i2d_ASN1_BIT_STRING);
191
192 M_ASN1_I2D_finish();
193 }
194
195X509_REQ *d2i_X509_REQ(X509_REQ **a, unsigned char **pp, long length)
196 {
197 M_ASN1_D2I_vars(a,X509_REQ *,X509_REQ_new);
198
199 M_ASN1_D2I_Init();
200 M_ASN1_D2I_start_sequence();
201 M_ASN1_D2I_get(ret->req_info,d2i_X509_REQ_INFO);
202
203 /* Keep a copy of the original encoding for signature checking */
204 ret->req_info->length = c.p - c.q;
205 if(!(ret->req_info->asn1 = OPENSSL_malloc(ret->req_info->length))) {
206 c.line=__LINE__;
207 c.error = ERR_R_MALLOC_FAILURE;
208 goto err;
209 }
210
211 memcpy(ret->req_info->asn1, c.q, ret->req_info->length);
212
213 M_ASN1_D2I_get(ret->sig_alg,d2i_X509_ALGOR);
214 M_ASN1_D2I_get(ret->signature,d2i_ASN1_BIT_STRING);
215 M_ASN1_D2I_Finish(a,X509_REQ_free,ASN1_F_D2I_X509_REQ);
216 }
217
218X509_REQ *X509_REQ_new(void)
219 {
220 X509_REQ *ret=NULL;
221 ASN1_CTX c;
222
223 M_ASN1_New_Malloc(ret,X509_REQ);
224 ret->references=1;
225 M_ASN1_New(ret->req_info,X509_REQ_INFO_new);
226 M_ASN1_New(ret->sig_alg,X509_ALGOR_new);
227 M_ASN1_New(ret->signature,M_ASN1_BIT_STRING_new);
228 return(ret);
229 M_ASN1_New_Error(ASN1_F_X509_REQ_NEW);
230 }
231
232void X509_REQ_free(X509_REQ *a)
233 {
234 int i;
235
236 if (a == NULL) return;
237
238 i=CRYPTO_add(&a->references,-1,CRYPTO_LOCK_X509_REQ);
239#ifdef REF_PRINT
240 REF_PRINT("X509_REQ",a);
241#endif
242 if (i > 0) return;
243#ifdef REF_CHECK
244 if (i < 0)
245 {
246 fprintf(stderr,"X509_REQ_free, bad reference count\n");
247 abort();
248 }
249#endif
250
251 X509_REQ_INFO_free(a->req_info);
252 X509_ALGOR_free(a->sig_alg);
253 M_ASN1_BIT_STRING_free(a->signature);
254 OPENSSL_free(a);
255 }
256 104
105ASN1_SEQUENCE_ref(X509_REQ, 0, CRYPTO_LOCK_X509_INFO) = {
106 ASN1_SIMPLE(X509_REQ, req_info, X509_REQ_INFO),
107 ASN1_SIMPLE(X509_REQ, sig_alg, X509_ALGOR),
108 ASN1_SIMPLE(X509_REQ, signature, ASN1_BIT_STRING)
109} ASN1_SEQUENCE_END_ref(X509_REQ, X509_REQ)
257 110
111IMPLEMENT_ASN1_FUNCTIONS(X509_REQ)
112IMPLEMENT_ASN1_DUP_FUNCTION(X509_REQ)
diff --git a/src/lib/libcrypto/asn1/x_sig.c b/src/lib/libcrypto/asn1/x_sig.c
index d79f147647..42efa86c1c 100644
--- a/src/lib/libcrypto/asn1/x_sig.c
+++ b/src/lib/libcrypto/asn1/x_sig.c
@@ -58,53 +58,12 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/asn1_mac.h> 61#include <openssl/asn1t.h>
62#include <openssl/x509.h> 62#include <openssl/x509.h>
63 63
64int i2d_X509_SIG(X509_SIG *a, unsigned char **pp) 64ASN1_SEQUENCE(X509_SIG) = {
65 { 65 ASN1_SIMPLE(X509_SIG, algor, X509_ALGOR),
66 M_ASN1_I2D_vars(a); 66 ASN1_SIMPLE(X509_SIG, digest, ASN1_OCTET_STRING)
67 67} ASN1_SEQUENCE_END(X509_SIG)
68 M_ASN1_I2D_len(a->algor, i2d_X509_ALGOR);
69 M_ASN1_I2D_len(a->digest, i2d_ASN1_OCTET_STRING);
70
71 M_ASN1_I2D_seq_total();
72
73 M_ASN1_I2D_put(a->algor, i2d_X509_ALGOR);
74 M_ASN1_I2D_put(a->digest, i2d_ASN1_OCTET_STRING);
75
76 M_ASN1_I2D_finish();
77 }
78
79X509_SIG *d2i_X509_SIG(X509_SIG **a, unsigned char **pp, long length)
80 {
81 M_ASN1_D2I_vars(a,X509_SIG *,X509_SIG_new);
82
83 M_ASN1_D2I_Init();
84 M_ASN1_D2I_start_sequence();
85 M_ASN1_D2I_get(ret->algor,d2i_X509_ALGOR);
86 M_ASN1_D2I_get(ret->digest,d2i_ASN1_OCTET_STRING);
87 M_ASN1_D2I_Finish(a,X509_SIG_free,ASN1_F_D2I_X509_SIG);
88 }
89
90X509_SIG *X509_SIG_new(void)
91 {
92 X509_SIG *ret=NULL;
93 ASN1_CTX c;
94
95 M_ASN1_New_Malloc(ret,X509_SIG);
96 M_ASN1_New(ret->algor,X509_ALGOR_new);
97 M_ASN1_New(ret->digest,M_ASN1_OCTET_STRING_new);
98 return(ret);
99 M_ASN1_New_Error(ASN1_F_X509_SIG_NEW);
100 }
101
102void X509_SIG_free(X509_SIG *a)
103 {
104 if (a == NULL) return;
105 X509_ALGOR_free(a->algor);
106 M_ASN1_OCTET_STRING_free(a->digest);
107 OPENSSL_free(a);
108 }
109
110 68
69IMPLEMENT_ASN1_FUNCTIONS(X509_SIG)
diff --git a/src/lib/libcrypto/asn1/x_spki.c b/src/lib/libcrypto/asn1/x_spki.c
index 4f01888f7d..2aece077c5 100644
--- a/src/lib/libcrypto/asn1/x_spki.c
+++ b/src/lib/libcrypto/asn1/x_spki.c
@@ -63,104 +63,19 @@
63#include <stdio.h> 63#include <stdio.h>
64#include "cryptlib.h" 64#include "cryptlib.h"
65#include <openssl/x509.h> 65#include <openssl/x509.h>
66#include <openssl/asn1_mac.h> 66#include <openssl/asn1t.h>
67 67
68int i2d_NETSCAPE_SPKAC(NETSCAPE_SPKAC *a, unsigned char **pp) 68ASN1_SEQUENCE(NETSCAPE_SPKAC) = {
69 { 69 ASN1_SIMPLE(NETSCAPE_SPKAC, pubkey, X509_PUBKEY),
70 M_ASN1_I2D_vars(a); 70 ASN1_SIMPLE(NETSCAPE_SPKAC, challenge, ASN1_IA5STRING)
71} ASN1_SEQUENCE_END(NETSCAPE_SPKAC)
71 72
72 M_ASN1_I2D_len(a->pubkey, i2d_X509_PUBKEY); 73IMPLEMENT_ASN1_FUNCTIONS(NETSCAPE_SPKAC)
73 M_ASN1_I2D_len(a->challenge, i2d_ASN1_IA5STRING);
74 74
75 M_ASN1_I2D_seq_total(); 75ASN1_SEQUENCE(NETSCAPE_SPKI) = {
76 76 ASN1_SIMPLE(NETSCAPE_SPKI, spkac, NETSCAPE_SPKAC),
77 M_ASN1_I2D_put(a->pubkey, i2d_X509_PUBKEY); 77 ASN1_SIMPLE(NETSCAPE_SPKI, sig_algor, X509_ALGOR),
78 M_ASN1_I2D_put(a->challenge, i2d_ASN1_IA5STRING); 78 ASN1_SIMPLE(NETSCAPE_SPKI, signature, ASN1_BIT_STRING)
79 79} ASN1_SEQUENCE_END(NETSCAPE_SPKI)
80 M_ASN1_I2D_finish();
81 }
82
83NETSCAPE_SPKAC *d2i_NETSCAPE_SPKAC(NETSCAPE_SPKAC **a, unsigned char **pp,
84 long length)
85 {
86 M_ASN1_D2I_vars(a,NETSCAPE_SPKAC *,NETSCAPE_SPKAC_new);
87
88 M_ASN1_D2I_Init();
89 M_ASN1_D2I_start_sequence();
90 M_ASN1_D2I_get(ret->pubkey,d2i_X509_PUBKEY);
91 M_ASN1_D2I_get(ret->challenge,d2i_ASN1_IA5STRING);
92 M_ASN1_D2I_Finish(a,NETSCAPE_SPKAC_free,ASN1_F_D2I_NETSCAPE_SPKAC);
93 }
94
95NETSCAPE_SPKAC *NETSCAPE_SPKAC_new(void)
96 {
97 NETSCAPE_SPKAC *ret=NULL;
98 ASN1_CTX c;
99
100 M_ASN1_New_Malloc(ret,NETSCAPE_SPKAC);
101 M_ASN1_New(ret->pubkey,X509_PUBKEY_new);
102 M_ASN1_New(ret->challenge,M_ASN1_IA5STRING_new);
103 return(ret);
104 M_ASN1_New_Error(ASN1_F_NETSCAPE_SPKAC_NEW);
105 }
106
107void NETSCAPE_SPKAC_free(NETSCAPE_SPKAC *a)
108 {
109 if (a == NULL) return;
110 X509_PUBKEY_free(a->pubkey);
111 M_ASN1_IA5STRING_free(a->challenge);
112 OPENSSL_free(a);
113 }
114
115int i2d_NETSCAPE_SPKI(NETSCAPE_SPKI *a, unsigned char **pp)
116 {
117 M_ASN1_I2D_vars(a);
118
119 M_ASN1_I2D_len(a->spkac, i2d_NETSCAPE_SPKAC);
120 M_ASN1_I2D_len(a->sig_algor, i2d_X509_ALGOR);
121 M_ASN1_I2D_len(a->signature, i2d_ASN1_BIT_STRING);
122
123 M_ASN1_I2D_seq_total();
124
125 M_ASN1_I2D_put(a->spkac, i2d_NETSCAPE_SPKAC);
126 M_ASN1_I2D_put(a->sig_algor, i2d_X509_ALGOR);
127 M_ASN1_I2D_put(a->signature, i2d_ASN1_BIT_STRING);
128
129 M_ASN1_I2D_finish();
130 }
131
132NETSCAPE_SPKI *d2i_NETSCAPE_SPKI(NETSCAPE_SPKI **a, unsigned char **pp,
133 long length)
134 {
135 M_ASN1_D2I_vars(a,NETSCAPE_SPKI *,NETSCAPE_SPKI_new);
136
137 M_ASN1_D2I_Init();
138 M_ASN1_D2I_start_sequence();
139 M_ASN1_D2I_get(ret->spkac,d2i_NETSCAPE_SPKAC);
140 M_ASN1_D2I_get(ret->sig_algor,d2i_X509_ALGOR);
141 M_ASN1_D2I_get(ret->signature,d2i_ASN1_BIT_STRING);
142 M_ASN1_D2I_Finish(a,NETSCAPE_SPKI_free,ASN1_F_D2I_NETSCAPE_SPKI);
143 }
144
145NETSCAPE_SPKI *NETSCAPE_SPKI_new(void)
146 {
147 NETSCAPE_SPKI *ret=NULL;
148 ASN1_CTX c;
149
150 M_ASN1_New_Malloc(ret,NETSCAPE_SPKI);
151 M_ASN1_New(ret->spkac,NETSCAPE_SPKAC_new);
152 M_ASN1_New(ret->sig_algor,X509_ALGOR_new);
153 M_ASN1_New(ret->signature,M_ASN1_BIT_STRING_new);
154 return(ret);
155 M_ASN1_New_Error(ASN1_F_NETSCAPE_SPKI_NEW);
156 }
157
158void NETSCAPE_SPKI_free(NETSCAPE_SPKI *a)
159 {
160 if (a == NULL) return;
161 NETSCAPE_SPKAC_free(a->spkac);
162 X509_ALGOR_free(a->sig_algor);
163 M_ASN1_BIT_STRING_free(a->signature);
164 OPENSSL_free(a);
165 }
166 80
81IMPLEMENT_ASN1_FUNCTIONS(NETSCAPE_SPKI)
diff --git a/src/lib/libcrypto/asn1/x_val.c b/src/lib/libcrypto/asn1/x_val.c
index 0f8f020b57..dc17c67758 100644
--- a/src/lib/libcrypto/asn1/x_val.c
+++ b/src/lib/libcrypto/asn1/x_val.c
@@ -58,52 +58,12 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/asn1_mac.h> 61#include <openssl/asn1t.h>
62#include <openssl/x509.h> 62#include <openssl/x509.h>
63 63
64int i2d_X509_VAL(X509_VAL *a, unsigned char **pp) 64ASN1_SEQUENCE(X509_VAL) = {
65 { 65 ASN1_SIMPLE(X509_VAL, notBefore, ASN1_TIME),
66 M_ASN1_I2D_vars(a); 66 ASN1_SIMPLE(X509_VAL, notAfter, ASN1_TIME)
67 67} ASN1_SEQUENCE_END(X509_VAL)
68 M_ASN1_I2D_len(a->notBefore,i2d_ASN1_TIME);
69 M_ASN1_I2D_len(a->notAfter,i2d_ASN1_TIME);
70
71 M_ASN1_I2D_seq_total();
72
73 M_ASN1_I2D_put(a->notBefore,i2d_ASN1_TIME);
74 M_ASN1_I2D_put(a->notAfter,i2d_ASN1_TIME);
75
76 M_ASN1_I2D_finish();
77 }
78
79X509_VAL *d2i_X509_VAL(X509_VAL **a, unsigned char **pp, long length)
80 {
81 M_ASN1_D2I_vars(a,X509_VAL *,X509_VAL_new);
82
83 M_ASN1_D2I_Init();
84 M_ASN1_D2I_start_sequence();
85 M_ASN1_D2I_get(ret->notBefore,d2i_ASN1_TIME);
86 M_ASN1_D2I_get(ret->notAfter,d2i_ASN1_TIME);
87 M_ASN1_D2I_Finish(a,X509_VAL_free,ASN1_F_D2I_X509_VAL);
88 }
89
90X509_VAL *X509_VAL_new(void)
91 {
92 X509_VAL *ret=NULL;
93 ASN1_CTX c;
94
95 M_ASN1_New_Malloc(ret,X509_VAL);
96 M_ASN1_New(ret->notBefore,M_ASN1_TIME_new);
97 M_ASN1_New(ret->notAfter,M_ASN1_TIME_new);
98 return(ret);
99 M_ASN1_New_Error(ASN1_F_X509_VAL_NEW);
100 }
101
102void X509_VAL_free(X509_VAL *a)
103 {
104 if (a == NULL) return;
105 M_ASN1_TIME_free(a->notBefore);
106 M_ASN1_TIME_free(a->notAfter);
107 OPENSSL_free(a);
108 }
109 68
69IMPLEMENT_ASN1_FUNCTIONS(X509_VAL)
diff --git a/src/lib/libcrypto/asn1/x_x509.c b/src/lib/libcrypto/asn1/x_x509.c
index 61ba856b17..b50167ce43 100644
--- a/src/lib/libcrypto/asn1/x_x509.c
+++ b/src/lib/libcrypto/asn1/x_x509.c
@@ -59,12 +59,71 @@
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/evp.h> 61#include <openssl/evp.h>
62#include <openssl/asn1_mac.h> 62#include <openssl/asn1t.h>
63#include <openssl/x509.h> 63#include <openssl/x509.h>
64#include <openssl/x509v3.h> 64#include <openssl/x509v3.h>
65 65
66static int x509_meth_num = 0; 66ASN1_SEQUENCE(X509_CINF) = {
67static STACK_OF(CRYPTO_EX_DATA_FUNCS) *x509_meth = NULL; 67 ASN1_EXP_OPT(X509_CINF, version, ASN1_INTEGER, 0),
68 ASN1_SIMPLE(X509_CINF, serialNumber, ASN1_INTEGER),
69 ASN1_SIMPLE(X509_CINF, signature, X509_ALGOR),
70 ASN1_SIMPLE(X509_CINF, issuer, X509_NAME),
71 ASN1_SIMPLE(X509_CINF, validity, X509_VAL),
72 ASN1_SIMPLE(X509_CINF, subject, X509_NAME),
73 ASN1_SIMPLE(X509_CINF, key, X509_PUBKEY),
74 ASN1_IMP_OPT(X509_CINF, issuerUID, ASN1_BIT_STRING, 1),
75 ASN1_IMP_OPT(X509_CINF, subjectUID, ASN1_BIT_STRING, 2),
76 ASN1_EXP_SEQUENCE_OF_OPT(X509_CINF, extensions, X509_EXTENSION, 3)
77} ASN1_SEQUENCE_END(X509_CINF)
78
79IMPLEMENT_ASN1_FUNCTIONS(X509_CINF)
80/* X509 top level structure needs a bit of customisation */
81
82static int x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it)
83{
84 X509 *ret = (X509 *)*pval;
85
86 switch(operation) {
87
88 case ASN1_OP_NEW_POST:
89 ret->valid=0;
90 ret->name = NULL;
91 ret->ex_flags = 0;
92 ret->ex_pathlen = -1;
93 ret->skid = NULL;
94 ret->akid = NULL;
95 ret->aux = NULL;
96 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_X509, ret, &ret->ex_data);
97 break;
98
99 case ASN1_OP_D2I_POST:
100 if (ret->name != NULL) OPENSSL_free(ret->name);
101 ret->name=X509_NAME_oneline(ret->cert_info->subject,NULL,0);
102 break;
103
104 case ASN1_OP_FREE_POST:
105 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_X509, ret, &ret->ex_data);
106 X509_CERT_AUX_free(ret->aux);
107 ASN1_OCTET_STRING_free(ret->skid);
108 AUTHORITY_KEYID_free(ret->akid);
109
110 if (ret->name != NULL) OPENSSL_free(ret->name);
111 break;
112
113 }
114
115 return 1;
116
117}
118
119ASN1_SEQUENCE_ref(X509, x509_cb, CRYPTO_LOCK_X509) = {
120 ASN1_SIMPLE(X509, cert_info, X509_CINF),
121 ASN1_SIMPLE(X509, sig_alg, X509_ALGOR),
122 ASN1_SIMPLE(X509, signature, ASN1_BIT_STRING)
123} ASN1_SEQUENCE_END_ref(X509, X509)
124
125IMPLEMENT_ASN1_FUNCTIONS(X509)
126IMPLEMENT_ASN1_DUP_FUNCTION(X509)
68 127
69static ASN1_METHOD meth={ 128static ASN1_METHOD meth={
70 (int (*)()) i2d_X509, 129 (int (*)()) i2d_X509,
@@ -77,97 +136,11 @@ ASN1_METHOD *X509_asn1_meth(void)
77 return(&meth); 136 return(&meth);
78 } 137 }
79 138
80int i2d_X509(X509 *a, unsigned char **pp)
81 {
82 M_ASN1_I2D_vars(a);
83
84 M_ASN1_I2D_len(a->cert_info, i2d_X509_CINF);
85 M_ASN1_I2D_len(a->sig_alg, i2d_X509_ALGOR);
86 M_ASN1_I2D_len(a->signature, i2d_ASN1_BIT_STRING);
87
88 M_ASN1_I2D_seq_total();
89
90 M_ASN1_I2D_put(a->cert_info, i2d_X509_CINF);
91 M_ASN1_I2D_put(a->sig_alg, i2d_X509_ALGOR);
92 M_ASN1_I2D_put(a->signature, i2d_ASN1_BIT_STRING);
93
94 M_ASN1_I2D_finish();
95 }
96
97X509 *d2i_X509(X509 **a, unsigned char **pp, long length)
98 {
99 M_ASN1_D2I_vars(a,X509 *,X509_new);
100
101 M_ASN1_D2I_Init();
102 M_ASN1_D2I_start_sequence();
103 M_ASN1_D2I_get(ret->cert_info,d2i_X509_CINF);
104 M_ASN1_D2I_get(ret->sig_alg,d2i_X509_ALGOR);
105 M_ASN1_D2I_get(ret->signature,d2i_ASN1_BIT_STRING);
106 if (ret->name != NULL) OPENSSL_free(ret->name);
107 ret->name=X509_NAME_oneline(ret->cert_info->subject,NULL,0);
108
109 M_ASN1_D2I_Finish(a,X509_free,ASN1_F_D2I_X509);
110 }
111
112X509 *X509_new(void)
113 {
114 X509 *ret=NULL;
115 ASN1_CTX c;
116
117 M_ASN1_New_Malloc(ret,X509);
118 ret->valid=0;
119 ret->references=1;
120 ret->name = NULL;
121 ret->ex_flags = 0;
122 ret->ex_pathlen = -1;
123 ret->skid = NULL;
124 ret->akid = NULL;
125 ret->aux = NULL;
126 M_ASN1_New(ret->cert_info,X509_CINF_new);
127 M_ASN1_New(ret->sig_alg,X509_ALGOR_new);
128 M_ASN1_New(ret->signature,M_ASN1_BIT_STRING_new);
129 CRYPTO_new_ex_data(x509_meth, ret, &ret->ex_data);
130 return(ret);
131 M_ASN1_New_Error(ASN1_F_X509_NEW);
132 }
133
134void X509_free(X509 *a)
135 {
136 int i;
137
138 if (a == NULL) return;
139
140 i=CRYPTO_add(&a->references,-1,CRYPTO_LOCK_X509);
141#ifdef REF_PRINT
142 REF_PRINT("X509",a);
143#endif
144 if (i > 0) return;
145#ifdef REF_CHECK
146 if (i < 0)
147 {
148 fprintf(stderr,"X509_free, bad reference count\n");
149 abort();
150 }
151#endif
152
153 CRYPTO_free_ex_data(x509_meth,a,&a->ex_data);
154 X509_CINF_free(a->cert_info);
155 X509_ALGOR_free(a->sig_alg);
156 M_ASN1_BIT_STRING_free(a->signature);
157 X509_CERT_AUX_free(a->aux);
158 ASN1_OCTET_STRING_free(a->skid);
159 AUTHORITY_KEYID_free(a->akid);
160
161 if (a->name != NULL) OPENSSL_free(a->name);
162 OPENSSL_free(a);
163 }
164
165int X509_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, 139int X509_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
166 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) 140 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
167 { 141 {
168 x509_meth_num++; 142 return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509, argl, argp,
169 return(CRYPTO_get_ex_new_index(x509_meth_num-1, 143 new_func, dup_func, free_func);
170 &x509_meth,argl,argp,new_func,dup_func,free_func));
171 } 144 }
172 145
173int X509_set_ex_data(X509 *r, int idx, void *arg) 146int X509_set_ex_data(X509 *r, int idx, void *arg)
diff --git a/src/lib/libcrypto/asn1/x_x509a.c b/src/lib/libcrypto/asn1/x_x509a.c
index ebcce87bf2..f244768b7e 100644
--- a/src/lib/libcrypto/asn1/x_x509a.c
+++ b/src/lib/libcrypto/asn1/x_x509a.c
@@ -59,7 +59,7 @@
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/evp.h> 61#include <openssl/evp.h>
62#include <openssl/asn1_mac.h> 62#include <openssl/asn1t.h>
63#include <openssl/x509.h> 63#include <openssl/x509.h>
64 64
65/* X509_CERT_AUX routines. These are used to encode additional 65/* X509_CERT_AUX routines. These are used to encode additional
@@ -71,72 +71,15 @@
71 71
72static X509_CERT_AUX *aux_get(X509 *x); 72static X509_CERT_AUX *aux_get(X509 *x);
73 73
74X509_CERT_AUX *d2i_X509_CERT_AUX(X509_CERT_AUX **a, unsigned char **pp, long length) 74ASN1_SEQUENCE(X509_CERT_AUX) = {
75{ 75 ASN1_SEQUENCE_OF_OPT(X509_CERT_AUX, trust, ASN1_OBJECT),
76 M_ASN1_D2I_vars(a, X509_CERT_AUX *, X509_CERT_AUX_new); 76 ASN1_IMP_SEQUENCE_OF_OPT(X509_CERT_AUX, reject, ASN1_OBJECT, 0),
77 77 ASN1_OPT(X509_CERT_AUX, alias, ASN1_UTF8STRING),
78 M_ASN1_D2I_Init(); 78 ASN1_OPT(X509_CERT_AUX, keyid, ASN1_OCTET_STRING),
79 M_ASN1_D2I_start_sequence(); 79 ASN1_IMP_SEQUENCE_OF_OPT(X509_CERT_AUX, other, X509_ALGOR, 1)
80 80} ASN1_SEQUENCE_END(X509_CERT_AUX)
81 M_ASN1_D2I_get_seq_opt_type(ASN1_OBJECT, ret->trust,
82 d2i_ASN1_OBJECT, ASN1_OBJECT_free);
83 M_ASN1_D2I_get_IMP_set_opt_type(ASN1_OBJECT, ret->reject,
84 d2i_ASN1_OBJECT, ASN1_OBJECT_free, 0);
85 M_ASN1_D2I_get_opt(ret->alias, d2i_ASN1_UTF8STRING, V_ASN1_UTF8STRING);
86 M_ASN1_D2I_get_opt(ret->keyid, d2i_ASN1_OCTET_STRING, V_ASN1_OCTET_STRING);
87 M_ASN1_D2I_get_IMP_set_opt_type(X509_ALGOR, ret->other,
88 d2i_X509_ALGOR, X509_ALGOR_free, 1);
89
90 M_ASN1_D2I_Finish(a, X509_CERT_AUX_free, ASN1_F_D2I_X509_CERT_AUX);
91}
92
93X509_CERT_AUX *X509_CERT_AUX_new()
94{
95 X509_CERT_AUX *ret = NULL;
96 ASN1_CTX c;
97 M_ASN1_New_Malloc(ret, X509_CERT_AUX);
98 ret->trust = NULL;
99 ret->reject = NULL;
100 ret->alias = NULL;
101 ret->keyid = NULL;
102 ret->other = NULL;
103 return(ret);
104 M_ASN1_New_Error(ASN1_F_X509_CERT_AUX_NEW);
105}
106
107void X509_CERT_AUX_free(X509_CERT_AUX *a)
108{
109 if(a == NULL) return;
110 sk_ASN1_OBJECT_pop_free(a->trust, ASN1_OBJECT_free);
111 sk_ASN1_OBJECT_pop_free(a->reject, ASN1_OBJECT_free);
112 ASN1_UTF8STRING_free(a->alias);
113 ASN1_OCTET_STRING_free(a->keyid);
114 sk_X509_ALGOR_pop_free(a->other, X509_ALGOR_free);
115 OPENSSL_free(a);
116}
117
118int i2d_X509_CERT_AUX(X509_CERT_AUX *a, unsigned char **pp)
119{
120 M_ASN1_I2D_vars(a);
121
122 M_ASN1_I2D_len_SEQUENCE_opt_type(ASN1_OBJECT, a->trust, i2d_ASN1_OBJECT);
123 M_ASN1_I2D_len_IMP_SEQUENCE_opt_type(ASN1_OBJECT, a->reject, i2d_ASN1_OBJECT, 0);
124
125 M_ASN1_I2D_len(a->alias, i2d_ASN1_UTF8STRING);
126 M_ASN1_I2D_len(a->keyid, i2d_ASN1_OCTET_STRING);
127 M_ASN1_I2D_len_IMP_SEQUENCE_opt_type(X509_ALGOR, a->other, i2d_X509_ALGOR, 1);
128 81
129 M_ASN1_I2D_seq_total(); 82IMPLEMENT_ASN1_FUNCTIONS(X509_CERT_AUX)
130
131 M_ASN1_I2D_put_SEQUENCE_opt_type(ASN1_OBJECT, a->trust, i2d_ASN1_OBJECT);
132 M_ASN1_I2D_put_IMP_SEQUENCE_opt_type(ASN1_OBJECT, a->reject, i2d_ASN1_OBJECT, 0);
133
134 M_ASN1_I2D_put(a->alias, i2d_ASN1_UTF8STRING);
135 M_ASN1_I2D_put(a->keyid, i2d_ASN1_OCTET_STRING);
136 M_ASN1_I2D_put_IMP_SEQUENCE_opt_type(X509_ALGOR, a->other, i2d_X509_ALGOR, 1);
137
138 M_ASN1_I2D_finish();
139}
140 83
141static X509_CERT_AUX *aux_get(X509 *x) 84static X509_CERT_AUX *aux_get(X509 *x)
142{ 85{
diff --git a/src/lib/libcrypto/bf/Makefile.ssl b/src/lib/libcrypto/bf/Makefile.ssl
index 9205ee7901..b045f54686 100644
--- a/src/lib/libcrypto/bf/Makefile.ssl
+++ b/src/lib/libcrypto/bf/Makefile.ssl
@@ -12,7 +12,8 @@ INSTALL_PREFIX=
12OPENSSLDIR= /usr/local/ssl 12OPENSSLDIR= /usr/local/ssl
13INSTALLTOP=/usr/local/ssl 13INSTALLTOP=/usr/local/ssl
14MAKE= make -f Makefile.ssl 14MAKE= make -f Makefile.ssl
15MAKEDEPEND= $(TOP)/util/domd $(TOP) 15MAKEDEPPROG= makedepend
16MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl 17MAKEFILE= Makefile.ssl
17AR= ar r 18AR= ar r
18 19
@@ -44,8 +45,7 @@ all: lib
44 45
45lib: $(LIBOBJ) 46lib: $(LIBOBJ)
46 $(AR) $(LIB) $(LIBOBJ) 47 $(AR) $(LIB) $(LIBOBJ)
47 @echo You may get an error following this line. Please ignore. 48 $(RANLIB) $(LIB) || echo Never mind.
48 - $(RANLIB) $(LIB)
49 @touch lib 49 @touch lib
50 50
51# elf 51# elf
@@ -107,13 +107,14 @@ clean:
107 107
108# DO NOT DELETE THIS LINE -- make depend depends on it. 108# DO NOT DELETE THIS LINE -- make depend depends on it.
109 109
110bf_cfb64.o: ../../include/openssl/blowfish.h 110bf_cfb64.o: ../../include/openssl/blowfish.h ../../include/openssl/e_os2.h
111bf_cfb64.o: ../../include/openssl/opensslconf.h bf_locl.h 111bf_cfb64.o: ../../include/openssl/opensslconf.h bf_cfb64.c bf_locl.h
112bf_ecb.o: ../../include/openssl/blowfish.h ../../include/openssl/opensslconf.h 112bf_ecb.o: ../../include/openssl/blowfish.h ../../include/openssl/e_os2.h
113bf_ecb.o: ../../include/openssl/opensslv.h bf_locl.h 113bf_ecb.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
114bf_enc.o: ../../include/openssl/blowfish.h ../../include/openssl/opensslconf.h 114bf_ecb.o: bf_ecb.c bf_locl.h
115bf_enc.o: bf_locl.h 115bf_enc.o: ../../include/openssl/blowfish.h ../../include/openssl/e_os2.h
116bf_ofb64.o: ../../include/openssl/blowfish.h 116bf_enc.o: ../../include/openssl/opensslconf.h bf_enc.c bf_locl.h
117bf_ofb64.o: ../../include/openssl/opensslconf.h bf_locl.h 117bf_ofb64.o: ../../include/openssl/blowfish.h ../../include/openssl/e_os2.h
118bf_skey.o: ../../include/openssl/blowfish.h ../../include/openssl/opensslconf.h 118bf_ofb64.o: ../../include/openssl/opensslconf.h bf_locl.h bf_ofb64.c
119bf_skey.o: bf_locl.h bf_pi.h 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/bf_opts.c b/src/lib/libcrypto/bf/bf_opts.c
index bbe32b28c9..171dada2ca 100644
--- a/src/lib/libcrypto/bf/bf_opts.c
+++ b/src/lib/libcrypto/bf/bf_opts.c
@@ -59,7 +59,7 @@
59/* define PART1, PART2, PART3 or PART4 to build only with a few of the options. 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. */ 60 * This is for machines with 64k code segment size restrictions. */
61 61
62#if !defined(MSDOS) && (!defined(VMS) || defined(__DECC)) 62#if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX)
63#define TIMES 63#define TIMES
64#endif 64#endif
65 65
@@ -82,7 +82,7 @@ OPENSSL_DECLARE_EXIT
82 The __TMS macro will show if it was. If it wasn't defined, we should 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 83 undefine TIMES, since that tells the rest of the program how things
84 should be handled. -- Richard Levitte */ 84 should be handled. -- Richard Levitte */
85#if defined(VMS) && defined(__DECC) && !defined(__TMS) 85#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
86#undef TIMES 86#undef TIMES
87#endif 87#endif
88 88
@@ -322,7 +322,7 @@ int main(int argc, char **argv)
322 break; 322 break;
323 } 323 }
324 exit(0); 324 exit(0);
325#if defined(LINT) || defined(MSDOS) 325#if defined(LINT) || defined(OPENSSL_SYS_MSDOS)
326 return(0); 326 return(0);
327#endif 327#endif
328 } 328 }
diff --git a/src/lib/libcrypto/bf/bf_skey.c b/src/lib/libcrypto/bf/bf_skey.c
index 4d6a232fe0..3673cdee6e 100644
--- a/src/lib/libcrypto/bf/bf_skey.c
+++ b/src/lib/libcrypto/bf/bf_skey.c
@@ -69,7 +69,7 @@ void BF_set_key(BF_KEY *key, int len, const unsigned char *data)
69 const unsigned char *d,*end; 69 const unsigned char *d,*end;
70 70
71 71
72 memcpy((char *)key,(char *)&bf_init,sizeof(BF_KEY)); 72 memcpy(key,&bf_init,sizeof(BF_KEY));
73 p=key->P; 73 p=key->P;
74 74
75 if (len > ((BF_ROUNDS+2)*4)) len=(BF_ROUNDS+2)*4; 75 if (len > ((BF_ROUNDS+2)*4)) len=(BF_ROUNDS+2)*4;
diff --git a/src/lib/libcrypto/bf/bfspeed.c b/src/lib/libcrypto/bf/bfspeed.c
index ecc9dff4e4..f346af64f3 100644
--- a/src/lib/libcrypto/bf/bfspeed.c
+++ b/src/lib/libcrypto/bf/bfspeed.c
@@ -59,7 +59,7 @@
59/* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */ 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 */ 60/* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */
61 61
62#if !defined(MSDOS) && (!defined(VMS) || defined(__DECC)) 62#if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX)
63#define TIMES 63#define TIMES
64#endif 64#endif
65 65
@@ -82,7 +82,7 @@ OPENSSL_DECLARE_EXIT
82 The __TMS macro will show if it was. If it wasn't defined, we should 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 83 undefine TIMES, since that tells the rest of the program how things
84 should be handled. -- Richard Levitte */ 84 should be handled. -- Richard Levitte */
85#if defined(VMS) && defined(__DECC) && !defined(__TMS) 85#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
86#undef TIMES 86#undef TIMES
87#endif 87#endif
88 88
@@ -268,7 +268,7 @@ int main(int argc, char **argv)
268 printf("Blowfish raw ecb bytes per sec = %12.3f (%9.3fuS)\n",b,8.0e6/b); 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); 269 printf("Blowfish cbc bytes per sec = %12.3f (%9.3fuS)\n",c,8.0e6/c);
270 exit(0); 270 exit(0);
271#if defined(LINT) || defined(MSDOS) 271#if defined(LINT) || defined(OPENSSL_SYS_MSDOS)
272 return(0); 272 return(0);
273#endif 273#endif
274 } 274 }
diff --git a/src/lib/libcrypto/bf/bftest.c b/src/lib/libcrypto/bf/bftest.c
index cf67cadefd..09895f2542 100644
--- a/src/lib/libcrypto/bf/bftest.c
+++ b/src/lib/libcrypto/bf/bftest.c
@@ -63,7 +63,7 @@
63#include <string.h> 63#include <string.h>
64#include <stdlib.h> 64#include <stdlib.h>
65 65
66#ifdef NO_BF 66#ifdef OPENSSL_NO_BF
67int main(int argc, char *argv[]) 67int main(int argc, char *argv[])
68{ 68{
69 printf("No BF support\n"); 69 printf("No BF support\n");
diff --git a/src/lib/libcrypto/bf/blowfish.h b/src/lib/libcrypto/bf/blowfish.h
index 78acfd63b4..cd49e85ab2 100644
--- a/src/lib/libcrypto/bf/blowfish.h
+++ b/src/lib/libcrypto/bf/blowfish.h
@@ -59,11 +59,13 @@
59#ifndef HEADER_BLOWFISH_H 59#ifndef HEADER_BLOWFISH_H
60#define HEADER_BLOWFISH_H 60#define HEADER_BLOWFISH_H
61 61
62#include <openssl/e_os2.h>
63
62#ifdef __cplusplus 64#ifdef __cplusplus
63extern "C" { 65extern "C" {
64#endif 66#endif
65 67
66#ifdef NO_BF 68#ifdef OPENSSL_NO_BF
67#error BF is disabled. 69#error BF is disabled.
68#endif 70#endif
69 71
@@ -77,9 +79,9 @@ extern "C" {
77 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 79 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
78 */ 80 */
79 81
80#if defined(WIN16) || defined(__LP32__) 82#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__)
81#define BF_LONG unsigned long 83#define BF_LONG unsigned long
82#elif defined(_CRAY) || defined(__ILP64__) 84#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)
83#define BF_LONG unsigned long 85#define BF_LONG unsigned long
84#define BF_LONG_LOG2 3 86#define BF_LONG_LOG2 3
85/* 87/*
diff --git a/src/lib/libcrypto/bio/Makefile.ssl b/src/lib/libcrypto/bio/Makefile.ssl
index 567d3fb870..de5631a105 100644
--- a/src/lib/libcrypto/bio/Makefile.ssl
+++ b/src/lib/libcrypto/bio/Makefile.ssl
@@ -5,13 +5,14 @@
5DIR= bio 5DIR= bio
6TOP= ../.. 6TOP= ../..
7CC= cc 7CC= cc
8INCLUDES= -I.. -I../../include 8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g 9CFLAG=-g
10INSTALL_PREFIX= 10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl 11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl 12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl 13MAKE= make -f Makefile.ssl
14MAKEDEPEND= $(TOP)/util/domd $(TOP) 14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
15MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
16AR= ar r 17AR= ar r
17 18
@@ -49,8 +50,7 @@ all: lib
49 50
50lib: $(LIBOBJ) 51lib: $(LIBOBJ)
51 $(AR) $(LIB) $(LIBOBJ) 52 $(AR) $(LIB) $(LIBOBJ)
52 @echo You may get an error following this line. Please ignore. 53 $(RANLIB) $(LIB) || echo Never mind.
53 - $(RANLIB) $(LIB)
54 @touch lib 54 @touch lib
55 55
56files: 56files:
@@ -89,156 +89,128 @@ clean:
89 89
90# DO NOT DELETE THIS LINE -- make depend depends on it. 90# DO NOT DELETE THIS LINE -- make depend depends on it.
91 91
92b_dump.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 92b_dump.o: ../../e_os.h ../../include/openssl/bio.h
93b_dump.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 93b_dump.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
94b_dump.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 94b_dump.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
95b_dump.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 95b_dump.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
96b_dump.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 96b_dump.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
97b_dump.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 97b_dump.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
98b_dump.o: ../cryptlib.h 98b_dump.o: ../cryptlib.h b_dump.c
99b_print.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 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 100b_print.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
101b_print.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 101b_print.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
102b_print.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 102b_print.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
103b_print.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 103b_print.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
104b_print.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 104b_print.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
105b_print.o: ../../include/openssl/symhacks.h ../cryptlib.h 105b_print.o: ../cryptlib.h b_print.c
106b_sock.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 106b_sock.o: ../../e_os.h ../../include/openssl/bio.h
107b_sock.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 107b_sock.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
108b_sock.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 108b_sock.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
109b_sock.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 109b_sock.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
110b_sock.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 110b_sock.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
111b_sock.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 111b_sock.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
112b_sock.o: ../cryptlib.h 112b_sock.o: ../cryptlib.h b_sock.c
113bf_buff.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 113bf_buff.o: ../../e_os.h ../../include/openssl/bio.h
114bf_buff.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 114bf_buff.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
115bf_buff.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 115bf_buff.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
116bf_buff.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 116bf_buff.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
117bf_buff.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 117bf_buff.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
118bf_buff.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 118bf_buff.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
119bf_buff.o: ../../include/openssl/err.h ../../include/openssl/evp.h 119bf_buff.o: ../cryptlib.h bf_buff.c
120bf_buff.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 120bf_nbio.o: ../../e_os.h ../../include/openssl/bio.h
121bf_buff.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 121bf_nbio.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
122bf_buff.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 122bf_nbio.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
123bf_buff.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 123bf_nbio.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
124bf_buff.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 124bf_nbio.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
125bf_buff.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 125bf_nbio.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
126bf_buff.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
127bf_buff.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
128bf_buff.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
129bf_buff.o: ../../include/openssl/symhacks.h ../cryptlib.h
130bf_nbio.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
131bf_nbio.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
132bf_nbio.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
133bf_nbio.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
134bf_nbio.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
135bf_nbio.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
136bf_nbio.o: ../../include/openssl/err.h ../../include/openssl/evp.h
137bf_nbio.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
138bf_nbio.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
139bf_nbio.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
140bf_nbio.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
141bf_nbio.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
142bf_nbio.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
143bf_nbio.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
144bf_nbio.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
145bf_nbio.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
146bf_nbio.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 126bf_nbio.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
147bf_nbio.o: ../cryptlib.h 127bf_nbio.o: ../cryptlib.h bf_nbio.c
148bf_null.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 128bf_null.o: ../../e_os.h ../../include/openssl/bio.h
149bf_null.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 129bf_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
150bf_null.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 130bf_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
151bf_null.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 131bf_null.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
152bf_null.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 132bf_null.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
153bf_null.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 133bf_null.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
154bf_null.o: ../../include/openssl/err.h ../../include/openssl/evp.h 134bf_null.o: ../cryptlib.h bf_null.c
155bf_null.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 135bio_cb.o: ../../e_os.h ../../include/openssl/bio.h
156bf_null.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 136bio_cb.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
157bf_null.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
158bf_null.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
159bf_null.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
160bf_null.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
161bf_null.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
162bf_null.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
163bf_null.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
164bf_null.o: ../../include/openssl/symhacks.h ../cryptlib.h
165bio_cb.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
166bio_cb.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h
167bio_cb.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 137bio_cb.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
168bio_cb.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 138bio_cb.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
169bio_cb.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 139bio_cb.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
170bio_cb.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 140bio_cb.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
171bio_cb.o: ../cryptlib.h 141bio_cb.o: ../cryptlib.h bio_cb.c
172bio_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h 142bio_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
173bio_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 143bio_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
144bio_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
174bio_err.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 145bio_err.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
175bio_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 146bio_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
176bio_lib.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 147bio_err.o: bio_err.c
177bio_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 148bio_lib.o: ../../e_os.h ../../include/openssl/bio.h
149bio_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
178bio_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 150bio_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
179bio_lib.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 151bio_lib.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
180bio_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 152bio_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
181bio_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 153bio_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
182bio_lib.o: ../cryptlib.h 154bio_lib.o: ../cryptlib.h bio_lib.c
183bss_acpt.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 155bss_acpt.o: ../../e_os.h ../../include/openssl/bio.h
184bss_acpt.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 156bss_acpt.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
185bss_acpt.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 157bss_acpt.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
186bss_acpt.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 158bss_acpt.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
187bss_acpt.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 159bss_acpt.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
188bss_acpt.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 160bss_acpt.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
189bss_acpt.o: ../cryptlib.h 161bss_acpt.o: ../cryptlib.h bss_acpt.c
190bss_bio.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h 162bss_bio.o: ../../e_os.h ../../include/openssl/bio.h
191bss_bio.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 163bss_bio.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
192bss_bio.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 164bss_bio.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
193bss_bio.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 165bss_bio.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
194bss_bio.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 166bss_bio.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
195bss_bio.o: ../../include/openssl/symhacks.h 167bss_bio.o: ../../include/openssl/symhacks.h bss_bio.c
196bss_conn.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 168bss_conn.o: ../../e_os.h ../../include/openssl/bio.h
197bss_conn.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 169bss_conn.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
198bss_conn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 170bss_conn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
199bss_conn.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 171bss_conn.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
200bss_conn.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 172bss_conn.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
201bss_conn.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 173bss_conn.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
202bss_conn.o: ../cryptlib.h 174bss_conn.o: ../cryptlib.h bss_conn.c
203bss_fd.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 175bss_fd.o: ../../e_os.h ../../include/openssl/bio.h
204bss_fd.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 176bss_fd.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
205bss_fd.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 177bss_fd.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
206bss_fd.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 178bss_fd.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
207bss_fd.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 179bss_fd.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
208bss_fd.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 180bss_fd.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
209bss_fd.o: ../cryptlib.h bss_sock.c 181bss_fd.o: ../cryptlib.h bss_fd.c
210bss_file.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 182bss_file.o: ../../e_os.h ../../include/openssl/bio.h
211bss_file.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 183bss_file.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
212bss_file.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 184bss_file.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
213bss_file.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 185bss_file.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
214bss_file.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 186bss_file.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
215bss_file.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 187bss_file.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
216bss_file.o: ../cryptlib.h 188bss_file.o: ../cryptlib.h bss_file.c
217bss_log.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 189bss_log.o: ../../e_os.h ../../include/openssl/bio.h
218bss_log.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 190bss_log.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
219bss_log.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 191bss_log.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
220bss_log.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 192bss_log.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
221bss_log.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 193bss_log.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
222bss_log.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 194bss_log.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
223bss_log.o: ../cryptlib.h 195bss_log.o: ../cryptlib.h bss_log.c
224bss_mem.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 196bss_mem.o: ../../e_os.h ../../include/openssl/bio.h
225bss_mem.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 197bss_mem.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
226bss_mem.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 198bss_mem.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
227bss_mem.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 199bss_mem.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
228bss_mem.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 200bss_mem.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
229bss_mem.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 201bss_mem.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
230bss_mem.o: ../cryptlib.h 202bss_mem.o: ../cryptlib.h bss_mem.c
231bss_null.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 203bss_null.o: ../../e_os.h ../../include/openssl/bio.h
232bss_null.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 204bss_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
233bss_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 205bss_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
234bss_null.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 206bss_null.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
235bss_null.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 207bss_null.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
236bss_null.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 208bss_null.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
237bss_null.o: ../cryptlib.h 209bss_null.o: ../cryptlib.h bss_null.c
238bss_sock.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 210bss_sock.o: ../../e_os.h ../../include/openssl/bio.h
239bss_sock.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 211bss_sock.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
240bss_sock.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 212bss_sock.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
241bss_sock.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 213bss_sock.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
242bss_sock.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 214bss_sock.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
243bss_sock.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 215bss_sock.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
244bss_sock.o: ../cryptlib.h 216bss_sock.o: ../cryptlib.h bss_sock.c
diff --git a/src/lib/libcrypto/bio/b_print.c b/src/lib/libcrypto/bio/b_print.c
index 91a049406e..b7e268f092 100644
--- a/src/lib/libcrypto/bio/b_print.c
+++ b/src/lib/libcrypto/bio/b_print.c
@@ -109,7 +109,7 @@
109#endif 109#endif
110 110
111#if HAVE_LONG_LONG 111#if HAVE_LONG_LONG
112# if defined(WIN32) && !defined(__GNUC__) 112# if defined(OPENSSL_SYS_WIN32) && !defined(__GNUC__)
113# define LLONG _int64 113# define LLONG _int64
114# else 114# else
115# define LLONG long long 115# define LLONG long long
@@ -569,7 +569,7 @@ pow10(int exp)
569} 569}
570 570
571static long 571static long
572round(LDOUBLE value) 572roundv(LDOUBLE value)
573{ 573{
574 long intpart; 574 long intpart;
575 intpart = (long) value; 575 intpart = (long) value;
@@ -621,7 +621,7 @@ fmtfp(
621 621
622 /* we "cheat" by converting the fractional part to integer by 622 /* we "cheat" by converting the fractional part to integer by
623 multiplying by a factor of 10 */ 623 multiplying by a factor of 10 */
624 fracpart = round((pow10(max)) * (ufvalue - intpart)); 624 fracpart = roundv((pow10(max)) * (ufvalue - intpart));
625 625
626 if (fracpart >= pow10(max)) { 626 if (fracpart >= pow10(max)) {
627 intpart++; 627 intpart++;
diff --git a/src/lib/libcrypto/bio/b_sock.c b/src/lib/libcrypto/bio/b_sock.c
index 62cc3f1a0c..dcaef68ea7 100644
--- a/src/lib/libcrypto/bio/b_sock.c
+++ b/src/lib/libcrypto/bio/b_sock.c
@@ -56,7 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_SOCK 59#ifndef OPENSSL_NO_SOCK
60 60
61#include <stdio.h> 61#include <stdio.h>
62#include <stdlib.h> 62#include <stdlib.h>
@@ -65,21 +65,21 @@
65#include "cryptlib.h" 65#include "cryptlib.h"
66#include <openssl/bio.h> 66#include <openssl/bio.h>
67 67
68#ifdef WIN16 68#ifdef OPENSSL_SYS_WIN16
69#define SOCKET_PROTOCOL 0 /* more microsoft stupidity */ 69#define SOCKET_PROTOCOL 0 /* more microsoft stupidity */
70#else 70#else
71#define SOCKET_PROTOCOL IPPROTO_TCP 71#define SOCKET_PROTOCOL IPPROTO_TCP
72#endif 72#endif
73 73
74#ifdef SO_MAXCONN 74#ifdef SO_MAXCONN
75#define MAX_LISTEN SOMAXCONN
76#elif defined(SO_MAXCONN)
77#define MAX_LISTEN SO_MAXCONN 75#define MAX_LISTEN SO_MAXCONN
76#elif defined(SOMAXCONN)
77#define MAX_LISTEN SOMAXCONN
78#else 78#else
79#define MAX_LISTEN 32 79#define MAX_LISTEN 32
80#endif 80#endif
81 81
82#ifdef WINDOWS 82#ifdef OPENSSL_SYS_WINDOWS
83static int wsa_init_done=0; 83static int wsa_init_done=0;
84#endif 84#endif
85 85
@@ -95,8 +95,10 @@ static struct ghbn_cache_st
95 } ghbn_cache[GHBN_NUM]; 95 } ghbn_cache[GHBN_NUM];
96 96
97static int get_ip(const char *str,unsigned char *ip); 97static int get_ip(const char *str,unsigned char *ip);
98#if 0
98static void ghbn_free(struct hostent *a); 99static void ghbn_free(struct hostent *a);
99static struct hostent *ghbn_dup(struct hostent *a); 100static struct hostent *ghbn_dup(struct hostent *a);
101#endif
100int BIO_get_host_ip(const char *str, unsigned char *ip) 102int BIO_get_host_ip(const char *str, unsigned char *ip)
101 { 103 {
102 int i; 104 int i;
@@ -266,6 +268,7 @@ long BIO_ghbn_ctrl(int cmd, int iarg, char *parg)
266 return(1); 268 return(1);
267 } 269 }
268 270
271#if 0
269static struct hostent *ghbn_dup(struct hostent *a) 272static struct hostent *ghbn_dup(struct hostent *a)
270 { 273 {
271 struct hostent *ret; 274 struct hostent *ret;
@@ -343,20 +346,27 @@ static void ghbn_free(struct hostent *a)
343 OPENSSL_free(a); 346 OPENSSL_free(a);
344 } 347 }
345 348
349#endif
350
346struct hostent *BIO_gethostbyname(const char *name) 351struct hostent *BIO_gethostbyname(const char *name)
347 { 352 {
353#if 1
354 /* Caching gethostbyname() results forever is wrong,
355 * so we have to let the true gethostbyname() worry about this */
356 return gethostbyname(name);
357#else
348 struct hostent *ret; 358 struct hostent *ret;
349 int i,lowi=0,j; 359 int i,lowi=0,j;
350 unsigned long low= (unsigned long)-1; 360 unsigned long low= (unsigned long)-1;
351 361
352/* return(gethostbyname(name)); */
353 362
354#if 0 /* It doesn't make sense to use locking here: The function interface 363# if 0
355 * is not thread-safe, because threads can never be sure when 364 /* It doesn't make sense to use locking here: The function interface
356 * some other thread destroys the data they were given a pointer to. 365 * is not thread-safe, because threads can never be sure when
357 */ 366 * some other thread destroys the data they were given a pointer to.
367 */
358 CRYPTO_w_lock(CRYPTO_LOCK_GETHOSTBYNAME); 368 CRYPTO_w_lock(CRYPTO_LOCK_GETHOSTBYNAME);
359#endif 369# endif
360 j=strlen(name); 370 j=strlen(name);
361 if (j < 128) 371 if (j < 128)
362 { 372 {
@@ -384,20 +394,21 @@ struct hostent *BIO_gethostbyname(const char *name)
384 * parameter is 'char *', instead of 'const char *' 394 * parameter is 'char *', instead of 'const char *'
385 */ 395 */
386 ret=gethostbyname( 396 ret=gethostbyname(
387#ifndef CONST_STRICT 397# ifndef CONST_STRICT
388 (char *) 398 (char *)
389#endif 399# endif
390 name); 400 name);
391 401
392 if (ret == NULL) 402 if (ret == NULL)
393 goto end; 403 goto end;
394 if (j > 128) /* too big to cache */ 404 if (j > 128) /* too big to cache */
395 { 405 {
396#if 0 /* If we were trying to make this function thread-safe (which 406# if 0
397 * is bound to fail), we'd have to give up in this case 407 /* If we were trying to make this function thread-safe (which
398 * (or allocate more memory). */ 408 * is bound to fail), we'd have to give up in this case
409 * (or allocate more memory). */
399 ret = NULL; 410 ret = NULL;
400#endif 411# endif
401 goto end; 412 goto end;
402 } 413 }
403 414
@@ -421,15 +432,17 @@ struct hostent *BIO_gethostbyname(const char *name)
421 ghbn_cache[i].order=BIO_ghbn_miss+BIO_ghbn_hits; 432 ghbn_cache[i].order=BIO_ghbn_miss+BIO_ghbn_hits;
422 } 433 }
423end: 434end:
424#if 0 435# if 0
425 CRYPTO_w_unlock(CRYPTO_LOCK_GETHOSTBYNAME); 436 CRYPTO_w_unlock(CRYPTO_LOCK_GETHOSTBYNAME);
426#endif 437# endif
427 return(ret); 438 return(ret);
439#endif
428 } 440 }
429 441
442
430int BIO_sock_init(void) 443int BIO_sock_init(void)
431 { 444 {
432#ifdef WINDOWS 445#ifdef OPENSSL_SYS_WINDOWS
433 static struct WSAData wsa_state; 446 static struct WSAData wsa_state;
434 447
435 if (!wsa_init_done) 448 if (!wsa_init_done)
@@ -449,13 +462,13 @@ int BIO_sock_init(void)
449 return(-1); 462 return(-1);
450 } 463 }
451 } 464 }
452#endif /* WINDOWS */ 465#endif /* OPENSSL_SYS_WINDOWS */
453 return(1); 466 return(1);
454 } 467 }
455 468
456void BIO_sock_cleanup(void) 469void BIO_sock_cleanup(void)
457 { 470 {
458#ifdef WINDOWS 471#ifdef OPENSSL_SYS_WINDOWS
459 if (wsa_init_done) 472 if (wsa_init_done)
460 { 473 {
461 wsa_init_done=0; 474 wsa_init_done=0;
@@ -465,7 +478,7 @@ void BIO_sock_cleanup(void)
465#endif 478#endif
466 } 479 }
467 480
468#if !defined(VMS) || __VMS_VER >= 70000000 481#if !defined(OPENSSL_SYS_VMS) || __VMS_VER >= 70000000
469 482
470int BIO_socket_ioctl(int fd, long type, unsigned long *arg) 483int BIO_socket_ioctl(int fd, long type, unsigned long *arg)
471 { 484 {
@@ -494,16 +507,16 @@ static int get_ip(const char *str, unsigned char ip[4])
494 { 507 {
495 ok=1; 508 ok=1;
496 tmp[num]=tmp[num]*10+c-'0'; 509 tmp[num]=tmp[num]*10+c-'0';
497 if (tmp[num] > 255) return(-1); 510 if (tmp[num] > 255) return(0);
498 } 511 }
499 else if (c == '.') 512 else if (c == '.')
500 { 513 {
501 if (!ok) return(-1); 514 if (!ok) return(-1);
502 if (num == 3) break; 515 if (num == 3) return(0);
503 num++; 516 num++;
504 ok=0; 517 ok=0;
505 } 518 }
506 else if ((num == 3) && ok) 519 else if (c == '\0' && (num == 3) && ok)
507 break; 520 break;
508 else 521 else
509 return(0); 522 return(0);
@@ -661,6 +674,7 @@ int BIO_accept(int sock, char **addr)
661 ret=accept(sock,(struct sockaddr *)&from,(void *)&len); 674 ret=accept(sock,(struct sockaddr *)&from,(void *)&len);
662 if (ret == INVALID_SOCKET) 675 if (ret == INVALID_SOCKET)
663 { 676 {
677 if(BIO_sock_should_retry(ret)) return -2;
664 SYSerr(SYS_F_ACCEPT,get_last_socket_error()); 678 SYSerr(SYS_F_ACCEPT,get_last_socket_error());
665 BIOerr(BIO_F_BIO_ACCEPT,BIO_R_ACCEPT_ERROR); 679 BIOerr(BIO_F_BIO_ACCEPT,BIO_R_ACCEPT_ERROR);
666 goto end; 680 goto end;
diff --git a/src/lib/libcrypto/bio/bf_buff.c b/src/lib/libcrypto/bio/bf_buff.c
index c90238bae1..6ccda06596 100644
--- a/src/lib/libcrypto/bio/bf_buff.c
+++ b/src/lib/libcrypto/bio/bf_buff.c
@@ -60,7 +60,6 @@
60#include <errno.h> 60#include <errno.h>
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/bio.h> 62#include <openssl/bio.h>
63#include <openssl/evp.h>
64 63
65static int buffer_write(BIO *h, const char *buf,int num); 64static int buffer_write(BIO *h, const char *buf,int num);
66static int buffer_read(BIO *h, char *buf, int size); 65static int buffer_read(BIO *h, char *buf, int size);
diff --git a/src/lib/libcrypto/bio/bf_lbuf.c b/src/lib/libcrypto/bio/bf_lbuf.c
index 7bcf8ed941..ec0f7eb0b7 100644
--- a/src/lib/libcrypto/bio/bf_lbuf.c
+++ b/src/lib/libcrypto/bio/bf_lbuf.c
@@ -200,7 +200,7 @@ static int linebuffer_write(BIO *b, const char *in, int inl)
200 } 200 }
201 } 201 }
202 202
203#ifdef DEBUG 203#if 0
204BIO_write(b->next_bio, "<*<", 3); 204BIO_write(b->next_bio, "<*<", 3);
205#endif 205#endif
206 i=BIO_write(b->next_bio, 206 i=BIO_write(b->next_bio,
@@ -210,13 +210,13 @@ BIO_write(b->next_bio, "<*<", 3);
210 ctx->obuf_len = orig_olen; 210 ctx->obuf_len = orig_olen;
211 BIO_copy_next_retry(b); 211 BIO_copy_next_retry(b);
212 212
213#ifdef DEBUG 213#if 0
214BIO_write(b->next_bio, ">*>", 3); 214BIO_write(b->next_bio, ">*>", 3);
215#endif 215#endif
216 if (i < 0) return((num > 0)?num:i); 216 if (i < 0) return((num > 0)?num:i);
217 if (i == 0) return(num); 217 if (i == 0) return(num);
218 } 218 }
219#ifdef DEBUG 219#if 0
220BIO_write(b->next_bio, ">*>", 3); 220BIO_write(b->next_bio, ">*>", 3);
221#endif 221#endif
222 if (i < ctx->obuf_len) 222 if (i < ctx->obuf_len)
@@ -229,20 +229,20 @@ BIO_write(b->next_bio, ">*>", 3);
229 buffer if a NL was found and there is anything to write. */ 229 buffer if a NL was found and there is anything to write. */
230 if ((foundnl || p - in > ctx->obuf_size) && p - in > 0) 230 if ((foundnl || p - in > ctx->obuf_size) && p - in > 0)
231 { 231 {
232#ifdef DEBUG 232#if 0
233BIO_write(b->next_bio, "<*<", 3); 233BIO_write(b->next_bio, "<*<", 3);
234#endif 234#endif
235 i=BIO_write(b->next_bio,in,p - in); 235 i=BIO_write(b->next_bio,in,p - in);
236 if (i <= 0) 236 if (i <= 0)
237 { 237 {
238 BIO_copy_next_retry(b); 238 BIO_copy_next_retry(b);
239#ifdef DEBUG 239#if 0
240BIO_write(b->next_bio, ">*>", 3); 240BIO_write(b->next_bio, ">*>", 3);
241#endif 241#endif
242 if (i < 0) return((num > 0)?num:i); 242 if (i < 0) return((num > 0)?num:i);
243 if (i == 0) return(num); 243 if (i == 0) return(num);
244 } 244 }
245#ifdef DEBUG 245#if 0
246BIO_write(b->next_bio, ">*>", 3); 246BIO_write(b->next_bio, ">*>", 3);
247#endif 247#endif
248 num+=i; 248 num+=i;
diff --git a/src/lib/libcrypto/bio/bf_nbio.c b/src/lib/libcrypto/bio/bf_nbio.c
index 413ef5c4c5..c193e9debf 100644
--- a/src/lib/libcrypto/bio/bf_nbio.c
+++ b/src/lib/libcrypto/bio/bf_nbio.c
@@ -61,7 +61,6 @@
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/rand.h> 62#include <openssl/rand.h>
63#include <openssl/bio.h> 63#include <openssl/bio.h>
64#include <openssl/evp.h>
65 64
66/* BIO_put and BIO_get both add to the digest, 65/* BIO_put and BIO_get both add to the digest,
67 * BIO_gets returns the digest */ 66 * BIO_gets returns the digest */
diff --git a/src/lib/libcrypto/bio/bf_null.c b/src/lib/libcrypto/bio/bf_null.c
index 2678a1a85d..c1bf39a904 100644
--- a/src/lib/libcrypto/bio/bf_null.c
+++ b/src/lib/libcrypto/bio/bf_null.c
@@ -60,7 +60,6 @@
60#include <errno.h> 60#include <errno.h>
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/bio.h> 62#include <openssl/bio.h>
63#include <openssl/evp.h>
64 63
65/* BIO_put and BIO_get both add to the digest, 64/* BIO_put and BIO_get both add to the digest,
66 * BIO_gets returns the digest */ 65 * BIO_gets returns the digest */
diff --git a/src/lib/libcrypto/bio/bio.h b/src/lib/libcrypto/bio/bio.h
index 97003b503c..b122c7069d 100644
--- a/src/lib/libcrypto/bio/bio.h
+++ b/src/lib/libcrypto/bio/bio.h
@@ -59,12 +59,13 @@
59#ifndef HEADER_BIO_H 59#ifndef HEADER_BIO_H
60#define HEADER_BIO_H 60#define HEADER_BIO_H
61 61
62#ifndef NO_FP_API 62#ifndef OPENSSL_NO_FP_API
63# include <stdio.h> 63# include <stdio.h>
64#endif 64#endif
65#include <stdarg.h> 65#include <stdarg.h>
66 66
67#include <openssl/crypto.h> 67#include <openssl/crypto.h>
68#include <openssl/e_os2.h>
68 69
69#ifdef __cplusplus 70#ifdef __cplusplus
70extern "C" { 71extern "C" {
@@ -179,7 +180,7 @@ extern "C" {
179#define BIO_retry_type(a) ((a)->flags & BIO_FLAGS_RWS) 180#define BIO_retry_type(a) ((a)->flags & BIO_FLAGS_RWS)
180#define BIO_should_retry(a) ((a)->flags & BIO_FLAGS_SHOULD_RETRY) 181#define BIO_should_retry(a) ((a)->flags & BIO_FLAGS_SHOULD_RETRY)
181 182
182/* The next two are used in conjunction with the 183/* The next three are used in conjunction with the
183 * BIO_should_io_special() condition. After this returns true, 184 * BIO_should_io_special() condition. After this returns true,
184 * BIO *BIO_get_retry_BIO(BIO *bio, int *reason); will walk the BIO 185 * BIO *BIO_get_retry_BIO(BIO *bio, int *reason); will walk the BIO
185 * stack and return the 'reason' for the special and the offending BIO. 186 * stack and return the 'reason' for the special and the offending BIO.
@@ -188,6 +189,8 @@ extern "C" {
188#define BIO_RR_SSL_X509_LOOKUP 0x01 189#define BIO_RR_SSL_X509_LOOKUP 0x01
189/* Returned from the connect BIO when a connect would have blocked */ 190/* Returned from the connect BIO when a connect would have blocked */
190#define BIO_RR_CONNECT 0x02 191#define BIO_RR_CONNECT 0x02
192/* Returned from the accept BIO when an accept would have blocked */
193#define BIO_RR_ACCEPT 0x03
191 194
192/* These are passed by the BIO callback */ 195/* These are passed by the BIO callback */
193#define BIO_CB_FREE 0x01 196#define BIO_CB_FREE 0x01
@@ -215,7 +218,7 @@ typedef struct bio_st BIO;
215 218
216typedef void bio_info_cb(struct bio_st *, int, const char *, int, long, long); 219typedef void bio_info_cb(struct bio_st *, int, const char *, int, long, long);
217 220
218#ifndef WIN16 221#ifndef OPENSSL_SYS_WIN16
219typedef struct bio_method_st 222typedef struct bio_method_st
220 { 223 {
221 int type; 224 int type;
@@ -356,8 +359,8 @@ typedef struct bio_f_buffer_ctx_struct
356#define BIO_set_conn_int_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,3,(char *)port) 359#define BIO_set_conn_int_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,3,(char *)port)
357#define BIO_get_conn_hostname(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0) 360#define BIO_get_conn_hostname(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0)
358#define BIO_get_conn_port(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1) 361#define BIO_get_conn_port(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1)
359#define BIO_get_conn_ip(b,ip) BIO_ptr_ctrl(b,BIO_C_SET_CONNECT,2) 362#define BIO_get_conn_ip(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2)
360#define BIO_get_conn_int_port(b,port) BIO_int_ctrl(b,BIO_C_SET_CONNECT,3,port) 363#define BIO_get_conn_int_port(b) BIO_int_ctrl(b,BIO_C_GET_CONNECT,3)
361 364
362 365
363#define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) 366#define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL)
@@ -431,7 +434,7 @@ int BIO_read_filename(BIO *b,const char *name);
431#define BIO_set_ssl_renegotiate_bytes(b,num) \ 434#define BIO_set_ssl_renegotiate_bytes(b,num) \
432 BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL); 435 BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL);
433#define BIO_get_num_renegotiates(b) \ 436#define BIO_get_num_renegotiates(b) \
434 BIO_ctrl(b,BIO_C_SET_SSL_NUM_RENEGOTIATES,0,NULL); 437 BIO_ctrl(b,BIO_C_GET_SSL_NUM_RENEGOTIATES,0,NULL);
435#define BIO_set_ssl_renegotiate_timeout(b,seconds) \ 438#define BIO_set_ssl_renegotiate_timeout(b,seconds) \
436 BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL); 439 BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL);
437 440
@@ -464,8 +467,9 @@ int BIO_read_filename(BIO *b,const char *name);
464size_t BIO_ctrl_pending(BIO *b); 467size_t BIO_ctrl_pending(BIO *b);
465size_t BIO_ctrl_wpending(BIO *b); 468size_t BIO_ctrl_wpending(BIO *b);
466#define BIO_flush(b) (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL) 469#define BIO_flush(b) (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL)
467#define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0,(bio_info_cb **)(cbp)) 470#define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0, \
468#define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,(bio_info_cb *)(cb)) 471 cbp)
472#define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,cb)
469 473
470/* For the BIO_f_buffer() type */ 474/* For the BIO_f_buffer() type */
471#define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL) 475#define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL)
@@ -493,8 +497,8 @@ int BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
493unsigned long BIO_number_read(BIO *bio); 497unsigned long BIO_number_read(BIO *bio);
494unsigned long BIO_number_written(BIO *bio); 498unsigned long BIO_number_written(BIO *bio);
495 499
496# ifndef NO_FP_API 500# ifndef OPENSSL_NO_FP_API
497# if defined(WIN16) && defined(_WINDLL) 501# if defined(OPENSSL_SYS_WIN16) && defined(_WINDLL)
498BIO_METHOD *BIO_s_file_internal(void); 502BIO_METHOD *BIO_s_file_internal(void);
499BIO *BIO_new_file_internal(char *filename, char *mode); 503BIO *BIO_new_file_internal(char *filename, char *mode);
500BIO *BIO_new_fp_internal(FILE *stream, int close_flag); 504BIO *BIO_new_fp_internal(FILE *stream, int close_flag);
@@ -536,7 +540,7 @@ int BIO_nread(BIO *bio, char **buf, int num);
536int BIO_nwrite0(BIO *bio, char **buf); 540int BIO_nwrite0(BIO *bio, char **buf);
537int BIO_nwrite(BIO *bio, char **buf, int num); 541int BIO_nwrite(BIO *bio, char **buf, int num);
538 542
539#ifndef WIN16 543#ifndef OPENSSL_SYS_WIN16
540long BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi, 544long BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi,
541 long argl,long ret); 545 long argl,long ret);
542#else 546#else
@@ -555,7 +559,7 @@ BIO_METHOD *BIO_s_bio(void);
555BIO_METHOD *BIO_s_null(void); 559BIO_METHOD *BIO_s_null(void);
556BIO_METHOD *BIO_f_null(void); 560BIO_METHOD *BIO_f_null(void);
557BIO_METHOD *BIO_f_buffer(void); 561BIO_METHOD *BIO_f_buffer(void);
558#ifdef VMS 562#ifdef OPENSSL_SYS_VMS
559BIO_METHOD *BIO_f_linebuffer(void); 563BIO_METHOD *BIO_f_linebuffer(void);
560#endif 564#endif
561BIO_METHOD *BIO_f_nbio_test(void); 565BIO_METHOD *BIO_f_nbio_test(void);
@@ -588,8 +592,6 @@ int BIO_sock_init(void );
588void BIO_sock_cleanup(void); 592void BIO_sock_cleanup(void);
589int BIO_set_tcp_ndelay(int sock,int turn_on); 593int BIO_set_tcp_ndelay(int sock,int turn_on);
590 594
591void ERR_load_BIO_strings(void );
592
593BIO *BIO_new_socket(int sock, int close_flag); 595BIO *BIO_new_socket(int sock, int close_flag);
594BIO *BIO_new_fd(int fd, int close_flag); 596BIO *BIO_new_fd(int fd, int close_flag);
595BIO *BIO_new_connect(char *host_port); 597BIO *BIO_new_connect(char *host_port);
@@ -615,6 +617,7 @@ int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args);
615/* The following lines are auto generated by the script mkerr.pl. Any changes 617/* The following lines are auto generated by the script mkerr.pl. Any changes
616 * made after this point may be overwritten when the script is next run. 618 * made after this point may be overwritten when the script is next run.
617 */ 619 */
620void ERR_load_BIO_strings(void);
618 621
619/* Error codes for the BIO functions. */ 622/* Error codes for the BIO functions. */
620 623
@@ -670,6 +673,7 @@ int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args);
670#define BIO_R_NO_HOSTNAME_SPECIFIED 112 673#define BIO_R_NO_HOSTNAME_SPECIFIED 112
671#define BIO_R_NO_PORT_DEFINED 113 674#define BIO_R_NO_PORT_DEFINED 113
672#define BIO_R_NO_PORT_SPECIFIED 114 675#define BIO_R_NO_PORT_SPECIFIED 114
676#define BIO_R_NO_SUCH_FILE 128
673#define BIO_R_NULL_PARAMETER 115 677#define BIO_R_NULL_PARAMETER 115
674#define BIO_R_TAG_MISMATCH 116 678#define BIO_R_TAG_MISMATCH 116
675#define BIO_R_UNABLE_TO_BIND_SOCKET 117 679#define BIO_R_UNABLE_TO_BIND_SOCKET 117
@@ -684,4 +688,3 @@ int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args);
684} 688}
685#endif 689#endif
686#endif 690#endif
687
diff --git a/src/lib/libcrypto/bio/bio_cb.c b/src/lib/libcrypto/bio/bio_cb.c
index 37c7c22666..0ffa4d2136 100644
--- a/src/lib/libcrypto/bio/bio_cb.c
+++ b/src/lib/libcrypto/bio/bio_cb.c
@@ -125,7 +125,7 @@ long MS_CALLBACK BIO_debug_callback(BIO *bio, int cmd, const char *argp,
125 b=(BIO *)bio->cb_arg; 125 b=(BIO *)bio->cb_arg;
126 if (b != NULL) 126 if (b != NULL)
127 BIO_write(b,buf,strlen(buf)); 127 BIO_write(b,buf,strlen(buf));
128#if !defined(NO_STDIO) && !defined(WIN16) 128#if !defined(OPENSSL_NO_STDIO) && !defined(OPENSSL_SYS_WIN16)
129 else 129 else
130 fputs(buf,stderr); 130 fputs(buf,stderr);
131#endif 131#endif
diff --git a/src/lib/libcrypto/bio/bio_err.c b/src/lib/libcrypto/bio/bio_err.c
index bb815fb1e6..99ca3cd0da 100644
--- a/src/lib/libcrypto/bio/bio_err.c
+++ b/src/lib/libcrypto/bio/bio_err.c
@@ -63,7 +63,7 @@
63#include <openssl/bio.h> 63#include <openssl/bio.h>
64 64
65/* BEGIN ERROR CODES */ 65/* BEGIN ERROR CODES */
66#ifndef NO_ERR 66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA BIO_str_functs[]= 67static ERR_STRING_DATA BIO_str_functs[]=
68 { 68 {
69{ERR_PACK(0,BIO_F_ACPT_STATE,0), "ACPT_STATE"}, 69{ERR_PACK(0,BIO_F_ACPT_STATE,0), "ACPT_STATE"},
@@ -120,6 +120,7 @@ static ERR_STRING_DATA BIO_str_reasons[]=
120{BIO_R_NO_HOSTNAME_SPECIFIED ,"no hostname specified"}, 120{BIO_R_NO_HOSTNAME_SPECIFIED ,"no hostname specified"},
121{BIO_R_NO_PORT_DEFINED ,"no port defined"}, 121{BIO_R_NO_PORT_DEFINED ,"no port defined"},
122{BIO_R_NO_PORT_SPECIFIED ,"no port specified"}, 122{BIO_R_NO_PORT_SPECIFIED ,"no port specified"},
123{BIO_R_NO_SUCH_FILE ,"no such file"},
123{BIO_R_NULL_PARAMETER ,"null parameter"}, 124{BIO_R_NULL_PARAMETER ,"null parameter"},
124{BIO_R_TAG_MISMATCH ,"tag mismatch"}, 125{BIO_R_TAG_MISMATCH ,"tag mismatch"},
125{BIO_R_UNABLE_TO_BIND_SOCKET ,"unable to bind socket"}, 126{BIO_R_UNABLE_TO_BIND_SOCKET ,"unable to bind socket"},
@@ -141,7 +142,7 @@ void ERR_load_BIO_strings(void)
141 if (init) 142 if (init)
142 { 143 {
143 init=0; 144 init=0;
144#ifndef NO_ERR 145#ifndef OPENSSL_NO_ERR
145 ERR_load_strings(ERR_LIB_BIO,BIO_str_functs); 146 ERR_load_strings(ERR_LIB_BIO,BIO_str_functs);
146 ERR_load_strings(ERR_LIB_BIO,BIO_str_reasons); 147 ERR_load_strings(ERR_LIB_BIO,BIO_str_reasons);
147#endif 148#endif
diff --git a/src/lib/libcrypto/bio/bio_lib.c b/src/lib/libcrypto/bio/bio_lib.c
index 381afc9b8e..50df2238fa 100644
--- a/src/lib/libcrypto/bio/bio_lib.c
+++ b/src/lib/libcrypto/bio/bio_lib.c
@@ -63,9 +63,6 @@
63#include <openssl/bio.h> 63#include <openssl/bio.h>
64#include <openssl/stack.h> 64#include <openssl/stack.h>
65 65
66static STACK_OF(CRYPTO_EX_DATA_FUNCS) *bio_meth=NULL;
67static int bio_meth_num=0;
68
69BIO *BIO_new(BIO_METHOD *method) 66BIO *BIO_new(BIO_METHOD *method)
70 { 67 {
71 BIO *ret=NULL; 68 BIO *ret=NULL;
@@ -100,10 +97,14 @@ int BIO_set(BIO *bio, BIO_METHOD *method)
100 bio->references=1; 97 bio->references=1;
101 bio->num_read=0L; 98 bio->num_read=0L;
102 bio->num_write=0L; 99 bio->num_write=0L;
103 CRYPTO_new_ex_data(bio_meth,bio,&bio->ex_data); 100 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data);
104 if (method->create != NULL) 101 if (method->create != NULL)
105 if (!method->create(bio)) 102 if (!method->create(bio))
103 {
104 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, bio,
105 &bio->ex_data);
106 return(0); 106 return(0);
107 }
107 return(1); 108 return(1);
108 } 109 }
109 110
@@ -129,7 +130,7 @@ int BIO_free(BIO *a)
129 ((i=(int)a->callback(a,BIO_CB_FREE,NULL,0,0L,1L)) <= 0)) 130 ((i=(int)a->callback(a,BIO_CB_FREE,NULL,0,0L,1L)) <= 0))
130 return(i); 131 return(i);
131 132
132 CRYPTO_free_ex_data(bio_meth,a,&a->ex_data); 133 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, a, &a->ex_data);
133 134
134 if ((a->method == NULL) || (a->method->destroy == NULL)) return(1); 135 if ((a->method == NULL) || (a->method->destroy == NULL)) return(1);
135 ret=a->method->destroy(a); 136 ret=a->method->destroy(a);
@@ -482,7 +483,8 @@ BIO *BIO_dup_chain(BIO *in)
482 } 483 }
483 484
484 /* copy app data */ 485 /* copy app data */
485 if (!CRYPTO_dup_ex_data(bio_meth,&new->ex_data,&bio->ex_data)) 486 if (!CRYPTO_dup_ex_data(CRYPTO_EX_INDEX_BIO, &new->ex_data,
487 &bio->ex_data))
486 goto err; 488 goto err;
487 489
488 if (ret == NULL) 490 if (ret == NULL)
@@ -512,9 +514,8 @@ void BIO_copy_next_retry(BIO *b)
512int BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, 514int BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
513 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) 515 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
514 { 516 {
515 bio_meth_num++; 517 return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_BIO, argl, argp,
516 return(CRYPTO_get_ex_new_index(bio_meth_num-1,&bio_meth, 518 new_func, dup_func, free_func);
517 argl,argp,new_func,dup_func,free_func));
518 } 519 }
519 520
520int BIO_set_ex_data(BIO *bio, int idx, void *data) 521int BIO_set_ex_data(BIO *bio, int idx, void *data)
diff --git a/src/lib/libcrypto/bio/bss_acpt.c b/src/lib/libcrypto/bio/bss_acpt.c
index 4da5822062..8ea1db158b 100644
--- a/src/lib/libcrypto/bio/bss_acpt.c
+++ b/src/lib/libcrypto/bio/bss_acpt.c
@@ -56,7 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_SOCK 59#ifndef OPENSSL_NO_SOCK
60 60
61#include <stdio.h> 61#include <stdio.h>
62#include <errno.h> 62#include <errno.h>
@@ -64,13 +64,13 @@
64#include "cryptlib.h" 64#include "cryptlib.h"
65#include <openssl/bio.h> 65#include <openssl/bio.h>
66 66
67#ifdef WIN16 67#ifdef OPENSSL_SYS_WIN16
68#define SOCKET_PROTOCOL 0 /* more microsoft stupidity */ 68#define SOCKET_PROTOCOL 0 /* more microsoft stupidity */
69#else 69#else
70#define SOCKET_PROTOCOL IPPROTO_TCP 70#define SOCKET_PROTOCOL IPPROTO_TCP
71#endif 71#endif
72 72
73#if (defined(VMS) && __VMS_VER < 70000000) 73#if (defined(OPENSSL_SYS_VMS) && __VMS_VER < 70000000)
74/* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */ 74/* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */
75#undef FIONBIO 75#undef FIONBIO
76#endif 76#endif
@@ -236,8 +236,20 @@ again:
236 c->state=ACPT_S_OK; 236 c->state=ACPT_S_OK;
237 goto again; 237 goto again;
238 } 238 }
239 BIO_clear_retry_flags(b);
240 b->retry_reason=0;
239 i=BIO_accept(c->accept_sock,&(c->addr)); 241 i=BIO_accept(c->accept_sock,&(c->addr));
242
243 /* -2 return means we should retry */
244 if(i == -2)
245 {
246 BIO_set_retry_special(b);
247 b->retry_reason=BIO_RR_ACCEPT;
248 return -1;
249 }
250
240 if (i < 0) return(i); 251 if (i < 0) return(i);
252
241 bio=BIO_new_socket(i,BIO_CLOSE); 253 bio=BIO_new_socket(i,BIO_CLOSE);
242 if (bio == NULL) goto err; 254 if (bio == NULL) goto err;
243 255
diff --git a/src/lib/libcrypto/bio/bss_bio.c b/src/lib/libcrypto/bio/bss_bio.c
index 78c6ab4fdd..a5da473031 100644
--- a/src/lib/libcrypto/bio/bss_bio.c
+++ b/src/lib/libcrypto/bio/bss_bio.c
@@ -22,7 +22,12 @@
22#include <openssl/err.h> 22#include <openssl/err.h>
23#include <openssl/crypto.h> 23#include <openssl/crypto.h>
24 24
25#include "openssl/e_os.h" 25#include "e_os.h"
26
27/* VxWorks defines SSIZE_MAX with an empty value causing compile errors */
28#if defined(OPENSSL_SYS_VSWORKS)
29# undef SSIZE_MAX
30#endif
26#ifndef SSIZE_MAX 31#ifndef SSIZE_MAX
27# define SSIZE_MAX INT_MAX 32# define SSIZE_MAX INT_MAX
28#endif 33#endif
@@ -474,7 +479,8 @@ static long bio_ctrl(BIO *bio, int cmd, long num, void *ptr)
474 break; 479 break;
475 480
476 case BIO_C_GET_WRITE_BUF_SIZE: 481 case BIO_C_GET_WRITE_BUF_SIZE:
477 num = (long) b->size; 482 ret = (long) b->size;
483 break;
478 484
479 case BIO_C_MAKE_BIO_PAIR: 485 case BIO_C_MAKE_BIO_PAIR:
480 { 486 {
diff --git a/src/lib/libcrypto/bio/bss_conn.c b/src/lib/libcrypto/bio/bss_conn.c
index a6b77a2cb9..f91ae4c8c6 100644
--- a/src/lib/libcrypto/bio/bss_conn.c
+++ b/src/lib/libcrypto/bio/bss_conn.c
@@ -56,7 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_SOCK 59#ifndef OPENSSL_NO_SOCK
60 60
61#include <stdio.h> 61#include <stdio.h>
62#include <errno.h> 62#include <errno.h>
@@ -64,13 +64,13 @@
64#include "cryptlib.h" 64#include "cryptlib.h"
65#include <openssl/bio.h> 65#include <openssl/bio.h>
66 66
67#ifdef WIN16 67#ifdef OPENSSL_SYS_WIN16
68#define SOCKET_PROTOCOL 0 /* more microsoft stupidity */ 68#define SOCKET_PROTOCOL 0 /* more microsoft stupidity */
69#else 69#else
70#define SOCKET_PROTOCOL IPPROTO_TCP 70#define SOCKET_PROTOCOL IPPROTO_TCP
71#endif 71#endif
72 72
73#if (defined(VMS) && __VMS_VER < 70000000) 73#if (defined(OPENSSL_SYS_VMS) && __VMS_VER < 70000000)
74/* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */ 74/* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */
75#undef FIONBIO 75#undef FIONBIO
76#endif 76#endif
@@ -95,7 +95,7 @@ typedef struct bio_connect_st
95 /* called when the connection is initially made 95 /* called when the connection is initially made
96 * callback(BIO,state,ret); The callback should return 96 * callback(BIO,state,ret); The callback should return
97 * 'ret'. state is for compatibility with the ssl info_callback */ 97 * 'ret'. state is for compatibility with the ssl info_callback */
98 int (*info_callback)(); 98 int (*info_callback)(const BIO *bio,int state,int ret);
99 } BIO_CONNECT; 99 } BIO_CONNECT;
100 100
101static int conn_write(BIO *h, const char *buf, int num); 101static int conn_write(BIO *h, const char *buf, int num);
@@ -236,7 +236,7 @@ static int conn_state(BIO *b, BIO_CONNECT *c)
236 } 236 }
237 c->state=BIO_CONN_S_CONNECT; 237 c->state=BIO_CONN_S_CONNECT;
238 238
239#if defined(SO_KEEPALIVE) && !defined(MPE) 239#if defined(SO_KEEPALIVE) && !defined(OPENSSL_SYS_MPE)
240 i=1; 240 i=1;
241 i=setsockopt(b->num,SOL_SOCKET,SO_KEEPALIVE,(char *)&i,sizeof(i)); 241 i=setsockopt(b->num,SOL_SOCKET,SO_KEEPALIVE,(char *)&i,sizeof(i));
242 if (i < 0) 242 if (i < 0)
@@ -574,7 +574,8 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
574 if (data->param_hostname) 574 if (data->param_hostname)
575 BIO_set_conn_hostname(dbio,data->param_hostname); 575 BIO_set_conn_hostname(dbio,data->param_hostname);
576 BIO_set_nbio(dbio,data->nbio); 576 BIO_set_nbio(dbio,data->nbio);
577 (void)BIO_set_info_callback(dbio,data->info_callback); 577 /* FIXME: the cast of the function seems unlikely to be a good idea */
578 (void)BIO_set_info_callback(dbio,(bio_info_cb *)data->info_callback);
578 } 579 }
579 break; 580 break;
580 case BIO_CTRL_SET_CALLBACK: 581 case BIO_CTRL_SET_CALLBACK:
@@ -613,7 +614,7 @@ static long conn_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp)
613 { 614 {
614 case BIO_CTRL_SET_CALLBACK: 615 case BIO_CTRL_SET_CALLBACK:
615 { 616 {
616 data->info_callback=(int (*)())fp; 617 data->info_callback=(int (*)(const struct bio_st *, int, int))fp;
617 } 618 }
618 break; 619 break;
619 default: 620 default:
diff --git a/src/lib/libcrypto/bio/bss_fd.c b/src/lib/libcrypto/bio/bss_fd.c
index 686c4909a2..5e3e187de6 100644
--- a/src/lib/libcrypto/bio/bss_fd.c
+++ b/src/lib/libcrypto/bio/bss_fd.c
@@ -56,7 +56,227 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#define BIO_FD 59#include <stdio.h>
60#include "bss_sock.c" 60#include <errno.h>
61#undef BIO_FD 61#define USE_SOCKETS
62#include "cryptlib.h"
63#include <openssl/bio.h>
62 64
65static int fd_write(BIO *h, const char *buf, int num);
66static int fd_read(BIO *h, char *buf, int size);
67static int fd_puts(BIO *h, const char *str);
68static long fd_ctrl(BIO *h, int cmd, long arg1, void *arg2);
69static int fd_new(BIO *h);
70static int fd_free(BIO *data);
71int BIO_fd_should_retry(int s);
72
73static BIO_METHOD methods_fdp=
74 {
75 BIO_TYPE_FD,"file descriptor",
76 fd_write,
77 fd_read,
78 fd_puts,
79 NULL, /* fd_gets, */
80 fd_ctrl,
81 fd_new,
82 fd_free,
83 NULL,
84 };
85
86BIO_METHOD *BIO_s_fd(void)
87 {
88 return(&methods_fdp);
89 }
90
91BIO *BIO_new_fd(int fd,int close_flag)
92 {
93 BIO *ret;
94 ret=BIO_new(BIO_s_fd());
95 if (ret == NULL) return(NULL);
96 BIO_set_fd(ret,fd,close_flag);
97 return(ret);
98 }
99
100static int fd_new(BIO *bi)
101 {
102 bi->init=0;
103 bi->num=0;
104 bi->ptr=NULL;
105 bi->flags=0;
106 return(1);
107 }
108
109static int fd_free(BIO *a)
110 {
111 if (a == NULL) return(0);
112 if (a->shutdown)
113 {
114 if (a->init)
115 {
116 close(a->num);
117 }
118 a->init=0;
119 a->flags=0;
120 }
121 return(1);
122 }
123
124static int fd_read(BIO *b, char *out,int outl)
125 {
126 int ret=0;
127
128 if (out != NULL)
129 {
130 clear_sys_error();
131 ret=read(b->num,out,outl);
132 BIO_clear_retry_flags(b);
133 if (ret <= 0)
134 {
135 if (BIO_fd_should_retry(ret))
136 BIO_set_retry_read(b);
137 }
138 }
139 return(ret);
140 }
141
142static int fd_write(BIO *b, const char *in, int inl)
143 {
144 int ret;
145 clear_sys_error();
146 ret=write(b->num,in,inl);
147 BIO_clear_retry_flags(b);
148 if (ret <= 0)
149 {
150 if (BIO_fd_should_retry(ret))
151 BIO_set_retry_write(b);
152 }
153 return(ret);
154 }
155
156static long fd_ctrl(BIO *b, int cmd, long num, void *ptr)
157 {
158 long ret=1;
159 int *ip;
160
161 switch (cmd)
162 {
163 case BIO_CTRL_RESET:
164 num=0;
165 case BIO_C_FILE_SEEK:
166 ret=(long)lseek(b->num,num,0);
167 break;
168 case BIO_C_FILE_TELL:
169 case BIO_CTRL_INFO:
170 ret=(long)lseek(b->num,0,1);
171 break;
172 case BIO_C_SET_FD:
173 fd_free(b);
174 b->num= *((int *)ptr);
175 b->shutdown=(int)num;
176 b->init=1;
177 break;
178 case BIO_C_GET_FD:
179 if (b->init)
180 {
181 ip=(int *)ptr;
182 if (ip != NULL) *ip=b->num;
183 ret=b->num;
184 }
185 else
186 ret= -1;
187 break;
188 case BIO_CTRL_GET_CLOSE:
189 ret=b->shutdown;
190 break;
191 case BIO_CTRL_SET_CLOSE:
192 b->shutdown=(int)num;
193 break;
194 case BIO_CTRL_PENDING:
195 case BIO_CTRL_WPENDING:
196 ret=0;
197 break;
198 case BIO_CTRL_DUP:
199 case BIO_CTRL_FLUSH:
200 ret=1;
201 break;
202 default:
203 ret=0;
204 break;
205 }
206 return(ret);
207 }
208
209static int fd_puts(BIO *bp, const char *str)
210 {
211 int n,ret;
212
213 n=strlen(str);
214 ret=fd_write(bp,str,n);
215 return(ret);
216 }
217
218int BIO_fd_should_retry(int i)
219 {
220 int err;
221
222 if ((i == 0) || (i == -1))
223 {
224 err=get_last_sys_error();
225
226#if defined(OPENSSL_SYS_WINDOWS) && 0 /* more microsoft stupidity? perhaps not? Ben 4/1/99 */
227 if ((i == -1) && (err == 0))
228 return(1);
229#endif
230
231 return(BIO_fd_non_fatal_error(err));
232 }
233 return(0);
234 }
235
236int BIO_fd_non_fatal_error(int err)
237 {
238 switch (err)
239 {
240
241#ifdef EWOULDBLOCK
242# ifdef WSAEWOULDBLOCK
243# if WSAEWOULDBLOCK != EWOULDBLOCK
244 case EWOULDBLOCK:
245# endif
246# else
247 case EWOULDBLOCK:
248# endif
249#endif
250
251#if defined(ENOTCONN)
252 case ENOTCONN:
253#endif
254
255#ifdef EINTR
256 case EINTR:
257#endif
258
259#ifdef EAGAIN
260#if EWOULDBLOCK != EAGAIN
261 case EAGAIN:
262# endif
263#endif
264
265#ifdef EPROTO
266 case EPROTO:
267#endif
268
269#ifdef EINPROGRESS
270 case EINPROGRESS:
271#endif
272
273#ifdef EALREADY
274 case EALREADY:
275#endif
276 return(1);
277 /* break; */
278 default:
279 break;
280 }
281 return(0);
282 }
diff --git a/src/lib/libcrypto/bio/bss_file.c b/src/lib/libcrypto/bio/bss_file.c
index 1f770b390f..8b3ff278d9 100644
--- a/src/lib/libcrypto/bio/bss_file.c
+++ b/src/lib/libcrypto/bio/bss_file.c
@@ -71,7 +71,7 @@
71#include <openssl/bio.h> 71#include <openssl/bio.h>
72#include <openssl/err.h> 72#include <openssl/err.h>
73 73
74#if !defined(NO_STDIO) 74#if !defined(OPENSSL_NO_STDIO)
75 75
76static int MS_CALLBACK file_write(BIO *h, const char *buf, int num); 76static int MS_CALLBACK file_write(BIO *h, const char *buf, int num);
77static int MS_CALLBACK file_read(BIO *h, char *buf, int size); 77static int MS_CALLBACK file_read(BIO *h, char *buf, int size);
@@ -103,7 +103,10 @@ BIO *BIO_new_file(const char *filename, const char *mode)
103 { 103 {
104 SYSerr(SYS_F_FOPEN,get_last_sys_error()); 104 SYSerr(SYS_F_FOPEN,get_last_sys_error());
105 ERR_add_error_data(5,"fopen('",filename,"','",mode,"')"); 105 ERR_add_error_data(5,"fopen('",filename,"','",mode,"')");
106 BIOerr(BIO_F_BIO_NEW_FILE,ERR_R_SYS_LIB); 106 if (errno == ENOENT)
107 BIOerr(BIO_F_BIO_NEW_FILE,BIO_R_NO_SUCH_FILE);
108 else
109 BIOerr(BIO_F_BIO_NEW_FILE,ERR_R_SYS_LIB);
107 return(NULL); 110 return(NULL);
108 } 111 }
109 if ((ret=BIO_new(BIO_s_file_internal())) == NULL) 112 if ((ret=BIO_new(BIO_s_file_internal())) == NULL)
@@ -204,12 +207,17 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr)
204 b->shutdown=(int)num&BIO_CLOSE; 207 b->shutdown=(int)num&BIO_CLOSE;
205 b->ptr=(char *)ptr; 208 b->ptr=(char *)ptr;
206 b->init=1; 209 b->init=1;
207#if defined(MSDOS) || defined(WINDOWS) 210#if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS)
208 /* Set correct text/binary mode */ 211 /* Set correct text/binary mode */
209 if (num & BIO_FP_TEXT) 212 if (num & BIO_FP_TEXT)
210 _setmode(fileno((FILE *)ptr),_O_TEXT); 213 _setmode(fileno((FILE *)ptr),_O_TEXT);
211 else 214 else
212 _setmode(fileno((FILE *)ptr),_O_BINARY); 215 _setmode(fileno((FILE *)ptr),_O_BINARY);
216#elif defined(OPENSSL_SYS_OS2)
217 if (num & BIO_FP_TEXT)
218 setmode(fileno((FILE *)ptr), O_TEXT);
219 else
220 setmode(fileno((FILE *)ptr), O_BINARY);
213#endif 221#endif
214 break; 222 break;
215 case BIO_C_SET_FILENAME: 223 case BIO_C_SET_FILENAME:
@@ -233,7 +241,7 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr)
233 ret=0; 241 ret=0;
234 break; 242 break;
235 } 243 }
236#if defined(MSDOS) || defined(WINDOWS) 244#if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS)
237 if (!(num & BIO_FP_TEXT)) 245 if (!(num & BIO_FP_TEXT))
238 strcat(p,"b"); 246 strcat(p,"b");
239 else 247 else
@@ -303,7 +311,7 @@ static int MS_CALLBACK file_puts(BIO *bp, const char *str)
303 return(ret); 311 return(ret);
304 } 312 }
305 313
306#endif /* NO_STDIO */ 314#endif /* OPENSSL_NO_STDIO */
307 315
308#endif /* HEADER_BSS_FILE_C */ 316#endif /* HEADER_BSS_FILE_C */
309 317
diff --git a/src/lib/libcrypto/bio/bss_log.c b/src/lib/libcrypto/bio/bss_log.c
index 1edf16a76f..a39d95297c 100644
--- a/src/lib/libcrypto/bio/bss_log.c
+++ b/src/lib/libcrypto/bio/bss_log.c
@@ -66,26 +66,27 @@
66#include <stdio.h> 66#include <stdio.h>
67#include <errno.h> 67#include <errno.h>
68 68
69#if defined(WIN32) 69#include "cryptlib.h"
70
71#if defined(OPENSSL_SYS_WIN32)
70# include <process.h> 72# include <process.h>
71#elif defined(VMS) || defined(__VMS) 73#elif defined(OPENSSL_SYS_VMS)
72# include <opcdef.h> 74# include <opcdef.h>
73# include <descrip.h> 75# include <descrip.h>
74# include <lib$routines.h> 76# include <lib$routines.h>
75# include <starlet.h> 77# include <starlet.h>
76#elif defined(__ultrix) 78#elif defined(__ultrix)
77# include <sys/syslog.h> 79# include <sys/syslog.h>
78#elif !defined(MSDOS) /* Unix */ 80#elif !defined(MSDOS) && !defined(OPENSSL_SYS_VXWORKS) && !defined(NO_SYSLOG) /* Unix */
79# include <syslog.h> 81# include <syslog.h>
80#endif 82#endif
81 83
82#include "cryptlib.h"
83#include <openssl/buffer.h> 84#include <openssl/buffer.h>
84#include <openssl/err.h> 85#include <openssl/err.h>
85 86
86#ifndef NO_SYSLOG 87#ifndef NO_SYSLOG
87 88
88#if defined(WIN32) 89#if defined(OPENSSL_SYS_WIN32)
89#define LOG_EMERG 0 90#define LOG_EMERG 0
90#define LOG_ALERT 1 91#define LOG_ALERT 1
91#define LOG_CRIT 2 92#define LOG_CRIT 2
@@ -96,7 +97,7 @@
96#define LOG_DEBUG 7 97#define LOG_DEBUG 7
97 98
98#define LOG_DAEMON (3<<3) 99#define LOG_DAEMON (3<<3)
99#elif defined(VMS) 100#elif defined(OPENSSL_SYS_VMS)
100/* On VMS, we don't really care about these, but we need them to compile */ 101/* On VMS, we don't really care about these, but we need them to compile */
101#define LOG_EMERG 0 102#define LOG_EMERG 0
102#define LOG_ALERT 1 103#define LOG_ALERT 1
@@ -118,7 +119,7 @@ static int MS_CALLBACK slg_free(BIO *data);
118static void xopenlog(BIO* bp, char* name, int level); 119static void xopenlog(BIO* bp, char* name, int level);
119static void xsyslog(BIO* bp, int priority, const char* string); 120static void xsyslog(BIO* bp, int priority, const char* string);
120static void xcloselog(BIO* bp); 121static void xcloselog(BIO* bp);
121#ifdef WIN32 122#ifdef OPENSSL_SYS_WIN32
122LONG (WINAPI *go_for_advapi)() = RegOpenKeyEx; 123LONG (WINAPI *go_for_advapi)() = RegOpenKeyEx;
123HANDLE (WINAPI *register_event_source)() = NULL; 124HANDLE (WINAPI *register_event_source)() = NULL;
124BOOL (WINAPI *deregister_event_source)() = NULL; 125BOOL (WINAPI *deregister_event_source)() = NULL;
@@ -241,7 +242,7 @@ static int MS_CALLBACK slg_puts(BIO *bp, const char *str)
241 return(ret); 242 return(ret);
242 } 243 }
243 244
244#if defined(WIN32) 245#if defined(OPENSSL_SYS_WIN32)
245 246
246static void xopenlog(BIO* bp, char* name, int level) 247static void xopenlog(BIO* bp, char* name, int level)
247{ 248{
@@ -313,7 +314,7 @@ static void xcloselog(BIO* bp)
313 bp->ptr= NULL; 314 bp->ptr= NULL;
314} 315}
315 316
316#elif defined(VMS) 317#elif defined(OPENSSL_SYS_VMS)
317 318
318static int VMS_OPC_target = LOG_DAEMON; 319static int VMS_OPC_target = LOG_DAEMON;
319 320
diff --git a/src/lib/libcrypto/bio/bss_sock.c b/src/lib/libcrypto/bio/bss_sock.c
index 50c6744c06..fdabd16d7e 100644
--- a/src/lib/libcrypto/bio/bss_sock.c
+++ b/src/lib/libcrypto/bio/bss_sock.c
@@ -56,7 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#if !defined(NO_SOCK) || defined(BIO_FD) 59#ifndef OPENSSL_NO_SOCK
60 60
61#include <stdio.h> 61#include <stdio.h>
62#include <errno.h> 62#include <errno.h>
@@ -64,7 +64,6 @@
64#include "cryptlib.h" 64#include "cryptlib.h"
65#include <openssl/bio.h> 65#include <openssl/bio.h>
66 66
67#ifndef BIO_FD
68static int sock_write(BIO *h, const char *buf, int num); 67static int sock_write(BIO *h, const char *buf, int num);
69static int sock_read(BIO *h, char *buf, int size); 68static int sock_read(BIO *h, char *buf, int size);
70static int sock_puts(BIO *h, const char *str); 69static int sock_puts(BIO *h, const char *str);
@@ -72,18 +71,7 @@ static long sock_ctrl(BIO *h, int cmd, long arg1, void *arg2);
72static int sock_new(BIO *h); 71static int sock_new(BIO *h);
73static int sock_free(BIO *data); 72static int sock_free(BIO *data);
74int BIO_sock_should_retry(int s); 73int BIO_sock_should_retry(int s);
75#else
76 74
77static int fd_write(BIO *h, const char *buf, int num);
78static int fd_read(BIO *h, char *buf, int size);
79static int fd_puts(BIO *h, const char *str);
80static long fd_ctrl(BIO *h, int cmd, long arg1, void *arg2);
81static int fd_new(BIO *h);
82static int fd_free(BIO *data);
83int BIO_fd_should_retry(int s);
84#endif
85
86#ifndef BIO_FD
87static BIO_METHOD methods_sockp= 75static BIO_METHOD methods_sockp=
88 { 76 {
89 BIO_TYPE_SOCKET, 77 BIO_TYPE_SOCKET,
@@ -102,49 +90,18 @@ BIO_METHOD *BIO_s_socket(void)
102 { 90 {
103 return(&methods_sockp); 91 return(&methods_sockp);
104 } 92 }
105#else
106static BIO_METHOD methods_fdp=
107 {
108 BIO_TYPE_FD,"file descriptor",
109 fd_write,
110 fd_read,
111 fd_puts,
112 NULL, /* fd_gets, */
113 fd_ctrl,
114 fd_new,
115 fd_free,
116 NULL,
117 };
118
119BIO_METHOD *BIO_s_fd(void)
120 {
121 return(&methods_fdp);
122 }
123#endif
124 93
125#ifndef BIO_FD
126BIO *BIO_new_socket(int fd, int close_flag) 94BIO *BIO_new_socket(int fd, int close_flag)
127#else
128BIO *BIO_new_fd(int fd,int close_flag)
129#endif
130 { 95 {
131 BIO *ret; 96 BIO *ret;
132 97
133#ifndef BIO_FD
134 ret=BIO_new(BIO_s_socket()); 98 ret=BIO_new(BIO_s_socket());
135#else
136 ret=BIO_new(BIO_s_fd());
137#endif
138 if (ret == NULL) return(NULL); 99 if (ret == NULL) return(NULL);
139 BIO_set_fd(ret,fd,close_flag); 100 BIO_set_fd(ret,fd,close_flag);
140 return(ret); 101 return(ret);
141 } 102 }
142 103
143#ifndef BIO_FD
144static int sock_new(BIO *bi) 104static int sock_new(BIO *bi)
145#else
146static int fd_new(BIO *bi)
147#endif
148 { 105 {
149 bi->init=0; 106 bi->init=0;
150 bi->num=0; 107 bi->num=0;
@@ -153,23 +110,14 @@ static int fd_new(BIO *bi)
153 return(1); 110 return(1);
154 } 111 }
155 112
156#ifndef BIO_FD
157static int sock_free(BIO *a) 113static int sock_free(BIO *a)
158#else
159static int fd_free(BIO *a)
160#endif
161 { 114 {
162 if (a == NULL) return(0); 115 if (a == NULL) return(0);
163 if (a->shutdown) 116 if (a->shutdown)
164 { 117 {
165 if (a->init) 118 if (a->init)
166 { 119 {
167#ifndef BIO_FD
168 SHUTDOWN2(a->num); 120 SHUTDOWN2(a->num);
169#else /* BIO_FD */
170 close(a->num);
171#endif
172
173 } 121 }
174 a->init=0; 122 a->init=0;
175 a->flags=0; 123 a->flags=0;
@@ -177,70 +125,40 @@ static int fd_free(BIO *a)
177 return(1); 125 return(1);
178 } 126 }
179 127
180#ifndef BIO_FD
181static int sock_read(BIO *b, char *out, int outl) 128static int sock_read(BIO *b, char *out, int outl)
182#else
183static int fd_read(BIO *b, char *out,int outl)
184#endif
185 { 129 {
186 int ret=0; 130 int ret=0;
187 131
188 if (out != NULL) 132 if (out != NULL)
189 { 133 {
190#ifndef BIO_FD
191 clear_socket_error(); 134 clear_socket_error();
192 ret=readsocket(b->num,out,outl); 135 ret=readsocket(b->num,out,outl);
193#else
194 clear_sys_error();
195 ret=read(b->num,out,outl);
196#endif
197 BIO_clear_retry_flags(b); 136 BIO_clear_retry_flags(b);
198 if (ret <= 0) 137 if (ret <= 0)
199 { 138 {
200#ifndef BIO_FD
201 if (BIO_sock_should_retry(ret)) 139 if (BIO_sock_should_retry(ret))
202#else
203 if (BIO_fd_should_retry(ret))
204#endif
205 BIO_set_retry_read(b); 140 BIO_set_retry_read(b);
206 } 141 }
207 } 142 }
208 return(ret); 143 return(ret);
209 } 144 }
210 145
211#ifndef BIO_FD
212static int sock_write(BIO *b, const char *in, int inl) 146static int sock_write(BIO *b, const char *in, int inl)
213#else
214static int fd_write(BIO *b, const char *in, int inl)
215#endif
216 { 147 {
217 int ret; 148 int ret;
218 149
219#ifndef BIO_FD
220 clear_socket_error(); 150 clear_socket_error();
221 ret=writesocket(b->num,in,inl); 151 ret=writesocket(b->num,in,inl);
222#else
223 clear_sys_error();
224 ret=write(b->num,in,inl);
225#endif
226 BIO_clear_retry_flags(b); 152 BIO_clear_retry_flags(b);
227 if (ret <= 0) 153 if (ret <= 0)
228 { 154 {
229#ifndef BIO_FD
230 if (BIO_sock_should_retry(ret)) 155 if (BIO_sock_should_retry(ret))
231#else
232 if (BIO_fd_should_retry(ret))
233#endif
234 BIO_set_retry_write(b); 156 BIO_set_retry_write(b);
235 } 157 }
236 return(ret); 158 return(ret);
237 } 159 }
238 160
239#ifndef BIO_FD
240static long sock_ctrl(BIO *b, int cmd, long num, void *ptr) 161static long sock_ctrl(BIO *b, int cmd, long num, void *ptr)
241#else
242static long fd_ctrl(BIO *b, int cmd, long num, void *ptr)
243#endif
244 { 162 {
245 long ret=1; 163 long ret=1;
246 int *ip; 164 int *ip;
@@ -250,26 +168,14 @@ static long fd_ctrl(BIO *b, int cmd, long num, void *ptr)
250 case BIO_CTRL_RESET: 168 case BIO_CTRL_RESET:
251 num=0; 169 num=0;
252 case BIO_C_FILE_SEEK: 170 case BIO_C_FILE_SEEK:
253#ifdef BIO_FD
254 ret=(long)lseek(b->num,num,0);
255#else
256 ret=0; 171 ret=0;
257#endif
258 break; 172 break;
259 case BIO_C_FILE_TELL: 173 case BIO_C_FILE_TELL:
260 case BIO_CTRL_INFO: 174 case BIO_CTRL_INFO:
261#ifdef BIO_FD
262 ret=(long)lseek(b->num,0,1);
263#else
264 ret=0; 175 ret=0;
265#endif
266 break; 176 break;
267 case BIO_C_SET_FD: 177 case BIO_C_SET_FD:
268#ifndef BIO_FD
269 sock_free(b); 178 sock_free(b);
270#else
271 fd_free(b);
272#endif
273 b->num= *((int *)ptr); 179 b->num= *((int *)ptr);
274 b->shutdown=(int)num; 180 b->shutdown=(int)num;
275 b->init=1; 181 b->init=1;
@@ -305,69 +211,38 @@ static long fd_ctrl(BIO *b, int cmd, long num, void *ptr)
305 return(ret); 211 return(ret);
306 } 212 }
307 213
308#ifdef undef
309static int sock_gets(BIO *bp, char *buf,int size)
310 {
311 return(-1);
312 }
313#endif
314
315#ifndef BIO_FD
316static int sock_puts(BIO *bp, const char *str) 214static int sock_puts(BIO *bp, const char *str)
317#else
318static int fd_puts(BIO *bp, const char *str)
319#endif
320 { 215 {
321 int n,ret; 216 int n,ret;
322 217
323 n=strlen(str); 218 n=strlen(str);
324#ifndef BIO_FD
325 ret=sock_write(bp,str,n); 219 ret=sock_write(bp,str,n);
326#else
327 ret=fd_write(bp,str,n);
328#endif
329 return(ret); 220 return(ret);
330 } 221 }
331 222
332#ifndef BIO_FD
333int BIO_sock_should_retry(int i) 223int BIO_sock_should_retry(int i)
334#else
335int BIO_fd_should_retry(int i)
336#endif
337 { 224 {
338 int err; 225 int err;
339 226
340 if ((i == 0) || (i == -1)) 227 if ((i == 0) || (i == -1))
341 { 228 {
342#ifndef BIO_FD
343 err=get_last_socket_error(); 229 err=get_last_socket_error();
344#else
345 err=get_last_sys_error();
346#endif
347 230
348#if defined(WINDOWS) && 0 /* more microsoft stupidity? perhaps not? Ben 4/1/99 */ 231#if defined(OPENSSL_SYS_WINDOWS) && 0 /* more microsoft stupidity? perhaps not? Ben 4/1/99 */
349 if ((i == -1) && (err == 0)) 232 if ((i == -1) && (err == 0))
350 return(1); 233 return(1);
351#endif 234#endif
352 235
353#ifndef BIO_FD
354 return(BIO_sock_non_fatal_error(err)); 236 return(BIO_sock_non_fatal_error(err));
355#else
356 return(BIO_fd_non_fatal_error(err));
357#endif
358 } 237 }
359 return(0); 238 return(0);
360 } 239 }
361 240
362#ifndef BIO_FD
363int BIO_sock_non_fatal_error(int err) 241int BIO_sock_non_fatal_error(int err)
364#else
365int BIO_fd_non_fatal_error(int err)
366#endif
367 { 242 {
368 switch (err) 243 switch (err)
369 { 244 {
370#if !defined(BIO_FD) && defined(WINDOWS) 245#if defined(OPENSSL_SYS_WINDOWS)
371# if defined(WSAEWOULDBLOCK) 246# if defined(WSAEWOULDBLOCK)
372 case WSAEWOULDBLOCK: 247 case WSAEWOULDBLOCK:
373# endif 248# endif
diff --git a/src/lib/libcrypto/bn/Makefile.ssl b/src/lib/libcrypto/bn/Makefile.ssl
index 526d7adb5c..eb6f0eeebd 100644
--- a/src/lib/libcrypto/bn/Makefile.ssl
+++ b/src/lib/libcrypto/bn/Makefile.ssl
@@ -6,13 +6,14 @@ DIR= bn
6TOP= ../.. 6TOP= ../..
7CC= cc 7CC= cc
8CPP= $(CC) -E 8CPP= $(CC) -E
9INCLUDES= -I.. -I../../include 9INCLUDES= -I.. -I$(TOP) -I../../include
10CFLAG=-g 10CFLAG=-g
11INSTALL_PREFIX= 11INSTALL_PREFIX=
12OPENSSLDIR= /usr/local/ssl 12OPENSSLDIR= /usr/local/ssl
13INSTALLTOP=/usr/local/ssl 13INSTALLTOP=/usr/local/ssl
14MAKE= make -f Makefile.ssl 14MAKE= make -f Makefile.ssl
15MAKEDEPEND= $(TOP)/util/domd $(TOP) 15MAKEDEPPROG= makedepend
16MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl 17MAKEFILE= Makefile.ssl
17AR= ar r 18AR= ar r
18 19
@@ -35,15 +36,15 @@ TEST=bntest.c exptest.c
35APPS= 36APPS=
36 37
37LIB=$(TOP)/libcrypto.a 38LIB=$(TOP)/libcrypto.a
38LIBSRC= bn_add.c bn_div.c bn_exp.c bn_lib.c bn_ctx.c bn_mul.c \ 39LIBSRC= bn_add.c bn_div.c bn_exp.c bn_lib.c bn_ctx.c bn_mul.c bn_mod.c \
39 bn_print.c bn_rand.c bn_shift.c bn_word.c bn_blind.c \ 40 bn_print.c bn_rand.c bn_shift.c bn_word.c bn_blind.c \
40 bn_gcd.c bn_prime.c bn_err.c bn_sqr.c bn_asm.c bn_recp.c bn_mont.c \ 41 bn_kron.c bn_sqrt.c bn_gcd.c bn_prime.c bn_err.c bn_sqr.c bn_asm.c \
41 bn_mpi.c bn_exp2.c 42 bn_recp.c bn_mont.c bn_mpi.c bn_exp2.c
42 43
43LIBOBJ= bn_add.o bn_div.o bn_exp.o bn_lib.o bn_ctx.o bn_mul.o \ 44LIBOBJ= bn_add.o bn_div.o bn_exp.o bn_lib.o bn_ctx.o bn_mul.o bn_mod.o \
44 bn_print.o bn_rand.o bn_shift.o bn_word.o bn_blind.o \ 45 bn_print.o bn_rand.o bn_shift.o bn_word.o bn_blind.o \
45 bn_gcd.o bn_prime.o bn_err.o bn_sqr.o $(BN_ASM) bn_recp.o bn_mont.o \ 46 bn_kron.o bn_sqrt.o bn_gcd.o bn_prime.o bn_err.o bn_sqr.o $(BN_ASM) \
46 bn_mpi.o bn_exp2.o 47 bn_recp.o bn_mont.o bn_mpi.o bn_exp2.o
47 48
48SRC= $(LIBSRC) 49SRC= $(LIBSRC)
49 50
@@ -68,8 +69,7 @@ bnbug: bnbug.c ../../libcrypto.a top
68 69
69lib: $(LIBOBJ) 70lib: $(LIBOBJ)
70 $(AR) $(LIB) $(LIBOBJ) 71 $(AR) $(LIB) $(LIBOBJ)
71 @echo You may get an error following this line. Please ignore. 72 $(RANLIB) $(LIB) || echo Never mind.
72 - $(RANLIB) $(LIB)
73 @touch lib 73 @touch lib
74 74
75# elf 75# elf
@@ -124,6 +124,18 @@ asm/sparcv8plus-gcc27.o: asm/sparcv8plus.S
124 $(CC) $(ASFLAGS) -E asm/sparcv8plus.S | \ 124 $(CC) $(ASFLAGS) -E asm/sparcv8plus.S | \
125 /usr/ccs/bin/as -xarch=v8plus - -o asm/sparcv8plus-gcc27.o 125 /usr/ccs/bin/as -xarch=v8plus - -o asm/sparcv8plus-gcc27.o
126 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
127files: 139files:
128 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO 140 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
129 141
@@ -168,146 +180,160 @@ clean:
168 180
169# DO NOT DELETE THIS LINE -- make depend depends on it. 181# DO NOT DELETE THIS LINE -- make depend depends on it.
170 182
171bn_add.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 183bn_add.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
172bn_add.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 184bn_add.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
173bn_add.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 185bn_add.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
174bn_add.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 186bn_add.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
175bn_add.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 187bn_add.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
176bn_add.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 188bn_add.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
177bn_add.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h 189bn_add.o: ../cryptlib.h bn_add.c bn_lcl.h
178bn_asm.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 190bn_asm.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
179bn_asm.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 191bn_asm.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
180bn_asm.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 192bn_asm.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
181bn_asm.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 193bn_asm.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
182bn_asm.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 194bn_asm.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
183bn_asm.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 195bn_asm.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
184bn_asm.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h 196bn_asm.o: ../cryptlib.h bn_asm.c bn_lcl.h
185bn_blind.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 197bn_blind.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
186bn_blind.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 198bn_blind.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
187bn_blind.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 199bn_blind.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
188bn_blind.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 200bn_blind.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
189bn_blind.o: ../../include/openssl/opensslconf.h
190bn_blind.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 201bn_blind.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
191bn_blind.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 202bn_blind.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
192bn_blind.o: ../cryptlib.h bn_lcl.h 203bn_blind.o: ../cryptlib.h bn_blind.c bn_lcl.h
193bn_ctx.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 204bn_ctx.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
194bn_ctx.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 205bn_ctx.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
195bn_ctx.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 206bn_ctx.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
196bn_ctx.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 207bn_ctx.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
197bn_ctx.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 208bn_ctx.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
198bn_ctx.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 209bn_ctx.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
199bn_ctx.o: ../../include/openssl/symhacks.h ../cryptlib.h 210bn_ctx.o: ../cryptlib.h bn_ctx.c bn_lcl.h
200bn_div.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 211bn_div.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
201bn_div.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 212bn_div.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
202bn_div.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 213bn_div.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
203bn_div.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 214bn_div.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
204bn_div.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 215bn_div.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
205bn_div.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 216bn_div.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
206bn_div.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h 217bn_div.o: ../cryptlib.h bn_div.c bn_lcl.h
207bn_err.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 218bn_err.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
208bn_err.o: ../../include/openssl/crypto.h ../../include/openssl/err.h 219bn_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
209bn_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 220bn_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
210bn_err.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 221bn_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
211bn_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 222bn_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
212bn_exp.o: ../../include/openssl/bio.h ../../include/openssl/bn.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
213bn_exp.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 225bn_exp.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
214bn_exp.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 226bn_exp.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
215bn_exp.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 227bn_exp.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
216bn_exp.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 228bn_exp.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
217bn_exp.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 229bn_exp.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
218bn_exp.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h 230bn_exp.o: ../cryptlib.h bn_exp.c bn_lcl.h
219bn_exp2.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 231bn_exp2.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
220bn_exp2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 232bn_exp2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
221bn_exp2.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 233bn_exp2.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
222bn_exp2.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 234bn_exp2.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
223bn_exp2.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 235bn_exp2.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
224bn_exp2.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 236bn_exp2.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
225bn_exp2.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h 237bn_exp2.o: ../cryptlib.h bn_exp2.c bn_lcl.h
226bn_gcd.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 238bn_gcd.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
227bn_gcd.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 239bn_gcd.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
228bn_gcd.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 240bn_gcd.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
229bn_gcd.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 241bn_gcd.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
230bn_gcd.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 242bn_gcd.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
231bn_gcd.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 243bn_gcd.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
232bn_gcd.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h 244bn_gcd.o: ../cryptlib.h bn_gcd.c bn_lcl.h
233bn_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.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
234bn_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 248bn_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
235bn_lib.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 249bn_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
236bn_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 250bn_lib.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
237bn_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 251bn_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
238bn_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 252bn_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
239bn_lib.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h 253bn_lib.o: ../cryptlib.h bn_lcl.h bn_lib.c
240bn_mont.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 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
241bn_mont.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 262bn_mont.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
242bn_mont.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 263bn_mont.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
243bn_mont.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 264bn_mont.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
244bn_mont.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 265bn_mont.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
245bn_mont.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 266bn_mont.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
246bn_mont.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h 267bn_mont.o: ../cryptlib.h bn_lcl.h bn_mont.c
247bn_mpi.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 268bn_mpi.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
248bn_mpi.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 269bn_mpi.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
249bn_mpi.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 270bn_mpi.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
250bn_mpi.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 271bn_mpi.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
251bn_mpi.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 272bn_mpi.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
252bn_mpi.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 273bn_mpi.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
253bn_mpi.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h 274bn_mpi.o: ../cryptlib.h bn_lcl.h bn_mpi.c
254bn_mul.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 275bn_mul.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
255bn_mul.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 276bn_mul.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
256bn_mul.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 277bn_mul.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
257bn_mul.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 278bn_mul.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
258bn_mul.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 279bn_mul.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
259bn_mul.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 280bn_mul.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
260bn_mul.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h 281bn_mul.o: ../cryptlib.h bn_lcl.h bn_mul.c
261bn_prime.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 282bn_prime.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
262bn_prime.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 283bn_prime.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
263bn_prime.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 284bn_prime.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
264bn_prime.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 285bn_prime.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
265bn_prime.o: ../../include/openssl/opensslconf.h 286bn_prime.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
266bn_prime.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 287bn_prime.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
267bn_prime.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 288bn_prime.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
268bn_prime.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h bn_prime.h 289bn_prime.o: ../cryptlib.h bn_lcl.h bn_prime.c bn_prime.h
269bn_print.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 290bn_print.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
270bn_print.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 291bn_print.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
271bn_print.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 292bn_print.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
272bn_print.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 293bn_print.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
273bn_print.o: ../../include/openssl/opensslconf.h
274bn_print.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 294bn_print.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
275bn_print.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 295bn_print.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
276bn_print.o: ../cryptlib.h bn_lcl.h 296bn_print.o: ../cryptlib.h bn_lcl.h bn_print.c
277bn_rand.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 297bn_rand.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
278bn_rand.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 298bn_rand.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
279bn_rand.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 299bn_rand.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
280bn_rand.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 300bn_rand.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
281bn_rand.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 301bn_rand.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
282bn_rand.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h 302bn_rand.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
283bn_rand.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 303bn_rand.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
284bn_rand.o: ../cryptlib.h bn_lcl.h 304bn_rand.o: ../cryptlib.h bn_lcl.h bn_rand.c
285bn_recp.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 305bn_recp.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
286bn_recp.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 306bn_recp.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
287bn_recp.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 307bn_recp.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
288bn_recp.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 308bn_recp.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
289bn_recp.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 309bn_recp.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
290bn_recp.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 310bn_recp.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
291bn_recp.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h 311bn_recp.o: ../cryptlib.h bn_lcl.h bn_recp.c
292bn_shift.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 312bn_shift.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
293bn_shift.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 313bn_shift.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
294bn_shift.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 314bn_shift.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
295bn_shift.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 315bn_shift.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
296bn_shift.o: ../../include/openssl/opensslconf.h
297bn_shift.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 316bn_shift.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
298bn_shift.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 317bn_shift.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
299bn_shift.o: ../cryptlib.h bn_lcl.h 318bn_shift.o: ../cryptlib.h bn_lcl.h bn_shift.c
300bn_sqr.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 319bn_sqr.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
301bn_sqr.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 320bn_sqr.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
302bn_sqr.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 321bn_sqr.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
303bn_sqr.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 322bn_sqr.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
304bn_sqr.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 323bn_sqr.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
305bn_sqr.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 324bn_sqr.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
306bn_sqr.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h 325bn_sqr.o: ../cryptlib.h bn_lcl.h bn_sqr.c
307bn_word.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 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
308bn_word.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 334bn_word.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
309bn_word.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 335bn_word.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
310bn_word.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 336bn_word.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
311bn_word.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 337bn_word.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
312bn_word.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 338bn_word.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
313bn_word.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.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
index a0fe58a677..b0f3a68a06 100644
--- a/src/lib/libcrypto/bn/asm/README
+++ b/src/lib/libcrypto/bn/asm/README
@@ -1,3 +1,5 @@
1<OBSOLETE>
2
1All assember in this directory are just version of the file 3All assember in this directory are just version of the file
2crypto/bn/bn_asm.c. 4crypto/bn/bn_asm.c.
3 5
@@ -21,3 +23,5 @@ pa-risc.s is the origional one which works fine and generated using gcc :-)
21 23
22pa-risc2W.s and pa-risc2.s are 64 and 32-bit PA-RISC 2.0 implementations 24pa-risc2W.s and pa-risc2.s are 64 and 32-bit PA-RISC 2.0 implementations
23by Chris Ruemmler from HP (with some help from the HP C compiler). 25by Chris Ruemmler from HP (with some help from the HP C compiler).
26
27</OBSOLETE>
diff --git a/src/lib/libcrypto/bn/asm/bn-586.pl b/src/lib/libcrypto/bn/asm/bn-586.pl
index 5191bed273..33f6125920 100644
--- a/src/lib/libcrypto/bn/asm/bn-586.pl
+++ b/src/lib/libcrypto/bn/asm/bn-586.pl
@@ -11,6 +11,7 @@ require "x86asm.pl";
11&bn_div_words("bn_div_words"); 11&bn_div_words("bn_div_words");
12&bn_add_words("bn_add_words"); 12&bn_add_words("bn_add_words");
13&bn_sub_words("bn_sub_words"); 13&bn_sub_words("bn_sub_words");
14&bn_sub_part_words("bn_sub_part_words");
14 15
15&asm_finish(); 16&asm_finish();
16 17
@@ -300,7 +301,7 @@ sub bn_add_words
300 &add($tmp1,$tmp2); 301 &add($tmp1,$tmp2);
301 &adc($c,0); 302 &adc($c,0);
302 &dec($num) if ($i != 6); 303 &dec($num) if ($i != 6);
303 &mov(&DWP($i*4,$r,"",0),$tmp1); # *a 304 &mov(&DWP($i*4,$r,"",0),$tmp1); # *r
304 &jz(&label("aw_end")) if ($i != 6); 305 &jz(&label("aw_end")) if ($i != 6);
305 } 306 }
306 &set_label("aw_end",0); 307 &set_label("aw_end",0);
@@ -372,7 +373,7 @@ sub bn_sub_words
372 &sub($tmp1,$tmp2); 373 &sub($tmp1,$tmp2);
373 &adc($c,0); 374 &adc($c,0);
374 &dec($num) if ($i != 6); 375 &dec($num) if ($i != 6);
375 &mov(&DWP($i*4,$r,"",0),$tmp1); # *a 376 &mov(&DWP($i*4,$r,"",0),$tmp1); # *r
376 &jz(&label("aw_end")) if ($i != 6); 377 &jz(&label("aw_end")) if ($i != 6);
377 } 378 }
378 &set_label("aw_end",0); 379 &set_label("aw_end",0);
@@ -382,3 +383,211 @@ sub bn_sub_words
382 &function_end($name); 383 &function_end($name);
383 } 384 }
384 385
386sub bn_sub_part_words
387 {
388 local($name)=@_;
389
390 &function_begin($name,"");
391
392 &comment("");
393 $a="esi";
394 $b="edi";
395 $c="eax";
396 $r="ebx";
397 $tmp1="ecx";
398 $tmp2="edx";
399 $num="ebp";
400
401 &mov($r,&wparam(0)); # get r
402 &mov($a,&wparam(1)); # get a
403 &mov($b,&wparam(2)); # get b
404 &mov($num,&wparam(3)); # get num
405 &xor($c,$c); # clear carry
406 &and($num,0xfffffff8); # num / 8
407
408 &jz(&label("aw_finish"));
409
410 &set_label("aw_loop",0);
411 for ($i=0; $i<8; $i++)
412 {
413 &comment("Round $i");
414
415 &mov($tmp1,&DWP($i*4,$a,"",0)); # *a
416 &mov($tmp2,&DWP($i*4,$b,"",0)); # *b
417 &sub($tmp1,$c);
418 &mov($c,0);
419 &adc($c,$c);
420 &sub($tmp1,$tmp2);
421 &adc($c,0);
422 &mov(&DWP($i*4,$r,"",0),$tmp1); # *r
423 }
424
425 &comment("");
426 &add($a,32);
427 &add($b,32);
428 &add($r,32);
429 &sub($num,8);
430 &jnz(&label("aw_loop"));
431
432 &set_label("aw_finish",0);
433 &mov($num,&wparam(3)); # get num
434 &and($num,7);
435 &jz(&label("aw_end"));
436
437 for ($i=0; $i<7; $i++)
438 {
439 &comment("Tail Round $i");
440 &mov($tmp1,&DWP(0,$a,"",0)); # *a
441 &mov($tmp2,&DWP(0,$b,"",0));# *b
442 &sub($tmp1,$c);
443 &mov($c,0);
444 &adc($c,$c);
445 &sub($tmp1,$tmp2);
446 &adc($c,0);
447 &mov(&DWP(0,$r,"",0),$tmp1); # *r
448 &add($a, 4);
449 &add($b, 4);
450 &add($r, 4);
451 &dec($num) if ($i != 6);
452 &jz(&label("aw_end")) if ($i != 6);
453 }
454 &set_label("aw_end",0);
455
456 &cmp(&wparam(4),0);
457 &je(&label("pw_end"));
458
459 &mov($num,&wparam(4)); # get dl
460 &cmp($num,0);
461 &je(&label("pw_end"));
462 &jge(&label("pw_pos"));
463
464 &comment("pw_neg");
465 &mov($tmp2,0);
466 &sub($tmp2,$num);
467 &mov($num,$tmp2);
468 &and($num,0xfffffff8); # num / 8
469 &jz(&label("pw_neg_finish"));
470
471 &set_label("pw_neg_loop",0);
472 for ($i=0; $i<8; $i++)
473 {
474 &comment("dl<0 Round $i");
475
476 &mov($tmp1,0);
477 &mov($tmp2,&DWP($i*4,$b,"",0)); # *b
478 &sub($tmp1,$c);
479 &mov($c,0);
480 &adc($c,$c);
481 &sub($tmp1,$tmp2);
482 &adc($c,0);
483 &mov(&DWP($i*4,$r,"",0),$tmp1); # *r
484 }
485
486 &comment("");
487 &add($b,32);
488 &add($r,32);
489 &sub($num,8);
490 &jnz(&label("pw_neg_loop"));
491
492 &set_label("pw_neg_finish",0);
493 &mov($tmp2,&wparam(4)); # get dl
494 &mov($num,0);
495 &sub($num,$tmp2);
496 &and($num,7);
497 &jz(&label("pw_end"));
498
499 for ($i=0; $i<7; $i++)
500 {
501 &comment("dl<0 Tail Round $i");
502 &mov($tmp1,0);
503 &mov($tmp2,&DWP($i*4,$b,"",0));# *b
504 &sub($tmp1,$c);
505 &mov($c,0);
506 &adc($c,$c);
507 &sub($tmp1,$tmp2);
508 &adc($c,0);
509 &dec($num) if ($i != 6);
510 &mov(&DWP($i*4,$r,"",0),$tmp1); # *r
511 &jz(&label("pw_end")) if ($i != 6);
512 }
513
514 &jmp(&label("pw_end"));
515
516 &set_label("pw_pos",0);
517
518 &and($num,0xfffffff8); # num / 8
519 &jz(&label("pw_pos_finish"));
520
521 &set_label("pw_pos_loop",0);
522
523 for ($i=0; $i<8; $i++)
524 {
525 &comment("dl>0 Round $i");
526
527 &mov($tmp1,&DWP($i*4,$a,"",0)); # *a
528 &sub($tmp1,$c);
529 &mov(&DWP($i*4,$r,"",0),$tmp1); # *r
530 &jnc(&label("pw_nc".$i));
531 }
532
533 &comment("");
534 &add($a,32);
535 &add($r,32);
536 &sub($num,8);
537 &jnz(&label("pw_pos_loop"));
538
539 &set_label("pw_pos_finish",0);
540 &mov($num,&wparam(4)); # get dl
541 &and($num,7);
542 &jz(&label("pw_end"));
543
544 for ($i=0; $i<7; $i++)
545 {
546 &comment("dl>0 Tail Round $i");
547 &mov($tmp1,&DWP($i*4,$a,"",0)); # *a
548 &sub($tmp1,$c);
549 &mov(&DWP($i*4,$r,"",0),$tmp1); # *r
550 &jnc(&label("pw_tail_nc".$i));
551 &dec($num) if ($i != 6);
552 &jz(&label("pw_end")) if ($i != 6);
553 }
554 &mov($c,1);
555 &jmp(&label("pw_end"));
556
557 &set_label("pw_nc_loop",0);
558 for ($i=0; $i<8; $i++)
559 {
560 &mov($tmp1,&DWP($i*4,$a,"",0)); # *a
561 &mov(&DWP($i*4,$r,"",0),$tmp1); # *r
562 &set_label("pw_nc".$i,0);
563 }
564
565 &comment("");
566 &add($a,32);
567 &add($r,32);
568 &sub($num,8);
569 &jnz(&label("pw_nc_loop"));
570
571 &mov($num,&wparam(4)); # get dl
572 &and($num,7);
573 &jz(&label("pw_nc_end"));
574
575 for ($i=0; $i<7; $i++)
576 {
577 &mov($tmp1,&DWP($i*4,$a,"",0)); # *a
578 &mov(&DWP($i*4,$r,"",0),$tmp1); # *r
579 &set_label("pw_tail_nc".$i,0);
580 &dec($num) if ($i != 6);
581 &jz(&label("pw_nc_end")) if ($i != 6);
582 }
583
584 &set_label("pw_nc_end",0);
585 &mov($c,0);
586
587 &set_label("pw_end",0);
588
589# &mov("eax",$c); # $c is "eax"
590
591 &function_end($name);
592 }
593
diff --git a/src/lib/libcrypto/bn/asm/ia64.S b/src/lib/libcrypto/bn/asm/ia64.S
new file mode 100644
index 0000000000..ae56066310
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/ia64.S
@@ -0,0 +1,1498 @@
1.explicit
2.text
3.ident "ia64.S, Version 1.1"
4.ident "IA-64 ISA artwork by Andy Polyakov <appro@fy.chalmers.se>"
5
6//
7// ====================================================================
8// Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL
9// project.
10//
11// Rights for redistribution and usage in source and binary forms are
12// granted according to the OpenSSL license. Warranty of any kind is
13// disclaimed.
14// ====================================================================
15//
16
17// Q. How much faster does it get?
18// A. Here is the output from 'openssl speed rsa dsa' for vanilla
19// 0.9.6a compiled with gcc version 2.96 20000731 (Red Hat
20// Linux 7.1 2.96-81):
21//
22// sign verify sign/s verify/s
23// rsa 512 bits 0.0036s 0.0003s 275.3 2999.2
24// rsa 1024 bits 0.0203s 0.0011s 49.3 894.1
25// rsa 2048 bits 0.1331s 0.0040s 7.5 250.9
26// rsa 4096 bits 0.9270s 0.0147s 1.1 68.1
27// sign verify sign/s verify/s
28// dsa 512 bits 0.0035s 0.0043s 288.3 234.8
29// dsa 1024 bits 0.0111s 0.0135s 90.0 74.2
30//
31// And here is similar output but for this assembler
32// implementation:-)
33//
34// sign verify sign/s verify/s
35// rsa 512 bits 0.0021s 0.0001s 549.4 9638.5
36// rsa 1024 bits 0.0055s 0.0002s 183.8 4481.1
37// rsa 2048 bits 0.0244s 0.0006s 41.4 1726.3
38// rsa 4096 bits 0.1295s 0.0018s 7.7 561.5
39// sign verify sign/s verify/s
40// dsa 512 bits 0.0012s 0.0013s 891.9 756.6
41// dsa 1024 bits 0.0023s 0.0028s 440.4 376.2
42//
43// Yes, you may argue that it's not fair comparison as it's
44// possible to craft the C implementation with BN_UMULT_HIGH
45// inline assembler macro. But of course! Here is the output
46// with the macro:
47//
48// sign verify sign/s verify/s
49// rsa 512 bits 0.0020s 0.0002s 495.0 6561.0
50// rsa 1024 bits 0.0086s 0.0004s 116.2 2235.7
51// rsa 2048 bits 0.0519s 0.0015s 19.3 667.3
52// rsa 4096 bits 0.3464s 0.0053s 2.9 187.7
53// sign verify sign/s verify/s
54// dsa 512 bits 0.0016s 0.0020s 613.1 510.5
55// dsa 1024 bits 0.0045s 0.0054s 221.0 183.9
56//
57// My code is still way faster, huh:-) And I believe that even
58// higher performance can be achieved. Note that as keys get
59// longer, performance gain is larger. Why? According to the
60// profiler there is another player in the field, namely
61// BN_from_montgomery consuming larger and larger portion of CPU
62// time as keysize decreases. I therefore consider putting effort
63// to assembler implementation of the following routine:
64//
65// void bn_mul_add_mont (BN_ULONG *rp,BN_ULONG *np,int nl,BN_ULONG n0)
66// {
67// int i,j;
68// BN_ULONG v;
69//
70// for (i=0; i<nl; i++)
71// {
72// v=bn_mul_add_words(rp,np,nl,(rp[0]*n0)&BN_MASK2);
73// nrp++;
74// rp++;
75// if (((nrp[-1]+=v)&BN_MASK2) < v)
76// for (j=0; ((++nrp[j])&BN_MASK2) == 0; j++) ;
77// }
78// }
79//
80// It might as well be beneficial to implement even combaX
81// variants, as it appears as it can literally unleash the
82// performance (see comment section to bn_mul_comba8 below).
83//
84// And finally for your reference the output for 0.9.6a compiled
85// with SGIcc version 0.01.0-12 (keep in mind that for the moment
86// of this writing it's not possible to convince SGIcc to use
87// BN_UMULT_HIGH inline assembler macro, yet the code is fast,
88// i.e. for a compiler generated one:-):
89//
90// sign verify sign/s verify/s
91// rsa 512 bits 0.0022s 0.0002s 452.7 5894.3
92// rsa 1024 bits 0.0097s 0.0005s 102.7 2002.9
93// rsa 2048 bits 0.0578s 0.0017s 17.3 600.2
94// rsa 4096 bits 0.3838s 0.0061s 2.6 164.5
95// sign verify sign/s verify/s
96// dsa 512 bits 0.0018s 0.0022s 547.3 459.6
97// dsa 1024 bits 0.0051s 0.0062s 196.6 161.3
98//
99// Oh! Benchmarks were performed on 733MHz Lion-class Itanium
100// system running Redhat Linux 7.1 (very special thanks to Ray
101// McCaffity of Williams Communications for providing an account).
102//
103// Q. What's the heck with 'rum 1<<5' at the end of every function?
104// A. Well, by clearing the "upper FP registers written" bit of the
105// User Mask I want to excuse the kernel from preserving upper
106// (f32-f128) FP register bank over process context switch, thus
107// minimizing bus bandwidth consumption during the switch (i.e.
108// after PKI opration completes and the program is off doing
109// something else like bulk symmetric encryption). Having said
110// this, I also want to point out that it might be good idea
111// to compile the whole toolkit (as well as majority of the
112// programs for that matter) with -mfixed-range=f32-f127 command
113// line option. No, it doesn't prevent the compiler from writing
114// to upper bank, but at least discourages to do so. If you don't
115// like the idea you have the option to compile the module with
116// -Drum=nop.m in command line.
117//
118
119#if 1
120//
121// bn_[add|sub]_words routines.
122//
123// Loops are spinning in 2*(n+5) ticks on Itanuim (provided that the
124// data reside in L1 cache, i.e. 2 ticks away). It's possible to
125// compress the epilogue and get down to 2*n+6, but at the cost of
126// scalability (the neat feature of this implementation is that it
127// shall automagically spin in n+5 on "wider" IA-64 implementations:-)
128// I consider that the epilogue is short enough as it is to trade tiny
129// performance loss on Itanium for scalability.
130//
131// BN_ULONG bn_add_words(BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,int num)
132//
133.global bn_add_words#
134.proc bn_add_words#
135.align 64
136.skip 32 // makes the loop body aligned at 64-byte boundary
137bn_add_words:
138 .prologue
139 .fframe 0
140 .save ar.pfs,r2
141{ .mii; alloc r2=ar.pfs,4,12,0,16
142 cmp4.le p6,p0=r35,r0 };;
143{ .mfb; mov r8=r0 // return value
144(p6) br.ret.spnt.many b0 };;
145
146 .save ar.lc,r3
147{ .mib; sub r10=r35,r0,1
148 mov r3=ar.lc
149 brp.loop.imp .L_bn_add_words_ctop,.L_bn_add_words_cend-16
150 }
151 .body
152{ .mib; mov r14=r32 // rp
153 mov r9=pr };;
154{ .mii; mov r15=r33 // ap
155 mov ar.lc=r10
156 mov ar.ec=6 }
157{ .mib; mov r16=r34 // bp
158 mov pr.rot=1<<16 };;
159
160.L_bn_add_words_ctop:
161{ .mii; (p16) ld8 r32=[r16],8 // b=*(bp++)
162 (p18) add r39=r37,r34
163 (p19) cmp.ltu.unc p56,p0=r40,r38 }
164{ .mfb; (p0) nop.m 0x0
165 (p0) nop.f 0x0
166 (p0) nop.b 0x0 }
167{ .mii; (p16) ld8 r35=[r15],8 // a=*(ap++)
168 (p58) cmp.eq.or p57,p0=-1,r41 // (p20)
169 (p58) add r41=1,r41 } // (p20)
170{ .mfb; (p21) st8 [r14]=r42,8 // *(rp++)=r
171 (p0) nop.f 0x0
172 br.ctop.sptk .L_bn_add_words_ctop };;
173.L_bn_add_words_cend:
174
175{ .mii;
176(p59) add r8=1,r8 // return value
177 mov pr=r9,-1
178 mov ar.lc=r3 }
179{ .mbb; nop.b 0x0
180 br.ret.sptk.many b0 };;
181.endp bn_add_words#
182
183//
184// BN_ULONG bn_sub_words(BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,int num)
185//
186.global bn_sub_words#
187.proc bn_sub_words#
188.align 64
189.skip 32 // makes the loop body aligned at 64-byte boundary
190bn_sub_words:
191 .prologue
192 .fframe 0
193 .save ar.pfs,r2
194{ .mii; alloc r2=ar.pfs,4,12,0,16
195 cmp4.le p6,p0=r35,r0 };;
196{ .mfb; mov r8=r0 // return value
197(p6) br.ret.spnt.many b0 };;
198
199 .save ar.lc,r3
200{ .mib; sub r10=r35,r0,1
201 mov r3=ar.lc
202 brp.loop.imp .L_bn_sub_words_ctop,.L_bn_sub_words_cend-16
203 }
204 .body
205{ .mib; mov r14=r32 // rp
206 mov r9=pr };;
207{ .mii; mov r15=r33 // ap
208 mov ar.lc=r10
209 mov ar.ec=6 }
210{ .mib; mov r16=r34 // bp
211 mov pr.rot=1<<16 };;
212
213.L_bn_sub_words_ctop:
214{ .mii; (p16) ld8 r32=[r16],8 // b=*(bp++)
215 (p18) sub r39=r37,r34
216 (p19) cmp.gtu.unc p56,p0=r40,r38 }
217{ .mfb; (p0) nop.m 0x0
218 (p0) nop.f 0x0
219 (p0) nop.b 0x0 }
220{ .mii; (p16) ld8 r35=[r15],8 // a=*(ap++)
221 (p58) cmp.eq.or p57,p0=0,r41 // (p20)
222 (p58) add r41=-1,r41 } // (p20)
223{ .mbb; (p21) st8 [r14]=r42,8 // *(rp++)=r
224 (p0) nop.b 0x0
225 br.ctop.sptk .L_bn_sub_words_ctop };;
226.L_bn_sub_words_cend:
227
228{ .mii;
229(p59) add r8=1,r8 // return value
230 mov pr=r9,-1
231 mov ar.lc=r3 }
232{ .mbb; nop.b 0x0
233 br.ret.sptk.many b0 };;
234.endp bn_sub_words#
235#endif
236
237#if 0
238#define XMA_TEMPTATION
239#endif
240
241#if 1
242//
243// BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w)
244//
245.global bn_mul_words#
246.proc bn_mul_words#
247.align 64
248.skip 32 // makes the loop body aligned at 64-byte boundary
249bn_mul_words:
250 .prologue
251 .fframe 0
252 .save ar.pfs,r2
253#ifdef XMA_TEMPTATION
254{ .mfi; alloc r2=ar.pfs,4,0,0,0 };;
255#else
256{ .mfi; alloc r2=ar.pfs,4,4,0,8 };;
257#endif
258{ .mib; mov r8=r0 // return value
259 cmp4.le p6,p0=r34,r0
260(p6) br.ret.spnt.many b0 };;
261
262 .save ar.lc,r3
263{ .mii; sub r10=r34,r0,1
264 mov r3=ar.lc
265 mov r9=pr };;
266
267 .body
268{ .mib; setf.sig f8=r35 // w
269 mov pr.rot=0x400001<<16
270 // ------^----- serves as (p48) at first (p26)
271 brp.loop.imp .L_bn_mul_words_ctop,.L_bn_mul_words_cend-16
272 }
273
274#ifndef XMA_TEMPTATION
275
276{ .mii; mov r14=r32 // rp
277 mov r15=r33 // ap
278 mov ar.lc=r10 }
279{ .mii; mov r39=0 // serves as r33 at first (p26)
280 mov ar.ec=12 };;
281
282// This loop spins in 2*(n+11) ticks. It's scheduled for data in L2
283// cache (i.e. 9 ticks away) as floating point load/store instructions
284// bypass L1 cache and L2 latency is actually best-case scenario for
285// ldf8. The loop is not scalable and shall run in 2*(n+11) even on
286// "wider" IA-64 implementations. It's a trade-off here. n+22 loop
287// would give us ~5% in *overall* performance improvement on "wider"
288// IA-64, but would hurt Itanium for about same because of longer
289// epilogue. As it's a matter of few percents in either case I've
290// chosen to trade the scalability for development time (you can see
291// this very instruction sequence in bn_mul_add_words loop which in
292// turn is scalable).
293.L_bn_mul_words_ctop:
294{ .mfi; (p25) getf.sig r36=f49 // low
295 (p21) xmpy.lu f45=f37,f8
296 (p27) cmp.ltu p52,p48=r39,r38 }
297{ .mfi; (p16) ldf8 f32=[r15],8
298 (p21) xmpy.hu f38=f37,f8
299 (p0) nop.i 0x0 };;
300{ .mii; (p26) getf.sig r32=f43 // high
301 .pred.rel "mutex",p48,p52
302 (p48) add r38=r37,r33 // (p26)
303 (p52) add r38=r37,r33,1 } // (p26)
304{ .mfb; (p27) st8 [r14]=r39,8
305 (p0) nop.f 0x0
306 br.ctop.sptk .L_bn_mul_words_ctop };;
307.L_bn_mul_words_cend:
308
309{ .mii; nop.m 0x0
310.pred.rel "mutex",p49,p53
311(p49) add r8=r34,r0
312(p53) add r8=r34,r0,1 }
313{ .mfb; nop.m 0x0
314 nop.f 0x0
315 nop.b 0x0 }
316
317#else // XMA_TEMPTATION
318
319 setf.sig f37=r0 // serves as carry at (p18) tick
320 mov ar.lc=r10
321 mov ar.ec=5;;
322
323// Most of you examining this code very likely wonder why in the name
324// of Intel the following loop is commented out? Indeed, it looks so
325// neat that you find it hard to believe that it's something wrong
326// with it, right? The catch is that every iteration depends on the
327// result from previous one and the latter isn't available instantly.
328// The loop therefore spins at the latency of xma minus 1, or in other
329// words at 6*(n+4) ticks:-( Compare to the "production" loop above
330// that runs in 2*(n+11) where the low latency problem is worked around
331// by moving the dependency to one-tick latent interger ALU. Note that
332// "distance" between ldf8 and xma is not latency of ldf8, but the
333// *difference* between xma and ldf8 latencies.
334.L_bn_mul_words_ctop:
335{ .mfi; (p16) ldf8 f32=[r33],8
336 (p18) xma.hu f38=f34,f8,f39 }
337{ .mfb; (p20) stf8 [r32]=f37,8
338 (p18) xma.lu f35=f34,f8,f39
339 br.ctop.sptk .L_bn_mul_words_ctop };;
340.L_bn_mul_words_cend:
341
342 getf.sig r8=f41 // the return value
343
344#endif // XMA_TEMPTATION
345
346{ .mii; nop.m 0x0
347 mov pr=r9,-1
348 mov ar.lc=r3 }
349{ .mfb; rum 1<<5 // clear um.mfh
350 nop.f 0x0
351 br.ret.sptk.many b0 };;
352.endp bn_mul_words#
353#endif
354
355#if 1
356//
357// BN_ULONG bn_mul_add_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w)
358//
359.global bn_mul_add_words#
360.proc bn_mul_add_words#
361.align 64
362//.skip 0 // makes the loop split at 64-byte boundary
363bn_mul_add_words:
364 .prologue
365 .fframe 0
366 .save ar.pfs,r2
367{ .mii; alloc r2=ar.pfs,4,12,0,16
368 cmp4.le p6,p0=r34,r0 };;
369{ .mfb; mov r8=r0 // return value
370(p6) br.ret.spnt.many b0 };;
371
372 .save ar.lc,r3
373{ .mii; sub r10=r34,r0,1
374 mov r3=ar.lc
375 mov r9=pr };;
376
377 .body
378{ .mib; setf.sig f8=r35 // w
379 mov pr.rot=0x400001<<16
380 // ------^----- serves as (p48) at first (p26)
381 brp.loop.imp .L_bn_mul_add_words_ctop,.L_bn_mul_add_words_cend-16
382 }
383{ .mii; mov r14=r32 // rp
384 mov r15=r33 // ap
385 mov ar.lc=r10 }
386{ .mii; mov r39=0 // serves as r33 at first (p26)
387 mov r18=r32 // rp copy
388 mov ar.ec=14 };;
389
390// This loop spins in 3*(n+13) ticks on Itanium and should spin in
391// 2*(n+13) on "wider" IA-64 implementations (to be verified with new
392// µ-architecture manuals as they become available). As usual it's
393// possible to compress the epilogue, down to 10 in this case, at the
394// cost of scalability. Compressed (and therefore non-scalable) loop
395// running at 3*(n+10) would buy you ~10% on Itanium but take ~35%
396// from "wider" IA-64 so let it be scalable! Special attention was
397// paid for having the loop body split at 64-byte boundary. ld8 is
398// scheduled for L1 cache as the data is more than likely there.
399// Indeed, bn_mul_words has put it there a moment ago:-)
400.L_bn_mul_add_words_ctop:
401{ .mfi; (p25) getf.sig r36=f49 // low
402 (p21) xmpy.lu f45=f37,f8
403 (p27) cmp.ltu p52,p48=r39,r38 }
404{ .mfi; (p16) ldf8 f32=[r15],8
405 (p21) xmpy.hu f38=f37,f8
406 (p27) add r43=r43,r39 };;
407{ .mii; (p26) getf.sig r32=f43 // high
408 .pred.rel "mutex",p48,p52
409 (p48) add r38=r37,r33 // (p26)
410 (p52) add r38=r37,r33,1 } // (p26)
411{ .mfb; (p27) cmp.ltu.unc p56,p0=r43,r39
412 (p0) nop.f 0x0
413 (p0) nop.b 0x0 }
414{ .mii; (p26) ld8 r42=[r18],8
415 (p58) cmp.eq.or p57,p0=-1,r44
416 (p58) add r44=1,r44 }
417{ .mfb; (p29) st8 [r14]=r45,8
418 (p0) nop.f 0x0
419 br.ctop.sptk .L_bn_mul_add_words_ctop};;
420.L_bn_mul_add_words_cend:
421
422{ .mii; nop.m 0x0
423.pred.rel "mutex",p51,p55
424(p51) add r8=r36,r0
425(p55) add r8=r36,r0,1 }
426{ .mfb; nop.m 0x0
427 nop.f 0x0
428 nop.b 0x0 };;
429{ .mii;
430(p59) add r8=1,r8
431 mov pr=r9,-1
432 mov ar.lc=r3 }
433{ .mfb; rum 1<<5 // clear um.mfh
434 nop.f 0x0
435 br.ret.sptk.many b0 };;
436.endp bn_mul_add_words#
437#endif
438
439#if 1
440//
441// void bn_sqr_words(BN_ULONG *rp, BN_ULONG *ap, int num)
442//
443.global bn_sqr_words#
444.proc bn_sqr_words#
445.align 64
446.skip 32 // makes the loop body aligned at 64-byte boundary
447bn_sqr_words:
448 .prologue
449 .fframe 0
450 .save ar.pfs,r2
451{ .mii; alloc r2=ar.pfs,3,0,0,0
452 sxt4 r34=r34 };;
453{ .mii; cmp.le p6,p0=r34,r0
454 mov r8=r0 } // return value
455{ .mfb; nop.f 0x0
456(p6) br.ret.spnt.many b0 };;
457
458 .save ar.lc,r3
459{ .mii; sub r10=r34,r0,1
460 mov r3=ar.lc
461 mov r9=pr };;
462
463 .body
464{ .mib;
465 mov pr.rot=1<<16
466 brp.loop.imp .L_bn_sqr_words_ctop,.L_bn_sqr_words_cend-16
467 }
468{ .mii; add r34=8,r32
469 mov ar.lc=r10
470 mov ar.ec=18 };;
471
472// 2*(n+17) on Itanium, (n+17) on "wider" IA-64 implementations. It's
473// possible to compress the epilogue (I'm getting tired to write this
474// comment over and over) and get down to 2*n+16 at the cost of
475// scalability. The decision will very likely be reconsidered after the
476// benchmark program is profiled. I.e. if perfomance gain on Itanium
477// will appear larger than loss on "wider" IA-64, then the loop should
478// be explicitely split and the epilogue compressed.
479.L_bn_sqr_words_ctop:
480{ .mfi; (p16) ldf8 f32=[r33],8
481 (p25) xmpy.lu f42=f41,f41
482 (p0) nop.i 0x0 }
483{ .mib; (p33) stf8 [r32]=f50,16
484 (p0) nop.i 0x0
485 (p0) nop.b 0x0 }
486{ .mfi; (p0) nop.m 0x0
487 (p25) xmpy.hu f52=f41,f41
488 (p0) nop.i 0x0 }
489{ .mib; (p33) stf8 [r34]=f60,16
490 (p0) nop.i 0x0
491 br.ctop.sptk .L_bn_sqr_words_ctop };;
492.L_bn_sqr_words_cend:
493
494{ .mii; nop.m 0x0
495 mov pr=r9,-1
496 mov ar.lc=r3 }
497{ .mfb; rum 1<<5 // clear um.mfh
498 nop.f 0x0
499 br.ret.sptk.many b0 };;
500.endp bn_sqr_words#
501#endif
502
503#if 1
504// Apparently we win nothing by implementing special bn_sqr_comba8.
505// Yes, it is possible to reduce the number of multiplications by
506// almost factor of two, but then the amount of additions would
507// increase by factor of two (as we would have to perform those
508// otherwise performed by xma ourselves). Normally we would trade
509// anyway as multiplications are way more expensive, but not this
510// time... Multiplication kernel is fully pipelined and as we drain
511// one 128-bit multiplication result per clock cycle multiplications
512// are effectively as inexpensive as additions. Special implementation
513// might become of interest for "wider" IA-64 implementation as you'll
514// be able to get through the multiplication phase faster (there won't
515// be any stall issues as discussed in the commentary section below and
516// you therefore will be able to employ all 4 FP units)... But these
517// Itanium days it's simply too hard to justify the effort so I just
518// drop down to bn_mul_comba8 code:-)
519//
520// void bn_sqr_comba8(BN_ULONG *r, BN_ULONG *a)
521//
522.global bn_sqr_comba8#
523.proc bn_sqr_comba8#
524.align 64
525bn_sqr_comba8:
526 .prologue
527 .fframe 0
528 .save ar.pfs,r2
529{ .mii; alloc r2=ar.pfs,2,1,0,0
530 mov r34=r33
531 add r14=8,r33 };;
532 .body
533{ .mii; add r17=8,r34
534 add r15=16,r33
535 add r18=16,r34 }
536{ .mfb; add r16=24,r33
537 br .L_cheat_entry_point8 };;
538.endp bn_sqr_comba8#
539#endif
540
541#if 1
542// I've estimated this routine to run in ~120 ticks, but in reality
543// (i.e. according to ar.itc) it takes ~160 ticks. Are those extra
544// cycles consumed for instructions fetch? Or did I misinterpret some
545// clause in Itanium µ-architecture manual? Comments are welcomed and
546// highly appreciated.
547//
548// However! It should be noted that even 160 ticks is darn good result
549// as it's over 10 (yes, ten, spelled as t-e-n) times faster than the
550// C version (compiled with gcc with inline assembler). I really
551// kicked compiler's butt here, didn't I? Yeah! This brings us to the
552// following statement. It's damn shame that this routine isn't called
553// very often nowadays! According to the profiler most CPU time is
554// consumed by bn_mul_add_words called from BN_from_montgomery. In
555// order to estimate what we're missing, I've compared the performance
556// of this routine against "traditional" implementation, i.e. against
557// following routine:
558//
559// void bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b)
560// { r[ 8]=bn_mul_words( &(r[0]),a,8,b[0]);
561// r[ 9]=bn_mul_add_words(&(r[1]),a,8,b[1]);
562// r[10]=bn_mul_add_words(&(r[2]),a,8,b[2]);
563// r[11]=bn_mul_add_words(&(r[3]),a,8,b[3]);
564// r[12]=bn_mul_add_words(&(r[4]),a,8,b[4]);
565// r[13]=bn_mul_add_words(&(r[5]),a,8,b[5]);
566// r[14]=bn_mul_add_words(&(r[6]),a,8,b[6]);
567// r[15]=bn_mul_add_words(&(r[7]),a,8,b[7]);
568// }
569//
570// The one below is over 8 times faster than the one above:-( Even
571// more reasons to "combafy" bn_mul_add_mont...
572//
573// And yes, this routine really made me wish there were an optimizing
574// assembler! It also feels like it deserves a dedication.
575//
576// To my wife for being there and to my kids...
577//
578// void bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b)
579//
580#define carry1 r14
581#define carry2 r15
582#define carry3 r34
583.global bn_mul_comba8#
584.proc bn_mul_comba8#
585.align 64
586bn_mul_comba8:
587 .prologue
588 .fframe 0
589 .save ar.pfs,r2
590{ .mii; alloc r2=ar.pfs,3,0,0,0
591 add r14=8,r33
592 add r17=8,r34 }
593 .body
594{ .mii; add r15=16,r33
595 add r18=16,r34
596 add r16=24,r33 }
597.L_cheat_entry_point8:
598{ .mmi; add r19=24,r34
599
600 ldf8 f32=[r33],32 };;
601
602{ .mmi; ldf8 f120=[r34],32
603 ldf8 f121=[r17],32 }
604{ .mmi; ldf8 f122=[r18],32
605 ldf8 f123=[r19],32 };;
606{ .mmi; ldf8 f124=[r34]
607 ldf8 f125=[r17] }
608{ .mmi; ldf8 f126=[r18]
609 ldf8 f127=[r19] }
610
611{ .mmi; ldf8 f33=[r14],32
612 ldf8 f34=[r15],32 }
613{ .mmi; ldf8 f35=[r16],32;;
614 ldf8 f36=[r33] }
615{ .mmi; ldf8 f37=[r14]
616 ldf8 f38=[r15] }
617{ .mfi; ldf8 f39=[r16]
618// -------\ Entering multiplier's heaven /-------
619// ------------\ /------------
620// -----------------\ /-----------------
621// ----------------------\/----------------------
622 xma.hu f41=f32,f120,f0 }
623{ .mfi; xma.lu f40=f32,f120,f0 };; // (*)
624{ .mfi; xma.hu f51=f32,f121,f0 }
625{ .mfi; xma.lu f50=f32,f121,f0 };;
626{ .mfi; xma.hu f61=f32,f122,f0 }
627{ .mfi; xma.lu f60=f32,f122,f0 };;
628{ .mfi; xma.hu f71=f32,f123,f0 }
629{ .mfi; xma.lu f70=f32,f123,f0 };;
630{ .mfi; xma.hu f81=f32,f124,f0 }
631{ .mfi; xma.lu f80=f32,f124,f0 };;
632{ .mfi; xma.hu f91=f32,f125,f0 }
633{ .mfi; xma.lu f90=f32,f125,f0 };;
634{ .mfi; xma.hu f101=f32,f126,f0 }
635{ .mfi; xma.lu f100=f32,f126,f0 };;
636{ .mfi; xma.hu f111=f32,f127,f0 }
637{ .mfi; xma.lu f110=f32,f127,f0 };;//
638// (*) You can argue that splitting at every second bundle would
639// prevent "wider" IA-64 implementations from achieving the peak
640// performance. Well, not really... The catch is that if you
641// intend to keep 4 FP units busy by splitting at every fourth
642// bundle and thus perform these 16 multiplications in 4 ticks,
643// the first bundle *below* would stall because the result from
644// the first xma bundle *above* won't be available for another 3
645// ticks (if not more, being an optimist, I assume that "wider"
646// implementation will have same latency:-). This stall will hold
647// you back and the performance would be as if every second bundle
648// were split *anyway*...
649{ .mfi; getf.sig r16=f40
650 xma.hu f42=f33,f120,f41
651 add r33=8,r32 }
652{ .mfi; xma.lu f41=f33,f120,f41 };;
653{ .mfi; getf.sig r24=f50
654 xma.hu f52=f33,f121,f51 }
655{ .mfi; xma.lu f51=f33,f121,f51 };;
656{ .mfi; st8 [r32]=r16,16
657 xma.hu f62=f33,f122,f61 }
658{ .mfi; xma.lu f61=f33,f122,f61 };;
659{ .mfi; xma.hu f72=f33,f123,f71 }
660{ .mfi; xma.lu f71=f33,f123,f71 };;
661{ .mfi; xma.hu f82=f33,f124,f81 }
662{ .mfi; xma.lu f81=f33,f124,f81 };;
663{ .mfi; xma.hu f92=f33,f125,f91 }
664{ .mfi; xma.lu f91=f33,f125,f91 };;
665{ .mfi; xma.hu f102=f33,f126,f101 }
666{ .mfi; xma.lu f101=f33,f126,f101 };;
667{ .mfi; xma.hu f112=f33,f127,f111 }
668{ .mfi; xma.lu f111=f33,f127,f111 };;//
669//-------------------------------------------------//
670{ .mfi; getf.sig r25=f41
671 xma.hu f43=f34,f120,f42 }
672{ .mfi; xma.lu f42=f34,f120,f42 };;
673{ .mfi; getf.sig r16=f60
674 xma.hu f53=f34,f121,f52 }
675{ .mfi; xma.lu f52=f34,f121,f52 };;
676{ .mfi; getf.sig r17=f51
677 xma.hu f63=f34,f122,f62
678 add r25=r25,r24 }
679{ .mfi; xma.lu f62=f34,f122,f62
680 mov carry1=0 };;
681{ .mfi; cmp.ltu p6,p0=r25,r24
682 xma.hu f73=f34,f123,f72 }
683{ .mfi; xma.lu f72=f34,f123,f72 };;
684{ .mfi; st8 [r33]=r25,16
685 xma.hu f83=f34,f124,f82
686(p6) add carry1=1,carry1 }
687{ .mfi; xma.lu f82=f34,f124,f82 };;
688{ .mfi; xma.hu f93=f34,f125,f92 }
689{ .mfi; xma.lu f92=f34,f125,f92 };;
690{ .mfi; xma.hu f103=f34,f126,f102 }
691{ .mfi; xma.lu f102=f34,f126,f102 };;
692{ .mfi; xma.hu f113=f34,f127,f112 }
693{ .mfi; xma.lu f112=f34,f127,f112 };;//
694//-------------------------------------------------//
695{ .mfi; getf.sig r18=f42
696 xma.hu f44=f35,f120,f43
697 add r17=r17,r16 }
698{ .mfi; xma.lu f43=f35,f120,f43 };;
699{ .mfi; getf.sig r24=f70
700 xma.hu f54=f35,f121,f53 }
701{ .mfi; mov carry2=0
702 xma.lu f53=f35,f121,f53 };;
703{ .mfi; getf.sig r25=f61
704 xma.hu f64=f35,f122,f63
705 cmp.ltu p7,p0=r17,r16 }
706{ .mfi; add r18=r18,r17
707 xma.lu f63=f35,f122,f63 };;
708{ .mfi; getf.sig r26=f52
709 xma.hu f74=f35,f123,f73
710(p7) add carry2=1,carry2 }
711{ .mfi; cmp.ltu p7,p0=r18,r17
712 xma.lu f73=f35,f123,f73
713 add r18=r18,carry1 };;
714{ .mfi;
715 xma.hu f84=f35,f124,f83
716(p7) add carry2=1,carry2 }
717{ .mfi; cmp.ltu p7,p0=r18,carry1
718 xma.lu f83=f35,f124,f83 };;
719{ .mfi; st8 [r32]=r18,16
720 xma.hu f94=f35,f125,f93
721(p7) add carry2=1,carry2 }
722{ .mfi; xma.lu f93=f35,f125,f93 };;
723{ .mfi; xma.hu f104=f35,f126,f103 }
724{ .mfi; xma.lu f103=f35,f126,f103 };;
725{ .mfi; xma.hu f114=f35,f127,f113 }
726{ .mfi; mov carry1=0
727 xma.lu f113=f35,f127,f113
728 add r25=r25,r24 };;//
729//-------------------------------------------------//
730{ .mfi; getf.sig r27=f43
731 xma.hu f45=f36,f120,f44
732 cmp.ltu p6,p0=r25,r24 }
733{ .mfi; xma.lu f44=f36,f120,f44
734 add r26=r26,r25 };;
735{ .mfi; getf.sig r16=f80
736 xma.hu f55=f36,f121,f54
737(p6) add carry1=1,carry1 }
738{ .mfi; xma.lu f54=f36,f121,f54 };;
739{ .mfi; getf.sig r17=f71
740 xma.hu f65=f36,f122,f64
741 cmp.ltu p6,p0=r26,r25 }
742{ .mfi; xma.lu f64=f36,f122,f64
743 add r27=r27,r26 };;
744{ .mfi; getf.sig r18=f62
745 xma.hu f75=f36,f123,f74
746(p6) add carry1=1,carry1 }
747{ .mfi; cmp.ltu p6,p0=r27,r26
748 xma.lu f74=f36,f123,f74
749 add r27=r27,carry2 };;
750{ .mfi; getf.sig r19=f53
751 xma.hu f85=f36,f124,f84
752(p6) add carry1=1,carry1 }
753{ .mfi; xma.lu f84=f36,f124,f84
754 cmp.ltu p6,p0=r27,carry2 };;
755{ .mfi; st8 [r33]=r27,16
756 xma.hu f95=f36,f125,f94
757(p6) add carry1=1,carry1 }
758{ .mfi; xma.lu f94=f36,f125,f94 };;
759{ .mfi; xma.hu f105=f36,f126,f104 }
760{ .mfi; mov carry2=0
761 xma.lu f104=f36,f126,f104
762 add r17=r17,r16 };;
763{ .mfi; xma.hu f115=f36,f127,f114
764 cmp.ltu p7,p0=r17,r16 }
765{ .mfi; xma.lu f114=f36,f127,f114
766 add r18=r18,r17 };;//
767//-------------------------------------------------//
768{ .mfi; getf.sig r20=f44
769 xma.hu f46=f37,f120,f45
770(p7) add carry2=1,carry2 }
771{ .mfi; cmp.ltu p7,p0=r18,r17
772 xma.lu f45=f37,f120,f45
773 add r19=r19,r18 };;
774{ .mfi; getf.sig r24=f90
775 xma.hu f56=f37,f121,f55 }
776{ .mfi; xma.lu f55=f37,f121,f55 };;
777{ .mfi; getf.sig r25=f81
778 xma.hu f66=f37,f122,f65
779(p7) add carry2=1,carry2 }
780{ .mfi; cmp.ltu p7,p0=r19,r18
781 xma.lu f65=f37,f122,f65
782 add r20=r20,r19 };;
783{ .mfi; getf.sig r26=f72
784 xma.hu f76=f37,f123,f75
785(p7) add carry2=1,carry2 }
786{ .mfi; cmp.ltu p7,p0=r20,r19
787 xma.lu f75=f37,f123,f75
788 add r20=r20,carry1 };;
789{ .mfi; getf.sig r27=f63
790 xma.hu f86=f37,f124,f85
791(p7) add carry2=1,carry2 }
792{ .mfi; xma.lu f85=f37,f124,f85
793 cmp.ltu p7,p0=r20,carry1 };;
794{ .mfi; getf.sig r28=f54
795 xma.hu f96=f37,f125,f95
796(p7) add carry2=1,carry2 }
797{ .mfi; st8 [r32]=r20,16
798 xma.lu f95=f37,f125,f95 };;
799{ .mfi; xma.hu f106=f37,f126,f105 }
800{ .mfi; mov carry1=0
801 xma.lu f105=f37,f126,f105
802 add r25=r25,r24 };;
803{ .mfi; xma.hu f116=f37,f127,f115
804 cmp.ltu p6,p0=r25,r24 }
805{ .mfi; xma.lu f115=f37,f127,f115
806 add r26=r26,r25 };;//
807//-------------------------------------------------//
808{ .mfi; getf.sig r29=f45
809 xma.hu f47=f38,f120,f46
810(p6) add carry1=1,carry1 }
811{ .mfi; cmp.ltu p6,p0=r26,r25
812 xma.lu f46=f38,f120,f46
813 add r27=r27,r26 };;
814{ .mfi; getf.sig r16=f100
815 xma.hu f57=f38,f121,f56
816(p6) add carry1=1,carry1 }
817{ .mfi; cmp.ltu p6,p0=r27,r26
818 xma.lu f56=f38,f121,f56
819 add r28=r28,r27 };;
820{ .mfi; getf.sig r17=f91
821 xma.hu f67=f38,f122,f66
822(p6) add carry1=1,carry1 }
823{ .mfi; cmp.ltu p6,p0=r28,r27
824 xma.lu f66=f38,f122,f66
825 add r29=r29,r28 };;
826{ .mfi; getf.sig r18=f82
827 xma.hu f77=f38,f123,f76
828(p6) add carry1=1,carry1 }
829{ .mfi; cmp.ltu p6,p0=r29,r28
830 xma.lu f76=f38,f123,f76
831 add r29=r29,carry2 };;
832{ .mfi; getf.sig r19=f73
833 xma.hu f87=f38,f124,f86
834(p6) add carry1=1,carry1 }
835{ .mfi; xma.lu f86=f38,f124,f86
836 cmp.ltu p6,p0=r29,carry2 };;
837{ .mfi; getf.sig r20=f64
838 xma.hu f97=f38,f125,f96
839(p6) add carry1=1,carry1 }
840{ .mfi; st8 [r33]=r29,16
841 xma.lu f96=f38,f125,f96 };;
842{ .mfi; getf.sig r21=f55
843 xma.hu f107=f38,f126,f106 }
844{ .mfi; mov carry2=0
845 xma.lu f106=f38,f126,f106
846 add r17=r17,r16 };;
847{ .mfi; xma.hu f117=f38,f127,f116
848 cmp.ltu p7,p0=r17,r16 }
849{ .mfi; xma.lu f116=f38,f127,f116
850 add r18=r18,r17 };;//
851//-------------------------------------------------//
852{ .mfi; getf.sig r22=f46
853 xma.hu f48=f39,f120,f47
854(p7) add carry2=1,carry2 }
855{ .mfi; cmp.ltu p7,p0=r18,r17
856 xma.lu f47=f39,f120,f47
857 add r19=r19,r18 };;
858{ .mfi; getf.sig r24=f110
859 xma.hu f58=f39,f121,f57
860(p7) add carry2=1,carry2 }
861{ .mfi; cmp.ltu p7,p0=r19,r18
862 xma.lu f57=f39,f121,f57
863 add r20=r20,r19 };;
864{ .mfi; getf.sig r25=f101
865 xma.hu f68=f39,f122,f67
866(p7) add carry2=1,carry2 }
867{ .mfi; cmp.ltu p7,p0=r20,r19
868 xma.lu f67=f39,f122,f67
869 add r21=r21,r20 };;
870{ .mfi; getf.sig r26=f92
871 xma.hu f78=f39,f123,f77
872(p7) add carry2=1,carry2 }
873{ .mfi; cmp.ltu p7,p0=r21,r20
874 xma.lu f77=f39,f123,f77
875 add r22=r22,r21 };;
876{ .mfi; getf.sig r27=f83
877 xma.hu f88=f39,f124,f87
878(p7) add carry2=1,carry2 }
879{ .mfi; cmp.ltu p7,p0=r22,r21
880 xma.lu f87=f39,f124,f87
881 add r22=r22,carry1 };;
882{ .mfi; getf.sig r28=f74
883 xma.hu f98=f39,f125,f97
884(p7) add carry2=1,carry2 }
885{ .mfi; xma.lu f97=f39,f125,f97
886 cmp.ltu p7,p0=r22,carry1 };;
887{ .mfi; getf.sig r29=f65
888 xma.hu f108=f39,f126,f107
889(p7) add carry2=1,carry2 }
890{ .mfi; st8 [r32]=r22,16
891 xma.lu f107=f39,f126,f107 };;
892{ .mfi; getf.sig r30=f56
893 xma.hu f118=f39,f127,f117 }
894{ .mfi; xma.lu f117=f39,f127,f117 };;//
895//-------------------------------------------------//
896// Leaving muliplier's heaven... Quite a ride, huh?
897
898{ .mii; getf.sig r31=f47
899 add r25=r25,r24
900 mov carry1=0 };;
901{ .mii; getf.sig r16=f111
902 cmp.ltu p6,p0=r25,r24
903 add r26=r26,r25 };;
904{ .mfb; getf.sig r17=f102 }
905{ .mii;
906(p6) add carry1=1,carry1
907 cmp.ltu p6,p0=r26,r25
908 add r27=r27,r26 };;
909{ .mfb; nop.m 0x0 }
910{ .mii;
911(p6) add carry1=1,carry1
912 cmp.ltu p6,p0=r27,r26
913 add r28=r28,r27 };;
914{ .mii; getf.sig r18=f93
915 add r17=r17,r16
916 mov carry3=0 }
917{ .mii;
918(p6) add carry1=1,carry1
919 cmp.ltu p6,p0=r28,r27
920 add r29=r29,r28 };;
921{ .mii; getf.sig r19=f84
922 cmp.ltu p7,p0=r17,r16 }
923{ .mii;
924(p6) add carry1=1,carry1
925 cmp.ltu p6,p0=r29,r28
926 add r30=r30,r29 };;
927{ .mii; getf.sig r20=f75
928 add r18=r18,r17 }
929{ .mii;
930(p6) add carry1=1,carry1
931 cmp.ltu p6,p0=r30,r29
932 add r31=r31,r30 };;
933{ .mfb; getf.sig r21=f66 }
934{ .mii; (p7) add carry3=1,carry3
935 cmp.ltu p7,p0=r18,r17
936 add r19=r19,r18 }
937{ .mfb; nop.m 0x0 }
938{ .mii;
939(p6) add carry1=1,carry1
940 cmp.ltu p6,p0=r31,r30
941 add r31=r31,carry2 };;
942{ .mfb; getf.sig r22=f57 }
943{ .mii; (p7) add carry3=1,carry3
944 cmp.ltu p7,p0=r19,r18
945 add r20=r20,r19 }
946{ .mfb; nop.m 0x0 }
947{ .mii;
948(p6) add carry1=1,carry1
949 cmp.ltu p6,p0=r31,carry2 };;
950{ .mfb; getf.sig r23=f48 }
951{ .mii; (p7) add carry3=1,carry3
952 cmp.ltu p7,p0=r20,r19
953 add r21=r21,r20 }
954{ .mii;
955(p6) add carry1=1,carry1 }
956{ .mfb; st8 [r33]=r31,16 };;
957
958{ .mfb; getf.sig r24=f112 }
959{ .mii; (p7) add carry3=1,carry3
960 cmp.ltu p7,p0=r21,r20
961 add r22=r22,r21 };;
962{ .mfb; getf.sig r25=f103 }
963{ .mii; (p7) add carry3=1,carry3
964 cmp.ltu p7,p0=r22,r21
965 add r23=r23,r22 };;
966{ .mfb; getf.sig r26=f94 }
967{ .mii; (p7) add carry3=1,carry3
968 cmp.ltu p7,p0=r23,r22
969 add r23=r23,carry1 };;
970{ .mfb; getf.sig r27=f85 }
971{ .mii; (p7) add carry3=1,carry3
972 cmp.ltu p7,p8=r23,carry1};;
973{ .mii; getf.sig r28=f76
974 add r25=r25,r24
975 mov carry1=0 }
976{ .mii; st8 [r32]=r23,16
977 (p7) add carry2=1,carry3
978 (p8) add carry2=0,carry3 };;
979
980{ .mfb; nop.m 0x0 }
981{ .mii; getf.sig r29=f67
982 cmp.ltu p6,p0=r25,r24
983 add r26=r26,r25 };;
984{ .mfb; getf.sig r30=f58 }
985{ .mii;
986(p6) add carry1=1,carry1
987 cmp.ltu p6,p0=r26,r25
988 add r27=r27,r26 };;
989{ .mfb; getf.sig r16=f113 }
990{ .mii;
991(p6) add carry1=1,carry1
992 cmp.ltu p6,p0=r27,r26
993 add r28=r28,r27 };;
994{ .mfb; getf.sig r17=f104 }
995{ .mii;
996(p6) add carry1=1,carry1
997 cmp.ltu p6,p0=r28,r27
998 add r29=r29,r28 };;
999{ .mfb; getf.sig r18=f95 }
1000{ .mii;
1001(p6) add carry1=1,carry1
1002 cmp.ltu p6,p0=r29,r28
1003 add r30=r30,r29 };;
1004{ .mii; getf.sig r19=f86
1005 add r17=r17,r16
1006 mov carry3=0 }
1007{ .mii;
1008(p6) add carry1=1,carry1
1009 cmp.ltu p6,p0=r30,r29
1010 add r30=r30,carry2 };;
1011{ .mii; getf.sig r20=f77
1012 cmp.ltu p7,p0=r17,r16
1013 add r18=r18,r17 }
1014{ .mii;
1015(p6) add carry1=1,carry1
1016 cmp.ltu p6,p0=r30,carry2 };;
1017{ .mfb; getf.sig r21=f68 }
1018{ .mii; st8 [r33]=r30,16
1019(p6) add carry1=1,carry1 };;
1020
1021{ .mfb; getf.sig r24=f114 }
1022{ .mii; (p7) add carry3=1,carry3
1023 cmp.ltu p7,p0=r18,r17
1024 add r19=r19,r18 };;
1025{ .mfb; getf.sig r25=f105 }
1026{ .mii; (p7) add carry3=1,carry3
1027 cmp.ltu p7,p0=r19,r18
1028 add r20=r20,r19 };;
1029{ .mfb; getf.sig r26=f96 }
1030{ .mii; (p7) add carry3=1,carry3
1031 cmp.ltu p7,p0=r20,r19
1032 add r21=r21,r20 };;
1033{ .mfb; getf.sig r27=f87 }
1034{ .mii; (p7) add carry3=1,carry3
1035 cmp.ltu p7,p0=r21,r20
1036 add r21=r21,carry1 };;
1037{ .mib; getf.sig r28=f78
1038 add r25=r25,r24 }
1039{ .mib; (p7) add carry3=1,carry3
1040 cmp.ltu p7,p8=r21,carry1};;
1041{ .mii; st8 [r32]=r21,16
1042 (p7) add carry2=1,carry3
1043 (p8) add carry2=0,carry3 }
1044
1045{ .mii; mov carry1=0
1046 cmp.ltu p6,p0=r25,r24
1047 add r26=r26,r25 };;
1048{ .mfb; getf.sig r16=f115 }
1049{ .mii;
1050(p6) add carry1=1,carry1
1051 cmp.ltu p6,p0=r26,r25
1052 add r27=r27,r26 };;
1053{ .mfb; getf.sig r17=f106 }
1054{ .mii;
1055(p6) add carry1=1,carry1
1056 cmp.ltu p6,p0=r27,r26
1057 add r28=r28,r27 };;
1058{ .mfb; getf.sig r18=f97 }
1059{ .mii;
1060(p6) add carry1=1,carry1
1061 cmp.ltu p6,p0=r28,r27
1062 add r28=r28,carry2 };;
1063{ .mib; getf.sig r19=f88
1064 add r17=r17,r16 }
1065{ .mib;
1066(p6) add carry1=1,carry1
1067 cmp.ltu p6,p0=r28,carry2 };;
1068{ .mii; st8 [r33]=r28,16
1069(p6) add carry1=1,carry1 }
1070
1071{ .mii; mov carry2=0
1072 cmp.ltu p7,p0=r17,r16
1073 add r18=r18,r17 };;
1074{ .mfb; getf.sig r24=f116 }
1075{ .mii; (p7) add carry2=1,carry2
1076 cmp.ltu p7,p0=r18,r17
1077 add r19=r19,r18 };;
1078{ .mfb; getf.sig r25=f107 }
1079{ .mii; (p7) add carry2=1,carry2
1080 cmp.ltu p7,p0=r19,r18
1081 add r19=r19,carry1 };;
1082{ .mfb; getf.sig r26=f98 }
1083{ .mii; (p7) add carry2=1,carry2
1084 cmp.ltu p7,p0=r19,carry1};;
1085{ .mii; st8 [r32]=r19,16
1086 (p7) add carry2=1,carry2 }
1087
1088{ .mfb; add r25=r25,r24 };;
1089
1090{ .mfb; getf.sig r16=f117 }
1091{ .mii; mov carry1=0
1092 cmp.ltu p6,p0=r25,r24
1093 add r26=r26,r25 };;
1094{ .mfb; getf.sig r17=f108 }
1095{ .mii;
1096(p6) add carry1=1,carry1
1097 cmp.ltu p6,p0=r26,r25
1098 add r26=r26,carry2 };;
1099{ .mfb; nop.m 0x0 }
1100{ .mii;
1101(p6) add carry1=1,carry1
1102 cmp.ltu p6,p0=r26,carry2 };;
1103{ .mii; st8 [r33]=r26,16
1104(p6) add carry1=1,carry1 }
1105
1106{ .mfb; add r17=r17,r16 };;
1107{ .mfb; getf.sig r24=f118 }
1108{ .mii; mov carry2=0
1109 cmp.ltu p7,p0=r17,r16
1110 add r17=r17,carry1 };;
1111{ .mii; (p7) add carry2=1,carry2
1112 cmp.ltu p7,p0=r17,carry1};;
1113{ .mii; st8 [r32]=r17
1114 (p7) add carry2=1,carry2 };;
1115{ .mfb; add r24=r24,carry2 };;
1116{ .mib; st8 [r33]=r24 }
1117
1118{ .mib; rum 1<<5 // clear um.mfh
1119 br.ret.sptk.many b0 };;
1120.endp bn_mul_comba8#
1121#undef carry3
1122#undef carry2
1123#undef carry1
1124#endif
1125
1126#if 1
1127// It's possible to make it faster (see comment to bn_sqr_comba8), but
1128// I reckon it doesn't worth the effort. Basically because the routine
1129// (actually both of them) practically never called... So I just play
1130// same trick as with bn_sqr_comba8.
1131//
1132// void bn_sqr_comba4(BN_ULONG *r, BN_ULONG *a)
1133//
1134.global bn_sqr_comba4#
1135.proc bn_sqr_comba4#
1136.align 64
1137bn_sqr_comba4:
1138 .prologue
1139 .fframe 0
1140 .save ar.pfs,r2
1141{ .mii; alloc r2=ar.pfs,2,1,0,0
1142 mov r34=r33
1143 add r14=8,r33 };;
1144 .body
1145{ .mii; add r17=8,r34
1146 add r15=16,r33
1147 add r18=16,r34 }
1148{ .mfb; add r16=24,r33
1149 br .L_cheat_entry_point4 };;
1150.endp bn_sqr_comba4#
1151#endif
1152
1153#if 1
1154// Runs in ~115 cycles and ~4.5 times faster than C. Well, whatever...
1155//
1156// void bn_mul_comba4(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b)
1157//
1158#define carry1 r14
1159#define carry2 r15
1160.global bn_mul_comba4#
1161.proc bn_mul_comba4#
1162.align 64
1163bn_mul_comba4:
1164 .prologue
1165 .fframe 0
1166 .save ar.pfs,r2
1167{ .mii; alloc r2=ar.pfs,3,0,0,0
1168 add r14=8,r33
1169 add r17=8,r34 }
1170 .body
1171{ .mii; add r15=16,r33
1172 add r18=16,r34
1173 add r16=24,r33 };;
1174.L_cheat_entry_point4:
1175{ .mmi; add r19=24,r34
1176
1177 ldf8 f32=[r33] }
1178
1179{ .mmi; ldf8 f120=[r34]
1180 ldf8 f121=[r17] };;
1181{ .mmi; ldf8 f122=[r18]
1182 ldf8 f123=[r19] }
1183
1184{ .mmi; ldf8 f33=[r14]
1185 ldf8 f34=[r15] }
1186{ .mfi; ldf8 f35=[r16]
1187
1188 xma.hu f41=f32,f120,f0 }
1189{ .mfi; xma.lu f40=f32,f120,f0 };;
1190{ .mfi; xma.hu f51=f32,f121,f0 }
1191{ .mfi; xma.lu f50=f32,f121,f0 };;
1192{ .mfi; xma.hu f61=f32,f122,f0 }
1193{ .mfi; xma.lu f60=f32,f122,f0 };;
1194{ .mfi; xma.hu f71=f32,f123,f0 }
1195{ .mfi; xma.lu f70=f32,f123,f0 };;//
1196// Major stall takes place here, and 3 more places below. Result from
1197// first xma is not available for another 3 ticks.
1198{ .mfi; getf.sig r16=f40
1199 xma.hu f42=f33,f120,f41
1200 add r33=8,r32 }
1201{ .mfi; xma.lu f41=f33,f120,f41 };;
1202{ .mfi; getf.sig r24=f50
1203 xma.hu f52=f33,f121,f51 }
1204{ .mfi; xma.lu f51=f33,f121,f51 };;
1205{ .mfi; st8 [r32]=r16,16
1206 xma.hu f62=f33,f122,f61 }
1207{ .mfi; xma.lu f61=f33,f122,f61 };;
1208{ .mfi; xma.hu f72=f33,f123,f71 }
1209{ .mfi; xma.lu f71=f33,f123,f71 };;//
1210//-------------------------------------------------//
1211{ .mfi; getf.sig r25=f41
1212 xma.hu f43=f34,f120,f42 }
1213{ .mfi; xma.lu f42=f34,f120,f42 };;
1214{ .mfi; getf.sig r16=f60
1215 xma.hu f53=f34,f121,f52 }
1216{ .mfi; xma.lu f52=f34,f121,f52 };;
1217{ .mfi; getf.sig r17=f51
1218 xma.hu f63=f34,f122,f62
1219 add r25=r25,r24 }
1220{ .mfi; mov carry1=0
1221 xma.lu f62=f34,f122,f62 };;
1222{ .mfi; st8 [r33]=r25,16
1223 xma.hu f73=f34,f123,f72
1224 cmp.ltu p6,p0=r25,r24 }
1225{ .mfi; xma.lu f72=f34,f123,f72 };;//
1226//-------------------------------------------------//
1227{ .mfi; getf.sig r18=f42
1228 xma.hu f44=f35,f120,f43
1229(p6) add carry1=1,carry1 }
1230{ .mfi; add r17=r17,r16
1231 xma.lu f43=f35,f120,f43
1232 mov carry2=0 };;
1233{ .mfi; getf.sig r24=f70
1234 xma.hu f54=f35,f121,f53
1235 cmp.ltu p7,p0=r17,r16 }
1236{ .mfi; xma.lu f53=f35,f121,f53 };;
1237{ .mfi; getf.sig r25=f61
1238 xma.hu f64=f35,f122,f63
1239 add r18=r18,r17 }
1240{ .mfi; xma.lu f63=f35,f122,f63
1241(p7) add carry2=1,carry2 };;
1242{ .mfi; getf.sig r26=f52
1243 xma.hu f74=f35,f123,f73
1244 cmp.ltu p7,p0=r18,r17 }
1245{ .mfi; xma.lu f73=f35,f123,f73
1246 add r18=r18,carry1 };;
1247//-------------------------------------------------//
1248{ .mii; st8 [r32]=r18,16
1249(p7) add carry2=1,carry2
1250 cmp.ltu p7,p0=r18,carry1 };;
1251
1252{ .mfi; getf.sig r27=f43 // last major stall
1253(p7) add carry2=1,carry2 };;
1254{ .mii; getf.sig r16=f71
1255 add r25=r25,r24
1256 mov carry1=0 };;
1257{ .mii; getf.sig r17=f62
1258 cmp.ltu p6,p0=r25,r24
1259 add r26=r26,r25 };;
1260{ .mii;
1261(p6) add carry1=1,carry1
1262 cmp.ltu p6,p0=r26,r25
1263 add r27=r27,r26 };;
1264{ .mii;
1265(p6) add carry1=1,carry1
1266 cmp.ltu p6,p0=r27,r26
1267 add r27=r27,carry2 };;
1268{ .mii; getf.sig r18=f53
1269(p6) add carry1=1,carry1
1270 cmp.ltu p6,p0=r27,carry2 };;
1271{ .mfi; st8 [r33]=r27,16
1272(p6) add carry1=1,carry1 }
1273
1274{ .mii; getf.sig r19=f44
1275 add r17=r17,r16
1276 mov carry2=0 };;
1277{ .mii; getf.sig r24=f72
1278 cmp.ltu p7,p0=r17,r16
1279 add r18=r18,r17 };;
1280{ .mii; (p7) add carry2=1,carry2
1281 cmp.ltu p7,p0=r18,r17
1282 add r19=r19,r18 };;
1283{ .mii; (p7) add carry2=1,carry2
1284 cmp.ltu p7,p0=r19,r18
1285 add r19=r19,carry1 };;
1286{ .mii; getf.sig r25=f63
1287 (p7) add carry2=1,carry2
1288 cmp.ltu p7,p0=r19,carry1};;
1289{ .mii; st8 [r32]=r19,16
1290 (p7) add carry2=1,carry2 }
1291
1292{ .mii; getf.sig r26=f54
1293 add r25=r25,r24
1294 mov carry1=0 };;
1295{ .mii; getf.sig r16=f73
1296 cmp.ltu p6,p0=r25,r24
1297 add r26=r26,r25 };;
1298{ .mii;
1299(p6) add carry1=1,carry1
1300 cmp.ltu p6,p0=r26,r25
1301 add r26=r26,carry2 };;
1302{ .mii; getf.sig r17=f64
1303(p6) add carry1=1,carry1
1304 cmp.ltu p6,p0=r26,carry2 };;
1305{ .mii; st8 [r33]=r26,16
1306(p6) add carry1=1,carry1 }
1307
1308{ .mii; getf.sig r24=f74
1309 add r17=r17,r16
1310 mov carry2=0 };;
1311{ .mii; cmp.ltu p7,p0=r17,r16
1312 add r17=r17,carry1 };;
1313
1314{ .mii; (p7) add carry2=1,carry2
1315 cmp.ltu p7,p0=r17,carry1};;
1316{ .mii; st8 [r32]=r17,16
1317 (p7) add carry2=1,carry2 };;
1318
1319{ .mii; add r24=r24,carry2 };;
1320{ .mii; st8 [r33]=r24 }
1321
1322{ .mib; rum 1<<5 // clear um.mfh
1323 br.ret.sptk.many b0 };;
1324.endp bn_mul_comba4#
1325#undef carry2
1326#undef carry1
1327#endif
1328
1329#if 1
1330//
1331// BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d)
1332//
1333// In the nutshell it's a port of my MIPS III/IV implementation.
1334//
1335#define AT r14
1336#define H r16
1337#define HH r20
1338#define L r17
1339#define D r18
1340#define DH r22
1341#define I r21
1342
1343#if 0
1344// Some preprocessors (most notably HP-UX) apper to be allergic to
1345// macros enclosed to parenthesis as these three will be.
1346#define cont p16
1347#define break p0 // p20
1348#define equ p24
1349#else
1350cont=p16
1351break=p0
1352equ=p24
1353#endif
1354
1355.global abort#
1356.global bn_div_words#
1357.proc bn_div_words#
1358.align 64
1359bn_div_words:
1360 .prologue
1361 .fframe 0
1362 .save ar.pfs,r2
1363 .save b0,r3
1364{ .mii; alloc r2=ar.pfs,3,5,0,8
1365 mov r3=b0
1366 mov r10=pr };;
1367{ .mmb; cmp.eq p6,p0=r34,r0
1368 mov r8=-1
1369(p6) br.ret.spnt.many b0 };;
1370
1371 .body
1372{ .mii; mov H=r32 // save h
1373 mov ar.ec=0 // don't rotate at exit
1374 mov pr.rot=0 }
1375{ .mii; mov L=r33 // save l
1376 mov r36=r0 };;
1377
1378.L_divw_shift: // -vv- note signed comparison
1379{ .mfi; (p0) cmp.lt p16,p0=r0,r34 // d
1380 (p0) shladd r33=r34,1,r0 }
1381{ .mfb; (p0) add r35=1,r36
1382 (p0) nop.f 0x0
1383(p16) br.wtop.dpnt .L_divw_shift };;
1384
1385{ .mii; mov D=r34
1386 shr.u DH=r34,32
1387 sub r35=64,r36 };;
1388{ .mii; setf.sig f7=DH
1389 shr.u AT=H,r35
1390 mov I=r36 };;
1391{ .mib; cmp.ne p6,p0=r0,AT
1392 shl H=H,r36
1393(p6) br.call.spnt.clr b0=abort };; // overflow, die...
1394
1395{ .mfi; fcvt.xuf.s1 f7=f7
1396 shr.u AT=L,r35 };;
1397{ .mii; shl L=L,r36
1398 or H=H,AT };;
1399
1400{ .mii; nop.m 0x0
1401 cmp.leu p6,p0=D,H;;
1402(p6) sub H=H,D }
1403
1404{ .mlx; setf.sig f14=D
1405 movl AT=0xffffffff };;
1406///////////////////////////////////////////////////////////
1407{ .mii; setf.sig f6=H
1408 shr.u HH=H,32;;
1409 cmp.eq p6,p7=HH,DH };;
1410{ .mfb;
1411(p6) setf.sig f8=AT
1412(p7) fcvt.xuf.s1 f6=f6
1413(p7) br.call.sptk b6=.L_udiv64_32_b6 };;
1414
1415{ .mfi; getf.sig r33=f8 // q
1416 xmpy.lu f9=f8,f14 }
1417{ .mfi; xmpy.hu f10=f8,f14
1418 shrp H=H,L,32 };;
1419
1420{ .mmi; getf.sig r35=f9 // tl
1421 getf.sig r31=f10 };; // th
1422
1423.L_divw_1st_iter:
1424{ .mii; (p0) add r32=-1,r33
1425 (p0) cmp.eq equ,cont=HH,r31 };;
1426{ .mii; (p0) cmp.ltu p8,p0=r35,D
1427 (p0) sub r34=r35,D
1428 (equ) cmp.leu break,cont=r35,H };;
1429{ .mib; (cont) cmp.leu cont,break=HH,r31
1430 (p8) add r31=-1,r31
1431(cont) br.wtop.spnt .L_divw_1st_iter };;
1432///////////////////////////////////////////////////////////
1433{ .mii; sub H=H,r35
1434 shl r8=r33,32
1435 shl L=L,32 };;
1436///////////////////////////////////////////////////////////
1437{ .mii; setf.sig f6=H
1438 shr.u HH=H,32;;
1439 cmp.eq p6,p7=HH,DH };;
1440{ .mfb;
1441(p6) setf.sig f8=AT
1442(p7) fcvt.xuf.s1 f6=f6
1443(p7) br.call.sptk b6=.L_udiv64_32_b6 };;
1444
1445{ .mfi; getf.sig r33=f8 // q
1446 xmpy.lu f9=f8,f14 }
1447{ .mfi; xmpy.hu f10=f8,f14
1448 shrp H=H,L,32 };;
1449
1450{ .mmi; getf.sig r35=f9 // tl
1451 getf.sig r31=f10 };; // th
1452
1453.L_divw_2nd_iter:
1454{ .mii; (p0) add r32=-1,r33
1455 (p0) cmp.eq equ,cont=HH,r31 };;
1456{ .mii; (p0) cmp.ltu p8,p0=r35,D
1457 (p0) sub r34=r35,D
1458 (equ) cmp.leu break,cont=r35,H };;
1459{ .mib; (cont) cmp.leu cont,break=HH,r31
1460 (p8) add r31=-1,r31
1461(cont) br.wtop.spnt .L_divw_2nd_iter };;
1462///////////////////////////////////////////////////////////
1463{ .mii; sub H=H,r35
1464 or r8=r8,r33
1465 mov ar.pfs=r2 };;
1466{ .mii; shr.u r9=H,I // remainder if anybody wants it
1467 mov pr=r10,-1 }
1468{ .mfb; br.ret.sptk.many b0 };;
1469
1470// Unsigned 64 by 32 (well, by 64 for the moment) bit integer division
1471// procedure.
1472//
1473// inputs: f6 = (double)a, f7 = (double)b
1474// output: f8 = (int)(a/b)
1475// clobbered: f8,f9,f10,f11,pred
1476pred=p15
1477// This procedure is essentially Intel code and therefore is
1478// copyrighted to Intel Corporation (I suppose...). It's sligtly
1479// modified for specific needs.
1480.align 32
1481.skip 16
1482.L_udiv64_32_b6:
1483 frcpa.s1 f8,pred=f6,f7;; // [0] y0 = 1 / b
1484
1485(pred) fnma.s1 f9=f7,f8,f1 // [5] e0 = 1 - b * y0
1486(pred) fmpy.s1 f10=f6,f8;; // [5] q0 = a * y0
1487(pred) fmpy.s1 f11=f9,f9 // [10] e1 = e0 * e0
1488(pred) fma.s1 f10=f9,f10,f10;; // [10] q1 = q0 + e0 * q0
1489(pred) fma.s1 f8=f9,f8,f8 //;; // [15] y1 = y0 + e0 * y0
1490(pred) fma.s1 f9=f11,f10,f10;; // [15] q2 = q1 + e1 * q1
1491(pred) fma.s1 f8=f11,f8,f8 //;; // [20] y2 = y1 + e1 * y1
1492(pred) fnma.s1 f10=f7,f9,f6;; // [20] r2 = a - b * q2
1493(pred) fma.s1 f8=f10,f8,f9;; // [25] q3 = q2 + r2 * y2
1494
1495 fcvt.fxu.trunc.s1 f8=f8 // [30] q = trunc(q3)
1496 br.ret.sptk.many b6;;
1497.endp bn_div_words#
1498#endif
diff --git a/src/lib/libcrypto/bn/asm/vms.mar b/src/lib/libcrypto/bn/asm/vms.mar
index ac9d57d7b0..465f2774b6 100644
--- a/src/lib/libcrypto/bn/asm/vms.mar
+++ b/src/lib/libcrypto/bn/asm/vms.mar
@@ -162,442 +162,237 @@ n=12 ;(AP) n by value (input)
162 movl #1,r0 ; return SS$_NORMAL 162 movl #1,r0 ; return SS$_NORMAL
163 ret 163 ret
164 164
165 .title (generated) 165 .title vax_bn_div_words unsigned divide
166 166;
167 .psect code,nowrt 167; Richard Levitte 20-Nov-2000
168 168;
169.entry BN_DIV_WORDS,^m<r2,r3,r4,r5,r6,r7,r8,r9,r10> 169; ULONG bn_div_words(ULONG h, ULONG l, ULONG d)
170 subl2 #4,sp 170; {
171 171; return ((ULONG)((((ULLONG)h)<<32)|l) / (ULLONG)d);
172 clrl r9 172; }
173 movl #2,r8 173;
174 174; Using EDIV would be very easy, if it didn't do signed calculations.
175 tstl 12(ap) 175; Therefore, som extra things have to happen around it. The way to
176 bneq noname.2 176; handle that is to shift all operands right one step (basically dividing
177 mnegl #1,r10 177; them by 2) and handle the different cases depending on what the lowest
178 brw noname.3 178; bit of each operand was.
179 tstl r0 179;
180 nop 180; To start with, let's define the following:
181noname.2: 181;
182 182; a' = l & 1
183 pushl 12(ap) 183; a2 = <h,l> >> 1 # UNSIGNED shift!
184 calls #1,BN_NUM_BITS_WORD 184; b' = d & 1
185 movl r0,r7 185; b2 = d >> 1 # UNSIGNED shift!
186 186;
187 cmpl r7,#32 187; Now, use EDIV to calculate a quotient and a remainder:
188 beql noname.4 188;
189 ashl r7,#1,r2 189; q'' = a2/b2
190 cmpl 4(ap),r2 190; r'' = a2 - q''*b2
191 blequ noname.4 191;
192 192; If b' is 0, the quotient is already correct, we just need to adjust the
193 pushl r7 193; remainder:
194 calls #1,BN_DIV_WORDS_ABORT 194;
195noname.4: 195; if (b' == 0)
196 196; {
197 subl3 r7,#32,r7 197; r = 2*r'' + a'
198 198; q = q''
199 movl 12(ap),r2 199; }
200 cmpl 4(ap),r2 200;
201 blssu noname.5 201; If b' is 1, we need to do other adjustements. The first thought is the
202 subl2 r2,4(ap) 202; following (note that r' will not always have the right value, but an
203noname.5: 203; adjustement follows further down):
204 204;
205 tstl r7 205; if (b' == 1)
206 beql noname.6 206; {
207 207; q' = q''
208 ashl r7,r2,12(ap) 208; r' = a - q'*b
209 209;
210 ashl r7,4(ap),r4 210; However, one can note the folowing relationship:
211 subl3 r7,#32,r3 211;
212 subl3 r3,#32,r2 212; r'' = a2 - q''*b2
213 extzv r3,r2,8(ap),r2 213; => 2*r'' = 2*a2 - 2*q''*b2
214 bisl3 r4,r2,4(ap) 214; = { a = 2*a2 + a', b = 2*b2 + b' = 2*b2 + 1,
215 215; q' = q'' }
216 ashl r7,8(ap),8(ap) 216; = a - a' - q'*(b - 1)
217noname.6: 217; = a - q'*b - a' + q'
218 218; = r' - a' + q'
219 bicl3 #65535,12(ap),r2 219; => r' = 2*r'' - q' + a'
220 extzv #16,#16,r2,r5 220;
221 221; This enables us to use r'' instead of discarding and calculating another
222 bicl3 #-65536,12(ap),r6 222; modulo:
223 223;
224noname.7: 224; if (b' == 1)
225 225; {
226 moval 4(ap),r2 226; q' = q''
227 movzwl 2(r2),r0 227; r' = (r'' << 1) - q' + a'
228 cmpl r0,r5 228;
229 bneq noname.8 229; Now, all we have to do is adjust r', because it might be < 0:
230 230;
231 movzwl #65535,r4 231; while (r' < 0)
232 brb noname.9 232; {
233noname.8: 233; r' = r' + b
234 234; q' = q' - 1
235 clrl r1 235; }
236 movl (r2),r0 236; }
237 movl r5,r2 237;
238 bgeq vcg.1 238; return q'
239 cmpl r2,r0
240 bgtru vcg.2
241 incl r1
242 brb vcg.2
243 nop
244vcg.1:
245 ediv r2,r0,r1,r0
246vcg.2:
247 movl r1,r4
248noname.9:
249
250noname.10:
251
252 mull3 r5,r4,r0
253 subl3 r0,4(ap),r3
254
255 bicl3 #65535,r3,r0
256 bneq noname.13
257 mull3 r6,r4,r2
258 ashl #16,r3,r1
259 bicl3 #65535,8(ap),r0
260 extzv #16,#16,r0,r0
261 addl2 r0,r1
262 cmpl r2,r1
263 bgtru noname.12
264noname.11:
265
266 brb noname.13
267 nop
268noname.12:
269
270 decl r4
271 brb noname.10
272noname.13:
273
274 mull3 r5,r4,r1
275
276 mull3 r6,r4,r0
277
278 extzv #16,#16,r0,r3
279
280 ashl #16,r0,r2
281 bicl3 #65535,r2,r0
282
283 addl2 r3,r1
284
285 moval 8(ap),r3
286 cmpl (r3),r0
287 bgequ noname.15
288 incl r1
289noname.15:
290
291 subl2 r0,(r3)
292
293 cmpl 4(ap),r1
294 bgequ noname.16
295
296 addl2 12(ap),4(ap)
297
298 decl r4
299noname.16:
300
301 subl2 r1,4(ap)
302
303 decl r8
304 beql noname.18
305noname.17:
306
307 ashl #16,r4,r9
308 239
309 ashl #16,4(ap),r2 240h=4 ;(AP) h by value (input)
310 movzwl 2(r3),r0 241l=8 ;(AP) l by value (input)
311 bisl2 r0,r2 242d=12 ;(AP) d by value (input)
312 bicl3 #0,r2,4(ap)
313 243
314 bicl3 #-65536,(r3),r0 244;aprim=r5
315 ashl #16,r0,(r3) 245;a2=r6
316 brw noname.7 246;a20=r6
317 nop 247;a21=r7
318noname.18: 248;bprim=r8
249;b2=r9
250;qprim=r10 ; initially used as q''
251;rprim=r11 ; initially used as r''
319 252
320 bisl2 r4,r9
321 253
322 movl r9,r10 254 .psect code,nowrt
323 255
324noname.3: 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$:
325 movl r10,r0 313 movl r10,r0
326 ret 314666$:
327 tstl r0 315 ret
328
329 316
330 .psect code,nowrt 317 .title vax_bn_add_words unsigned add of two arrays
331 318;
332.entry BN_ADD_WORDS,^m<r2,r3,r4,r5,r6,r7> 319; Richard Levitte 20-Nov-2000
333 320;
334 tstl 16(ap) 321; ULONG bn_add_words(ULONG r[], ULONG a[], ULONG b[], int n) {
335 bgtr noname.21 322; ULONG c = 0;
336 clrl r7 323; int i;
337 brw noname.22 324; for (i = 0; i < n; i++) <c,r[i]> = a[i] + b[i] + c;
338noname.21: 325; return(c);
339 326; }
340 clrl r4
341
342 tstl r0
343noname.23:
344
345 movl 8(ap),r6
346 addl3 r4,(r6),r2
347
348 bicl2 #0,r2
349
350 clrl r0
351 cmpl r2,r4
352 bgequ vcg.3
353 incl r0
354vcg.3:
355 movl r0,r4
356
357 movl 12(ap),r5
358 addl3 (r5),r2,r1
359 bicl2 #0,r1
360
361 clrl r0
362 cmpl r1,r2
363 bgequ vcg.4
364 incl r0
365vcg.4:
366 addl2 r0,r4
367
368 movl 4(ap),r3
369 movl r1,(r3)
370
371 decl 16(ap)
372 bgtr gen.1
373 brw noname.25
374gen.1:
375noname.24:
376
377 addl3 r4,4(r6),r2
378
379 bicl2 #0,r2
380
381 clrl r0
382 cmpl r2,r4
383 bgequ vcg.5
384 incl r0
385vcg.5:
386 movl r0,r4
387
388 addl3 4(r5),r2,r1
389 bicl2 #0,r1
390
391 clrl r0
392 cmpl r1,r2
393 bgequ vcg.6
394 incl r0
395vcg.6:
396 addl2 r0,r4
397
398 movl r1,4(r3)
399
400 decl 16(ap)
401 bleq noname.25
402noname.26:
403
404 addl3 r4,8(r6),r2
405
406 bicl2 #0,r2
407
408 clrl r0
409 cmpl r2,r4
410 bgequ vcg.7
411 incl r0
412vcg.7:
413 movl r0,r4
414
415 addl3 8(r5),r2,r1
416 bicl2 #0,r1
417
418 clrl r0
419 cmpl r1,r2
420 bgequ vcg.8
421 incl r0
422vcg.8:
423 addl2 r0,r4
424
425 movl r1,8(r3)
426
427 decl 16(ap)
428 bleq noname.25
429noname.27:
430
431 addl3 r4,12(r6),r2
432
433 bicl2 #0,r2
434
435 clrl r0
436 cmpl r2,r4
437 bgequ vcg.9
438 incl r0
439vcg.9:
440 movl r0,r4
441
442 addl3 12(r5),r2,r1
443 bicl2 #0,r1
444
445 clrl r0
446 cmpl r1,r2
447 bgequ vcg.10
448 incl r0
449vcg.10:
450 addl2 r0,r4
451 327
452 movl r1,12(r3) 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)
453 332
454 decl 16(ap)
455 bleq noname.25
456noname.28:
457 333
458 addl3 #16,r6,8(ap) 334 .psect code,nowrt
459 335
460 addl3 #16,r5,12(ap) 336.entry bn_add_words,^m<r2,r3,r4,r5,r6>
461 337
462 addl3 #16,r3,4(ap) 338 moval @r(ap),r2
463 brw noname.23 339 moval @a(ap),r3
464 tstl r0 340 moval @b(ap),r4
465noname.25: 341 movl n(ap),r5 ; assumed >0 by C code
342 clrl r0 ; c
466 343
467 movl r4,r7 344 tstl r5 ; carry = 0
345 bleq 666$
468 346
469noname.22: 3470$:
470 movl r7,r0 348 movl (r3)+,r6 ; carry untouched
471 ret 349 adwc (r4)+,r6 ; carry used and touched
472 nop 350 movl r6,(r2)+ ; carry untouched
351 sobgtr r5,0$ ; carry untouched
473 352
353 adwc #0,r0
354666$:
355 ret
474 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; }
475 367
476;r=4 ;(AP) 368r=4 ;(AP) r by reference (output)
477;a=8 ;(AP) 369a=8 ;(AP) a by reference (input)
478;b=12 ;(AP) 370b=12 ;(AP) b by reference (input)
479;n=16 ;(AP) n by value (input) 371n=16 ;(AP) n by value (input)
480 372
481 .psect code,nowrt
482 373
483.entry BN_SUB_WORDS,^m<r2,r3,r4,r5,r6,r7> 374 .psect code,nowrt
484 375
485 clrl r6 376.entry bn_sub_words,^m<r2,r3,r4,r5,r6>
486 377
487 tstl 16(ap) 378 moval @r(ap),r2
488 bgtr noname.31 379 moval @a(ap),r3
489 clrl r7 380 moval @b(ap),r4
490 brw noname.32 381 movl n(ap),r5 ; assumed >0 by C code
491 tstl r0 382 clrl r0 ; c
492noname.31:
493 383
494noname.33: 384 tstl r5 ; carry = 0
385 bleq 666$
495 386
496 movl 8(ap),r5 3870$:
497 movl (r5),r1 388 movl (r3)+,r6 ; carry untouched
498 movl 12(ap),r4 389 sbwc (r4)+,r6 ; carry used and touched
499 movl (r4),r2 390 movl r6,(r2)+ ; carry untouched
500 391 sobgtr r5,0$ ; carry untouched
501 movl 4(ap),r3
502 subl3 r2,r1,r0
503 subl2 r6,r0
504 bicl3 #0,r0,(r3)
505
506 cmpl r1,r2
507 beql noname.34
508 clrl r0
509 cmpl r1,r2
510 bgequ vcg.11
511 incl r0
512vcg.11:
513 movl r0,r6
514noname.34:
515
516 decl 16(ap)
517 bgtr gen.2
518 brw noname.36
519gen.2:
520noname.35:
521
522 movl 4(r5),r2
523 movl 4(r4),r1
524
525 subl3 r1,r2,r0
526 subl2 r6,r0
527 bicl3 #0,r0,4(r3)
528
529 cmpl r2,r1
530 beql noname.37
531 clrl r0
532 cmpl r2,r1
533 bgequ vcg.12
534 incl r0
535vcg.12:
536 movl r0,r6
537noname.37:
538
539 decl 16(ap)
540 bleq noname.36
541noname.38:
542
543 movl 8(r5),r1
544 movl 8(r4),r2
545
546 subl3 r2,r1,r0
547 subl2 r6,r0
548 bicl3 #0,r0,8(r3)
549
550 cmpl r1,r2
551 beql noname.39
552 clrl r0
553 cmpl r1,r2
554 bgequ vcg.13
555 incl r0
556vcg.13:
557 movl r0,r6
558noname.39:
559
560 decl 16(ap)
561 bleq noname.36
562noname.40:
563
564 movl 12(r5),r1
565 movl 12(r4),r2
566
567 subl3 r2,r1,r0
568 subl2 r6,r0
569 bicl3 #0,r0,12(r3)
570
571 cmpl r1,r2
572 beql noname.41
573 clrl r0
574 cmpl r1,r2
575 bgequ vcg.14
576 incl r0
577vcg.14:
578 movl r0,r6
579noname.41:
580
581 decl 16(ap)
582 bleq noname.36
583noname.42:
584
585 addl3 #16,r5,8(ap)
586
587 addl3 #16,r4,12(ap)
588
589 addl3 #16,r3,4(ap)
590 brw noname.33
591 tstl r0
592noname.36:
593
594 movl r6,r7
595
596noname.32:
597 movl r7,r0
598 ret
599 nop
600 392
393 adwc #0,r0
394666$:
395 ret
601 396
602 397
603;r=4 ;(AP) 398;r=4 ;(AP)
@@ -6615,81 +6410,3 @@ noname.610:
6615 6410
6616; For now, the code below doesn't work, so I end this prematurely. 6411; For now, the code below doesn't work, so I end this prematurely.
6617.end 6412.end
6618
6619 .title vax_bn_div64 division 64/32=>32
6620;
6621; r.l. 16-jan-1998
6622;
6623; unsigned int bn_div64(unsigned long h, unsigned long l, unsigned long d)
6624; return <h,l>/d;
6625;
6626
6627 .psect code,nowrt
6628
6629h=4 ;(AP) by value (input)
6630l=8 ;(AP) by value (input)
6631d=12 ;(AP) by value (input)
6632
6633.entry bn_div64,^m<r2,r3,r4,r5,r6,r7,r8,r9>
6634
6635 movl l(ap),r2 ; l
6636 movl h(ap),r3 ; h
6637 movl d(ap),r4 ; d
6638 clrl r5 ; q
6639 clrl r6 ; r
6640
6641 ; Treat "negative" specially
6642 tstl r3
6643 blss 30$
6644
6645 tstl r4
6646 beql 90$
6647
6648 ediv r4,r2,r5,r6
6649 bvs 666$
6650
6651 movl r5,r0
6652 ret
6653
665430$:
6655 ; The theory here is to do some harmless shifting and a little
6656 ; bit of rounding (brackets are to designate when decimals are
6657 ; cut off):
6658 ;
6659 ; result = 2 * [ ([<h,0>/2] + [d/2]) / d ] + [ l / d ]
6660
6661 movl #0,r7
6662 movl r3,r8 ; copy h
6663 ashq #-1,r7,r7 ; [<h,0>/2] => <r8,r7>
6664 bicl2 #^X80000000,r8 ; Remove "sign"
6665
6666 movl r4,r9 ; copy d
6667 ashl #-1,r9,r9 ; [d/2] => r9
6668 bicl2 #^X80000000,r9 ; Remove "sign"
6669
6670 addl2 r9,r7
6671 adwc #0,r8 ; [<h,0>/2] + [d/2] => <r8,r7>
6672
6673 ediv r4,r7,r5,r6 ; [ ([<h,0>/2] + [d/2]) / d ] => <r5,r6>
6674 bvs 666$
6675
6676 movl #0,r6
6677 ashq #1,r5,r5 ; 2 * [ ([<h,0>/2] + [d/2]) / d ] => r5
6678
6679 movl #0,r3
6680 ediv r4,r2,r8,r9 ; [ l / d ] => <r8,r9>
6681
6682 addl2 r8,r5 ;
6683 bcs 666$
6684
6685 movl r5,r0
6686 ret
6687
668890$:
6689 movl #-1,r0
6690 ret
6691
6692666$:
6693
6694
6695.end
diff --git a/src/lib/libcrypto/bn/bn.h b/src/lib/libcrypto/bn/bn.h
index b232c2ceae..d25b49c9d8 100644
--- a/src/lib/libcrypto/bn/bn.h
+++ b/src/lib/libcrypto/bn/bn.h
@@ -59,24 +59,22 @@
59#ifndef HEADER_BN_H 59#ifndef HEADER_BN_H
60#define HEADER_BN_H 60#define HEADER_BN_H
61 61
62#ifndef NO_FP_API 62#include <openssl/e_os2.h>
63#ifndef OPENSSL_NO_FP_API
63#include <stdio.h> /* FILE */ 64#include <stdio.h> /* FILE */
64#endif 65#endif
65#include <openssl/opensslconf.h>
66 66
67#ifdef __cplusplus 67#ifdef __cplusplus
68extern "C" { 68extern "C" {
69#endif 69#endif
70 70
71#ifdef VMS 71#ifdef OPENSSL_SYS_VMS
72#undef BN_LLONG /* experimental, so far... */ 72#undef BN_LLONG /* experimental, so far... */
73#endif 73#endif
74 74
75#define BN_MUL_COMBA 75#define BN_MUL_COMBA
76#define BN_SQR_COMBA 76#define BN_SQR_COMBA
77#define BN_RECURSION 77#define BN_RECURSION
78#define RECP_MUL_MOD
79#define MONT_MUL_MOD
80 78
81/* This next option uses the C libraries (2 word)/(1 word) function. 79/* This next option uses the C libraries (2 word)/(1 word) function.
82 * If it is not defined, I use my C version (which is slower). 80 * If it is not defined, I use my C version (which is slower).
@@ -89,8 +87,11 @@ extern "C" {
89 * For machines with only one compiler (or shared libraries), this should 87 * For machines with only one compiler (or shared libraries), this should
90 * be on. Again this in only really a problem on machines 88 * be on. Again this in only really a problem on machines
91 * using "long long's", are 32bit, and are not using my assembler code. */ 89 * using "long long's", are 32bit, and are not using my assembler code. */
92#if defined(MSDOS) || defined(WINDOWS) || defined(WIN32) || defined(linux) 90#if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || \
93#define BN_DIV2W 91 defined(OPENSSL_SYS_WIN32) || defined(linux)
92# ifndef BN_DIV2W
93# define BN_DIV2W
94# endif
94#endif 95#endif
95 96
96/* assuming long is 64bit - this is the DEC Alpha 97/* assuming long is 64bit - this is the DEC Alpha
@@ -142,7 +143,7 @@ extern "C" {
142#endif 143#endif
143 144
144#ifdef THIRTY_TWO_BIT 145#ifdef THIRTY_TWO_BIT
145#if defined(WIN32) && !defined(__GNUC__) 146#if defined(OPENSSL_SYS_WIN32) && !defined(__GNUC__)
146#define BN_ULLONG unsigned _int64 147#define BN_ULLONG unsigned _int64
147#else 148#else
148#define BN_ULLONG unsigned long long 149#define BN_ULLONG unsigned long long
@@ -153,7 +154,7 @@ extern "C" {
153#define BN_BYTES 4 154#define BN_BYTES 4
154#define BN_BITS2 32 155#define BN_BITS2 32
155#define BN_BITS4 16 156#define BN_BITS4 16
156#ifdef WIN32 157#ifdef OPENSSL_SYS_WIN32
157/* VC++ doesn't like the LL suffix */ 158/* VC++ doesn't like the LL suffix */
158#define BN_MASK (0xffffffffffffffffL) 159#define BN_MASK (0xffffffffffffffffL)
159#else 160#else
@@ -238,18 +239,8 @@ typedef struct bignum_st
238 int flags; 239 int flags;
239 } BIGNUM; 240 } BIGNUM;
240 241
241/* Used for temp variables */ 242/* Used for temp variables (declaration hidden in bn_lcl.h) */
242#define BN_CTX_NUM 16 243typedef struct bignum_ctx BN_CTX;
243#define BN_CTX_NUM_POS 12
244typedef struct bignum_ctx
245 {
246 int tos;
247 BIGNUM bn[BN_CTX_NUM];
248 int flags;
249 int depth;
250 int pos[BN_CTX_NUM_POS];
251 int too_many;
252 } BN_CTX;
253 244
254typedef struct bn_blinding_st 245typedef struct bn_blinding_st
255 { 246 {
@@ -283,9 +274,6 @@ typedef struct bn_recp_ctx_st
283 int flags; 274 int flags;
284 } BN_RECP_CTX; 275 } BN_RECP_CTX;
285 276
286#define BN_to_montgomery(r,a,mont,ctx) BN_mod_mul_montgomery(\
287 r,a,&((mont)->RR),(mont),ctx)
288
289#define BN_prime_checks 0 /* default: select number of iterations 277#define BN_prime_checks 0 /* default: select number of iterations
290 based on the size of the number */ 278 based on the size of the number */
291 279
@@ -308,17 +296,22 @@ typedef struct bn_recp_ctx_st
308 /* b >= 100 */ 27) 296 /* b >= 100 */ 27)
309 297
310#define BN_num_bytes(a) ((BN_num_bits(a)+7)/8) 298#define BN_num_bytes(a) ((BN_num_bits(a)+7)/8)
311#define BN_is_word(a,w) (((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w))) 299
312#define BN_is_zero(a) (((a)->top == 0) || BN_is_word(a,0)) 300/* Note that BN_abs_is_word does not work reliably for w == 0 */
313#define BN_is_one(a) (BN_is_word((a),1)) 301#define BN_abs_is_word(a,w) (((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w)))
314#define BN_is_odd(a) (((a)->top > 0) && ((a)->d[0] & 1)) 302#define BN_is_zero(a) (((a)->top == 0) || BN_abs_is_word(a,0))
303#define BN_is_one(a) (BN_abs_is_word((a),1) && !(a)->neg)
304#define BN_is_word(a,w) ((w) ? BN_abs_is_word((a),(w)) && !(a)->neg : \
305 BN_is_zero((a)))
306#define BN_is_odd(a) (((a)->top > 0) && ((a)->d[0] & 1))
307
315#define BN_one(a) (BN_set_word((a),1)) 308#define BN_one(a) (BN_set_word((a),1))
316#define BN_zero(a) (BN_set_word((a),0)) 309#define BN_zero(a) (BN_set_word((a),0))
317 310
318/*#define BN_ascii2bn(a) BN_hex2bn(a) */ 311/*#define BN_ascii2bn(a) BN_hex2bn(a) */
319/*#define BN_bn2ascii(a) BN_bn2hex(a) */ 312/*#define BN_bn2ascii(a) BN_bn2hex(a) */
320 313
321BIGNUM *BN_value_one(void); 314const BIGNUM *BN_value_one(void);
322char * BN_options(void); 315char * BN_options(void);
323BN_CTX *BN_CTX_new(void); 316BN_CTX *BN_CTX_new(void);
324void BN_CTX_init(BN_CTX *c); 317void BN_CTX_init(BN_CTX *c);
@@ -329,51 +322,70 @@ void BN_CTX_end(BN_CTX *ctx);
329int BN_rand(BIGNUM *rnd, int bits, int top,int bottom); 322int BN_rand(BIGNUM *rnd, int bits, int top,int bottom);
330int BN_pseudo_rand(BIGNUM *rnd, int bits, int top,int bottom); 323int BN_pseudo_rand(BIGNUM *rnd, int bits, int top,int bottom);
331int BN_rand_range(BIGNUM *rnd, BIGNUM *range); 324int BN_rand_range(BIGNUM *rnd, BIGNUM *range);
325int BN_pseudo_rand_range(BIGNUM *rnd, BIGNUM *range);
332int BN_num_bits(const BIGNUM *a); 326int BN_num_bits(const BIGNUM *a);
333int BN_num_bits_word(BN_ULONG); 327int BN_num_bits_word(BN_ULONG);
334BIGNUM *BN_new(void); 328BIGNUM *BN_new(void);
335void BN_init(BIGNUM *); 329void BN_init(BIGNUM *);
336void BN_clear_free(BIGNUM *a); 330void BN_clear_free(BIGNUM *a);
337BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b); 331BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b);
332void BN_swap(BIGNUM *a, BIGNUM *b);
338BIGNUM *BN_bin2bn(const unsigned char *s,int len,BIGNUM *ret); 333BIGNUM *BN_bin2bn(const unsigned char *s,int len,BIGNUM *ret);
339int BN_bn2bin(const BIGNUM *a, unsigned char *to); 334int BN_bn2bin(const BIGNUM *a, unsigned char *to);
340BIGNUM *BN_mpi2bn(unsigned char *s,int len,BIGNUM *ret); 335BIGNUM *BN_mpi2bn(const unsigned char *s,int len,BIGNUM *ret);
341int BN_bn2mpi(const BIGNUM *a, unsigned char *to); 336int BN_bn2mpi(const BIGNUM *a, unsigned char *to);
342int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); 337int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
343int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); 338int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
344int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); 339int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
345int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); 340int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
346int BN_mod(BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx); 341int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
342int BN_sqr(BIGNUM *r, const BIGNUM *a,BN_CTX *ctx);
343
347int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, 344int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,
348 BN_CTX *ctx); 345 BN_CTX *ctx);
349int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx); 346#define BN_mod(rem,m,d,ctx) BN_div(NULL,(rem),(m),(d),(ctx))
350int BN_sqr(BIGNUM *r, BIGNUM *a,BN_CTX *ctx); 347int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx);
348int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx);
349int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m);
350int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx);
351int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m);
352int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
353 const BIGNUM *m, BN_CTX *ctx);
354int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
355int BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
356int BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m);
357int BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m, BN_CTX *ctx);
358int BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m);
359
351BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w); 360BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w);
352BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w); 361BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w);
353int BN_mul_word(BIGNUM *a, BN_ULONG w); 362int BN_mul_word(BIGNUM *a, BN_ULONG w);
354int BN_add_word(BIGNUM *a, BN_ULONG w); 363int BN_add_word(BIGNUM *a, BN_ULONG w);
355int BN_sub_word(BIGNUM *a, BN_ULONG w); 364int BN_sub_word(BIGNUM *a, BN_ULONG w);
356int BN_set_word(BIGNUM *a, BN_ULONG w); 365int BN_set_word(BIGNUM *a, BN_ULONG w);
357BN_ULONG BN_get_word(BIGNUM *a); 366BN_ULONG BN_get_word(const BIGNUM *a);
367
358int BN_cmp(const BIGNUM *a, const BIGNUM *b); 368int BN_cmp(const BIGNUM *a, const BIGNUM *b);
359void BN_free(BIGNUM *a); 369void BN_free(BIGNUM *a);
360int BN_is_bit_set(const BIGNUM *a, int n); 370int BN_is_bit_set(const BIGNUM *a, int n);
361int BN_lshift(BIGNUM *r, const BIGNUM *a, int n); 371int BN_lshift(BIGNUM *r, const BIGNUM *a, int n);
362int BN_lshift1(BIGNUM *r, BIGNUM *a); 372int BN_lshift1(BIGNUM *r, const BIGNUM *a);
363int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p,BN_CTX *ctx); 373int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,BN_CTX *ctx);
364int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p, 374
365 const BIGNUM *m,BN_CTX *ctx); 375int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
366int BN_mod_exp_mont(BIGNUM *r, BIGNUM *a, const BIGNUM *p, 376 const BIGNUM *m,BN_CTX *ctx);
367 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); 377int BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
378 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
368int BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p, 379int BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p,
369 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); 380 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
370int BN_mod_exp2_mont(BIGNUM *r, BIGNUM *a1, BIGNUM *p1,BIGNUM *a2, 381int BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1, const BIGNUM *p1,
371 BIGNUM *p2,BIGNUM *m,BN_CTX *ctx,BN_MONT_CTX *m_ctx); 382 const BIGNUM *a2, const BIGNUM *p2,const BIGNUM *m,
372int BN_mod_exp_simple(BIGNUM *r, BIGNUM *a, BIGNUM *p, 383 BN_CTX *ctx,BN_MONT_CTX *m_ctx);
373 BIGNUM *m,BN_CTX *ctx); 384int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
385 const BIGNUM *m,BN_CTX *ctx);
386
374int BN_mask_bits(BIGNUM *a,int n); 387int BN_mask_bits(BIGNUM *a,int n);
375int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m, BN_CTX *ctx); 388#ifndef OPENSSL_NO_FP_API
376#ifndef NO_FP_API
377int BN_print_fp(FILE *fp, const BIGNUM *a); 389int BN_print_fp(FILE *fp, const BIGNUM *a);
378#endif 390#endif
379#ifdef HEADER_BIO_H 391#ifdef HEADER_BIO_H
@@ -381,9 +393,9 @@ int BN_print(BIO *fp, const BIGNUM *a);
381#else 393#else
382int BN_print(void *fp, const BIGNUM *a); 394int BN_print(void *fp, const BIGNUM *a);
383#endif 395#endif
384int BN_reciprocal(BIGNUM *r, BIGNUM *m, int len, BN_CTX *ctx); 396int BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx);
385int BN_rshift(BIGNUM *r, BIGNUM *a, int n); 397int BN_rshift(BIGNUM *r, const BIGNUM *a, int n);
386int BN_rshift1(BIGNUM *r, BIGNUM *a); 398int BN_rshift1(BIGNUM *r, const BIGNUM *a);
387void BN_clear(BIGNUM *a); 399void BN_clear(BIGNUM *a);
388BIGNUM *BN_dup(const BIGNUM *a); 400BIGNUM *BN_dup(const BIGNUM *a);
389int BN_ucmp(const BIGNUM *a, const BIGNUM *b); 401int BN_ucmp(const BIGNUM *a, const BIGNUM *b);
@@ -393,23 +405,30 @@ char * BN_bn2hex(const BIGNUM *a);
393char * BN_bn2dec(const BIGNUM *a); 405char * BN_bn2dec(const BIGNUM *a);
394int BN_hex2bn(BIGNUM **a, const char *str); 406int BN_hex2bn(BIGNUM **a, const char *str);
395int BN_dec2bn(BIGNUM **a, const char *str); 407int BN_dec2bn(BIGNUM **a, const char *str);
396int BN_gcd(BIGNUM *r,BIGNUM *in_a,BIGNUM *in_b,BN_CTX *ctx); 408int BN_gcd(BIGNUM *r,const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx);
397BIGNUM *BN_mod_inverse(BIGNUM *ret,BIGNUM *a, const BIGNUM *n,BN_CTX *ctx); 409int BN_kronecker(const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx); /* returns -2 for error */
398BIGNUM *BN_generate_prime(BIGNUM *ret,int bits,int safe,BIGNUM *add, 410BIGNUM *BN_mod_inverse(BIGNUM *ret,
399 BIGNUM *rem,void (*callback)(int,int,void *),void *cb_arg); 411 const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx);
412BIGNUM *BN_mod_sqrt(BIGNUM *ret,
413 const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx);
414BIGNUM *BN_generate_prime(BIGNUM *ret,int bits,int safe,
415 const BIGNUM *add, const BIGNUM *rem,
416 void (*callback)(int,int,void *),void *cb_arg);
400int BN_is_prime(const BIGNUM *p,int nchecks, 417int BN_is_prime(const BIGNUM *p,int nchecks,
401 void (*callback)(int,int,void *), 418 void (*callback)(int,int,void *),
402 BN_CTX *ctx,void *cb_arg); 419 BN_CTX *ctx,void *cb_arg);
403int BN_is_prime_fasttest(const BIGNUM *p,int nchecks, 420int BN_is_prime_fasttest(const BIGNUM *p,int nchecks,
404 void (*callback)(int,int,void *),BN_CTX *ctx,void *cb_arg, 421 void (*callback)(int,int,void *),BN_CTX *ctx,void *cb_arg,
405 int do_trial_division); 422 int do_trial_division);
406void ERR_load_BN_strings(void );
407 423
408BN_MONT_CTX *BN_MONT_CTX_new(void ); 424BN_MONT_CTX *BN_MONT_CTX_new(void );
409void BN_MONT_CTX_init(BN_MONT_CTX *ctx); 425void BN_MONT_CTX_init(BN_MONT_CTX *ctx);
410int BN_mod_mul_montgomery(BIGNUM *r,BIGNUM *a,BIGNUM *b,BN_MONT_CTX *mont, 426int BN_mod_mul_montgomery(BIGNUM *r,const BIGNUM *a,const BIGNUM *b,
411 BN_CTX *ctx); 427 BN_MONT_CTX *mont, BN_CTX *ctx);
412int BN_from_montgomery(BIGNUM *r,BIGNUM *a,BN_MONT_CTX *mont,BN_CTX *ctx); 428#define BN_to_montgomery(r,a,mont,ctx) BN_mod_mul_montgomery(\
429 (r),(a),&((mont)->RR),(mont),(ctx))
430int BN_from_montgomery(BIGNUM *r,const BIGNUM *a,
431 BN_MONT_CTX *mont, BN_CTX *ctx);
413void BN_MONT_CTX_free(BN_MONT_CTX *mont); 432void BN_MONT_CTX_free(BN_MONT_CTX *mont);
414int BN_MONT_CTX_set(BN_MONT_CTX *mont,const BIGNUM *modulus,BN_CTX *ctx); 433int BN_MONT_CTX_set(BN_MONT_CTX *mont,const BIGNUM *modulus,BN_CTX *ctx);
415BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to,BN_MONT_CTX *from); 434BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to,BN_MONT_CTX *from);
@@ -427,12 +446,12 @@ void BN_RECP_CTX_init(BN_RECP_CTX *recp);
427BN_RECP_CTX *BN_RECP_CTX_new(void); 446BN_RECP_CTX *BN_RECP_CTX_new(void);
428void BN_RECP_CTX_free(BN_RECP_CTX *recp); 447void BN_RECP_CTX_free(BN_RECP_CTX *recp);
429int BN_RECP_CTX_set(BN_RECP_CTX *recp,const BIGNUM *rdiv,BN_CTX *ctx); 448int BN_RECP_CTX_set(BN_RECP_CTX *recp,const BIGNUM *rdiv,BN_CTX *ctx);
430int BN_mod_mul_reciprocal(BIGNUM *r, BIGNUM *x, BIGNUM *y, 449int BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y,
431 BN_RECP_CTX *recp,BN_CTX *ctx); 450 BN_RECP_CTX *recp,BN_CTX *ctx);
432int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, 451int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
433 const BIGNUM *m, BN_CTX *ctx); 452 const BIGNUM *m, BN_CTX *ctx);
434int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, 453int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,
435 BN_RECP_CTX *recp, BN_CTX *ctx); 454 BN_RECP_CTX *recp, BN_CTX *ctx);
436 455
437/* library internal functions */ 456/* library internal functions */
438 457
@@ -440,6 +459,7 @@ int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *m,
440 (a):bn_expand2((a),(bits)/BN_BITS2+1)) 459 (a):bn_expand2((a),(bits)/BN_BITS2+1))
441#define bn_wexpand(a,words) (((words) <= (a)->dmax)?(a):bn_expand2((a),(words))) 460#define bn_wexpand(a,words) (((words) <= (a)->dmax)?(a):bn_expand2((a),(words)))
442BIGNUM *bn_expand2(BIGNUM *a, int words); 461BIGNUM *bn_expand2(BIGNUM *a, int words);
462BIGNUM *bn_dup_expand(const BIGNUM *a, int words);
443 463
444#define bn_fix_top(a) \ 464#define bn_fix_top(a) \
445 { \ 465 { \
@@ -451,15 +471,15 @@ BIGNUM *bn_expand2(BIGNUM *a, int words);
451 } \ 471 } \
452 } 472 }
453 473
454BN_ULONG bn_mul_add_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w); 474BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w);
455BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w); 475BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w);
456void bn_sqr_words(BN_ULONG *rp, BN_ULONG *ap, int num); 476void bn_sqr_words(BN_ULONG *rp, const BN_ULONG *ap, int num);
457BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d); 477BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d);
458BN_ULONG bn_add_words(BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,int num); 478BN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int num);
459BN_ULONG bn_sub_words(BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,int num); 479BN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int num);
460 480
461#ifdef BN_DEBUG 481#ifdef BN_DEBUG
462 void bn_dump1(FILE *o, const char *a, BN_ULONG *b,int n); 482void bn_dump1(FILE *o, const char *a, const BN_ULONG *b,int n);
463# define bn_print(a) {fprintf(stderr, #a "="); BN_print_fp(stderr,a); \ 483# define bn_print(a) {fprintf(stderr, #a "="); BN_print_fp(stderr,a); \
464 fprintf(stderr,"\n");} 484 fprintf(stderr,"\n");}
465# define bn_dump(a,n) bn_dump1(stderr,#a,a,n); 485# define bn_dump(a,n) bn_dump1(stderr,#a,a,n);
@@ -474,6 +494,7 @@ int BN_bntest_rand(BIGNUM *rnd, int bits, int top,int bottom);
474/* The following lines are auto generated by the script mkerr.pl. Any changes 494/* The following lines are auto generated by the script mkerr.pl. Any changes
475 * made after this point may be overwritten when the script is next run. 495 * made after this point may be overwritten when the script is next run.
476 */ 496 */
497void ERR_load_BN_strings(void);
477 498
478/* Error codes for the BN functions. */ 499/* Error codes for the BN functions. */
479 500
@@ -488,11 +509,14 @@ int BN_bntest_rand(BIGNUM *rnd, int bits, int top,int bottom);
488#define BN_F_BN_CTX_NEW 106 509#define BN_F_BN_CTX_NEW 106
489#define BN_F_BN_DIV 107 510#define BN_F_BN_DIV 107
490#define BN_F_BN_EXPAND2 108 511#define BN_F_BN_EXPAND2 108
512#define BN_F_BN_EXPAND_INTERNAL 120
491#define BN_F_BN_MOD_EXP2_MONT 118 513#define BN_F_BN_MOD_EXP2_MONT 118
492#define BN_F_BN_MOD_EXP_MONT 109 514#define BN_F_BN_MOD_EXP_MONT 109
493#define BN_F_BN_MOD_EXP_MONT_WORD 117 515#define BN_F_BN_MOD_EXP_MONT_WORD 117
494#define BN_F_BN_MOD_INVERSE 110 516#define BN_F_BN_MOD_INVERSE 110
517#define BN_F_BN_MOD_LSHIFT_QUICK 119
495#define BN_F_BN_MOD_MUL_RECIPROCAL 111 518#define BN_F_BN_MOD_MUL_RECIPROCAL 111
519#define BN_F_BN_MOD_SQRT 121
496#define BN_F_BN_MPI2BN 112 520#define BN_F_BN_MPI2BN 112
497#define BN_F_BN_NEW 113 521#define BN_F_BN_NEW 113
498#define BN_F_BN_RAND 114 522#define BN_F_BN_RAND 114
@@ -507,14 +531,17 @@ int BN_bntest_rand(BIGNUM *rnd, int bits, int top,int bottom);
507#define BN_R_DIV_BY_ZERO 103 531#define BN_R_DIV_BY_ZERO 103
508#define BN_R_ENCODING_ERROR 104 532#define BN_R_ENCODING_ERROR 104
509#define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA 105 533#define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA 105
534#define BN_R_INPUT_NOT_REDUCED 110
510#define BN_R_INVALID_LENGTH 106 535#define BN_R_INVALID_LENGTH 106
511#define BN_R_INVALID_RANGE 115 536#define BN_R_INVALID_RANGE 115
537#define BN_R_NOT_A_SQUARE 111
512#define BN_R_NOT_INITIALIZED 107 538#define BN_R_NOT_INITIALIZED 107
513#define BN_R_NO_INVERSE 108 539#define BN_R_NO_INVERSE 108
540#define BN_R_P_IS_NOT_PRIME 112
541#define BN_R_TOO_MANY_ITERATIONS 113
514#define BN_R_TOO_MANY_TEMPORARY_VARIABLES 109 542#define BN_R_TOO_MANY_TEMPORARY_VARIABLES 109
515 543
516#ifdef __cplusplus 544#ifdef __cplusplus
517} 545}
518#endif 546#endif
519#endif 547#endif
520
diff --git a/src/lib/libcrypto/bn/bn_add.c b/src/lib/libcrypto/bn/bn_add.c
index 5d24691233..6cba07e9f6 100644
--- a/src/lib/libcrypto/bn/bn_add.c
+++ b/src/lib/libcrypto/bn/bn_add.c
@@ -64,6 +64,7 @@
64int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) 64int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
65 { 65 {
66 const BIGNUM *tmp; 66 const BIGNUM *tmp;
67 int a_neg = a->neg;
67 68
68 bn_check_top(a); 69 bn_check_top(a);
69 bn_check_top(b); 70 bn_check_top(b);
@@ -73,10 +74,10 @@ int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
73 * -a + b b-a 74 * -a + b b-a
74 * -a + -b -(a+b) 75 * -a + -b -(a+b)
75 */ 76 */
76 if (a->neg ^ b->neg) 77 if (a_neg ^ b->neg)
77 { 78 {
78 /* only one is negative */ 79 /* only one is negative */
79 if (a->neg) 80 if (a_neg)
80 { tmp=a; a=b; b=tmp; } 81 { tmp=a; a=b; b=tmp; }
81 82
82 /* we are now a - b */ 83 /* we are now a - b */
@@ -94,12 +95,11 @@ int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
94 return(1); 95 return(1);
95 } 96 }
96 97
97 if (a->neg) /* both are neg */ 98 if (!BN_uadd(r,a,b)) return(0);
99 if (a_neg) /* both are neg */
98 r->neg=1; 100 r->neg=1;
99 else 101 else
100 r->neg=0; 102 r->neg=0;
101
102 if (!BN_uadd(r,a,b)) return(0);
103 return(1); 103 return(1);
104 } 104 }
105 105
@@ -160,6 +160,7 @@ int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
160 *(rp++)= *(ap++); 160 *(rp++)= *(ap++);
161 } 161 }
162 /* memcpy(rp,ap,sizeof(*ap)*(max-i));*/ 162 /* memcpy(rp,ap,sizeof(*ap)*(max-i));*/
163 r->neg = 0;
163 return(1); 164 return(1);
164 } 165 }
165 166
@@ -251,6 +252,7 @@ int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
251#endif 252#endif
252 253
253 r->top=max; 254 r->top=max;
255 r->neg=0;
254 bn_fix_top(r); 256 bn_fix_top(r);
255 return(1); 257 return(1);
256 } 258 }
diff --git a/src/lib/libcrypto/bn/bn_asm.c b/src/lib/libcrypto/bn/bn_asm.c
index 44e52a40db..be8aa3ffc5 100644
--- a/src/lib/libcrypto/bn/bn_asm.c
+++ b/src/lib/libcrypto/bn/bn_asm.c
@@ -68,7 +68,7 @@
68 68
69#if defined(BN_LLONG) || defined(BN_UMULT_HIGH) 69#if defined(BN_LLONG) || defined(BN_UMULT_HIGH)
70 70
71BN_ULONG bn_mul_add_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w) 71BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w)
72 { 72 {
73 BN_ULONG c1=0; 73 BN_ULONG c1=0;
74 74
@@ -93,7 +93,7 @@ BN_ULONG bn_mul_add_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w)
93 return(c1); 93 return(c1);
94 } 94 }
95 95
96BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w) 96BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w)
97 { 97 {
98 BN_ULONG c1=0; 98 BN_ULONG c1=0;
99 99
@@ -117,7 +117,7 @@ BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w)
117 return(c1); 117 return(c1);
118 } 118 }
119 119
120void bn_sqr_words(BN_ULONG *r, BN_ULONG *a, int n) 120void bn_sqr_words(BN_ULONG *r, const BN_ULONG *a, int n)
121 { 121 {
122 assert(n >= 0); 122 assert(n >= 0);
123 if (n <= 0) return; 123 if (n <= 0) return;
@@ -139,7 +139,7 @@ void bn_sqr_words(BN_ULONG *r, BN_ULONG *a, int n)
139 139
140#else /* !(defined(BN_LLONG) || defined(BN_UMULT_HIGH)) */ 140#else /* !(defined(BN_LLONG) || defined(BN_UMULT_HIGH)) */
141 141
142BN_ULONG bn_mul_add_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w) 142BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w)
143 { 143 {
144 BN_ULONG c=0; 144 BN_ULONG c=0;
145 BN_ULONG bl,bh; 145 BN_ULONG bl,bh;
@@ -166,7 +166,7 @@ BN_ULONG bn_mul_add_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w)
166 return(c); 166 return(c);
167 } 167 }
168 168
169BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w) 169BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w)
170 { 170 {
171 BN_ULONG carry=0; 171 BN_ULONG carry=0;
172 BN_ULONG bl,bh; 172 BN_ULONG bl,bh;
@@ -193,7 +193,7 @@ BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w)
193 return(carry); 193 return(carry);
194 } 194 }
195 195
196void bn_sqr_words(BN_ULONG *r, BN_ULONG *a, int n) 196void bn_sqr_words(BN_ULONG *r, const BN_ULONG *a, int n)
197 { 197 {
198 assert(n >= 0); 198 assert(n >= 0);
199 if (n <= 0) return; 199 if (n <= 0) return;
@@ -296,7 +296,7 @@ BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d)
296#endif /* !defined(BN_LLONG) && defined(BN_DIV2W) */ 296#endif /* !defined(BN_LLONG) && defined(BN_DIV2W) */
297 297
298#ifdef BN_LLONG 298#ifdef BN_LLONG
299BN_ULONG bn_add_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n) 299BN_ULONG bn_add_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int n)
300 { 300 {
301 BN_ULLONG ll=0; 301 BN_ULLONG ll=0;
302 302
@@ -332,7 +332,7 @@ BN_ULONG bn_add_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
332 return((BN_ULONG)ll); 332 return((BN_ULONG)ll);
333 } 333 }
334#else /* !BN_LLONG */ 334#else /* !BN_LLONG */
335BN_ULONG bn_add_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n) 335BN_ULONG bn_add_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int n)
336 { 336 {
337 BN_ULONG c,l,t; 337 BN_ULONG c,l,t;
338 338
@@ -382,7 +382,7 @@ BN_ULONG bn_add_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
382 } 382 }
383#endif /* !BN_LLONG */ 383#endif /* !BN_LLONG */
384 384
385BN_ULONG bn_sub_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n) 385BN_ULONG bn_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int n)
386 { 386 {
387 BN_ULONG t1,t2; 387 BN_ULONG t1,t2;
388 int c=0; 388 int c=0;
@@ -673,7 +673,7 @@ void bn_mul_comba4(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b)
673 r[7]=c2; 673 r[7]=c2;
674 } 674 }
675 675
676void bn_sqr_comba8(BN_ULONG *r, BN_ULONG *a) 676void bn_sqr_comba8(BN_ULONG *r, const BN_ULONG *a)
677 { 677 {
678#ifdef BN_LLONG 678#ifdef BN_LLONG
679 BN_ULLONG t,tt; 679 BN_ULLONG t,tt;
@@ -754,7 +754,7 @@ void bn_sqr_comba8(BN_ULONG *r, BN_ULONG *a)
754 r[15]=c1; 754 r[15]=c1;
755 } 755 }
756 756
757void bn_sqr_comba4(BN_ULONG *r, BN_ULONG *a) 757void bn_sqr_comba4(BN_ULONG *r, const BN_ULONG *a)
758 { 758 {
759#ifdef BN_LLONG 759#ifdef BN_LLONG
760 BN_ULLONG t,tt; 760 BN_ULLONG t,tt;
diff --git a/src/lib/libcrypto/bn/bn_ctx.c b/src/lib/libcrypto/bn/bn_ctx.c
index b1a8d7571e..7daf19eb84 100644
--- a/src/lib/libcrypto/bn/bn_ctx.c
+++ b/src/lib/libcrypto/bn/bn_ctx.c
@@ -61,8 +61,9 @@
61 61
62#include <stdio.h> 62#include <stdio.h>
63#include <assert.h> 63#include <assert.h>
64
64#include "cryptlib.h" 65#include "cryptlib.h"
65#include <openssl/bn.h> 66#include "bn_lcl.h"
66 67
67 68
68BN_CTX *BN_CTX_new(void) 69BN_CTX *BN_CTX_new(void)
@@ -83,6 +84,7 @@ BN_CTX *BN_CTX_new(void)
83 84
84void BN_CTX_init(BN_CTX *ctx) 85void BN_CTX_init(BN_CTX *ctx)
85 { 86 {
87#if 0 /* explicit version */
86 int i; 88 int i;
87 ctx->tos = 0; 89 ctx->tos = 0;
88 ctx->flags = 0; 90 ctx->flags = 0;
@@ -90,6 +92,9 @@ void BN_CTX_init(BN_CTX *ctx)
90 ctx->too_many = 0; 92 ctx->too_many = 0;
91 for (i = 0; i < BN_CTX_NUM; i++) 93 for (i = 0; i < BN_CTX_NUM; i++)
92 BN_init(&(ctx->bn[i])); 94 BN_init(&(ctx->bn[i]));
95#else
96 memset(ctx, 0, sizeof *ctx);
97#endif
93 } 98 }
94 99
95void BN_CTX_free(BN_CTX *ctx) 100void BN_CTX_free(BN_CTX *ctx)
@@ -112,8 +117,14 @@ void BN_CTX_start(BN_CTX *ctx)
112 ctx->depth++; 117 ctx->depth++;
113 } 118 }
114 119
120
115BIGNUM *BN_CTX_get(BN_CTX *ctx) 121BIGNUM *BN_CTX_get(BN_CTX *ctx)
116 { 122 {
123 /* Note: If BN_CTX_get is ever changed to allocate BIGNUMs dynamically,
124 * make sure that if BN_CTX_get fails once it will return NULL again
125 * until BN_CTX_end is called. (This is so that callers have to check
126 * only the last return value.)
127 */
117 if (ctx->depth > BN_CTX_NUM_POS || ctx->tos >= BN_CTX_NUM) 128 if (ctx->depth > BN_CTX_NUM_POS || ctx->tos >= BN_CTX_NUM)
118 { 129 {
119 if (!ctx->too_many) 130 if (!ctx->too_many)
diff --git a/src/lib/libcrypto/bn/bn_div.c b/src/lib/libcrypto/bn/bn_div.c
index c328b5b411..ac1a09615a 100644
--- a/src/lib/libcrypto/bn/bn_div.c
+++ b/src/lib/libcrypto/bn/bn_div.c
@@ -61,6 +61,7 @@
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include "bn_lcl.h" 62#include "bn_lcl.h"
63 63
64
64/* The old slow way */ 65/* The old slow way */
65#if 0 66#if 0
66int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, 67int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,
@@ -126,9 +127,10 @@ int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,
126 127
127#else 128#else
128 129
129#if !defined(NO_ASM) && !defined(NO_INLINE_ASM) && !defined(PEDANTIC) && !defined(BN_DIV3W) 130#if !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) \
131 && !defined(PEDANTIC) && !defined(BN_DIV3W)
130# if defined(__GNUC__) && __GNUC__>=2 132# if defined(__GNUC__) && __GNUC__>=2
131# if defined(__i386) 133# if defined(__i386) || defined (__i386__)
132 /* 134 /*
133 * There were two reasons for implementing this template: 135 * There were two reasons for implementing this template:
134 * - GNU C generates a call to a function (__udivdi3 to be exact) 136 * - GNU C generates a call to a function (__udivdi3 to be exact)
@@ -150,8 +152,16 @@ int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,
150# define REMAINDER_IS_ALREADY_CALCULATED 152# define REMAINDER_IS_ALREADY_CALCULATED
151# endif /* __<cpu> */ 153# endif /* __<cpu> */
152# endif /* __GNUC__ */ 154# endif /* __GNUC__ */
153#endif /* NO_ASM */ 155#endif /* OPENSSL_NO_ASM */
156
154 157
158/* BN_div computes dv := num / divisor, rounding towards zero, and sets up
159 * rm such that dv*divisor + rm = num holds.
160 * Thus:
161 * dv->neg == num->neg ^ divisor->neg (unless the result is zero)
162 * rm->neg == num->neg (unless the remainder is zero)
163 * If 'dv' or 'rm' is NULL, the respective value is not returned.
164 */
155int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor, 165int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
156 BN_CTX *ctx) 166 BN_CTX *ctx)
157 { 167 {
@@ -185,7 +195,7 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
185 if (dv == NULL) 195 if (dv == NULL)
186 res=BN_CTX_get(ctx); 196 res=BN_CTX_get(ctx);
187 else res=dv; 197 else res=dv;
188 if (sdiv==NULL || res == NULL) goto err; 198 if (sdiv == NULL || res == NULL) goto err;
189 tmp->neg=0; 199 tmp->neg=0;
190 200
191 /* First we normalise the numbers */ 201 /* First we normalise the numbers */
@@ -232,12 +242,14 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
232 } 242 }
233 else 243 else
234 res->top--; 244 res->top--;
245 if (res->top == 0)
246 res->neg = 0;
235 resp--; 247 resp--;
236 248
237 for (i=0; i<loop-1; i++) 249 for (i=0; i<loop-1; i++)
238 { 250 {
239 BN_ULONG q,l0; 251 BN_ULONG q,l0;
240#if defined(BN_DIV3W) && !defined(NO_ASM) 252#if defined(BN_DIV3W) && !defined(OPENSSL_NO_ASM)
241 BN_ULONG bn_div_3_words(BN_ULONG*,BN_ULONG,BN_ULONG); 253 BN_ULONG bn_div_3_words(BN_ULONG*,BN_ULONG,BN_ULONG);
242 q=bn_div_3_words(wnump,d1,d0); 254 q=bn_div_3_words(wnump,d1,d0);
243#else 255#else
@@ -331,8 +343,13 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
331 } 343 }
332 if (rm != NULL) 344 if (rm != NULL)
333 { 345 {
346 /* Keep a copy of the neg flag in num because if rm==num
347 * BN_rshift() will overwrite it.
348 */
349 int neg = num->neg;
334 BN_rshift(rm,snum,norm_shift); 350 BN_rshift(rm,snum,norm_shift);
335 rm->neg=num->neg; 351 if (!BN_is_zero(rm))
352 rm->neg = neg;
336 } 353 }
337 BN_CTX_end(ctx); 354 BN_CTX_end(ctx);
338 return(1); 355 return(1);
@@ -342,40 +359,3 @@ err:
342 } 359 }
343 360
344#endif 361#endif
345
346/* rem != m */
347int BN_mod(BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx)
348 {
349#if 0 /* The old slow way */
350 int i,nm,nd;
351 BIGNUM *dv;
352
353 if (BN_ucmp(m,d) < 0)
354 return((BN_copy(rem,m) == NULL)?0:1);
355
356 BN_CTX_start(ctx);
357 dv=BN_CTX_get(ctx);
358
359 if (!BN_copy(rem,m)) goto err;
360
361 nm=BN_num_bits(rem);
362 nd=BN_num_bits(d);
363 if (!BN_lshift(dv,d,nm-nd)) goto err;
364 for (i=nm-nd; i>=0; i--)
365 {
366 if (BN_cmp(rem,dv) >= 0)
367 {
368 if (!BN_sub(rem,rem,dv)) goto err;
369 }
370 if (!BN_rshift1(dv,dv)) goto err;
371 }
372 BN_CTX_end(ctx);
373 return(1);
374 err:
375 BN_CTX_end(ctx);
376 return(0);
377#else
378 return(BN_div(NULL,rem,m,d,ctx));
379#endif
380 }
381
diff --git a/src/lib/libcrypto/bn/bn_err.c b/src/lib/libcrypto/bn/bn_err.c
index adc6a214fc..fb84ee96d8 100644
--- a/src/lib/libcrypto/bn/bn_err.c
+++ b/src/lib/libcrypto/bn/bn_err.c
@@ -63,7 +63,7 @@
63#include <openssl/bn.h> 63#include <openssl/bn.h>
64 64
65/* BEGIN ERROR CODES */ 65/* BEGIN ERROR CODES */
66#ifndef NO_ERR 66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA BN_str_functs[]= 67static ERR_STRING_DATA BN_str_functs[]=
68 { 68 {
69{ERR_PACK(0,BN_F_BN_BLINDING_CONVERT,0), "BN_BLINDING_convert"}, 69{ERR_PACK(0,BN_F_BN_BLINDING_CONVERT,0), "BN_BLINDING_convert"},
@@ -76,11 +76,14 @@ static ERR_STRING_DATA BN_str_functs[]=
76{ERR_PACK(0,BN_F_BN_CTX_NEW,0), "BN_CTX_new"}, 76{ERR_PACK(0,BN_F_BN_CTX_NEW,0), "BN_CTX_new"},
77{ERR_PACK(0,BN_F_BN_DIV,0), "BN_div"}, 77{ERR_PACK(0,BN_F_BN_DIV,0), "BN_div"},
78{ERR_PACK(0,BN_F_BN_EXPAND2,0), "bn_expand2"}, 78{ERR_PACK(0,BN_F_BN_EXPAND2,0), "bn_expand2"},
79{ERR_PACK(0,BN_F_BN_EXPAND_INTERNAL,0), "BN_EXPAND_INTERNAL"},
79{ERR_PACK(0,BN_F_BN_MOD_EXP2_MONT,0), "BN_mod_exp2_mont"}, 80{ERR_PACK(0,BN_F_BN_MOD_EXP2_MONT,0), "BN_mod_exp2_mont"},
80{ERR_PACK(0,BN_F_BN_MOD_EXP_MONT,0), "BN_mod_exp_mont"}, 81{ERR_PACK(0,BN_F_BN_MOD_EXP_MONT,0), "BN_mod_exp_mont"},
81{ERR_PACK(0,BN_F_BN_MOD_EXP_MONT_WORD,0), "BN_mod_exp_mont_word"}, 82{ERR_PACK(0,BN_F_BN_MOD_EXP_MONT_WORD,0), "BN_mod_exp_mont_word"},
82{ERR_PACK(0,BN_F_BN_MOD_INVERSE,0), "BN_mod_inverse"}, 83{ERR_PACK(0,BN_F_BN_MOD_INVERSE,0), "BN_mod_inverse"},
84{ERR_PACK(0,BN_F_BN_MOD_LSHIFT_QUICK,0), "BN_mod_lshift_quick"},
83{ERR_PACK(0,BN_F_BN_MOD_MUL_RECIPROCAL,0), "BN_mod_mul_reciprocal"}, 85{ERR_PACK(0,BN_F_BN_MOD_MUL_RECIPROCAL,0), "BN_mod_mul_reciprocal"},
86{ERR_PACK(0,BN_F_BN_MOD_SQRT,0), "BN_mod_sqrt"},
84{ERR_PACK(0,BN_F_BN_MPI2BN,0), "BN_mpi2bn"}, 87{ERR_PACK(0,BN_F_BN_MPI2BN,0), "BN_mpi2bn"},
85{ERR_PACK(0,BN_F_BN_NEW,0), "BN_new"}, 88{ERR_PACK(0,BN_F_BN_NEW,0), "BN_new"},
86{ERR_PACK(0,BN_F_BN_RAND,0), "BN_rand"}, 89{ERR_PACK(0,BN_F_BN_RAND,0), "BN_rand"},
@@ -98,10 +101,14 @@ static ERR_STRING_DATA BN_str_reasons[]=
98{BN_R_DIV_BY_ZERO ,"div by zero"}, 101{BN_R_DIV_BY_ZERO ,"div by zero"},
99{BN_R_ENCODING_ERROR ,"encoding error"}, 102{BN_R_ENCODING_ERROR ,"encoding error"},
100{BN_R_EXPAND_ON_STATIC_BIGNUM_DATA ,"expand on static bignum data"}, 103{BN_R_EXPAND_ON_STATIC_BIGNUM_DATA ,"expand on static bignum data"},
104{BN_R_INPUT_NOT_REDUCED ,"input not reduced"},
101{BN_R_INVALID_LENGTH ,"invalid length"}, 105{BN_R_INVALID_LENGTH ,"invalid length"},
102{BN_R_INVALID_RANGE ,"invalid range"}, 106{BN_R_INVALID_RANGE ,"invalid range"},
107{BN_R_NOT_A_SQUARE ,"not a square"},
103{BN_R_NOT_INITIALIZED ,"not initialized"}, 108{BN_R_NOT_INITIALIZED ,"not initialized"},
104{BN_R_NO_INVERSE ,"no inverse"}, 109{BN_R_NO_INVERSE ,"no inverse"},
110{BN_R_P_IS_NOT_PRIME ,"p is not prime"},
111{BN_R_TOO_MANY_ITERATIONS ,"too many iterations"},
105{BN_R_TOO_MANY_TEMPORARY_VARIABLES ,"too many temporary variables"}, 112{BN_R_TOO_MANY_TEMPORARY_VARIABLES ,"too many temporary variables"},
106{0,NULL} 113{0,NULL}
107 }; 114 };
@@ -115,7 +122,7 @@ void ERR_load_BN_strings(void)
115 if (init) 122 if (init)
116 { 123 {
117 init=0; 124 init=0;
118#ifndef NO_ERR 125#ifndef OPENSSL_NO_ERR
119 ERR_load_strings(ERR_LIB_BN,BN_str_functs); 126 ERR_load_strings(ERR_LIB_BN,BN_str_functs);
120 ERR_load_strings(ERR_LIB_BN,BN_str_reasons); 127 ERR_load_strings(ERR_LIB_BN,BN_str_reasons);
121#endif 128#endif
diff --git a/src/lib/libcrypto/bn/bn_exp.c b/src/lib/libcrypto/bn/bn_exp.c
index d2c91628ac..afdfd580fb 100644
--- a/src/lib/libcrypto/bn/bn_exp.c
+++ b/src/lib/libcrypto/bn/bn_exp.c
@@ -110,38 +110,13 @@
110 */ 110 */
111 111
112 112
113#include <stdio.h>
114#include "cryptlib.h" 113#include "cryptlib.h"
115#include "bn_lcl.h" 114#include "bn_lcl.h"
116 115
117#define TABLE_SIZE 32 116#define TABLE_SIZE 32
118 117
119/* slow but works */
120int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m, BN_CTX *ctx)
121 {
122 BIGNUM *t;
123 int r=0;
124
125 bn_check_top(a);
126 bn_check_top(b);
127 bn_check_top(m);
128
129 BN_CTX_start(ctx);
130 if ((t = BN_CTX_get(ctx)) == NULL) goto err;
131 if (a == b)
132 { if (!BN_sqr(t,a,ctx)) goto err; }
133 else
134 { if (!BN_mul(t,a,b,ctx)) goto err; }
135 if (!BN_mod(ret,t,m,ctx)) goto err;
136 r=1;
137err:
138 BN_CTX_end(ctx);
139 return(r);
140 }
141
142
143/* this one works - simple but works */ 118/* this one works - simple but works */
144int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BN_CTX *ctx) 119int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
145 { 120 {
146 int i,bits,ret=0; 121 int i,bits,ret=0;
147 BIGNUM *v,*rr; 122 BIGNUM *v,*rr;
@@ -176,7 +151,7 @@ err:
176 } 151 }
177 152
178 153
179int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p, const BIGNUM *m, 154int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m,
180 BN_CTX *ctx) 155 BN_CTX *ctx)
181 { 156 {
182 int ret; 157 int ret;
@@ -185,6 +160,40 @@ int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p, const BIGNUM *m,
185 bn_check_top(p); 160 bn_check_top(p);
186 bn_check_top(m); 161 bn_check_top(m);
187 162
163 /* For even modulus m = 2^k*m_odd, it might make sense to compute
164 * a^p mod m_odd and a^p mod 2^k separately (with Montgomery
165 * exponentiation for the odd part), using appropriate exponent
166 * reductions, and combine the results using the CRT.
167 *
168 * For now, we use Montgomery only if the modulus is odd; otherwise,
169 * exponentiation using the reciprocal-based quick remaindering
170 * algorithm is used.
171 *
172 * (Timing obtained with expspeed.c [computations a^p mod m
173 * where a, p, m are of the same length: 256, 512, 1024, 2048,
174 * 4096, 8192 bits], compared to the running time of the
175 * standard algorithm:
176 *
177 * BN_mod_exp_mont 33 .. 40 % [AMD K6-2, Linux, debug configuration]
178 * 55 .. 77 % [UltraSparc processor, but
179 * debug-solaris-sparcv8-gcc conf.]
180 *
181 * BN_mod_exp_recp 50 .. 70 % [AMD K6-2, Linux, debug configuration]
182 * 62 .. 118 % [UltraSparc, debug-solaris-sparcv8-gcc]
183 *
184 * On the Sparc, BN_mod_exp_recp was faster than BN_mod_exp_mont
185 * at 2048 and more bits, but at 512 and 1024 bits, it was
186 * slower even than the standard algorithm!
187 *
188 * "Real" timings [linux-elf, solaris-sparcv9-gcc configurations]
189 * should be obtained when the new Montgomery reduction code
190 * has been integrated into OpenSSL.)
191 */
192
193#define MONT_MUL_MOD
194#define MONT_EXP_WORD
195#define RECP_MUL_MOD
196
188#ifdef MONT_MUL_MOD 197#ifdef MONT_MUL_MOD
189 /* I have finally been able to take out this pre-condition of 198 /* I have finally been able to take out this pre-condition of
190 * the top bit being set. It was caused by an error in BN_div 199 * the top bit being set. It was caused by an error in BN_div
@@ -194,12 +203,14 @@ int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p, const BIGNUM *m,
194 203
195 if (BN_is_odd(m)) 204 if (BN_is_odd(m))
196 { 205 {
197 if (a->top == 1) 206# ifdef MONT_EXP_WORD
207 if (a->top == 1 && !a->neg)
198 { 208 {
199 BN_ULONG A = a->d[0]; 209 BN_ULONG A = a->d[0];
200 ret=BN_mod_exp_mont_word(r,A,p,m,ctx,NULL); 210 ret=BN_mod_exp_mont_word(r,A,p,m,ctx,NULL);
201 } 211 }
202 else 212 else
213# endif
203 ret=BN_mod_exp_mont(r,a,p,m,ctx,NULL); 214 ret=BN_mod_exp_mont(r,a,p,m,ctx,NULL);
204 } 215 }
205 else 216 else
@@ -227,20 +238,35 @@ int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
227 238
228 if (bits == 0) 239 if (bits == 0)
229 { 240 {
230 BN_one(r); 241 ret = BN_one(r);
231 return(1); 242 return ret;
232 } 243 }
233 244
234 BN_CTX_start(ctx); 245 BN_CTX_start(ctx);
235 if ((aa = BN_CTX_get(ctx)) == NULL) goto err; 246 if ((aa = BN_CTX_get(ctx)) == NULL) goto err;
236 247
237 BN_RECP_CTX_init(&recp); 248 BN_RECP_CTX_init(&recp);
238 if (BN_RECP_CTX_set(&recp,m,ctx) <= 0) goto err; 249 if (m->neg)
250 {
251 /* ignore sign of 'm' */
252 if (!BN_copy(aa, m)) goto err;
253 aa->neg = 0;
254 if (BN_RECP_CTX_set(&recp,aa,ctx) <= 0) goto err;
255 }
256 else
257 {
258 if (BN_RECP_CTX_set(&recp,m,ctx) <= 0) goto err;
259 }
239 260
240 BN_init(&(val[0])); 261 BN_init(&(val[0]));
241 ts=1; 262 ts=1;
242 263
243 if (!BN_mod(&(val[0]),a,m,ctx)) goto err; /* 1 */ 264 if (!BN_nnmod(&(val[0]),a,m,ctx)) goto err; /* 1 */
265 if (BN_is_zero(&(val[0])))
266 {
267 ret = BN_zero(r);
268 goto err;
269 }
244 270
245 window = BN_window_bits_for_exponent_size(bits); 271 window = BN_window_bits_for_exponent_size(bits);
246 if (window > 1) 272 if (window > 1)
@@ -325,13 +351,13 @@ err:
325 } 351 }
326 352
327 353
328int BN_mod_exp_mont(BIGNUM *rr, BIGNUM *a, const BIGNUM *p, 354int BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
329 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont) 355 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont)
330 { 356 {
331 int i,j,bits,ret=0,wstart,wend,window,wvalue; 357 int i,j,bits,ret=0,wstart,wend,window,wvalue;
332 int start=1,ts=0; 358 int start=1,ts=0;
333 BIGNUM *d,*r; 359 BIGNUM *d,*r;
334 BIGNUM *aa; 360 const BIGNUM *aa;
335 BIGNUM val[TABLE_SIZE]; 361 BIGNUM val[TABLE_SIZE];
336 BN_MONT_CTX *mont=NULL; 362 BN_MONT_CTX *mont=NULL;
337 363
@@ -347,9 +373,10 @@ int BN_mod_exp_mont(BIGNUM *rr, BIGNUM *a, const BIGNUM *p,
347 bits=BN_num_bits(p); 373 bits=BN_num_bits(p);
348 if (bits == 0) 374 if (bits == 0)
349 { 375 {
350 BN_one(rr); 376 ret = BN_one(rr);
351 return(1); 377 return ret;
352 } 378 }
379
353 BN_CTX_start(ctx); 380 BN_CTX_start(ctx);
354 d = BN_CTX_get(ctx); 381 d = BN_CTX_get(ctx);
355 r = BN_CTX_get(ctx); 382 r = BN_CTX_get(ctx);
@@ -368,14 +395,19 @@ int BN_mod_exp_mont(BIGNUM *rr, BIGNUM *a, const BIGNUM *p,
368 395
369 BN_init(&val[0]); 396 BN_init(&val[0]);
370 ts=1; 397 ts=1;
371 if (BN_ucmp(a,m) >= 0) 398 if (a->neg || BN_ucmp(a,m) >= 0)
372 { 399 {
373 if (!BN_mod(&(val[0]),a,m,ctx)) 400 if (!BN_nnmod(&(val[0]),a,m,ctx))
374 goto err; 401 goto err;
375 aa= &(val[0]); 402 aa= &(val[0]);
376 } 403 }
377 else 404 else
378 aa=a; 405 aa=a;
406 if (BN_is_zero(aa))
407 {
408 ret = BN_zero(rr);
409 goto err;
410 }
379 if (!BN_to_montgomery(&(val[0]),aa,mont,ctx)) goto err; /* 1 */ 411 if (!BN_to_montgomery(&(val[0]),aa,mont,ctx)) goto err; /* 1 */
380 412
381 window = BN_window_bits_for_exponent_size(bits); 413 window = BN_window_bits_for_exponent_size(bits);
@@ -475,26 +507,39 @@ int BN_mod_exp_mont_word(BIGNUM *rr, BN_ULONG a, const BIGNUM *p,
475 (/* BN_ucmp(r, (m)) < 0 ? 1 :*/ \ 507 (/* BN_ucmp(r, (m)) < 0 ? 1 :*/ \
476 (BN_mod(t, r, m, ctx) && (swap_tmp = r, r = t, t = swap_tmp, 1)))) 508 (BN_mod(t, r, m, ctx) && (swap_tmp = r, r = t, t = swap_tmp, 1))))
477 /* BN_MOD_MUL_WORD is only used with 'w' large, 509 /* BN_MOD_MUL_WORD is only used with 'w' large,
478 * so the BN_ucmp test is probably more overhead 510 * so the BN_ucmp test is probably more overhead
479 * than always using BN_mod (which uses BN_copy if 511 * than always using BN_mod (which uses BN_copy if
480 * a similar test returns true). */ 512 * a similar test returns true). */
513 /* We can use BN_mod and do not need BN_nnmod because our
514 * accumulator is never negative (the result of BN_mod does
515 * not depend on the sign of the modulus).
516 */
481#define BN_TO_MONTGOMERY_WORD(r, w, mont) \ 517#define BN_TO_MONTGOMERY_WORD(r, w, mont) \
482 (BN_set_word(r, (w)) && BN_to_montgomery(r, r, (mont), ctx)) 518 (BN_set_word(r, (w)) && BN_to_montgomery(r, r, (mont), ctx))
483 519
484 bn_check_top(p); 520 bn_check_top(p);
485 bn_check_top(m); 521 bn_check_top(m);
486 522
487 if (!(m->d[0] & 1)) 523 if (m->top == 0 || !(m->d[0] & 1))
488 { 524 {
489 BNerr(BN_F_BN_MOD_EXP_MONT_WORD,BN_R_CALLED_WITH_EVEN_MODULUS); 525 BNerr(BN_F_BN_MOD_EXP_MONT_WORD,BN_R_CALLED_WITH_EVEN_MODULUS);
490 return(0); 526 return(0);
491 } 527 }
528 if (m->top == 1)
529 a %= m->d[0]; /* make sure that 'a' is reduced */
530
492 bits = BN_num_bits(p); 531 bits = BN_num_bits(p);
493 if (bits == 0) 532 if (bits == 0)
494 { 533 {
495 BN_one(rr); 534 ret = BN_one(rr);
496 return(1); 535 return ret;
536 }
537 if (a == 0)
538 {
539 ret = BN_zero(rr);
540 return ret;
497 } 541 }
542
498 BN_CTX_start(ctx); 543 BN_CTX_start(ctx);
499 d = BN_CTX_get(ctx); 544 d = BN_CTX_get(ctx);
500 r = BN_CTX_get(ctx); 545 r = BN_CTX_get(ctx);
@@ -590,8 +635,9 @@ err:
590 635
591 636
592/* The old fallback, simple version :-) */ 637/* The old fallback, simple version :-) */
593int BN_mod_exp_simple(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m, 638int BN_mod_exp_simple(BIGNUM *r,
594 BN_CTX *ctx) 639 const BIGNUM *a, const BIGNUM *p, const BIGNUM *m,
640 BN_CTX *ctx)
595 { 641 {
596 int i,j,bits,ret=0,wstart,wend,window,wvalue,ts=0; 642 int i,j,bits,ret=0,wstart,wend,window,wvalue,ts=0;
597 int start=1; 643 int start=1;
@@ -602,8 +648,8 @@ int BN_mod_exp_simple(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m,
602 648
603 if (bits == 0) 649 if (bits == 0)
604 { 650 {
605 BN_one(r); 651 ret = BN_one(r);
606 return(1); 652 return ret;
607 } 653 }
608 654
609 BN_CTX_start(ctx); 655 BN_CTX_start(ctx);
@@ -611,7 +657,12 @@ int BN_mod_exp_simple(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m,
611 657
612 BN_init(&(val[0])); 658 BN_init(&(val[0]));
613 ts=1; 659 ts=1;
614 if (!BN_mod(&(val[0]),a,m,ctx)) goto err; /* 1 */ 660 if (!BN_nnmod(&(val[0]),a,m,ctx)) goto err; /* 1 */
661 if (BN_is_zero(&(val[0])))
662 {
663 ret = BN_zero(r);
664 goto err;
665 }
615 666
616 window = BN_window_bits_for_exponent_size(bits); 667 window = BN_window_bits_for_exponent_size(bits);
617 if (window > 1) 668 if (window > 1)
diff --git a/src/lib/libcrypto/bn/bn_exp2.c b/src/lib/libcrypto/bn/bn_exp2.c
index 29029f4c72..73ccd58a83 100644
--- a/src/lib/libcrypto/bn/bn_exp2.c
+++ b/src/lib/libcrypto/bn/bn_exp2.c
@@ -115,13 +115,14 @@
115 115
116#define TABLE_SIZE 32 116#define TABLE_SIZE 32
117 117
118int BN_mod_exp2_mont(BIGNUM *rr, BIGNUM *a1, BIGNUM *p1, BIGNUM *a2, 118int BN_mod_exp2_mont(BIGNUM *rr, const BIGNUM *a1, const BIGNUM *p1,
119 BIGNUM *p2, BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont) 119 const BIGNUM *a2, const BIGNUM *p2, const BIGNUM *m,
120 BN_CTX *ctx, BN_MONT_CTX *in_mont)
120 { 121 {
121 int i,j,bits,b,bits1,bits2,ret=0,wpos1,wpos2,window1,window2,wvalue1,wvalue2; 122 int i,j,bits,b,bits1,bits2,ret=0,wpos1,wpos2,window1,window2,wvalue1,wvalue2;
122 int r_is_one=1,ts1=0,ts2=0; 123 int r_is_one=1,ts1=0,ts2=0;
123 BIGNUM *d,*r; 124 BIGNUM *d,*r;
124 BIGNUM *a_mod_m; 125 const BIGNUM *a_mod_m;
125 BIGNUM val1[TABLE_SIZE], val2[TABLE_SIZE]; 126 BIGNUM val1[TABLE_SIZE], val2[TABLE_SIZE];
126 BN_MONT_CTX *mont=NULL; 127 BN_MONT_CTX *mont=NULL;
127 128
@@ -140,9 +141,10 @@ int BN_mod_exp2_mont(BIGNUM *rr, BIGNUM *a1, BIGNUM *p1, BIGNUM *a2,
140 bits2=BN_num_bits(p2); 141 bits2=BN_num_bits(p2);
141 if ((bits1 == 0) && (bits2 == 0)) 142 if ((bits1 == 0) && (bits2 == 0))
142 { 143 {
143 BN_one(rr); 144 ret = BN_one(rr);
144 return(1); 145 return ret;
145 } 146 }
147
146 bits=(bits1 > bits2)?bits1:bits2; 148 bits=(bits1 > bits2)?bits1:bits2;
147 149
148 BN_CTX_start(ctx); 150 BN_CTX_start(ctx);
@@ -166,7 +168,7 @@ int BN_mod_exp2_mont(BIGNUM *rr, BIGNUM *a1, BIGNUM *p1, BIGNUM *a2,
166 */ 168 */
167 BN_init(&val1[0]); 169 BN_init(&val1[0]);
168 ts1=1; 170 ts1=1;
169 if (BN_ucmp(a1,m) >= 0) 171 if (a1->neg || BN_ucmp(a1,m) >= 0)
170 { 172 {
171 if (!BN_mod(&(val1[0]),a1,m,ctx)) 173 if (!BN_mod(&(val1[0]),a1,m,ctx))
172 goto err; 174 goto err;
@@ -174,6 +176,12 @@ int BN_mod_exp2_mont(BIGNUM *rr, BIGNUM *a1, BIGNUM *p1, BIGNUM *a2,
174 } 176 }
175 else 177 else
176 a_mod_m = a1; 178 a_mod_m = a1;
179 if (BN_is_zero(a_mod_m))
180 {
181 ret = BN_zero(rr);
182 goto err;
183 }
184
177 if (!BN_to_montgomery(&(val1[0]),a_mod_m,mont,ctx)) goto err; 185 if (!BN_to_montgomery(&(val1[0]),a_mod_m,mont,ctx)) goto err;
178 if (window1 > 1) 186 if (window1 > 1)
179 { 187 {
@@ -195,7 +203,7 @@ int BN_mod_exp2_mont(BIGNUM *rr, BIGNUM *a1, BIGNUM *p1, BIGNUM *a2,
195 */ 203 */
196 BN_init(&val2[0]); 204 BN_init(&val2[0]);
197 ts2=1; 205 ts2=1;
198 if (BN_ucmp(a2,m) >= 0) 206 if (a2->neg || BN_ucmp(a2,m) >= 0)
199 { 207 {
200 if (!BN_mod(&(val2[0]),a2,m,ctx)) 208 if (!BN_mod(&(val2[0]),a2,m,ctx))
201 goto err; 209 goto err;
@@ -203,6 +211,11 @@ int BN_mod_exp2_mont(BIGNUM *rr, BIGNUM *a1, BIGNUM *p1, BIGNUM *a2,
203 } 211 }
204 else 212 else
205 a_mod_m = a2; 213 a_mod_m = a2;
214 if (BN_is_zero(a_mod_m))
215 {
216 ret = BN_zero(rr);
217 goto err;
218 }
206 if (!BN_to_montgomery(&(val2[0]),a_mod_m,mont,ctx)) goto err; 219 if (!BN_to_montgomery(&(val2[0]),a_mod_m,mont,ctx)) goto err;
207 if (window2 > 1) 220 if (window2 > 1)
208 { 221 {
diff --git a/src/lib/libcrypto/bn/bn_gcd.c b/src/lib/libcrypto/bn/bn_gcd.c
index 398207196b..7649f63fd2 100644
--- a/src/lib/libcrypto/bn/bn_gcd.c
+++ b/src/lib/libcrypto/bn/bn_gcd.c
@@ -55,14 +55,66 @@
55 * copied and put under another distribution licence 55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58/* ====================================================================
59 * Copyright (c) 1998-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 */
58 111
59#include <stdio.h>
60#include "cryptlib.h" 112#include "cryptlib.h"
61#include "bn_lcl.h" 113#include "bn_lcl.h"
62 114
63static BIGNUM *euclid(BIGNUM *a, BIGNUM *b); 115static BIGNUM *euclid(BIGNUM *a, BIGNUM *b);
64 116
65int BN_gcd(BIGNUM *r, BIGNUM *in_a, BIGNUM *in_b, BN_CTX *ctx) 117int BN_gcd(BIGNUM *r, const BIGNUM *in_a, const BIGNUM *in_b, BN_CTX *ctx)
66 { 118 {
67 BIGNUM *a,*b,*t; 119 BIGNUM *a,*b,*t;
68 int ret=0; 120 int ret=0;
@@ -77,6 +129,8 @@ int BN_gcd(BIGNUM *r, BIGNUM *in_a, BIGNUM *in_b, BN_CTX *ctx)
77 129
78 if (BN_copy(a,in_a) == NULL) goto err; 130 if (BN_copy(a,in_a) == NULL) goto err;
79 if (BN_copy(b,in_b) == NULL) goto err; 131 if (BN_copy(b,in_b) == NULL) goto err;
132 a->neg = 0;
133 b->neg = 0;
80 134
81 if (BN_cmp(a,b) < 0) { t=a; a=b; b=t; } 135 if (BN_cmp(a,b) < 0) { t=a; a=b; b=t; }
82 t=euclid(a,b); 136 t=euclid(a,b);
@@ -97,10 +151,10 @@ static BIGNUM *euclid(BIGNUM *a, BIGNUM *b)
97 bn_check_top(a); 151 bn_check_top(a);
98 bn_check_top(b); 152 bn_check_top(b);
99 153
100 for (;;) 154 /* 0 <= b <= a */
155 while (!BN_is_zero(b))
101 { 156 {
102 if (BN_is_zero(b)) 157 /* 0 < b <= a */
103 break;
104 158
105 if (BN_is_odd(a)) 159 if (BN_is_odd(a))
106 { 160 {
@@ -133,7 +187,9 @@ static BIGNUM *euclid(BIGNUM *a, BIGNUM *b)
133 shifts++; 187 shifts++;
134 } 188 }
135 } 189 }
190 /* 0 <= b <= a */
136 } 191 }
192
137 if (shifts) 193 if (shifts)
138 { 194 {
139 if (!BN_lshift(a,a,shifts)) goto err; 195 if (!BN_lshift(a,a,shifts)) goto err;
@@ -143,11 +199,13 @@ err:
143 return(NULL); 199 return(NULL);
144 } 200 }
145 201
202
146/* solves ax == 1 (mod n) */ 203/* solves ax == 1 (mod n) */
147BIGNUM *BN_mod_inverse(BIGNUM *in, BIGNUM *a, const BIGNUM *n, BN_CTX *ctx) 204BIGNUM *BN_mod_inverse(BIGNUM *in,
205 const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx)
148 { 206 {
149 BIGNUM *A,*B,*X,*Y,*M,*D,*R=NULL; 207 BIGNUM *A,*B,*X,*Y,*M,*D,*T,*R=NULL;
150 BIGNUM *T,*ret=NULL; 208 BIGNUM *ret=NULL;
151 int sign; 209 int sign;
152 210
153 bn_check_top(a); 211 bn_check_top(a);
@@ -160,7 +218,8 @@ BIGNUM *BN_mod_inverse(BIGNUM *in, BIGNUM *a, const BIGNUM *n, BN_CTX *ctx)
160 D = BN_CTX_get(ctx); 218 D = BN_CTX_get(ctx);
161 M = BN_CTX_get(ctx); 219 M = BN_CTX_get(ctx);
162 Y = BN_CTX_get(ctx); 220 Y = BN_CTX_get(ctx);
163 if (Y == NULL) goto err; 221 T = BN_CTX_get(ctx);
222 if (T == NULL) goto err;
164 223
165 if (in == NULL) 224 if (in == NULL)
166 R=BN_new(); 225 R=BN_new();
@@ -168,34 +227,256 @@ BIGNUM *BN_mod_inverse(BIGNUM *in, BIGNUM *a, const BIGNUM *n, BN_CTX *ctx)
168 R=in; 227 R=in;
169 if (R == NULL) goto err; 228 if (R == NULL) goto err;
170 229
171 BN_zero(X); 230 BN_one(X);
172 BN_one(Y); 231 BN_zero(Y);
173 if (BN_copy(A,a) == NULL) goto err; 232 if (BN_copy(B,a) == NULL) goto err;
174 if (BN_copy(B,n) == NULL) goto err; 233 if (BN_copy(A,n) == NULL) goto err;
175 sign=1; 234 A->neg = 0;
235 if (B->neg || (BN_ucmp(B, A) >= 0))
236 {
237 if (!BN_nnmod(B, B, A, ctx)) goto err;
238 }
239 sign = -1;
240 /* From B = a mod |n|, A = |n| it follows that
241 *
242 * 0 <= B < A,
243 * -sign*X*a == B (mod |n|),
244 * sign*Y*a == A (mod |n|).
245 */
176 246
177 while (!BN_is_zero(B)) 247 if (BN_is_odd(n) && (BN_num_bits(n) <= (BN_BITS <= 32 ? 450 : 2048)))
178 { 248 {
179 if (!BN_div(D,M,A,B,ctx)) goto err; 249 /* Binary inversion algorithm; requires odd modulus.
180 T=A; 250 * This is faster than the general algorithm if the modulus
181 A=B; 251 * is sufficiently small (about 400 .. 500 bits on 32-bit
182 B=M; 252 * sytems, but much more on 64-bit systems) */
183 /* T has a struct, M does not */ 253 int shift;
184 254
185 if (!BN_mul(T,D,X,ctx)) goto err; 255 while (!BN_is_zero(B))
186 if (!BN_add(T,T,Y)) goto err; 256 {
187 M=Y; 257 /*
188 Y=X; 258 * 0 < B < |n|,
189 X=T; 259 * 0 < A <= |n|,
190 sign= -sign; 260 * (1) -sign*X*a == B (mod |n|),
261 * (2) sign*Y*a == A (mod |n|)
262 */
263
264 /* Now divide B by the maximum possible power of two in the integers,
265 * and divide X by the same value mod |n|.
266 * When we're done, (1) still holds. */
267 shift = 0;
268 while (!BN_is_bit_set(B, shift)) /* note that 0 < B */
269 {
270 shift++;
271
272 if (BN_is_odd(X))
273 {
274 if (!BN_uadd(X, X, n)) goto err;
275 }
276 /* now X is even, so we can easily divide it by two */
277 if (!BN_rshift1(X, X)) goto err;
278 }
279 if (shift > 0)
280 {
281 if (!BN_rshift(B, B, shift)) goto err;
282 }
283
284
285 /* Same for A and Y. Afterwards, (2) still holds. */
286 shift = 0;
287 while (!BN_is_bit_set(A, shift)) /* note that 0 < A */
288 {
289 shift++;
290
291 if (BN_is_odd(Y))
292 {
293 if (!BN_uadd(Y, Y, n)) goto err;
294 }
295 /* now Y is even */
296 if (!BN_rshift1(Y, Y)) goto err;
297 }
298 if (shift > 0)
299 {
300 if (!BN_rshift(A, A, shift)) goto err;
301 }
302
303
304 /* We still have (1) and (2).
305 * Both A and B are odd.
306 * The following computations ensure that
307 *
308 * 0 <= B < |n|,
309 * 0 < A < |n|,
310 * (1) -sign*X*a == B (mod |n|),
311 * (2) sign*Y*a == A (mod |n|),
312 *
313 * and that either A or B is even in the next iteration.
314 */
315 if (BN_ucmp(B, A) >= 0)
316 {
317 /* -sign*(X + Y)*a == B - A (mod |n|) */
318 if (!BN_uadd(X, X, Y)) goto err;
319 /* NB: we could use BN_mod_add_quick(X, X, Y, n), but that
320 * actually makes the algorithm slower */
321 if (!BN_usub(B, B, A)) goto err;
322 }
323 else
324 {
325 /* sign*(X + Y)*a == A - B (mod |n|) */
326 if (!BN_uadd(Y, Y, X)) goto err;
327 /* as above, BN_mod_add_quick(Y, Y, X, n) would slow things down */
328 if (!BN_usub(A, A, B)) goto err;
329 }
330 }
331 }
332 else
333 {
334 /* general inversion algorithm */
335
336 while (!BN_is_zero(B))
337 {
338 BIGNUM *tmp;
339
340 /*
341 * 0 < B < A,
342 * (*) -sign*X*a == B (mod |n|),
343 * sign*Y*a == A (mod |n|)
344 */
345
346 /* (D, M) := (A/B, A%B) ... */
347 if (BN_num_bits(A) == BN_num_bits(B))
348 {
349 if (!BN_one(D)) goto err;
350 if (!BN_sub(M,A,B)) goto err;
351 }
352 else if (BN_num_bits(A) == BN_num_bits(B) + 1)
353 {
354 /* A/B is 1, 2, or 3 */
355 if (!BN_lshift1(T,B)) goto err;
356 if (BN_ucmp(A,T) < 0)
357 {
358 /* A < 2*B, so D=1 */
359 if (!BN_one(D)) goto err;
360 if (!BN_sub(M,A,B)) goto err;
361 }
362 else
363 {
364 /* A >= 2*B, so D=2 or D=3 */
365 if (!BN_sub(M,A,T)) goto err;
366 if (!BN_add(D,T,B)) goto err; /* use D (:= 3*B) as temp */
367 if (BN_ucmp(A,D) < 0)
368 {
369 /* A < 3*B, so D=2 */
370 if (!BN_set_word(D,2)) goto err;
371 /* M (= A - 2*B) already has the correct value */
372 }
373 else
374 {
375 /* only D=3 remains */
376 if (!BN_set_word(D,3)) goto err;
377 /* currently M = A - 2*B, but we need M = A - 3*B */
378 if (!BN_sub(M,M,B)) goto err;
379 }
380 }
381 }
382 else
383 {
384 if (!BN_div(D,M,A,B,ctx)) goto err;
385 }
386
387 /* Now
388 * A = D*B + M;
389 * thus we have
390 * (**) sign*Y*a == D*B + M (mod |n|).
391 */
392
393 tmp=A; /* keep the BIGNUM object, the value does not matter */
394
395 /* (A, B) := (B, A mod B) ... */
396 A=B;
397 B=M;
398 /* ... so we have 0 <= B < A again */
399
400 /* Since the former M is now B and the former B is now A,
401 * (**) translates into
402 * sign*Y*a == D*A + B (mod |n|),
403 * i.e.
404 * sign*Y*a - D*A == B (mod |n|).
405 * Similarly, (*) translates into
406 * -sign*X*a == A (mod |n|).
407 *
408 * Thus,
409 * sign*Y*a + D*sign*X*a == B (mod |n|),
410 * i.e.
411 * sign*(Y + D*X)*a == B (mod |n|).
412 *
413 * So if we set (X, Y, sign) := (Y + D*X, X, -sign), we arrive back at
414 * -sign*X*a == B (mod |n|),
415 * sign*Y*a == A (mod |n|).
416 * Note that X and Y stay non-negative all the time.
417 */
418
419 /* most of the time D is very small, so we can optimize tmp := D*X+Y */
420 if (BN_is_one(D))
421 {
422 if (!BN_add(tmp,X,Y)) goto err;
423 }
424 else
425 {
426 if (BN_is_word(D,2))
427 {
428 if (!BN_lshift1(tmp,X)) goto err;
429 }
430 else if (BN_is_word(D,4))
431 {
432 if (!BN_lshift(tmp,X,2)) goto err;
433 }
434 else if (D->top == 1)
435 {
436 if (!BN_copy(tmp,X)) goto err;
437 if (!BN_mul_word(tmp,D->d[0])) goto err;
438 }
439 else
440 {
441 if (!BN_mul(tmp,D,X,ctx)) goto err;
442 }
443 if (!BN_add(tmp,tmp,Y)) goto err;
444 }
445
446 M=Y; /* keep the BIGNUM object, the value does not matter */
447 Y=X;
448 X=tmp;
449 sign = -sign;
450 }
191 } 451 }
452
453 /*
454 * The while loop (Euclid's algorithm) ends when
455 * A == gcd(a,n);
456 * we have
457 * sign*Y*a == A (mod |n|),
458 * where Y is non-negative.
459 */
460
192 if (sign < 0) 461 if (sign < 0)
193 { 462 {
194 if (!BN_sub(Y,n,Y)) goto err; 463 if (!BN_sub(Y,n,Y)) goto err;
195 } 464 }
465 /* Now Y*a == A (mod |n|). */
466
196 467
197 if (BN_is_one(A)) 468 if (BN_is_one(A))
198 { if (!BN_mod(R,Y,n,ctx)) goto err; } 469 {
470 /* Y*a == 1 (mod |n|) */
471 if (!Y->neg && BN_ucmp(Y,n) < 0)
472 {
473 if (!BN_copy(R,Y)) goto err;
474 }
475 else
476 {
477 if (!BN_nnmod(R,Y,n,ctx)) goto err;
478 }
479 }
199 else 480 else
200 { 481 {
201 BNerr(BN_F_BN_MOD_INVERSE,BN_R_NO_INVERSE); 482 BNerr(BN_F_BN_MOD_INVERSE,BN_R_NO_INVERSE);
@@ -207,4 +488,3 @@ err:
207 BN_CTX_end(ctx); 488 BN_CTX_end(ctx);
208 return(ret); 489 return(ret);
209 } 490 }
210
diff --git a/src/lib/libcrypto/bn/bn_kron.c b/src/lib/libcrypto/bn/bn_kron.c
new file mode 100644
index 0000000000..49f75594ae
--- /dev/null
+++ b/src/lib/libcrypto/bn/bn_kron.c
@@ -0,0 +1,182 @@
1/* crypto/bn/bn_kron.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 "bn_lcl.h"
57
58
59/* least significant word */
60#define BN_lsw(n) (((n)->top == 0) ? (BN_ULONG) 0 : (n)->d[0])
61
62/* Returns -2 for errors because both -1 and 0 are valid results. */
63int BN_kronecker(const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
64 {
65 int i;
66 int ret = -2; /* avoid 'uninitialized' warning */
67 int err = 0;
68 BIGNUM *A, *B, *tmp;
69 /* In 'tab', only odd-indexed entries are relevant:
70 * For any odd BIGNUM n,
71 * tab[BN_lsw(n) & 7]
72 * is $(-1)^{(n^2-1)/8}$ (using TeX notation).
73 * Note that the sign of n does not matter.
74 */
75 static const int tab[8] = {0, 1, 0, -1, 0, -1, 0, 1};
76
77 BN_CTX_start(ctx);
78 A = BN_CTX_get(ctx);
79 B = BN_CTX_get(ctx);
80 if (B == NULL) goto end;
81
82 err = !BN_copy(A, a);
83 if (err) goto end;
84 err = !BN_copy(B, b);
85 if (err) goto end;
86
87 /*
88 * Kronecker symbol, imlemented according to Henri Cohen,
89 * "A Course in Computational Algebraic Number Theory"
90 * (algorithm 1.4.10).
91 */
92
93 /* Cohen's step 1: */
94
95 if (BN_is_zero(B))
96 {
97 ret = BN_abs_is_word(A, 1);
98 goto end;
99 }
100
101 /* Cohen's step 2: */
102
103 if (!BN_is_odd(A) && !BN_is_odd(B))
104 {
105 ret = 0;
106 goto end;
107 }
108
109 /* now B is non-zero */
110 i = 0;
111 while (!BN_is_bit_set(B, i))
112 i++;
113 err = !BN_rshift(B, B, i);
114 if (err) goto end;
115 if (i & 1)
116 {
117 /* i is odd */
118 /* (thus B was even, thus A must be odd!) */
119
120 /* set 'ret' to $(-1)^{(A^2-1)/8}$ */
121 ret = tab[BN_lsw(A) & 7];
122 }
123 else
124 {
125 /* i is even */
126 ret = 1;
127 }
128
129 if (B->neg)
130 {
131 B->neg = 0;
132 if (A->neg)
133 ret = -ret;
134 }
135
136 /* now B is positive and odd, so what remains to be done is
137 * to compute the Jacobi symbol (A/B) and multiply it by 'ret' */
138
139 while (1)
140 {
141 /* Cohen's step 3: */
142
143 /* B is positive and odd */
144
145 if (BN_is_zero(A))
146 {
147 ret = BN_is_one(B) ? ret : 0;
148 goto end;
149 }
150
151 /* now A is non-zero */
152 i = 0;
153 while (!BN_is_bit_set(A, i))
154 i++;
155 err = !BN_rshift(A, A, i);
156 if (err) goto end;
157 if (i & 1)
158 {
159 /* i is odd */
160 /* multiply 'ret' by $(-1)^{(B^2-1)/8}$ */
161 ret = ret * tab[BN_lsw(B) & 7];
162 }
163
164 /* Cohen's step 4: */
165 /* multiply 'ret' by $(-1)^{(A-1)(B-1)/4}$ */
166 if ((A->neg ? ~BN_lsw(A) : BN_lsw(A)) & BN_lsw(B) & 2)
167 ret = -ret;
168
169 /* (A, B) := (B mod |A|, |A|) */
170 err = !BN_nnmod(B, B, A, ctx);
171 if (err) goto end;
172 tmp = A; A = B; B = tmp;
173 tmp->neg = 0;
174 }
175
176 end:
177 BN_CTX_end(ctx);
178 if (err)
179 return -2;
180 else
181 return ret;
182 }
diff --git a/src/lib/libcrypto/bn/bn_lcl.h b/src/lib/libcrypto/bn/bn_lcl.h
index 9c959921b4..8a4dba375a 100644
--- a/src/lib/libcrypto/bn/bn_lcl.h
+++ b/src/lib/libcrypto/bn/bn_lcl.h
@@ -119,6 +119,20 @@ extern "C" {
119#endif 119#endif
120 120
121 121
122/* Used for temp variables */
123#define BN_CTX_NUM 32
124#define BN_CTX_NUM_POS 12
125struct bignum_ctx
126 {
127 int tos;
128 BIGNUM bn[BN_CTX_NUM];
129 int flags;
130 int depth;
131 int pos[BN_CTX_NUM_POS];
132 int too_many;
133 } /* BN_CTX */;
134
135
122/* 136/*
123 * BN_window_bits_for_exponent_size -- macro for sliding window mod_exp functions 137 * BN_window_bits_for_exponent_size -- macro for sliding window mod_exp functions
124 * 138 *
@@ -171,7 +185,7 @@ extern "C" {
171#define BN_MUL_LOW_RECURSIVE_SIZE_NORMAL (32) /* 32 */ 185#define BN_MUL_LOW_RECURSIVE_SIZE_NORMAL (32) /* 32 */
172#define BN_MONT_CTX_SET_SIZE_WORD (64) /* 32 */ 186#define BN_MONT_CTX_SET_SIZE_WORD (64) /* 32 */
173 187
174#if !defined(NO_ASM) && !defined(NO_INLINE_ASM) && !defined(PEDANTIC) 188#if !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) && !defined(PEDANTIC)
175/* 189/*
176 * BN_UMULT_HIGH section. 190 * BN_UMULT_HIGH section.
177 * 191 *
@@ -217,7 +231,7 @@ extern "C" {
217 ret; }) 231 ret; })
218# endif /* compiler */ 232# endif /* compiler */
219# endif /* cpu */ 233# endif /* cpu */
220#endif /* NO_ASM */ 234#endif /* OPENSSL_NO_ASM */
221 235
222/************************************************************* 236/*************************************************************
223 * Using the long long type 237 * Using the long long type
@@ -398,19 +412,26 @@ extern "C" {
398void bn_mul_normal(BN_ULONG *r,BN_ULONG *a,int na,BN_ULONG *b,int nb); 412void bn_mul_normal(BN_ULONG *r,BN_ULONG *a,int na,BN_ULONG *b,int nb);
399void bn_mul_comba8(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b); 413void bn_mul_comba8(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b);
400void bn_mul_comba4(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b); 414void bn_mul_comba4(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b);
401void bn_sqr_normal(BN_ULONG *r, BN_ULONG *a, int n, BN_ULONG *tmp); 415void bn_sqr_normal(BN_ULONG *r, const BN_ULONG *a, int n, BN_ULONG *tmp);
402void bn_sqr_comba8(BN_ULONG *r,BN_ULONG *a); 416void bn_sqr_comba8(BN_ULONG *r,const BN_ULONG *a);
403void bn_sqr_comba4(BN_ULONG *r,BN_ULONG *a); 417void bn_sqr_comba4(BN_ULONG *r,const BN_ULONG *a);
404int bn_cmp_words(BN_ULONG *a,BN_ULONG *b,int n); 418int bn_cmp_words(const BN_ULONG *a,const BN_ULONG *b,int n);
405void bn_mul_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,int n2,BN_ULONG *t); 419int bn_cmp_part_words(const BN_ULONG *a, const BN_ULONG *b,
420 int cl, int dl);
421void bn_mul_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,int n2,
422 int dna,int dnb,BN_ULONG *t);
406void 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,
407 int tn, int n,BN_ULONG *t); 424 int n,int tna,int tnb,BN_ULONG *t);
408void bn_sqr_recursive(BN_ULONG *r,BN_ULONG *a, int n2, BN_ULONG *t); 425void bn_sqr_recursive(BN_ULONG *r,const BN_ULONG *a, int n2, BN_ULONG *t);
409void 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);
410void 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,
411 BN_ULONG *t); 428 BN_ULONG *t);
412void 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,
413 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);
414 435
415#ifdef __cplusplus 436#ifdef __cplusplus
416} 437}
diff --git a/src/lib/libcrypto/bn/bn_lib.c b/src/lib/libcrypto/bn/bn_lib.c
index 7767d65170..a016cb7f53 100644
--- a/src/lib/libcrypto/bn/bn_lib.c
+++ b/src/lib/libcrypto/bn/bn_lib.c
@@ -128,7 +128,7 @@ int BN_get_params(int which)
128 else return(0); 128 else return(0);
129 } 129 }
130 130
131BIGNUM *BN_value_one(void) 131const BIGNUM *BN_value_one(void)
132 { 132 {
133 static BN_ULONG data_one=1L; 133 static BN_ULONG data_one=1L;
134 static BIGNUM const_one={&data_one,1,1,0}; 134 static BIGNUM const_one={&data_one,1,1,0};
@@ -305,172 +305,168 @@ BIGNUM *BN_new(void)
305 return(ret); 305 return(ret);
306 } 306 }
307 307
308/* This is an internal function that should not be used in applications. 308/* This is used both by bn_expand2() and bn_dup_expand() */
309 * It ensures that 'b' has enough room for a 'words' word number number. 309/* The caller MUST check that words > b->dmax before calling this */
310 * It is mostly used by the various BIGNUM routines. If there is an error, 310static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
311 * NULL is returned. If not, 'b' is returned. */
312
313BIGNUM *bn_expand2(BIGNUM *b, int words)
314 { 311 {
315 BN_ULONG *A,*a; 312 BN_ULONG *A,*a = NULL;
316 const BN_ULONG *B; 313 const BN_ULONG *B;
317 int i; 314 int i;
318 315
319 bn_check_top(b); 316 if (words > (INT_MAX/(4*BN_BITS2)))
317 {
318 BNerr(BN_F_BN_EXPAND_INTERNAL,BN_R_BIGNUM_TOO_LONG);
319 return NULL;
320 }
320 321
321 if (words > b->dmax) 322 bn_check_top(b);
323 if (BN_get_flags(b,BN_FLG_STATIC_DATA))
322 { 324 {
323 if (words > (INT_MAX/(4*BN_BITS2))) 325 BNerr(BN_F_BN_EXPAND_INTERNAL,BN_R_EXPAND_ON_STATIC_BIGNUM_DATA);
324 { 326 return(NULL);
325 BNerr(BN_F_BN_EXPAND2,BN_R_BIGNUM_TOO_LONG); 327 }
326 return NULL; 328 a=A=(BN_ULONG *)OPENSSL_malloc(sizeof(BN_ULONG)*(words+1));
327 } 329 if (A == NULL)
328 330 {
329 bn_check_top(b); 331 BNerr(BN_F_BN_EXPAND_INTERNAL,ERR_R_MALLOC_FAILURE);
330 if (BN_get_flags(b,BN_FLG_STATIC_DATA)) 332 return(NULL);
333 }
334#if 1
335 B=b->d;
336 /* Check if the previous number needs to be copied */
337 if (B != NULL)
338 {
339 for (i=b->top>>2; i>0; i--,A+=4,B+=4)
331 { 340 {
332 BNerr(BN_F_BN_EXPAND2,BN_R_EXPAND_ON_STATIC_BIGNUM_DATA); 341 /*
333 return(NULL); 342 * The fact that the loop is unrolled
343 * 4-wise is a tribute to Intel. It's
344 * the one that doesn't have enough
345 * registers to accomodate more data.
346 * I'd unroll it 8-wise otherwise:-)
347 *
348 * <appro@fy.chalmers.se>
349 */
350 BN_ULONG a0,a1,a2,a3;
351 a0=B[0]; a1=B[1]; a2=B[2]; a3=B[3];
352 A[0]=a0; A[1]=a1; A[2]=a2; A[3]=a3;
334 } 353 }
335 a=A=(BN_ULONG *)OPENSSL_malloc(sizeof(BN_ULONG)*(words+1)); 354 switch (b->top&3)
336 if (A == NULL)
337 { 355 {
338 BNerr(BN_F_BN_EXPAND2,ERR_R_MALLOC_FAILURE); 356 case 3: A[2]=B[2];
339 return(NULL); 357 case 2: A[1]=B[1];
358 case 1: A[0]=B[0];
359 case 0: /* workaround for ultrix cc: without 'case 0', the optimizer does
360 * the switch table by doing a=top&3; a--; goto jump_table[a];
361 * which fails for top== 0 */
362 ;
340 } 363 }
341#if 1 364 }
342 B=b->d; 365
343 /* Check if the previous number needs to be copied */ 366 /* Now need to zero any data between b->top and b->max */
344 if (B != NULL) 367 /* XXX Why? */
345 { 368
346#if 0 369 A= &(a[b->top]);
347 /* This lot is an unrolled loop to copy b->top 370 for (i=(words - b->top)>>3; i>0; i--,A+=8)
348 * BN_ULONGs from B to A 371 {
349 */ 372 A[0]=0; A[1]=0; A[2]=0; A[3]=0;
350/* 373 A[4]=0; A[5]=0; A[6]=0; A[7]=0;
351 * I have nothing against unrolling but it's usually done for 374 }
352 * several reasons, namely: 375 for (i=(words - b->top)&7; i>0; i--,A++)
353 * - minimize percentage of decision making code, i.e. branches; 376 A[0]=0;
354 * - avoid cache trashing;
355 * - make it possible to schedule loads earlier;
356 * Now let's examine the code below. The cornerstone of C is
357 * "programmer is always right" and that's what we love it for:-)
358 * For this very reason C compilers have to be paranoid when it
359 * comes to data aliasing and assume the worst. Yeah, but what
360 * does it mean in real life? This means that loop body below will
361 * be compiled to sequence of loads immediately followed by stores
362 * as compiler assumes the worst, something in A==B+1 style. As a
363 * result CPU pipeline is going to starve for incoming data. Secondly
364 * if A and B happen to share same cache line such code is going to
365 * cause severe cache trashing. Both factors have severe impact on
366 * performance of modern CPUs and this is the reason why this
367 * particular piece of code is #ifdefed away and replaced by more
368 * "friendly" version found in #else section below. This comment
369 * also applies to BN_copy function.
370 *
371 * <appro@fy.chalmers.se>
372 */
373 for (i=b->top&(~7); i>0; i-=8)
374 {
375 A[0]=B[0]; A[1]=B[1]; A[2]=B[2]; A[3]=B[3];
376 A[4]=B[4]; A[5]=B[5]; A[6]=B[6]; A[7]=B[7];
377 A+=8;
378 B+=8;
379 }
380 switch (b->top&7)
381 {
382 case 7:
383 A[6]=B[6];
384 case 6:
385 A[5]=B[5];
386 case 5:
387 A[4]=B[4];
388 case 4:
389 A[3]=B[3];
390 case 3:
391 A[2]=B[2];
392 case 2:
393 A[1]=B[1];
394 case 1:
395 A[0]=B[0];
396 case 0:
397 /* I need the 'case 0' entry for utrix cc.
398 * If the optimizer is turned on, it does the
399 * switch table by doing
400 * a=top&7
401 * a--;
402 * goto jump_table[a];
403 * If top is 0, this makes us jump to 0xffffffc
404 * which is rather bad :-(.
405 * eric 23-Apr-1998
406 */
407 ;
408 }
409#else 377#else
410 for (i=b->top>>2; i>0; i--,A+=4,B+=4) 378 memset(A,0,sizeof(BN_ULONG)*(words+1));
379 memcpy(A,b->d,sizeof(b->d[0])*b->top);
380#endif
381
382 return(a);
383 }
384
385/* This is an internal function that can be used instead of bn_expand2()
386 * when there is a need to copy BIGNUMs instead of only expanding the
387 * data part, while still expanding them.
388 * Especially useful when needing to expand BIGNUMs that are declared
389 * 'const' and should therefore not be changed.
390 * The reason to use this instead of a BN_dup() followed by a bn_expand2()
391 * is memory allocation overhead. A BN_dup() followed by a bn_expand2()
392 * will allocate new memory for the BIGNUM data twice, and free it once,
393 * while bn_dup_expand() makes sure allocation is made only once.
394 */
395
396BIGNUM *bn_dup_expand(const BIGNUM *b, int words)
397 {
398 BIGNUM *r = NULL;
399
400 if (words > b->dmax)
401 {
402 BN_ULONG *a = bn_expand_internal(b, words);
403
404 if (a)
405 {
406 r = BN_new();
407 if (r)
411 { 408 {
412 /* 409 r->top = b->top;
413 * The fact that the loop is unrolled 410 r->dmax = words;
414 * 4-wise is a tribute to Intel. It's 411 r->neg = b->neg;
415 * the one that doesn't have enough 412 r->d = a;
416 * registers to accomodate more data.
417 * I'd unroll it 8-wise otherwise:-)
418 *
419 * <appro@fy.chalmers.se>
420 */
421 BN_ULONG a0,a1,a2,a3;
422 a0=B[0]; a1=B[1]; a2=B[2]; a3=B[3];
423 A[0]=a0; A[1]=a1; A[2]=a2; A[3]=a3;
424 } 413 }
425 switch (b->top&3) 414 else
426 { 415 {
427 case 3: A[2]=B[2]; 416 /* r == NULL, BN_new failure */
428 case 2: A[1]=B[1]; 417 OPENSSL_free(a);
429 case 1: A[0]=B[0];
430 case 0: ; /* ultrix cc workaround, see above */
431 } 418 }
432#endif
433 OPENSSL_free(b->d);
434 } 419 }
420 /* If a == NULL, there was an error in allocation in
421 bn_expand_internal(), and NULL should be returned */
422 }
423 else
424 {
425 r = BN_dup(b);
426 }
435 427
436 b->d=a; 428 return r;
437 b->dmax=words; 429 }
430
431/* This is an internal function that should not be used in applications.
432 * It ensures that 'b' has enough room for a 'words' word number number.
433 * It is mostly used by the various BIGNUM routines. If there is an error,
434 * NULL is returned. If not, 'b' is returned. */
438 435
439 /* Now need to zero any data between b->top and b->max */ 436BIGNUM *bn_expand2(BIGNUM *b, int words)
437 {
438 if (words > b->dmax)
439 {
440 BN_ULONG *a = bn_expand_internal(b, words);
440 441
441 A= &(b->d[b->top]); 442 if (a)
442 for (i=(b->dmax - b->top)>>3; i>0; i--,A+=8)
443 { 443 {
444 A[0]=0; A[1]=0; A[2]=0; A[3]=0; 444 if (b->d)
445 A[4]=0; A[5]=0; A[6]=0; A[7]=0; 445 OPENSSL_free(b->d);
446 }
447 for (i=(b->dmax - b->top)&7; i>0; i--,A++)
448 A[0]=0;
449#else
450 memset(A,0,sizeof(BN_ULONG)*(words+1));
451 memcpy(A,b->d,sizeof(b->d[0])*b->top);
452 b->d=a; 446 b->d=a;
453 b->max=words; 447 b->dmax=words;
454#endif 448 }
455 449 else
456/* memset(&(p[b->max]),0,((words+1)-b->max)*sizeof(BN_ULONG)); */ 450 b = NULL;
457/* { int i; for (i=b->max; i<words+1; i++) p[i]=i;} */
458
459 } 451 }
460 return(b); 452 return b;
461 } 453 }
462 454
463BIGNUM *BN_dup(const BIGNUM *a) 455BIGNUM *BN_dup(const BIGNUM *a)
464 { 456 {
465 BIGNUM *r; 457 BIGNUM *r, *t;
466 458
467 if (a == NULL) return NULL; 459 if (a == NULL) return NULL;
468 460
469 bn_check_top(a); 461 bn_check_top(a);
470 462
471 r=BN_new(); 463 t = BN_new();
472 if (r == NULL) return(NULL); 464 if (t == NULL) return(NULL);
473 return((BIGNUM *)BN_copy(r,a)); 465 r = BN_copy(t, a);
466 /* now r == t || r == NULL */
467 if (r == NULL)
468 BN_free(t);
469 return r;
474 } 470 }
475 471
476BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b) 472BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)
@@ -498,7 +494,7 @@ BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)
498 case 3: A[2]=B[2]; 494 case 3: A[2]=B[2];
499 case 2: A[1]=B[1]; 495 case 2: A[1]=B[1];
500 case 1: A[0]=B[0]; 496 case 1: A[0]=B[0];
501 case 0: ; /* ultrix cc workaround, see comments in bn_expand2 */ 497 case 0: ; /* ultrix cc workaround, see comments in bn_expand_internal */
502 } 498 }
503#else 499#else
504 memcpy(a->d,b->d,sizeof(b->d[0])*b->top); 500 memcpy(a->d,b->d,sizeof(b->d[0])*b->top);
@@ -512,6 +508,35 @@ BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)
512 return(a); 508 return(a);
513 } 509 }
514 510
511void BN_swap(BIGNUM *a, BIGNUM *b)
512 {
513 int flags_old_a, flags_old_b;
514 BN_ULONG *tmp_d;
515 int tmp_top, tmp_dmax, tmp_neg;
516
517 flags_old_a = a->flags;
518 flags_old_b = b->flags;
519
520 tmp_d = a->d;
521 tmp_top = a->top;
522 tmp_dmax = a->dmax;
523 tmp_neg = a->neg;
524
525 a->d = b->d;
526 a->top = b->top;
527 a->dmax = b->dmax;
528 a->neg = b->neg;
529
530 b->d = tmp_d;
531 b->top = tmp_top;
532 b->dmax = tmp_dmax;
533 b->neg = tmp_neg;
534
535 a->flags = (flags_old_a & BN_FLG_MALLOCED) | (flags_old_b & BN_FLG_STATIC_DATA);
536 b->flags = (flags_old_b & BN_FLG_MALLOCED) | (flags_old_a & BN_FLG_STATIC_DATA);
537 }
538
539
515void BN_clear(BIGNUM *a) 540void BN_clear(BIGNUM *a)
516 { 541 {
517 if (a->d != NULL) 542 if (a->d != NULL)
@@ -520,7 +545,7 @@ void BN_clear(BIGNUM *a)
520 a->neg=0; 545 a->neg=0;
521 } 546 }
522 547
523BN_ULONG BN_get_word(BIGNUM *a) 548BN_ULONG BN_get_word(const BIGNUM *a)
524 { 549 {
525 int i,n; 550 int i,n;
526 BN_ULONG ret=0; 551 BN_ULONG ret=0;
@@ -568,7 +593,6 @@ int BN_set_word(BIGNUM *a, BN_ULONG w)
568 return(1); 593 return(1);
569 } 594 }
570 595
571/* ignore negative */
572BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret) 596BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret)
573 { 597 {
574 unsigned int i,m; 598 unsigned int i,m;
@@ -589,6 +613,7 @@ BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret)
589 i=((n-1)/BN_BYTES)+1; 613 i=((n-1)/BN_BYTES)+1;
590 m=((n-1)%(BN_BYTES)); 614 m=((n-1)%(BN_BYTES));
591 ret->top=i; 615 ret->top=i;
616 ret->neg=0;
592 while (n-- > 0) 617 while (n-- > 0)
593 { 618 {
594 l=(l<<8L)| *(s++); 619 l=(l<<8L)| *(s++);
@@ -743,7 +768,7 @@ int BN_mask_bits(BIGNUM *a, int n)
743 return(1); 768 return(1);
744 } 769 }
745 770
746int bn_cmp_words(BN_ULONG *a, BN_ULONG *b, int n) 771int bn_cmp_words(const BN_ULONG *a, const BN_ULONG *b, int n)
747 { 772 {
748 int i; 773 int i;
749 BN_ULONG aa,bb; 774 BN_ULONG aa,bb;
@@ -760,3 +785,34 @@ int bn_cmp_words(BN_ULONG *a, BN_ULONG *b, int n)
760 return(0); 785 return(0);
761 } 786 }
762 787
788/* Here follows a specialised variants of bn_cmp_words(). It has the
789 property of performing the operation on arrays of different sizes.
790 The sizes of those arrays is expressed through cl, which is the
791 common length ( basicall, min(len(a),len(b)) ), and dl, which is the
792 delta between the two lengths, calculated as len(a)-len(b).
793 All lengths are the number of BN_ULONGs... */
794
795int bn_cmp_part_words(const BN_ULONG *a, const BN_ULONG *b,
796 int cl, int dl)
797 {
798 int n,i;
799 n = cl-1;
800
801 if (dl < 0)
802 {
803 for (i=dl; i<0; i++)
804 {
805 if (b[n-i] != 0)
806 return -1; /* a < b */
807 }
808 }
809 if (dl > 0)
810 {
811 for (i=dl; i>0; i--)
812 {
813 if (a[n+i] != 0)
814 return 1; /* a > b */
815 }
816 }
817 return bn_cmp_words(a,b,cl);
818 }
diff --git a/src/lib/libcrypto/bn/bn_mod.c b/src/lib/libcrypto/bn/bn_mod.c
new file mode 100644
index 0000000000..5cf82480d7
--- /dev/null
+++ b/src/lib/libcrypto/bn/bn_mod.c
@@ -0,0 +1,296 @@
1/* crypto/bn/bn_mod.c */
2/* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de>
3 * for the OpenSSL project. */
4/* ====================================================================
5 * Copyright (c) 1998-2000 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 * openssl-core@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/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
58 * All rights reserved.
59 *
60 * This package is an SSL implementation written
61 * by Eric Young (eay@cryptsoft.com).
62 * The implementation was written so as to conform with Netscapes SSL.
63 *
64 * This library is free for commercial and non-commercial use as long as
65 * the following conditions are aheared to. The following conditions
66 * apply to all code found in this distribution, be it the RC4, RSA,
67 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
68 * included with this distribution is covered by the same copyright terms
69 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
70 *
71 * Copyright remains Eric Young's, and as such any Copyright notices in
72 * the code are not to be removed.
73 * If this package is used in a product, Eric Young should be given attribution
74 * as the author of the parts of the library used.
75 * This can be in the form of a textual message at program startup or
76 * in documentation (online or textual) provided with the package.
77 *
78 * Redistribution and use in source and binary forms, with or without
79 * modification, are permitted provided that the following conditions
80 * are met:
81 * 1. Redistributions of source code must retain the copyright
82 * notice, this list of conditions and the following disclaimer.
83 * 2. Redistributions in binary form must reproduce the above copyright
84 * notice, this list of conditions and the following disclaimer in the
85 * documentation and/or other materials provided with the distribution.
86 * 3. All advertising materials mentioning features or use of this software
87 * must display the following acknowledgement:
88 * "This product includes cryptographic software written by
89 * Eric Young (eay@cryptsoft.com)"
90 * The word 'cryptographic' can be left out if the rouines from the library
91 * being used are not cryptographic related :-).
92 * 4. If you include any Windows specific code (or a derivative thereof) from
93 * the apps directory (application code) you must include an acknowledgement:
94 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
95 *
96 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
97 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
98 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
99 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
100 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
101 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
102 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
103 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
104 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
105 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
106 * SUCH DAMAGE.
107 *
108 * The licence and distribution terms for any publically available version or
109 * derivative of this code cannot be changed. i.e. this code cannot simply be
110 * copied and put under another distribution licence
111 * [including the GNU Public Licence.]
112 */
113
114#include "cryptlib.h"
115#include "bn_lcl.h"
116
117
118#if 0 /* now just a #define */
119int BN_mod(BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx)
120 {
121 return(BN_div(NULL,rem,m,d,ctx));
122 /* note that rem->neg == m->neg (unless the remainder is zero) */
123 }
124#endif
125
126
127int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx)
128 {
129 /* like BN_mod, but returns non-negative remainder
130 * (i.e., 0 <= r < |d| always holds) */
131
132 if (!(BN_mod(r,m,d,ctx)))
133 return 0;
134 if (!r->neg)
135 return 1;
136 /* now -|d| < r < 0, so we have to set r := r + |d| */
137 return (d->neg ? BN_sub : BN_add)(r, r, d);
138}
139
140
141int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx)
142 {
143 if (!BN_add(r, a, b)) return 0;
144 return BN_nnmod(r, r, m, ctx);
145 }
146
147
148/* BN_mod_add variant that may be used if both a and b are non-negative
149 * and less than m */
150int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m)
151 {
152 if (!BN_add(r, a, b)) return 0;
153 if (BN_ucmp(r, m) >= 0)
154 return BN_usub(r, r, m);
155 return 1;
156 }
157
158
159int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx)
160 {
161 if (!BN_sub(r, a, b)) return 0;
162 return BN_nnmod(r, r, m, ctx);
163 }
164
165
166/* BN_mod_sub variant that may be used if both a and b are non-negative
167 * and less than m */
168int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m)
169 {
170 if (!BN_sub(r, a, b)) return 0;
171 if (r->neg)
172 return BN_add(r, r, m);
173 return 1;
174 }
175
176
177/* slow but works */
178int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,
179 BN_CTX *ctx)
180 {
181 BIGNUM *t;
182 int ret=0;
183
184 bn_check_top(a);
185 bn_check_top(b);
186 bn_check_top(m);
187
188 BN_CTX_start(ctx);
189 if ((t = BN_CTX_get(ctx)) == NULL) goto err;
190 if (a == b)
191 { if (!BN_sqr(t,a,ctx)) goto err; }
192 else
193 { if (!BN_mul(t,a,b,ctx)) goto err; }
194 if (!BN_nnmod(r,t,m,ctx)) goto err;
195 ret=1;
196err:
197 BN_CTX_end(ctx);
198 return(ret);
199 }
200
201
202int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx)
203 {
204 if (!BN_sqr(r, a, ctx)) return 0;
205 /* r->neg == 0, thus we don't need BN_nnmod */
206 return BN_mod(r, r, m, ctx);
207 }
208
209
210int BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx)
211 {
212 if (!BN_lshift1(r, a)) return 0;
213 return BN_nnmod(r, r, m, ctx);
214 }
215
216
217/* BN_mod_lshift1 variant that may be used if a is non-negative
218 * and less than m */
219int BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m)
220 {
221 if (!BN_lshift1(r, a)) return 0;
222 if (BN_cmp(r, m) >= 0)
223 return BN_sub(r, r, m);
224 return 1;
225 }
226
227
228int BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m, BN_CTX *ctx)
229 {
230 BIGNUM *abs_m = NULL;
231 int ret;
232
233 if (!BN_nnmod(r, a, m, ctx)) return 0;
234
235 if (m->neg)
236 {
237 abs_m = BN_dup(m);
238 if (abs_m == NULL) return 0;
239 abs_m->neg = 0;
240 }
241
242 ret = BN_mod_lshift_quick(r, r, n, (abs_m ? abs_m : m));
243
244 if (abs_m)
245 BN_free(abs_m);
246 return ret;
247 }
248
249
250/* BN_mod_lshift variant that may be used if a is non-negative
251 * and less than m */
252int BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m)
253 {
254 if (r != a)
255 {
256 if (BN_copy(r, a) == NULL) return 0;
257 }
258
259 while (n > 0)
260 {
261 int max_shift;
262
263 /* 0 < r < m */
264 max_shift = BN_num_bits(m) - BN_num_bits(r);
265 /* max_shift >= 0 */
266
267 if (max_shift < 0)
268 {
269 BNerr(BN_F_BN_MOD_LSHIFT_QUICK, BN_R_INPUT_NOT_REDUCED);
270 return 0;
271 }
272
273 if (max_shift > n)
274 max_shift = n;
275
276 if (max_shift)
277 {
278 if (!BN_lshift(r, r, max_shift)) return 0;
279 n -= max_shift;
280 }
281 else
282 {
283 if (!BN_lshift1(r, r)) return 0;
284 --n;
285 }
286
287 /* BN_num_bits(r) <= BN_num_bits(m) */
288
289 if (BN_cmp(r, m) >= 0)
290 {
291 if (!BN_sub(r, r, m)) return 0;
292 }
293 }
294
295 return 1;
296 }
diff --git a/src/lib/libcrypto/bn/bn_mont.c b/src/lib/libcrypto/bn/bn_mont.c
index 8cf1febacc..82942a4759 100644
--- a/src/lib/libcrypto/bn/bn_mont.c
+++ b/src/lib/libcrypto/bn/bn_mont.c
@@ -69,20 +69,17 @@
69 69
70#define MONT_WORD /* use the faster word-based algorithm */ 70#define MONT_WORD /* use the faster word-based algorithm */
71 71
72int BN_mod_mul_montgomery(BIGNUM *r, BIGNUM *a, BIGNUM *b, 72int BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
73 BN_MONT_CTX *mont, BN_CTX *ctx) 73 BN_MONT_CTX *mont, BN_CTX *ctx)
74 { 74 {
75 BIGNUM *tmp,*tmp2; 75 BIGNUM *tmp;
76 int ret=0; 76 int ret=0;
77 77
78 BN_CTX_start(ctx); 78 BN_CTX_start(ctx);
79 tmp = BN_CTX_get(ctx); 79 tmp = BN_CTX_get(ctx);
80 tmp2 = BN_CTX_get(ctx); 80 if (tmp == NULL) goto err;
81 if (tmp == NULL || tmp2 == NULL) goto err;
82 81
83 bn_check_top(tmp); 82 bn_check_top(tmp);
84 bn_check_top(tmp2);
85
86 if (a == b) 83 if (a == b)
87 { 84 {
88 if (!BN_sqr(tmp,a,ctx)) goto err; 85 if (!BN_sqr(tmp,a,ctx)) goto err;
@@ -99,7 +96,7 @@ err:
99 return(ret); 96 return(ret);
100 } 97 }
101 98
102int BN_from_montgomery(BIGNUM *ret, BIGNUM *a, BN_MONT_CTX *mont, 99int BN_from_montgomery(BIGNUM *ret, const BIGNUM *a, BN_MONT_CTX *mont,
103 BN_CTX *ctx) 100 BN_CTX *ctx)
104 { 101 {
105 int retn=0; 102 int retn=0;
@@ -144,7 +141,7 @@ int BN_from_montgomery(BIGNUM *ret, BIGNUM *a, BN_MONT_CTX *mont,
144 n0=mont->n0; 141 n0=mont->n0;
145 142
146#ifdef BN_COUNT 143#ifdef BN_COUNT
147 printf("word BN_from_montgomery %d * %d\n",nl,nl); 144 fprintf(stderr,"word BN_from_montgomery %d * %d\n",nl,nl);
148#endif 145#endif
149 for (i=0; i<nl; i++) 146 for (i=0; i<nl; i++)
150 { 147 {
@@ -229,7 +226,7 @@ int BN_from_montgomery(BIGNUM *ret, BIGNUM *a, BN_MONT_CTX *mont,
229 226
230 if (BN_ucmp(ret, &(mont->N)) >= 0) 227 if (BN_ucmp(ret, &(mont->N)) >= 0)
231 { 228 {
232 BN_usub(ret,ret,&(mont->N)); 229 if (!BN_usub(ret,ret,&(mont->N))) goto err;
233 } 230 }
234 retn=1; 231 retn=1;
235 err: 232 err:
@@ -277,6 +274,7 @@ int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)
277 BN_init(&Ri); 274 BN_init(&Ri);
278 R= &(mont->RR); /* grab RR as a temp */ 275 R= &(mont->RR); /* grab RR as a temp */
279 BN_copy(&(mont->N),mod); /* Set N */ 276 BN_copy(&(mont->N),mod); /* Set N */
277 mont->N.neg = 0;
280 278
281#ifdef MONT_WORD 279#ifdef MONT_WORD
282 { 280 {
@@ -292,40 +290,45 @@ int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)
292 tmod.d=buf; 290 tmod.d=buf;
293 tmod.top=1; 291 tmod.top=1;
294 tmod.dmax=2; 292 tmod.dmax=2;
295 tmod.neg=mod->neg; 293 tmod.neg=0;
296 /* Ri = R^-1 mod N*/ 294 /* Ri = R^-1 mod N*/
297 if ((BN_mod_inverse(&Ri,R,&tmod,ctx)) == NULL) 295 if ((BN_mod_inverse(&Ri,R,&tmod,ctx)) == NULL)
298 goto err; 296 goto err;
299 BN_lshift(&Ri,&Ri,BN_BITS2); /* R*Ri */ 297 if (!BN_lshift(&Ri,&Ri,BN_BITS2)) goto err; /* R*Ri */
300 if (!BN_is_zero(&Ri)) 298 if (!BN_is_zero(&Ri))
301 BN_sub_word(&Ri,1); 299 {
300 if (!BN_sub_word(&Ri,1)) goto err;
301 }
302 else /* if N mod word size == 1 */ 302 else /* if N mod word size == 1 */
303 BN_set_word(&Ri,BN_MASK2); /* Ri-- (mod word size) */ 303 {
304 BN_div(&Ri,NULL,&Ri,&tmod,ctx); /* Ni = (R*Ri-1)/N, 304 if (!BN_set_word(&Ri,BN_MASK2)) goto err; /* Ri-- (mod word size) */
305 * keep only least significant word: */ 305 }
306 mont->n0=Ri.d[0]; 306 if (!BN_div(&Ri,NULL,&Ri,&tmod,ctx)) goto err;
307 /* Ni = (R*Ri-1)/N,
308 * keep only least significant word: */
309 mont->n0 = (Ri.top > 0) ? Ri.d[0] : 0;
307 BN_free(&Ri); 310 BN_free(&Ri);
308 } 311 }
309#else /* !MONT_WORD */ 312#else /* !MONT_WORD */
310 { /* bignum version */ 313 { /* bignum version */
311 mont->ri=BN_num_bits(mod); 314 mont->ri=BN_num_bits(&mont->N);
312 BN_zero(R); 315 if (!BN_zero(R)) goto err;
313 BN_set_bit(R,mont->ri); /* R = 2^ri */ 316 if (!BN_set_bit(R,mont->ri)) goto err; /* R = 2^ri */
314 /* Ri = R^-1 mod N*/ 317 /* Ri = R^-1 mod N*/
315 if ((BN_mod_inverse(&Ri,R,mod,ctx)) == NULL) 318 if ((BN_mod_inverse(&Ri,R,&mont->N,ctx)) == NULL)
316 goto err; 319 goto err;
317 BN_lshift(&Ri,&Ri,mont->ri); /* R*Ri */ 320 if (!BN_lshift(&Ri,&Ri,mont->ri)) goto err; /* R*Ri */
318 BN_sub_word(&Ri,1); 321 if (!BN_sub_word(&Ri,1)) goto err;
319 /* Ni = (R*Ri-1) / N */ 322 /* Ni = (R*Ri-1) / N */
320 BN_div(&(mont->Ni),NULL,&Ri,mod,ctx); 323 if (!BN_div(&(mont->Ni),NULL,&Ri,&mont->N,ctx)) goto err;
321 BN_free(&Ri); 324 BN_free(&Ri);
322 } 325 }
323#endif 326#endif
324 327
325 /* setup RR for conversions */ 328 /* setup RR for conversions */
326 BN_zero(&(mont->RR)); 329 if (!BN_zero(&(mont->RR))) goto err;
327 BN_set_bit(&(mont->RR),mont->ri*2); 330 if (!BN_set_bit(&(mont->RR),mont->ri*2)) goto err;
328 BN_mod(&(mont->RR),&(mont->RR),&(mont->N),ctx); 331 if (!BN_mod(&(mont->RR),&(mont->RR),&(mont->N),ctx)) goto err;
329 332
330 return(1); 333 return(1);
331err: 334err:
@@ -336,9 +339,9 @@ BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from)
336 { 339 {
337 if (to == from) return(to); 340 if (to == from) return(to);
338 341
339 BN_copy(&(to->RR),&(from->RR)); 342 if (!BN_copy(&(to->RR),&(from->RR))) return NULL;
340 BN_copy(&(to->N),&(from->N)); 343 if (!BN_copy(&(to->N),&(from->N))) return NULL;
341 BN_copy(&(to->Ni),&(from->Ni)); 344 if (!BN_copy(&(to->Ni),&(from->Ni))) return NULL;
342 to->ri=from->ri; 345 to->ri=from->ri;
343 to->n0=from->n0; 346 to->n0=from->n0;
344 return(to); 347 return(to);
diff --git a/src/lib/libcrypto/bn/bn_mpi.c b/src/lib/libcrypto/bn/bn_mpi.c
index 80e1dca6b7..05fa9d1e9a 100644
--- a/src/lib/libcrypto/bn/bn_mpi.c
+++ b/src/lib/libcrypto/bn/bn_mpi.c
@@ -88,7 +88,7 @@ int BN_bn2mpi(const BIGNUM *a, unsigned char *d)
88 return(num+4+ext); 88 return(num+4+ext);
89 } 89 }
90 90
91BIGNUM *BN_mpi2bn(unsigned char *d, int n, BIGNUM *a) 91BIGNUM *BN_mpi2bn(const unsigned char *d, int n, BIGNUM *a)
92 { 92 {
93 long len; 93 long len;
94 int neg=0; 94 int neg=0;
diff --git a/src/lib/libcrypto/bn/bn_mul.c b/src/lib/libcrypto/bn/bn_mul.c
index 3e8d8b9567..41ea925b8d 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__))/* 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
@@ -105,21 +421,21 @@ void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
105 return; 421 return;
106 } 422 }
107 /* r=(a[0]-a[1])*(b[1]-b[0]) */ 423 /* r=(a[0]-a[1])*(b[1]-b[0]) */
108 c1=bn_cmp_words(a,&(a[n]),n); 424 c1=bn_cmp_part_words(a,&(a[n]),tna,n-tna);
109 c2=bn_cmp_words(&(b[n]),b,n); 425 c2=bn_cmp_part_words(&(b[n]),b,tnb,tnb-n);
110 zero=neg=0; 426 zero=neg=0;
111 switch (c1*3+c2) 427 switch (c1*3+c2)
112 { 428 {
113 case -4: 429 case -4:
114 bn_sub_words(t, &(a[n]),a, n); /* - */ 430 bn_sub_part_words(t, &(a[n]),a, tna,tna-n); /* - */
115 bn_sub_words(&(t[n]),b, &(b[n]),n); /* - */ 431 bn_sub_part_words(&(t[n]),b, &(b[n]),tnb,n-tnb); /* - */
116 break; 432 break;
117 case -3: 433 case -3:
118 zero=1; 434 zero=1;
119 break; 435 break;
120 case -2: 436 case -2:
121 bn_sub_words(t, &(a[n]),a, n); /* - */ 437 bn_sub_part_words(t, &(a[n]),a, tna,tna-n); /* - */
122 bn_sub_words(&(t[n]),&(b[n]),b, n); /* + */ 438 bn_sub_part_words(&(t[n]),&(b[n]),b, tnb,tnb-n); /* + */
123 neg=1; 439 neg=1;
124 break; 440 break;
125 case -1: 441 case -1:
@@ -128,21 +444,22 @@ void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
128 zero=1; 444 zero=1;
129 break; 445 break;
130 case 2: 446 case 2:
131 bn_sub_words(t, a, &(a[n]),n); /* + */ 447 bn_sub_part_words(t, a, &(a[n]),tna,n-tna); /* + */
132 bn_sub_words(&(t[n]),b, &(b[n]),n); /* - */ 448 bn_sub_part_words(&(t[n]),b, &(b[n]),tnb,n-tnb); /* - */
133 neg=1; 449 neg=1;
134 break; 450 break;
135 case 3: 451 case 3:
136 zero=1; 452 zero=1;
137 break; 453 break;
138 case 4: 454 case 4:
139 bn_sub_words(t, a, &(a[n]),n); 455 bn_sub_part_words(t, a, &(a[n]),tna,n-tna);
140 bn_sub_words(&(t[n]),&(b[n]),b, n); 456 bn_sub_part_words(&(t[n]),&(b[n]),b, tnb,tnb-n);
141 break; 457 break;
142 } 458 }
143 459
144# ifdef BN_MUL_COMBA 460# ifdef BN_MUL_COMBA
145 if (n == 4) 461 if (n == 4 && dna == 0 && dnb == 0) /* XXX: bn_mul_comba4 could take
462 extra args to do this well */
146 { 463 {
147 if (!zero) 464 if (!zero)
148 bn_mul_comba4(&(t[n2]),t,&(t[n])); 465 bn_mul_comba4(&(t[n2]),t,&(t[n]));
@@ -152,7 +469,9 @@ void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
152 bn_mul_comba4(r,a,b); 469 bn_mul_comba4(r,a,b);
153 bn_mul_comba4(&(r[n2]),&(a[n]),&(b[n])); 470 bn_mul_comba4(&(r[n2]),&(a[n]),&(b[n]));
154 } 471 }
155 else if (n == 8) 472 else if (n == 8 && dna == 0 && dnb == 0) /* XXX: bn_mul_comba8 could
473 take extra args to do this
474 well */
156 { 475 {
157 if (!zero) 476 if (!zero)
158 bn_mul_comba8(&(t[n2]),t,&(t[n])); 477 bn_mul_comba8(&(t[n2]),t,&(t[n]));
@@ -167,11 +486,11 @@ void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
167 { 486 {
168 p= &(t[n2*2]); 487 p= &(t[n2*2]);
169 if (!zero) 488 if (!zero)
170 bn_mul_recursive(&(t[n2]),t,&(t[n]),n,p); 489 bn_mul_recursive(&(t[n2]),t,&(t[n]),n,0,0,p);
171 else 490 else
172 memset(&(t[n2]),0,n2*sizeof(BN_ULONG)); 491 memset(&(t[n2]),0,n2*sizeof(BN_ULONG));
173 bn_mul_recursive(r,a,b,n,p); 492 bn_mul_recursive(r,a,b,n,0,0,p);
174 bn_mul_recursive(&(r[n2]),&(a[n]),&(b[n]),n,p); 493 bn_mul_recursive(&(r[n2]),&(a[n]),&(b[n]),n,dna,dnb,p);
175 } 494 }
176 495
177 /* t[32] holds (a[0]-a[1])*(b[1]-b[0]), c1 is the sign 496 /* t[32] holds (a[0]-a[1])*(b[1]-b[0]), c1 is the sign
@@ -220,39 +539,39 @@ void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
220 539
221/* n+tn is the word length 540/* n+tn is the word length
222 * t needs to be n*4 is size, as does r */ 541 * 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, 542void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n,
224 int n, BN_ULONG *t) 543 int tna, int tnb, BN_ULONG *t)
225 { 544 {
226 int i,j,n2=n*2; 545 int i,j,n2=n*2;
227 unsigned int c1,c2,neg,zero; 546 unsigned int c1,c2,neg,zero;
228 BN_ULONG ln,lo,*p; 547 BN_ULONG ln,lo,*p;
229 548
230# ifdef BN_COUNT 549# ifdef BN_COUNT
231 printf(" bn_mul_part_recursive %d * %d\n",tn+n,tn+n); 550 fprintf(stderr," bn_mul_part_recursive (%d+%d) * (%d+%d)\n",
551 tna, n, tnb, n);
232# endif 552# endif
233 if (n < 8) 553 if (n < 8)
234 { 554 {
235 i=tn+n; 555 bn_mul_normal(r,a,n+tna,b,n+tnb);
236 bn_mul_normal(r,a,i,b,i);
237 return; 556 return;
238 } 557 }
239 558
240 /* r=(a[0]-a[1])*(b[1]-b[0]) */ 559 /* r=(a[0]-a[1])*(b[1]-b[0]) */
241 c1=bn_cmp_words(a,&(a[n]),n); 560 c1=bn_cmp_part_words(a,&(a[n]),tna,n-tna);
242 c2=bn_cmp_words(&(b[n]),b,n); 561 c2=bn_cmp_part_words(&(b[n]),b,tnb,tnb-n);
243 zero=neg=0; 562 zero=neg=0;
244 switch (c1*3+c2) 563 switch (c1*3+c2)
245 { 564 {
246 case -4: 565 case -4:
247 bn_sub_words(t, &(a[n]),a, n); /* - */ 566 bn_sub_part_words(t, &(a[n]),a, tna,tna-n); /* - */
248 bn_sub_words(&(t[n]),b, &(b[n]),n); /* - */ 567 bn_sub_part_words(&(t[n]),b, &(b[n]),tnb,n-tnb); /* - */
249 break; 568 break;
250 case -3: 569 case -3:
251 zero=1; 570 zero=1;
252 /* break; */ 571 /* break; */
253 case -2: 572 case -2:
254 bn_sub_words(t, &(a[n]),a, n); /* - */ 573 bn_sub_part_words(t, &(a[n]),a, tna,tna-n); /* - */
255 bn_sub_words(&(t[n]),&(b[n]),b, n); /* + */ 574 bn_sub_part_words(&(t[n]),&(b[n]),b, tnb,tnb-n); /* + */
256 neg=1; 575 neg=1;
257 break; 576 break;
258 case -1: 577 case -1:
@@ -261,16 +580,16 @@ void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int tn,
261 zero=1; 580 zero=1;
262 /* break; */ 581 /* break; */
263 case 2: 582 case 2:
264 bn_sub_words(t, a, &(a[n]),n); /* + */ 583 bn_sub_part_words(t, a, &(a[n]),tna,n-tna); /* + */
265 bn_sub_words(&(t[n]),b, &(b[n]),n); /* - */ 584 bn_sub_part_words(&(t[n]),b, &(b[n]),tnb,n-tnb); /* - */
266 neg=1; 585 neg=1;
267 break; 586 break;
268 case 3: 587 case 3:
269 zero=1; 588 zero=1;
270 /* break; */ 589 /* break; */
271 case 4: 590 case 4:
272 bn_sub_words(t, a, &(a[n]),n); 591 bn_sub_part_words(t, a, &(a[n]),tna,n-tna);
273 bn_sub_words(&(t[n]),&(b[n]),b, n); 592 bn_sub_part_words(&(t[n]),&(b[n]),b, tnb,tnb-n);
274 break; 593 break;
275 } 594 }
276 /* The zero case isn't yet implemented here. The speedup 595 /* The zero case isn't yet implemented here. The speedup
@@ -289,54 +608,59 @@ void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int tn,
289 { 608 {
290 bn_mul_comba8(&(t[n2]),t,&(t[n])); 609 bn_mul_comba8(&(t[n2]),t,&(t[n]));
291 bn_mul_comba8(r,a,b); 610 bn_mul_comba8(r,a,b);
292 bn_mul_normal(&(r[n2]),&(a[n]),tn,&(b[n]),tn); 611 bn_mul_normal(&(r[n2]),&(a[n]),tna,&(b[n]),tnb);
293 memset(&(r[n2+tn*2]),0,sizeof(BN_ULONG)*(n2-tn*2)); 612 memset(&(r[n2+tna+tnb]),0,sizeof(BN_ULONG)*(n2-tna-tnb));
294 } 613 }
295 else 614 else
296 { 615 {
297 p= &(t[n2*2]); 616 p= &(t[n2*2]);
298 bn_mul_recursive(&(t[n2]),t,&(t[n]),n,p); 617 bn_mul_recursive(&(t[n2]),t,&(t[n]),n,0,0,p);
299 bn_mul_recursive(r,a,b,n,p); 618 bn_mul_recursive(r,a,b,n,0,0,p);
300 i=n/2; 619 i=n/2;
301 /* If there is only a bottom half to the number, 620 /* If there is only a bottom half to the number,
302 * just do it */ 621 * just do it */
303 j=tn-i; 622 if (tna > tnb)
623 j = tna - i;
624 else
625 j = tnb - i;
304 if (j == 0) 626 if (j == 0)
305 { 627 {
306 bn_mul_recursive(&(r[n2]),&(a[n]),&(b[n]),i,p); 628 bn_mul_recursive(&(r[n2]),&(a[n]),&(b[n]),
629 i,tna-i,tnb-i,p);
307 memset(&(r[n2+i*2]),0,sizeof(BN_ULONG)*(n2-i*2)); 630 memset(&(r[n2+i*2]),0,sizeof(BN_ULONG)*(n2-i*2));
308 } 631 }
309 else if (j > 0) /* eg, n == 16, i == 8 and tn == 11 */ 632 else if (j > 0) /* eg, n == 16, i == 8 and tn == 11 */
310 { 633 {
311 bn_mul_part_recursive(&(r[n2]),&(a[n]),&(b[n]), 634 bn_mul_part_recursive(&(r[n2]),&(a[n]),&(b[n]),
312 j,i,p); 635 i,tna-i,tnb-i,p);
313 memset(&(r[n2+tn*2]),0, 636 memset(&(r[n2+tna+tnb]),0,
314 sizeof(BN_ULONG)*(n2-tn*2)); 637 sizeof(BN_ULONG)*(n2-tna-tnb));
315 } 638 }
316 else /* (j < 0) eg, n == 16, i == 8 and tn == 5 */ 639 else /* (j < 0) eg, n == 16, i == 8 and tn == 5 */
317 { 640 {
318 memset(&(r[n2]),0,sizeof(BN_ULONG)*n2); 641 memset(&(r[n2]),0,sizeof(BN_ULONG)*n2);
319 if (tn < BN_MUL_RECURSIVE_SIZE_NORMAL) 642 if (tna < BN_MUL_RECURSIVE_SIZE_NORMAL
643 && tnb < BN_MUL_RECURSIVE_SIZE_NORMAL)
320 { 644 {
321 bn_mul_normal(&(r[n2]),&(a[n]),tn,&(b[n]),tn); 645 bn_mul_normal(&(r[n2]),&(a[n]),tna,&(b[n]),tnb);
322 } 646 }
323 else 647 else
324 { 648 {
325 for (;;) 649 for (;;)
326 { 650 {
327 i/=2; 651 i/=2;
328 if (i < tn) 652 if (i < tna && i < tnb)
329 { 653 {
330 bn_mul_part_recursive(&(r[n2]), 654 bn_mul_part_recursive(&(r[n2]),
331 &(a[n]),&(b[n]), 655 &(a[n]),&(b[n]),
332 tn-i,i,p); 656 i,tna-i,tnb-i,p);
333 break; 657 break;
334 } 658 }
335 else if (i == tn) 659 else if (i <= tna && i <= tnb)
336 { 660 {
337 bn_mul_recursive(&(r[n2]), 661 bn_mul_recursive(&(r[n2]),
338 &(a[n]),&(b[n]), 662 &(a[n]),&(b[n]),
339 i,p); 663 i,tna-i,tnb-i,p);
340 break; 664 break;
341 } 665 }
342 } 666 }
@@ -397,10 +721,10 @@ void bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
397 int n=n2/2; 721 int n=n2/2;
398 722
399# ifdef BN_COUNT 723# ifdef BN_COUNT
400 printf(" bn_mul_low_recursive %d * %d\n",n2,n2); 724 fprintf(stderr," bn_mul_low_recursive %d * %d\n",n2,n2);
401# endif 725# endif
402 726
403 bn_mul_recursive(r,a,b,n,&(t[0])); 727 bn_mul_recursive(r,a,b,n,0,0,&(t[0]));
404 if (n >= BN_MUL_LOW_RECURSIVE_SIZE_NORMAL) 728 if (n >= BN_MUL_LOW_RECURSIVE_SIZE_NORMAL)
405 { 729 {
406 bn_mul_low_recursive(&(t[0]),&(a[0]),&(b[n]),n,&(t[n2])); 730 bn_mul_low_recursive(&(t[0]),&(a[0]),&(b[n]),n,&(t[n2]));
@@ -431,7 +755,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; 755 BN_ULONG ll,lc,*lp,*mp;
432 756
433# ifdef BN_COUNT 757# ifdef BN_COUNT
434 printf(" bn_mul_high %d * %d\n",n2,n2); 758 fprintf(stderr," bn_mul_high %d * %d\n",n2,n2);
435# endif 759# endif
436 n=n2/2; 760 n=n2/2;
437 761
@@ -484,8 +808,8 @@ void bn_mul_high(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, BN_ULONG *l, int n2,
484 else 808 else
485# endif 809# endif
486 { 810 {
487 bn_mul_recursive(&(t[0]),&(r[0]),&(r[n]),n,&(t[n2])); 811 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])); 812 bn_mul_recursive(r,&(a[n]),&(b[n]),n,0,0,&(t[n2]));
489 } 813 }
490 814
491 /* s0 == low(al*bl) 815 /* s0 == low(al*bl)
@@ -608,21 +932,21 @@ void bn_mul_high(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, BN_ULONG *l, int n2,
608 } 932 }
609#endif /* BN_RECURSION */ 933#endif /* BN_RECURSION */
610 934
611int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx) 935int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
612 { 936 {
937 int ret=0;
613 int top,al,bl; 938 int top,al,bl;
614 BIGNUM *rr; 939 BIGNUM *rr;
615 int ret = 0;
616#if defined(BN_MUL_COMBA) || defined(BN_RECURSION) 940#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)
617 int i; 941 int i;
618#endif 942#endif
619#ifdef BN_RECURSION 943#ifdef BN_RECURSION
620 BIGNUM *t; 944 BIGNUM *t=NULL;
621 int j,k; 945 int j=0,k;
622#endif 946#endif
623 947
624#ifdef BN_COUNT 948#ifdef BN_COUNT
625 printf("BN_mul %d * %d\n",a->top,b->top); 949 fprintf(stderr,"BN_mul %d * %d\n",a->top,b->top);
626#endif 950#endif
627 951
628 bn_check_top(a); 952 bn_check_top(a);
@@ -675,17 +999,55 @@ int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx)
675#ifdef BN_RECURSION 999#ifdef BN_RECURSION
676 if ((al >= BN_MULL_SIZE_NORMAL) && (bl >= BN_MULL_SIZE_NORMAL)) 1000 if ((al >= BN_MULL_SIZE_NORMAL) && (bl >= BN_MULL_SIZE_NORMAL))
677 { 1001 {
1002 if (i >= -1 && i <= 1)
1003 {
1004 int sav_j =0;
1005 /* Find out the power of two lower or equal
1006 to the longest of the two numbers */
1007 if (i >= 0)
1008 {
1009 j = BN_num_bits_word((BN_ULONG)al);
1010 }
1011 if (i == -1)
1012 {
1013 j = BN_num_bits_word((BN_ULONG)bl);
1014 }
1015 sav_j = j;
1016 j = 1<<(j-1);
1017 assert(j <= al || j <= bl);
1018 k = j+j;
1019 t = BN_CTX_get(ctx);
1020 if (al > j || bl > j)
1021 {
1022 bn_wexpand(t,k*4);
1023 bn_wexpand(rr,k*4);
1024 bn_mul_part_recursive(rr->d,a->d,b->d,
1025 j,al-j,bl-j,t->d);
1026 }
1027 else /* al <= j || bl <= j */
1028 {
1029 bn_wexpand(t,k*2);
1030 bn_wexpand(rr,k*2);
1031 bn_mul_recursive(rr->d,a->d,b->d,
1032 j,al-j,bl-j,t->d);
1033 }
1034 rr->top=top;
1035 goto end;
1036 }
1037#if 0
678 if (i == 1 && !BN_get_flags(b,BN_FLG_STATIC_DATA)) 1038 if (i == 1 && !BN_get_flags(b,BN_FLG_STATIC_DATA))
679 { 1039 {
680 bn_wexpand(b,al); 1040 BIGNUM *tmp_bn = (BIGNUM *)b;
681 b->d[bl]=0; 1041 bn_wexpand(tmp_bn,al);
1042 tmp_bn->d[bl]=0;
682 bl++; 1043 bl++;
683 i--; 1044 i--;
684 } 1045 }
685 else if (i == -1 && !BN_get_flags(a,BN_FLG_STATIC_DATA)) 1046 else if (i == -1 && !BN_get_flags(a,BN_FLG_STATIC_DATA))
686 { 1047 {
687 bn_wexpand(a,bl); 1048 BIGNUM *tmp_bn = (BIGNUM *)a;
688 a->d[al]=0; 1049 bn_wexpand(tmp_bn,bl);
1050 tmp_bn->d[al]=0;
689 al++; 1051 al++;
690 i++; 1052 i++;
691 } 1053 }
@@ -705,19 +1067,14 @@ int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx)
705 } 1067 }
706 else 1068 else
707 { 1069 {
708 bn_wexpand(a,k);
709 bn_wexpand(b,k);
710 bn_wexpand(t,k*4); 1070 bn_wexpand(t,k*4);
711 bn_wexpand(rr,k*4); 1071 bn_wexpand(rr,k*4);
712 for (i=a->top; i<k; i++)
713 a->d[i]=0;
714 for (i=b->top; i<k; i++)
715 b->d[i]=0;
716 bn_mul_part_recursive(rr->d,a->d,b->d,al-j,j,t->d); 1072 bn_mul_part_recursive(rr->d,a->d,b->d,al-j,j,t->d);
717 } 1073 }
718 rr->top=top; 1074 rr->top=top;
719 goto end; 1075 goto end;
720 } 1076 }
1077#endif
721 } 1078 }
722#endif /* BN_RECURSION */ 1079#endif /* BN_RECURSION */
723 if (bn_wexpand(rr,top) == NULL) goto err; 1080 if (bn_wexpand(rr,top) == NULL) goto err;
@@ -740,7 +1097,7 @@ void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb)
740 BN_ULONG *rr; 1097 BN_ULONG *rr;
741 1098
742#ifdef BN_COUNT 1099#ifdef BN_COUNT
743 printf(" bn_mul_normal %d * %d\n",na,nb); 1100 fprintf(stderr," bn_mul_normal %d * %d\n",na,nb);
744#endif 1101#endif
745 1102
746 if (na < nb) 1103 if (na < nb)
@@ -753,7 +1110,13 @@ void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb)
753 1110
754 } 1111 }
755 rr= &(r[na]); 1112 rr= &(r[na]);
756 rr[0]=bn_mul_words(r,a,na,b[0]); 1113 if (nb <= 0)
1114 {
1115 (void)bn_mul_words(r,a,na,0);
1116 return;
1117 }
1118 else
1119 rr[0]=bn_mul_words(r,a,na,b[0]);
757 1120
758 for (;;) 1121 for (;;)
759 { 1122 {
@@ -774,7 +1137,7 @@ void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb)
774void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n) 1137void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
775 { 1138 {
776#ifdef BN_COUNT 1139#ifdef BN_COUNT
777 printf(" bn_mul_low_normal %d * %d\n",n,n); 1140 fprintf(stderr," bn_mul_low_normal %d * %d\n",n,n);
778#endif 1141#endif
779 bn_mul_words(r,a,n,b[0]); 1142 bn_mul_words(r,a,n,b[0]);
780 1143
diff --git a/src/lib/libcrypto/bn/bn_prime.c b/src/lib/libcrypto/bn/bn_prime.c
index a5f01b92eb..918b9237c6 100644
--- a/src/lib/libcrypto/bn/bn_prime.c
+++ b/src/lib/libcrypto/bn/bn_prime.c
@@ -56,7 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58/* ==================================================================== 58/* ====================================================================
59 * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. 59 * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.
60 * 60 *
61 * Redistribution and use in source and binary forms, with or without 61 * Redistribution and use in source and binary forms, with or without
62 * modification, are permitted provided that the following conditions 62 * modification, are permitted provided that the following conditions
@@ -125,12 +125,13 @@ static int witness(BIGNUM *w, const BIGNUM *a, const BIGNUM *a1,
125 const BIGNUM *a1_odd, int k, BN_CTX *ctx, BN_MONT_CTX *mont); 125 const BIGNUM *a1_odd, int k, BN_CTX *ctx, BN_MONT_CTX *mont);
126static int probable_prime(BIGNUM *rnd, int bits); 126static int probable_prime(BIGNUM *rnd, int bits);
127static int probable_prime_dh(BIGNUM *rnd, int bits, 127static int probable_prime_dh(BIGNUM *rnd, int bits,
128 BIGNUM *add, BIGNUM *rem, BN_CTX *ctx); 128 const BIGNUM *add, const BIGNUM *rem, BN_CTX *ctx);
129static int probable_prime_dh_safe(BIGNUM *rnd, int bits, 129static int probable_prime_dh_safe(BIGNUM *rnd, int bits,
130 BIGNUM *add, BIGNUM *rem, BN_CTX *ctx); 130 const BIGNUM *add, const BIGNUM *rem, BN_CTX *ctx);
131 131
132BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe, BIGNUM *add, 132BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe,
133 BIGNUM *rem, void (*callback)(int,int,void *), void *cb_arg) 133 const BIGNUM *add, const BIGNUM *rem,
134 void (*callback)(int,int,void *), void *cb_arg)
134 { 135 {
135 BIGNUM *rnd=NULL; 136 BIGNUM *rnd=NULL;
136 BIGNUM t; 137 BIGNUM t;
@@ -225,12 +226,15 @@ int BN_is_prime_fasttest(const BIGNUM *a, int checks,
225 BN_MONT_CTX *mont = NULL; 226 BN_MONT_CTX *mont = NULL;
226 const BIGNUM *A = NULL; 227 const BIGNUM *A = NULL;
227 228
229 if (BN_cmp(a, BN_value_one()) <= 0)
230 return 0;
231
228 if (checks == BN_prime_checks) 232 if (checks == BN_prime_checks)
229 checks = BN_prime_checks_for_size(BN_num_bits(a)); 233 checks = BN_prime_checks_for_size(BN_num_bits(a));
230 234
231 /* first look for small factors */ 235 /* first look for small factors */
232 if (!BN_is_odd(a)) 236 if (!BN_is_odd(a))
233 return(0); 237 return 0;
234 if (do_trial_division) 238 if (do_trial_division)
235 { 239 {
236 for (i = 1; i < NUMPRIMES; i++) 240 for (i = 1; i < NUMPRIMES; i++)
@@ -289,11 +293,8 @@ int BN_is_prime_fasttest(const BIGNUM *a, int checks,
289 293
290 for (i = 0; i < checks; i++) 294 for (i = 0; i < checks; i++)
291 { 295 {
292 if (!BN_pseudo_rand(check, BN_num_bits(A1), 0, 0)) 296 if (!BN_pseudo_rand_range(check, A1))
293 goto err; 297 goto err;
294 if (BN_cmp(check, A1) >= 0)
295 if (!BN_sub(check, check, A1))
296 goto err;
297 if (!BN_add_word(check, 1)) 298 if (!BN_add_word(check, 1))
298 goto err; 299 goto err;
299 /* now 1 <= check < A */ 300 /* now 1 <= check < A */
@@ -376,8 +377,8 @@ again:
376 return(1); 377 return(1);
377 } 378 }
378 379
379static int probable_prime_dh(BIGNUM *rnd, int bits, BIGNUM *add, BIGNUM *rem, 380static int probable_prime_dh(BIGNUM *rnd, int bits,
380 BN_CTX *ctx) 381 const BIGNUM *add, const BIGNUM *rem, BN_CTX *ctx)
381 { 382 {
382 int i,ret=0; 383 int i,ret=0;
383 BIGNUM *t1; 384 BIGNUM *t1;
@@ -413,8 +414,8 @@ err:
413 return(ret); 414 return(ret);
414 } 415 }
415 416
416static int probable_prime_dh_safe(BIGNUM *p, int bits, BIGNUM *padd, 417static int probable_prime_dh_safe(BIGNUM *p, int bits, const BIGNUM *padd,
417 BIGNUM *rem, BN_CTX *ctx) 418 const BIGNUM *rem, BN_CTX *ctx)
418 { 419 {
419 int i,ret=0; 420 int i,ret=0;
420 BIGNUM *t1,*qadd,*q; 421 BIGNUM *t1,*qadd,*q;
diff --git a/src/lib/libcrypto/bn/bn_print.c b/src/lib/libcrypto/bn/bn_print.c
index 532e66bcc3..5f46b1826c 100644
--- a/src/lib/libcrypto/bn/bn_print.c
+++ b/src/lib/libcrypto/bn/bn_print.c
@@ -277,8 +277,8 @@ err:
277 return(0); 277 return(0);
278 } 278 }
279 279
280#ifndef NO_BIO 280#ifndef OPENSSL_NO_BIO
281#ifndef NO_FP_API 281#ifndef OPENSSL_NO_FP_API
282int BN_print_fp(FILE *fp, const BIGNUM *a) 282int BN_print_fp(FILE *fp, const BIGNUM *a)
283 { 283 {
284 BIO *b; 284 BIO *b;
@@ -321,7 +321,7 @@ end:
321#endif 321#endif
322 322
323#ifdef BN_DEBUG 323#ifdef BN_DEBUG
324void bn_dump1(FILE *o, const char *a, BN_ULONG *b,int n) 324void bn_dump1(FILE *o, const char *a, const BN_ULONG *b,int n)
325 { 325 {
326 int i; 326 int i;
327 fprintf(o, "%s=", a); 327 fprintf(o, "%s=", a);
diff --git a/src/lib/libcrypto/bn/bn_rand.c b/src/lib/libcrypto/bn/bn_rand.c
index acd0619921..9e08ccd22e 100644
--- a/src/lib/libcrypto/bn/bn_rand.c
+++ b/src/lib/libcrypto/bn/bn_rand.c
@@ -55,6 +55,59 @@
55 * copied and put under another distribution licence 55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58/* ====================================================================
59 * Copyright (c) 1998-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 */
58 111
59#include <stdio.h> 112#include <stdio.h>
60#include <time.h> 113#include <time.h>
@@ -171,9 +224,11 @@ int BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom)
171 } 224 }
172#endif 225#endif
173 226
227
174/* random number r: 0 <= r < range */ 228/* random number r: 0 <= r < range */
175int BN_rand_range(BIGNUM *r, BIGNUM *range) 229static int bn_rand_range(int pseudo, BIGNUM *r, BIGNUM *range)
176 { 230 {
231 int (*bn_rand)(BIGNUM *, int, int, int) = pseudo ? BN_pseudo_rand : BN_rand;
177 int n; 232 int n;
178 233
179 if (range->neg || BN_is_zero(range)) 234 if (range->neg || BN_is_zero(range))
@@ -184,26 +239,19 @@ int BN_rand_range(BIGNUM *r, BIGNUM *range)
184 239
185 n = BN_num_bits(range); /* n > 0 */ 240 n = BN_num_bits(range); /* n > 0 */
186 241
242 /* BN_is_bit_set(range, n - 1) always holds */
243
187 if (n == 1) 244 if (n == 1)
188 { 245 {
189 if (!BN_zero(r)) return 0; 246 if (!BN_zero(r)) return 0;
190 } 247 }
191 else if (BN_is_bit_set(range, n - 2)) 248 else if (!BN_is_bit_set(range, n - 2) && !BN_is_bit_set(range, n - 3))
192 {
193 do
194 {
195 /* range = 11..._2, so each iteration succeeds with probability >= .75 */
196 if (!BN_rand(r, n, -1, 0)) return 0;
197 }
198 while (BN_cmp(r, range) >= 0);
199 }
200 else
201 { 249 {
202 /* range = 10..._2, 250 /* range = 100..._2,
203 * so 3*range (= 11..._2) is exactly one bit longer than range */ 251 * so 3*range (= 11..._2) is exactly one bit longer than range */
204 do 252 do
205 { 253 {
206 if (!BN_rand(r, n + 1, -1, 0)) return 0; 254 if (!bn_rand(r, n + 1, -1, 0)) return 0;
207 /* If r < 3*range, use r := r MOD range 255 /* If r < 3*range, use r := r MOD range
208 * (which is either r, r - range, or r - 2*range). 256 * (which is either r, r - range, or r - 2*range).
209 * Otherwise, iterate once more. 257 * Otherwise, iterate once more.
@@ -218,6 +266,26 @@ int BN_rand_range(BIGNUM *r, BIGNUM *range)
218 } 266 }
219 while (BN_cmp(r, range) >= 0); 267 while (BN_cmp(r, range) >= 0);
220 } 268 }
269 else
270 {
271 do
272 {
273 /* range = 11..._2 or range = 101..._2 */
274 if (!bn_rand(r, n, -1, 0)) return 0;
275 }
276 while (BN_cmp(r, range) >= 0);
277 }
221 278
222 return 1; 279 return 1;
223 } 280 }
281
282
283int BN_rand_range(BIGNUM *r, BIGNUM *range)
284 {
285 return bn_rand_range(0, r, range);
286 }
287
288int BN_pseudo_rand_range(BIGNUM *r, BIGNUM *range)
289 {
290 return bn_rand_range(1, r, range);
291 }
diff --git a/src/lib/libcrypto/bn/bn_recp.c b/src/lib/libcrypto/bn/bn_recp.c
index d019941d6b..ef5fdd4708 100644
--- a/src/lib/libcrypto/bn/bn_recp.c
+++ b/src/lib/libcrypto/bn/bn_recp.c
@@ -93,18 +93,19 @@ void BN_RECP_CTX_free(BN_RECP_CTX *recp)
93 93
94int BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *d, BN_CTX *ctx) 94int BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *d, BN_CTX *ctx)
95 { 95 {
96 BN_copy(&(recp->N),d); 96 if (!BN_copy(&(recp->N),d)) return 0;
97 BN_zero(&(recp->Nr)); 97 if (!BN_zero(&(recp->Nr))) return 0;
98 recp->num_bits=BN_num_bits(d); 98 recp->num_bits=BN_num_bits(d);
99 recp->shift=0; 99 recp->shift=0;
100 return(1); 100 return(1);
101 } 101 }
102 102
103int BN_mod_mul_reciprocal(BIGNUM *r, BIGNUM *x, BIGNUM *y, BN_RECP_CTX *recp, 103int BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y,
104 BN_CTX *ctx) 104 BN_RECP_CTX *recp, BN_CTX *ctx)
105 { 105 {
106 int ret=0; 106 int ret=0;
107 BIGNUM *a; 107 BIGNUM *a;
108 const BIGNUM *ca;
108 109
109 BN_CTX_start(ctx); 110 BN_CTX_start(ctx);
110 if ((a = BN_CTX_get(ctx)) == NULL) goto err; 111 if ((a = BN_CTX_get(ctx)) == NULL) goto err;
@@ -114,19 +115,19 @@ int BN_mod_mul_reciprocal(BIGNUM *r, BIGNUM *x, BIGNUM *y, BN_RECP_CTX *recp,
114 { if (!BN_sqr(a,x,ctx)) goto err; } 115 { if (!BN_sqr(a,x,ctx)) goto err; }
115 else 116 else
116 { if (!BN_mul(a,x,y,ctx)) goto err; } 117 { if (!BN_mul(a,x,y,ctx)) goto err; }
118 ca = a;
117 } 119 }
118 else 120 else
119 a=x; /* Just do the mod */ 121 ca=x; /* Just do the mod */
120 122
121 BN_div_recp(NULL,r,a,recp,ctx); 123 ret = BN_div_recp(NULL,r,ca,recp,ctx);
122 ret=1;
123err: 124err:
124 BN_CTX_end(ctx); 125 BN_CTX_end(ctx);
125 return(ret); 126 return(ret);
126 } 127 }
127 128
128int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, BN_RECP_CTX *recp, 129int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,
129 BN_CTX *ctx) 130 BN_RECP_CTX *recp, BN_CTX *ctx)
130 { 131 {
131 int i,j,ret=0; 132 int i,j,ret=0;
132 BIGNUM *a,*b,*d,*r; 133 BIGNUM *a,*b,*d,*r;
@@ -146,8 +147,8 @@ int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, BN_RECP_CTX *recp,
146 147
147 if (BN_ucmp(m,&(recp->N)) < 0) 148 if (BN_ucmp(m,&(recp->N)) < 0)
148 { 149 {
149 BN_zero(d); 150 if (!BN_zero(d)) return 0;
150 BN_copy(r,m); 151 if (!BN_copy(r,m)) return 0;
151 BN_CTX_end(ctx); 152 BN_CTX_end(ctx);
152 return(1); 153 return(1);
153 } 154 }
@@ -157,20 +158,28 @@ int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, BN_RECP_CTX *recp,
157 * we need multiply ABCDEF by 3 digests of the reciprocal of ab 158 * we need multiply ABCDEF by 3 digests of the reciprocal of ab
158 * 159 *
159 */ 160 */
160 i=BN_num_bits(m);
161 161
162 /* i := max(BN_num_bits(m), 2*BN_num_bits(N)) */
163 i=BN_num_bits(m);
162 j=recp->num_bits<<1; 164 j=recp->num_bits<<1;
163 if (j>i) i=j; 165 if (j>i) i=j;
164 j>>=1;
165 166
167 /* Nr := round(2^i / N) */
166 if (i != recp->shift) 168 if (i != recp->shift)
167 recp->shift=BN_reciprocal(&(recp->Nr),&(recp->N), 169 recp->shift=BN_reciprocal(&(recp->Nr),&(recp->N),
168 i,ctx); 170 i,ctx); /* BN_reciprocal returns i, or -1 for an error */
171 if (recp->shift == -1) goto err;
169 172
170 if (!BN_rshift(a,m,j)) goto err; 173 /* d := |round(round(m / 2^BN_num_bits(N)) * recp->Nr / 2^(i - BN_num_bits(N)))|
174 * = |round(round(m / 2^BN_num_bits(N)) * round(2^i / N) / 2^(i - BN_num_bits(N)))|
175 * <= |(m / 2^BN_num_bits(N)) * (2^i / N) * (2^BN_num_bits(N) / 2^i)|
176 * = |m/N|
177 */
178 if (!BN_rshift(a,m,recp->num_bits)) goto err;
171 if (!BN_mul(b,a,&(recp->Nr),ctx)) goto err; 179 if (!BN_mul(b,a,&(recp->Nr),ctx)) goto err;
172 if (!BN_rshift(d,b,i-j)) goto err; 180 if (!BN_rshift(d,b,i-recp->num_bits)) goto err;
173 d->neg=0; 181 d->neg=0;
182
174 if (!BN_mul(b,&(recp->N),d,ctx)) goto err; 183 if (!BN_mul(b,&(recp->N),d,ctx)) goto err;
175 if (!BN_usub(r,m,b)) goto err; 184 if (!BN_usub(r,m,b)) goto err;
176 r->neg=0; 185 r->neg=0;
@@ -201,20 +210,21 @@ err:
201 * We actually calculate with an extra word of precision, so 210 * We actually calculate with an extra word of precision, so
202 * we can do faster division if the remainder is not required. 211 * we can do faster division if the remainder is not required.
203 */ 212 */
204int BN_reciprocal(BIGNUM *r, BIGNUM *m, int len, BN_CTX *ctx) 213/* r := 2^len / m */
214int BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx)
205 { 215 {
206 int ret= -1; 216 int ret= -1;
207 BIGNUM t; 217 BIGNUM t;
208 218
209 BN_init(&t); 219 BN_init(&t);
210 220
211 BN_zero(&t); 221 if (!BN_zero(&t)) goto err;
212 if (!BN_set_bit(&t,len)) goto err; 222 if (!BN_set_bit(&t,len)) goto err;
213 223
214 if (!BN_div(r,NULL,&t,m,ctx)) goto err; 224 if (!BN_div(r,NULL,&t,m,ctx)) goto err;
225
215 ret=len; 226 ret=len;
216err: 227err:
217 BN_free(&t); 228 BN_free(&t);
218 return(ret); 229 return(ret);
219 } 230 }
220
diff --git a/src/lib/libcrypto/bn/bn_shift.c b/src/lib/libcrypto/bn/bn_shift.c
index c2608f9f4a..70f785ea18 100644
--- a/src/lib/libcrypto/bn/bn_shift.c
+++ b/src/lib/libcrypto/bn/bn_shift.c
@@ -60,7 +60,7 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include "bn_lcl.h" 61#include "bn_lcl.h"
62 62
63int BN_lshift1(BIGNUM *r, BIGNUM *a) 63int BN_lshift1(BIGNUM *r, const BIGNUM *a)
64 { 64 {
65 register BN_ULONG *ap,*rp,t,c; 65 register BN_ULONG *ap,*rp,t,c;
66 int i; 66 int i;
@@ -92,7 +92,7 @@ int BN_lshift1(BIGNUM *r, BIGNUM *a)
92 return(1); 92 return(1);
93 } 93 }
94 94
95int BN_rshift1(BIGNUM *r, BIGNUM *a) 95int BN_rshift1(BIGNUM *r, const BIGNUM *a)
96 { 96 {
97 BN_ULONG *ap,*rp,t,c; 97 BN_ULONG *ap,*rp,t,c;
98 int i; 98 int i;
@@ -128,8 +128,8 @@ int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
128 BN_ULONG l; 128 BN_ULONG l;
129 129
130 r->neg=a->neg; 130 r->neg=a->neg;
131 if (bn_wexpand(r,a->top+(n/BN_BITS2)+1) == NULL) return(0);
132 nw=n/BN_BITS2; 131 nw=n/BN_BITS2;
132 if (bn_wexpand(r,a->top+nw+1) == NULL) return(0);
133 lb=n%BN_BITS2; 133 lb=n%BN_BITS2;
134 rb=BN_BITS2-lb; 134 rb=BN_BITS2-lb;
135 f=a->d; 135 f=a->d;
@@ -153,7 +153,7 @@ int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
153 return(1); 153 return(1);
154 } 154 }
155 155
156int BN_rshift(BIGNUM *r, BIGNUM *a, int n) 156int BN_rshift(BIGNUM *r, const BIGNUM *a, int n)
157 { 157 {
158 int i,j,nw,lb,rb; 158 int i,j,nw,lb,rb;
159 BN_ULONG *t,*f; 159 BN_ULONG *t,*f;
diff --git a/src/lib/libcrypto/bn/bn_sqr.c b/src/lib/libcrypto/bn/bn_sqr.c
index 75f4f38392..c1d0cca438 100644
--- a/src/lib/libcrypto/bn/bn_sqr.c
+++ b/src/lib/libcrypto/bn/bn_sqr.c
@@ -62,14 +62,14 @@
62 62
63/* r must not be a */ 63/* r must not be a */
64/* I've just gone over this and it is now %20 faster on x86 - eay - 27 Jun 96 */ 64/* I've just gone over this and it is now %20 faster on x86 - eay - 27 Jun 96 */
65int BN_sqr(BIGNUM *r, BIGNUM *a, BN_CTX *ctx) 65int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
66 { 66 {
67 int max,al; 67 int max,al;
68 int ret = 0; 68 int ret = 0;
69 BIGNUM *tmp,*rr; 69 BIGNUM *tmp,*rr;
70 70
71#ifdef BN_COUNT 71#ifdef BN_COUNT
72printf("BN_sqr %d * %d\n",a->top,a->top); 72 fprintf(stderr,"BN_sqr %d * %d\n",a->top,a->top);
73#endif 73#endif
74 bn_check_top(a); 74 bn_check_top(a);
75 75
@@ -88,7 +88,6 @@ printf("BN_sqr %d * %d\n",a->top,a->top);
88 max=(al+al); 88 max=(al+al);
89 if (bn_wexpand(rr,max+1) == NULL) goto err; 89 if (bn_wexpand(rr,max+1) == NULL) goto err;
90 90
91 r->neg=0;
92 if (al == 4) 91 if (al == 4)
93 { 92 {
94#ifndef BN_SQR_COMBA 93#ifndef BN_SQR_COMBA
@@ -124,7 +123,6 @@ printf("BN_sqr %d * %d\n",a->top,a->top);
124 k=j+j; 123 k=j+j;
125 if (al == j) 124 if (al == j)
126 { 125 {
127 if (bn_wexpand(a,k*2) == NULL) goto err;
128 if (bn_wexpand(tmp,k*2) == NULL) goto err; 126 if (bn_wexpand(tmp,k*2) == NULL) goto err;
129 bn_sqr_recursive(rr->d,a->d,al,tmp->d); 127 bn_sqr_recursive(rr->d,a->d,al,tmp->d);
130 } 128 }
@@ -141,6 +139,7 @@ printf("BN_sqr %d * %d\n",a->top,a->top);
141 } 139 }
142 140
143 rr->top=max; 141 rr->top=max;
142 rr->neg=0;
144 if ((max > 0) && (rr->d[max-1] == 0)) rr->top--; 143 if ((max > 0) && (rr->d[max-1] == 0)) rr->top--;
145 if (rr != r) BN_copy(r,rr); 144 if (rr != r) BN_copy(r,rr);
146 ret = 1; 145 ret = 1;
@@ -150,10 +149,11 @@ printf("BN_sqr %d * %d\n",a->top,a->top);
150 } 149 }
151 150
152/* tmp must have 2*n words */ 151/* tmp must have 2*n words */
153void bn_sqr_normal(BN_ULONG *r, BN_ULONG *a, int n, BN_ULONG *tmp) 152void bn_sqr_normal(BN_ULONG *r, const BN_ULONG *a, int n, BN_ULONG *tmp)
154 { 153 {
155 int i,j,max; 154 int i,j,max;
156 BN_ULONG *ap,*rp; 155 const BN_ULONG *ap;
156 BN_ULONG *rp;
157 157
158 max=n*2; 158 max=n*2;
159 ap=a; 159 ap=a;
@@ -197,14 +197,14 @@ void bn_sqr_normal(BN_ULONG *r, BN_ULONG *a, int n, BN_ULONG *tmp)
197 * a[0]*b[0]+a[1]*b[1]+(a[0]-a[1])*(b[1]-b[0]) 197 * a[0]*b[0]+a[1]*b[1]+(a[0]-a[1])*(b[1]-b[0])
198 * a[1]*b[1] 198 * a[1]*b[1]
199 */ 199 */
200void bn_sqr_recursive(BN_ULONG *r, BN_ULONG *a, int n2, BN_ULONG *t) 200void bn_sqr_recursive(BN_ULONG *r, const BN_ULONG *a, int n2, BN_ULONG *t)
201 { 201 {
202 int n=n2/2; 202 int n=n2/2;
203 int zero,c1; 203 int zero,c1;
204 BN_ULONG ln,lo,*p; 204 BN_ULONG ln,lo,*p;
205 205
206#ifdef BN_COUNT 206#ifdef BN_COUNT
207printf(" bn_sqr_recursive %d * %d\n",n2,n2); 207 fprintf(stderr," bn_sqr_recursive %d * %d\n",n2,n2);
208#endif 208#endif
209 if (n2 == 4) 209 if (n2 == 4)
210 { 210 {
@@ -245,7 +245,7 @@ printf(" bn_sqr_recursive %d * %d\n",n2,n2);
245 if (!zero) 245 if (!zero)
246 bn_sqr_recursive(&(t[n2]),t,n,p); 246 bn_sqr_recursive(&(t[n2]),t,n,p);
247 else 247 else
248 memset(&(t[n2]),0,n*sizeof(BN_ULONG)); 248 memset(&(t[n2]),0,n2*sizeof(BN_ULONG));
249 bn_sqr_recursive(r,a,n,p); 249 bn_sqr_recursive(r,a,n,p);
250 bn_sqr_recursive(&(r[n2]),&(a[n]),n,p); 250 bn_sqr_recursive(&(r[n2]),&(a[n]),n,p);
251 251
diff --git a/src/lib/libcrypto/bn/bn_sqrt.c b/src/lib/libcrypto/bn/bn_sqrt.c
new file mode 100644
index 0000000000..e2a1105dc8
--- /dev/null
+++ b/src/lib/libcrypto/bn/bn_sqrt.c
@@ -0,0 +1,387 @@
1/* crypto/bn/bn_mod.c */
2/* Written by Lenka Fibikova <fibikova@exp-math.uni-essen.de>
3 * and Bodo Moeller for the OpenSSL project. */
4/* ====================================================================
5 * Copyright (c) 1998-2000 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 * openssl-core@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 "cryptlib.h"
59#include "bn_lcl.h"
60
61
62BIGNUM *BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
63/* Returns 'ret' such that
64 * ret^2 == a (mod p),
65 * using the Tonelli/Shanks algorithm (cf. Henri Cohen, "A Course
66 * in Algebraic Computational Number Theory", algorithm 1.5.1).
67 * 'p' must be prime!
68 * If 'a' is not a square, this is not necessarily detected by
69 * the algorithms; a bogus result must be expected in this case.
70 */
71 {
72 BIGNUM *ret = in;
73 int err = 1;
74 int r;
75 BIGNUM *b, *q, *t, *x, *y;
76 int e, i, j;
77
78 if (!BN_is_odd(p) || BN_abs_is_word(p, 1))
79 {
80 if (BN_abs_is_word(p, 2))
81 {
82 if (ret == NULL)
83 ret = BN_new();
84 if (ret == NULL)
85 goto end;
86 if (!BN_set_word(ret, BN_is_bit_set(a, 0)))
87 {
88 BN_free(ret);
89 return NULL;
90 }
91 return ret;
92 }
93
94 BNerr(BN_F_BN_MOD_SQRT, BN_R_P_IS_NOT_PRIME);
95 return(NULL);
96 }
97
98 if (BN_is_zero(a) || BN_is_one(a))
99 {
100 if (ret == NULL)
101 ret = BN_new();
102 if (ret == NULL)
103 goto end;
104 if (!BN_set_word(ret, BN_is_one(a)))
105 {
106 BN_free(ret);
107 return NULL;
108 }
109 return ret;
110 }
111
112#if 0 /* if BN_mod_sqrt is used with correct input, this just wastes time */
113 r = BN_kronecker(a, p, ctx);
114 if (r < -1) return NULL;
115 if (r == -1)
116 {
117 BNerr(BN_F_BN_MOD_SQRT, BN_R_NOT_A_SQUARE);
118 return(NULL);
119 }
120#endif
121
122 BN_CTX_start(ctx);
123 b = BN_CTX_get(ctx);
124 q = BN_CTX_get(ctx);
125 t = BN_CTX_get(ctx);
126 x = BN_CTX_get(ctx);
127 y = BN_CTX_get(ctx);
128 if (y == NULL) goto end;
129
130 if (ret == NULL)
131 ret = BN_new();
132 if (ret == NULL) goto end;
133
134 /* now write |p| - 1 as 2^e*q where q is odd */
135 e = 1;
136 while (!BN_is_bit_set(p, e))
137 e++;
138 /* we'll set q later (if needed) */
139
140 if (e == 1)
141 {
142 /* The easy case: (|p|-1)/2 is odd, so 2 has an inverse
143 * modulo (|p|-1)/2, and square roots can be computed
144 * directly by modular exponentiation.
145 * We have
146 * 2 * (|p|+1)/4 == 1 (mod (|p|-1)/2),
147 * so we can use exponent (|p|+1)/4, i.e. (|p|-3)/4 + 1.
148 */
149 if (!BN_rshift(q, p, 2)) goto end;
150 q->neg = 0;
151 if (!BN_add_word(q, 1)) goto end;
152 if (!BN_mod_exp(ret, a, q, p, ctx)) goto end;
153 err = 0;
154 goto end;
155 }
156
157 if (e == 2)
158 {
159 /* |p| == 5 (mod 8)
160 *
161 * In this case 2 is always a non-square since
162 * Legendre(2,p) = (-1)^((p^2-1)/8) for any odd prime.
163 * So if a really is a square, then 2*a is a non-square.
164 * Thus for
165 * b := (2*a)^((|p|-5)/8),
166 * i := (2*a)*b^2
167 * we have
168 * i^2 = (2*a)^((1 + (|p|-5)/4)*2)
169 * = (2*a)^((p-1)/2)
170 * = -1;
171 * so if we set
172 * x := a*b*(i-1),
173 * then
174 * x^2 = a^2 * b^2 * (i^2 - 2*i + 1)
175 * = a^2 * b^2 * (-2*i)
176 * = a*(-i)*(2*a*b^2)
177 * = a*(-i)*i
178 * = a.
179 *
180 * (This is due to A.O.L. Atkin,
181 * <URL: http://listserv.nodak.edu/scripts/wa.exe?A2=ind9211&L=nmbrthry&O=T&P=562>,
182 * November 1992.)
183 */
184
185 /* make sure that a is reduced modulo p */
186 if (a->neg || BN_ucmp(a, p) >= 0)
187 {
188 if (!BN_nnmod(x, a, p, ctx)) goto end;
189 a = x; /* use x as temporary variable */
190 }
191
192 /* t := 2*a */
193 if (!BN_mod_lshift1_quick(t, a, p)) goto end;
194
195 /* b := (2*a)^((|p|-5)/8) */
196 if (!BN_rshift(q, p, 3)) goto end;
197 q->neg = 0;
198 if (!BN_mod_exp(b, t, q, p, ctx)) goto end;
199
200 /* y := b^2 */
201 if (!BN_mod_sqr(y, b, p, ctx)) goto end;
202
203 /* t := (2*a)*b^2 - 1*/
204 if (!BN_mod_mul(t, t, y, p, ctx)) goto end;
205 if (!BN_sub_word(t, 1)) goto end;
206
207 /* x = a*b*t */
208 if (!BN_mod_mul(x, a, b, p, ctx)) goto end;
209 if (!BN_mod_mul(x, x, t, p, ctx)) goto end;
210
211 if (!BN_copy(ret, x)) goto end;
212 err = 0;
213 goto end;
214 }
215
216 /* e > 2, so we really have to use the Tonelli/Shanks algorithm.
217 * First, find some y that is not a square. */
218 if (!BN_copy(q, p)) goto end; /* use 'q' as temp */
219 q->neg = 0;
220 i = 2;
221 do
222 {
223 /* For efficiency, try small numbers first;
224 * if this fails, try random numbers.
225 */
226 if (i < 22)
227 {
228 if (!BN_set_word(y, i)) goto end;
229 }
230 else
231 {
232 if (!BN_pseudo_rand(y, BN_num_bits(p), 0, 0)) goto end;
233 if (BN_ucmp(y, p) >= 0)
234 {
235 if (!(p->neg ? BN_add : BN_sub)(y, y, p)) goto end;
236 }
237 /* now 0 <= y < |p| */
238 if (BN_is_zero(y))
239 if (!BN_set_word(y, i)) goto end;
240 }
241
242 r = BN_kronecker(y, q, ctx); /* here 'q' is |p| */
243 if (r < -1) goto end;
244 if (r == 0)
245 {
246 /* m divides p */
247 BNerr(BN_F_BN_MOD_SQRT, BN_R_P_IS_NOT_PRIME);
248 goto end;
249 }
250 }
251 while (r == 1 && ++i < 82);
252
253 if (r != -1)
254 {
255 /* Many rounds and still no non-square -- this is more likely
256 * a bug than just bad luck.
257 * Even if p is not prime, we should have found some y
258 * such that r == -1.
259 */
260 BNerr(BN_F_BN_MOD_SQRT, BN_R_TOO_MANY_ITERATIONS);
261 goto end;
262 }
263
264 /* Here's our actual 'q': */
265 if (!BN_rshift(q, q, e)) goto end;
266
267 /* Now that we have some non-square, we can find an element
268 * of order 2^e by computing its q'th power. */
269 if (!BN_mod_exp(y, y, q, p, ctx)) goto end;
270 if (BN_is_one(y))
271 {
272 BNerr(BN_F_BN_MOD_SQRT, BN_R_P_IS_NOT_PRIME);
273 goto end;
274 }
275
276 /* Now we know that (if p is indeed prime) there is an integer
277 * k, 0 <= k < 2^e, such that
278 *
279 * a^q * y^k == 1 (mod p).
280 *
281 * As a^q is a square and y is not, k must be even.
282 * q+1 is even, too, so there is an element
283 *
284 * X := a^((q+1)/2) * y^(k/2),
285 *
286 * and it satisfies
287 *
288 * X^2 = a^q * a * y^k
289 * = a,
290 *
291 * so it is the square root that we are looking for.
292 */
293
294 /* t := (q-1)/2 (note that q is odd) */
295 if (!BN_rshift1(t, q)) goto end;
296
297 /* x := a^((q-1)/2) */
298 if (BN_is_zero(t)) /* special case: p = 2^e + 1 */
299 {
300 if (!BN_nnmod(t, a, p, ctx)) goto end;
301 if (BN_is_zero(t))
302 {
303 /* special case: a == 0 (mod p) */
304 if (!BN_zero(ret)) goto end;
305 err = 0;
306 goto end;
307 }
308 else
309 if (!BN_one(x)) goto end;
310 }
311 else
312 {
313 if (!BN_mod_exp(x, a, t, p, ctx)) goto end;
314 if (BN_is_zero(x))
315 {
316 /* special case: a == 0 (mod p) */
317 if (!BN_zero(ret)) goto end;
318 err = 0;
319 goto end;
320 }
321 }
322
323 /* b := a*x^2 (= a^q) */
324 if (!BN_mod_sqr(b, x, p, ctx)) goto end;
325 if (!BN_mod_mul(b, b, a, p, ctx)) goto end;
326
327 /* x := a*x (= a^((q+1)/2)) */
328 if (!BN_mod_mul(x, x, a, p, ctx)) goto end;
329
330 while (1)
331 {
332 /* Now b is a^q * y^k for some even k (0 <= k < 2^E
333 * where E refers to the original value of e, which we
334 * don't keep in a variable), and x is a^((q+1)/2) * y^(k/2).
335 *
336 * We have a*b = x^2,
337 * y^2^(e-1) = -1,
338 * b^2^(e-1) = 1.
339 */
340
341 if (BN_is_one(b))
342 {
343 if (!BN_copy(ret, x)) goto end;
344 err = 0;
345 goto end;
346 }
347
348
349 /* find smallest i such that b^(2^i) = 1 */
350 i = 1;
351 if (!BN_mod_sqr(t, b, p, ctx)) goto end;
352 while (!BN_is_one(t))
353 {
354 i++;
355 if (i == e)
356 {
357 BNerr(BN_F_BN_MOD_SQRT, BN_R_NOT_A_SQUARE);
358 goto end;
359 }
360 if (!BN_mod_mul(t, t, t, p, ctx)) goto end;
361 }
362
363
364 /* t := y^2^(e - i - 1) */
365 if (!BN_copy(t, y)) goto end;
366 for (j = e - i - 1; j > 0; j--)
367 {
368 if (!BN_mod_sqr(t, t, p, ctx)) goto end;
369 }
370 if (!BN_mod_mul(y, t, t, p, ctx)) goto end;
371 if (!BN_mod_mul(x, x, t, p, ctx)) goto end;
372 if (!BN_mod_mul(b, b, y, p, ctx)) goto end;
373 e = i;
374 }
375
376 end:
377 if (err)
378 {
379 if (ret != NULL && ret != in)
380 {
381 BN_clear_free(ret);
382 }
383 ret = NULL;
384 }
385 BN_CTX_end(ctx);
386 return ret;
387 }
diff --git a/src/lib/libcrypto/bn/bnspeed.c b/src/lib/libcrypto/bn/bnspeed.c
index 20fc7e08ff..b554ac8cf8 100644
--- a/src/lib/libcrypto/bn/bnspeed.c
+++ b/src/lib/libcrypto/bn/bnspeed.c
@@ -71,7 +71,7 @@
71#include <openssl/crypto.h> 71#include <openssl/crypto.h>
72#include <openssl/err.h> 72#include <openssl/err.h>
73 73
74#if !defined(MSDOS) && (!defined(VMS) || defined(__DECC)) 74#if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX)
75#define TIMES 75#define TIMES
76#endif 76#endif
77 77
@@ -87,7 +87,7 @@
87 The __TMS macro will show if it was. If it wasn't defined, we should 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 88 undefine TIMES, since that tells the rest of the program how things
89 should be handled. -- Richard Levitte */ 89 should be handled. -- Richard Levitte */
90#if defined(VMS) && defined(__DECC) && !defined(__TMS) 90#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
91#undef TIMES 91#undef TIMES
92#endif 92#endif
93 93
diff --git a/src/lib/libcrypto/bn/bntest.c b/src/lib/libcrypto/bn/bntest.c
index af0c2629e8..443cf420e5 100644
--- a/src/lib/libcrypto/bn/bntest.c
+++ b/src/lib/libcrypto/bn/bntest.c
@@ -60,7 +60,7 @@
60#include <stdlib.h> 60#include <stdlib.h>
61#include <string.h> 61#include <string.h>
62 62
63#include "openssl/e_os.h" 63#include "e_os.h"
64 64
65#include <openssl/bio.h> 65#include <openssl/bio.h>
66#include <openssl/bn.h> 66#include <openssl/bn.h>
@@ -68,7 +68,7 @@
68#include <openssl/x509.h> 68#include <openssl/x509.h>
69#include <openssl/err.h> 69#include <openssl/err.h>
70 70
71#ifdef WINDOWS 71#ifdef OPENSSL_SYS_WINDOWS
72#include "../bio/bss_file.c" 72#include "../bio/bss_file.c"
73#endif 73#endif
74 74
@@ -91,10 +91,12 @@ int test_mod(BIO *bp,BN_CTX *ctx);
91int test_mod_mul(BIO *bp,BN_CTX *ctx); 91int test_mod_mul(BIO *bp,BN_CTX *ctx);
92int test_mod_exp(BIO *bp,BN_CTX *ctx); 92int test_mod_exp(BIO *bp,BN_CTX *ctx);
93int test_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);
94int rand_neg(void); 96int rand_neg(void);
95static int results=0; 97static int results=0;
96 98
97#ifdef NO_STDIO 99#ifdef OPENSSL_NO_STDIO
98#define APPS_WIN16 100#define APPS_WIN16
99#include "bss_file.c" 101#include "bss_file.c"
100#endif 102#endif
@@ -224,6 +226,14 @@ int main(int argc, char *argv[])
224 if (!test_exp(out,ctx)) goto err; 226 if (!test_exp(out,ctx)) goto err;
225 BIO_flush(out); 227 BIO_flush(out);
226 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
227 BN_CTX_free(ctx); 237 BN_CTX_free(ctx);
228 BIO_free(out); 238 BIO_free(out);
229 239
@@ -243,7 +253,6 @@ int test_add(BIO *bp)
243 { 253 {
244 BIGNUM a,b,c; 254 BIGNUM a,b,c;
245 int i; 255 int i;
246 int j;
247 256
248 BN_init(&a); 257 BN_init(&a);
249 BN_init(&b); 258 BN_init(&b);
@@ -255,9 +264,6 @@ int test_add(BIO *bp)
255 BN_bntest_rand(&b,450+i,0,0); 264 BN_bntest_rand(&b,450+i,0,0);
256 a.neg=rand_neg(); 265 a.neg=rand_neg();
257 b.neg=rand_neg(); 266 b.neg=rand_neg();
258 if (bp == NULL)
259 for (j=0; j<10000; j++)
260 BN_add(&c,&a,&b);
261 BN_add(&c,&a,&b); 267 BN_add(&c,&a,&b);
262 if (bp != NULL) 268 if (bp != NULL)
263 { 269 {
@@ -291,7 +297,6 @@ int test_sub(BIO *bp)
291 { 297 {
292 BIGNUM a,b,c; 298 BIGNUM a,b,c;
293 int i; 299 int i;
294 int j;
295 300
296 BN_init(&a); 301 BN_init(&a);
297 BN_init(&b); 302 BN_init(&b);
@@ -312,9 +317,6 @@ int test_sub(BIO *bp)
312 a.neg=rand_neg(); 317 a.neg=rand_neg();
313 b.neg=rand_neg(); 318 b.neg=rand_neg();
314 } 319 }
315 if (bp == NULL)
316 for (j=0; j<10000; j++)
317 BN_sub(&c,&a,&b);
318 BN_sub(&c,&a,&b); 320 BN_sub(&c,&a,&b);
319 if (bp != NULL) 321 if (bp != NULL)
320 { 322 {
@@ -346,7 +348,6 @@ int test_div(BIO *bp, BN_CTX *ctx)
346 { 348 {
347 BIGNUM a,b,c,d,e; 349 BIGNUM a,b,c,d,e;
348 int i; 350 int i;
349 int j;
350 351
351 BN_init(&a); 352 BN_init(&a);
352 BN_init(&b); 353 BN_init(&b);
@@ -367,9 +368,6 @@ int test_div(BIO *bp, BN_CTX *ctx)
367 BN_bntest_rand(&b,50+3*(i-num1),0,0); 368 BN_bntest_rand(&b,50+3*(i-num1),0,0);
368 a.neg=rand_neg(); 369 a.neg=rand_neg();
369 b.neg=rand_neg(); 370 b.neg=rand_neg();
370 if (bp == NULL)
371 for (j=0; j<100; j++)
372 BN_div(&d,&c,&a,&b,ctx);
373 BN_div(&d,&c,&a,&b,ctx); 371 BN_div(&d,&c,&a,&b,ctx);
374 if (bp != NULL) 372 if (bp != NULL)
375 { 373 {
@@ -415,7 +413,6 @@ int test_div_recp(BIO *bp, BN_CTX *ctx)
415 BIGNUM a,b,c,d,e; 413 BIGNUM a,b,c,d,e;
416 BN_RECP_CTX recp; 414 BN_RECP_CTX recp;
417 int i; 415 int i;
418 int j;
419 416
420 BN_RECP_CTX_init(&recp); 417 BN_RECP_CTX_init(&recp);
421 BN_init(&a); 418 BN_init(&a);
@@ -438,9 +435,6 @@ int test_div_recp(BIO *bp, BN_CTX *ctx)
438 a.neg=rand_neg(); 435 a.neg=rand_neg();
439 b.neg=rand_neg(); 436 b.neg=rand_neg();
440 BN_RECP_CTX_set(&recp,&b,ctx); 437 BN_RECP_CTX_set(&recp,&b,ctx);
441 if (bp == NULL)
442 for (j=0; j<100; j++)
443 BN_div_recp(&d,&c,&a,&recp,ctx);
444 BN_div_recp(&d,&c,&a,&recp,ctx); 438 BN_div_recp(&d,&c,&a,&recp,ctx);
445 if (bp != NULL) 439 if (bp != NULL)
446 { 440 {
@@ -491,10 +485,11 @@ int test_mul(BIO *bp)
491 { 485 {
492 BIGNUM a,b,c,d,e; 486 BIGNUM a,b,c,d,e;
493 int i; 487 int i;
494 int j; 488 BN_CTX *ctx;
495 BN_CTX ctx;
496 489
497 BN_CTX_init(&ctx); 490 ctx = BN_CTX_new();
491 if (ctx == NULL) exit(1);
492
498 BN_init(&a); 493 BN_init(&a);
499 BN_init(&b); 494 BN_init(&b);
500 BN_init(&c); 495 BN_init(&c);
@@ -512,10 +507,7 @@ int test_mul(BIO *bp)
512 BN_bntest_rand(&b,i-num1,0,0); 507 BN_bntest_rand(&b,i-num1,0,0);
513 a.neg=rand_neg(); 508 a.neg=rand_neg();
514 b.neg=rand_neg(); 509 b.neg=rand_neg();
515 if (bp == NULL) 510 BN_mul(&c,&a,&b,ctx);
516 for (j=0; j<100; j++)
517 BN_mul(&c,&a,&b,&ctx);
518 BN_mul(&c,&a,&b,&ctx);
519 if (bp != NULL) 511 if (bp != NULL)
520 { 512 {
521 if (!results) 513 if (!results)
@@ -528,7 +520,7 @@ int test_mul(BIO *bp)
528 BN_print(bp,&c); 520 BN_print(bp,&c);
529 BIO_puts(bp,"\n"); 521 BIO_puts(bp,"\n");
530 } 522 }
531 BN_div(&d,&e,&c,&a,&ctx); 523 BN_div(&d,&e,&c,&a,ctx);
532 BN_sub(&d,&d,&b); 524 BN_sub(&d,&d,&b);
533 if(!BN_is_zero(&d) || !BN_is_zero(&e)) 525 if(!BN_is_zero(&d) || !BN_is_zero(&e))
534 { 526 {
@@ -541,7 +533,7 @@ int test_mul(BIO *bp)
541 BN_free(&c); 533 BN_free(&c);
542 BN_free(&d); 534 BN_free(&d);
543 BN_free(&e); 535 BN_free(&e);
544 BN_CTX_free(&ctx); 536 BN_CTX_free(ctx);
545 return(1); 537 return(1);
546 } 538 }
547 539
@@ -549,7 +541,6 @@ int test_sqr(BIO *bp, BN_CTX *ctx)
549 { 541 {
550 BIGNUM a,c,d,e; 542 BIGNUM a,c,d,e;
551 int i; 543 int i;
552 int j;
553 544
554 BN_init(&a); 545 BN_init(&a);
555 BN_init(&c); 546 BN_init(&c);
@@ -560,9 +551,6 @@ int test_sqr(BIO *bp, BN_CTX *ctx)
560 { 551 {
561 BN_bntest_rand(&a,40+i*10,0,0); 552 BN_bntest_rand(&a,40+i*10,0,0);
562 a.neg=rand_neg(); 553 a.neg=rand_neg();
563 if (bp == NULL)
564 for (j=0; j<100; j++)
565 BN_sqr(&c,&a,ctx);
566 BN_sqr(&c,&a,ctx); 554 BN_sqr(&c,&a,ctx);
567 if (bp != NULL) 555 if (bp != NULL)
568 { 556 {
@@ -596,7 +584,6 @@ int test_mont(BIO *bp, BN_CTX *ctx)
596 BIGNUM a,b,c,d,A,B; 584 BIGNUM a,b,c,d,A,B;
597 BIGNUM n; 585 BIGNUM n;
598 int i; 586 int i;
599 int j;
600 BN_MONT_CTX *mont; 587 BN_MONT_CTX *mont;
601 588
602 BN_init(&a); 589 BN_init(&a);
@@ -620,12 +607,12 @@ int test_mont(BIO *bp, BN_CTX *ctx)
620 BN_bntest_rand(&n,bits,0,1); 607 BN_bntest_rand(&n,bits,0,1);
621 BN_MONT_CTX_set(mont,&n,ctx); 608 BN_MONT_CTX_set(mont,&n,ctx);
622 609
610 BN_nnmod(&a,&a,&n,ctx);
611 BN_nnmod(&b,&b,&n,ctx);
612
623 BN_to_montgomery(&A,&a,mont,ctx); 613 BN_to_montgomery(&A,&a,mont,ctx);
624 BN_to_montgomery(&B,&b,mont,ctx); 614 BN_to_montgomery(&B,&b,mont,ctx);
625 615
626 if (bp == NULL)
627 for (j=0; j<100; j++)
628 BN_mod_mul_montgomery(&c,&A,&B,mont,ctx);/**/
629 BN_mod_mul_montgomery(&c,&A,&B,mont,ctx);/**/ 616 BN_mod_mul_montgomery(&c,&A,&B,mont,ctx);/**/
630 BN_from_montgomery(&A,&c,mont,ctx);/**/ 617 BN_from_montgomery(&A,&c,mont,ctx);/**/
631 if (bp != NULL) 618 if (bp != NULL)
@@ -671,7 +658,6 @@ int test_mod(BIO *bp, BN_CTX *ctx)
671 { 658 {
672 BIGNUM *a,*b,*c,*d,*e; 659 BIGNUM *a,*b,*c,*d,*e;
673 int i; 660 int i;
674 int j;
675 661
676 a=BN_new(); 662 a=BN_new();
677 b=BN_new(); 663 b=BN_new();
@@ -685,9 +671,6 @@ int test_mod(BIO *bp, BN_CTX *ctx)
685 BN_bntest_rand(b,450+i*10,0,0); /**/ 671 BN_bntest_rand(b,450+i*10,0,0); /**/
686 a->neg=rand_neg(); 672 a->neg=rand_neg();
687 b->neg=rand_neg(); 673 b->neg=rand_neg();
688 if (bp == NULL)
689 for (j=0; j<100; j++)
690 BN_mod(c,a,b,ctx);/**/
691 BN_mod(c,a,b,ctx);/**/ 674 BN_mod(c,a,b,ctx);/**/
692 if (bp != NULL) 675 if (bp != NULL)
693 { 676 {
@@ -720,7 +703,7 @@ int test_mod(BIO *bp, BN_CTX *ctx)
720int test_mod_mul(BIO *bp, BN_CTX *ctx) 703int test_mod_mul(BIO *bp, BN_CTX *ctx)
721 { 704 {
722 BIGNUM *a,*b,*c,*d,*e; 705 BIGNUM *a,*b,*c,*d,*e;
723 int i; 706 int i,j;
724 707
725 a=BN_new(); 708 a=BN_new();
726 b=BN_new(); 709 b=BN_new();
@@ -728,6 +711,7 @@ int test_mod_mul(BIO *bp, BN_CTX *ctx)
728 d=BN_new(); 711 d=BN_new();
729 e=BN_new(); 712 e=BN_new();
730 713
714 for (j=0; j<3; j++) {
731 BN_bntest_rand(c,1024,0,0); /**/ 715 BN_bntest_rand(c,1024,0,0); /**/
732 for (i=0; i<num0; i++) 716 for (i=0; i<num0; i++)
733 { 717 {
@@ -735,10 +719,6 @@ int test_mod_mul(BIO *bp, BN_CTX *ctx)
735 BN_bntest_rand(b,425+i*11,0,0); /**/ 719 BN_bntest_rand(b,425+i*11,0,0); /**/
736 a->neg=rand_neg(); 720 a->neg=rand_neg();
737 b->neg=rand_neg(); 721 b->neg=rand_neg();
738 /* if (bp == NULL)
739 for (j=0; j<100; j++)
740 BN_mod_mul(d,a,b,c,ctx);*/ /**/
741
742 if (!BN_mod_mul(e,a,b,c,ctx)) 722 if (!BN_mod_mul(e,a,b,c,ctx))
743 { 723 {
744 unsigned long l; 724 unsigned long l;
@@ -757,6 +737,16 @@ int test_mod_mul(BIO *bp, BN_CTX *ctx)
757 BN_print(bp,b); 737 BN_print(bp,b);
758 BIO_puts(bp," % "); 738 BIO_puts(bp," % ");
759 BN_print(bp,c); 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 }
760 BIO_puts(bp," - "); 750 BIO_puts(bp," - ");
761 } 751 }
762 BN_print(bp,e); 752 BN_print(bp,e);
@@ -768,9 +758,11 @@ int test_mod_mul(BIO *bp, BN_CTX *ctx)
768 if(!BN_is_zero(b)) 758 if(!BN_is_zero(b))
769 { 759 {
770 fprintf(stderr,"Modulo multiply test failed!\n"); 760 fprintf(stderr,"Modulo multiply test failed!\n");
761 ERR_print_errors_fp(stderr);
771 return 0; 762 return 0;
772 } 763 }
773 } 764 }
765 }
774 BN_free(a); 766 BN_free(a);
775 BN_free(b); 767 BN_free(b);
776 BN_free(c); 768 BN_free(c);
@@ -880,6 +872,183 @@ int test_exp(BIO *bp, BN_CTX *ctx)
880 return(1); 872 return(1);
881 } 873 }
882 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; /* XXX should be BN_mod_exp_recp, but ..._recp triggers a bug that must be fixed */
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
883int test_lshift(BIO *bp,BN_CTX *ctx,BIGNUM *a_) 1052int test_lshift(BIO *bp,BN_CTX *ctx,BIGNUM *a_)
884 { 1053 {
885 BIGNUM *a,*b,*c,*d; 1054 BIGNUM *a,*b,*c,*d;
@@ -1052,7 +1221,7 @@ int test_rshift1(BIO *bp)
1052 } 1221 }
1053 BN_sub(c,a,b); 1222 BN_sub(c,a,b);
1054 BN_sub(c,c,b); 1223 BN_sub(c,c,b);
1055 if(!BN_is_zero(c) && !BN_is_one(c)) 1224 if(!BN_is_zero(c) && !BN_abs_is_word(c, 1))
1056 { 1225 {
1057 fprintf(stderr,"Right shift one test failed!\n"); 1226 fprintf(stderr,"Right shift one test failed!\n");
1058 return 0; 1227 return 0;
diff --git a/src/lib/libcrypto/bn/expspeed.c b/src/lib/libcrypto/bn/expspeed.c
index 2044ab9bff..07a1bcf51c 100644
--- a/src/lib/libcrypto/bn/expspeed.c
+++ b/src/lib/libcrypto/bn/expspeed.c
@@ -61,6 +61,31 @@
61/* most of this code has been pilfered from my libdes speed.c program */ 61/* most of this code has been pilfered from my libdes speed.c program */
62 62
63#define BASENUM 5000 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
64#undef PROG 89#undef PROG
65#define PROG bnspeed_main 90#define PROG bnspeed_main
66 91
@@ -70,8 +95,9 @@
70#include <string.h> 95#include <string.h>
71#include <openssl/crypto.h> 96#include <openssl/crypto.h>
72#include <openssl/err.h> 97#include <openssl/err.h>
98#include <openssl/rand.h>
73 99
74#if !defined(MSDOS) && (!defined(VMS) || defined(__DECC)) 100#if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX)
75#define TIMES 101#define TIMES
76#endif 102#endif
77 103
@@ -87,7 +113,7 @@
87 The __TMS macro will show if it was. If it wasn't defined, we should 113 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 114 undefine TIMES, since that tells the rest of the program how things
89 should be handled. -- Richard Levitte */ 115 should be handled. -- Richard Levitte */
90#if defined(VMS) && defined(__DECC) && !defined(__TMS) 116#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
91#undef TIMES 117#undef TIMES
92#endif 118#endif
93 119
@@ -161,11 +187,16 @@ static double Time_F(int s)
161#endif 187#endif
162 } 188 }
163 189
164#define NUM_SIZES 6 190#define NUM_SIZES 7
165static int sizes[NUM_SIZES]={256,512,1024,2048,4096,8192}; 191#if NUM_START > NUM_SIZES
166static int mul_c[NUM_SIZES]={8*8*8*8*8,8*8*8*8,8*8*8,8*8,8,1}; 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};
167/*static int sizes[NUM_SIZES]={59,179,299,419,539}; */ 196/*static int sizes[NUM_SIZES]={59,179,299,419,539}; */
168 197
198#define RAND_SEED(string) { const char str[] = string; RAND_seed(string, sizeof str); }
199
169void do_mul_exp(BIGNUM *r,BIGNUM *a,BIGNUM *b,BIGNUM *c,BN_CTX *ctx); 200void do_mul_exp(BIGNUM *r,BIGNUM *a,BIGNUM *b,BIGNUM *c,BN_CTX *ctx);
170 201
171int main(int argc, char **argv) 202int main(int argc, char **argv)
@@ -173,13 +204,23 @@ int main(int argc, char **argv)
173 BN_CTX *ctx; 204 BN_CTX *ctx;
174 BIGNUM *a,*b,*c,*r; 205 BIGNUM *a,*b,*c,*r;
175 206
207#if 1
208 if (!CRYPTO_set_mem_debug_functions(0,0,0,0,0))
209 abort();
210#endif
211
176 ctx=BN_CTX_new(); 212 ctx=BN_CTX_new();
177 a=BN_new(); 213 a=BN_new();
178 b=BN_new(); 214 b=BN_new();
179 c=BN_new(); 215 c=BN_new();
180 r=BN_new(); 216 r=BN_new();
181 217
218 while (!RAND_status())
219 /* not enough bits */
220 RAND_SEED("I demand a manual recount!");
221
182 do_mul_exp(r,a,b,c,ctx); 222 do_mul_exp(r,a,b,c,ctx);
223 return 0;
183 } 224 }
184 225
185void do_mul_exp(BIGNUM *r, BIGNUM *a, BIGNUM *b, BIGNUM *c, BN_CTX *ctx) 226void do_mul_exp(BIGNUM *r, BIGNUM *a, BIGNUM *b, BIGNUM *c, BN_CTX *ctx)
@@ -187,29 +228,126 @@ void do_mul_exp(BIGNUM *r, BIGNUM *a, BIGNUM *b, BIGNUM *c, BN_CTX *ctx)
187 int i,k; 228 int i,k;
188 double tm; 229 double tm;
189 long num; 230 long num;
190 BN_MONT_CTX m;
191
192 memset(&m,0,sizeof(m));
193 231
194 num=BASENUM; 232 num=BASENUM;
195 for (i=0; i<NUM_SIZES; i++) 233 for (i=NUM_START; i<NUM_SIZES; i++)
196 { 234 {
197 BN_rand(a,sizes[i],1,0); 235#ifdef C_PRIME
198 BN_rand(b,sizes[i],1,0); 236# ifdef TEST_SQRT
199 BN_rand(c,sizes[i],1,1); 237 if (!BN_set_word(a, 64)) goto err;
200 BN_mod(a,a,c,ctx); 238 if (!BN_set_word(b, P_MOD_64)) goto err;
201 BN_mod(b,b,c,ctx); 239# define ADD a
202 240# define REM b
203 BN_MONT_CTX_set(&m,c,ctx); 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
204 249
205 Time_F(START);
206 for (k=0; k<num; k++) 250 for (k=0; k<num; k++)
207 BN_mod_exp_mont(r,a,b,c,ctx,&m); 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 }
208 tm=Time_F(STOP); 307 tm=Time_F(STOP);
209 printf("mul %4d ^ %4d %% %d -> %8.3fms %5.1f\n",sizes[i],sizes[i],sizes[i],tm*1000.0/num,tm*mul_c[i]/num); 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);
210 num/=7; 329 num/=7;
211 if (num <= 0) num=1; 330 if (num <= 0) num=1;
212 } 331 }
332 return;
213 333
334 err:
335 ERR_print_errors_fp(stderr);
214 } 336 }
215 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
index 3e86f2ea0e..5ca570d1a8 100644
--- a/src/lib/libcrypto/bn/exptest.c
+++ b/src/lib/libcrypto/bn/exptest.c
@@ -63,7 +63,7 @@
63#include <openssl/bn.h> 63#include <openssl/bn.h>
64#include <openssl/rand.h> 64#include <openssl/rand.h>
65#include <openssl/err.h> 65#include <openssl/err.h>
66#ifdef WINDOWS 66#ifdef OPENSSL_SYS_WINDOWS
67#include "../bio/bss_file.c" 67#include "../bio/bss_file.c"
68#endif 68#endif
69 69
diff --git a/src/lib/libcrypto/bn/vms-helper.c b/src/lib/libcrypto/bn/vms-helper.c
index 0fa79c4edb..4b63149bf3 100644
--- a/src/lib/libcrypto/bn/vms-helper.c
+++ b/src/lib/libcrypto/bn/vms-helper.c
@@ -60,7 +60,7 @@
60bn_div_words_abort(int i) 60bn_div_words_abort(int i)
61{ 61{
62#ifdef BN_DEBUG 62#ifdef BN_DEBUG
63#if !defined(NO_STDIO) && !defined(WIN16) 63#if !defined(OPENSSL_NO_STDIO) && !defined(OPENSSL_SYS_WIN16)
64 fprintf(stderr,"Division would overflow (%d)\n",i); 64 fprintf(stderr,"Division would overflow (%d)\n",i);
65#endif 65#endif
66 abort(); 66 abort();
diff --git a/src/lib/libcrypto/buffer/Makefile.ssl b/src/lib/libcrypto/buffer/Makefile.ssl
index a64681fd22..b8b6439503 100644
--- a/src/lib/libcrypto/buffer/Makefile.ssl
+++ b/src/lib/libcrypto/buffer/Makefile.ssl
@@ -5,13 +5,14 @@
5DIR= buffer 5DIR= buffer
6TOP= ../.. 6TOP= ../..
7CC= cc 7CC= cc
8INCLUDES= -I.. -I../../include 8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g 9CFLAG=-g
10INSTALL_PREFIX= 10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl 11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl 12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl 13MAKE= make -f Makefile.ssl
14MAKEDEPEND= $(TOP)/util/domd $(TOP) 14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
15MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
16AR= ar r 17AR= ar r
17 18
@@ -39,8 +40,7 @@ all: lib
39 40
40lib: $(LIBOBJ) 41lib: $(LIBOBJ)
41 $(AR) $(LIB) $(LIBOBJ) 42 $(AR) $(LIB) $(LIBOBJ)
42 @echo You may get an error following this line. Please ignore. 43 $(RANLIB) $(LIB) || echo Never mind.
43 - $(RANLIB) $(LIB)
44 @touch lib 44 @touch lib
45 45
46files: 46files:
@@ -80,14 +80,15 @@ clean:
80# DO NOT DELETE THIS LINE -- make depend depends on it. 80# DO NOT DELETE THIS LINE -- make depend depends on it.
81 81
82buf_err.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 82buf_err.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
83buf_err.o: ../../include/openssl/crypto.h ../../include/openssl/err.h 83buf_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
84buf_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslv.h 84buf_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
85buf_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
85buf_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 86buf_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
86buf_err.o: ../../include/openssl/symhacks.h 87buf_err.o: ../../include/openssl/symhacks.h buf_err.c
87buffer.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 88buffer.o: ../../e_os.h ../../include/openssl/bio.h
88buffer.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 89buffer.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
89buffer.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 90buffer.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
90buffer.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 91buffer.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
91buffer.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 92buffer.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
92buffer.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 93buffer.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
93buffer.o: ../cryptlib.h 94buffer.o: ../cryptlib.h buffer.c
diff --git a/src/lib/libcrypto/buffer/buf_err.c b/src/lib/libcrypto/buffer/buf_err.c
index 2f971a5f38..5eee653e14 100644
--- a/src/lib/libcrypto/buffer/buf_err.c
+++ b/src/lib/libcrypto/buffer/buf_err.c
@@ -63,7 +63,7 @@
63#include <openssl/buffer.h> 63#include <openssl/buffer.h>
64 64
65/* BEGIN ERROR CODES */ 65/* BEGIN ERROR CODES */
66#ifndef NO_ERR 66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA BUF_str_functs[]= 67static ERR_STRING_DATA BUF_str_functs[]=
68 { 68 {
69{ERR_PACK(0,BUF_F_BUF_MEM_GROW,0), "BUF_MEM_grow"}, 69{ERR_PACK(0,BUF_F_BUF_MEM_GROW,0), "BUF_MEM_grow"},
@@ -86,7 +86,7 @@ void ERR_load_BUF_strings(void)
86 if (init) 86 if (init)
87 { 87 {
88 init=0; 88 init=0;
89#ifndef NO_ERR 89#ifndef OPENSSL_NO_ERR
90 ERR_load_strings(ERR_LIB_BUF,BUF_str_functs); 90 ERR_load_strings(ERR_LIB_BUF,BUF_str_functs);
91 ERR_load_strings(ERR_LIB_BUF,BUF_str_reasons); 91 ERR_load_strings(ERR_LIB_BUF,BUF_str_reasons);
92#endif 92#endif
diff --git a/src/lib/libcrypto/buffer/buffer.c b/src/lib/libcrypto/buffer/buffer.c
index b76ff3ad7a..9299baba9e 100644
--- a/src/lib/libcrypto/buffer/buffer.c
+++ b/src/lib/libcrypto/buffer/buffer.c
@@ -118,8 +118,9 @@ int BUF_MEM_grow(BUF_MEM *str, int len)
118 else 118 else
119 { 119 {
120 str->data=ret; 120 str->data=ret;
121 str->length=len;
122 str->max=n; 121 str->max=n;
122 memset(&str->data[str->length],0,len-str->length);
123 str->length=len;
123 } 124 }
124 return(len); 125 return(len);
125 } 126 }
diff --git a/src/lib/libcrypto/buffer/buffer.h b/src/lib/libcrypto/buffer/buffer.h
index bff26bf391..11e2d0359a 100644
--- a/src/lib/libcrypto/buffer/buffer.h
+++ b/src/lib/libcrypto/buffer/buffer.h
@@ -75,12 +75,11 @@ void BUF_MEM_free(BUF_MEM *a);
75int BUF_MEM_grow(BUF_MEM *str, int len); 75int BUF_MEM_grow(BUF_MEM *str, int len);
76char * BUF_strdup(const char *str); 76char * BUF_strdup(const char *str);
77 77
78void ERR_load_BUF_strings(void );
79
80/* BEGIN ERROR CODES */ 78/* BEGIN ERROR CODES */
81/* 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
82 * 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.
83 */ 81 */
82void ERR_load_BUF_strings(void);
84 83
85/* Error codes for the BUF functions. */ 84/* Error codes for the BUF functions. */
86 85
@@ -95,4 +94,3 @@ void ERR_load_BUF_strings(void );
95} 94}
96#endif 95#endif
97#endif 96#endif
98
diff --git a/src/lib/libcrypto/cast/Makefile.ssl b/src/lib/libcrypto/cast/Makefile.ssl
index 1f8b898f7c..a2bf56276b 100644
--- a/src/lib/libcrypto/cast/Makefile.ssl
+++ b/src/lib/libcrypto/cast/Makefile.ssl
@@ -12,7 +12,8 @@ INSTALL_PREFIX=
12OPENSSLDIR= /usr/local/ssl 12OPENSSLDIR= /usr/local/ssl
13INSTALLTOP=/usr/local/ssl 13INSTALLTOP=/usr/local/ssl
14MAKE= make -f Makefile.ssl 14MAKE= make -f Makefile.ssl
15MAKEDEPEND= $(TOP)/util/domd $(TOP) 15MAKEDEPPROG= makedepend
16MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl 17MAKEFILE= Makefile.ssl
17AR= ar r 18AR= ar r
18 19
@@ -47,8 +48,7 @@ all: lib
47 48
48lib: $(LIBOBJ) 49lib: $(LIBOBJ)
49 $(AR) $(LIB) $(LIBOBJ) 50 $(AR) $(LIB) $(LIBOBJ)
50 @echo You may get an error following this line. Please ignore. 51 $(RANLIB) $(LIB) || echo Never mind.
51 - $(RANLIB) $(LIB)
52 @touch lib 52 @touch lib
53 53
54# elf 54# elf
@@ -108,18 +108,18 @@ clean:
108 108
109# DO NOT DELETE THIS LINE -- make depend depends on it. 109# DO NOT DELETE THIS LINE -- make depend depends on it.
110 110
111c_cfb64.o: ../../include/openssl/cast.h ../../include/openssl/e_os.h 111c_cfb64.o: ../../e_os.h ../../include/openssl/cast.h
112c_cfb64.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h 112c_cfb64.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
113c_cfb64.o: cast_lcl.h 113c_cfb64.o: c_cfb64.c cast_lcl.h
114c_ecb.o: ../../include/openssl/cast.h ../../include/openssl/e_os.h 114c_ecb.o: ../../e_os.h ../../include/openssl/cast.h
115c_ecb.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h 115c_ecb.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
116c_ecb.o: ../../include/openssl/opensslv.h cast_lcl.h 116c_ecb.o: ../../include/openssl/opensslv.h c_ecb.c cast_lcl.h
117c_enc.o: ../../include/openssl/cast.h ../../include/openssl/e_os.h 117c_enc.o: ../../e_os.h ../../include/openssl/cast.h
118c_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h 118c_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
119c_enc.o: cast_lcl.h 119c_enc.o: c_enc.c cast_lcl.h
120c_ofb64.o: ../../include/openssl/cast.h ../../include/openssl/e_os.h 120c_ofb64.o: ../../e_os.h ../../include/openssl/cast.h
121c_ofb64.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h 121c_ofb64.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
122c_ofb64.o: cast_lcl.h 122c_ofb64.o: c_ofb64.c cast_lcl.h
123c_skey.o: ../../include/openssl/cast.h ../../include/openssl/e_os.h 123c_skey.o: ../../e_os.h ../../include/openssl/cast.h
124c_skey.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h 124c_skey.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
125c_skey.o: cast_lcl.h cast_s.h 125c_skey.o: c_skey.c cast_lcl.h cast_s.h
diff --git a/src/lib/libcrypto/cast/cast.h b/src/lib/libcrypto/cast/cast.h
index e24e133099..b28e4e4f3b 100644
--- a/src/lib/libcrypto/cast/cast.h
+++ b/src/lib/libcrypto/cast/cast.h
@@ -63,7 +63,7 @@
63extern "C" { 63extern "C" {
64#endif 64#endif
65 65
66#ifdef NO_CAST 66#ifdef OPENSSL_NO_CAST
67#error CAST is disabled. 67#error CAST is disabled.
68#endif 68#endif
69 69
diff --git a/src/lib/libcrypto/cast/cast_lcl.h b/src/lib/libcrypto/cast/cast_lcl.h
index 5fab8a43f6..37f41cc6a4 100644
--- a/src/lib/libcrypto/cast/cast_lcl.h
+++ b/src/lib/libcrypto/cast/cast_lcl.h
@@ -56,12 +56,18 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifdef WIN32 59
60#include "e_os.h"
61
62#ifdef OPENSSL_SYS_WIN32
60#include <stdlib.h> 63#include <stdlib.h>
61#endif 64#endif
62 65
63 66
64#include "openssl/e_os.h" /* OPENSSL_EXTERN */ 67#ifdef OPENSSL_BUILD_SHLIBCRYPTO
68# undef OPENSSL_EXTERN
69# define OPENSSL_EXTERN OPENSSL_EXPORT
70#endif
65 71
66#undef c2l 72#undef c2l
67#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \ 73#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \
@@ -151,7 +157,7 @@
151 *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ 157 *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
152 *((c)++)=(unsigned char)(((l) )&0xff)) 158 *((c)++)=(unsigned char)(((l) )&0xff))
153 159
154#if defined(WIN32) && defined(_MSC_VER) 160#if defined(OPENSSL_SYS_WIN32) && defined(_MSC_VER)
155#define ROTL(a,n) (_lrotl(a,n)) 161#define ROTL(a,n) (_lrotl(a,n))
156#else 162#else
157#define ROTL(a,n) ((((a)<<(n))&0xffffffffL)|((a)>>(32-(n)))) 163#define ROTL(a,n) ((((a)<<(n))&0xffffffffL)|((a)>>(32-(n))))
diff --git a/src/lib/libcrypto/cast/cast_spd.c b/src/lib/libcrypto/cast/cast_spd.c
index 0af915cf20..76abf50d98 100644
--- a/src/lib/libcrypto/cast/cast_spd.c
+++ b/src/lib/libcrypto/cast/cast_spd.c
@@ -59,7 +59,7 @@
59/* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */ 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 */ 60/* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */
61 61
62#if !defined(MSDOS) && (!defined(VMS) || defined(__DECC)) 62#if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX)
63#define TIMES 63#define TIMES
64#endif 64#endif
65 65
@@ -82,7 +82,7 @@ OPENSSL_DECLARE_EXIT
82 The __TMS macro will show if it was. If it wasn't defined, we should 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 83 undefine TIMES, since that tells the rest of the program how things
84 should be handled. -- Richard Levitte */ 84 should be handled. -- Richard Levitte */
85#if defined(VMS) && defined(__DECC) && !defined(__TMS) 85#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
86#undef TIMES 86#undef TIMES
87#endif 87#endif
88 88
@@ -268,7 +268,7 @@ int main(int argc, char **argv)
268 printf("CAST raw ecb bytes per sec = %12.2f (%9.3fuS)\n",b,8.0e6/b); 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); 269 printf("CAST cbc bytes per sec = %12.2f (%9.3fuS)\n",c,8.0e6/c);
270 exit(0); 270 exit(0);
271#if defined(LINT) || defined(MSDOS) 271#if defined(LINT) || defined(OPENSSL_SYS_MSDOS)
272 return(0); 272 return(0);
273#endif 273#endif
274 } 274 }
diff --git a/src/lib/libcrypto/cast/castopts.c b/src/lib/libcrypto/cast/castopts.c
index c783796610..1b858d153b 100644
--- a/src/lib/libcrypto/cast/castopts.c
+++ b/src/lib/libcrypto/cast/castopts.c
@@ -59,7 +59,7 @@
59/* define PART1, PART2, PART3 or PART4 to build only with a few of the options. 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. */ 60 * This is for machines with 64k code segment size restrictions. */
61 61
62#if !defined(MSDOS) && (!defined(VMS) || defined(__DECC)) 62#if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC))
63#define TIMES 63#define TIMES
64#endif 64#endif
65 65
@@ -82,7 +82,7 @@ OPENSSL_DECLARE_EXIT
82 The __TMS macro will show if it was. If it wasn't defined, we should 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 83 undefine TIMES, since that tells the rest of the program how things
84 should be handled. -- Richard Levitte */ 84 should be handled. -- Richard Levitte */
85#if defined(VMS) && defined(__DECC) && !defined(__TMS) 85#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
86#undef TIMES 86#undef TIMES
87#endif 87#endif
88 88
@@ -332,7 +332,7 @@ int main(int argc, char **argv)
332 break; 332 break;
333 } 333 }
334 exit(0); 334 exit(0);
335#if defined(LINT) || defined(MSDOS) 335#if defined(LINT) || defined(OPENSSL_SYS_MSDOS)
336 return(0); 336 return(0);
337#endif 337#endif
338 } 338 }
diff --git a/src/lib/libcrypto/cast/casttest.c b/src/lib/libcrypto/cast/casttest.c
index ab2aeac606..099e790886 100644
--- a/src/lib/libcrypto/cast/casttest.c
+++ b/src/lib/libcrypto/cast/casttest.c
@@ -60,7 +60,7 @@
60#include <string.h> 60#include <string.h>
61#include <stdlib.h> 61#include <stdlib.h>
62 62
63#ifdef NO_CAST 63#ifdef OPENSSL_NO_CAST
64int main(int argc, char *argv[]) 64int main(int argc, char *argv[])
65{ 65{
66 printf("No CAST support\n"); 66 printf("No CAST support\n");
diff --git a/src/lib/libcrypto/comp/Makefile.ssl b/src/lib/libcrypto/comp/Makefile.ssl
index b696ac75fe..5dadb65cd4 100644
--- a/src/lib/libcrypto/comp/Makefile.ssl
+++ b/src/lib/libcrypto/comp/Makefile.ssl
@@ -5,13 +5,14 @@
5DIR= comp 5DIR= comp
6TOP= ../.. 6TOP= ../..
7CC= cc 7CC= cc
8INCLUDES= -I.. -I../../include 8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g 9CFLAG=-g
10INSTALL_PREFIX= 10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl 11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl 12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl 13MAKE= make -f Makefile.ssl
14MAKEDEPEND= $(TOP)/util/domd $(TOP) 14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
15MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
16AR= ar r 17AR= ar r
17 18
@@ -22,10 +23,10 @@ TEST=
22APPS= 23APPS=
23 24
24LIB=$(TOP)/libcrypto.a 25LIB=$(TOP)/libcrypto.a
25LIBSRC= comp_lib.c \ 26LIBSRC= comp_lib.c comp_err.c \
26 c_rle.c c_zlib.c 27 c_rle.c c_zlib.c
27 28
28LIBOBJ= comp_lib.o \ 29LIBOBJ= comp_lib.o comp_err.o \
29 c_rle.o c_zlib.o 30 c_rle.o c_zlib.o
30 31
31SRC= $(LIBSRC) 32SRC= $(LIBSRC)
@@ -42,8 +43,7 @@ all: lib
42 43
43lib: $(LIBOBJ) 44lib: $(LIBOBJ)
44 $(AR) $(LIB) $(LIBOBJ) 45 $(AR) $(LIB) $(LIBOBJ)
45 @echo You may get an error following this line. Please ignore. 46 $(RANLIB) $(LIB) || echo Never mind.
46 - $(RANLIB) $(LIB)
47 @touch lib 47 @touch lib
48 48
49files: 49files:
@@ -84,19 +84,31 @@ clean:
84 84
85c_rle.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 85c_rle.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
86c_rle.o: ../../include/openssl/bn.h ../../include/openssl/comp.h 86c_rle.o: ../../include/openssl/bn.h ../../include/openssl/comp.h
87c_rle.o: ../../include/openssl/crypto.h ../../include/openssl/obj_mac.h 87c_rle.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
88c_rle.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 88c_rle.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
89c_rle.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 89c_rle.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
90c_rle.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.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
91c_zlib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 92c_zlib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
92c_zlib.o: ../../include/openssl/bn.h ../../include/openssl/comp.h 93c_zlib.o: ../../include/openssl/bn.h ../../include/openssl/comp.h
93c_zlib.o: ../../include/openssl/crypto.h ../../include/openssl/obj_mac.h 94c_zlib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
94c_zlib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 95c_zlib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
95c_zlib.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 96c_zlib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
97c_zlib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
96c_zlib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.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
97comp_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 107comp_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
98comp_lib.o: ../../include/openssl/bn.h ../../include/openssl/comp.h 108comp_lib.o: ../../include/openssl/bn.h ../../include/openssl/comp.h
99comp_lib.o: ../../include/openssl/crypto.h ../../include/openssl/obj_mac.h 109comp_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
100comp_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 110comp_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
101comp_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 111comp_lib.o: ../../include/openssl/opensslconf.h
102comp_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.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_rle.c b/src/lib/libcrypto/comp/c_rle.c
index 1a819e3737..efd366fa22 100644
--- a/src/lib/libcrypto/comp/c_rle.c
+++ b/src/lib/libcrypto/comp/c_rle.c
@@ -17,6 +17,7 @@ static COMP_METHOD rle_method={
17 rle_compress_block, 17 rle_compress_block,
18 rle_expand_block, 18 rle_expand_block,
19 NULL, 19 NULL,
20 NULL,
20 }; 21 };
21 22
22COMP_METHOD *COMP_rle(void) 23COMP_METHOD *COMP_rle(void)
diff --git a/src/lib/libcrypto/comp/c_zlib.c b/src/lib/libcrypto/comp/c_zlib.c
index 6684ab4841..cd2f8a491b 100644
--- a/src/lib/libcrypto/comp/c_zlib.c
+++ b/src/lib/libcrypto/comp/c_zlib.c
@@ -6,11 +6,10 @@
6 6
7COMP_METHOD *COMP_zlib(void ); 7COMP_METHOD *COMP_zlib(void );
8 8
9#ifndef ZLIB 9static COMP_METHOD zlib_method_nozlib={
10
11static COMP_METHOD zlib_method={
12 NID_undef, 10 NID_undef,
13 "(null)", 11 "(undef)",
12 NULL,
14 NULL, 13 NULL,
15 NULL, 14 NULL,
16 NULL, 15 NULL,
@@ -18,6 +17,8 @@ static COMP_METHOD zlib_method={
18 NULL, 17 NULL,
19 }; 18 };
20 19
20#ifndef ZLIB
21#undef ZLIB_SHARED
21#else 22#else
22 23
23#include <zlib.h> 24#include <zlib.h>
@@ -38,8 +39,56 @@ static COMP_METHOD zlib_method={
38 zlib_compress_block, 39 zlib_compress_block,
39 zlib_expand_block, 40 zlib_expand_block,
40 NULL, 41 NULL,
42 NULL,
41 }; 43 };
42 44
45/*
46 * When OpenSSL is built on Windows, we do not want to require that
47 * the ZLIB.DLL be available in order for the OpenSSL DLLs to
48 * work. Therefore, all ZLIB routines are loaded at run time
49 * and we do not link to a .LIB file.
50 */
51#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32)
52# include <windows.h>
53
54# define Z_CALLCONV _stdcall
55# define ZLIB_SHARED
56#else
57# define Z_CALLCONV
58#endif /* !(OPENSSL_SYS_WINDOWS || OPENSSL_SYS_WIN32) */
59
60#ifdef ZLIB_SHARED
61#include <openssl/dso.h>
62
63/* Prototypes for built in stubs */
64static int stub_compress(Bytef *dest,uLongf *destLen,
65 const Bytef *source, uLong sourceLen);
66static int stub_inflateEnd(z_streamp strm);
67static int stub_inflate(z_streamp strm, int flush);
68static int stub_inflateInit_(z_streamp strm, const char * version,
69 int stream_size);
70
71/* Function pointers */
72typedef int (Z_CALLCONV *compress_ft)(Bytef *dest,uLongf *destLen,
73 const Bytef *source, uLong sourceLen);
74typedef int (Z_CALLCONV *inflateEnd_ft)(z_streamp strm);
75typedef int (Z_CALLCONV *inflate_ft)(z_streamp strm, int flush);
76typedef int (Z_CALLCONV *inflateInit__ft)(z_streamp strm,
77 const char * version, int stream_size);
78static compress_ft p_compress=NULL;
79static inflateEnd_ft p_inflateEnd=NULL;
80static inflate_ft p_inflate=NULL;
81static inflateInit__ft p_inflateInit_=NULL;
82
83static int zlib_loaded = 0; /* only attempt to init func pts once */
84static DSO *zlib_dso = NULL;
85
86#define compress stub_compress
87#define inflateEnd stub_inflateEnd
88#define inflate stub_inflate
89#define inflateInit_ stub_inflateInit_
90#endif /* ZLIB_SHARED */
91
43static int zlib_compress_block(COMP_CTX *ctx, unsigned char *out, 92static int zlib_compress_block(COMP_CTX *ctx, unsigned char *out,
44 unsigned int olen, unsigned char *in, unsigned int ilen) 93 unsigned int olen, unsigned char *in, unsigned int ilen)
45 { 94 {
@@ -66,7 +115,10 @@ static int zlib_compress_block(COMP_CTX *ctx, unsigned char *out,
66 memcpy(&(out[1]),in,ilen); 115 memcpy(&(out[1]),in,ilen);
67 l=ilen+1; 116 l=ilen+1;
68 } 117 }
69fprintf(stderr,"compress(%4d)->%4d %s\n",ilen,(int)l,(clear)?"clear":"zlib"); 118#ifdef DEBUG_ZLIB
119 fprintf(stderr,"compress(%4d)->%4d %s\n",
120 ilen,(int)l,(clear)?"clear":"zlib");
121#endif
70 return((int)l); 122 return((int)l);
71 } 123 }
72 124
@@ -88,7 +140,10 @@ static int zlib_expand_block(COMP_CTX *ctx, unsigned char *out,
88 memcpy(out,&(in[1]),ilen-1); 140 memcpy(out,&(in[1]),ilen-1);
89 l=ilen-1; 141 l=ilen-1;
90 } 142 }
91 fprintf(stderr,"expand (%4d)->%4d %s\n",ilen,(int)l,in[0]?"zlib":"clear"); 143#ifdef DEBUG_ZLIB
144 fprintf(stderr,"expand (%4d)->%4d %s\n",
145 ilen,(int)l,in[0]?"zlib":"clear");
146#endif
92 return((int)l); 147 return((int)l);
93 } 148 }
94 149
@@ -128,6 +183,78 @@ static int zz_uncompress (Bytef *dest, uLongf *destLen, const Bytef *source,
128 183
129COMP_METHOD *COMP_zlib(void) 184COMP_METHOD *COMP_zlib(void)
130 { 185 {
131 return(&zlib_method); 186 COMP_METHOD *meth = &zlib_method_nozlib;
187
188#ifdef ZLIB_SHARED
189 if (!zlib_loaded)
190 {
191#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32)
192 zlib_dso = DSO_load(NULL, "ZLIB", NULL, 0);
193#else
194 zlib_dso = DSO_load(NULL, "z", NULL, 0);
195#endif
196 if (zlib_dso != NULL)
197 {
198 p_compress
199 = (compress_ft) DSO_bind_func(zlib_dso,
200 "compress");
201 p_inflateEnd
202 = (inflateEnd_ft) DSO_bind_func(zlib_dso,
203 "inflateEnd");
204 p_inflate
205 = (inflate_ft) DSO_bind_func(zlib_dso,
206 "inflate");
207 p_inflateInit_
208 = (inflateInit__ft) DSO_bind_func(zlib_dso,
209 "inflateInit_");
210 zlib_loaded++;
211 meth = &zlib_method;
212 }
213 }
214
215#elif defined(ZLIB)
216 meth = &zlib_method;
217#endif
218
219 return(meth);
220 }
221
222#ifdef ZLIB_SHARED
223/* Stubs for each function to be dynamicly loaded */
224static int
225stub_compress(Bytef *dest,uLongf *destLen,const Bytef *source, uLong sourceLen)
226 {
227 if (p_compress)
228 return(p_compress(dest,destLen,source,sourceLen));
229 else
230 return(Z_MEM_ERROR);
231 }
232
233static int
234stub_inflateEnd(z_streamp strm)
235 {
236 if ( p_inflateEnd )
237 return(p_inflateEnd(strm));
238 else
239 return(Z_MEM_ERROR);
240 }
241
242static int
243stub_inflate(z_streamp strm, int flush)
244 {
245 if ( p_inflate )
246 return(p_inflate(strm,flush));
247 else
248 return(Z_MEM_ERROR);
249 }
250
251static int
252stub_inflateInit_(z_streamp strm, const char * version, int stream_size)
253 {
254 if ( p_inflateInit_ )
255 return(p_inflateInit_(strm,version,stream_size));
256 else
257 return(Z_MEM_ERROR);
132 } 258 }
133 259
260#endif /* ZLIB_SHARED */
diff --git a/src/lib/libcrypto/comp/comp.h b/src/lib/libcrypto/comp/comp.h
index 0922609542..ab48b78ae9 100644
--- a/src/lib/libcrypto/comp/comp.h
+++ b/src/lib/libcrypto/comp/comp.h
@@ -39,14 +39,13 @@ int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen,
39int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen, 39int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen,
40 unsigned char *in, int ilen); 40 unsigned char *in, int ilen);
41COMP_METHOD *COMP_rle(void ); 41COMP_METHOD *COMP_rle(void );
42#ifdef ZLIB
43COMP_METHOD *COMP_zlib(void ); 42COMP_METHOD *COMP_zlib(void );
44#endif
45 43
46/* BEGIN ERROR CODES */ 44/* BEGIN ERROR CODES */
47/* The following lines are auto generated by the script mkerr.pl. Any changes 45/* The following lines are auto generated by the script mkerr.pl. Any changes
48 * made after this point may be overwritten when the script is next run. 46 * made after this point may be overwritten when the script is next run.
49 */ 47 */
48void ERR_load_COMP_strings(void);
50 49
51/* Error codes for the COMP functions. */ 50/* Error codes for the COMP functions. */
52 51
@@ -58,4 +57,3 @@ COMP_METHOD *COMP_zlib(void );
58} 57}
59#endif 58#endif
60#endif 59#endif
61
diff --git a/src/lib/libcrypto/comp/comp_err.c b/src/lib/libcrypto/comp/comp_err.c
index c10282a73c..1652b8c2c4 100644
--- a/src/lib/libcrypto/comp/comp_err.c
+++ b/src/lib/libcrypto/comp/comp_err.c
@@ -63,7 +63,7 @@
63#include <openssl/comp.h> 63#include <openssl/comp.h>
64 64
65/* BEGIN ERROR CODES */ 65/* BEGIN ERROR CODES */
66#ifndef NO_ERR 66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA COMP_str_functs[]= 67static ERR_STRING_DATA COMP_str_functs[]=
68 { 68 {
69{0,NULL} 69{0,NULL}
@@ -83,7 +83,7 @@ void ERR_load_COMP_strings(void)
83 if (init) 83 if (init)
84 { 84 {
85 init=0; 85 init=0;
86#ifndef NO_ERR 86#ifndef OPENSSL_NO_ERR
87 ERR_load_strings(ERR_LIB_COMP,COMP_str_functs); 87 ERR_load_strings(ERR_LIB_COMP,COMP_str_functs);
88 ERR_load_strings(ERR_LIB_COMP,COMP_str_reasons); 88 ERR_load_strings(ERR_LIB_COMP,COMP_str_reasons);
89#endif 89#endif
diff --git a/src/lib/libcrypto/conf/Makefile.ssl b/src/lib/libcrypto/conf/Makefile.ssl
index 9df4fca877..795eec1a01 100644
--- a/src/lib/libcrypto/conf/Makefile.ssl
+++ b/src/lib/libcrypto/conf/Makefile.ssl
@@ -5,13 +5,14 @@
5DIR= conf 5DIR= conf
6TOP= ../.. 6TOP= ../..
7CC= cc 7CC= cc
8INCLUDES= -I.. -I../../include 8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g 9CFLAG=-g
10INSTALL_PREFIX= 10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl 11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl 12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl 13MAKE= make -f Makefile.ssl
14MAKEDEPEND= $(TOP)/util/domd $(TOP) 14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
15MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
16AR= ar r 17AR= ar r
17 18
@@ -22,9 +23,11 @@ TEST=
22APPS= 23APPS=
23 24
24LIB=$(TOP)/libcrypto.a 25LIB=$(TOP)/libcrypto.a
25LIBSRC= conf_err.c conf_lib.c conf_api.c conf_def.c 26LIBSRC= conf_err.c conf_lib.c conf_api.c conf_def.c conf_mod.c \
27 conf_mall.c conf_sap.c
26 28
27LIBOBJ= conf_err.o conf_lib.o conf_api.o conf_def.o 29LIBOBJ= conf_err.o conf_lib.o conf_api.o conf_def.o conf_mod.o \
30 conf_mall.o conf_sap.o
28 31
29SRC= $(LIBSRC) 32SRC= $(LIBSRC)
30 33
@@ -40,8 +43,7 @@ all: lib
40 43
41lib: $(LIBOBJ) 44lib: $(LIBOBJ)
42 $(AR) $(LIB) $(LIBOBJ) 45 $(AR) $(LIB) $(LIBOBJ)
43 @echo You may get an error following this line. Please ignore. 46 $(RANLIB) $(LIB) || echo Never mind.
44 - $(RANLIB) $(LIB)
45 @touch lib 47 @touch lib
46 48
47files: 49files:
@@ -80,30 +82,80 @@ clean:
80 82
81# DO NOT DELETE THIS LINE -- make depend depends on it. 83# DO NOT DELETE THIS LINE -- make depend depends on it.
82 84
83conf_api.o: ../../include/openssl/bio.h ../../include/openssl/conf.h 85conf_api.o: ../../e_os.h ../../include/openssl/bio.h
84conf_api.o: ../../include/openssl/conf_api.h ../../include/openssl/crypto.h 86conf_api.o: ../../include/openssl/conf.h ../../include/openssl/conf_api.h
85conf_api.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 87conf_api.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
86conf_api.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 88conf_api.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
87conf_api.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 89conf_api.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
88conf_api.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 90conf_api.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
91conf_api.o: conf_api.c
89conf_def.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 92conf_def.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
90conf_def.o: ../../include/openssl/conf.h ../../include/openssl/conf_api.h 93conf_def.o: ../../include/openssl/conf.h ../../include/openssl/conf_api.h
91conf_def.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 94conf_def.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
92conf_def.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 95conf_def.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
93conf_def.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 96conf_def.o: ../../include/openssl/opensslconf.h
94conf_def.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 97conf_def.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
95conf_def.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 98conf_def.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
96conf_def.o: conf_def.h 99conf_def.o: conf_def.c conf_def.h
97conf_err.o: ../../include/openssl/bio.h ../../include/openssl/conf.h 100conf_err.o: ../../include/openssl/bio.h ../../include/openssl/conf.h
98conf_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 101conf_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
99conf_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 102conf_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
100conf_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 103conf_err.o: ../../include/openssl/opensslconf.h
101conf_err.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 104conf_err.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
102conf_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 105conf_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
106conf_err.o: conf_err.c
103conf_lib.o: ../../include/openssl/bio.h ../../include/openssl/conf.h 107conf_lib.o: ../../include/openssl/bio.h ../../include/openssl/conf.h
104conf_lib.o: ../../include/openssl/conf_api.h ../../include/openssl/crypto.h 108conf_lib.o: ../../include/openssl/conf_api.h ../../include/openssl/crypto.h
105conf_lib.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 109conf_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
106conf_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 110conf_lib.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
107conf_lib.o: ../../include/openssl/opensslconf.h
108conf_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 111conf_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
109conf_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.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/asn1.h
115conf_mall.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
116conf_mall.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
117conf_mall.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
118conf_mall.o: ../../include/openssl/dsa.h ../../include/openssl/dso.h
119conf_mall.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
120conf_mall.o: ../../include/openssl/err.h ../../include/openssl/evp.h
121conf_mall.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
122conf_mall.o: ../../include/openssl/objects.h
123conf_mall.o: ../../include/openssl/opensslconf.h
124conf_mall.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
125conf_mall.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
126conf_mall.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
127conf_mall.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
128conf_mall.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
129conf_mall.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
130conf_mall.o: ../cryptlib.h conf_mall.c
131conf_mod.o: ../../e_os.h ../../include/openssl/asn1.h
132conf_mod.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
133conf_mod.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
134conf_mod.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
135conf_mod.o: ../../include/openssl/dsa.h ../../include/openssl/dso.h
136conf_mod.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
137conf_mod.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
138conf_mod.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
139conf_mod.o: ../../include/openssl/opensslconf.h
140conf_mod.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
141conf_mod.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
142conf_mod.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
143conf_mod.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
144conf_mod.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
145conf_mod.o: ../cryptlib.h conf_mod.c
146conf_sap.o: ../../e_os.h ../../include/openssl/asn1.h
147conf_sap.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
148conf_sap.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
149conf_sap.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
150conf_sap.o: ../../include/openssl/dsa.h ../../include/openssl/dso.h
151conf_sap.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
152conf_sap.o: ../../include/openssl/err.h ../../include/openssl/evp.h
153conf_sap.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
154conf_sap.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
155conf_sap.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
156conf_sap.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
157conf_sap.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
158conf_sap.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
159conf_sap.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
160conf_sap.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
161conf_sap.o: ../cryptlib.h conf_sap.c
diff --git a/src/lib/libcrypto/conf/README b/src/lib/libcrypto/conf/README
new file mode 100644
index 0000000000..ca58d0240f
--- /dev/null
+++ b/src/lib/libcrypto/conf/README
@@ -0,0 +1,78 @@
1WARNING WARNING WARNING!!!
2
3This stuff is experimental, may change radically or be deleted altogether
4before OpenSSL 0.9.7 release. You have been warned!
5
6Configuration modules. These are a set of modules which can perform
7various configuration functions.
8
9Currently the routines should be called at most once when an application
10starts up: that is before it starts any threads.
11
12The routines read a configuration file set up like this:
13
14-----
15#default section
16openssl_init=init_section
17
18[init_section]
19
20module1=value1
21#Second instance of module1
22module1.1=valueX
23module2=value2
24module3=dso_literal
25module4=dso_section
26
27[dso_section]
28
29path=/some/path/to/some/dso.so
30other_stuff=other_value
31----
32
33When this file is loaded a configuration module with the specified
34string (module* in the above example) is looked up and its init
35function called as:
36
37int conf_init_func(CONF_IMODULE *md, CONF *cnf);
38
39The function can then take whatever action is appropriate, for example
40further lookups based on the value. Multiple instances of the same
41config module can be loaded.
42
43When the application closes down the modules are cleaned up by calling
44an optional finish function:
45
46void conf_finish_func(CONF_IMODULE *md);
47
48The finish functions are called in reverse order: that is the last module
49loaded is the first one cleaned up.
50
51If no module exists with a given name then an attempt is made to load
52a DSO with the supplied name. This might mean that "module3" attempts
53to load a DSO called libmodule3.so or module3.dll for example. An explicit
54DSO name can be given by including a separate section as in the module4 example
55above.
56
57The DSO is expected to at least contain an initialization function:
58
59int OPENSSL_init(CONF_IMODULE *md, CONF *cnf);
60
61and may also include a finish function:
62
63void OPENSSL_finish(CONF_IMODULE *md);
64
65Static modules can also be added using,
66
67int CONF_module_add(char *name, dso_mod_init_func *ifunc, dso_mod_finish_func *ffunc);
68
69where "name" is the name in the configuration file this function corresponds to.
70
71A set of builtin modules (currently only an ASN1 non functional test module) can be
72added by calling OPENSSL_load_builtin_modules().
73
74The function OPENSSL_config() is intended as a simple configuration function that
75any application can call to perform various default configuration tasks. It uses the
76file openssl.cnf in the usual locations.
77
78
diff --git a/src/lib/libcrypto/conf/cnf_save.c b/src/lib/libcrypto/conf/cnf_save.c
index e907cc2242..1439487526 100644
--- a/src/lib/libcrypto/conf/cnf_save.c
+++ b/src/lib/libcrypto/conf/cnf_save.c
@@ -59,7 +59,8 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <openssl/conf.h> 60#include <openssl/conf.h>
61 61
62void print_conf(CONF_VALUE *cv); 62static void print_conf(CONF_VALUE *cv);
63static IMPLEMENT_LHASH_DOALL_FN(print_conf, CONF_VALUE *);
63 64
64main() 65main()
65 { 66 {
@@ -73,11 +74,11 @@ main()
73 exit(1); 74 exit(1);
74 } 75 }
75 76
76 lh_doall(conf,print_conf); 77 lh_doall(conf,LHASH_DOALL_FN(print_conf));
77 } 78 }
78 79
79 80
80void print_conf(CONF_VALUE *cv) 81static void print_conf(CONF_VALUE *cv)
81 { 82 {
82 int i; 83 int i;
83 CONF_VALUE *v; 84 CONF_VALUE *v;
diff --git a/src/lib/libcrypto/conf/conf.c b/src/lib/libcrypto/conf/conf.c
new file mode 100644
index 0000000000..3031fa3b44
--- /dev/null
+++ b/src/lib/libcrypto/conf/conf.c
@@ -0,0 +1,730 @@
1/* crypto/conf/conf.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/stack.h>
63#include <openssl/lhash.h>
64#include <openssl/conf.h>
65#include <openssl/buffer.h>
66#include <openssl/err.h>
67
68#include "conf_lcl.h"
69
70static void value_free_hash(CONF_VALUE *a, LHASH *conf);
71static void value_free_stack(CONF_VALUE *a,LHASH *conf);
72static unsigned long hash(CONF_VALUE *v);
73static int cmp_conf(CONF_VALUE *a,CONF_VALUE *b);
74static char *eat_ws(char *p);
75static char *eat_alpha_numeric(char *p);
76static void clear_comments(char *p);
77static int str_copy(LHASH *conf,char *section,char **to, char *from);
78static char *scan_quote(char *p);
79static CONF_VALUE *new_section(LHASH *conf,char *section);
80static CONF_VALUE *get_section(LHASH *conf,char *section);
81#define scan_esc(p) ((((p)[1] == '\0')?(p++):(p+=2)),p)
82
83const char *CONF_version="CONF" OPENSSL_VERSION_PTEXT;
84
85
86LHASH *CONF_load(LHASH *h, const char *file, long *line)
87 {
88 LHASH *ltmp;
89 BIO *in=NULL;
90
91#ifdef VMS
92 in=BIO_new_file(file, "r");
93#else
94 in=BIO_new_file(file, "rb");
95#endif
96 if (in == NULL)
97 {
98 CONFerr(CONF_F_CONF_LOAD,ERR_R_SYS_LIB);
99 return NULL;
100 }
101
102 ltmp = CONF_load_bio(h, in, line);
103 BIO_free(in);
104
105 return ltmp;
106}
107#ifndef NO_FP_API
108LHASH *CONF_load_fp(LHASH *h, FILE *in, long *line)
109{
110 BIO *btmp;
111 LHASH *ltmp;
112 if(!(btmp = BIO_new_fp(in, BIO_NOCLOSE))) {
113 CONFerr(CONF_F_CONF_LOAD_FP,ERR_R_BUF_LIB);
114 return NULL;
115 }
116 ltmp = CONF_load_bio(h, btmp, line);
117 BIO_free(btmp);
118 return ltmp;
119}
120#endif
121
122LHASH *CONF_load_bio(LHASH *h, BIO *in, long *line)
123 {
124 LHASH *ret=NULL;
125#define BUFSIZE 512
126 char btmp[16];
127 int bufnum=0,i,ii;
128 BUF_MEM *buff=NULL;
129 char *s,*p,*end;
130 int again,n;
131 long eline=0;
132 CONF_VALUE *v=NULL,*vv,*tv;
133 CONF_VALUE *sv=NULL;
134 char *section=NULL,*buf;
135 STACK_OF(CONF_VALUE) *section_sk=NULL,*ts;
136 char *start,*psection,*pname;
137
138 if ((buff=BUF_MEM_new()) == NULL)
139 {
140 CONFerr(CONF_F_CONF_LOAD_BIO,ERR_R_BUF_LIB);
141 goto err;
142 }
143
144 section=(char *)Malloc(10);
145 if (section == NULL)
146 {
147 CONFerr(CONF_F_CONF_LOAD_BIO,ERR_R_MALLOC_FAILURE);
148 goto err;
149 }
150 strcpy(section,"default");
151
152 if (h == NULL)
153 {
154 if ((ret=lh_new(hash,cmp_conf)) == NULL)
155 {
156 CONFerr(CONF_F_CONF_LOAD_BIO,ERR_R_MALLOC_FAILURE);
157 goto err;
158 }
159 }
160 else
161 ret=h;
162
163 sv=new_section(ret,section);
164 if (sv == NULL)
165 {
166 CONFerr(CONF_F_CONF_LOAD_BIO,
167 CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
168 goto err;
169 }
170 section_sk=(STACK_OF(CONF_VALUE) *)sv->value;
171
172 bufnum=0;
173 for (;;)
174 {
175 again=0;
176 if (!BUF_MEM_grow(buff,bufnum+BUFSIZE))
177 {
178 CONFerr(CONF_F_CONF_LOAD_BIO,ERR_R_BUF_LIB);
179 goto err;
180 }
181 p= &(buff->data[bufnum]);
182 *p='\0';
183 BIO_gets(in, p, BUFSIZE-1);
184 p[BUFSIZE-1]='\0';
185 ii=i=strlen(p);
186 if (i == 0) break;
187 while (i > 0)
188 {
189 if ((p[i-1] != '\r') && (p[i-1] != '\n'))
190 break;
191 else
192 i--;
193 }
194 /* we removed some trailing stuff so there is a new
195 * line on the end. */
196 if (i == ii)
197 again=1; /* long line */
198 else
199 {
200 p[i]='\0';
201 eline++; /* another input line */
202 }
203
204 /* we now have a line with trailing \r\n removed */
205
206 /* i is the number of bytes */
207 bufnum+=i;
208
209 v=NULL;
210 /* check for line continuation */
211 if (bufnum >= 1)
212 {
213 /* If we have bytes and the last char '\\' and
214 * second last char is not '\\' */
215 p= &(buff->data[bufnum-1]);
216 if ( IS_ESC(p[0]) &&
217 ((bufnum <= 1) || !IS_ESC(p[-1])))
218 {
219 bufnum--;
220 again=1;
221 }
222 }
223 if (again) continue;
224 bufnum=0;
225 buf=buff->data;
226
227 clear_comments(buf);
228 n=strlen(buf);
229 s=eat_ws(buf);
230 if (IS_EOF(*s)) continue; /* blank line */
231 if (*s == '[')
232 {
233 char *ss;
234
235 s++;
236 start=eat_ws(s);
237 ss=start;
238again:
239 end=eat_alpha_numeric(ss);
240 p=eat_ws(end);
241 if (*p != ']')
242 {
243 if (*p != '\0')
244 {
245 ss=p;
246 goto again;
247 }
248 CONFerr(CONF_F_CONF_LOAD_BIO,
249 CONF_R_MISSING_CLOSE_SQUARE_BRACKET);
250 goto err;
251 }
252 *end='\0';
253 if (!str_copy(ret,NULL,&section,start)) goto err;
254 if ((sv=get_section(ret,section)) == NULL)
255 sv=new_section(ret,section);
256 if (sv == NULL)
257 {
258 CONFerr(CONF_F_CONF_LOAD_BIO,
259 CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
260 goto err;
261 }
262 section_sk=(STACK_OF(CONF_VALUE) *)sv->value;
263 continue;
264 }
265 else
266 {
267 pname=s;
268 psection=NULL;
269 end=eat_alpha_numeric(s);
270 if ((end[0] == ':') && (end[1] == ':'))
271 {
272 *end='\0';
273 end+=2;
274 psection=pname;
275 pname=end;
276 end=eat_alpha_numeric(end);
277 }
278 p=eat_ws(end);
279 if (*p != '=')
280 {
281 CONFerr(CONF_F_CONF_LOAD_BIO,
282 CONF_R_MISSING_EQUAL_SIGN);
283 goto err;
284 }
285 *end='\0';
286 p++;
287 start=eat_ws(p);
288 while (!IS_EOF(*p))
289 p++;
290 p--;
291 while ((p != start) && (IS_WS(*p)))
292 p--;
293 p++;
294 *p='\0';
295
296 if (!(v=(CONF_VALUE *)Malloc(sizeof(CONF_VALUE))))
297 {
298 CONFerr(CONF_F_CONF_LOAD_BIO,
299 ERR_R_MALLOC_FAILURE);
300 goto err;
301 }
302 if (psection == NULL) psection=section;
303 v->name=(char *)Malloc(strlen(pname)+1);
304 v->value=NULL;
305 if (v->name == NULL)
306 {
307 CONFerr(CONF_F_CONF_LOAD_BIO,
308 ERR_R_MALLOC_FAILURE);
309 goto err;
310 }
311 strcpy(v->name,pname);
312 if (!str_copy(ret,psection,&(v->value),start)) goto err;
313
314 if (strcmp(psection,section) != 0)
315 {
316 if ((tv=get_section(ret,psection))
317 == NULL)
318 tv=new_section(ret,psection);
319 if (tv == NULL)
320 {
321 CONFerr(CONF_F_CONF_LOAD_BIO,
322 CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
323 goto err;
324 }
325 ts=(STACK_OF(CONF_VALUE) *)tv->value;
326 }
327 else
328 {
329 tv=sv;
330 ts=section_sk;
331 }
332 v->section=tv->section;
333 if (!sk_CONF_VALUE_push(ts,v))
334 {
335 CONFerr(CONF_F_CONF_LOAD_BIO,
336 ERR_R_MALLOC_FAILURE);
337 goto err;
338 }
339 vv=(CONF_VALUE *)lh_insert(ret,v);
340 if (vv != NULL)
341 {
342 sk_CONF_VALUE_delete_ptr(ts,vv);
343 Free(vv->name);
344 Free(vv->value);
345 Free(vv);
346 }
347 v=NULL;
348 }
349 }
350 if (buff != NULL) BUF_MEM_free(buff);
351 if (section != NULL) Free(section);
352 return(ret);
353err:
354 if (buff != NULL) BUF_MEM_free(buff);
355 if (section != NULL) Free(section);
356 if (line != NULL) *line=eline;
357 sprintf(btmp,"%ld",eline);
358 ERR_add_error_data(2,"line ",btmp);
359 if ((h != ret) && (ret != NULL)) CONF_free(ret);
360 if (v != NULL)
361 {
362 if (v->name != NULL) Free(v->name);
363 if (v->value != NULL) Free(v->value);
364 if (v != NULL) Free(v);
365 }
366 return(NULL);
367 }
368
369char *CONF_get_string(LHASH *conf, char *section, char *name)
370 {
371 CONF_VALUE *v,vv;
372 char *p;
373
374 if (name == NULL) return(NULL);
375 if (conf != NULL)
376 {
377 if (section != NULL)
378 {
379 vv.name=name;
380 vv.section=section;
381 v=(CONF_VALUE *)lh_retrieve(conf,&vv);
382 if (v != NULL) return(v->value);
383 if (strcmp(section,"ENV") == 0)
384 {
385 p=Getenv(name);
386 if (p != NULL) return(p);
387 }
388 }
389 vv.section="default";
390 vv.name=name;
391 v=(CONF_VALUE *)lh_retrieve(conf,&vv);
392 if (v != NULL)
393 return(v->value);
394 else
395 return(NULL);
396 }
397 else
398 return(Getenv(name));
399 }
400
401static CONF_VALUE *get_section(LHASH *conf, char *section)
402 {
403 CONF_VALUE *v,vv;
404
405 if ((conf == NULL) || (section == NULL)) return(NULL);
406 vv.name=NULL;
407 vv.section=section;
408 v=(CONF_VALUE *)lh_retrieve(conf,&vv);
409 return(v);
410 }
411
412STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf, char *section)
413 {
414 CONF_VALUE *v;
415
416 v=get_section(conf,section);
417 if (v != NULL)
418 return((STACK_OF(CONF_VALUE) *)v->value);
419 else
420 return(NULL);
421 }
422
423long CONF_get_number(LHASH *conf, char *section, char *name)
424 {
425 char *str;
426 long ret=0;
427
428 str=CONF_get_string(conf,section,name);
429 if (str == NULL) return(0);
430 for (;;)
431 {
432 if (IS_NUMER(*str))
433 ret=ret*10+(*str -'0');
434 else
435 return(ret);
436 str++;
437 }
438 }
439
440void CONF_free(LHASH *conf)
441 {
442 if (conf == NULL) return;
443
444 conf->down_load=0; /* evil thing to make sure the 'Free()'
445 * works as expected */
446 lh_doall_arg(conf,(void (*)())value_free_hash,conf);
447
448 /* We now have only 'section' entries in the hash table.
449 * Due to problems with */
450
451 lh_doall_arg(conf,(void (*)())value_free_stack,conf);
452 lh_free(conf);
453 }
454
455static void value_free_hash(CONF_VALUE *a, LHASH *conf)
456 {
457 if (a->name != NULL)
458 {
459 a=(CONF_VALUE *)lh_delete(conf,a);
460 }
461 }
462
463static void value_free_stack(CONF_VALUE *a, LHASH *conf)
464 {
465 CONF_VALUE *vv;
466 STACK *sk;
467 int i;
468
469 if (a->name != NULL) return;
470
471 sk=(STACK *)a->value;
472 for (i=sk_num(sk)-1; i>=0; i--)
473 {
474 vv=(CONF_VALUE *)sk_value(sk,i);
475 Free(vv->value);
476 Free(vv->name);
477 Free(vv);
478 }
479 if (sk != NULL) sk_free(sk);
480 Free(a->section);
481 Free(a);
482 }
483
484static void clear_comments(char *p)
485 {
486 char *to;
487
488 to=p;
489 for (;;)
490 {
491 if (IS_COMMENT(*p))
492 {
493 *p='\0';
494 return;
495 }
496 if (IS_QUOTE(*p))
497 {
498 p=scan_quote(p);
499 continue;
500 }
501 if (IS_ESC(*p))
502 {
503 p=scan_esc(p);
504 continue;
505 }
506 if (IS_EOF(*p))
507 return;
508 else
509 p++;
510 }
511 }
512
513static int str_copy(LHASH *conf, char *section, char **pto, char *from)
514 {
515 int q,r,rr=0,to=0,len=0;
516 char *s,*e,*rp,*p,*rrp,*np,*cp,v;
517 BUF_MEM *buf;
518
519 if ((buf=BUF_MEM_new()) == NULL) return(0);
520
521 len=strlen(from)+1;
522 if (!BUF_MEM_grow(buf,len)) goto err;
523
524 for (;;)
525 {
526 if (IS_QUOTE(*from))
527 {
528 q= *from;
529 from++;
530 while ((*from != '\0') && (*from != q))
531 {
532 if (*from == '\\')
533 {
534 from++;
535 if (*from == '\0') break;
536 }
537 buf->data[to++]= *(from++);
538 }
539 }
540 else if (*from == '\\')
541 {
542 from++;
543 v= *(from++);
544 if (v == '\0') break;
545 else if (v == 'r') v='\r';
546 else if (v == 'n') v='\n';
547 else if (v == 'b') v='\b';
548 else if (v == 't') v='\t';
549 buf->data[to++]= v;
550 }
551 else if (*from == '\0')
552 break;
553 else if (*from == '$')
554 {
555 /* try to expand it */
556 rrp=NULL;
557 s= &(from[1]);
558 if (*s == '{')
559 q='}';
560 else if (*s == '(')
561 q=')';
562 else q=0;
563
564 if (q) s++;
565 cp=section;
566 e=np=s;
567 while (IS_ALPHA_NUMERIC(*e))
568 e++;
569 if ((e[0] == ':') && (e[1] == ':'))
570 {
571 cp=np;
572 rrp=e;
573 rr= *e;
574 *rrp='\0';
575 e+=2;
576 np=e;
577 while (IS_ALPHA_NUMERIC(*e))
578 e++;
579 }
580 r= *e;
581 *e='\0';
582 rp=e;
583 if (q)
584 {
585 if (r != q)
586 {
587 CONFerr(CONF_F_STR_COPY,CONF_R_NO_CLOSE_BRACE);
588 goto err;
589 }
590 e++;
591 }
592 /* So at this point we have
593 * ns which is the start of the name string which is
594 * '\0' terminated.
595 * cs which is the start of the section string which is
596 * '\0' terminated.
597 * e is the 'next point after'.
598 * r and s are the chars replaced by the '\0'
599 * rp and sp is where 'r' and 's' came from.
600 */
601 p=CONF_get_string(conf,cp,np);
602 if (rrp != NULL) *rrp=rr;
603 *rp=r;
604 if (p == NULL)
605 {
606 CONFerr(CONF_F_STR_COPY,CONF_R_VARIABLE_HAS_NO_VALUE);
607 goto err;
608 }
609 BUF_MEM_grow(buf,(strlen(p)+len-(e-from)));
610 while (*p)
611 buf->data[to++]= *(p++);
612 from=e;
613 }
614 else
615 buf->data[to++]= *(from++);
616 }
617 buf->data[to]='\0';
618 if (*pto != NULL) Free(*pto);
619 *pto=buf->data;
620 Free(buf);
621 return(1);
622err:
623 if (buf != NULL) BUF_MEM_free(buf);
624 return(0);
625 }
626
627static char *eat_ws(char *p)
628 {
629 while (IS_WS(*p) && (!IS_EOF(*p)))
630 p++;
631 return(p);
632 }
633
634static char *eat_alpha_numeric(char *p)
635 {
636 for (;;)
637 {
638 if (IS_ESC(*p))
639 {
640 p=scan_esc(p);
641 continue;
642 }
643 if (!IS_ALPHA_NUMERIC_PUNCT(*p))
644 return(p);
645 p++;
646 }
647 }
648
649static unsigned long hash(CONF_VALUE *v)
650 {
651 return((lh_strhash(v->section)<<2)^lh_strhash(v->name));
652 }
653
654static int cmp_conf(CONF_VALUE *a, CONF_VALUE *b)
655 {
656 int i;
657
658 if (a->section != b->section)
659 {
660 i=strcmp(a->section,b->section);
661 if (i) return(i);
662 }
663
664 if ((a->name != NULL) && (b->name != NULL))
665 {
666 i=strcmp(a->name,b->name);
667 return(i);
668 }
669 else if (a->name == b->name)
670 return(0);
671 else
672 return((a->name == NULL)?-1:1);
673 }
674
675static char *scan_quote(char *p)
676 {
677 int q= *p;
678
679 p++;
680 while (!(IS_EOF(*p)) && (*p != q))
681 {
682 if (IS_ESC(*p))
683 {
684 p++;
685 if (IS_EOF(*p)) return(p);
686 }
687 p++;
688 }
689 if (*p == q) p++;
690 return(p);
691 }
692
693static CONF_VALUE *new_section(LHASH *conf, char *section)
694 {
695 STACK *sk=NULL;
696 int ok=0,i;
697 CONF_VALUE *v=NULL,*vv;
698
699 if ((sk=sk_new_null()) == NULL)
700 goto err;
701 if ((v=(CONF_VALUE *)Malloc(sizeof(CONF_VALUE))) == NULL)
702 goto err;
703 i=strlen(section)+1;
704 if ((v->section=(char *)Malloc(i)) == NULL)
705 goto err;
706
707 memcpy(v->section,section,i);
708 v->name=NULL;
709 v->value=(char *)sk;
710
711 vv=(CONF_VALUE *)lh_insert(conf,v);
712 if (vv != NULL)
713 {
714#if !defined(NO_STDIO) && !defined(WIN16)
715 fprintf(stderr,"internal fault\n");
716#endif
717 abort();
718 }
719 ok=1;
720err:
721 if (!ok)
722 {
723 if (sk != NULL) sk_free(sk);
724 if (v != NULL) Free(v);
725 v=NULL;
726 }
727 return(v);
728 }
729
730IMPLEMENT_STACK_OF(CONF_VALUE)
diff --git a/src/lib/libcrypto/conf/conf.h b/src/lib/libcrypto/conf/conf.h
index cd40a0db21..3c03fb19c0 100644
--- a/src/lib/libcrypto/conf/conf.h
+++ b/src/lib/libcrypto/conf/conf.h
@@ -63,7 +63,7 @@
63#include <openssl/lhash.h> 63#include <openssl/lhash.h>
64#include <openssl/stack.h> 64#include <openssl/stack.h>
65#include <openssl/safestack.h> 65#include <openssl/safestack.h>
66#include <openssl/e_os.h> 66#include <openssl/e_os2.h>
67 67
68#ifdef __cplusplus 68#ifdef __cplusplus
69extern "C" { 69extern "C" {
@@ -77,6 +77,8 @@ typedef struct
77 } CONF_VALUE; 77 } CONF_VALUE;
78 78
79DECLARE_STACK_OF(CONF_VALUE) 79DECLARE_STACK_OF(CONF_VALUE)
80DECLARE_STACK_OF(CONF_MODULE)
81DECLARE_STACK_OF(CONF_IMODULE)
80 82
81struct conf_st; 83struct conf_st;
82typedef struct conf_st CONF; 84typedef struct conf_st CONF;
@@ -86,29 +88,47 @@ typedef struct conf_method_st CONF_METHOD;
86struct conf_method_st 88struct conf_method_st
87 { 89 {
88 const char *name; 90 const char *name;
89 CONF *(MS_FAR *create)(CONF_METHOD *meth); 91 CONF *(*create)(CONF_METHOD *meth);
90 int (MS_FAR *init)(CONF *conf); 92 int (*init)(CONF *conf);
91 int (MS_FAR *destroy)(CONF *conf); 93 int (*destroy)(CONF *conf);
92 int (MS_FAR *destroy_data)(CONF *conf); 94 int (*destroy_data)(CONF *conf);
93 int (MS_FAR *load)(CONF *conf, BIO *bp, long *eline); 95 int (*load_bio)(CONF *conf, BIO *bp, long *eline);
94 int (MS_FAR *dump)(CONF *conf, BIO *bp); 96 int (*dump)(const CONF *conf, BIO *bp);
95 int (MS_FAR *is_number)(CONF *conf, char c); 97 int (*is_number)(const CONF *conf, char c);
96 int (MS_FAR *to_int)(CONF *conf, char c); 98 int (*to_int)(const CONF *conf, char c);
99 int (*load)(CONF *conf, const char *name, long *eline);
97 }; 100 };
98 101
102/* Module definitions */
103
104typedef struct conf_imodule_st CONF_IMODULE;
105typedef struct conf_module_st CONF_MODULE;
106
107/* DSO module function typedefs */
108typedef int conf_init_func(CONF_IMODULE *md, const CONF *cnf);
109typedef void conf_finish_func(CONF_IMODULE *md);
110
111#define CONF_MFLAGS_IGNORE_ERRORS 0x1
112#define CONF_MFLAGS_IGNORE_RETURN_CODES 0x2
113#define CONF_MFLAGS_SILENT 0x4
114#define CONF_MFLAGS_NO_DSO 0x8
115#define CONF_MFLAGS_IGNORE_MISSING_FILE 0x10
116
99int CONF_set_default_method(CONF_METHOD *meth); 117int CONF_set_default_method(CONF_METHOD *meth);
118void CONF_set_nconf(CONF *conf,LHASH *hash);
100LHASH *CONF_load(LHASH *conf,const char *file,long *eline); 119LHASH *CONF_load(LHASH *conf,const char *file,long *eline);
101#ifndef NO_FP_API 120#ifndef OPENSSL_NO_FP_API
102LHASH *CONF_load_fp(LHASH *conf, FILE *fp,long *eline); 121LHASH *CONF_load_fp(LHASH *conf, FILE *fp,long *eline);
103#endif 122#endif
104LHASH *CONF_load_bio(LHASH *conf, BIO *bp,long *eline); 123LHASH *CONF_load_bio(LHASH *conf, BIO *bp,long *eline);
105STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,char *section); 124STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,const char *section);
106char *CONF_get_string(LHASH *conf,char *group,char *name); 125char *CONF_get_string(LHASH *conf,const char *group,const char *name);
107long CONF_get_number(LHASH *conf,char *group,char *name); 126long CONF_get_number(LHASH *conf,const char *group,const char *name);
108void CONF_free(LHASH *conf); 127void CONF_free(LHASH *conf);
109int CONF_dump_fp(LHASH *conf, FILE *out); 128int CONF_dump_fp(LHASH *conf, FILE *out);
110int CONF_dump_bio(LHASH *conf, BIO *out); 129int CONF_dump_bio(LHASH *conf, BIO *out);
111void ERR_load_CONF_strings(void ); 130
131void OPENSSL_config(const char *config_name);
112 132
113/* New conf code. The semantics are different from the functions above. 133/* New conf code. The semantics are different from the functions above.
114 If that wasn't the case, the above functions would have been replaced */ 134 If that wasn't the case, the above functions would have been replaced */
@@ -130,21 +150,57 @@ void NCONF_free(CONF *conf);
130void NCONF_free_data(CONF *conf); 150void NCONF_free_data(CONF *conf);
131 151
132int NCONF_load(CONF *conf,const char *file,long *eline); 152int NCONF_load(CONF *conf,const char *file,long *eline);
133#ifndef NO_FP_API 153#ifndef OPENSSL_NO_FP_API
134int NCONF_load_fp(CONF *conf, FILE *fp,long *eline); 154int NCONF_load_fp(CONF *conf, FILE *fp,long *eline);
135#endif 155#endif
136int NCONF_load_bio(CONF *conf, BIO *bp,long *eline); 156int NCONF_load_bio(CONF *conf, BIO *bp,long *eline);
137STACK_OF(CONF_VALUE) *NCONF_get_section(CONF *conf,char *section); 157STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf,const char *section);
138char *NCONF_get_string(CONF *conf,char *group,char *name); 158char *NCONF_get_string(const CONF *conf,const char *group,const char *name);
159int NCONF_get_number_e(const CONF *conf,const char *group,const char *name,
160 long *result);
161int NCONF_dump_fp(const CONF *conf, FILE *out);
162int NCONF_dump_bio(const CONF *conf, BIO *out);
163
164#if 0 /* The following function has no error checking,
165 and should therefore be avoided */
139long NCONF_get_number(CONF *conf,char *group,char *name); 166long NCONF_get_number(CONF *conf,char *group,char *name);
140int NCONF_dump_fp(CONF *conf, FILE *out); 167#else
141int NCONF_dump_bio(CONF *conf, BIO *out); 168#define NCONF_get_number(c,g,n,r) NCONF_get_number_e(c,g,n,r)
142 169#endif
170
171/* Module functions */
172
173int CONF_modules_load(const CONF *cnf, const char *appname,
174 unsigned long flags);
175int CONF_modules_load_file(const char *filename, const char *appname,
176 unsigned long flags);
177void CONF_modules_unload(int all);
178void CONF_modules_finish(void);
179int CONF_module_add(const char *name, conf_init_func *ifunc,
180 conf_finish_func *ffunc);
181
182const char *CONF_imodule_get_name(const CONF_IMODULE *md);
183const char *CONF_imodule_get_value(const CONF_IMODULE *md);
184void *CONF_imodule_get_usr_data(const CONF_IMODULE *md);
185void CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data);
186CONF_MODULE *CONF_imodule_get_module(const CONF_IMODULE *md);
187unsigned long CONF_imodule_get_flags(const CONF_IMODULE *md);
188void CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags);
189void *CONF_module_get_usr_data(CONF_MODULE *pmod);
190void CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data);
191
192char *CONF_get1_default_config_file(void);
193
194int CONF_parse_list(const char *list, int sep, int nospc,
195 int (*list_cb)(const char *elem, int len, void *usr), void *arg);
196
197void OPENSSL_load_builtin_modules(void);
143 198
144/* BEGIN ERROR CODES */ 199/* BEGIN ERROR CODES */
145/* The following lines are auto generated by the script mkerr.pl. Any changes 200/* The following lines are auto generated by the script mkerr.pl. Any changes
146 * made after this point may be overwritten when the script is next run. 201 * made after this point may be overwritten when the script is next run.
147 */ 202 */
203void ERR_load_CONF_strings(void);
148 204
149/* Error codes for the CONF functions. */ 205/* Error codes for the CONF functions. */
150 206
@@ -153,27 +209,40 @@ int NCONF_dump_bio(CONF *conf, BIO *out);
153#define CONF_F_CONF_LOAD 100 209#define CONF_F_CONF_LOAD 100
154#define CONF_F_CONF_LOAD_BIO 102 210#define CONF_F_CONF_LOAD_BIO 102
155#define CONF_F_CONF_LOAD_FP 103 211#define CONF_F_CONF_LOAD_FP 103
212#define CONF_F_CONF_MODULES_LOAD 116
213#define CONF_F_MODULE_INIT 115
214#define CONF_F_MODULE_LOAD_DSO 117
215#define CONF_F_MODULE_RUN 118
156#define CONF_F_NCONF_DUMP_BIO 105 216#define CONF_F_NCONF_DUMP_BIO 105
157#define CONF_F_NCONF_DUMP_FP 106 217#define CONF_F_NCONF_DUMP_FP 106
158#define CONF_F_NCONF_GET_NUMBER 107 218#define CONF_F_NCONF_GET_NUMBER 107
219#define CONF_F_NCONF_GET_NUMBER_E 112
159#define CONF_F_NCONF_GET_SECTION 108 220#define CONF_F_NCONF_GET_SECTION 108
160#define CONF_F_NCONF_GET_STRING 109 221#define CONF_F_NCONF_GET_STRING 109
222#define CONF_F_NCONF_LOAD 113
161#define CONF_F_NCONF_LOAD_BIO 110 223#define CONF_F_NCONF_LOAD_BIO 110
224#define CONF_F_NCONF_LOAD_FP 114
162#define CONF_F_NCONF_NEW 111 225#define CONF_F_NCONF_NEW 111
163#define CONF_F_STR_COPY 101 226#define CONF_F_STR_COPY 101
164 227
165/* Reason codes. */ 228/* Reason codes. */
229#define CONF_R_ERROR_LOADING_DSO 110
166#define CONF_R_MISSING_CLOSE_SQUARE_BRACKET 100 230#define CONF_R_MISSING_CLOSE_SQUARE_BRACKET 100
167#define CONF_R_MISSING_EQUAL_SIGN 101 231#define CONF_R_MISSING_EQUAL_SIGN 101
232#define CONF_R_MISSING_FINISH_FUNCTION 111
233#define CONF_R_MISSING_INIT_FUNCTION 112
234#define CONF_R_MODULE_INITIALIZATION_ERROR 109
168#define CONF_R_NO_CLOSE_BRACE 102 235#define CONF_R_NO_CLOSE_BRACE 102
169#define CONF_R_NO_CONF 105 236#define CONF_R_NO_CONF 105
170#define CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE 106 237#define CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE 106
171#define CONF_R_NO_SECTION 107 238#define CONF_R_NO_SECTION 107
239#define CONF_R_NO_SUCH_FILE 114
240#define CONF_R_NO_VALUE 108
172#define CONF_R_UNABLE_TO_CREATE_NEW_SECTION 103 241#define CONF_R_UNABLE_TO_CREATE_NEW_SECTION 103
242#define CONF_R_UNKNOWN_MODULE_NAME 113
173#define CONF_R_VARIABLE_HAS_NO_VALUE 104 243#define CONF_R_VARIABLE_HAS_NO_VALUE 104
174 244
175#ifdef __cplusplus 245#ifdef __cplusplus
176} 246}
177#endif 247#endif
178#endif 248#endif
179
diff --git a/src/lib/libcrypto/conf/conf_api.c b/src/lib/libcrypto/conf/conf_api.c
index d05a778ff6..0032baa711 100644
--- a/src/lib/libcrypto/conf/conf_api.c
+++ b/src/lib/libcrypto/conf/conf_api.c
@@ -67,26 +67,34 @@
67#include <string.h> 67#include <string.h>
68#include <openssl/conf.h> 68#include <openssl/conf.h>
69#include <openssl/conf_api.h> 69#include <openssl/conf_api.h>
70#include "e_os.h"
70 71
71static void value_free_hash(CONF_VALUE *a, LHASH *conf); 72static void value_free_hash(CONF_VALUE *a, LHASH *conf);
72static void value_free_stack(CONF_VALUE *a,LHASH *conf); 73static void value_free_stack(CONF_VALUE *a,LHASH *conf);
73static unsigned long hash(CONF_VALUE *v); 74static IMPLEMENT_LHASH_DOALL_ARG_FN(value_free_hash, CONF_VALUE *, LHASH *)
74static int cmp_conf(CONF_VALUE *a,CONF_VALUE *b); 75static IMPLEMENT_LHASH_DOALL_ARG_FN(value_free_stack, CONF_VALUE *, LHASH *)
76/* We don't use function pointer casting or wrapper functions - but cast each
77 * callback parameter inside the callback functions. */
78/* static unsigned long hash(CONF_VALUE *v); */
79static unsigned long hash(const void *v_void);
80/* static int cmp_conf(CONF_VALUE *a,CONF_VALUE *b); */
81static int cmp_conf(const void *a_void,const void *b_void);
75 82
76/* Up until OpenSSL 0.9.5a, this was get_section */ 83/* Up until OpenSSL 0.9.5a, this was get_section */
77CONF_VALUE *_CONF_get_section(CONF *conf, char *section) 84CONF_VALUE *_CONF_get_section(const CONF *conf, const char *section)
78 { 85 {
79 CONF_VALUE *v,vv; 86 CONF_VALUE *v,vv;
80 87
81 if ((conf == NULL) || (section == NULL)) return(NULL); 88 if ((conf == NULL) || (section == NULL)) return(NULL);
82 vv.name=NULL; 89 vv.name=NULL;
83 vv.section=section; 90 vv.section=(char *)section;
84 v=(CONF_VALUE *)lh_retrieve(conf->data,&vv); 91 v=(CONF_VALUE *)lh_retrieve(conf->data,&vv);
85 return(v); 92 return(v);
86 } 93 }
87 94
88/* Up until OpenSSL 0.9.5a, this was CONF_get_section */ 95/* Up until OpenSSL 0.9.5a, this was CONF_get_section */
89STACK_OF(CONF_VALUE) *_CONF_get_section_values(CONF *conf, char *section) 96STACK_OF(CONF_VALUE) *_CONF_get_section_values(const CONF *conf,
97 const char *section)
90 { 98 {
91 CONF_VALUE *v; 99 CONF_VALUE *v;
92 100
@@ -121,7 +129,7 @@ int _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value)
121 return 1; 129 return 1;
122 } 130 }
123 131
124char *_CONF_get_string(CONF *conf, char *section, char *name) 132char *_CONF_get_string(const CONF *conf, const char *section, const char *name)
125 { 133 {
126 CONF_VALUE *v,vv; 134 CONF_VALUE *v,vv;
127 char *p; 135 char *p;
@@ -131,8 +139,8 @@ char *_CONF_get_string(CONF *conf, char *section, char *name)
131 { 139 {
132 if (section != NULL) 140 if (section != NULL)
133 { 141 {
134 vv.name=name; 142 vv.name=(char *)name;
135 vv.section=section; 143 vv.section=(char *)section;
136 v=(CONF_VALUE *)lh_retrieve(conf->data,&vv); 144 v=(CONF_VALUE *)lh_retrieve(conf->data,&vv);
137 if (v != NULL) return(v->value); 145 if (v != NULL) return(v->value);
138 if (strcmp(section,"ENV") == 0) 146 if (strcmp(section,"ENV") == 0)
@@ -142,7 +150,7 @@ char *_CONF_get_string(CONF *conf, char *section, char *name)
142 } 150 }
143 } 151 }
144 vv.section="default"; 152 vv.section="default";
145 vv.name=name; 153 vv.name=(char *)name;
146 v=(CONF_VALUE *)lh_retrieve(conf->data,&vv); 154 v=(CONF_VALUE *)lh_retrieve(conf->data,&vv);
147 if (v != NULL) 155 if (v != NULL)
148 return(v->value); 156 return(v->value);
@@ -153,6 +161,9 @@ char *_CONF_get_string(CONF *conf, char *section, char *name)
153 return(Getenv(name)); 161 return(Getenv(name));
154 } 162 }
155 163
164#if 0 /* There's no way to provide error checking with this function, so
165 force implementors of the higher levels to get a string and read
166 the number themselves. */
156long _CONF_get_number(CONF *conf, char *section, char *name) 167long _CONF_get_number(CONF *conf, char *section, char *name)
157 { 168 {
158 char *str; 169 char *str;
@@ -169,6 +180,7 @@ long _CONF_get_number(CONF *conf, char *section, char *name)
169 str++; 180 str++;
170 } 181 }
171 } 182 }
183#endif
172 184
173int _CONF_new_data(CONF *conf) 185int _CONF_new_data(CONF *conf)
174 { 186 {
@@ -177,7 +189,7 @@ int _CONF_new_data(CONF *conf)
177 return 0; 189 return 0;
178 } 190 }
179 if (conf->data == NULL) 191 if (conf->data == NULL)
180 if ((conf->data = lh_new(hash,cmp_conf)) == NULL) 192 if ((conf->data = lh_new(hash, cmp_conf)) == NULL)
181 { 193 {
182 return 0; 194 return 0;
183 } 195 }
@@ -190,12 +202,14 @@ void _CONF_free_data(CONF *conf)
190 202
191 conf->data->down_load=0; /* evil thing to make sure the 'OPENSSL_free()' 203 conf->data->down_load=0; /* evil thing to make sure the 'OPENSSL_free()'
192 * works as expected */ 204 * works as expected */
193 lh_doall_arg(conf->data,(void (*)())value_free_hash,conf->data); 205 lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(value_free_hash),
206 conf->data);
194 207
195 /* We now have only 'section' entries in the hash table. 208 /* We now have only 'section' entries in the hash table.
196 * Due to problems with */ 209 * Due to problems with */
197 210
198 lh_doall_arg(conf->data,(void (*)())value_free_stack,conf->data); 211 lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(value_free_stack),
212 conf->data);
199 lh_free(conf->data); 213 lh_free(conf->data);
200 } 214 }
201 215
@@ -228,14 +242,19 @@ static void value_free_stack(CONF_VALUE *a, LHASH *conf)
228 OPENSSL_free(a); 242 OPENSSL_free(a);
229 } 243 }
230 244
231static unsigned long hash(CONF_VALUE *v) 245/* static unsigned long hash(CONF_VALUE *v) */
246static unsigned long hash(const void *v_void)
232 { 247 {
248 CONF_VALUE *v = (CONF_VALUE *)v_void;
233 return((lh_strhash(v->section)<<2)^lh_strhash(v->name)); 249 return((lh_strhash(v->section)<<2)^lh_strhash(v->name));
234 } 250 }
235 251
236static int cmp_conf(CONF_VALUE *a, CONF_VALUE *b) 252/* static int cmp_conf(CONF_VALUE *a, CONF_VALUE *b) */
253static int cmp_conf(const void *a_void,const void *b_void)
237 { 254 {
238 int i; 255 int i;
256 CONF_VALUE *a = (CONF_VALUE *)a_void;
257 CONF_VALUE *b = (CONF_VALUE *)b_void;
239 258
240 if (a->section != b->section) 259 if (a->section != b->section)
241 { 260 {
@@ -255,7 +274,7 @@ static int cmp_conf(CONF_VALUE *a, CONF_VALUE *b)
255 } 274 }
256 275
257/* Up until OpenSSL 0.9.5a, this was new_section */ 276/* Up until OpenSSL 0.9.5a, this was new_section */
258CONF_VALUE *_CONF_new_section(CONF *conf, char *section) 277CONF_VALUE *_CONF_new_section(CONF *conf, const char *section)
259 { 278 {
260 STACK *sk=NULL; 279 STACK *sk=NULL;
261 int ok=0,i; 280 int ok=0,i;
diff --git a/src/lib/libcrypto/conf/conf_api.h b/src/lib/libcrypto/conf/conf_api.h
index a5cc17b233..87a954aff6 100644
--- a/src/lib/libcrypto/conf/conf_api.h
+++ b/src/lib/libcrypto/conf/conf_api.h
@@ -67,15 +67,17 @@ extern "C" {
67#endif 67#endif
68 68
69/* Up until OpenSSL 0.9.5a, this was new_section */ 69/* Up until OpenSSL 0.9.5a, this was new_section */
70CONF_VALUE *_CONF_new_section(CONF *conf, char *section); 70CONF_VALUE *_CONF_new_section(CONF *conf, const char *section);
71/* Up until OpenSSL 0.9.5a, this was get_section */ 71/* Up until OpenSSL 0.9.5a, this was get_section */
72CONF_VALUE *_CONF_get_section(CONF *conf, char *section); 72CONF_VALUE *_CONF_get_section(const CONF *conf, const char *section);
73/* Up until OpenSSL 0.9.5a, this was CONF_get_section */ 73/* Up until OpenSSL 0.9.5a, this was CONF_get_section */
74STACK_OF(CONF_VALUE) *_CONF_get_section_values(CONF *conf, char *section); 74STACK_OF(CONF_VALUE) *_CONF_get_section_values(const CONF *conf,
75 const char *section);
75 76
76int _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value); 77int _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value);
77char *_CONF_get_string(CONF *conf, char *section, char *name); 78char *_CONF_get_string(const CONF *conf, const char *section,
78long _CONF_get_number(CONF *conf, char *section, char *name); 79 const char *name);
80long _CONF_get_number(const CONF *conf, const char *section, const char *name);
79 81
80int _CONF_new_data(CONF *conf); 82int _CONF_new_data(CONF *conf);
81void _CONF_free_data(CONF *conf); 83void _CONF_free_data(CONF *conf);
diff --git a/src/lib/libcrypto/conf/conf_def.c b/src/lib/libcrypto/conf/conf_def.c
index 773df32c68..31f2766246 100644
--- a/src/lib/libcrypto/conf/conf_def.c
+++ b/src/lib/libcrypto/conf/conf_def.c
@@ -81,10 +81,11 @@ static int def_init_default(CONF *conf);
81static int def_init_WIN32(CONF *conf); 81static int def_init_WIN32(CONF *conf);
82static int def_destroy(CONF *conf); 82static int def_destroy(CONF *conf);
83static int def_destroy_data(CONF *conf); 83static int def_destroy_data(CONF *conf);
84static int def_load(CONF *conf, BIO *bp, long *eline); 84static int def_load(CONF *conf, const char *name, long *eline);
85static int def_dump(CONF *conf, BIO *bp); 85static int def_load_bio(CONF *conf, BIO *bp, long *eline);
86static int def_is_number(CONF *conf, char c); 86static int def_dump(const CONF *conf, BIO *bp);
87static int def_to_int(CONF *conf, char c); 87static int def_is_number(const CONF *conf, char c);
88static int def_to_int(const CONF *conf, char c);
88 89
89const char *CONF_def_version="CONF_def" OPENSSL_VERSION_PTEXT; 90const char *CONF_def_version="CONF_def" OPENSSL_VERSION_PTEXT;
90 91
@@ -94,10 +95,11 @@ static CONF_METHOD default_method = {
94 def_init_default, 95 def_init_default,
95 def_destroy, 96 def_destroy,
96 def_destroy_data, 97 def_destroy_data,
97 def_load, 98 def_load_bio,
98 def_dump, 99 def_dump,
99 def_is_number, 100 def_is_number,
100 def_to_int 101 def_to_int,
102 def_load
101 }; 103 };
102 104
103static CONF_METHOD WIN32_method = { 105static CONF_METHOD WIN32_method = {
@@ -106,10 +108,11 @@ static CONF_METHOD WIN32_method = {
106 def_init_WIN32, 108 def_init_WIN32,
107 def_destroy, 109 def_destroy,
108 def_destroy_data, 110 def_destroy_data,
109 def_load, 111 def_load_bio,
110 def_dump, 112 def_dump,
111 def_is_number, 113 def_is_number,
112 def_to_int 114 def_to_int,
115 def_load
113 }; 116 };
114 117
115CONF_METHOD *NCONF_default() 118CONF_METHOD *NCONF_default()
@@ -177,7 +180,32 @@ static int def_destroy_data(CONF *conf)
177 return 1; 180 return 1;
178 } 181 }
179 182
180static int def_load(CONF *conf, BIO *in, long *line) 183static int def_load(CONF *conf, const char *name, long *line)
184 {
185 int ret;
186 BIO *in=NULL;
187
188#ifdef OPENSSL_SYS_VMS
189 in=BIO_new_file(name, "r");
190#else
191 in=BIO_new_file(name, "rb");
192#endif
193 if (in == NULL)
194 {
195 if (ERR_GET_REASON(ERR_peek_last_error()) == BIO_R_NO_SUCH_FILE)
196 CONFerr(CONF_F_CONF_LOAD,CONF_R_NO_SUCH_FILE);
197 else
198 CONFerr(CONF_F_CONF_LOAD,ERR_R_SYS_LIB);
199 return 0;
200 }
201
202 ret = def_load_bio(conf, in, line);
203 BIO_free(in);
204
205 return ret;
206 }
207
208static int def_load_bio(CONF *conf, BIO *in, long *line)
181 { 209 {
182#define BUFSIZE 512 210#define BUFSIZE 512
183 char btmp[16]; 211 char btmp[16];
@@ -418,7 +446,11 @@ err:
418 if (line != NULL) *line=eline; 446 if (line != NULL) *line=eline;
419 sprintf(btmp,"%ld",eline); 447 sprintf(btmp,"%ld",eline);
420 ERR_add_error_data(2,"line ",btmp); 448 ERR_add_error_data(2,"line ",btmp);
421 if ((h != conf->data) && (conf->data != NULL)) CONF_free(conf->data); 449 if ((h != conf->data) && (conf->data != NULL))
450 {
451 CONF_free(conf->data);
452 conf->data=NULL;
453 }
422 if (v != NULL) 454 if (v != NULL)
423 { 455 {
424 if (v->name != NULL) OPENSSL_free(v->name); 456 if (v->name != NULL) OPENSSL_free(v->name);
@@ -685,18 +717,20 @@ static void dump_value(CONF_VALUE *a, BIO *out)
685 BIO_printf(out, "[[%s]]\n", a->section); 717 BIO_printf(out, "[[%s]]\n", a->section);
686 } 718 }
687 719
688static int def_dump(CONF *conf, BIO *out) 720static IMPLEMENT_LHASH_DOALL_ARG_FN(dump_value, CONF_VALUE *, BIO *)
721
722static int def_dump(const CONF *conf, BIO *out)
689 { 723 {
690 lh_doall_arg(conf->data, (void (*)())dump_value, out); 724 lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(dump_value), out);
691 return 1; 725 return 1;
692 } 726 }
693 727
694static int def_is_number(CONF *conf, char c) 728static int def_is_number(const CONF *conf, char c)
695 { 729 {
696 return IS_NUMBER(conf,c); 730 return IS_NUMBER(conf,c);
697 } 731 }
698 732
699static int def_to_int(CONF *conf, char c) 733static int def_to_int(const CONF *conf, char c)
700 { 734 {
701 return c - '0'; 735 return c - '0';
702 } 736 }
diff --git a/src/lib/libcrypto/conf/conf_def.h b/src/lib/libcrypto/conf/conf_def.h
index 3244d9a331..92a7d8ad77 100644
--- a/src/lib/libcrypto/conf/conf_def.h
+++ b/src/lib/libcrypto/conf/conf_def.h
@@ -71,6 +71,7 @@
71#define CONF_COMMENT 128 71#define CONF_COMMENT 128
72#define CONF_FCOMMENT 2048 72#define CONF_FCOMMENT 2048
73#define CONF_EOF 8 73#define CONF_EOF 8
74#define CONF_HIGHBIT 4096
74#define CONF_ALPHA (CONF_UPPER|CONF_LOWER) 75#define CONF_ALPHA (CONF_UPPER|CONF_LOWER)
75#define CONF_ALPHA_NUMERIC (CONF_ALPHA|CONF_NUMBER|CONF_UNDER) 76#define CONF_ALPHA_NUMERIC (CONF_ALPHA|CONF_NUMBER|CONF_UNDER)
76#define CONF_ALPHA_NUMERIC_PUNCT (CONF_ALPHA|CONF_NUMBER|CONF_UNDER| \ 77#define CONF_ALPHA_NUMERIC_PUNCT (CONF_ALPHA|CONF_NUMBER|CONF_UNDER| \
@@ -78,68 +79,102 @@
78 79
79#define KEYTYPES(c) ((unsigned short *)((c)->meth_data)) 80#define KEYTYPES(c) ((unsigned short *)((c)->meth_data))
80#ifndef CHARSET_EBCDIC 81#ifndef CHARSET_EBCDIC
81#define IS_COMMENT(c,a) (KEYTYPES(c)[(a)&0x7f]&CONF_COMMENT) 82#define IS_COMMENT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_COMMENT)
82#define IS_FCOMMENT(c,a) (KEYTYPES(c)[(a)&0x7f]&CONF_FCOMMENT) 83#define IS_FCOMMENT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_FCOMMENT)
83#define IS_EOF(c,a) (KEYTYPES(c)[(a)&0x7f]&CONF_EOF) 84#define IS_EOF(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_EOF)
84#define IS_ESC(c,a) (KEYTYPES(c)[(a)&0x7f]&CONF_ESC) 85#define IS_ESC(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_ESC)
85#define IS_NUMBER(c,a) (KEYTYPES(c)[(a)&0x7f]&CONF_NUMBER) 86#define IS_NUMBER(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_NUMBER)
86#define IS_WS(c,a) (KEYTYPES(c)[(a)&0x7f]&CONF_WS) 87#define IS_WS(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_WS)
87#define IS_ALPHA_NUMERIC(c,a) (KEYTYPES(c)[(a)&0x7f]&CONF_ALPHA_NUMERIC) 88#define IS_ALPHA_NUMERIC(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_ALPHA_NUMERIC)
88#define IS_ALPHA_NUMERIC_PUNCT(c,a) \ 89#define IS_ALPHA_NUMERIC_PUNCT(c,a) \
89 (KEYTYPES(c)[(a)&0x7f]&CONF_ALPHA_NUMERIC_PUNCT) 90 (KEYTYPES(c)[(a)&0xff]&CONF_ALPHA_NUMERIC_PUNCT)
90#define IS_QUOTE(c,a) (KEYTYPES(c)[(a)&0x7f]&CONF_QUOTE) 91#define IS_QUOTE(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_QUOTE)
91#define IS_DQUOTE(c,a) (KEYTYPES(c)[(a)&0x7f]&CONF_DQUOTE) 92#define IS_DQUOTE(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_DQUOTE)
93#define IS_HIGHBIT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_HIGHBIT)
92 94
93#else /*CHARSET_EBCDIC*/ 95#else /*CHARSET_EBCDIC*/
94 96
95#define IS_COMMENT(c,a) (KEYTYPES(c)[os_toascii[a]&0x7f]&CONF_COMMENT) 97#define IS_COMMENT(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_COMMENT)
96#define IS_FCOMMENT(c,a) (KEYTYPES(c)[os_toascii[a]&0x7f]&CONF_FCOMMENT) 98#define IS_FCOMMENT(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_FCOMMENT)
97#define IS_EOF(c,a) (KEYTYPES(c)[os_toascii[a]&0x7f]&CONF_EOF) 99#define IS_EOF(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_EOF)
98#define IS_ESC(c,a) (KEYTYPES(c)[os_toascii[a]&0x7f]&CONF_ESC) 100#define IS_ESC(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_ESC)
99#define IS_NUMBER(c,a) (KEYTYPES(c)[os_toascii[a]&0x7f]&CONF_NUMBER) 101#define IS_NUMBER(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_NUMBER)
100#define IS_WS(c,a) (KEYTYPES(c)[os_toascii[a]&0x7f]&CONF_WS) 102#define IS_WS(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_WS)
101#define IS_ALPHA_NUMERIC(c,a) (KEYTYPES(c)[os_toascii[a]&0x7f]&CONF_ALPHA_NUMERIC) 103#define IS_ALPHA_NUMERIC(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_ALPHA_NUMERIC)
102#define IS_ALPHA_NUMERIC_PUNCT(c,a) \ 104#define IS_ALPHA_NUMERIC_PUNCT(c,a) \
103 (KEYTYPES(c)[os_toascii[a]&0x7f]&CONF_ALPHA_NUMERIC_PUNCT) 105 (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_ALPHA_NUMERIC_PUNCT)
104#define IS_QUOTE(c,a) (KEYTYPES(c)[os_toascii[a]&0x7f]&CONF_QUOTE) 106#define IS_QUOTE(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_QUOTE)
105#define IS_DQUOTE(c,a) (KEYTYPES(c)[os_toascii[a]&0x7f]&CONF_DQUOTE) 107#define IS_DQUOTE(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_DQUOTE)
108#define IS_HIGHBIT(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_HIGHBIT)
106#endif /*CHARSET_EBCDIC*/ 109#endif /*CHARSET_EBCDIC*/
107 110
108static unsigned short CONF_type_default[128]={ 111static unsigned short CONF_type_default[256]={
109 0x008,0x000,0x000,0x000,0x000,0x000,0x000,0x000, 112 0x0008,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
110 0x000,0x010,0x010,0x000,0x000,0x010,0x000,0x000, 113 0x0000,0x0010,0x0010,0x0000,0x0000,0x0010,0x0000,0x0000,
111 0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000, 114 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
112 0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000, 115 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
113 0x010,0x200,0x040,0x080,0x000,0x200,0x200,0x040, 116 0x0010,0x0200,0x0040,0x0080,0x0000,0x0200,0x0200,0x0040,
114 0x000,0x000,0x200,0x200,0x200,0x200,0x200,0x200, 117 0x0000,0x0000,0x0200,0x0200,0x0200,0x0200,0x0200,0x0200,
115 0x001,0x001,0x001,0x001,0x001,0x001,0x001,0x001, 118 0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
116 0x001,0x001,0x000,0x200,0x000,0x000,0x000,0x200, 119 0x0001,0x0001,0x0000,0x0200,0x0000,0x0000,0x0000,0x0200,
117 0x200,0x002,0x002,0x002,0x002,0x002,0x002,0x002, 120 0x0200,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,
118 0x002,0x002,0x002,0x002,0x002,0x002,0x002,0x002, 121 0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,
119 0x002,0x002,0x002,0x002,0x002,0x002,0x002,0x002, 122 0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,
120 0x002,0x002,0x002,0x000,0x020,0x000,0x200,0x100, 123 0x0002,0x0002,0x0002,0x0000,0x0020,0x0000,0x0200,0x0100,
121 0x040,0x004,0x004,0x004,0x004,0x004,0x004,0x004, 124 0x0040,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,
122 0x004,0x004,0x004,0x004,0x004,0x004,0x004,0x004, 125 0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,
123 0x004,0x004,0x004,0x004,0x004,0x004,0x004,0x004, 126 0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,
124 0x004,0x004,0x004,0x000,0x200,0x000,0x200,0x000, 127 0x0004,0x0004,0x0004,0x0000,0x0200,0x0000,0x0200,0x0000,
128 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
129 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
130 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
131 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
132 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
133 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
134 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
135 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
136 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
137 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
138 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
139 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
140 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
141 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
142 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
143 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
125 }; 144 };
126 145
127static unsigned short CONF_type_win32[128]={ 146static unsigned short CONF_type_win32[256]={
128 0x008,0x000,0x000,0x000,0x000,0x000,0x000,0x000, 147 0x0008,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
129 0x000,0x010,0x010,0x000,0x000,0x010,0x000,0x000, 148 0x0000,0x0010,0x0010,0x0000,0x0000,0x0010,0x0000,0x0000,
130 0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000, 149 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
131 0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000, 150 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
132 0x010,0x200,0x400,0x000,0x000,0x200,0x200,0x000, 151 0x0010,0x0200,0x0400,0x0000,0x0000,0x0200,0x0200,0x0000,
133 0x000,0x000,0x200,0x200,0x200,0x200,0x200,0x200, 152 0x0000,0x0000,0x0200,0x0200,0x0200,0x0200,0x0200,0x0200,
134 0x001,0x001,0x001,0x001,0x001,0x001,0x001,0x001, 153 0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
135 0x001,0x001,0x000,0xA00,0x000,0x000,0x000,0x200, 154 0x0001,0x0001,0x0000,0x0A00,0x0000,0x0000,0x0000,0x0200,
136 0x200,0x002,0x002,0x002,0x002,0x002,0x002,0x002, 155 0x0200,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,
137 0x002,0x002,0x002,0x002,0x002,0x002,0x002,0x002, 156 0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,
138 0x002,0x002,0x002,0x002,0x002,0x002,0x002,0x002, 157 0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,
139 0x002,0x002,0x002,0x000,0x000,0x000,0x200,0x100, 158 0x0002,0x0002,0x0002,0x0000,0x0000,0x0000,0x0200,0x0100,
140 0x000,0x004,0x004,0x004,0x004,0x004,0x004,0x004, 159 0x0000,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,
141 0x004,0x004,0x004,0x004,0x004,0x004,0x004,0x004, 160 0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,
142 0x004,0x004,0x004,0x004,0x004,0x004,0x004,0x004, 161 0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,
143 0x004,0x004,0x004,0x000,0x200,0x000,0x200,0x000, 162 0x0004,0x0004,0x0004,0x0000,0x0200,0x0000,0x0200,0x0000,
163 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
164 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
165 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
166 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
167 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
168 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
169 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
170 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
171 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
172 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
173 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
174 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
175 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
176 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
177 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
178 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,
144 }; 179 };
145 180
diff --git a/src/lib/libcrypto/conf/conf_err.c b/src/lib/libcrypto/conf/conf_err.c
index 8c2bc6f1c4..ee07bfe9d9 100644
--- a/src/lib/libcrypto/conf/conf_err.c
+++ b/src/lib/libcrypto/conf/conf_err.c
@@ -63,19 +63,26 @@
63#include <openssl/conf.h> 63#include <openssl/conf.h>
64 64
65/* BEGIN ERROR CODES */ 65/* BEGIN ERROR CODES */
66#ifndef NO_ERR 66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA CONF_str_functs[]= 67static ERR_STRING_DATA CONF_str_functs[]=
68 { 68 {
69{ERR_PACK(0,CONF_F_CONF_DUMP_FP,0), "CONF_dump_fp"}, 69{ERR_PACK(0,CONF_F_CONF_DUMP_FP,0), "CONF_dump_fp"},
70{ERR_PACK(0,CONF_F_CONF_LOAD,0), "CONF_load"}, 70{ERR_PACK(0,CONF_F_CONF_LOAD,0), "CONF_load"},
71{ERR_PACK(0,CONF_F_CONF_LOAD_BIO,0), "CONF_load_bio"}, 71{ERR_PACK(0,CONF_F_CONF_LOAD_BIO,0), "CONF_load_bio"},
72{ERR_PACK(0,CONF_F_CONF_LOAD_FP,0), "CONF_load_fp"}, 72{ERR_PACK(0,CONF_F_CONF_LOAD_FP,0), "CONF_load_fp"},
73{ERR_PACK(0,CONF_F_CONF_MODULES_LOAD,0), "CONF_modules_load"},
74{ERR_PACK(0,CONF_F_MODULE_INIT,0), "MODULE_INIT"},
75{ERR_PACK(0,CONF_F_MODULE_LOAD_DSO,0), "MODULE_LOAD_DSO"},
76{ERR_PACK(0,CONF_F_MODULE_RUN,0), "MODULE_RUN"},
73{ERR_PACK(0,CONF_F_NCONF_DUMP_BIO,0), "NCONF_dump_bio"}, 77{ERR_PACK(0,CONF_F_NCONF_DUMP_BIO,0), "NCONF_dump_bio"},
74{ERR_PACK(0,CONF_F_NCONF_DUMP_FP,0), "NCONF_dump_fp"}, 78{ERR_PACK(0,CONF_F_NCONF_DUMP_FP,0), "NCONF_dump_fp"},
75{ERR_PACK(0,CONF_F_NCONF_GET_NUMBER,0), "NCONF_get_number"}, 79{ERR_PACK(0,CONF_F_NCONF_GET_NUMBER,0), "NCONF_get_number"},
80{ERR_PACK(0,CONF_F_NCONF_GET_NUMBER_E,0), "NCONF_get_number_e"},
76{ERR_PACK(0,CONF_F_NCONF_GET_SECTION,0), "NCONF_get_section"}, 81{ERR_PACK(0,CONF_F_NCONF_GET_SECTION,0), "NCONF_get_section"},
77{ERR_PACK(0,CONF_F_NCONF_GET_STRING,0), "NCONF_get_string"}, 82{ERR_PACK(0,CONF_F_NCONF_GET_STRING,0), "NCONF_get_string"},
83{ERR_PACK(0,CONF_F_NCONF_LOAD,0), "NCONF_load"},
78{ERR_PACK(0,CONF_F_NCONF_LOAD_BIO,0), "NCONF_load_bio"}, 84{ERR_PACK(0,CONF_F_NCONF_LOAD_BIO,0), "NCONF_load_bio"},
85{ERR_PACK(0,CONF_F_NCONF_LOAD_FP,0), "NCONF_load_fp"},
79{ERR_PACK(0,CONF_F_NCONF_NEW,0), "NCONF_new"}, 86{ERR_PACK(0,CONF_F_NCONF_NEW,0), "NCONF_new"},
80{ERR_PACK(0,CONF_F_STR_COPY,0), "STR_COPY"}, 87{ERR_PACK(0,CONF_F_STR_COPY,0), "STR_COPY"},
81{0,NULL} 88{0,NULL}
@@ -83,13 +90,20 @@ static ERR_STRING_DATA CONF_str_functs[]=
83 90
84static ERR_STRING_DATA CONF_str_reasons[]= 91static ERR_STRING_DATA CONF_str_reasons[]=
85 { 92 {
93{CONF_R_ERROR_LOADING_DSO ,"error loading dso"},
86{CONF_R_MISSING_CLOSE_SQUARE_BRACKET ,"missing close square bracket"}, 94{CONF_R_MISSING_CLOSE_SQUARE_BRACKET ,"missing close square bracket"},
87{CONF_R_MISSING_EQUAL_SIGN ,"missing equal sign"}, 95{CONF_R_MISSING_EQUAL_SIGN ,"missing equal sign"},
96{CONF_R_MISSING_FINISH_FUNCTION ,"missing finish function"},
97{CONF_R_MISSING_INIT_FUNCTION ,"missing init function"},
98{CONF_R_MODULE_INITIALIZATION_ERROR ,"module initialization error"},
88{CONF_R_NO_CLOSE_BRACE ,"no close brace"}, 99{CONF_R_NO_CLOSE_BRACE ,"no close brace"},
89{CONF_R_NO_CONF ,"no conf"}, 100{CONF_R_NO_CONF ,"no conf"},
90{CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE ,"no conf or environment variable"}, 101{CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE ,"no conf or environment variable"},
91{CONF_R_NO_SECTION ,"no section"}, 102{CONF_R_NO_SECTION ,"no section"},
103{CONF_R_NO_SUCH_FILE ,"no such file"},
104{CONF_R_NO_VALUE ,"no value"},
92{CONF_R_UNABLE_TO_CREATE_NEW_SECTION ,"unable to create new section"}, 105{CONF_R_UNABLE_TO_CREATE_NEW_SECTION ,"unable to create new section"},
106{CONF_R_UNKNOWN_MODULE_NAME ,"unknown module name"},
93{CONF_R_VARIABLE_HAS_NO_VALUE ,"variable has no value"}, 107{CONF_R_VARIABLE_HAS_NO_VALUE ,"variable has no value"},
94{0,NULL} 108{0,NULL}
95 }; 109 };
@@ -103,7 +117,7 @@ void ERR_load_CONF_strings(void)
103 if (init) 117 if (init)
104 { 118 {
105 init=0; 119 init=0;
106#ifndef NO_ERR 120#ifndef OPENSSL_NO_ERR
107 ERR_load_strings(ERR_LIB_CONF,CONF_str_functs); 121 ERR_load_strings(ERR_LIB_CONF,CONF_str_functs);
108 ERR_load_strings(ERR_LIB_CONF,CONF_str_reasons); 122 ERR_load_strings(ERR_LIB_CONF,CONF_str_reasons);
109#endif 123#endif
diff --git a/src/lib/libcrypto/conf/conf_lib.c b/src/lib/libcrypto/conf/conf_lib.c
index 11ec639732..7998f34c7b 100644
--- a/src/lib/libcrypto/conf/conf_lib.c
+++ b/src/lib/libcrypto/conf/conf_lib.c
@@ -67,6 +67,17 @@ const char *CONF_version="CONF" OPENSSL_VERSION_PTEXT;
67 67
68static CONF_METHOD *default_CONF_method=NULL; 68static CONF_METHOD *default_CONF_method=NULL;
69 69
70/* Init a 'CONF' structure from an old LHASH */
71
72void CONF_set_nconf(CONF *conf, LHASH *hash)
73 {
74 if (default_CONF_method == NULL)
75 default_CONF_method = NCONF_default();
76
77 default_CONF_method->init(conf);
78 conf->data = hash;
79 }
80
70/* The following section contains the "CONF classic" functions, 81/* The following section contains the "CONF classic" functions,
71 rewritten in terms of the new CONF interface. */ 82 rewritten in terms of the new CONF interface. */
72 83
@@ -81,7 +92,7 @@ LHASH *CONF_load(LHASH *conf, const char *file, long *eline)
81 LHASH *ltmp; 92 LHASH *ltmp;
82 BIO *in=NULL; 93 BIO *in=NULL;
83 94
84#ifdef VMS 95#ifdef OPENSSL_SYS_VMS
85 in=BIO_new_file(file, "r"); 96 in=BIO_new_file(file, "r");
86#else 97#else
87 in=BIO_new_file(file, "rb"); 98 in=BIO_new_file(file, "rb");
@@ -98,7 +109,7 @@ LHASH *CONF_load(LHASH *conf, const char *file, long *eline)
98 return ltmp; 109 return ltmp;
99 } 110 }
100 111
101#ifndef NO_FP_API 112#ifndef OPENSSL_NO_FP_API
102LHASH *CONF_load_fp(LHASH *conf, FILE *fp,long *eline) 113LHASH *CONF_load_fp(LHASH *conf, FILE *fp,long *eline)
103 { 114 {
104 BIO *btmp; 115 BIO *btmp;
@@ -118,18 +129,15 @@ LHASH *CONF_load_bio(LHASH *conf, BIO *bp,long *eline)
118 CONF ctmp; 129 CONF ctmp;
119 int ret; 130 int ret;
120 131
121 if (default_CONF_method == NULL) 132 CONF_set_nconf(&ctmp, conf);
122 default_CONF_method = NCONF_default();
123 133
124 default_CONF_method->init(&ctmp);
125 ctmp.data = conf;
126 ret = NCONF_load_bio(&ctmp, bp, eline); 134 ret = NCONF_load_bio(&ctmp, bp, eline);
127 if (ret) 135 if (ret)
128 return ctmp.data; 136 return ctmp.data;
129 return NULL; 137 return NULL;
130 } 138 }
131 139
132STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,char *section) 140STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,const char *section)
133 { 141 {
134 if (conf == NULL) 142 if (conf == NULL)
135 { 143 {
@@ -138,17 +146,12 @@ STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,char *section)
138 else 146 else
139 { 147 {
140 CONF ctmp; 148 CONF ctmp;
141 149 CONF_set_nconf(&ctmp, conf);
142 if (default_CONF_method == NULL)
143 default_CONF_method = NCONF_default();
144
145 default_CONF_method->init(&ctmp);
146 ctmp.data = conf;
147 return NCONF_get_section(&ctmp, section); 150 return NCONF_get_section(&ctmp, section);
148 } 151 }
149 } 152 }
150 153
151char *CONF_get_string(LHASH *conf,char *group,char *name) 154char *CONF_get_string(LHASH *conf,const char *group,const char *name)
152 { 155 {
153 if (conf == NULL) 156 if (conf == NULL)
154 { 157 {
@@ -157,48 +160,43 @@ char *CONF_get_string(LHASH *conf,char *group,char *name)
157 else 160 else
158 { 161 {
159 CONF ctmp; 162 CONF ctmp;
160 163 CONF_set_nconf(&ctmp, conf);
161 if (default_CONF_method == NULL)
162 default_CONF_method = NCONF_default();
163
164 default_CONF_method->init(&ctmp);
165 ctmp.data = conf;
166 return NCONF_get_string(&ctmp, group, name); 164 return NCONF_get_string(&ctmp, group, name);
167 } 165 }
168 } 166 }
169 167
170long CONF_get_number(LHASH *conf,char *group,char *name) 168long CONF_get_number(LHASH *conf,const char *group,const char *name)
171 { 169 {
170 int status;
171 long result = 0;
172
172 if (conf == NULL) 173 if (conf == NULL)
173 { 174 {
174 return NCONF_get_number(NULL, group, name); 175 status = NCONF_get_number_e(NULL, group, name, &result);
175 } 176 }
176 else 177 else
177 { 178 {
178 CONF ctmp; 179 CONF ctmp;
180 CONF_set_nconf(&ctmp, conf);
181 status = NCONF_get_number_e(&ctmp, group, name, &result);
182 }
179 183
180 if (default_CONF_method == NULL) 184 if (status == 0)
181 default_CONF_method = NCONF_default(); 185 {
182 186 /* This function does not believe in errors... */
183 default_CONF_method->init(&ctmp); 187 ERR_get_error();
184 ctmp.data = conf;
185 return NCONF_get_number(&ctmp, group, name);
186 } 188 }
189 return result;
187 } 190 }
188 191
189void CONF_free(LHASH *conf) 192void CONF_free(LHASH *conf)
190 { 193 {
191 CONF ctmp; 194 CONF ctmp;
192 195 CONF_set_nconf(&ctmp, conf);
193 if (default_CONF_method == NULL)
194 default_CONF_method = NCONF_default();
195
196 default_CONF_method->init(&ctmp);
197 ctmp.data = conf;
198 NCONF_free_data(&ctmp); 196 NCONF_free_data(&ctmp);
199 } 197 }
200 198
201#ifndef NO_FP_API 199#ifndef OPENSSL_NO_FP_API
202int CONF_dump_fp(LHASH *conf, FILE *out) 200int CONF_dump_fp(LHASH *conf, FILE *out)
203 { 201 {
204 BIO *btmp; 202 BIO *btmp;
@@ -217,12 +215,7 @@ int CONF_dump_fp(LHASH *conf, FILE *out)
217int CONF_dump_bio(LHASH *conf, BIO *out) 215int CONF_dump_bio(LHASH *conf, BIO *out)
218 { 216 {
219 CONF ctmp; 217 CONF ctmp;
220 218 CONF_set_nconf(&ctmp, conf);
221 if (default_CONF_method == NULL)
222 default_CONF_method = NCONF_default();
223
224 default_CONF_method->init(&ctmp);
225 ctmp.data = conf;
226 return NCONF_dump_bio(&ctmp, out); 219 return NCONF_dump_bio(&ctmp, out);
227 } 220 }
228 221
@@ -265,34 +258,23 @@ void NCONF_free_data(CONF *conf)
265 258
266int NCONF_load(CONF *conf, const char *file, long *eline) 259int NCONF_load(CONF *conf, const char *file, long *eline)
267 { 260 {
268 int ret; 261 if (conf == NULL)
269 BIO *in=NULL;
270
271#ifdef VMS
272 in=BIO_new_file(file, "r");
273#else
274 in=BIO_new_file(file, "rb");
275#endif
276 if (in == NULL)
277 { 262 {
278 CONFerr(CONF_F_CONF_LOAD,ERR_R_SYS_LIB); 263 CONFerr(CONF_F_NCONF_LOAD,CONF_R_NO_CONF);
279 return 0; 264 return 0;
280 } 265 }
281 266
282 ret = NCONF_load_bio(conf, in, eline); 267 return conf->meth->load(conf, file, eline);
283 BIO_free(in);
284
285 return ret;
286 } 268 }
287 269
288#ifndef NO_FP_API 270#ifndef OPENSSL_NO_FP_API
289int NCONF_load_fp(CONF *conf, FILE *fp,long *eline) 271int NCONF_load_fp(CONF *conf, FILE *fp,long *eline)
290 { 272 {
291 BIO *btmp; 273 BIO *btmp;
292 int ret; 274 int ret;
293 if(!(btmp = BIO_new_fp(fp, BIO_NOCLOSE))) 275 if(!(btmp = BIO_new_fp(fp, BIO_NOCLOSE)))
294 { 276 {
295 CONFerr(CONF_F_CONF_LOAD_FP,ERR_R_BUF_LIB); 277 CONFerr(CONF_F_NCONF_LOAD_FP,ERR_R_BUF_LIB);
296 return 0; 278 return 0;
297 } 279 }
298 ret = NCONF_load_bio(conf, btmp, eline); 280 ret = NCONF_load_bio(conf, btmp, eline);
@@ -309,10 +291,10 @@ int NCONF_load_bio(CONF *conf, BIO *bp,long *eline)
309 return 0; 291 return 0;
310 } 292 }
311 293
312 return conf->meth->load(conf, bp, eline); 294 return conf->meth->load_bio(conf, bp, eline);
313 } 295 }
314 296
315STACK_OF(CONF_VALUE) *NCONF_get_section(CONF *conf,char *section) 297STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf,const char *section)
316 { 298 {
317 if (conf == NULL) 299 if (conf == NULL)
318 { 300 {
@@ -329,7 +311,7 @@ STACK_OF(CONF_VALUE) *NCONF_get_section(CONF *conf,char *section)
329 return _CONF_get_section_values(conf, section); 311 return _CONF_get_section_values(conf, section);
330 } 312 }
331 313
332char *NCONF_get_string(CONF *conf,char *group,char *name) 314char *NCONF_get_string(const CONF *conf,const char *group,const char *name)
333 { 315 {
334 char *s = _CONF_get_string(conf, group, name); 316 char *s = _CONF_get_string(conf, group, name);
335 317
@@ -343,29 +325,39 @@ char *NCONF_get_string(CONF *conf,char *group,char *name)
343 CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE); 325 CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE);
344 return NULL; 326 return NULL;
345 } 327 }
328 CONFerr(CONF_F_NCONF_GET_STRING,
329 CONF_R_NO_VALUE);
330 ERR_add_error_data(4,"group=",group," name=",name);
346 return NULL; 331 return NULL;
347 } 332 }
348 333
349long NCONF_get_number(CONF *conf,char *group,char *name) 334int NCONF_get_number_e(const CONF *conf,const char *group,const char *name,
335 long *result)
350 { 336 {
351#if 0 /* As with _CONF_get_string(), we rely on the possibility of finding 337 char *str;
352 an environment variable with a suitable name. Unfortunately, there's 338
353 no way with the current API to see if we found one or not... 339 if (result == NULL)
354 The meaning of this is that if a number is not found anywhere, it
355 will always default to 0. */
356 if (conf == NULL)
357 { 340 {
358 CONFerr(CONF_F_NCONF_GET_NUMBER, 341 CONFerr(CONF_F_NCONF_GET_NUMBER_E,ERR_R_PASSED_NULL_PARAMETER);
359 CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE);
360 return 0; 342 return 0;
361 } 343 }
362#endif 344
363 345 str = NCONF_get_string(conf,group,name);
364 return _CONF_get_number(conf, group, name); 346
347 if (str == NULL)
348 return 0;
349
350 for (*result = 0;conf->meth->is_number(conf, *str);)
351 {
352 *result = (*result)*10 + conf->meth->to_int(conf, *str);
353 str++;
354 }
355
356 return 1;
365 } 357 }
366 358
367#ifndef NO_FP_API 359#ifndef OPENSSL_NO_FP_API
368int NCONF_dump_fp(CONF *conf, FILE *out) 360int NCONF_dump_fp(const CONF *conf, FILE *out)
369 { 361 {
370 BIO *btmp; 362 BIO *btmp;
371 int ret; 363 int ret;
@@ -379,7 +371,7 @@ int NCONF_dump_fp(CONF *conf, FILE *out)
379 } 371 }
380#endif 372#endif
381 373
382int NCONF_dump_bio(CONF *conf, BIO *out) 374int NCONF_dump_bio(const CONF *conf, BIO *out)
383 { 375 {
384 if (conf == NULL) 376 if (conf == NULL)
385 { 377 {
@@ -390,3 +382,19 @@ int NCONF_dump_bio(CONF *conf, BIO *out)
390 return conf->meth->dump(conf, out); 382 return conf->meth->dump(conf, out);
391 } 383 }
392 384
385/* This function should be avoided */
386#undef NCONF_get_number
387long NCONF_get_number(CONF *conf,char *group,char *name)
388 {
389 int status;
390 long ret=0;
391
392 status = NCONF_get_number_e(conf, group, name, &ret);
393 if (status == 0)
394 {
395 /* This function does not believe in errors... */
396 ERR_get_error();
397 }
398 return ret;
399 }
400
diff --git a/src/lib/libcrypto/conf/conf_mall.c b/src/lib/libcrypto/conf/conf_mall.c
new file mode 100644
index 0000000000..d702af689b
--- /dev/null
+++ b/src/lib/libcrypto/conf/conf_mall.c
@@ -0,0 +1,76 @@
1/* conf_mall.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 <stdio.h>
60#include <openssl/crypto.h>
61#include "cryptlib.h"
62#include <openssl/conf.h>
63#include <openssl/dso.h>
64#include <openssl/x509.h>
65#include <openssl/asn1.h>
66#include <openssl/engine.h>
67
68/* Load all OpenSSL builtin modules */
69
70void OPENSSL_load_builtin_modules(void)
71 {
72 /* Add builtin modules here */
73 ASN1_add_oid_module();
74 ENGINE_add_conf_module();
75 }
76
diff --git a/src/lib/libcrypto/conf/conf_mod.c b/src/lib/libcrypto/conf/conf_mod.c
new file mode 100644
index 0000000000..f92babc2e2
--- /dev/null
+++ b/src/lib/libcrypto/conf/conf_mod.c
@@ -0,0 +1,616 @@
1/* conf_mod.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 <stdio.h>
60#include <ctype.h>
61#include <openssl/crypto.h>
62#include "cryptlib.h"
63#include <openssl/conf.h>
64#include <openssl/dso.h>
65#include <openssl/x509.h>
66
67
68#define DSO_mod_init_name "OPENSSL_init"
69#define DSO_mod_finish_name "OPENSSL_finish"
70
71
72/* This structure contains a data about supported modules.
73 * entries in this table correspond to either dynamic or
74 * static modules.
75 */
76
77struct conf_module_st
78 {
79 /* DSO of this module or NULL if static */
80 DSO *dso;
81 /* Name of the module */
82 char *name;
83 /* Init function */
84 conf_init_func *init;
85 /* Finish function */
86 conf_finish_func *finish;
87 /* Number of successfully initialized modules */
88 int links;
89 void *usr_data;
90 };
91
92
93/* This structure contains information about modules that have been
94 * successfully initialized. There may be more than one entry for a
95 * given module.
96 */
97
98struct conf_imodule_st
99 {
100 CONF_MODULE *pmod;
101 char *name;
102 char *value;
103 unsigned long flags;
104 void *usr_data;
105 };
106
107static STACK_OF(CONF_MODULE) *supported_modules = NULL;
108static STACK_OF(CONF_IMODULE) *initialized_modules = NULL;
109
110static void module_free(CONF_MODULE *md);
111static void module_finish(CONF_IMODULE *imod);
112static int module_run(const CONF *cnf, char *name, char *value,
113 unsigned long flags);
114static CONF_MODULE *module_add(DSO *dso, const char *name,
115 conf_init_func *ifunc, conf_finish_func *ffunc);
116static CONF_MODULE *module_find(char *name);
117static int module_init(CONF_MODULE *pmod, char *name, char *value,
118 const CONF *cnf);
119static CONF_MODULE *module_load_dso(const CONF *cnf, char *name, char *value,
120 unsigned long flags);
121
122/* Main function: load modules from a CONF structure */
123
124int CONF_modules_load(const CONF *cnf, const char *appname,
125 unsigned long flags)
126 {
127 STACK_OF(CONF_VALUE) *values;
128 CONF_VALUE *vl;
129 char *vsection;
130
131 int ret, i;
132
133 if (!cnf)
134 return 1;
135
136 if (appname == NULL)
137 appname = "openssl_conf";
138
139 vsection = NCONF_get_string(cnf, NULL, appname);
140
141 if (!vsection)
142 {
143 ERR_clear_error();
144 return 1;
145 }
146
147 values = NCONF_get_section(cnf, vsection);
148
149 if (!values)
150 return 0;
151
152 for (i = 0; i < sk_CONF_VALUE_num(values); i++)
153 {
154 vl = sk_CONF_VALUE_value(values, i);
155 ret = module_run(cnf, vl->name, vl->value, flags);
156 if (ret <= 0)
157 if(!(flags & CONF_MFLAGS_IGNORE_ERRORS))
158 return ret;
159 }
160
161 return 1;
162
163 }
164
165int CONF_modules_load_file(const char *filename, const char *appname,
166 unsigned long flags)
167 {
168 char *file = NULL;
169 CONF *conf = NULL;
170 int ret = 0;
171 conf = NCONF_new(NULL);
172 if (!conf)
173 goto err;
174
175 if (filename == NULL)
176 {
177 file = CONF_get1_default_config_file();
178 if (!file)
179 goto err;
180 }
181 else
182 file = (char *)filename;
183
184 if (NCONF_load(conf, file, NULL) <= 0)
185 {
186 if ((flags & CONF_MFLAGS_IGNORE_MISSING_FILE) &&
187 (ERR_GET_REASON(ERR_peek_last_error()) == CONF_R_NO_SUCH_FILE))
188 {
189 ERR_clear_error();
190 ret = 1;
191 }
192 goto err;
193 }
194
195 ret = CONF_modules_load(conf, appname, flags);
196
197 err:
198 if (filename == NULL)
199 OPENSSL_free(file);
200 NCONF_free(conf);
201
202 return ret;
203 }
204
205static int module_run(const CONF *cnf, char *name, char *value,
206 unsigned long flags)
207 {
208 CONF_MODULE *md;
209 int ret;
210
211 md = module_find(name);
212
213 /* Module not found: try to load DSO */
214 if (!md && !(flags & CONF_MFLAGS_NO_DSO))
215 md = module_load_dso(cnf, name, value, flags);
216
217 if (!md)
218 {
219 if (!(flags & CONF_MFLAGS_SILENT))
220 {
221 CONFerr(CONF_F_MODULE_RUN, CONF_R_UNKNOWN_MODULE_NAME);
222 ERR_add_error_data(2, "module=", name);
223 }
224 return -1;
225 }
226
227 ret = module_init(md, name, value, cnf);
228
229 if (ret <= 0)
230 {
231 if (!(flags & CONF_MFLAGS_SILENT))
232 {
233 char rcode[10];
234 CONFerr(CONF_F_CONF_MODULES_LOAD, CONF_R_MODULE_INITIALIZATION_ERROR);
235 sprintf(rcode, "%-8d", ret);
236 ERR_add_error_data(6, "module=", name, ", value=", value, ", retcode=", rcode);
237 }
238 }
239
240 return ret;
241 }
242
243/* Load a module from a DSO */
244static CONF_MODULE *module_load_dso(const CONF *cnf, char *name, char *value,
245 unsigned long flags)
246 {
247 DSO *dso = NULL;
248 conf_init_func *ifunc;
249 conf_finish_func *ffunc;
250 char *path = NULL;
251 int errcode = 0;
252 CONF_MODULE *md;
253 /* Look for alternative path in module section */
254 path = NCONF_get_string(cnf, value, "path");
255 if (!path)
256 {
257 ERR_get_error();
258 path = name;
259 }
260 dso = DSO_load(NULL, path, NULL, 0);
261 if (!dso)
262 {
263 errcode = CONF_R_ERROR_LOADING_DSO;
264 goto err;
265 }
266 ifunc = (conf_init_func *)DSO_bind_func(dso, DSO_mod_init_name);
267 if (!ifunc)
268 {
269 errcode = CONF_R_MISSING_INIT_FUNCTION;
270 goto err;
271 }
272 ffunc = (conf_finish_func *)DSO_bind_func(dso, DSO_mod_finish_name);
273 /* All OK, add module */
274 md = module_add(dso, name, ifunc, ffunc);
275
276 if (!md)
277 goto err;
278
279 return md;
280
281 err:
282 if (dso)
283 DSO_free(dso);
284 CONFerr(CONF_F_MODULE_LOAD_DSO, errcode);
285 ERR_add_error_data(4, "module=", name, ", path=", path);
286 return NULL;
287 }
288
289/* add module to list */
290static CONF_MODULE *module_add(DSO *dso, const char *name,
291 conf_init_func *ifunc, conf_finish_func *ffunc)
292 {
293 CONF_MODULE *tmod = NULL;
294 if (supported_modules == NULL)
295 supported_modules = sk_CONF_MODULE_new_null();
296 if (supported_modules == NULL)
297 return NULL;
298 tmod = OPENSSL_malloc(sizeof(CONF_MODULE));
299 if (tmod == NULL)
300 return NULL;
301
302 tmod->dso = dso;
303 tmod->name = BUF_strdup(name);
304 tmod->init = ifunc;
305 tmod->finish = ffunc;
306 tmod->links = 0;
307
308 if (!sk_CONF_MODULE_push(supported_modules, tmod))
309 {
310 OPENSSL_free(tmod);
311 return NULL;
312 }
313
314 return tmod;
315 }
316
317/* Find a module from the list. We allow module names of the
318 * form modname.XXXX to just search for modname to allow the
319 * same module to be initialized more than once.
320 */
321
322static CONF_MODULE *module_find(char *name)
323 {
324 CONF_MODULE *tmod;
325 int i, nchar;
326 char *p;
327 p = strrchr(name, '.');
328
329 if (p)
330 nchar = p - name;
331 else
332 nchar = strlen(name);
333
334 for (i = 0; i < sk_CONF_MODULE_num(supported_modules); i++)
335 {
336 tmod = sk_CONF_MODULE_value(supported_modules, i);
337 if (!strncmp(tmod->name, name, nchar))
338 return tmod;
339 }
340
341 return NULL;
342
343 }
344
345/* initialize a module */
346static int module_init(CONF_MODULE *pmod, char *name, char *value,
347 const CONF *cnf)
348 {
349 int ret = 1;
350 int init_called = 0;
351 CONF_IMODULE *imod = NULL;
352
353 /* Otherwise add initialized module to list */
354 imod = OPENSSL_malloc(sizeof(CONF_IMODULE));
355 if (!imod)
356 goto err;
357
358 imod->pmod = pmod;
359 imod->name = BUF_strdup(name);
360 imod->value = BUF_strdup(value);
361 imod->usr_data = NULL;
362
363 if (!imod->name || !imod->value)
364 goto memerr;
365
366 /* Try to initialize module */
367 if(pmod->init)
368 {
369 ret = pmod->init(imod, cnf);
370 init_called = 1;
371 /* Error occurred, exit */
372 if (ret <= 0)
373 goto err;
374 }
375
376 if (initialized_modules == NULL)
377 {
378 initialized_modules = sk_CONF_IMODULE_new_null();
379 if (!initialized_modules)
380 {
381 CONFerr(CONF_F_MODULE_INIT, ERR_R_MALLOC_FAILURE);
382 goto err;
383 }
384 }
385
386 if (!sk_CONF_IMODULE_push(initialized_modules, imod))
387 {
388 CONFerr(CONF_F_MODULE_INIT, ERR_R_MALLOC_FAILURE);
389 goto err;
390 }
391
392 pmod->links++;
393
394 return ret;
395
396 err:
397
398 /* We've started the module so we'd better finish it */
399 if (pmod->finish && init_called)
400 pmod->finish(imod);
401
402 memerr:
403 if (imod)
404 {
405 if (imod->name)
406 OPENSSL_free(imod->name);
407 if (imod->value)
408 OPENSSL_free(imod->value);
409 OPENSSL_free(imod);
410 }
411
412 return -1;
413
414 }
415
416/* Unload any dynamic modules that have a link count of zero:
417 * i.e. have no active initialized modules. If 'all' is set
418 * then all modules are unloaded including static ones.
419 */
420
421void CONF_modules_unload(int all)
422 {
423 int i;
424 CONF_MODULE *md;
425 CONF_modules_finish();
426 /* unload modules in reverse order */
427 for (i = sk_CONF_MODULE_num(supported_modules) - 1; i >= 0; i--)
428 {
429 md = sk_CONF_MODULE_value(supported_modules, i);
430 /* If static or in use and 'all' not set ignore it */
431 if (((md->links > 0) || !md->dso) && !all)
432 continue;
433 /* Since we're working in reverse this is OK */
434 sk_CONF_MODULE_delete(supported_modules, i);
435 module_free(md);
436 }
437 if (sk_CONF_MODULE_num(supported_modules) == 0)
438 {
439 sk_CONF_MODULE_free(supported_modules);
440 supported_modules = NULL;
441 }
442 }
443
444/* unload a single module */
445static void module_free(CONF_MODULE *md)
446 {
447 if (md->dso)
448 DSO_free(md->dso);
449 OPENSSL_free(md->name);
450 OPENSSL_free(md);
451 }
452
453/* finish and free up all modules instances */
454
455void CONF_modules_finish(void)
456 {
457 CONF_IMODULE *imod;
458 while (sk_CONF_IMODULE_num(initialized_modules) > 0)
459 {
460 imod = sk_CONF_IMODULE_pop(initialized_modules);
461 module_finish(imod);
462 }
463 sk_CONF_IMODULE_free(initialized_modules);
464 initialized_modules = NULL;
465 }
466
467/* finish a module instance */
468
469static void module_finish(CONF_IMODULE *imod)
470 {
471 if (imod->pmod->finish)
472 imod->pmod->finish(imod);
473 imod->pmod->links--;
474 OPENSSL_free(imod->name);
475 OPENSSL_free(imod->value);
476 OPENSSL_free(imod);
477 }
478
479/* Add a static module to OpenSSL */
480
481int CONF_module_add(const char *name, conf_init_func *ifunc,
482 conf_finish_func *ffunc)
483 {
484 if (module_add(NULL, name, ifunc, ffunc))
485 return 1;
486 else
487 return 0;
488 }
489
490void CONF_modules_free(void)
491 {
492 CONF_modules_finish();
493 CONF_modules_unload(1);
494 }
495
496/* Utility functions */
497
498const char *CONF_imodule_get_name(const CONF_IMODULE *md)
499 {
500 return md->name;
501 }
502
503const char *CONF_imodule_get_value(const CONF_IMODULE *md)
504 {
505 return md->value;
506 }
507
508void *CONF_imodule_get_usr_data(const CONF_IMODULE *md)
509 {
510 return md->usr_data;
511 }
512
513void CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data)
514 {
515 md->usr_data = usr_data;
516 }
517
518CONF_MODULE *CONF_imodule_get_module(const CONF_IMODULE *md)
519 {
520 return md->pmod;
521 }
522
523unsigned long CONF_imodule_get_flags(const CONF_IMODULE *md)
524 {
525 return md->flags;
526 }
527
528void CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags)
529 {
530 md->flags = flags;
531 }
532
533void *CONF_module_get_usr_data(CONF_MODULE *pmod)
534 {
535 return pmod->usr_data;
536 }
537
538void CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data)
539 {
540 pmod->usr_data = usr_data;
541 }
542
543/* Return default config file name */
544
545char *CONF_get1_default_config_file(void)
546 {
547 char *file;
548 int len;
549
550 file = getenv("OPENSSL_CONF");
551 if (file)
552 return BUF_strdup(file);
553
554 len = strlen(X509_get_default_cert_area());
555#ifndef OPENSSL_SYS_VMS
556 len++;
557#endif
558 len += strlen(OPENSSL_CONF);
559
560 file = OPENSSL_malloc(len + 1);
561
562 if (!file)
563 return NULL;
564 strcpy(file,X509_get_default_cert_area());
565#ifndef OPENSSL_SYS_VMS
566 strcat(file,"/");
567#endif
568 strcat(file,OPENSSL_CONF);
569
570 return file;
571 }
572
573/* This function takes a list separated by 'sep' and calls the
574 * callback function giving the start and length of each member
575 * optionally stripping leading and trailing whitespace. This can
576 * be used to parse comma separated lists for example.
577 */
578
579int CONF_parse_list(const char *list, int sep, int nospc,
580 int (*list_cb)(const char *elem, int len, void *usr), void *arg)
581 {
582 int ret;
583 const char *lstart, *tmpend, *p;
584 lstart = list;
585
586 for(;;)
587 {
588 if (nospc)
589 {
590 while(*lstart && isspace((unsigned char)*lstart))
591 lstart++;
592 }
593 p = strchr(lstart, sep);
594 if (p == lstart || !*lstart)
595 ret = list_cb(NULL, 0, arg);
596 else
597 {
598 if (p)
599 tmpend = p - 1;
600 else
601 tmpend = lstart + strlen(lstart) - 1;
602 if (nospc)
603 {
604 while(isspace((unsigned char)*tmpend))
605 tmpend--;
606 }
607 ret = list_cb(lstart, tmpend - lstart + 1, arg);
608 }
609 if (ret <= 0)
610 return ret;
611 if (p == NULL)
612 return 1;
613 lstart = p + 1;
614 }
615 }
616
diff --git a/src/lib/libcrypto/conf/conf_sap.c b/src/lib/libcrypto/conf/conf_sap.c
new file mode 100644
index 0000000000..97fb174303
--- /dev/null
+++ b/src/lib/libcrypto/conf/conf_sap.c
@@ -0,0 +1,107 @@
1/* conf_sap.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 <stdio.h>
60#include <openssl/crypto.h>
61#include "cryptlib.h"
62#include <openssl/conf.h>
63#include <openssl/dso.h>
64#include <openssl/x509.h>
65#include <openssl/asn1.h>
66#include <openssl/engine.h>
67
68/* This is the automatic configuration loader: it is called automatically by
69 * OpenSSL when any of a number of standard initialisation functions are called,
70 * unless this is overridden by calling OPENSSL_no_config()
71 */
72
73static int openssl_configured = 0;
74
75void OPENSSL_config(const char *config_name)
76 {
77 if (openssl_configured)
78 return;
79
80 OPENSSL_load_builtin_modules();
81 /* Need to load ENGINEs */
82 ENGINE_load_builtin_engines();
83 /* Add others here? */
84
85
86 ERR_clear_error();
87 if (CONF_modules_load_file(NULL, NULL,
88 CONF_MFLAGS_IGNORE_MISSING_FILE) <= 0)
89 {
90 BIO *bio_err;
91 ERR_load_crypto_strings();
92 if ((bio_err=BIO_new_fp(stderr, BIO_NOCLOSE)) != NULL)
93 {
94 BIO_printf(bio_err,"Auto configuration failed\n");
95 ERR_print_errors(bio_err);
96 BIO_free(bio_err);
97 }
98 exit(1);
99 }
100
101 return;
102 }
103
104void OPENSSL_no_config()
105 {
106 openssl_configured = 1;
107 }
diff --git a/src/lib/libcrypto/conf/keysets.pl b/src/lib/libcrypto/conf/keysets.pl
index 56669e76ac..50ed67fa52 100644
--- a/src/lib/libcrypto/conf/keysets.pl
+++ b/src/lib/libcrypto/conf/keysets.pl
@@ -12,8 +12,9 @@ $DQUOTE=0x400;
12$COMMENT=0x80; 12$COMMENT=0x80;
13$FCOMMENT=0x800; 13$FCOMMENT=0x800;
14$EOF=0x08; 14$EOF=0x08;
15$HIGHBIT=0x1000;
15 16
16foreach (0 .. 127) 17foreach (0 .. 255)
17 { 18 {
18 $v=0; 19 $v=0;
19 $c=sprintf("%c",$_); 20 $c=sprintf("%c",$_);
@@ -27,11 +28,12 @@ foreach (0 .. 127)
27 $v|=$QUOTE if ($c =~ /['`"]/); # for emacs: "`'}/) 28 $v|=$QUOTE if ($c =~ /['`"]/); # for emacs: "`'}/)
28 $v|=$COMMENT if ($c =~ /\#/); 29 $v|=$COMMENT if ($c =~ /\#/);
29 $v|=$EOF if ($c =~ /\0/); 30 $v|=$EOF if ($c =~ /\0/);
31 $v|=$HIGHBIT if ($c =~/[\x80-\xff]/);
30 32
31 push(@V_def,$v); 33 push(@V_def,$v);
32 } 34 }
33 35
34foreach (0 .. 127) 36foreach (0 .. 255)
35 { 37 {
36 $v=0; 38 $v=0;
37 $c=sprintf("%c",$_); 39 $c=sprintf("%c",$_);
@@ -44,6 +46,7 @@ foreach (0 .. 127)
44 $v|=$DQUOTE if ($c =~ /["]/); # for emacs: "}/) 46 $v|=$DQUOTE if ($c =~ /["]/); # for emacs: "}/)
45 $v|=$FCOMMENT if ($c =~ /;/); 47 $v|=$FCOMMENT if ($c =~ /;/);
46 $v|=$EOF if ($c =~ /\0/); 48 $v|=$EOF if ($c =~ /\0/);
49 $v|=$HIGHBIT if ($c =~/[\x80-\xff]/);
47 50
48 push(@V_w32,$v); 51 push(@V_w32,$v);
49 } 52 }
@@ -122,6 +125,7 @@ print <<"EOF";
122#define CONF_COMMENT $COMMENT 125#define CONF_COMMENT $COMMENT
123#define CONF_FCOMMENT $FCOMMENT 126#define CONF_FCOMMENT $FCOMMENT
124#define CONF_EOF $EOF 127#define CONF_EOF $EOF
128#define CONF_HIGHBIT $HIGHBIT
125#define CONF_ALPHA (CONF_UPPER|CONF_LOWER) 129#define CONF_ALPHA (CONF_UPPER|CONF_LOWER)
126#define CONF_ALPHA_NUMERIC (CONF_ALPHA|CONF_NUMBER|CONF_UNDER) 130#define CONF_ALPHA_NUMERIC (CONF_ALPHA|CONF_NUMBER|CONF_UNDER)
127#define CONF_ALPHA_NUMERIC_PUNCT (CONF_ALPHA|CONF_NUMBER|CONF_UNDER| \\ 131#define CONF_ALPHA_NUMERIC_PUNCT (CONF_ALPHA|CONF_NUMBER|CONF_UNDER| \\
@@ -129,51 +133,53 @@ print <<"EOF";
129 133
130#define KEYTYPES(c) ((unsigned short *)((c)->meth_data)) 134#define KEYTYPES(c) ((unsigned short *)((c)->meth_data))
131#ifndef CHARSET_EBCDIC 135#ifndef CHARSET_EBCDIC
132#define IS_COMMENT(c,a) (KEYTYPES(c)[(a)&0x7f]&CONF_COMMENT) 136#define IS_COMMENT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_COMMENT)
133#define IS_FCOMMENT(c,a) (KEYTYPES(c)[(a)&0x7f]&CONF_FCOMMENT) 137#define IS_FCOMMENT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_FCOMMENT)
134#define IS_EOF(c,a) (KEYTYPES(c)[(a)&0x7f]&CONF_EOF) 138#define IS_EOF(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_EOF)
135#define IS_ESC(c,a) (KEYTYPES(c)[(a)&0x7f]&CONF_ESC) 139#define IS_ESC(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_ESC)
136#define IS_NUMBER(c,a) (KEYTYPES(c)[(a)&0x7f]&CONF_NUMBER) 140#define IS_NUMBER(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_NUMBER)
137#define IS_WS(c,a) (KEYTYPES(c)[(a)&0x7f]&CONF_WS) 141#define IS_WS(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_WS)
138#define IS_ALPHA_NUMERIC(c,a) (KEYTYPES(c)[(a)&0x7f]&CONF_ALPHA_NUMERIC) 142#define IS_ALPHA_NUMERIC(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_ALPHA_NUMERIC)
139#define IS_ALPHA_NUMERIC_PUNCT(c,a) \\ 143#define IS_ALPHA_NUMERIC_PUNCT(c,a) \\
140 (KEYTYPES(c)[(a)&0x7f]&CONF_ALPHA_NUMERIC_PUNCT) 144 (KEYTYPES(c)[(a)&0xff]&CONF_ALPHA_NUMERIC_PUNCT)
141#define IS_QUOTE(c,a) (KEYTYPES(c)[(a)&0x7f]&CONF_QUOTE) 145#define IS_QUOTE(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_QUOTE)
142#define IS_DQUOTE(c,a) (KEYTYPES(c)[(a)&0x7f]&CONF_DQUOTE) 146#define IS_DQUOTE(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_DQUOTE)
147#define IS_HIGHBIT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_HIGHBIT)
143 148
144#else /*CHARSET_EBCDIC*/ 149#else /*CHARSET_EBCDIC*/
145 150
146#define IS_COMMENT(c,a) (KEYTYPES(c)[os_toascii[a]&0x7f]&CONF_COMMENT) 151#define IS_COMMENT(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_COMMENT)
147#define IS_FCOMMENT(c,a) (KEYTYPES(c)[os_toascii[a]&0x7f]&CONF_FCOMMENT) 152#define IS_FCOMMENT(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_FCOMMENT)
148#define IS_EOF(c,a) (KEYTYPES(c)[os_toascii[a]&0x7f]&CONF_EOF) 153#define IS_EOF(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_EOF)
149#define IS_ESC(c,a) (KEYTYPES(c)[os_toascii[a]&0x7f]&CONF_ESC) 154#define IS_ESC(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_ESC)
150#define IS_NUMBER(c,a) (KEYTYPES(c)[os_toascii[a]&0x7f]&CONF_NUMBER) 155#define IS_NUMBER(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_NUMBER)
151#define IS_WS(c,a) (KEYTYPES(c)[os_toascii[a]&0x7f]&CONF_WS) 156#define IS_WS(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_WS)
152#define IS_ALPHA_NUMERIC(c,a) (KEYTYPES(c)[os_toascii[a]&0x7f]&CONF_ALPHA_NUMERIC) 157#define IS_ALPHA_NUMERIC(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_ALPHA_NUMERIC)
153#define IS_ALPHA_NUMERIC_PUNCT(c,a) \\ 158#define IS_ALPHA_NUMERIC_PUNCT(c,a) \\
154 (KEYTYPES(c)[os_toascii[a]&0x7f]&CONF_ALPHA_NUMERIC_PUNCT) 159 (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_ALPHA_NUMERIC_PUNCT)
155#define IS_QUOTE(c,a) (KEYTYPES(c)[os_toascii[a]&0x7f]&CONF_QUOTE) 160#define IS_QUOTE(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_QUOTE)
156#define IS_DQUOTE(c,a) (KEYTYPES(c)[os_toascii[a]&0x7f]&CONF_DQUOTE) 161#define IS_DQUOTE(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_DQUOTE)
162#define IS_HIGHBIT(c,a) (KEYTYPES(c)[os_toascii[a]&0xff]&CONF_HIGHBIT)
157#endif /*CHARSET_EBCDIC*/ 163#endif /*CHARSET_EBCDIC*/
158 164
159EOF 165EOF
160 166
161print "static unsigned short CONF_type_default[128]={"; 167print "static unsigned short CONF_type_default[256]={";
162 168
163for ($i=0; $i<128; $i++) 169for ($i=0; $i<256; $i++)
164 { 170 {
165 print "\n\t" if ($i % 8) == 0; 171 print "\n\t" if ($i % 8) == 0;
166 printf "0x%03X,",$V_def[$i]; 172 printf "0x%04X,",$V_def[$i];
167 } 173 }
168 174
169print "\n\t};\n\n"; 175print "\n\t};\n\n";
170 176
171print "static unsigned short CONF_type_win32[128]={"; 177print "static unsigned short CONF_type_win32[256]={";
172 178
173for ($i=0; $i<128; $i++) 179for ($i=0; $i<256; $i++)
174 { 180 {
175 print "\n\t" if ($i % 8) == 0; 181 print "\n\t" if ($i % 8) == 0;
176 printf "0x%03X,",$V_w32[$i]; 182 printf "0x%04X,",$V_w32[$i];
177 } 183 }
178 184
179print "\n\t};\n\n"; 185print "\n\t};\n\n";
diff --git a/src/lib/libcrypto/cpt_err.c b/src/lib/libcrypto/cpt_err.c
index 7018b74ca0..1b4a1cb4d4 100644
--- a/src/lib/libcrypto/cpt_err.c
+++ b/src/lib/libcrypto/cpt_err.c
@@ -63,13 +63,18 @@
63#include <openssl/crypto.h> 63#include <openssl/crypto.h>
64 64
65/* BEGIN ERROR CODES */ 65/* BEGIN ERROR CODES */
66#ifndef NO_ERR 66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA CRYPTO_str_functs[]= 67static ERR_STRING_DATA CRYPTO_str_functs[]=
68 { 68 {
69{ERR_PACK(0,CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX,0), "CRYPTO_get_ex_new_index"}, 69{ERR_PACK(0,CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX,0), "CRYPTO_get_ex_new_index"},
70{ERR_PACK(0,CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID,0), "CRYPTO_get_new_dynlockid"}, 70{ERR_PACK(0,CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID,0), "CRYPTO_get_new_dynlockid"},
71{ERR_PACK(0,CRYPTO_F_CRYPTO_GET_NEW_LOCKID,0), "CRYPTO_get_new_lockid"}, 71{ERR_PACK(0,CRYPTO_F_CRYPTO_GET_NEW_LOCKID,0), "CRYPTO_get_new_lockid"},
72{ERR_PACK(0,CRYPTO_F_CRYPTO_SET_EX_DATA,0), "CRYPTO_set_ex_data"}, 72{ERR_PACK(0,CRYPTO_F_CRYPTO_SET_EX_DATA,0), "CRYPTO_set_ex_data"},
73{ERR_PACK(0,CRYPTO_F_DEF_ADD_INDEX,0), "DEF_ADD_INDEX"},
74{ERR_PACK(0,CRYPTO_F_DEF_GET_CLASS,0), "DEF_GET_CLASS"},
75{ERR_PACK(0,CRYPTO_F_INT_DUP_EX_DATA,0), "INT_DUP_EX_DATA"},
76{ERR_PACK(0,CRYPTO_F_INT_FREE_EX_DATA,0), "INT_FREE_EX_DATA"},
77{ERR_PACK(0,CRYPTO_F_INT_NEW_EX_DATA,0), "INT_NEW_EX_DATA"},
73{0,NULL} 78{0,NULL}
74 }; 79 };
75 80
@@ -88,7 +93,7 @@ void ERR_load_CRYPTO_strings(void)
88 if (init) 93 if (init)
89 { 94 {
90 init=0; 95 init=0;
91#ifndef NO_ERR 96#ifndef OPENSSL_NO_ERR
92 ERR_load_strings(ERR_LIB_CRYPTO,CRYPTO_str_functs); 97 ERR_load_strings(ERR_LIB_CRYPTO,CRYPTO_str_functs);
93 ERR_load_strings(ERR_LIB_CRYPTO,CRYPTO_str_reasons); 98 ERR_load_strings(ERR_LIB_CRYPTO,CRYPTO_str_reasons);
94#endif 99#endif
diff --git a/src/lib/libcrypto/cryptlib.c b/src/lib/libcrypto/cryptlib.c
index a7a9262133..612b3b93b4 100644
--- a/src/lib/libcrypto/cryptlib.c
+++ b/src/lib/libcrypto/cryptlib.c
@@ -62,7 +62,7 @@
62#include <openssl/crypto.h> 62#include <openssl/crypto.h>
63#include <openssl/safestack.h> 63#include <openssl/safestack.h>
64 64
65#if defined(WIN32) || defined(WIN16) 65#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN16)
66static double SSLeay_MSVC5_hack=0.0; /* and for VC1.5 */ 66static double SSLeay_MSVC5_hack=0.0; /* and for VC1.5 */
67#endif 67#endif
68 68
@@ -74,7 +74,7 @@ static const char* lock_names[CRYPTO_NUM_LOCKS] =
74 { 74 {
75 "<<ERROR>>", 75 "<<ERROR>>",
76 "err", 76 "err",
77 "err_hash", 77 "ex_data",
78 "x509", 78 "x509",
79 "x509_info", 79 "x509_info",
80 "x509_pkey", 80 "x509_pkey",
@@ -90,6 +90,7 @@ static const char* lock_names[CRYPTO_NUM_LOCKS] =
90 "ssl_sess_cert", 90 "ssl_sess_cert",
91 "ssl", 91 "ssl",
92 "rand", 92 "rand",
93 "rand2",
93 "debug_malloc", 94 "debug_malloc",
94 "BIO", 95 "BIO",
95 "gethostbyname", 96 "gethostbyname",
@@ -101,7 +102,8 @@ static const char* lock_names[CRYPTO_NUM_LOCKS] =
101 "dso", 102 "dso",
102 "dynlock", 103 "dynlock",
103 "engine", 104 "engine",
104#if CRYPTO_NUM_LOCKS != 29 105 "ui",
106#if CRYPTO_NUM_LOCKS != 31
105# error "Inconsistency between crypto.h and cryptlib.c" 107# error "Inconsistency between crypto.h and cryptlib.c"
106#endif 108#endif
107 }; 109 };
@@ -133,11 +135,11 @@ int CRYPTO_get_new_lockid(char *name)
133 char *str; 135 char *str;
134 int i; 136 int i;
135 137
138#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN16)
136 /* A hack to make Visual C++ 5.0 work correctly when linking as 139 /* A hack to make Visual C++ 5.0 work correctly when linking as
137 * a DLL using /MT. Without this, the application cannot use 140 * a DLL using /MT. Without this, the application cannot use
138 * and floating point printf's. 141 * and floating point printf's.
139 * It also seems to be needed for Visual C 1.5 (win16) */ 142 * It also seems to be needed for Visual C 1.5 (win16) */
140#if defined(WIN32) || defined(WIN16)
141 SSLeay_MSVC5_hack=(double)name[0]*(double)name[1]; 143 SSLeay_MSVC5_hack=(double)name[0]*(double)name[1];
142#endif 144#endif
143 145
@@ -228,7 +230,10 @@ void CRYPTO_destroy_dynlockid(int i)
228 CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK); 230 CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK);
229 231
230 if (dyn_locks == NULL || i >= sk_CRYPTO_dynlock_num(dyn_locks)) 232 if (dyn_locks == NULL || i >= sk_CRYPTO_dynlock_num(dyn_locks))
233 {
234 CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
231 return; 235 return;
236 }
232 pointer = sk_CRYPTO_dynlock_value(dyn_locks, i); 237 pointer = sk_CRYPTO_dynlock_value(dyn_locks, i);
233 if (pointer != NULL) 238 if (pointer != NULL)
234 { 239 {
@@ -354,9 +359,9 @@ unsigned long CRYPTO_thread_id(void)
354 359
355 if (id_callback == NULL) 360 if (id_callback == NULL)
356 { 361 {
357#ifdef WIN16 362#ifdef OPENSSL_SYS_WIN16
358 ret=(unsigned long)GetCurrentTask(); 363 ret=(unsigned long)GetCurrentTask();
359#elif defined(WIN32) 364#elif defined(OPENSSL_SYS_WIN32)
360 ret=(unsigned long)GetCurrentThreadId(); 365 ret=(unsigned long)GetCurrentThreadId();
361#elif defined(GETPID_IS_MEANINGLESS) 366#elif defined(GETPID_IS_MEANINGLESS)
362 ret=1L; 367 ret=1L;
@@ -462,7 +467,7 @@ const char *CRYPTO_get_lock_name(int type)
462 } 467 }
463 468
464#ifdef _DLL 469#ifdef _DLL
465#ifdef WIN32 470#ifdef OPENSSL_SYS_WIN32
466 471
467/* All we really need to do is remove the 'error' state when a thread 472/* All we really need to do is remove the 'error' state when a thread
468 * detaches */ 473 * detaches */
diff --git a/src/lib/libcrypto/cryptlib.h b/src/lib/libcrypto/cryptlib.h
index 5eff5d3141..a0489e57fc 100644
--- a/src/lib/libcrypto/cryptlib.h
+++ b/src/lib/libcrypto/cryptlib.h
@@ -62,7 +62,7 @@
62#include <stdlib.h> 62#include <stdlib.h>
63#include <string.h> 63#include <string.h>
64 64
65#include "openssl/e_os.h" 65#include "e_os.h"
66 66
67#include <openssl/crypto.h> 67#include <openssl/crypto.h>
68#include <openssl/buffer.h> 68#include <openssl/buffer.h>
@@ -74,7 +74,7 @@
74extern "C" { 74extern "C" {
75#endif 75#endif
76 76
77#ifndef VMS 77#ifndef OPENSSL_SYS_VMS
78#define X509_CERT_AREA OPENSSLDIR 78#define X509_CERT_AREA OPENSSLDIR
79#define X509_CERT_DIR OPENSSLDIR "/certs" 79#define X509_CERT_DIR OPENSSLDIR "/certs"
80#define X509_CERT_FILE OPENSSLDIR "/cert.pem" 80#define X509_CERT_FILE OPENSSLDIR "/cert.pem"
diff --git a/src/lib/libcrypto/crypto-lib.com b/src/lib/libcrypto/crypto-lib.com
index 482a136177..ca0247be00 100644
--- a/src/lib/libcrypto/crypto-lib.com
+++ b/src/lib/libcrypto/crypto-lib.com
@@ -88,10 +88,10 @@ $! Define The Different Encryption Types.
88$! 88$!
89$ ENCRYPT_TYPES = "Basic,MD2,MD4,MD5,SHA,MDC2,HMAC,RIPEMD,"+ - 89$ ENCRYPT_TYPES = "Basic,MD2,MD4,MD5,SHA,MDC2,HMAC,RIPEMD,"+ -
90 "DES,RC2,RC4,RC5,IDEA,BF,CAST,"+ - 90 "DES,RC2,RC4,RC5,IDEA,BF,CAST,"+ -
91 "BN,RSA,DSA,DH,DSO,ENGINE,"+ - 91 "BN,EC,RSA,DSA,DH,DSO,ENGINE,AES,"+ -
92 "BUFFER,BIO,STACK,LHASH,RAND,ERR,OBJECTS,"+ - 92 "BUFFER,BIO,STACK,LHASH,RAND,ERR,OBJECTS,"+ -
93 "EVP,EVP_2,ASN1,ASN1_2,PEM,X509,X509V3,"+ - 93 "EVP,EVP_2,ASN1,ASN1_2,PEM,X509,X509V3,"+ -
94 "CONF,TXT_DB,PKCS7,PKCS12,COMP" 94 "CONF,TXT_DB,PKCS7,PKCS12,COMP,OCSP,UI,KRB5"
95$ ENCRYPT_PROGRAMS = "DES,PKCS7" 95$ ENCRYPT_PROGRAMS = "DES,PKCS7"
96$! 96$!
97$! Check To Make Sure We Have Valid Command Line Parameters. 97$! Check To Make Sure We Have Valid Command Line Parameters.
@@ -174,7 +174,7 @@ $!
174$ APPS_DES = "DES/DES,CBC3_ENC" 174$ APPS_DES = "DES/DES,CBC3_ENC"
175$ APPS_PKCS7 = "ENC/ENC;DEC/DEC;SIGN/SIGN;VERIFY/VERIFY,EXAMPLE" 175$ APPS_PKCS7 = "ENC/ENC;DEC/DEC;SIGN/SIGN;VERIFY/VERIFY,EXAMPLE"
176$ 176$
177$ LIB_ = "cryptlib,mem,mem_dbg,cversion,ex_data,tmdiff,cpt_err,ebcdic,uid" 177$ LIB_ = "cryptlib,mem,mem_dbg,cversion,ex_data,tmdiff,cpt_err,ebcdic,uid,o_time"
178$ LIB_MD2 = "md2_dgst,md2_one" 178$ LIB_MD2 = "md2_dgst,md2_one"
179$ LIB_MD4 = "md4_dgst,md4_one" 179$ LIB_MD4 = "md4_dgst,md4_one"
180$ LIB_MD5 = "md5_dgst,md5_one" 180$ LIB_MD5 = "md5_dgst,md5_one"
@@ -186,8 +186,9 @@ $ LIB_DES = "set_key,ecb_enc,cbc_enc,"+ -
186 "ecb3_enc,cfb64enc,cfb64ede,cfb_enc,ofb64ede,"+ - 186 "ecb3_enc,cfb64enc,cfb64ede,cfb_enc,ofb64ede,"+ -
187 "enc_read,enc_writ,ofb64enc,"+ - 187 "enc_read,enc_writ,ofb64enc,"+ -
188 "ofb_enc,str2key,pcbc_enc,qud_cksm,rand_key,"+ - 188 "ofb_enc,str2key,pcbc_enc,qud_cksm,rand_key,"+ -
189 "des_enc,fcrypt_b,read2pwd,"+ - 189 "des_enc,fcrypt_b,"+ -
190 "fcrypt,xcbc_enc,read_pwd,rpc_enc,cbc_cksm,ede_cbcm_enc" 190 "fcrypt,xcbc_enc,rpc_enc,cbc_cksm,"+ -
191 "ede_cbcm_enc,des_old,des_old2,read2pwd"
191$ LIB_RC2 = "rc2_ecb,rc2_skey,rc2_cbc,rc2cfb64,rc2ofb64" 192$ LIB_RC2 = "rc2_ecb,rc2_skey,rc2_cbc,rc2cfb64,rc2ofb64"
192$ LIB_RC4 = "rc4_skey,rc4_enc" 193$ LIB_RC4 = "rc4_skey,rc4_enc"
193$ LIB_RC5 = "rc5_skey,rc5_ecb,rc5_enc,rc5cfb64,rc5ofb64" 194$ LIB_RC5 = "rc5_skey,rc5_ecb,rc5_enc,rc5cfb64,rc5ofb64"
@@ -196,18 +197,26 @@ $ LIB_BF = "bf_skey,bf_ecb,bf_enc,bf_cfb64,bf_ofb64"
196$ LIB_CAST = "c_skey,c_ecb,c_enc,c_cfb64,c_ofb64" 197$ LIB_CAST = "c_skey,c_ecb,c_enc,c_cfb64,c_ofb64"
197$ LIB_BN_ASM = "[.asm]vms.mar,vms-helper" 198$ LIB_BN_ASM = "[.asm]vms.mar,vms-helper"
198$ IF F$TRNLNM("OPENSSL_NO_ASM").OR.ARCH.EQS."AXP" THEN LIB_BN_ASM = "bn_asm" 199$ IF F$TRNLNM("OPENSSL_NO_ASM").OR.ARCH.EQS."AXP" THEN LIB_BN_ASM = "bn_asm"
199$ LIB_BN = "bn_add,bn_div,bn_exp,bn_lib,bn_ctx,bn_mul,"+ - 200$ LIB_BN = "bn_add,bn_div,bn_exp,bn_lib,bn_ctx,bn_mul,bn_mod,"+ -
200 "bn_print,bn_rand,bn_shift,bn_word,bn_blind,"+ - 201 "bn_print,bn_rand,bn_shift,bn_word,bn_blind,"+ -
201 "bn_gcd,bn_prime,bn_err,bn_sqr,"+LIB_BN_ASM+",bn_recp,bn_mont,"+ - 202 "bn_kron,bn_sqrt,bn_gcd,bn_prime,bn_err,bn_sqr,"+LIB_BN_ASM+","+ -
202 "bn_mpi,bn_exp2" 203 "bn_recp,bn_mont,bn_mpi,bn_exp2"
203$ LIB_RSA = "rsa_eay,rsa_gen,rsa_lib,rsa_sign,rsa_saos,rsa_err,"+ - 204$ LIB_RSA = "rsa_eay,rsa_gen,rsa_lib,rsa_sign,rsa_saos,rsa_err,"+ -
204 "rsa_pk1,rsa_ssl,rsa_none,rsa_oaep,rsa_chk,rsa_null" 205 "rsa_pk1,rsa_ssl,rsa_none,rsa_oaep,rsa_chk,rsa_null,"+ -
206 "rsa_asn1"
207$ LIB_EC = "ec_lib,ecp_smpl,ecp_mont,ecp_recp,ecp_nist,ec_cvt,ec_mult,"+ -
208 "ec_err"
205$ LIB_DSA = "dsa_gen,dsa_key,dsa_lib,dsa_asn1,dsa_vrf,dsa_sign,dsa_err,dsa_ossl" 209$ LIB_DSA = "dsa_gen,dsa_key,dsa_lib,dsa_asn1,dsa_vrf,dsa_sign,dsa_err,dsa_ossl"
206$ LIB_DH = "dh_gen,dh_key,dh_lib,dh_check,dh_err" 210$ LIB_DH = "dh_asn1,dh_gen,dh_key,dh_lib,dh_check,dh_err"
207$ LIB_DSO = "dso_dl,dso_dlfcn,dso_err,dso_lib,dso_null,"+ - 211$ LIB_DSO = "dso_dl,dso_dlfcn,dso_err,dso_lib,dso_null,"+ -
208 "dso_openssl,dso_win32,dso_vms" 212 "dso_openssl,dso_win32,dso_vms"
209$ LIB_ENGINE = "engine_err,engine_lib,engine_list,engine_openssl,"+ - 213$ LIB_ENGINE = "eng_err,eng_lib,eng_list,eng_init,eng_ctrl,"+ -
210 "hw_atalla,hw_cswift,hw_ncipher" 214 "eng_table,eng_pkey,eng_fat,eng_all,"+ -
215 "tb_rsa,tb_dsa,tb_dh,tb_rand,tb_cipher,tb_digest,"+ -
216 "eng_openssl,eng_dyn,eng_cnf,"+ -
217 "hw_atalla,hw_cswift,hw_ncipher,hw_nuron,hw_ubsec,"+ -
218 "hw_openbsd_dev_crypto,hw_aep,hw_sureware,hw_4758_cca"
219$ LIB_AES = "aes_core,aes_misc,aes_ecb,aes_cbc,aes_cfb,aes_ofb,aes_ctr"
211$ LIB_BUFFER = "buffer,buf_err" 220$ LIB_BUFFER = "buffer,buf_err"
212$ LIB_BIO = "bio_lib,bio_cb,bio_err,"+ - 221$ LIB_BIO = "bio_lib,bio_cb,bio_err,"+ -
213 "bss_mem,bss_null,bss_fd,"+ - 222 "bss_mem,bss_null,bss_fd,"+ -
@@ -217,12 +226,13 @@ $ LIB_BIO = "bio_lib,bio_cb,bio_err,"+ -
217 "bf_lbuf" 226 "bf_lbuf"
218$ LIB_STACK = "stack" 227$ LIB_STACK = "stack"
219$ LIB_LHASH = "lhash,lh_stats" 228$ LIB_LHASH = "lhash,lh_stats"
220$ LIB_RAND = "md_rand,randfile,rand_lib,rand_err,rand_egd,rand_win" 229$ LIB_RAND = "md_rand,randfile,rand_lib,rand_err,rand_egd,"+ -
230 "rand_vms"
221$ LIB_ERR = "err,err_all,err_prn" 231$ LIB_ERR = "err,err_all,err_prn"
222$ LIB_OBJECTS = "o_names,obj_dat,obj_lib,obj_err" 232$ LIB_OBJECTS = "o_names,obj_dat,obj_lib,obj_err"
223$ LIB_EVP = "encode,digest,evp_enc,evp_key,"+ - 233$ LIB_EVP = "encode,digest,evp_enc,evp_key,"+ -
224 "e_des,e_bf,e_idea,e_des3,"+ - 234 "e_des,e_bf,e_idea,e_des3,"+ -
225 "e_rc4,names,"+ - 235 "e_rc4,e_aes,names,"+ -
226 "e_xcbc_d,e_rc2,e_cast,e_rc5" 236 "e_xcbc_d,e_rc2,e_cast,e_rc5"
227$ LIB_EVP_2 = "m_null,m_md2,m_md4,m_md5,m_sha,m_sha1," + - 237$ LIB_EVP_2 = "m_null,m_md2,m_md4,m_md5,m_sha,m_sha1," + -
228 "m_dss,m_dss1,m_mdc2,m_ripemd,"+ - 238 "m_dss,m_dss1,m_mdc2,m_ripemd,"+ -
@@ -231,43 +241,48 @@ $ LIB_EVP_2 = "m_null,m_md2,m_md4,m_md5,m_sha,m_sha1," + -
231 "c_all,c_allc,c_alld,evp_lib,bio_ok,"+- 241 "c_all,c_allc,c_alld,evp_lib,bio_ok,"+-
232 "evp_pkey,evp_pbe,p5_crpt,p5_crpt2" 242 "evp_pkey,evp_pbe,p5_crpt,p5_crpt2"
233$ LIB_ASN1 = "a_object,a_bitstr,a_utctm,a_gentm,a_time,a_int,a_octet,"+ - 243$ LIB_ASN1 = "a_object,a_bitstr,a_utctm,a_gentm,a_time,a_int,a_octet,"+ -
234 "a_null,a_print,a_type,a_set,a_dup,a_d2i_fp,a_i2d_fp,a_bmp,"+ - 244 "a_print,a_type,a_set,a_dup,a_d2i_fp,a_i2d_fp,"+ -
235 "a_enum,a_vis,a_utf8,a_sign,a_digest,a_verify,a_mbstr,a_strex,"+ - 245 "a_enum,a_utf8,a_sign,a_digest,a_verify,a_mbstr,a_strex,"+ -
236 "x_algor,x_val,x_pubkey,x_sig,x_req,x_attrib,"+ - 246 "x_algor,x_val,x_pubkey,x_sig,x_req,x_attrib,x_bignum,"+ -
237 "x_name,x_cinf,x_x509,x_x509a,x_crl,x_info,x_spki,nsseq,"+ - 247 "x_long,x_name,x_x509,x_x509a,x_crl,x_info,x_spki,nsseq,"+ -
238 "d2i_r_pr,i2d_r_pr,d2i_r_pu,i2d_r_pu,"+ -
239 "d2i_s_pr,i2d_s_pr,d2i_s_pu,i2d_s_pu,"+ -
240 "d2i_pu,d2i_pr,i2d_pu,i2d_pr" 248 "d2i_pu,d2i_pr,i2d_pu,i2d_pr"
241$ LIB_ASN1_2 = "t_req,t_x509,t_x509a,t_crl,t_pkey,t_spki,t_bitst,"+ - 249$ LIB_ASN1_2 = "t_req,t_x509,t_x509a,t_crl,t_pkey,t_spki,t_bitst,"+ -
242 "p7_i_s,p7_signi,p7_signd,p7_recip,p7_enc_c,p7_evp,"+ - 250 "tasn_new,tasn_fre,tasn_enc,tasn_dec,tasn_utl,tasn_typ,"+ -
243 "p7_dgst,p7_s_e,p7_enc,p7_lib,"+ - 251 "f_int,f_string,n_pkey,"+ -
244 "f_int,f_string,i2d_dhp,i2d_dsap,d2i_dhp,d2i_dsap,n_pkey,"+ -
245 "f_enum,a_hdr,x_pkey,a_bool,x_exten,"+ - 252 "f_enum,a_hdr,x_pkey,a_bool,x_exten,"+ -
246 "asn1_par,asn1_lib,asn1_err,a_meth,a_bytes,a_strnid,"+ - 253 "asn1_par,asn1_lib,asn1_err,a_meth,a_bytes,a_strnid,"+ -
247 "evp_asn1,asn_pack,p5_pbe,p5_pbev2,p8_pkey" 254 "evp_asn1,asn_pack,p5_pbe,p5_pbev2,p8_pkey,asn_moid"
248$ LIB_PEM = "pem_sign,pem_seal,pem_info,pem_lib,pem_all,pem_err" 255$ LIB_PEM = "pem_sign,pem_seal,pem_info,pem_lib,pem_all,pem_err,"+ -
256 "pem_x509,pem_xaux,pem_oth,pem_pk8,pem_pkey"
249$ LIB_X509 = "x509_def,x509_d2,x509_r2x,x509_cmp,"+ - 257$ LIB_X509 = "x509_def,x509_d2,x509_r2x,x509_cmp,"+ -
250 "x509_obj,x509_req,x509spki,x509_vfy,"+ - 258 "x509_obj,x509_req,x509spki,x509_vfy,"+ -
251 "x509_set,x509rset,x509_err,"+ - 259 "x509_set,x509cset,x509rset,x509_err,"+ -
252 "x509name,x509_v3,x509_ext,x509_att,"+ - 260 "x509name,x509_v3,x509_ext,x509_att,"+ -
253 "x509type,x509_lu,x_all,x509_txt,"+ - 261 "x509type,x509_lu,x_all,x509_txt,"+ -
254 "x509_trs,by_file,by_dir" 262 "x509_trs,by_file,by_dir"
255$ LIB_X509V3 = "v3_bcons,v3_bitst,v3_conf,v3_extku,v3_ia5,v3_lib,"+ - 263$ LIB_X509V3 = "v3_bcons,v3_bitst,v3_conf,v3_extku,v3_ia5,v3_lib,"+ -
256 "v3_prn,v3_utl,v3err,v3_genn,v3_alt,v3_skey,v3_akey,v3_pku,"+ - 264 "v3_prn,v3_utl,v3err,v3_genn,v3_alt,v3_skey,v3_akey,v3_pku,"+ -
257 "v3_int,v3_enum,v3_sxnet,v3_cpols,v3_crld,v3_purp,v3_info" 265 "v3_int,v3_enum,v3_sxnet,v3_cpols,v3_crld,v3_purp,v3_info,"+ -
258$ LIB_CONF = "conf_err,conf_lib,conf_api,conf_def" 266 "v3_ocsp,v3_akeya"
267$ LIB_CONF = "conf_err,conf_lib,conf_api,conf_def,conf_mod,conf_mall"
259$ LIB_TXT_DB = "txt_db" 268$ LIB_TXT_DB = "txt_db"
260$ LIB_PKCS7 = "pk7_lib,pkcs7err,pk7_doit,pk7_smime,pk7_attr,pk7_mime" 269$ LIB_PKCS7 = "pk7_asn1,pk7_lib,pkcs7err,pk7_doit,pk7_smime,pk7_attr,"+ -
261$ LIB_PKCS12 = "p12_add,p12_attr,p12_bags,p12_crpt,p12_crt,p12_decr,"+ - 270 "pk7_mime"
262 "p12_init,p12_key,p12_kiss,p12_lib,p12_mac,p12_mutl,"+ - 271$ LIB_PKCS12 = "p12_add,p12_asn,p12_attr,p12_crpt,p12_crt,p12_decr,"+ -
263 "p12_sbag,p12_utl,p12_npas,pk12err" 272 "p12_init,p12_key,p12_kiss,p12_mutl,"+ -
273 "p12_utl,p12_npas,pk12err,p12_p8d,p12_p8e"
264$ LIB_COMP = "comp_lib,"+ - 274$ LIB_COMP = "comp_lib,"+ -
265 "c_rle,c_zlib" 275 "c_rle,c_zlib"
276$ LIB_OCSP = "ocsp_asn,ocsp_ext,ocsp_ht,ocsp_lib,ocsp_cl,"+ -
277 "ocsp_srv,ocsp_prn,ocsp_vfy,ocsp_err"
278$ LIB_UI_COMPAT = ",ui_compat"
279$ LIB_UI = "ui_err,ui_lib,ui_openssl,ui_util"+LIB_UI_COMPAT
280$ LIB_KRB5 = "krb5_asn"
266$! 281$!
267$! Setup exceptional compilations 282$! Setup exceptional compilations
268$! 283$!
269$ COMPILEWITH_CC3 = ",bss_rtcp," 284$ COMPILEWITH_CC3 = ",bss_rtcp,"
270$ COMPILEWITH_CC4 = ",a_utctm,bss_log," 285$ COMPILEWITH_CC4 = ",a_utctm,bss_log,o_time,"
271$ COMPILEWITH_CC5 = ",md2_dgst,md4_dgst,md5_dgst,mdc2dgst," + - 286$ COMPILEWITH_CC5 = ",md2_dgst,md4_dgst,md5_dgst,mdc2dgst," + -
272 "sha_dgst,sha1dgst,rmd_dgst,bf_enc," 287 "sha_dgst,sha1dgst,rmd_dgst,bf_enc,"
273$! 288$!
@@ -895,6 +910,7 @@ $ ENDIF
895$! 910$!
896$! Check To See If P2 Is Blank. 911$! Check To See If P2 Is Blank.
897$! 912$!
913$ P2 = "NORSAREF"
898$ IF (P2.EQS."NORSAREF") 914$ IF (P2.EQS."NORSAREF")
899$ THEN 915$ THEN
900$! 916$!
@@ -1140,31 +1156,7 @@ $ ENDIF
1140$! 1156$!
1141$! Set Up Initial CC Definitions, Possibly With User Ones 1157$! Set Up Initial CC Definitions, Possibly With User Ones
1142$! 1158$!
1143$ CCDEFS = "VMS=1,TCPIP_TYPE_''P5',DSO_VMS" 1159$ CCDEFS = "TCPIP_TYPE_''P5',DSO_VMS"
1144$ IF F$TRNLNM("OPENSSL_NO_ASM") THEN CCDEFS = CCDEFS + ",NO_ASM"
1145$ IF F$TRNLNM("OPENSSL_NO_RSA") THEN CCDEFS = CCDEFS + ",NO_RSA"
1146$ IF F$TRNLNM("OPENSSL_NO_DSA") THEN CCDEFS = CCDEFS + ",NO_DSA"
1147$ IF F$TRNLNM("OPENSSL_NO_DH") THEN CCDEFS = CCDEFS + ",NO_DH"
1148$ IF F$TRNLNM("OPENSSL_NO_MD2") THEN CCDEFS = CCDEFS + ",NO_MD2"
1149$ IF F$TRNLNM("OPENSSL_NO_MD5") THEN CCDEFS = CCDEFS + ",NO_MD5"
1150$ IF F$TRNLNM("OPENSSL_NO_RIPEMD") THEN CCDEFS = CCDEFS + ",NO_RIPEMD"
1151$ IF F$TRNLNM("OPENSSL_NO_SHA") THEN CCDEFS = CCDEFS + ",NO_SHA"
1152$ IF F$TRNLNM("OPENSSL_NO_SHA0") THEN CCDEFS = CCDEFS + ",NO_SHA0"
1153$ IF F$TRNLNM("OPENSSL_NO_SHA1") THEN CCDEFS = CCDEFS + ",NO_SHA1"
1154$ IF F$TRNLNM("OPENSSL_NO_DES")
1155$ THEN
1156$ CCDEFS = CCDEFS + ",NO_DES,NO_MDC2"
1157$ ELSE
1158$ IF F$TRNLNM("OPENSSL_NO_MDC2") THEN CCDEFS = CCDEFS + ",NO_MDC2"
1159$ ENDIF
1160$ IF F$TRNLNM("OPENSSL_NO_RC2") THEN CCDEFS = CCDEFS + ",NO_RC2"
1161$ IF F$TRNLNM("OPENSSL_NO_RC4") THEN CCDEFS = CCDEFS + ",NO_RC4"
1162$ IF F$TRNLNM("OPENSSL_NO_RC5") THEN CCDEFS = CCDEFS + ",NO_RC5"
1163$ IF F$TRNLNM("OPENSSL_NO_IDEA") THEN CCDEFS = CCDEFS + ",NO_IDEA"
1164$ IF F$TRNLNM("OPENSSL_NO_BF") THEN CCDEFS = CCDEFS + ",NO_BF"
1165$ IF F$TRNLNM("OPENSSL_NO_CAST") THEN CCDEFS = CCDEFS + ",NO_CAST"
1166$ IF F$TRNLNM("OPENSSL_NO_HMAC") THEN CCDEFS = CCDEFS + ",NO_HMAC"
1167$ IF F$TRNLNM("OPENSSL_NO_SSL2") THEN CCDEFS = CCDEFS + ",NO_SSL2"
1168$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS 1160$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS
1169$ CCEXTRAFLAGS = "" 1161$ CCEXTRAFLAGS = ""
1170$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS 1162$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS
@@ -1197,7 +1189,7 @@ $ IF ARCH.EQS."VAX" .AND. F$TRNLNM("DECC$CC_DEFAULT").NES."/DECC" -
1197 THEN CC = "CC/DECC" 1189 THEN CC = "CC/DECC"
1198$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/STANDARD=ANSI89" + - 1190$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/STANDARD=ANSI89" + -
1199 "/NOLIST/PREFIX=ALL" + - 1191 "/NOLIST/PREFIX=ALL" + -
1200 "/INCLUDE=(SYS$DISK:[],SYS$DISK:[.ENGINE.VENDOR_DEFNS])" + - 1192 "/INCLUDE=(SYS$DISK:[],SYS$DISK:[-],SYS$DISK:[.ENGINE.VENDOR_DEFNS],SYS$DISK:[.EVP])" + -
1201 CCEXTRAFLAGS 1193 CCEXTRAFLAGS
1202$! 1194$!
1203$! Define The Linker Options File Name. 1195$! Define The Linker Options File Name.
@@ -1231,7 +1223,7 @@ $ EXIT
1231$ ENDIF 1223$ ENDIF
1232$ IF F$TRNLNM("DECC$CC_DEFAULT").EQS."/DECC" THEN CC = "CC/VAXC" 1224$ IF F$TRNLNM("DECC$CC_DEFAULT").EQS."/DECC" THEN CC = "CC/VAXC"
1233$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/NOLIST" + - 1225$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/NOLIST" + -
1234 "/INCLUDE=(SYS$DISK:[],SYS$DISK:[.ENGINE.VENDOR_DEFNS])" + - 1226 "/INCLUDE=(SYS$DISK:[],SYS$DISK:[-],SYS$DISK:[.ENGINE.VENDOR_DEFNS])" + -
1235 CCEXTRAFLAGS 1227 CCEXTRAFLAGS
1236$ CCDEFS = """VAXC""," + CCDEFS 1228$ CCDEFS = """VAXC""," + CCDEFS
1237$! 1229$!
@@ -1263,7 +1255,7 @@ $!
1263$! Use GNU C... 1255$! Use GNU C...
1264$! 1256$!
1265$ CC = "GCC/NOCASE_HACK/''GCC_OPTIMIZE'/''DEBUGGER'/NOLIST" + - 1257$ CC = "GCC/NOCASE_HACK/''GCC_OPTIMIZE'/''DEBUGGER'/NOLIST" + -
1266 "/INCLUDE=(SYS$DISK:[],SYS$DISK:[.ENGINE.VENDOR_DEFNS])" + - 1258 "/INCLUDE=(SYS$DISK:[],SYS$DISK:[-],SYS$DISK:[.ENGINE.VENDOR_DEFNS])" + -
1267 CCEXTRAFLAGS 1259 CCEXTRAFLAGS
1268$! 1260$!
1269$! Define The Linker Options File Name. 1261$! Define The Linker Options File Name.
@@ -1462,6 +1454,7 @@ $!
1462$! Save directory information 1454$! Save directory information
1463$! 1455$!
1464$ __HERE = F$PARSE(F$PARSE("A.;",F$ENVIRONMENT("PROCEDURE"))-"A.;","[]A.;") - "A.;" 1456$ __HERE = F$PARSE(F$PARSE("A.;",F$ENVIRONMENT("PROCEDURE"))-"A.;","[]A.;") - "A.;"
1457$ __HERE = F$EDIT(__HERE,"UPCASE")
1465$ __TOP = __HERE - "CRYPTO]" 1458$ __TOP = __HERE - "CRYPTO]"
1466$ __INCLUDE = __TOP + "INCLUDE.OPENSSL]" 1459$ __INCLUDE = __TOP + "INCLUDE.OPENSSL]"
1467$! 1460$!
diff --git a/src/lib/libcrypto/crypto.h b/src/lib/libcrypto/crypto.h
index 9257673279..fc6ff860af 100644
--- a/src/lib/libcrypto/crypto.h
+++ b/src/lib/libcrypto/crypto.h
@@ -61,7 +61,7 @@
61 61
62#include <stdlib.h> 62#include <stdlib.h>
63 63
64#ifndef NO_FP_API 64#ifndef OPENSSL_NO_FP_API
65#include <stdio.h> 65#include <stdio.h>
66#endif 66#endif
67 67
@@ -90,13 +90,14 @@ extern "C" {
90#define SSLEAY_CFLAGS 2 90#define SSLEAY_CFLAGS 2
91#define SSLEAY_BUILT_ON 3 91#define SSLEAY_BUILT_ON 3
92#define SSLEAY_PLATFORM 4 92#define SSLEAY_PLATFORM 4
93#define SSLEAY_DIR 5
93 94
94/* When changing the CRYPTO_LOCK_* list, be sure to maintin the text lock 95/* When changing the CRYPTO_LOCK_* list, be sure to maintin the text lock
95 * names in cryptlib.c 96 * names in cryptlib.c
96 */ 97 */
97 98
98#define CRYPTO_LOCK_ERR 1 99#define CRYPTO_LOCK_ERR 1
99#define CRYPTO_LOCK_ERR_HASH 2 100#define CRYPTO_LOCK_EX_DATA 2
100#define CRYPTO_LOCK_X509 3 101#define CRYPTO_LOCK_X509 3
101#define CRYPTO_LOCK_X509_INFO 4 102#define CRYPTO_LOCK_X509_INFO 4
102#define CRYPTO_LOCK_X509_PKEY 5 103#define CRYPTO_LOCK_X509_PKEY 5
@@ -112,25 +113,27 @@ extern "C" {
112#define CRYPTO_LOCK_SSL_SESS_CERT 15 113#define CRYPTO_LOCK_SSL_SESS_CERT 15
113#define CRYPTO_LOCK_SSL 16 114#define CRYPTO_LOCK_SSL 16
114#define CRYPTO_LOCK_RAND 17 115#define CRYPTO_LOCK_RAND 17
115#define CRYPTO_LOCK_MALLOC 18 116#define CRYPTO_LOCK_RAND2 18
116#define CRYPTO_LOCK_BIO 19 117#define CRYPTO_LOCK_MALLOC 19
117#define CRYPTO_LOCK_GETHOSTBYNAME 20 118#define CRYPTO_LOCK_BIO 20
118#define CRYPTO_LOCK_GETSERVBYNAME 21 119#define CRYPTO_LOCK_GETHOSTBYNAME 21
119#define CRYPTO_LOCK_READDIR 22 120#define CRYPTO_LOCK_GETSERVBYNAME 22
120#define CRYPTO_LOCK_RSA_BLINDING 23 121#define CRYPTO_LOCK_READDIR 23
121#define CRYPTO_LOCK_DH 24 122#define CRYPTO_LOCK_RSA_BLINDING 24
122#define CRYPTO_LOCK_MALLOC2 25 123#define CRYPTO_LOCK_DH 25
123#define CRYPTO_LOCK_DSO 26 124#define CRYPTO_LOCK_MALLOC2 26
124#define CRYPTO_LOCK_DYNLOCK 27 125#define CRYPTO_LOCK_DSO 27
125#define CRYPTO_LOCK_ENGINE 28 126#define CRYPTO_LOCK_DYNLOCK 28
126#define CRYPTO_NUM_LOCKS 29 127#define CRYPTO_LOCK_ENGINE 29
128#define CRYPTO_LOCK_UI 30
129#define CRYPTO_NUM_LOCKS 31
127 130
128#define CRYPTO_LOCK 1 131#define CRYPTO_LOCK 1
129#define CRYPTO_UNLOCK 2 132#define CRYPTO_UNLOCK 2
130#define CRYPTO_READ 4 133#define CRYPTO_READ 4
131#define CRYPTO_WRITE 8 134#define CRYPTO_WRITE 8
132 135
133#ifndef NO_LOCKING 136#ifndef OPENSSL_NO_LOCKING
134#ifndef CRYPTO_w_lock 137#ifndef CRYPTO_w_lock
135#define CRYPTO_w_lock(type) \ 138#define CRYPTO_w_lock(type) \
136 CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,__FILE__,__LINE__) 139 CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)
@@ -224,6 +227,16 @@ DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS)
224#define CRYPTO_EX_INDEX_SSL_SESSION 3 227#define CRYPTO_EX_INDEX_SSL_SESSION 3
225#define CRYPTO_EX_INDEX_X509_STORE 4 228#define CRYPTO_EX_INDEX_X509_STORE 4
226#define CRYPTO_EX_INDEX_X509_STORE_CTX 5 229#define CRYPTO_EX_INDEX_X509_STORE_CTX 5
230#define CRYPTO_EX_INDEX_RSA 6
231#define CRYPTO_EX_INDEX_DSA 7
232#define CRYPTO_EX_INDEX_DH 8
233#define CRYPTO_EX_INDEX_ENGINE 9
234#define CRYPTO_EX_INDEX_X509 10
235#define CRYPTO_EX_INDEX_UI 11
236
237/* Dynamically assigned indexes start from this value (don't use directly, use
238 * via CRYPTO_ex_data_new_class). */
239#define CRYPTO_EX_INDEX_USER 100
227 240
228 241
229/* This is the default callbacks, but we can have others as well: 242/* This is the default callbacks, but we can have others as well:
@@ -280,14 +293,31 @@ unsigned long SSLeay(void);
280 293
281int OPENSSL_issetugid(void); 294int OPENSSL_issetugid(void);
282 295
283int CRYPTO_get_ex_new_index(int idx, STACK_OF(CRYPTO_EX_DATA_FUNCS) **skp, long argl, void *argp, 296/* An opaque type representing an implementation of "ex_data" support */
284 CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); 297typedef struct st_CRYPTO_EX_DATA_IMPL CRYPTO_EX_DATA_IMPL;
298/* Return an opaque pointer to the current "ex_data" implementation */
299const CRYPTO_EX_DATA_IMPL *CRYPTO_get_ex_data_implementation(void);
300/* Sets the "ex_data" implementation to be used (if it's not too late) */
301int CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i);
302/* Get a new "ex_data" class, and return the corresponding "class_index" */
303int CRYPTO_ex_data_new_class(void);
304/* Within a given class, get/register a new index */
305int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,
306 CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
307 CRYPTO_EX_free *free_func);
308/* Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a given
309 * class (invokes whatever per-class callbacks are applicable) */
310int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
311int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
312 CRYPTO_EX_DATA *from);
313void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
314/* Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular index
315 * (relative to the class type involved) */
285int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val); 316int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val);
286void *CRYPTO_get_ex_data(CRYPTO_EX_DATA *ad,int idx); 317void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad,int idx);
287int CRYPTO_dup_ex_data(STACK_OF(CRYPTO_EX_DATA_FUNCS) *meth, CRYPTO_EX_DATA *to, 318/* This function cleans up all "ex_data" state. It mustn't be called under
288 CRYPTO_EX_DATA *from); 319 * potential race-conditions. */
289void CRYPTO_free_ex_data(STACK_OF(CRYPTO_EX_DATA_FUNCS) *meth, void *obj, CRYPTO_EX_DATA *ad); 320void CRYPTO_cleanup_all_ex_data(void);
290void CRYPTO_new_ex_data(STACK_OF(CRYPTO_EX_DATA_FUNCS) *meth, void *obj, CRYPTO_EX_DATA *ad);
291 321
292int CRYPTO_get_new_lockid(char *name); 322int CRYPTO_get_new_lockid(char *name);
293 323
@@ -322,6 +352,11 @@ void (*CRYPTO_get_dynlock_destroy_callback(void))(struct CRYPTO_dynlock_value *l
322 * call the latter last if you need different functions */ 352 * call the latter last if you need different functions */
323int CRYPTO_set_mem_functions(void *(*m)(size_t),void *(*r)(void *,size_t), void (*f)(void *)); 353int CRYPTO_set_mem_functions(void *(*m)(size_t),void *(*r)(void *,size_t), void (*f)(void *));
324int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*free_func)(void *)); 354int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*free_func)(void *));
355int CRYPTO_set_mem_ex_functions(void *(*m)(size_t,const char *,int),
356 void *(*r)(void *,size_t,const char *,int),
357 void (*f)(void *));
358int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t,const char *,int),
359 void (*free_func)(void *));
325int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int), 360int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int),
326 void (*r)(void *,void *,int,const char *,int,int), 361 void (*r)(void *,void *,int,const char *,int,int),
327 void (*f)(void *,int), 362 void (*f)(void *,int),
@@ -329,6 +364,11 @@ int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int),
329 long (*go)(void)); 364 long (*go)(void));
330void CRYPTO_get_mem_functions(void *(**m)(size_t),void *(**r)(void *, size_t), void (**f)(void *)); 365void CRYPTO_get_mem_functions(void *(**m)(size_t),void *(**r)(void *, size_t), void (**f)(void *));
331void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *)); 366void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *));
367void CRYPTO_get_mem_ex_functions(void *(**m)(size_t,const char *,int),
368 void *(**r)(void *, size_t,const char *,int),
369 void (**f)(void *));
370void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t,const char *,int),
371 void (**f)(void *));
332void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int), 372void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int),
333 void (**r)(void *,void *,int,const char *,int,int), 373 void (**r)(void *,void *,int,const char *,int,int),
334 void (**f)(void *,int), 374 void (**f)(void *,int),
@@ -351,6 +391,9 @@ int CRYPTO_push_info_(const char *info, const char *file, int line);
351int CRYPTO_pop_info(void); 391int CRYPTO_pop_info(void);
352int CRYPTO_remove_all_info(void); 392int CRYPTO_remove_all_info(void);
353 393
394
395/* Default debugging functions (enabled by CRYPTO_malloc_debug_init() macro;
396 * used as default in CRYPTO_MDEBUG compilations): */
354/* The last argument has the following significance: 397/* The last argument has the following significance:
355 * 398 *
356 * 0: called before the actual memory allocation has taken place 399 * 0: called before the actual memory allocation has taken place
@@ -359,31 +402,32 @@ int CRYPTO_remove_all_info(void);
359void CRYPTO_dbg_malloc(void *addr,int num,const char *file,int line,int before_p); 402void CRYPTO_dbg_malloc(void *addr,int num,const char *file,int line,int before_p);
360void CRYPTO_dbg_realloc(void *addr1,void *addr2,int num,const char *file,int line,int before_p); 403void CRYPTO_dbg_realloc(void *addr1,void *addr2,int num,const char *file,int line,int before_p);
361void CRYPTO_dbg_free(void *addr,int before_p); 404void CRYPTO_dbg_free(void *addr,int before_p);
362
363/* Tell the debugging code about options. By default, the following values 405/* Tell the debugging code about options. By default, the following values
364 * apply: 406 * apply:
365 * 407 *
366 * 0: Clear all options. 408 * 0: Clear all options.
367 * 1: Set the "Show Time" option. 409 * V_CRYPTO_MDEBUG_TIME (1): Set the "Show Time" option.
368 * 2: Set the "Show Thread Number" option. 410 * V_CRYPTO_MDEBUG_THREAD (2): Set the "Show Thread Number" option.
369 * 3: 1 + 2 411 * V_CRYPTO_MDEBUG_ALL (3): 1 + 2
370 */ 412 */
371void CRYPTO_dbg_set_options(long bits); 413void CRYPTO_dbg_set_options(long bits);
372long CRYPTO_dbg_get_options(void); 414long CRYPTO_dbg_get_options(void);
373 415
374#ifndef NO_FP_API 416
417#ifndef OPENSSL_NO_FP_API
375void CRYPTO_mem_leaks_fp(FILE *); 418void CRYPTO_mem_leaks_fp(FILE *);
376#endif 419#endif
377void CRYPTO_mem_leaks(struct bio_st *bio); 420void CRYPTO_mem_leaks(struct bio_st *bio);
378/* unsigned long order, char *file, int line, int num_bytes, char *addr */ 421/* unsigned long order, char *file, int line, int num_bytes, char *addr */
379void CRYPTO_mem_leaks_cb(void (*cb)(unsigned long, const char *, int, int, void *)); 422typedef void *CRYPTO_MEM_LEAK_CB(unsigned long, const char *, int, int, void *);
423void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb);
380 424
381void ERR_load_CRYPTO_strings(void);
382 425
383/* BEGIN ERROR CODES */ 426/* BEGIN ERROR CODES */
384/* 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
385 * made after this point may be overwritten when the script is next run. 428 * made after this point may be overwritten when the script is next run.
386 */ 429 */
430void ERR_load_CRYPTO_strings(void);
387 431
388/* Error codes for the CRYPTO functions. */ 432/* Error codes for the CRYPTO functions. */
389 433
@@ -392,6 +436,11 @@ void ERR_load_CRYPTO_strings(void);
392#define CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID 103 436#define CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID 103
393#define CRYPTO_F_CRYPTO_GET_NEW_LOCKID 101 437#define CRYPTO_F_CRYPTO_GET_NEW_LOCKID 101
394#define CRYPTO_F_CRYPTO_SET_EX_DATA 102 438#define CRYPTO_F_CRYPTO_SET_EX_DATA 102
439#define CRYPTO_F_DEF_ADD_INDEX 104
440#define CRYPTO_F_DEF_GET_CLASS 105
441#define CRYPTO_F_INT_DUP_EX_DATA 106
442#define CRYPTO_F_INT_FREE_EX_DATA 107
443#define CRYPTO_F_INT_NEW_EX_DATA 108
395 444
396/* Reason codes. */ 445/* Reason codes. */
397#define CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK 100 446#define CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK 100
@@ -400,4 +449,3 @@ void ERR_load_CRYPTO_strings(void);
400} 449}
401#endif 450#endif
402#endif 451#endif
403
diff --git a/src/lib/libcrypto/cversion.c b/src/lib/libcrypto/cversion.c
index affdfca98f..f7a1b7a4f0 100644
--- a/src/lib/libcrypto/cversion.c
+++ b/src/lib/libcrypto/cversion.c
@@ -102,6 +102,14 @@ const char *SSLeay_version(int t)
102 return("platform: information not available"); 102 return("platform: information not available");
103#endif 103#endif
104 } 104 }
105 if (t == SSLEAY_DIR)
106 {
107#ifdef OPENSSLDIR
108 return "OPENSSLDIR: \"" OPENSSLDIR "\"";
109#else
110 return "OPENSSLDIR: N/A";
111#endif
112 }
105 return("not available"); 113 return("not available");
106 } 114 }
107 115
diff --git a/src/lib/libcrypto/des/Makefile.ssl b/src/lib/libcrypto/des/Makefile.ssl
index cc5379feb2..04a73a9326 100644
--- a/src/lib/libcrypto/des/Makefile.ssl
+++ b/src/lib/libcrypto/des/Makefile.ssl
@@ -6,13 +6,14 @@ DIR= des
6TOP= ../.. 6TOP= ../..
7CC= cc 7CC= cc
8CPP= $(CC) -E 8CPP= $(CC) -E
9INCLUDES=-I../../include 9INCLUDES=-I$(TOP) -I../../include
10CFLAG=-g 10CFLAG=-g
11INSTALL_PREFIX= 11INSTALL_PREFIX=
12OPENSSLDIR= /usr/local/ssl 12OPENSSLDIR= /usr/local/ssl
13INSTALLTOP=/usr/local/ssl 13INSTALLTOP=/usr/local/ssl
14MAKE= make -f Makefile.ssl 14MAKE= make -f Makefile.ssl
15MAKEDEPEND= $(TOP)/util/domd $(TOP) 15MAKEDEPPROG= makedepend
16MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl 17MAKEFILE= Makefile.ssl
17AR= ar r 18AR= ar r
18RANLIB= ranlib 19RANLIB= ranlib
@@ -30,22 +31,23 @@ LIB=$(TOP)/libcrypto.a
30LIBSRC= cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c \ 31LIBSRC= cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c \
31 ecb3_enc.c ecb_enc.c enc_read.c enc_writ.c \ 32 ecb3_enc.c ecb_enc.c enc_read.c enc_writ.c \
32 fcrypt.c ofb64enc.c ofb_enc.c pcbc_enc.c \ 33 fcrypt.c ofb64enc.c ofb_enc.c pcbc_enc.c \
33 qud_cksm.c rand_key.c read_pwd.c rpc_enc.c set_key.c \ 34 qud_cksm.c rand_key.c rpc_enc.c set_key.c \
34 des_enc.c fcrypt_b.c read2pwd.c \ 35 des_enc.c fcrypt_b.c \
35 xcbc_enc.c \ 36 xcbc_enc.c \
36 str2key.c cfb64ede.c ofb64ede.c ede_cbcm_enc.c 37 str2key.c cfb64ede.c ofb64ede.c ede_cbcm_enc.c des_old.c des_old2.c \
38 read2pwd.c
37 39
38LIBOBJ= set_key.o ecb_enc.o cbc_enc.o \ 40LIBOBJ= set_key.o ecb_enc.o cbc_enc.o \
39 ecb3_enc.o cfb64enc.o cfb64ede.o cfb_enc.o ofb64ede.o \ 41 ecb3_enc.o cfb64enc.o cfb64ede.o cfb_enc.o ofb64ede.o \
40 enc_read.o enc_writ.o ofb64enc.o \ 42 enc_read.o enc_writ.o ofb64enc.o \
41 ofb_enc.o str2key.o pcbc_enc.o qud_cksm.o rand_key.o \ 43 ofb_enc.o str2key.o pcbc_enc.o qud_cksm.o rand_key.o \
42 ${DES_ENC} read2pwd.o \ 44 ${DES_ENC} \
43 fcrypt.o xcbc_enc.o read_pwd.o rpc_enc.o cbc_cksm.o \ 45 fcrypt.o xcbc_enc.o rpc_enc.o cbc_cksm.o \
44 ede_cbcm_enc.o 46 ede_cbcm_enc.o des_old.o des_old2.o read2pwd.o
45 47
46SRC= $(LIBSRC) 48SRC= $(LIBSRC)
47 49
48EXHEADER= des.h 50EXHEADER= des.h des_old.h
49HEADER= des_locl.h rpc_des.h spr.h des_ver.h $(EXHEADER) 51HEADER= des_locl.h rpc_des.h spr.h des_ver.h $(EXHEADER)
50 52
51ALL= $(GENERAL) $(SRC) $(HEADER) 53ALL= $(GENERAL) $(SRC) $(HEADER)
@@ -57,8 +59,7 @@ all: lib
57 59
58lib: $(LIBOBJ) 60lib: $(LIBOBJ)
59 $(AR) $(LIB) $(LIBOBJ) 61 $(AR) $(LIB) $(LIBOBJ)
60 @echo You may get an error following this line. Please ignore. 62 $(RANLIB) $(LIB) || echo Never mind.
61 - $(RANLIB) $(LIB)
62 @touch lib 63 @touch lib
63 64
64des: des.o cbc3_enc.o lib 65des: des.o cbc3_enc.o lib
@@ -141,72 +142,184 @@ clean:
141 142
142# DO NOT DELETE THIS LINE -- make depend depends on it. 143# DO NOT DELETE THIS LINE -- make depend depends on it.
143 144
144cbc_cksm.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 145cbc_cksm.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
145cbc_cksm.o: ../../include/openssl/opensslconf.h des_locl.h 146cbc_cksm.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
146cbc_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 147cbc_cksm.o: ../../include/openssl/opensslconf.h
147cbc_enc.o: ../../include/openssl/opensslconf.h des_locl.h ncbc_enc.c 148cbc_cksm.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
148cfb64ede.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 149cbc_cksm.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
149cfb64ede.o: ../../include/openssl/opensslconf.h des_locl.h 150cbc_cksm.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
150cfb64enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 151cbc_cksm.o: cbc_cksm.c des_locl.h
151cfb64enc.o: ../../include/openssl/opensslconf.h des_locl.h 152cbc_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
152cfb_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 153cbc_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
153cfb_enc.o: ../../include/openssl/opensslconf.h des_locl.h 154cbc_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
154des_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 155cbc_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
155des_enc.o: ../../include/openssl/opensslconf.h des_locl.h des_locl.h ncbc_enc.c 156cbc_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
156ecb3_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 157cbc_enc.o: ../../include/openssl/ui_compat.h cbc_enc.c des_locl.h ncbc_enc.c
157ecb3_enc.o: ../../include/openssl/opensslconf.h des_locl.h 158cfb64ede.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
158ecb_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 159cfb64ede.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
160cfb64ede.o: ../../include/openssl/opensslconf.h
161cfb64ede.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
162cfb64ede.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
163cfb64ede.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
164cfb64ede.o: cfb64ede.c des_locl.h
165cfb64enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
166cfb64enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
167cfb64enc.o: ../../include/openssl/opensslconf.h
168cfb64enc.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
169cfb64enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
170cfb64enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
171cfb64enc.o: cfb64enc.c des_locl.h
172cfb_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
173cfb_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
174cfb_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
175cfb_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
176cfb_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
177cfb_enc.o: ../../include/openssl/ui_compat.h cfb_enc.c des_locl.h
178des_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
179des_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
180des_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
181des_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
182des_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
183des_enc.o: ../../include/openssl/ui_compat.h des_enc.c des_locl.h ncbc_enc.c
184des_old.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
185des_old.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
186des_old.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
187des_old.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
188des_old.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
189des_old.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
190des_old.o: ../../include/openssl/ui_compat.h des_old.c
191des_old2.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
192des_old2.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
193des_old2.o: ../../include/openssl/opensslconf.h
194des_old2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
195des_old2.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
196des_old2.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
197des_old2.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
198des_old2.o: des_old2.c
199ecb3_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
200ecb3_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
201ecb3_enc.o: ../../include/openssl/opensslconf.h
202ecb3_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
203ecb3_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
204ecb3_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
205ecb3_enc.o: des_locl.h ecb3_enc.c
206ecb_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
207ecb_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
159ecb_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 208ecb_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
160ecb_enc.o: des_locl.h spr.h 209ecb_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
161ede_cbcm_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 210ecb_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
162ede_cbcm_enc.o: ../../include/openssl/opensslconf.h des_locl.h 211ecb_enc.o: ../../include/openssl/ui_compat.h des_locl.h ecb_enc.c spr.h
163enc_read.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 212ede_cbcm_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
164enc_read.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 213ede_cbcm_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
165enc_read.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 214ede_cbcm_enc.o: ../../include/openssl/opensslconf.h
166enc_read.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 215ede_cbcm_enc.o: ../../include/openssl/opensslv.h
167enc_read.o: ../../include/openssl/opensslconf.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
168enc_read.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 224enc_read.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
169enc_read.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 225enc_read.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
170enc_read.o: ../cryptlib.h des_locl.h 226enc_read.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
171enc_writ.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 227enc_read.o: ../cryptlib.h des_locl.h enc_read.c
172enc_writ.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 228enc_writ.o: ../../e_os.h ../../include/openssl/bio.h
173enc_writ.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 229enc_writ.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
174enc_writ.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 230enc_writ.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
175enc_writ.o: ../../include/openssl/opensslconf.h 231enc_writ.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
176enc_writ.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 232enc_writ.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
177enc_writ.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 233enc_writ.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
178enc_writ.o: ../../include/openssl/symhacks.h ../cryptlib.h des_locl.h 234enc_writ.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
179fcrypt.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 235enc_writ.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
180fcrypt.o: ../../include/openssl/opensslconf.h des_locl.h 236enc_writ.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
181fcrypt_b.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 237enc_writ.o: ../cryptlib.h des_locl.h enc_writ.c
182fcrypt_b.o: ../../include/openssl/opensslconf.h des_locl.h 238fcrypt.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
183ofb64ede.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 239fcrypt.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
184ofb64ede.o: ../../include/openssl/opensslconf.h des_locl.h 240fcrypt.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
185ofb64enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 241fcrypt.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
186ofb64enc.o: ../../include/openssl/opensslconf.h des_locl.h 242fcrypt.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
187ofb_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 243fcrypt.o: ../../include/openssl/ui_compat.h des_locl.h fcrypt.c
188ofb_enc.o: ../../include/openssl/opensslconf.h des_locl.h 244fcrypt_b.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
189pcbc_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 245fcrypt_b.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
190pcbc_enc.o: ../../include/openssl/opensslconf.h des_locl.h 246fcrypt_b.o: ../../include/openssl/opensslconf.h
191qud_cksm.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 247fcrypt_b.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
192qud_cksm.o: ../../include/openssl/opensslconf.h des_locl.h 248fcrypt_b.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
193rand_key.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 249fcrypt_b.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
194rand_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/rand.h 250fcrypt_b.o: des_locl.h fcrypt_b.c
195read2pwd.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 251ofb64ede.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
196read2pwd.o: ../../include/openssl/opensslconf.h des_locl.h 252ofb64ede.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
197read_pwd.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 253ofb64ede.o: ../../include/openssl/opensslconf.h
198read_pwd.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 254ofb64ede.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
199read_pwd.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 255ofb64ede.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
200read_pwd.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 256ofb64ede.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
201read_pwd.o: ../../include/openssl/opensslconf.h 257ofb64ede.o: des_locl.h ofb64ede.c
202read_pwd.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 258ofb64enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
203read_pwd.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 259ofb64enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
204read_pwd.o: ../cryptlib.h des_locl.h 260ofb64enc.o: ../../include/openssl/opensslconf.h
205rpc_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 261ofb64enc.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
206rpc_enc.o: ../../include/openssl/opensslconf.h des_locl.h des_ver.h rpc_des.h 262ofb64enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
207set_key.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 263ofb64enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
208set_key.o: ../../include/openssl/opensslconf.h des_locl.h 264ofb64enc.o: des_locl.h ofb64enc.c
209str2key.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 265ofb_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
210str2key.o: ../../include/openssl/opensslconf.h des_locl.h 266ofb_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
211xcbc_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h 267ofb_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
212xcbc_enc.o: ../../include/openssl/opensslconf.h des_locl.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/asm/crypt586.pl b/src/lib/libcrypto/des/asm/crypt586.pl
index 197c413ea6..3d41d82f69 100644
--- a/src/lib/libcrypto/des/asm/crypt586.pl
+++ b/src/lib/libcrypto/des/asm/crypt586.pl
@@ -14,7 +14,7 @@ require "x86asm.pl";
14$L="edi"; 14$L="edi";
15$R="esi"; 15$R="esi";
16 16
17&external_label("des_SPtrans"); 17&external_label("DES_SPtrans");
18&fcrypt_body("fcrypt_body"); 18&fcrypt_body("fcrypt_body");
19&asm_finish(); 19&asm_finish();
20 20
@@ -22,7 +22,7 @@ sub fcrypt_body
22 { 22 {
23 local($name,$do_ip)=@_; 23 local($name,$do_ip)=@_;
24 24
25 &function_begin($name,"EXTRN _des_SPtrans:DWORD"); 25 &function_begin($name,"EXTRN _DES_SPtrans:DWORD");
26 26
27 &comment(""); 27 &comment("");
28 &comment("Load the 2 words"); 28 &comment("Load the 2 words");
@@ -39,11 +39,11 @@ sub fcrypt_body
39 { 39 {
40 &comment(""); 40 &comment("");
41 &comment("Round $i"); 41 &comment("Round $i");
42 &D_ENCRYPT($i,$L,$R,$i*2,$ks,"des_SPtrans","eax","ebx","ecx","edx"); 42 &D_ENCRYPT($i,$L,$R,$i*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx");
43 43
44 &comment(""); 44 &comment("");
45 &comment("Round ".sprintf("%d",$i+1)); 45 &comment("Round ".sprintf("%d",$i+1));
46 &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$ks,"des_SPtrans","eax","ebx","ecx","edx"); 46 &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx");
47 } 47 }
48 &mov("ebx", &swtmp(0)); 48 &mov("ebx", &swtmp(0));
49 &mov("eax", $L); 49 &mov("eax", $L);
diff --git a/src/lib/libcrypto/des/asm/des-586.pl b/src/lib/libcrypto/des/asm/des-586.pl
index c890766bc9..0d08e8a3a9 100644
--- a/src/lib/libcrypto/des/asm/des-586.pl
+++ b/src/lib/libcrypto/des/asm/des-586.pl
@@ -19,21 +19,21 @@ require "desboth.pl";
19$L="edi"; 19$L="edi";
20$R="esi"; 20$R="esi";
21 21
22&external_label("des_SPtrans"); 22&external_label("DES_SPtrans");
23&des_encrypt("des_encrypt1",1); 23&DES_encrypt("DES_encrypt1",1);
24&des_encrypt("des_encrypt2",0); 24&DES_encrypt("DES_encrypt2",0);
25&des_encrypt3("des_encrypt3",1); 25&DES_encrypt3("DES_encrypt3",1);
26&des_encrypt3("des_decrypt3",0); 26&DES_encrypt3("DES_decrypt3",0);
27&cbc("des_ncbc_encrypt","des_encrypt1","des_encrypt1",0,4,5,3,5,-1); 27&cbc("DES_ncbc_encrypt","DES_encrypt1","DES_encrypt1",0,4,5,3,5,-1);
28&cbc("des_ede3_cbc_encrypt","des_encrypt3","des_decrypt3",0,6,7,3,4,5); 28&cbc("DES_ede3_cbc_encrypt","DES_encrypt3","DES_decrypt3",0,6,7,3,4,5);
29 29
30&asm_finish(); 30&asm_finish();
31 31
32sub des_encrypt 32sub DES_encrypt
33 { 33 {
34 local($name,$do_ip)=@_; 34 local($name,$do_ip)=@_;
35 35
36 &function_begin_B($name,"EXTRN _des_SPtrans:DWORD"); 36 &function_begin_B($name,"EXTRN _DES_SPtrans:DWORD");
37 37
38 &push("esi"); 38 &push("esi");
39 &push("edi"); 39 &push("edi");
@@ -80,11 +80,11 @@ sub des_encrypt
80 { 80 {
81 &comment(""); 81 &comment("");
82 &comment("Round $i"); 82 &comment("Round $i");
83 &D_ENCRYPT($i,$L,$R,$i*2,$ks,"des_SPtrans","eax","ebx","ecx","edx"); 83 &D_ENCRYPT($i,$L,$R,$i*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx");
84 84
85 &comment(""); 85 &comment("");
86 &comment("Round ".sprintf("%d",$i+1)); 86 &comment("Round ".sprintf("%d",$i+1));
87 &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$ks,"des_SPtrans","eax","ebx","ecx","edx"); 87 &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx");
88 } 88 }
89 &jmp(&label("end")); 89 &jmp(&label("end"));
90 90
@@ -94,10 +94,10 @@ sub des_encrypt
94 { 94 {
95 &comment(""); 95 &comment("");
96 &comment("Round $i"); 96 &comment("Round $i");
97 &D_ENCRYPT(15-$i,$L,$R,$i*2,$ks,"des_SPtrans","eax","ebx","ecx","edx"); 97 &D_ENCRYPT(15-$i,$L,$R,$i*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx");
98 &comment(""); 98 &comment("");
99 &comment("Round ".sprintf("%d",$i-1)); 99 &comment("Round ".sprintf("%d",$i-1));
100 &D_ENCRYPT(15-$i+1,$R,$L,($i-1)*2,$ks,"des_SPtrans","eax","ebx","ecx","edx"); 100 &D_ENCRYPT(15-$i+1,$R,$L,($i-1)*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx");
101 } 101 }
102 102
103 &set_label("end"); 103 &set_label("end");
diff --git a/src/lib/libcrypto/des/asm/des686.pl b/src/lib/libcrypto/des/asm/des686.pl
index 84c3e85438..d3ad5d5edd 100644
--- a/src/lib/libcrypto/des/asm/des686.pl
+++ b/src/lib/libcrypto/des/asm/des686.pl
@@ -46,19 +46,19 @@ EOF
46$L="edi"; 46$L="edi";
47$R="esi"; 47$R="esi";
48 48
49&des_encrypt("des_encrypt1",1); 49&DES_encrypt("DES_encrypt1",1);
50&des_encrypt("des_encrypt2",0); 50&DES_encrypt("DES_encrypt2",0);
51 51
52&des_encrypt3("des_encrypt3",1); 52&DES_encrypt3("DES_encrypt3",1);
53&des_encrypt3("des_decrypt3",0); 53&DES_encrypt3("DES_decrypt3",0);
54 54
55&file_end(); 55&file_end();
56 56
57sub des_encrypt 57sub DES_encrypt
58 { 58 {
59 local($name,$do_ip)=@_; 59 local($name,$do_ip)=@_;
60 60
61 &function_begin($name,"EXTRN _des_SPtrans:DWORD"); 61 &function_begin($name,"EXTRN _DES_SPtrans:DWORD");
62 62
63 &comment(""); 63 &comment("");
64 &comment("Load the 2 words"); 64 &comment("Load the 2 words");
@@ -94,11 +94,11 @@ sub des_encrypt
94 { 94 {
95 &comment(""); 95 &comment("");
96 &comment("Round $i"); 96 &comment("Round $i");
97 &D_ENCRYPT($L,$R,$i*2,"ebp","des_SPtrans","ecx","edx","eax","ebx"); 97 &D_ENCRYPT($L,$R,$i*2,"ebp","DES_SPtrans","ecx","edx","eax","ebx");
98 98
99 &comment(""); 99 &comment("");
100 &comment("Round ".sprintf("%d",$i+1)); 100 &comment("Round ".sprintf("%d",$i+1));
101 &D_ENCRYPT($R,$L,($i+1)*2,"ebp","des_SPtrans","ecx","edx","eax","ebx"); 101 &D_ENCRYPT($R,$L,($i+1)*2,"ebp","DES_SPtrans","ecx","edx","eax","ebx");
102 } 102 }
103 &jmp(&label("end")); 103 &jmp(&label("end"));
104 104
@@ -108,10 +108,10 @@ sub des_encrypt
108 { 108 {
109 &comment(""); 109 &comment("");
110 &comment("Round $i"); 110 &comment("Round $i");
111 &D_ENCRYPT($L,$R,$i*2,"ebp","des_SPtrans","ecx","edx","eax","ebx"); 111 &D_ENCRYPT($L,$R,$i*2,"ebp","DES_SPtrans","ecx","edx","eax","ebx");
112 &comment(""); 112 &comment("");
113 &comment("Round ".sprintf("%d",$i-1)); 113 &comment("Round ".sprintf("%d",$i-1));
114 &D_ENCRYPT($R,$L,($i-1)*2,"ebp","des_SPtrans","ecx","edx","eax","ebx"); 114 &D_ENCRYPT($R,$L,($i-1)*2,"ebp","DES_SPtrans","ecx","edx","eax","ebx");
115 } 115 }
116 116
117 &set_label("end"); 117 &set_label("end");
diff --git a/src/lib/libcrypto/des/asm/desboth.pl b/src/lib/libcrypto/des/asm/desboth.pl
index d5106414db..eec00886e4 100644
--- a/src/lib/libcrypto/des/asm/desboth.pl
+++ b/src/lib/libcrypto/des/asm/desboth.pl
@@ -3,7 +3,7 @@
3$L="edi"; 3$L="edi";
4$R="esi"; 4$R="esi";
5 5
6sub des_encrypt3 6sub DES_encrypt3
7 { 7 {
8 local($name,$enc)=@_; 8 local($name,$enc)=@_;
9 9
@@ -47,15 +47,15 @@ sub des_encrypt3
47 &mov(&swtmp(2), (DWC(($enc)?"1":"0"))); 47 &mov(&swtmp(2), (DWC(($enc)?"1":"0")));
48 &mov(&swtmp(1), "eax"); 48 &mov(&swtmp(1), "eax");
49 &mov(&swtmp(0), "ebx"); 49 &mov(&swtmp(0), "ebx");
50 &call("des_encrypt2"); 50 &call("DES_encrypt2");
51 &mov(&swtmp(2), (DWC(($enc)?"0":"1"))); 51 &mov(&swtmp(2), (DWC(($enc)?"0":"1")));
52 &mov(&swtmp(1), "edi"); 52 &mov(&swtmp(1), "edi");
53 &mov(&swtmp(0), "ebx"); 53 &mov(&swtmp(0), "ebx");
54 &call("des_encrypt2"); 54 &call("DES_encrypt2");
55 &mov(&swtmp(2), (DWC(($enc)?"1":"0"))); 55 &mov(&swtmp(2), (DWC(($enc)?"1":"0")));
56 &mov(&swtmp(1), "esi"); 56 &mov(&swtmp(1), "esi");
57 &mov(&swtmp(0), "ebx"); 57 &mov(&swtmp(0), "ebx");
58 &call("des_encrypt2"); 58 &call("DES_encrypt2");
59 59
60 &stack_pop(3); 60 &stack_pop(3);
61 &mov($L,&DWP(0,"ebx","",0)); 61 &mov($L,&DWP(0,"ebx","",0));
diff --git a/src/lib/libcrypto/des/cbc3_enc.c b/src/lib/libcrypto/des/cbc3_enc.c
index 527e74f3de..b5db4e14f7 100644
--- a/src/lib/libcrypto/des/cbc3_enc.c
+++ b/src/lib/libcrypto/des/cbc3_enc.c
@@ -59,41 +59,41 @@
59#include "des_locl.h" 59#include "des_locl.h"
60 60
61/* HAS BUGS! DON'T USE - this is only present for use in des.c */ 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, 62void DES_3cbc_encrypt(DES_cblock *input, DES_cblock *output, long length,
63 des_key_schedule ks1, des_key_schedule ks2, des_cblock *iv1, 63 DES_key_schedule ks1, DES_key_schedule ks2, DES_cblock *iv1,
64 des_cblock *iv2, int enc) 64 DES_cblock *iv2, int enc)
65 { 65 {
66 int off=((int)length-1)/8; 66 int off=((int)length-1)/8;
67 long l8=((length+7)/8)*8; 67 long l8=((length+7)/8)*8;
68 des_cblock niv1,niv2; 68 DES_cblock niv1,niv2;
69 69
70 if (enc == DES_ENCRYPT) 70 if (enc == DES_ENCRYPT)
71 { 71 {
72 des_cbc_encrypt((unsigned char*)input, 72 DES_cbc_encrypt((unsigned char*)input,
73 (unsigned char*)output,length,ks1,iv1,enc); 73 (unsigned char*)output,length,&ks1,iv1,enc);
74 if (length >= sizeof(des_cblock)) 74 if (length >= sizeof(DES_cblock))
75 memcpy(niv1,output[off],sizeof(des_cblock)); 75 memcpy(niv1,output[off],sizeof(DES_cblock));
76 des_cbc_encrypt((unsigned char*)output, 76 DES_cbc_encrypt((unsigned char*)output,
77 (unsigned char*)output,l8,ks2,iv1,!enc); 77 (unsigned char*)output,l8,&ks2,iv1,!enc);
78 des_cbc_encrypt((unsigned char*)output, 78 DES_cbc_encrypt((unsigned char*)output,
79 (unsigned char*)output,l8,ks1,iv2,enc); 79 (unsigned char*)output,l8,&ks1,iv2,enc);
80 if (length >= sizeof(des_cblock)) 80 if (length >= sizeof(DES_cblock))
81 memcpy(niv2,output[off],sizeof(des_cblock)); 81 memcpy(niv2,output[off],sizeof(DES_cblock));
82 } 82 }
83 else 83 else
84 { 84 {
85 if (length >= sizeof(des_cblock)) 85 if (length >= sizeof(DES_cblock))
86 memcpy(niv2,input[off],sizeof(des_cblock)); 86 memcpy(niv2,input[off],sizeof(DES_cblock));
87 des_cbc_encrypt((unsigned char*)input, 87 DES_cbc_encrypt((unsigned char*)input,
88 (unsigned char*)output,l8,ks1,iv2,enc); 88 (unsigned char*)output,l8,&ks1,iv2,enc);
89 des_cbc_encrypt((unsigned char*)output, 89 DES_cbc_encrypt((unsigned char*)output,
90 (unsigned char*)output,l8,ks2,iv1,!enc); 90 (unsigned char*)output,l8,&ks2,iv1,!enc);
91 if (length >= sizeof(des_cblock)) 91 if (length >= sizeof(DES_cblock))
92 memcpy(niv1,output[off],sizeof(des_cblock)); 92 memcpy(niv1,output[off],sizeof(DES_cblock));
93 des_cbc_encrypt((unsigned char*)output, 93 DES_cbc_encrypt((unsigned char*)output,
94 (unsigned char*)output,length,ks1,iv1,enc); 94 (unsigned char*)output,length,&ks1,iv1,enc);
95 } 95 }
96 memcpy(*iv1,niv1,sizeof(des_cblock)); 96 memcpy(*iv1,niv1,sizeof(DES_cblock));
97 memcpy(*iv2,niv2,sizeof(des_cblock)); 97 memcpy(*iv2,niv2,sizeof(DES_cblock));
98 } 98 }
99 99
diff --git a/src/lib/libcrypto/des/cbc_cksm.c b/src/lib/libcrypto/des/cbc_cksm.c
index b857df0985..6c5305b99d 100644
--- a/src/lib/libcrypto/des/cbc_cksm.c
+++ b/src/lib/libcrypto/des/cbc_cksm.c
@@ -58,9 +58,9 @@
58 58
59#include "des_locl.h" 59#include "des_locl.h"
60 60
61DES_LONG des_cbc_cksum(const unsigned char *in, des_cblock *output, 61DES_LONG DES_cbc_cksum(const unsigned char *in, DES_cblock *output,
62 long length, 62 long length, DES_key_schedule *schedule,
63 des_key_schedule schedule, const_des_cblock *ivec) 63 const_DES_cblock *ivec)
64 { 64 {
65 register DES_LONG tout0,tout1,tin0,tin1; 65 register DES_LONG tout0,tout1,tin0,tin1;
66 register long l=length; 66 register long l=length;
@@ -82,7 +82,7 @@ DES_LONG des_cbc_cksum(const unsigned char *in, des_cblock *output,
82 82
83 tin0^=tout0; tin[0]=tin0; 83 tin0^=tout0; tin[0]=tin0;
84 tin1^=tout1; tin[1]=tin1; 84 tin1^=tout1; tin[1]=tin1;
85 des_encrypt1((DES_LONG *)tin,schedule,DES_ENCRYPT); 85 DES_encrypt1((DES_LONG *)tin,schedule,DES_ENCRYPT);
86 /* fix 15/10/91 eay - thanks to keithr@sco.COM */ 86 /* fix 15/10/91 eay - thanks to keithr@sco.COM */
87 tout0=tin[0]; 87 tout0=tin[0];
88 tout1=tin[1]; 88 tout1=tin[1];
diff --git a/src/lib/libcrypto/des/cfb64ede.c b/src/lib/libcrypto/des/cfb64ede.c
index 5362a551bf..60c1aa08db 100644
--- a/src/lib/libcrypto/des/cfb64ede.c
+++ b/src/lib/libcrypto/des/cfb64ede.c
@@ -63,9 +63,10 @@
63 * 64bit block we have used is contained in *num; 63 * 64bit block we have used is contained in *num;
64 */ 64 */
65 65
66void des_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out, 66void DES_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out,
67 long length, des_key_schedule ks1, des_key_schedule ks2, 67 long length, DES_key_schedule *ks1,
68 des_key_schedule ks3, des_cblock *ivec, int *num, int enc) 68 DES_key_schedule *ks2, DES_key_schedule *ks3,
69 DES_cblock *ivec, int *num, int enc)
69 { 70 {
70 register DES_LONG v0,v1; 71 register DES_LONG v0,v1;
71 register long l=length; 72 register long l=length;
@@ -85,7 +86,7 @@ void des_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out,
85 86
86 ti[0]=v0; 87 ti[0]=v0;
87 ti[1]=v1; 88 ti[1]=v1;
88 des_encrypt3(ti,ks1,ks2,ks3); 89 DES_encrypt3(ti,ks1,ks2,ks3);
89 v0=ti[0]; 90 v0=ti[0];
90 v1=ti[1]; 91 v1=ti[1];
91 92
@@ -111,7 +112,7 @@ void des_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out,
111 112
112 ti[0]=v0; 113 ti[0]=v0;
113 ti[1]=v1; 114 ti[1]=v1;
114 des_encrypt3(ti,ks1,ks2,ks3); 115 DES_encrypt3(ti,ks1,ks2,ks3);
115 v0=ti[0]; 116 v0=ti[0];
116 v1=ti[1]; 117 v1=ti[1];
117 118
@@ -132,10 +133,10 @@ void des_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out,
132 } 133 }
133 134
134#ifdef undef /* MACRO */ 135#ifdef undef /* MACRO */
135void des_ede2_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, 136void DES_ede2_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
136 des_key_schedule ks1, des_key_schedule ks2, des_cblock (*ivec), 137 DES_key_schedule ks1, DES_key_schedule ks2, DES_cblock (*ivec),
137 int *num, int enc) 138 int *num, int enc)
138 { 139 {
139 des_ede3_cfb64_encrypt(in,out,length,ks1,ks2,ks1,ivec,num,enc); 140 DES_ede3_cfb64_encrypt(in,out,length,ks1,ks2,ks1,ivec,num,enc);
140 } 141 }
141#endif 142#endif
diff --git a/src/lib/libcrypto/des/cfb64enc.c b/src/lib/libcrypto/des/cfb64enc.c
index 105530dfa3..5ec8683e40 100644
--- a/src/lib/libcrypto/des/cfb64enc.c
+++ b/src/lib/libcrypto/des/cfb64enc.c
@@ -63,9 +63,9 @@
63 * 64bit block we have used is contained in *num; 63 * 64bit block we have used is contained in *num;
64 */ 64 */
65 65
66void des_cfb64_encrypt(const unsigned char *in, unsigned char *out, 66void DES_cfb64_encrypt(const unsigned char *in, unsigned char *out,
67 long length, des_key_schedule schedule, des_cblock *ivec, 67 long length, DES_key_schedule *schedule,
68 int *num, int enc) 68 DES_cblock *ivec, int *num, int enc)
69 { 69 {
70 register DES_LONG v0,v1; 70 register DES_LONG v0,v1;
71 register long l=length; 71 register long l=length;
@@ -82,7 +82,7 @@ void des_cfb64_encrypt(const unsigned char *in, unsigned char *out,
82 { 82 {
83 c2l(iv,v0); ti[0]=v0; 83 c2l(iv,v0); ti[0]=v0;
84 c2l(iv,v1); ti[1]=v1; 84 c2l(iv,v1); ti[1]=v1;
85 des_encrypt1(ti,schedule,DES_ENCRYPT); 85 DES_encrypt1(ti,schedule,DES_ENCRYPT);
86 iv = &(*ivec)[0]; 86 iv = &(*ivec)[0];
87 v0=ti[0]; l2c(v0,iv); 87 v0=ti[0]; l2c(v0,iv);
88 v0=ti[1]; l2c(v0,iv); 88 v0=ti[1]; l2c(v0,iv);
@@ -102,7 +102,7 @@ void des_cfb64_encrypt(const unsigned char *in, unsigned char *out,
102 { 102 {
103 c2l(iv,v0); ti[0]=v0; 103 c2l(iv,v0); ti[0]=v0;
104 c2l(iv,v1); ti[1]=v1; 104 c2l(iv,v1); ti[1]=v1;
105 des_encrypt1(ti,schedule,DES_ENCRYPT); 105 DES_encrypt1(ti,schedule,DES_ENCRYPT);
106 iv = &(*ivec)[0]; 106 iv = &(*ivec)[0];
107 v0=ti[0]; l2c(v0,iv); 107 v0=ti[0]; l2c(v0,iv);
108 v0=ti[1]; l2c(v0,iv); 108 v0=ti[1]; l2c(v0,iv);
diff --git a/src/lib/libcrypto/des/cfb_enc.c b/src/lib/libcrypto/des/cfb_enc.c
index ec4fd4ea67..17bf77ca9e 100644
--- a/src/lib/libcrypto/des/cfb_enc.c
+++ b/src/lib/libcrypto/des/cfb_enc.c
@@ -64,8 +64,8 @@
64 * the second. The second 12 bits will come from the 3rd and half the 4th 64 * the second. The second 12 bits will come from the 3rd and half the 4th
65 * byte. 65 * byte.
66 */ 66 */
67void des_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, 67void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
68 long length, des_key_schedule schedule, des_cblock *ivec, int enc) 68 long length, DES_key_schedule *schedule, DES_cblock *ivec, int enc)
69 { 69 {
70 register DES_LONG d0,d1,v0,v1,n=(numbits+7)/8; 70 register DES_LONG d0,d1,v0,v1,n=(numbits+7)/8;
71 register DES_LONG mask0,mask1; 71 register DES_LONG mask0,mask1;
@@ -100,7 +100,7 @@ void des_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
100 l-=n; 100 l-=n;
101 ti[0]=v0; 101 ti[0]=v0;
102 ti[1]=v1; 102 ti[1]=v1;
103 des_encrypt1((DES_LONG *)ti,schedule,DES_ENCRYPT); 103 DES_encrypt1((DES_LONG *)ti,schedule,DES_ENCRYPT);
104 c2ln(in,d0,d1,n); 104 c2ln(in,d0,d1,n);
105 in+=n; 105 in+=n;
106 d0=(d0^ti[0])&mask0; 106 d0=(d0^ti[0])&mask0;
@@ -132,7 +132,7 @@ void des_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
132 l-=n; 132 l-=n;
133 ti[0]=v0; 133 ti[0]=v0;
134 ti[1]=v1; 134 ti[1]=v1;
135 des_encrypt1((DES_LONG *)ti,schedule,DES_ENCRYPT); 135 DES_encrypt1((DES_LONG *)ti,schedule,DES_ENCRYPT);
136 c2ln(in,d0,d1,n); 136 c2ln(in,d0,d1,n);
137 in+=n; 137 in+=n;
138 /* 30-08-94 - eay - changed because l>>32 and 138 /* 30-08-94 - eay - changed because l>>32 and
diff --git a/src/lib/libcrypto/des/des-lib.com b/src/lib/libcrypto/des/des-lib.com
index 2aea7a0dea..fc2c35a1ce 100644
--- a/src/lib/libcrypto/des/des-lib.com
+++ b/src/lib/libcrypto/des/des-lib.com
@@ -846,8 +846,8 @@ $ ENDIF
846$! 846$!
847$! Set Up Initial CC Definitions, Possibly With User Ones 847$! Set Up Initial CC Definitions, Possibly With User Ones
848$! 848$!
849$ CCDEFS = "VMS=1" 849$ CCDEFS = ""
850$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS 850$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = USER_CCDEFS
851$ CCEXTRAFLAGS = "" 851$ CCEXTRAFLAGS = ""
852$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS 852$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS
853$ CCDISABLEWARNINGS = "" 853$ CCDISABLEWARNINGS = ""
diff --git a/src/lib/libcrypto/des/des.c b/src/lib/libcrypto/des/des.c
index 215d7413c0..d8c846b23d 100644
--- a/src/lib/libcrypto/des/des.c
+++ b/src/lib/libcrypto/des/des.c
@@ -59,25 +59,25 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <stdlib.h> 60#include <stdlib.h>
61#include <string.h> 61#include <string.h>
62#ifndef MSDOS
63#ifndef VMS
64#include <openssl/opensslconf.h> 62#include <openssl/opensslconf.h>
63#ifndef OPENSSL_SYS_MSDOS
64#ifndef OPENSSL_SYS_VMS
65#include OPENSSL_UNISTD 65#include OPENSSL_UNISTD
66#else /* VMS */ 66#else /* OPENSSL_SYS_VMS */
67#ifdef __DECC 67#ifdef __DECC
68#include <unistd.h> 68#include <unistd.h>
69#else /* not __DECC */ 69#else /* not __DECC */
70#include <math.h> 70#include <math.h>
71#endif /* __DECC */ 71#endif /* __DECC */
72#endif /* VMS */ 72#endif /* OPENSSL_SYS_VMS */
73#else /* MSDOS */ 73#else /* OPENSSL_SYS_MSDOS */
74#include <io.h> 74#include <io.h>
75#endif 75#endif
76 76
77#include <time.h> 77#include <time.h>
78#include "des_ver.h" 78#include "des_ver.h"
79 79
80#ifdef VMS 80#ifdef OPENSSL_SYS_VMS
81#include <types.h> 81#include <types.h>
82#include <stat.h> 82#include <stat.h>
83#else 83#else
@@ -88,6 +88,7 @@
88#endif 88#endif
89#include <openssl/des.h> 89#include <openssl/des.h>
90#include <openssl/rand.h> 90#include <openssl/rand.h>
91#include <openssl/ui_compat.h>
91 92
92void usage(void); 93void usage(void);
93void doencryption(void); 94void doencryption(void);
@@ -96,10 +97,10 @@ void uufwriteEnd(FILE *fp);
96int uufread(unsigned char *out,int size,unsigned int num,FILE *fp); 97int uufread(unsigned char *out,int size,unsigned int num,FILE *fp);
97int uuencode(unsigned char *in,int num,unsigned char *out); 98int uuencode(unsigned char *in,int num,unsigned char *out);
98int uudecode(unsigned char *in,int num,unsigned char *out); 99int uudecode(unsigned char *in,int num,unsigned char *out);
99void des_3cbc_encrypt(des_cblock *input,des_cblock *output,long length, 100void DES_3cbc_encrypt(DES_cblock *input,DES_cblock *output,long length,
100 des_key_schedule sk1,des_key_schedule sk2, 101 DES_key_schedule sk1,DES_key_schedule sk2,
101 des_cblock *ivec1,des_cblock *ivec2,int enc); 102 DES_cblock *ivec1,DES_cblock *ivec2,int enc);
102#ifdef VMS 103#ifdef OPENSSL_SYS_VMS
103#define EXIT(a) exit(a&0x10000000L) 104#define EXIT(a) exit(a&0x10000000L)
104#else 105#else
105#define EXIT(a) exit(a) 106#define EXIT(a) exit(a)
@@ -119,7 +120,7 @@ int uubufnum=0;
119#define OUTUUBUF (65*100) 120#define OUTUUBUF (65*100)
120unsigned char b[OUTUUBUF]; 121unsigned char b[OUTUUBUF];
121unsigned char bb[300]; 122unsigned char bb[300];
122des_cblock cksum={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; 123DES_cblock cksum={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
123char cksumname[200]=""; 124char cksumname[200]="";
124 125
125int vflag,cflag,eflag,dflag,kflag,bflag,fflag,sflag,uflag,flag3,hflag,error; 126int vflag,cflag,eflag,dflag,kflag,bflag,fflag,sflag,uflag,flag3,hflag,error;
@@ -152,12 +153,14 @@ int main(int argc, char **argv)
152 case 'c': 153 case 'c':
153 cflag=1; 154 cflag=1;
154 strncpy(cksumname,p,200); 155 strncpy(cksumname,p,200);
156 cksumname[sizeof(cksumname)-1]='\0';
155 p+=strlen(cksumname); 157 p+=strlen(cksumname);
156 break; 158 break;
157 case 'C': 159 case 'C':
158 cflag=1; 160 cflag=1;
159 longk=1; 161 longk=1;
160 strncpy(cksumname,p,200); 162 strncpy(cksumname,p,200);
163 cksumname[sizeof(cksumname)-1]='\0';
161 p+=strlen(cksumname); 164 p+=strlen(cksumname);
162 break; 165 break;
163 case 'e': 166 case 'e':
@@ -189,6 +192,7 @@ int main(int argc, char **argv)
189 case 'u': 192 case 'u':
190 uflag=1; 193 uflag=1;
191 strncpy(uuname,p,200); 194 strncpy(uuname,p,200);
195 uuname[sizeof(uuname)-1]='\0';
192 p+=strlen(uuname); 196 p+=strlen(uuname);
193 break; 197 break;
194 case 'h': 198 case 'h':
@@ -258,12 +262,12 @@ int main(int argc, char **argv)
258#endif 262#endif
259 if ( (in != NULL) && 263 if ( (in != NULL) &&
260 (out != NULL) && 264 (out != NULL) &&
261#ifndef MSDOS 265#ifndef OPENSSL_SYS_MSDOS
262 (stat(in,&ins) != -1) && 266 (stat(in,&ins) != -1) &&
263 (stat(out,&outs) != -1) && 267 (stat(out,&outs) != -1) &&
264 (ins.st_dev == outs.st_dev) && 268 (ins.st_dev == outs.st_dev) &&
265 (ins.st_ino == outs.st_ino)) 269 (ins.st_ino == outs.st_ino))
266#else /* MSDOS */ 270#else /* OPENSSL_SYS_MSDOS */
267 (strcmp(in,out) == 0)) 271 (strcmp(in,out) == 0))
268#endif 272#endif
269 { 273 {
@@ -298,7 +302,7 @@ int main(int argc, char **argv)
298 EXIT(5); 302 EXIT(5);
299 } 303 }
300 304
301#ifdef MSDOS 305#ifdef OPENSSL_SYS_MSDOS
302 /* This should set the file to binary mode. */ 306 /* This should set the file to binary mode. */
303 { 307 {
304#include <fcntl.h> 308#include <fcntl.h>
@@ -360,14 +364,14 @@ void doencryption(void)
360#endif 364#endif
361 365
362 register int i; 366 register int i;
363 des_key_schedule ks,ks2; 367 DES_key_schedule ks,ks2;
364 des_cblock iv,iv2; 368 DES_cblock iv,iv2;
365 char *p; 369 char *p;
366 int num=0,j,k,l,rem,ll,len,last,ex=0; 370 int num=0,j,k,l,rem,ll,len,last,ex=0;
367 des_cblock kk,k2; 371 DES_cblock kk,k2;
368 FILE *O; 372 FILE *O;
369 int Exit=0; 373 int Exit=0;
370#ifndef MSDOS 374#ifndef OPENSSL_SYS_MSDOS
371 static unsigned char buf[BUFSIZE+8],obuf[BUFSIZE+8]; 375 static unsigned char buf[BUFSIZE+8],obuf[BUFSIZE+8];
372#else 376#else
373 static unsigned char *buf=NULL,*obuf=NULL; 377 static unsigned char *buf=NULL,*obuf=NULL;
@@ -422,19 +426,19 @@ void doencryption(void)
422 else 426 else
423 k2[i-8]=k; 427 k2[i-8]=k;
424 } 428 }
425 des_set_key_unchecked(&k2,ks2); 429 DES_set_key_unchecked(&k2,&ks2);
426 memset(k2,0,sizeof(k2)); 430 memset(k2,0,sizeof(k2));
427 } 431 }
428 else if (longk || flag3) 432 else if (longk || flag3)
429 { 433 {
430 if (flag3) 434 if (flag3)
431 { 435 {
432 des_string_to_2keys(key,&kk,&k2); 436 DES_string_to_2keys(key,&kk,&k2);
433 des_set_key_unchecked(&k2,ks2); 437 DES_set_key_unchecked(&k2,&ks2);
434 memset(k2,0,sizeof(k2)); 438 memset(k2,0,sizeof(k2));
435 } 439 }
436 else 440 else
437 des_string_to_key(key,&kk); 441 DES_string_to_key(key,&kk);
438 } 442 }
439 else 443 else
440 for (i=0; i<KEYSIZ; i++) 444 for (i=0; i<KEYSIZ; i++)
@@ -452,7 +456,7 @@ void doencryption(void)
452 kk[i]=key[i]|0x80; 456 kk[i]=key[i]|0x80;
453 } 457 }
454 458
455 des_set_key_unchecked(&kk,ks); 459 DES_set_key_unchecked(&kk,&ks);
456 memset(key,0,sizeof(key)); 460 memset(key,0,sizeof(key));
457 memset(kk,0,sizeof(kk)); 461 memset(kk,0,sizeof(kk));
458 /* woops - A bug that does not showup under unix :-( */ 462 /* woops - A bug that does not showup under unix :-( */
@@ -491,8 +495,8 @@ void doencryption(void)
491 495
492 if (cflag) 496 if (cflag)
493 { 497 {
494 des_cbc_cksum(buf,&cksum, 498 DES_cbc_cksum(buf,&cksum,
495 (long)len,ks,&cksum); 499 (long)len,&ks,&cksum);
496 if (!eflag) 500 if (!eflag)
497 { 501 {
498 if (feof(DES_IN)) break; 502 if (feof(DES_IN)) break;
@@ -502,24 +506,24 @@ void doencryption(void)
502 506
503 if (bflag && !flag3) 507 if (bflag && !flag3)
504 for (i=0; i<l; i+=8) 508 for (i=0; i<l; i+=8)
505 des_ecb_encrypt( 509 DES_ecb_encrypt(
506 (des_cblock *)&(buf[i]), 510 (DES_cblock *)&(buf[i]),
507 (des_cblock *)&(obuf[i]), 511 (DES_cblock *)&(obuf[i]),
508 ks,do_encrypt); 512 &ks,do_encrypt);
509 else if (flag3 && bflag) 513 else if (flag3 && bflag)
510 for (i=0; i<l; i+=8) 514 for (i=0; i<l; i+=8)
511 des_ecb2_encrypt( 515 DES_ecb2_encrypt(
512 (des_cblock *)&(buf[i]), 516 (DES_cblock *)&(buf[i]),
513 (des_cblock *)&(obuf[i]), 517 (DES_cblock *)&(obuf[i]),
514 ks,ks2,do_encrypt); 518 &ks,&ks2,do_encrypt);
515 else if (flag3 && !bflag) 519 else if (flag3 && !bflag)
516 { 520 {
517 char tmpbuf[8]; 521 char tmpbuf[8];
518 522
519 if (rem) memcpy(tmpbuf,&(buf[l]), 523 if (rem) memcpy(tmpbuf,&(buf[l]),
520 (unsigned int)rem); 524 (unsigned int)rem);
521 des_3cbc_encrypt( 525 DES_3cbc_encrypt(
522 (des_cblock *)buf,(des_cblock *)obuf, 526 (DES_cblock *)buf,(DES_cblock *)obuf,
523 (long)l,ks,ks2,&iv, 527 (long)l,ks,ks2,&iv,
524 &iv2,do_encrypt); 528 &iv2,do_encrypt);
525 if (rem) memcpy(&(buf[l]),tmpbuf, 529 if (rem) memcpy(&(buf[l]),tmpbuf,
@@ -527,9 +531,9 @@ void doencryption(void)
527 } 531 }
528 else 532 else
529 { 533 {
530 des_cbc_encrypt( 534 DES_cbc_encrypt(
531 buf,obuf, 535 buf,obuf,
532 (long)l,ks,&iv,do_encrypt); 536 (long)l,&ks,&iv,do_encrypt);
533 if (l >= 8) memcpy(iv,&(obuf[l-8]),8); 537 if (l >= 8) memcpy(iv,&(obuf[l-8]),8);
534 } 538 }
535 if (rem) memcpy(buf,&(buf[l]),(unsigned int)rem); 539 if (rem) memcpy(buf,&(buf[l]),(unsigned int)rem);
@@ -581,28 +585,28 @@ void doencryption(void)
581 585
582 if (bflag && !flag3) 586 if (bflag && !flag3)
583 for (i=0; i<l; i+=8) 587 for (i=0; i<l; i+=8)
584 des_ecb_encrypt( 588 DES_ecb_encrypt(
585 (des_cblock *)&(buf[i]), 589 (DES_cblock *)&(buf[i]),
586 (des_cblock *)&(obuf[i]), 590 (DES_cblock *)&(obuf[i]),
587 ks,do_encrypt); 591 &ks,do_encrypt);
588 else if (flag3 && bflag) 592 else if (flag3 && bflag)
589 for (i=0; i<l; i+=8) 593 for (i=0; i<l; i+=8)
590 des_ecb2_encrypt( 594 DES_ecb2_encrypt(
591 (des_cblock *)&(buf[i]), 595 (DES_cblock *)&(buf[i]),
592 (des_cblock *)&(obuf[i]), 596 (DES_cblock *)&(obuf[i]),
593 ks,ks2,do_encrypt); 597 &ks,&ks2,do_encrypt);
594 else if (flag3 && !bflag) 598 else if (flag3 && !bflag)
595 { 599 {
596 des_3cbc_encrypt( 600 DES_3cbc_encrypt(
597 (des_cblock *)buf,(des_cblock *)obuf, 601 (DES_cblock *)buf,(DES_cblock *)obuf,
598 (long)l,ks,ks2,&iv, 602 (long)l,ks,ks2,&iv,
599 &iv2,do_encrypt); 603 &iv2,do_encrypt);
600 } 604 }
601 else 605 else
602 { 606 {
603 des_cbc_encrypt( 607 DES_cbc_encrypt(
604 buf,obuf, 608 buf,obuf,
605 (long)l,ks,&iv,do_encrypt); 609 (long)l,&ks,&iv,do_encrypt);
606 if (l >= 8) memcpy(iv,&(buf[l-8]),8); 610 if (l >= 8) memcpy(iv,&(buf[l-8]),8);
607 } 611 }
608 612
@@ -627,9 +631,9 @@ void doencryption(void)
627 l=l-8+last; 631 l=l-8+last;
628 } 632 }
629 i=0; 633 i=0;
630 if (cflag) des_cbc_cksum(obuf, 634 if (cflag) DES_cbc_cksum(obuf,
631 (des_cblock *)cksum,(long)l/8*8,ks, 635 (DES_cblock *)cksum,(long)l/8*8,&ks,
632 (des_cblock *)cksum); 636 (DES_cblock *)cksum);
633 while (i != l) 637 while (i != l)
634 { 638 {
635 j=fwrite(obuf,1,(unsigned int)l-i,DES_OUT); 639 j=fwrite(obuf,1,(unsigned int)l-i,DES_OUT);
@@ -664,8 +668,8 @@ void doencryption(void)
664problems: 668problems:
665 memset(buf,0,sizeof(buf)); 669 memset(buf,0,sizeof(buf));
666 memset(obuf,0,sizeof(obuf)); 670 memset(obuf,0,sizeof(obuf));
667 memset(ks,0,sizeof(ks)); 671 memset(&ks,0,sizeof(ks));
668 memset(ks2,0,sizeof(ks2)); 672 memset(&ks2,0,sizeof(ks2));
669 memset(iv,0,sizeof(iv)); 673 memset(iv,0,sizeof(iv));
670 memset(iv2,0,sizeof(iv2)); 674 memset(iv2,0,sizeof(iv2));
671 memset(kk,0,sizeof(kk)); 675 memset(kk,0,sizeof(kk));
diff --git a/src/lib/libcrypto/des/des.h b/src/lib/libcrypto/des/des.h
index 6b8a7ee11b..dfe5ff64e4 100644
--- a/src/lib/libcrypto/des/des.h
+++ b/src/lib/libcrypto/des/des.h
@@ -59,39 +59,52 @@
59#ifndef HEADER_DES_H 59#ifndef HEADER_DES_H
60#define HEADER_DES_H 60#define HEADER_DES_H
61 61
62#ifdef NO_DES 62#ifdef OPENSSL_NO_DES
63#error DES is disabled. 63#error DES is disabled.
64#endif 64#endif
65 65
66#ifdef _KERBEROS_DES_H
67#error <openssl/des.h> replaces <kerberos/des.h>.
68#endif
69
70#include <openssl/opensslconf.h> /* DES_LONG */ 66#include <openssl/opensslconf.h> /* DES_LONG */
71#include <openssl/e_os2.h> /* OPENSSL_EXTERN */ 67#include <openssl/e_os2.h> /* OPENSSL_EXTERN */
72 68
69#ifdef OPENSSL_BUILD_SHLIBCRYPTO
70# undef OPENSSL_EXTERN
71# define OPENSSL_EXTERN OPENSSL_EXPORT
72#endif
73
74#define des_SPtrans DES_SPtrans
75
73#ifdef __cplusplus 76#ifdef __cplusplus
74extern "C" { 77extern "C" {
75#endif 78#endif
76 79
77typedef unsigned char des_cblock[8]; 80typedef unsigned char DES_cblock[8];
78typedef /* const */ unsigned char const_des_cblock[8]; 81typedef /* const */ unsigned char const_DES_cblock[8];
79/* With "const", gcc 2.8.1 on Solaris thinks that des_cblock * 82/* With "const", gcc 2.8.1 on Solaris thinks that DES_cblock *
80 * and const_des_cblock * are incompatible pointer types. */ 83 * and const_DES_cblock * are incompatible pointer types. */
81 84
82typedef struct des_ks_struct 85typedef struct DES_ks
86 {
87 union
83 { 88 {
84 union { 89 DES_cblock cblock;
85 des_cblock cblock; 90 /* make sure things are correct size on machines with
86 /* make sure things are correct size on machines with 91 * 8 byte longs */
87 * 8 byte longs */ 92 DES_LONG deslong[2];
88 DES_LONG deslong[2]; 93 } ks[16];
89 } ks; 94 } DES_key_schedule;
90 int weak_key; 95
91 } des_key_schedule[16]; 96#ifndef OPENSSL_DISABLE_OLD_DES_SUPPORT
97# ifndef OPENSSL_ENABLE_OLD_DES_SUPPORT
98# define OPENSSL_ENABLE_OLD_DES_SUPPORT
99# endif
100#endif
92 101
93#define DES_KEY_SZ (sizeof(des_cblock)) 102#ifdef OPENSSL_ENABLE_OLD_DES_SUPPORT
94#define DES_SCHEDULE_SZ (sizeof(des_key_schedule)) 103# include <openssl/des_old.h>
104#endif
105
106#define DES_KEY_SZ (sizeof(DES_cblock))
107#define DES_SCHEDULE_SZ (sizeof(DES_key_schedule))
95 108
96#define DES_ENCRYPT 1 109#define DES_ENCRYPT 1
97#define DES_DECRYPT 0 110#define DES_DECRYPT 0
@@ -99,44 +112,45 @@ typedef struct des_ks_struct
99#define DES_CBC_MODE 0 112#define DES_CBC_MODE 0
100#define DES_PCBC_MODE 1 113#define DES_PCBC_MODE 1
101 114
102#define des_ecb2_encrypt(i,o,k1,k2,e) \ 115#define DES_ecb2_encrypt(i,o,k1,k2,e) \
103 des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e)) 116 DES_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))
104 117
105#define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \ 118#define DES_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \
106 des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e)) 119 DES_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))
107 120
108#define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \ 121#define DES_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \
109 des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e)) 122 DES_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))
110 123
111#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \ 124#define DES_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \
112 des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n)) 125 DES_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))
113 126
114OPENSSL_EXTERN int des_check_key; /* defaults to false */ 127OPENSSL_DECLARE_GLOBAL(int,DES_check_key); /* defaults to false */
115OPENSSL_EXTERN int des_rw_mode; /* defaults to DES_PCBC_MODE */ 128#define DES_check_key OPENSSL_GLOBAL_REF(DES_check_key)
116OPENSSL_EXTERN int des_set_weak_key_flag; /* set the weak key flag */ 129OPENSSL_DECLARE_GLOBAL(int,DES_rw_mode); /* defaults to DES_PCBC_MODE */
117 130#define DES_rw_mode OPENSSL_GLOBAL_REF(DES_rw_mode)
118const char *des_options(void); 131
119void des_ecb3_encrypt(const_des_cblock *input, des_cblock *output, 132const char *DES_options(void);
120 des_key_schedule ks1,des_key_schedule ks2, 133void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output,
121 des_key_schedule ks3, int enc); 134 DES_key_schedule *ks1,DES_key_schedule *ks2,
122DES_LONG des_cbc_cksum(const unsigned char *input,des_cblock *output, 135 DES_key_schedule *ks3, int enc);
123 long length,des_key_schedule schedule, 136DES_LONG DES_cbc_cksum(const unsigned char *input,DES_cblock *output,
124 const_des_cblock *ivec); 137 long length,DES_key_schedule *schedule,
125/* des_cbc_encrypt does not update the IV! Use des_ncbc_encrypt instead. */ 138 const_DES_cblock *ivec);
126void des_cbc_encrypt(const unsigned char *input,unsigned char *output, 139/* DES_cbc_encrypt does not update the IV! Use DES_ncbc_encrypt instead. */
127 long length,des_key_schedule schedule,des_cblock *ivec, 140void DES_cbc_encrypt(const unsigned char *input,unsigned char *output,
141 long length,DES_key_schedule *schedule,DES_cblock *ivec,
128 int enc); 142 int enc);
129void des_ncbc_encrypt(const unsigned char *input,unsigned char *output, 143void DES_ncbc_encrypt(const unsigned char *input,unsigned char *output,
130 long length,des_key_schedule schedule,des_cblock *ivec, 144 long length,DES_key_schedule *schedule,DES_cblock *ivec,
131 int enc); 145 int enc);
132void des_xcbc_encrypt(const unsigned char *input,unsigned char *output, 146void DES_xcbc_encrypt(const unsigned char *input,unsigned char *output,
133 long length,des_key_schedule schedule,des_cblock *ivec, 147 long length,DES_key_schedule *schedule,DES_cblock *ivec,
134 const_des_cblock *inw,const_des_cblock *outw,int enc); 148 const_DES_cblock *inw,const_DES_cblock *outw,int enc);
135void des_cfb_encrypt(const unsigned char *in,unsigned char *out,int numbits, 149void DES_cfb_encrypt(const unsigned char *in,unsigned char *out,int numbits,
136 long length,des_key_schedule schedule,des_cblock *ivec, 150 long length,DES_key_schedule *schedule,DES_cblock *ivec,
137 int enc); 151 int enc);
138void des_ecb_encrypt(const_des_cblock *input,des_cblock *output, 152void DES_ecb_encrypt(const_DES_cblock *input,DES_cblock *output,
139 des_key_schedule ks,int enc); 153 DES_key_schedule *ks,int enc);
140 154
141/* This is the DES encryption function that gets called by just about 155/* This is the DES encryption function that gets called by just about
142 every other DES routine in the library. You should not use this 156 every other DES routine in the library. You should not use this
@@ -145,119 +159,81 @@ void des_ecb_encrypt(const_des_cblock *input,des_cblock *output,
145 long, and this needs to be done to make sure 'non-aligned' memory 159 long, and this needs to be done to make sure 'non-aligned' memory
146 access do not occur. The characters are loaded 'little endian'. 160 access do not occur. The characters are loaded 'little endian'.
147 Data is a pointer to 2 unsigned long's and ks is the 161 Data is a pointer to 2 unsigned long's and ks is the
148 des_key_schedule to use. enc, is non zero specifies encryption, 162 DES_key_schedule to use. enc, is non zero specifies encryption,
149 zero if decryption. */ 163 zero if decryption. */
150void des_encrypt1(DES_LONG *data,des_key_schedule ks, int enc); 164void DES_encrypt1(DES_LONG *data,DES_key_schedule *ks, int enc);
151 165
152/* This functions is the same as des_encrypt1() except that the DES 166/* This functions is the same as DES_encrypt1() except that the DES
153 initial permutation (IP) and final permutation (FP) have been left 167 initial permutation (IP) and final permutation (FP) have been left
154 out. As for des_encrypt1(), you should not use this function. 168 out. As for DES_encrypt1(), you should not use this function.
155 It is used by the routines in the library that implement triple DES. 169 It is used by the routines in the library that implement triple DES.
156 IP() des_encrypt2() des_encrypt2() des_encrypt2() FP() is the same 170 IP() DES_encrypt2() DES_encrypt2() DES_encrypt2() FP() is the same
157 as des_encrypt1() des_encrypt1() des_encrypt1() except faster :-). */ 171 as DES_encrypt1() DES_encrypt1() DES_encrypt1() except faster :-). */
158void des_encrypt2(DES_LONG *data,des_key_schedule ks, int enc); 172void DES_encrypt2(DES_LONG *data,DES_key_schedule *ks, int enc);
159 173
160void des_encrypt3(DES_LONG *data, des_key_schedule ks1, 174void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1,
161 des_key_schedule ks2, des_key_schedule ks3); 175 DES_key_schedule *ks2, DES_key_schedule *ks3);
162void des_decrypt3(DES_LONG *data, des_key_schedule ks1, 176void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1,
163 des_key_schedule ks2, des_key_schedule ks3); 177 DES_key_schedule *ks2, DES_key_schedule *ks3);
164void des_ede3_cbc_encrypt(const unsigned char *input,unsigned char *output, 178void DES_ede3_cbc_encrypt(const unsigned char *input,unsigned char *output,
165 long length, 179 long length,
166 des_key_schedule ks1,des_key_schedule ks2, 180 DES_key_schedule *ks1,DES_key_schedule *ks2,
167 des_key_schedule ks3,des_cblock *ivec,int enc); 181 DES_key_schedule *ks3,DES_cblock *ivec,int enc);
168void des_ede3_cbcm_encrypt(const unsigned char *in,unsigned char *out, 182void DES_ede3_cbcm_encrypt(const unsigned char *in,unsigned char *out,
169 long length, 183 long length,
170 des_key_schedule ks1,des_key_schedule ks2, 184 DES_key_schedule *ks1,DES_key_schedule *ks2,
171 des_key_schedule ks3, 185 DES_key_schedule *ks3,
172 des_cblock *ivec1,des_cblock *ivec2, 186 DES_cblock *ivec1,DES_cblock *ivec2,
173 int enc); 187 int enc);
174void des_ede3_cfb64_encrypt(const unsigned char *in,unsigned char *out, 188void DES_ede3_cfb64_encrypt(const unsigned char *in,unsigned char *out,
175 long length,des_key_schedule ks1, 189 long length,DES_key_schedule *ks1,
176 des_key_schedule ks2,des_key_schedule ks3, 190 DES_key_schedule *ks2,DES_key_schedule *ks3,
177 des_cblock *ivec,int *num,int enc); 191 DES_cblock *ivec,int *num,int enc);
178void des_ede3_ofb64_encrypt(const unsigned char *in,unsigned char *out, 192void DES_ede3_ofb64_encrypt(const unsigned char *in,unsigned char *out,
179 long length,des_key_schedule ks1, 193 long length,DES_key_schedule *ks1,
180 des_key_schedule ks2,des_key_schedule ks3, 194 DES_key_schedule *ks2,DES_key_schedule *ks3,
181 des_cblock *ivec,int *num); 195 DES_cblock *ivec,int *num);
182 196
183void des_xwhite_in2out(const_des_cblock *des_key,const_des_cblock *in_white, 197void DES_xwhite_in2out(const_DES_cblock *DES_key,const_DES_cblock *in_white,
184 des_cblock *out_white); 198 DES_cblock *out_white);
185 199
186int des_enc_read(int fd,void *buf,int len,des_key_schedule sched, 200int DES_enc_read(int fd,void *buf,int len,DES_key_schedule *sched,
187 des_cblock *iv); 201 DES_cblock *iv);
188int des_enc_write(int fd,const void *buf,int len,des_key_schedule sched, 202int DES_enc_write(int fd,const void *buf,int len,DES_key_schedule *sched,
189 des_cblock *iv); 203 DES_cblock *iv);
190char *des_fcrypt(const char *buf,const char *salt, char *ret); 204char *DES_fcrypt(const char *buf,const char *salt, char *ret);
191char *des_crypt(const char *buf,const char *salt); 205char *DES_crypt(const char *buf,const char *salt);
192#if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT) 206void DES_ofb_encrypt(const unsigned char *in,unsigned char *out,int numbits,
193char *crypt(const char *buf,const char *salt); 207 long length,DES_key_schedule *schedule,DES_cblock *ivec);
194#endif 208void DES_pcbc_encrypt(const unsigned char *input,unsigned char *output,
195void des_ofb_encrypt(const unsigned char *in,unsigned char *out,int numbits, 209 long length,DES_key_schedule *schedule,DES_cblock *ivec,
196 long length,des_key_schedule schedule,des_cblock *ivec);
197void des_pcbc_encrypt(const unsigned char *input,unsigned char *output,
198 long length,des_key_schedule schedule,des_cblock *ivec,
199 int enc); 210 int enc);
200DES_LONG des_quad_cksum(const unsigned char *input,des_cblock output[], 211DES_LONG DES_quad_cksum(const unsigned char *input,DES_cblock output[],
201 long length,int out_count,des_cblock *seed); 212 long length,int out_count,DES_cblock *seed);
202void des_random_seed(des_cblock *key); 213int DES_random_key(DES_cblock *ret);
203int des_random_key(des_cblock *ret); 214void DES_set_odd_parity(DES_cblock *key);
204int des_read_password(des_cblock *key,const char *prompt,int verify); 215int DES_check_key_parity(const_DES_cblock *key);
205int des_read_2passwords(des_cblock *key1,des_cblock *key2, 216int DES_is_weak_key(const_DES_cblock *key);
206 const char *prompt,int verify); 217/* DES_set_key (= set_key = DES_key_sched = key_sched) calls
207int des_read_pw_string(char *buf,int length,const char *prompt,int verify); 218 * DES_set_key_checked if global variable DES_check_key is set,
208void des_set_odd_parity(des_cblock *key); 219 * DES_set_key_unchecked otherwise. */
209int des_check_key_parity(const_des_cblock *key); 220int DES_set_key(const_DES_cblock *key,DES_key_schedule *schedule);
210int des_is_weak_key(const_des_cblock *key); 221int DES_key_sched(const_DES_cblock *key,DES_key_schedule *schedule);
211/* des_set_key (= set_key = des_key_sched = key_sched) calls 222int DES_set_key_checked(const_DES_cblock *key,DES_key_schedule *schedule);
212 * des_set_key_checked if global variable des_check_key is set, 223void DES_set_key_unchecked(const_DES_cblock *key,DES_key_schedule *schedule);
213 * des_set_key_unchecked otherwise. */ 224void DES_string_to_key(const char *str,DES_cblock *key);
214int des_set_key(const_des_cblock *key,des_key_schedule schedule); 225void DES_string_to_2keys(const char *str,DES_cblock *key1,DES_cblock *key2);
215int des_key_sched(const_des_cblock *key,des_key_schedule schedule); 226void DES_cfb64_encrypt(const unsigned char *in,unsigned char *out,long length,
216int des_set_key_checked(const_des_cblock *key,des_key_schedule schedule); 227 DES_key_schedule *schedule,DES_cblock *ivec,int *num,
217void des_set_key_unchecked(const_des_cblock *key,des_key_schedule schedule);
218void des_string_to_key(const char *str,des_cblock *key);
219void des_string_to_2keys(const char *str,des_cblock *key1,des_cblock *key2);
220void des_cfb64_encrypt(const unsigned char *in,unsigned char *out,long length,
221 des_key_schedule schedule,des_cblock *ivec,int *num,
222 int enc); 228 int enc);
223void des_ofb64_encrypt(const unsigned char *in,unsigned char *out,long length, 229void DES_ofb64_encrypt(const unsigned char *in,unsigned char *out,long length,
224 des_key_schedule schedule,des_cblock *ivec,int *num); 230 DES_key_schedule *schedule,DES_cblock *ivec,int *num);
225int des_read_pw(char *buf,char *buff,int size,const char *prompt,int verify);
226
227/* The following definitions provide compatibility with the MIT Kerberos
228 * library. The des_key_schedule structure is not binary compatible. */
229 231
230#define _KERBEROS_DES_H 232int DES_read_password(DES_cblock *key, const char *prompt, int verify);
231 233int DES_read_2passwords(DES_cblock *key1, DES_cblock *key2, const char *prompt,
232#define KRBDES_ENCRYPT DES_ENCRYPT 234 int verify);
233#define KRBDES_DECRYPT DES_DECRYPT
234
235#ifdef KERBEROS
236# define ENCRYPT DES_ENCRYPT
237# define DECRYPT DES_DECRYPT
238#endif
239
240#ifndef NCOMPAT
241# define C_Block des_cblock
242# define Key_schedule des_key_schedule
243# define KEY_SZ DES_KEY_SZ
244# define string_to_key des_string_to_key
245# define read_pw_string des_read_pw_string
246# define random_key des_random_key
247# define pcbc_encrypt des_pcbc_encrypt
248# define set_key des_set_key
249# define key_sched des_key_sched
250# define ecb_encrypt des_ecb_encrypt
251# define cbc_encrypt des_cbc_encrypt
252# define ncbc_encrypt des_ncbc_encrypt
253# define xcbc_encrypt des_xcbc_encrypt
254# define cbc_cksum des_cbc_cksum
255# define quad_cksum des_quad_cksum
256# define check_parity des_check_key_parity
257#endif
258 235
259typedef des_key_schedule bit_64; 236#define DES_fixup_key_parity DES_set_odd_parity
260#define des_fixup_key_parity des_set_odd_parity
261 237
262#ifdef __cplusplus 238#ifdef __cplusplus
263} 239}
diff --git a/src/lib/libcrypto/des/des_enc.c b/src/lib/libcrypto/des/des_enc.c
index 0bd9fa39bc..1c37ab96d3 100644
--- a/src/lib/libcrypto/des/des_enc.c
+++ b/src/lib/libcrypto/des/des_enc.c
@@ -58,11 +58,11 @@
58 58
59#include "des_locl.h" 59#include "des_locl.h"
60 60
61void des_encrypt1(DES_LONG *data, des_key_schedule ks, int enc) 61void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc)
62 { 62 {
63 register DES_LONG l,r,t,u; 63 register DES_LONG l,r,t,u;
64#ifdef DES_PTR 64#ifdef DES_PTR
65 register const unsigned char *des_SP=(const unsigned char *)des_SPtrans; 65 register const unsigned char *des_SP=(const unsigned char *)DES_SPtrans;
66#endif 66#endif
67#ifndef DES_UNROLL 67#ifndef DES_UNROLL
68 register int i; 68 register int i;
@@ -75,7 +75,7 @@ void des_encrypt1(DES_LONG *data, des_key_schedule ks, int enc)
75 IP(r,l); 75 IP(r,l);
76 /* Things have been modified so that the initial rotate is 76 /* Things have been modified so that the initial rotate is
77 * done outside the loop. This required the 77 * done outside the loop. This required the
78 * des_SPtrans values in sp.h to be rotated 1 bit to the right. 78 * DES_SPtrans values in sp.h to be rotated 1 bit to the right.
79 * One perl script later and things have a 5% speed up on a sparc2. 79 * One perl script later and things have a 5% speed up on a sparc2.
80 * Thanks to Richard Outerbridge <71755.204@CompuServe.COM> 80 * Thanks to Richard Outerbridge <71755.204@CompuServe.COM>
81 * for pointing this out. */ 81 * for pointing this out. */
@@ -84,7 +84,7 @@ void des_encrypt1(DES_LONG *data, des_key_schedule ks, int enc)
84 r=ROTATE(r,29)&0xffffffffL; 84 r=ROTATE(r,29)&0xffffffffL;
85 l=ROTATE(l,29)&0xffffffffL; 85 l=ROTATE(l,29)&0xffffffffL;
86 86
87 s=ks->ks.deslong; 87 s=ks->ks->deslong;
88 /* I don't know if it is worth the effort of loop unrolling the 88 /* I don't know if it is worth the effort of loop unrolling the
89 * inner loop */ 89 * inner loop */
90 if (enc) 90 if (enc)
@@ -156,11 +156,11 @@ void des_encrypt1(DES_LONG *data, des_key_schedule ks, int enc)
156 l=r=t=u=0; 156 l=r=t=u=0;
157 } 157 }
158 158
159void des_encrypt2(DES_LONG *data, des_key_schedule ks, int enc) 159void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc)
160 { 160 {
161 register DES_LONG l,r,t,u; 161 register DES_LONG l,r,t,u;
162#ifdef DES_PTR 162#ifdef DES_PTR
163 register const unsigned char *des_SP=(const unsigned char *)des_SPtrans; 163 register const unsigned char *des_SP=(const unsigned char *)DES_SPtrans;
164#endif 164#endif
165#ifndef DES_UNROLL 165#ifndef DES_UNROLL
166 register int i; 166 register int i;
@@ -172,7 +172,7 @@ void des_encrypt2(DES_LONG *data, des_key_schedule ks, int enc)
172 172
173 /* Things have been modified so that the initial rotate is 173 /* Things have been modified so that the initial rotate is
174 * done outside the loop. This required the 174 * done outside the loop. This required the
175 * des_SPtrans values in sp.h to be rotated 1 bit to the right. 175 * DES_SPtrans values in sp.h to be rotated 1 bit to the right.
176 * One perl script later and things have a 5% speed up on a sparc2. 176 * One perl script later and things have a 5% speed up on a sparc2.
177 * Thanks to Richard Outerbridge <71755.204@CompuServe.COM> 177 * Thanks to Richard Outerbridge <71755.204@CompuServe.COM>
178 * for pointing this out. */ 178 * for pointing this out. */
@@ -180,7 +180,7 @@ void des_encrypt2(DES_LONG *data, des_key_schedule ks, int enc)
180 r=ROTATE(r,29)&0xffffffffL; 180 r=ROTATE(r,29)&0xffffffffL;
181 l=ROTATE(l,29)&0xffffffffL; 181 l=ROTATE(l,29)&0xffffffffL;
182 182
183 s=ks->ks.deslong; 183 s=ks->ks->deslong;
184 /* I don't know if it is worth the effort of loop unrolling the 184 /* I don't know if it is worth the effort of loop unrolling the
185 * inner loop */ 185 * inner loop */
186 if (enc) 186 if (enc)
@@ -247,8 +247,8 @@ void des_encrypt2(DES_LONG *data, des_key_schedule ks, int enc)
247 l=r=t=u=0; 247 l=r=t=u=0;
248 } 248 }
249 249
250void des_encrypt3(DES_LONG *data, des_key_schedule ks1, des_key_schedule ks2, 250void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1,
251 des_key_schedule ks3) 251 DES_key_schedule *ks2, DES_key_schedule *ks3)
252 { 252 {
253 register DES_LONG l,r; 253 register DES_LONG l,r;
254 254
@@ -257,9 +257,9 @@ void des_encrypt3(DES_LONG *data, des_key_schedule ks1, des_key_schedule ks2,
257 IP(l,r); 257 IP(l,r);
258 data[0]=l; 258 data[0]=l;
259 data[1]=r; 259 data[1]=r;
260 des_encrypt2((DES_LONG *)data,ks1,DES_ENCRYPT); 260 DES_encrypt2((DES_LONG *)data,ks1,DES_ENCRYPT);
261 des_encrypt2((DES_LONG *)data,ks2,DES_DECRYPT); 261 DES_encrypt2((DES_LONG *)data,ks2,DES_DECRYPT);
262 des_encrypt2((DES_LONG *)data,ks3,DES_ENCRYPT); 262 DES_encrypt2((DES_LONG *)data,ks3,DES_ENCRYPT);
263 l=data[0]; 263 l=data[0];
264 r=data[1]; 264 r=data[1];
265 FP(r,l); 265 FP(r,l);
@@ -267,8 +267,8 @@ void des_encrypt3(DES_LONG *data, des_key_schedule ks1, des_key_schedule ks2,
267 data[1]=r; 267 data[1]=r;
268 } 268 }
269 269
270void des_decrypt3(DES_LONG *data, des_key_schedule ks1, des_key_schedule ks2, 270void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1,
271 des_key_schedule ks3) 271 DES_key_schedule *ks2, DES_key_schedule *ks3)
272 { 272 {
273 register DES_LONG l,r; 273 register DES_LONG l,r;
274 274
@@ -277,9 +277,9 @@ void des_decrypt3(DES_LONG *data, des_key_schedule ks1, des_key_schedule ks2,
277 IP(l,r); 277 IP(l,r);
278 data[0]=l; 278 data[0]=l;
279 data[1]=r; 279 data[1]=r;
280 des_encrypt2((DES_LONG *)data,ks3,DES_DECRYPT); 280 DES_encrypt2((DES_LONG *)data,ks3,DES_DECRYPT);
281 des_encrypt2((DES_LONG *)data,ks2,DES_ENCRYPT); 281 DES_encrypt2((DES_LONG *)data,ks2,DES_ENCRYPT);
282 des_encrypt2((DES_LONG *)data,ks1,DES_DECRYPT); 282 DES_encrypt2((DES_LONG *)data,ks1,DES_DECRYPT);
283 l=data[0]; 283 l=data[0];
284 r=data[1]; 284 r=data[1];
285 FP(r,l); 285 FP(r,l);
@@ -290,11 +290,12 @@ void des_decrypt3(DES_LONG *data, des_key_schedule ks1, des_key_schedule ks2,
290#ifndef DES_DEFAULT_OPTIONS 290#ifndef DES_DEFAULT_OPTIONS
291 291
292#undef CBC_ENC_C__DONT_UPDATE_IV 292#undef CBC_ENC_C__DONT_UPDATE_IV
293#include "ncbc_enc.c" /* des_ncbc_encrypt */ 293#include "ncbc_enc.c" /* DES_ncbc_encrypt */
294 294
295void des_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output, 295void DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,
296 long length, des_key_schedule ks1, des_key_schedule ks2, 296 long length, DES_key_schedule *ks1,
297 des_key_schedule ks3, des_cblock *ivec, int enc) 297 DES_key_schedule *ks2, DES_key_schedule *ks3,
298 DES_cblock *ivec, int enc)
298 { 299 {
299 register DES_LONG tin0,tin1; 300 register DES_LONG tin0,tin1;
300 register DES_LONG tout0,tout1,xor0,xor1; 301 register DES_LONG tout0,tout1,xor0,xor1;
@@ -321,7 +322,7 @@ void des_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,
321 322
322 tin[0]=tin0; 323 tin[0]=tin0;
323 tin[1]=tin1; 324 tin[1]=tin1;
324 des_encrypt3((DES_LONG *)tin,ks1,ks2,ks3); 325 DES_encrypt3((DES_LONG *)tin,ks1,ks2,ks3);
325 tout0=tin[0]; 326 tout0=tin[0];
326 tout1=tin[1]; 327 tout1=tin[1];
327 328
@@ -336,7 +337,7 @@ void des_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,
336 337
337 tin[0]=tin0; 338 tin[0]=tin0;
338 tin[1]=tin1; 339 tin[1]=tin1;
339 des_encrypt3((DES_LONG *)tin,ks1,ks2,ks3); 340 DES_encrypt3((DES_LONG *)tin,ks1,ks2,ks3);
340 tout0=tin[0]; 341 tout0=tin[0];
341 tout1=tin[1]; 342 tout1=tin[1];
342 343
@@ -363,7 +364,7 @@ void des_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,
363 364
364 tin[0]=tin0; 365 tin[0]=tin0;
365 tin[1]=tin1; 366 tin[1]=tin1;
366 des_decrypt3((DES_LONG *)tin,ks1,ks2,ks3); 367 DES_decrypt3((DES_LONG *)tin,ks1,ks2,ks3);
367 tout0=tin[0]; 368 tout0=tin[0];
368 tout1=tin[1]; 369 tout1=tin[1];
369 370
@@ -384,7 +385,7 @@ void des_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,
384 385
385 tin[0]=tin0; 386 tin[0]=tin0;
386 tin[1]=tin1; 387 tin[1]=tin1;
387 des_decrypt3((DES_LONG *)tin,ks1,ks2,ks3); 388 DES_decrypt3((DES_LONG *)tin,ks1,ks2,ks3);
388 tout0=tin[0]; 389 tout0=tin[0];
389 tout1=tin[1]; 390 tout1=tin[1];
390 391
diff --git a/src/lib/libcrypto/des/des_locl.h b/src/lib/libcrypto/des/des_locl.h
index 1ace8f5930..70e833be3f 100644
--- a/src/lib/libcrypto/des/des_locl.h
+++ b/src/lib/libcrypto/des/des_locl.h
@@ -59,19 +59,19 @@
59#ifndef HEADER_DES_LOCL_H 59#ifndef HEADER_DES_LOCL_H
60#define HEADER_DES_LOCL_H 60#define HEADER_DES_LOCL_H
61 61
62#if defined(WIN32) || defined(WIN16) 62#include <openssl/e_os2.h>
63#ifndef MSDOS 63
64#define MSDOS 64#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN16)
65#ifndef OPENSSL_SYS_MSDOS
66#define OPENSSL_SYS_MSDOS
65#endif 67#endif
66#endif 68#endif
67 69
68#include <stdio.h> 70#include <stdio.h>
69#include <stdlib.h> 71#include <stdlib.h>
70 72
71#include <openssl/opensslconf.h> 73#ifndef OPENSSL_SYS_MSDOS
72 74#if !defined(OPENSSL_SYS_VMS) || defined(__DECC)
73#ifndef MSDOS
74#if !defined(VMS) || defined(__DECC)
75#ifdef OPENSSL_UNISTD 75#ifdef OPENSSL_UNISTD
76# include OPENSSL_UNISTD 76# include OPENSSL_UNISTD
77#else 77#else
@@ -82,17 +82,22 @@
82#endif 82#endif
83#include <openssl/des.h> 83#include <openssl/des.h>
84 84
85#ifdef MSDOS /* Visual C++ 2.1 (Windows NT/95) */ 85#ifdef OPENSSL_SYS_MSDOS /* Visual C++ 2.1 (Windows NT/95) */
86#include <stdlib.h> 86#include <stdlib.h>
87#include <errno.h> 87#include <errno.h>
88#include <time.h> 88#include <time.h>
89#include <io.h> 89#include <io.h>
90#endif 90#endif
91 91
92#if defined(__STDC__) || defined(VMS) || defined(M_XENIX) || defined(MSDOS) 92#if defined(__STDC__) || defined(OPENSSL_SYS_VMS) || defined(M_XENIX) || defined(OPENSSL_SYS_MSDOS)
93#include <string.h> 93#include <string.h>
94#endif 94#endif
95 95
96#ifdef OPENSSL_BUILD_SHLIBCRYPTO
97# undef OPENSSL_EXTERN
98# define OPENSSL_EXTERN OPENSSL_EXPORT
99#endif
100
96#define ITERATIONS 16 101#define ITERATIONS 16
97#define HALF_ITERATIONS 8 102#define HALF_ITERATIONS 8
98 103
@@ -155,7 +160,7 @@
155 } \ 160 } \
156 } 161 }
157 162
158#if defined(WIN32) && defined(_MSC_VER) 163#if defined(OPENSSL_SYS_WIN32) && defined(_MSC_VER)
159#define ROTATE(a,n) (_lrotr(a,n)) 164#define ROTATE(a,n) (_lrotr(a,n))
160#else 165#else
161#define ROTATE(a,n) (((a)>>(n))+((a)<<(32-(n)))) 166#define ROTATE(a,n) (((a)>>(n))+((a)<<(32-(n))))
@@ -278,24 +283,24 @@
278 u1=(int)u&0x3f; \ 283 u1=(int)u&0x3f; \
279 u2&=0x3f; \ 284 u2&=0x3f; \
280 u>>=16L; \ 285 u>>=16L; \
281 LL^=des_SPtrans[0][u1]; \ 286 LL^=DES_SPtrans[0][u1]; \
282 LL^=des_SPtrans[2][u2]; \ 287 LL^=DES_SPtrans[2][u2]; \
283 u3=(int)u>>8L; \ 288 u3=(int)u>>8L; \
284 u1=(int)u&0x3f; \ 289 u1=(int)u&0x3f; \
285 u3&=0x3f; \ 290 u3&=0x3f; \
286 LL^=des_SPtrans[4][u1]; \ 291 LL^=DES_SPtrans[4][u1]; \
287 LL^=des_SPtrans[6][u3]; \ 292 LL^=DES_SPtrans[6][u3]; \
288 u2=(int)t>>8L; \ 293 u2=(int)t>>8L; \
289 u1=(int)t&0x3f; \ 294 u1=(int)t&0x3f; \
290 u2&=0x3f; \ 295 u2&=0x3f; \
291 t>>=16L; \ 296 t>>=16L; \
292 LL^=des_SPtrans[1][u1]; \ 297 LL^=DES_SPtrans[1][u1]; \
293 LL^=des_SPtrans[3][u2]; \ 298 LL^=DES_SPtrans[3][u2]; \
294 u3=(int)t>>8L; \ 299 u3=(int)t>>8L; \
295 u1=(int)t&0x3f; \ 300 u1=(int)t&0x3f; \
296 u3&=0x3f; \ 301 u3&=0x3f; \
297 LL^=des_SPtrans[5][u1]; \ 302 LL^=DES_SPtrans[5][u1]; \
298 LL^=des_SPtrans[7][u3]; } 303 LL^=DES_SPtrans[7][u3]; }
299#endif 304#endif
300#ifdef DES_RISC2 305#ifdef DES_RISC2
301#define D_ENCRYPT(LL,R,S) {\ 306#define D_ENCRYPT(LL,R,S) {\
@@ -306,25 +311,25 @@
306 u2=(int)u>>8L; \ 311 u2=(int)u>>8L; \
307 u1=(int)u&0x3f; \ 312 u1=(int)u&0x3f; \
308 u2&=0x3f; \ 313 u2&=0x3f; \
309 LL^=des_SPtrans[0][u1]; \ 314 LL^=DES_SPtrans[0][u1]; \
310 LL^=des_SPtrans[2][u2]; \ 315 LL^=DES_SPtrans[2][u2]; \
311 s1=(int)u>>16L; \ 316 s1=(int)u>>16L; \
312 s2=(int)u>>24L; \ 317 s2=(int)u>>24L; \
313 s1&=0x3f; \ 318 s1&=0x3f; \
314 s2&=0x3f; \ 319 s2&=0x3f; \
315 LL^=des_SPtrans[4][s1]; \ 320 LL^=DES_SPtrans[4][s1]; \
316 LL^=des_SPtrans[6][s2]; \ 321 LL^=DES_SPtrans[6][s2]; \
317 u2=(int)t>>8L; \ 322 u2=(int)t>>8L; \
318 u1=(int)t&0x3f; \ 323 u1=(int)t&0x3f; \
319 u2&=0x3f; \ 324 u2&=0x3f; \
320 LL^=des_SPtrans[1][u1]; \ 325 LL^=DES_SPtrans[1][u1]; \
321 LL^=des_SPtrans[3][u2]; \ 326 LL^=DES_SPtrans[3][u2]; \
322 s1=(int)t>>16; \ 327 s1=(int)t>>16; \
323 s2=(int)t>>24L; \ 328 s2=(int)t>>24L; \
324 s1&=0x3f; \ 329 s1&=0x3f; \
325 s2&=0x3f; \ 330 s2&=0x3f; \
326 LL^=des_SPtrans[5][s1]; \ 331 LL^=DES_SPtrans[5][s1]; \
327 LL^=des_SPtrans[7][s2]; } 332 LL^=DES_SPtrans[7][s2]; }
328#endif 333#endif
329 334
330#else 335#else
@@ -333,14 +338,14 @@
333 LOAD_DATA_tmp(R,S,u,t,E0,E1); \ 338 LOAD_DATA_tmp(R,S,u,t,E0,E1); \
334 t=ROTATE(t,4); \ 339 t=ROTATE(t,4); \
335 LL^=\ 340 LL^=\
336 des_SPtrans[0][(u>> 2L)&0x3f]^ \ 341 DES_SPtrans[0][(u>> 2L)&0x3f]^ \
337 des_SPtrans[2][(u>>10L)&0x3f]^ \ 342 DES_SPtrans[2][(u>>10L)&0x3f]^ \
338 des_SPtrans[4][(u>>18L)&0x3f]^ \ 343 DES_SPtrans[4][(u>>18L)&0x3f]^ \
339 des_SPtrans[6][(u>>26L)&0x3f]^ \ 344 DES_SPtrans[6][(u>>26L)&0x3f]^ \
340 des_SPtrans[1][(t>> 2L)&0x3f]^ \ 345 DES_SPtrans[1][(t>> 2L)&0x3f]^ \
341 des_SPtrans[3][(t>>10L)&0x3f]^ \ 346 DES_SPtrans[3][(t>>10L)&0x3f]^ \
342 des_SPtrans[5][(t>>18L)&0x3f]^ \ 347 DES_SPtrans[5][(t>>18L)&0x3f]^ \
343 des_SPtrans[7][(t>>26L)&0x3f]; } 348 DES_SPtrans[7][(t>>26L)&0x3f]; }
344#endif 349#endif
345#endif 350#endif
346 351
@@ -405,8 +410,8 @@
405 PERM_OP(l,r,tt, 4,0x0f0f0f0fL); \ 410 PERM_OP(l,r,tt, 4,0x0f0f0f0fL); \
406 } 411 }
407 412
408OPENSSL_EXTERN const DES_LONG des_SPtrans[8][64]; 413OPENSSL_EXTERN const DES_LONG DES_SPtrans[8][64];
409 414
410void fcrypt_body(DES_LONG *out,des_key_schedule ks, 415void fcrypt_body(DES_LONG *out,DES_key_schedule *ks,
411 DES_LONG Eswap0, DES_LONG Eswap1); 416 DES_LONG Eswap0, DES_LONG Eswap1);
412#endif 417#endif
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..3778f93c15
--- /dev/null
+++ b/src/lib/libcrypto/des/des_old.h
@@ -0,0 +1,437 @@
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)
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#define crypt(b,s)\
278 _ossl_old_crypt((b),(s))
279#define des_ofb_encrypt(i,o,n,l,k,iv)\
280 _ossl_old_des_ofb_encrypt((i),(o),(n),(l),(k),(iv))
281#define des_pcbc_encrypt(i,o,l,k,iv,e)\
282 _ossl_old_des_pcbc_encrypt((i),(o),(l),(k),(iv),(e))
283#define des_quad_cksum(i,o,l,c,s)\
284 _ossl_old_des_quad_cksum((i),(o),(l),(c),(s))
285#define des_random_seed(k)\
286 _ossl_old_des_random_seed((k))
287#define des_random_key(r)\
288 _ossl_old_des_random_key((r))
289#define des_read_password(k,p,v) \
290 _ossl_old_des_read_password((k),(p),(v))
291#define des_read_2passwords(k1,k2,p,v) \
292 _ossl_old_des_read_2passwords((k1),(k2),(p),(v))
293#define des_set_odd_parity(k)\
294 _ossl_old_des_set_odd_parity((k))
295#define des_is_weak_key(k)\
296 _ossl_old_des_is_weak_key((k))
297#define des_set_key(k,ks)\
298 _ossl_old_des_set_key((k),(ks))
299#define des_key_sched(k,ks)\
300 _ossl_old_des_key_sched((k),(ks))
301#define des_string_to_key(s,k)\
302 _ossl_old_des_string_to_key((s),(k))
303#define des_string_to_2keys(s,k1,k2)\
304 _ossl_old_des_string_to_2keys((s),(k1),(k2))
305#define des_cfb64_encrypt(i,o,l,ks,iv,n,e)\
306 _ossl_old_des_cfb64_encrypt((i),(o),(l),(ks),(iv),(n),(e))
307#define des_ofb64_encrypt(i,o,l,ks,iv,n)\
308 _ossl_old_des_ofb64_encrypt((i),(o),(l),(ks),(iv),(n))
309
310
311#define des_ecb2_encrypt(i,o,k1,k2,e) \
312 des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))
313
314#define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \
315 des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))
316
317#define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \
318 des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))
319
320#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \
321 des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))
322
323#define des_check_key DES_check_key
324#define des_rw_mode DES_rw_mode
325#endif
326
327const char *_ossl_old_des_options(void);
328void _ossl_old_des_ecb3_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,
329 _ossl_old_des_key_schedule ks1,_ossl_old_des_key_schedule ks2,
330 _ossl_old_des_key_schedule ks3, int enc);
331DES_LONG _ossl_old_des_cbc_cksum(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,
332 long length,_ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec);
333void _ossl_old_des_cbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length,
334 _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc);
335void _ossl_old_des_ncbc_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_xcbc_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,
339 _ossl_old_des_cblock *inw,_ossl_old_des_cblock *outw,int enc);
340void _ossl_old_des_cfb_encrypt(unsigned char *in,unsigned char *out,int numbits,
341 long length,_ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc);
342void _ossl_old_des_ecb_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,
343 _ossl_old_des_key_schedule ks,int enc);
344void _ossl_old_des_encrypt(DES_LONG *data,_ossl_old_des_key_schedule ks, int enc);
345void _ossl_old_des_encrypt2(DES_LONG *data,_ossl_old_des_key_schedule ks, int enc);
346void _ossl_old_des_encrypt3(DES_LONG *data, _ossl_old_des_key_schedule ks1,
347 _ossl_old_des_key_schedule ks2, _ossl_old_des_key_schedule ks3);
348void _ossl_old_des_decrypt3(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_ede3_cbc_encrypt(_ossl_old_des_cblock *input, _ossl_old_des_cblock *output,
351 long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2,
352 _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int enc);
353void _ossl_old_des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out,
354 long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2,
355 _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int *num, int enc);
356void _ossl_old_des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out,
357 long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2,
358 _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int *num);
359
360void _ossl_old_des_xwhite_in2out(_ossl_old_des_cblock (*des_key), _ossl_old_des_cblock (*in_white),
361 _ossl_old_des_cblock (*out_white));
362
363int _ossl_old_des_enc_read(int fd,char *buf,int len,_ossl_old_des_key_schedule sched,
364 _ossl_old_des_cblock *iv);
365int _ossl_old_des_enc_write(int fd,char *buf,int len,_ossl_old_des_key_schedule sched,
366 _ossl_old_des_cblock *iv);
367char *_ossl_old_des_fcrypt(const char *buf,const char *salt, char *ret);
368char *_ossl_old_des_crypt(const char *buf,const char *salt);
369#if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT)
370char *_ossl_old_crypt(const char *buf,const char *salt);
371#endif
372void _ossl_old_des_ofb_encrypt(unsigned char *in,unsigned char *out,
373 int numbits,long length,_ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec);
374void _ossl_old_des_pcbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length,
375 _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc);
376DES_LONG _ossl_old_des_quad_cksum(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,
377 long length,int out_count,_ossl_old_des_cblock *seed);
378void _ossl_old_des_random_seed(_ossl_old_des_cblock key);
379void _ossl_old_des_random_key(_ossl_old_des_cblock ret);
380int _ossl_old_des_read_password(_ossl_old_des_cblock *key,const char *prompt,int verify);
381int _ossl_old_des_read_2passwords(_ossl_old_des_cblock *key1,_ossl_old_des_cblock *key2,
382 const char *prompt,int verify);
383void _ossl_old_des_set_odd_parity(_ossl_old_des_cblock *key);
384int _ossl_old_des_is_weak_key(_ossl_old_des_cblock *key);
385int _ossl_old_des_set_key(_ossl_old_des_cblock *key,_ossl_old_des_key_schedule schedule);
386int _ossl_old_des_key_sched(_ossl_old_des_cblock *key,_ossl_old_des_key_schedule schedule);
387void _ossl_old_des_string_to_key(char *str,_ossl_old_des_cblock *key);
388void _ossl_old_des_string_to_2keys(char *str,_ossl_old_des_cblock *key1,_ossl_old_des_cblock *key2);
389void _ossl_old_des_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
390 _ossl_old_des_key_schedule schedule, _ossl_old_des_cblock *ivec, int *num, int enc);
391void _ossl_old_des_ofb64_encrypt(unsigned char *in, unsigned char *out, long length,
392 _ossl_old_des_key_schedule schedule, _ossl_old_des_cblock *ivec, int *num);
393
394void _ossl_096_des_random_seed(des_cblock *key);
395
396/* The following definitions provide compatibility with the MIT Kerberos
397 * library. The _ossl_old_des_key_schedule structure is not binary compatible. */
398
399#define _KERBEROS_DES_H
400
401#define KRBDES_ENCRYPT DES_ENCRYPT
402#define KRBDES_DECRYPT DES_DECRYPT
403
404#ifdef KERBEROS
405# define ENCRYPT DES_ENCRYPT
406# define DECRYPT DES_DECRYPT
407#endif
408
409#ifndef NCOMPAT
410# define C_Block des_cblock
411# define Key_schedule des_key_schedule
412# define KEY_SZ DES_KEY_SZ
413# define string_to_key des_string_to_key
414# define read_pw_string des_read_pw_string
415# define random_key des_random_key
416# define pcbc_encrypt des_pcbc_encrypt
417# define set_key des_set_key
418# define key_sched des_key_sched
419# define ecb_encrypt des_ecb_encrypt
420# define cbc_encrypt des_cbc_encrypt
421# define ncbc_encrypt des_ncbc_encrypt
422# define xcbc_encrypt des_xcbc_encrypt
423# define cbc_cksum des_cbc_cksum
424# define quad_cksum des_quad_cksum
425# define check_parity des_check_key_parity
426#endif
427
428#define des_fixup_key_parity DES_fixup_key_parity
429
430#ifdef __cplusplus
431}
432#endif
433
434/* for DES_read_pw_string et al */
435#include <openssl/ui_compat.h>
436
437#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
index 138ee1c6b4..79278b920e 100644
--- a/src/lib/libcrypto/des/des_opts.c
+++ b/src/lib/libcrypto/des/des_opts.c
@@ -59,12 +59,12 @@
59/* define PART1, PART2, PART3 or PART4 to build only with a few of the options. 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. */ 60 * This is for machines with 64k code segment size restrictions. */
61 61
62#if !defined(MSDOS) && (!defined(VMS) || defined(__DECC)) 62#if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX)
63#define TIMES 63#define TIMES
64#endif 64#endif
65 65
66#include <stdio.h> 66#include <stdio.h>
67#ifndef MSDOS 67#ifndef OPENSSL_SYS_MSDOS
68#include <openssl/e_os2.h> 68#include <openssl/e_os2.h>
69#include OPENSSL_UNISTD 69#include OPENSSL_UNISTD
70#else 70#else
@@ -84,7 +84,7 @@ extern void exit();
84 The __TMS macro will show if it was. If it wasn't defined, we should 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 85 undefine TIMES, since that tells the rest of the program how things
86 should be handled. -- Richard Levitte */ 86 should be handled. -- Richard Levitte */
87#if defined(VMS) && defined(__DECC) && !defined(__TMS) 87#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
88#undef TIMES 88#undef TIMES
89#endif 89#endif
90 90
@@ -118,10 +118,10 @@ extern void exit();
118#undef DES_RISC2 118#undef DES_RISC2
119#undef DES_PTR 119#undef DES_PTR
120#undef D_ENCRYPT 120#undef D_ENCRYPT
121#define des_encrypt1 des_encrypt_u4_cisc_idx 121#define DES_encrypt1 des_encrypt_u4_cisc_idx
122#define des_encrypt2 des_encrypt2_u4_cisc_idx 122#define DES_encrypt2 des_encrypt2_u4_cisc_idx
123#define des_encrypt3 des_encrypt3_u4_cisc_idx 123#define DES_encrypt3 des_encrypt3_u4_cisc_idx
124#define des_decrypt3 des_decrypt3_u4_cisc_idx 124#define DES_decrypt3 des_decrypt3_u4_cisc_idx
125#undef HEADER_DES_LOCL_H 125#undef HEADER_DES_LOCL_H
126#include "des_enc.c" 126#include "des_enc.c"
127 127
@@ -130,14 +130,14 @@ extern void exit();
130#undef DES_RISC2 130#undef DES_RISC2
131#undef DES_PTR 131#undef DES_PTR
132#undef D_ENCRYPT 132#undef D_ENCRYPT
133#undef des_encrypt1 133#undef DES_encrypt1
134#undef des_encrypt2 134#undef DES_encrypt2
135#undef des_encrypt3 135#undef DES_encrypt3
136#undef des_decrypt3 136#undef DES_decrypt3
137#define des_encrypt1 des_encrypt_u16_cisc_idx 137#define DES_encrypt1 des_encrypt_u16_cisc_idx
138#define des_encrypt2 des_encrypt2_u16_cisc_idx 138#define DES_encrypt2 des_encrypt2_u16_cisc_idx
139#define des_encrypt3 des_encrypt3_u16_cisc_idx 139#define DES_encrypt3 des_encrypt3_u16_cisc_idx
140#define des_decrypt3 des_decrypt3_u16_cisc_idx 140#define DES_decrypt3 des_decrypt3_u16_cisc_idx
141#undef HEADER_DES_LOCL_H 141#undef HEADER_DES_LOCL_H
142#include "des_enc.c" 142#include "des_enc.c"
143 143
@@ -146,14 +146,14 @@ extern void exit();
146#undef DES_RISC2 146#undef DES_RISC2
147#undef DES_PTR 147#undef DES_PTR
148#undef D_ENCRYPT 148#undef D_ENCRYPT
149#undef des_encrypt1 149#undef DES_encrypt1
150#undef des_encrypt2 150#undef DES_encrypt2
151#undef des_encrypt3 151#undef DES_encrypt3
152#undef des_decrypt3 152#undef DES_decrypt3
153#define des_encrypt1 des_encrypt_u4_risc1_idx 153#define DES_encrypt1 des_encrypt_u4_risc1_idx
154#define des_encrypt2 des_encrypt2_u4_risc1_idx 154#define DES_encrypt2 des_encrypt2_u4_risc1_idx
155#define des_encrypt3 des_encrypt3_u4_risc1_idx 155#define DES_encrypt3 des_encrypt3_u4_risc1_idx
156#define des_decrypt3 des_decrypt3_u4_risc1_idx 156#define DES_decrypt3 des_decrypt3_u4_risc1_idx
157#undef HEADER_DES_LOCL_H 157#undef HEADER_DES_LOCL_H
158#include "des_enc.c" 158#include "des_enc.c"
159 159
@@ -166,14 +166,14 @@ extern void exit();
166#define DES_RISC2 166#define DES_RISC2
167#undef DES_PTR 167#undef DES_PTR
168#undef D_ENCRYPT 168#undef D_ENCRYPT
169#undef des_encrypt1 169#undef DES_encrypt1
170#undef des_encrypt2 170#undef DES_encrypt2
171#undef des_encrypt3 171#undef DES_encrypt3
172#undef des_decrypt3 172#undef DES_decrypt3
173#define des_encrypt1 des_encrypt_u4_risc2_idx 173#define DES_encrypt1 des_encrypt_u4_risc2_idx
174#define des_encrypt2 des_encrypt2_u4_risc2_idx 174#define DES_encrypt2 des_encrypt2_u4_risc2_idx
175#define des_encrypt3 des_encrypt3_u4_risc2_idx 175#define DES_encrypt3 des_encrypt3_u4_risc2_idx
176#define des_decrypt3 des_decrypt3_u4_risc2_idx 176#define DES_decrypt3 des_decrypt3_u4_risc2_idx
177#undef HEADER_DES_LOCL_H 177#undef HEADER_DES_LOCL_H
178#include "des_enc.c" 178#include "des_enc.c"
179 179
@@ -182,14 +182,14 @@ extern void exit();
182#undef DES_RISC2 182#undef DES_RISC2
183#undef DES_PTR 183#undef DES_PTR
184#undef D_ENCRYPT 184#undef D_ENCRYPT
185#undef des_encrypt1 185#undef DES_encrypt1
186#undef des_encrypt2 186#undef DES_encrypt2
187#undef des_encrypt3 187#undef DES_encrypt3
188#undef des_decrypt3 188#undef DES_decrypt3
189#define des_encrypt1 des_encrypt_u16_risc1_idx 189#define DES_encrypt1 des_encrypt_u16_risc1_idx
190#define des_encrypt2 des_encrypt2_u16_risc1_idx 190#define DES_encrypt2 des_encrypt2_u16_risc1_idx
191#define des_encrypt3 des_encrypt3_u16_risc1_idx 191#define DES_encrypt3 des_encrypt3_u16_risc1_idx
192#define des_decrypt3 des_decrypt3_u16_risc1_idx 192#define DES_decrypt3 des_decrypt3_u16_risc1_idx
193#undef HEADER_DES_LOCL_H 193#undef HEADER_DES_LOCL_H
194#include "des_enc.c" 194#include "des_enc.c"
195 195
@@ -198,14 +198,14 @@ extern void exit();
198#define DES_RISC2 198#define DES_RISC2
199#undef DES_PTR 199#undef DES_PTR
200#undef D_ENCRYPT 200#undef D_ENCRYPT
201#undef des_encrypt1 201#undef DES_encrypt1
202#undef des_encrypt2 202#undef DES_encrypt2
203#undef des_encrypt3 203#undef DES_encrypt3
204#undef des_decrypt3 204#undef DES_decrypt3
205#define des_encrypt1 des_encrypt_u16_risc2_idx 205#define DES_encrypt1 des_encrypt_u16_risc2_idx
206#define des_encrypt2 des_encrypt2_u16_risc2_idx 206#define DES_encrypt2 des_encrypt2_u16_risc2_idx
207#define des_encrypt3 des_encrypt3_u16_risc2_idx 207#define DES_encrypt3 des_encrypt3_u16_risc2_idx
208#define des_decrypt3 des_decrypt3_u16_risc2_idx 208#define DES_decrypt3 des_decrypt3_u16_risc2_idx
209#undef HEADER_DES_LOCL_H 209#undef HEADER_DES_LOCL_H
210#include "des_enc.c" 210#include "des_enc.c"
211 211
@@ -218,14 +218,14 @@ extern void exit();
218#undef DES_RISC2 218#undef DES_RISC2
219#define DES_PTR 219#define DES_PTR
220#undef D_ENCRYPT 220#undef D_ENCRYPT
221#undef des_encrypt1 221#undef DES_encrypt1
222#undef des_encrypt2 222#undef DES_encrypt2
223#undef des_encrypt3 223#undef DES_encrypt3
224#undef des_decrypt3 224#undef DES_decrypt3
225#define des_encrypt1 des_encrypt_u4_cisc_ptr 225#define DES_encrypt1 des_encrypt_u4_cisc_ptr
226#define des_encrypt2 des_encrypt2_u4_cisc_ptr 226#define DES_encrypt2 des_encrypt2_u4_cisc_ptr
227#define des_encrypt3 des_encrypt3_u4_cisc_ptr 227#define DES_encrypt3 des_encrypt3_u4_cisc_ptr
228#define des_decrypt3 des_decrypt3_u4_cisc_ptr 228#define DES_decrypt3 des_decrypt3_u4_cisc_ptr
229#undef HEADER_DES_LOCL_H 229#undef HEADER_DES_LOCL_H
230#include "des_enc.c" 230#include "des_enc.c"
231 231
@@ -234,14 +234,14 @@ extern void exit();
234#undef DES_RISC2 234#undef DES_RISC2
235#define DES_PTR 235#define DES_PTR
236#undef D_ENCRYPT 236#undef D_ENCRYPT
237#undef des_encrypt1 237#undef DES_encrypt1
238#undef des_encrypt2 238#undef DES_encrypt2
239#undef des_encrypt3 239#undef DES_encrypt3
240#undef des_decrypt3 240#undef DES_decrypt3
241#define des_encrypt1 des_encrypt_u16_cisc_ptr 241#define DES_encrypt1 des_encrypt_u16_cisc_ptr
242#define des_encrypt2 des_encrypt2_u16_cisc_ptr 242#define DES_encrypt2 des_encrypt2_u16_cisc_ptr
243#define des_encrypt3 des_encrypt3_u16_cisc_ptr 243#define DES_encrypt3 des_encrypt3_u16_cisc_ptr
244#define des_decrypt3 des_decrypt3_u16_cisc_ptr 244#define DES_decrypt3 des_decrypt3_u16_cisc_ptr
245#undef HEADER_DES_LOCL_H 245#undef HEADER_DES_LOCL_H
246#include "des_enc.c" 246#include "des_enc.c"
247 247
@@ -250,14 +250,14 @@ extern void exit();
250#undef DES_RISC2 250#undef DES_RISC2
251#define DES_PTR 251#define DES_PTR
252#undef D_ENCRYPT 252#undef D_ENCRYPT
253#undef des_encrypt1 253#undef DES_encrypt1
254#undef des_encrypt2 254#undef DES_encrypt2
255#undef des_encrypt3 255#undef DES_encrypt3
256#undef des_decrypt3 256#undef DES_decrypt3
257#define des_encrypt1 des_encrypt_u4_risc1_ptr 257#define DES_encrypt1 des_encrypt_u4_risc1_ptr
258#define des_encrypt2 des_encrypt2_u4_risc1_ptr 258#define DES_encrypt2 des_encrypt2_u4_risc1_ptr
259#define des_encrypt3 des_encrypt3_u4_risc1_ptr 259#define DES_encrypt3 des_encrypt3_u4_risc1_ptr
260#define des_decrypt3 des_decrypt3_u4_risc1_ptr 260#define DES_decrypt3 des_decrypt3_u4_risc1_ptr
261#undef HEADER_DES_LOCL_H 261#undef HEADER_DES_LOCL_H
262#include "des_enc.c" 262#include "des_enc.c"
263 263
@@ -270,14 +270,14 @@ extern void exit();
270#define DES_RISC2 270#define DES_RISC2
271#define DES_PTR 271#define DES_PTR
272#undef D_ENCRYPT 272#undef D_ENCRYPT
273#undef des_encrypt1 273#undef DES_encrypt1
274#undef des_encrypt2 274#undef DES_encrypt2
275#undef des_encrypt3 275#undef DES_encrypt3
276#undef des_decrypt3 276#undef DES_decrypt3
277#define des_encrypt1 des_encrypt_u4_risc2_ptr 277#define DES_encrypt1 des_encrypt_u4_risc2_ptr
278#define des_encrypt2 des_encrypt2_u4_risc2_ptr 278#define DES_encrypt2 des_encrypt2_u4_risc2_ptr
279#define des_encrypt3 des_encrypt3_u4_risc2_ptr 279#define DES_encrypt3 des_encrypt3_u4_risc2_ptr
280#define des_decrypt3 des_decrypt3_u4_risc2_ptr 280#define DES_decrypt3 des_decrypt3_u4_risc2_ptr
281#undef HEADER_DES_LOCL_H 281#undef HEADER_DES_LOCL_H
282#include "des_enc.c" 282#include "des_enc.c"
283 283
@@ -286,14 +286,14 @@ extern void exit();
286#undef DES_RISC2 286#undef DES_RISC2
287#define DES_PTR 287#define DES_PTR
288#undef D_ENCRYPT 288#undef D_ENCRYPT
289#undef des_encrypt1 289#undef DES_encrypt1
290#undef des_encrypt2 290#undef DES_encrypt2
291#undef des_encrypt3 291#undef DES_encrypt3
292#undef des_decrypt3 292#undef DES_decrypt3
293#define des_encrypt1 des_encrypt_u16_risc1_ptr 293#define DES_encrypt1 des_encrypt_u16_risc1_ptr
294#define des_encrypt2 des_encrypt2_u16_risc1_ptr 294#define DES_encrypt2 des_encrypt2_u16_risc1_ptr
295#define des_encrypt3 des_encrypt3_u16_risc1_ptr 295#define DES_encrypt3 des_encrypt3_u16_risc1_ptr
296#define des_decrypt3 des_decrypt3_u16_risc1_ptr 296#define DES_decrypt3 des_decrypt3_u16_risc1_ptr
297#undef HEADER_DES_LOCL_H 297#undef HEADER_DES_LOCL_H
298#include "des_enc.c" 298#include "des_enc.c"
299 299
@@ -302,14 +302,14 @@ extern void exit();
302#define DES_RISC2 302#define DES_RISC2
303#define DES_PTR 303#define DES_PTR
304#undef D_ENCRYPT 304#undef D_ENCRYPT
305#undef des_encrypt1 305#undef DES_encrypt1
306#undef des_encrypt2 306#undef DES_encrypt2
307#undef des_encrypt3 307#undef DES_encrypt3
308#undef des_decrypt3 308#undef DES_decrypt3
309#define des_encrypt1 des_encrypt_u16_risc2_ptr 309#define DES_encrypt1 des_encrypt_u16_risc2_ptr
310#define des_encrypt2 des_encrypt2_u16_risc2_ptr 310#define DES_encrypt2 des_encrypt2_u16_risc2_ptr
311#define des_encrypt3 des_encrypt3_u16_risc2_ptr 311#define DES_encrypt3 des_encrypt3_u16_risc2_ptr
312#define des_decrypt3 des_decrypt3_u16_risc2_ptr 312#define DES_decrypt3 des_decrypt3_u16_risc2_ptr
313#undef HEADER_DES_LOCL_H 313#undef HEADER_DES_LOCL_H
314#include "des_enc.c" 314#include "des_enc.c"
315 315
@@ -401,7 +401,7 @@ double Time_F(int s)
401 for (count=0,run=1; COND(cb); count++) \ 401 for (count=0,run=1; COND(cb); count++) \
402 { \ 402 { \
403 unsigned long d[2]; \ 403 unsigned long d[2]; \
404 func(d,&(sch[0]),DES_ENCRYPT); \ 404 func(d,&sch,DES_ENCRYPT); \
405 } \ 405 } \
406 tm[index]=Time_F(STOP); \ 406 tm[index]=Time_F(STOP); \
407 fprintf(stderr,"%ld %s's in %.2f second\n",count,name,tm[index]); \ 407 fprintf(stderr,"%ld %s's in %.2f second\n",count,name,tm[index]); \
@@ -415,10 +415,10 @@ int main(int argc, char **argv)
415 { 415 {
416 long count; 416 long count;
417 static unsigned char buf[BUFSIZE]; 417 static unsigned char buf[BUFSIZE];
418 static des_cblock key ={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0}; 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}; 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}; 420 static DES_cblock key3={0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34};
421 des_key_schedule sch,sch2,sch3; 421 DES_key_schedule sch,sch2,sch3;
422 double d,tm[16],max=0; 422 double d,tm[16],max=0;
423 int rank[16]; 423 int rank[16];
424 char *str[16]; 424 char *str[16];
@@ -438,13 +438,13 @@ int main(int argc, char **argv)
438 fprintf(stderr,"program when this computer is idle.\n"); 438 fprintf(stderr,"program when this computer is idle.\n");
439#endif 439#endif
440 440
441 des_set_key_unchecked(&key,sch); 441 DES_set_key_unchecked(&key,&sch);
442 des_set_key_unchecked(&key2,sch2); 442 DES_set_key_unchecked(&key2,&sch2);
443 des_set_key_unchecked(&key3,sch3); 443 DES_set_key_unchecked(&key3,&sch3);
444 444
445#ifndef SIGALRM 445#ifndef SIGALRM
446 fprintf(stderr,"First we calculate the approximate speed ...\n"); 446 fprintf(stderr,"First we calculate the approximate speed ...\n");
447 des_set_key_unchecked(&key,sch); 447 DES_set_key_unchecked(&key,sch);
448 count=10; 448 count=10;
449 do { 449 do {
450 long i; 450 long i;
@@ -453,7 +453,7 @@ int main(int argc, char **argv)
453 count*=2; 453 count*=2;
454 Time_F(START); 454 Time_F(START);
455 for (i=count; i; i--) 455 for (i=count; i; i--)
456 des_encrypt1(data,&(sch[0]),DES_ENCRYPT); 456 DES_encrypt1(data,&(sch[0]),DES_ENCRYPT);
457 d=Time_F(STOP); 457 d=Time_F(STOP);
458 } while (d < 3.0); 458 } while (d < 3.0);
459 ca=count; 459 ca=count;
@@ -598,7 +598,7 @@ int main(int argc, char **argv)
598 break; 598 break;
599 } 599 }
600 exit(0); 600 exit(0);
601#if defined(LINT) || defined(MSDOS) 601#if defined(LINT) || defined(OPENSSL_SYS_MSDOS)
602 return(0); 602 return(0);
603#endif 603#endif
604 } 604 }
diff --git a/src/lib/libcrypto/des/des_ver.h b/src/lib/libcrypto/des/des_ver.h
index de3c02f110..0fa94d5368 100644
--- a/src/lib/libcrypto/des/des_ver.h
+++ b/src/lib/libcrypto/des/des_ver.h
@@ -57,5 +57,11 @@
57 */ 57 */
58 58
59#include <openssl/e_os2.h> 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
60OPENSSL_EXTERN char *DES_version; /* SSLeay version string */ 66OPENSSL_EXTERN char *DES_version; /* SSLeay version string */
61OPENSSL_EXTERN char *libdes_version; /* old libdes version string */ 67OPENSSL_EXTERN char *libdes_version; /* old libdes version string */
diff --git a/src/lib/libcrypto/des/destest.c b/src/lib/libcrypto/des/destest.c
index df0d615d6b..58e8c35dcb 100644
--- a/src/lib/libcrypto/des/destest.c
+++ b/src/lib/libcrypto/des/destest.c
@@ -56,25 +56,26 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#if defined(WIN32) || defined(WIN16) || defined(WINDOWS) 59#include <stdio.h>
60#ifndef MSDOS 60#include <stdlib.h>
61#define MSDOS 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
62#endif 66#endif
63#endif 67#endif
64 68
65#include <stdio.h> 69#ifndef OPENSSL_SYS_MSDOS
66#include <stdlib.h> 70#if !defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_VMS_DECC)
67#ifndef MSDOS
68#if !defined(VMS) || defined(__DECC)
69#include <openssl/opensslconf.h>
70#include OPENSSL_UNISTD 71#include OPENSSL_UNISTD
71#endif /* VMS */ 72#endif
72#else 73#else
73#include <io.h> 74#include <io.h>
74#endif 75#endif
75#include <string.h> 76#include <string.h>
76 77
77#ifdef NO_DES 78#ifdef OPENSSL_NO_DES
78int main(int argc, char *argv[]) 79int main(int argc, char *argv[])
79{ 80{
80 printf("No DES support\n"); 81 printf("No DES support\n");
@@ -83,7 +84,7 @@ int main(int argc, char *argv[])
83#else 84#else
84#include <openssl/des.h> 85#include <openssl/des.h>
85 86
86#if defined(PERL5) || defined(__FreeBSD__) 87#if defined(PERL5) || defined(__FreeBSD__) || defined(NeXT)
87#define crypt(c,s) (des_crypt((c),(s))) 88#define crypt(c,s) (des_crypt((c),(s)))
88#endif 89#endif
89 90
@@ -348,19 +349,19 @@ int main(int argc, char *argv[])
348 int num; 349 int num;
349 char *str; 350 char *str;
350 351
351#ifndef NO_DESCBCM 352#ifndef OPENSSL_NO_DESCBCM
352 printf("Doing cbcm\n"); 353 printf("Doing cbcm\n");
353 if ((j=des_set_key_checked(&cbc_key,ks)) != 0) 354 if ((j=DES_set_key_checked(&cbc_key,&ks)) != 0)
354 { 355 {
355 printf("Key error %d\n",j); 356 printf("Key error %d\n",j);
356 err=1; 357 err=1;
357 } 358 }
358 if ((j=des_set_key_checked(&cbc2_key,ks2)) != 0) 359 if ((j=DES_set_key_checked(&cbc2_key,&ks2)) != 0)
359 { 360 {
360 printf("Key error %d\n",j); 361 printf("Key error %d\n",j);
361 err=1; 362 err=1;
362 } 363 }
363 if ((j=des_set_key_checked(&cbc3_key,ks3)) != 0) 364 if ((j=DES_set_key_checked(&cbc3_key,&ks3)) != 0)
364 { 365 {
365 printf("Key error %d\n",j); 366 printf("Key error %d\n",j);
366 err=1; 367 err=1;
@@ -372,9 +373,9 @@ int main(int argc, char *argv[])
372 memcpy(iv3,cbc_iv,sizeof(cbc_iv)); 373 memcpy(iv3,cbc_iv,sizeof(cbc_iv));
373 memset(iv2,'\0',sizeof iv2); 374 memset(iv2,'\0',sizeof iv2);
374 375
375 des_ede3_cbcm_encrypt(cbc_data,cbc_out,16L,ks,ks2,ks3,&iv3,&iv2, 376 DES_ede3_cbcm_encrypt(cbc_data,cbc_out,16L,&ks,&ks2,&ks3,&iv3,&iv2,
376 DES_ENCRYPT); 377 DES_ENCRYPT);
377 des_ede3_cbcm_encrypt(&cbc_data[16],&cbc_out[16],i-16,ks,ks2,ks3, 378 DES_ede3_cbcm_encrypt(&cbc_data[16],&cbc_out[16],i-16,&ks,&ks2,&ks3,
378 &iv3,&iv2,DES_ENCRYPT); 379 &iv3,&iv2,DES_ENCRYPT);
379 /* if (memcmp(cbc_out,cbc3_ok, 380 /* if (memcmp(cbc_out,cbc3_ok,
380 (unsigned int)(strlen((char *)cbc_data)+1+7)/8*8) != 0) 381 (unsigned int)(strlen((char *)cbc_data)+1+7)/8*8) != 0)
@@ -385,7 +386,7 @@ int main(int argc, char *argv[])
385 */ 386 */
386 memcpy(iv3,cbc_iv,sizeof(cbc_iv)); 387 memcpy(iv3,cbc_iv,sizeof(cbc_iv));
387 memset(iv2,'\0',sizeof iv2); 388 memset(iv2,'\0',sizeof iv2);
388 des_ede3_cbcm_encrypt(cbc_out,cbc_in,i,ks,ks2,ks3,&iv3,&iv2,DES_DECRYPT); 389 DES_ede3_cbcm_encrypt(cbc_out,cbc_in,i,&ks,&ks2,&ks3,&iv3,&iv2,DES_DECRYPT);
389 if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0) 390 if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0)
390 { 391 {
391 int n; 392 int n;
@@ -404,7 +405,7 @@ int main(int argc, char *argv[])
404 printf("Doing ecb\n"); 405 printf("Doing ecb\n");
405 for (i=0; i<NUM_TESTS; i++) 406 for (i=0; i<NUM_TESTS; i++)
406 { 407 {
407 des_set_key_unchecked(&key_data[i],ks); 408 DES_set_key_unchecked(&key_data[i],&ks);
408 memcpy(in,plain_data[i],8); 409 memcpy(in,plain_data[i],8);
409 memset(out,0,8); 410 memset(out,0,8);
410 memset(outin,0,8); 411 memset(outin,0,8);
@@ -430,9 +431,9 @@ int main(int argc, char *argv[])
430 printf("Doing ede ecb\n"); 431 printf("Doing ede ecb\n");
431 for (i=0; i<(NUM_TESTS-1); i++) 432 for (i=0; i<(NUM_TESTS-1); i++)
432 { 433 {
433 des_set_key_unchecked(&key_data[i],ks); 434 DES_set_key_unchecked(&key_data[i],&ks);
434 des_set_key_unchecked(&key_data[i+1],ks2); 435 DES_set_key_unchecked(&key_data[i+1],&ks2);
435 des_set_key_unchecked(&key_data[i+2],ks3); 436 DES_set_key_unchecked(&key_data[i+2],&ks3);
436 memcpy(in,plain_data[i],8); 437 memcpy(in,plain_data[i],8);
437 memset(out,0,8); 438 memset(out,0,8);
438 memset(outin,0,8); 439 memset(outin,0,8);
@@ -456,7 +457,7 @@ int main(int argc, char *argv[])
456#endif 457#endif
457 458
458 printf("Doing cbc\n"); 459 printf("Doing cbc\n");
459 if ((j=des_set_key_checked(&cbc_key,ks)) != 0) 460 if ((j=DES_set_key_checked(&cbc_key,&ks)) != 0)
460 { 461 {
461 printf("Key error %d\n",j); 462 printf("Key error %d\n",j);
462 err=1; 463 err=1;
@@ -483,7 +484,7 @@ int main(int argc, char *argv[])
483 484
484#ifndef LIBDES_LIT 485#ifndef LIBDES_LIT
485 printf("Doing desx cbc\n"); 486 printf("Doing desx cbc\n");
486 if ((j=des_set_key_checked(&cbc_key,ks)) != 0) 487 if ((j=DES_set_key_checked(&cbc_key,&ks)) != 0)
487 { 488 {
488 printf("Key error %d\n",j); 489 printf("Key error %d\n",j);
489 err=1; 490 err=1;
@@ -509,17 +510,17 @@ int main(int argc, char *argv[])
509#endif 510#endif
510 511
511 printf("Doing ede cbc\n"); 512 printf("Doing ede cbc\n");
512 if ((j=des_set_key_checked(&cbc_key,ks)) != 0) 513 if ((j=DES_set_key_checked(&cbc_key,&ks)) != 0)
513 { 514 {
514 printf("Key error %d\n",j); 515 printf("Key error %d\n",j);
515 err=1; 516 err=1;
516 } 517 }
517 if ((j=des_set_key_checked(&cbc2_key,ks2)) != 0) 518 if ((j=DES_set_key_checked(&cbc2_key,&ks2)) != 0)
518 { 519 {
519 printf("Key error %d\n",j); 520 printf("Key error %d\n",j);
520 err=1; 521 err=1;
521 } 522 }
522 if ((j=des_set_key_checked(&cbc3_key,ks3)) != 0) 523 if ((j=DES_set_key_checked(&cbc3_key,&ks3)) != 0)
523 { 524 {
524 printf("Key error %d\n",j); 525 printf("Key error %d\n",j);
525 err=1; 526 err=1;
@@ -530,13 +531,22 @@ int main(int argc, char *argv[])
530 /* i=((i+7)/8)*8; */ 531 /* i=((i+7)/8)*8; */
531 memcpy(iv3,cbc_iv,sizeof(cbc_iv)); 532 memcpy(iv3,cbc_iv,sizeof(cbc_iv));
532 533
533 des_ede3_cbc_encrypt(cbc_data,cbc_out,16L,ks,ks2,ks3,&iv3,DES_ENCRYPT); 534 des_ede3_cbc_encrypt(cbc_data,cbc_out,16L,ks,ks2,ks3,&iv3,
535 DES_ENCRYPT);
534 des_ede3_cbc_encrypt(&(cbc_data[16]),&(cbc_out[16]),i-16,ks,ks2,ks3, 536 des_ede3_cbc_encrypt(&(cbc_data[16]),&(cbc_out[16]),i-16,ks,ks2,ks3,
535 &iv3,DES_ENCRYPT); 537 &iv3,DES_ENCRYPT);
536 if (memcmp(cbc_out,cbc3_ok, 538 if (memcmp(cbc_out,cbc3_ok,
537 (unsigned int)(strlen((char *)cbc_data)+1+7)/8*8) != 0) 539 (unsigned int)(strlen((char *)cbc_data)+1+7)/8*8) != 0)
538 { 540 {
541 int n;
542
539 printf("des_ede3_cbc_encrypt encrypt error\n"); 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");
540 err=1; 550 err=1;
541 } 551 }
542 552
@@ -544,13 +554,21 @@ int main(int argc, char *argv[])
544 des_ede3_cbc_encrypt(cbc_out,cbc_in,i,ks,ks2,ks3,&iv3,DES_DECRYPT); 554 des_ede3_cbc_encrypt(cbc_out,cbc_in,i,ks,ks2,ks3,&iv3,DES_DECRYPT);
545 if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0) 555 if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0)
546 { 556 {
557 int n;
558
547 printf("des_ede3_cbc_encrypt decrypt error\n"); 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");
548 err=1; 566 err=1;
549 } 567 }
550 568
551#ifndef LIBDES_LIT 569#ifndef LIBDES_LIT
552 printf("Doing pcbc\n"); 570 printf("Doing pcbc\n");
553 if ((j=des_set_key_checked(&cbc_key,ks)) != 0) 571 if ((j=DES_set_key_checked(&cbc_key,&ks)) != 0)
554 { 572 {
555 printf("Key error %d\n",j); 573 printf("Key error %d\n",j);
556 err=1; 574 err=1;
@@ -613,7 +631,7 @@ int main(int argc, char *argv[])
613 printf("done\n"); 631 printf("done\n");
614 632
615 printf("Doing ofb\n"); 633 printf("Doing ofb\n");
616 des_set_key_checked(&ofb_key,ks); 634 DES_set_key_checked(&ofb_key,&ks);
617 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); 635 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
618 des_ofb_encrypt(plain,ofb_buf1,64,sizeof(plain)/8,ks,&ofb_tmp); 636 des_ofb_encrypt(plain,ofb_buf1,64,sizeof(plain)/8,ks,&ofb_tmp);
619 if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0) 637 if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0)
@@ -642,7 +660,7 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
642 } 660 }
643 661
644 printf("Doing ofb64\n"); 662 printf("Doing ofb64\n");
645 des_set_key_checked(&ofb_key,ks); 663 DES_set_key_checked(&ofb_key,&ks);
646 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); 664 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
647 memset(ofb_buf1,0,sizeof(ofb_buf1)); 665 memset(ofb_buf1,0,sizeof(ofb_buf1));
648 memset(ofb_buf2,0,sizeof(ofb_buf1)); 666 memset(ofb_buf2,0,sizeof(ofb_buf1));
@@ -659,7 +677,8 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
659 } 677 }
660 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); 678 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
661 num=0; 679 num=0;
662 des_ofb64_encrypt(ofb_buf1,ofb_buf2,sizeof(ofb_buf1),ks,&ofb_tmp,&num); 680 des_ofb64_encrypt(ofb_buf1,ofb_buf2,sizeof(ofb_buf1),ks,&ofb_tmp,
681 &num);
663 if (memcmp(plain,ofb_buf2,sizeof(ofb_buf2)) != 0) 682 if (memcmp(plain,ofb_buf2,sizeof(ofb_buf2)) != 0)
664 { 683 {
665 printf("ofb64_encrypt decrypt error\n"); 684 printf("ofb64_encrypt decrypt error\n");
@@ -667,15 +686,15 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
667 } 686 }
668 687
669 printf("Doing ede_ofb64\n"); 688 printf("Doing ede_ofb64\n");
670 des_set_key_checked(&ofb_key,ks); 689 DES_set_key_checked(&ofb_key,&ks);
671 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); 690 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
672 memset(ofb_buf1,0,sizeof(ofb_buf1)); 691 memset(ofb_buf1,0,sizeof(ofb_buf1));
673 memset(ofb_buf2,0,sizeof(ofb_buf1)); 692 memset(ofb_buf2,0,sizeof(ofb_buf1));
674 num=0; 693 num=0;
675 for (i=0; i<sizeof(plain); i++) 694 for (i=0; i<sizeof(plain); i++)
676 { 695 {
677 des_ede3_ofb64_encrypt(&(plain[i]),&(ofb_buf1[i]),1,ks,ks,ks, 696 des_ede3_ofb64_encrypt(&(plain[i]),&(ofb_buf1[i]),1,ks,ks,
678 &ofb_tmp,&num); 697 ks,&ofb_tmp,&num);
679 } 698 }
680 if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0) 699 if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0)
681 { 700 {
@@ -684,8 +703,8 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
684 } 703 }
685 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); 704 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
686 num=0; 705 num=0;
687 des_ede3_ofb64_encrypt(ofb_buf1,ofb_buf2,sizeof(ofb_buf1),ks, 706 des_ede3_ofb64_encrypt(ofb_buf1,ofb_buf2,sizeof(ofb_buf1),ks,ks,ks,
688 ks,ks,&ofb_tmp,&num); 707 &ofb_tmp,&num);
689 if (memcmp(plain,ofb_buf2,sizeof(ofb_buf2)) != 0) 708 if (memcmp(plain,ofb_buf2,sizeof(ofb_buf2)) != 0)
690 { 709 {
691 printf("ede_ofb64_encrypt decrypt error\n"); 710 printf("ede_ofb64_encrypt decrypt error\n");
@@ -693,7 +712,7 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
693 } 712 }
694 713
695 printf("Doing cbc_cksum\n"); 714 printf("Doing cbc_cksum\n");
696 des_set_key_checked(&cbc_key,ks); 715 DES_set_key_checked(&cbc_key,&ks);
697 cs=des_cbc_cksum(cbc_data,&cret,strlen((char *)cbc_data),ks,&cbc_iv); 716 cs=des_cbc_cksum(cbc_data,&cret,strlen((char *)cbc_data),ks,&cbc_iv);
698 if (cs != cbc_cksum_ret) 717 if (cs != cbc_cksum_ret)
699 { 718 {
@@ -708,7 +727,7 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
708 } 727 }
709 728
710 printf("Doing quad_cksum\n"); 729 printf("Doing quad_cksum\n");
711 cs=quad_cksum(cbc_data,(des_cblock *)lqret, 730 cs=des_quad_cksum(cbc_data,(des_cblock *)lqret,
712 (long)strlen((char *)cbc_data),2,(des_cblock *)cbc_iv); 731 (long)strlen((char *)cbc_data),2,(des_cblock *)cbc_iv);
713 if (cs != 0x70d7a63aL) 732 if (cs != 0x70d7a63aL)
714 { 733 {
@@ -829,7 +848,7 @@ static int cfb_test(int bits, unsigned char *cfb_cipher)
829 des_key_schedule ks; 848 des_key_schedule ks;
830 int i,err=0; 849 int i,err=0;
831 850
832 des_set_key_checked(&cfb_key,ks); 851 DES_set_key_checked(&cfb_key,&ks);
833 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); 852 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
834 des_cfb_encrypt(plain,cfb_buf1,bits,sizeof(plain),ks,&cfb_tmp, 853 des_cfb_encrypt(plain,cfb_buf1,bits,sizeof(plain),ks,&cfb_tmp,
835 DES_ENCRYPT); 854 DES_ENCRYPT);
@@ -858,7 +877,7 @@ static int cfb64_test(unsigned char *cfb_cipher)
858 des_key_schedule ks; 877 des_key_schedule ks;
859 int err=0,i,n; 878 int err=0,i,n;
860 879
861 des_set_key_checked(&cfb_key,ks); 880 DES_set_key_checked(&cfb_key,&ks);
862 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); 881 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
863 n=0; 882 n=0;
864 des_cfb64_encrypt(plain,cfb_buf1,12,ks,&cfb_tmp,&n,DES_ENCRYPT); 883 des_cfb64_encrypt(plain,cfb_buf1,12,ks,&cfb_tmp,&n,DES_ENCRYPT);
@@ -891,7 +910,7 @@ static int ede_cfb64_test(unsigned char *cfb_cipher)
891 des_key_schedule ks; 910 des_key_schedule ks;
892 int err=0,i,n; 911 int err=0,i,n;
893 912
894 des_set_key_checked(&cfb_key,ks); 913 DES_set_key_checked(&cfb_key,&ks);
895 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); 914 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
896 n=0; 915 n=0;
897 des_ede3_cfb64_encrypt(plain,cfb_buf1,12,ks,ks,ks,&cfb_tmp,&n, 916 des_ede3_cfb64_encrypt(plain,cfb_buf1,12,ks,ks,ks,&cfb_tmp,&n,
diff --git a/src/lib/libcrypto/des/ecb3_enc.c b/src/lib/libcrypto/des/ecb3_enc.c
index fb28b97e1a..c3437bc606 100644
--- a/src/lib/libcrypto/des/ecb3_enc.c
+++ b/src/lib/libcrypto/des/ecb3_enc.c
@@ -58,8 +58,9 @@
58 58
59#include "des_locl.h" 59#include "des_locl.h"
60 60
61void des_ecb3_encrypt(const_des_cblock *input, des_cblock *output, 61void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output,
62 des_key_schedule ks1, des_key_schedule ks2, des_key_schedule ks3, 62 DES_key_schedule *ks1, DES_key_schedule *ks2,
63 DES_key_schedule *ks3,
63 int enc) 64 int enc)
64 { 65 {
65 register DES_LONG l0,l1; 66 register DES_LONG l0,l1;
@@ -72,9 +73,9 @@ void des_ecb3_encrypt(const_des_cblock *input, des_cblock *output,
72 ll[0]=l0; 73 ll[0]=l0;
73 ll[1]=l1; 74 ll[1]=l1;
74 if (enc) 75 if (enc)
75 des_encrypt3(ll,ks1,ks2,ks3); 76 DES_encrypt3(ll,ks1,ks2,ks3);
76 else 77 else
77 des_decrypt3(ll,ks1,ks2,ks3); 78 DES_decrypt3(ll,ks1,ks2,ks3);
78 l0=ll[0]; 79 l0=ll[0];
79 l1=ll[1]; 80 l1=ll[1];
80 l2c(l0,out); 81 l2c(l0,out);
diff --git a/src/lib/libcrypto/des/ecb_enc.c b/src/lib/libcrypto/des/ecb_enc.c
index d481327ef3..4650f2fa0f 100644
--- a/src/lib/libcrypto/des/ecb_enc.c
+++ b/src/lib/libcrypto/des/ecb_enc.c
@@ -63,7 +63,7 @@
63OPENSSL_GLOBAL const char *libdes_version="libdes" OPENSSL_VERSION_PTEXT; 63OPENSSL_GLOBAL const char *libdes_version="libdes" OPENSSL_VERSION_PTEXT;
64OPENSSL_GLOBAL const char *DES_version="DES" OPENSSL_VERSION_PTEXT; 64OPENSSL_GLOBAL const char *DES_version="DES" OPENSSL_VERSION_PTEXT;
65 65
66const char *des_options(void) 66const char *DES_options(void)
67 { 67 {
68 static int init=1; 68 static int init=1;
69 static char buf[32]; 69 static char buf[32];
@@ -103,9 +103,8 @@ const char *des_options(void)
103 } 103 }
104 104
105 105
106void des_ecb_encrypt(const_des_cblock *input, des_cblock *output, 106void DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output,
107 des_key_schedule ks, 107 DES_key_schedule *ks, int enc)
108 int enc)
109 { 108 {
110 register DES_LONG l; 109 register DES_LONG l;
111 DES_LONG ll[2]; 110 DES_LONG ll[2];
@@ -114,9 +113,8 @@ void des_ecb_encrypt(const_des_cblock *input, des_cblock *output,
114 113
115 c2l(in,l); ll[0]=l; 114 c2l(in,l); ll[0]=l;
116 c2l(in,l); ll[1]=l; 115 c2l(in,l); ll[1]=l;
117 des_encrypt1(ll,ks,enc); 116 DES_encrypt1(ll,ks,enc);
118 l=ll[0]; l2c(l,out); 117 l=ll[0]; l2c(l,out);
119 l=ll[1]; l2c(l,out); 118 l=ll[1]; l2c(l,out);
120 l=ll[0]=ll[1]=0; 119 l=ll[0]=ll[1]=0;
121 } 120 }
122
diff --git a/src/lib/libcrypto/des/ede_cbcm_enc.c b/src/lib/libcrypto/des/ede_cbcm_enc.c
index b98f7e17af..fa45aa272b 100644
--- a/src/lib/libcrypto/des/ede_cbcm_enc.c
+++ b/src/lib/libcrypto/des/ede_cbcm_enc.c
@@ -68,12 +68,12 @@ http://www.cs.technion.ac.il/users/wwwb/cgi-bin/tr-get.cgi/1998/CS/CS0928.ps.gz
68 68
69*/ 69*/
70 70
71#ifndef NO_DESCBCM 71#ifndef OPENSSL_NO_DESCBCM
72#include "des_locl.h" 72#include "des_locl.h"
73 73
74void des_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out, 74void DES_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out,
75 long length, des_key_schedule ks1, des_key_schedule ks2, 75 long length, DES_key_schedule *ks1, DES_key_schedule *ks2,
76 des_key_schedule ks3, des_cblock *ivec1, des_cblock *ivec2, 76 DES_key_schedule *ks3, DES_cblock *ivec1, DES_cblock *ivec2,
77 int enc) 77 int enc)
78 { 78 {
79 register DES_LONG tin0,tin1; 79 register DES_LONG tin0,tin1;
@@ -95,7 +95,7 @@ void des_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out,
95 { 95 {
96 tin[0]=m0; 96 tin[0]=m0;
97 tin[1]=m1; 97 tin[1]=m1;
98 des_encrypt1(tin,ks3,1); 98 DES_encrypt1(tin,ks3,1);
99 m0=tin[0]; 99 m0=tin[0];
100 m1=tin[1]; 100 m1=tin[1];
101 101
@@ -113,13 +113,13 @@ void des_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out,
113 113
114 tin[0]=tin0; 114 tin[0]=tin0;
115 tin[1]=tin1; 115 tin[1]=tin1;
116 des_encrypt1(tin,ks1,1); 116 DES_encrypt1(tin,ks1,1);
117 tin[0]^=m0; 117 tin[0]^=m0;
118 tin[1]^=m1; 118 tin[1]^=m1;
119 des_encrypt1(tin,ks2,0); 119 DES_encrypt1(tin,ks2,0);
120 tin[0]^=m0; 120 tin[0]^=m0;
121 tin[1]^=m1; 121 tin[1]^=m1;
122 des_encrypt1(tin,ks1,1); 122 DES_encrypt1(tin,ks1,1);
123 tout0=tin[0]; 123 tout0=tin[0];
124 tout1=tin[1]; 124 tout1=tin[1];
125 125
@@ -146,7 +146,7 @@ void des_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out,
146 { 146 {
147 tin[0]=m0; 147 tin[0]=m0;
148 tin[1]=m1; 148 tin[1]=m1;
149 des_encrypt1(tin,ks3,1); 149 DES_encrypt1(tin,ks3,1);
150 m0=tin[0]; 150 m0=tin[0];
151 m1=tin[1]; 151 m1=tin[1];
152 152
@@ -158,13 +158,13 @@ void des_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out,
158 158
159 tin[0]=tin0; 159 tin[0]=tin0;
160 tin[1]=tin1; 160 tin[1]=tin1;
161 des_encrypt1(tin,ks1,0); 161 DES_encrypt1(tin,ks1,0);
162 tin[0]^=m0; 162 tin[0]^=m0;
163 tin[1]^=m1; 163 tin[1]^=m1;
164 des_encrypt1(tin,ks2,1); 164 DES_encrypt1(tin,ks2,1);
165 tin[0]^=m0; 165 tin[0]^=m0;
166 tin[1]^=m1; 166 tin[1]^=m1;
167 des_encrypt1(tin,ks1,0); 167 DES_encrypt1(tin,ks1,0);
168 tout0=tin[0]; 168 tout0=tin[0];
169 tout1=tin[1]; 169 tout1=tin[1];
170 170
diff --git a/src/lib/libcrypto/des/enc_read.c b/src/lib/libcrypto/des/enc_read.c
index af2d9177d2..c70fb686b8 100644
--- a/src/lib/libcrypto/des/enc_read.c
+++ b/src/lib/libcrypto/des/enc_read.c
@@ -63,15 +63,15 @@
63 63
64/* This has some uglies in it but it works - even over sockets. */ 64/* This has some uglies in it but it works - even over sockets. */
65/*extern int errno;*/ 65/*extern int errno;*/
66OPENSSL_GLOBAL int des_rw_mode=DES_PCBC_MODE; 66OPENSSL_IMPLEMENT_GLOBAL(int,DES_rw_mode)=DES_PCBC_MODE;
67 67
68 68
69/* 69/*
70 * WARNINGS: 70 * WARNINGS:
71 * 71 *
72 * - The data format used by des_enc_write() and des_enc_read() 72 * - The data format used by DES_enc_write() and DES_enc_read()
73 * has a cryptographic weakness: When asked to write more 73 * has a cryptographic weakness: When asked to write more
74 * than MAXWRITE bytes, des_enc_write will split the data 74 * than MAXWRITE bytes, DES_enc_write will split the data
75 * into several chunks that are all encrypted 75 * into several chunks that are all encrypted
76 * using the same IV. So don't use these functions unless you 76 * using the same IV. So don't use these functions unless you
77 * are sure you know what you do (in which case you might 77 * are sure you know what you do (in which case you might
@@ -84,8 +84,8 @@ OPENSSL_GLOBAL int des_rw_mode=DES_PCBC_MODE;
84 */ 84 */
85 85
86 86
87int des_enc_read(int fd, void *buf, int len, des_key_schedule sched, 87int DES_enc_read(int fd, void *buf, int len, DES_key_schedule *sched,
88 des_cblock *iv) 88 DES_cblock *iv)
89 { 89 {
90 /* data to be unencrypted */ 90 /* data to be unencrypted */
91 int net_num=0; 91 int net_num=0;
@@ -180,10 +180,10 @@ int des_enc_read(int fd, void *buf, int len, des_key_schedule sched,
180 /* Check if there will be data left over. */ 180 /* Check if there will be data left over. */
181 if (len < num) 181 if (len < num)
182 { 182 {
183 if (des_rw_mode & DES_PCBC_MODE) 183 if (DES_rw_mode & DES_PCBC_MODE)
184 des_pcbc_encrypt(net,unnet,num,sched,iv,DES_DECRYPT); 184 DES_pcbc_encrypt(net,unnet,num,sched,iv,DES_DECRYPT);
185 else 185 else
186 des_cbc_encrypt(net,unnet,num,sched,iv,DES_DECRYPT); 186 DES_cbc_encrypt(net,unnet,num,sched,iv,DES_DECRYPT);
187 memcpy(buf,unnet,len); 187 memcpy(buf,unnet,len);
188 unnet_start=len; 188 unnet_start=len;
189 unnet_left=num-len; 189 unnet_left=num-len;
@@ -202,11 +202,11 @@ int des_enc_read(int fd, void *buf, int len, des_key_schedule sched,
202 if (len < rnum) 202 if (len < rnum)
203 { 203 {
204 204
205 if (des_rw_mode & DES_PCBC_MODE) 205 if (DES_rw_mode & DES_PCBC_MODE)
206 des_pcbc_encrypt(net,tmpbuf,num,sched,iv, 206 DES_pcbc_encrypt(net,tmpbuf,num,sched,iv,
207 DES_DECRYPT); 207 DES_DECRYPT);
208 else 208 else
209 des_cbc_encrypt(net,tmpbuf,num,sched,iv, 209 DES_cbc_encrypt(net,tmpbuf,num,sched,iv,
210 DES_DECRYPT); 210 DES_DECRYPT);
211 211
212 /* eay 26/08/92 fix a bug that returned more 212 /* eay 26/08/92 fix a bug that returned more
@@ -215,11 +215,11 @@ int des_enc_read(int fd, void *buf, int len, des_key_schedule sched,
215 } 215 }
216 else 216 else
217 { 217 {
218 if (des_rw_mode & DES_PCBC_MODE) 218 if (DES_rw_mode & DES_PCBC_MODE)
219 des_pcbc_encrypt(net,buf,num,sched,iv, 219 DES_pcbc_encrypt(net,buf,num,sched,iv,
220 DES_DECRYPT); 220 DES_DECRYPT);
221 else 221 else
222 des_cbc_encrypt(net,buf,num,sched,iv, 222 DES_cbc_encrypt(net,buf,num,sched,iv,
223 DES_DECRYPT); 223 DES_DECRYPT);
224 } 224 }
225 } 225 }
diff --git a/src/lib/libcrypto/des/enc_writ.c b/src/lib/libcrypto/des/enc_writ.c
index cc2b50fb50..af5b8c2349 100644
--- a/src/lib/libcrypto/des/enc_writ.c
+++ b/src/lib/libcrypto/des/enc_writ.c
@@ -66,9 +66,9 @@
66/* 66/*
67 * WARNINGS: 67 * WARNINGS:
68 * 68 *
69 * - The data format used by des_enc_write() and des_enc_read() 69 * - The data format used by DES_enc_write() and DES_enc_read()
70 * has a cryptographic weakness: When asked to write more 70 * has a cryptographic weakness: When asked to write more
71 * than MAXWRITE bytes, des_enc_write will split the data 71 * than MAXWRITE bytes, DES_enc_write will split the data
72 * into several chunks that are all encrypted 72 * into several chunks that are all encrypted
73 * using the same IV. So don't use these functions unless you 73 * using the same IV. So don't use these functions unless you
74 * are sure you know what you do (in which case you might 74 * are sure you know what you do (in which case you might
@@ -77,8 +77,8 @@
77 * - This code cannot handle non-blocking sockets. 77 * - This code cannot handle non-blocking sockets.
78 */ 78 */
79 79
80int des_enc_write(int fd, const void *_buf, int len, 80int DES_enc_write(int fd, const void *_buf, int len,
81 des_key_schedule sched, des_cblock *iv) 81 DES_key_schedule *sched, DES_cblock *iv)
82 { 82 {
83#ifdef _LIBC 83#ifdef _LIBC
84 extern unsigned long time(); 84 extern unsigned long time();
@@ -111,7 +111,7 @@ int des_enc_write(int fd, const void *_buf, int len,
111 j=0; 111 j=0;
112 for (i=0; i<len; i+=k) 112 for (i=0; i<len; i+=k)
113 { 113 {
114 k=des_enc_write(fd,&(buf[i]), 114 k=DES_enc_write(fd,&(buf[i]),
115 ((len-i) > MAXWRITE)?MAXWRITE:(len-i),sched,iv); 115 ((len-i) > MAXWRITE)?MAXWRITE:(len-i),sched,iv);
116 if (k < 0) 116 if (k < 0)
117 return(k); 117 return(k);
@@ -139,11 +139,11 @@ int des_enc_write(int fd, const void *_buf, int len,
139 rnum=((len+7)/8*8); /* round up to nearest eight */ 139 rnum=((len+7)/8*8); /* round up to nearest eight */
140 } 140 }
141 141
142 if (des_rw_mode & DES_PCBC_MODE) 142 if (DES_rw_mode & DES_PCBC_MODE)
143 des_pcbc_encrypt(cp,&(outbuf[HDRSIZE]),(len<8)?8:len,sched,iv, 143 DES_pcbc_encrypt(cp,&(outbuf[HDRSIZE]),(len<8)?8:len,sched,iv,
144 DES_ENCRYPT); 144 DES_ENCRYPT);
145 else 145 else
146 des_cbc_encrypt(cp,&(outbuf[HDRSIZE]),(len<8)?8:len,sched,iv, 146 DES_cbc_encrypt(cp,&(outbuf[HDRSIZE]),(len<8)?8:len,sched,iv,
147 DES_ENCRYPT); 147 DES_ENCRYPT);
148 148
149 /* output */ 149 /* output */
diff --git a/src/lib/libcrypto/des/fcrypt.c b/src/lib/libcrypto/des/fcrypt.c
index 9b21f81cc2..d3d27de9f7 100644
--- a/src/lib/libcrypto/des/fcrypt.c
+++ b/src/lib/libcrypto/des/fcrypt.c
@@ -50,48 +50,55 @@ static unsigned const char cov_2char[64]={
500x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A 500x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A
51}; 51};
52 52
53#ifndef NOPROTO 53void fcrypt_body(DES_LONG *out,DES_key_schedule *ks,
54void fcrypt_body(DES_LONG *out,des_key_schedule ks, 54 DES_LONG Eswap0, DES_LONG Eswap1);
55 DES_LONG Eswap0, DES_LONG Eswap1);
56 55
57#if defined(PERL5) || defined(FreeBSD) || defined(__OpenBSD__) 56char *DES_crypt(const char *buf, const char *salt)
58char *des_crypt(const char *buf,const char *salt);
59#else
60char *crypt(const char *buf,const char *salt);
61#endif
62#else
63void fcrypt_body();
64#ifdef PERL5
65char *des_crypt();
66#else
67char *crypt();
68#endif
69#endif
70
71#if defined(PERL5) || defined(FreeBSD) || defined(__OpenBSD__)
72char *des_crypt(buf,salt)
73#else
74char *crypt(buf,salt)
75#endif
76const char *buf;
77const char *salt;
78 { 57 {
79 static char buff[14]; 58 static char buff[14];
80 59
81 return(des_fcrypt(buf,salt,buff)); 60#ifndef CHARSET_EBCDIC
61 return(DES_fcrypt(buf,salt,buff));
62#else
63 char e_salt[2+1];
64 char e_buf[32+1]; /* replace 32 by 8 ? */
65 char *ret;
66
67 /* Copy at most 2 chars of salt */
68 if ((e_salt[0] = salt[0]) != '\0')
69 e_salt[1] = salt[1];
70
71 /* Copy at most 32 chars of password */
72 strncpy (e_buf, buf, sizeof(e_buf));
73
74 /* Make sure we have a delimiter */
75 e_salt[sizeof(e_salt)-1] = e_buf[sizeof(e_buf)-1] = '\0';
76
77 /* Convert the e_salt to ASCII, as that's what DES_fcrypt works on */
78 ebcdic2ascii(e_salt, e_salt, sizeof e_salt);
79
80 /* Convert the cleartext password to ASCII */
81 ebcdic2ascii(e_buf, e_buf, sizeof e_buf);
82
83 /* Encrypt it (from/to ASCII) */
84 ret = DES_fcrypt(e_buf,e_salt,buff);
85
86 /* Convert the result back to EBCDIC */
87 ascii2ebcdic(ret, ret, strlen(ret));
88
89 return ret;
90#endif
82 } 91 }
83 92
84 93
85char *des_fcrypt(buf,salt,ret) 94
86const char *buf; 95char *DES_fcrypt(const char *buf, const char *salt, char *ret)
87const char *salt;
88char *ret;
89 { 96 {
90 unsigned int i,j,x,y; 97 unsigned int i,j,x,y;
91 DES_LONG Eswap0,Eswap1; 98 DES_LONG Eswap0,Eswap1;
92 DES_LONG out[2],ll; 99 DES_LONG out[2],ll;
93 des_cblock key; 100 DES_cblock key;
94 des_key_schedule ks; 101 DES_key_schedule ks;
95 unsigned char bb[9]; 102 unsigned char bb[9];
96 unsigned char *b=bb; 103 unsigned char *b=bb;
97 unsigned char c,u; 104 unsigned char c,u;
@@ -104,10 +111,17 @@ char *ret;
104 * crypt to "*". This was found when replacing the crypt in 111 * crypt to "*". This was found when replacing the crypt in
105 * our shared libraries. People found that the disabled 112 * our shared libraries. People found that the disabled
106 * accounts effectively had no passwd :-(. */ 113 * accounts effectively had no passwd :-(. */
114#ifndef CHARSET_EBCDIC
107 x=ret[0]=((salt[0] == '\0')?'A':salt[0]); 115 x=ret[0]=((salt[0] == '\0')?'A':salt[0]);
108 Eswap0=con_salt[x]<<2; 116 Eswap0=con_salt[x]<<2;
109 x=ret[1]=((salt[1] == '\0')?'A':salt[1]); 117 x=ret[1]=((salt[1] == '\0')?'A':salt[1]);
110 Eswap1=con_salt[x]<<6; 118 Eswap1=con_salt[x]<<6;
119#else
120 x=ret[0]=((salt[0] == '\0')?os_toascii['A']:salt[0]);
121 Eswap0=con_salt[x]<<2;
122 x=ret[1]=((salt[1] == '\0')?os_toascii['A']:salt[1]);
123 Eswap1=con_salt[x]<<6;
124#endif
111 125
112/* EAY 126/* EAY
113r=strlen(buf); 127r=strlen(buf);
@@ -122,8 +136,8 @@ r=(r+7)/8;
122 for (; i<8; i++) 136 for (; i<8; i++)
123 key[i]=0; 137 key[i]=0;
124 138
125 des_set_key_unchecked(&key,ks); 139 DES_set_key_unchecked(&key,&ks);
126 fcrypt_body(&(out[0]),ks,Eswap0,Eswap1); 140 fcrypt_body(&(out[0]),&ks,Eswap0,Eswap1);
127 141
128 ll=out[0]; l2c(ll,b); 142 ll=out[0]; l2c(ll,b);
129 ll=out[1]; l2c(ll,b); 143 ll=out[1]; l2c(ll,b);
@@ -149,4 +163,3 @@ r=(r+7)/8;
149 ret[13]='\0'; 163 ret[13]='\0';
150 return(ret); 164 return(ret);
151 } 165 }
152
diff --git a/src/lib/libcrypto/des/fcrypt_b.c b/src/lib/libcrypto/des/fcrypt_b.c
index 22c87f5983..1390138787 100644
--- a/src/lib/libcrypto/des/fcrypt_b.c
+++ b/src/lib/libcrypto/des/fcrypt_b.c
@@ -77,12 +77,12 @@
77#define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\ 77#define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\
78 (a)=(a)^(t)^(t>>(16-(n))))\ 78 (a)=(a)^(t)^(t>>(16-(n))))\
79 79
80void fcrypt_body(DES_LONG *out, des_key_schedule ks, DES_LONG Eswap0, 80void fcrypt_body(DES_LONG *out, DES_key_schedule *ks, DES_LONG Eswap0,
81 DES_LONG Eswap1) 81 DES_LONG Eswap1)
82 { 82 {
83 register DES_LONG l,r,t,u; 83 register DES_LONG l,r,t,u;
84#ifdef DES_PTR 84#ifdef DES_PTR
85 register const unsigned char *des_SP=(const unsigned char *)des_SPtrans; 85 register const unsigned char *des_SP=(const unsigned char *)DES_SPtrans;
86#endif 86#endif
87 register DES_LONG *s; 87 register DES_LONG *s;
88 register int j; 88 register int j;
diff --git a/src/lib/libcrypto/des/ncbc_enc.c b/src/lib/libcrypto/des/ncbc_enc.c
index b8db07b199..fda23d522f 100644
--- a/src/lib/libcrypto/des/ncbc_enc.c
+++ b/src/lib/libcrypto/des/ncbc_enc.c
@@ -1,8 +1,8 @@
1/* crypto/des/ncbc_enc.c */ 1/* crypto/des/ncbc_enc.c */
2/* 2/*
3 * #included by: 3 * #included by:
4 * cbc_enc.c (des_cbc_encrypt) 4 * cbc_enc.c (DES_cbc_encrypt)
5 * des_enc.c (des_ncbc_encrypt) 5 * des_enc.c (DES_ncbc_encrypt)
6 */ 6 */
7/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 7/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
8 * All rights reserved. 8 * All rights reserved.
@@ -64,11 +64,11 @@
64#include "des_locl.h" 64#include "des_locl.h"
65 65
66#ifdef CBC_ENC_C__DONT_UPDATE_IV 66#ifdef CBC_ENC_C__DONT_UPDATE_IV
67void des_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, 67void DES_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
68 des_key_schedule schedule, des_cblock *ivec, int enc) 68 DES_key_schedule *_schedule, DES_cblock *ivec, int enc)
69#else 69#else
70void des_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length, 70void DES_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length,
71 des_key_schedule schedule, des_cblock *ivec, int enc) 71 DES_key_schedule *_schedule, DES_cblock *ivec, int enc)
72#endif 72#endif
73 { 73 {
74 register DES_LONG tin0,tin1; 74 register DES_LONG tin0,tin1;
@@ -89,7 +89,7 @@ void des_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length,
89 c2l(in,tin1); 89 c2l(in,tin1);
90 tin0^=tout0; tin[0]=tin0; 90 tin0^=tout0; tin[0]=tin0;
91 tin1^=tout1; tin[1]=tin1; 91 tin1^=tout1; tin[1]=tin1;
92 des_encrypt1((DES_LONG *)tin,schedule,DES_ENCRYPT); 92 DES_encrypt1((DES_LONG *)tin,_schedule,DES_ENCRYPT);
93 tout0=tin[0]; l2c(tout0,out); 93 tout0=tin[0]; l2c(tout0,out);
94 tout1=tin[1]; l2c(tout1,out); 94 tout1=tin[1]; l2c(tout1,out);
95 } 95 }
@@ -98,7 +98,7 @@ void des_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length,
98 c2ln(in,tin0,tin1,l+8); 98 c2ln(in,tin0,tin1,l+8);
99 tin0^=tout0; tin[0]=tin0; 99 tin0^=tout0; tin[0]=tin0;
100 tin1^=tout1; tin[1]=tin1; 100 tin1^=tout1; tin[1]=tin1;
101 des_encrypt1((DES_LONG *)tin,schedule,DES_ENCRYPT); 101 DES_encrypt1((DES_LONG *)tin,_schedule,DES_ENCRYPT);
102 tout0=tin[0]; l2c(tout0,out); 102 tout0=tin[0]; l2c(tout0,out);
103 tout1=tin[1]; l2c(tout1,out); 103 tout1=tin[1]; l2c(tout1,out);
104 } 104 }
@@ -116,7 +116,7 @@ void des_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length,
116 { 116 {
117 c2l(in,tin0); tin[0]=tin0; 117 c2l(in,tin0); tin[0]=tin0;
118 c2l(in,tin1); tin[1]=tin1; 118 c2l(in,tin1); tin[1]=tin1;
119 des_encrypt1((DES_LONG *)tin,schedule,DES_DECRYPT); 119 DES_encrypt1((DES_LONG *)tin,_schedule,DES_DECRYPT);
120 tout0=tin[0]^xor0; 120 tout0=tin[0]^xor0;
121 tout1=tin[1]^xor1; 121 tout1=tin[1]^xor1;
122 l2c(tout0,out); 122 l2c(tout0,out);
@@ -128,7 +128,7 @@ void des_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length,
128 { 128 {
129 c2l(in,tin0); tin[0]=tin0; 129 c2l(in,tin0); tin[0]=tin0;
130 c2l(in,tin1); tin[1]=tin1; 130 c2l(in,tin1); tin[1]=tin1;
131 des_encrypt1((DES_LONG *)tin,schedule,DES_DECRYPT); 131 DES_encrypt1((DES_LONG *)tin,_schedule,DES_DECRYPT);
132 tout0=tin[0]^xor0; 132 tout0=tin[0]^xor0;
133 tout1=tin[1]^xor1; 133 tout1=tin[1]^xor1;
134 l2cn(tout0,tout1,out,l+8); 134 l2cn(tout0,tout1,out,l+8);
diff --git a/src/lib/libcrypto/des/ofb64ede.c b/src/lib/libcrypto/des/ofb64ede.c
index 6eafe908da..26bbf9a6a7 100644
--- a/src/lib/libcrypto/des/ofb64ede.c
+++ b/src/lib/libcrypto/des/ofb64ede.c
@@ -62,15 +62,16 @@
62 * used. The extra state information to record how much of the 62 * used. The extra state information to record how much of the
63 * 64bit block we have used is contained in *num; 63 * 64bit block we have used is contained in *num;
64 */ 64 */
65void des_ede3_ofb64_encrypt(register const unsigned char *in, 65void DES_ede3_ofb64_encrypt(register const unsigned char *in,
66 register unsigned char *out, long length, des_key_schedule k1, 66 register unsigned char *out, long length,
67 des_key_schedule k2, des_key_schedule k3, des_cblock *ivec, 67 DES_key_schedule *k1, DES_key_schedule *k2,
68 int *num) 68 DES_key_schedule *k3, DES_cblock *ivec,
69 int *num)
69 { 70 {
70 register DES_LONG v0,v1; 71 register DES_LONG v0,v1;
71 register int n= *num; 72 register int n= *num;
72 register long l=length; 73 register long l=length;
73 des_cblock d; 74 DES_cblock d;
74 register char *dp; 75 register char *dp;
75 DES_LONG ti[2]; 76 DES_LONG ti[2];
76 unsigned char *iv; 77 unsigned char *iv;
@@ -90,7 +91,7 @@ void des_ede3_ofb64_encrypt(register const unsigned char *in,
90 { 91 {
91 /* ti[0]=v0; */ 92 /* ti[0]=v0; */
92 /* ti[1]=v1; */ 93 /* ti[1]=v1; */
93 des_encrypt3(ti,k1,k2,k3); 94 DES_encrypt3(ti,k1,k2,k3);
94 v0=ti[0]; 95 v0=ti[0];
95 v1=ti[1]; 96 v1=ti[1];
96 97
@@ -115,10 +116,10 @@ void des_ede3_ofb64_encrypt(register const unsigned char *in,
115 } 116 }
116 117
117#ifdef undef /* MACRO */ 118#ifdef undef /* MACRO */
118void des_ede2_ofb64_encrypt(register unsigned char *in, 119void DES_ede2_ofb64_encrypt(register unsigned char *in,
119 register unsigned char *out, long length, des_key_schedule k1, 120 register unsigned char *out, long length, DES_key_schedule k1,
120 des_key_schedule k2, des_cblock (*ivec), int *num) 121 DES_key_schedule k2, DES_cblock (*ivec), int *num)
121 { 122 {
122 des_ede3_ofb64_encrypt(in, out, length, k1,k2,k1, ivec, num); 123 DES_ede3_ofb64_encrypt(in, out, length, k1,k2,k1, ivec, num);
123 } 124 }
124#endif 125#endif
diff --git a/src/lib/libcrypto/des/ofb64enc.c b/src/lib/libcrypto/des/ofb64enc.c
index 1a1d1f1ac4..8ca3d49dea 100644
--- a/src/lib/libcrypto/des/ofb64enc.c
+++ b/src/lib/libcrypto/des/ofb64enc.c
@@ -62,14 +62,14 @@
62 * used. The extra state information to record how much of the 62 * used. The extra state information to record how much of the
63 * 64bit block we have used is contained in *num; 63 * 64bit block we have used is contained in *num;
64 */ 64 */
65void des_ofb64_encrypt(register const unsigned char *in, 65void DES_ofb64_encrypt(register const unsigned char *in,
66 register unsigned char *out, long length, des_key_schedule schedule, 66 register unsigned char *out, long length,
67 des_cblock *ivec, int *num) 67 DES_key_schedule *schedule, DES_cblock *ivec, int *num)
68 { 68 {
69 register DES_LONG v0,v1,t; 69 register DES_LONG v0,v1,t;
70 register int n= *num; 70 register int n= *num;
71 register long l=length; 71 register long l=length;
72 des_cblock d; 72 DES_cblock d;
73 register unsigned char *dp; 73 register unsigned char *dp;
74 DES_LONG ti[2]; 74 DES_LONG ti[2];
75 unsigned char *iv; 75 unsigned char *iv;
@@ -87,7 +87,7 @@ void des_ofb64_encrypt(register const unsigned char *in,
87 { 87 {
88 if (n == 0) 88 if (n == 0)
89 { 89 {
90 des_encrypt1(ti,schedule,DES_ENCRYPT); 90 DES_encrypt1(ti,schedule,DES_ENCRYPT);
91 dp=d; 91 dp=d;
92 t=ti[0]; l2c(t,dp); 92 t=ti[0]; l2c(t,dp);
93 t=ti[1]; l2c(t,dp); 93 t=ti[1]; l2c(t,dp);
diff --git a/src/lib/libcrypto/des/ofb_enc.c b/src/lib/libcrypto/des/ofb_enc.c
index 70493e632c..e887a3c6f4 100644
--- a/src/lib/libcrypto/des/ofb_enc.c
+++ b/src/lib/libcrypto/des/ofb_enc.c
@@ -64,8 +64,9 @@
64 * the second. The second 12 bits will come from the 3rd and half the 4th 64 * the second. The second 12 bits will come from the 3rd and half the 4th
65 * byte. 65 * byte.
66 */ 66 */
67void des_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits, 67void DES_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
68 long length, des_key_schedule schedule, des_cblock *ivec) 68 long length, DES_key_schedule *schedule,
69 DES_cblock *ivec)
69 { 70 {
70 register DES_LONG d0,d1,vv0,vv1,v0,v1,n=(numbits+7)/8; 71 register DES_LONG d0,d1,vv0,vv1,v0,v1,n=(numbits+7)/8;
71 register DES_LONG mask0,mask1; 72 register DES_LONG mask0,mask1;
@@ -101,7 +102,7 @@ void des_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
101 { 102 {
102 ti[0]=v0; 103 ti[0]=v0;
103 ti[1]=v1; 104 ti[1]=v1;
104 des_encrypt1((DES_LONG *)ti,schedule,DES_ENCRYPT); 105 DES_encrypt1((DES_LONG *)ti,schedule,DES_ENCRYPT);
105 vv0=ti[0]; 106 vv0=ti[0];
106 vv1=ti[1]; 107 vv1=ti[1];
107 c2ln(in,d0,d1,n); 108 c2ln(in,d0,d1,n);
diff --git a/src/lib/libcrypto/des/pcbc_enc.c b/src/lib/libcrypto/des/pcbc_enc.c
index 5b987f074d..17a40f9520 100644
--- a/src/lib/libcrypto/des/pcbc_enc.c
+++ b/src/lib/libcrypto/des/pcbc_enc.c
@@ -58,8 +58,9 @@
58 58
59#include "des_locl.h" 59#include "des_locl.h"
60 60
61void des_pcbc_encrypt(const unsigned char *input, unsigned char *output, 61void DES_pcbc_encrypt(const unsigned char *input, unsigned char *output,
62 long length, des_key_schedule schedule, des_cblock *ivec, int enc) 62 long length, DES_key_schedule *schedule,
63 DES_cblock *ivec, int enc)
63 { 64 {
64 register DES_LONG sin0,sin1,xor0,xor1,tout0,tout1; 65 register DES_LONG sin0,sin1,xor0,xor1,tout0,tout1;
65 DES_LONG tin[2]; 66 DES_LONG tin[2];
@@ -85,7 +86,7 @@ void des_pcbc_encrypt(const unsigned char *input, unsigned char *output,
85 c2ln(in,sin0,sin1,length); 86 c2ln(in,sin0,sin1,length);
86 tin[0]=sin0^xor0; 87 tin[0]=sin0^xor0;
87 tin[1]=sin1^xor1; 88 tin[1]=sin1^xor1;
88 des_encrypt1((DES_LONG *)tin,schedule,DES_ENCRYPT); 89 DES_encrypt1((DES_LONG *)tin,schedule,DES_ENCRYPT);
89 tout0=tin[0]; 90 tout0=tin[0];
90 tout1=tin[1]; 91 tout1=tin[1];
91 xor0=sin0^tout0; 92 xor0=sin0^tout0;
@@ -103,7 +104,7 @@ void des_pcbc_encrypt(const unsigned char *input, unsigned char *output,
103 c2l(in,sin1); 104 c2l(in,sin1);
104 tin[0]=sin0; 105 tin[0]=sin0;
105 tin[1]=sin1; 106 tin[1]=sin1;
106 des_encrypt1((DES_LONG *)tin,schedule,DES_DECRYPT); 107 DES_encrypt1((DES_LONG *)tin,schedule,DES_DECRYPT);
107 tout0=tin[0]^xor0; 108 tout0=tin[0]^xor0;
108 tout1=tin[1]^xor1; 109 tout1=tin[1]^xor1;
109 if (length >= 8) 110 if (length >= 8)
diff --git a/src/lib/libcrypto/des/qud_cksm.c b/src/lib/libcrypto/des/qud_cksm.c
index 9fff989edb..dac201227e 100644
--- a/src/lib/libcrypto/des/qud_cksm.c
+++ b/src/lib/libcrypto/des/qud_cksm.c
@@ -73,8 +73,8 @@
73/* Got the value MIT uses via brute force :-) 2/10/90 eay */ 73/* Got the value MIT uses via brute force :-) 2/10/90 eay */
74#define NOISE ((DES_LONG)83653421L) 74#define NOISE ((DES_LONG)83653421L)
75 75
76DES_LONG des_quad_cksum(const unsigned char *input, des_cblock output[], 76DES_LONG DES_quad_cksum(const unsigned char *input, DES_cblock output[],
77 long length, int out_count, des_cblock *seed) 77 long length, int out_count, DES_cblock *seed)
78 { 78 {
79 DES_LONG z0,z1,t0,t1; 79 DES_LONG z0,z1,t0,t1;
80 int i; 80 int i;
diff --git a/src/lib/libcrypto/des/rand_key.c b/src/lib/libcrypto/des/rand_key.c
index ee1a6c274e..2398165568 100644
--- a/src/lib/libcrypto/des/rand_key.c
+++ b/src/lib/libcrypto/des/rand_key.c
@@ -56,18 +56,13 @@
56#include <openssl/des.h> 56#include <openssl/des.h>
57#include <openssl/rand.h> 57#include <openssl/rand.h>
58 58
59void des_random_seed(des_cblock *key) 59int DES_random_key(DES_cblock *ret)
60 {
61 RAND_seed(key, sizeof(des_cblock));
62 }
63
64int des_random_key(des_cblock *ret)
65 { 60 {
66 do 61 do
67 { 62 {
68 if (RAND_bytes((unsigned char *)ret, sizeof(des_cblock)) != 1) 63 if (RAND_bytes((unsigned char *)ret, sizeof(DES_cblock)) != 1)
69 return (0); 64 return (0);
70 } while (des_is_weak_key(ret)); 65 } while (DES_is_weak_key(ret));
71 des_set_odd_parity(ret); 66 DES_set_odd_parity(ret);
72 return (1); 67 return (1);
73 } 68 }
diff --git a/src/lib/libcrypto/des/read2pwd.c b/src/lib/libcrypto/des/read2pwd.c
index a8ceaf088a..b4720c3a98 100644
--- a/src/lib/libcrypto/des/read2pwd.c
+++ b/src/lib/libcrypto/des/read2pwd.c
@@ -1,4 +1,57 @@
1/* crypto/des/read2pwd.c */ 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 */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 55/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 56 * All rights reserved.
4 * 57 *
@@ -56,28 +109,30 @@
56 * [including the GNU Public Licence.] 109 * [including the GNU Public Licence.]
57 */ 110 */
58 111
59#include "des_locl.h" 112#include <string.h>
113#include <openssl/des.h>
114#include <openssl/ui.h>
60 115
61int des_read_password(des_cblock *key, const char *prompt, int verify) 116int DES_read_password(DES_cblock *key, const char *prompt, int verify)
62 { 117 {
63 int ok; 118 int ok;
64 char buf[BUFSIZ],buff[BUFSIZ]; 119 char buf[BUFSIZ],buff[BUFSIZ];
65 120
66 if ((ok=des_read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0) 121 if ((ok=UI_UTIL_read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0)
67 des_string_to_key(buf,key); 122 DES_string_to_key(buf,key);
68 memset(buf,0,BUFSIZ); 123 memset(buf,0,BUFSIZ);
69 memset(buff,0,BUFSIZ); 124 memset(buff,0,BUFSIZ);
70 return(ok); 125 return(ok);
71 } 126 }
72 127
73int des_read_2passwords(des_cblock *key1, des_cblock *key2, const char *prompt, 128int DES_read_2passwords(DES_cblock *key1, DES_cblock *key2, const char *prompt,
74 int verify) 129 int verify)
75 { 130 {
76 int ok; 131 int ok;
77 char buf[BUFSIZ],buff[BUFSIZ]; 132 char buf[BUFSIZ],buff[BUFSIZ];
78 133
79 if ((ok=des_read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0) 134 if ((ok=UI_UTIL_read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0)
80 des_string_to_2keys(buf,key1,key2); 135 DES_string_to_2keys(buf,key1,key2);
81 memset(buf,0,BUFSIZ); 136 memset(buf,0,BUFSIZ);
82 memset(buff,0,BUFSIZ); 137 memset(buff,0,BUFSIZ);
83 return(ok); 138 return(ok);
diff --git a/src/lib/libcrypto/des/read_pwd.c b/src/lib/libcrypto/des/read_pwd.c
index c27ec336e7..ae9aef620b 100644
--- a/src/lib/libcrypto/des/read_pwd.c
+++ b/src/lib/libcrypto/des/read_pwd.c
@@ -56,8 +56,8 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#if !defined(MSDOS) && !defined(VMS) && !defined(WIN32) 59#include <openssl/e_os2.h>
60#include <openssl/opensslconf.h> 60#if !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_WIN32)
61#ifdef OPENSSL_UNISTD 61#ifdef OPENSSL_UNISTD
62# include OPENSSL_UNISTD 62# include OPENSSL_UNISTD
63#else 63#else
@@ -78,7 +78,7 @@
78/* #define SIGACTION */ /* Define this if you have sigaction() */ 78/* #define SIGACTION */ /* Define this if you have sigaction() */
79 79
80#ifdef WIN16TTY 80#ifdef WIN16TTY
81#undef WIN16 81#undef OPENSSL_SYS_WIN16
82#undef _WINDOWS 82#undef _WINDOWS
83#include <graph.h> 83#include <graph.h>
84#endif 84#endif
@@ -92,7 +92,7 @@
92#include <setjmp.h> 92#include <setjmp.h>
93#include <errno.h> 93#include <errno.h>
94 94
95#ifdef VMS /* prototypes for sys$whatever */ 95#ifdef OPENSSL_SYS_VMS /* prototypes for sys$whatever */
96#include <starlet.h> 96#include <starlet.h>
97#ifdef __DECC 97#ifdef __DECC
98#pragma message disable DOLLARID 98#pragma message disable DOLLARID
@@ -127,12 +127,18 @@
127#undef SGTTY 127#undef SGTTY
128#endif 128#endif
129 129
130#if !defined(TERMIO) && !defined(TERMIOS) && !defined(VMS) && !defined(MSDOS) && !defined(MAC_OS_pre_X) && !defined(MAC_OS_GUSI_SOURCE) 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 131#undef TERMIOS
132#undef TERMIO 132#undef TERMIO
133#define SGTTY 133#define SGTTY
134#endif 134#endif
135 135
136#if defined(OPENSSL_SYS_VSWORKS)
137#undef TERMIOS
138#undef TERMIO
139#undef SGTTY
140#endif
141
136#ifdef TERMIOS 142#ifdef TERMIOS
137#include <termios.h> 143#include <termios.h>
138#define TTY_STRUCT struct termios 144#define TTY_STRUCT struct termios
@@ -157,16 +163,16 @@
157#define TTY_set(tty,data) ioctl(tty,TIOCSETP,data) 163#define TTY_set(tty,data) ioctl(tty,TIOCSETP,data)
158#endif 164#endif
159 165
160#if !defined(_LIBC) && !defined(MSDOS) && !defined(VMS) && !defined(MAC_OS_pre_X) 166#if !defined(_LIBC) && !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VMS) && !defined(MAC_OS_pre_X)
161#include <sys/ioctl.h> 167#include <sys/ioctl.h>
162#endif 168#endif
163 169
164#if defined(MSDOS) && !defined(__CYGWIN32__) 170#if defined(OPENSSL_SYS_MSDOS) && !defined(__CYGWIN32__)
165#include <conio.h> 171#include <conio.h>
166#define fgets(a,b,c) noecho_fgets(a,b,c) 172#define fgets(a,b,c) noecho_fgets(a,b,c)
167#endif 173#endif
168 174
169#ifdef VMS 175#ifdef OPENSSL_SYS_VMS
170#include <ssdef.h> 176#include <ssdef.h>
171#include <iodef.h> 177#include <iodef.h>
172#include <ttdef.h> 178#include <ttdef.h>
@@ -195,17 +201,17 @@ static void read_till_nl(FILE *);
195static void recsig(int); 201static void recsig(int);
196static void pushsig(void); 202static void pushsig(void);
197static void popsig(void); 203static void popsig(void);
198#if defined(MSDOS) && !defined(WIN16) 204#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN16)
199static int noecho_fgets(char *buf, int size, FILE *tty); 205static int noecho_fgets(char *buf, int size, FILE *tty);
200#endif 206#endif
201#ifdef SIGACTION 207#ifdef SIGACTION
202 static struct sigaction savsig[NX509_SIG]; 208 static struct sigaction savsig[NX509_SIG];
203#else 209#else
204 static void (*savsig[NX509_SIG])(int ); 210 static void (*savsig[NX509_SIG])(int );
205#endif 211#endif
206static jmp_buf save; 212static jmp_buf save;
207 213
208int des_read_pw_string(char *buf, int length, const char *prompt, 214int _ossl_old_des_read_pw_string(char *buf, int length, const char *prompt,
209 int verify) 215 int verify)
210 { 216 {
211 char buff[BUFSIZ]; 217 char buff[BUFSIZ];
@@ -216,7 +222,7 @@ int des_read_pw_string(char *buf, int length, const char *prompt,
216 return(ret); 222 return(ret);
217 } 223 }
218 224
219#ifndef WIN16 225#ifndef OPENSSL_SYS_WIN16
220 226
221static void read_till_nl(FILE *in) 227static void read_till_nl(FILE *in)
222 { 228 {
@@ -233,14 +239,14 @@ static void read_till_nl(FILE *in)
233int des_read_pw(char *buf, char *buff, int size, const char *prompt, 239int des_read_pw(char *buf, char *buff, int size, const char *prompt,
234 int verify) 240 int verify)
235 { 241 {
236#ifdef VMS 242#ifdef OPENSSL_SYS_VMS
237 struct IOSB iosb; 243 struct IOSB iosb;
238 $DESCRIPTOR(terminal,"TT"); 244 $DESCRIPTOR(terminal,"TT");
239 long tty_orig[3], tty_new[3]; 245 long tty_orig[3], tty_new[3];
240 long status; 246 long status;
241 unsigned short channel = 0; 247 unsigned short channel = 0;
242#else 248#else
243#ifndef MSDOS 249#ifndef OPENSSL_SYS_MSDOS
244 TTY_STRUCT tty_orig,tty_new; 250 TTY_STRUCT tty_orig,tty_new;
245#endif 251#endif
246#endif 252#endif
@@ -265,19 +271,19 @@ int des_read_pw(char *buf, char *buff, int size, const char *prompt,
265 is_a_tty=1; 271 is_a_tty=1;
266 tty=NULL; 272 tty=NULL;
267 273
268#ifdef MSDOS 274#ifdef OPENSSL_SYS_MSDOS
269 if ((tty=fopen("con","r")) == NULL) 275 if ((tty=fopen("con","r")) == NULL)
270 tty=stdin; 276 tty=stdin;
271#elif defined(MAC_OS_pre_X) 277#elif defined(MAC_OS_pre_X) || defined(OPENSSL_SYS_VSWORKS)
272 tty=stdin; 278 tty=stdin;
273#else 279#else
274#ifndef MPE 280#ifndef OPENSSL_SYS_MPE
275 if ((tty=fopen("/dev/tty","r")) == NULL) 281 if ((tty=fopen("/dev/tty","r")) == NULL)
276#endif 282#endif
277 tty=stdin; 283 tty=stdin;
278#endif 284#endif
279 285
280#if defined(TTY_get) && !defined(VMS) 286#if defined(TTY_get) && !defined(OPENSSL_SYS_VMS)
281 if (TTY_get(fileno(tty),&tty_orig) == -1) 287 if (TTY_get(fileno(tty),&tty_orig) == -1)
282 { 288 {
283#ifdef ENOTTY 289#ifdef ENOTTY
@@ -296,7 +302,7 @@ int des_read_pw(char *buf, char *buff, int size, const char *prompt,
296 } 302 }
297 memcpy(&(tty_new),&(tty_orig),sizeof(tty_orig)); 303 memcpy(&(tty_new),&(tty_orig),sizeof(tty_orig));
298#endif 304#endif
299#ifdef VMS 305#ifdef OPENSSL_SYS_VMS
300 status = sys$assign(&terminal,&channel,0,0); 306 status = sys$assign(&terminal,&channel,0,0);
301 if (status != SS$_NORMAL) 307 if (status != SS$_NORMAL)
302 return(-1); 308 return(-1);
@@ -312,15 +318,15 @@ int des_read_pw(char *buf, char *buff, int size, const char *prompt,
312 tty_new.TTY_FLAGS &= ~ECHO; 318 tty_new.TTY_FLAGS &= ~ECHO;
313#endif 319#endif
314 320
315#if defined(TTY_set) && !defined(VMS) 321#if defined(TTY_set) && !defined(OPENSSL_SYS_VMS)
316 if (is_a_tty && (TTY_set(fileno(tty),&tty_new) == -1)) 322 if (is_a_tty && (TTY_set(fileno(tty),&tty_new) == -1))
317#ifdef MPE 323#ifdef OPENSSL_SYS_MPE
318 ; /* MPE lies -- echo really has been disabled */ 324 ; /* MPE lies -- echo really has been disabled */
319#else 325#else
320 return(-1); 326 return(-1);
321#endif 327#endif
322#endif 328#endif
323#ifdef VMS 329#ifdef OPENSSL_SYS_VMS
324 tty_new[0] = tty_orig[0]; 330 tty_new[0] = tty_orig[0];
325 tty_new[1] = tty_orig[1] | TT$M_NOECHO; 331 tty_new[1] = tty_orig[1] | TT$M_NOECHO;
326 tty_new[2] = tty_orig[2]; 332 tty_new[2] = tty_orig[2];
@@ -366,14 +372,14 @@ int des_read_pw(char *buf, char *buff, int size, const char *prompt,
366 372
367error: 373error:
368 fprintf(stderr,"\n"); 374 fprintf(stderr,"\n");
369#ifdef DEBUG 375#if 0
370 perror("fgets(tty)"); 376 perror("fgets(tty)");
371#endif 377#endif
372 /* What can we do if there is an error? */ 378 /* What can we do if there is an error? */
373#if defined(TTY_set) && !defined(VMS) 379#if defined(TTY_set) && !defined(OPENSSL_SYS_VMS)
374 if (ps >= 2) TTY_set(fileno(tty),&tty_orig); 380 if (ps >= 2) TTY_set(fileno(tty),&tty_orig);
375#endif 381#endif
376#ifdef VMS 382#ifdef OPENSSL_SYS_VMS
377 if (ps >= 2) 383 if (ps >= 2)
378 status = sys$qiow(0,channel,IO$_SETMODE,&iosb,0,0 384 status = sys$qiow(0,channel,IO$_SETMODE,&iosb,0,0
379 ,tty_orig,12,0,0,0,0); 385 ,tty_orig,12,0,0,0,0);
@@ -381,13 +387,13 @@ error:
381 387
382 if (ps >= 1) popsig(); 388 if (ps >= 1) popsig();
383 if (stdin != tty) fclose(tty); 389 if (stdin != tty) fclose(tty);
384#ifdef VMS 390#ifdef OPENSSL_SYS_VMS
385 status = sys$dassgn(channel); 391 status = sys$dassgn(channel);
386#endif 392#endif
387 return(!ok); 393 return(!ok);
388 } 394 }
389 395
390#else /* WIN16 */ 396#else /* OPENSSL_SYS_WIN16 */
391 397
392int des_read_pw(char *buf, char *buff, int size, char *prompt, int verify) 398int des_read_pw(char *buf, char *buff, int size, char *prompt, int verify)
393 { 399 {
@@ -460,7 +466,7 @@ static void recsig(int i)
460#endif 466#endif
461 } 467 }
462 468
463#if defined(MSDOS) && !defined(WIN16) 469#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN16)
464static int noecho_fgets(char *buf, int size, FILE *tty) 470static int noecho_fgets(char *buf, int size, FILE *tty)
465 { 471 {
466 int i; 472 int i;
diff --git a/src/lib/libcrypto/des/rpc_enc.c b/src/lib/libcrypto/des/rpc_enc.c
index 32d96d5cae..d937d08da5 100644
--- a/src/lib/libcrypto/des/rpc_enc.c
+++ b/src/lib/libcrypto/des/rpc_enc.c
@@ -63,20 +63,20 @@
63int _des_crypt(char *buf,int len,struct desparams *desp); 63int _des_crypt(char *buf,int len,struct desparams *desp);
64int _des_crypt(char *buf, int len, struct desparams *desp) 64int _des_crypt(char *buf, int len, struct desparams *desp)
65 { 65 {
66 des_key_schedule ks; 66 DES_key_schedule ks;
67 int enc; 67 int enc;
68 68
69 des_set_key_unchecked(&desp->des_key,ks); 69 DES_set_key_unchecked(&desp->des_key,&ks);
70 enc=(desp->des_dir == ENCRYPT)?DES_ENCRYPT:DES_DECRYPT; 70 enc=(desp->des_dir == ENCRYPT)?DES_ENCRYPT:DES_DECRYPT;
71 71
72 if (desp->des_mode == CBC) 72 if (desp->des_mode == CBC)
73 des_ecb_encrypt((const_des_cblock *)desp->UDES.UDES_buf, 73 DES_ecb_encrypt((const_DES_cblock *)desp->UDES.UDES_buf,
74 (des_cblock *)desp->UDES.UDES_buf,ks, 74 (DES_cblock *)desp->UDES.UDES_buf,&ks,
75 enc); 75 enc);
76 else 76 else
77 { 77 {
78 des_ncbc_encrypt(desp->UDES.UDES_buf,desp->UDES.UDES_buf, 78 DES_ncbc_encrypt(desp->UDES.UDES_buf,desp->UDES.UDES_buf,
79 len,ks,&desp->des_ivec,enc); 79 len,&ks,&desp->des_ivec,enc);
80#ifdef undef 80#ifdef undef
81 /* len will always be %8 if called from common_crypt 81 /* len will always be %8 if called from common_crypt
82 * in secure_rpc. 82 * in secure_rpc.
diff --git a/src/lib/libcrypto/des/rpw.c b/src/lib/libcrypto/des/rpw.c
index 0b6b1519b0..8a9473c4f9 100644
--- a/src/lib/libcrypto/des/rpw.c
+++ b/src/lib/libcrypto/des/rpw.c
@@ -61,7 +61,7 @@
61 61
62int main(int argc, char *argv[]) 62int main(int argc, char *argv[])
63 { 63 {
64 des_cblock k,k1; 64 DES_cblock k,k1;
65 int i; 65 int i;
66 66
67 printf("read passwd\n"); 67 printf("read passwd\n");
diff --git a/src/lib/libcrypto/des/set_key.c b/src/lib/libcrypto/des/set_key.c
index 09afd4fc03..683916e71b 100644
--- a/src/lib/libcrypto/des/set_key.c
+++ b/src/lib/libcrypto/des/set_key.c
@@ -65,7 +65,7 @@
65 */ 65 */
66#include "des_locl.h" 66#include "des_locl.h"
67 67
68OPENSSL_GLOBAL int des_check_key=0; 68OPENSSL_IMPLEMENT_GLOBAL(int,DES_check_key); /* defaults to false */
69 69
70static const unsigned char odd_parity[256]={ 70static const unsigned char odd_parity[256]={
71 1, 1, 2, 2, 4, 4, 7, 7, 8, 8, 11, 11, 13, 13, 14, 14, 71 1, 1, 2, 2, 4, 4, 7, 7, 8, 8, 11, 11, 13, 13, 14, 14,
@@ -85,7 +85,7 @@ static const unsigned char odd_parity[256]={
85224,224,227,227,229,229,230,230,233,233,234,234,236,236,239,239, 85224,224,227,227,229,229,230,230,233,233,234,234,236,236,239,239,
86241,241,242,242,244,244,247,247,248,248,251,251,253,253,254,254}; 86241,241,242,242,244,244,247,247,248,248,251,251,253,253,254,254};
87 87
88void des_set_odd_parity(des_cblock *key) 88void DES_set_odd_parity(DES_cblock *key)
89 { 89 {
90 int i; 90 int i;
91 91
@@ -93,7 +93,7 @@ void des_set_odd_parity(des_cblock *key)
93 (*key)[i]=odd_parity[(*key)[i]]; 93 (*key)[i]=odd_parity[(*key)[i]];
94 } 94 }
95 95
96int des_check_key_parity(const_des_cblock *key) 96int DES_check_key_parity(const_DES_cblock *key)
97 { 97 {
98 int i; 98 int i;
99 99
@@ -115,7 +115,7 @@ int des_check_key_parity(const_des_cblock *key)
115 * (and actual cblock values). 115 * (and actual cblock values).
116 */ 116 */
117#define NUM_WEAK_KEY 16 117#define NUM_WEAK_KEY 16
118static des_cblock weak_keys[NUM_WEAK_KEY]={ 118static DES_cblock weak_keys[NUM_WEAK_KEY]={
119 /* weak keys */ 119 /* weak keys */
120 {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01}, 120 {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01},
121 {0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE}, 121 {0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE},
@@ -135,7 +135,7 @@ static des_cblock weak_keys[NUM_WEAK_KEY]={
135 {0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1,0xFE}, 135 {0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1,0xFE},
136 {0xFE,0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1}}; 136 {0xFE,0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1}};
137 137
138int des_is_weak_key(const_des_cblock *key) 138int DES_is_weak_key(const_DES_cblock *key)
139 { 139 {
140 int i; 140 int i;
141 141
@@ -146,7 +146,7 @@ int des_is_weak_key(const_des_cblock *key)
146 * eay 93/06/29 146 * eay 93/06/29
147 * Another problem, I was comparing only the first 4 147 * Another problem, I was comparing only the first 4
148 * bytes, 97/03/18 */ 148 * bytes, 97/03/18 */
149 if (memcmp(weak_keys[i],key,sizeof(des_cblock)) == 0) return(1); 149 if (memcmp(weak_keys[i],key,sizeof(DES_cblock)) == 0) return(1);
150 return(0); 150 return(0);
151 } 151 }
152 152
@@ -307,15 +307,15 @@ static const DES_LONG des_skb[8][64]={
307 0x00002822L,0x04002822L,0x00042822L,0x04042822L, 307 0x00002822L,0x04002822L,0x00042822L,0x04042822L,
308 }}; 308 }};
309 309
310int des_set_key(const_des_cblock *key, des_key_schedule schedule) 310int DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule)
311 { 311 {
312 if (des_check_key) 312 if (DES_check_key)
313 { 313 {
314 return des_set_key_checked(key, schedule); 314 return DES_set_key_checked(key, schedule);
315 } 315 }
316 else 316 else
317 { 317 {
318 des_set_key_unchecked(key, schedule); 318 DES_set_key_unchecked(key, schedule);
319 return 0; 319 return 0;
320 } 320 }
321 } 321 }
@@ -324,17 +324,17 @@ int des_set_key(const_des_cblock *key, des_key_schedule schedule)
324 * return -1 if key parity error, 324 * return -1 if key parity error,
325 * return -2 if illegal weak key. 325 * return -2 if illegal weak key.
326 */ 326 */
327int des_set_key_checked(const_des_cblock *key, des_key_schedule schedule) 327int DES_set_key_checked(const_DES_cblock *key, DES_key_schedule *schedule)
328 { 328 {
329 if (!des_check_key_parity(key)) 329 if (!DES_check_key_parity(key))
330 return(-1); 330 return(-1);
331 if (des_is_weak_key(key)) 331 if (DES_is_weak_key(key))
332 return(-2); 332 return(-2);
333 des_set_key_unchecked(key, schedule); 333 DES_set_key_unchecked(key, schedule);
334 return 0; 334 return 0;
335 } 335 }
336 336
337void des_set_key_unchecked(const_des_cblock *key, des_key_schedule schedule) 337void DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule)
338 { 338 {
339 static int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0}; 339 static int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0};
340 register DES_LONG c,d,t,s,t2; 340 register DES_LONG c,d,t,s,t2;
@@ -342,7 +342,11 @@ void des_set_key_unchecked(const_des_cblock *key, des_key_schedule schedule)
342 register DES_LONG *k; 342 register DES_LONG *k;
343 register int i; 343 register int i;
344 344
345 k = &schedule->ks.deslong[0]; 345#if OPENBSD_DEV_CRYPTO
346 memcpy(schedule->key,key,sizeof schedule->key);
347 schedule->session=NULL;
348#endif
349 k = &schedule->ks->deslong[0];
346 in = &(*key)[0]; 350 in = &(*key)[0];
347 351
348 c2l(in,c); 352 c2l(in,c);
@@ -390,13 +394,14 @@ void des_set_key_unchecked(const_des_cblock *key, des_key_schedule schedule)
390 } 394 }
391 } 395 }
392 396
393int des_key_sched(const_des_cblock *key, des_key_schedule schedule) 397int DES_key_sched(const_DES_cblock *key, DES_key_schedule *schedule)
394 { 398 {
395 return(des_set_key(key,schedule)); 399 return(DES_set_key(key,schedule));
396 } 400 }
397 401/*
398#undef des_fixup_key_parity 402#undef des_fixup_key_parity
399void des_fixup_key_parity(des_cblock *key) 403void des_fixup_key_parity(des_cblock *key)
400 { 404 {
401 des_set_odd_parity(key); 405 des_set_odd_parity(key);
402 } 406 }
407*/
diff --git a/src/lib/libcrypto/des/speed.c b/src/lib/libcrypto/des/speed.c
index 1223edf290..48fc1d49fc 100644
--- a/src/lib/libcrypto/des/speed.c
+++ b/src/lib/libcrypto/des/speed.c
@@ -59,7 +59,7 @@
59/* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */ 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 */ 60/* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */
61 61
62#if !defined(MSDOS) && (!defined(VMS) || defined(__DECC)) 62#if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX)
63#define TIMES 63#define TIMES
64#endif 64#endif
65 65
@@ -82,7 +82,7 @@ OPENSSL_DECLARE_EXIT
82 The __TMS macro will show if it was. If it wasn't defined, we should 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 83 undefine TIMES, since that tells the rest of the program how things
84 should be handled. -- Richard Levitte */ 84 should be handled. -- Richard Levitte */
85#if defined(VMS) && defined(__DECC) && !defined(__TMS) 85#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
86#undef TIMES 86#undef TIMES
87#endif 87#endif
88 88
@@ -176,10 +176,10 @@ int main(int argc, char **argv)
176 { 176 {
177 long count; 177 long count;
178 static unsigned char buf[BUFSIZE]; 178 static unsigned char buf[BUFSIZE];
179 static des_cblock key ={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0}; 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}; 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}; 181 static DES_cblock key3={0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34};
182 des_key_schedule sch,sch2,sch3; 182 DES_key_schedule sch,sch2,sch3;
183 double a,b,c,d,e; 183 double a,b,c,d,e;
184#ifndef SIGALRM 184#ifndef SIGALRM
185 long ca,cb,cc,cd,ce; 185 long ca,cb,cc,cd,ce;
@@ -190,12 +190,12 @@ int main(int argc, char **argv)
190 printf("program when this computer is idle.\n"); 190 printf("program when this computer is idle.\n");
191#endif 191#endif
192 192
193 des_set_key_unchecked(&key2,sch2); 193 DES_set_key_unchecked(&key2,&sch2);
194 des_set_key_unchecked(&key3,sch3); 194 DES_set_key_unchecked(&key3,&sch3);
195 195
196#ifndef SIGALRM 196#ifndef SIGALRM
197 printf("First we calculate the approximate speed ...\n"); 197 printf("First we calculate the approximate speed ...\n");
198 des_set_key_unchecked(&key,sch); 198 DES_set_key_unchecked(&key,&sch);
199 count=10; 199 count=10;
200 do { 200 do {
201 long i; 201 long i;
@@ -204,7 +204,7 @@ int main(int argc, char **argv)
204 count*=2; 204 count*=2;
205 Time_F(START); 205 Time_F(START);
206 for (i=count; i; i--) 206 for (i=count; i; i--)
207 des_encrypt1(data,&(sch[0]),DES_ENCRYPT); 207 DES_encrypt1(data,&sch,DES_ENCRYPT);
208 d=Time_F(STOP); 208 d=Time_F(STOP);
209 } while (d < 3.0); 209 } while (d < 3.0);
210 ca=count; 210 ca=count;
@@ -225,63 +225,63 @@ int main(int argc, char **argv)
225 225
226 Time_F(START); 226 Time_F(START);
227 for (count=0,run=1; COND(ca); count++) 227 for (count=0,run=1; COND(ca); count++)
228 des_set_key_unchecked(&key,sch); 228 DES_set_key_unchecked(&key,&sch);
229 d=Time_F(STOP); 229 d=Time_F(STOP);
230 printf("%ld set_key's in %.2f seconds\n",count,d); 230 printf("%ld set_key's in %.2f seconds\n",count,d);
231 a=((double)COUNT(ca))/d; 231 a=((double)COUNT(ca))/d;
232 232
233#ifdef SIGALRM 233#ifdef SIGALRM
234 printf("Doing des_encrypt's for 10 seconds\n"); 234 printf("Doing DES_encrypt's for 10 seconds\n");
235 alarm(10); 235 alarm(10);
236#else 236#else
237 printf("Doing des_encrypt %ld times\n",cb); 237 printf("Doing DES_encrypt %ld times\n",cb);
238#endif 238#endif
239 Time_F(START); 239 Time_F(START);
240 for (count=0,run=1; COND(cb); count++) 240 for (count=0,run=1; COND(cb); count++)
241 { 241 {
242 DES_LONG data[2]; 242 DES_LONG data[2];
243 243
244 des_encrypt1(data,&(sch[0]),DES_ENCRYPT); 244 DES_encrypt1(data,&sch,DES_ENCRYPT);
245 } 245 }
246 d=Time_F(STOP); 246 d=Time_F(STOP);
247 printf("%ld des_encrypt's in %.2f second\n",count,d); 247 printf("%ld DES_encrypt's in %.2f second\n",count,d);
248 b=((double)COUNT(cb)*8)/d; 248 b=((double)COUNT(cb)*8)/d;
249 249
250#ifdef SIGALRM 250#ifdef SIGALRM
251 printf("Doing des_cbc_encrypt on %ld byte blocks for 10 seconds\n", 251 printf("Doing DES_cbc_encrypt on %ld byte blocks for 10 seconds\n",
252 BUFSIZE); 252 BUFSIZE);
253 alarm(10); 253 alarm(10);
254#else 254#else
255 printf("Doing des_cbc_encrypt %ld times on %ld byte blocks\n",cc, 255 printf("Doing DES_cbc_encrypt %ld times on %ld byte blocks\n",cc,
256 BUFSIZE); 256 BUFSIZE);
257#endif 257#endif
258 Time_F(START); 258 Time_F(START);
259 for (count=0,run=1; COND(cc); count++) 259 for (count=0,run=1; COND(cc); count++)
260 des_ncbc_encrypt(buf,buf,BUFSIZE,&(sch[0]), 260 DES_ncbc_encrypt(buf,buf,BUFSIZE,&sch,
261 &key,DES_ENCRYPT); 261 &key,DES_ENCRYPT);
262 d=Time_F(STOP); 262 d=Time_F(STOP);
263 printf("%ld des_cbc_encrypt's of %ld byte blocks in %.2f second\n", 263 printf("%ld DES_cbc_encrypt's of %ld byte blocks in %.2f second\n",
264 count,BUFSIZE,d); 264 count,BUFSIZE,d);
265 c=((double)COUNT(cc)*BUFSIZE)/d; 265 c=((double)COUNT(cc)*BUFSIZE)/d;
266 266
267#ifdef SIGALRM 267#ifdef SIGALRM
268 printf("Doing des_ede_cbc_encrypt on %ld byte blocks for 10 seconds\n", 268 printf("Doing DES_ede_cbc_encrypt on %ld byte blocks for 10 seconds\n",
269 BUFSIZE); 269 BUFSIZE);
270 alarm(10); 270 alarm(10);
271#else 271#else
272 printf("Doing des_ede_cbc_encrypt %ld times on %ld byte blocks\n",cd, 272 printf("Doing DES_ede_cbc_encrypt %ld times on %ld byte blocks\n",cd,
273 BUFSIZE); 273 BUFSIZE);
274#endif 274#endif
275 Time_F(START); 275 Time_F(START);
276 for (count=0,run=1; COND(cd); count++) 276 for (count=0,run=1; COND(cd); count++)
277 des_ede3_cbc_encrypt(buf,buf,BUFSIZE, 277 DES_ede3_cbc_encrypt(buf,buf,BUFSIZE,
278 &(sch[0]), 278 &sch,
279 &(sch2[0]), 279 &sch2,
280 &(sch3[0]), 280 &sch3,
281 &key, 281 &key,
282 DES_ENCRYPT); 282 DES_ENCRYPT);
283 d=Time_F(STOP); 283 d=Time_F(STOP);
284 printf("%ld des_ede_cbc_encrypt's of %ld byte blocks in %.2f second\n", 284 printf("%ld DES_ede_cbc_encrypt's of %ld byte blocks in %.2f second\n",
285 count,BUFSIZE,d); 285 count,BUFSIZE,d);
286 d=((double)COUNT(cd)*BUFSIZE)/d; 286 d=((double)COUNT(cd)*BUFSIZE)/d;
287 287
@@ -304,7 +304,7 @@ int main(int argc, char **argv)
304 printf("DES ede cbc bytes per sec = %12.2f (%9.3fuS)\n",d,8.0e6/d); 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); 305 printf("crypt per sec = %12.2f (%9.3fuS)\n",e,1.0e6/e);
306 exit(0); 306 exit(0);
307#if defined(LINT) || defined(MSDOS) 307#if defined(LINT) || defined(OPENSSL_SYS_MSDOS)
308 return(0); 308 return(0);
309#endif 309#endif
310 } 310 }
diff --git a/src/lib/libcrypto/des/spr.h b/src/lib/libcrypto/des/spr.h
index b8fbdcf8d3..b91936a5a5 100644
--- a/src/lib/libcrypto/des/spr.h
+++ b/src/lib/libcrypto/des/spr.h
@@ -56,7 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59OPENSSL_GLOBAL const DES_LONG des_SPtrans[8][64]={ 59OPENSSL_GLOBAL const DES_LONG DES_SPtrans[8][64]={
60{ 60{
61/* nibble 0 */ 61/* nibble 0 */
620x02080800L, 0x00080000L, 0x02000002L, 0x02080802L, 620x02080800L, 0x00080000L, 0x02000002L, 0x02080802L,
diff --git a/src/lib/libcrypto/des/str2key.c b/src/lib/libcrypto/des/str2key.c
index c6abb87201..36c3f81d99 100644
--- a/src/lib/libcrypto/des/str2key.c
+++ b/src/lib/libcrypto/des/str2key.c
@@ -58,9 +58,9 @@
58 58
59#include "des_locl.h" 59#include "des_locl.h"
60 60
61void des_string_to_key(const char *str, des_cblock *key) 61void DES_string_to_key(const char *str, DES_cblock *key)
62 { 62 {
63 des_key_schedule ks; 63 DES_key_schedule ks;
64 int i,length; 64 int i,length;
65 register unsigned char j; 65 register unsigned char j;
66 66
@@ -85,16 +85,22 @@ void des_string_to_key(const char *str, des_cblock *key)
85 } 85 }
86 } 86 }
87#endif 87#endif
88 des_set_odd_parity(key); 88 DES_set_odd_parity(key);
89 des_set_key_unchecked(key,ks); 89#ifdef EXPERIMENTAL_STR_TO_STRONG_KEY
90 des_cbc_cksum((const unsigned char*)str,key,length,ks,key); 90 if(DES_is_weak_key(key))
91 memset(ks,0,sizeof(ks)); 91 (*key)[7] ^= 0xF0;
92 des_set_odd_parity(key); 92 DES_set_key(key,&ks);
93#else
94 DES_set_key_unchecked(key,&ks);
95#endif
96 DES_cbc_cksum((const unsigned char*)str,key,length,&ks,key);
97 memset(&ks,0,sizeof(ks));
98 DES_set_odd_parity(key);
93 } 99 }
94 100
95void des_string_to_2keys(const char *str, des_cblock *key1, des_cblock *key2) 101void DES_string_to_2keys(const char *str, DES_cblock *key1, DES_cblock *key2)
96 { 102 {
97 des_key_schedule ks; 103 DES_key_schedule ks;
98 int i,length; 104 int i,length;
99 register unsigned char j; 105 register unsigned char j;
100 106
@@ -143,13 +149,25 @@ void des_string_to_2keys(const char *str, des_cblock *key1, des_cblock *key2)
143 } 149 }
144 if (length <= 8) memcpy(key2,key1,8); 150 if (length <= 8) memcpy(key2,key1,8);
145#endif 151#endif
146 des_set_odd_parity(key1); 152 DES_set_odd_parity(key1);
147 des_set_odd_parity(key2); 153 DES_set_odd_parity(key2);
148 des_set_key_unchecked(key1,ks); 154#ifdef EXPERIMENTAL_STR_TO_STRONG_KEY
149 des_cbc_cksum((const unsigned char*)str,key1,length,ks,key1); 155 if(DES_is_weak_key(key1))
150 des_set_key_unchecked(key2,ks); 156 (*key1)[7] ^= 0xF0;
151 des_cbc_cksum((const unsigned char*)str,key2,length,ks,key2); 157 DES_set_key(key1,&ks);
152 memset(ks,0,sizeof(ks)); 158#else
153 des_set_odd_parity(key1); 159 DES_set_key_unchecked(key1,&ks);
154 des_set_odd_parity(key2); 160#endif
161 DES_cbc_cksum((const unsigned char*)str,key1,length,&ks,key1);
162#ifdef EXPERIMENTAL_STR_TO_STRONG_KEY
163 if(DES_is_weak_key(key2))
164 (*key2)[7] ^= 0xF0;
165 DES_set_key(key2,&ks);
166#else
167 DES_set_key_unchecked(key2,&ks);
168#endif
169 DES_cbc_cksum((const unsigned char*)str,key2,length,&ks,key2);
170 memset(&ks,0,sizeof(ks));
171 DES_set_odd_parity(key1);
172 DES_set_odd_parity(key2);
155 } 173 }
diff --git a/src/lib/libcrypto/des/xcbc_enc.c b/src/lib/libcrypto/des/xcbc_enc.c
index ccfede13ac..47246eb466 100644
--- a/src/lib/libcrypto/des/xcbc_enc.c
+++ b/src/lib/libcrypto/des/xcbc_enc.c
@@ -79,8 +79,8 @@ static unsigned char desx_white_in2out[256]={
790xA7,0x1C,0xC9,0x09,0x69,0x9A,0x83,0xCF,0x29,0x39,0xB9,0xE9,0x4C,0xFF,0x43,0xAB, 790xA7,0x1C,0xC9,0x09,0x69,0x9A,0x83,0xCF,0x29,0x39,0xB9,0xE9,0x4C,0xFF,0x43,0xAB,
80 }; 80 };
81 81
82void des_xwhite_in2out(const_des_cblock *des_key, const_des_cblock *in_white, 82void DES_xwhite_in2out(const_DES_cblock *des_key, const_DES_cblock *in_white,
83 des_cblock *out_white) 83 DES_cblock *out_white)
84 { 84 {
85 int out0,out1; 85 int out0,out1;
86 int i; 86 int i;
@@ -107,9 +107,10 @@ void des_xwhite_in2out(const_des_cblock *des_key, const_des_cblock *in_white,
107 } 107 }
108 } 108 }
109 109
110void des_xcbc_encrypt(const unsigned char *in, unsigned char *out, 110void DES_xcbc_encrypt(const unsigned char *in, unsigned char *out,
111 long length, des_key_schedule schedule, des_cblock *ivec, 111 long length, DES_key_schedule *schedule,
112 const_des_cblock *inw, const_des_cblock *outw, int enc) 112 DES_cblock *ivec, const_DES_cblock *inw,
113 const_DES_cblock *outw, int enc)
113 { 114 {
114 register DES_LONG tin0,tin1; 115 register DES_LONG tin0,tin1;
115 register DES_LONG tout0,tout1,xor0,xor1; 116 register DES_LONG tout0,tout1,xor0,xor1;
@@ -138,7 +139,7 @@ void des_xcbc_encrypt(const unsigned char *in, unsigned char *out,
138 c2l(in,tin1); 139 c2l(in,tin1);
139 tin0^=tout0^inW0; tin[0]=tin0; 140 tin0^=tout0^inW0; tin[0]=tin0;
140 tin1^=tout1^inW1; tin[1]=tin1; 141 tin1^=tout1^inW1; tin[1]=tin1;
141 des_encrypt1(tin,schedule,DES_ENCRYPT); 142 DES_encrypt1(tin,schedule,DES_ENCRYPT);
142 tout0=tin[0]^outW0; l2c(tout0,out); 143 tout0=tin[0]^outW0; l2c(tout0,out);
143 tout1=tin[1]^outW1; l2c(tout1,out); 144 tout1=tin[1]^outW1; l2c(tout1,out);
144 } 145 }
@@ -147,7 +148,7 @@ void des_xcbc_encrypt(const unsigned char *in, unsigned char *out,
147 c2ln(in,tin0,tin1,l+8); 148 c2ln(in,tin0,tin1,l+8);
148 tin0^=tout0^inW0; tin[0]=tin0; 149 tin0^=tout0^inW0; tin[0]=tin0;
149 tin1^=tout1^inW1; tin[1]=tin1; 150 tin1^=tout1^inW1; tin[1]=tin1;
150 des_encrypt1(tin,schedule,DES_ENCRYPT); 151 DES_encrypt1(tin,schedule,DES_ENCRYPT);
151 tout0=tin[0]^outW0; l2c(tout0,out); 152 tout0=tin[0]^outW0; l2c(tout0,out);
152 tout1=tin[1]^outW1; l2c(tout1,out); 153 tout1=tin[1]^outW1; l2c(tout1,out);
153 } 154 }
@@ -163,7 +164,7 @@ void des_xcbc_encrypt(const unsigned char *in, unsigned char *out,
163 { 164 {
164 c2l(in,tin0); tin[0]=tin0^outW0; 165 c2l(in,tin0); tin[0]=tin0^outW0;
165 c2l(in,tin1); tin[1]=tin1^outW1; 166 c2l(in,tin1); tin[1]=tin1^outW1;
166 des_encrypt1(tin,schedule,DES_DECRYPT); 167 DES_encrypt1(tin,schedule,DES_DECRYPT);
167 tout0=tin[0]^xor0^inW0; 168 tout0=tin[0]^xor0^inW0;
168 tout1=tin[1]^xor1^inW1; 169 tout1=tin[1]^xor1^inW1;
169 l2c(tout0,out); 170 l2c(tout0,out);
@@ -175,7 +176,7 @@ void des_xcbc_encrypt(const unsigned char *in, unsigned char *out,
175 { 176 {
176 c2l(in,tin0); tin[0]=tin0^outW0; 177 c2l(in,tin0); tin[0]=tin0^outW0;
177 c2l(in,tin1); tin[1]=tin1^outW1; 178 c2l(in,tin1); tin[1]=tin1^outW1;
178 des_encrypt1(tin,schedule,DES_DECRYPT); 179 DES_encrypt1(tin,schedule,DES_DECRYPT);
179 tout0=tin[0]^xor0^inW0; 180 tout0=tin[0]^xor0^inW0;
180 tout1=tin[1]^xor1^inW1; 181 tout1=tin[1]^xor1^inW1;
181 l2cn(tout0,tout1,out,l+8); 182 l2cn(tout0,tout1,out,l+8);
diff --git a/src/lib/libcrypto/dh/Makefile.ssl b/src/lib/libcrypto/dh/Makefile.ssl
index bf4b47ca9a..209e2bf39c 100644
--- a/src/lib/libcrypto/dh/Makefile.ssl
+++ b/src/lib/libcrypto/dh/Makefile.ssl
@@ -5,13 +5,14 @@
5DIR= dh 5DIR= dh
6TOP= ../.. 6TOP= ../..
7CC= cc 7CC= cc
8INCLUDES= -I.. -I../../include 8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g 9CFLAG=-g
10INSTALL_PREFIX= 10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl 11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl 12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl 13MAKE= make -f Makefile.ssl
14MAKEDEPEND= $(TOP)/util/domd $(TOP) 14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
15MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
16AR= ar r 17AR= ar r
17 18
@@ -22,8 +23,8 @@ TEST= dhtest.c
22APPS= 23APPS=
23 24
24LIB=$(TOP)/libcrypto.a 25LIB=$(TOP)/libcrypto.a
25LIBSRC= dh_gen.c dh_key.c dh_lib.c dh_check.c dh_err.c 26LIBSRC= dh_asn1.c dh_gen.c dh_key.c dh_lib.c dh_check.c dh_err.c
26LIBOBJ= dh_gen.o dh_key.o dh_lib.o dh_check.o dh_err.o 27LIBOBJ= dh_asn1.o dh_gen.o dh_key.o dh_lib.o dh_check.o dh_err.o
27 28
28SRC= $(LIBSRC) 29SRC= $(LIBSRC)
29 30
@@ -39,8 +40,7 @@ all: lib
39 40
40lib: $(LIBOBJ) 41lib: $(LIBOBJ)
41 $(AR) $(LIB) $(LIBOBJ) 42 $(AR) $(LIB) $(LIBOBJ)
42 @echo You may get an error following this line. Please ignore. 43 $(RANLIB) $(LIB) || echo Never mind.
43 - $(RANLIB) $(LIB)
44 @touch lib 44 @touch lib
45 45
46files: 46files:
@@ -79,61 +79,58 @@ clean:
79 79
80# DO NOT DELETE THIS LINE -- make depend depends on it. 80# DO NOT DELETE THIS LINE -- make depend depends on it.
81 81
82dh_check.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 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
83dh_check.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 93dh_check.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
84dh_check.o: ../../include/openssl/dh.h ../../include/openssl/e_os.h 94dh_check.o: ../../include/openssl/dh.h ../../include/openssl/e_os2.h
85dh_check.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 95dh_check.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
86dh_check.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 96dh_check.o: ../../include/openssl/opensslconf.h
87dh_check.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 97dh_check.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
88dh_check.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 98dh_check.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
89dh_check.o: ../cryptlib.h 99dh_check.o: ../../include/openssl/symhacks.h ../cryptlib.h dh_check.c
90dh_err.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 100dh_err.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
91dh_err.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h 101dh_err.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
92dh_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 102dh_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
93dh_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 103dh_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
104dh_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
94dh_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 105dh_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
95dh_err.o: ../../include/openssl/symhacks.h 106dh_err.o: ../../include/openssl/symhacks.h dh_err.c
96dh_gen.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 107dh_gen.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
97dh_gen.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 108dh_gen.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
98dh_gen.o: ../../include/openssl/dh.h ../../include/openssl/e_os.h 109dh_gen.o: ../../include/openssl/dh.h ../../include/openssl/e_os2.h
99dh_gen.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 110dh_gen.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
100dh_gen.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 111dh_gen.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
101dh_gen.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 112dh_gen.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
102dh_gen.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 113dh_gen.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
103dh_gen.o: ../cryptlib.h 114dh_gen.o: ../cryptlib.h dh_gen.c
104dh_key.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 115dh_key.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
105dh_key.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 116dh_key.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
106dh_key.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 117dh_key.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
107dh_key.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 118dh_key.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
108dh_key.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
109dh_key.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
110dh_key.o: ../../include/openssl/engine.h ../../include/openssl/err.h 119dh_key.o: ../../include/openssl/engine.h ../../include/openssl/err.h
111dh_key.o: ../../include/openssl/evp.h ../../include/openssl/idea.h 120dh_key.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
112dh_key.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h 121dh_key.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
113dh_key.o: ../../include/openssl/md4.h ../../include/openssl/md5.h 122dh_key.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
114dh_key.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h 123dh_key.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
115dh_key.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 124dh_key.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
116dh_key.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 125dh_key.o: ../cryptlib.h dh_key.c
117dh_key.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 126dh_lib.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
118dh_key.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 127dh_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
119dh_key.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 128dh_lib.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
120dh_key.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 129dh_lib.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
121dh_key.o: ../../include/openssl/symhacks.h ../cryptlib.h
122dh_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
123dh_lib.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
124dh_lib.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
125dh_lib.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
126dh_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
127dh_lib.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
128dh_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h 130dh_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h
129dh_lib.o: ../../include/openssl/evp.h ../../include/openssl/idea.h 131dh_lib.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
130dh_lib.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h 132dh_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
131dh_lib.o: ../../include/openssl/md4.h ../../include/openssl/md5.h 133dh_lib.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
132dh_lib.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h 134dh_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
133dh_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 135dh_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
134dh_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 136dh_lib.o: ../cryptlib.h dh_lib.c
135dh_lib.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
136dh_lib.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
137dh_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
138dh_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
139dh_lib.o: ../../include/openssl/symhacks.h ../cryptlib.h
diff --git a/src/lib/libcrypto/dh/dh.h b/src/lib/libcrypto/dh/dh.h
index 7a8d9f88c2..d51dc130f4 100644
--- a/src/lib/libcrypto/dh/dh.h
+++ b/src/lib/libcrypto/dh/dh.h
@@ -59,15 +59,16 @@
59#ifndef HEADER_DH_H 59#ifndef HEADER_DH_H
60#define HEADER_DH_H 60#define HEADER_DH_H
61 61
62#ifdef NO_DH 62#ifdef OPENSSL_NO_DH
63#error DH is disabled. 63#error DH is disabled.
64#endif 64#endif
65 65
66#ifndef NO_BIO 66#ifndef OPENSSL_NO_BIO
67#include <openssl/bio.h> 67#include <openssl/bio.h>
68#endif 68#endif
69#include <openssl/bn.h> 69#include <openssl/bn.h>
70#include <openssl/crypto.h> 70#include <openssl/crypto.h>
71#include <openssl/ossl_typ.h>
71 72
72#define DH_FLAG_CACHE_MONT_P 0x01 73#define DH_FLAG_CACHE_MONT_P 0x01
73 74
@@ -81,9 +82,9 @@ typedef struct dh_method {
81 const char *name; 82 const char *name;
82 /* Methods here */ 83 /* Methods here */
83 int (*generate_key)(DH *dh); 84 int (*generate_key)(DH *dh);
84 int (*compute_key)(unsigned char *key,BIGNUM *pub_key,DH *dh); 85 int (*compute_key)(unsigned char *key,const BIGNUM *pub_key,DH *dh);
85 int (*bn_mod_exp)(DH *dh, BIGNUM *r, BIGNUM *a, const BIGNUM *p, 86 int (*bn_mod_exp)(const DH *dh, BIGNUM *r, const BIGNUM *a,
86 const BIGNUM *m, BN_CTX *ctx, 87 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
87 BN_MONT_CTX *m_ctx); /* Can be null */ 88 BN_MONT_CTX *m_ctx); /* Can be null */
88 89
89 int (*init)(DH *dh); 90 int (*init)(DH *dh);
@@ -115,11 +116,8 @@ struct dh_st
115 116
116 int references; 117 int references;
117 CRYPTO_EX_DATA ex_data; 118 CRYPTO_EX_DATA ex_data;
118#if 0 119 const DH_METHOD *meth;
119 DH_METHOD *meth; 120 ENGINE *engine;
120#else
121 struct engine_st *engine;
122#endif
123 }; 121 };
124 122
125#define DH_GENERATOR_2 2 123#define DH_GENERATOR_2 2
@@ -152,46 +150,42 @@ struct dh_st
152 (unsigned char *)(x)) 150 (unsigned char *)(x))
153#endif 151#endif
154 152
155DH_METHOD *DH_OpenSSL(void); 153const DH_METHOD *DH_OpenSSL(void);
156 154
157void DH_set_default_openssl_method(DH_METHOD *meth); 155void DH_set_default_method(const DH_METHOD *meth);
158DH_METHOD *DH_get_default_openssl_method(void); 156const DH_METHOD *DH_get_default_method(void);
159#if 0 157int DH_set_method(DH *dh, const DH_METHOD *meth);
160DH_METHOD *DH_set_method(DH *dh, DH_METHOD *meth); 158DH *DH_new_method(ENGINE *engine);
161DH *DH_new_method(DH_METHOD *meth);
162#else
163int DH_set_method(DH *dh, struct engine_st *engine);
164DH *DH_new_method(struct engine_st *engine);
165#endif
166 159
167DH * DH_new(void); 160DH * DH_new(void);
168void DH_free(DH *dh); 161void DH_free(DH *dh);
169int DH_size(DH *dh); 162int DH_up_ref(DH *dh);
163int DH_size(const DH *dh);
170int DH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, 164int DH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
171 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); 165 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
172int DH_set_ex_data(DH *d, int idx, void *arg); 166int DH_set_ex_data(DH *d, int idx, void *arg);
173void *DH_get_ex_data(DH *d, int idx); 167void *DH_get_ex_data(DH *d, int idx);
174DH * DH_generate_parameters(int prime_len,int generator, 168DH * DH_generate_parameters(int prime_len,int generator,
175 void (*callback)(int,int,void *),void *cb_arg); 169 void (*callback)(int,int,void *),void *cb_arg);
176int DH_check(DH *dh,int *codes); 170int DH_check(const DH *dh,int *codes);
177int DH_generate_key(DH *dh); 171int DH_generate_key(DH *dh);
178int DH_compute_key(unsigned char *key,BIGNUM *pub_key,DH *dh); 172int DH_compute_key(unsigned char *key,const BIGNUM *pub_key,DH *dh);
179DH * d2i_DHparams(DH **a,unsigned char **pp, long length); 173DH * d2i_DHparams(DH **a,const unsigned char **pp, long length);
180int i2d_DHparams(DH *a,unsigned char **pp); 174int i2d_DHparams(const DH *a,unsigned char **pp);
181#ifndef NO_FP_API 175#ifndef OPENSSL_NO_FP_API
182int DHparams_print_fp(FILE *fp, DH *x); 176int DHparams_print_fp(FILE *fp, const DH *x);
183#endif 177#endif
184#ifndef NO_BIO 178#ifndef OPENSSL_NO_BIO
185int DHparams_print(BIO *bp, DH *x); 179int DHparams_print(BIO *bp, const DH *x);
186#else 180#else
187int DHparams_print(char *bp, DH *x); 181int DHparams_print(char *bp, const DH *x);
188#endif 182#endif
189void ERR_load_DH_strings(void );
190 183
191/* BEGIN ERROR CODES */ 184/* BEGIN ERROR CODES */
192/* The following lines are auto generated by the script mkerr.pl. Any changes 185/* The following lines are auto generated by the script mkerr.pl. Any changes
193 * made after this point may be overwritten when the script is next run. 186 * made after this point may be overwritten when the script is next run.
194 */ 187 */
188void ERR_load_DH_strings(void);
195 189
196/* Error codes for the DH functions. */ 190/* Error codes for the DH functions. */
197 191
@@ -201,13 +195,13 @@ void ERR_load_DH_strings(void );
201#define DH_F_DH_COMPUTE_KEY 102 195#define DH_F_DH_COMPUTE_KEY 102
202#define DH_F_DH_GENERATE_KEY 103 196#define DH_F_DH_GENERATE_KEY 103
203#define DH_F_DH_GENERATE_PARAMETERS 104 197#define DH_F_DH_GENERATE_PARAMETERS 104
204#define DH_F_DH_NEW 105 198#define DH_F_DH_NEW_METHOD 105
205 199
206/* Reason codes. */ 200/* Reason codes. */
201#define DH_R_BAD_GENERATOR 101
207#define DH_R_NO_PRIVATE_VALUE 100 202#define DH_R_NO_PRIVATE_VALUE 100
208 203
209#ifdef __cplusplus 204#ifdef __cplusplus
210} 205}
211#endif 206#endif
212#endif 207#endif
213
diff --git a/src/lib/libcrypto/dh/dh_asn1.c b/src/lib/libcrypto/dh/dh_asn1.c
new file mode 100644
index 0000000000..769b5b68c5
--- /dev/null
+++ b/src/lib/libcrypto/dh/dh_asn1.c
@@ -0,0 +1,87 @@
1/* dh_asn1.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) 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/bn.h>
62#include <openssl/dh.h>
63#include <openssl/objects.h>
64#include <openssl/asn1t.h>
65
66/* Override the default free and new methods */
67static int dh_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it)
68{
69 if(operation == ASN1_OP_NEW_PRE) {
70 *pval = (ASN1_VALUE *)DH_new();
71 if(*pval) return 2;
72 return 0;
73 } else if(operation == ASN1_OP_FREE_PRE) {
74 DH_free((DH *)*pval);
75 *pval = NULL;
76 return 2;
77 }
78 return 1;
79}
80
81ASN1_SEQUENCE_cb(DHparams, dh_cb) = {
82 ASN1_SIMPLE(DH, p, BIGNUM),
83 ASN1_SIMPLE(DH, g, BIGNUM),
84 ASN1_OPT(DH, length, ZLONG),
85} ASN1_SEQUENCE_END_cb(DH, DHparams)
86
87IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DH, DHparams, DHparams)
diff --git a/src/lib/libcrypto/dh/dh_check.c b/src/lib/libcrypto/dh/dh_check.c
index 7e5cfd8bfc..f0373f7d68 100644
--- a/src/lib/libcrypto/dh/dh_check.c
+++ b/src/lib/libcrypto/dh/dh_check.c
@@ -70,7 +70,7 @@
70 * should hold. 70 * should hold.
71 */ 71 */
72 72
73int DH_check(DH *dh, int *ret) 73int DH_check(const DH *dh, int *ret)
74 { 74 {
75 int ok=0; 75 int ok=0;
76 BN_CTX *ctx=NULL; 76 BN_CTX *ctx=NULL;
diff --git a/src/lib/libcrypto/dh/dh_err.c b/src/lib/libcrypto/dh/dh_err.c
index ff2d1684c2..d837950aec 100644
--- a/src/lib/libcrypto/dh/dh_err.c
+++ b/src/lib/libcrypto/dh/dh_err.c
@@ -1,6 +1,6 @@
1/* crypto/dh/dh_err.c */ 1/* crypto/dh/dh_err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2002 The OpenSSL Project. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
@@ -63,7 +63,7 @@
63#include <openssl/dh.h> 63#include <openssl/dh.h>
64 64
65/* BEGIN ERROR CODES */ 65/* BEGIN ERROR CODES */
66#ifndef NO_ERR 66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA DH_str_functs[]= 67static ERR_STRING_DATA DH_str_functs[]=
68 { 68 {
69{ERR_PACK(0,DH_F_DHPARAMS_PRINT,0), "DHparams_print"}, 69{ERR_PACK(0,DH_F_DHPARAMS_PRINT,0), "DHparams_print"},
@@ -71,12 +71,13 @@ static ERR_STRING_DATA DH_str_functs[]=
71{ERR_PACK(0,DH_F_DH_COMPUTE_KEY,0), "DH_compute_key"}, 71{ERR_PACK(0,DH_F_DH_COMPUTE_KEY,0), "DH_compute_key"},
72{ERR_PACK(0,DH_F_DH_GENERATE_KEY,0), "DH_generate_key"}, 72{ERR_PACK(0,DH_F_DH_GENERATE_KEY,0), "DH_generate_key"},
73{ERR_PACK(0,DH_F_DH_GENERATE_PARAMETERS,0), "DH_generate_parameters"}, 73{ERR_PACK(0,DH_F_DH_GENERATE_PARAMETERS,0), "DH_generate_parameters"},
74{ERR_PACK(0,DH_F_DH_NEW,0), "DH_new"}, 74{ERR_PACK(0,DH_F_DH_NEW_METHOD,0), "DH_new_method"},
75{0,NULL} 75{0,NULL}
76 }; 76 };
77 77
78static ERR_STRING_DATA DH_str_reasons[]= 78static ERR_STRING_DATA DH_str_reasons[]=
79 { 79 {
80{DH_R_BAD_GENERATOR ,"bad generator"},
80{DH_R_NO_PRIVATE_VALUE ,"no private value"}, 81{DH_R_NO_PRIVATE_VALUE ,"no private value"},
81{0,NULL} 82{0,NULL}
82 }; 83 };
@@ -90,7 +91,7 @@ void ERR_load_DH_strings(void)
90 if (init) 91 if (init)
91 { 92 {
92 init=0; 93 init=0;
93#ifndef NO_ERR 94#ifndef OPENSSL_NO_ERR
94 ERR_load_strings(ERR_LIB_DH,DH_str_functs); 95 ERR_load_strings(ERR_LIB_DH,DH_str_functs);
95 ERR_load_strings(ERR_LIB_DH,DH_str_reasons); 96 ERR_load_strings(ERR_LIB_DH,DH_str_reasons);
96#endif 97#endif
diff --git a/src/lib/libcrypto/dh/dh_gen.c b/src/lib/libcrypto/dh/dh_gen.c
index 7a6a38fbb4..06f78b35ab 100644
--- a/src/lib/libcrypto/dh/dh_gen.c
+++ b/src/lib/libcrypto/dh/dh_gen.c
@@ -82,7 +82,10 @@
82 * Since DH should be using a safe prime (both p and q are prime), 82 * Since DH should be using a safe prime (both p and q are prime),
83 * this generator function can take a very very long time to run. 83 * this generator function can take a very very long time to run.
84 */ 84 */
85 85/* Actually there is no reason to insist that 'generator' be a generator.
86 * It's just as OK (and in some sense better) to use a generator of the
87 * order-q subgroup.
88 */
86DH *DH_generate_parameters(int prime_len, int generator, 89DH *DH_generate_parameters(int prime_len, int generator,
87 void (*callback)(int,int,void *), void *cb_arg) 90 void (*callback)(int,int,void *), void *cb_arg)
88 { 91 {
@@ -100,30 +103,43 @@ DH *DH_generate_parameters(int prime_len, int generator,
100 t2 = BN_CTX_get(ctx); 103 t2 = BN_CTX_get(ctx);
101 if (t1 == NULL || t2 == NULL) goto err; 104 if (t1 == NULL || t2 == NULL) goto err;
102 105
106 if (generator <= 1)
107 {
108 DHerr(DH_F_DH_GENERATE_PARAMETERS, DH_R_BAD_GENERATOR);
109 goto err;
110 }
103 if (generator == DH_GENERATOR_2) 111 if (generator == DH_GENERATOR_2)
104 { 112 {
105 BN_set_word(t1,24); 113 if (!BN_set_word(t1,24)) goto err;
106 BN_set_word(t2,11); 114 if (!BN_set_word(t2,11)) goto err;
107 g=2; 115 g=2;
108 } 116 }
109#ifdef undef /* does not work for safe primes */ 117#if 0 /* does not work for safe primes */
110 else if (generator == DH_GENERATOR_3) 118 else if (generator == DH_GENERATOR_3)
111 { 119 {
112 BN_set_word(t1,12); 120 if (!BN_set_word(t1,12)) goto err;
113 BN_set_word(t2,5); 121 if (!BN_set_word(t2,5)) goto err;
114 g=3; 122 g=3;
115 } 123 }
116#endif 124#endif
117 else if (generator == DH_GENERATOR_5) 125 else if (generator == DH_GENERATOR_5)
118 { 126 {
119 BN_set_word(t1,10); 127 if (!BN_set_word(t1,10)) goto err;
120 BN_set_word(t2,3); 128 if (!BN_set_word(t2,3)) goto err;
121 /* BN_set_word(t3,7); just have to miss 129 /* BN_set_word(t3,7); just have to miss
122 * out on these ones :-( */ 130 * out on these ones :-( */
123 g=5; 131 g=5;
124 } 132 }
125 else 133 else
134 {
135 /* in the general case, don't worry if 'generator' is a
136 * generator or not: since we are using safe primes,
137 * it will generate either an order-q or an order-2q group,
138 * which both is OK */
139 if (!BN_set_word(t1,2)) goto err;
140 if (!BN_set_word(t2,1)) goto err;
126 g=generator; 141 g=generator;
142 }
127 143
128 p=BN_generate_prime(NULL,prime_len,1,t1,t2,callback,cb_arg); 144 p=BN_generate_prime(NULL,prime_len,1,t1,t2,callback,cb_arg);
129 if (p == NULL) goto err; 145 if (p == NULL) goto err;
diff --git a/src/lib/libcrypto/dh/dh_key.c b/src/lib/libcrypto/dh/dh_key.c
index 22b087b778..1a0efca2c4 100644
--- a/src/lib/libcrypto/dh/dh_key.c
+++ b/src/lib/libcrypto/dh/dh_key.c
@@ -64,8 +64,9 @@
64#include <openssl/engine.h> 64#include <openssl/engine.h>
65 65
66static int generate_key(DH *dh); 66static int generate_key(DH *dh);
67static int compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh); 67static int compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh);
68static int dh_bn_mod_exp(DH *dh, BIGNUM *r, BIGNUM *a, const BIGNUM *p, 68static int dh_bn_mod_exp(const DH *dh, BIGNUM *r,
69 const BIGNUM *a, const BIGNUM *p,
69 const BIGNUM *m, BN_CTX *ctx, 70 const BIGNUM *m, BN_CTX *ctx,
70 BN_MONT_CTX *m_ctx); 71 BN_MONT_CTX *m_ctx);
71static int dh_init(DH *dh); 72static int dh_init(DH *dh);
@@ -73,12 +74,12 @@ static int dh_finish(DH *dh);
73 74
74int DH_generate_key(DH *dh) 75int DH_generate_key(DH *dh)
75 { 76 {
76 return ENGINE_get_DH(dh->engine)->generate_key(dh); 77 return dh->meth->generate_key(dh);
77 } 78 }
78 79
79int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh) 80int DH_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh)
80 { 81 {
81 return ENGINE_get_DH(dh->engine)->compute_key(key, pub_key, dh); 82 return dh->meth->compute_key(key, pub_key, dh);
82 } 83 }
83 84
84static DH_METHOD dh_ossl = { 85static DH_METHOD dh_ossl = {
@@ -92,7 +93,7 @@ dh_finish,
92NULL 93NULL
93}; 94};
94 95
95DH_METHOD *DH_OpenSSL(void) 96const DH_METHOD *DH_OpenSSL(void)
96{ 97{
97 return &dh_ossl; 98 return &dh_ossl;
98} 99}
@@ -100,19 +101,20 @@ DH_METHOD *DH_OpenSSL(void)
100static int generate_key(DH *dh) 101static int generate_key(DH *dh)
101 { 102 {
102 int ok=0; 103 int ok=0;
103 BN_CTX ctx; 104 int generate_new_key=0;
105 unsigned l;
106 BN_CTX *ctx;
104 BN_MONT_CTX *mont; 107 BN_MONT_CTX *mont;
105 BIGNUM *pub_key=NULL,*priv_key=NULL; 108 BIGNUM *pub_key=NULL,*priv_key=NULL;
106 109
107 BN_CTX_init(&ctx); 110 ctx = BN_CTX_new();
111 if (ctx == NULL) goto err;
108 112
109 if (dh->priv_key == NULL) 113 if (dh->priv_key == NULL)
110 { 114 {
111 priv_key=BN_new(); 115 priv_key=BN_new();
112 if (priv_key == NULL) goto err; 116 if (priv_key == NULL) goto err;
113 do 117 generate_new_key=1;
114 if (!BN_rand_range(priv_key, dh->p)) goto err;
115 while (BN_is_zero(priv_key));
116 } 118 }
117 else 119 else
118 priv_key=dh->priv_key; 120 priv_key=dh->priv_key;
@@ -129,12 +131,16 @@ static int generate_key(DH *dh)
129 { 131 {
130 if ((dh->method_mont_p=(char *)BN_MONT_CTX_new()) != NULL) 132 if ((dh->method_mont_p=(char *)BN_MONT_CTX_new()) != NULL)
131 if (!BN_MONT_CTX_set((BN_MONT_CTX *)dh->method_mont_p, 133 if (!BN_MONT_CTX_set((BN_MONT_CTX *)dh->method_mont_p,
132 dh->p,&ctx)) goto err; 134 dh->p,ctx)) goto err;
133 } 135 }
134 mont=(BN_MONT_CTX *)dh->method_mont_p; 136 mont=(BN_MONT_CTX *)dh->method_mont_p;
135 137
136 if (!ENGINE_get_DH(dh->engine)->bn_mod_exp(dh, pub_key, dh->g, 138 if (generate_new_key)
137 priv_key,dh->p,&ctx,mont)) 139 {
140 l = dh->length ? dh->length : BN_num_bits(dh->p)-1; /* secret exponent length */
141 if (!BN_rand(priv_key, l, 0, 0)) goto err;
142 }
143 if (!dh->meth->bn_mod_exp(dh, pub_key, dh->g, priv_key,dh->p,ctx,mont))
138 goto err; 144 goto err;
139 145
140 dh->pub_key=pub_key; 146 dh->pub_key=pub_key;
@@ -146,20 +152,21 @@ err:
146 152
147 if ((pub_key != NULL) && (dh->pub_key == NULL)) BN_free(pub_key); 153 if ((pub_key != NULL) && (dh->pub_key == NULL)) BN_free(pub_key);
148 if ((priv_key != NULL) && (dh->priv_key == NULL)) BN_free(priv_key); 154 if ((priv_key != NULL) && (dh->priv_key == NULL)) BN_free(priv_key);
149 BN_CTX_free(&ctx); 155 BN_CTX_free(ctx);
150 return(ok); 156 return(ok);
151 } 157 }
152 158
153static int compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh) 159static int compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh)
154 { 160 {
155 BN_CTX ctx; 161 BN_CTX *ctx;
156 BN_MONT_CTX *mont; 162 BN_MONT_CTX *mont;
157 BIGNUM *tmp; 163 BIGNUM *tmp;
158 int ret= -1; 164 int ret= -1;
159 165
160 BN_CTX_init(&ctx); 166 ctx = BN_CTX_new();
161 BN_CTX_start(&ctx); 167 if (ctx == NULL) goto err;
162 tmp = BN_CTX_get(&ctx); 168 BN_CTX_start(ctx);
169 tmp = BN_CTX_get(ctx);
163 170
164 if (dh->priv_key == NULL) 171 if (dh->priv_key == NULL)
165 { 172 {
@@ -170,12 +177,11 @@ static int compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh)
170 { 177 {
171 if ((dh->method_mont_p=(char *)BN_MONT_CTX_new()) != NULL) 178 if ((dh->method_mont_p=(char *)BN_MONT_CTX_new()) != NULL)
172 if (!BN_MONT_CTX_set((BN_MONT_CTX *)dh->method_mont_p, 179 if (!BN_MONT_CTX_set((BN_MONT_CTX *)dh->method_mont_p,
173 dh->p,&ctx)) goto err; 180 dh->p,ctx)) goto err;
174 } 181 }
175 182
176 mont=(BN_MONT_CTX *)dh->method_mont_p; 183 mont=(BN_MONT_CTX *)dh->method_mont_p;
177 if (!ENGINE_get_DH(dh->engine)->bn_mod_exp(dh, tmp, pub_key, 184 if (!dh->meth->bn_mod_exp(dh, tmp, pub_key, dh->priv_key,dh->p,ctx,mont))
178 dh->priv_key,dh->p,&ctx,mont))
179 { 185 {
180 DHerr(DH_F_DH_COMPUTE_KEY,ERR_R_BN_LIB); 186 DHerr(DH_F_DH_COMPUTE_KEY,ERR_R_BN_LIB);
181 goto err; 187 goto err;
@@ -183,12 +189,13 @@ static int compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh)
183 189
184 ret=BN_bn2bin(tmp,key); 190 ret=BN_bn2bin(tmp,key);
185err: 191err:
186 BN_CTX_end(&ctx); 192 BN_CTX_end(ctx);
187 BN_CTX_free(&ctx); 193 BN_CTX_free(ctx);
188 return(ret); 194 return(ret);
189 } 195 }
190 196
191static int dh_bn_mod_exp(DH *dh, BIGNUM *r, BIGNUM *a, const BIGNUM *p, 197static int dh_bn_mod_exp(const DH *dh, BIGNUM *r,
198 const BIGNUM *a, const BIGNUM *p,
192 const BIGNUM *m, BN_CTX *ctx, 199 const BIGNUM *m, BN_CTX *ctx,
193 BN_MONT_CTX *m_ctx) 200 BN_MONT_CTX *m_ctx)
194 { 201 {
diff --git a/src/lib/libcrypto/dh/dh_lib.c b/src/lib/libcrypto/dh/dh_lib.c
index 96f118c153..ba5fd41057 100644
--- a/src/lib/libcrypto/dh/dh_lib.c
+++ b/src/lib/libcrypto/dh/dh_lib.c
@@ -64,95 +64,78 @@
64 64
65const char *DH_version="Diffie-Hellman" OPENSSL_VERSION_PTEXT; 65const char *DH_version="Diffie-Hellman" OPENSSL_VERSION_PTEXT;
66 66
67static DH_METHOD *default_DH_method; 67static const DH_METHOD *default_DH_method = NULL;
68static int dh_meth_num = 0; 68
69static STACK_OF(CRYPTO_EX_DATA_FUNCS) *dh_meth = NULL; 69void DH_set_default_method(const DH_METHOD *meth)
70 70 {
71void DH_set_default_openssl_method(DH_METHOD *meth) 71 default_DH_method = meth;
72{ 72 }
73 ENGINE *e;
74 /* We'll need to notify the "openssl" ENGINE of this
75 * change too. We won't bother locking things down at
76 * our end as there was never any locking in these
77 * functions! */
78 if(default_DH_method != meth)
79 {
80 default_DH_method = meth;
81 e = ENGINE_by_id("openssl");
82 if(e)
83 {
84 ENGINE_set_DH(e, meth);
85 ENGINE_free(e);
86 }
87 }
88}
89 73
90DH_METHOD *DH_get_default_openssl_method(void) 74const DH_METHOD *DH_get_default_method(void)
91{ 75 {
92 if(!default_DH_method) default_DH_method = DH_OpenSSL(); 76 if(!default_DH_method)
77 default_DH_method = DH_OpenSSL();
93 return default_DH_method; 78 return default_DH_method;
94} 79 }
95 80
96#if 0 81int DH_set_method(DH *dh, const DH_METHOD *meth)
97DH_METHOD *DH_set_method(DH *dh, DH_METHOD *meth) 82 {
98{ 83 /* NB: The caller is specifically setting a method, so it's not up to us
99 DH_METHOD *mtmp; 84 * to deal with which ENGINE it comes from. */
85 const DH_METHOD *mtmp;
100 mtmp = dh->meth; 86 mtmp = dh->meth;
101 if (mtmp->finish) mtmp->finish(dh); 87 if (mtmp->finish) mtmp->finish(dh);
88 if (dh->engine)
89 {
90 ENGINE_finish(dh->engine);
91 dh->engine = NULL;
92 }
102 dh->meth = meth; 93 dh->meth = meth;
103 if (meth->init) meth->init(dh); 94 if (meth->init) meth->init(dh);
104 return mtmp; 95 return 1;
105} 96 }
106#else
107int DH_set_method(DH *dh, ENGINE *engine)
108{
109 ENGINE *mtmp;
110 DH_METHOD *meth;
111 mtmp = dh->engine;
112 meth = ENGINE_get_DH(mtmp);
113 if (!ENGINE_init(engine))
114 return 0;
115 if (meth->finish) meth->finish(dh);
116 dh->engine= engine;
117 meth = ENGINE_get_DH(engine);
118 if (meth->init) meth->init(dh);
119 /* SHOULD ERROR CHECK THIS!!! */
120 ENGINE_finish(mtmp);
121 return 1;
122}
123#endif
124 97
125DH *DH_new(void) 98DH *DH_new(void)
126{ 99 {
127 return DH_new_method(NULL); 100 return DH_new_method(NULL);
128} 101 }
129 102
130#if 0
131DH *DH_new_method(DH_METHOD *meth)
132#else
133DH *DH_new_method(ENGINE *engine) 103DH *DH_new_method(ENGINE *engine)
134#endif
135 { 104 {
136 DH_METHOD *meth;
137 DH *ret; 105 DH *ret;
138 ret=(DH *)OPENSSL_malloc(sizeof(DH));
139 106
107 ret=(DH *)OPENSSL_malloc(sizeof(DH));
140 if (ret == NULL) 108 if (ret == NULL)
141 { 109 {
142 DHerr(DH_F_DH_NEW,ERR_R_MALLOC_FAILURE); 110 DHerr(DH_F_DH_NEW_METHOD,ERR_R_MALLOC_FAILURE);
143 return(NULL); 111 return(NULL);
144 } 112 }
145 if(engine) 113
114 ret->meth = DH_get_default_method();
115 if (engine)
116 {
117 if (!ENGINE_init(engine))
118 {
119 DHerr(DH_F_DH_NEW_METHOD, ERR_R_ENGINE_LIB);
120 OPENSSL_free(ret);
121 return NULL;
122 }
146 ret->engine = engine; 123 ret->engine = engine;
124 }
147 else 125 else
126 ret->engine = ENGINE_get_default_DH();
127 if(ret->engine)
148 { 128 {
149 if((ret->engine=ENGINE_get_default_DH()) == NULL) 129 ret->meth = ENGINE_get_DH(ret->engine);
130 if(!ret->meth)
150 { 131 {
132 DHerr(DH_F_DH_NEW_METHOD,ERR_R_ENGINE_LIB);
133 ENGINE_finish(ret->engine);
151 OPENSSL_free(ret); 134 OPENSSL_free(ret);
152 return NULL; 135 return NULL;
153 } 136 }
154 } 137 }
155 meth = ENGINE_get_DH(ret->engine); 138
156 ret->pad=0; 139 ret->pad=0;
157 ret->version=0; 140 ret->version=0;
158 ret->p=NULL; 141 ret->p=NULL;
@@ -167,11 +150,13 @@ DH *DH_new_method(ENGINE *engine)
167 ret->counter = NULL; 150 ret->counter = NULL;
168 ret->method_mont_p=NULL; 151 ret->method_mont_p=NULL;
169 ret->references = 1; 152 ret->references = 1;
170 ret->flags=meth->flags; 153 ret->flags=ret->meth->flags;
171 CRYPTO_new_ex_data(dh_meth,ret,&ret->ex_data); 154 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DH, ret, &ret->ex_data);
172 if ((meth->init != NULL) && !meth->init(ret)) 155 if ((ret->meth->init != NULL) && !ret->meth->init(ret))
173 { 156 {
174 CRYPTO_free_ex_data(dh_meth,ret,&ret->ex_data); 157 if (ret->engine)
158 ENGINE_finish(ret->engine);
159 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DH, ret, &ret->ex_data);
175 OPENSSL_free(ret); 160 OPENSSL_free(ret);
176 ret=NULL; 161 ret=NULL;
177 } 162 }
@@ -180,7 +165,6 @@ DH *DH_new_method(ENGINE *engine)
180 165
181void DH_free(DH *r) 166void DH_free(DH *r)
182 { 167 {
183 DH_METHOD *meth;
184 int i; 168 int i;
185 if(r == NULL) return; 169 if(r == NULL) return;
186 i = CRYPTO_add(&r->references, -1, CRYPTO_LOCK_DH); 170 i = CRYPTO_add(&r->references, -1, CRYPTO_LOCK_DH);
@@ -196,11 +180,12 @@ void DH_free(DH *r)
196 } 180 }
197#endif 181#endif
198 182
199 meth = ENGINE_get_DH(r->engine); 183 if (r->meth->finish)
200 if(meth->finish) meth->finish(r); 184 r->meth->finish(r);
201 ENGINE_finish(r->engine); 185 if (r->engine)
186 ENGINE_finish(r->engine);
202 187
203 CRYPTO_free_ex_data(dh_meth, r, &r->ex_data); 188 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DH, r, &r->ex_data);
204 189
205 if (r->p != NULL) BN_clear_free(r->p); 190 if (r->p != NULL) BN_clear_free(r->p);
206 if (r->g != NULL) BN_clear_free(r->g); 191 if (r->g != NULL) BN_clear_free(r->g);
@@ -213,12 +198,27 @@ void DH_free(DH *r)
213 OPENSSL_free(r); 198 OPENSSL_free(r);
214 } 199 }
215 200
201int DH_up_ref(DH *r)
202 {
203 int i = CRYPTO_add(&r->references, 1, CRYPTO_LOCK_DH);
204#ifdef REF_PRINT
205 REF_PRINT("DH",r);
206#endif
207#ifdef REF_CHECK
208 if (i < 2)
209 {
210 fprintf(stderr, "DH_up, bad reference count\n");
211 abort();
212 }
213#endif
214 return ((i > 1) ? 1 : 0);
215 }
216
216int DH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, 217int DH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
217 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) 218 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
218 { 219 {
219 dh_meth_num++; 220 return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_DH, argl, argp,
220 return(CRYPTO_get_ex_new_index(dh_meth_num-1, 221 new_func, dup_func, free_func);
221 &dh_meth,argl,argp,new_func,dup_func,free_func));
222 } 222 }
223 223
224int DH_set_ex_data(DH *d, int idx, void *arg) 224int DH_set_ex_data(DH *d, int idx, void *arg)
@@ -231,7 +231,7 @@ void *DH_get_ex_data(DH *d, int idx)
231 return(CRYPTO_get_ex_data(&d->ex_data,idx)); 231 return(CRYPTO_get_ex_data(&d->ex_data,idx));
232 } 232 }
233 233
234int DH_size(DH *dh) 234int DH_size(const DH *dh)
235 { 235 {
236 return(BN_num_bytes(dh->p)); 236 return(BN_num_bytes(dh->p));
237 } 237 }
diff --git a/src/lib/libcrypto/dh/dhtest.c b/src/lib/libcrypto/dh/dhtest.c
index f0151253d7..34894ced73 100644
--- a/src/lib/libcrypto/dh/dhtest.c
+++ b/src/lib/libcrypto/dh/dhtest.c
@@ -59,15 +59,16 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <stdlib.h> 60#include <stdlib.h>
61#include <string.h> 61#include <string.h>
62#ifdef WINDOWS 62#ifdef OPENSSL_SYS_WINDOWS
63#include "../bio/bss_file.c" 63#include "../bio/bss_file.c"
64#endif 64#endif
65#include <openssl/crypto.h> 65#include <openssl/crypto.h>
66#include <openssl/bio.h> 66#include <openssl/bio.h>
67#include <openssl/bn.h> 67#include <openssl/bn.h>
68#include <openssl/rand.h> 68#include <openssl/rand.h>
69#include <openssl/err.h>
69 70
70#ifdef NO_DH 71#ifdef OPENSSL_NO_DH
71int main(int argc, char *argv[]) 72int main(int argc, char *argv[])
72{ 73{
73 printf("No DH support\n"); 74 printf("No DH support\n");
@@ -76,14 +77,14 @@ int main(int argc, char *argv[])
76#else 77#else
77#include <openssl/dh.h> 78#include <openssl/dh.h>
78 79
79#ifdef WIN16 80#ifdef OPENSSL_SYS_WIN16
80#define MS_CALLBACK _far _loadds 81#define MS_CALLBACK _far _loadds
81#else 82#else
82#define MS_CALLBACK 83#define MS_CALLBACK
83#endif 84#endif
84 85
85static void MS_CALLBACK cb(int p, int n, void *arg); 86static void MS_CALLBACK cb(int p, int n, void *arg);
86#ifdef NO_STDIO 87#ifdef OPENSSL_NO_STDIO
87#define APPS_WIN16 88#define APPS_WIN16
88#include "bss_file.c" 89#include "bss_file.c"
89#endif 90#endif
@@ -99,7 +100,11 @@ int main(int argc, char *argv[])
99 int i,alen,blen,aout,bout,ret=1; 100 int i,alen,blen,aout,bout,ret=1;
100 BIO *out; 101 BIO *out;
101 102
102#ifdef WIN32 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
103 CRYPTO_malloc_init(); 108 CRYPTO_malloc_init();
104#endif 109#endif
105 110
@@ -112,6 +117,16 @@ int main(int argc, char *argv[])
112 a=DH_generate_parameters(64,DH_GENERATOR_5,cb,out); 117 a=DH_generate_parameters(64,DH_GENERATOR_5,cb,out);
113 if (a == NULL) goto err; 118 if (a == NULL) goto err;
114 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
115 BIO_puts(out,"\np ="); 130 BIO_puts(out,"\np =");
116 BN_print(out,a->p); 131 BN_print(out,a->p);
117 BIO_puts(out,"\ng ="); 132 BIO_puts(out,"\ng =");
@@ -170,11 +185,16 @@ int main(int argc, char *argv[])
170 else 185 else
171 ret=0; 186 ret=0;
172err: 187err:
188 ERR_print_errors_fp(stderr);
189
173 if (abuf != NULL) OPENSSL_free(abuf); 190 if (abuf != NULL) OPENSSL_free(abuf);
174 if (bbuf != NULL) OPENSSL_free(bbuf); 191 if (bbuf != NULL) OPENSSL_free(bbuf);
175 if(b != NULL) DH_free(b); 192 if(b != NULL) DH_free(b);
176 if(a != NULL) DH_free(a); 193 if(a != NULL) DH_free(a);
177 BIO_free(out); 194 BIO_free(out);
195 CRYPTO_cleanup_all_ex_data();
196 ERR_remove_state(0);
197 CRYPTO_mem_leaks_fp(stderr);
178 exit(ret); 198 exit(ret);
179 return(ret); 199 return(ret);
180 } 200 }
diff --git a/src/lib/libcrypto/doc/DH_set_method.pod b/src/lib/libcrypto/doc/DH_set_method.pod
index 62088eea1b..d990bf8786 100644
--- a/src/lib/libcrypto/doc/DH_set_method.pod
+++ b/src/lib/libcrypto/doc/DH_set_method.pod
@@ -82,8 +82,8 @@ the default engine for Diffie-Hellman opertaions is used.
82 82
83=head1 RETURN VALUES 83=head1 RETURN VALUES
84 84
85DH_OpenSSL() and DH_get_default_method() return pointers to the respective 85DH_OpenSSL() and DH_get_default_openssl_method() return pointers to the
86DH_METHODs. 86respective B<DH_METHOD>s.
87 87
88DH_set_default_openssl_method() returns no value. 88DH_set_default_openssl_method() returns no value.
89 89
diff --git a/src/lib/libcrypto/doc/DSA_set_method.pod b/src/lib/libcrypto/doc/DSA_set_method.pod
index c56dfd0f47..36a1052d27 100644
--- a/src/lib/libcrypto/doc/DSA_set_method.pod
+++ b/src/lib/libcrypto/doc/DSA_set_method.pod
@@ -90,7 +90,7 @@ struct
90=head1 RETURN VALUES 90=head1 RETURN VALUES
91 91
92DSA_OpenSSL() and DSA_get_default_openssl_method() return pointers to the 92DSA_OpenSSL() and DSA_get_default_openssl_method() return pointers to the
93respective DSA_METHODs. 93respective B<DSA_METHOD>s.
94 94
95DSA_set_default_openssl_method() returns no value. 95DSA_set_default_openssl_method() returns no value.
96 96
diff --git a/src/lib/libcrypto/doc/ERR_get_error.pod b/src/lib/libcrypto/doc/ERR_get_error.pod
index 3551bacb8d..9fdedbcb91 100644
--- a/src/lib/libcrypto/doc/ERR_get_error.pod
+++ b/src/lib/libcrypto/doc/ERR_get_error.pod
@@ -2,8 +2,10 @@
2 2
3=head1 NAME 3=head1 NAME
4 4
5ERR_get_error, ERR_peek_error, ERR_get_error_line, ERR_peek_error_line, 5ERR_get_error, ERR_peek_error, ERR_peek_last_error,
6ERR_get_error_line_data, ERR_peek_error_line_data - obtain error code and data 6ERR_get_error_line, ERR_peek_error_line, ERR_peek_last_error_line,
7ERR_get_error_line_data, ERR_peek_error_line_data,
8ERR_peek_error_line_data - obtain error code and data
7 9
8=head1 SYNOPSIS 10=head1 SYNOPSIS
9 11
@@ -11,22 +13,29 @@ ERR_get_error_line_data, ERR_peek_error_line_data - obtain error code and data
11 13
12 unsigned long ERR_get_error(void); 14 unsigned long ERR_get_error(void);
13 unsigned long ERR_peek_error(void); 15 unsigned long ERR_peek_error(void);
16 unsigned long ERR_peek_last_error(void);
14 17
15 unsigned long ERR_get_error_line(const char **file, int *line); 18 unsigned long ERR_get_error_line(const char **file, int *line);
16 unsigned long ERR_peek_error_line(const char **file, int *line); 19 unsigned long ERR_peek_error_line(const char **file, int *line);
20 unsigned long ERR_peek_last_error_line(const char **file, int *line);
17 21
18 unsigned long ERR_get_error_line_data(const char **file, int *line, 22 unsigned long ERR_get_error_line_data(const char **file, int *line,
19 const char **data, int *flags); 23 const char **data, int *flags);
20 unsigned long ERR_peek_error_line_data(const char **file, int *line, 24 unsigned long ERR_peek_error_line_data(const char **file, int *line,
21 const char **data, int *flags); 25 const char **data, int *flags);
26 unsigned long ERR_peek_last_error_line_data(const char **file, int *line,
27 const char **data, int *flags);
22 28
23=head1 DESCRIPTION 29=head1 DESCRIPTION
24 30
25ERR_get_error() returns the last error code from the thread's error 31ERR_get_error() returns the earliest error code from the thread's error
26queue and removes the entry. This function can be called repeatedly 32queue and removes the entry. This function can be called repeatedly
27until there are no more error codes to return. 33until there are no more error codes to return.
28 34
29ERR_peek_error() returns the last error code from the thread's 35ERR_peek_error() returns the earliest error code from the thread's
36error queue without modifying it.
37
38ERR_peek_last_error() returns the latest error code from the thread's
30error queue without modifying it. 39error queue without modifying it.
31 40
32See L<ERR_GET_LIB(3)|ERR_GET_LIB(3)> for obtaining information about 41See L<ERR_GET_LIB(3)|ERR_GET_LIB(3)> for obtaining information about
@@ -34,12 +43,14 @@ location and reason of the error, and
34L<ERR_error_string(3)|ERR_error_string(3)> for human-readable error 43L<ERR_error_string(3)|ERR_error_string(3)> for human-readable error
35messages. 44messages.
36 45
37ERR_get_error_line() and ERR_peek_error_line() are the same as the 46ERR_get_error_line(), ERR_peek_error_line() and
38above, but they additionally store the file name and line number where 47ERR_peek_last_error_line() are the same as the above, but they
48additionally store the file name and line number where
39the error occurred in *B<file> and *B<line>, unless these are B<NULL>. 49the error occurred in *B<file> and *B<line>, unless these are B<NULL>.
40 50
41ERR_get_error_line_data() and ERR_peek_error_line_data() store 51ERR_get_error_line_data(), ERR_peek_error_line_data() and
42additional data and flags associated with the error code in *B<data> 52ERR_get_last_error_line_data() store additional data and flags
53associated with the error code in *B<data>
43and *B<flags>, unless these are B<NULL>. *B<data> contains a string 54and *B<flags>, unless these are B<NULL>. *B<data> contains a string
44if *B<flags>&B<ERR_TXT_STRING>. If it has been allocated by OPENSSL_malloc(), 55if *B<flags>&B<ERR_TXT_STRING>. If it has been allocated by OPENSSL_malloc(),
45*B<flags>&B<ERR_TXT_MALLOCED> is true. 56*B<flags>&B<ERR_TXT_MALLOCED> is true.
@@ -59,5 +70,7 @@ ERR_get_error(), ERR_peek_error(), ERR_get_error_line() and
59ERR_peek_error_line() are available in all versions of SSLeay and 70ERR_peek_error_line() are available in all versions of SSLeay and
60OpenSSL. ERR_get_error_line_data() and ERR_peek_error_line_data() 71OpenSSL. ERR_get_error_line_data() and ERR_peek_error_line_data()
61were added in SSLeay 0.9.0. 72were added in SSLeay 0.9.0.
73ERR_peek_last_error(), ERR_peek_last_error_line() and
74ERR_peek_last_error_line_data() were added in OpenSSL 0.9.7.
62 75
63=cut 76=cut
diff --git a/src/lib/libcrypto/doc/EVP_BytesToKey.pod b/src/lib/libcrypto/doc/EVP_BytesToKey.pod
new file mode 100644
index 0000000000..5ce4add082
--- /dev/null
+++ b/src/lib/libcrypto/doc/EVP_BytesToKey.pod
@@ -0,0 +1,67 @@
1=pod
2
3=head1 NAME
4
5 EVP_BytesToKey - password based encryption routine
6
7=head1 SYNOPSIS
8
9 #include <openssl/evp.h>
10
11 int EVP_BytesToKey(const EVP_CIPHER *type,const EVP_MD *md,
12 const unsigned char *salt,
13 const unsigned char *data, int datal, int count,
14 unsigned char *key,unsigned char *iv);
15
16=head1 DESCRIPTION
17
18EVP_BytesToKey() derives a key and IV from various parameters. B<type> is
19the cipher to derive the key and IV for. B<md> is the message digest to use.
20The B<salt> paramter is used as a salt in the derivation: it should point to
21an 8 byte buffer or NULL if no salt is used. B<data> is a buffer containing
22B<datal> bytes which is used to derive the keying data. B<count> is the
23iteration count to use. The derived key and IV will be written to B<key>
24and B<iv> respectively.
25
26=head1 NOTES
27
28A typical application of this function is to derive keying material for an
29encryption algorithm from a password in the B<data> parameter.
30
31Increasing the B<count> parameter slows down the algorithm which makes it
32harder for an attacker to peform a brute force attack using a large number
33of candidate passwords.
34
35If the total key and IV length is less than the digest length and
36B<MD5> is used then the derivation algorithm is compatible with PKCS#5 v1.5
37otherwise a non standard extension is used to derive the extra data.
38
39Newer applications should use more standard algorithms such as PKCS#5
40v2.0 for key derivation.
41
42=head1 KEY DERIVATION ALGORITHM
43
44The key and IV is derived by concatenating D_1, D_2, etc until
45enough data is available for the key and IV. D_i is defined as:
46
47 D_i = HASH^count(D_(i-1) || data || salt)
48
49where || denotes concatentaion, D_0 is empty, HASH is the digest
50algorithm in use, HASH^1(data) is simply HASH(data), HASH^2(data)
51is HASH(HASH(data)) and so on.
52
53The initial bytes are used for the key and the subsequent bytes for
54the IV.
55
56=head1 RETURN VALUES
57
58EVP_BytesToKey() returns the size of the derived key in bytes.
59
60=head1 SEE ALSO
61
62L<evp(3)|evp(3)>, L<rand(3)|rand(3)>,
63L<EVP_EncryptInit(3)|EVP_EncryptInit(3)>,
64
65=head1 HISTORY
66
67=cut
diff --git a/src/lib/libcrypto/doc/EVP_DigestInit.pod b/src/lib/libcrypto/doc/EVP_DigestInit.pod
index fefc858f7e..acd4d0167a 100644
--- a/src/lib/libcrypto/doc/EVP_DigestInit.pod
+++ b/src/lib/libcrypto/doc/EVP_DigestInit.pod
@@ -2,9 +2,10 @@
2 2
3=head1 NAME 3=head1 NAME
4 4
5EVP_DigestInit, EVP_DigestUpdate, EVP_DigestFinal, EVP_MAX_MD_SIZE, 5EVP_MD_CTX_init, EVP_MD_CTX_create, EVP_DigestInit_ex, EVP_DigestUpdate,
6EVP_MD_CTX_copy, EVP_MD_type, EVP_MD_pkey_type, EVP_MD_size, EVP_MD_block_size, 6EVP_DigestFinal_ex, EVP_MD_CTX_cleanup, EVP_MD_CTX_destroy, EVP_MAX_MD_SIZE,
7EVP_MD_CTX_md, EVP_MD_CTX_size, EVP_MD_CTX_block_size, EVP_MD_CTX_type, 7EVP_MD_CTX_copy_ex EVP_MD_CTX_copy, EVP_MD_type, EVP_MD_pkey_type, EVP_MD_size,
8EVP_MD_block_size, EVP_MD_CTX_md, EVP_MD_CTX_size, EVP_MD_CTX_block_size, EVP_MD_CTX_type,
8EVP_md_null, EVP_md2, EVP_md5, EVP_sha, EVP_sha1, EVP_dss, EVP_dss1, EVP_mdc2, 9EVP_md_null, EVP_md2, EVP_md5, EVP_sha, EVP_sha1, EVP_dss, EVP_dss1, EVP_mdc2,
9EVP_ripemd160, EVP_get_digestbyname, EVP_get_digestbynid, EVP_get_digestbyobj - 10EVP_ripemd160, EVP_get_digestbyname, EVP_get_digestbynid, EVP_get_digestbyobj -
10EVP digest routines 11EVP digest routines
@@ -13,15 +14,28 @@ EVP digest routines
13 14
14 #include <openssl/evp.h> 15 #include <openssl/evp.h>
15 16
16 void EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type); 17 void EVP_MD_CTX_init(EVP_MD_CTX *ctx);
17 void EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt); 18 EVP_MD_CTX *EVP_MD_CTX_create(void);
18 void EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md, 19
20 int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl);
21 int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt);
22 int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md,
19 unsigned int *s); 23 unsigned int *s);
20 24
21 #define EVP_MAX_MD_SIZE (16+20) /* The SSLv3 md5+sha1 type */ 25 int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx);
26 void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx);
27
28 int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out,const EVP_MD_CTX *in);
29
30 int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type);
31 int EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md,
32 unsigned int *s);
22 33
23 int EVP_MD_CTX_copy(EVP_MD_CTX *out,EVP_MD_CTX *in); 34 int EVP_MD_CTX_copy(EVP_MD_CTX *out,EVP_MD_CTX *in);
24 35
36 #define EVP_MAX_MD_SIZE (16+20) /* The SSLv3 md5+sha1 type */
37
38
25 #define EVP_MD_type(e) ((e)->type) 39 #define EVP_MD_type(e) ((e)->type)
26 #define EVP_MD_pkey_type(e) ((e)->pkey_type) 40 #define EVP_MD_pkey_type(e) ((e)->pkey_type)
27 #define EVP_MD_size(e) ((e)->md_size) 41 #define EVP_MD_size(e) ((e)->md_size)
@@ -32,15 +46,15 @@ EVP digest routines
32 #define EVP_MD_CTX_block_size(e) EVP_MD_block_size((e)->digest) 46 #define EVP_MD_CTX_block_size(e) EVP_MD_block_size((e)->digest)
33 #define EVP_MD_CTX_type(e) EVP_MD_type((e)->digest) 47 #define EVP_MD_CTX_type(e) EVP_MD_type((e)->digest)
34 48
35 EVP_MD *EVP_md_null(void); 49 const EVP_MD *EVP_md_null(void);
36 EVP_MD *EVP_md2(void); 50 const EVP_MD *EVP_md2(void);
37 EVP_MD *EVP_md5(void); 51 const EVP_MD *EVP_md5(void);
38 EVP_MD *EVP_sha(void); 52 const EVP_MD *EVP_sha(void);
39 EVP_MD *EVP_sha1(void); 53 const EVP_MD *EVP_sha1(void);
40 EVP_MD *EVP_dss(void); 54 const EVP_MD *EVP_dss(void);
41 EVP_MD *EVP_dss1(void); 55 const EVP_MD *EVP_dss1(void);
42 EVP_MD *EVP_mdc2(void); 56 const EVP_MD *EVP_mdc2(void);
43 EVP_MD *EVP_ripemd160(void); 57 const EVP_MD *EVP_ripemd160(void);
44 58
45 const EVP_MD *EVP_get_digestbyname(const char *name); 59 const EVP_MD *EVP_get_digestbyname(const char *name);
46 #define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a)) 60 #define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a))
@@ -50,25 +64,48 @@ EVP digest routines
50 64
51The EVP digest routines are a high level interface to message digests. 65The EVP digest routines are a high level interface to message digests.
52 66
53EVP_DigestInit() initializes a digest context B<ctx> to use a digest 67EVP_MD_CTX_init() initializes digest contet B<ctx>.
54B<type>: this will typically be supplied by a function such as 68
55EVP_sha1(). 69EVP_MD_CTX_create() allocates, initializes and returns a digest contet.
70
71EVP_DigestInit_ex() sets up digest context B<ctx> to use a digest
72B<type> from ENGINE B<impl>. B<ctx> must be initialized before calling this
73function. B<type> will typically be supplied by a functionsuch as EVP_sha1().
74If B<impl> is NULL then the default implementation of digest B<type> is used.
56 75
57EVP_DigestUpdate() hashes B<cnt> bytes of data at B<d> into the 76EVP_DigestUpdate() hashes B<cnt> bytes of data at B<d> into the
58digest context B<ctx>. This function can be called several times on the 77digest context B<ctx>. This function can be called several times on the
59same B<ctx> to hash additional data. 78same B<ctx> to hash additional data.
60 79
61EVP_DigestFinal() retrieves the digest value from B<ctx> and places 80EVP_DigestFinal_ex() retrieves the digest value from B<ctx> and places
62it in B<md>. If the B<s> parameter is not NULL then the number of 81it in B<md>. If the B<s> parameter is not NULL then the number of
63bytes of data written (i.e. the length of the digest) will be written 82bytes of data written (i.e. the length of the digest) will be written
64to the integer at B<s>, at most B<EVP_MAX_MD_SIZE> bytes will be written. 83to the integer at B<s>, at most B<EVP_MAX_MD_SIZE> bytes will be written.
65After calling EVP_DigestFinal() no additional calls to EVP_DigestUpdate() 84After calling EVP_DigestFinal_ex() no additional calls to EVP_DigestUpdate()
66can be made, but EVP_DigestInit() can be called to initialize a new 85can be made, but EVP_DigestInit_ex() can be called to initialize a new
67digest operation. 86digest operation.
68 87
69EVP_MD_CTX_copy() can be used to copy the message digest state from 88EVP_MD_CTX_cleanup() cleans up digest context B<ctx>, it should be called
89after a digest context is no longer needed.
90
91EVP_MD_CTX_destroy() cleans up digest context B<ctx> and frees up the
92space allocated to it, it should be called only on a context created
93using EVP_MD_CTX_create().
94
95EVP_MD_CTX_copy_ex() can be used to copy the message digest state from
70B<in> to B<out>. This is useful if large amounts of data are to be 96B<in> to B<out>. This is useful if large amounts of data are to be
71hashed which only differ in the last few bytes. 97hashed which only differ in the last few bytes. B<out> must be initialized
98before calling this function.
99
100EVP_DigestInit() behaves in the same way as EVP_DigestInit_ex() except
101the passed context B<ctx> does not have to be initialized, and it always
102uses the default digest implementation.
103
104EVP_DigestFinal() is similar to EVP_DigestFinal_ex() except the digest
105contet B<ctx> is automatically cleaned up.
106
107EVP_MD_CTX_copy() is similar to EVP_MD_CTX_copy_ex() except the destination
108B<out> does not have to be initialized.
72 109
73EVP_MD_size() and EVP_MD_CTX_size() return the size of the message digest 110EVP_MD_size() and EVP_MD_CTX_size() return the size of the message digest
74when passed an B<EVP_MD> or an B<EVP_MD_CTX> structure, i.e. the size of the 111when passed an B<EVP_MD> or an B<EVP_MD_CTX> structure, i.e. the size of the
@@ -107,9 +144,10 @@ using, for example, OpenSSL_add_all_digests() for these functions to work.
107 144
108=head1 RETURN VALUES 145=head1 RETURN VALUES
109 146
110EVP_DigestInit(), EVP_DigestUpdate() and EVP_DigestFinal() do not return values. 147EVP_DigestInit_ex(), EVP_DigestUpdate() and EVP_DigestFinal_ex() return 1 for
148success and 0 for failure.
111 149
112EVP_MD_CTX_copy() returns 1 if successful or 0 for failure. 150EVP_MD_CTX_copy_ex() returns 1 if successful or 0 for failure.
113 151
114EVP_MD_type(), EVP_MD_pkey_type() and EVP_MD_type() return the NID of the 152EVP_MD_type(), EVP_MD_pkey_type() and EVP_MD_type() return the NID of the
115corresponding OBJECT IDENTIFIER or NID_undef if none exists. 153corresponding OBJECT IDENTIFIER or NID_undef if none exists.
@@ -134,6 +172,19 @@ transparent to the digest used and much more flexible.
134SHA1 is the digest of choice for new applications. The other digest algorithms 172SHA1 is the digest of choice for new applications. The other digest algorithms
135are still in common use. 173are still in common use.
136 174
175For most applications the B<impl> parameter to EVP_DigestInit_ex() will be
176set to NULL to use the default digest implementation.
177
178The functions EVP_DigestInit(), EVP_DigestFinal() and EVP_MD_CTX_copy() are
179obsolete but are retained to maintain compatibility with existing code. New
180applications should use EVP_DigestInit_ex(), EVP_DigestFinal_ex() and
181EVP_MD_CTX_copy_ex() because they can efficiently reuse a digest context
182instead of initializing and cleaning it up on each call and allow non default
183implementations of digests to be specified.
184
185In OpenSSL 0.9.7 and later if digest contexts are not cleaned up after use
186memory leaks will occur.
187
137=head1 EXAMPLE 188=head1 EXAMPLE
138 189
139This example digests the data "Test Message\n" and "Hello World\n", using the 190This example digests the data "Test Message\n" and "Hello World\n", using the
@@ -165,10 +216,12 @@ digest name passed on the command line.
165 exit(1); 216 exit(1);
166 } 217 }
167 218
168 EVP_DigestInit(&mdctx, md); 219 EVP_MD_CTX_init(&mdctx);
220 EVP_DigestInit_ex(&mdctx, md, NULL);
169 EVP_DigestUpdate(&mdctx, mess1, strlen(mess1)); 221 EVP_DigestUpdate(&mdctx, mess1, strlen(mess1));
170 EVP_DigestUpdate(&mdctx, mess2, strlen(mess2)); 222 EVP_DigestUpdate(&mdctx, mess2, strlen(mess2));
171 EVP_DigestFinal(&mdctx, md_value, &md_len); 223 EVP_DigestFinal_ex(&mdctx, md_value, &md_len);
224 EVP_MD_CTX_cleanup(&mdctx);
172 225
173 printf("Digest is: "); 226 printf("Digest is: ");
174 for(i = 0; i < md_len; i++) printf("%02x", md_value[i]); 227 for(i = 0; i < md_len; i++) printf("%02x", md_value[i]);
@@ -177,17 +230,10 @@ digest name passed on the command line.
177 230
178=head1 BUGS 231=head1 BUGS
179 232
180Several of the functions do not return values: maybe they should. Although the
181internal digest operations will never fail some future hardware based operations
182might.
183
184The link between digests and signing algorithms results in a situation where 233The link between digests and signing algorithms results in a situation where
185EVP_sha1() must be used with RSA and EVP_dss1() must be used with DSS 234EVP_sha1() must be used with RSA and EVP_dss1() must be used with DSS
186even though they are identical digests. 235even though they are identical digests.
187 236
188The size of an B<EVP_MD_CTX> structure is determined at compile time: this results
189in code that must be recompiled if the size of B<EVP_MD_CTX> increases.
190
191=head1 SEE ALSO 237=head1 SEE ALSO
192 238
193L<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)>,
@@ -199,4 +245,7 @@ L<SHA1(3)|SHA1(3)>
199EVP_DigestInit(), EVP_DigestUpdate() and EVP_DigestFinal() are 245EVP_DigestInit(), EVP_DigestUpdate() and EVP_DigestFinal() are
200available in all versions of SSLeay and OpenSSL. 246available in all versions of SSLeay and OpenSSL.
201 247
248EVP_DigestInit_ex(), EVP_DigestFinal_ex() and EVP_MD_CTX_copy_ex()
249were added in OpenSSL 0.9.7.
250
202=cut 251=cut
diff --git a/src/lib/libcrypto/doc/EVP_EncryptInit.pod b/src/lib/libcrypto/doc/EVP_EncryptInit.pod
index 9afe2396e2..371b6a2287 100644
--- a/src/lib/libcrypto/doc/EVP_EncryptInit.pod
+++ b/src/lib/libcrypto/doc/EVP_EncryptInit.pod
@@ -2,43 +2,65 @@
2 2
3=head1 NAME 3=head1 NAME
4 4
5EVP_EncryptInit, EVP_EncryptUpdate, EVP_EncryptFinal, EVP_DecryptInit, 5EVP_CIPHER_CTX_init, EVP_EncryptInit_ex, EVP_EncryptUpdate,
6EVP_DecryptUpdate, EVP_DecryptFinal, EVP_CipherInit, EVP_CipherUpdate, 6EVP_EncryptFinal_ex, EVP_DecryptInit_ex, EVP_DecryptUpdate,
7EVP_CipherFinal, EVP_CIPHER_CTX_set_key_length, EVP_CIPHER_CTX_ctrl, 7EVP_DecryptFinal_ex, EVP_CipherInit_ex, EVP_CipherUpdate,
8EVP_CIPHER_CTX_cleanup, EVP_get_cipherbyname, EVP_get_cipherbynid, 8EVP_CipherFinal_ex, EVP_CIPHER_CTX_set_key_length,
9EVP_get_cipherbyobj, EVP_CIPHER_nid, EVP_CIPHER_block_size, 9EVP_CIPHER_CTX_ctrl, EVP_CIPHER_CTX_cleanup, EVP_EncryptInit,
10EVP_CIPHER_key_length, EVP_CIPHER_iv_length, EVP_CIPHER_flags, 10EVP_EncryptFinal, EVP_DecryptInit, EVP_DecryptFinal,
11EVP_CIPHER_mode, EVP_CIPHER_type, EVP_CIPHER_CTX_cipher, EVP_CIPHER_CTX_nid, 11EVP_CipherInit, EVP_CipherFinal, EVP_get_cipherbyname,
12EVP_CIPHER_CTX_block_size, EVP_CIPHER_CTX_key_length, EVP_CIPHER_CTX_iv_length, 12EVP_get_cipherbynid, EVP_get_cipherbyobj, EVP_CIPHER_nid,
13EVP_CIPHER_CTX_get_app_data, EVP_CIPHER_CTX_set_app_data, EVP_CIPHER_CTX_type, 13EVP_CIPHER_block_size, EVP_CIPHER_key_length, EVP_CIPHER_iv_length,
14EVP_CIPHER_CTX_flags, EVP_CIPHER_CTX_mode, EVP_CIPHER_param_to_asn1, 14EVP_CIPHER_flags, EVP_CIPHER_mode, EVP_CIPHER_type, EVP_CIPHER_CTX_cipher,
15EVP_CIPHER_asn1_to_param - EVP cipher routines 15EVP_CIPHER_CTX_nid, EVP_CIPHER_CTX_block_size, EVP_CIPHER_CTX_key_length,
16EVP_CIPHER_CTX_iv_length, EVP_CIPHER_CTX_get_app_data,
17EVP_CIPHER_CTX_set_app_data, EVP_CIPHER_CTX_type, EVP_CIPHER_CTX_flags,
18EVP_CIPHER_CTX_mode, EVP_CIPHER_param_to_asn1, EVP_CIPHER_asn1_to_param,
19EVP_CIPHER_CTX_set_padding - EVP cipher routines
16 20
17=head1 SYNOPSIS 21=head1 SYNOPSIS
18 22
19 #include <openssl/evp.h> 23 #include <openssl/evp.h>
20 24
21 int EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, 25 int EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a);
22 unsigned char *key, unsigned char *iv); 26
27 int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
28 ENGINE *impl, unsigned char *key, unsigned char *iv);
23 int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, 29 int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
24 int *outl, unsigned char *in, int inl); 30 int *outl, unsigned char *in, int inl);
31 int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out,
32 int *outl);
33
34 int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
35 ENGINE *impl, unsigned char *key, unsigned char *iv);
36 int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
37 int *outl, unsigned char *in, int inl);
38 int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm,
39 int *outl);
40
41 int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
42 ENGINE *impl, unsigned char *key, unsigned char *iv, int enc);
43 int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
44 int *outl, unsigned char *in, int inl);
45 int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm,
46 int *outl);
47
48 int EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
49 unsigned char *key, unsigned char *iv);
25 int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, 50 int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out,
26 int *outl); 51 int *outl);
27 52
28 int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, 53 int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
29 unsigned char *key, unsigned char *iv); 54 unsigned char *key, unsigned char *iv);
30 int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
31 int *outl, unsigned char *in, int inl);
32 int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, 55 int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm,
33 int *outl); 56 int *outl);
34 57
35 int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, 58 int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
36 unsigned char *key, unsigned char *iv, int enc); 59 unsigned char *key, unsigned char *iv, int enc);
37 int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
38 int *outl, unsigned char *in, int inl);
39 int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, 60 int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm,
40 int *outl); 61 int *outl);
41 62
63 int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *x, int padding);
42 int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen); 64 int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen);
43 int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr); 65 int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);
44 int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a); 66 int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a);
@@ -74,14 +96,19 @@ EVP_CIPHER_asn1_to_param - EVP cipher routines
74The EVP cipher routines are a high level interface to certain 96The EVP cipher routines are a high level interface to certain
75symmetric ciphers. 97symmetric ciphers.
76 98
77EVP_EncryptInit() initializes a cipher context B<ctx> for encryption 99EVP_CIPHER_CTX_init() initializes cipher contex B<ctx>.
78with cipher B<type>. B<type> is normally supplied by a function such 100
79as EVP_des_cbc() . B<key> is the symmetric key to use and B<iv> is the 101EVP_EncryptInit_ex() sets up cipher context B<ctx> for encryption
80IV to use (if necessary), the actual number of bytes used for the 102with cipher B<type> from ENGINE B<impl>. B<ctx> must be initialized
81key and IV depends on the cipher. It is possible to set all parameters 103before calling this function. B<type> is normally supplied
82to NULL except B<type> in an initial call and supply the remaining 104by a function such as EVP_des_cbc(). If B<impl> is NULL then the
83parameters in subsequent calls, all of which have B<type> set to NULL. 105default implementation is used. B<key> is the symmetric key to use
84This is done when the default cipher parameters are not appropriate. 106and B<iv> is the IV to use (if necessary), the actual number of bytes
107used for the key and IV depends on the cipher. It is possible to set
108all parameters to NULL except B<type> in an initial call and supply
109the remaining parameters in subsequent calls, all of which have B<type>
110set to NULL. This is done when the default cipher parameters are not
111appropriate.
85 112
86EVP_EncryptUpdate() encrypts B<inl> bytes from the buffer B<in> and 113EVP_EncryptUpdate() encrypts B<inl> bytes from the buffer B<in> and
87writes the encrypted version to B<out>. This function can be called 114writes the encrypted version to B<out>. This function can be called
@@ -89,32 +116,49 @@ multiple times to encrypt successive blocks of data. The amount
89of data written depends on the block alignment of the encrypted data: 116of data written depends on the block alignment of the encrypted data:
90as a result the amount of data written may be anything from zero bytes 117as a result the amount of data written may be anything from zero bytes
91to (inl + cipher_block_size - 1) so B<outl> should contain sufficient 118to (inl + cipher_block_size - 1) so B<outl> should contain sufficient
92room. The actual number of bytes written is placed in B<outl>. 119room. The actual number of bytes written is placed in B<outl>.
120
121If padding is enabled (the default) then EVP_EncryptFinal_ex() encrypts
122the "final" data, that is any data that remains in a partial block.
123It uses L<standard block padding|/NOTES> (aka PKCS padding). The encrypted
124final data is written to B<out> which should have sufficient space for
125one cipher block. The number of bytes written is placed in B<outl>. After
126this function is called the encryption operation is finished and no further
127calls to EVP_EncryptUpdate() should be made.
93 128
94EVP_EncryptFinal() encrypts the "final" data, that is any data that 129If padding is disabled then EVP_EncryptFinal_ex() will not encrypt any more
95remains in a partial block. It uses L<standard block padding|/NOTES> (aka PKCS 130data and it will return an error if any data remains in a partial block:
96padding). The encrypted final data is written to B<out> which should 131that is if the total data length is not a multiple of the block size.
97have sufficient space for one cipher block. The number of bytes written
98is placed in B<outl>. After this function is called the encryption operation
99is finished and no further calls to EVP_EncryptUpdate() should be made.
100 132
101EVP_DecryptInit(), EVP_DecryptUpdate() and EVP_DecryptFinal() are the 133EVP_DecryptInit_ex(), EVP_DecryptUpdate() and EVP_DecryptFinal_ex() are the
102corresponding decryption operations. EVP_DecryptFinal() will return an 134corresponding decryption operations. EVP_DecryptFinal() will return an
103error code if the final block is not correctly formatted. The parameters 135error code if padding is enabled and the final block is not correctly
104and restrictions are identical to the encryption operations except that 136formatted. The parameters and restrictions are identical to the encryption
105the decrypted data buffer B<out> passed to EVP_DecryptUpdate() should 137operations except that if padding is enabled the decrypted data buffer B<out>
106have sufficient room for (B<inl> + cipher_block_size) bytes unless the 138passed to EVP_DecryptUpdate() should have sufficient room for
107cipher block size is 1 in which case B<inl> bytes is sufficient. 139(B<inl> + cipher_block_size) bytes unless the cipher block size is 1 in
108 140which case B<inl> bytes is sufficient.
109EVP_CipherInit(), EVP_CipherUpdate() and EVP_CipherFinal() are functions 141
110that can be used for decryption or encryption. The operation performed 142EVP_CipherInit_ex(), EVP_CipherUpdate() and EVP_CipherFinal_ex() are
111depends on the value of the B<enc> parameter. It should be set to 1 for 143functions that can be used for decryption or encryption. The operation
112encryption, 0 for decryption and -1 to leave the value unchanged (the 144performed depends on the value of the B<enc> parameter. It should be set
113actual value of 'enc' being supplied in a previous call). 145to 1 for encryption, 0 for decryption and -1 to leave the value unchanged
114 146(the actual value of 'enc' being supplied in a previous call).
115EVP_CIPHER_CTX_cleanup() clears all information from a cipher context. 147
116It should be called after all operations using a cipher are complete 148EVP_CIPHER_CTX_cleanup() clears all information from a cipher context
117so sensitive information does not remain in memory. 149and free up any allocated memory associate with it. It should be called
150after all operations using a cipher are complete so sensitive information
151does not remain in memory.
152
153EVP_EncryptInit(), EVP_DecryptInit() and EVP_CipherInit() behave in a
154similar way to EVP_EncryptInit_ex(), EVP_DecryptInit_ex and
155EVP_CipherInit_ex() except the B<ctx> paramter does not need to be
156initialized and they always use the default cipher implementation.
157
158EVP_EncryptFinal(), EVP_DecryptFinal() and EVP_CipherFinal() behave in a
159similar way to EVP_EncryptFinal_ex(), EVP_DecryptFinal_ex() and
160EVP_CipherFinal_ex() except B<ctx> is automatically cleaned up
161after the call.
118 162
119EVP_get_cipherbyname(), EVP_get_cipherbynid() and EVP_get_cipherbyobj() 163EVP_get_cipherbyname(), EVP_get_cipherbynid() and EVP_get_cipherbyobj()
120return an EVP_CIPHER structure when passed a cipher name, a NID or an 164return an EVP_CIPHER structure when passed a cipher name, a NID or an
@@ -125,6 +169,13 @@ passed an B<EVP_CIPHER> or B<EVP_CIPHER_CTX> structure. The actual NID
125value is an internal value which may not have a corresponding OBJECT 169value is an internal value which may not have a corresponding OBJECT
126IDENTIFIER. 170IDENTIFIER.
127 171
172EVP_CIPHER_CTX_set_padding() enables or disables padding. By default
173encryption operations are padded using standard block padding and the
174padding is checked and removed when decrypting. If the B<pad> parameter
175is zero then no padding is performed, the total amount of data encrypted
176or decrypted must then be a multiple of the block size or an error will
177occur.
178
128EVP_CIPHER_key_length() and EVP_CIPHER_CTX_key_length() return the key 179EVP_CIPHER_key_length() and EVP_CIPHER_CTX_key_length() return the key
129length of a cipher when passed an B<EVP_CIPHER> or B<EVP_CIPHER_CTX> 180length of a cipher when passed an B<EVP_CIPHER> or B<EVP_CIPHER_CTX>
130structure. The constant B<EVP_MAX_KEY_LENGTH> is the maximum key length 181structure. The constant B<EVP_MAX_KEY_LENGTH> is the maximum key length
@@ -185,14 +236,14 @@ RC5 can be set.
185 236
186=head1 RETURN VALUES 237=head1 RETURN VALUES
187 238
188EVP_EncryptInit(), EVP_EncryptUpdate() and EVP_EncryptFinal() return 1 for success 239EVP_CIPHER_CTX_init, EVP_EncryptInit_ex(), EVP_EncryptUpdate() and
189and 0 for failure. 240EVP_EncryptFinal_ex() return 1 for success and 0 for failure.
190 241
191EVP_DecryptInit() and EVP_DecryptUpdate() return 1 for success and 0 for failure. 242EVP_DecryptInit_ex() and EVP_DecryptUpdate() return 1 for success and 0 for failure.
192EVP_DecryptFinal() returns 0 if the decrypt failed or 1 for success. 243EVP_DecryptFinal_ex() returns 0 if the decrypt failed or 1 for success.
193 244
194EVP_CipherInit() and EVP_CipherUpdate() return 1 for success and 0 for failure. 245EVP_CipherInit_ex() and EVP_CipherUpdate() return 1 for success and 0 for failure.
195EVP_CipherFinal() returns 1 for a decryption failure or 1 for success. 246EVP_CipherFinal_ex() returns 0 for a decryption failure or 1 for success.
196 247
197EVP_CIPHER_CTX_cleanup() returns 1 for success and 0 for failure. 248EVP_CIPHER_CTX_cleanup() returns 1 for success and 0 for failure.
198 249
@@ -207,6 +258,8 @@ size.
207EVP_CIPHER_key_length() and EVP_CIPHER_CTX_key_length() return the key 258EVP_CIPHER_key_length() and EVP_CIPHER_CTX_key_length() return the key
208length. 259length.
209 260
261EVP_CIPHER_CTX_set_padding() always returns 1.
262
210EVP_CIPHER_iv_length() and EVP_CIPHER_CTX_iv_length() return the IV 263EVP_CIPHER_iv_length() and EVP_CIPHER_CTX_iv_length() return the IV
211length or zero if the cipher does not use an IV. 264length or zero if the cipher does not use an IV.
212 265
@@ -301,25 +354,26 @@ encrypted then 5 padding bytes of value 5 will be added.
301 354
302When decrypting the final block is checked to see if it has the correct form. 355When decrypting the final block is checked to see if it has the correct form.
303 356
304Although the decryption operation can produce an error, it is not a strong 357Although the decryption operation can produce an error if padding is enabled,
305test that the input data or key is correct. A random block has better than 358it is not a strong test that the input data or key is correct. A random block
3061 in 256 chance of being of the correct format and problems with the 359has better than 1 in 256 chance of being of the correct format and problems with
307input data earlier on will not produce a final decrypt error. 360the input data earlier on will not produce a final decrypt error.
308 361
309The functions EVP_EncryptInit(), EVP_EncryptUpdate(), EVP_EncryptFinal(), 362If padding is disabled then the decryption operation will always succeed if
310EVP_DecryptInit(), EVP_DecryptUpdate(), EVP_CipherInit() and EVP_CipherUpdate() 363the total amount of data decrypted is a multiple of the block size.
311and EVP_CIPHER_CTX_cleanup() did not return errors in OpenSSL version 0.9.5a or 364
312earlier. Software only versions of encryption algorithms will never return 365The functions EVP_EncryptInit(), EVP_EncryptFinal(), EVP_DecryptInit(),
313error codes for these functions, unless there is a programming error (for example 366EVP_CipherInit() and EVP_CipherFinal() are obsolete but are retained for
314and attempt to set the key before the cipher is set in EVP_EncryptInit() ). 367compatibility with existing code. New code should use EVP_EncryptInit_ex(),
368EVP_EncryptFinal_ex(), EVP_DecryptInit_ex(), EVP_DecryptFinal_ex(),
369EVP_CipherInit_ex() and EVP_CipherFinal_ex() because they can reuse an
370existing context without allocating and freeing it up on each call.
315 371
316=head1 BUGS 372=head1 BUGS
317 373
318For RC5 the number of rounds can currently only be set to 8, 12 or 16. This is 374For RC5 the number of rounds can currently only be set to 8, 12 or 16. This is
319a limitation of the current RC5 code rather than the EVP interface. 375a limitation of the current RC5 code rather than the EVP interface.
320 376
321It should be possible to disable PKCS padding: currently it isn't.
322
323EVP_MAX_KEY_LENGTH and EVP_MAX_IV_LENGTH only refer to the internal ciphers with 377EVP_MAX_KEY_LENGTH and EVP_MAX_IV_LENGTH only refer to the internal ciphers with
324default key lengths. If custom ciphers exceed these values the results are 378default key lengths. If custom ciphers exceed these values the results are
325unpredictable. This is because it has become standard practice to define a 379unpredictable. This is because it has become standard practice to define a
@@ -333,22 +387,113 @@ for certain common S/MIME ciphers (RC2, DES, triple DES) in CBC mode.
333Get the number of rounds used in RC5: 387Get the number of rounds used in RC5:
334 388
335 int nrounds; 389 int nrounds;
336 EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GET_RC5_ROUNDS, 0, &i); 390 EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GET_RC5_ROUNDS, 0, &nrounds);
337 391
338Get the RC2 effective key length: 392Get the RC2 effective key length:
339 393
340 int key_bits; 394 int key_bits;
341 EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GET_RC2_KEY_BITS, 0, &i); 395 EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GET_RC2_KEY_BITS, 0, &key_bits);
342 396
343Set the number of rounds used in RC5: 397Set the number of rounds used in RC5:
344 398
345 int nrounds; 399 int nrounds;
346 EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_SET_RC5_ROUNDS, i, NULL); 400 EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_SET_RC5_ROUNDS, nrounds, NULL);
347 401
348Set the number of rounds used in RC2: 402Set the effective key length used in RC2:
403
404 int key_bits;
405 EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_SET_RC2_KEY_BITS, key_bits, NULL);
406
407Encrypt a string using blowfish:
408
409 int do_crypt(char *outfile)
410 {
411 unsigned char outbuf[1024];
412 int outlen, tmplen;
413 /* Bogus key and IV: we'd normally set these from
414 * another source.
415 */
416 unsigned char key[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
417 unsigned char iv[] = {1,2,3,4,5,6,7,8};
418 char intext[] = "Some Crypto Text";
419 EVP_CIPHER_CTX ctx;
420 FILE *out;
421 EVP_CIPHER_CTX_init(&ctx);
422 EVP_EncryptInit_ex(&ctx, NULL, EVP_bf_cbc(), key, iv);
423
424 if(!EVP_EncryptUpdate(&ctx, outbuf, &outlen, intext, strlen(intext)))
425 {
426 /* Error */
427 return 0;
428 }
429 /* Buffer passed to EVP_EncryptFinal() must be after data just
430 * encrypted to avoid overwriting it.
431 */
432 if(!EVP_EncryptFinal_ex(&ctx, outbuf + outlen, &tmplen))
433 {
434 /* Error */
435 return 0;
436 }
437 outlen += tmplen;
438 EVP_CIPHER_CTX_cleanup(&ctx);
439 /* Need binary mode for fopen because encrypted data is
440 * binary data. Also cannot use strlen() on it because
441 * it wont be null terminated and may contain embedded
442 * nulls.
443 */
444 out = fopen(outfile, "wb");
445 fwrite(outbuf, 1, outlen, out);
446 fclose(out);
447 return 1;
448 }
449
450The ciphertext from the above example can be decrypted using the B<openssl>
451utility with the command line:
452
453 S<openssl bf -in cipher.bin -K 000102030405060708090A0B0C0D0E0F -iv 0102030405060708 -d>
454
455General encryption, decryption function example using FILE I/O and RC2 with an
45680 bit key:
457
458 int do_crypt(FILE *in, FILE *out, int do_encrypt)
459 {
460 /* Allow enough space in output buffer for additional block */
461 inbuf[1024], outbuf[1024 + EVP_MAX_BLOCK_LENGTH];
462 int inlen, outlen;
463 /* Bogus key and IV: we'd normally set these from
464 * another source.
465 */
466 unsigned char key[] = "0123456789";
467 unsigned char iv[] = "12345678";
468 /* Don't set key or IV because we will modify the parameters */
469 EVP_CIPHER_CTX_init(&ctx);
470 EVP_CipherInit_ex(&ctx, EVP_rc2(), NULL, NULL, NULL, do_encrypt);
471 EVP_CIPHER_CTX_set_key_length(&ctx, 10);
472 /* We finished modifying parameters so now we can set key and IV */
473 EVP_CipherInit_ex(&ctx, NULL, NULL, key, iv, do_encrypt);
474
475 for(;;)
476 {
477 inlen = fread(inbuf, 1, 1024, in);
478 if(inlen <= 0) break;
479 if(!EVP_CipherUpdate(&ctx, outbuf, &outlen, inbuf, inlen))
480 {
481 /* Error */
482 return 0;
483 }
484 fwrite(outbuf, 1, outlen, out);
485 }
486 if(!EVP_CipherFinal_ex(&ctx, outbuf, &outlen))
487 {
488 /* Error */
489 return 0;
490 }
491 fwrite(outbuf, 1, outlen, out);
492
493 EVP_CIPHER_CTX_cleanup(&ctx);
494 return 1;
495 }
349 496
350 int nrounds;
351 EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_SET_RC2_KEY_BITS, i, NULL);
352 497
353=head1 SEE ALSO 498=head1 SEE ALSO
354 499
diff --git a/src/lib/libcrypto/doc/EVP_SignInit.pod b/src/lib/libcrypto/doc/EVP_SignInit.pod
index d5ce245ecd..b1ac129430 100644
--- a/src/lib/libcrypto/doc/EVP_SignInit.pod
+++ b/src/lib/libcrypto/doc/EVP_SignInit.pod
@@ -8,10 +8,12 @@ EVP_SignInit, EVP_SignUpdate, EVP_SignFinal - EVP signing functions
8 8
9 #include <openssl/evp.h> 9 #include <openssl/evp.h>
10 10
11 void EVP_SignInit(EVP_MD_CTX *ctx, const EVP_MD *type); 11 int EVP_SignInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl);
12 void EVP_SignUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt); 12 int EVP_SignUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt);
13 int EVP_SignFinal(EVP_MD_CTX *ctx,unsigned char *sig,unsigned int *s, EVP_PKEY *pkey); 13 int EVP_SignFinal(EVP_MD_CTX *ctx,unsigned char *sig,unsigned int *s, EVP_PKEY *pkey);
14 14
15 void EVP_SignInit(EVP_MD_CTX *ctx, const EVP_MD *type);
16
15 int EVP_PKEY_size(EVP_PKEY *pkey); 17 int EVP_PKEY_size(EVP_PKEY *pkey);
16 18
17=head1 DESCRIPTION 19=head1 DESCRIPTION
@@ -19,9 +21,9 @@ EVP_SignInit, EVP_SignUpdate, EVP_SignFinal - EVP signing functions
19The EVP signature routines are a high level interface to digital 21The EVP signature routines are a high level interface to digital
20signatures. 22signatures.
21 23
22EVP_SignInit() initializes a signing context B<ctx> to using digest 24EVP_SignInit_ex() sets up signing context B<ctx> to use digest
23B<type>: this will typically be supplied by a function such as 25B<type> from ENGINE B<impl>. B<ctx> must be initialized with
24EVP_sha1(). 26EVP_MD_CTX_init() before calling this function.
25 27
26EVP_SignUpdate() hashes B<cnt> bytes of data at B<d> into the 28EVP_SignUpdate() hashes B<cnt> bytes of data at B<d> into the
27signature context B<ctx>. This function can be called several times on the 29signature context B<ctx>. This function can be called several times on the
@@ -31,18 +33,18 @@ EVP_SignFinal() signs the data in B<ctx> using the private key B<pkey>
31and places the signature in B<sig>. If the B<s> parameter is not NULL 33and places the signature in B<sig>. If the B<s> parameter is not NULL
32then the number of bytes of data written (i.e. the length of the signature) 34then the number of bytes of data written (i.e. the length of the signature)
33will be written to the integer at B<s>, at most EVP_PKEY_size(pkey) bytes 35will be written to the integer at B<s>, at most EVP_PKEY_size(pkey) bytes
34will be written. After calling EVP_SignFinal() no additional calls to 36will be written.
35EVP_SignUpdate() can be made, but EVP_SignInit() can be called to initialize 37
36a new signature operation. 38EVP_SignInit() initializes a signing context B<ctx> to use the default
39implementation of digest B<type>.
37 40
38EVP_PKEY_size() returns the maximum size of a signature in bytes. The actual 41EVP_PKEY_size() returns the maximum size of a signature in bytes. The actual
39signature returned by EVP_SignFinal() may be smaller. 42signature returned by EVP_SignFinal() may be smaller.
40 43
41=head1 RETURN VALUES 44=head1 RETURN VALUES
42 45
43EVP_SignInit() and EVP_SignUpdate() do not return values. 46EVP_SignInit_ex(), EVP_SignUpdate() and EVP_SignFinal() return 1
44 47for success and 0 for failure.
45EVP_SignFinal() returns 1 for success and 0 for failure.
46 48
47EVP_PKEY_size() returns the maximum size of a signature in bytes. 49EVP_PKEY_size() returns the maximum size of a signature in bytes.
48 50
@@ -63,11 +65,18 @@ When signing with DSA private keys the random number generator must be seeded
63or the operation will fail. The random number generator does not need to be 65or the operation will fail. The random number generator does not need to be
64seeded for RSA signatures. 66seeded for RSA signatures.
65 67
68The call to EVP_SignFinal() internally finalizes a copy of the digest context.
69This means that calls to EVP_SignUpdate() and EVP_SignFinal() can be called
70later to digest and sign additional data.
71
72Since only a copy of the digest context is ever finalized the context must
73be cleaned up after use by calling EVP_MD_CTX_cleanup() or a memory leak
74will occur.
75
66=head1 BUGS 76=head1 BUGS
67 77
68Several of the functions do not return values: maybe they should. Although the 78Older versions of this documentation wrongly stated that calls to
69internal digest operations will never fail some future hardware based operations 79EVP_SignUpdate() could not be made after calling EVP_SignFinal().
70might.
71 80
72=head1 SEE ALSO 81=head1 SEE ALSO
73 82
@@ -82,4 +91,6 @@ L<SHA1(3)|SHA1(3)>, L<digest(1)|digest(1)>
82EVP_SignInit(), EVP_SignUpdate() and EVP_SignFinal() are 91EVP_SignInit(), EVP_SignUpdate() and EVP_SignFinal() are
83available in all versions of SSLeay and OpenSSL. 92available in all versions of SSLeay and OpenSSL.
84 93
94EVP_SignInit_ex() was added in OpenSSL 0.9.7
95
85=cut 96=cut
diff --git a/src/lib/libcrypto/doc/EVP_VerifyInit.pod b/src/lib/libcrypto/doc/EVP_VerifyInit.pod
index 736a0f4a82..80c656fde8 100644
--- a/src/lib/libcrypto/doc/EVP_VerifyInit.pod
+++ b/src/lib/libcrypto/doc/EVP_VerifyInit.pod
@@ -8,30 +8,35 @@ EVP_VerifyInit, EVP_VerifyUpdate, EVP_VerifyFinal - EVP signature verification f
8 8
9 #include <openssl/evp.h> 9 #include <openssl/evp.h>
10 10
11 void EVP_VerifyInit(EVP_MD_CTX *ctx, const EVP_MD *type); 11 int EVP_VerifyInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl);
12 void EVP_VerifyUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt); 12 int EVP_VerifyUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt);
13 int EVP_VerifyFinal(EVP_MD_CTX *ctx,unsigned char *sigbuf, unsigned int siglen,EVP_PKEY *pkey); 13 int EVP_VerifyFinal(EVP_MD_CTX *ctx,unsigned char *sigbuf, unsigned int siglen,EVP_PKEY *pkey);
14 14
15 int EVP_VerifyInit(EVP_MD_CTX *ctx, const EVP_MD *type);
16
15=head1 DESCRIPTION 17=head1 DESCRIPTION
16 18
17The EVP signature verification routines are a high level interface to digital 19The EVP signature verification routines are a high level interface to digital
18signatures. 20signatures.
19 21
20EVP_VerifyInit() initializes a verification context B<ctx> to using digest 22EVP_VerifyInit_ex() sets up verification context B<ctx> to use digest
21B<type>: this will typically be supplied by a function such as EVP_sha1(). 23B<type> from ENGINE B<impl>. B<ctx> must be initialized by calling
24EVP_MD_CTX_init() before calling this function.
22 25
23EVP_VerifyUpdate() hashes B<cnt> bytes of data at B<d> into the 26EVP_VerifyUpdate() hashes B<cnt> bytes of data at B<d> into the
24verification context B<ctx>. This function can be called several times on the 27verification context B<ctx>. This function can be called several times on the
25same B<ctx> to include additional data. 28same B<ctx> to include additional data.
26 29
27EVP_VerifyFinal() verifies the data in B<ctx> using the public key B<pkey> 30EVP_VerifyFinal() verifies the data in B<ctx> using the public key B<pkey>
28and against the B<siglen> bytes at B<sigbuf>. After calling EVP_VerifyFinal() 31and against the B<siglen> bytes at B<sigbuf>.
29no additional calls to EVP_VerifyUpdate() can be made, but EVP_VerifyInit() 32
30can be called to initialize a new verification operation. 33EVP_VerifyInit() initializes verification context B<ctx> to use the default
34implementation of digest B<type>.
31 35
32=head1 RETURN VALUES 36=head1 RETURN VALUES
33 37
34EVP_VerifyInit() and EVP_VerifyUpdate() do not return values. 38EVP_VerifyInit_ex() and EVP_VerifyUpdate() return 1 for success and 0 for
39failure.
35 40
36EVP_VerifyFinal() returns 1 for a correct signature, 0 for failure and -1 if some 41EVP_VerifyFinal() returns 1 for a correct signature, 0 for failure and -1 if some
37other error occurred. 42other error occurred.
@@ -49,11 +54,18 @@ digest algorithm must be used with the correct public key type. A list of
49algorithms and associated public key algorithms appears in 54algorithms and associated public key algorithms appears in
50L<EVP_DigestInit(3)|EVP_DigestInit(3)>. 55L<EVP_DigestInit(3)|EVP_DigestInit(3)>.
51 56
57The call to EVP_VerifyFinal() internally finalizes a copy of the digest context.
58This means that calls to EVP_VerifyUpdate() and EVP_VerifyFinal() can be called
59later to digest and verify additional data.
60
61Since only a copy of the digest context is ever finalized the context must
62be cleaned up after use by calling EVP_MD_CTX_cleanup() or a memory leak
63will occur.
64
52=head1 BUGS 65=head1 BUGS
53 66
54Several of the functions do not return values: maybe they should. Although the 67Older versions of this documentation wrongly stated that calls to
55internal digest operations will never fail some future hardware based operations 68EVP_VerifyUpdate() could not be made after calling EVP_VerifyFinal().
56might.
57 69
58=head1 SEE ALSO 70=head1 SEE ALSO
59 71
@@ -69,4 +81,6 @@ L<sha(3)|sha(3)>, L<digest(1)|digest(1)>
69EVP_VerifyInit(), EVP_VerifyUpdate() and EVP_VerifyFinal() are 81EVP_VerifyInit(), EVP_VerifyUpdate() and EVP_VerifyFinal() are
70available in all versions of SSLeay and OpenSSL. 82available in all versions of SSLeay and OpenSSL.
71 83
84EVP_VerifyInit_ex() was added in OpenSSL 0.9.7
85
72=cut 86=cut
diff --git a/src/lib/libcrypto/doc/OPENSSL_VERSION_NUMBER.pod b/src/lib/libcrypto/doc/OPENSSL_VERSION_NUMBER.pod
index 68ea723259..c39ac35e78 100644
--- a/src/lib/libcrypto/doc/OPENSSL_VERSION_NUMBER.pod
+++ b/src/lib/libcrypto/doc/OPENSSL_VERSION_NUMBER.pod
@@ -2,7 +2,7 @@
2 2
3=head1 NAME 3=head1 NAME
4 4
5OPENSSL_VERSION_NUMBER, SSLeay SSLeay_version - get OpenSSL version number 5OPENSSL_VERSION_NUMBER, SSLeay, SSLeay_version - get OpenSSL version number
6 6
7=head1 SYNOPSIS 7=head1 SYNOPSIS
8 8
@@ -11,7 +11,7 @@ OPENSSL_VERSION_NUMBER, SSLeay SSLeay_version - get OpenSSL version number
11 11
12 #include <openssl/crypto.h> 12 #include <openssl/crypto.h>
13 long SSLeay(void); 13 long SSLeay(void);
14 char *SSLeay_version(int t); 14 const char *SSLeay_version(int t);
15 15
16=head1 DESCRIPTION 16=head1 DESCRIPTION
17 17
@@ -55,20 +55,32 @@ SSLeay_version() returns different strings depending on B<t>:
55=over 4 55=over 4
56 56
57=item SSLEAY_VERSION 57=item SSLEAY_VERSION
58
58The text variant of the version number and the release date. For example, 59The text variant of the version number and the release date. For example,
59"OpenSSL 0.9.5a 1 Apr 2000". 60"OpenSSL 0.9.5a 1 Apr 2000".
60 61
61=item SSLEAY_CFLAGS 62=item SSLEAY_CFLAGS
62The flags given to the C compiler when compiling OpenSSL are returned in a 63
63string. 64The compiler flags set for the compilation process in the form
65"compiler: ..." if available or "compiler: information not available"
66otherwise.
67
68=item SSLEAY_BUILT_ON
69
70The date of the build process in the form "built on: ..." if available
71or "built on: date not available" otherwise.
64 72
65=item SSLEAY_PLATFORM 73=item SSLEAY_PLATFORM
66The platform name used when OpenSSL was configured is returned.
67 74
68=back 75The "Configure" target of the library build in the form "platform: ..."
76if available or "platform: information not available" otherwise.
77
78=item SSLEAY_DIR
69 79
70If the data request isn't available, a text saying that the information is 80The "OPENSSLDIR" setting of the library build in the form "OPENSSLDIR: "...""
71not available is returned. 81if available or "OPENSSLDIR: N/A" otherwise.
82
83=back
72 84
73For an unknown B<t>, the text "not available" is returned. 85For an unknown B<t>, the text "not available" is returned.
74 86
@@ -84,5 +96,6 @@ L<crypto(3)|crypto(3)>
84 96
85SSLeay() and SSLEAY_VERSION_NUMBER are available in all versions of SSLeay and OpenSSL. 97SSLeay() and SSLEAY_VERSION_NUMBER are available in all versions of SSLeay and OpenSSL.
86OPENSSL_VERSION_NUMBER is available in all versions of OpenSSL. 98OPENSSL_VERSION_NUMBER is available in all versions of OpenSSL.
99B<SSLEAY_DIR> was added in OpenSSL 0.9.7.
87 100
88=cut 101=cut
diff --git a/src/lib/libcrypto/doc/RSA_generate_key.pod b/src/lib/libcrypto/doc/RSA_generate_key.pod
index 0e0f0a764c..11bc0b3459 100644
--- a/src/lib/libcrypto/doc/RSA_generate_key.pod
+++ b/src/lib/libcrypto/doc/RSA_generate_key.pod
@@ -19,7 +19,7 @@ be seeded prior to calling RSA_generate_key().
19 19
20The modulus size will be B<num> bits, and the public exponent will be 20The modulus size will be B<num> bits, and the public exponent will be
21B<e>. Key sizes with B<num> E<lt> 1024 should be considered insecure. 21B<e>. Key sizes with B<num> E<lt> 1024 should be considered insecure.
22The exponent is an odd number, typically 3 or 65535. 22The exponent is an odd number, typically 3, 17 or 65537.
23 23
24A callback function may be used to provide feedback about the 24A callback function may be used to provide feedback about the
25progress of the key generation. If B<callback> is not B<NULL>, it 25progress of the key generation. If B<callback> is not B<NULL>, it
diff --git a/src/lib/libcrypto/doc/RSA_public_encrypt.pod b/src/lib/libcrypto/doc/RSA_public_encrypt.pod
index 23861c0004..8022a23f99 100644
--- a/src/lib/libcrypto/doc/RSA_public_encrypt.pod
+++ b/src/lib/libcrypto/doc/RSA_public_encrypt.pod
@@ -74,10 +74,6 @@ SSL, PKCS #1 v2.0
74 74
75L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>, L<RSA_size(3)|RSA_size(3)> 75L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>, L<RSA_size(3)|RSA_size(3)>
76 76
77=head1 NOTES
78
79The L<RSA_PKCS1_RSAref(3)|RSA_PKCS1_RSAref(3)> method supports only the RSA_PKCS1_PADDING mode.
80
81=head1 HISTORY 77=head1 HISTORY
82 78
83The B<padding> argument was added in SSLeay 0.8. RSA_NO_PADDING is 79The B<padding> argument was added in SSLeay 0.8. RSA_NO_PADDING is
diff --git a/src/lib/libcrypto/doc/RSA_set_method.pod b/src/lib/libcrypto/doc/RSA_set_method.pod
index b672712292..14917dd35f 100644
--- a/src/lib/libcrypto/doc/RSA_set_method.pod
+++ b/src/lib/libcrypto/doc/RSA_set_method.pod
@@ -3,7 +3,7 @@
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_PKCS1_RSAref, 6RSA_get_method, RSA_PKCS1_SSLeay,
7RSA_null_method, RSA_flags, RSA_new_method - select RSA method 7RSA_null_method, RSA_flags, RSA_new_method - select RSA method
8 8
9=head1 SYNOPSIS 9=head1 SYNOPSIS
@@ -15,14 +15,12 @@ RSA_null_method, RSA_flags, RSA_new_method - select RSA method
15 15
16 RSA_METHOD *RSA_get_default_openssl_method(void); 16 RSA_METHOD *RSA_get_default_openssl_method(void);
17 17
18 RSA_METHOD *RSA_set_method(RSA *rsa, ENGINE *engine); 18 int RSA_set_method(RSA *rsa, ENGINE *engine);
19 19
20 RSA_METHOD *RSA_get_method(RSA *rsa); 20 RSA_METHOD *RSA_get_method(RSA *rsa);
21 21
22 RSA_METHOD *RSA_PKCS1_SSLeay(void); 22 RSA_METHOD *RSA_PKCS1_SSLeay(void);
23 23
24 RSA_METHOD *RSA_PKCS1_RSAref(void);
25
26 RSA_METHOD *RSA_null_method(void); 24 RSA_METHOD *RSA_null_method(void);
27 25
28 int RSA_flags(RSA *rsa); 26 int RSA_flags(RSA *rsa);
@@ -35,17 +33,8 @@ An B<RSA_METHOD> specifies the functions that OpenSSL uses for RSA
35operations. By modifying the method, alternative implementations 33operations. By modifying the method, alternative implementations
36such as hardware accelerators may be used. 34such as hardware accelerators may be used.
37 35
38Initially, the default is to use the OpenSSL internal implementation, 36Initially, the default is to use the OpenSSL internal implementation.
39unless OpenSSL was configured with the C<rsaref> or C<-DRSA_NULL> 37RSA_PKCS1_SSLeay() returns a pointer to that method.
40options. RSA_PKCS1_SSLeay() returns a pointer to that method.
41
42RSA_PKCS1_RSAref() returns a pointer to a method that uses the RSAref
43library. This is the default method in the C<rsaref> configuration;
44the function is not available in other configurations.
45RSA_null_method() returns a pointer to a method that does not support
46the RSA transformation. It is the default if OpenSSL is compiled with
47C<-DRSA_NULL>. These methods may be useful in the USA because of a
48patent on the RSA cryptosystem.
49 38
50RSA_set_default_openssl_method() makes B<meth> the default method for all B<RSA> 39RSA_set_default_openssl_method() makes B<meth> the default method for all B<RSA>
51structures created later. B<NB:> This is true only whilst the default engine 40structures created later. B<NB:> This is true only whilst the default engine
@@ -132,9 +121,8 @@ the default engine for RSA operations is used.
132 121
133=head1 RETURN VALUES 122=head1 RETURN VALUES
134 123
135RSA_PKCS1_SSLeay(), RSA_PKCS1_RSAref(), RSA_PKCS1_null_method(), 124RSA_PKCS1_SSLeay(), RSA_PKCS1_null_method(), RSA_get_default_openssl_method()
136RSA_get_default_openssl_method() and RSA_get_method() return pointers to 125and RSA_get_method() return pointers to the respective RSA_METHODs.
137the respective RSA_METHODs.
138 126
139RSA_set_default_openssl_method() returns no value. 127RSA_set_default_openssl_method() returns no value.
140 128
@@ -163,6 +151,6 @@ added in OpenSSL 0.9.4.
163RSA_set_default_openssl_method() and RSA_get_default_openssl_method() 151RSA_set_default_openssl_method() and RSA_get_default_openssl_method()
164replaced RSA_set_default_method() and RSA_get_default_method() respectively, 152replaced RSA_set_default_method() and RSA_get_default_method() respectively,
165and RSA_set_method() and RSA_new_method() were altered to use B<ENGINE>s 153and RSA_set_method() and RSA_new_method() were altered to use B<ENGINE>s
166rather than B<DH_METHOD>s during development of OpenSSL 0.9.6. 154rather than B<RSA_METHOD>s during development of OpenSSL 0.9.6.
167 155
168=cut 156=cut
diff --git a/src/lib/libcrypto/doc/bn.pod b/src/lib/libcrypto/doc/bn.pod
index d183028d61..210dfeac08 100644
--- a/src/lib/libcrypto/doc/bn.pod
+++ b/src/lib/libcrypto/doc/bn.pod
@@ -21,19 +21,27 @@ bn - multiprecision integer arithmetics
21 BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b); 21 BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b);
22 BIGNUM *BN_dup(const BIGNUM *a); 22 BIGNUM *BN_dup(const BIGNUM *a);
23 23
24 BIGNUM *BN_swap(BIGNUM *a, BIGNUM *b);
25
24 int BN_num_bytes(const BIGNUM *a); 26 int BN_num_bytes(const BIGNUM *a);
25 int BN_num_bits(const BIGNUM *a); 27 int BN_num_bits(const BIGNUM *a);
26 int BN_num_bits_word(BN_ULONG w); 28 int BN_num_bits_word(BN_ULONG w);
27 29
28 int BN_add(BIGNUM *r, BIGNUM *a, BIGNUM *b); 30 int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
29 int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); 31 int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
30 int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx); 32 int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
33 int BN_sqr(BIGNUM *r, BIGNUM *a, BN_CTX *ctx);
31 int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *a, const BIGNUM *d, 34 int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *a, const BIGNUM *d,
32 BN_CTX *ctx); 35 BN_CTX *ctx);
33 int BN_sqr(BIGNUM *r, BIGNUM *a, BN_CTX *ctx);
34 int BN_mod(BIGNUM *rem, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); 36 int BN_mod(BIGNUM *rem, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
37 int BN_nnmod(BIGNUM *rem, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
38 int BN_mod_add(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m,
39 BN_CTX *ctx);
40 int BN_mod_sub(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m,
41 BN_CTX *ctx);
35 int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m, 42 int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m,
36 BN_CTX *ctx); 43 BN_CTX *ctx);
44 int BN_mod_sqr(BIGNUM *ret, BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
37 int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BN_CTX *ctx); 45 int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BN_CTX *ctx);
38 int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p, 46 int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
39 const BIGNUM *m, BN_CTX *ctx); 47 const BIGNUM *m, BN_CTX *ctx);
@@ -54,13 +62,14 @@ bn - multiprecision integer arithmetics
54 62
55 int BN_zero(BIGNUM *a); 63 int BN_zero(BIGNUM *a);
56 int BN_one(BIGNUM *a); 64 int BN_one(BIGNUM *a);
57 BIGNUM *BN_value_one(void); 65 const BIGNUM *BN_value_one(void);
58 int BN_set_word(BIGNUM *a, unsigned long w); 66 int BN_set_word(BIGNUM *a, unsigned long w);
59 unsigned long BN_get_word(BIGNUM *a); 67 unsigned long BN_get_word(BIGNUM *a);
60 68
61 int BN_rand(BIGNUM *rnd, int bits, int top, int bottom); 69 int BN_rand(BIGNUM *rnd, int bits, int top, int bottom);
62 int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom); 70 int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom);
63 int BN_rand_range(BIGNUM *rnd, BIGNUM *range); 71 int BN_rand_range(BIGNUM *rnd, BIGNUM *range);
72 int BN_pseudo_rand_range(BIGNUM *rnd, BIGNUM *range);
64 73
65 BIGNUM *BN_generate_prime(BIGNUM *ret, int bits,int safe, BIGNUM *add, 74 BIGNUM *BN_generate_prime(BIGNUM *ret, int bits,int safe, BIGNUM *add,
66 BIGNUM *rem, void (*callback)(int, int, void *), void *cb_arg); 75 BIGNUM *rem, void (*callback)(int, int, void *), void *cb_arg);
@@ -138,7 +147,7 @@ of B<BIGNUM>s to external formats is described in L<BN_bn2bin(3)|BN_bn2bin(3)>.
138L<bn_internal(3)|bn_internal(3)>, 147L<bn_internal(3)|bn_internal(3)>,
139L<dh(3)|dh(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>, 148L<dh(3)|dh(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>,
140L<BN_new(3)|BN_new(3)>, L<BN_CTX_new(3)|BN_CTX_new(3)>, 149L<BN_new(3)|BN_new(3)>, L<BN_CTX_new(3)|BN_CTX_new(3)>,
141L<BN_copy(3)|BN_copy(3)>, L<BN_num_bytes(3)|BN_num_bytes(3)>, 150L<BN_copy(3)|BN_copy(3)>, L<BN_swap(3)|BN_swap(3)>, L<BN_num_bytes(3)|BN_num_bytes(3)>,
142L<BN_add(3)|BN_add(3)>, L<BN_add_word(3)|BN_add_word(3)>, 151L<BN_add(3)|BN_add(3)>, L<BN_add_word(3)|BN_add_word(3)>,
143L<BN_cmp(3)|BN_cmp(3)>, L<BN_zero(3)|BN_zero(3)>, L<BN_rand(3)|BN_rand(3)>, 152L<BN_cmp(3)|BN_cmp(3)>, L<BN_zero(3)|BN_zero(3)>, L<BN_rand(3)|BN_rand(3)>,
144L<BN_generate_prime(3)|BN_generate_prime(3)>, L<BN_set_bit(3)|BN_set_bit(3)>, 153L<BN_generate_prime(3)|BN_generate_prime(3)>, L<BN_set_bit(3)|BN_set_bit(3)>,
diff --git a/src/lib/libcrypto/doc/rsa.pod b/src/lib/libcrypto/doc/rsa.pod
index ef0d4df205..09ad30cab1 100644
--- a/src/lib/libcrypto/doc/rsa.pod
+++ b/src/lib/libcrypto/doc/rsa.pod
@@ -37,7 +37,6 @@ rsa - RSA public key cryptosystem
37 int RSA_set_method(RSA *rsa, ENGINE *engine); 37 int RSA_set_method(RSA *rsa, ENGINE *engine);
38 RSA_METHOD *RSA_get_method(RSA *rsa); 38 RSA_METHOD *RSA_get_method(RSA *rsa);
39 RSA_METHOD *RSA_PKCS1_SSLeay(void); 39 RSA_METHOD *RSA_PKCS1_SSLeay(void);
40 RSA_METHOD *RSA_PKCS1_RSAref(void);
41 RSA_METHOD *RSA_null_method(void); 40 RSA_METHOD *RSA_null_method(void);
42 int RSA_flags(RSA *rsa); 41 int RSA_flags(RSA *rsa);
43 RSA *RSA_new_method(ENGINE *engine); 42 RSA *RSA_new_method(ENGINE *engine);
diff --git a/src/lib/libcrypto/dsa/Makefile.ssl b/src/lib/libcrypto/dsa/Makefile.ssl
index d88f596364..32ecf6ee01 100644
--- a/src/lib/libcrypto/dsa/Makefile.ssl
+++ b/src/lib/libcrypto/dsa/Makefile.ssl
@@ -5,13 +5,14 @@
5DIR= dsa 5DIR= dsa
6TOP= ../.. 6TOP= ../..
7CC= cc 7CC= cc
8INCLUDES= -I.. -I../../include 8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g 9CFLAG=-g
10INSTALL_PREFIX= 10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl 11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl 12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl 13MAKE= make -f Makefile.ssl
14MAKEDEPEND= $(TOP)/util/domd $(TOP) 14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
15MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
16AR= ar r 17AR= ar r
17 18
@@ -41,8 +42,7 @@ all: lib
41 42
42lib: $(LIBOBJ) 43lib: $(LIBOBJ)
43 $(AR) $(LIB) $(LIBOBJ) 44 $(AR) $(LIB) $(LIBOBJ)
44 @echo You may get an error following this line. Please ignore. 45 $(RANLIB) $(LIB) || echo Never mind.
45 - $(RANLIB) $(LIB)
46 @touch lib 46 @touch lib
47 47
48files: 48files:
@@ -81,110 +81,89 @@ clean:
81 81
82# DO NOT DELETE THIS LINE -- make depend depends on it. 82# DO NOT DELETE THIS LINE -- make depend depends on it.
83 83
84dsa_asn1.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 84dsa_asn1.o: ../../e_os.h ../../include/openssl/asn1.h
85dsa_asn1.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 85dsa_asn1.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
86dsa_asn1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 86dsa_asn1.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
87dsa_asn1.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 87dsa_asn1.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
88dsa_asn1.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 88dsa_asn1.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
89dsa_asn1.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 89dsa_asn1.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
90dsa_asn1.o: ../../include/openssl/opensslconf.h 90dsa_asn1.o: ../../include/openssl/opensslconf.h
91dsa_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 91dsa_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
92dsa_asn1.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 92dsa_asn1.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
93dsa_asn1.o: ../cryptlib.h 93dsa_asn1.o: ../../include/openssl/symhacks.h ../cryptlib.h dsa_asn1.c
94dsa_err.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 94dsa_err.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
95dsa_err.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h 95dsa_err.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
96dsa_err.o: ../../include/openssl/dsa.h ../../include/openssl/err.h 96dsa_err.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
97dsa_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 97dsa_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
98dsa_err.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 98dsa_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
99dsa_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
99dsa_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.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/asn1.h
100dsa_gen.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 103dsa_gen.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
101dsa_gen.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 104dsa_gen.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
102dsa_gen.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 105dsa_gen.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
103dsa_gen.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 106dsa_gen.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
104dsa_gen.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 107dsa_gen.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
108dsa_gen.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
105dsa_gen.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 109dsa_gen.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
106dsa_gen.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h 110dsa_gen.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
107dsa_gen.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 111dsa_gen.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
108dsa_gen.o: ../../include/openssl/symhacks.h ../cryptlib.h 112dsa_gen.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
109dsa_key.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 113dsa_gen.o: ../cryptlib.h dsa_gen.c
114dsa_key.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
110dsa_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 115dsa_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
111dsa_key.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 116dsa_key.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
112dsa_key.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 117dsa_key.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
113dsa_key.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 118dsa_key.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
114dsa_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 119dsa_key.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
115dsa_key.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h 120dsa_key.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
116dsa_key.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 121dsa_key.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
117dsa_key.o: ../../include/openssl/symhacks.h ../cryptlib.h 122dsa_key.o: ../cryptlib.h dsa_key.c
118dsa_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 123dsa_lib.o: ../../e_os.h ../../include/openssl/asn1.h
119dsa_lib.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 124dsa_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
120dsa_lib.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 125dsa_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
121dsa_lib.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
122dsa_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 126dsa_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
123dsa_lib.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 127dsa_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
124dsa_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h 128dsa_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
125dsa_lib.o: ../../include/openssl/evp.h ../../include/openssl/idea.h 129dsa_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
126dsa_lib.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h 130dsa_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
127dsa_lib.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
128dsa_lib.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
129dsa_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
130dsa_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
131dsa_lib.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
132dsa_lib.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
133dsa_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 131dsa_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
134dsa_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 132dsa_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
135dsa_lib.o: ../../include/openssl/symhacks.h ../cryptlib.h 133dsa_lib.o: ../../include/openssl/ui.h ../cryptlib.h dsa_lib.c
136dsa_ossl.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 134dsa_ossl.o: ../../e_os.h ../../include/openssl/asn1.h
137dsa_ossl.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 135dsa_ossl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
138dsa_ossl.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 136dsa_ossl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
139dsa_ossl.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
140dsa_ossl.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 137dsa_ossl.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
141dsa_ossl.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 138dsa_ossl.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
142dsa_ossl.o: ../../include/openssl/engine.h ../../include/openssl/err.h 139dsa_ossl.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
143dsa_ossl.o: ../../include/openssl/evp.h ../../include/openssl/idea.h 140dsa_ossl.o: ../../include/openssl/opensslconf.h
144dsa_ossl.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h 141dsa_ossl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
145dsa_ossl.o: ../../include/openssl/md4.h ../../include/openssl/md5.h 142dsa_ossl.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
146dsa_ossl.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h 143dsa_ossl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
147dsa_ossl.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 144dsa_ossl.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
148dsa_ossl.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 145dsa_ossl.o: ../cryptlib.h dsa_ossl.c
149dsa_ossl.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 146dsa_sign.o: ../../e_os.h ../../include/openssl/asn1.h
150dsa_ossl.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 147dsa_sign.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
151dsa_ossl.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 148dsa_sign.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
152dsa_ossl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
153dsa_ossl.o: ../../include/openssl/symhacks.h ../cryptlib.h
154dsa_sign.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
155dsa_sign.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
156dsa_sign.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
157dsa_sign.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
158dsa_sign.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 149dsa_sign.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
159dsa_sign.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 150dsa_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
160dsa_sign.o: ../../include/openssl/engine.h ../../include/openssl/err.h 151dsa_sign.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
161dsa_sign.o: ../../include/openssl/evp.h ../../include/openssl/idea.h 152dsa_sign.o: ../../include/openssl/opensslconf.h
162dsa_sign.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h 153dsa_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
163dsa_sign.o: ../../include/openssl/md4.h ../../include/openssl/md5.h 154dsa_sign.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
164dsa_sign.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h 155dsa_sign.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
165dsa_sign.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 156dsa_sign.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
166dsa_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 157dsa_sign.o: ../cryptlib.h dsa_sign.c
167dsa_sign.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 158dsa_vrf.o: ../../e_os.h ../../include/openssl/asn1.h
168dsa_sign.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 159dsa_vrf.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h
169dsa_sign.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
170dsa_sign.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
171dsa_sign.o: ../../include/openssl/symhacks.h ../cryptlib.h
172dsa_vrf.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
173dsa_vrf.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
174dsa_vrf.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 160dsa_vrf.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
175dsa_vrf.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h 161dsa_vrf.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
176dsa_vrf.o: ../../include/openssl/des.h ../../include/openssl/dh.h 162dsa_vrf.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
177dsa_vrf.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h 163dsa_vrf.o: ../../include/openssl/engine.h ../../include/openssl/err.h
178dsa_vrf.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h 164dsa_vrf.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
179dsa_vrf.o: ../../include/openssl/err.h ../../include/openssl/evp.h 165dsa_vrf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
180dsa_vrf.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 166dsa_vrf.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
181dsa_vrf.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 167dsa_vrf.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
182dsa_vrf.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 168dsa_vrf.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
183dsa_vrf.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 169dsa_vrf.o: ../cryptlib.h dsa_vrf.c
184dsa_vrf.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
185dsa_vrf.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
186dsa_vrf.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
187dsa_vrf.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
188dsa_vrf.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
189dsa_vrf.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
190dsa_vrf.o: ../cryptlib.h
diff --git a/src/lib/libcrypto/dsa/dsa.h b/src/lib/libcrypto/dsa/dsa.h
index 12b60a8faa..9b3baadf2c 100644
--- a/src/lib/libcrypto/dsa/dsa.h
+++ b/src/lib/libcrypto/dsa/dsa.h
@@ -65,16 +65,17 @@
65#ifndef HEADER_DSA_H 65#ifndef HEADER_DSA_H
66#define HEADER_DSA_H 66#define HEADER_DSA_H
67 67
68#ifdef NO_DSA 68#ifdef OPENSSL_NO_DSA
69#error DSA is disabled. 69#error DSA is disabled.
70#endif 70#endif
71 71
72#ifndef NO_BIO 72#ifndef OPENSSL_NO_BIO
73#include <openssl/bio.h> 73#include <openssl/bio.h>
74#endif 74#endif
75#include <openssl/bn.h> 75#include <openssl/bn.h>
76#include <openssl/crypto.h> 76#include <openssl/crypto.h>
77#ifndef NO_DH 77#include <openssl/ossl_typ.h>
78#ifndef OPENSSL_NO_DH
78# include <openssl/dh.h> 79# include <openssl/dh.h>
79#endif 80#endif
80 81
@@ -116,7 +117,7 @@ struct dsa_st
116 /* This first variable is used to pick up errors where 117 /* This first variable is used to pick up errors where
117 * a DSA is passed instead of of a EVP_PKEY */ 118 * a DSA is passed instead of of a EVP_PKEY */
118 int pad; 119 int pad;
119 int version; 120 long version;
120 int write_params; 121 int write_params;
121 BIGNUM *p; 122 BIGNUM *p;
122 BIGNUM *q; /* == 20 */ 123 BIGNUM *q; /* == 20 */
@@ -133,11 +134,9 @@ struct dsa_st
133 char *method_mont_p; 134 char *method_mont_p;
134 int references; 135 int references;
135 CRYPTO_EX_DATA ex_data; 136 CRYPTO_EX_DATA ex_data;
136#if 0 137 const DSA_METHOD *meth;
137 DSA_METHOD *meth; 138 /* functional reference if 'meth' is ENGINE-provided */
138#else 139 ENGINE *engine;
139 struct engine_st *engine;
140#endif
141 }; 140 };
142 141
143#define DSAparams_dup(x) (DSA *)ASN1_dup((int (*)())i2d_DSAparams, \ 142#define DSAparams_dup(x) (DSA *)ASN1_dup((int (*)())i2d_DSAparams, \
@@ -154,62 +153,55 @@ struct dsa_st
154 153
155DSA_SIG * DSA_SIG_new(void); 154DSA_SIG * DSA_SIG_new(void);
156void DSA_SIG_free(DSA_SIG *a); 155void DSA_SIG_free(DSA_SIG *a);
157int i2d_DSA_SIG(DSA_SIG *a, unsigned char **pp); 156int i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp);
158DSA_SIG * d2i_DSA_SIG(DSA_SIG **v, unsigned char **pp, long length); 157DSA_SIG * d2i_DSA_SIG(DSA_SIG **v, const unsigned char **pp, long length);
159 158
160DSA_SIG * DSA_do_sign(const unsigned char *dgst,int dlen,DSA *dsa); 159DSA_SIG * DSA_do_sign(const unsigned char *dgst,int dlen,DSA *dsa);
161int DSA_do_verify(const unsigned char *dgst,int dgst_len, 160int DSA_do_verify(const unsigned char *dgst,int dgst_len,
162 DSA_SIG *sig,DSA *dsa); 161 DSA_SIG *sig,DSA *dsa);
163 162
164DSA_METHOD *DSA_OpenSSL(void); 163const DSA_METHOD *DSA_OpenSSL(void);
165 164
166void DSA_set_default_openssl_method(DSA_METHOD *); 165void DSA_set_default_method(const DSA_METHOD *);
167DSA_METHOD *DSA_get_default_openssl_method(void); 166const DSA_METHOD *DSA_get_default_method(void);
168#if 0 167int DSA_set_method(DSA *dsa, const DSA_METHOD *);
169DSA_METHOD *DSA_set_method(DSA *dsa, DSA_METHOD *);
170#else
171int DSA_set_method(DSA *dsa, struct engine_st *engine);
172#endif
173 168
174DSA * DSA_new(void); 169DSA * DSA_new(void);
175#if 0 170DSA * DSA_new_method(ENGINE *engine);
176DSA * DSA_new_method(DSA_METHOD *meth); 171void DSA_free (DSA *r);
177#else 172/* "up" the DSA object's reference count */
178DSA * DSA_new_method(struct engine_st *engine); 173int DSA_up_ref(DSA *r);
179#endif 174int DSA_size(const DSA *);
180int DSA_size(DSA *);
181 /* next 4 return -1 on error */ 175 /* next 4 return -1 on error */
182int DSA_sign_setup( DSA *dsa,BN_CTX *ctx_in,BIGNUM **kinvp,BIGNUM **rp); 176int DSA_sign_setup( DSA *dsa,BN_CTX *ctx_in,BIGNUM **kinvp,BIGNUM **rp);
183int DSA_sign(int type,const unsigned char *dgst,int dlen, 177int DSA_sign(int type,const unsigned char *dgst,int dlen,
184 unsigned char *sig, unsigned int *siglen, DSA *dsa); 178 unsigned char *sig, unsigned int *siglen, DSA *dsa);
185int DSA_verify(int type,const unsigned char *dgst,int dgst_len, 179int DSA_verify(int type,const unsigned char *dgst,int dgst_len,
186 unsigned char *sigbuf, int siglen, DSA *dsa); 180 const unsigned char *sigbuf, int siglen, DSA *dsa);
187void DSA_free (DSA *r);
188int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, 181int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
189 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); 182 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
190int DSA_set_ex_data(DSA *d, int idx, void *arg); 183int DSA_set_ex_data(DSA *d, int idx, void *arg);
191void *DSA_get_ex_data(DSA *d, int idx); 184void *DSA_get_ex_data(DSA *d, int idx);
192 185
193void ERR_load_DSA_strings(void ); 186DSA * d2i_DSAPublicKey(DSA **a, const unsigned char **pp, long length);
194 187DSA * d2i_DSAPrivateKey(DSA **a, const unsigned char **pp, long length);
195DSA * d2i_DSAPublicKey(DSA **a, unsigned char **pp, long length); 188DSA * d2i_DSAparams(DSA **a, const unsigned char **pp, long length);
196DSA * d2i_DSAPrivateKey(DSA **a, unsigned char **pp, long length); 189DSA * DSA_generate_parameters(int bits,
197DSA * d2i_DSAparams(DSA **a, unsigned char **pp, long length); 190 unsigned char *seed,int seed_len,
198DSA * DSA_generate_parameters(int bits, unsigned char *seed,int seed_len,
199 int *counter_ret, unsigned long *h_ret,void 191 int *counter_ret, unsigned long *h_ret,void
200 (*callback)(int, int, void *),void *cb_arg); 192 (*callback)(int, int, void *),void *cb_arg);
201int DSA_generate_key(DSA *a); 193int DSA_generate_key(DSA *a);
202int i2d_DSAPublicKey(DSA *a, unsigned char **pp); 194int i2d_DSAPublicKey(const DSA *a, unsigned char **pp);
203int i2d_DSAPrivateKey(DSA *a, unsigned char **pp); 195int i2d_DSAPrivateKey(const DSA *a, unsigned char **pp);
204int i2d_DSAparams(DSA *a,unsigned char **pp); 196int i2d_DSAparams(const DSA *a,unsigned char **pp);
205 197
206#ifndef NO_BIO 198#ifndef OPENSSL_NO_BIO
207int DSAparams_print(BIO *bp, DSA *x); 199int DSAparams_print(BIO *bp, const DSA *x);
208int DSA_print(BIO *bp, DSA *x, int off); 200int DSA_print(BIO *bp, const DSA *x, int off);
209#endif 201#endif
210#ifndef NO_FP_API 202#ifndef OPENSSL_NO_FP_API
211int DSAparams_print_fp(FILE *fp, DSA *x); 203int DSAparams_print_fp(FILE *fp, const DSA *x);
212int DSA_print_fp(FILE *bp, DSA *x, int off); 204int DSA_print_fp(FILE *bp, const DSA *x, int off);
213#endif 205#endif
214 206
215#define DSS_prime_checks 50 207#define DSS_prime_checks 50
@@ -218,16 +210,17 @@ int DSA_print_fp(FILE *bp, DSA *x, int off);
218#define DSA_is_prime(n, callback, cb_arg) \ 210#define DSA_is_prime(n, callback, cb_arg) \
219 BN_is_prime(n, DSS_prime_checks, callback, NULL, cb_arg) 211 BN_is_prime(n, DSS_prime_checks, callback, NULL, cb_arg)
220 212
221#ifndef NO_DH 213#ifndef OPENSSL_NO_DH
222/* Convert DSA structure (key or just parameters) into DH structure 214/* Convert DSA structure (key or just parameters) into DH structure
223 * (be careful to avoid small subgroup attacks when using this!) */ 215 * (be careful to avoid small subgroup attacks when using this!) */
224DH *DSA_dup_DH(DSA *r); 216DH *DSA_dup_DH(const DSA *r);
225#endif 217#endif
226 218
227/* BEGIN ERROR CODES */ 219/* BEGIN ERROR CODES */
228/* The following lines are auto generated by the script mkerr.pl. Any changes 220/* The following lines are auto generated by the script mkerr.pl. Any changes
229 * made after this point may be overwritten when the script is next run. 221 * made after this point may be overwritten when the script is next run.
230 */ 222 */
223void ERR_load_DSA_strings(void);
231 224
232/* Error codes for the DSA functions. */ 225/* Error codes for the DSA functions. */
233 226
@@ -237,7 +230,7 @@ DH *DSA_dup_DH(DSA *r);
237#define DSA_F_DSAPARAMS_PRINT_FP 101 230#define DSA_F_DSAPARAMS_PRINT_FP 101
238#define DSA_F_DSA_DO_SIGN 112 231#define DSA_F_DSA_DO_SIGN 112
239#define DSA_F_DSA_DO_VERIFY 113 232#define DSA_F_DSA_DO_VERIFY 113
240#define DSA_F_DSA_NEW 103 233#define DSA_F_DSA_NEW_METHOD 103
241#define DSA_F_DSA_PRINT 104 234#define DSA_F_DSA_PRINT 104
242#define DSA_F_DSA_PRINT_FP 105 235#define DSA_F_DSA_PRINT_FP 105
243#define DSA_F_DSA_SIGN 106 236#define DSA_F_DSA_SIGN 106
@@ -245,6 +238,7 @@ DH *DSA_dup_DH(DSA *r);
245#define DSA_F_DSA_SIG_NEW 109 238#define DSA_F_DSA_SIG_NEW 109
246#define DSA_F_DSA_VERIFY 108 239#define DSA_F_DSA_VERIFY 108
247#define DSA_F_I2D_DSA_SIG 111 240#define DSA_F_I2D_DSA_SIG 111
241#define DSA_F_SIG_CB 114
248 242
249/* Reason codes. */ 243/* Reason codes. */
250#define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100 244#define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100
@@ -254,4 +248,3 @@ DH *DSA_dup_DH(DSA *r);
254} 248}
255#endif 249#endif
256#endif 250#endif
257
diff --git a/src/lib/libcrypto/dsa/dsa_asn1.c b/src/lib/libcrypto/dsa/dsa_asn1.c
index a76c8f7c7e..23fce555aa 100644
--- a/src/lib/libcrypto/dsa/dsa_asn1.c
+++ b/src/lib/libcrypto/dsa/dsa_asn1.c
@@ -1,96 +1,140 @@
1/* crypto/dsa/dsa_asn1.c */ 1/* dsa_asn1.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) 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 */
2 58
3#include <stdio.h> 59#include <stdio.h>
4#include "cryptlib.h" 60#include "cryptlib.h"
5#include <openssl/dsa.h> 61#include <openssl/dsa.h>
6#include <openssl/asn1.h> 62#include <openssl/asn1.h>
7#include <openssl/asn1_mac.h> 63#include <openssl/asn1t.h>
8 64
9DSA_SIG *DSA_SIG_new(void) 65/* Override the default new methods */
66static int sig_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it)
10{ 67{
11 DSA_SIG *ret; 68 if(operation == ASN1_OP_NEW_PRE) {
12 69 DSA_SIG *sig;
13 ret = OPENSSL_malloc(sizeof(DSA_SIG)); 70 sig = OPENSSL_malloc(sizeof(DSA_SIG));
14 if (ret == NULL) 71 sig->r = NULL;
15 { 72 sig->s = NULL;
16 DSAerr(DSA_F_DSA_SIG_NEW,ERR_R_MALLOC_FAILURE); 73 *pval = (ASN1_VALUE *)sig;
17 return(NULL); 74 if(sig) return 2;
18 } 75 DSAerr(DSA_F_SIG_CB, ERR_R_MALLOC_FAILURE);
19 ret->r = NULL; 76 return 0;
20 ret->s = NULL; 77 }
21 return(ret); 78 return 1;
22} 79}
23 80
24void DSA_SIG_free(DSA_SIG *r) 81ASN1_SEQUENCE_cb(DSA_SIG, sig_cb) = {
82 ASN1_SIMPLE(DSA_SIG, r, CBIGNUM),
83 ASN1_SIMPLE(DSA_SIG, s, CBIGNUM)
84} ASN1_SEQUENCE_END_cb(DSA_SIG, DSA_SIG)
85
86IMPLEMENT_ASN1_FUNCTIONS_const(DSA_SIG)
87
88/* Override the default free and new methods */
89static int dsa_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it)
25{ 90{
26 if (r == NULL) return; 91 if(operation == ASN1_OP_NEW_PRE) {
27 if (r->r) BN_clear_free(r->r); 92 *pval = (ASN1_VALUE *)DSA_new();
28 if (r->s) BN_clear_free(r->s); 93 if(*pval) return 2;
29 OPENSSL_free(r); 94 return 0;
95 } else if(operation == ASN1_OP_FREE_PRE) {
96 DSA_free((DSA *)*pval);
97 *pval = NULL;
98 return 2;
99 }
100 return 1;
30} 101}
31 102
32int i2d_DSA_SIG(DSA_SIG *v, unsigned char **pp) 103ASN1_SEQUENCE_cb(DSAPrivateKey, dsa_cb) = {
33{ 104 ASN1_SIMPLE(DSA, version, LONG),
34 int t=0,len; 105 ASN1_SIMPLE(DSA, p, BIGNUM),
35 ASN1_INTEGER rbs,sbs; 106 ASN1_SIMPLE(DSA, q, BIGNUM),
36 unsigned char *p; 107 ASN1_SIMPLE(DSA, g, BIGNUM),
108 ASN1_SIMPLE(DSA, pub_key, BIGNUM),
109 ASN1_SIMPLE(DSA, priv_key, BIGNUM)
110} ASN1_SEQUENCE_END_cb(DSA, DSAPrivateKey)
37 111
38 rbs.data=OPENSSL_malloc(BN_num_bits(v->r)/8+1); 112IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DSA, DSAPrivateKey, DSAPrivateKey)
39 if (rbs.data == NULL)
40 {
41 DSAerr(DSA_F_I2D_DSA_SIG, ERR_R_MALLOC_FAILURE);
42 return(0);
43 }
44 rbs.type=V_ASN1_INTEGER;
45 rbs.length=BN_bn2bin(v->r,rbs.data);
46 sbs.data=OPENSSL_malloc(BN_num_bits(v->s)/8+1);
47 if (sbs.data == NULL)
48 {
49 OPENSSL_free(rbs.data);
50 DSAerr(DSA_F_I2D_DSA_SIG, ERR_R_MALLOC_FAILURE);
51 return(0);
52 }
53 sbs.type=V_ASN1_INTEGER;
54 sbs.length=BN_bn2bin(v->s,sbs.data);
55 113
56 len=i2d_ASN1_INTEGER(&rbs,NULL); 114ASN1_SEQUENCE_cb(DSAparams, dsa_cb) = {
57 len+=i2d_ASN1_INTEGER(&sbs,NULL); 115 ASN1_SIMPLE(DSA, p, BIGNUM),
116 ASN1_SIMPLE(DSA, q, BIGNUM),
117 ASN1_SIMPLE(DSA, g, BIGNUM),
118} ASN1_SEQUENCE_END_cb(DSA, DSAparams)
58 119
59 if (pp) 120IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DSA, DSAparams, DSAparams)
60 {
61 p=*pp;
62 ASN1_put_object(&p,1,len,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);
63 i2d_ASN1_INTEGER(&rbs,&p);
64 i2d_ASN1_INTEGER(&sbs,&p);
65 }
66 t=ASN1_object_size(1,len,V_ASN1_SEQUENCE);
67 OPENSSL_free(rbs.data);
68 OPENSSL_free(sbs.data);
69 return(t);
70}
71 121
72DSA_SIG *d2i_DSA_SIG(DSA_SIG **a, unsigned char **pp, long length) 122/* DSA public key is a bit trickier... its effectively a CHOICE type
73{ 123 * decided by a field called write_params which can either write out
74 int i=ERR_R_NESTED_ASN1_ERROR; 124 * just the public key as an INTEGER or the parameters and public key
75 ASN1_INTEGER *bs=NULL; 125 * in a SEQUENCE
76 M_ASN1_D2I_vars(a,DSA_SIG *,DSA_SIG_new); 126 */
77 127
78 M_ASN1_D2I_Init(); 128ASN1_SEQUENCE(dsa_pub_internal) = {
79 M_ASN1_D2I_start_sequence(); 129 ASN1_SIMPLE(DSA, pub_key, BIGNUM),
80 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); 130 ASN1_SIMPLE(DSA, p, BIGNUM),
81 if ((ret->r=BN_bin2bn(bs->data,bs->length,ret->r)) == NULL) 131 ASN1_SIMPLE(DSA, q, BIGNUM),
82 goto err_bn; 132 ASN1_SIMPLE(DSA, g, BIGNUM)
83 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); 133} ASN1_SEQUENCE_END_name(DSA, dsa_pub_internal)
84 if ((ret->s=BN_bin2bn(bs->data,bs->length,ret->s)) == NULL)
85 goto err_bn;
86 M_ASN1_BIT_STRING_free(bs);
87 M_ASN1_D2I_Finish_2(a);
88 134
89err_bn: 135ASN1_CHOICE_cb(DSAPublicKey, dsa_cb) = {
90 i=ERR_R_BN_LIB; 136 ASN1_SIMPLE(DSA, pub_key, BIGNUM),
91err: 137 ASN1_EX_COMBINE(0, 0, dsa_pub_internal)
92 DSAerr(DSA_F_D2I_DSA_SIG,i); 138} ASN1_CHOICE_END_cb(DSA, DSAPublicKey, write_params)
93 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_SIG_free(ret); 139
94 if (bs != NULL) M_ASN1_BIT_STRING_free(bs); 140IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DSA, DSAPublicKey, DSAPublicKey)
95 return(NULL);
96}
diff --git a/src/lib/libcrypto/dsa/dsa_err.c b/src/lib/libcrypto/dsa/dsa_err.c
index 736aeef7c4..79aa4ff526 100644
--- a/src/lib/libcrypto/dsa/dsa_err.c
+++ b/src/lib/libcrypto/dsa/dsa_err.c
@@ -63,7 +63,7 @@
63#include <openssl/dsa.h> 63#include <openssl/dsa.h>
64 64
65/* BEGIN ERROR CODES */ 65/* BEGIN ERROR CODES */
66#ifndef NO_ERR 66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA DSA_str_functs[]= 67static ERR_STRING_DATA DSA_str_functs[]=
68 { 68 {
69{ERR_PACK(0,DSA_F_D2I_DSA_SIG,0), "d2i_DSA_SIG"}, 69{ERR_PACK(0,DSA_F_D2I_DSA_SIG,0), "d2i_DSA_SIG"},
@@ -71,7 +71,7 @@ static ERR_STRING_DATA DSA_str_functs[]=
71{ERR_PACK(0,DSA_F_DSAPARAMS_PRINT_FP,0), "DSAparams_print_fp"}, 71{ERR_PACK(0,DSA_F_DSAPARAMS_PRINT_FP,0), "DSAparams_print_fp"},
72{ERR_PACK(0,DSA_F_DSA_DO_SIGN,0), "DSA_do_sign"}, 72{ERR_PACK(0,DSA_F_DSA_DO_SIGN,0), "DSA_do_sign"},
73{ERR_PACK(0,DSA_F_DSA_DO_VERIFY,0), "DSA_do_verify"}, 73{ERR_PACK(0,DSA_F_DSA_DO_VERIFY,0), "DSA_do_verify"},
74{ERR_PACK(0,DSA_F_DSA_NEW,0), "DSA_new"}, 74{ERR_PACK(0,DSA_F_DSA_NEW_METHOD,0), "DSA_new_method"},
75{ERR_PACK(0,DSA_F_DSA_PRINT,0), "DSA_print"}, 75{ERR_PACK(0,DSA_F_DSA_PRINT,0), "DSA_print"},
76{ERR_PACK(0,DSA_F_DSA_PRINT_FP,0), "DSA_print_fp"}, 76{ERR_PACK(0,DSA_F_DSA_PRINT_FP,0), "DSA_print_fp"},
77{ERR_PACK(0,DSA_F_DSA_SIGN,0), "DSA_sign"}, 77{ERR_PACK(0,DSA_F_DSA_SIGN,0), "DSA_sign"},
@@ -79,6 +79,7 @@ static ERR_STRING_DATA DSA_str_functs[]=
79{ERR_PACK(0,DSA_F_DSA_SIG_NEW,0), "DSA_SIG_new"}, 79{ERR_PACK(0,DSA_F_DSA_SIG_NEW,0), "DSA_SIG_new"},
80{ERR_PACK(0,DSA_F_DSA_VERIFY,0), "DSA_verify"}, 80{ERR_PACK(0,DSA_F_DSA_VERIFY,0), "DSA_verify"},
81{ERR_PACK(0,DSA_F_I2D_DSA_SIG,0), "i2d_DSA_SIG"}, 81{ERR_PACK(0,DSA_F_I2D_DSA_SIG,0), "i2d_DSA_SIG"},
82{ERR_PACK(0,DSA_F_SIG_CB,0), "SIG_CB"},
82{0,NULL} 83{0,NULL}
83 }; 84 };
84 85
@@ -98,7 +99,7 @@ void ERR_load_DSA_strings(void)
98 if (init) 99 if (init)
99 { 100 {
100 init=0; 101 init=0;
101#ifndef NO_ERR 102#ifndef OPENSSL_NO_ERR
102 ERR_load_strings(ERR_LIB_DSA,DSA_str_functs); 103 ERR_load_strings(ERR_LIB_DSA,DSA_str_functs);
103 ERR_load_strings(ERR_LIB_DSA,DSA_str_reasons); 104 ERR_load_strings(ERR_LIB_DSA,DSA_str_reasons);
104#endif 105#endif
diff --git a/src/lib/libcrypto/dsa/dsa_gen.c b/src/lib/libcrypto/dsa/dsa_gen.c
index 2294a362d9..dc9c249310 100644
--- a/src/lib/libcrypto/dsa/dsa_gen.c
+++ b/src/lib/libcrypto/dsa/dsa_gen.c
@@ -61,25 +61,27 @@
61#ifdef GENUINE_DSA 61#ifdef GENUINE_DSA
62/* Parameter generation follows the original release of FIPS PUB 186, 62/* Parameter generation follows the original release of FIPS PUB 186,
63 * Appendix 2.2 (i.e. use SHA as defined in FIPS PUB 180) */ 63 * Appendix 2.2 (i.e. use SHA as defined in FIPS PUB 180) */
64#define HASH SHA 64#define HASH EVP_sha()
65#else 65#else
66/* Parameter generation follows the updated Appendix 2.2 for FIPS PUB 186, 66/* Parameter generation follows the updated Appendix 2.2 for FIPS PUB 186,
67 * also Appendix 2.2 of FIPS PUB 186-1 (i.e. use SHA as defined in 67 * also Appendix 2.2 of FIPS PUB 186-1 (i.e. use SHA as defined in
68 * FIPS PUB 180-1) */ 68 * FIPS PUB 180-1) */
69#define HASH SHA1 69#define HASH EVP_sha1()
70#endif 70#endif
71 71
72#ifndef NO_SHA 72#ifndef OPENSSL_NO_SHA
73 73
74#include <stdio.h> 74#include <stdio.h>
75#include <time.h> 75#include <time.h>
76#include "cryptlib.h" 76#include "cryptlib.h"
77#include <openssl/sha.h> 77#include <openssl/evp.h>
78#include <openssl/bn.h> 78#include <openssl/bn.h>
79#include <openssl/dsa.h> 79#include <openssl/dsa.h>
80#include <openssl/rand.h> 80#include <openssl/rand.h>
81#include <openssl/sha.h>
81 82
82DSA *DSA_generate_parameters(int bits, unsigned char *seed_in, int seed_len, 83DSA *DSA_generate_parameters(int bits,
84 unsigned char *seed_in, int seed_len,
83 int *counter_ret, unsigned long *h_ret, 85 int *counter_ret, unsigned long *h_ret,
84 void (*callback)(int, int, void *), 86 void (*callback)(int, int, void *),
85 void *cb_arg) 87 void *cb_arg)
@@ -157,8 +159,8 @@ DSA *DSA_generate_parameters(int bits, unsigned char *seed_in, int seed_len,
157 } 159 }
158 160
159 /* step 2 */ 161 /* step 2 */
160 HASH(seed,SHA_DIGEST_LENGTH,md); 162 EVP_Digest(seed,SHA_DIGEST_LENGTH,md,NULL,HASH, NULL);
161 HASH(buf,SHA_DIGEST_LENGTH,buf2); 163 EVP_Digest(buf,SHA_DIGEST_LENGTH,buf2,NULL,HASH, NULL);
162 for (i=0; i<SHA_DIGEST_LENGTH; i++) 164 for (i=0; i<SHA_DIGEST_LENGTH; i++)
163 md[i]^=buf2[i]; 165 md[i]^=buf2[i];
164 166
@@ -205,7 +207,7 @@ DSA *DSA_generate_parameters(int bits, unsigned char *seed_in, int seed_len,
205 if (buf[i] != 0) break; 207 if (buf[i] != 0) break;
206 } 208 }
207 209
208 HASH(buf,SHA_DIGEST_LENGTH,md); 210 EVP_Digest(buf,SHA_DIGEST_LENGTH,md,NULL,HASH, NULL);
209 211
210 /* step 8 */ 212 /* step 8 */
211 if (!BN_bin2bn(md,SHA_DIGEST_LENGTH,r0)) 213 if (!BN_bin2bn(md,SHA_DIGEST_LENGTH,r0))
diff --git a/src/lib/libcrypto/dsa/dsa_key.c b/src/lib/libcrypto/dsa/dsa_key.c
index a68d236e05..bf718c1c6d 100644
--- a/src/lib/libcrypto/dsa/dsa_key.c
+++ b/src/lib/libcrypto/dsa/dsa_key.c
@@ -56,11 +56,10 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_SHA 59#ifndef OPENSSL_NO_SHA
60#include <stdio.h> 60#include <stdio.h>
61#include <time.h> 61#include <time.h>
62#include "cryptlib.h" 62#include "cryptlib.h"
63#include <openssl/sha.h>
64#include <openssl/bn.h> 63#include <openssl/bn.h>
65#include <openssl/dsa.h> 64#include <openssl/dsa.h>
66#include <openssl/rand.h> 65#include <openssl/rand.h>
diff --git a/src/lib/libcrypto/dsa/dsa_lib.c b/src/lib/libcrypto/dsa/dsa_lib.c
index 15f667a203..da2cdfa3d6 100644
--- a/src/lib/libcrypto/dsa/dsa_lib.c
+++ b/src/lib/libcrypto/dsa/dsa_lib.c
@@ -67,96 +67,78 @@
67 67
68const char *DSA_version="DSA" OPENSSL_VERSION_PTEXT; 68const char *DSA_version="DSA" OPENSSL_VERSION_PTEXT;
69 69
70static DSA_METHOD *default_DSA_method; 70static const DSA_METHOD *default_DSA_method = NULL;
71static int dsa_meth_num = 0;
72static STACK_OF(CRYPTO_EX_DATA_FUNCS) *dsa_meth = NULL;
73
74void DSA_set_default_openssl_method(DSA_METHOD *meth)
75{
76 ENGINE *e;
77 /* We'll need to notify the "openssl" ENGINE of this
78 * change too. We won't bother locking things down at
79 * our end as there was never any locking in these
80 * functions! */
81 if(default_DSA_method != meth)
82 {
83 default_DSA_method = meth;
84 e = ENGINE_by_id("openssl");
85 if(e)
86 {
87 ENGINE_set_DSA(e, meth);
88 ENGINE_free(e);
89 }
90 }
91}
92 71
93DSA_METHOD *DSA_get_default_openssl_method(void) 72void DSA_set_default_method(const DSA_METHOD *meth)
94{ 73 {
95 if(!default_DSA_method) default_DSA_method = DSA_OpenSSL(); 74 default_DSA_method = meth;
75 }
76
77const DSA_METHOD *DSA_get_default_method(void)
78 {
79 if(!default_DSA_method)
80 default_DSA_method = DSA_OpenSSL();
96 return default_DSA_method; 81 return default_DSA_method;
97} 82 }
98 83
99DSA *DSA_new(void) 84DSA *DSA_new(void)
100{ 85 {
101 return DSA_new_method(NULL); 86 return DSA_new_method(NULL);
102} 87 }
103 88
104#if 0 89int DSA_set_method(DSA *dsa, const DSA_METHOD *meth)
105DSA_METHOD *DSA_set_method(DSA *dsa, DSA_METHOD *meth) 90 {
106{ 91 /* NB: The caller is specifically setting a method, so it's not up to us
107 DSA_METHOD *mtmp; 92 * to deal with which ENGINE it comes from. */
93 const DSA_METHOD *mtmp;
108 mtmp = dsa->meth; 94 mtmp = dsa->meth;
109 if (mtmp->finish) mtmp->finish(dsa); 95 if (mtmp->finish) mtmp->finish(dsa);
96 if (dsa->engine)
97 {
98 ENGINE_finish(dsa->engine);
99 dsa->engine = NULL;
100 }
110 dsa->meth = meth; 101 dsa->meth = meth;
111 if (meth->init) meth->init(dsa); 102 if (meth->init) meth->init(dsa);
112 return mtmp; 103 return 1;
113}
114#else
115int DSA_set_method(DSA *dsa, ENGINE *engine)
116 {
117 ENGINE *mtmp;
118 DSA_METHOD *meth;
119 mtmp = dsa->engine;
120 meth = ENGINE_get_DSA(mtmp);
121 if (!ENGINE_init(engine))
122 return 0;
123 if (meth->finish) meth->finish(dsa);
124 dsa->engine = engine;
125 meth = ENGINE_get_DSA(engine);
126 if (meth->init) meth->init(dsa);
127 /* SHOULD ERROR CHECK THIS!!! */
128 ENGINE_finish(mtmp);
129 return 1;
130 } 104 }
131#endif
132 105
133
134#if 0
135DSA *DSA_new_method(DSA_METHOD *meth)
136#else
137DSA *DSA_new_method(ENGINE *engine) 106DSA *DSA_new_method(ENGINE *engine)
138#endif
139 { 107 {
140 DSA_METHOD *meth;
141 DSA *ret; 108 DSA *ret;
142 109
143 ret=(DSA *)OPENSSL_malloc(sizeof(DSA)); 110 ret=(DSA *)OPENSSL_malloc(sizeof(DSA));
144 if (ret == NULL) 111 if (ret == NULL)
145 { 112 {
146 DSAerr(DSA_F_DSA_NEW,ERR_R_MALLOC_FAILURE); 113 DSAerr(DSA_F_DSA_NEW_METHOD,ERR_R_MALLOC_FAILURE);
147 return(NULL); 114 return(NULL);
148 } 115 }
149 if(engine) 116 ret->meth = DSA_get_default_method();
117 if (engine)
118 {
119 if (!ENGINE_init(engine))
120 {
121 DSAerr(DSA_F_DSA_NEW_METHOD, ERR_R_ENGINE_LIB);
122 OPENSSL_free(ret);
123 return NULL;
124 }
150 ret->engine = engine; 125 ret->engine = engine;
126 }
151 else 127 else
128 ret->engine = ENGINE_get_default_DSA();
129 if(ret->engine)
152 { 130 {
153 if((ret->engine=ENGINE_get_default_DSA()) == NULL) 131 ret->meth = ENGINE_get_DSA(ret->engine);
132 if(!ret->meth)
154 { 133 {
134 DSAerr(DSA_F_DSA_NEW_METHOD,
135 ERR_R_ENGINE_LIB);
136 ENGINE_finish(ret->engine);
155 OPENSSL_free(ret); 137 OPENSSL_free(ret);
156 return NULL; 138 return NULL;
157 } 139 }
158 } 140 }
159 meth = ENGINE_get_DSA(ret->engine); 141
160 ret->pad=0; 142 ret->pad=0;
161 ret->version=0; 143 ret->version=0;
162 ret->write_params=1; 144 ret->write_params=1;
@@ -172,11 +154,13 @@ DSA *DSA_new_method(ENGINE *engine)
172 ret->method_mont_p=NULL; 154 ret->method_mont_p=NULL;
173 155
174 ret->references=1; 156 ret->references=1;
175 ret->flags=meth->flags; 157 ret->flags=ret->meth->flags;
176 CRYPTO_new_ex_data(dsa_meth,ret,&ret->ex_data); 158 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data);
177 if ((meth->init != NULL) && !meth->init(ret)) 159 if ((ret->meth->init != NULL) && !ret->meth->init(ret))
178 { 160 {
179 CRYPTO_free_ex_data(dsa_meth,ret,&ret->ex_data); 161 if (ret->engine)
162 ENGINE_finish(ret->engine);
163 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data);
180 OPENSSL_free(ret); 164 OPENSSL_free(ret);
181 ret=NULL; 165 ret=NULL;
182 } 166 }
@@ -186,7 +170,6 @@ DSA *DSA_new_method(ENGINE *engine)
186 170
187void DSA_free(DSA *r) 171void DSA_free(DSA *r)
188 { 172 {
189 DSA_METHOD *meth;
190 int i; 173 int i;
191 174
192 if (r == NULL) return; 175 if (r == NULL) return;
@@ -204,11 +187,12 @@ void DSA_free(DSA *r)
204 } 187 }
205#endif 188#endif
206 189
207 meth = ENGINE_get_DSA(r->engine); 190 if(r->meth->finish)
208 if(meth->finish) meth->finish(r); 191 r->meth->finish(r);
209 ENGINE_finish(r->engine); 192 if(r->engine)
193 ENGINE_finish(r->engine);
210 194
211 CRYPTO_free_ex_data(dsa_meth, r, &r->ex_data); 195 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, r, &r->ex_data);
212 196
213 if (r->p != NULL) BN_clear_free(r->p); 197 if (r->p != NULL) BN_clear_free(r->p);
214 if (r->q != NULL) BN_clear_free(r->q); 198 if (r->q != NULL) BN_clear_free(r->q);
@@ -220,7 +204,23 @@ void DSA_free(DSA *r)
220 OPENSSL_free(r); 204 OPENSSL_free(r);
221 } 205 }
222 206
223int DSA_size(DSA *r) 207int DSA_up_ref(DSA *r)
208 {
209 int i = CRYPTO_add(&r->references, 1, CRYPTO_LOCK_DSA);
210#ifdef REF_PRINT
211 REF_PRINT("DSA",r);
212#endif
213#ifdef REF_CHECK
214 if (i < 2)
215 {
216 fprintf(stderr, "DSA_up_ref, bad reference count\n");
217 abort();
218 }
219#endif
220 return ((i > 1) ? 1 : 0);
221 }
222
223int DSA_size(const DSA *r)
224 { 224 {
225 int ret,i; 225 int ret,i;
226 ASN1_INTEGER bs; 226 ASN1_INTEGER bs;
@@ -242,9 +242,8 @@ int DSA_size(DSA *r)
242int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, 242int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
243 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) 243 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
244 { 244 {
245 dsa_meth_num++; 245 return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_DSA, argl, argp,
246 return(CRYPTO_get_ex_new_index(dsa_meth_num-1, 246 new_func, dup_func, free_func);
247 &dsa_meth,argl,argp,new_func,dup_func,free_func));
248 } 247 }
249 248
250int DSA_set_ex_data(DSA *d, int idx, void *arg) 249int DSA_set_ex_data(DSA *d, int idx, void *arg)
@@ -257,8 +256,8 @@ void *DSA_get_ex_data(DSA *d, int idx)
257 return(CRYPTO_get_ex_data(&d->ex_data,idx)); 256 return(CRYPTO_get_ex_data(&d->ex_data,idx));
258 } 257 }
259 258
260#ifndef NO_DH 259#ifndef OPENSSL_NO_DH
261DH *DSA_dup_DH(DSA *r) 260DH *DSA_dup_DH(const DSA *r)
262 { 261 {
263 /* DSA has p, q, g, optional pub_key, optional priv_key. 262 /* DSA has p, q, g, optional pub_key, optional priv_key.
264 * DH has p, optional length, g, optional pub_key, optional priv_key. 263 * DH has p, optional length, g, optional pub_key, optional priv_key.
diff --git a/src/lib/libcrypto/dsa/dsa_ossl.c b/src/lib/libcrypto/dsa/dsa_ossl.c
index 34c6e9a141..07addc94d9 100644
--- a/src/lib/libcrypto/dsa/dsa_ossl.c
+++ b/src/lib/libcrypto/dsa/dsa_ossl.c
@@ -94,7 +94,7 @@ dsa_finish,
94NULL 94NULL
95}; 95};
96 96
97DSA_METHOD *DSA_OpenSSL(void) 97const DSA_METHOD *DSA_OpenSSL(void)
98{ 98{
99 return &openssl_dsa_meth; 99 return &openssl_dsa_meth;
100} 100}
@@ -204,7 +204,7 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp)
204 } 204 }
205 205
206 /* Compute r = (g^k mod p) mod q */ 206 /* Compute r = (g^k mod p) mod q */
207 if (!ENGINE_get_DSA(dsa->engine)->bn_mod_exp(dsa, r,dsa->g,&k,dsa->p,ctx, 207 if (!dsa->meth->bn_mod_exp(dsa, r,dsa->g,&k,dsa->p,ctx,
208 (BN_MONT_CTX *)dsa->method_mont_p)) goto err; 208 (BN_MONT_CTX *)dsa->method_mont_p)) goto err;
209 if (!BN_mod(r,r,dsa->q,ctx)) goto err; 209 if (!BN_mod(r,r,dsa->q,ctx)) goto err;
210 210
@@ -237,6 +237,11 @@ static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig,
237 BIGNUM u1,u2,t1; 237 BIGNUM u1,u2,t1;
238 BN_MONT_CTX *mont=NULL; 238 BN_MONT_CTX *mont=NULL;
239 int ret = -1; 239 int ret = -1;
240 if (!dsa->p || !dsa->q || !dsa->g)
241 {
242 DSAerr(DSA_F_DSA_DO_VERIFY,DSA_R_MISSING_PARAMETERS);
243 return -1;
244 }
240 245
241 if ((ctx=BN_CTX_new()) == NULL) goto err; 246 if ((ctx=BN_CTX_new()) == NULL) goto err;
242 BN_init(&u1); 247 BN_init(&u1);
@@ -293,7 +298,7 @@ static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig,
293 if (!BN_mod(&u1,&u1,dsa->q,ctx)) goto err; 298 if (!BN_mod(&u1,&u1,dsa->q,ctx)) goto err;
294#else 299#else
295 { 300 {
296 if (!ENGINE_get_DSA(dsa->engine)->dsa_mod_exp(dsa, &t1,dsa->g,&u1,dsa->pub_key,&u2, 301 if (!dsa->meth->dsa_mod_exp(dsa, &t1,dsa->g,&u1,dsa->pub_key,&u2,
297 dsa->p,ctx,mont)) goto err; 302 dsa->p,ctx,mont)) goto err;
298 /* BN_copy(&u1,&t1); */ 303 /* BN_copy(&u1,&t1); */
299 /* let u1 = u1 mod q */ 304 /* let u1 = u1 mod q */
diff --git a/src/lib/libcrypto/dsa/dsa_sign.c b/src/lib/libcrypto/dsa/dsa_sign.c
index dfe27bae47..e9469ca62f 100644
--- a/src/lib/libcrypto/dsa/dsa_sign.c
+++ b/src/lib/libcrypto/dsa/dsa_sign.c
@@ -68,7 +68,7 @@
68 68
69DSA_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)
70 { 70 {
71 return ENGINE_get_DSA(dsa->engine)->dsa_do_sign(dgst, dlen, dsa); 71 return dsa->meth->dsa_do_sign(dgst, dlen, dsa);
72 } 72 }
73 73
74int DSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char *sig, 74int DSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char *sig,
@@ -88,6 +88,6 @@ int DSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char *sig,
88 88
89int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) 89int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp)
90 { 90 {
91 return ENGINE_get_DSA(dsa->engine)->dsa_sign_setup(dsa, ctx_in, kinvp, rp); 91 return dsa->meth->dsa_sign_setup(dsa, ctx_in, kinvp, rp);
92 } 92 }
93 93
diff --git a/src/lib/libcrypto/dsa/dsa_vrf.c b/src/lib/libcrypto/dsa/dsa_vrf.c
index 2e891ae491..066c6b5b28 100644
--- a/src/lib/libcrypto/dsa/dsa_vrf.c
+++ b/src/lib/libcrypto/dsa/dsa_vrf.c
@@ -70,7 +70,7 @@
70int 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,
71 DSA *dsa) 71 DSA *dsa)
72 { 72 {
73 return ENGINE_get_DSA(dsa->engine)->dsa_do_verify(dgst, dgst_len, sig, dsa); 73 return dsa->meth->dsa_do_verify(dgst, dgst_len, sig, dsa);
74 } 74 }
75 75
76/* data has already been hashed (probably with SHA or SHA-1). */ 76/* data has already been hashed (probably with SHA or SHA-1). */
@@ -80,7 +80,7 @@ int DSA_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig,
80 * -1: error 80 * -1: error
81 */ 81 */
82int DSA_verify(int type, const unsigned char *dgst, int dgst_len, 82int DSA_verify(int type, const unsigned char *dgst, int dgst_len,
83 unsigned char *sigbuf, int siglen, DSA *dsa) 83 const unsigned char *sigbuf, int siglen, DSA *dsa)
84 { 84 {
85 DSA_SIG *s; 85 DSA_SIG *s;
86 int ret=-1; 86 int ret=-1;
diff --git a/src/lib/libcrypto/dsa/dsatest.c b/src/lib/libcrypto/dsa/dsatest.c
index 309a7cda89..12da64f9f4 100644
--- a/src/lib/libcrypto/dsa/dsatest.c
+++ b/src/lib/libcrypto/dsa/dsatest.c
@@ -65,11 +65,12 @@
65#include <openssl/rand.h> 65#include <openssl/rand.h>
66#include <openssl/bio.h> 66#include <openssl/bio.h>
67#include <openssl/err.h> 67#include <openssl/err.h>
68#ifdef WINDOWS 68#include <openssl/engine.h>
69#ifdef OPENSSL_SYS_WINDOWS
69#include "../bio/bss_file.c" 70#include "../bio/bss_file.c"
70#endif 71#endif
71 72
72#ifdef NO_DSA 73#ifdef OPENSSL_NO_DSA
73int main(int argc, char *argv[]) 74int main(int argc, char *argv[])
74{ 75{
75 printf("No DSA support\n"); 76 printf("No DSA support\n");
@@ -78,7 +79,7 @@ int main(int argc, char *argv[])
78#else 79#else
79#include <openssl/dsa.h> 80#include <openssl/dsa.h>
80 81
81#ifdef WIN16 82#ifdef OPENSSL_SYS_WIN16
82#define MS_CALLBACK _far _loadds 83#define MS_CALLBACK _far _loadds
83#else 84#else
84#define MS_CALLBACK 85#define MS_CALLBACK
@@ -136,14 +137,16 @@ int main(int argc, char **argv)
136 unsigned char sig[256]; 137 unsigned char sig[256];
137 unsigned int siglen; 138 unsigned int siglen;
138 139
139 ERR_load_crypto_strings();
140 RAND_seed(rnd_seed, sizeof rnd_seed);
141
142 if (bio_err == NULL) 140 if (bio_err == NULL)
143 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); 141 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
144 142
143 CRYPTO_malloc_debug_init();
144 CRYPTO_dbg_set_options(V_CRYPTO_MDEBUG_ALL);
145 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); 145 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
146 146
147 ERR_load_crypto_strings();
148 RAND_seed(rnd_seed, sizeof rnd_seed);
149
147 BIO_printf(bio_err,"test generation of DSA parameters\n"); 150 BIO_printf(bio_err,"test generation of DSA parameters\n");
148 151
149 dsa=DSA_generate_parameters(512,seed,20,&counter,&h,dsa_cb,bio_err); 152 dsa=DSA_generate_parameters(512,seed,20,&counter,&h,dsa_cb,bio_err);
@@ -200,7 +203,9 @@ end:
200 if (!ret) 203 if (!ret)
201 ERR_print_errors(bio_err); 204 ERR_print_errors(bio_err);
202 if (dsa != NULL) DSA_free(dsa); 205 if (dsa != NULL) DSA_free(dsa);
206 CRYPTO_cleanup_all_ex_data();
203 ERR_remove_state(0); 207 ERR_remove_state(0);
208 ERR_free_strings();
204 CRYPTO_mem_leaks(bio_err); 209 CRYPTO_mem_leaks(bio_err);
205 if (bio_err != NULL) 210 if (bio_err != NULL)
206 { 211 {
diff --git a/src/lib/libcrypto/dso/Makefile.ssl b/src/lib/libcrypto/dso/Makefile.ssl
index 48b36c8330..cca9376bdb 100644
--- a/src/lib/libcrypto/dso/Makefile.ssl
+++ b/src/lib/libcrypto/dso/Makefile.ssl
@@ -5,13 +5,14 @@
5DIR= dso 5DIR= dso
6TOP= ../.. 6TOP= ../..
7CC= cc 7CC= cc
8INCLUDES= -I.. -I../../include 8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g 9CFLAG=-g
10INSTALL_PREFIX= 10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl 11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl 12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl 13MAKE= make -f Makefile.ssl
14MAKEDEPEND= $(TOP)/util/domd $(TOP) 14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
15MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
16AR= ar r 17AR= ar r
17 18
@@ -41,8 +42,7 @@ all: lib
41 42
42lib: $(LIBOBJ) 43lib: $(LIBOBJ)
43 $(AR) $(LIB) $(LIBOBJ) 44 $(AR) $(LIB) $(LIBOBJ)
44 @echo You may get an error following this line. Please ignore. 45 $(RANLIB) $(LIB) || echo Never mind.
45 - $(RANLIB) $(LIB)
46 @touch lib 46 @touch lib
47 47
48files: 48files:
@@ -81,61 +81,62 @@ clean:
81 81
82# DO NOT DELETE THIS LINE -- make depend depends on it. 82# DO NOT DELETE THIS LINE -- make depend depends on it.
83 83
84dso_dl.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 84dso_dl.o: ../../e_os.h ../../include/openssl/bio.h
85dso_dl.o: ../../include/openssl/crypto.h ../../include/openssl/dso.h 85dso_dl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
86dso_dl.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 86dso_dl.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
87dso_dl.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 87dso_dl.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
88dso_dl.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 88dso_dl.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
89dso_dl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 89dso_dl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
90dso_dl.o: ../../include/openssl/symhacks.h ../cryptlib.h 90dso_dl.o: ../../include/openssl/symhacks.h ../cryptlib.h dso_dl.c
91dso_dlfcn.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 91dso_dlfcn.o: ../../e_os.h ../../include/openssl/bio.h
92dso_dlfcn.o: ../../include/openssl/crypto.h ../../include/openssl/dso.h 92dso_dlfcn.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
93dso_dlfcn.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 93dso_dlfcn.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
94dso_dlfcn.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 94dso_dlfcn.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
95dso_dlfcn.o: ../../include/openssl/opensslconf.h 95dso_dlfcn.o: ../../include/openssl/opensslconf.h
96dso_dlfcn.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 96dso_dlfcn.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
97dso_dlfcn.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 97dso_dlfcn.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
98dso_dlfcn.o: ../cryptlib.h 98dso_dlfcn.o: ../cryptlib.h dso_dlfcn.c
99dso_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h 99dso_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
100dso_err.o: ../../include/openssl/dso.h ../../include/openssl/err.h 100dso_err.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
101dso_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslv.h 101dso_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
102dso_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
102dso_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 103dso_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
103dso_err.o: ../../include/openssl/symhacks.h 104dso_err.o: ../../include/openssl/symhacks.h dso_err.c
104dso_lib.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 105dso_lib.o: ../../e_os.h ../../include/openssl/bio.h
105dso_lib.o: ../../include/openssl/crypto.h ../../include/openssl/dso.h 106dso_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
106dso_lib.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 107dso_lib.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
107dso_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 108dso_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
108dso_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 109dso_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
109dso_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 110dso_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
110dso_lib.o: ../../include/openssl/symhacks.h ../cryptlib.h 111dso_lib.o: ../../include/openssl/symhacks.h ../cryptlib.h dso_lib.c
111dso_null.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 112dso_null.o: ../../e_os.h ../../include/openssl/bio.h
112dso_null.o: ../../include/openssl/crypto.h ../../include/openssl/dso.h 113dso_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
113dso_null.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 114dso_null.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
114dso_null.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 115dso_null.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
115dso_null.o: ../../include/openssl/opensslconf.h 116dso_null.o: ../../include/openssl/opensslconf.h
116dso_null.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 117dso_null.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
117dso_null.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 118dso_null.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
118dso_null.o: ../cryptlib.h 119dso_null.o: ../cryptlib.h dso_null.c
119dso_openssl.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 120dso_openssl.o: ../../e_os.h ../../include/openssl/bio.h
120dso_openssl.o: ../../include/openssl/crypto.h ../../include/openssl/dso.h 121dso_openssl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
121dso_openssl.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 122dso_openssl.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
122dso_openssl.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 123dso_openssl.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
123dso_openssl.o: ../../include/openssl/opensslconf.h 124dso_openssl.o: ../../include/openssl/opensslconf.h
124dso_openssl.o: ../../include/openssl/opensslv.h 125dso_openssl.o: ../../include/openssl/opensslv.h
125dso_openssl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 126dso_openssl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
126dso_openssl.o: ../../include/openssl/symhacks.h ../cryptlib.h 127dso_openssl.o: ../../include/openssl/symhacks.h ../cryptlib.h dso_openssl.c
127dso_vms.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 128dso_vms.o: ../../e_os.h ../../include/openssl/bio.h
128dso_vms.o: ../../include/openssl/crypto.h ../../include/openssl/dso.h 129dso_vms.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
129dso_vms.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 130dso_vms.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
130dso_vms.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 131dso_vms.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
131dso_vms.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 132dso_vms.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
132dso_vms.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 133dso_vms.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
133dso_vms.o: ../../include/openssl/symhacks.h ../cryptlib.h 134dso_vms.o: ../../include/openssl/symhacks.h ../cryptlib.h dso_vms.c
134dso_win32.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 135dso_win32.o: ../../e_os.h ../../include/openssl/bio.h
135dso_win32.o: ../../include/openssl/crypto.h ../../include/openssl/dso.h 136dso_win32.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
136dso_win32.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 137dso_win32.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
137dso_win32.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 138dso_win32.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
138dso_win32.o: ../../include/openssl/opensslconf.h 139dso_win32.o: ../../include/openssl/opensslconf.h
139dso_win32.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 140dso_win32.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
140dso_win32.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 141dso_win32.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
141dso_win32.o: ../cryptlib.h 142dso_win32.o: ../cryptlib.h dso_win32.c
diff --git a/src/lib/libcrypto/dso/README b/src/lib/libcrypto/dso/README
index 6ba03c5631..d0bc9a89fb 100644
--- a/src/lib/libcrypto/dso/README
+++ b/src/lib/libcrypto/dso/README
@@ -1,16 +1,3 @@
1TODO
2----
3
4Find a way where name-translation can be done in a way that is
5sensitive to particular methods (ie. generic code could still do
6different path/filename substitutions on win32 to what it does on
7*nix) but doesn't assume some canonical form. Already one case
8exists where the "blah -> (libblah.so,blah.dll)" mapping doesn't
9suffice. I suspect a callback with an enumerated (or string?)
10parameter could be the way to go here ... DSO_ctrl the callback
11into place and it can be invoked to handle name translation with
12some clue to the calling code as to what kind of system it is.
13
14NOTES 1NOTES
15----- 2-----
16 3
@@ -21,4 +8,15 @@ according to their man page, prefer developers to move to that.
21I'll leave Richard's changes there as I guess dso_dl is needed 8I'll leave Richard's changes there as I guess dso_dl is needed
22for HPUX10.20. 9for HPUX10.20.
23 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)).
24 22
diff --git a/src/lib/libcrypto/dso/dso.h b/src/lib/libcrypto/dso/dso.h
index bed7c464a6..aa721f7feb 100644
--- a/src/lib/libcrypto/dso/dso.h
+++ b/src/lib/libcrypto/dso/dso.h
@@ -70,31 +70,51 @@ extern "C" {
70#define DSO_CTRL_SET_FLAGS 2 70#define DSO_CTRL_SET_FLAGS 2
71#define DSO_CTRL_OR_FLAGS 3 71#define DSO_CTRL_OR_FLAGS 3
72 72
73/* These flags control the translation of file-names from canonical to 73/* By default, DSO_load() will translate the provided filename into a form
74 * native. Eg. in the CryptoSwift support, the "dl" and "dlfcn" 74 * typical for the platform (more specifically the DSO_METHOD) using the
75 * methods will translate "swift" -> "libswift.so" whereas the "win32" 75 * dso_name_converter function of the method. Eg. win32 will transform "blah"
76 * method will translate "swift" -> "swift.dll". NB: Until I can figure 76 * into "blah.dll", and dlfcn will transform it into "libblah.so". The
77 * out how to be more "conventional" with this, the methods will only 77 * behaviour can be overriden by setting the name_converter callback in the DSO
78 * honour this flag if it looks like it was passed a file without any 78 * object (using DSO_set_name_converter()). This callback could even utilise
79 * path and if the filename is small enough. 79 * the DSO_METHOD's converter too if it only wants to override behaviour for
80 */ 80 * one or two possible DSO methods. However, the following flag can be set in a
81#define DSO_FLAG_NAME_TRANSLATION 0x01 81 * DSO to prevent *any* native name-translation at all - eg. if the caller has
82 * prompted the user for a path to a driver library so the filename should be
83 * interpreted as-is. */
84#define DSO_FLAG_NO_NAME_TRANSLATION 0x01
85/* An extra flag to give if only the extension should be added as
86 * translation. This is obviously only of importance on Unix and
87 * other operating systems where the translation also may prefix
88 * the name with something, like 'lib', and ignored everywhere else.
89 * This flag is also ignored if DSO_FLAG_NO_NAME_TRANSLATION is used
90 * at the same time. */
91#define DSO_FLAG_NAME_TRANSLATION_EXT_ONLY 0x02
82 92
83/* The following flag controls the translation of symbol names to upper 93/* The following flag controls the translation of symbol names to upper
84 * case. This is currently only being implemented for OpenVMS. 94 * case. This is currently only being implemented for OpenVMS.
85 */ 95 */
86#define DSO_FLAG_UPCASE_SYMBOL 0x02 96#define DSO_FLAG_UPCASE_SYMBOL 0x10
87 97
88 98
89typedef void (*DSO_FUNC_TYPE)(void); 99typedef void (*DSO_FUNC_TYPE)(void);
90 100
91typedef struct dso_st DSO; 101typedef struct dso_st DSO;
92 102
103/* The function prototype used for method functions (or caller-provided
104 * callbacks) that transform filenames. They are passed a DSO structure pointer
105 * (or NULL if they are to be used independantly of a DSO object) and a
106 * filename to transform. They should either return NULL (if there is an error
107 * condition) or a newly allocated string containing the transformed form that
108 * the caller will need to free with OPENSSL_free() when done. */
109typedef char* (*DSO_NAME_CONVERTER_FUNC)(DSO *, const char *);
110
93typedef struct dso_meth_st 111typedef struct dso_meth_st
94 { 112 {
95 const char *name; 113 const char *name;
96 /* Loads a shared library */ 114 /* Loads a shared library, NB: new DSO_METHODs must ensure that a
97 int (*dso_load)(DSO *dso, const char *filename); 115 * successful load populates the loaded_filename field, and likewise a
116 * successful unload OPENSSL_frees and NULLs it out. */
117 int (*dso_load)(DSO *dso);
98 /* Unloads a shared library */ 118 /* Unloads a shared library */
99 int (*dso_unload)(DSO *dso); 119 int (*dso_unload)(DSO *dso);
100 /* Binds a variable */ 120 /* Binds a variable */
@@ -117,6 +137,9 @@ typedef struct dso_meth_st
117 /* The generic (yuck) "ctrl()" function. NB: Negative return 137 /* The generic (yuck) "ctrl()" function. NB: Negative return
118 * values (rather than zero) indicate errors. */ 138 * values (rather than zero) indicate errors. */
119 long (*dso_ctrl)(DSO *dso, int cmd, long larg, void *parg); 139 long (*dso_ctrl)(DSO *dso, int cmd, long larg, void *parg);
140 /* The default DSO_METHOD-specific function for converting filenames to
141 * a canonical native form. */
142 DSO_NAME_CONVERTER_FUNC dso_name_converter;
120 143
121 /* [De]Initialisation handlers. */ 144 /* [De]Initialisation handlers. */
122 int (*init)(DSO *dso); 145 int (*init)(DSO *dso);
@@ -140,6 +163,23 @@ struct dso_st
140 /* For use by applications etc ... use this for your bits'n'pieces, 163 /* For use by applications etc ... use this for your bits'n'pieces,
141 * don't touch meth_data! */ 164 * don't touch meth_data! */
142 CRYPTO_EX_DATA ex_data; 165 CRYPTO_EX_DATA ex_data;
166 /* If this callback function pointer is set to non-NULL, then it will
167 * be used on DSO_load() in place of meth->dso_name_converter. NB: This
168 * should normally set using DSO_set_name_converter(). */
169 DSO_NAME_CONVERTER_FUNC name_converter;
170 /* This is populated with (a copy of) the platform-independant
171 * filename used for this DSO. */
172 char *filename;
173 /* This is populated with (a copy of) the translated filename by which
174 * the DSO was actually loaded. It is NULL iff the DSO is not currently
175 * loaded. NB: This is here because the filename translation process
176 * may involve a callback being invoked more than once not only to
177 * convert to a platform-specific form, but also to try different
178 * filenames in the process of trying to perform a load. As such, this
179 * variable can be used to indicate (a) whether this DSO structure
180 * corresponds to a loaded library or not, and (b) the filename with
181 * which it was actually loaded. */
182 char *loaded_filename;
143 }; 183 };
144 184
145 185
@@ -147,10 +187,38 @@ DSO * DSO_new(void);
147DSO * DSO_new_method(DSO_METHOD *method); 187DSO * DSO_new_method(DSO_METHOD *method);
148int DSO_free(DSO *dso); 188int DSO_free(DSO *dso);
149int DSO_flags(DSO *dso); 189int DSO_flags(DSO *dso);
150int DSO_up(DSO *dso); 190int DSO_up_ref(DSO *dso);
151long DSO_ctrl(DSO *dso, int cmd, long larg, void *parg); 191long DSO_ctrl(DSO *dso, int cmd, long larg, void *parg);
152 192
153void DSO_set_default_method(DSO_METHOD *meth); 193/* This function sets the DSO's name_converter callback. If it is non-NULL,
194 * then it will be used instead of the associated DSO_METHOD's function. If
195 * oldcb is non-NULL then it is set to the function pointer value being
196 * replaced. Return value is non-zero for success. */
197int DSO_set_name_converter(DSO *dso, DSO_NAME_CONVERTER_FUNC cb,
198 DSO_NAME_CONVERTER_FUNC *oldcb);
199/* These functions can be used to get/set the platform-independant filename
200 * used for a DSO. NB: set will fail if the DSO is already loaded. */
201const char *DSO_get_filename(DSO *dso);
202int DSO_set_filename(DSO *dso, const char *filename);
203/* This function will invoke the DSO's name_converter callback to translate a
204 * filename, or if the callback isn't set it will instead use the DSO_METHOD's
205 * converter. If "filename" is NULL, the "filename" in the DSO itself will be
206 * used. If the DSO_FLAG_NO_NAME_TRANSLATION flag is set, then the filename is
207 * simply duplicated. NB: This function is usually called from within a
208 * DSO_METHOD during the processing of a DSO_load() call, and is exposed so that
209 * caller-created DSO_METHODs can do the same thing. A non-NULL return value
210 * will need to be OPENSSL_free()'d. */
211char *DSO_convert_filename(DSO *dso, const char *filename);
212/* If the DSO is currently loaded, this returns the filename that it was loaded
213 * under, otherwise it returns NULL. So it is also useful as a test as to
214 * whether the DSO is currently loaded. NB: This will not necessarily return
215 * the same value as DSO_convert_filename(dso, dso->filename), because the
216 * DSO_METHOD's load function may have tried a variety of filenames (with
217 * and/or without the aid of the converters) before settling on the one it
218 * actually loaded. */
219const char *DSO_get_loaded_filename(DSO *dso);
220
221void DSO_set_default_method(DSO_METHOD *meth);
154DSO_METHOD *DSO_get_default_method(void); 222DSO_METHOD *DSO_get_default_method(void);
155DSO_METHOD *DSO_get_method(DSO *dso); 223DSO_METHOD *DSO_get_method(DSO *dso);
156DSO_METHOD *DSO_set_method(DSO *dso, DSO_METHOD *meth); 224DSO_METHOD *DSO_set_method(DSO *dso, DSO_METHOD *meth);
@@ -159,8 +227,7 @@ DSO_METHOD *DSO_set_method(DSO *dso, DSO_METHOD *meth);
159 * for the first and third parameters. Use DSO_up and DSO_free for 227 * for the first and third parameters. Use DSO_up and DSO_free for
160 * subsequent reference count handling. Any flags passed in will be set 228 * subsequent reference count handling. Any flags passed in will be set
161 * in the constructed DSO after its init() function but before the 229 * in the constructed DSO after its init() function but before the
162 * load operation. This will be done with; 230 * load operation. If 'dso' is non-NULL, 'flags' is ignored. */
163 * DSO_ctrl(dso, DSO_CTRL_SET_FLAGS, flags, NULL); */
164DSO *DSO_load(DSO *dso, const char *filename, DSO_METHOD *meth, int flags); 231DSO *DSO_load(DSO *dso, const char *filename, DSO_METHOD *meth, int flags);
165 232
166/* This function binds to a variable inside a shared library. */ 233/* This function binds to a variable inside a shared library. */
@@ -194,52 +261,58 @@ DSO_METHOD *DSO_METHOD_win32(void);
194/* If VMS is defined, use shared images. If not, return NULL. */ 261/* If VMS is defined, use shared images. If not, return NULL. */
195DSO_METHOD *DSO_METHOD_vms(void); 262DSO_METHOD *DSO_METHOD_vms(void);
196 263
197void ERR_load_DSO_strings(void);
198
199/* BEGIN ERROR CODES */ 264/* BEGIN ERROR CODES */
200/* The following lines are auto generated by the script mkerr.pl. Any changes 265/* The following lines are auto generated by the script mkerr.pl. Any changes
201 * made after this point may be overwritten when the script is next run. 266 * made after this point may be overwritten when the script is next run.
202 */ 267 */
268void ERR_load_DSO_strings(void);
203 269
204/* Error codes for the DSO functions. */ 270/* Error codes for the DSO functions. */
205 271
206/* Function codes. */ 272/* Function codes. */
207#define DSO_F_DLFCN_BIND_FUNC 100 273#define DSO_F_DLFCN_BIND_FUNC 100
208#define DSO_F_DLFCN_BIND_VAR 101 274#define DSO_F_DLFCN_BIND_VAR 101
209#define DSO_F_DLFCN_CTRL 102 275#define DSO_F_DLFCN_LOAD 102
210#define DSO_F_DLFCN_LOAD 103 276#define DSO_F_DLFCN_NAME_CONVERTER 123
211#define DSO_F_DLFCN_UNLOAD 104 277#define DSO_F_DLFCN_UNLOAD 103
212#define DSO_F_DL_BIND_FUNC 105 278#define DSO_F_DL_BIND_FUNC 104
213#define DSO_F_DL_BIND_VAR 106 279#define DSO_F_DL_BIND_VAR 105
214#define DSO_F_DL_CTRL 107 280#define DSO_F_DL_LOAD 106
215#define DSO_F_DL_LOAD 108 281#define DSO_F_DL_NAME_CONVERTER 124
216#define DSO_F_DL_UNLOAD 109 282#define DSO_F_DL_UNLOAD 107
217#define DSO_F_DSO_BIND_FUNC 110 283#define DSO_F_DSO_BIND_FUNC 108
218#define DSO_F_DSO_BIND_VAR 111 284#define DSO_F_DSO_BIND_VAR 109
219#define DSO_F_DSO_CTRL 112 285#define DSO_F_DSO_CONVERT_FILENAME 126
220#define DSO_F_DSO_FREE 113 286#define DSO_F_DSO_CTRL 110
221#define DSO_F_DSO_LOAD 114 287#define DSO_F_DSO_FREE 111
222#define DSO_F_DSO_NEW_METHOD 115 288#define DSO_F_DSO_GET_FILENAME 127
223#define DSO_F_DSO_UP 116 289#define DSO_F_DSO_GET_LOADED_FILENAME 128
224#define DSO_F_VMS_BIND_VAR 122 290#define DSO_F_DSO_LOAD 112
225#define DSO_F_VMS_CTRL 123 291#define DSO_F_DSO_NEW_METHOD 113
226#define DSO_F_VMS_LOAD 124 292#define DSO_F_DSO_SET_FILENAME 129
227#define DSO_F_VMS_UNLOAD 125 293#define DSO_F_DSO_SET_NAME_CONVERTER 122
228#define DSO_F_WIN32_BIND_FUNC 117 294#define DSO_F_DSO_UP_REF 114
229#define DSO_F_WIN32_BIND_VAR 118 295#define DSO_F_VMS_BIND_VAR 115
230#define DSO_F_WIN32_CTRL 119 296#define DSO_F_VMS_LOAD 116
297#define DSO_F_VMS_UNLOAD 117
298#define DSO_F_WIN32_BIND_FUNC 118
299#define DSO_F_WIN32_BIND_VAR 119
231#define DSO_F_WIN32_LOAD 120 300#define DSO_F_WIN32_LOAD 120
301#define DSO_F_WIN32_NAME_CONVERTER 125
232#define DSO_F_WIN32_UNLOAD 121 302#define DSO_F_WIN32_UNLOAD 121
233 303
234/* Reason codes. */ 304/* Reason codes. */
235#define DSO_R_CTRL_FAILED 100 305#define DSO_R_CTRL_FAILED 100
236#define DSO_R_FILENAME_TOO_BIG 109 306#define DSO_R_DSO_ALREADY_LOADED 110
237#define DSO_R_FINISH_FAILED 101 307#define DSO_R_FILENAME_TOO_BIG 101
238#define DSO_R_LOAD_FAILED 102 308#define DSO_R_FINISH_FAILED 102
239#define DSO_R_NULL_HANDLE 103 309#define DSO_R_LOAD_FAILED 103
240#define DSO_R_STACK_ERROR 104 310#define DSO_R_NAME_TRANSLATION_FAILED 109
241#define DSO_R_SYM_FAILURE 105 311#define DSO_R_NO_FILENAME 111
242#define DSO_R_UNKNOWN_COMMAND 106 312#define DSO_R_NULL_HANDLE 104
313#define DSO_R_SET_FILENAME_FAILED 112
314#define DSO_R_STACK_ERROR 105
315#define DSO_R_SYM_FAILURE 106
243#define DSO_R_UNLOAD_FAILED 107 316#define DSO_R_UNLOAD_FAILED 107
244#define DSO_R_UNSUPPORTED 108 317#define DSO_R_UNSUPPORTED 108
245 318
@@ -247,4 +320,3 @@ void ERR_load_DSO_strings(void);
247} 320}
248#endif 321#endif
249#endif 322#endif
250
diff --git a/src/lib/libcrypto/dso/dso_dl.c b/src/lib/libcrypto/dso/dso_dl.c
index 455bd66ecf..195717e993 100644
--- a/src/lib/libcrypto/dso/dso_dl.c
+++ b/src/lib/libcrypto/dso/dso_dl.c
@@ -1,5 +1,5 @@
1/* dso_dl.c */ 1/* dso_dl.c */
2/* Written by Richard Levitte (levitte@openssl.org) for the OpenSSL 2/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
@@ -72,7 +72,7 @@ DSO_METHOD *DSO_METHOD_dl(void)
72/* Part of the hack in "dl_load" ... */ 72/* Part of the hack in "dl_load" ... */
73#define DSO_MAX_TRANSLATED_SIZE 256 73#define DSO_MAX_TRANSLATED_SIZE 256
74 74
75static int dl_load(DSO *dso, const char *filename); 75static int dl_load(DSO *dso);
76static int dl_unload(DSO *dso); 76static int dl_unload(DSO *dso);
77static void *dl_bind_var(DSO *dso, const char *symname); 77static void *dl_bind_var(DSO *dso, const char *symname);
78static DSO_FUNC_TYPE dl_bind_func(DSO *dso, const char *symname); 78static DSO_FUNC_TYPE dl_bind_func(DSO *dso, const char *symname);
@@ -81,8 +81,9 @@ static int dl_unbind_var(DSO *dso, char *symname, void *symptr);
81static int dl_unbind_func(DSO *dso, char *symname, DSO_FUNC_TYPE symptr); 81static int dl_unbind_func(DSO *dso, char *symname, DSO_FUNC_TYPE symptr);
82static int dl_init(DSO *dso); 82static int dl_init(DSO *dso);
83static int dl_finish(DSO *dso); 83static int dl_finish(DSO *dso);
84static int dl_ctrl(DSO *dso, int cmd, long larg, void *parg);
84#endif 85#endif
85static long dl_ctrl(DSO *dso, int cmd, long larg, void *parg); 86static char *dl_name_converter(DSO *dso, const char *filename);
86 87
87static DSO_METHOD dso_meth_dl = { 88static DSO_METHOD dso_meth_dl = {
88 "OpenSSL 'dl' shared library method", 89 "OpenSSL 'dl' shared library method",
@@ -95,7 +96,8 @@ static DSO_METHOD dso_meth_dl = {
95 NULL, /* unbind_var */ 96 NULL, /* unbind_var */
96 NULL, /* unbind_func */ 97 NULL, /* unbind_func */
97#endif 98#endif
98 dl_ctrl, 99 NULL, /* ctrl */
100 dl_name_converter,
99 NULL, /* init */ 101 NULL, /* init */
100 NULL /* finish */ 102 NULL /* finish */
101 }; 103 };
@@ -111,40 +113,43 @@ DSO_METHOD *DSO_METHOD_dl(void)
111 * type so the cast is safe. 113 * type so the cast is safe.
112 */ 114 */
113 115
114#if defined(__hpux) 116static int dl_load(DSO *dso)
115static const char extension[] = ".sl";
116#else
117static const char extension[] = ".so";
118#endif
119static int dl_load(DSO *dso, const char *filename)
120 { 117 {
121 shl_t ptr; 118 shl_t ptr = NULL;
122 char translated[DSO_MAX_TRANSLATED_SIZE]; 119 /* We don't do any fancy retries or anything, just take the method's
123 int len; 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);
124 123
125 /* The same comment as in dlfcn_load applies here. bleurgh. */ 124 if(filename == NULL)
126 len = strlen(filename) + strlen(extension);
127 if((dso->flags & DSO_FLAG_NAME_TRANSLATION) &&
128 (len + 3 < DSO_MAX_TRANSLATED_SIZE) &&
129 (strstr(filename, "/") == NULL))
130 { 125 {
131 sprintf(translated, "lib%s%s", filename, extension); 126 DSOerr(DSO_F_DL_LOAD,DSO_R_NO_FILENAME);
132 ptr = shl_load(translated, BIND_IMMEDIATE, NULL); 127 goto err;
133 } 128 }
134 else 129 ptr = shl_load(filename, BIND_IMMEDIATE|DYNAMIC_PATH, NULL);
135 ptr = shl_load(filename, BIND_IMMEDIATE, NULL);
136 if(ptr == NULL) 130 if(ptr == NULL)
137 { 131 {
138 DSOerr(DSO_F_DL_LOAD,DSO_R_LOAD_FAILED); 132 DSOerr(DSO_F_DL_LOAD,DSO_R_LOAD_FAILED);
139 return(0); 133 ERR_add_error_data(4, "filename(", filename, "): ",
134 strerror(errno));
135 goto err;
140 } 136 }
141 if(!sk_push(dso->meth_data, (char *)ptr)) 137 if(!sk_push(dso->meth_data, (char *)ptr))
142 { 138 {
143 DSOerr(DSO_F_DL_LOAD,DSO_R_STACK_ERROR); 139 DSOerr(DSO_F_DL_LOAD,DSO_R_STACK_ERROR);
144 shl_unload(ptr); 140 goto err;
145 return(0);
146 } 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;
147 return(1); 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);
148 } 153 }
149 154
150static int dl_unload(DSO *dso) 155static int dl_unload(DSO *dso)
@@ -195,6 +200,8 @@ static void *dl_bind_var(DSO *dso, const char *symname)
195 if (shl_findsym(&ptr, symname, TYPE_UNDEFINED, &sym) < 0) 200 if (shl_findsym(&ptr, symname, TYPE_UNDEFINED, &sym) < 0)
196 { 201 {
197 DSOerr(DSO_F_DL_BIND_VAR,DSO_R_SYM_FAILURE); 202 DSOerr(DSO_F_DL_BIND_VAR,DSO_R_SYM_FAILURE);
203 ERR_add_error_data(4, "symname(", symname, "): ",
204 strerror(errno));
198 return(NULL); 205 return(NULL);
199 } 206 }
200 return(sym); 207 return(sym);
@@ -224,33 +231,54 @@ static DSO_FUNC_TYPE dl_bind_func(DSO *dso, const char *symname)
224 if (shl_findsym(&ptr, symname, TYPE_UNDEFINED, &sym) < 0) 231 if (shl_findsym(&ptr, symname, TYPE_UNDEFINED, &sym) < 0)
225 { 232 {
226 DSOerr(DSO_F_DL_BIND_FUNC,DSO_R_SYM_FAILURE); 233 DSOerr(DSO_F_DL_BIND_FUNC,DSO_R_SYM_FAILURE);
234 ERR_add_error_data(4, "symname(", symname, "): ",
235 strerror(errno));
227 return(NULL); 236 return(NULL);
228 } 237 }
229 return((DSO_FUNC_TYPE)sym); 238 return((DSO_FUNC_TYPE)sym);
230 } 239 }
231 240
232static long dl_ctrl(DSO *dso, int cmd, long larg, void *parg) 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)
233 { 252 {
234 if(dso == NULL) 253 char *translated;
254 int len, rsize, transform;
255
256 len = strlen(filename);
257 rsize = len + 1;
258 transform = (strstr(filename, "/") == NULL);
235 { 259 {
236 DSOerr(DSO_F_DL_CTRL,ERR_R_PASSED_NULL_PARAMETER); 260 /* We will convert this to "%s.s?" or "lib%s.s?" */
237 return(-1); 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" */
238 } 264 }
239 switch(cmd) 265 translated = OPENSSL_malloc(rsize);
266 if(translated == NULL)
240 { 267 {
241 case DSO_CTRL_GET_FLAGS: 268 DSOerr(DSO_F_DL_NAME_CONVERTER,
242 return dso->flags; 269 DSO_R_NAME_TRANSLATION_FAILED);
243 case DSO_CTRL_SET_FLAGS: 270 return(NULL);
244 dso->flags = larg;
245 return(0);
246 case DSO_CTRL_OR_FLAGS:
247 dso->flags |= larg;
248 return(0);
249 default:
250 break;
251 } 271 }
252 DSOerr(DSO_F_DL_CTRL,DSO_R_UNKNOWN_COMMAND); 272 if(transform)
253 return(-1); 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);
254 } 282 }
255 283
256#endif /* DSO_DL */ 284#endif /* DSO_DL */
diff --git a/src/lib/libcrypto/dso/dso_dlfcn.c b/src/lib/libcrypto/dso/dso_dlfcn.c
index e709c721cc..1a19164d3b 100644
--- a/src/lib/libcrypto/dso/dso_dlfcn.c
+++ b/src/lib/libcrypto/dso/dso_dlfcn.c
@@ -74,7 +74,7 @@ DSO_METHOD *DSO_METHOD_dlfcn(void)
74/* Part of the hack in "dlfcn_load" ... */ 74/* Part of the hack in "dlfcn_load" ... */
75#define DSO_MAX_TRANSLATED_SIZE 256 75#define DSO_MAX_TRANSLATED_SIZE 256
76 76
77static int dlfcn_load(DSO *dso, const char *filename); 77static int dlfcn_load(DSO *dso);
78static int dlfcn_unload(DSO *dso); 78static int dlfcn_unload(DSO *dso);
79static void *dlfcn_bind_var(DSO *dso, const char *symname); 79static void *dlfcn_bind_var(DSO *dso, const char *symname);
80static DSO_FUNC_TYPE dlfcn_bind_func(DSO *dso, const char *symname); 80static DSO_FUNC_TYPE dlfcn_bind_func(DSO *dso, const char *symname);
@@ -82,8 +82,9 @@ static DSO_FUNC_TYPE dlfcn_bind_func(DSO *dso, const char *symname);
82static int dlfcn_unbind(DSO *dso, char *symname, void *symptr); 82static int dlfcn_unbind(DSO *dso, char *symname, void *symptr);
83static int dlfcn_init(DSO *dso); 83static int dlfcn_init(DSO *dso);
84static int dlfcn_finish(DSO *dso); 84static int dlfcn_finish(DSO *dso);
85#endif
86static long dlfcn_ctrl(DSO *dso, int cmd, long larg, void *parg); 85static long dlfcn_ctrl(DSO *dso, int cmd, long larg, void *parg);
86#endif
87static char *dlfcn_name_converter(DSO *dso, const char *filename);
87 88
88static DSO_METHOD dso_meth_dlfcn = { 89static DSO_METHOD dso_meth_dlfcn = {
89 "OpenSSL 'dlfcn' shared library method", 90 "OpenSSL 'dlfcn' shared library method",
@@ -96,7 +97,8 @@ static DSO_METHOD dso_meth_dlfcn = {
96 NULL, /* unbind_var */ 97 NULL, /* unbind_var */
97 NULL, /* unbind_func */ 98 NULL, /* unbind_func */
98#endif 99#endif
99 dlfcn_ctrl, 100 NULL, /* ctrl */
101 dlfcn_name_converter,
100 NULL, /* init */ 102 NULL, /* init */
101 NULL /* finish */ 103 NULL /* finish */
102 }; 104 };
@@ -130,41 +132,40 @@ DSO_METHOD *DSO_METHOD_dlfcn(void)
130 * (i) the handle (void*) returned from dlopen(). 132 * (i) the handle (void*) returned from dlopen().
131 */ 133 */
132 134
133static int dlfcn_load(DSO *dso, const char *filename) 135static int dlfcn_load(DSO *dso)
134 { 136 {
135 void *ptr; 137 void *ptr = NULL;
136 char translated[DSO_MAX_TRANSLATED_SIZE]; 138 /* See applicable comments in dso_dl.c */
137 int len; 139 char *filename = DSO_convert_filename(dso, NULL);
138 140
139 /* NB: This is a hideous hack, but I'm not yet sure what 141 if(filename == NULL)
140 * to replace it with. This attempts to convert any filename,
141 * that looks like it has no path information, into a
142 * translated form, e. "blah" -> "libblah.so" */
143 len = strlen(filename);
144 if((dso->flags & DSO_FLAG_NAME_TRANSLATION) &&
145 (len + 6 < DSO_MAX_TRANSLATED_SIZE) &&
146 (strstr(filename, "/") == NULL))
147 { 142 {
148 sprintf(translated, "lib%s.so", filename); 143 DSOerr(DSO_F_DLFCN_LOAD,DSO_R_NO_FILENAME);
149 ptr = dlopen(translated, DLOPEN_FLAG); 144 goto err;
150 }
151 else
152 {
153 ptr = dlopen(filename, DLOPEN_FLAG);
154 } 145 }
146 ptr = dlopen(filename, DLOPEN_FLAG);
155 if(ptr == NULL) 147 if(ptr == NULL)
156 { 148 {
157 DSOerr(DSO_F_DLFCN_LOAD,DSO_R_LOAD_FAILED); 149 DSOerr(DSO_F_DLFCN_LOAD,DSO_R_LOAD_FAILED);
158 return(0); 150 ERR_add_error_data(4, "filename(", filename, "): ", dlerror());
151 goto err;
159 } 152 }
160 if(!sk_push(dso->meth_data, (char *)ptr)) 153 if(!sk_push(dso->meth_data, (char *)ptr))
161 { 154 {
162 DSOerr(DSO_F_DLFCN_LOAD,DSO_R_STACK_ERROR); 155 DSOerr(DSO_F_DLFCN_LOAD,DSO_R_STACK_ERROR);
163 dlclose(ptr); 156 goto err;
164 return(0);
165 } 157 }
158 /* Success */
159 dso->loaded_filename = filename;
166 return(1); 160 return(1);
167 } 161err:
162 /* Cleanup! */
163 if(filename != NULL)
164 OPENSSL_free(filename);
165 if(ptr != NULL)
166 dlclose(ptr);
167 return(0);
168}
168 169
169static int dlfcn_unload(DSO *dso) 170static int dlfcn_unload(DSO *dso)
170 { 171 {
@@ -214,6 +215,7 @@ static void *dlfcn_bind_var(DSO *dso, const char *symname)
214 if(sym == NULL) 215 if(sym == NULL)
215 { 216 {
216 DSOerr(DSO_F_DLFCN_BIND_VAR,DSO_R_SYM_FAILURE); 217 DSOerr(DSO_F_DLFCN_BIND_VAR,DSO_R_SYM_FAILURE);
218 ERR_add_error_data(4, "symname(", symname, "): ", dlerror());
217 return(NULL); 219 return(NULL);
218 } 220 }
219 return(sym); 221 return(sym);
@@ -244,33 +246,44 @@ static DSO_FUNC_TYPE dlfcn_bind_func(DSO *dso, const char *symname)
244 if(sym == NULL) 246 if(sym == NULL)
245 { 247 {
246 DSOerr(DSO_F_DLFCN_BIND_FUNC,DSO_R_SYM_FAILURE); 248 DSOerr(DSO_F_DLFCN_BIND_FUNC,DSO_R_SYM_FAILURE);
249 ERR_add_error_data(4, "symname(", symname, "): ", dlerror());
247 return(NULL); 250 return(NULL);
248 } 251 }
249 return(sym); 252 return(sym);
250 } 253 }
251 254
252static long dlfcn_ctrl(DSO *dso, int cmd, long larg, void *parg) 255static char *dlfcn_name_converter(DSO *dso, const char *filename)
253 { 256 {
254 if(dso == NULL) 257 char *translated;
258 int len, rsize, transform;
259
260 len = strlen(filename);
261 rsize = len + 1;
262 transform = (strstr(filename, "/") == NULL);
263 if(transform)
255 { 264 {
256 DSOerr(DSO_F_DLFCN_CTRL,ERR_R_PASSED_NULL_PARAMETER); 265 /* We will convert this to "%s.so" or "lib%s.so" */
257 return(-1); 266 rsize += 3; /* The length of ".so" */
267 if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0)
268 rsize += 3; /* The length of "lib" */
258 } 269 }
259 switch(cmd) 270 translated = OPENSSL_malloc(rsize);
271 if(translated == NULL)
260 { 272 {
261 case DSO_CTRL_GET_FLAGS: 273 DSOerr(DSO_F_DLFCN_NAME_CONVERTER,
262 return dso->flags; 274 DSO_R_NAME_TRANSLATION_FAILED);
263 case DSO_CTRL_SET_FLAGS: 275 return(NULL);
264 dso->flags = (int)larg;
265 return(0);
266 case DSO_CTRL_OR_FLAGS:
267 dso->flags |= (int)larg;
268 return(0);
269 default:
270 break;
271 } 276 }
272 DSOerr(DSO_F_DLFCN_CTRL,DSO_R_UNKNOWN_COMMAND); 277 if(transform)
273 return(-1); 278 {
279 if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0)
280 sprintf(translated, "lib%s.so", filename);
281 else
282 sprintf(translated, "%s.so", filename);
283 }
284 else
285 sprintf(translated, "%s", filename);
286 return(translated);
274 } 287 }
275 288
276#endif /* DSO_DLFCN */ 289#endif /* DSO_DLFCN */
diff --git a/src/lib/libcrypto/dso/dso_err.c b/src/lib/libcrypto/dso/dso_err.c
index a3d7321c9b..cf452de1aa 100644
--- a/src/lib/libcrypto/dso/dso_err.c
+++ b/src/lib/libcrypto/dso/dso_err.c
@@ -63,34 +63,38 @@
63#include <openssl/dso.h> 63#include <openssl/dso.h>
64 64
65/* BEGIN ERROR CODES */ 65/* BEGIN ERROR CODES */
66#ifndef NO_ERR 66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA DSO_str_functs[]= 67static ERR_STRING_DATA DSO_str_functs[]=
68 { 68 {
69{ERR_PACK(0,DSO_F_DLFCN_BIND_FUNC,0), "DLFCN_BIND_FUNC"}, 69{ERR_PACK(0,DSO_F_DLFCN_BIND_FUNC,0), "DLFCN_BIND_FUNC"},
70{ERR_PACK(0,DSO_F_DLFCN_BIND_VAR,0), "DLFCN_BIND_VAR"}, 70{ERR_PACK(0,DSO_F_DLFCN_BIND_VAR,0), "DLFCN_BIND_VAR"},
71{ERR_PACK(0,DSO_F_DLFCN_CTRL,0), "DLFCN_CTRL"},
72{ERR_PACK(0,DSO_F_DLFCN_LOAD,0), "DLFCN_LOAD"}, 71{ERR_PACK(0,DSO_F_DLFCN_LOAD,0), "DLFCN_LOAD"},
72{ERR_PACK(0,DSO_F_DLFCN_NAME_CONVERTER,0), "DLFCN_NAME_CONVERTER"},
73{ERR_PACK(0,DSO_F_DLFCN_UNLOAD,0), "DLFCN_UNLOAD"}, 73{ERR_PACK(0,DSO_F_DLFCN_UNLOAD,0), "DLFCN_UNLOAD"},
74{ERR_PACK(0,DSO_F_DL_BIND_FUNC,0), "DL_BIND_FUNC"}, 74{ERR_PACK(0,DSO_F_DL_BIND_FUNC,0), "DL_BIND_FUNC"},
75{ERR_PACK(0,DSO_F_DL_BIND_VAR,0), "DL_BIND_VAR"}, 75{ERR_PACK(0,DSO_F_DL_BIND_VAR,0), "DL_BIND_VAR"},
76{ERR_PACK(0,DSO_F_DL_CTRL,0), "DL_CTRL"},
77{ERR_PACK(0,DSO_F_DL_LOAD,0), "DL_LOAD"}, 76{ERR_PACK(0,DSO_F_DL_LOAD,0), "DL_LOAD"},
77{ERR_PACK(0,DSO_F_DL_NAME_CONVERTER,0), "DL_NAME_CONVERTER"},
78{ERR_PACK(0,DSO_F_DL_UNLOAD,0), "DL_UNLOAD"}, 78{ERR_PACK(0,DSO_F_DL_UNLOAD,0), "DL_UNLOAD"},
79{ERR_PACK(0,DSO_F_DSO_BIND_FUNC,0), "DSO_bind_func"}, 79{ERR_PACK(0,DSO_F_DSO_BIND_FUNC,0), "DSO_bind_func"},
80{ERR_PACK(0,DSO_F_DSO_BIND_VAR,0), "DSO_bind_var"}, 80{ERR_PACK(0,DSO_F_DSO_BIND_VAR,0), "DSO_bind_var"},
81{ERR_PACK(0,DSO_F_DSO_CONVERT_FILENAME,0), "DSO_convert_filename"},
81{ERR_PACK(0,DSO_F_DSO_CTRL,0), "DSO_ctrl"}, 82{ERR_PACK(0,DSO_F_DSO_CTRL,0), "DSO_ctrl"},
82{ERR_PACK(0,DSO_F_DSO_FREE,0), "DSO_free"}, 83{ERR_PACK(0,DSO_F_DSO_FREE,0), "DSO_free"},
84{ERR_PACK(0,DSO_F_DSO_GET_FILENAME,0), "DSO_get_filename"},
85{ERR_PACK(0,DSO_F_DSO_GET_LOADED_FILENAME,0), "DSO_get_loaded_filename"},
83{ERR_PACK(0,DSO_F_DSO_LOAD,0), "DSO_load"}, 86{ERR_PACK(0,DSO_F_DSO_LOAD,0), "DSO_load"},
84{ERR_PACK(0,DSO_F_DSO_NEW_METHOD,0), "DSO_new_method"}, 87{ERR_PACK(0,DSO_F_DSO_NEW_METHOD,0), "DSO_new_method"},
85{ERR_PACK(0,DSO_F_DSO_UP,0), "DSO_up"}, 88{ERR_PACK(0,DSO_F_DSO_SET_FILENAME,0), "DSO_set_filename"},
89{ERR_PACK(0,DSO_F_DSO_SET_NAME_CONVERTER,0), "DSO_set_name_converter"},
90{ERR_PACK(0,DSO_F_DSO_UP_REF,0), "DSO_up_ref"},
86{ERR_PACK(0,DSO_F_VMS_BIND_VAR,0), "VMS_BIND_VAR"}, 91{ERR_PACK(0,DSO_F_VMS_BIND_VAR,0), "VMS_BIND_VAR"},
87{ERR_PACK(0,DSO_F_VMS_CTRL,0), "VMS_CTRL"},
88{ERR_PACK(0,DSO_F_VMS_LOAD,0), "VMS_LOAD"}, 92{ERR_PACK(0,DSO_F_VMS_LOAD,0), "VMS_LOAD"},
89{ERR_PACK(0,DSO_F_VMS_UNLOAD,0), "VMS_UNLOAD"}, 93{ERR_PACK(0,DSO_F_VMS_UNLOAD,0), "VMS_UNLOAD"},
90{ERR_PACK(0,DSO_F_WIN32_BIND_FUNC,0), "WIN32_BIND_FUNC"}, 94{ERR_PACK(0,DSO_F_WIN32_BIND_FUNC,0), "WIN32_BIND_FUNC"},
91{ERR_PACK(0,DSO_F_WIN32_BIND_VAR,0), "WIN32_BIND_VAR"}, 95{ERR_PACK(0,DSO_F_WIN32_BIND_VAR,0), "WIN32_BIND_VAR"},
92{ERR_PACK(0,DSO_F_WIN32_CTRL,0), "WIN32_CTRL"},
93{ERR_PACK(0,DSO_F_WIN32_LOAD,0), "WIN32_LOAD"}, 96{ERR_PACK(0,DSO_F_WIN32_LOAD,0), "WIN32_LOAD"},
97{ERR_PACK(0,DSO_F_WIN32_NAME_CONVERTER,0), "WIN32_NAME_CONVERTER"},
94{ERR_PACK(0,DSO_F_WIN32_UNLOAD,0), "WIN32_UNLOAD"}, 98{ERR_PACK(0,DSO_F_WIN32_UNLOAD,0), "WIN32_UNLOAD"},
95{0,NULL} 99{0,NULL}
96 }; 100 };
@@ -98,13 +102,16 @@ static ERR_STRING_DATA DSO_str_functs[]=
98static ERR_STRING_DATA DSO_str_reasons[]= 102static ERR_STRING_DATA DSO_str_reasons[]=
99 { 103 {
100{DSO_R_CTRL_FAILED ,"control command failed"}, 104{DSO_R_CTRL_FAILED ,"control command failed"},
105{DSO_R_DSO_ALREADY_LOADED ,"dso already loaded"},
101{DSO_R_FILENAME_TOO_BIG ,"filename too big"}, 106{DSO_R_FILENAME_TOO_BIG ,"filename too big"},
102{DSO_R_FINISH_FAILED ,"cleanup method function failed"}, 107{DSO_R_FINISH_FAILED ,"cleanup method function failed"},
103{DSO_R_LOAD_FAILED ,"could not load the shared library"}, 108{DSO_R_LOAD_FAILED ,"could not load the shared library"},
109{DSO_R_NAME_TRANSLATION_FAILED ,"name translation failed"},
110{DSO_R_NO_FILENAME ,"no filename"},
104{DSO_R_NULL_HANDLE ,"a null shared library handle was used"}, 111{DSO_R_NULL_HANDLE ,"a null shared library handle was used"},
112{DSO_R_SET_FILENAME_FAILED ,"set filename failed"},
105{DSO_R_STACK_ERROR ,"the meth_data stack is corrupt"}, 113{DSO_R_STACK_ERROR ,"the meth_data stack is corrupt"},
106{DSO_R_SYM_FAILURE ,"could not bind to the requested symbol name"}, 114{DSO_R_SYM_FAILURE ,"could not bind to the requested symbol name"},
107{DSO_R_UNKNOWN_COMMAND ,"unknown control command"},
108{DSO_R_UNLOAD_FAILED ,"could not unload the shared library"}, 115{DSO_R_UNLOAD_FAILED ,"could not unload the shared library"},
109{DSO_R_UNSUPPORTED ,"functionality not supported"}, 116{DSO_R_UNSUPPORTED ,"functionality not supported"},
110{0,NULL} 117{0,NULL}
@@ -119,7 +126,7 @@ void ERR_load_DSO_strings(void)
119 if (init) 126 if (init)
120 { 127 {
121 init=0; 128 init=0;
122#ifndef NO_ERR 129#ifndef OPENSSL_NO_ERR
123 ERR_load_strings(ERR_LIB_DSO,DSO_str_functs); 130 ERR_load_strings(ERR_LIB_DSO,DSO_str_functs);
124 ERR_load_strings(ERR_LIB_DSO,DSO_str_reasons); 131 ERR_load_strings(ERR_LIB_DSO,DSO_str_reasons);
125#endif 132#endif
diff --git a/src/lib/libcrypto/dso/dso_lib.c b/src/lib/libcrypto/dso/dso_lib.c
index acd166697e..556069b9b8 100644
--- a/src/lib/libcrypto/dso/dso_lib.c
+++ b/src/lib/libcrypto/dso/dso_lib.c
@@ -108,7 +108,7 @@ DSO *DSO_new_method(DSO_METHOD *meth)
108 } 108 }
109 memset(ret, 0, sizeof(DSO)); 109 memset(ret, 0, sizeof(DSO));
110 ret->meth_data = sk_new_null(); 110 ret->meth_data = sk_new_null();
111 if((ret->meth_data = sk_new_null()) == NULL) 111 if(ret->meth_data == NULL)
112 { 112 {
113 /* sk_new doesn't generate any errors so we do */ 113 /* sk_new doesn't generate any errors so we do */
114 DSOerr(DSO_F_DSO_NEW_METHOD,ERR_R_MALLOC_FAILURE); 114 DSOerr(DSO_F_DSO_NEW_METHOD,ERR_R_MALLOC_FAILURE);
@@ -164,6 +164,10 @@ int DSO_free(DSO *dso)
164 } 164 }
165 165
166 sk_free(dso->meth_data); 166 sk_free(dso->meth_data);
167 if(dso->filename != NULL)
168 OPENSSL_free(dso->filename);
169 if(dso->loaded_filename != NULL)
170 OPENSSL_free(dso->loaded_filename);
167 171
168 OPENSSL_free(dso); 172 OPENSSL_free(dso);
169 return(1); 173 return(1);
@@ -175,11 +179,11 @@ int DSO_flags(DSO *dso)
175 } 179 }
176 180
177 181
178int DSO_up(DSO *dso) 182int DSO_up_ref(DSO *dso)
179 { 183 {
180 if (dso == NULL) 184 if (dso == NULL)
181 { 185 {
182 DSOerr(DSO_F_DSO_UP,ERR_R_PASSED_NULL_PARAMETER); 186 DSOerr(DSO_F_DSO_UP_REF,ERR_R_PASSED_NULL_PARAMETER);
183 return(0); 187 return(0);
184 } 188 }
185 189
@@ -192,48 +196,60 @@ DSO *DSO_load(DSO *dso, const char *filename, DSO_METHOD *meth, int flags)
192 DSO *ret; 196 DSO *ret;
193 int allocated = 0; 197 int allocated = 0;
194 198
195 if(filename == NULL)
196 {
197 DSOerr(DSO_F_DSO_LOAD,ERR_R_PASSED_NULL_PARAMETER);
198 return(NULL);
199 }
200 if(dso == NULL) 199 if(dso == NULL)
201 { 200 {
202 ret = DSO_new_method(meth); 201 ret = DSO_new_method(meth);
203 if(ret == NULL) 202 if(ret == NULL)
204 { 203 {
205 DSOerr(DSO_F_DSO_LOAD,ERR_R_MALLOC_FAILURE); 204 DSOerr(DSO_F_DSO_LOAD,ERR_R_MALLOC_FAILURE);
206 return(NULL); 205 goto err;
207 } 206 }
208 allocated = 1; 207 allocated = 1;
208 /* Pass the provided flags to the new DSO object */
209 if(DSO_ctrl(ret, DSO_CTRL_SET_FLAGS, flags, NULL) < 0)
210 {
211 DSOerr(DSO_F_DSO_LOAD,DSO_R_CTRL_FAILED);
212 goto err;
213 }
209 } 214 }
210 else 215 else
211 ret = dso; 216 ret = dso;
212 /* Bleurgh ... have to check for negative return values for 217 /* Don't load if we're currently already loaded */
213 * errors. <grimace> */ 218 if(ret->filename != NULL)
214 if(DSO_ctrl(ret, DSO_CTRL_SET_FLAGS, flags, NULL) < 0)
215 { 219 {
216 DSOerr(DSO_F_DSO_LOAD,DSO_R_CTRL_FAILED); 220 DSOerr(DSO_F_DSO_LOAD,DSO_R_DSO_ALREADY_LOADED);
217 if(allocated) 221 goto err;
218 DSO_free(ret); 222 }
219 return(NULL); 223 /* filename can only be NULL if we were passed a dso that already has
224 * one set. */
225 if(filename != NULL)
226 if(!DSO_set_filename(ret, filename))
227 {
228 DSOerr(DSO_F_DSO_LOAD,DSO_R_SET_FILENAME_FAILED);
229 goto err;
230 }
231 filename = ret->filename;
232 if(filename == NULL)
233 {
234 DSOerr(DSO_F_DSO_LOAD,DSO_R_NO_FILENAME);
235 goto err;
220 } 236 }
221 if(ret->meth->dso_load == NULL) 237 if(ret->meth->dso_load == NULL)
222 { 238 {
223 DSOerr(DSO_F_DSO_LOAD,DSO_R_UNSUPPORTED); 239 DSOerr(DSO_F_DSO_LOAD,DSO_R_UNSUPPORTED);
224 if(allocated) 240 goto err;
225 DSO_free(ret);
226 return(NULL);
227 } 241 }
228 if(!ret->meth->dso_load(ret, filename)) 242 if(!ret->meth->dso_load(ret))
229 { 243 {
230 DSOerr(DSO_F_DSO_LOAD,DSO_R_LOAD_FAILED); 244 DSOerr(DSO_F_DSO_LOAD,DSO_R_LOAD_FAILED);
231 if(allocated) 245 goto err;
232 DSO_free(ret);
233 return(NULL);
234 } 246 }
235 /* Load succeeded */ 247 /* Load succeeded */
236 return(ret); 248 return(ret);
249err:
250 if(allocated)
251 DSO_free(ret);
252 return(NULL);
237 } 253 }
238 254
239void *DSO_bind_var(DSO *dso, const char *symname) 255void *DSO_bind_var(DSO *dso, const char *symname)
@@ -297,6 +313,22 @@ long DSO_ctrl(DSO *dso, int cmd, long larg, void *parg)
297 DSOerr(DSO_F_DSO_CTRL,ERR_R_PASSED_NULL_PARAMETER); 313 DSOerr(DSO_F_DSO_CTRL,ERR_R_PASSED_NULL_PARAMETER);
298 return(-1); 314 return(-1);
299 } 315 }
316 /* We should intercept certain generic commands and only pass control
317 * to the method-specific ctrl() function if it's something we don't
318 * handle. */
319 switch(cmd)
320 {
321 case DSO_CTRL_GET_FLAGS:
322 return dso->flags;
323 case DSO_CTRL_SET_FLAGS:
324 dso->flags = (int)larg;
325 return(0);
326 case DSO_CTRL_OR_FLAGS:
327 dso->flags |= (int)larg;
328 return(0);
329 default:
330 break;
331 }
300 if((dso->meth == NULL) || (dso->meth->dso_ctrl == NULL)) 332 if((dso->meth == NULL) || (dso->meth->dso_ctrl == NULL))
301 { 333 {
302 DSOerr(DSO_F_DSO_CTRL,DSO_R_UNSUPPORTED); 334 DSOerr(DSO_F_DSO_CTRL,DSO_R_UNSUPPORTED);
@@ -304,3 +336,104 @@ long DSO_ctrl(DSO *dso, int cmd, long larg, void *parg)
304 } 336 }
305 return(dso->meth->dso_ctrl(dso,cmd,larg,parg)); 337 return(dso->meth->dso_ctrl(dso,cmd,larg,parg));
306 } 338 }
339
340int DSO_set_name_converter(DSO *dso, DSO_NAME_CONVERTER_FUNC cb,
341 DSO_NAME_CONVERTER_FUNC *oldcb)
342 {
343 if(dso == NULL)
344 {
345 DSOerr(DSO_F_DSO_SET_NAME_CONVERTER,
346 ERR_R_PASSED_NULL_PARAMETER);
347 return(0);
348 }
349 if(oldcb)
350 *oldcb = dso->name_converter;
351 dso->name_converter = cb;
352 return(1);
353 }
354
355const char *DSO_get_filename(DSO *dso)
356 {
357 if(dso == NULL)
358 {
359 DSOerr(DSO_F_DSO_GET_FILENAME,ERR_R_PASSED_NULL_PARAMETER);
360 return(NULL);
361 }
362 return(dso->filename);
363 }
364
365int DSO_set_filename(DSO *dso, const char *filename)
366 {
367 char *copied;
368
369 if((dso == NULL) || (filename == NULL))
370 {
371 DSOerr(DSO_F_DSO_SET_FILENAME,ERR_R_PASSED_NULL_PARAMETER);
372 return(0);
373 }
374 if(dso->loaded_filename)
375 {
376 DSOerr(DSO_F_DSO_SET_FILENAME,DSO_R_DSO_ALREADY_LOADED);
377 return(0);
378 }
379 /* We'll duplicate filename */
380 copied = OPENSSL_malloc(strlen(filename) + 1);
381 if(copied == NULL)
382 {
383 DSOerr(DSO_F_DSO_SET_FILENAME,ERR_R_MALLOC_FAILURE);
384 return(0);
385 }
386 strcpy(copied, filename);
387 if(dso->filename)
388 OPENSSL_free(dso->filename);
389 dso->filename = copied;
390 return(1);
391 }
392
393char *DSO_convert_filename(DSO *dso, const char *filename)
394 {
395 char *result = NULL;
396
397 if(dso == NULL)
398 {
399 DSOerr(DSO_F_DSO_CONVERT_FILENAME,ERR_R_PASSED_NULL_PARAMETER);
400 return(NULL);
401 }
402 if(filename == NULL)
403 filename = dso->filename;
404 if(filename == NULL)
405 {
406 DSOerr(DSO_F_DSO_CONVERT_FILENAME,DSO_R_NO_FILENAME);
407 return(NULL);
408 }
409 if((dso->flags & DSO_FLAG_NO_NAME_TRANSLATION) == 0)
410 {
411 if(dso->name_converter != NULL)
412 result = dso->name_converter(dso, filename);
413 else if(dso->meth->dso_name_converter != NULL)
414 result = dso->meth->dso_name_converter(dso, filename);
415 }
416 if(result == NULL)
417 {
418 result = OPENSSL_malloc(strlen(filename) + 1);
419 if(result == NULL)
420 {
421 DSOerr(DSO_F_DSO_CONVERT_FILENAME,
422 ERR_R_MALLOC_FAILURE);
423 return(NULL);
424 }
425 strcpy(result, filename);
426 }
427 return(result);
428 }
429
430const char *DSO_get_loaded_filename(DSO *dso)
431 {
432 if(dso == NULL)
433 {
434 DSOerr(DSO_F_DSO_GET_LOADED_FILENAME,
435 ERR_R_PASSED_NULL_PARAMETER);
436 return(NULL);
437 }
438 return(dso->loaded_filename);
439 }
diff --git a/src/lib/libcrypto/dso/dso_vms.c b/src/lib/libcrypto/dso/dso_vms.c
index ab48b63eb7..1674619d17 100644
--- a/src/lib/libcrypto/dso/dso_vms.c
+++ b/src/lib/libcrypto/dso/dso_vms.c
@@ -59,17 +59,17 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <string.h> 60#include <string.h>
61#include <errno.h> 61#include <errno.h>
62#ifdef VMS 62#include "cryptlib.h"
63#include <openssl/dso.h>
64#ifdef OPENSSL_SYS_VMS
63#pragma message disable DOLLARID 65#pragma message disable DOLLARID
64#include <lib$routines.h> 66#include <lib$routines.h>
65#include <stsdef.h> 67#include <stsdef.h>
66#include <descrip.h> 68#include <descrip.h>
67#include <starlet.h> 69#include <starlet.h>
68#endif 70#endif
69#include "cryptlib.h"
70#include <openssl/dso.h>
71 71
72#ifndef VMS 72#ifndef OPENSSL_SYS_VMS
73DSO_METHOD *DSO_METHOD_vms(void) 73DSO_METHOD *DSO_METHOD_vms(void)
74 { 74 {
75 return NULL; 75 return NULL;
@@ -77,7 +77,7 @@ DSO_METHOD *DSO_METHOD_vms(void)
77#else 77#else
78#pragma message disable DOLLARID 78#pragma message disable DOLLARID
79 79
80static int vms_load(DSO *dso, const char *filename); 80static int vms_load(DSO *dso);
81static int vms_unload(DSO *dso); 81static int vms_unload(DSO *dso);
82static void *vms_bind_var(DSO *dso, const char *symname); 82static void *vms_bind_var(DSO *dso, const char *symname);
83static DSO_FUNC_TYPE vms_bind_func(DSO *dso, const char *symname); 83static DSO_FUNC_TYPE vms_bind_func(DSO *dso, const char *symname);
@@ -86,8 +86,9 @@ static int vms_unbind_var(DSO *dso, char *symname, void *symptr);
86static int vms_unbind_func(DSO *dso, char *symname, DSO_FUNC_TYPE symptr); 86static int vms_unbind_func(DSO *dso, char *symname, DSO_FUNC_TYPE symptr);
87static int vms_init(DSO *dso); 87static int vms_init(DSO *dso);
88static int vms_finish(DSO *dso); 88static int vms_finish(DSO *dso);
89#endif
90static long vms_ctrl(DSO *dso, int cmd, long larg, void *parg); 89static long vms_ctrl(DSO *dso, int cmd, long larg, void *parg);
90#endif
91static char *vms_name_converter(DSO *dso, const char *filename);
91 92
92static DSO_METHOD dso_meth_vms = { 93static DSO_METHOD dso_meth_vms = {
93 "OpenSSL 'VMS' shared library method", 94 "OpenSSL 'VMS' shared library method",
@@ -100,7 +101,8 @@ static DSO_METHOD dso_meth_vms = {
100 NULL, /* unbind_var */ 101 NULL, /* unbind_var */
101 NULL, /* unbind_func */ 102 NULL, /* unbind_func */
102#endif 103#endif
103 vms_ctrl, 104 NULL, /* ctrl */
105 vms_name_converter,
104 NULL, /* init */ 106 NULL, /* init */
105 NULL /* finish */ 107 NULL /* finish */
106 }; 108 };
@@ -128,11 +130,20 @@ DSO_METHOD *DSO_METHOD_vms(void)
128 return(&dso_meth_vms); 130 return(&dso_meth_vms);
129 } 131 }
130 132
131static int vms_load(DSO *dso, const char *filename) 133static int vms_load(DSO *dso)
132 { 134 {
135 void *ptr = NULL;
136 /* See applicable comments in dso_dl.c */
137 char *filename = DSO_convert_filename(dso, NULL);
133 DSO_VMS_INTERNAL *p; 138 DSO_VMS_INTERNAL *p;
134 const char *sp1, *sp2; /* Search result */ 139 const char *sp1, *sp2; /* Search result */
135 140
141 if(filename == NULL)
142 {
143 DSOerr(DSO_F_DLFCN_LOAD,DSO_R_NO_FILENAME);
144 goto err;
145 }
146
136 /* A file specification may look like this: 147 /* A file specification may look like this:
137 * 148 *
138 * node::dev:[dir-spec]name.type;ver 149 * node::dev:[dir-spec]name.type;ver
@@ -174,14 +185,14 @@ static int vms_load(DSO *dso, const char *filename)
174 || (sp1 - filename) + strlen(sp2) > FILENAME_MAX) 185 || (sp1 - filename) + strlen(sp2) > FILENAME_MAX)
175 { 186 {
176 DSOerr(DSO_F_VMS_LOAD,DSO_R_FILENAME_TOO_BIG); 187 DSOerr(DSO_F_VMS_LOAD,DSO_R_FILENAME_TOO_BIG);
177 return(0); 188 goto err;
178 } 189 }
179 190
180 p = (DSO_VMS_INTERNAL *)OPENSSL_malloc(sizeof(DSO_VMS_INTERNAL)); 191 p = (DSO_VMS_INTERNAL *)OPENSSL_malloc(sizeof(DSO_VMS_INTERNAL));
181 if(p == NULL) 192 if(p == NULL)
182 { 193 {
183 DSOerr(DSO_F_VMS_LOAD,ERR_R_MALLOC_FAILURE); 194 DSOerr(DSO_F_VMS_LOAD,ERR_R_MALLOC_FAILURE);
184 return(0); 195 goto err;
185 } 196 }
186 197
187 strncpy(p->filename, sp1, sp2-sp1); 198 strncpy(p->filename, sp1, sp2-sp1);
@@ -203,10 +214,19 @@ static int vms_load(DSO *dso, const char *filename)
203 if(!sk_push(dso->meth_data, (char *)p)) 214 if(!sk_push(dso->meth_data, (char *)p))
204 { 215 {
205 DSOerr(DSO_F_VMS_LOAD,DSO_R_STACK_ERROR); 216 DSOerr(DSO_F_VMS_LOAD,DSO_R_STACK_ERROR);
206 OPENSSL_free(p); 217 goto err;
207 return(0);
208 } 218 }
219
220 /* Success (for now, we lie. We actually do not know...) */
221 dso->loaded_filename = filename;
209 return(1); 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);
210 } 230 }
211 231
212/* Note that this doesn't actually unload the shared image, as there is no 232/* Note that this doesn't actually unload the shared image, as there is no
@@ -259,8 +279,12 @@ void vms_bind_sym(DSO *dso, const char *symname, void **sym)
259 { 279 {
260 DSO_VMS_INTERNAL *ptr; 280 DSO_VMS_INTERNAL *ptr;
261 int status; 281 int status;
282#if 0
262 int flags = (1<<4); /* LIB$M_FIS_MIXEDCASE, but this symbol isn't 283 int flags = (1<<4); /* LIB$M_FIS_MIXEDCASE, but this symbol isn't
263 defined in VMS older than 7.0 or so */ 284 defined in VMS older than 7.0 or so */
285#else
286 int flags = 0;
287#endif
264 struct dsc$descriptor_s symname_dsc; 288 struct dsc$descriptor_s symname_dsc;
265 *sym = NULL; 289 *sym = NULL;
266 290
@@ -344,28 +368,12 @@ static DSO_FUNC_TYPE vms_bind_func(DSO *dso, const char *symname)
344 return sym; 368 return sym;
345 } 369 }
346 370
347static long vms_ctrl(DSO *dso, int cmd, long larg, void *parg) 371static char *vms_name_converter(DSO *dso, const char *filename)
348 { 372 {
349 if(dso == NULL) 373 int len = strlen(filename);
350 { 374 char *not_translated = OPENSSL_malloc(len+1);
351 DSOerr(DSO_F_VMS_CTRL,ERR_R_PASSED_NULL_PARAMETER); 375 strcpy(not_translated,filename);
352 return(-1); 376 return(not_translated);
353 } 377 }
354 switch(cmd) 378
355 { 379#endif /* OPENSSL_SYS_VMS */
356 case DSO_CTRL_GET_FLAGS:
357 return dso->flags;
358 case DSO_CTRL_SET_FLAGS:
359 dso->flags = (int)larg;
360 return(0);
361 case DSO_CTRL_OR_FLAGS:
362 dso->flags |= (int)larg;
363 return(0);
364 default:
365 break;
366 }
367 DSOerr(DSO_F_VMS_CTRL,DSO_R_UNKNOWN_COMMAND);
368 return(-1);
369 }
370
371#endif /* VMS */
diff --git a/src/lib/libcrypto/dso/dso_win32.c b/src/lib/libcrypto/dso/dso_win32.c
index 7f1d904806..af8586d754 100644
--- a/src/lib/libcrypto/dso/dso_win32.c
+++ b/src/lib/libcrypto/dso/dso_win32.c
@@ -61,7 +61,7 @@
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/dso.h> 62#include <openssl/dso.h>
63 63
64#ifndef WIN32 64#ifndef OPENSSL_SYS_WIN32
65DSO_METHOD *DSO_METHOD_win32(void) 65DSO_METHOD *DSO_METHOD_win32(void)
66 { 66 {
67 return NULL; 67 return NULL;
@@ -71,7 +71,7 @@ DSO_METHOD *DSO_METHOD_win32(void)
71/* Part of the hack in "win32_load" ... */ 71/* Part of the hack in "win32_load" ... */
72#define DSO_MAX_TRANSLATED_SIZE 256 72#define DSO_MAX_TRANSLATED_SIZE 256
73 73
74static int win32_load(DSO *dso, const char *filename); 74static int win32_load(DSO *dso);
75static int win32_unload(DSO *dso); 75static int win32_unload(DSO *dso);
76static void *win32_bind_var(DSO *dso, const char *symname); 76static void *win32_bind_var(DSO *dso, const char *symname);
77static DSO_FUNC_TYPE win32_bind_func(DSO *dso, const char *symname); 77static DSO_FUNC_TYPE win32_bind_func(DSO *dso, const char *symname);
@@ -80,8 +80,9 @@ static int win32_unbind_var(DSO *dso, char *symname, void *symptr);
80static int win32_unbind_func(DSO *dso, char *symname, DSO_FUNC_TYPE symptr); 80static int win32_unbind_func(DSO *dso, char *symname, DSO_FUNC_TYPE symptr);
81static int win32_init(DSO *dso); 81static int win32_init(DSO *dso);
82static int win32_finish(DSO *dso); 82static int win32_finish(DSO *dso);
83#endif
84static long win32_ctrl(DSO *dso, int cmd, long larg, void *parg); 83static long win32_ctrl(DSO *dso, int cmd, long larg, void *parg);
84#endif
85static char *win32_name_converter(DSO *dso, const char *filename);
85 86
86static DSO_METHOD dso_meth_win32 = { 87static DSO_METHOD dso_meth_win32 = {
87 "OpenSSL 'win32' shared library method", 88 "OpenSSL 'win32' shared library method",
@@ -94,7 +95,8 @@ static DSO_METHOD dso_meth_win32 = {
94 NULL, /* unbind_var */ 95 NULL, /* unbind_var */
95 NULL, /* unbind_func */ 96 NULL, /* unbind_func */
96#endif 97#endif
97 win32_ctrl, 98 NULL, /* ctrl */
99 win32_name_converter,
98 NULL, /* init */ 100 NULL, /* init */
99 NULL /* finish */ 101 NULL /* finish */
100 }; 102 };
@@ -109,50 +111,48 @@ DSO_METHOD *DSO_METHOD_win32(void)
109 * LoadLibrary(), and copied. 111 * LoadLibrary(), and copied.
110 */ 112 */
111 113
112static int win32_load(DSO *dso, const char *filename) 114static int win32_load(DSO *dso)
113 { 115 {
114 HINSTANCE h, *p; 116 HINSTANCE h = NULL, *p = NULL;
115 char translated[DSO_MAX_TRANSLATED_SIZE]; 117 /* See applicable comments from dso_dl.c */
116 int len; 118 char *filename = DSO_convert_filename(dso, NULL);
117 119
118 /* NB: This is a hideous hack, but I'm not yet sure what 120 if(filename == NULL)
119 * to replace it with. This attempts to convert any filename,
120 * that looks like it has no path information, into a
121 * translated form, e. "blah" -> "blah.dll" ... I'm more
122 * comfortable putting hacks into win32 code though ;-) */
123 len = strlen(filename);
124 if((dso->flags & DSO_FLAG_NAME_TRANSLATION) &&
125 (len + 4 < DSO_MAX_TRANSLATED_SIZE) &&
126 (strstr(filename, "/") == NULL) &&
127 (strstr(filename, "\\") == NULL) &&
128 (strstr(filename, ":") == NULL))
129 { 121 {
130 sprintf(translated, "%s.dll", filename); 122 DSOerr(DSO_F_WIN32_LOAD,DSO_R_NO_FILENAME);
131 h = LoadLibrary(translated); 123 goto err;
132 } 124 }
133 else 125 h = LoadLibrary(filename);
134 h = LoadLibrary(filename);
135 if(h == NULL) 126 if(h == NULL)
136 { 127 {
137 DSOerr(DSO_F_WIN32_LOAD,DSO_R_LOAD_FAILED); 128 DSOerr(DSO_F_WIN32_LOAD,DSO_R_LOAD_FAILED);
138 return(0); 129 ERR_add_error_data(3, "filename(", filename, ")");
130 goto err;
139 } 131 }
140 p = (HINSTANCE *)OPENSSL_malloc(sizeof(HINSTANCE)); 132 p = (HINSTANCE *)OPENSSL_malloc(sizeof(HINSTANCE));
141 if(p == NULL) 133 if(p == NULL)
142 { 134 {
143 DSOerr(DSO_F_WIN32_LOAD,ERR_R_MALLOC_FAILURE); 135 DSOerr(DSO_F_WIN32_LOAD,ERR_R_MALLOC_FAILURE);
144 FreeLibrary(h); 136 goto err;
145 return(0);
146 } 137 }
147 *p = h; 138 *p = h;
148 if(!sk_push(dso->meth_data, (char *)p)) 139 if(!sk_push(dso->meth_data, (char *)p))
149 { 140 {
150 DSOerr(DSO_F_WIN32_LOAD,DSO_R_STACK_ERROR); 141 DSOerr(DSO_F_WIN32_LOAD,DSO_R_STACK_ERROR);
151 FreeLibrary(h); 142 goto err;
152 OPENSSL_free(p);
153 return(0);
154 } 143 }
144 /* Success */
145 dso->loaded_filename = filename;
155 return(1); 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 } 156 }
157 157
158static int win32_unload(DSO *dso) 158static int win32_unload(DSO *dso)
@@ -211,6 +211,7 @@ static void *win32_bind_var(DSO *dso, const char *symname)
211 if(sym == NULL) 211 if(sym == NULL)
212 { 212 {
213 DSOerr(DSO_F_WIN32_BIND_VAR,DSO_R_SYM_FAILURE); 213 DSOerr(DSO_F_WIN32_BIND_VAR,DSO_R_SYM_FAILURE);
214 ERR_add_error_data(3, "symname(", symname, ")");
214 return(NULL); 215 return(NULL);
215 } 216 }
216 return(sym); 217 return(sym);
@@ -241,33 +242,38 @@ static DSO_FUNC_TYPE win32_bind_func(DSO *dso, const char *symname)
241 if(sym == NULL) 242 if(sym == NULL)
242 { 243 {
243 DSOerr(DSO_F_WIN32_BIND_FUNC,DSO_R_SYM_FAILURE); 244 DSOerr(DSO_F_WIN32_BIND_FUNC,DSO_R_SYM_FAILURE);
245 ERR_add_error_data(3, "symname(", symname, ")");
244 return(NULL); 246 return(NULL);
245 } 247 }
246 return((DSO_FUNC_TYPE)sym); 248 return((DSO_FUNC_TYPE)sym);
247 } 249 }
248 250
249static long win32_ctrl(DSO *dso, int cmd, long larg, void *parg) 251static char *win32_name_converter(DSO *dso, const char *filename)
250 { 252 {
251 if(dso == NULL) 253 char *translated;
252 { 254 int len, transform;
253 DSOerr(DSO_F_WIN32_CTRL,ERR_R_PASSED_NULL_PARAMETER); 255
254 return(-1); 256 len = strlen(filename);
255 } 257 transform = ((strstr(filename, "/") == NULL) &&
256 switch(cmd) 258 (strstr(filename, "\\") == NULL) &&
257 { 259 (strstr(filename, ":") == NULL));
258 case DSO_CTRL_GET_FLAGS: 260 if(transform)
259 return dso->flags; 261 /* We will convert this to "%s.dll" */
260 case DSO_CTRL_SET_FLAGS: 262 translated = OPENSSL_malloc(len + 5);
261 dso->flags = (int)larg; 263 else
262 return(0); 264 /* We will simply duplicate filename */
263 case DSO_CTRL_OR_FLAGS: 265 translated = OPENSSL_malloc(len + 1);
264 dso->flags |= (int)larg; 266 if(translated == NULL)
265 return(0); 267 {
266 default: 268 DSOerr(DSO_F_WIN32_NAME_CONVERTER,
267 break; 269 DSO_R_NAME_TRANSLATION_FAILED);
268 } 270 return(NULL);
269 DSOerr(DSO_F_WIN32_CTRL,DSO_R_UNKNOWN_COMMAND); 271 }
270 return(-1); 272 if(transform)
271 } 273 sprintf(translated, "%s.dll", filename);
274 else
275 sprintf(translated, "%s", filename);
276 return(translated);
277 }
272 278
273#endif /* WIN32 */ 279#endif /* OPENSSL_SYS_WIN32 */
diff --git a/src/lib/libcrypto/ebcdic.c b/src/lib/libcrypto/ebcdic.c
index 91a7a8bcb4..bc968ea807 100644
--- a/src/lib/libcrypto/ebcdic.c
+++ b/src/lib/libcrypto/ebcdic.c
@@ -211,7 +211,8 @@ ascii2ebcdic(void *dest, const void *srce, size_t count)
211} 211}
212 212
213#else /*CHARSET_EBCDIC*/ 213#else /*CHARSET_EBCDIC*/
214#if defined(PEDANTIC) || defined(VMS) || defined(__VMS) 214#include <openssl/opensslconf.h>
215#if defined(PEDANTIC) || defined(__DECC)
215static void *dummy=&dummy; 216static void *dummy=&dummy;
216#endif 217#endif
217#endif 218#endif
diff --git a/src/lib/libcrypto/ec/Makefile.ssl b/src/lib/libcrypto/ec/Makefile.ssl
new file mode 100644
index 0000000000..7a21b7195f
--- /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 @$(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) $(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
new file mode 100644
index 0000000000..a52d4edf14
--- /dev/null
+++ b/src/lib/libcrypto/ec/ec.h
@@ -0,0 +1,245 @@
1/* crypto/ec/ec.h */
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#ifndef HEADER_EC_H
57#define HEADER_EC_H
58
59#ifdef OPENSSL_NO_EC
60#error EC is disabled.
61#endif
62
63#include <openssl/bn.h>
64#include <openssl/symhacks.h>
65
66#ifdef __cplusplus
67extern "C" {
68#endif
69
70
71typedef enum {
72 /* values as defined in X9.62 (ECDSA) and elsewhere */
73 POINT_CONVERSION_COMPRESSED = 2,
74 POINT_CONVERSION_UNCOMPRESSED = 4,
75 POINT_CONVERSION_HYBRID = 6
76} point_conversion_form_t;
77
78
79typedef struct ec_method_st EC_METHOD;
80
81typedef struct ec_group_st
82 /*
83 EC_METHOD *meth;
84 -- field definition
85 -- curve coefficients
86 -- optional generator with associated information (order, cofactor)
87 -- optional extra data (TODO: precomputed table for fast computation of multiples of generator)
88 */
89 EC_GROUP;
90
91typedef struct ec_point_st EC_POINT;
92
93
94/* EC_METHODs for curves over GF(p).
95 * EC_GFp_simple_method provides the basis for the optimized methods.
96 */
97const EC_METHOD *EC_GFp_simple_method(void);
98const EC_METHOD *EC_GFp_mont_method(void);
99#if 0
100const EC_METHOD *EC_GFp_recp_method(void); /* TODO */
101const EC_METHOD *EC_GFp_nist_method(void); /* TODO */
102#endif
103
104
105EC_GROUP *EC_GROUP_new(const EC_METHOD *);
106void EC_GROUP_free(EC_GROUP *);
107void EC_GROUP_clear_free(EC_GROUP *);
108int EC_GROUP_copy(EC_GROUP *, const EC_GROUP *);
109
110const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *);
111
112
113/* We don't have types for field specifications and field elements in general.
114 * Otherwise we could declare
115 * int EC_GROUP_set_curve(EC_GROUP *, .....);
116 */
117int EC_GROUP_set_curve_GFp(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *);
118int EC_GROUP_get_curve_GFp(const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *);
119
120/* EC_GROUP_new_GFp() calls EC_GROUP_new() and EC_GROUP_set_GFp()
121 * after choosing an appropriate EC_METHOD */
122EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *);
123
124int EC_GROUP_set_generator(EC_GROUP *, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor);
125EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *);
126int EC_GROUP_get_order(const EC_GROUP *, BIGNUM *order, BN_CTX *);
127int EC_GROUP_get_cofactor(const EC_GROUP *, BIGNUM *cofactor, BN_CTX *);
128
129EC_POINT *EC_POINT_new(const EC_GROUP *);
130void EC_POINT_free(EC_POINT *);
131void EC_POINT_clear_free(EC_POINT *);
132int EC_POINT_copy(EC_POINT *, const EC_POINT *);
133
134const EC_METHOD *EC_POINT_method_of(const EC_POINT *);
135
136int EC_POINT_set_to_infinity(const EC_GROUP *, EC_POINT *);
137int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *, EC_POINT *,
138 const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *);
139int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *, const EC_POINT *,
140 BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *);
141int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *, EC_POINT *,
142 const BIGNUM *x, const BIGNUM *y, BN_CTX *);
143int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *, const EC_POINT *,
144 BIGNUM *x, BIGNUM *y, BN_CTX *);
145int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *, EC_POINT *,
146 const BIGNUM *x, int y_bit, BN_CTX *);
147
148size_t EC_POINT_point2oct(const EC_GROUP *, const EC_POINT *, point_conversion_form_t form,
149 unsigned char *buf, size_t len, BN_CTX *);
150int EC_POINT_oct2point(const EC_GROUP *, EC_POINT *,
151 const unsigned char *buf, size_t len, BN_CTX *);
152
153int EC_POINT_add(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *);
154int EC_POINT_dbl(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, BN_CTX *);
155int EC_POINT_invert(const EC_GROUP *, EC_POINT *, BN_CTX *);
156
157int EC_POINT_is_at_infinity(const EC_GROUP *, const EC_POINT *);
158int EC_POINT_is_on_curve(const EC_GROUP *, const EC_POINT *, BN_CTX *);
159int EC_POINT_cmp(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b, BN_CTX *);
160
161int EC_POINT_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *);
162int EC_POINTs_make_affine(const EC_GROUP *, size_t num, EC_POINT *[], BN_CTX *);
163
164
165int EC_POINTs_mul(const EC_GROUP *, EC_POINT *r, const BIGNUM *, size_t num, const EC_POINT *[], const BIGNUM *[], BN_CTX *);
166int EC_POINT_mul(const EC_GROUP *, EC_POINT *r, const BIGNUM *, const EC_POINT *, const BIGNUM *, BN_CTX *);
167int EC_GROUP_precompute_mult(EC_GROUP *, BN_CTX *);
168
169
170
171/* BEGIN ERROR CODES */
172/* The following lines are auto generated by the script mkerr.pl. Any changes
173 * made after this point may be overwritten when the script is next run.
174 */
175void ERR_load_EC_strings(void);
176
177/* Error codes for the EC functions. */
178
179/* Function codes. */
180#define EC_F_COMPUTE_WNAF 143
181#define EC_F_EC_GFP_MONT_FIELD_DECODE 133
182#define EC_F_EC_GFP_MONT_FIELD_ENCODE 134
183#define EC_F_EC_GFP_MONT_FIELD_MUL 131
184#define EC_F_EC_GFP_MONT_FIELD_SQR 132
185#define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE_GFP 100
186#define EC_F_EC_GFP_SIMPLE_GROUP_SET_GENERATOR 101
187#define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE 102
188#define EC_F_EC_GFP_SIMPLE_OCT2POINT 103
189#define EC_F_EC_GFP_SIMPLE_POINT2OCT 104
190#define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE 137
191#define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES_GFP 105
192#define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES_GFP 128
193#define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP 129
194#define EC_F_EC_GROUP_COPY 106
195#define EC_F_EC_GROUP_GET0_GENERATOR 139
196#define EC_F_EC_GROUP_GET_COFACTOR 140
197#define EC_F_EC_GROUP_GET_CURVE_GFP 130
198#define EC_F_EC_GROUP_GET_EXTRA_DATA 107
199#define EC_F_EC_GROUP_GET_ORDER 141
200#define EC_F_EC_GROUP_NEW 108
201#define EC_F_EC_GROUP_PRECOMPUTE_MULT 142
202#define EC_F_EC_GROUP_SET_CURVE_GFP 109
203#define EC_F_EC_GROUP_SET_EXTRA_DATA 110
204#define EC_F_EC_GROUP_SET_GENERATOR 111
205#define EC_F_EC_POINTS_MAKE_AFFINE 136
206#define EC_F_EC_POINTS_MUL 138
207#define EC_F_EC_POINT_ADD 112
208#define EC_F_EC_POINT_CMP 113
209#define EC_F_EC_POINT_COPY 114
210#define EC_F_EC_POINT_DBL 115
211#define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP 116
212#define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP 117
213#define EC_F_EC_POINT_IS_AT_INFINITY 118
214#define EC_F_EC_POINT_IS_ON_CURVE 119
215#define EC_F_EC_POINT_MAKE_AFFINE 120
216#define EC_F_EC_POINT_NEW 121
217#define EC_F_EC_POINT_OCT2POINT 122
218#define EC_F_EC_POINT_POINT2OCT 123
219#define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP 124
220#define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP 125
221#define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP 126
222#define EC_F_EC_POINT_SET_TO_INFINITY 127
223#define EC_F_GFP_MONT_GROUP_SET_CURVE_GFP 135
224
225/* Reason codes. */
226#define EC_R_BUFFER_TOO_SMALL 100
227#define EC_R_INCOMPATIBLE_OBJECTS 101
228#define EC_R_INVALID_ARGUMENT 112
229#define EC_R_INVALID_COMPRESSED_POINT 110
230#define EC_R_INVALID_COMPRESSION_BIT 109
231#define EC_R_INVALID_ENCODING 102
232#define EC_R_INVALID_FIELD 103
233#define EC_R_INVALID_FORM 104
234#define EC_R_NOT_INITIALIZED 111
235#define EC_R_NO_SUCH_EXTRA_DATA 105
236#define EC_R_POINT_AT_INFINITY 106
237#define EC_R_POINT_IS_NOT_ON_CURVE 107
238#define EC_R_SLOT_FULL 108
239#define EC_R_UNDEFINED_GENERATOR 113
240#define EC_R_UNKNOWN_ORDER 114
241
242#ifdef __cplusplus
243}
244#endif
245#endif
diff --git a/src/lib/libcrypto/ec/ec_cvt.c b/src/lib/libcrypto/ec/ec_cvt.c
new file mode 100644
index 0000000000..45b0ec33a0
--- /dev/null
+++ b/src/lib/libcrypto/ec/ec_cvt.c
@@ -0,0 +1,80 @@
1/* crypto/ec/ec_cvt.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
59EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
60 {
61 const EC_METHOD *meth;
62 EC_GROUP *ret;
63
64 /* Finally, this will use EC_GFp_nist_method if 'p' is a special
65 * prime with optimized modular arithmetics (for NIST curves)
66 */
67 meth = EC_GFp_mont_method();
68
69 ret = EC_GROUP_new(meth);
70 if (ret == NULL)
71 return NULL;
72
73 if (!EC_GROUP_set_curve_GFp(ret, p, a, b, ctx))
74 {
75 EC_GROUP_clear_free(ret);
76 return NULL;
77 }
78
79 return ret;
80 }
diff --git a/src/lib/libcrypto/ec/ec_err.c b/src/lib/libcrypto/ec/ec_err.c
new file mode 100644
index 0000000000..394cdc021f
--- /dev/null
+++ b/src/lib/libcrypto/ec/ec_err.c
@@ -0,0 +1,151 @@
1/* crypto/ec/ec_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 <openssl/ec.h>
64
65/* BEGIN ERROR CODES */
66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA EC_str_functs[]=
68 {
69{ERR_PACK(0,EC_F_COMPUTE_WNAF,0), "COMPUTE_WNAF"},
70{ERR_PACK(0,EC_F_EC_GFP_MONT_FIELD_DECODE,0), "ec_GFp_mont_field_decode"},
71{ERR_PACK(0,EC_F_EC_GFP_MONT_FIELD_ENCODE,0), "ec_GFp_mont_field_encode"},
72{ERR_PACK(0,EC_F_EC_GFP_MONT_FIELD_MUL,0), "ec_GFp_mont_field_mul"},
73{ERR_PACK(0,EC_F_EC_GFP_MONT_FIELD_SQR,0), "ec_GFp_mont_field_sqr"},
74{ERR_PACK(0,EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE_GFP,0), "ec_GFp_simple_group_set_curve_GFp"},
75{ERR_PACK(0,EC_F_EC_GFP_SIMPLE_GROUP_SET_GENERATOR,0), "ec_GFp_simple_group_set_generator"},
76{ERR_PACK(0,EC_F_EC_GFP_SIMPLE_MAKE_AFFINE,0), "ec_GFp_simple_make_affine"},
77{ERR_PACK(0,EC_F_EC_GFP_SIMPLE_OCT2POINT,0), "ec_GFp_simple_oct2point"},
78{ERR_PACK(0,EC_F_EC_GFP_SIMPLE_POINT2OCT,0), "ec_GFp_simple_point2oct"},
79{ERR_PACK(0,EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE,0), "ec_GFp_simple_points_make_affine"},
80{ERR_PACK(0,EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES_GFP,0), "ec_GFp_simple_point_get_affine_coordinates_GFp"},
81{ERR_PACK(0,EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES_GFP,0), "ec_GFp_simple_point_set_affine_coordinates_GFp"},
82{ERR_PACK(0,EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP,0), "ec_GFp_simple_set_compressed_coordinates_GFp"},
83{ERR_PACK(0,EC_F_EC_GROUP_COPY,0), "EC_GROUP_copy"},
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"},
86{ERR_PACK(0,EC_F_EC_GROUP_GET_CURVE_GFP,0), "EC_GROUP_get_curve_GFp"},
87{ERR_PACK(0,EC_F_EC_GROUP_GET_EXTRA_DATA,0), "EC_GROUP_get_extra_data"},
88{ERR_PACK(0,EC_F_EC_GROUP_GET_ORDER,0), "EC_GROUP_get_order"},
89{ERR_PACK(0,EC_F_EC_GROUP_NEW,0), "EC_GROUP_new"},
90{ERR_PACK(0,EC_F_EC_GROUP_PRECOMPUTE_MULT,0), "EC_GROUP_precompute_mult"},
91{ERR_PACK(0,EC_F_EC_GROUP_SET_CURVE_GFP,0), "EC_GROUP_set_curve_GFp"},
92{ERR_PACK(0,EC_F_EC_GROUP_SET_EXTRA_DATA,0), "EC_GROUP_set_extra_data"},
93{ERR_PACK(0,EC_F_EC_GROUP_SET_GENERATOR,0), "EC_GROUP_set_generator"},
94{ERR_PACK(0,EC_F_EC_POINTS_MAKE_AFFINE,0), "EC_POINTs_make_affine"},
95{ERR_PACK(0,EC_F_EC_POINTS_MUL,0), "EC_POINTs_mul"},
96{ERR_PACK(0,EC_F_EC_POINT_ADD,0), "EC_POINT_add"},
97{ERR_PACK(0,EC_F_EC_POINT_CMP,0), "EC_POINT_cmp"},
98{ERR_PACK(0,EC_F_EC_POINT_COPY,0), "EC_POINT_copy"},
99{ERR_PACK(0,EC_F_EC_POINT_DBL,0), "EC_POINT_dbl"},
100{ERR_PACK(0,EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP,0), "EC_POINT_get_affine_coordinates_GFp"},
101{ERR_PACK(0,EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP,0), "EC_POINT_get_Jprojective_coordinates_GFp"},
102{ERR_PACK(0,EC_F_EC_POINT_IS_AT_INFINITY,0), "EC_POINT_is_at_infinity"},
103{ERR_PACK(0,EC_F_EC_POINT_IS_ON_CURVE,0), "EC_POINT_is_on_curve"},
104{ERR_PACK(0,EC_F_EC_POINT_MAKE_AFFINE,0), "EC_POINT_make_affine"},
105{ERR_PACK(0,EC_F_EC_POINT_NEW,0), "EC_POINT_new"},
106{ERR_PACK(0,EC_F_EC_POINT_OCT2POINT,0), "EC_POINT_oct2point"},
107{ERR_PACK(0,EC_F_EC_POINT_POINT2OCT,0), "EC_POINT_point2oct"},
108{ERR_PACK(0,EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP,0), "EC_POINT_set_affine_coordinates_GFp"},
109{ERR_PACK(0,EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP,0), "EC_POINT_set_compressed_coordinates_GFp"},
110{ERR_PACK(0,EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP,0), "EC_POINT_set_Jprojective_coordinates_GFp"},
111{ERR_PACK(0,EC_F_EC_POINT_SET_TO_INFINITY,0), "EC_POINT_set_to_infinity"},
112{ERR_PACK(0,EC_F_GFP_MONT_GROUP_SET_CURVE_GFP,0), "GFP_MONT_GROUP_SET_CURVE_GFP"},
113{0,NULL}
114 };
115
116static ERR_STRING_DATA EC_str_reasons[]=
117 {
118{EC_R_BUFFER_TOO_SMALL ,"buffer too small"},
119{EC_R_INCOMPATIBLE_OBJECTS ,"incompatible objects"},
120{EC_R_INVALID_ARGUMENT ,"invalid argument"},
121{EC_R_INVALID_COMPRESSED_POINT ,"invalid compressed point"},
122{EC_R_INVALID_COMPRESSION_BIT ,"invalid compression bit"},
123{EC_R_INVALID_ENCODING ,"invalid encoding"},
124{EC_R_INVALID_FIELD ,"invalid field"},
125{EC_R_INVALID_FORM ,"invalid form"},
126{EC_R_NOT_INITIALIZED ,"not initialized"},
127{EC_R_NO_SUCH_EXTRA_DATA ,"no such extra data"},
128{EC_R_POINT_AT_INFINITY ,"point at infinity"},
129{EC_R_POINT_IS_NOT_ON_CURVE ,"point is not on curve"},
130{EC_R_SLOT_FULL ,"slot full"},
131{EC_R_UNDEFINED_GENERATOR ,"undefined generator"},
132{EC_R_UNKNOWN_ORDER ,"unknown order"},
133{0,NULL}
134 };
135
136#endif
137
138void ERR_load_EC_strings(void)
139 {
140 static int init=1;
141
142 if (init)
143 {
144 init=0;
145#ifndef OPENSSL_NO_ERR
146 ERR_load_strings(ERR_LIB_EC,EC_str_functs);
147 ERR_load_strings(ERR_LIB_EC,EC_str_reasons);
148#endif
149
150 }
151 }
diff --git a/src/lib/libcrypto/ec/ec_lcl.h b/src/lib/libcrypto/ec/ec_lcl.h
new file mode 100644
index 0000000000..cc4cf27755
--- /dev/null
+++ b/src/lib/libcrypto/ec/ec_lcl.h
@@ -0,0 +1,277 @@
1/* crypto/ec/ec_lcl.h */
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
57#include <stdlib.h>
58
59#include <openssl/ec.h>
60
61
62/* Structure details are not part of the exported interface,
63 * so all this may change in future versions. */
64
65struct ec_method_st {
66 /* used by EC_GROUP_new, EC_GROUP_free, EC_GROUP_clear_free, EC_GROUP_copy: */
67 int (*group_init)(EC_GROUP *);
68 void (*group_finish)(EC_GROUP *);
69 void (*group_clear_finish)(EC_GROUP *);
70 int (*group_copy)(EC_GROUP *, const EC_GROUP *);
71
72 /* used by EC_GROUP_set_curve_GFp and EC_GROUP_get_curve_GFp: */
73 int (*group_set_curve_GFp)(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *);
74 int (*group_get_curve_GFp)(const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *);
75
76 /* used by EC_GROUP_set_generator, EC_GROUP_get0_generator,
77 * EC_GROUP_get_order, EC_GROUP_get_cofactor:
78 */
79 int (*group_set_generator)(EC_GROUP *, const EC_POINT *generator,
80 const BIGNUM *order, const BIGNUM *cofactor);
81 EC_POINT *(*group_get0_generator)(const EC_GROUP *);
82 int (*group_get_order)(const EC_GROUP *, BIGNUM *order, BN_CTX *);
83 int (*group_get_cofactor)(const EC_GROUP *, BIGNUM *cofactor, BN_CTX *);
84
85 /* used by EC_POINT_new, EC_POINT_free, EC_POINT_clear_free, EC_POINT_copy: */
86 int (*point_init)(EC_POINT *);
87 void (*point_finish)(EC_POINT *);
88 void (*point_clear_finish)(EC_POINT *);
89 int (*point_copy)(EC_POINT *, const EC_POINT *);
90
91 /* used by EC_POINT_set_to_infinity,
92 * EC_POINT_set_Jprojective_coordinates_GFp, EC_POINT_get_Jprojective_coordinates_GFp,
93 * EC_POINT_set_affine_coordinates_GFp, EC_POINT_get_affine_coordinates_GFp,
94 * EC_POINT_set_compressed_coordinates_GFp:
95 */
96 int (*point_set_to_infinity)(const EC_GROUP *, EC_POINT *);
97 int (*point_set_Jprojective_coordinates_GFp)(const EC_GROUP *, EC_POINT *,
98 const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *);
99 int (*point_get_Jprojective_coordinates_GFp)(const EC_GROUP *, const EC_POINT *,
100 BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *);
101 int (*point_set_affine_coordinates_GFp)(const EC_GROUP *, EC_POINT *,
102 const BIGNUM *x, const BIGNUM *y, BN_CTX *);
103 int (*point_get_affine_coordinates_GFp)(const EC_GROUP *, const EC_POINT *,
104 BIGNUM *x, BIGNUM *y, BN_CTX *);
105 int (*point_set_compressed_coordinates_GFp)(const EC_GROUP *, EC_POINT *,
106 const BIGNUM *x, int y_bit, BN_CTX *);
107
108 /* used by EC_POINT_point2oct, EC_POINT_oct2point: */
109 size_t (*point2oct)(const EC_GROUP *, const EC_POINT *, point_conversion_form_t form,
110 unsigned char *buf, size_t len, BN_CTX *);
111 int (*oct2point)(const EC_GROUP *, EC_POINT *,
112 const unsigned char *buf, size_t len, BN_CTX *);
113
114 /* used by EC_POINT_add, EC_POINT_dbl, ECP_POINT_invert: */
115 int (*add)(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *);
116 int (*dbl)(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, BN_CTX *);
117 int (*invert)(const EC_GROUP *, EC_POINT *, BN_CTX *);
118
119 /* used by EC_POINT_is_at_infinity, EC_POINT_is_on_curve, EC_POINT_cmp: */
120 int (*is_at_infinity)(const EC_GROUP *, const EC_POINT *);
121 int (*is_on_curve)(const EC_GROUP *, const EC_POINT *, BN_CTX *);
122 int (*point_cmp)(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b, BN_CTX *);
123
124 /* used by EC_POINT_make_affine, EC_POINTs_make_affine: */
125 int (*make_affine)(const EC_GROUP *, EC_POINT *, BN_CTX *);
126 int (*points_make_affine)(const EC_GROUP *, size_t num, EC_POINT *[], BN_CTX *);
127
128
129 /* internal functions */
130
131 /* 'field_mul' and 'field_sqr' can be used by 'add' and 'dbl' so that
132 * the same implementations of point operations can be used with different
133 * optimized implementations of expensive field operations: */
134 int (*field_mul)(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *);
135 int (*field_sqr)(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *);
136
137 int (*field_encode)(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *); /* e.g. to Montgomery */
138 int (*field_decode)(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *); /* e.g. from Montgomery */
139 int (*field_set_to_one)(const EC_GROUP *, BIGNUM *r, BN_CTX *);
140} /* EC_METHOD */;
141
142
143struct ec_group_st {
144 const EC_METHOD *meth;
145
146 void *extra_data;
147 void *(*extra_data_dup_func)(void *);
148 void (*extra_data_free_func)(void *);
149 void (*extra_data_clear_free_func)(void *);
150
151 /* All members except 'meth' and 'extra_data...' are handled by
152 * the method functions, even if they appear generic */
153
154 BIGNUM field; /* Field specification.
155 * For curves over GF(p), this is the modulus. */
156
157 BIGNUM a, b; /* Curve coefficients.
158 * (Here the assumption is that BIGNUMs can be used
159 * or abused for all kinds of fields, not just GF(p).)
160 * For characteristic > 3, the curve is defined
161 * by a Weierstrass equation of the form
162 * y^2 = x^3 + a*x + b.
163 */
164 int a_is_minus3; /* enable optimized point arithmetics for special case */
165
166 EC_POINT *generator; /* optional */
167 BIGNUM order, cofactor;
168
169 void *field_data1; /* method-specific (e.g., Montgomery structure) */
170 void *field_data2; /* method-specific */
171} /* EC_GROUP */;
172
173
174/* Basically a 'mixin' for extra data, but available for EC_GROUPs only
175 * (with visibility limited to 'package' level for now).
176 * We use the function pointers as index for retrieval; this obviates
177 * global ex_data-style index tables.
178 * (Currently, we have one slot only, but is is possible to extend this
179 * if necessary.) */
180int EC_GROUP_set_extra_data(EC_GROUP *, void *extra_data, void *(*extra_data_dup_func)(void *),
181 void (*extra_data_free_func)(void *), void (*extra_data_clear_free_func)(void *));
182void *EC_GROUP_get_extra_data(const EC_GROUP *, void *(*extra_data_dup_func)(void *),
183 void (*extra_data_free_func)(void *), void (*extra_data_clear_free_func)(void *));
184void EC_GROUP_free_extra_data(EC_GROUP *);
185void EC_GROUP_clear_free_extra_data(EC_GROUP *);
186
187
188
189struct ec_point_st {
190 const EC_METHOD *meth;
191
192 /* All members except 'meth' are handled by the method functions,
193 * even if they appear generic */
194
195 BIGNUM X;
196 BIGNUM Y;
197 BIGNUM Z; /* Jacobian projective coordinates:
198 * (X, Y, Z) represents (X/Z^2, Y/Z^3) if Z != 0 */
199 int Z_is_one; /* enable optimized point arithmetics for special case */
200} /* EC_POINT */;
201
202
203
204/* method functions in ecp_smpl.c */
205int ec_GFp_simple_group_init(EC_GROUP *);
206void ec_GFp_simple_group_finish(EC_GROUP *);
207void ec_GFp_simple_group_clear_finish(EC_GROUP *);
208int ec_GFp_simple_group_copy(EC_GROUP *, const EC_GROUP *);
209int ec_GFp_simple_group_set_curve_GFp(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *);
210int ec_GFp_simple_group_get_curve_GFp(const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *);
211int ec_GFp_simple_group_set_generator(EC_GROUP *, const EC_POINT *generator,
212 const BIGNUM *order, const BIGNUM *cofactor);
213EC_POINT *ec_GFp_simple_group_get0_generator(const EC_GROUP *);
214int ec_GFp_simple_group_get_order(const EC_GROUP *, BIGNUM *order, BN_CTX *);
215int ec_GFp_simple_group_get_cofactor(const EC_GROUP *, BIGNUM *cofactor, BN_CTX *);
216int ec_GFp_simple_point_init(EC_POINT *);
217void ec_GFp_simple_point_finish(EC_POINT *);
218void ec_GFp_simple_point_clear_finish(EC_POINT *);
219int ec_GFp_simple_point_copy(EC_POINT *, const EC_POINT *);
220int ec_GFp_simple_point_set_to_infinity(const EC_GROUP *, EC_POINT *);
221int ec_GFp_simple_set_Jprojective_coordinates_GFp(const EC_GROUP *, EC_POINT *,
222 const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *);
223int ec_GFp_simple_get_Jprojective_coordinates_GFp(const EC_GROUP *, const EC_POINT *,
224 BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *);
225int ec_GFp_simple_point_set_affine_coordinates_GFp(const EC_GROUP *, EC_POINT *,
226 const BIGNUM *x, const BIGNUM *y, BN_CTX *);
227int ec_GFp_simple_point_get_affine_coordinates_GFp(const EC_GROUP *, const EC_POINT *,
228 BIGNUM *x, BIGNUM *y, BN_CTX *);
229int ec_GFp_simple_set_compressed_coordinates_GFp(const EC_GROUP *, EC_POINT *,
230 const BIGNUM *x, int y_bit, BN_CTX *);
231size_t ec_GFp_simple_point2oct(const EC_GROUP *, const EC_POINT *, point_conversion_form_t form,
232 unsigned char *buf, size_t len, BN_CTX *);
233int ec_GFp_simple_oct2point(const EC_GROUP *, EC_POINT *,
234 const unsigned char *buf, size_t len, BN_CTX *);
235int ec_GFp_simple_add(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *);
236int ec_GFp_simple_dbl(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, BN_CTX *);
237int ec_GFp_simple_invert(const EC_GROUP *, EC_POINT *, BN_CTX *);
238int ec_GFp_simple_is_at_infinity(const EC_GROUP *, const EC_POINT *);
239int ec_GFp_simple_is_on_curve(const EC_GROUP *, const EC_POINT *, BN_CTX *);
240int ec_GFp_simple_cmp(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b, BN_CTX *);
241int ec_GFp_simple_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *);
242int ec_GFp_simple_points_make_affine(const EC_GROUP *, size_t num, EC_POINT *[], BN_CTX *);
243int ec_GFp_simple_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *);
244int ec_GFp_simple_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *);
245
246
247/* method functions in ecp_mont.c */
248int ec_GFp_mont_group_init(EC_GROUP *);
249int ec_GFp_mont_group_set_curve_GFp(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *);
250void ec_GFp_mont_group_finish(EC_GROUP *);
251void ec_GFp_mont_group_clear_finish(EC_GROUP *);
252int ec_GFp_mont_group_copy(EC_GROUP *, const EC_GROUP *);
253int ec_GFp_mont_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *);
254int ec_GFp_mont_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *);
255int ec_GFp_mont_field_encode(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *);
256int ec_GFp_mont_field_decode(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *);
257int ec_GFp_mont_field_set_to_one(const EC_GROUP *, BIGNUM *r, BN_CTX *);
258
259
260/* method functions in ecp_recp.c */
261int ec_GFp_recp_group_init(EC_GROUP *);
262int ec_GFp_recp_group_set_curve_GFp(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *);
263void ec_GFp_recp_group_finish(EC_GROUP *);
264void ec_GFp_recp_group_clear_finish(EC_GROUP *);
265int ec_GFp_recp_group_copy(EC_GROUP *, const EC_GROUP *);
266int ec_GFp_recp_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *);
267int ec_GFp_recp_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *);
268
269
270/* method functions in ecp_nist.c */
271int ec_GFp_nist_group_init(EC_GROUP *);
272int ec_GFp_nist_group_set_curve_GFp(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *);
273void ec_GFp_nist_group_finish(EC_GROUP *);
274void ec_GFp_nist_group_clear_finish(EC_GROUP *);
275int ec_GFp_nist_group_copy(EC_GROUP *, const EC_GROUP *);
276int ec_GFp_nist_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *);
277int ec_GFp_nist_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *);
diff --git a/src/lib/libcrypto/ec/ec_lib.c b/src/lib/libcrypto/ec/ec_lib.c
new file mode 100644
index 0000000000..e0d78d67fb
--- /dev/null
+++ b/src/lib/libcrypto/ec/ec_lib.c
@@ -0,0 +1,646 @@
1/* crypto/ec/ec_lib.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 <string.h>
57
58#include <openssl/err.h>
59#include <openssl/opensslv.h>
60
61#include "ec_lcl.h"
62
63static const char EC_version[] = "EC" OPENSSL_VERSION_PTEXT;
64
65
66/* functions for EC_GROUP objects */
67
68EC_GROUP *EC_GROUP_new(const EC_METHOD *meth)
69 {
70 EC_GROUP *ret;
71
72 if (meth == NULL)
73 {
74 ECerr(EC_F_EC_GROUP_NEW, ERR_R_PASSED_NULL_PARAMETER);
75 return NULL;
76 }
77 if (meth->group_init == 0)
78 {
79 ECerr(EC_F_EC_GROUP_NEW, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
80 return NULL;
81 }
82
83 ret = OPENSSL_malloc(sizeof *ret);
84 if (ret == NULL)
85 {
86 ECerr(EC_F_EC_GROUP_NEW, ERR_R_MALLOC_FAILURE);
87 return NULL;
88 }
89
90 ret->meth = meth;
91
92 ret->extra_data = NULL;
93 ret->extra_data_dup_func = 0;
94 ret->extra_data_free_func = 0;
95 ret->extra_data_clear_free_func = 0;
96
97 if (!meth->group_init(ret))
98 {
99 OPENSSL_free(ret);
100 return NULL;
101 }
102
103 return ret;
104 }
105
106
107void EC_GROUP_free(EC_GROUP *group)
108 {
109 if (group->meth->group_finish != 0)
110 group->meth->group_finish(group);
111
112 EC_GROUP_free_extra_data(group);
113
114 OPENSSL_free(group);
115 }
116
117
118void EC_GROUP_clear_free(EC_GROUP *group)
119 {
120 if (group->meth->group_clear_finish != 0)
121 group->meth->group_clear_finish(group);
122 else if (group->meth != NULL && group->meth->group_finish != 0)
123 group->meth->group_finish(group);
124
125 EC_GROUP_clear_free_extra_data(group);
126
127 memset(group, 0, sizeof *group);
128 OPENSSL_free(group);
129 }
130
131
132int EC_GROUP_copy(EC_GROUP *dest, const EC_GROUP *src)
133 {
134 if (dest->meth->group_copy == 0)
135 {
136 ECerr(EC_F_EC_GROUP_COPY, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
137 return 0;
138 }
139 if (dest->meth != src->meth)
140 {
141 ECerr(EC_F_EC_GROUP_COPY, EC_R_INCOMPATIBLE_OBJECTS);
142 return 0;
143 }
144 if (dest == src)
145 return 1;
146
147 EC_GROUP_clear_free_extra_data(dest);
148 if (src->extra_data_dup_func)
149 {
150 if (src->extra_data != NULL)
151 {
152 dest->extra_data = src->extra_data_dup_func(src->extra_data);
153 if (dest->extra_data == NULL)
154 return 0;
155 }
156
157 dest->extra_data_dup_func = src->extra_data_dup_func;
158 dest->extra_data_free_func = src->extra_data_free_func;
159 dest->extra_data_clear_free_func = src->extra_data_clear_free_func;
160 }
161
162 return dest->meth->group_copy(dest, src);
163 }
164
165
166const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group)
167 {
168 return group->meth;
169 }
170
171
172int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
173 {
174 if (group->meth->group_set_curve_GFp == 0)
175 {
176 ECerr(EC_F_EC_GROUP_SET_CURVE_GFP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
177 return 0;
178 }
179 return group->meth->group_set_curve_GFp(group, p, a, b, ctx);
180 }
181
182
183int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx)
184 {
185 if (group->meth->group_get_curve_GFp == 0)
186 {
187 ECerr(EC_F_EC_GROUP_GET_CURVE_GFP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
188 return 0;
189 }
190 return group->meth->group_get_curve_GFp(group, p, a, b, ctx);
191 }
192
193
194int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor)
195 {
196 if (group->meth->group_set_generator == 0)
197 {
198 ECerr(EC_F_EC_GROUP_SET_GENERATOR, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
199 return 0;
200 }
201 return group->meth->group_set_generator(group, generator, order, cofactor);
202 }
203
204
205EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group)
206 {
207 if (group->meth->group_get0_generator == 0)
208 {
209 ECerr(EC_F_EC_GROUP_GET0_GENERATOR, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
210 return 0;
211 }
212 return group->meth->group_get0_generator(group);
213 }
214
215
216int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx)
217 {
218 if (group->meth->group_get_order == 0)
219 {
220 ECerr(EC_F_EC_GROUP_GET_ORDER, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
221 return 0;
222 }
223 return group->meth->group_get_order(group, order, ctx);
224 }
225
226
227int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, BN_CTX *ctx)
228 {
229 if (group->meth->group_get_cofactor == 0)
230 {
231 ECerr(EC_F_EC_GROUP_GET_COFACTOR, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
232 return 0;
233 }
234 return group->meth->group_get_cofactor(group, cofactor, ctx);
235 }
236
237
238/* this has 'package' visibility */
239int EC_GROUP_set_extra_data(EC_GROUP *group, void *extra_data, void *(*extra_data_dup_func)(void *),
240 void (*extra_data_free_func)(void *), void (*extra_data_clear_free_func)(void *))
241 {
242 if ((group->extra_data != NULL)
243 || (group->extra_data_dup_func != 0)
244 || (group->extra_data_free_func != 0)
245 || (group->extra_data_clear_free_func != 0))
246 {
247 ECerr(EC_F_EC_GROUP_SET_EXTRA_DATA, EC_R_SLOT_FULL);
248 return 0;
249 }
250
251 group->extra_data = extra_data;
252 group->extra_data_dup_func = extra_data_dup_func;
253 group->extra_data_free_func = extra_data_free_func;
254 group->extra_data_clear_free_func = extra_data_clear_free_func;
255 return 1;
256 }
257
258
259/* this has 'package' visibility */
260void *EC_GROUP_get_extra_data(const EC_GROUP *group, void *(*extra_data_dup_func)(void *),
261 void (*extra_data_free_func)(void *), void (*extra_data_clear_free_func)(void *))
262 {
263 if ((group->extra_data_dup_func != extra_data_dup_func)
264 || (group->extra_data_free_func != extra_data_free_func)
265 || (group->extra_data_clear_free_func != extra_data_clear_free_func))
266 {
267 ECerr(EC_F_EC_GROUP_GET_EXTRA_DATA, EC_R_NO_SUCH_EXTRA_DATA);
268 return NULL;
269 }
270
271 return group->extra_data;
272 }
273
274
275/* this has 'package' visibility */
276void EC_GROUP_free_extra_data(EC_GROUP *group)
277 {
278 if (group->extra_data_free_func)
279 group->extra_data_free_func(group->extra_data);
280 group->extra_data = NULL;
281 group->extra_data_dup_func = 0;
282 group->extra_data_free_func = 0;
283 group->extra_data_clear_free_func = 0;
284 }
285
286
287/* this has 'package' visibility */
288void EC_GROUP_clear_free_extra_data(EC_GROUP *group)
289 {
290 if (group->extra_data_clear_free_func)
291 group->extra_data_clear_free_func(group->extra_data);
292 else if (group->extra_data_free_func)
293 group->extra_data_free_func(group->extra_data);
294 group->extra_data = NULL;
295 group->extra_data_dup_func = 0;
296 group->extra_data_free_func = 0;
297 group->extra_data_clear_free_func = 0;
298 }
299
300
301
302/* functions for EC_POINT objects */
303
304EC_POINT *EC_POINT_new(const EC_GROUP *group)
305 {
306 EC_POINT *ret;
307
308 if (group == NULL)
309 {
310 ECerr(EC_F_EC_POINT_NEW, ERR_R_PASSED_NULL_PARAMETER);
311 return NULL;
312 }
313 if (group->meth->point_init == 0)
314 {
315 ECerr(EC_F_EC_POINT_NEW, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
316 return NULL;
317 }
318
319 ret = OPENSSL_malloc(sizeof *ret);
320 if (ret == NULL)
321 {
322 ECerr(EC_F_EC_POINT_NEW, ERR_R_MALLOC_FAILURE);
323 return NULL;
324 }
325
326 ret->meth = group->meth;
327
328 if (!ret->meth->point_init(ret))
329 {
330 OPENSSL_free(ret);
331 return NULL;
332 }
333
334 return ret;
335 }
336
337
338void EC_POINT_free(EC_POINT *point)
339 {
340 if (point->meth->point_finish != 0)
341 point->meth->point_finish(point);
342 OPENSSL_free(point);
343 }
344
345
346void EC_POINT_clear_free(EC_POINT *point)
347 {
348 if (point->meth->point_clear_finish != 0)
349 point->meth->point_clear_finish(point);
350 else if (point->meth != NULL && point->meth->point_finish != 0)
351 point->meth->point_finish(point);
352 memset(point, 0, sizeof *point);
353 OPENSSL_free(point);
354 }
355
356
357int EC_POINT_copy(EC_POINT *dest, const EC_POINT *src)
358 {
359 if (dest->meth->point_copy == 0)
360 {
361 ECerr(EC_F_EC_POINT_COPY, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
362 return 0;
363 }
364 if (dest->meth != src->meth)
365 {
366 ECerr(EC_F_EC_POINT_COPY, EC_R_INCOMPATIBLE_OBJECTS);
367 return 0;
368 }
369 if (dest == src)
370 return 1;
371 return dest->meth->point_copy(dest, src);
372 }
373
374
375const EC_METHOD *EC_POINT_method_of(const EC_POINT *point)
376 {
377 return point->meth;
378 }
379
380
381int EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point)
382 {
383 if (group->meth->point_set_to_infinity == 0)
384 {
385 ECerr(EC_F_EC_POINT_SET_TO_INFINITY, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
386 return 0;
387 }
388 if (group->meth != point->meth)
389 {
390 ECerr(EC_F_EC_POINT_SET_TO_INFINITY, EC_R_INCOMPATIBLE_OBJECTS);
391 return 0;
392 }
393 return group->meth->point_set_to_infinity(group, point);
394 }
395
396
397int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, EC_POINT *point,
398 const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *ctx)
399 {
400 if (group->meth->point_set_Jprojective_coordinates_GFp == 0)
401 {
402 ECerr(EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
403 return 0;
404 }
405 if (group->meth != point->meth)
406 {
407 ECerr(EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP, EC_R_INCOMPATIBLE_OBJECTS);
408 return 0;
409 }
410 return group->meth->point_set_Jprojective_coordinates_GFp(group, point, x, y, z, ctx);
411 }
412
413
414int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group, const EC_POINT *point,
415 BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx)
416 {
417 if (group->meth->point_get_Jprojective_coordinates_GFp == 0)
418 {
419 ECerr(EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
420 return 0;
421 }
422 if (group->meth != point->meth)
423 {
424 ECerr(EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP, EC_R_INCOMPATIBLE_OBJECTS);
425 return 0;
426 }
427 return group->meth->point_get_Jprojective_coordinates_GFp(group, point, x, y, z, ctx);
428 }
429
430
431int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *point,
432 const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx)
433 {
434 if (group->meth->point_set_affine_coordinates_GFp == 0)
435 {
436 ECerr(EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
437 return 0;
438 }
439 if (group->meth != point->meth)
440 {
441 ECerr(EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP, EC_R_INCOMPATIBLE_OBJECTS);
442 return 0;
443 }
444 return group->meth->point_set_affine_coordinates_GFp(group, point, x, y, ctx);
445 }
446
447
448int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group, const EC_POINT *point,
449 BIGNUM *x, BIGNUM *y, BN_CTX *ctx)
450 {
451 if (group->meth->point_get_affine_coordinates_GFp == 0)
452 {
453 ECerr(EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
454 return 0;
455 }
456 if (group->meth != point->meth)
457 {
458 ECerr(EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP, EC_R_INCOMPATIBLE_OBJECTS);
459 return 0;
460 }
461 return group->meth->point_get_affine_coordinates_GFp(group, point, x, y, ctx);
462 }
463
464
465int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *point,
466 const BIGNUM *x, int y_bit, BN_CTX *ctx)
467 {
468 if (group->meth->point_set_compressed_coordinates_GFp == 0)
469 {
470 ECerr(EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
471 return 0;
472 }
473 if (group->meth != point->meth)
474 {
475 ECerr(EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP, EC_R_INCOMPATIBLE_OBJECTS);
476 return 0;
477 }
478 return group->meth->point_set_compressed_coordinates_GFp(group, point, x, y_bit, ctx);
479 }
480
481
482size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *point, point_conversion_form_t form,
483 unsigned char *buf, size_t len, BN_CTX *ctx)
484 {
485 if (group->meth->point2oct == 0)
486 {
487 ECerr(EC_F_EC_POINT_POINT2OCT, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
488 return 0;
489 }
490 if (group->meth != point->meth)
491 {
492 ECerr(EC_F_EC_POINT_POINT2OCT, EC_R_INCOMPATIBLE_OBJECTS);
493 return 0;
494 }
495 return group->meth->point2oct(group, point, form, buf, len, ctx);
496 }
497
498
499int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *point,
500 const unsigned char *buf, size_t len, BN_CTX *ctx)
501 {
502 if (group->meth->oct2point == 0)
503 {
504 ECerr(EC_F_EC_POINT_OCT2POINT, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
505 return 0;
506 }
507 if (group->meth != point->meth)
508 {
509 ECerr(EC_F_EC_POINT_OCT2POINT, EC_R_INCOMPATIBLE_OBJECTS);
510 return 0;
511 }
512 return group->meth->oct2point(group, point, buf, len, ctx);
513 }
514
515
516int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx)
517 {
518 if (group->meth->add == 0)
519 {
520 ECerr(EC_F_EC_POINT_ADD, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
521 return 0;
522 }
523 if ((group->meth != r->meth) || (r->meth != a->meth) || (a->meth != b->meth))
524 {
525 ECerr(EC_F_EC_POINT_ADD, EC_R_INCOMPATIBLE_OBJECTS);
526 return 0;
527 }
528 return group->meth->add(group, r, a, b, ctx);
529 }
530
531
532int EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx)
533 {
534 if (group->meth->dbl == 0)
535 {
536 ECerr(EC_F_EC_POINT_DBL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
537 return 0;
538 }
539 if ((group->meth != r->meth) || (r->meth != a->meth))
540 {
541 ECerr(EC_F_EC_POINT_DBL, EC_R_INCOMPATIBLE_OBJECTS);
542 return 0;
543 }
544 return group->meth->dbl(group, r, a, ctx);
545 }
546
547
548int EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx)
549 {
550 if (group->meth->dbl == 0)
551 {
552 ECerr(EC_F_EC_POINT_DBL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
553 return 0;
554 }
555 if (group->meth != a->meth)
556 {
557 ECerr(EC_F_EC_POINT_DBL, EC_R_INCOMPATIBLE_OBJECTS);
558 return 0;
559 }
560 return group->meth->invert(group, a, ctx);
561 }
562
563
564int EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *point)
565 {
566 if (group->meth->is_at_infinity == 0)
567 {
568 ECerr(EC_F_EC_POINT_IS_AT_INFINITY, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
569 return 0;
570 }
571 if (group->meth != point->meth)
572 {
573 ECerr(EC_F_EC_POINT_IS_AT_INFINITY, EC_R_INCOMPATIBLE_OBJECTS);
574 return 0;
575 }
576 return group->meth->is_at_infinity(group, point);
577 }
578
579
580int EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx)
581 {
582 if (group->meth->is_on_curve == 0)
583 {
584 ECerr(EC_F_EC_POINT_IS_ON_CURVE, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
585 return 0;
586 }
587 if (group->meth != point->meth)
588 {
589 ECerr(EC_F_EC_POINT_IS_ON_CURVE, EC_R_INCOMPATIBLE_OBJECTS);
590 return 0;
591 }
592 return group->meth->is_on_curve(group, point, ctx);
593 }
594
595
596int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx)
597 {
598 if (group->meth->point_cmp == 0)
599 {
600 ECerr(EC_F_EC_POINT_CMP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
601 return 0;
602 }
603 if ((group->meth != a->meth) || (a->meth != b->meth))
604 {
605 ECerr(EC_F_EC_POINT_CMP, EC_R_INCOMPATIBLE_OBJECTS);
606 return 0;
607 }
608 return group->meth->point_cmp(group, a, b, ctx);
609 }
610
611
612int EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx)
613 {
614 if (group->meth->make_affine == 0)
615 {
616 ECerr(EC_F_EC_POINT_MAKE_AFFINE, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
617 return 0;
618 }
619 if (group->meth != point->meth)
620 {
621 ECerr(EC_F_EC_POINT_MAKE_AFFINE, EC_R_INCOMPATIBLE_OBJECTS);
622 return 0;
623 }
624 return group->meth->make_affine(group, point, ctx);
625 }
626
627
628int EC_POINTs_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], BN_CTX *ctx)
629 {
630 size_t i;
631
632 if (group->meth->points_make_affine == 0)
633 {
634 ECerr(EC_F_EC_POINTS_MAKE_AFFINE, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
635 return 0;
636 }
637 for (i = 0; i < num; i++)
638 {
639 if (group->meth != points[i]->meth)
640 {
641 ECerr(EC_F_EC_POINTS_MAKE_AFFINE, EC_R_INCOMPATIBLE_OBJECTS);
642 return 0;
643 }
644 }
645 return group->meth->points_make_affine(group, num, points, ctx);
646 }
diff --git a/src/lib/libcrypto/ec/ec_mult.c b/src/lib/libcrypto/ec/ec_mult.c
new file mode 100644
index 0000000000..603ba31b81
--- /dev/null
+++ b/src/lib/libcrypto/ec/ec_mult.c
@@ -0,0 +1,473 @@
1/* crypto/ec/ec_mult.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 <openssl/err.h>
57
58#include "ec_lcl.h"
59
60
61/* TODO: optional precomputation of multiples of the generator */
62
63
64
65/*
66 * wNAF-based interleaving multi-exponentation method
67 * (<URL:http://www.informatik.tu-darmstadt.de/TI/Mitarbeiter/moeller.html#multiexp>)
68 */
69
70
71/* Determine the width-(w+1) Non-Adjacent Form (wNAF) of 'scalar'.
72 * This is an array r[] of values that are either zero or odd with an
73 * absolute value less than 2^w satisfying
74 * scalar = \sum_j r[j]*2^j
75 * where at most one of any w+1 consecutive digits is non-zero.
76 */
77static signed char *compute_wNAF(const BIGNUM *scalar, int w, size_t *ret_len, BN_CTX *ctx)
78 {
79 BIGNUM *c;
80 int ok = 0;
81 signed char *r = NULL;
82 int sign = 1;
83 int bit, next_bit, mask;
84 size_t len = 0, j;
85
86 BN_CTX_start(ctx);
87 c = BN_CTX_get(ctx);
88 if (c == NULL) goto err;
89
90 if (w <= 0 || w > 7) /* 'signed char' can represent integers with absolute values less than 2^7 */
91 {
92 ECerr(EC_F_COMPUTE_WNAF, ERR_R_INTERNAL_ERROR);
93 goto err;
94 }
95 bit = 1 << w; /* at most 128 */
96 next_bit = bit << 1; /* at most 256 */
97 mask = next_bit - 1; /* at most 255 */
98
99 if (!BN_copy(c, scalar)) goto err;
100 if (c->neg)
101 {
102 sign = -1;
103 c->neg = 0;
104 }
105
106 len = BN_num_bits(c) + 1; /* wNAF may be one digit longer than binary representation */
107 r = OPENSSL_malloc(len);
108 if (r == NULL) goto err;
109
110 j = 0;
111 while (!BN_is_zero(c))
112 {
113 int u = 0;
114
115 if (BN_is_odd(c))
116 {
117 if (c->d == NULL || c->top == 0)
118 {
119 ECerr(EC_F_COMPUTE_WNAF, ERR_R_INTERNAL_ERROR);
120 goto err;
121 }
122 u = c->d[0] & mask;
123 if (u & bit)
124 {
125 u -= next_bit;
126 /* u < 0 */
127 if (!BN_add_word(c, -u)) goto err;
128 }
129 else
130 {
131 /* u > 0 */
132 if (!BN_sub_word(c, u)) goto err;
133 }
134
135 if (u <= -bit || u >= bit || !(u & 1) || c->neg)
136 {
137 ECerr(EC_F_COMPUTE_WNAF, ERR_R_INTERNAL_ERROR);
138 goto err;
139 }
140 }
141
142 r[j++] = sign * u;
143
144 if (BN_is_odd(c))
145 {
146 ECerr(EC_F_COMPUTE_WNAF, ERR_R_INTERNAL_ERROR);
147 goto err;
148 }
149 if (!BN_rshift1(c, c)) goto err;
150 }
151
152 if (j > len)
153 {
154 ECerr(EC_F_COMPUTE_WNAF, ERR_R_INTERNAL_ERROR);
155 goto err;
156 }
157 len = j;
158 ok = 1;
159
160 err:
161 BN_CTX_end(ctx);
162 if (!ok)
163 {
164 OPENSSL_free(r);
165 r = NULL;
166 }
167 if (ok)
168 *ret_len = len;
169 return r;
170 }
171
172
173/* TODO: table should be optimised for the wNAF-based implementation,
174 * sometimes smaller windows will give better performance
175 * (thus the boundaries should be increased)
176 */
177#define EC_window_bits_for_scalar_size(b) \
178 ((b) >= 2000 ? 6 : \
179 (b) >= 800 ? 5 : \
180 (b) >= 300 ? 4 : \
181 (b) >= 70 ? 3 : \
182 (b) >= 20 ? 2 : \
183 1)
184
185/* Compute
186 * \sum scalars[i]*points[i],
187 * also including
188 * scalar*generator
189 * in the addition if scalar != NULL
190 */
191int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
192 size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *ctx)
193 {
194 BN_CTX *new_ctx = NULL;
195 EC_POINT *generator = NULL;
196 EC_POINT *tmp = NULL;
197 size_t totalnum;
198 size_t i, j;
199 int k;
200 int r_is_inverted = 0;
201 int r_is_at_infinity = 1;
202 size_t *wsize = NULL; /* individual window sizes */
203 signed char **wNAF = NULL; /* individual wNAFs */
204 size_t *wNAF_len = NULL;
205 size_t max_len = 0;
206 size_t num_val;
207 EC_POINT **val = NULL; /* precomputation */
208 EC_POINT **v;
209 EC_POINT ***val_sub = NULL; /* pointers to sub-arrays of 'val' */
210 int ret = 0;
211
212 if (scalar != NULL)
213 {
214 generator = EC_GROUP_get0_generator(group);
215 if (generator == NULL)
216 {
217 ECerr(EC_F_EC_POINTS_MUL, EC_R_UNDEFINED_GENERATOR);
218 return 0;
219 }
220 }
221
222 for (i = 0; i < num; i++)
223 {
224 if (group->meth != points[i]->meth)
225 {
226 ECerr(EC_F_EC_POINTS_MUL, EC_R_INCOMPATIBLE_OBJECTS);
227 return 0;
228 }
229 }
230
231 totalnum = num + (scalar != NULL);
232
233 wsize = OPENSSL_malloc(totalnum * sizeof wsize[0]);
234 wNAF_len = OPENSSL_malloc(totalnum * sizeof wNAF_len[0]);
235 wNAF = OPENSSL_malloc((totalnum + 1) * sizeof wNAF[0]);
236 if (wNAF != NULL)
237 {
238 wNAF[0] = NULL; /* preliminary pivot */
239 }
240 if (wsize == NULL || wNAF_len == NULL || wNAF == NULL) goto err;
241
242 /* num_val := total number of points to precompute */
243 num_val = 0;
244 for (i = 0; i < totalnum; i++)
245 {
246 size_t bits;
247
248 bits = i < num ? BN_num_bits(scalars[i]) : BN_num_bits(scalar);
249 wsize[i] = EC_window_bits_for_scalar_size(bits);
250 num_val += 1u << (wsize[i] - 1);
251 }
252
253 /* all precomputed points go into a single array 'val',
254 * 'val_sub[i]' is a pointer to the subarray for the i-th point */
255 val = OPENSSL_malloc((num_val + 1) * sizeof val[0]);
256 if (val == NULL) goto err;
257 val[num_val] = NULL; /* pivot element */
258
259 val_sub = OPENSSL_malloc(totalnum * sizeof val_sub[0]);
260 if (val_sub == NULL) goto err;
261
262 /* allocate points for precomputation */
263 v = val;
264 for (i = 0; i < totalnum; i++)
265 {
266 val_sub[i] = v;
267 for (j = 0; j < (1u << (wsize[i] - 1)); j++)
268 {
269 *v = EC_POINT_new(group);
270 if (*v == NULL) goto err;
271 v++;
272 }
273 }
274 if (!(v == val + num_val))
275 {
276 ECerr(EC_F_EC_POINTS_MUL, ERR_R_INTERNAL_ERROR);
277 goto err;
278 }
279
280 if (ctx == NULL)
281 {
282 ctx = new_ctx = BN_CTX_new();
283 if (ctx == NULL)
284 goto err;
285 }
286
287 tmp = EC_POINT_new(group);
288 if (tmp == NULL) goto err;
289
290 /* prepare precomputed values:
291 * val_sub[i][0] := points[i]
292 * val_sub[i][1] := 3 * points[i]
293 * val_sub[i][2] := 5 * points[i]
294 * ...
295 */
296 for (i = 0; i < totalnum; i++)
297 {
298 if (i < num)
299 {
300 if (!EC_POINT_copy(val_sub[i][0], points[i])) goto err;
301 }
302 else
303 {
304 if (!EC_POINT_copy(val_sub[i][0], generator)) goto err;
305 }
306
307 if (wsize[i] > 1)
308 {
309 if (!EC_POINT_dbl(group, tmp, val_sub[i][0], ctx)) goto err;
310 for (j = 1; j < (1u << (wsize[i] - 1)); j++)
311 {
312 if (!EC_POINT_add(group, val_sub[i][j], val_sub[i][j - 1], tmp, ctx)) goto err;
313 }
314 }
315
316 wNAF[i + 1] = NULL; /* make sure we always have a pivot */
317 wNAF[i] = compute_wNAF((i < num ? scalars[i] : scalar), wsize[i], &wNAF_len[i], ctx);
318 if (wNAF[i] == NULL) goto err;
319 if (wNAF_len[i] > max_len)
320 max_len = wNAF_len[i];
321 }
322
323#if 1 /* optional; EC_window_bits_for_scalar_size assumes we do this step */
324 if (!EC_POINTs_make_affine(group, num_val, val, ctx)) goto err;
325#endif
326
327 r_is_at_infinity = 1;
328
329 for (k = max_len - 1; k >= 0; k--)
330 {
331 if (!r_is_at_infinity)
332 {
333 if (!EC_POINT_dbl(group, r, r, ctx)) goto err;
334 }
335
336 for (i = 0; i < totalnum; i++)
337 {
338 if (wNAF_len[i] > (size_t)k)
339 {
340 int digit = wNAF[i][k];
341 int is_neg;
342
343 if (digit)
344 {
345 is_neg = digit < 0;
346
347 if (is_neg)
348 digit = -digit;
349
350 if (is_neg != r_is_inverted)
351 {
352 if (!r_is_at_infinity)
353 {
354 if (!EC_POINT_invert(group, r, ctx)) goto err;
355 }
356 r_is_inverted = !r_is_inverted;
357 }
358
359 /* digit > 0 */
360
361 if (r_is_at_infinity)
362 {
363 if (!EC_POINT_copy(r, val_sub[i][digit >> 1])) goto err;
364 r_is_at_infinity = 0;
365 }
366 else
367 {
368 if (!EC_POINT_add(group, r, r, val_sub[i][digit >> 1], ctx)) goto err;
369 }
370 }
371 }
372 }
373 }
374
375 if (r_is_at_infinity)
376 {
377 if (!EC_POINT_set_to_infinity(group, r)) goto err;
378 }
379 else
380 {
381 if (r_is_inverted)
382 if (!EC_POINT_invert(group, r, ctx)) goto err;
383 }
384
385 ret = 1;
386
387 err:
388 if (new_ctx != NULL)
389 BN_CTX_free(new_ctx);
390 if (tmp != NULL)
391 EC_POINT_free(tmp);
392 if (wsize != NULL)
393 OPENSSL_free(wsize);
394 if (wNAF_len != NULL)
395 OPENSSL_free(wNAF_len);
396 if (wNAF != NULL)
397 {
398 signed char **w;
399
400 for (w = wNAF; *w != NULL; w++)
401 OPENSSL_free(*w);
402
403 OPENSSL_free(wNAF);
404 }
405 if (val != NULL)
406 {
407 for (v = val; *v != NULL; v++)
408 EC_POINT_clear_free(*v);
409
410 OPENSSL_free(val);
411 }
412 if (val_sub != NULL)
413 {
414 OPENSSL_free(val_sub);
415 }
416 return ret;
417 }
418
419
420int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *g_scalar, const EC_POINT *point, const BIGNUM *p_scalar, BN_CTX *ctx)
421 {
422 const EC_POINT *points[1];
423 const BIGNUM *scalars[1];
424
425 points[0] = point;
426 scalars[0] = p_scalar;
427
428 return EC_POINTs_mul(group, r, g_scalar, (point != NULL && p_scalar != NULL), points, scalars, ctx);
429 }
430
431
432int EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
433 {
434 const EC_POINT *generator;
435 BN_CTX *new_ctx = NULL;
436 BIGNUM *order;
437 int ret = 0;
438
439 generator = EC_GROUP_get0_generator(group);
440 if (generator == NULL)
441 {
442 ECerr(EC_F_EC_GROUP_PRECOMPUTE_MULT, EC_R_UNDEFINED_GENERATOR);
443 return 0;
444 }
445
446 if (ctx == NULL)
447 {
448 ctx = new_ctx = BN_CTX_new();
449 if (ctx == NULL)
450 return 0;
451 }
452
453 BN_CTX_start(ctx);
454 order = BN_CTX_get(ctx);
455 if (order == NULL) goto err;
456
457 if (!EC_GROUP_get_order(group, order, ctx)) return 0;
458 if (BN_is_zero(order))
459 {
460 ECerr(EC_F_EC_GROUP_PRECOMPUTE_MULT, EC_R_UNKNOWN_ORDER);
461 goto err;
462 }
463
464 /* TODO */
465
466 ret = 1;
467
468 err:
469 BN_CTX_end(ctx);
470 if (new_ctx != NULL)
471 BN_CTX_free(new_ctx);
472 return ret;
473 }
diff --git a/src/lib/libcrypto/ec/ecp_mont.c b/src/lib/libcrypto/ec/ecp_mont.c
new file mode 100644
index 0000000000..7b30d4c38a
--- /dev/null
+++ b/src/lib/libcrypto/ec/ecp_mont.c
@@ -0,0 +1,304 @@
1/* crypto/ec/ecp_mont.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 <openssl/err.h>
57
58#include "ec_lcl.h"
59
60
61const EC_METHOD *EC_GFp_mont_method(void)
62 {
63 static const EC_METHOD ret = {
64 ec_GFp_mont_group_init,
65 ec_GFp_mont_group_finish,
66 ec_GFp_mont_group_clear_finish,
67 ec_GFp_mont_group_copy,
68 ec_GFp_mont_group_set_curve_GFp,
69 ec_GFp_simple_group_get_curve_GFp,
70 ec_GFp_simple_group_set_generator,
71 ec_GFp_simple_group_get0_generator,
72 ec_GFp_simple_group_get_order,
73 ec_GFp_simple_group_get_cofactor,
74 ec_GFp_simple_point_init,
75 ec_GFp_simple_point_finish,
76 ec_GFp_simple_point_clear_finish,
77 ec_GFp_simple_point_copy,
78 ec_GFp_simple_point_set_to_infinity,
79 ec_GFp_simple_set_Jprojective_coordinates_GFp,
80 ec_GFp_simple_get_Jprojective_coordinates_GFp,
81 ec_GFp_simple_point_set_affine_coordinates_GFp,
82 ec_GFp_simple_point_get_affine_coordinates_GFp,
83 ec_GFp_simple_set_compressed_coordinates_GFp,
84 ec_GFp_simple_point2oct,
85 ec_GFp_simple_oct2point,
86 ec_GFp_simple_add,
87 ec_GFp_simple_dbl,
88 ec_GFp_simple_invert,
89 ec_GFp_simple_is_at_infinity,
90 ec_GFp_simple_is_on_curve,
91 ec_GFp_simple_cmp,
92 ec_GFp_simple_make_affine,
93 ec_GFp_simple_points_make_affine,
94 ec_GFp_mont_field_mul,
95 ec_GFp_mont_field_sqr,
96 ec_GFp_mont_field_encode,
97 ec_GFp_mont_field_decode,
98 ec_GFp_mont_field_set_to_one };
99
100 return &ret;
101 }
102
103
104int ec_GFp_mont_group_init(EC_GROUP *group)
105 {
106 int ok;
107
108 ok = ec_GFp_simple_group_init(group);
109 group->field_data1 = NULL;
110 group->field_data2 = NULL;
111 return ok;
112 }
113
114
115int ec_GFp_mont_group_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
116 {
117 BN_CTX *new_ctx = NULL;
118 BN_MONT_CTX *mont = NULL;
119 BIGNUM *one = NULL;
120 int ret = 0;
121
122 if (group->field_data1 != NULL)
123 {
124 BN_MONT_CTX_free(group->field_data1);
125 group->field_data1 = NULL;
126 }
127 if (group->field_data2 != NULL)
128 {
129 BN_free(group->field_data2);
130 group->field_data2 = NULL;
131 }
132
133 if (ctx == NULL)
134 {
135 ctx = new_ctx = BN_CTX_new();
136 if (ctx == NULL)
137 return 0;
138 }
139
140 mont = BN_MONT_CTX_new();
141 if (mont == NULL) goto err;
142 if (!BN_MONT_CTX_set(mont, p, ctx))
143 {
144 ECerr(EC_F_GFP_MONT_GROUP_SET_CURVE_GFP, ERR_R_BN_LIB);
145 goto err;
146 }
147 one = BN_new();
148 if (one == NULL) goto err;
149 if (!BN_to_montgomery(one, BN_value_one(), mont, ctx)) goto err;
150
151 group->field_data1 = mont;
152 mont = NULL;
153 group->field_data2 = one;
154 one = NULL;
155
156 ret = ec_GFp_simple_group_set_curve_GFp(group, p, a, b, ctx);
157
158 if (!ret)
159 {
160 BN_MONT_CTX_free(group->field_data1);
161 group->field_data1 = NULL;
162 BN_free(group->field_data2);
163 group->field_data2 = NULL;
164 }
165
166 err:
167 if (new_ctx != NULL)
168 BN_CTX_free(new_ctx);
169 if (mont != NULL)
170 BN_MONT_CTX_free(mont);
171 return ret;
172 }
173
174
175void ec_GFp_mont_group_finish(EC_GROUP *group)
176 {
177 if (group->field_data1 != NULL)
178 {
179 BN_MONT_CTX_free(group->field_data1);
180 group->field_data1 = NULL;
181 }
182 if (group->field_data2 != NULL)
183 {
184 BN_free(group->field_data2);
185 group->field_data2 = NULL;
186 }
187 ec_GFp_simple_group_finish(group);
188 }
189
190
191void ec_GFp_mont_group_clear_finish(EC_GROUP *group)
192 {
193 if (group->field_data1 != NULL)
194 {
195 BN_MONT_CTX_free(group->field_data1);
196 group->field_data1 = NULL;
197 }
198 if (group->field_data2 != NULL)
199 {
200 BN_clear_free(group->field_data2);
201 group->field_data2 = NULL;
202 }
203 ec_GFp_simple_group_clear_finish(group);
204 }
205
206
207int ec_GFp_mont_group_copy(EC_GROUP *dest, const EC_GROUP *src)
208 {
209 if (dest->field_data1 != NULL)
210 {
211 BN_MONT_CTX_free(dest->field_data1);
212 dest->field_data1 = NULL;
213 }
214 if (dest->field_data2 != NULL)
215 {
216 BN_clear_free(dest->field_data2);
217 dest->field_data2 = NULL;
218 }
219
220 if (!ec_GFp_simple_group_copy(dest, src)) return 0;
221
222 if (src->field_data1 != NULL)
223 {
224 dest->field_data1 = BN_MONT_CTX_new();
225 if (dest->field_data1 == NULL) return 0;
226 if (!BN_MONT_CTX_copy(dest->field_data1, src->field_data1)) goto err;
227 }
228 if (src->field_data2 != NULL)
229 {
230 dest->field_data2 = BN_dup(src->field_data2);
231 if (dest->field_data2 == NULL) goto err;
232 }
233
234 return 1;
235
236 err:
237 if (dest->field_data1 != NULL)
238 {
239 BN_MONT_CTX_free(dest->field_data1);
240 dest->field_data1 = NULL;
241 }
242 return 0;
243 }
244
245
246int ec_GFp_mont_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
247 {
248 if (group->field_data1 == NULL)
249 {
250 ECerr(EC_F_EC_GFP_MONT_FIELD_MUL, EC_R_NOT_INITIALIZED);
251 return 0;
252 }
253
254 return BN_mod_mul_montgomery(r, a, b, group->field_data1, ctx);
255 }
256
257
258int ec_GFp_mont_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
259 {
260 if (group->field_data1 == NULL)
261 {
262 ECerr(EC_F_EC_GFP_MONT_FIELD_SQR, EC_R_NOT_INITIALIZED);
263 return 0;
264 }
265
266 return BN_mod_mul_montgomery(r, a, a, group->field_data1, ctx);
267 }
268
269
270int ec_GFp_mont_field_encode(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
271 {
272 if (group->field_data1 == NULL)
273 {
274 ECerr(EC_F_EC_GFP_MONT_FIELD_ENCODE, EC_R_NOT_INITIALIZED);
275 return 0;
276 }
277
278 return BN_to_montgomery(r, a, (BN_MONT_CTX *)group->field_data1, ctx);
279 }
280
281
282int ec_GFp_mont_field_decode(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
283 {
284 if (group->field_data1 == NULL)
285 {
286 ECerr(EC_F_EC_GFP_MONT_FIELD_DECODE, EC_R_NOT_INITIALIZED);
287 return 0;
288 }
289
290 return BN_from_montgomery(r, a, group->field_data1, ctx);
291 }
292
293
294int ec_GFp_mont_field_set_to_one(const EC_GROUP *group, BIGNUM *r, BN_CTX *ctx)
295 {
296 if (group->field_data2 == NULL)
297 {
298 ECerr(EC_F_EC_GFP_MONT_FIELD_DECODE, EC_R_NOT_INITIALIZED);
299 return 0;
300 }
301
302 if (!BN_copy(r, group->field_data2)) return 0;
303 return 1;
304 }
diff --git a/src/lib/libcrypto/ec/ecp_nist.c b/src/lib/libcrypto/ec/ecp_nist.c
new file mode 100644
index 0000000000..ed07748675
--- /dev/null
+++ b/src/lib/libcrypto/ec/ecp_nist.c
@@ -0,0 +1,134 @@
1/* crypto/ec/ecp_nist.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_nist_method(void)
60 {
61 static const EC_METHOD ret = {
62 ec_GFp_nist_group_init,
63 ec_GFp_nist_group_finish,
64 ec_GFp_nist_group_clear_finish,
65 ec_GFp_nist_group_copy,
66 ec_GFp_nist_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_nist_field_mul,
93 ec_GFp_nist_field_sqr,
94 0 /* field_encode */,
95 0 /* field_decode */,
96 0 /* field_set_to_one */ };
97
98 return &ret;
99 }
100#endif
101
102
103int ec_GFp_nist_group_init(EC_GROUP *group)
104 {
105 int ok;
106
107 ok = ec_GFp_simple_group_init(group);
108 group->field_data1 = NULL;
109 return ok;
110 }
111
112
113int ec_GFp_nist_group_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
114/* TODO */
115
116
117void ec_GFp_nist_group_finish(EC_GROUP *group);
118/* TODO */
119
120
121void ec_GFp_nist_group_clear_finish(EC_GROUP *group);
122/* TODO */
123
124
125int ec_GFp_nist_group_copy(EC_GROUP *dest, const EC_GROUP *src);
126/* TODO */
127
128
129int ec_GFp_nist_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
130/* TODO */
131
132
133int ec_GFp_nist_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx);
134/* TODO */
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/ecp_smpl.c b/src/lib/libcrypto/ec/ecp_smpl.c
new file mode 100644
index 0000000000..4666a052bf
--- /dev/null
+++ b/src/lib/libcrypto/ec/ecp_smpl.c
@@ -0,0 +1,1717 @@
1/* crypto/ec/ecp_smpl.c */
2/* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de>
3 * for the OpenSSL project. */
4/* ====================================================================
5 * Copyright (c) 1998-2001 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 * openssl-core@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 <openssl/err.h>
59
60#include "ec_lcl.h"
61
62
63const EC_METHOD *EC_GFp_simple_method(void)
64 {
65 static const EC_METHOD ret = {
66 ec_GFp_simple_group_init,
67 ec_GFp_simple_group_finish,
68 ec_GFp_simple_group_clear_finish,
69 ec_GFp_simple_group_copy,
70 ec_GFp_simple_group_set_curve_GFp,
71 ec_GFp_simple_group_get_curve_GFp,
72 ec_GFp_simple_group_set_generator,
73 ec_GFp_simple_group_get0_generator,
74 ec_GFp_simple_group_get_order,
75 ec_GFp_simple_group_get_cofactor,
76 ec_GFp_simple_point_init,
77 ec_GFp_simple_point_finish,
78 ec_GFp_simple_point_clear_finish,
79 ec_GFp_simple_point_copy,
80 ec_GFp_simple_point_set_to_infinity,
81 ec_GFp_simple_set_Jprojective_coordinates_GFp,
82 ec_GFp_simple_get_Jprojective_coordinates_GFp,
83 ec_GFp_simple_point_set_affine_coordinates_GFp,
84 ec_GFp_simple_point_get_affine_coordinates_GFp,
85 ec_GFp_simple_set_compressed_coordinates_GFp,
86 ec_GFp_simple_point2oct,
87 ec_GFp_simple_oct2point,
88 ec_GFp_simple_add,
89 ec_GFp_simple_dbl,
90 ec_GFp_simple_invert,
91 ec_GFp_simple_is_at_infinity,
92 ec_GFp_simple_is_on_curve,
93 ec_GFp_simple_cmp,
94 ec_GFp_simple_make_affine,
95 ec_GFp_simple_points_make_affine,
96 ec_GFp_simple_field_mul,
97 ec_GFp_simple_field_sqr,
98 0 /* field_encode */,
99 0 /* field_decode */,
100 0 /* field_set_to_one */ };
101
102 return &ret;
103 }
104
105
106int ec_GFp_simple_group_init(EC_GROUP *group)
107 {
108 BN_init(&group->field);
109 BN_init(&group->a);
110 BN_init(&group->b);
111 group->a_is_minus3 = 0;
112 group->generator = NULL;
113 BN_init(&group->order);
114 BN_init(&group->cofactor);
115 return 1;
116 }
117
118
119void ec_GFp_simple_group_finish(EC_GROUP *group)
120 {
121 BN_free(&group->field);
122 BN_free(&group->a);
123 BN_free(&group->b);
124 if (group->generator != NULL)
125 EC_POINT_free(group->generator);
126 BN_free(&group->order);
127 BN_free(&group->cofactor);
128 }
129
130
131void ec_GFp_simple_group_clear_finish(EC_GROUP *group)
132 {
133 BN_clear_free(&group->field);
134 BN_clear_free(&group->a);
135 BN_clear_free(&group->b);
136 if (group->generator != NULL)
137 {
138 EC_POINT_clear_free(group->generator);
139 group->generator = NULL;
140 }
141 BN_clear_free(&group->order);
142 BN_clear_free(&group->cofactor);
143 }
144
145
146int ec_GFp_simple_group_copy(EC_GROUP *dest, const EC_GROUP *src)
147 {
148 if (!BN_copy(&dest->field, &src->field)) return 0;
149 if (!BN_copy(&dest->a, &src->a)) return 0;
150 if (!BN_copy(&dest->b, &src->b)) return 0;
151
152 dest->a_is_minus3 = src->a_is_minus3;
153
154 if (src->generator != NULL)
155 {
156 if (dest->generator == NULL)
157 {
158 dest->generator = EC_POINT_new(dest);
159 if (dest->generator == NULL) return 0;
160 }
161 if (!EC_POINT_copy(dest->generator, src->generator)) return 0;
162 }
163 else
164 {
165 /* src->generator == NULL */
166 if (dest->generator != NULL)
167 {
168 EC_POINT_clear_free(dest->generator);
169 dest->generator = NULL;
170 }
171 }
172
173 if (!BN_copy(&dest->order, &src->order)) return 0;
174 if (!BN_copy(&dest->cofactor, &src->cofactor)) return 0;
175
176 return 1;
177 }
178
179
180int ec_GFp_simple_group_set_curve_GFp(EC_GROUP *group,
181 const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
182 {
183 int ret = 0;
184 BN_CTX *new_ctx = NULL;
185 BIGNUM *tmp_a;
186
187 /* p must be a prime > 3 */
188 if (BN_num_bits(p) <= 2 || !BN_is_odd(p))
189 {
190 ECerr(EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE_GFP, EC_R_INVALID_FIELD);
191 return 0;
192 }
193
194 if (ctx == NULL)
195 {
196 ctx = new_ctx = BN_CTX_new();
197 if (ctx == NULL)
198 return 0;
199 }
200
201 BN_CTX_start(ctx);
202 tmp_a = BN_CTX_get(ctx);
203 if (tmp_a == NULL) goto err;
204
205 /* group->field */
206 if (!BN_copy(&group->field, p)) goto err;
207 group->field.neg = 0;
208
209 /* group->a */
210 if (!BN_nnmod(tmp_a, a, p, ctx)) goto err;
211 if (group->meth->field_encode)
212 { if (!group->meth->field_encode(group, &group->a, tmp_a, ctx)) goto err; }
213 else
214 if (!BN_copy(&group->a, tmp_a)) goto err;
215
216 /* group->b */
217 if (!BN_nnmod(&group->b, b, p, ctx)) goto err;
218 if (group->meth->field_encode)
219 if (!group->meth->field_encode(group, &group->b, &group->b, ctx)) goto err;
220
221 /* group->a_is_minus3 */
222 if (!BN_add_word(tmp_a, 3)) goto err;
223 group->a_is_minus3 = (0 == BN_cmp(tmp_a, &group->field));
224
225 ret = 1;
226
227 err:
228 BN_CTX_end(ctx);
229 if (new_ctx != NULL)
230 BN_CTX_free(new_ctx);
231 return ret;
232 }
233
234
235int ec_GFp_simple_group_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx)
236 {
237 int ret = 0;
238 BN_CTX *new_ctx = NULL;
239
240 if (p != NULL)
241 {
242 if (!BN_copy(p, &group->field)) return 0;
243 }
244
245 if (a != NULL || b != NULL)
246 {
247 if (group->meth->field_decode)
248 {
249 if (ctx == NULL)
250 {
251 ctx = new_ctx = BN_CTX_new();
252 if (ctx == NULL)
253 return 0;
254 }
255 if (a != NULL)
256 {
257 if (!group->meth->field_decode(group, a, &group->a, ctx)) goto err;
258 }
259 if (b != NULL)
260 {
261 if (!group->meth->field_decode(group, b, &group->b, ctx)) goto err;
262 }
263 }
264 else
265 {
266 if (a != NULL)
267 {
268 if (!BN_copy(a, &group->a)) goto err;
269 }
270 if (b != NULL)
271 {
272 if (!BN_copy(b, &group->b)) goto err;
273 }
274 }
275 }
276
277 ret = 1;
278
279 err:
280 if (new_ctx)
281 BN_CTX_free(new_ctx);
282 return ret;
283 }
284
285
286
287int ec_GFp_simple_group_set_generator(EC_GROUP *group, const EC_POINT *generator,
288 const BIGNUM *order, const BIGNUM *cofactor)
289 {
290 if (generator == NULL)
291 {
292 ECerr(EC_F_EC_GFP_SIMPLE_GROUP_SET_GENERATOR, ERR_R_PASSED_NULL_PARAMETER);
293 return 0 ;
294 }
295
296 if (group->generator == NULL)
297 {
298 group->generator = EC_POINT_new(group);
299 if (group->generator == NULL) return 0;
300 }
301 if (!EC_POINT_copy(group->generator, generator)) return 0;
302
303 if (order != NULL)
304 { if (!BN_copy(&group->order, order)) return 0; }
305 else
306 { if (!BN_zero(&group->order)) return 0; }
307
308 if (cofactor != NULL)
309 { if (!BN_copy(&group->cofactor, cofactor)) return 0; }
310 else
311 { if (!BN_zero(&group->cofactor)) return 0; }
312
313 return 1;
314 }
315
316
317EC_POINT *ec_GFp_simple_group_get0_generator(const EC_GROUP *group)
318 {
319 return group->generator;
320 }
321
322
323int ec_GFp_simple_group_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx)
324 {
325 if (!BN_copy(order, &group->order))
326 return 0;
327
328 return !BN_is_zero(&group->order);
329 }
330
331
332int ec_GFp_simple_group_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, BN_CTX *ctx)
333 {
334 if (!BN_copy(cofactor, &group->cofactor))
335 return 0;
336
337 return !BN_is_zero(&group->cofactor);
338 }
339
340
341int ec_GFp_simple_point_init(EC_POINT *point)
342 {
343 BN_init(&point->X);
344 BN_init(&point->Y);
345 BN_init(&point->Z);
346 point->Z_is_one = 0;
347
348 return 1;
349 }
350
351
352void ec_GFp_simple_point_finish(EC_POINT *point)
353 {
354 BN_free(&point->X);
355 BN_free(&point->Y);
356 BN_free(&point->Z);
357 }
358
359
360void ec_GFp_simple_point_clear_finish(EC_POINT *point)
361 {
362 BN_clear_free(&point->X);
363 BN_clear_free(&point->Y);
364 BN_clear_free(&point->Z);
365 point->Z_is_one = 0;
366 }
367
368
369int ec_GFp_simple_point_copy(EC_POINT *dest, const EC_POINT *src)
370 {
371 if (!BN_copy(&dest->X, &src->X)) return 0;
372 if (!BN_copy(&dest->Y, &src->Y)) return 0;
373 if (!BN_copy(&dest->Z, &src->Z)) return 0;
374 dest->Z_is_one = src->Z_is_one;
375
376 return 1;
377 }
378
379
380int ec_GFp_simple_point_set_to_infinity(const EC_GROUP *group, EC_POINT *point)
381 {
382 point->Z_is_one = 0;
383 return (BN_zero(&point->Z));
384 }
385
386
387int ec_GFp_simple_set_Jprojective_coordinates_GFp(const EC_GROUP *group, EC_POINT *point,
388 const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *ctx)
389 {
390 BN_CTX *new_ctx = NULL;
391 int ret = 0;
392
393 if (ctx == NULL)
394 {
395 ctx = new_ctx = BN_CTX_new();
396 if (ctx == NULL)
397 return 0;
398 }
399
400 if (x != NULL)
401 {
402 if (!BN_nnmod(&point->X, x, &group->field, ctx)) goto err;
403 if (group->meth->field_encode)
404 {
405 if (!group->meth->field_encode(group, &point->X, &point->X, ctx)) goto err;
406 }
407 }
408
409 if (y != NULL)
410 {
411 if (!BN_nnmod(&point->Y, y, &group->field, ctx)) goto err;
412 if (group->meth->field_encode)
413 {
414 if (!group->meth->field_encode(group, &point->Y, &point->Y, ctx)) goto err;
415 }
416 }
417
418 if (z != NULL)
419 {
420 int Z_is_one;
421
422 if (!BN_nnmod(&point->Z, z, &group->field, ctx)) goto err;
423 Z_is_one = BN_is_one(&point->Z);
424 if (group->meth->field_encode)
425 {
426 if (Z_is_one && (group->meth->field_set_to_one != 0))
427 {
428 if (!group->meth->field_set_to_one(group, &point->Z, ctx)) goto err;
429 }
430 else
431 {
432 if (!group->meth->field_encode(group, &point->Z, &point->Z, ctx)) goto err;
433 }
434 }
435 point->Z_is_one = Z_is_one;
436 }
437
438 ret = 1;
439
440 err:
441 if (new_ctx != NULL)
442 BN_CTX_free(new_ctx);
443 return ret;
444 }
445
446
447int ec_GFp_simple_get_Jprojective_coordinates_GFp(const EC_GROUP *group, const EC_POINT *point,
448 BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx)
449 {
450 BN_CTX *new_ctx = NULL;
451 int ret = 0;
452
453 if (group->meth->field_decode != 0)
454 {
455 if (ctx == NULL)
456 {
457 ctx = new_ctx = BN_CTX_new();
458 if (ctx == NULL)
459 return 0;
460 }
461
462 if (x != NULL)
463 {
464 if (!group->meth->field_decode(group, x, &point->X, ctx)) goto err;
465 }
466 if (y != NULL)
467 {
468 if (!group->meth->field_decode(group, y, &point->Y, ctx)) goto err;
469 }
470 if (z != NULL)
471 {
472 if (!group->meth->field_decode(group, z, &point->Z, ctx)) goto err;
473 }
474 }
475 else
476 {
477 if (x != NULL)
478 {
479 if (!BN_copy(x, &point->X)) goto err;
480 }
481 if (y != NULL)
482 {
483 if (!BN_copy(y, &point->Y)) goto err;
484 }
485 if (z != NULL)
486 {
487 if (!BN_copy(z, &point->Z)) goto err;
488 }
489 }
490
491 ret = 1;
492
493 err:
494 if (new_ctx != NULL)
495 BN_CTX_free(new_ctx);
496 return ret;
497 }
498
499
500int ec_GFp_simple_point_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *point,
501 const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx)
502 {
503 if (x == NULL || y == NULL)
504 {
505 /* unlike for projective coordinates, we do not tolerate this */
506 ECerr(EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES_GFP, ERR_R_PASSED_NULL_PARAMETER);
507 return 0;
508 }
509
510 return EC_POINT_set_Jprojective_coordinates_GFp(group, point, x, y, BN_value_one(), ctx);
511 }
512
513
514int ec_GFp_simple_point_get_affine_coordinates_GFp(const EC_GROUP *group, const EC_POINT *point,
515 BIGNUM *x, BIGNUM *y, BN_CTX *ctx)
516 {
517 BN_CTX *new_ctx = NULL;
518 BIGNUM *X, *Y, *Z, *Z_1, *Z_2, *Z_3;
519 const BIGNUM *X_, *Y_, *Z_;
520 int ret = 0;
521
522 if (EC_POINT_is_at_infinity(group, point))
523 {
524 ECerr(EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES_GFP, EC_R_POINT_AT_INFINITY);
525 return 0;
526 }
527
528 if (ctx == NULL)
529 {
530 ctx = new_ctx = BN_CTX_new();
531 if (ctx == NULL)
532 return 0;
533 }
534
535 BN_CTX_start(ctx);
536 X = BN_CTX_get(ctx);
537 Y = BN_CTX_get(ctx);
538 Z = BN_CTX_get(ctx);
539 Z_1 = BN_CTX_get(ctx);
540 Z_2 = BN_CTX_get(ctx);
541 Z_3 = BN_CTX_get(ctx);
542 if (Z_3 == NULL) goto err;
543
544 /* transform (X, Y, Z) into (x, y) := (X/Z^2, Y/Z^3) */
545
546 if (group->meth->field_decode)
547 {
548 if (!group->meth->field_decode(group, X, &point->X, ctx)) goto err;
549 if (!group->meth->field_decode(group, Y, &point->Y, ctx)) goto err;
550 if (!group->meth->field_decode(group, Z, &point->Z, ctx)) goto err;
551 X_ = X; Y_ = Y; Z_ = Z;
552 }
553 else
554 {
555 X_ = &point->X;
556 Y_ = &point->Y;
557 Z_ = &point->Z;
558 }
559
560 if (BN_is_one(Z_))
561 {
562 if (x != NULL)
563 {
564 if (!BN_copy(x, X_)) goto err;
565 }
566 if (y != NULL)
567 {
568 if (!BN_copy(y, Y_)) goto err;
569 }
570 }
571 else
572 {
573 if (!BN_mod_inverse(Z_1, Z_, &group->field, ctx))
574 {
575 ECerr(EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES_GFP, ERR_R_BN_LIB);
576 goto err;
577 }
578
579 if (group->meth->field_encode == 0)
580 {
581 /* field_sqr works on standard representation */
582 if (!group->meth->field_sqr(group, Z_2, Z_1, ctx)) goto err;
583 }
584 else
585 {
586 if (!BN_mod_sqr(Z_2, Z_1, &group->field, ctx)) goto err;
587 }
588
589 if (x != NULL)
590 {
591 if (group->meth->field_encode == 0)
592 {
593 /* field_mul works on standard representation */
594 if (!group->meth->field_mul(group, x, X_, Z_2, ctx)) goto err;
595 }
596 else
597 {
598 if (!BN_mod_mul(x, X_, Z_2, &group->field, ctx)) goto err;
599 }
600 }
601
602 if (y != NULL)
603 {
604 if (group->meth->field_encode == 0)
605 {
606 /* field_mul works on standard representation */
607 if (!group->meth->field_mul(group, Z_3, Z_2, Z_1, ctx)) goto err;
608 if (!group->meth->field_mul(group, y, Y_, Z_3, ctx)) goto err;
609
610 }
611 else
612 {
613 if (!BN_mod_mul(Z_3, Z_2, Z_1, &group->field, ctx)) goto err;
614 if (!BN_mod_mul(y, Y_, Z_3, &group->field, ctx)) goto err;
615 }
616 }
617 }
618
619 ret = 1;
620
621 err:
622 BN_CTX_end(ctx);
623 if (new_ctx != NULL)
624 BN_CTX_free(new_ctx);
625 return ret;
626 }
627
628
629int ec_GFp_simple_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *point,
630 const BIGNUM *x_, int y_bit, BN_CTX *ctx)
631 {
632 BN_CTX *new_ctx = NULL;
633 BIGNUM *tmp1, *tmp2, *x, *y;
634 int ret = 0;
635
636 if (ctx == NULL)
637 {
638 ctx = new_ctx = BN_CTX_new();
639 if (ctx == NULL)
640 return 0;
641 }
642
643 y_bit = (y_bit != 0);
644
645 BN_CTX_start(ctx);
646 tmp1 = BN_CTX_get(ctx);
647 tmp2 = BN_CTX_get(ctx);
648 x = BN_CTX_get(ctx);
649 y = BN_CTX_get(ctx);
650 if (y == NULL) goto err;
651
652 /* Recover y. We have a Weierstrass equation
653 * y^2 = x^3 + a*x + b,
654 * so y is one of the square roots of x^3 + a*x + b.
655 */
656
657 /* tmp1 := x^3 */
658 if (!BN_nnmod(x, x_, &group->field,ctx)) goto err;
659 if (group->meth->field_decode == 0)
660 {
661 /* field_{sqr,mul} work on standard representation */
662 if (!group->meth->field_sqr(group, tmp2, x_, ctx)) goto err;
663 if (!group->meth->field_mul(group, tmp1, tmp2, x_, ctx)) goto err;
664 }
665 else
666 {
667 if (!BN_mod_sqr(tmp2, x_, &group->field, ctx)) goto err;
668 if (!BN_mod_mul(tmp1, tmp2, x_, &group->field, ctx)) goto err;
669 }
670
671 /* tmp1 := tmp1 + a*x */
672 if (group->a_is_minus3)
673 {
674 if (!BN_mod_lshift1_quick(tmp2, x, &group->field)) goto err;
675 if (!BN_mod_add_quick(tmp2, tmp2, x, &group->field)) goto err;
676 if (!BN_mod_sub_quick(tmp1, tmp1, tmp2, &group->field)) goto err;
677 }
678 else
679 {
680 if (group->meth->field_decode)
681 {
682 if (!group->meth->field_decode(group, tmp2, &group->a, ctx)) goto err;
683 if (!BN_mod_mul(tmp2, tmp2, x, &group->field, ctx)) goto err;
684 }
685 else
686 {
687 /* field_mul works on standard representation */
688 if (!group->meth->field_mul(group, tmp2, &group->a, x, ctx)) goto err;
689 }
690
691 if (!BN_mod_add_quick(tmp1, tmp1, tmp2, &group->field)) goto err;
692 }
693
694 /* tmp1 := tmp1 + b */
695 if (group->meth->field_decode)
696 {
697 if (!group->meth->field_decode(group, tmp2, &group->b, ctx)) goto err;
698 if (!BN_mod_add_quick(tmp1, tmp1, tmp2, &group->field)) goto err;
699 }
700 else
701 {
702 if (!BN_mod_add_quick(tmp1, tmp1, &group->b, &group->field)) goto err;
703 }
704
705 if (!BN_mod_sqrt(y, tmp1, &group->field, ctx))
706 {
707 unsigned long err = ERR_peek_error();
708
709 if (ERR_GET_LIB(err) == ERR_LIB_BN && ERR_GET_REASON(err) == BN_R_NOT_A_SQUARE)
710 {
711 (void)ERR_get_error();
712 ECerr(EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP, EC_R_INVALID_COMPRESSED_POINT);
713 }
714 else
715 ECerr(EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP, ERR_R_BN_LIB);
716 goto err;
717 }
718 /* If tmp1 is not a square (i.e. there is no point on the curve with
719 * our x), then y now is a nonsense value too */
720
721 if (y_bit != BN_is_odd(y))
722 {
723 if (BN_is_zero(y))
724 {
725 int kron;
726
727 kron = BN_kronecker(x, &group->field, ctx);
728 if (kron == -2) goto err;
729
730 if (kron == 1)
731 ECerr(EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP, EC_R_INVALID_COMPRESSION_BIT);
732 else
733 ECerr(EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP, EC_R_INVALID_COMPRESSED_POINT);
734 goto err;
735 }
736 if (!BN_usub(y, &group->field, y)) goto err;
737 }
738 if (y_bit != BN_is_odd(y))
739 {
740 ECerr(EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP, ERR_R_INTERNAL_ERROR);
741 goto err;
742 }
743
744 if (!EC_POINT_set_affine_coordinates_GFp(group, point, x, y, ctx)) goto err;
745
746 ret = 1;
747
748 err:
749 BN_CTX_end(ctx);
750 if (new_ctx != NULL)
751 BN_CTX_free(new_ctx);
752 return ret;
753 }
754
755
756size_t ec_GFp_simple_point2oct(const EC_GROUP *group, const EC_POINT *point, point_conversion_form_t form,
757 unsigned char *buf, size_t len, BN_CTX *ctx)
758 {
759 size_t ret;
760 BN_CTX *new_ctx = NULL;
761 int used_ctx = 0;
762 BIGNUM *x, *y;
763 size_t field_len, i, skip;
764
765 if ((form != POINT_CONVERSION_COMPRESSED)
766 && (form != POINT_CONVERSION_UNCOMPRESSED)
767 && (form != POINT_CONVERSION_HYBRID))
768 {
769 ECerr(EC_F_EC_GFP_SIMPLE_POINT2OCT, EC_R_INVALID_FORM);
770 goto err;
771 }
772
773 if (EC_POINT_is_at_infinity(group, point))
774 {
775 /* encodes to a single 0 octet */
776 if (buf != NULL)
777 {
778 if (len < 1)
779 {
780 ECerr(EC_F_EC_GFP_SIMPLE_POINT2OCT, EC_R_BUFFER_TOO_SMALL);
781 return 0;
782 }
783 buf[0] = 0;
784 }
785 return 1;
786 }
787
788
789 /* ret := required output buffer length */
790 field_len = BN_num_bytes(&group->field);
791 ret = (form == POINT_CONVERSION_COMPRESSED) ? 1 + field_len : 1 + 2*field_len;
792
793 /* if 'buf' is NULL, just return required length */
794 if (buf != NULL)
795 {
796 if (len < ret)
797 {
798 ECerr(EC_F_EC_GFP_SIMPLE_POINT2OCT, EC_R_BUFFER_TOO_SMALL);
799 goto err;
800 }
801
802 if (ctx == NULL)
803 {
804 ctx = new_ctx = BN_CTX_new();
805 if (ctx == NULL)
806 return 0;
807 }
808
809 BN_CTX_start(ctx);
810 used_ctx = 1;
811 x = BN_CTX_get(ctx);
812 y = BN_CTX_get(ctx);
813 if (y == NULL) goto err;
814
815 if (!EC_POINT_get_affine_coordinates_GFp(group, point, x, y, ctx)) goto err;
816
817 if ((form == POINT_CONVERSION_COMPRESSED || form == POINT_CONVERSION_HYBRID) && BN_is_odd(y))
818 buf[0] = form + 1;
819 else
820 buf[0] = form;
821
822 i = 1;
823
824 skip = field_len - BN_num_bytes(x);
825 if (skip > field_len)
826 {
827 ECerr(EC_F_EC_GFP_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR);
828 goto err;
829 }
830 while (skip > 0)
831 {
832 buf[i++] = 0;
833 skip--;
834 }
835 skip = BN_bn2bin(x, buf + i);
836 i += skip;
837 if (i != 1 + field_len)
838 {
839 ECerr(EC_F_EC_GFP_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR);
840 goto err;
841 }
842
843 if (form == POINT_CONVERSION_UNCOMPRESSED || form == POINT_CONVERSION_HYBRID)
844 {
845 skip = field_len - BN_num_bytes(y);
846 if (skip > field_len)
847 {
848 ECerr(EC_F_EC_GFP_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR);
849 goto err;
850 }
851 while (skip > 0)
852 {
853 buf[i++] = 0;
854 skip--;
855 }
856 skip = BN_bn2bin(y, buf + i);
857 i += skip;
858 }
859
860 if (i != ret)
861 {
862 ECerr(EC_F_EC_GFP_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR);
863 goto err;
864 }
865 }
866
867 if (used_ctx)
868 BN_CTX_end(ctx);
869 if (new_ctx != NULL)
870 BN_CTX_free(new_ctx);
871 return ret;
872
873 err:
874 if (used_ctx)
875 BN_CTX_end(ctx);
876 if (new_ctx != NULL)
877 BN_CTX_free(new_ctx);
878 return 0;
879 }
880
881
882int ec_GFp_simple_oct2point(const EC_GROUP *group, EC_POINT *point,
883 const unsigned char *buf, size_t len, BN_CTX *ctx)
884 {
885 point_conversion_form_t form;
886 int y_bit;
887 BN_CTX *new_ctx = NULL;
888 BIGNUM *x, *y;
889 size_t field_len, enc_len;
890 int ret = 0;
891
892 if (len == 0)
893 {
894 ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_BUFFER_TOO_SMALL);
895 return 0;
896 }
897 form = buf[0];
898 y_bit = form & 1;
899 form = form & ~1;
900 if ((form != 0) && (form != POINT_CONVERSION_COMPRESSED)
901 && (form != POINT_CONVERSION_UNCOMPRESSED)
902 && (form != POINT_CONVERSION_HYBRID))
903 {
904 ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING);
905 return 0;
906 }
907 if ((form == 0 || form == POINT_CONVERSION_UNCOMPRESSED) && y_bit)
908 {
909 ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING);
910 return 0;
911 }
912
913 if (form == 0)
914 {
915 if (len != 1)
916 {
917 ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING);
918 return 0;
919 }
920
921 return EC_POINT_set_to_infinity(group, point);
922 }
923
924 field_len = BN_num_bytes(&group->field);
925 enc_len = (form == POINT_CONVERSION_COMPRESSED) ? 1 + field_len : 1 + 2*field_len;
926
927 if (len != enc_len)
928 {
929 ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING);
930 return 0;
931 }
932
933 if (ctx == NULL)
934 {
935 ctx = new_ctx = BN_CTX_new();
936 if (ctx == NULL)
937 return 0;
938 }
939
940 BN_CTX_start(ctx);
941 x = BN_CTX_get(ctx);
942 y = BN_CTX_get(ctx);
943 if (y == NULL) goto err;
944
945 if (!BN_bin2bn(buf + 1, field_len, x)) goto err;
946 if (BN_ucmp(x, &group->field) >= 0)
947 {
948 ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING);
949 goto err;
950 }
951
952 if (form == POINT_CONVERSION_COMPRESSED)
953 {
954 if (!EC_POINT_set_compressed_coordinates_GFp(group, point, x, y_bit, ctx)) goto err;
955 }
956 else
957 {
958 if (!BN_bin2bn(buf + 1 + field_len, field_len, y)) goto err;
959 if (BN_ucmp(y, &group->field) >= 0)
960 {
961 ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING);
962 goto err;
963 }
964 if (form == POINT_CONVERSION_HYBRID)
965 {
966 if (y_bit != BN_is_odd(y))
967 {
968 ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING);
969 goto err;
970 }
971 }
972
973 if (!EC_POINT_set_affine_coordinates_GFp(group, point, x, y, ctx)) goto err;
974 }
975
976 if (!EC_POINT_is_on_curve(group, point, ctx)) /* test required by X9.62 */
977 {
978 ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_POINT_IS_NOT_ON_CURVE);
979 goto err;
980 }
981
982 ret = 1;
983
984 err:
985 BN_CTX_end(ctx);
986 if (new_ctx != NULL)
987 BN_CTX_free(new_ctx);
988 return ret;
989 }
990
991
992int ec_GFp_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx)
993 {
994 int (*field_mul)(const EC_GROUP *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *);
995 int (*field_sqr)(const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *);
996 const BIGNUM *p;
997 BN_CTX *new_ctx = NULL;
998 BIGNUM *n0, *n1, *n2, *n3, *n4, *n5, *n6;
999 int ret = 0;
1000
1001 if (a == b)
1002 return EC_POINT_dbl(group, r, a, ctx);
1003 if (EC_POINT_is_at_infinity(group, a))
1004 return EC_POINT_copy(r, b);
1005 if (EC_POINT_is_at_infinity(group, b))
1006 return EC_POINT_copy(r, a);
1007
1008 field_mul = group->meth->field_mul;
1009 field_sqr = group->meth->field_sqr;
1010 p = &group->field;
1011
1012 if (ctx == NULL)
1013 {
1014 ctx = new_ctx = BN_CTX_new();
1015 if (ctx == NULL)
1016 return 0;
1017 }
1018
1019 BN_CTX_start(ctx);
1020 n0 = BN_CTX_get(ctx);
1021 n1 = BN_CTX_get(ctx);
1022 n2 = BN_CTX_get(ctx);
1023 n3 = BN_CTX_get(ctx);
1024 n4 = BN_CTX_get(ctx);
1025 n5 = BN_CTX_get(ctx);
1026 n6 = BN_CTX_get(ctx);
1027 if (n6 == NULL) goto end;
1028
1029 /* Note that in this function we must not read components of 'a' or 'b'
1030 * once we have written the corresponding components of 'r'.
1031 * ('r' might be one of 'a' or 'b'.)
1032 */
1033
1034 /* n1, n2 */
1035 if (b->Z_is_one)
1036 {
1037 if (!BN_copy(n1, &a->X)) goto end;
1038 if (!BN_copy(n2, &a->Y)) goto end;
1039 /* n1 = X_a */
1040 /* n2 = Y_a */
1041 }
1042 else
1043 {
1044 if (!field_sqr(group, n0, &b->Z, ctx)) goto end;
1045 if (!field_mul(group, n1, &a->X, n0, ctx)) goto end;
1046 /* n1 = X_a * Z_b^2 */
1047
1048 if (!field_mul(group, n0, n0, &b->Z, ctx)) goto end;
1049 if (!field_mul(group, n2, &a->Y, n0, ctx)) goto end;
1050 /* n2 = Y_a * Z_b^3 */
1051 }
1052
1053 /* n3, n4 */
1054 if (a->Z_is_one)
1055 {
1056 if (!BN_copy(n3, &b->X)) goto end;
1057 if (!BN_copy(n4, &b->Y)) goto end;
1058 /* n3 = X_b */
1059 /* n4 = Y_b */
1060 }
1061 else
1062 {
1063 if (!field_sqr(group, n0, &a->Z, ctx)) goto end;
1064 if (!field_mul(group, n3, &b->X, n0, ctx)) goto end;
1065 /* n3 = X_b * Z_a^2 */
1066
1067 if (!field_mul(group, n0, n0, &a->Z, ctx)) goto end;
1068 if (!field_mul(group, n4, &b->Y, n0, ctx)) goto end;
1069 /* n4 = Y_b * Z_a^3 */
1070 }
1071
1072 /* n5, n6 */
1073 if (!BN_mod_sub_quick(n5, n1, n3, p)) goto end;
1074 if (!BN_mod_sub_quick(n6, n2, n4, p)) goto end;
1075 /* n5 = n1 - n3 */
1076 /* n6 = n2 - n4 */
1077
1078 if (BN_is_zero(n5))
1079 {
1080 if (BN_is_zero(n6))
1081 {
1082 /* a is the same point as b */
1083 BN_CTX_end(ctx);
1084 ret = EC_POINT_dbl(group, r, a, ctx);
1085 ctx = NULL;
1086 goto end;
1087 }
1088 else
1089 {
1090 /* a is the inverse of b */
1091 if (!BN_zero(&r->Z)) goto end;
1092 r->Z_is_one = 0;
1093 ret = 1;
1094 goto end;
1095 }
1096 }
1097
1098 /* 'n7', 'n8' */
1099 if (!BN_mod_add_quick(n1, n1, n3, p)) goto end;
1100 if (!BN_mod_add_quick(n2, n2, n4, p)) goto end;
1101 /* 'n7' = n1 + n3 */
1102 /* 'n8' = n2 + n4 */
1103
1104 /* Z_r */
1105 if (a->Z_is_one && b->Z_is_one)
1106 {
1107 if (!BN_copy(&r->Z, n5)) goto end;
1108 }
1109 else
1110 {
1111 if (a->Z_is_one)
1112 { if (!BN_copy(n0, &b->Z)) goto end; }
1113 else if (b->Z_is_one)
1114 { if (!BN_copy(n0, &a->Z)) goto end; }
1115 else
1116 { if (!field_mul(group, n0, &a->Z, &b->Z, ctx)) goto end; }
1117 if (!field_mul(group, &r->Z, n0, n5, ctx)) goto end;
1118 }
1119 r->Z_is_one = 0;
1120 /* Z_r = Z_a * Z_b * n5 */
1121
1122 /* X_r */
1123 if (!field_sqr(group, n0, n6, ctx)) goto end;
1124 if (!field_sqr(group, n4, n5, ctx)) goto end;
1125 if (!field_mul(group, n3, n1, n4, ctx)) goto end;
1126 if (!BN_mod_sub_quick(&r->X, n0, n3, p)) goto end;
1127 /* X_r = n6^2 - n5^2 * 'n7' */
1128
1129 /* 'n9' */
1130 if (!BN_mod_lshift1_quick(n0, &r->X, p)) goto end;
1131 if (!BN_mod_sub_quick(n0, n3, n0, p)) goto end;
1132 /* n9 = n5^2 * 'n7' - 2 * X_r */
1133
1134 /* Y_r */
1135 if (!field_mul(group, n0, n0, n6, ctx)) goto end;
1136 if (!field_mul(group, n5, n4, n5, ctx)) goto end; /* now n5 is n5^3 */
1137 if (!field_mul(group, n1, n2, n5, ctx)) goto end;
1138 if (!BN_mod_sub_quick(n0, n0, n1, p)) goto end;
1139 if (BN_is_odd(n0))
1140 if (!BN_add(n0, n0, p)) goto end;
1141 /* now 0 <= n0 < 2*p, and n0 is even */
1142 if (!BN_rshift1(&r->Y, n0)) goto end;
1143 /* Y_r = (n6 * 'n9' - 'n8' * 'n5^3') / 2 */
1144
1145 ret = 1;
1146
1147 end:
1148 if (ctx) /* otherwise we already called BN_CTX_end */
1149 BN_CTX_end(ctx);
1150 if (new_ctx != NULL)
1151 BN_CTX_free(new_ctx);
1152 return ret;
1153 }
1154
1155
1156int ec_GFp_simple_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx)
1157 {
1158 int (*field_mul)(const EC_GROUP *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *);
1159 int (*field_sqr)(const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *);
1160 const BIGNUM *p;
1161 BN_CTX *new_ctx = NULL;
1162 BIGNUM *n0, *n1, *n2, *n3;
1163 int ret = 0;
1164
1165 if (EC_POINT_is_at_infinity(group, a))
1166 {
1167 if (!BN_zero(&r->Z)) return 0;
1168 r->Z_is_one = 0;
1169 return 1;
1170 }
1171
1172 field_mul = group->meth->field_mul;
1173 field_sqr = group->meth->field_sqr;
1174 p = &group->field;
1175
1176 if (ctx == NULL)
1177 {
1178 ctx = new_ctx = BN_CTX_new();
1179 if (ctx == NULL)
1180 return 0;
1181 }
1182
1183 BN_CTX_start(ctx);
1184 n0 = BN_CTX_get(ctx);
1185 n1 = BN_CTX_get(ctx);
1186 n2 = BN_CTX_get(ctx);
1187 n3 = BN_CTX_get(ctx);
1188 if (n3 == NULL) goto err;
1189
1190 /* Note that in this function we must not read components of 'a'
1191 * once we have written the corresponding components of 'r'.
1192 * ('r' might the same as 'a'.)
1193 */
1194
1195 /* n1 */
1196 if (a->Z_is_one)
1197 {
1198 if (!field_sqr(group, n0, &a->X, ctx)) goto err;
1199 if (!BN_mod_lshift1_quick(n1, n0, p)) goto err;
1200 if (!BN_mod_add_quick(n0, n0, n1, p)) goto err;
1201 if (!BN_mod_add_quick(n1, n0, &group->a, p)) goto err;
1202 /* n1 = 3 * X_a^2 + a_curve */
1203 }
1204 else if (group->a_is_minus3)
1205 {
1206 if (!field_sqr(group, n1, &a->Z, ctx)) goto err;
1207 if (!BN_mod_add_quick(n0, &a->X, n1, p)) goto err;
1208 if (!BN_mod_sub_quick(n2, &a->X, n1, p)) goto err;
1209 if (!field_mul(group, n1, n0, n2, ctx)) goto err;
1210 if (!BN_mod_lshift1_quick(n0, n1, p)) goto err;
1211 if (!BN_mod_add_quick(n1, n0, n1, p)) goto err;
1212 /* n1 = 3 * (X_a + Z_a^2) * (X_a - Z_a^2)
1213 * = 3 * X_a^2 - 3 * Z_a^4 */
1214 }
1215 else
1216 {
1217 if (!field_sqr(group, n0, &a->X, ctx)) goto err;
1218 if (!BN_mod_lshift1_quick(n1, n0, p)) goto err;
1219 if (!BN_mod_add_quick(n0, n0, n1, p)) goto err;
1220 if (!field_sqr(group, n1, &a->Z, ctx)) goto err;
1221 if (!field_sqr(group, n1, n1, ctx)) goto err;
1222 if (!field_mul(group, n1, n1, &group->a, ctx)) goto err;
1223 if (!BN_mod_add_quick(n1, n1, n0, p)) goto err;
1224 /* n1 = 3 * X_a^2 + a_curve * Z_a^4 */
1225 }
1226
1227 /* Z_r */
1228 if (a->Z_is_one)
1229 {
1230 if (!BN_copy(n0, &a->Y)) goto err;
1231 }
1232 else
1233 {
1234 if (!field_mul(group, n0, &a->Y, &a->Z, ctx)) goto err;
1235 }
1236 if (!BN_mod_lshift1_quick(&r->Z, n0, p)) goto err;
1237 r->Z_is_one = 0;
1238 /* Z_r = 2 * Y_a * Z_a */
1239
1240 /* n2 */
1241 if (!field_sqr(group, n3, &a->Y, ctx)) goto err;
1242 if (!field_mul(group, n2, &a->X, n3, ctx)) goto err;
1243 if (!BN_mod_lshift_quick(n2, n2, 2, p)) goto err;
1244 /* n2 = 4 * X_a * Y_a^2 */
1245
1246 /* X_r */
1247 if (!BN_mod_lshift1_quick(n0, n2, p)) goto err;
1248 if (!field_sqr(group, &r->X, n1, ctx)) goto err;
1249 if (!BN_mod_sub_quick(&r->X, &r->X, n0, p)) goto err;
1250 /* X_r = n1^2 - 2 * n2 */
1251
1252 /* n3 */
1253 if (!field_sqr(group, n0, n3, ctx)) goto err;
1254 if (!BN_mod_lshift_quick(n3, n0, 3, p)) goto err;
1255 /* n3 = 8 * Y_a^4 */
1256
1257 /* Y_r */
1258 if (!BN_mod_sub_quick(n0, n2, &r->X, p)) goto err;
1259 if (!field_mul(group, n0, n1, n0, ctx)) goto err;
1260 if (!BN_mod_sub_quick(&r->Y, n0, n3, p)) goto err;
1261 /* Y_r = n1 * (n2 - X_r) - n3 */
1262
1263 ret = 1;
1264
1265 err:
1266 BN_CTX_end(ctx);
1267 if (new_ctx != NULL)
1268 BN_CTX_free(new_ctx);
1269 return ret;
1270 }
1271
1272
1273int ec_GFp_simple_invert(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx)
1274 {
1275 if (EC_POINT_is_at_infinity(group, point) || BN_is_zero(&point->Y))
1276 /* point is its own inverse */
1277 return 1;
1278
1279 return BN_usub(&point->Y, &group->field, &point->Y);
1280 }
1281
1282
1283int ec_GFp_simple_is_at_infinity(const EC_GROUP *group, const EC_POINT *point)
1284 {
1285 return BN_is_zero(&point->Z);
1286 }
1287
1288
1289int ec_GFp_simple_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx)
1290 {
1291 int (*field_mul)(const EC_GROUP *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *);
1292 int (*field_sqr)(const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *);
1293 const BIGNUM *p;
1294 BN_CTX *new_ctx = NULL;
1295 BIGNUM *rh, *tmp1, *tmp2, *Z4, *Z6;
1296 int ret = -1;
1297
1298 if (EC_POINT_is_at_infinity(group, point))
1299 return 1;
1300
1301 field_mul = group->meth->field_mul;
1302 field_sqr = group->meth->field_sqr;
1303 p = &group->field;
1304
1305 if (ctx == NULL)
1306 {
1307 ctx = new_ctx = BN_CTX_new();
1308 if (ctx == NULL)
1309 return -1;
1310 }
1311
1312 BN_CTX_start(ctx);
1313 rh = BN_CTX_get(ctx);
1314 tmp1 = BN_CTX_get(ctx);
1315 tmp2 = BN_CTX_get(ctx);
1316 Z4 = BN_CTX_get(ctx);
1317 Z6 = BN_CTX_get(ctx);
1318 if (Z6 == NULL) goto err;
1319
1320 /* We have a curve defined by a Weierstrass equation
1321 * y^2 = x^3 + a*x + b.
1322 * The point to consider is given in Jacobian projective coordinates
1323 * where (X, Y, Z) represents (x, y) = (X/Z^2, Y/Z^3).
1324 * Substituting this and multiplying by Z^6 transforms the above equation into
1325 * Y^2 = X^3 + a*X*Z^4 + b*Z^6.
1326 * To test this, we add up the right-hand side in 'rh'.
1327 */
1328
1329 /* rh := X^3 */
1330 if (!field_sqr(group, rh, &point->X, ctx)) goto err;
1331 if (!field_mul(group, rh, rh, &point->X, ctx)) goto err;
1332
1333 if (!point->Z_is_one)
1334 {
1335 if (!field_sqr(group, tmp1, &point->Z, ctx)) goto err;
1336 if (!field_sqr(group, Z4, tmp1, ctx)) goto err;
1337 if (!field_mul(group, Z6, Z4, tmp1, ctx)) goto err;
1338
1339 /* rh := rh + a*X*Z^4 */
1340 if (!field_mul(group, tmp1, &point->X, Z4, ctx)) goto err;
1341 if (group->a_is_minus3)
1342 {
1343 if (!BN_mod_lshift1_quick(tmp2, tmp1, p)) goto err;
1344 if (!BN_mod_add_quick(tmp2, tmp2, tmp1, p)) goto err;
1345 if (!BN_mod_sub_quick(rh, rh, tmp2, p)) goto err;
1346 }
1347 else
1348 {
1349 if (!field_mul(group, tmp2, tmp1, &group->a, ctx)) goto err;
1350 if (!BN_mod_add_quick(rh, rh, tmp2, p)) goto err;
1351 }
1352
1353 /* rh := rh + b*Z^6 */
1354 if (!field_mul(group, tmp1, &group->b, Z6, ctx)) goto err;
1355 if (!BN_mod_add_quick(rh, rh, tmp1, p)) goto err;
1356 }
1357 else
1358 {
1359 /* point->Z_is_one */
1360
1361 /* rh := rh + a*X */
1362 if (group->a_is_minus3)
1363 {
1364 if (!BN_mod_lshift1_quick(tmp2, &point->X, p)) goto err;
1365 if (!BN_mod_add_quick(tmp2, tmp2, &point->X, p)) goto err;
1366 if (!BN_mod_sub_quick(rh, rh, tmp2, p)) goto err;
1367 }
1368 else
1369 {
1370 if (!field_mul(group, tmp2, &point->X, &group->a, ctx)) goto err;
1371 if (!BN_mod_add_quick(rh, rh, tmp2, p)) goto err;
1372 }
1373
1374 /* rh := rh + b */
1375 if (!BN_mod_add_quick(rh, rh, &group->b, p)) goto err;
1376 }
1377
1378 /* 'lh' := Y^2 */
1379 if (!field_sqr(group, tmp1, &point->Y, ctx)) goto err;
1380
1381 ret = (0 == BN_cmp(tmp1, rh));
1382
1383 err:
1384 BN_CTX_end(ctx);
1385 if (new_ctx != NULL)
1386 BN_CTX_free(new_ctx);
1387 return ret;
1388 }
1389
1390
1391int ec_GFp_simple_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx)
1392 {
1393 /* return values:
1394 * -1 error
1395 * 0 equal (in affine coordinates)
1396 * 1 not equal
1397 */
1398
1399 int (*field_mul)(const EC_GROUP *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *);
1400 int (*field_sqr)(const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *);
1401 BN_CTX *new_ctx = NULL;
1402 BIGNUM *tmp1, *tmp2, *Za23, *Zb23;
1403 const BIGNUM *tmp1_, *tmp2_;
1404 int ret = -1;
1405
1406 if (EC_POINT_is_at_infinity(group, a))
1407 {
1408 return EC_POINT_is_at_infinity(group, b) ? 0 : 1;
1409 }
1410
1411 if (a->Z_is_one && b->Z_is_one)
1412 {
1413 return ((BN_cmp(&a->X, &b->X) == 0) && BN_cmp(&a->Y, &b->Y) == 0) ? 0 : 1;
1414 }
1415
1416 field_mul = group->meth->field_mul;
1417 field_sqr = group->meth->field_sqr;
1418
1419 if (ctx == NULL)
1420 {
1421 ctx = new_ctx = BN_CTX_new();
1422 if (ctx == NULL)
1423 return -1;
1424 }
1425
1426 BN_CTX_start(ctx);
1427 tmp1 = BN_CTX_get(ctx);
1428 tmp2 = BN_CTX_get(ctx);
1429 Za23 = BN_CTX_get(ctx);
1430 Zb23 = BN_CTX_get(ctx);
1431 if (Zb23 == NULL) goto end;
1432
1433 /* We have to decide whether
1434 * (X_a/Z_a^2, Y_a/Z_a^3) = (X_b/Z_b^2, Y_b/Z_b^3),
1435 * or equivalently, whether
1436 * (X_a*Z_b^2, Y_a*Z_b^3) = (X_b*Z_a^2, Y_b*Z_a^3).
1437 */
1438
1439 if (!b->Z_is_one)
1440 {
1441 if (!field_sqr(group, Zb23, &b->Z, ctx)) goto end;
1442 if (!field_mul(group, tmp1, &a->X, Zb23, ctx)) goto end;
1443 tmp1_ = tmp1;
1444 }
1445 else
1446 tmp1_ = &a->X;
1447 if (!a->Z_is_one)
1448 {
1449 if (!field_sqr(group, Za23, &a->Z, ctx)) goto end;
1450 if (!field_mul(group, tmp2, &b->X, Za23, ctx)) goto end;
1451 tmp2_ = tmp2;
1452 }
1453 else
1454 tmp2_ = &b->X;
1455
1456 /* compare X_a*Z_b^2 with X_b*Z_a^2 */
1457 if (BN_cmp(tmp1_, tmp2_) != 0)
1458 {
1459 ret = 1; /* points differ */
1460 goto end;
1461 }
1462
1463
1464 if (!b->Z_is_one)
1465 {
1466 if (!field_mul(group, Zb23, Zb23, &b->Z, ctx)) goto end;
1467 if (!field_mul(group, tmp1, &a->Y, Zb23, ctx)) goto end;
1468 /* tmp1_ = tmp1 */
1469 }
1470 else
1471 tmp1_ = &a->Y;
1472 if (!a->Z_is_one)
1473 {
1474 if (!field_mul(group, Za23, Za23, &a->Z, ctx)) goto end;
1475 if (!field_mul(group, tmp2, &b->Y, Za23, ctx)) goto end;
1476 /* tmp2_ = tmp2 */
1477 }
1478 else
1479 tmp2_ = &b->Y;
1480
1481 /* compare Y_a*Z_b^3 with Y_b*Z_a^3 */
1482 if (BN_cmp(tmp1_, tmp2_) != 0)
1483 {
1484 ret = 1; /* points differ */
1485 goto end;
1486 }
1487
1488 /* points are equal */
1489 ret = 0;
1490
1491 end:
1492 BN_CTX_end(ctx);
1493 if (new_ctx != NULL)
1494 BN_CTX_free(new_ctx);
1495 return ret;
1496 }
1497
1498
1499int ec_GFp_simple_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx)
1500 {
1501 BN_CTX *new_ctx = NULL;
1502 BIGNUM *x, *y;
1503 int ret = 0;
1504
1505 if (point->Z_is_one || EC_POINT_is_at_infinity(group, point))
1506 return 1;
1507
1508 if (ctx == NULL)
1509 {
1510 ctx = new_ctx = BN_CTX_new();
1511 if (ctx == NULL)
1512 return 0;
1513 }
1514
1515 BN_CTX_start(ctx);
1516 x = BN_CTX_get(ctx);
1517 y = BN_CTX_get(ctx);
1518 if (y == NULL) goto err;
1519
1520 if (!EC_POINT_get_affine_coordinates_GFp(group, point, x, y, ctx)) goto err;
1521 if (!EC_POINT_set_affine_coordinates_GFp(group, point, x, y, ctx)) goto err;
1522 if (!point->Z_is_one)
1523 {
1524 ECerr(EC_F_EC_GFP_SIMPLE_MAKE_AFFINE, ERR_R_INTERNAL_ERROR);
1525 goto err;
1526 }
1527
1528 ret = 1;
1529
1530 err:
1531 BN_CTX_end(ctx);
1532 if (new_ctx != NULL)
1533 BN_CTX_free(new_ctx);
1534 return ret;
1535 }
1536
1537
1538int ec_GFp_simple_points_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], BN_CTX *ctx)
1539 {
1540 BN_CTX *new_ctx = NULL;
1541 BIGNUM *tmp0, *tmp1;
1542 size_t pow2 = 0;
1543 BIGNUM **heap = NULL;
1544 size_t i;
1545 int ret = 0;
1546
1547 if (num == 0)
1548 return 1;
1549
1550 if (ctx == NULL)
1551 {
1552 ctx = new_ctx = BN_CTX_new();
1553 if (ctx == NULL)
1554 return 0;
1555 }
1556
1557 BN_CTX_start(ctx);
1558 tmp0 = BN_CTX_get(ctx);
1559 tmp1 = BN_CTX_get(ctx);
1560 if (tmp0 == NULL || tmp1 == NULL) goto err;
1561
1562 /* Before converting the individual points, compute inverses of all Z values.
1563 * Modular inversion is rather slow, but luckily we can do with a single
1564 * explicit inversion, plus about 3 multiplications per input value.
1565 */
1566
1567 pow2 = 1;
1568 while (num > pow2)
1569 pow2 <<= 1;
1570 /* Now pow2 is the smallest power of 2 satifsying pow2 >= num.
1571 * We need twice that. */
1572 pow2 <<= 1;
1573
1574 heap = OPENSSL_malloc(pow2 * sizeof heap[0]);
1575 if (heap == NULL) goto err;
1576
1577 /* The array is used as a binary tree, exactly as in heapsort:
1578 *
1579 * heap[1]
1580 * heap[2] heap[3]
1581 * heap[4] heap[5] heap[6] heap[7]
1582 * heap[8]heap[9] heap[10]heap[11] heap[12]heap[13] heap[14] heap[15]
1583 *
1584 * We put the Z's in the last line;
1585 * then we set each other node to the product of its two child-nodes (where
1586 * empty or 0 entries are treated as ones);
1587 * then we invert heap[1];
1588 * then we invert each other node by replacing it by the product of its
1589 * parent (after inversion) and its sibling (before inversion).
1590 */
1591 heap[0] = NULL;
1592 for (i = pow2/2 - 1; i > 0; i--)
1593 heap[i] = NULL;
1594 for (i = 0; i < num; i++)
1595 heap[pow2/2 + i] = &points[i]->Z;
1596 for (i = pow2/2 + num; i < pow2; i++)
1597 heap[i] = NULL;
1598
1599 /* set each node to the product of its children */
1600 for (i = pow2/2 - 1; i > 0; i--)
1601 {
1602 heap[i] = BN_new();
1603 if (heap[i] == NULL) goto err;
1604
1605 if (heap[2*i] != NULL)
1606 {
1607 if ((heap[2*i + 1] == NULL) || BN_is_zero(heap[2*i + 1]))
1608 {
1609 if (!BN_copy(heap[i], heap[2*i])) goto err;
1610 }
1611 else
1612 {
1613 if (BN_is_zero(heap[2*i]))
1614 {
1615 if (!BN_copy(heap[i], heap[2*i + 1])) goto err;
1616 }
1617 else
1618 {
1619 if (!group->meth->field_mul(group, heap[i],
1620 heap[2*i], heap[2*i + 1], ctx)) goto err;
1621 }
1622 }
1623 }
1624 }
1625
1626 /* invert heap[1] */
1627 if (!BN_is_zero(heap[1]))
1628 {
1629 if (!BN_mod_inverse(heap[1], heap[1], &group->field, ctx))
1630 {
1631 ECerr(EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE, ERR_R_BN_LIB);
1632 goto err;
1633 }
1634 }
1635 if (group->meth->field_encode != 0)
1636 {
1637 /* in the Montgomery case, we just turned R*H (representing H)
1638 * into 1/(R*H), but we need R*(1/H) (representing 1/H);
1639 * i.e. we have need to multiply by the Montgomery factor twice */
1640 if (!group->meth->field_encode(group, heap[1], heap[1], ctx)) goto err;
1641 if (!group->meth->field_encode(group, heap[1], heap[1], ctx)) goto err;
1642 }
1643
1644 /* set other heap[i]'s to their inverses */
1645 for (i = 2; i < pow2/2 + num; i += 2)
1646 {
1647 /* i is even */
1648 if ((heap[i + 1] != NULL) && !BN_is_zero(heap[i + 1]))
1649 {
1650 if (!group->meth->field_mul(group, tmp0, heap[i/2], heap[i + 1], ctx)) goto err;
1651 if (!group->meth->field_mul(group, tmp1, heap[i/2], heap[i], ctx)) goto err;
1652 if (!BN_copy(heap[i], tmp0)) goto err;
1653 if (!BN_copy(heap[i + 1], tmp1)) goto err;
1654 }
1655 else
1656 {
1657 if (!BN_copy(heap[i], heap[i/2])) goto err;
1658 }
1659 }
1660
1661 /* we have replaced all non-zero Z's by their inverses, now fix up all the points */
1662 for (i = 0; i < num; i++)
1663 {
1664 EC_POINT *p = points[i];
1665
1666 if (!BN_is_zero(&p->Z))
1667 {
1668 /* turn (X, Y, 1/Z) into (X/Z^2, Y/Z^3, 1) */
1669
1670 if (!group->meth->field_sqr(group, tmp1, &p->Z, ctx)) goto err;
1671 if (!group->meth->field_mul(group, &p->X, &p->X, tmp1, ctx)) goto err;
1672
1673 if (!group->meth->field_mul(group, tmp1, tmp1, &p->Z, ctx)) goto err;
1674 if (!group->meth->field_mul(group, &p->Y, &p->Y, tmp1, ctx)) goto err;
1675
1676 if (group->meth->field_set_to_one != 0)
1677 {
1678 if (!group->meth->field_set_to_one(group, &p->Z, ctx)) goto err;
1679 }
1680 else
1681 {
1682 if (!BN_one(&p->Z)) goto err;
1683 }
1684 p->Z_is_one = 1;
1685 }
1686 }
1687
1688 ret = 1;
1689
1690 err:
1691 BN_CTX_end(ctx);
1692 if (new_ctx != NULL)
1693 BN_CTX_free(new_ctx);
1694 if (heap != NULL)
1695 {
1696 /* heap[pow2/2] .. heap[pow2-1] have not been allocated locally! */
1697 for (i = pow2/2 - 1; i > 0; i--)
1698 {
1699 if (heap[i] != NULL)
1700 BN_clear_free(heap[i]);
1701 }
1702 OPENSSL_free(heap);
1703 }
1704 return ret;
1705 }
1706
1707
1708int ec_GFp_simple_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
1709 {
1710 return BN_mod_mul(r, a, b, &group->field, ctx);
1711 }
1712
1713
1714int ec_GFp_simple_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
1715 {
1716 return BN_mod_sqr(r, a, &group->field, ctx);
1717 }
diff --git a/src/lib/libcrypto/ec/ectest.c b/src/lib/libcrypto/ec/ectest.c
new file mode 100644
index 0000000000..243cd83fb5
--- /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
79void 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
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
index d49b7c8159..eeea47fbf5 100644
--- a/src/lib/libcrypto/engine/Makefile.ssl
+++ b/src/lib/libcrypto/engine/Makefile.ssl
@@ -5,13 +5,14 @@
5DIR= engine 5DIR= engine
6TOP= ../.. 6TOP= ../..
7CC= cc 7CC= cc
8INCLUDES= -I.. -I../../include 8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g 9CFLAG=-g
10INSTALL_PREFIX= 10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl 11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl 12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl 13MAKE= make -f Makefile.ssl
14MAKEDEPEND= $(TOP)/util/domd $(TOP) 14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
15MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
16AR= ar r 17AR= ar r
17 18
@@ -22,10 +23,18 @@ TEST= enginetest.c
22APPS= 23APPS=
23 24
24LIB=$(TOP)/libcrypto.a 25LIB=$(TOP)/libcrypto.a
25LIBSRC= engine_err.c engine_lib.c engine_list.c engine_openssl.c \ 26LIBSRC= eng_err.c eng_lib.c eng_list.c eng_init.c eng_ctrl.c \
26 hw_atalla.c hw_cswift.c hw_ncipher.c 27 eng_table.c eng_pkey.c eng_fat.c eng_all.c \
27LIBOBJ= engine_err.o engine_lib.o engine_list.o engine_openssl.o \ 28 tb_rsa.c tb_dsa.c tb_dh.c tb_rand.c tb_cipher.c tb_digest.c \
28 hw_atalla.o hw_cswift.o hw_ncipher.o 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_openbsd_dev_crypto.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_openbsd_dev_crypto.o hw_aep.o hw_sureware.o hw_4758_cca.o
29 38
30SRC= $(LIBSRC) 39SRC= $(LIBSRC)
31 40
@@ -48,7 +57,7 @@ files:
48 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO 57 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
49 58
50links: 59links:
51 @$(SHELL) $(TOP)/util/point.sh Makefile.ssl Makefile 60 @$(TOP)/util/point.sh Makefile.ssl Makefile
52 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) 61 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
53 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) 62 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
54 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) 63 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
@@ -63,6 +72,10 @@ install:
63tags: 72tags:
64 ctags $(SRC) 73 ctags $(SRC)
65 74
75errors:
76 $(PERL) $(TOP)/util/mkerr.pl -conf hw.ec \
77 -nostatic -staticloader -write hw_*.c; \
78
66tests: 79tests:
67 80
68lint: 81lint:
@@ -80,141 +93,361 @@ clean:
80 93
81# DO NOT DELETE THIS LINE -- make depend depends on it. 94# DO NOT DELETE THIS LINE -- make depend depends on it.
82 95
83engine_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 96eng_all.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
84engine_err.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 97eng_all.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
85engine_err.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h 98eng_all.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
86engine_err.o: ../../include/openssl/des.h ../../include/openssl/dh.h 99eng_all.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
87engine_err.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h 100eng_all.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
88engine_err.o: ../../include/openssl/engine.h ../../include/openssl/err.h 101eng_all.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
89engine_err.o: ../../include/openssl/evp.h ../../include/openssl/idea.h 102eng_all.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
90engine_err.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h 103eng_all.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
91engine_err.o: ../../include/openssl/md4.h ../../include/openssl/md5.h 104eng_all.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
92engine_err.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h 105eng_all.o: ../../include/openssl/ui.h eng_all.c eng_int.h
93engine_err.o: ../../include/openssl/objects.h 106eng_cnf.o: ../../e_os.h ../../include/openssl/asn1.h
94engine_err.o: ../../include/openssl/opensslconf.h 107eng_cnf.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
95engine_err.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 108eng_cnf.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
96engine_err.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 109eng_cnf.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
97engine_err.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 110eng_cnf.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
98engine_err.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 111eng_cnf.o: ../../include/openssl/engine.h ../../include/openssl/err.h
99engine_err.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 112eng_cnf.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
100engine_err.o: ../../include/openssl/symhacks.h 113eng_cnf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
101engine_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 114eng_cnf.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
102engine_lib.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 115eng_cnf.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
103engine_lib.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 116eng_cnf.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
104engine_lib.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 117eng_cnf.o: ../cryptlib.h eng_cnf.c
105engine_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 118eng_ctrl.o: ../../e_os.h ../../include/openssl/asn1.h
106engine_lib.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 119eng_ctrl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
107engine_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h 120eng_ctrl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
108engine_lib.o: ../../include/openssl/evp.h ../../include/openssl/idea.h 121eng_ctrl.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
109engine_lib.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h 122eng_ctrl.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
110engine_lib.o: ../../include/openssl/md4.h ../../include/openssl/md5.h 123eng_ctrl.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
111engine_lib.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h 124eng_ctrl.o: ../../include/openssl/opensslconf.h
112engine_lib.o: ../../include/openssl/objects.h 125eng_ctrl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
113engine_lib.o: ../../include/openssl/opensslconf.h 126eng_ctrl.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
114engine_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 127eng_ctrl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
115engine_lib.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 128eng_ctrl.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
116engine_lib.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 129eng_ctrl.o: ../cryptlib.h eng_ctrl.c eng_int.h
117engine_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 130eng_dyn.o: ../../e_os.h ../../include/openssl/asn1.h
118engine_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 131eng_dyn.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
119engine_lib.o: ../../include/openssl/symhacks.h ../cryptlib.h engine_int.h 132eng_dyn.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
120engine_list.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 133eng_dyn.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
121engine_list.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 134eng_dyn.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
122engine_list.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 135eng_dyn.o: ../../include/openssl/engine.h ../../include/openssl/err.h
123engine_list.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 136eng_dyn.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
124engine_list.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 137eng_dyn.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
125engine_list.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 138eng_dyn.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
126engine_list.o: ../../include/openssl/engine.h ../../include/openssl/err.h 139eng_dyn.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
127engine_list.o: ../../include/openssl/evp.h ../../include/openssl/idea.h 140eng_dyn.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
128engine_list.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h 141eng_dyn.o: ../cryptlib.h eng_dyn.c eng_int.h
129engine_list.o: ../../include/openssl/md4.h ../../include/openssl/md5.h 142eng_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
130engine_list.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h 143eng_err.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
131engine_list.o: ../../include/openssl/objects.h 144eng_err.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
132engine_list.o: ../../include/openssl/opensslconf.h 145eng_err.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
133engine_list.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 146eng_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
134engine_list.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 147eng_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
135engine_list.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 148eng_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
136engine_list.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 149eng_err.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
137engine_list.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 150eng_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
138engine_list.o: ../../include/openssl/symhacks.h ../cryptlib.h engine_int.h 151eng_err.o: ../../include/openssl/ui.h eng_err.c
139engine_openssl.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 152eng_fat.o: ../../e_os.h ../../include/openssl/asn1.h
140engine_openssl.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 153eng_fat.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
141engine_openssl.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 154eng_fat.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
142engine_openssl.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 155eng_fat.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
143engine_openssl.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 156eng_fat.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
144engine_openssl.o: ../../include/openssl/dso.h ../../include/openssl/e_os.h 157eng_fat.o: ../../include/openssl/engine.h ../../include/openssl/err.h
145engine_openssl.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h 158eng_fat.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
146engine_openssl.o: ../../include/openssl/err.h ../../include/openssl/evp.h 159eng_fat.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
147engine_openssl.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 160eng_fat.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
148engine_openssl.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 161eng_fat.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
149engine_openssl.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 162eng_fat.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
150engine_openssl.o: ../../include/openssl/obj_mac.h 163eng_fat.o: ../cryptlib.h eng_fat.c eng_int.h
151engine_openssl.o: ../../include/openssl/objects.h 164eng_init.o: ../../e_os.h ../../include/openssl/asn1.h
152engine_openssl.o: ../../include/openssl/opensslconf.h 165eng_init.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
153engine_openssl.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 166eng_init.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
154engine_openssl.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 167eng_init.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
155engine_openssl.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 168eng_init.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
156engine_openssl.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 169eng_init.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
157engine_openssl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 170eng_init.o: ../../include/openssl/opensslconf.h
158engine_openssl.o: ../../include/openssl/symhacks.h ../cryptlib.h engine_int.h 171eng_init.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
159hw_atalla.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 172eng_init.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
160hw_atalla.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 173eng_init.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
161hw_atalla.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 174eng_init.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
162hw_atalla.o: ../../include/openssl/crypto.h ../../include/openssl/des.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/asn1.h
200eng_openssl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
201eng_openssl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
202eng_openssl.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
203eng_openssl.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
204eng_openssl.o: ../../include/openssl/engine.h ../../include/openssl/err.h
205eng_openssl.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
206eng_openssl.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
207eng_openssl.o: ../../include/openssl/opensslconf.h
208eng_openssl.o: ../../include/openssl/opensslv.h
209eng_openssl.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h
210eng_openssl.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h
211eng_openssl.o: ../../include/openssl/rand.h ../../include/openssl/rc4.h
212eng_openssl.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
213eng_openssl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
214eng_openssl.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
215eng_openssl.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
216eng_openssl.o: ../cryptlib.h eng_openssl.c
217eng_pkey.o: ../../e_os.h ../../include/openssl/asn1.h
218eng_pkey.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
219eng_pkey.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
220eng_pkey.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
221eng_pkey.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
222eng_pkey.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
223eng_pkey.o: ../../include/openssl/opensslconf.h
224eng_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
225eng_pkey.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
226eng_pkey.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
227eng_pkey.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
228eng_pkey.o: ../cryptlib.h eng_int.h eng_pkey.c
229eng_table.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
230eng_table.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
231eng_table.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
232eng_table.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
233eng_table.o: ../../include/openssl/err.h ../../include/openssl/evp.h
234eng_table.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
235eng_table.o: ../../include/openssl/objects.h
236eng_table.o: ../../include/openssl/opensslconf.h
237eng_table.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
238eng_table.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
239eng_table.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
240eng_table.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
241eng_table.o: eng_int.h eng_table.c
242hw_4758_cca.o: ../../e_os.h ../../include/openssl/asn1.h
243hw_4758_cca.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
244hw_4758_cca.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
245hw_4758_cca.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
246hw_4758_cca.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
247hw_4758_cca.o: ../../include/openssl/engine.h ../../include/openssl/err.h
248hw_4758_cca.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
249hw_4758_cca.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
250hw_4758_cca.o: ../../include/openssl/opensslconf.h
251hw_4758_cca.o: ../../include/openssl/opensslv.h
252hw_4758_cca.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
253hw_4758_cca.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
254hw_4758_cca.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
255hw_4758_cca.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
256hw_4758_cca.o: ../../include/openssl/ui.h ../../include/openssl/x509.h
257hw_4758_cca.o: ../../include/openssl/x509_vfy.h ../cryptlib.h hw_4758_cca.c
258hw_4758_cca.o: hw_4758_cca_err.c hw_4758_cca_err.h vendor_defns/hw_4758_cca.h
259hw_aep.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
260hw_aep.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
261hw_aep.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
262hw_aep.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
263hw_aep.o: ../../include/openssl/engine.h ../../include/openssl/err.h
264hw_aep.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
265hw_aep.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
266hw_aep.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
267hw_aep.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
268hw_aep.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h hw_aep.c
269hw_aep.o: hw_aep_err.c hw_aep_err.h vendor_defns/aep.h
270hw_atalla.o: ../../e_os.h ../../include/openssl/asn1.h
271hw_atalla.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
272hw_atalla.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
163hw_atalla.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 273hw_atalla.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
164hw_atalla.o: ../../include/openssl/dso.h ../../include/openssl/e_os.h 274hw_atalla.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
165hw_atalla.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h 275hw_atalla.o: ../../include/openssl/engine.h ../../include/openssl/err.h
166hw_atalla.o: ../../include/openssl/err.h ../../include/openssl/evp.h 276hw_atalla.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
167hw_atalla.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 277hw_atalla.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
168hw_atalla.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 278hw_atalla.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
169hw_atalla.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 279hw_atalla.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
170hw_atalla.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 280hw_atalla.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
171hw_atalla.o: ../../include/openssl/opensslconf.h 281hw_atalla.o: ../cryptlib.h hw_atalla.c hw_atalla_err.c hw_atalla_err.h
172hw_atalla.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
173hw_atalla.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
174hw_atalla.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
175hw_atalla.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
176hw_atalla.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
177hw_atalla.o: ../../include/openssl/symhacks.h ../cryptlib.h engine_int.h
178hw_atalla.o: vendor_defns/atalla.h 282hw_atalla.o: vendor_defns/atalla.h
179hw_cswift.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 283hw_cswift.o: ../../e_os.h ../../include/openssl/asn1.h
180hw_cswift.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 284hw_cswift.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
181hw_cswift.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 285hw_cswift.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
182hw_cswift.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
183hw_cswift.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 286hw_cswift.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
184hw_cswift.o: ../../include/openssl/dso.h ../../include/openssl/e_os.h 287hw_cswift.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
185hw_cswift.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h 288hw_cswift.o: ../../include/openssl/engine.h ../../include/openssl/err.h
186hw_cswift.o: ../../include/openssl/err.h ../../include/openssl/evp.h 289hw_cswift.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
187hw_cswift.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 290hw_cswift.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
188hw_cswift.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 291hw_cswift.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
189hw_cswift.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 292hw_cswift.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
190hw_cswift.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 293hw_cswift.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
191hw_cswift.o: ../../include/openssl/opensslconf.h 294hw_cswift.o: ../cryptlib.h hw_cswift.c hw_cswift_err.c hw_cswift_err.h
192hw_cswift.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
193hw_cswift.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
194hw_cswift.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
195hw_cswift.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
196hw_cswift.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
197hw_cswift.o: ../../include/openssl/symhacks.h ../cryptlib.h engine_int.h
198hw_cswift.o: vendor_defns/cswift.h 295hw_cswift.o: vendor_defns/cswift.h
199hw_ncipher.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 296hw_ncipher.o: ../../e_os.h ../../include/openssl/asn1.h
200hw_ncipher.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 297hw_ncipher.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
201hw_ncipher.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 298hw_ncipher.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
202hw_ncipher.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
203hw_ncipher.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 299hw_ncipher.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
204hw_ncipher.o: ../../include/openssl/dso.h ../../include/openssl/e_os.h 300hw_ncipher.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
205hw_ncipher.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h 301hw_ncipher.o: ../../include/openssl/engine.h ../../include/openssl/err.h
206hw_ncipher.o: ../../include/openssl/err.h ../../include/openssl/evp.h 302hw_ncipher.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
207hw_ncipher.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
208hw_ncipher.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
209hw_ncipher.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
210hw_ncipher.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 303hw_ncipher.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
211hw_ncipher.o: ../../include/openssl/opensslconf.h 304hw_ncipher.o: ../../include/openssl/opensslconf.h
212hw_ncipher.o: ../../include/openssl/opensslv.h ../../include/openssl/pem.h 305hw_ncipher.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
213hw_ncipher.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h 306hw_ncipher.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
214hw_ncipher.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h 307hw_ncipher.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
215hw_ncipher.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 308hw_ncipher.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
216hw_ncipher.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 309hw_ncipher.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
217hw_ncipher.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 310hw_ncipher.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
218hw_ncipher.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
219hw_ncipher.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 311hw_ncipher.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
220hw_ncipher.o: ../cryptlib.h engine_int.h vendor_defns/hwcryptohook.h 312hw_ncipher.o: ../cryptlib.h hw_ncipher.c hw_ncipher_err.c hw_ncipher_err.h
313hw_ncipher.o: vendor_defns/hwcryptohook.h
314hw_nuron.o: ../../e_os.h ../../include/openssl/asn1.h
315hw_nuron.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
316hw_nuron.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
317hw_nuron.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
318hw_nuron.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
319hw_nuron.o: ../../include/openssl/engine.h ../../include/openssl/err.h
320hw_nuron.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
321hw_nuron.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
322hw_nuron.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
323hw_nuron.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
324hw_nuron.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
325hw_nuron.o: ../cryptlib.h hw_nuron.c hw_nuron_err.c hw_nuron_err.h
326hw_openbsd_dev_crypto.o: ../../include/openssl/asn1.h
327hw_openbsd_dev_crypto.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
328hw_openbsd_dev_crypto.o: ../../include/openssl/conf.h
329hw_openbsd_dev_crypto.o: ../../include/openssl/crypto.h
330hw_openbsd_dev_crypto.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
331hw_openbsd_dev_crypto.o: ../../include/openssl/e_os2.h
332hw_openbsd_dev_crypto.o: ../../include/openssl/engine.h
333hw_openbsd_dev_crypto.o: ../../include/openssl/err.h
334hw_openbsd_dev_crypto.o: ../../include/openssl/evp.h
335hw_openbsd_dev_crypto.o: ../../include/openssl/lhash.h
336hw_openbsd_dev_crypto.o: ../../include/openssl/obj_mac.h
337hw_openbsd_dev_crypto.o: ../../include/openssl/objects.h
338hw_openbsd_dev_crypto.o: ../../include/openssl/opensslconf.h
339hw_openbsd_dev_crypto.o: ../../include/openssl/opensslv.h
340hw_openbsd_dev_crypto.o: ../../include/openssl/ossl_typ.h
341hw_openbsd_dev_crypto.o: ../../include/openssl/rand.h
342hw_openbsd_dev_crypto.o: ../../include/openssl/rsa.h
343hw_openbsd_dev_crypto.o: ../../include/openssl/safestack.h
344hw_openbsd_dev_crypto.o: ../../include/openssl/stack.h
345hw_openbsd_dev_crypto.o: ../../include/openssl/symhacks.h
346hw_openbsd_dev_crypto.o: ../../include/openssl/ui.h ../evp/evp_locl.h eng_int.h
347hw_openbsd_dev_crypto.o: hw_openbsd_dev_crypto.c
348hw_sureware.o: ../../e_os.h ../../include/openssl/asn1.h
349hw_sureware.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
350hw_sureware.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
351hw_sureware.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
352hw_sureware.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
353hw_sureware.o: ../../include/openssl/engine.h ../../include/openssl/err.h
354hw_sureware.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
355hw_sureware.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
356hw_sureware.o: ../../include/openssl/opensslconf.h
357hw_sureware.o: ../../include/openssl/opensslv.h
358hw_sureware.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h
359hw_sureware.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h
360hw_sureware.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
361hw_sureware.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
362hw_sureware.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
363hw_sureware.o: ../../include/openssl/ui.h ../../include/openssl/x509.h
364hw_sureware.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_int.h
365hw_sureware.o: engine.h hw_sureware.c hw_sureware_err.c hw_sureware_err.h
366hw_sureware.o: vendor_defns/sureware.h
367hw_ubsec.o: ../../e_os.h ../../include/openssl/asn1.h
368hw_ubsec.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
369hw_ubsec.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
370hw_ubsec.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
371hw_ubsec.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
372hw_ubsec.o: ../../include/openssl/engine.h ../../include/openssl/err.h
373hw_ubsec.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
374hw_ubsec.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
375hw_ubsec.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
376hw_ubsec.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
377hw_ubsec.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
378hw_ubsec.o: ../cryptlib.h hw_ubsec.c hw_ubsec_err.c hw_ubsec_err.h
379hw_ubsec.o: vendor_defns/hw_ubsec.h
380tb_cipher.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
381tb_cipher.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
382tb_cipher.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
383tb_cipher.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
384tb_cipher.o: ../../include/openssl/err.h ../../include/openssl/evp.h
385tb_cipher.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
386tb_cipher.o: ../../include/openssl/objects.h
387tb_cipher.o: ../../include/openssl/opensslconf.h
388tb_cipher.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
389tb_cipher.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
390tb_cipher.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
391tb_cipher.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
392tb_cipher.o: eng_int.h tb_cipher.c
393tb_dh.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
394tb_dh.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
395tb_dh.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
396tb_dh.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
397tb_dh.o: ../../include/openssl/err.h ../../include/openssl/evp.h
398tb_dh.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
399tb_dh.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
400tb_dh.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
401tb_dh.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
402tb_dh.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
403tb_dh.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h eng_int.h
404tb_dh.o: tb_dh.c
405tb_digest.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
406tb_digest.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
407tb_digest.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
408tb_digest.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
409tb_digest.o: ../../include/openssl/err.h ../../include/openssl/evp.h
410tb_digest.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
411tb_digest.o: ../../include/openssl/objects.h
412tb_digest.o: ../../include/openssl/opensslconf.h
413tb_digest.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
414tb_digest.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
415tb_digest.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
416tb_digest.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
417tb_digest.o: eng_int.h tb_digest.c
418tb_dsa.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
419tb_dsa.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
420tb_dsa.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
421tb_dsa.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
422tb_dsa.o: ../../include/openssl/err.h ../../include/openssl/evp.h
423tb_dsa.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
424tb_dsa.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
425tb_dsa.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
426tb_dsa.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
427tb_dsa.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
428tb_dsa.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h eng_int.h
429tb_dsa.o: tb_dsa.c
430tb_rand.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
431tb_rand.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
432tb_rand.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
433tb_rand.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
434tb_rand.o: ../../include/openssl/err.h ../../include/openssl/evp.h
435tb_rand.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
436tb_rand.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
437tb_rand.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
438tb_rand.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
439tb_rand.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
440tb_rand.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
441tb_rand.o: eng_int.h tb_rand.c
442tb_rsa.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
443tb_rsa.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
444tb_rsa.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
445tb_rsa.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
446tb_rsa.o: ../../include/openssl/err.h ../../include/openssl/evp.h
447tb_rsa.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
448tb_rsa.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
449tb_rsa.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
450tb_rsa.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
451tb_rsa.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
452tb_rsa.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h eng_int.h
453tb_rsa.o: tb_rsa.c
diff --git a/src/lib/libcrypto/engine/README b/src/lib/libcrypto/engine/README
index 96595e6f35..6b69b70f57 100644
--- a/src/lib/libcrypto/engine/README
+++ b/src/lib/libcrypto/engine/README
@@ -1,278 +1,211 @@
1NOTES, THOUGHTS, and EVERYTHING 1Notes: 2001-09-24
2-------------------------------
3
4(1) Concurrency and locking ... I made a change to the ENGINE_free code
5 because I spotted a potential hold-up in proceedings (doing too
6 much inside a lock including calling a callback), there may be
7 other bits like this. What do the speed/optimisation freaks think
8 of this aspect of the code and design? There's lots of locking for
9 manipulation functions and I need that to keep things nice and
10 solid, but this manipulation is mostly (de)initialisation, I would
11 think that most run-time locking is purely in the ENGINE_init and
12 ENGINE_finish calls that might be made when getting handles for
13 RSA (and friends') structures. These would be mostly reference
14 count operations as the functional references should always be 1
15 or greater at run-time to prevent init/deinit thrashing.
16
17(2) nCipher support, via the HWCryptoHook API, is now in the code.
18 Apparently this hasn't been tested too much yet, but it looks
19 good. :-) Atalla support has been added too, but shares a lot in
20 common with Ben's original hooks in bn_exp.c (although it has been
21 ENGINE-ified, and error handling wrapped around it) and it's also
22 had some low-volume testing, so it should be usable.
23
24(3) Of more concern, we need to work out (a) how to put together usable
25 RAND_METHODs for units that just have one "get n or less random
26 bytes" function, (b) we also need to determine how to hook the code
27 in crypto/rand/ to use the ENGINE defaults in a way similar to what
28 has been done in crypto/rsa/, crypto/dsa/, etc.
29
30(4) ENGINE should really grow to encompass more than 3 public key
31 algorithms and randomness gathering. The structure/data level of
32 the engine code is hidden from code outside the crypto/engine/
33 directory so change shouldn't be too viral. More important though
34 is how things should evolve ... this needs thought and discussion.
35
36
37-----------------------------------==*==-----------------------------------
38
39More notes 2000-08-01
40---------------------
41
42Geoff Thorpe, who designed the engine part, wrote a pretty good description
43of the thoughts he had when he built it, good enough to include verbatim here
44(with his permission) -- Richard Levitte
45
46
47Date: Tue, 1 Aug 2000 16:54:08 +0100 (BST)
48From: Geoff Thorpe
49Subject: Re: The thoughts to merge BRANCH_engine into the main trunk are
50 emerging
51
52Hi there,
53
54I'm going to try and do some justice to this, but I'm a little short on
55time and the there is an endless amount that could be discussed on this
56subject. sigh ... please bear with me :-)
57
58> The changes in BRANCH_engine dig deep into the core of OpenSSL, for example
59> into the RSA and RAND routines, adding a level of indirection which is needed
60> to keep the abstraction, as far as I understand. It would be a good thing if
61> those who do play with those things took a look at the changes that have been
62> done in the branch and say out loud how much (or hopefully little) we've made
63> fools of ourselves.
64
65The point here is that the code that has emerged in the BRANCH_engine
66branch was based on some initial requirements of mine that I went in and
67addressed, and Richard has picked up the ball and run with it too. It
68would be really useful to get some review of the approach we've taken, but
69first I think I need to describe as best I can the reasons behind what has
70been done so far, in particular what issues we have tried to address when
71doing this, and what issues we have intentionally (or necessarily) tried
72to avoid.
73
74methods, engines, and evps
75--------------------------
76
77There has been some dicussion, particularly with Steve, about where this
78ENGINE stuff might fit into the conceptual picture as/when we start to
79abstract algorithms a little bit to make the library more extensible. In
80particular, it would desirable to have algorithms (symmetric, hash, pkc,
81etc) abstracted in some way that allows them to be just objects sitting in
82a list (or database) ... it'll just happen that the "DSA" object doesn't
83support encryption whereas the "RSA" object does. This requires a lot of
84consideration to begin to know how to tackle it; in particular how
85encapsulated should these things be? If the objects also understand their
86own ASN1 encodings and what-not, then it would for example be possible to
87add support for elliptic-curve DSA in as a new algorithm and automatically
88have ECC-DSA certificates supported in SSL applications. Possible, but not
89easy. :-)
90
91Whatever, it seems that the way to go (if I've grok'd Steve's comments on
92this in the past) is to amalgamate these things in EVP as is already done
93(I think) for ciphers or hashes (Steve, please correct/elaborate). I
94certainly think something should be done in this direction because right
95now we have different source directories, types, functions, and methods
96for each algorithm - even when conceptually they are very much different
97feathers of the same bird. (This is certainly all true for the public-key
98stuff, and may be partially true for the other parts.)
99
100ENGINE was *not* conceived as a way of solving this, far from it. Nor was
101it conceived as a way of replacing the various "***_METHOD"s. It was
102conceived as an abstraction of a sort of "virtual crypto device". If we
103lived in a world where "EVP_ALGO"s (or something like them) encapsulated
104particular algorithms like RSA,DSA,MD5,RC4,etc, and "***_METHOD"s
105encapsulated interfaces to algorithms (eg. some algo's might support a
106PKC_METHOD, a HASH_METHOD, or a CIPHER_METHOD, who knows?), then I would
107think that ENGINE would encapsulate an implementation of arbitrarily many
108of those algorithms - perhaps as alternatives to existing algorithms
109and/or perhaps as new previously unimplemented algorithms. An ENGINE could
110be used to contain an alternative software implementation, a wrapper for a
111hardware acceleration and/or key-management unit, a comms-wrapper for
112distributing cryptographic operations to remote machines, or any other
113"devices" your imagination can dream up.
114
115However, what has been done in the ENGINE branch so far is nothing more
116than starting to get our toes wet. I had a couple of self-imposed
117requirements when putting the initial abstraction together, and I may have
118already posed these in one form or another on the list, but briefly;
119
120 (i) only bother with public key algorithms for now, and maybe RAND too
121 (motivated by the need to get hardware support going and the fact
122 this was a comparitively easy subset to address to begin with).
123
124 (ii) don't change (if at all possible) the existing crypto code, ie. the
125 implementations, the way the ***_METHODs work, etc.
126
127 (iii) ensure that if no function from the ENGINE code is ever called then
128 things work the way they always did, and there is no memory
129 allocation (otherwise the failure to cleanup would be a problem -
130 this is part of the reason no STACKs were used, the other part of
131 the reason being I found them inappropriate).
132
133 (iv) ensure that all the built-in crypto was encapsulated by one of
134 these "ENGINE"s and that this engine was automatically selected as
135 the default.
136
137 (v) provide the minimum hooking possible in the existing crypto code
138 so that global functions (eg. RSA_public_encrypt) do not need any
139 extra parameter, yet will use whatever the current default ENGINE
140 for that RSA key is, and that the default can be set "per-key"
141 and globally (new keys will assume the global default, and keys
142 without their own default will be operated on using the global
143 default). NB: Try and make (v) conflict as little as possible with
144 (ii). :-)
145
146 (vi) wrap the ENGINE code up in duct tape so you can't even see the
147 corners. Ie. expose no structures at all, just black-box pointers.
148
149 (v) maintain internally a list of ENGINEs on which a calling
150 application can iterate, interrogate, etc. Allow a calling
151 application to hook in new ENGINEs, remove ENGINEs from the list,
152 and enforce uniqueness within the global list of each ENGINE's
153 "unique id".
154
155 (vi) keep reference counts for everything - eg. this includes storing a
156 reference inside each RSA structure to the ENGINE that it uses.
157 This is freed when the RSA structure is destroyed, or has its
158 ENGINE explicitly changed. The net effect needs to be that at any
159 time, it is deterministic to know whether an ENGINE is in use or
160 can be safely removed (or unloaded in the case of the other type
161 of reference) without invalidating function pointers that may or
162 may not be used indavertently in the future. This was actually
163 one of the biggest problems to overcome in the existing OpenSSL
164 code - implementations had always been assumed to be ever-present,
165 so there was no trivial way to get round this.
166
167 (vii) distinguish between structural references and functional
168 references.
169
170A *little* detail
171----------------- 2-----------------
172 3
173While my mind is on it; I'll illustrate the bit in item (vii). This idea 4This "description" (if one chooses to call it that) needed some major updating
174turned out to be very handy - the ENGINEs themselves need to be operated 5so here goes. This update addresses a change being made at the same time to
175on and manipulated simply as objects without necessarily trying to 6OpenSSL, and it pretty much completely restructures the underlying mechanics of
176"enable" them for use. Eg. most host machines will not have the necessary 7the "ENGINE" code. So it serves a double purpose of being a "ENGINE internals
177hardware or software to support all the engines one might compile into 8for masochists" document *and* a rather extensive commit log message. (I'd get
178OpenSSL, yet it needs to be possible to iterate across the ENGINEs, 9lynched for sticking all this in CHANGES or the commit mails :-).
179querying their names, properties, etc - all happening in a thread-safe 10
180manner that uses reference counts (if you imagine two threads iterating 11ENGINE_TABLE underlies this restructuring, as described in the internal header
181through a list and one thread removing the ENGINE the other is currently 12"eng_int.h", implemented in eng_table.c, and used in each of the "class" files;
182looking at - you can see the gotcha waiting to happen). For all of this, 13tb_rsa.c, tb_dsa.c, etc.
183*structural references* are used and operate much like the other reference 14
184counts in OpenSSL. 15However, "EVP_CIPHER" underlies the motivation and design of ENGINE_TABLE so
185 16I'll mention a bit about that first. EVP_CIPHER (and most of this applies
186The other kind of reference count is for *functional* references - these 17equally to EVP_MD for digests) is both a "method" and a algorithm/mode
187indicate a reference on which the caller can actually assume the 18identifier that, in the current API, "lingers". These cipher description +
188particular ENGINE to be initialised and usable to perform the operations 19implementation structures can be defined or obtained directly by applications,
189it implements. Any increment or decrement of the functional reference 20or can be loaded "en masse" into EVP storage so that they can be catalogued and
190count automatically invokes a corresponding change in the structural 21searched in various ways, ie. two ways of encrypting with the "des_cbc"
191reference count, as it is fairly obvious that a functional reference is a 22algorithm/mode pair are;
192restricted case of a structural reference. So struct_ref >= funct_ref at 23
193all times. NB: functional references are usually obtained by a call to 24(i) directly;
194ENGINE_init(), but can also be created implicitly by calls that require a 25 const EVP_CIPHER *cipher = EVP_des_cbc();
195new functional reference to be created, eg. ENGINE_set_default(). Either 26 EVP_EncryptInit(&ctx, cipher, key, iv);
196way the only time the underlying ENGINE's "init" function is really called 27 [ ... use EVP_EncryptUpdate() and EVP_EncryptFinal() ...]
197is when the (functional) reference count increases to 1, similarly the 28
198underlying "finish" handler is only called as the count goes down to 0. 29(ii) indirectly;
199The effect of this, for example, is that if you set the default ENGINE for 30 OpenSSL_add_all_ciphers();
200RSA operations to be "cswift", then its functional reference count will 31 cipher = EVP_get_cipherbyname("des_cbc");
201already be at least 1 so the CryptoSwift shared-library and the card will 32 EVP_EncryptInit(&ctx, cipher, key, iv);
202stay loaded and initialised until such time as all RSA keys using the 33 [ ... etc ... ]
203cswift ENGINE are changed or destroyed and the default ENGINE for RSA 34
204operations has been changed. This prevents repeated thrashing of init and 35The latter is more generally used because it also allows ciphers/digests to be
205finish handling if the count keeps getting down as far as zero. 36looked up based on other identifiers which can be useful for automatic cipher
206 37selection, eg. in SSL/TLS, or by user-controllable configuration.
207Otherwise, the way the ENGINE code has been put together I think pretty 38
208much reflects the above points. The reason for the ENGINE structure having 39The important point about this is that EVP_CIPHER definitions and structures are
209individual RSA_METHOD, DSA_METHOD, etc pointers is simply that it was the 40passed around with impunity and there is no safe way, without requiring massive
210easiest way to go about things for now, to hook it all into the raw 41rewrites of many applications, to assume that EVP_CIPHERs can be reference
211RSA,DSA,etc code, and I was trying to the keep the structure invisible 42counted. One an EVP_CIPHER is exposed to the caller, neither it nor anything it
212anyway so that the way this is internally managed could be easily changed 43comes from can "safely" be destroyed. Unless of course the way of getting to
213later on when we start to work out what's to be done about these other 44such ciphers is via entirely distinct API calls that didn't exist before.
214abstractions. 45However existing API usage cannot be made to understand when an EVP_CIPHER
215 46pointer, that has been passed to the caller, is no longer being used.
216Down the line, if some EVP-based technique emerges for adequately 47
217encapsulating algorithms and all their various bits and pieces, then I can 48The other problem with the existing API w.r.t. to hooking EVP_CIPHER support
218imagine that "ENGINE" would turn into a reference-counting database of 49into ENGINE is storage - the OBJ_NAME-based storage used by EVP to register
219these EVP things, of which the default "openssl" ENGINE would be the 50ciphers simultaneously registers cipher *types* and cipher *implementations* -
220library's own object database of pre-built software implemented algorithms 51they are effectively the same thing, an "EVP_CIPHER" pointer. The problem with
221(and such). It would also be cool to see the idea of "METHOD"s detached 52hooking in ENGINEs is that multiple ENGINEs may implement the same ciphers. The
222from the algorithms themselves ... so RSA, DSA, ElGamal, etc can all 53solution is necessarily that ENGINE-provided ciphers simply are not registered,
223expose essentially the same METHOD (aka interface), which would include 54stored, or exposed to the caller in the same manner as existing ciphers. This is
224any querying/flagging stuff to identify what the algorithm can/can't do, 55especially necessary considering the fact ENGINE uses reference counts to allow
225its name, and other stuff like max/min block sizes, key sizes, etc. This 56for cleanup, modularity, and DSO support - yet EVP_CIPHERs, as exposed to
226would result in ENGINE similarly detaching its internal database of 57callers in the current API, support no such controls.
227algorithm implementations from the function definitions that return 58
228interfaces to them. I think ... 59Another sticking point for integrating cipher support into ENGINE is linkage.
229 60Already there is a problem with the way ENGINE supports RSA, DSA, etc whereby
230As for DSOs etc. Well the DSO code is pretty handy (but could be made much 61they are available *because* they're part of a giant ENGINE called "openssl".
231more so) for loading vendor's driver-libraries and talking to them in some 62Ie. all implementations *have* to come from an ENGINE, but we get round that by
232generic way, but right now there's still big problems associated with 63having a giant ENGINE with all the software support encapsulated. This creates
233actually putting OpenSSL code (ie. new ENGINEs, or anything else for that 64linker hassles if nothing else - linking a 1-line application that calls 2 basic
234matter) in dynamically loadable libraries. These problems won't go away in 65RSA functions (eg. "RSA_free(RSA_new());") will result in large quantities of
235a hurry so I don't think we should expect to have any kind of 66ENGINE code being linked in *and* because of that DSA, DH, and RAND also. If we
236shared-library extensions any time soon - but solving the problems is a 67continue with this approach for EVP_CIPHER support (even if it *was* possible)
237good thing to aim for, and would as a side-effect probably help make 68we would lose our ability to link selectively by selectively loading certain
238OpenSSL more usable as a shared-library itself (looking at the things 69implementations of certain functionality. Touching any part of any kind of
239needed to do this will show you why). 70crypto would result in massive static linkage of everything else. So the
240 71solution is to change the way ENGINE feeds existing "classes", ie. how the
241One of the problems is that if you look at any of the ENGINE 72hooking to ENGINE works from RSA, DSA, DH, RAND, as well as adding new hooking
242implementations, eg. hw_cswift.c or hw_ncipher.c, you'll see how it needs 73for EVP_CIPHER, and EVP_MD.
243a variety of functionality and definitions from various areas of OpenSSL, 74
244including crypto/bn/, crypto/err/, crypto/ itself (locking for example), 75The way this is now being done is by mostly reverting back to how things used to
245crypto/dso/, crypto/engine/, crypto/rsa, etc etc etc. So if similar code 76work prior to ENGINE :-). Ie. RSA now has a "RSA_METHOD" pointer again - this
246were to be suctioned off into shared libraries, the shared libraries would 77was previously replaced by an "ENGINE" pointer and all RSA code that required
247either have to duplicate all the definitions and code and avoid loader 78the RSA_METHOD would call ENGINE_get_RSA() each time on its ENGINE handle to
248conflicts, or OpenSSL would have to somehow expose all that functionality 79temporarily get and use the ENGINE's RSA implementation. Apart from being more
249to the shared-library. If this isn't a big enough problem, the issue of 80efficient, switching back to each RSA having an RSA_METHOD pointer also allows
250binary compatibility will be - anyone writing Apache modules can tell you 81us to conceivably operate with *no* ENGINE. As we'll see, this removes any need
251that (Ralf? Ben? :-). However, I don't think OpenSSL would need to be 82for a fallback ENGINE that encapsulates default implementations - we can simply
252quite so forgiving as Apache should be, so OpenSSL could simply tell its 83have our RSA structure pointing its RSA_METHOD pointer to the software
253version to the DSO and leave the DSO with the problem of deciding whether 84implementation and have its ENGINE pointer set to NULL.
254to proceed or bail out for fear of binary incompatibilities. 85
255 86A look at the EVP_CIPHER hooking is most explanatory, the RSA, DSA (etc) cases
256Certainly one thing that would go a long way to addressing this is to 87turn out to be degenerate forms of the same thing. The EVP storage of ciphers,
257embark on a bit of an opaqueness mission. I've set the ENGINE code up with 88and the existing EVP API functions that return "software" implementations and
258this in mind - it's so draconian that even to declare your own ENGINE, you 89descriptions remain untouched. However, the storage takes more meaning in terms
259have to get the engine code to create the underlying ENGINE structure, and 90of "cipher description" and less meaning in terms of "implementation". When an
260then feed in the new ENGINE's function/method pointers through various 91EVP_CIPHER_CTX is actually initialised with an EVP_CIPHER method and is about to
261"set" functions. The more of the code that takes on such a black-box 92begin en/decryption, the hooking to ENGINE comes into play. What happens is that
262approach, the more of the code that will be (a) easy to expose to shared 93cipher-specific ENGINE code is asked for an ENGINE pointer (a functional
263libraries that need it, and (b) easy to expose to applications wanting to 94reference) for any ENGINE that is registered to perform the algo/mode that the
264use OpenSSL itself as a shared-library. From my own explorations in 95provided EVP_CIPHER structure represents. Under normal circumstances, that
265OpenSSL, the biggest leviathan I've seen that is a problem in this respect 96ENGINE code will return NULL because no ENGINEs will have had any cipher
266is the BIGNUM code. Trying to "expose" the bignum code through any kind of 97implementations *registered*. As such, a NULL ENGINE pointer is stored in the
267organised "METHODs", let alone do all the necessary bignum operations 98EVP_CIPHER_CTX context, and the EVP_CIPHER structure is left hooked into the
268solely through functions rather than direct access to the structures and 99context and so is used as the implementation. Pretty much how things work now
269macros, will be a massive pain in the "r"s. 100except we'd have a redundant ENGINE pointer set to NULL and doing nothing.
270 101
271Anyway, I'm done for now - hope it was readable. Thoughts? 102Conversely, if an ENGINE *has* been registered to perform the algorithm/mode
272 103combination represented by the provided EVP_CIPHER, then a functional reference
273Cheers, 104to that ENGINE will be returned to the EVP_CIPHER_CTX during initialisation.
274Geoff 105That functional reference will be stored in the context (and released on
275 106cleanup) - and having that reference provides a *safe* way to use an EVP_CIPHER
276 107definition that is private to the ENGINE. Ie. the EVP_CIPHER provided by the
277-----------------------------------==*==----------------------------------- 108application will actually be replaced by an EVP_CIPHER from the registered
109ENGINE - it will support the same algorithm/mode as the original but will be a
110completely different implementation. Because this EVP_CIPHER isn't stored in the
111EVP storage, nor is it returned to applications from traditional API functions,
112there is no associated problem with it not having reference counts. And of
113course, when one of these "private" cipher implementations is hooked into
114EVP_CIPHER_CTX, it is done whilst the EVP_CIPHER_CTX holds a functional
115reference to the ENGINE that owns it, thus the use of the ENGINE's EVP_CIPHER is
116safe.
117
118The "cipher-specific ENGINE code" I mentioned is implemented in tb_cipher.c but
119in essence it is simply an instantiation of "ENGINE_TABLE" code for use by
120EVP_CIPHER code. tb_digest.c is virtually identical but, of course, it is for
121use by EVP_MD code. Ditto for tb_rsa.c, tb_dsa.c, etc. These instantiations of
122ENGINE_TABLE essentially provide linker-separation of the classes so that even
123if ENGINEs implement *all* possible algorithms, an application using only
124EVP_CIPHER code will link at most code relating to EVP_CIPHER, tb_cipher.c, core
125ENGINE code that is independant of class, and of course the ENGINE
126implementation that the application loaded. It will *not* however link any
127class-specific ENGINE code for digests, RSA, etc nor will it bleed over into
128other APIs, such as the RSA/DSA/etc library code.
129
130ENGINE_TABLE is a little more complicated than may seem necessary but this is
131mostly to avoid a lot of "init()"-thrashing on ENGINEs (that may have to load
132DSOs, and other expensive setup that shouldn't be thrashed unnecessarily) *and*
133to duplicate "default" behaviour. Basically an ENGINE_TABLE instantiation, for
134example tb_cipher.c, implements a hash-table keyed by integer "nid" values.
135These nids provide the uniquenness of an algorithm/mode - and each nid will hash
136to a potentially NULL "ENGINE_PILE". An ENGINE_PILE is essentially a list of
137pointers to ENGINEs that implement that particular 'nid'. Each "pile" uses some
138caching tricks such that requests on that 'nid' will be cached and all future
139requests will return immediately (well, at least with minimal operation) unless
140a change is made to the pile, eg. perhaps an ENGINE was unloaded. The reason is
141that an application could have support for 10 ENGINEs statically linked
142in, and the machine in question may not have any of the hardware those 10
143ENGINEs support. If each of those ENGINEs has a "des_cbc" implementation, we
144want to avoid every EVP_CIPHER_CTX setup from trying (and failing) to initialise
145each of those 10 ENGINEs. Instead, the first such request will try to do that
146and will either return (and cache) a NULL ENGINE pointer or will return a
147functional reference to the first that successfully initialised. In the latter
148case it will also cache an extra functional reference to the ENGINE as a
149"default" for that 'nid'. The caching is acknowledged by a 'uptodate' variable
150that is unset only if un/registration takes place on that pile. Ie. if
151implementations of "des_cbc" are added or removed. This behaviour can be
152tweaked; the ENGINE_TABLE_FLAG_NOINIT value can be passed to
153ENGINE_set_table_flags(), in which case the only ENGINEs that tb_cipher.c will
154try to initialise from the "pile" will be those that are already initialised
155(ie. it's simply an increment of the functional reference count, and no real
156"initialisation" will take place).
157
158RSA, DSA, DH, and RAND all have their own ENGINE_TABLE code as well, and the
159difference is that they all use an implicit 'nid' of 1. Whereas EVP_CIPHERs are
160actually qualitatively different depending on 'nid' (the "des_cbc" EVP_CIPHER is
161not an interoperable implementation of "aes_256_cbc"), RSA_METHODs are
162necessarily interoperable and don't have different flavours, only different
163implementations. In other words, the ENGINE_TABLE for RSA will either be empty,
164or will have a single ENGING_PILE hashed to by the 'nid' 1 and that pile
165represents ENGINEs that implement the single "type" of RSA there is.
166
167Cleanup - the registration and unregistration may pose questions about how
168cleanup works with the ENGINE_PILE doing all this caching nonsense (ie. when the
169application or EVP_CIPHER code releases its last reference to an ENGINE, the
170ENGINE_PILE code may still have references and thus those ENGINEs will stay
171hooked in forever). The way this is handled is via "unregistration". With these
172new ENGINE changes, an abstract ENGINE can be loaded and initialised, but that
173is an algorithm-agnostic process. Even if initialised, it will not have
174registered any of its implementations (to do so would link all class "table"
175code despite the fact the application may use only ciphers, for example). This
176is deliberately a distinct step. Moreover, registration and unregistration has
177nothing to do with whether an ENGINE is *functional* or not (ie. you can even
178register an ENGINE and its implementations without it being operational, you may
179not even have the drivers to make it operate). What actually happens with
180respect to cleanup is managed inside eng_lib.c with the "engine_cleanup_***"
181functions. These functions are internal-only and each part of ENGINE code that
182could require cleanup will, upon performing its first allocation, register a
183callback with the "engine_cleanup" code. The other part of this that makes it
184tick is that the ENGINE_TABLE instantiations (tb_***.c) use NULL as their
185initialised state. So if RSA code asks for an ENGINE and no ENGINE has
186registered an implementation, the code will simply return NULL and the tb_rsa.c
187state will be unchanged. Thus, no cleanup is required unless registration takes
188place. ENGINE_cleanup() will simply iterate across a list of registered cleanup
189callbacks calling each in turn, and will then internally delete its own storage
190(a STACK). When a cleanup callback is next registered (eg. if the cleanup() is
191part of a gracefull restart and the application wants to cleanup all state then
192start again), the internal STACK storage will be freshly allocated. This is much
193the same as the situation in the ENGINE_TABLE instantiations ... NULL is the
194initialised state, so only modification operations (not queries) will cause that
195code to have to register a cleanup.
196
197What else? The bignum callbacks and associated ENGINE functions have been
198removed for two obvious reasons; (i) there was no way to generalise them to the
199mechanism now used by RSA/DSA/..., because there's no such thing as a BIGNUM
200method, and (ii) because of (i), there was no meaningful way for library or
201application code to automatically hook and use ENGINE supplied bignum functions
202anyway. Also, ENGINE_cpy() has been removed (although an internal-only version
203exists) - the idea of providing an ENGINE_cpy() function probably wasn't a good
204one and now certainly doesn't make sense in any generalised way. Some of the
205RSA, DSA, DH, and RAND functions that were fiddled during the original ENGINE
206changes have now, as a consequence, been reverted back. This is because the
207hooking of ENGINE is now automatic (and passive, it can interally use a NULL
208ENGINE pointer to simply ignore ENGINE from then on).
209
210Hell, that should be enough for now ... comments welcome: geoff@openssl.org
278 211
diff --git a/src/lib/libcrypto/engine/eng_all.c b/src/lib/libcrypto/engine/eng_all.c
new file mode 100644
index 0000000000..a35b3db9e8
--- /dev/null
+++ b/src/lib/libcrypto/engine/eng_all.c
@@ -0,0 +1,118 @@
1/* crypto/engine/eng_all.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) 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 <openssl/err.h>
60#include <openssl/engine.h>
61#include "eng_int.h"
62
63#ifdef __OpenBSD__
64static int openbsd_default_loaded = 0;
65#endif
66
67void ENGINE_load_builtin_engines(void)
68 {
69 /* There's no longer any need for an "openssl" ENGINE unless, one day,
70 * it is the *only* way for standard builtin implementations to be be
71 * accessed (ie. it would be possible to statically link binaries with
72 * *no* builtin implementations). */
73#if 0
74 ENGINE_load_openssl();
75#endif
76 ENGINE_load_dynamic();
77#ifndef OPENSSL_NO_HW
78#ifndef OPENSSL_NO_HW_CSWIFT
79 ENGINE_load_cswift();
80#endif
81#ifndef OPENSSL_NO_HW_NCIPHER
82 ENGINE_load_chil();
83#endif
84#ifndef OPENSSL_NO_HW_ATALLA
85 ENGINE_load_atalla();
86#endif
87#ifndef OPENSSL_NO_HW_NURON
88 ENGINE_load_nuron();
89#endif
90#ifndef OPENSSL_NO_HW_UBSEC
91 ENGINE_load_ubsec();
92#endif
93#ifndef OPENSSL_NO_HW_AEP
94 ENGINE_load_aep();
95#endif
96#ifndef OPENSSL_NO_HW_SUREWARE
97 ENGINE_load_sureware();
98#endif
99#ifdef OPENSSL_OPENBSD_DEV_CRYPTO
100 ENGINE_load_openbsd_dev_crypto();
101#endif
102#ifdef __OpenBSD__
103 ENGINE_load_cryptodev();
104#endif
105#endif
106 }
107
108#ifdef __OpenBSD__
109void ENGINE_setup_openbsd(void) {
110 if (!openbsd_default_loaded) {
111 ENGINE_load_cryptodev();
112 ENGINE_register_all_complete();
113 }
114 openbsd_default_loaded=1;
115}
116#endif
117
118
diff --git a/src/lib/libcrypto/engine/eng_cnf.c b/src/lib/libcrypto/engine/eng_cnf.c
new file mode 100644
index 0000000000..8c0ae8a1ad
--- /dev/null
+++ b/src/lib/libcrypto/engine/eng_cnf.c
@@ -0,0 +1,242 @@
1/* eng_cnf.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 <stdio.h>
60#include <openssl/crypto.h>
61#include "cryptlib.h"
62#include <openssl/conf.h>
63#include <openssl/engine.h>
64
65/* #define ENGINE_CONF_DEBUG */
66
67/* ENGINE config module */
68
69static char *skip_dot(char *name)
70 {
71 char *p;
72 p = strchr(name, '.');
73 if (p)
74 return p + 1;
75 return name;
76 }
77
78static STACK_OF(ENGINE) *initialized_engines = NULL;
79
80static int int_engine_init(ENGINE *e)
81 {
82 if (!ENGINE_init(e))
83 return 0;
84 if (!initialized_engines)
85 initialized_engines = sk_ENGINE_new_null();
86 if (!initialized_engines || !sk_ENGINE_push(initialized_engines, e))
87 {
88 ENGINE_finish(e);
89 return 0;
90 }
91 return 1;
92 }
93
94
95int int_engine_configure(char *name, char *value, const CONF *cnf)
96 {
97 int i;
98 int ret = 0;
99 long do_init = -1;
100 STACK_OF(CONF_VALUE) *ecmds;
101 CONF_VALUE *ecmd;
102 char *ctrlname, *ctrlvalue;
103 ENGINE *e = NULL;
104 name = skip_dot(name);
105#ifdef ENGINE_CONF_DEBUG
106 fprintf(stderr, "Configuring engine %s\n", name);
107#endif
108 /* Value is a section containing ENGINE commands */
109 ecmds = NCONF_get_section(cnf, value);
110
111 if (!ecmds)
112 {
113 ENGINEerr(ENGINE_F_INT_ENGINE_CONFIGURE, ENGINE_R_ENGINE_SECTION_ERROR);
114 return 0;
115 }
116
117 for (i = 0; i < sk_CONF_VALUE_num(ecmds); i++)
118 {
119 ecmd = sk_CONF_VALUE_value(ecmds, i);
120 ctrlname = skip_dot(ecmd->name);
121 ctrlvalue = ecmd->value;
122#ifdef ENGINE_CONF_DEBUG
123 fprintf(stderr, "ENGINE conf: doing ctrl(%s,%s)\n", ctrlname, ctrlvalue);
124#endif
125
126 /* First handle some special pseudo ctrls */
127
128 /* Override engine name to use */
129 if (!strcmp(ctrlname, "engine_id"))
130 name = ctrlvalue;
131 /* Load a dynamic ENGINE */
132 else if (!strcmp(ctrlname, "dynamic_path"))
133 {
134 e = ENGINE_by_id("dynamic");
135 if (!e)
136 goto err;
137 if (!ENGINE_ctrl_cmd_string(e, "SO_PATH", ctrlvalue, 0))
138 goto err;
139 if (!ENGINE_ctrl_cmd_string(e, "LIST_ADD", "2", 0))
140 goto err;
141 if (!ENGINE_ctrl_cmd_string(e, "LOAD", NULL, 0))
142 goto err;
143 }
144 /* ... add other pseudos here ... */
145 else
146 {
147 /* At this point we need an ENGINE structural reference
148 * if we don't already have one.
149 */
150 if (!e)
151 {
152 e = ENGINE_by_id(name);
153 if (!e)
154 return 0;
155 }
156 /* Allow "EMPTY" to mean no value: this allows a valid
157 * "value" to be passed to ctrls of type NO_INPUT
158 */
159 if (!strcmp(ctrlvalue, "EMPTY"))
160 ctrlvalue = NULL;
161 else if (!strcmp(ctrlname, "init"))
162 {
163 if (!NCONF_get_number_e(cnf, value, "init", &do_init))
164 goto err;
165 if (do_init == 1)
166 {
167 if (!int_engine_init(e))
168 goto err;
169 }
170 else if (do_init != 0)
171 {
172 ENGINEerr(ENGINE_F_INT_ENGINE_CONFIGURE, ENGINE_R_INVALID_INIT_VALUE);
173 goto err;
174 }
175 }
176 else if (!strcmp(ctrlname, "default_algorithms"))
177 {
178 if (!ENGINE_set_default_string(e, ctrlvalue))
179 goto err;
180 }
181 else if (!ENGINE_ctrl_cmd_string(e,
182 ctrlname, ctrlvalue, 0))
183 return 0;
184 }
185
186
187
188 }
189 if (e && (do_init == -1) && !int_engine_init(e))
190 goto err;
191 ret = 1;
192 err:
193 if (e)
194 ENGINE_free(e);
195 return ret;
196 }
197
198
199static int int_engine_module_init(CONF_IMODULE *md, const CONF *cnf)
200 {
201 STACK_OF(CONF_VALUE) *elist;
202 CONF_VALUE *cval;
203 int i;
204#ifdef ENGINE_CONF_DEBUG
205 fprintf(stderr, "Called engine module: name %s, value %s\n",
206 CONF_imodule_get_name(md), CONF_imodule_get_value(md));
207#endif
208 /* Value is a section containing ENGINEs to configure */
209 elist = NCONF_get_section(cnf, CONF_imodule_get_value(md));
210
211 if (!elist)
212 {
213 ENGINEerr(ENGINE_F_ENGINE_MODULE_INIT, ENGINE_R_ENGINES_SECTION_ERROR);
214 return 0;
215 }
216
217 for (i = 0; i < sk_CONF_VALUE_num(elist); i++)
218 {
219 cval = sk_CONF_VALUE_value(elist, i);
220 if (!int_engine_configure(cval->name, cval->value, cnf))
221 return 0;
222 }
223
224 return 1;
225 }
226
227static void int_engine_module_finish(CONF_IMODULE *md)
228 {
229 ENGINE *e;
230 while ((e = sk_ENGINE_pop(initialized_engines)))
231 ENGINE_finish(e);
232 sk_ENGINE_free(initialized_engines);
233 initialized_engines = NULL;
234 }
235
236
237void ENGINE_add_conf_module(void)
238 {
239 CONF_module_add("engines",
240 int_engine_module_init,
241 int_engine_module_finish);
242 }
diff --git a/src/lib/libcrypto/engine/eng_ctrl.c b/src/lib/libcrypto/engine/eng_ctrl.c
new file mode 100644
index 0000000000..ad3858395b
--- /dev/null
+++ b/src/lib/libcrypto/engine/eng_ctrl.c
@@ -0,0 +1,387 @@
1/* crypto/engine/eng_ctrl.c */
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/crypto.h>
57#include "cryptlib.h"
58#include "eng_int.h"
59#include <openssl/engine.h>
60
61/* When querying a ENGINE-specific control command's 'description', this string
62 * is used if the ENGINE_CMD_DEFN has cmd_desc set to NULL. */
63static const char *int_no_description = "";
64
65/* These internal functions handle 'CMD'-related control commands when the
66 * ENGINE in question has asked us to take care of it (ie. the ENGINE did not
67 * set the ENGINE_FLAGS_MANUAL_CMD_CTRL flag. */
68
69static int int_ctrl_cmd_is_null(const ENGINE_CMD_DEFN *defn)
70 {
71 if((defn->cmd_num == 0) || (defn->cmd_name == NULL))
72 return 1;
73 return 0;
74 }
75
76static int int_ctrl_cmd_by_name(const ENGINE_CMD_DEFN *defn, const char *s)
77 {
78 int idx = 0;
79 while(!int_ctrl_cmd_is_null(defn) && (strcmp(defn->cmd_name, s) != 0))
80 {
81 idx++;
82 defn++;
83 }
84 if(int_ctrl_cmd_is_null(defn))
85 /* The given name wasn't found */
86 return -1;
87 return idx;
88 }
89
90static int int_ctrl_cmd_by_num(const ENGINE_CMD_DEFN *defn, unsigned int num)
91 {
92 int idx = 0;
93 /* NB: It is stipulated that 'cmd_defn' lists are ordered by cmd_num. So
94 * our searches don't need to take any longer than necessary. */
95 while(!int_ctrl_cmd_is_null(defn) && (defn->cmd_num < num))
96 {
97 idx++;
98 defn++;
99 }
100 if(defn->cmd_num == num)
101 return idx;
102 /* The given cmd_num wasn't found */
103 return -1;
104 }
105
106static int int_ctrl_helper(ENGINE *e, int cmd, long i, void *p, void (*f)())
107 {
108 int idx;
109 char *s = (char *)p;
110 /* Take care of the easy one first (eg. it requires no searches) */
111 if(cmd == ENGINE_CTRL_GET_FIRST_CMD_TYPE)
112 {
113 if((e->cmd_defns == NULL) || int_ctrl_cmd_is_null(e->cmd_defns))
114 return 0;
115 return e->cmd_defns->cmd_num;
116 }
117 /* One or two commands require that "p" be a valid string buffer */
118 if((cmd == ENGINE_CTRL_GET_CMD_FROM_NAME) ||
119 (cmd == ENGINE_CTRL_GET_NAME_FROM_CMD) ||
120 (cmd == ENGINE_CTRL_GET_DESC_FROM_CMD))
121 {
122 if(s == NULL)
123 {
124 ENGINEerr(ENGINE_F_INT_CTRL_HELPER,
125 ERR_R_PASSED_NULL_PARAMETER);
126 return -1;
127 }
128 }
129 /* Now handle cmd_name -> cmd_num conversion */
130 if(cmd == ENGINE_CTRL_GET_CMD_FROM_NAME)
131 {
132 if((e->cmd_defns == NULL) || ((idx = int_ctrl_cmd_by_name(
133 e->cmd_defns, s)) < 0))
134 {
135 ENGINEerr(ENGINE_F_INT_CTRL_HELPER,
136 ENGINE_R_INVALID_CMD_NAME);
137 return -1;
138 }
139 return e->cmd_defns[idx].cmd_num;
140 }
141 /* For the rest of the commands, the 'long' argument must specify a
142 * valie command number - so we need to conduct a search. */
143 if((e->cmd_defns == NULL) || ((idx = int_ctrl_cmd_by_num(e->cmd_defns,
144 (unsigned int)i)) < 0))
145 {
146 ENGINEerr(ENGINE_F_INT_CTRL_HELPER,
147 ENGINE_R_INVALID_CMD_NUMBER);
148 return -1;
149 }
150 /* Now the logic splits depending on command type */
151 switch(cmd)
152 {
153 case ENGINE_CTRL_GET_NEXT_CMD_TYPE:
154 idx++;
155 if(int_ctrl_cmd_is_null(e->cmd_defns + idx))
156 /* end-of-list */
157 return 0;
158 else
159 return e->cmd_defns[idx].cmd_num;
160 case ENGINE_CTRL_GET_NAME_LEN_FROM_CMD:
161 return strlen(e->cmd_defns[idx].cmd_name);
162 case ENGINE_CTRL_GET_NAME_FROM_CMD:
163 return sprintf(s, "%s", e->cmd_defns[idx].cmd_name);
164 case ENGINE_CTRL_GET_DESC_LEN_FROM_CMD:
165 if(e->cmd_defns[idx].cmd_desc)
166 return strlen(e->cmd_defns[idx].cmd_desc);
167 return strlen(int_no_description);
168 case ENGINE_CTRL_GET_DESC_FROM_CMD:
169 if(e->cmd_defns[idx].cmd_desc)
170 return sprintf(s, "%s", e->cmd_defns[idx].cmd_desc);
171 return sprintf(s, "%s", int_no_description);
172 case ENGINE_CTRL_GET_CMD_FLAGS:
173 return e->cmd_defns[idx].cmd_flags;
174 }
175 /* Shouldn't really be here ... */
176 ENGINEerr(ENGINE_F_INT_CTRL_HELPER,ENGINE_R_INTERNAL_LIST_ERROR);
177 return -1;
178 }
179
180int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
181 {
182 int ctrl_exists, ref_exists;
183 if(e == NULL)
184 {
185 ENGINEerr(ENGINE_F_ENGINE_CTRL,ERR_R_PASSED_NULL_PARAMETER);
186 return 0;
187 }
188 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
189 ref_exists = ((e->struct_ref > 0) ? 1 : 0);
190 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
191 ctrl_exists = ((e->ctrl == NULL) ? 0 : 1);
192 if(!ref_exists)
193 {
194 ENGINEerr(ENGINE_F_ENGINE_CTRL,ENGINE_R_NO_REFERENCE);
195 return 0;
196 }
197 /* Intercept any "root-level" commands before trying to hand them on to
198 * ctrl() handlers. */
199 switch(cmd)
200 {
201 case ENGINE_CTRL_HAS_CTRL_FUNCTION:
202 return ctrl_exists;
203 case ENGINE_CTRL_GET_FIRST_CMD_TYPE:
204 case ENGINE_CTRL_GET_NEXT_CMD_TYPE:
205 case ENGINE_CTRL_GET_CMD_FROM_NAME:
206 case ENGINE_CTRL_GET_NAME_LEN_FROM_CMD:
207 case ENGINE_CTRL_GET_NAME_FROM_CMD:
208 case ENGINE_CTRL_GET_DESC_LEN_FROM_CMD:
209 case ENGINE_CTRL_GET_DESC_FROM_CMD:
210 case ENGINE_CTRL_GET_CMD_FLAGS:
211 if(ctrl_exists && !(e->flags & ENGINE_FLAGS_MANUAL_CMD_CTRL))
212 return int_ctrl_helper(e,cmd,i,p,f);
213 if(!ctrl_exists)
214 {
215 ENGINEerr(ENGINE_F_ENGINE_CTRL,ENGINE_R_NO_CONTROL_FUNCTION);
216 /* For these cmd-related functions, failure is indicated
217 * by a -1 return value (because 0 is used as a valid
218 * return in some places). */
219 return -1;
220 }
221 default:
222 break;
223 }
224 /* Anything else requires a ctrl() handler to exist. */
225 if(!ctrl_exists)
226 {
227 ENGINEerr(ENGINE_F_ENGINE_CTRL,ENGINE_R_NO_CONTROL_FUNCTION);
228 return 0;
229 }
230 return e->ctrl(e, cmd, i, p, f);
231 }
232
233int ENGINE_cmd_is_executable(ENGINE *e, int cmd)
234 {
235 int flags;
236 if((flags = ENGINE_ctrl(e, ENGINE_CTRL_GET_CMD_FLAGS, cmd, NULL, NULL)) < 0)
237 {
238 ENGINEerr(ENGINE_F_ENGINE_CMD_IS_EXECUTABLE,
239 ENGINE_R_INVALID_CMD_NUMBER);
240 return 0;
241 }
242 if(!(flags & ENGINE_CMD_FLAG_NO_INPUT) &&
243 !(flags & ENGINE_CMD_FLAG_NUMERIC) &&
244 !(flags & ENGINE_CMD_FLAG_STRING))
245 return 0;
246 return 1;
247 }
248
249int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name,
250 long i, void *p, void (*f)(), int cmd_optional)
251 {
252 int num;
253
254 if((e == NULL) || (cmd_name == NULL))
255 {
256 ENGINEerr(ENGINE_F_ENGINE_CTRL_CMD_STRING,
257 ERR_R_PASSED_NULL_PARAMETER);
258 return 0;
259 }
260 if((e->ctrl == NULL) || ((num = ENGINE_ctrl(e,
261 ENGINE_CTRL_GET_CMD_FROM_NAME,
262 0, (void *)cmd_name, NULL)) <= 0))
263 {
264 /* If the command didn't *have* to be supported, we fake
265 * success. This allows certain settings to be specified for
266 * multiple ENGINEs and only require a change of ENGINE id
267 * (without having to selectively apply settings). Eg. changing
268 * from a hardware device back to the regular software ENGINE
269 * without editing the config file, etc. */
270 if(cmd_optional)
271 {
272 ERR_clear_error();
273 return 1;
274 }
275 ENGINEerr(ENGINE_F_ENGINE_CTRL_CMD,
276 ENGINE_R_INVALID_CMD_NAME);
277 return 0;
278 }
279 /* Force the result of the control command to 0 or 1, for the reasons
280 * mentioned before. */
281 if (ENGINE_ctrl(e, num, i, p, f))
282 return 1;
283 return 0;
284 }
285
286int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg,
287 int cmd_optional)
288 {
289 int num, flags;
290 long l;
291 char *ptr;
292 if((e == NULL) || (cmd_name == NULL))
293 {
294 ENGINEerr(ENGINE_F_ENGINE_CTRL_CMD_STRING,
295 ERR_R_PASSED_NULL_PARAMETER);
296 return 0;
297 }
298 if((e->ctrl == NULL) || ((num = ENGINE_ctrl(e,
299 ENGINE_CTRL_GET_CMD_FROM_NAME,
300 0, (void *)cmd_name, NULL)) <= 0))
301 {
302 /* If the command didn't *have* to be supported, we fake
303 * success. This allows certain settings to be specified for
304 * multiple ENGINEs and only require a change of ENGINE id
305 * (without having to selectively apply settings). Eg. changing
306 * from a hardware device back to the regular software ENGINE
307 * without editing the config file, etc. */
308 if(cmd_optional)
309 {
310 ERR_clear_error();
311 return 1;
312 }
313 ENGINEerr(ENGINE_F_ENGINE_CTRL_CMD_STRING,
314 ENGINE_R_INVALID_CMD_NAME);
315 return 0;
316 }
317 if(!ENGINE_cmd_is_executable(e, num))
318 {
319 ENGINEerr(ENGINE_F_ENGINE_CTRL_CMD_STRING,
320 ENGINE_R_CMD_NOT_EXECUTABLE);
321 return 0;
322 }
323 if((flags = ENGINE_ctrl(e, ENGINE_CTRL_GET_CMD_FLAGS, num, NULL, NULL)) < 0)
324 {
325 /* Shouldn't happen, given that ENGINE_cmd_is_executable()
326 * returned success. */
327 ENGINEerr(ENGINE_F_ENGINE_CTRL_CMD_STRING,
328 ENGINE_R_INTERNAL_LIST_ERROR);
329 return 0;
330 }
331 /* If the command takes no input, there must be no input. And vice
332 * versa. */
333 if(flags & ENGINE_CMD_FLAG_NO_INPUT)
334 {
335 if(arg != NULL)
336 {
337 ENGINEerr(ENGINE_F_ENGINE_CTRL_CMD_STRING,
338 ENGINE_R_COMMAND_TAKES_NO_INPUT);
339 return 0;
340 }
341 /* We deliberately force the result of ENGINE_ctrl() to 0 or 1
342 * rather than returning it as "return data". This is to ensure
343 * usage of these commands is consistent across applications and
344 * that certain applications don't understand it one way, and
345 * others another. */
346 if(ENGINE_ctrl(e, num, 0, (void *)arg, NULL))
347 return 1;
348 return 0;
349 }
350 /* So, we require input */
351 if(arg == NULL)
352 {
353 ENGINEerr(ENGINE_F_ENGINE_CTRL_CMD_STRING,
354 ENGINE_R_COMMAND_TAKES_INPUT);
355 return 0;
356 }
357 /* If it takes string input, that's easy */
358 if(flags & ENGINE_CMD_FLAG_STRING)
359 {
360 /* Same explanation as above */
361 if(ENGINE_ctrl(e, num, 0, (void *)arg, NULL))
362 return 1;
363 return 0;
364 }
365 /* If it doesn't take numeric either, then it is unsupported for use in
366 * a config-setting situation, which is what this function is for. This
367 * should never happen though, because ENGINE_cmd_is_executable() was
368 * used. */
369 if(!(flags & ENGINE_CMD_FLAG_NUMERIC))
370 {
371 ENGINEerr(ENGINE_F_ENGINE_CTRL_CMD_STRING,
372 ENGINE_R_INTERNAL_LIST_ERROR);
373 return 0;
374 }
375 l = strtol(arg, &ptr, 10);
376 if((arg == ptr) || (*ptr != '\0'))
377 {
378 ENGINEerr(ENGINE_F_ENGINE_CTRL_CMD_STRING,
379 ENGINE_R_ARGUMENT_IS_NOT_A_NUMBER);
380 return 0;
381 }
382 /* Force the result of the control command to 0 or 1, for the reasons
383 * mentioned before. */
384 if(ENGINE_ctrl(e, num, l, NULL, NULL))
385 return 1;
386 return 0;
387 }
diff --git a/src/lib/libcrypto/engine/eng_dyn.c b/src/lib/libcrypto/engine/eng_dyn.c
new file mode 100644
index 0000000000..4fefcc0cae
--- /dev/null
+++ b/src/lib/libcrypto/engine/eng_dyn.c
@@ -0,0 +1,446 @@
1/* crypto/engine/eng_dyn.c */
2/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL
3 * project 2001.
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
60#include <stdio.h>
61#include <openssl/crypto.h>
62#include "cryptlib.h"
63#include "eng_int.h"
64#include <openssl/engine.h>
65#include <openssl/dso.h>
66
67/* Shared libraries implementing ENGINEs for use by the "dynamic" ENGINE loader
68 * should implement the hook-up functions with the following prototypes. */
69
70/* Our ENGINE handlers */
71static int dynamic_init(ENGINE *e);
72static int dynamic_finish(ENGINE *e);
73static int dynamic_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)());
74/* Predeclare our context type */
75typedef struct st_dynamic_data_ctx dynamic_data_ctx;
76/* The implementation for the important control command */
77static int dynamic_load(ENGINE *e, dynamic_data_ctx *ctx);
78
79#define DYNAMIC_CMD_SO_PATH ENGINE_CMD_BASE
80#define DYNAMIC_CMD_NO_VCHECK (ENGINE_CMD_BASE + 1)
81#define DYNAMIC_CMD_ID (ENGINE_CMD_BASE + 2)
82#define DYNAMIC_CMD_LIST_ADD (ENGINE_CMD_BASE + 3)
83#define DYNAMIC_CMD_LOAD (ENGINE_CMD_BASE + 4)
84
85/* The constants used when creating the ENGINE */
86static const char *engine_dynamic_id = "dynamic";
87static const char *engine_dynamic_name = "Dynamic engine loading support";
88static const ENGINE_CMD_DEFN dynamic_cmd_defns[] = {
89 {DYNAMIC_CMD_SO_PATH,
90 "SO_PATH",
91 "Specifies the path to the new ENGINE shared library",
92 ENGINE_CMD_FLAG_STRING},
93 {DYNAMIC_CMD_NO_VCHECK,
94 "NO_VCHECK",
95 "Specifies to continue even if version checking fails (boolean)",
96 ENGINE_CMD_FLAG_NUMERIC},
97 {DYNAMIC_CMD_ID,
98 "ID",
99 "Specifies an ENGINE id name for loading",
100 ENGINE_CMD_FLAG_STRING},
101 {DYNAMIC_CMD_LIST_ADD,
102 "LIST_ADD",
103 "Whether to add a loaded ENGINE to the internal list (0=no,1=yes,2=mandatory)",
104 ENGINE_CMD_FLAG_NUMERIC},
105 {DYNAMIC_CMD_LOAD,
106 "LOAD",
107 "Load up the ENGINE specified by other settings",
108 ENGINE_CMD_FLAG_NO_INPUT},
109 {0, NULL, NULL, 0}
110 };
111static const ENGINE_CMD_DEFN dynamic_cmd_defns_empty[] = {
112 {0, NULL, NULL, 0}
113 };
114
115/* Loading code stores state inside the ENGINE structure via the "ex_data"
116 * element. We load all our state into a single structure and use that as a
117 * single context in the "ex_data" stack. */
118struct st_dynamic_data_ctx
119 {
120 /* The DSO object we load that supplies the ENGINE code */
121 DSO *dynamic_dso;
122 /* The function pointer to the version checking shared library function */
123 dynamic_v_check_fn v_check;
124 /* The function pointer to the engine-binding shared library function */
125 dynamic_bind_engine bind_engine;
126 /* The default name/path for loading the shared library */
127 const char *DYNAMIC_LIBNAME;
128 /* Whether to continue loading on a version check failure */
129 int no_vcheck;
130 /* If non-NULL, stipulates the 'id' of the ENGINE to be loaded */
131 const char *engine_id;
132 /* If non-zero, a successfully loaded ENGINE should be added to the internal
133 * ENGINE list. If 2, the add must succeed or the entire load should fail. */
134 int list_add_value;
135 /* The symbol name for the version checking function */
136 const char *DYNAMIC_F1;
137 /* The symbol name for the "initialise ENGINE structure" function */
138 const char *DYNAMIC_F2;
139 };
140
141/* This is the "ex_data" index we obtain and reserve for use with our context
142 * structure. */
143static int dynamic_ex_data_idx = -1;
144
145/* Because our ex_data element may or may not get allocated depending on whether
146 * a "first-use" occurs before the ENGINE is freed, we have a memory leak
147 * problem to solve. We can't declare a "new" handler for the ex_data as we
148 * don't want a dynamic_data_ctx in *all* ENGINE structures of all types (this
149 * is a bug in the design of CRYPTO_EX_DATA). As such, we just declare a "free"
150 * handler and that will get called if an ENGINE is being destroyed and there
151 * was an ex_data element corresponding to our context type. */
152static void dynamic_data_ctx_free_func(void *parent, void *ptr,
153 CRYPTO_EX_DATA *ad, int idx, long argl, void *argp)
154 {
155 if(ptr)
156 {
157 dynamic_data_ctx *ctx = (dynamic_data_ctx *)ptr;
158 if(ctx->dynamic_dso)
159 DSO_free(ctx->dynamic_dso);
160 OPENSSL_free(ctx);
161 }
162 }
163
164/* Construct the per-ENGINE context. We create it blindly and then use a lock to
165 * check for a race - if so, all but one of the threads "racing" will have
166 * wasted their time. The alternative involves creating everything inside the
167 * lock which is far worse. */
168static int dynamic_set_data_ctx(ENGINE *e, dynamic_data_ctx **ctx)
169 {
170 dynamic_data_ctx *c;
171 c = OPENSSL_malloc(sizeof(dynamic_data_ctx));
172 if(!ctx)
173 {
174 ENGINEerr(ENGINE_F_SET_DATA_CTX,ERR_R_MALLOC_FAILURE);
175 return 0;
176 }
177 memset(c, 0, sizeof(dynamic_data_ctx));
178 c->dynamic_dso = NULL;
179 c->v_check = NULL;
180 c->bind_engine = NULL;
181 c->DYNAMIC_LIBNAME = NULL;
182 c->no_vcheck = 0;
183 c->engine_id = NULL;
184 c->list_add_value = 0;
185 c->DYNAMIC_F1 = "v_check";
186 c->DYNAMIC_F2 = "bind_engine";
187 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
188 if((*ctx = (dynamic_data_ctx *)ENGINE_get_ex_data(e,
189 dynamic_ex_data_idx)) == NULL)
190 {
191 /* Good, we're the first */
192 ENGINE_set_ex_data(e, dynamic_ex_data_idx, c);
193 *ctx = c;
194 c = NULL;
195 }
196 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
197 /* If we lost the race to set the context, c is non-NULL and *ctx is the
198 * context of the thread that won. */
199 if(c)
200 OPENSSL_free(c);
201 return 1;
202 }
203
204/* This function retrieves the context structure from an ENGINE's "ex_data", or
205 * if it doesn't exist yet, sets it up. */
206static dynamic_data_ctx *dynamic_get_data_ctx(ENGINE *e)
207 {
208 dynamic_data_ctx *ctx;
209 if(dynamic_ex_data_idx < 0)
210 {
211 /* Create and register the ENGINE ex_data, and associate our
212 * "free" function with it to ensure any allocated contexts get
213 * freed when an ENGINE goes underground. */
214 int new_idx = ENGINE_get_ex_new_index(0, NULL, NULL, NULL,
215 dynamic_data_ctx_free_func);
216 if(new_idx == -1)
217 {
218 ENGINEerr(ENGINE_F_DYNAMIC_GET_DATA_CTX,ENGINE_R_NO_INDEX);
219 return NULL;
220 }
221 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
222 /* Avoid a race by checking again inside this lock */
223 if(dynamic_ex_data_idx < 0)
224 {
225 /* Good, someone didn't beat us to it */
226 dynamic_ex_data_idx = new_idx;
227 new_idx = -1;
228 }
229 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
230 /* In theory we could "give back" the index here if
231 * (new_idx>-1), but it's not possible and wouldn't gain us much
232 * if it were. */
233 }
234 ctx = (dynamic_data_ctx *)ENGINE_get_ex_data(e, dynamic_ex_data_idx);
235 /* Check if the context needs to be created */
236 if((ctx == NULL) && !dynamic_set_data_ctx(e, &ctx))
237 /* "set_data" will set errors if necessary */
238 return NULL;
239 return ctx;
240 }
241
242static ENGINE *engine_dynamic(void)
243 {
244 ENGINE *ret = ENGINE_new();
245 if(!ret)
246 return NULL;
247 if(!ENGINE_set_id(ret, engine_dynamic_id) ||
248 !ENGINE_set_name(ret, engine_dynamic_name) ||
249 !ENGINE_set_init_function(ret, dynamic_init) ||
250 !ENGINE_set_finish_function(ret, dynamic_finish) ||
251 !ENGINE_set_ctrl_function(ret, dynamic_ctrl) ||
252 !ENGINE_set_flags(ret, ENGINE_FLAGS_BY_ID_COPY) ||
253 !ENGINE_set_cmd_defns(ret, dynamic_cmd_defns))
254 {
255 ENGINE_free(ret);
256 return NULL;
257 }
258 return ret;
259 }
260
261void ENGINE_load_dynamic(void)
262 {
263 ENGINE *toadd = engine_dynamic();
264 if(!toadd) return;
265 ENGINE_add(toadd);
266 /* If the "add" worked, it gets a structural reference. So either way,
267 * we release our just-created reference. */
268 ENGINE_free(toadd);
269 /* If the "add" didn't work, it was probably a conflict because it was
270 * already added (eg. someone calling ENGINE_load_blah then calling
271 * ENGINE_load_builtin_engines() perhaps). */
272 ERR_clear_error();
273 }
274
275static int dynamic_init(ENGINE *e)
276 {
277 /* We always return failure - the "dyanamic" engine itself can't be used
278 * for anything. */
279 return 0;
280 }
281
282static int dynamic_finish(ENGINE *e)
283 {
284 /* This should never be called on account of "dynamic_init" always
285 * failing. */
286 return 0;
287 }
288
289static int dynamic_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
290 {
291 dynamic_data_ctx *ctx = dynamic_get_data_ctx(e);
292 int initialised;
293
294 if(!ctx)
295 {
296 ENGINEerr(ENGINE_F_DYNAMIC_CTRL,ENGINE_R_NOT_LOADED);
297 return 0;
298 }
299 initialised = ((ctx->dynamic_dso == NULL) ? 0 : 1);
300 /* All our control commands require the ENGINE to be uninitialised */
301 if(initialised)
302 {
303 ENGINEerr(ENGINE_F_DYNAMIC_CTRL,
304 ENGINE_R_ALREADY_LOADED);
305 return 0;
306 }
307 switch(cmd)
308 {
309 case DYNAMIC_CMD_SO_PATH:
310 /* a NULL 'p' or a string of zero-length is the same thing */
311 if(p && (strlen((const char *)p) < 1))
312 p = NULL;
313 ctx->DYNAMIC_LIBNAME = (const char *)p;
314 return 1;
315 case DYNAMIC_CMD_NO_VCHECK:
316 ctx->no_vcheck = ((i == 0) ? 0 : 1);
317 return 1;
318 case DYNAMIC_CMD_ID:
319 /* a NULL 'p' or a string of zero-length is the same thing */
320 if(p && (strlen((const char *)p) < 1))
321 p = NULL;
322 ctx->engine_id = (const char *)p;
323 return 1;
324 case DYNAMIC_CMD_LIST_ADD:
325 if((i < 0) || (i > 2))
326 {
327 ENGINEerr(ENGINE_F_DYNAMIC_CTRL,
328 ENGINE_R_INVALID_ARGUMENT);
329 return 0;
330 }
331 ctx->list_add_value = (int)i;
332 return 1;
333 case DYNAMIC_CMD_LOAD:
334 return dynamic_load(e, ctx);
335 default:
336 break;
337 }
338 ENGINEerr(ENGINE_F_DYNAMIC_CTRL,ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED);
339 return 0;
340 }
341
342static int dynamic_load(ENGINE *e, dynamic_data_ctx *ctx)
343 {
344 ENGINE cpy;
345 dynamic_fns fns;
346
347 if(!ctx->DYNAMIC_LIBNAME || ((ctx->dynamic_dso = DSO_load(NULL,
348 ctx->DYNAMIC_LIBNAME, NULL, 0)) == NULL))
349 {
350 ENGINEerr(ENGINE_F_DYNAMIC_LOAD,
351 ENGINE_R_DSO_NOT_FOUND);
352 return 0;
353 }
354 /* We have to find a bind function otherwise it'll always end badly */
355 if(!(ctx->bind_engine = (dynamic_bind_engine)DSO_bind_func(
356 ctx->dynamic_dso, ctx->DYNAMIC_F2)))
357 {
358 ctx->bind_engine = NULL;
359 DSO_free(ctx->dynamic_dso);
360 ctx->dynamic_dso = NULL;
361 ENGINEerr(ENGINE_F_DYNAMIC_LOAD,
362 ENGINE_R_DSO_FAILURE);
363 return 0;
364 }
365 /* Do we perform version checking? */
366 if(!ctx->no_vcheck)
367 {
368 unsigned long vcheck_res = 0;
369 /* Now we try to find a version checking function and decide how
370 * to cope with failure if/when it fails. */
371 ctx->v_check = (dynamic_v_check_fn)DSO_bind_func(
372 ctx->dynamic_dso, ctx->DYNAMIC_F1);
373 if(ctx->v_check)
374 vcheck_res = ctx->v_check(OSSL_DYNAMIC_VERSION);
375 /* We fail if the version checker veto'd the load *or* if it is
376 * deferring to us (by returning its version) and we think it is
377 * too old. */
378 if(vcheck_res < OSSL_DYNAMIC_OLDEST)
379 {
380 /* Fail */
381 ctx->bind_engine = NULL;
382 ctx->v_check = NULL;
383 DSO_free(ctx->dynamic_dso);
384 ctx->dynamic_dso = NULL;
385 ENGINEerr(ENGINE_F_DYNAMIC_LOAD,
386 ENGINE_R_VERSION_INCOMPATIBILITY);
387 return 0;
388 }
389 }
390 /* First binary copy the ENGINE structure so that we can roll back if
391 * the hand-over fails */
392 memcpy(&cpy, e, sizeof(ENGINE));
393 /* Provide the ERR, "ex_data", memory, and locking callbacks so the
394 * loaded library uses our state rather than its own. FIXME: As noted in
395 * engine.h, much of this would be simplified if each area of code
396 * provided its own "summary" structure of all related callbacks. It
397 * would also increase opaqueness. */
398 fns.err_fns = ERR_get_implementation();
399 fns.ex_data_fns = CRYPTO_get_ex_data_implementation();
400 CRYPTO_get_mem_functions(&fns.mem_fns.malloc_cb,
401 &fns.mem_fns.realloc_cb,
402 &fns.mem_fns.free_cb);
403 fns.lock_fns.lock_locking_cb = CRYPTO_get_locking_callback();
404 fns.lock_fns.lock_add_lock_cb = CRYPTO_get_add_lock_callback();
405 fns.lock_fns.dynlock_create_cb = CRYPTO_get_dynlock_create_callback();
406 fns.lock_fns.dynlock_lock_cb = CRYPTO_get_dynlock_lock_callback();
407 fns.lock_fns.dynlock_destroy_cb = CRYPTO_get_dynlock_destroy_callback();
408 /* Now that we've loaded the dynamic engine, make sure no "dynamic"
409 * ENGINE elements will show through. */
410 engine_set_all_null(e);
411
412 /* Try to bind the ENGINE onto our own ENGINE structure */
413 if(!ctx->bind_engine(e, ctx->engine_id, &fns))
414 {
415 ctx->bind_engine = NULL;
416 ctx->v_check = NULL;
417 DSO_free(ctx->dynamic_dso);
418 ctx->dynamic_dso = NULL;
419 ENGINEerr(ENGINE_F_DYNAMIC_LOAD,ENGINE_R_INIT_FAILED);
420 /* Copy the original ENGINE structure back */
421 memcpy(e, &cpy, sizeof(ENGINE));
422 return 0;
423 }
424 /* Do we try to add this ENGINE to the internal list too? */
425 if(ctx->list_add_value > 0)
426 {
427 if(!ENGINE_add(e))
428 {
429 /* Do we tolerate this or fail? */
430 if(ctx->list_add_value > 1)
431 {
432 /* Fail - NB: By this time, it's too late to
433 * rollback, and trying to do so allows the
434 * bind_engine() code to have created leaks. We
435 * just have to fail where we are, after the
436 * ENGINE has changed. */
437 ENGINEerr(ENGINE_F_DYNAMIC_LOAD,
438 ENGINE_R_CONFLICTING_ENGINE_ID);
439 return 0;
440 }
441 /* Tolerate */
442 ERR_clear_error();
443 }
444 }
445 return 1;
446 }
diff --git a/src/lib/libcrypto/engine/eng_err.c b/src/lib/libcrypto/engine/eng_err.c
new file mode 100644
index 0000000000..f6c5630395
--- /dev/null
+++ b/src/lib/libcrypto/engine/eng_err.c
@@ -0,0 +1,165 @@
1/* crypto/engine/eng_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 <openssl/engine.h>
64
65/* BEGIN ERROR CODES */
66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA ENGINE_str_functs[]=
68 {
69{ERR_PACK(0,ENGINE_F_DYNAMIC_CTRL,0), "DYNAMIC_CTRL"},
70{ERR_PACK(0,ENGINE_F_DYNAMIC_GET_DATA_CTX,0), "DYNAMIC_GET_DATA_CTX"},
71{ERR_PACK(0,ENGINE_F_DYNAMIC_LOAD,0), "DYNAMIC_LOAD"},
72{ERR_PACK(0,ENGINE_F_ENGINE_ADD,0), "ENGINE_add"},
73{ERR_PACK(0,ENGINE_F_ENGINE_BY_ID,0), "ENGINE_by_id"},
74{ERR_PACK(0,ENGINE_F_ENGINE_CMD_IS_EXECUTABLE,0), "ENGINE_cmd_is_executable"},
75{ERR_PACK(0,ENGINE_F_ENGINE_CTRL,0), "ENGINE_ctrl"},
76{ERR_PACK(0,ENGINE_F_ENGINE_CTRL_CMD,0), "ENGINE_ctrl_cmd"},
77{ERR_PACK(0,ENGINE_F_ENGINE_CTRL_CMD_STRING,0), "ENGINE_ctrl_cmd_string"},
78{ERR_PACK(0,ENGINE_F_ENGINE_FINISH,0), "ENGINE_finish"},
79{ERR_PACK(0,ENGINE_F_ENGINE_FREE,0), "ENGINE_free"},
80{ERR_PACK(0,ENGINE_F_ENGINE_GET_CIPHER,0), "ENGINE_get_cipher"},
81{ERR_PACK(0,ENGINE_F_ENGINE_GET_DEFAULT_TYPE,0), "ENGINE_GET_DEFAULT_TYPE"},
82{ERR_PACK(0,ENGINE_F_ENGINE_GET_DIGEST,0), "ENGINE_get_digest"},
83{ERR_PACK(0,ENGINE_F_ENGINE_GET_NEXT,0), "ENGINE_get_next"},
84{ERR_PACK(0,ENGINE_F_ENGINE_GET_PREV,0), "ENGINE_get_prev"},
85{ERR_PACK(0,ENGINE_F_ENGINE_INIT,0), "ENGINE_init"},
86{ERR_PACK(0,ENGINE_F_ENGINE_LIST_ADD,0), "ENGINE_LIST_ADD"},
87{ERR_PACK(0,ENGINE_F_ENGINE_LIST_REMOVE,0), "ENGINE_LIST_REMOVE"},
88{ERR_PACK(0,ENGINE_F_ENGINE_LOAD_PRIVATE_KEY,0), "ENGINE_load_private_key"},
89{ERR_PACK(0,ENGINE_F_ENGINE_LOAD_PUBLIC_KEY,0), "ENGINE_load_public_key"},
90{ERR_PACK(0,ENGINE_F_ENGINE_MODULE_INIT,0), "ENGINE_MODULE_INIT"},
91{ERR_PACK(0,ENGINE_F_ENGINE_NEW,0), "ENGINE_new"},
92{ERR_PACK(0,ENGINE_F_ENGINE_REMOVE,0), "ENGINE_remove"},
93{ERR_PACK(0,ENGINE_F_ENGINE_SET_DEFAULT_STRING,0), "ENGINE_set_default_string"},
94{ERR_PACK(0,ENGINE_F_ENGINE_SET_DEFAULT_TYPE,0), "ENGINE_SET_DEFAULT_TYPE"},
95{ERR_PACK(0,ENGINE_F_ENGINE_SET_ID,0), "ENGINE_set_id"},
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"},
98{ERR_PACK(0,ENGINE_F_ENGINE_UNLOAD_KEY,0), "ENGINE_UNLOAD_KEY"},
99{ERR_PACK(0,ENGINE_F_INT_CTRL_HELPER,0), "INT_CTRL_HELPER"},
100{ERR_PACK(0,ENGINE_F_INT_ENGINE_CONFIGURE,0), "INT_ENGINE_CONFIGURE"},
101{ERR_PACK(0,ENGINE_F_LOG_MESSAGE,0), "LOG_MESSAGE"},
102{ERR_PACK(0,ENGINE_F_SET_DATA_CTX,0), "SET_DATA_CTX"},
103{0,NULL}
104 };
105
106static ERR_STRING_DATA ENGINE_str_reasons[]=
107 {
108{ENGINE_R_ALREADY_LOADED ,"already loaded"},
109{ENGINE_R_ARGUMENT_IS_NOT_A_NUMBER ,"argument is not a number"},
110{ENGINE_R_CMD_NOT_EXECUTABLE ,"cmd not executable"},
111{ENGINE_R_COMMAND_TAKES_INPUT ,"command takes input"},
112{ENGINE_R_COMMAND_TAKES_NO_INPUT ,"command takes no input"},
113{ENGINE_R_CONFLICTING_ENGINE_ID ,"conflicting engine id"},
114{ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED ,"ctrl command not implemented"},
115{ENGINE_R_DH_NOT_IMPLEMENTED ,"dh not implemented"},
116{ENGINE_R_DSA_NOT_IMPLEMENTED ,"dsa not implemented"},
117{ENGINE_R_DSO_FAILURE ,"DSO failure"},
118{ENGINE_R_DSO_NOT_FOUND ,"dso not found"},
119{ENGINE_R_ENGINES_SECTION_ERROR ,"engines section error"},
120{ENGINE_R_ENGINE_IS_NOT_IN_LIST ,"engine is not in the list"},
121{ENGINE_R_ENGINE_SECTION_ERROR ,"engine section error"},
122{ENGINE_R_FAILED_LOADING_PRIVATE_KEY ,"failed loading private key"},
123{ENGINE_R_FAILED_LOADING_PUBLIC_KEY ,"failed loading public key"},
124{ENGINE_R_FINISH_FAILED ,"finish failed"},
125{ENGINE_R_GET_HANDLE_FAILED ,"could not obtain hardware handle"},
126{ENGINE_R_ID_OR_NAME_MISSING ,"'id' or 'name' missing"},
127{ENGINE_R_INIT_FAILED ,"init failed"},
128{ENGINE_R_INTERNAL_LIST_ERROR ,"internal list error"},
129{ENGINE_R_INVALID_ARGUMENT ,"invalid argument"},
130{ENGINE_R_INVALID_CMD_NAME ,"invalid cmd name"},
131{ENGINE_R_INVALID_CMD_NUMBER ,"invalid cmd number"},
132{ENGINE_R_INVALID_INIT_VALUE ,"invalid init value"},
133{ENGINE_R_INVALID_STRING ,"invalid string"},
134{ENGINE_R_NOT_INITIALISED ,"not initialised"},
135{ENGINE_R_NOT_LOADED ,"not loaded"},
136{ENGINE_R_NO_CONTROL_FUNCTION ,"no control function"},
137{ENGINE_R_NO_INDEX ,"no index"},
138{ENGINE_R_NO_LOAD_FUNCTION ,"no load function"},
139{ENGINE_R_NO_REFERENCE ,"no reference"},
140{ENGINE_R_NO_SUCH_ENGINE ,"no such engine"},
141{ENGINE_R_NO_UNLOAD_FUNCTION ,"no unload function"},
142{ENGINE_R_PROVIDE_PARAMETERS ,"provide parameters"},
143{ENGINE_R_RSA_NOT_IMPLEMENTED ,"rsa not implemented"},
144{ENGINE_R_UNIMPLEMENTED_CIPHER ,"unimplemented cipher"},
145{ENGINE_R_UNIMPLEMENTED_DIGEST ,"unimplemented digest"},
146{ENGINE_R_VERSION_INCOMPATIBILITY ,"version incompatibility"},
147{0,NULL}
148 };
149
150#endif
151
152void ERR_load_ENGINE_strings(void)
153 {
154 static int init=1;
155
156 if (init)
157 {
158 init=0;
159#ifndef OPENSSL_NO_ERR
160 ERR_load_strings(ERR_LIB_ENGINE,ENGINE_str_functs);
161 ERR_load_strings(ERR_LIB_ENGINE,ENGINE_str_reasons);
162#endif
163
164 }
165 }
diff --git a/src/lib/libcrypto/engine/eng_fat.c b/src/lib/libcrypto/engine/eng_fat.c
new file mode 100644
index 0000000000..af918b1499
--- /dev/null
+++ b/src/lib/libcrypto/engine/eng_fat.c
@@ -0,0 +1,148 @@
1/* crypto/engine/eng_fat.c */
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/crypto.h>
57#include "cryptlib.h"
58#include "eng_int.h"
59#include <openssl/engine.h>
60#include <openssl/conf.h>
61
62int ENGINE_set_default(ENGINE *e, unsigned int flags)
63 {
64 if((flags & ENGINE_METHOD_CIPHERS) && !ENGINE_set_default_ciphers(e))
65 return 0;
66 if((flags & ENGINE_METHOD_DIGESTS) && !ENGINE_set_default_digests(e))
67 return 0;
68#ifndef OPENSSL_NO_RSA
69 if((flags & ENGINE_METHOD_RSA) & !ENGINE_set_default_RSA(e))
70 return 0;
71#endif
72#ifndef OPENSSL_NO_DSA
73 if((flags & ENGINE_METHOD_DSA) & !ENGINE_set_default_DSA(e))
74 return 0;
75#endif
76#ifndef OPENSSL_NO_DH
77 if((flags & ENGINE_METHOD_DH) & !ENGINE_set_default_DH(e))
78 return 0;
79#endif
80 if((flags & ENGINE_METHOD_RAND) & !ENGINE_set_default_RAND(e))
81 return 0;
82 return 1;
83 }
84
85/* Set default algorithms using a string */
86
87int int_def_cb(const char *alg, int len, void *arg)
88 {
89 unsigned int *pflags = arg;
90 if (!strncmp(alg, "ALL", len))
91 *pflags |= ENGINE_METHOD_ALL;
92 else if (!strncmp(alg, "RSA", len))
93 *pflags |= ENGINE_METHOD_RSA;
94 else if (!strncmp(alg, "DSA", len))
95 *pflags |= ENGINE_METHOD_DSA;
96 else if (!strncmp(alg, "DH", len))
97 *pflags |= ENGINE_METHOD_DH;
98 else if (!strncmp(alg, "RAND", len))
99 *pflags |= ENGINE_METHOD_RAND;
100 else if (!strncmp(alg, "CIPHERS", len))
101 *pflags |= ENGINE_METHOD_CIPHERS;
102 else if (!strncmp(alg, "DIGESTS", len))
103 *pflags |= ENGINE_METHOD_DIGESTS;
104 else
105 return 0;
106 return 1;
107 }
108
109
110int ENGINE_set_default_string(ENGINE *e, const char *list)
111 {
112 unsigned int flags = 0;
113 if (!CONF_parse_list(list, ',', 1, int_def_cb, &flags))
114 {
115 ENGINEerr(ENGINE_F_ENGINE_SET_DEFAULT_STRING,
116 ENGINE_R_INVALID_STRING);
117 ERR_add_error_data(2, "str=",list);
118 return 0;
119 }
120 return ENGINE_set_default(e, flags);
121 }
122
123int ENGINE_register_complete(ENGINE *e)
124 {
125 ENGINE_register_ciphers(e);
126 ENGINE_register_digests(e);
127#ifndef OPENSSL_NO_RSA
128 ENGINE_register_RSA(e);
129#endif
130#ifndef OPENSSL_NO_DSA
131 ENGINE_register_DSA(e);
132#endif
133#ifndef OPENSSL_NO_DH
134 ENGINE_register_DH(e);
135#endif
136 ENGINE_register_RAND(e);
137 return 1;
138 }
139
140int ENGINE_register_all_complete(void)
141 {
142 ENGINE *e;
143
144 for(e=ENGINE_get_first() ; e ; e=ENGINE_get_next(e)) {
145 ENGINE_register_complete(e);
146 }
147 return 1;
148 }
diff --git a/src/lib/libcrypto/engine/eng_init.c b/src/lib/libcrypto/engine/eng_init.c
new file mode 100644
index 0000000000..cc9396e863
--- /dev/null
+++ b/src/lib/libcrypto/engine/eng_init.c
@@ -0,0 +1,158 @@
1/* crypto/engine/eng_init.c */
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/crypto.h>
57#include "cryptlib.h"
58#include "eng_int.h"
59#include <openssl/engine.h>
60
61/* Initialise a engine type for use (or up its functional reference count
62 * if it's already in use). This version is only used internally. */
63int engine_unlocked_init(ENGINE *e)
64 {
65 int to_return = 1;
66
67 if((e->funct_ref == 0) && e->init)
68 /* This is the first functional reference and the engine
69 * requires initialisation so we do it now. */
70 to_return = e->init(e);
71 if(to_return)
72 {
73 /* OK, we return a functional reference which is also a
74 * structural reference. */
75 e->struct_ref++;
76 e->funct_ref++;
77 engine_ref_debug(e, 0, 1)
78 engine_ref_debug(e, 1, 1)
79 }
80 return to_return;
81 }
82
83/* Free a functional reference to a engine type. This version is only used
84 * internally. */
85int engine_unlocked_finish(ENGINE *e, int unlock_for_handlers)
86 {
87 int to_return = 1;
88
89 /* Reduce the functional reference count here so if it's the terminating
90 * case, we can release the lock safely and call the finish() handler
91 * without risk of a race. We get a race if we leave the count until
92 * after and something else is calling "finish" at the same time -
93 * there's a chance that both threads will together take the count from
94 * 2 to 0 without either calling finish(). */
95 e->funct_ref--;
96 engine_ref_debug(e, 1, -1);
97 if((e->funct_ref == 0) && e->finish)
98 {
99 if(unlock_for_handlers)
100 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
101 to_return = e->finish(e);
102 if(unlock_for_handlers)
103 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
104 if(!to_return)
105 return 0;
106 }
107#ifdef REF_CHECK
108 if(e->funct_ref < 0)
109 {
110 fprintf(stderr,"ENGINE_finish, bad functional reference count\n");
111 abort();
112 }
113#endif
114 /* Release the structural reference too */
115 if(!engine_free_util(e, 0))
116 {
117 ENGINEerr(ENGINE_F_ENGINE_FINISH,ENGINE_R_FINISH_FAILED);
118 return 0;
119 }
120 return to_return;
121 }
122
123/* The API (locked) version of "init" */
124int ENGINE_init(ENGINE *e)
125 {
126 int ret;
127 if(e == NULL)
128 {
129 ENGINEerr(ENGINE_F_ENGINE_INIT,ERR_R_PASSED_NULL_PARAMETER);
130 return 0;
131 }
132 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
133 ret = engine_unlocked_init(e);
134 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
135 return ret;
136 }
137
138/* The API (locked) version of "finish" */
139int ENGINE_finish(ENGINE *e)
140 {
141 int to_return = 1;
142
143 if(e == NULL)
144 {
145 ENGINEerr(ENGINE_F_ENGINE_FINISH,ERR_R_PASSED_NULL_PARAMETER);
146 return 0;
147 }
148 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
149 to_return = engine_unlocked_finish(e, 1);
150 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
151 if(!to_return)
152 {
153 ENGINEerr(ENGINE_F_ENGINE_FINISH,ENGINE_R_FINISH_FAILED);
154 return 0;
155 }
156 return to_return;
157 }
158
diff --git a/src/lib/libcrypto/engine/eng_int.h b/src/lib/libcrypto/engine/eng_int.h
new file mode 100644
index 0000000000..38335f99cd
--- /dev/null
+++ b/src/lib/libcrypto/engine/eng_int.h
@@ -0,0 +1,185 @@
1/* crypto/engine/eng_int.h */
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#ifndef HEADER_ENGINE_INT_H
60#define HEADER_ENGINE_INT_H
61
62/* Take public definitions from engine.h */
63#include <openssl/engine.h>
64
65#ifdef __cplusplus
66extern "C" {
67#endif
68
69/* If we compile with this symbol defined, then both reference counts in the
70 * ENGINE structure will be monitored with a line of output on stderr for each
71 * change. This prints the engine's pointer address (truncated to unsigned int),
72 * "struct" or "funct" to indicate the reference type, the before and after
73 * reference count, and the file:line-number pair. The "engine_ref_debug"
74 * statements must come *after* the change. */
75#ifdef ENGINE_REF_COUNT_DEBUG
76
77#define engine_ref_debug(e, isfunct, diff) \
78 fprintf(stderr, "engine: %08x %s from %d to %d (%s:%d)\n", \
79 (unsigned int)(e), (isfunct ? "funct" : "struct"), \
80 ((isfunct) ? ((e)->funct_ref - (diff)) : ((e)->struct_ref - (diff))), \
81 ((isfunct) ? (e)->funct_ref : (e)->struct_ref), \
82 (__FILE__), (__LINE__));
83
84#else
85
86#define engine_ref_debug(e, isfunct, diff)
87
88#endif
89
90/* Any code that will need cleanup operations should use these functions to
91 * register callbacks. ENGINE_cleanup() will call all registered callbacks in
92 * order. NB: both the "add" functions assume CRYPTO_LOCK_ENGINE to already be
93 * held (in "write" mode). */
94typedef void (ENGINE_CLEANUP_CB)(void);
95typedef struct st_engine_cleanup_item
96 {
97 ENGINE_CLEANUP_CB *cb;
98 } ENGINE_CLEANUP_ITEM;
99DECLARE_STACK_OF(ENGINE_CLEANUP_ITEM)
100void engine_cleanup_add_first(ENGINE_CLEANUP_CB *cb);
101void engine_cleanup_add_last(ENGINE_CLEANUP_CB *cb);
102
103/* We need stacks of ENGINEs for use in eng_table.c */
104DECLARE_STACK_OF(ENGINE)
105
106/* If this symbol is defined then engine_table_select(), the function that is
107 * used by RSA, DSA (etc) code to select registered ENGINEs, cache defaults and
108 * functional references (etc), will display debugging summaries to stderr. */
109/* #define ENGINE_TABLE_DEBUG */
110
111/* This represents an implementation table. Dependent code should instantiate it
112 * as a (ENGINE_TABLE *) pointer value set initially to NULL. */
113typedef struct st_engine_table ENGINE_TABLE;
114int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup,
115 ENGINE *e, const int *nids, int num_nids, int setdefault);
116void engine_table_unregister(ENGINE_TABLE **table, ENGINE *e);
117void engine_table_cleanup(ENGINE_TABLE **table);
118#ifndef ENGINE_TABLE_DEBUG
119ENGINE *engine_table_select(ENGINE_TABLE **table, int nid);
120#else
121ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f, int l);
122#define engine_table_select(t,n) engine_table_select_tmp(t,n,__FILE__,__LINE__)
123#endif
124
125/* Internal versions of API functions that have control over locking. These are
126 * used between C files when functionality needs to be shared but the caller may
127 * already be controlling of the CRYPTO_LOCK_ENGINE lock. */
128int engine_unlocked_init(ENGINE *e);
129int engine_unlocked_finish(ENGINE *e, int unlock_for_handlers);
130int engine_free_util(ENGINE *e, int locked);
131
132/* This function will reset all "set"able values in an ENGINE to NULL. This
133 * won't touch reference counts or ex_data, but is equivalent to calling all the
134 * ENGINE_set_***() functions with a NULL value. */
135void engine_set_all_null(ENGINE *e);
136
137/* NB: Bitwise OR-able values for the "flags" variable in ENGINE are now exposed
138 * in engine.h. */
139
140/* This is a structure for storing implementations of various crypto
141 * algorithms and functions. */
142struct engine_st
143 {
144 const char *id;
145 const char *name;
146 const RSA_METHOD *rsa_meth;
147 const DSA_METHOD *dsa_meth;
148 const DH_METHOD *dh_meth;
149 const RAND_METHOD *rand_meth;
150 /* Cipher handling is via this callback */
151 ENGINE_CIPHERS_PTR ciphers;
152 /* Digest handling is via this callback */
153 ENGINE_DIGESTS_PTR digests;
154
155
156 ENGINE_GEN_INT_FUNC_PTR destroy;
157
158 ENGINE_GEN_INT_FUNC_PTR init;
159 ENGINE_GEN_INT_FUNC_PTR finish;
160 ENGINE_CTRL_FUNC_PTR ctrl;
161 ENGINE_LOAD_KEY_PTR load_privkey;
162 ENGINE_LOAD_KEY_PTR load_pubkey;
163
164 const ENGINE_CMD_DEFN *cmd_defns;
165 int flags;
166 /* reference count on the structure itself */
167 int struct_ref;
168 /* reference count on usability of the engine type. NB: This
169 * controls the loading and initialisation of any functionlity
170 * required by this engine, whereas the previous count is
171 * simply to cope with (de)allocation of this structure. Hence,
172 * running_ref <= struct_ref at all times. */
173 int funct_ref;
174 /* A place to store per-ENGINE data */
175 CRYPTO_EX_DATA ex_data;
176 /* Used to maintain the linked-list of engines. */
177 struct engine_st *prev;
178 struct engine_st *next;
179 };
180
181#ifdef __cplusplus
182}
183#endif
184
185#endif /* HEADER_ENGINE_INT_H */
diff --git a/src/lib/libcrypto/engine/eng_lib.c b/src/lib/libcrypto/engine/eng_lib.c
new file mode 100644
index 0000000000..a66d0f08af
--- /dev/null
+++ b/src/lib/libcrypto/engine/eng_lib.c
@@ -0,0 +1,321 @@
1/* crypto/engine/eng_lib.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/crypto.h>
60#include "cryptlib.h"
61#include "eng_int.h"
62#include <openssl/rand.h> /* FIXME: This shouldn't be needed */
63#include <openssl/engine.h>
64
65/* The "new"/"free" stuff first */
66
67ENGINE *ENGINE_new(void)
68 {
69 ENGINE *ret;
70
71 ret = (ENGINE *)OPENSSL_malloc(sizeof(ENGINE));
72 if(ret == NULL)
73 {
74 ENGINEerr(ENGINE_F_ENGINE_NEW, ERR_R_MALLOC_FAILURE);
75 return NULL;
76 }
77 memset(ret, 0, sizeof(ENGINE));
78 ret->struct_ref = 1;
79 engine_ref_debug(ret, 0, 1)
80 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_ENGINE, ret, &ret->ex_data);
81 return ret;
82 }
83
84/* Placed here (close proximity to ENGINE_new) so that modifications to the
85 * elements of the ENGINE structure are more likely to be caught and changed
86 * here. */
87void engine_set_all_null(ENGINE *e)
88 {
89 e->id = NULL;
90 e->name = NULL;
91 e->rsa_meth = NULL;
92 e->dsa_meth = NULL;
93 e->dh_meth = NULL;
94 e->rand_meth = NULL;
95 e->ciphers = NULL;
96 e->digests = NULL;
97 e->destroy = NULL;
98 e->init = NULL;
99 e->finish = NULL;
100 e->ctrl = NULL;
101 e->load_privkey = NULL;
102 e->load_pubkey = NULL;
103 e->cmd_defns = NULL;
104 e->flags = 0;
105 }
106
107int engine_free_util(ENGINE *e, int locked)
108 {
109 int i;
110
111 if(e == NULL)
112 {
113 ENGINEerr(ENGINE_F_ENGINE_FREE,
114 ERR_R_PASSED_NULL_PARAMETER);
115 return 0;
116 }
117 if(locked)
118 i = CRYPTO_add(&e->struct_ref,-1,CRYPTO_LOCK_ENGINE);
119 else
120 i = --e->struct_ref;
121 engine_ref_debug(e, 0, -1)
122 if (i > 0) return 1;
123#ifdef REF_CHECK
124 if (i < 0)
125 {
126 fprintf(stderr,"ENGINE_free, bad structural reference count\n");
127 abort();
128 }
129#endif
130 /* Give the ENGINE a chance to do any structural cleanup corresponding
131 * to allocation it did in its constructor (eg. unload error strings) */
132 if(e->destroy)
133 e->destroy(e);
134 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_ENGINE, e, &e->ex_data);
135 OPENSSL_free(e);
136 return 1;
137 }
138
139int ENGINE_free(ENGINE *e)
140 {
141 return engine_free_util(e, 1);
142 }
143
144/* Cleanup stuff */
145
146/* ENGINE_cleanup() is coded such that anything that does work that will need
147 * cleanup can register a "cleanup" callback here. That way we don't get linker
148 * bloat by referring to all *possible* cleanups, but any linker bloat into code
149 * "X" will cause X's cleanup function to end up here. */
150static STACK_OF(ENGINE_CLEANUP_ITEM) *cleanup_stack = NULL;
151static int int_cleanup_check(int create)
152 {
153 if(cleanup_stack) return 1;
154 if(!create) return 0;
155 cleanup_stack = sk_ENGINE_CLEANUP_ITEM_new_null();
156 return (cleanup_stack ? 1 : 0);
157 }
158static ENGINE_CLEANUP_ITEM *int_cleanup_item(ENGINE_CLEANUP_CB *cb)
159 {
160 ENGINE_CLEANUP_ITEM *item = OPENSSL_malloc(sizeof(
161 ENGINE_CLEANUP_ITEM));
162 if(!item) return NULL;
163 item->cb = cb;
164 return item;
165 }
166void engine_cleanup_add_first(ENGINE_CLEANUP_CB *cb)
167 {
168 ENGINE_CLEANUP_ITEM *item;
169 if(!int_cleanup_check(1)) return;
170 item = int_cleanup_item(cb);
171 if(item)
172 sk_ENGINE_CLEANUP_ITEM_insert(cleanup_stack, item, 0);
173 }
174void engine_cleanup_add_last(ENGINE_CLEANUP_CB *cb)
175 {
176 ENGINE_CLEANUP_ITEM *item;
177 if(!int_cleanup_check(1)) return;
178 item = int_cleanup_item(cb);
179 if(item)
180 sk_ENGINE_CLEANUP_ITEM_push(cleanup_stack, item);
181 }
182/* The API function that performs all cleanup */
183static void engine_cleanup_cb_free(ENGINE_CLEANUP_ITEM *item)
184 {
185 (*(item->cb))();
186 OPENSSL_free(item);
187 }
188void ENGINE_cleanup(void)
189 {
190 if(int_cleanup_check(0))
191 {
192 sk_ENGINE_CLEANUP_ITEM_pop_free(cleanup_stack,
193 engine_cleanup_cb_free);
194 cleanup_stack = NULL;
195 }
196 /* FIXME: This should be handled (somehow) through RAND, eg. by it
197 * registering a cleanup callback. */
198 RAND_set_rand_method(NULL);
199 }
200
201/* Now the "ex_data" support */
202
203int ENGINE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
204 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
205 {
206 return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_ENGINE, argl, argp,
207 new_func, dup_func, free_func);
208 }
209
210int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg)
211 {
212 return(CRYPTO_set_ex_data(&e->ex_data, idx, arg));
213 }
214
215void *ENGINE_get_ex_data(const ENGINE *e, int idx)
216 {
217 return(CRYPTO_get_ex_data(&e->ex_data, idx));
218 }
219
220/* Functions to get/set an ENGINE's elements - mainly to avoid exposing the
221 * ENGINE structure itself. */
222
223int ENGINE_set_id(ENGINE *e, const char *id)
224 {
225 if(id == NULL)
226 {
227 ENGINEerr(ENGINE_F_ENGINE_SET_ID,
228 ERR_R_PASSED_NULL_PARAMETER);
229 return 0;
230 }
231 e->id = id;
232 return 1;
233 }
234
235int ENGINE_set_name(ENGINE *e, const char *name)
236 {
237 if(name == NULL)
238 {
239 ENGINEerr(ENGINE_F_ENGINE_SET_NAME,
240 ERR_R_PASSED_NULL_PARAMETER);
241 return 0;
242 }
243 e->name = name;
244 return 1;
245 }
246
247int ENGINE_set_destroy_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR destroy_f)
248 {
249 e->destroy = destroy_f;
250 return 1;
251 }
252
253int ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f)
254 {
255 e->init = init_f;
256 return 1;
257 }
258
259int ENGINE_set_finish_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f)
260 {
261 e->finish = finish_f;
262 return 1;
263 }
264
265int ENGINE_set_ctrl_function(ENGINE *e, ENGINE_CTRL_FUNC_PTR ctrl_f)
266 {
267 e->ctrl = ctrl_f;
268 return 1;
269 }
270
271int ENGINE_set_flags(ENGINE *e, int flags)
272 {
273 e->flags = flags;
274 return 1;
275 }
276
277int ENGINE_set_cmd_defns(ENGINE *e, const ENGINE_CMD_DEFN *defns)
278 {
279 e->cmd_defns = defns;
280 return 1;
281 }
282
283const char *ENGINE_get_id(const ENGINE *e)
284 {
285 return e->id;
286 }
287
288const char *ENGINE_get_name(const ENGINE *e)
289 {
290 return e->name;
291 }
292
293ENGINE_GEN_INT_FUNC_PTR ENGINE_get_destroy_function(const ENGINE *e)
294 {
295 return e->destroy;
296 }
297
298ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const ENGINE *e)
299 {
300 return e->init;
301 }
302
303ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(const ENGINE *e)
304 {
305 return e->finish;
306 }
307
308ENGINE_CTRL_FUNC_PTR ENGINE_get_ctrl_function(const ENGINE *e)
309 {
310 return e->ctrl;
311 }
312
313int ENGINE_get_flags(const ENGINE *e)
314 {
315 return e->flags;
316 }
317
318const ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e)
319 {
320 return e->cmd_defns;
321 }
diff --git a/src/lib/libcrypto/engine/eng_list.c b/src/lib/libcrypto/engine/eng_list.c
new file mode 100644
index 0000000000..ce48d2255a
--- /dev/null
+++ b/src/lib/libcrypto/engine/eng_list.c
@@ -0,0 +1,383 @@
1/* crypto/engine/eng_list.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/crypto.h>
60#include "cryptlib.h"
61#include "eng_int.h"
62#include <openssl/engine.h>
63
64/* The linked-list of pointers to engine types. engine_list_head
65 * incorporates an implicit structural reference but engine_list_tail
66 * does not - the latter is a computational niceity and only points
67 * to something that is already pointed to by its predecessor in the
68 * list (or engine_list_head itself). In the same way, the use of the
69 * "prev" pointer in each ENGINE is to save excessive list iteration,
70 * it doesn't correspond to an extra structural reference. Hence,
71 * engine_list_head, and each non-null "next" pointer account for
72 * the list itself assuming exactly 1 structural reference on each
73 * list member. */
74static ENGINE *engine_list_head = NULL;
75static ENGINE *engine_list_tail = NULL;
76
77/* This cleanup function is only needed internally. If it should be called, we
78 * register it with the "ENGINE_cleanup()" stack to be called during cleanup. */
79
80static void engine_list_cleanup(void)
81 {
82 ENGINE *iterator = engine_list_head;
83
84 while(iterator != NULL)
85 {
86 ENGINE_remove(iterator);
87 iterator = engine_list_head;
88 }
89 return;
90 }
91
92/* These static functions starting with a lower case "engine_" always
93 * take place when CRYPTO_LOCK_ENGINE has been locked up. */
94static int engine_list_add(ENGINE *e)
95 {
96 int conflict = 0;
97 ENGINE *iterator = NULL;
98
99 if(e == NULL)
100 {
101 ENGINEerr(ENGINE_F_ENGINE_LIST_ADD,
102 ERR_R_PASSED_NULL_PARAMETER);
103 return 0;
104 }
105 iterator = engine_list_head;
106 while(iterator && !conflict)
107 {
108 conflict = (strcmp(iterator->id, e->id) == 0);
109 iterator = iterator->next;
110 }
111 if(conflict)
112 {
113 ENGINEerr(ENGINE_F_ENGINE_LIST_ADD,
114 ENGINE_R_CONFLICTING_ENGINE_ID);
115 return 0;
116 }
117 if(engine_list_head == NULL)
118 {
119 /* We are adding to an empty list. */
120 if(engine_list_tail)
121 {
122 ENGINEerr(ENGINE_F_ENGINE_LIST_ADD,
123 ENGINE_R_INTERNAL_LIST_ERROR);
124 return 0;
125 }
126 engine_list_head = e;
127 e->prev = NULL;
128 /* The first time the list allocates, we should register the
129 * cleanup. */
130 engine_cleanup_add_last(engine_list_cleanup);
131 }
132 else
133 {
134 /* We are adding to the tail of an existing list. */
135 if((engine_list_tail == NULL) ||
136 (engine_list_tail->next != NULL))
137 {
138 ENGINEerr(ENGINE_F_ENGINE_LIST_ADD,
139 ENGINE_R_INTERNAL_LIST_ERROR);
140 return 0;
141 }
142 engine_list_tail->next = e;
143 e->prev = engine_list_tail;
144 }
145 /* Having the engine in the list assumes a structural
146 * reference. */
147 e->struct_ref++;
148 engine_ref_debug(e, 0, 1)
149 /* However it came to be, e is the last item in the list. */
150 engine_list_tail = e;
151 e->next = NULL;
152 return 1;
153 }
154
155static int engine_list_remove(ENGINE *e)
156 {
157 ENGINE *iterator;
158
159 if(e == NULL)
160 {
161 ENGINEerr(ENGINE_F_ENGINE_LIST_REMOVE,
162 ERR_R_PASSED_NULL_PARAMETER);
163 return 0;
164 }
165 /* We need to check that e is in our linked list! */
166 iterator = engine_list_head;
167 while(iterator && (iterator != e))
168 iterator = iterator->next;
169 if(iterator == NULL)
170 {
171 ENGINEerr(ENGINE_F_ENGINE_LIST_REMOVE,
172 ENGINE_R_ENGINE_IS_NOT_IN_LIST);
173 return 0;
174 }
175 /* un-link e from the chain. */
176 if(e->next)
177 e->next->prev = e->prev;
178 if(e->prev)
179 e->prev->next = e->next;
180 /* Correct our head/tail if necessary. */
181 if(engine_list_head == e)
182 engine_list_head = e->next;
183 if(engine_list_tail == e)
184 engine_list_tail = e->prev;
185 engine_free_util(e, 0);
186 return 1;
187 }
188
189/* Get the first/last "ENGINE" type available. */
190ENGINE *ENGINE_get_first(void)
191 {
192 ENGINE *ret;
193
194 CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
195 ret = engine_list_head;
196 if(ret)
197 {
198 ret->struct_ref++;
199 engine_ref_debug(ret, 0, 1)
200 }
201 CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
202 return ret;
203 }
204
205ENGINE *ENGINE_get_last(void)
206 {
207 ENGINE *ret;
208
209 CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
210 ret = engine_list_tail;
211 if(ret)
212 {
213 ret->struct_ref++;
214 engine_ref_debug(ret, 0, 1)
215 }
216 CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
217 return ret;
218 }
219
220/* Iterate to the next/previous "ENGINE" type (NULL = end of the list). */
221ENGINE *ENGINE_get_next(ENGINE *e)
222 {
223 ENGINE *ret = NULL;
224 if(e == NULL)
225 {
226 ENGINEerr(ENGINE_F_ENGINE_GET_NEXT,
227 ERR_R_PASSED_NULL_PARAMETER);
228 return 0;
229 }
230 CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
231 ret = e->next;
232 if(ret)
233 {
234 /* Return a valid structural refernce to the next ENGINE */
235 ret->struct_ref++;
236 engine_ref_debug(ret, 0, 1)
237 }
238 CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
239 /* Release the structural reference to the previous ENGINE */
240 ENGINE_free(e);
241 return ret;
242 }
243
244ENGINE *ENGINE_get_prev(ENGINE *e)
245 {
246 ENGINE *ret = NULL;
247 if(e == NULL)
248 {
249 ENGINEerr(ENGINE_F_ENGINE_GET_PREV,
250 ERR_R_PASSED_NULL_PARAMETER);
251 return 0;
252 }
253 CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
254 ret = e->prev;
255 if(ret)
256 {
257 /* Return a valid structural reference to the next ENGINE */
258 ret->struct_ref++;
259 engine_ref_debug(ret, 0, 1)
260 }
261 CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
262 /* Release the structural reference to the previous ENGINE */
263 ENGINE_free(e);
264 return ret;
265 }
266
267/* Add another "ENGINE" type into the list. */
268int ENGINE_add(ENGINE *e)
269 {
270 int to_return = 1;
271 if(e == NULL)
272 {
273 ENGINEerr(ENGINE_F_ENGINE_ADD,
274 ERR_R_PASSED_NULL_PARAMETER);
275 return 0;
276 }
277 if((e->id == NULL) || (e->name == NULL))
278 {
279 ENGINEerr(ENGINE_F_ENGINE_ADD,
280 ENGINE_R_ID_OR_NAME_MISSING);
281 }
282 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
283 if(!engine_list_add(e))
284 {
285 ENGINEerr(ENGINE_F_ENGINE_ADD,
286 ENGINE_R_INTERNAL_LIST_ERROR);
287 to_return = 0;
288 }
289 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
290 return to_return;
291 }
292
293/* Remove an existing "ENGINE" type from the array. */
294int ENGINE_remove(ENGINE *e)
295 {
296 int to_return = 1;
297 if(e == NULL)
298 {
299 ENGINEerr(ENGINE_F_ENGINE_REMOVE,
300 ERR_R_PASSED_NULL_PARAMETER);
301 return 0;
302 }
303 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
304 if(!engine_list_remove(e))
305 {
306 ENGINEerr(ENGINE_F_ENGINE_REMOVE,
307 ENGINE_R_INTERNAL_LIST_ERROR);
308 to_return = 0;
309 }
310 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
311 return to_return;
312 }
313
314static void engine_cpy(ENGINE *dest, const ENGINE *src)
315 {
316 dest->id = src->id;
317 dest->name = src->name;
318#ifndef OPENSSL_NO_RSA
319 dest->rsa_meth = src->rsa_meth;
320#endif
321#ifndef OPENSSL_NO_DSA
322 dest->dsa_meth = src->dsa_meth;
323#endif
324#ifndef OPENSSL_NO_DH
325 dest->dh_meth = src->dh_meth;
326#endif
327 dest->rand_meth = src->rand_meth;
328 dest->ciphers = src->ciphers;
329 dest->digests = src->digests;
330 dest->destroy = src->destroy;
331 dest->init = src->init;
332 dest->finish = src->finish;
333 dest->ctrl = src->ctrl;
334 dest->load_privkey = src->load_privkey;
335 dest->load_pubkey = src->load_pubkey;
336 dest->cmd_defns = src->cmd_defns;
337 dest->flags = src->flags;
338 }
339
340ENGINE *ENGINE_by_id(const char *id)
341 {
342 ENGINE *iterator;
343 if(id == NULL)
344 {
345 ENGINEerr(ENGINE_F_ENGINE_BY_ID,
346 ERR_R_PASSED_NULL_PARAMETER);
347 return NULL;
348 }
349 CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
350 iterator = engine_list_head;
351 while(iterator && (strcmp(id, iterator->id) != 0))
352 iterator = iterator->next;
353 if(iterator)
354 {
355 /* We need to return a structural reference. If this is an
356 * ENGINE type that returns copies, make a duplicate - otherwise
357 * increment the existing ENGINE's reference count. */
358 if(iterator->flags & ENGINE_FLAGS_BY_ID_COPY)
359 {
360 ENGINE *cp = ENGINE_new();
361 if(!cp)
362 iterator = NULL;
363 else
364 {
365 engine_cpy(cp, iterator);
366 iterator = cp;
367 }
368 }
369 else
370 {
371 iterator->struct_ref++;
372 engine_ref_debug(iterator, 0, 1)
373 }
374 }
375 CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
376 if(iterator == NULL)
377 {
378 ENGINEerr(ENGINE_F_ENGINE_BY_ID,
379 ENGINE_R_NO_SUCH_ENGINE);
380 ERR_add_error_data(2, "id=", id);
381 }
382 return iterator;
383 }
diff --git a/src/lib/libcrypto/engine/eng_openssl.c b/src/lib/libcrypto/engine/eng_openssl.c
new file mode 100644
index 0000000000..e9d976f46b
--- /dev/null
+++ b/src/lib/libcrypto/engine/eng_openssl.c
@@ -0,0 +1,347 @@
1/* crypto/engine/eng_openssl.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
60#include <stdio.h>
61#include <openssl/crypto.h>
62#include "cryptlib.h"
63#include <openssl/engine.h>
64#include <openssl/dso.h>
65#include <openssl/pem.h>
66
67/* This testing gunk is implemented (and explained) lower down. It also assumes
68 * the application explicitly calls "ENGINE_load_openssl()" because this is no
69 * longer automatic in ENGINE_load_builtin_engines(). */
70#define TEST_ENG_OPENSSL_RC4
71#define TEST_ENG_OPENSSL_PKEY
72/* #define TEST_ENG_OPENSSL_RC4_OTHERS */
73#define TEST_ENG_OPENSSL_RC4_P_INIT
74/* #define TEST_ENG_OPENSSL_RC4_P_CIPHER */
75#define TEST_ENG_OPENSSL_SHA
76/* #define TEST_ENG_OPENSSL_SHA_OTHERS */
77/* #define TEST_ENG_OPENSSL_SHA_P_INIT */
78/* #define TEST_ENG_OPENSSL_SHA_P_UPDATE */
79/* #define TEST_ENG_OPENSSL_SHA_P_FINAL */
80
81#ifdef TEST_ENG_OPENSSL_RC4
82static int openssl_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
83 const int **nids, int nid);
84#endif
85#ifdef TEST_ENG_OPENSSL_SHA
86static int openssl_digests(ENGINE *e, const EVP_MD **digest,
87 const int **nids, int nid);
88#endif
89
90#ifdef TEST_ENG_OPENSSL_PKEY
91static EVP_PKEY *openssl_load_privkey(ENGINE *eng, const char *key_id,
92 UI_METHOD *ui_method, void *callback_data);
93#endif
94
95/* The constants used when creating the ENGINE */
96static const char *engine_openssl_id = "openssl";
97static const char *engine_openssl_name = "Software engine support";
98
99/* This internal function is used by ENGINE_openssl() and possibly by the
100 * "dynamic" ENGINE support too */
101static int bind_helper(ENGINE *e)
102 {
103 if(!ENGINE_set_id(e, engine_openssl_id)
104 || !ENGINE_set_name(e, engine_openssl_name)
105#ifndef TEST_ENG_OPENSSL_NO_ALGORITHMS
106#ifndef OPENSSL_NO_RSA
107 || !ENGINE_set_RSA(e, RSA_get_default_method())
108#endif
109#ifndef OPENSSL_NO_DSA
110 || !ENGINE_set_DSA(e, DSA_get_default_method())
111#endif
112#ifndef OPENSSL_NO_DH
113 || !ENGINE_set_DH(e, DH_get_default_method())
114#endif
115 || !ENGINE_set_RAND(e, RAND_SSLeay())
116#ifdef TEST_ENG_OPENSSL_RC4
117 || !ENGINE_set_ciphers(e, openssl_ciphers)
118#endif
119#ifdef TEST_ENG_OPENSSL_SHA
120 || !ENGINE_set_digests(e, openssl_digests)
121#endif
122#endif
123#ifdef TEST_ENG_OPENSSL_PKEY
124 || !ENGINE_set_load_privkey_function(e, openssl_load_privkey)
125#endif
126 )
127 return 0;
128 /* If we add errors to this ENGINE, ensure the error handling is setup here */
129 /* openssl_load_error_strings(); */
130 return 1;
131 }
132
133static ENGINE *engine_openssl(void)
134 {
135 ENGINE *ret = ENGINE_new();
136 if(!ret)
137 return NULL;
138 if(!bind_helper(ret))
139 {
140 ENGINE_free(ret);
141 return NULL;
142 }
143 return ret;
144 }
145
146void ENGINE_load_openssl(void)
147 {
148 ENGINE *toadd = engine_openssl();
149 if(!toadd) return;
150 ENGINE_add(toadd);
151 /* If the "add" worked, it gets a structural reference. So either way,
152 * we release our just-created reference. */
153 ENGINE_free(toadd);
154 ERR_clear_error();
155 }
156
157/* This stuff is needed if this ENGINE is being compiled into a self-contained
158 * shared-library. */
159#ifdef ENGINE_DYNAMIC_SUPPORT
160static int bind_fn(ENGINE *e, const char *id)
161 {
162 if(id && (strcmp(id, engine_openssl_id) != 0))
163 return 0;
164 if(!bind_helper(e))
165 return 0;
166 return 1;
167 }
168IMPLEMENT_DYNAMIC_CHECK_FN()
169IMPLEMENT_DYNAMIC_BIND_FN(bind_fn)
170#endif /* ENGINE_DYNAMIC_SUPPORT */
171
172#ifdef TEST_ENG_OPENSSL_RC4
173/* This section of code compiles an "alternative implementation" of two modes of
174 * RC4 into this ENGINE. The result is that EVP_CIPHER operation for "rc4"
175 * should under normal circumstances go via this support rather than the default
176 * EVP support. There are other symbols to tweak the testing;
177 * TEST_ENC_OPENSSL_RC4_OTHERS - print a one line message to stderr each time
178 * we're asked for a cipher we don't support (should not happen).
179 * TEST_ENG_OPENSSL_RC4_P_INIT - print a one line message to stderr each time
180 * the "init_key" handler is called.
181 * TEST_ENG_OPENSSL_RC4_P_CIPHER - ditto for the "cipher" handler.
182 */
183#include <openssl/evp.h>
184#include <openssl/rc4.h>
185#define TEST_RC4_KEY_SIZE 16
186static int test_cipher_nids[] = {NID_rc4,NID_rc4_40};
187static int test_cipher_nids_number = 2;
188typedef struct {
189 unsigned char key[TEST_RC4_KEY_SIZE];
190 RC4_KEY ks;
191 } TEST_RC4_KEY;
192#define test(ctx) ((TEST_RC4_KEY *)(ctx)->cipher_data)
193static int test_rc4_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
194 const unsigned char *iv, int enc)
195 {
196#ifdef TEST_ENG_OPENSSL_RC4_P_INIT
197 fprintf(stderr, "(TEST_ENG_OPENSSL_RC4) test_init_key() called\n");
198#endif
199 memcpy(&test(ctx)->key[0],key,EVP_CIPHER_CTX_key_length(ctx));
200 RC4_set_key(&test(ctx)->ks,EVP_CIPHER_CTX_key_length(ctx),
201 test(ctx)->key);
202 return 1;
203 }
204static int test_rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
205 const unsigned char *in, unsigned int inl)
206 {
207#ifdef TEST_ENG_OPENSSL_RC4_P_CIPHER
208 fprintf(stderr, "(TEST_ENG_OPENSSL_RC4) test_cipher() called\n");
209#endif
210 RC4(&test(ctx)->ks,inl,in,out);
211 return 1;
212 }
213static const EVP_CIPHER test_r4_cipher=
214 {
215 NID_rc4,
216 1,TEST_RC4_KEY_SIZE,0,
217 EVP_CIPH_VARIABLE_LENGTH,
218 test_rc4_init_key,
219 test_rc4_cipher,
220 NULL,
221 sizeof(TEST_RC4_KEY),
222 NULL,
223 NULL,
224 NULL
225 };
226static const EVP_CIPHER test_r4_40_cipher=
227 {
228 NID_rc4_40,
229 1,5 /* 40 bit */,0,
230 EVP_CIPH_VARIABLE_LENGTH,
231 test_rc4_init_key,
232 test_rc4_cipher,
233 NULL,
234 sizeof(TEST_RC4_KEY),
235 NULL,
236 NULL,
237 NULL
238 };
239static int openssl_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
240 const int **nids, int nid)
241 {
242 if(!cipher)
243 {
244 /* We are returning a list of supported nids */
245 *nids = test_cipher_nids;
246 return test_cipher_nids_number;
247 }
248 /* We are being asked for a specific cipher */
249 if(nid == NID_rc4)
250 *cipher = &test_r4_cipher;
251 else if(nid == NID_rc4_40)
252 *cipher = &test_r4_40_cipher;
253 else
254 {
255#ifdef TEST_ENG_OPENSSL_RC4_OTHERS
256 fprintf(stderr, "(TEST_ENG_OPENSSL_RC4) returning NULL for "
257 "nid %d\n", nid);
258#endif
259 *cipher = NULL;
260 return 0;
261 }
262 return 1;
263 }
264#endif
265
266#ifdef TEST_ENG_OPENSSL_SHA
267/* Much the same sort of comment as for TEST_ENG_OPENSSL_RC4 */
268#include <openssl/evp.h>
269#include <openssl/sha.h>
270static int test_digest_nids[] = {NID_sha1};
271static int test_digest_nids_number = 1;
272static int test_sha1_init(EVP_MD_CTX *ctx)
273 {
274#ifdef TEST_ENG_OPENSSL_SHA_P_INIT
275 fprintf(stderr, "(TEST_ENG_OPENSSL_SHA) test_sha1_init() called\n");
276#endif
277 return SHA1_Init(ctx->md_data);
278 }
279static int test_sha1_update(EVP_MD_CTX *ctx,const void *data,unsigned long count)
280 {
281#ifdef TEST_ENG_OPENSSL_SHA_P_UPDATE
282 fprintf(stderr, "(TEST_ENG_OPENSSL_SHA) test_sha1_update() called\n");
283#endif
284 return SHA1_Update(ctx->md_data,data,count);
285 }
286static int test_sha1_final(EVP_MD_CTX *ctx,unsigned char *md)
287 {
288#ifdef TEST_ENG_OPENSSL_SHA_P_FINAL
289 fprintf(stderr, "(TEST_ENG_OPENSSL_SHA) test_sha1_final() called\n");
290#endif
291 return SHA1_Final(md,ctx->md_data);
292 }
293static const EVP_MD test_sha_md=
294 {
295 NID_sha1,
296 NID_sha1WithRSAEncryption,
297 SHA_DIGEST_LENGTH,
298 0,
299 test_sha1_init,
300 test_sha1_update,
301 test_sha1_final,
302 NULL,
303 NULL,
304 EVP_PKEY_RSA_method,
305 SHA_CBLOCK,
306 sizeof(EVP_MD *)+sizeof(SHA_CTX),
307 };
308static int openssl_digests(ENGINE *e, const EVP_MD **digest,
309 const int **nids, int nid)
310 {
311 if(!digest)
312 {
313 /* We are returning a list of supported nids */
314 *nids = test_digest_nids;
315 return test_digest_nids_number;
316 }
317 /* We are being asked for a specific digest */
318 if(nid == NID_sha1)
319 *digest = &test_sha_md;
320 else
321 {
322#ifdef TEST_ENG_OPENSSL_SHA_OTHERS
323 fprintf(stderr, "(TEST_ENG_OPENSSL_SHA) returning NULL for "
324 "nid %d\n", nid);
325#endif
326 *digest = NULL;
327 return 0;
328 }
329 return 1;
330 }
331#endif
332
333#ifdef TEST_ENG_OPENSSL_PKEY
334static EVP_PKEY *openssl_load_privkey(ENGINE *eng, const char *key_id,
335 UI_METHOD *ui_method, void *callback_data)
336 {
337 BIO *in;
338 EVP_PKEY *key;
339 fprintf(stderr, "(TEST_ENG_OPENSSL_PKEY)Loading Private key %s\n", key_id);
340 in = BIO_new_file(key_id, "r");
341 if (!in)
342 return NULL;
343 key = PEM_read_bio_PrivateKey(in, NULL, 0, NULL);
344 BIO_free(in);
345 return key;
346 }
347#endif
diff --git a/src/lib/libcrypto/engine/eng_pkey.c b/src/lib/libcrypto/engine/eng_pkey.c
new file mode 100644
index 0000000000..8c69171511
--- /dev/null
+++ b/src/lib/libcrypto/engine/eng_pkey.c
@@ -0,0 +1,157 @@
1/* crypto/engine/eng_pkey.c */
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/crypto.h>
57#include "cryptlib.h"
58#include "eng_int.h"
59#include <openssl/engine.h>
60
61/* Basic get/set stuff */
62
63int ENGINE_set_load_privkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpriv_f)
64 {
65 e->load_privkey = loadpriv_f;
66 return 1;
67 }
68
69int ENGINE_set_load_pubkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpub_f)
70 {
71 e->load_pubkey = loadpub_f;
72 return 1;
73 }
74
75ENGINE_LOAD_KEY_PTR ENGINE_get_load_privkey_function(const ENGINE *e)
76 {
77 return e->load_privkey;
78 }
79
80ENGINE_LOAD_KEY_PTR ENGINE_get_load_pubkey_function(const ENGINE *e)
81 {
82 return e->load_pubkey;
83 }
84
85/* API functions to load public/private keys */
86
87EVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id,
88 UI_METHOD *ui_method, void *callback_data)
89 {
90 EVP_PKEY *pkey;
91
92 if(e == NULL)
93 {
94 ENGINEerr(ENGINE_F_ENGINE_LOAD_PRIVATE_KEY,
95 ERR_R_PASSED_NULL_PARAMETER);
96 return 0;
97 }
98 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
99 if(e->funct_ref == 0)
100 {
101 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
102 ENGINEerr(ENGINE_F_ENGINE_LOAD_PRIVATE_KEY,
103 ENGINE_R_NOT_INITIALISED);
104 return 0;
105 }
106 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
107 if (!e->load_privkey)
108 {
109 ENGINEerr(ENGINE_F_ENGINE_LOAD_PRIVATE_KEY,
110 ENGINE_R_NO_LOAD_FUNCTION);
111 return 0;
112 }
113 pkey = e->load_privkey(e, key_id, ui_method, callback_data);
114 if (!pkey)
115 {
116 ENGINEerr(ENGINE_F_ENGINE_LOAD_PRIVATE_KEY,
117 ENGINE_R_FAILED_LOADING_PRIVATE_KEY);
118 return 0;
119 }
120 return pkey;
121 }
122
123EVP_PKEY *ENGINE_load_public_key(ENGINE *e, const char *key_id,
124 UI_METHOD *ui_method, void *callback_data)
125 {
126 EVP_PKEY *pkey;
127
128 if(e == NULL)
129 {
130 ENGINEerr(ENGINE_F_ENGINE_LOAD_PUBLIC_KEY,
131 ERR_R_PASSED_NULL_PARAMETER);
132 return 0;
133 }
134 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
135 if(e->funct_ref == 0)
136 {
137 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
138 ENGINEerr(ENGINE_F_ENGINE_LOAD_PUBLIC_KEY,
139 ENGINE_R_NOT_INITIALISED);
140 return 0;
141 }
142 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
143 if (!e->load_pubkey)
144 {
145 ENGINEerr(ENGINE_F_ENGINE_LOAD_PUBLIC_KEY,
146 ENGINE_R_NO_LOAD_FUNCTION);
147 return 0;
148 }
149 pkey = e->load_pubkey(e, key_id, ui_method, callback_data);
150 if (!pkey)
151 {
152 ENGINEerr(ENGINE_F_ENGINE_LOAD_PUBLIC_KEY,
153 ENGINE_R_FAILED_LOADING_PUBLIC_KEY);
154 return 0;
155 }
156 return pkey;
157 }
diff --git a/src/lib/libcrypto/engine/eng_table.c b/src/lib/libcrypto/engine/eng_table.c
new file mode 100644
index 0000000000..c69a84a8bf
--- /dev/null
+++ b/src/lib/libcrypto/engine/eng_table.c
@@ -0,0 +1,361 @@
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 * licensing@OpenSSL.org.
25 *
26 * 5. Products derived from this software may not be called "OpenSSL"
27 * nor may "OpenSSL" appear in their names without prior written
28 * permission of the OpenSSL Project.
29 *
30 * 6. Redistributions of any form whatsoever must retain the following
31 * acknowledgment:
32 * "This product includes software developed by the OpenSSL Project
33 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
34 *
35 * 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#include <openssl/evp.h>
56#include <openssl/engine.h>
57#include "eng_int.h"
58
59/* This is the type of item in the 'implementation' table. Each 'nid' hashes to
60 * a (potentially NULL) ENGINE_PILE structure which contains a stack of ENGINE*
61 * pointers. These pointers aren't references, because they're inserted and
62 * removed during ENGINE creation and ENGINE destruction. They point to ENGINEs
63 * that *exist* (ie. have a structural reference count greater than zero) rather
64 * than ENGINEs that are *functional*. Each pointer in those stacks are to
65 * ENGINEs that implements the algorithm corresponding to each 'nid'. */
66
67/* The type of the items in the table */
68typedef struct st_engine_pile
69 {
70 /* The 'nid' of the algorithm/mode this ENGINE_PILE structure represents
71 * */
72 int nid;
73 /* A stack of ENGINE pointers for ENGINEs that support this
74 * algorithm/mode. In the event that 'funct' is NULL, the first entry in
75 * this stack that initialises will be set as 'funct' and assumed as the
76 * default for operations of this type. */
77 STACK_OF(ENGINE) *sk;
78 /* The default ENGINE to perform this algorithm/mode. */
79 ENGINE *funct;
80 /* This value optimises engine_table_select(). If it is called it sets
81 * this value to 1. Any changes to this ENGINE_PILE resets it to zero.
82 * As such, no ENGINE_init() thrashing is done unless ENGINEs
83 * continually register (and/or unregister). */
84 int uptodate;
85 } ENGINE_PILE;
86
87/* The type of the hash table of ENGINE_PILE structures such that each are
88 * unique and keyed by the 'nid' value. */
89struct st_engine_table
90 {
91 LHASH piles;
92 }; /* ENGINE_TABLE */
93
94/* This value stores global options controlling behaviour of (mostly) the
95 * engine_table_select() function. It's a bitmask of flag values of the form
96 * ENGINE_TABLE_FLAG_*** (as defined in engine.h) and is controlled by the
97 * ENGINE_[get|set]_table_flags() function. */
98static unsigned int table_flags = 0;
99
100/* API function manipulating 'table_flags' */
101unsigned int ENGINE_get_table_flags(void)
102 {
103 return table_flags;
104 }
105void ENGINE_set_table_flags(unsigned int flags)
106 {
107 table_flags = flags;
108 }
109
110/* Internal functions for the "piles" hash table */
111static unsigned long engine_pile_hash(const ENGINE_PILE *c)
112 {
113 return c->nid;
114 }
115static int engine_pile_cmp(const ENGINE_PILE *a, const ENGINE_PILE *b)
116 {
117 return a->nid - b->nid;
118 }
119static IMPLEMENT_LHASH_HASH_FN(engine_pile_hash, const ENGINE_PILE *)
120static IMPLEMENT_LHASH_COMP_FN(engine_pile_cmp, const ENGINE_PILE *)
121static int int_table_check(ENGINE_TABLE **t, int create)
122 {
123 LHASH *lh;
124 if(*t)
125 return 1;
126 if(!create)
127 return 0;
128 if((lh = lh_new(LHASH_HASH_FN(engine_pile_hash),
129 LHASH_COMP_FN(engine_pile_cmp))) == NULL)
130 return 0;
131 *t = (ENGINE_TABLE *)lh;
132 return 1;
133 }
134
135/* Privately exposed (via eng_int.h) functions for adding and/or removing
136 * ENGINEs from the implementation table */
137int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup,
138 ENGINE *e, const int *nids, int num_nids, int setdefault)
139 {
140 int ret = 0, added = 0;
141 ENGINE_PILE tmplate, *fnd;
142 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
143 if(!(*table))
144 added = 1;
145 if(!int_table_check(table, 1))
146 goto end;
147 if(added)
148 /* The cleanup callback needs to be added */
149 engine_cleanup_add_first(cleanup);
150 while(num_nids--)
151 {
152 tmplate.nid = *nids;
153 fnd = lh_retrieve(&(*table)->piles, &tmplate);
154 if(!fnd)
155 {
156 fnd = OPENSSL_malloc(sizeof(ENGINE_PILE));
157 if(!fnd)
158 goto end;
159 fnd->uptodate = 1;
160 fnd->nid = *nids;
161 fnd->sk = sk_ENGINE_new_null();
162 if(!fnd->sk)
163 {
164 OPENSSL_free(fnd);
165 goto end;
166 }
167 fnd->funct= NULL;
168 lh_insert(&(*table)->piles, fnd);
169 }
170 /* A registration shouldn't add duplciate entries */
171 sk_ENGINE_delete_ptr(fnd->sk, e);
172 /* if 'setdefault', this ENGINE goes to the head of the list */
173 if(!sk_ENGINE_push(fnd->sk, e))
174 goto end;
175 /* "touch" this ENGINE_PILE */
176 fnd->uptodate = 0;
177 if(setdefault)
178 {
179 if(!engine_unlocked_init(e))
180 {
181 ENGINEerr(ENGINE_F_ENGINE_TABLE_REGISTER,
182 ENGINE_R_INIT_FAILED);
183 goto end;
184 }
185 if(fnd->funct)
186 engine_unlocked_finish(fnd->funct, 0);
187 fnd->funct = e;
188 }
189 nids++;
190 }
191 ret = 1;
192end:
193 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
194 return ret;
195 }
196static void int_unregister_cb(ENGINE_PILE *pile, ENGINE *e)
197 {
198 int n;
199 /* Iterate the 'c->sk' stack removing any occurance of 'e' */
200 while((n = sk_ENGINE_find(pile->sk, e)) >= 0)
201 {
202 sk_ENGINE_delete(pile->sk, n);
203 /* "touch" this ENGINE_CIPHER */
204 pile->uptodate = 0;
205 }
206 if(pile->funct == e)
207 {
208 engine_unlocked_finish(e, 0);
209 pile->funct = NULL;
210 }
211 }
212static IMPLEMENT_LHASH_DOALL_ARG_FN(int_unregister_cb,ENGINE_PILE *,ENGINE *)
213void engine_table_unregister(ENGINE_TABLE **table, ENGINE *e)
214 {
215 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
216 if(int_table_check(table, 0))
217 lh_doall_arg(&(*table)->piles,
218 LHASH_DOALL_ARG_FN(int_unregister_cb), e);
219 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
220 }
221
222static void int_cleanup_cb(ENGINE_PILE *p)
223 {
224 sk_ENGINE_free(p->sk);
225 if(p->funct)
226 engine_unlocked_finish(p->funct, 0);
227 OPENSSL_free(p);
228 }
229static IMPLEMENT_LHASH_DOALL_FN(int_cleanup_cb,ENGINE_PILE *)
230void engine_table_cleanup(ENGINE_TABLE **table)
231 {
232 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
233 if(*table)
234 {
235 lh_doall(&(*table)->piles, LHASH_DOALL_FN(int_cleanup_cb));
236 lh_free(&(*table)->piles);
237 *table = NULL;
238 }
239 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
240 }
241
242/* Exposed API function to get a functional reference from the implementation
243 * table (ie. try to get a functional reference from the tabled structural
244 * references) for a given cipher 'nid' */
245#ifndef ENGINE_TABLE_DEBUG
246ENGINE *engine_table_select(ENGINE_TABLE **table, int nid)
247#else
248ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f, int l)
249#endif
250 {
251 ENGINE *ret = NULL;
252 ENGINE_PILE tmplate, *fnd=NULL;
253 int initres, loop = 0;
254
255 /* If 'engine_ciphers' is NULL, then it's absolutely *sure* that no
256 * ENGINEs have registered any implementations! */
257 if(!(*table))
258 {
259#ifdef ENGINE_TABLE_DEBUG
260 fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, no "
261 "registered for anything!\n", f, l, nid);
262#endif
263 return NULL;
264 }
265 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
266 /* Check again inside the lock otherwise we could race against cleanup
267 * operations. But don't worry about a fprintf(stderr). */
268 if(!int_table_check(table, 0))
269 goto end;
270 tmplate.nid = nid;
271 fnd = lh_retrieve(&(*table)->piles, &tmplate);
272 if(!fnd)
273 goto end;
274 if(fnd->funct && engine_unlocked_init(fnd->funct))
275 {
276#ifdef ENGINE_TABLE_DEBUG
277 fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, using "
278 "ENGINE '%s' cached\n", f, l, nid, fnd->funct->id);
279#endif
280 ret = fnd->funct;
281 goto end;
282 }
283 if(fnd->uptodate)
284 {
285 ret = fnd->funct;
286 goto end;
287 }
288trynext:
289 ret = sk_ENGINE_value(fnd->sk, loop++);
290 if(!ret)
291 {
292#ifdef ENGINE_TABLE_DEBUG
293 fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, no "
294 "registered implementations would initialise\n",
295 f, l, nid);
296#endif
297 goto end;
298 }
299#if 0
300 /* Don't need to get a reference if we hold the lock. If the locking has
301 * to change in future, that would be different ... */
302 ret->struct_ref++; engine_ref_debug(ret, 0, 1)
303#endif
304 /* Try and initialise the ENGINE if it's already functional *or* if the
305 * ENGINE_TABLE_FLAG_NOINIT flag is not set. */
306 if((ret->funct_ref > 0) || !(table_flags & ENGINE_TABLE_FLAG_NOINIT))
307 initres = engine_unlocked_init(ret);
308 else
309 initres = 0;
310#if 0
311 /* Release the structural reference */
312 ret->struct_ref--; engine_ref_debug(ret, 0, -1);
313#endif
314 if(initres)
315 {
316 /* If we didn't have a default (functional reference) for this
317 * 'nid' (or we had one but for whatever reason we're now
318 * initialising a different one), use this opportunity to set
319 * 'funct'. */
320 if((fnd->funct != ret) && engine_unlocked_init(ret))
321 {
322 /* If there was a previous default we release it. */
323 if(fnd->funct)
324 engine_unlocked_finish(fnd->funct, 0);
325 /* We got an extra functional reference for the
326 * per-'nid' default */
327 fnd->funct = ret;
328#ifdef ENGINE_TABLE_DEBUG
329 fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, "
330 "setting default to '%s'\n", f, l, nid, ret->id);
331#endif
332 }
333#ifdef ENGINE_TABLE_DEBUG
334 fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, using "
335 "newly initialised '%s'\n", f, l, nid, ret->id);
336#endif
337 goto end;
338 }
339 goto trynext;
340end:
341 /* Whatever happened - we should "untouch" our uptodate file seeing as
342 * we have tried our best to find a functional reference for 'nid'. If
343 * it failed, it is unlikely to succeed again until some future
344 * registrations (or unregistrations) have taken place that affect that
345 * 'nid'. */
346 if(fnd)
347 fnd->uptodate = 1;
348#ifdef ENGINE_TABLE_DEBUG
349 if(ret)
350 fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, caching "
351 "ENGINE '%s'\n", f, l, nid, ret->id);
352 else
353 fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, caching "
354 "'no matching ENGINE'\n", f, l, nid);
355#endif
356 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
357 /* Whatever happened, any failed init()s are not failures in this
358 * context, so clear our error state. */
359 ERR_clear_error();
360 return ret;
361 }
diff --git a/src/lib/libcrypto/engine/engine.h b/src/lib/libcrypto/engine/engine.h
index 2983f47034..97f5de9e12 100644
--- a/src/lib/libcrypto/engine/engine.h
+++ b/src/lib/libcrypto/engine/engine.h
@@ -3,7 +3,7 @@
3 * project 2000. 3 * project 2000.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. 6 * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
@@ -59,36 +59,171 @@
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/ossl_typ.h>
62#include <openssl/bn.h> 63#include <openssl/bn.h>
64#ifndef OPENSSL_NO_RSA
63#include <openssl/rsa.h> 65#include <openssl/rsa.h>
66#endif
67#ifndef OPENSSL_NO_DSA
64#include <openssl/dsa.h> 68#include <openssl/dsa.h>
69#endif
70#ifndef OPENSSL_NO_DH
65#include <openssl/dh.h> 71#include <openssl/dh.h>
72#endif
66#include <openssl/rand.h> 73#include <openssl/rand.h>
67#include <openssl/evp.h> 74#include <openssl/ui.h>
68#include <openssl/symhacks.h> 75#include <openssl/symhacks.h>
76#include <openssl/err.h>
69 77
70#ifdef __cplusplus 78#ifdef __cplusplus
71extern "C" { 79extern "C" {
72#endif 80#endif
73 81
82/* Fixups for missing algorithms */
83#ifdef OPENSSL_NO_RSA
84typedef void RSA_METHOD;
85#endif
86#ifdef OPENSSL_NO_DSA
87typedef void DSA_METHOD;
88#endif
89#ifdef OPENSSL_NO_DH
90typedef void DH_METHOD;
91#endif
92
74/* These flags are used to control combinations of algorithm (methods) 93/* These flags are used to control combinations of algorithm (methods)
75 * by bitwise "OR"ing. */ 94 * by bitwise "OR"ing. */
76#define ENGINE_METHOD_RSA (unsigned int)0x0001 95#define ENGINE_METHOD_RSA (unsigned int)0x0001
77#define ENGINE_METHOD_DSA (unsigned int)0x0002 96#define ENGINE_METHOD_DSA (unsigned int)0x0002
78#define ENGINE_METHOD_DH (unsigned int)0x0004 97#define ENGINE_METHOD_DH (unsigned int)0x0004
79#define ENGINE_METHOD_RAND (unsigned int)0x0008 98#define ENGINE_METHOD_RAND (unsigned int)0x0008
80#define ENGINE_METHOD_BN_MOD_EXP (unsigned int)0x0010 99#define ENGINE_METHOD_CIPHERS (unsigned int)0x0040
81#define ENGINE_METHOD_BN_MOD_EXP_CRT (unsigned int)0x0020 100#define ENGINE_METHOD_DIGESTS (unsigned int)0x0080
82/* Obvious all-or-nothing cases. */ 101/* Obvious all-or-nothing cases. */
83#define ENGINE_METHOD_ALL (unsigned int)0xFFFF 102#define ENGINE_METHOD_ALL (unsigned int)0xFFFF
84#define ENGINE_METHOD_NONE (unsigned int)0x0000 103#define ENGINE_METHOD_NONE (unsigned int)0x0000
85 104
105/* This(ese) flag(s) controls behaviour of the ENGINE_TABLE mechanism used
106 * internally to control registration of ENGINE implementations, and can be set
107 * by ENGINE_set_table_flags(). The "NOINIT" flag prevents attempts to
108 * initialise registered ENGINEs if they are not already initialised. */
109#define ENGINE_TABLE_FLAG_NOINIT (unsigned int)0x0001
110
111/* ENGINE flags that can be set by ENGINE_set_flags(). */
112/* #define ENGINE_FLAGS_MALLOCED 0x0001 */ /* Not used */
113
114/* This flag is for ENGINEs that wish to handle the various 'CMD'-related
115 * control commands on their own. Without this flag, ENGINE_ctrl() handles these
116 * control commands on behalf of the ENGINE using their "cmd_defns" data. */
117#define ENGINE_FLAGS_MANUAL_CMD_CTRL (int)0x0002
118
119/* This flag is for ENGINEs who return new duplicate structures when found via
120 * "ENGINE_by_id()". When an ENGINE must store state (eg. if ENGINE_ctrl()
121 * commands are called in sequence as part of some stateful process like
122 * key-generation setup and execution), it can set this flag - then each attempt
123 * to obtain the ENGINE will result in it being copied into a new structure.
124 * Normally, ENGINEs don't declare this flag so ENGINE_by_id() just increments
125 * the existing ENGINE's structural reference count. */
126#define ENGINE_FLAGS_BY_ID_COPY (int)0x0004
127
128/* ENGINEs can support their own command types, and these flags are used in
129 * ENGINE_CTRL_GET_CMD_FLAGS to indicate to the caller what kind of input each
130 * command expects. Currently only numeric and string input is supported. If a
131 * control command supports none of the _NUMERIC, _STRING, or _NO_INPUT options,
132 * then it is regarded as an "internal" control command - and not for use in
133 * config setting situations. As such, they're not available to the
134 * ENGINE_ctrl_cmd_string() function, only raw ENGINE_ctrl() access. Changes to
135 * this list of 'command types' should be reflected carefully in
136 * ENGINE_cmd_is_executable() and ENGINE_ctrl_cmd_string(). */
137
138/* accepts a 'long' input value (3rd parameter to ENGINE_ctrl) */
139#define ENGINE_CMD_FLAG_NUMERIC (unsigned int)0x0001
140/* accepts string input (cast from 'void*' to 'const char *', 4th parameter to
141 * ENGINE_ctrl) */
142#define ENGINE_CMD_FLAG_STRING (unsigned int)0x0002
143/* Indicates that the control command takes *no* input. Ie. the control command
144 * is unparameterised. */
145#define ENGINE_CMD_FLAG_NO_INPUT (unsigned int)0x0004
146/* Indicates that the control command is internal. This control command won't
147 * be shown in any output, and is only usable through the ENGINE_ctrl_cmd()
148 * function. */
149#define ENGINE_CMD_FLAG_INTERNAL (unsigned int)0x0008
150
151/* NB: These 3 control commands are deprecated and should not be used. ENGINEs
152 * relying on these commands should compile conditional support for
153 * compatibility (eg. if these symbols are defined) but should also migrate the
154 * same functionality to their own ENGINE-specific control functions that can be
155 * "discovered" by calling applications. The fact these control commands
156 * wouldn't be "executable" (ie. usable by text-based config) doesn't change the
157 * fact that application code can find and use them without requiring per-ENGINE
158 * hacking. */
159
86/* These flags are used to tell the ctrl function what should be done. 160/* These flags are used to tell the ctrl function what should be done.
87 * All command numbers are shared between all engines, even if some don't 161 * All command numbers are shared between all engines, even if some don't
88 * make sense to some engines. In such a case, they do nothing but return 162 * make sense to some engines. In such a case, they do nothing but return
89 * the error ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED. */ 163 * the error ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED. */
90#define ENGINE_CTRL_SET_LOGSTREAM 1 164#define ENGINE_CTRL_SET_LOGSTREAM 1
91#define ENGINE_CTRL_SET_PASSWORD_CALLBACK 2 165#define ENGINE_CTRL_SET_PASSWORD_CALLBACK 2
166#define ENGINE_CTRL_HUP 3 /* Close and reinitialise any
167 handles/connections etc. */
168#define ENGINE_CTRL_SET_USER_INTERFACE 4 /* Alternative to callback */
169#define ENGINE_CTRL_SET_CALLBACK_DATA 5 /* User-specific data, used
170 when calling the password
171 callback and the user
172 interface */
173
174/* These control commands allow an application to deal with an arbitrary engine
175 * in a dynamic way. Warn: Negative return values indicate errors FOR THESE
176 * COMMANDS because zero is used to indicate 'end-of-list'. Other commands,
177 * including ENGINE-specific command types, return zero for an error.
178 *
179 * An ENGINE can choose to implement these ctrl functions, and can internally
180 * manage things however it chooses - it does so by setting the
181 * ENGINE_FLAGS_MANUAL_CMD_CTRL flag (using ENGINE_set_flags()). Otherwise the
182 * ENGINE_ctrl() code handles this on the ENGINE's behalf using the cmd_defns
183 * data (set using ENGINE_set_cmd_defns()). This means an ENGINE's ctrl()
184 * handler need only implement its own commands - the above "meta" commands will
185 * be taken care of. */
186
187/* Returns non-zero if the supplied ENGINE has a ctrl() handler. If "not", then
188 * all the remaining control commands will return failure, so it is worth
189 * checking this first if the caller is trying to "discover" the engine's
190 * capabilities and doesn't want errors generated unnecessarily. */
191#define ENGINE_CTRL_HAS_CTRL_FUNCTION 10
192/* Returns a positive command number for the first command supported by the
193 * engine. Returns zero if no ctrl commands are supported. */
194#define ENGINE_CTRL_GET_FIRST_CMD_TYPE 11
195/* The 'long' argument specifies a command implemented by the engine, and the
196 * return value is the next command supported, or zero if there are no more. */
197#define ENGINE_CTRL_GET_NEXT_CMD_TYPE 12
198/* The 'void*' argument is a command name (cast from 'const char *'), and the
199 * return value is the command that corresponds to it. */
200#define ENGINE_CTRL_GET_CMD_FROM_NAME 13
201/* The next two allow a command to be converted into its corresponding string
202 * form. In each case, the 'long' argument supplies the command. In the NAME_LEN
203 * case, the return value is the length of the command name (not counting a
204 * trailing EOL). In the NAME case, the 'void*' argument must be a string buffer
205 * large enough, and it will be populated with the name of the command (WITH a
206 * trailing EOL). */
207#define ENGINE_CTRL_GET_NAME_LEN_FROM_CMD 14
208#define ENGINE_CTRL_GET_NAME_FROM_CMD 15
209/* The next two are similar but give a "short description" of a command. */
210#define ENGINE_CTRL_GET_DESC_LEN_FROM_CMD 16
211#define ENGINE_CTRL_GET_DESC_FROM_CMD 17
212/* With this command, the return value is the OR'd combination of
213 * ENGINE_CMD_FLAG_*** values that indicate what kind of input a given
214 * engine-specific ctrl command expects. */
215#define ENGINE_CTRL_GET_CMD_FLAGS 18
216
217/* ENGINE implementations should start the numbering of their own control
218 * commands from this value. (ie. ENGINE_CMD_BASE, ENGINE_CMD_BASE + 1, etc). */
219#define ENGINE_CMD_BASE 200
220
221/* NB: These 2 nCipher "chil" control commands are deprecated, and their
222 * functionality is now available through ENGINE-specific control commands
223 * (exposed through the above-mentioned 'CMD'-handling). Code using these 2
224 * commands should be migrated to the more general command handling before these
225 * are removed. */
226
92/* Flags specific to the nCipher "chil" engine */ 227/* Flags specific to the nCipher "chil" engine */
93#define ENGINE_CTRL_CHIL_SET_FORKCHECK 100 228#define ENGINE_CTRL_CHIL_SET_FORKCHECK 100
94 /* Depending on the value of the (long)i argument, this sets or 229 /* Depending on the value of the (long)i argument, this sets or
@@ -99,45 +234,55 @@ extern "C" {
99 /* This prevents the initialisation function from providing mutex 234 /* This prevents the initialisation function from providing mutex
100 * callbacks to the nCipher library. */ 235 * callbacks to the nCipher library. */
101 236
102/* As we're missing a BIGNUM_METHOD, we need a couple of locally 237/* If an ENGINE supports its own specific control commands and wishes the
103 * defined function types that engines can implement. */ 238 * framework to handle the above 'ENGINE_CMD_***'-manipulation commands on its
104 239 * behalf, it should supply a null-terminated array of ENGINE_CMD_DEFN entries
105#ifndef HEADER_ENGINE_INT_H 240 * to ENGINE_set_cmd_defns(). It should also implement a ctrl() handler that
106/* mod_exp operation, calculates; r = a ^ p mod m 241 * supports the stated commands (ie. the "cmd_num" entries as described by the
107 * NB: ctx can be NULL, but if supplied, the implementation may use 242 * array). NB: The array must be ordered in increasing order of cmd_num.
108 * it if it wishes. */ 243 * "null-terminated" means that the last ENGINE_CMD_DEFN element has cmd_num set
109typedef int (*BN_MOD_EXP)(BIGNUM *r, BIGNUM *a, const BIGNUM *p, 244 * to zero and/or cmd_name set to NULL. */
110 const BIGNUM *m, BN_CTX *ctx); 245typedef struct ENGINE_CMD_DEFN_st
111 246 {
112/* private key operation for RSA, provided seperately in case other 247 unsigned int cmd_num; /* The command number */
113 * RSA implementations wish to use it. */ 248 const char *cmd_name; /* The command name itself */
114typedef int (*BN_MOD_EXP_CRT)(BIGNUM *r, BIGNUM *a, const BIGNUM *p, 249 const char *cmd_desc; /* A short description of the command */
115 const BIGNUM *q, const BIGNUM *dmp1, const BIGNUM *dmq1, 250 unsigned int cmd_flags; /* The input the command expects */
116 const BIGNUM *iqmp, BN_CTX *ctx); 251 } ENGINE_CMD_DEFN;
117 252
118/* Generic function pointer */ 253/* Generic function pointer */
119typedef void (*ENGINE_GEN_FUNC_PTR)(); 254typedef int (*ENGINE_GEN_FUNC_PTR)();
120/* Generic function pointer taking no arguments */ 255/* Generic function pointer taking no arguments */
121typedef void (*ENGINE_GEN_INT_FUNC_PTR)(void); 256typedef int (*ENGINE_GEN_INT_FUNC_PTR)(ENGINE *);
122/* Specific control function pointer */ 257/* Specific control function pointer */
123typedef int (*ENGINE_CTRL_FUNC_PTR)(int cmd, long i, void *p, void (*f)()); 258typedef int (*ENGINE_CTRL_FUNC_PTR)(ENGINE *, int, long, void *, void (*f)());
124 259/* Generic load_key function pointer */
125/* The list of "engine" types is a static array of (const ENGINE*) 260typedef EVP_PKEY * (*ENGINE_LOAD_KEY_PTR)(ENGINE *, const char *,
126 * pointers (not dynamic because static is fine for now and we otherwise 261 UI_METHOD *ui_method, void *callback_data);
127 * have to hook an appropriate load/unload function in to initialise and 262/* These callback types are for an ENGINE's handler for cipher and digest logic.
128 * cleanup). */ 263 * These handlers have these prototypes;
129typedef struct engine_st ENGINE; 264 * int foo(ENGINE *e, const EVP_CIPHER **cipher, const int **nids, int nid);
130#endif 265 * int foo(ENGINE *e, const EVP_MD **digest, const int **nids, int nid);
266 * Looking at how to implement these handlers in the case of cipher support, if
267 * the framework wants the EVP_CIPHER for 'nid', it will call;
268 * foo(e, &p_evp_cipher, NULL, nid); (return zero for failure)
269 * If the framework wants a list of supported 'nid's, it will call;
270 * foo(e, NULL, &p_nids, 0); (returns number of 'nids' or -1 for error)
271 */
272/* Returns to a pointer to the array of supported cipher 'nid's. If the second
273 * parameter is non-NULL it is set to the size of the returned array. */
274typedef int (*ENGINE_CIPHERS_PTR)(ENGINE *, const EVP_CIPHER **, const int **, int);
275typedef int (*ENGINE_DIGESTS_PTR)(ENGINE *, const EVP_MD **, const int **, int);
131 276
132/* STRUCTURE functions ... all of these functions deal with pointers to 277/* STRUCTURE functions ... all of these functions deal with pointers to ENGINE
133 * ENGINE structures where the pointers have a "structural reference". 278 * structures where the pointers have a "structural reference". This means that
134 * This means that their reference is to allow access to the structure 279 * their reference is to allowed access to the structure but it does not imply
135 * but it does not imply that the structure is functional. To simply 280 * that the structure is functional. To simply increment or decrement the
136 * increment or decrement the structural reference count, use ENGINE_new 281 * structural reference count, use ENGINE_by_id and ENGINE_free. NB: This is not
137 * and ENGINE_free. NB: This is not required when iterating using 282 * required when iterating using ENGINE_get_next as it will automatically
138 * ENGINE_get_next as it will automatically decrement the structural 283 * decrement the structural reference count of the "current" ENGINE and
139 * reference count of the "current" ENGINE and increment the structural 284 * increment the structural reference count of the ENGINE it returns (unless it
140 * reference count of the ENGINE it returns (unless it is NULL). */ 285 * is NULL). */
141 286
142/* Get the first/last "ENGINE" type available. */ 287/* Get the first/last "ENGINE" type available. */
143ENGINE *ENGINE_get_first(void); 288ENGINE *ENGINE_get_first(void);
@@ -151,67 +296,170 @@ int ENGINE_add(ENGINE *e);
151int ENGINE_remove(ENGINE *e); 296int ENGINE_remove(ENGINE *e);
152/* Retrieve an engine from the list by its unique "id" value. */ 297/* Retrieve an engine from the list by its unique "id" value. */
153ENGINE *ENGINE_by_id(const char *id); 298ENGINE *ENGINE_by_id(const char *id);
299/* Add all the built-in engines. */
300void ENGINE_load_openssl(void);
301void ENGINE_load_dynamic(void);
302void ENGINE_load_cswift(void);
303void ENGINE_load_chil(void);
304void ENGINE_load_atalla(void);
305void ENGINE_load_nuron(void);
306void ENGINE_load_ubsec(void);
307void ENGINE_load_aep(void);
308void ENGINE_load_sureware(void);
309void ENGINE_load_4758cca(void);
310void ENGINE_load_openbsd_dev_crypto(void);
311void ENGINE_load_builtin_engines(void);
312#ifdef __OpenBSD__
313void ENGINE_load_cryptodev(void);
314#endif
315
316/* Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation
317 * "registry" handling. */
318unsigned int ENGINE_get_table_flags(void);
319void ENGINE_set_table_flags(unsigned int flags);
154 320
155/* These functions are useful for manufacturing new ENGINE 321/* Manage registration of ENGINEs per "table". For each type, there are 3
156 * structures. They don't address reference counting at all - 322 * functions;
157 * one uses them to populate an ENGINE structure with personalised 323 * ENGINE_register_***(e) - registers the implementation from 'e' (if it has one)
158 * implementations of things prior to using it directly or adding 324 * ENGINE_unregister_***(e) - unregister the implementation from 'e'
159 * it to the builtin ENGINE list in OpenSSL. These are also here 325 * ENGINE_register_all_***() - call ENGINE_register_***() for each 'e' in the list
160 * so that the ENGINE structure doesn't have to be exposed and 326 * Cleanup is automatically registered from each table when required, so
161 * break binary compatibility! 327 * ENGINE_cleanup() will reverse any "register" operations. */
162 * 328
163 * NB: I'm changing ENGINE_new to force the ENGINE structure to 329int ENGINE_register_RSA(ENGINE *e);
164 * be allocated from within OpenSSL. See the comment for 330void ENGINE_unregister_RSA(ENGINE *e);
165 * ENGINE_get_struct_size(). 331void ENGINE_register_all_RSA(void);
166 */ 332
167#if 0 333int ENGINE_register_DSA(ENGINE *e);
168ENGINE *ENGINE_new(ENGINE *e); 334void ENGINE_unregister_DSA(ENGINE *e);
169#else 335void ENGINE_register_all_DSA(void);
336
337int ENGINE_register_DH(ENGINE *e);
338void ENGINE_unregister_DH(ENGINE *e);
339void ENGINE_register_all_DH(void);
340
341int ENGINE_register_RAND(ENGINE *e);
342void ENGINE_unregister_RAND(ENGINE *e);
343void ENGINE_register_all_RAND(void);
344
345int ENGINE_register_ciphers(ENGINE *e);
346void ENGINE_unregister_ciphers(ENGINE *e);
347void ENGINE_register_all_ciphers(void);
348
349int ENGINE_register_digests(ENGINE *e);
350void ENGINE_unregister_digests(ENGINE *e);
351void ENGINE_register_all_digests(void);
352
353/* These functions register all support from the above categories. Note, use of
354 * these functions can result in static linkage of code your application may not
355 * need. If you only need a subset of functionality, consider using more
356 * selective initialisation. */
357int ENGINE_register_complete(ENGINE *e);
358int ENGINE_register_all_complete(void);
359
360/* Send parametrised control commands to the engine. The possibilities to send
361 * down an integer, a pointer to data or a function pointer are provided. Any of
362 * the parameters may or may not be NULL, depending on the command number. In
363 * actuality, this function only requires a structural (rather than functional)
364 * reference to an engine, but many control commands may require the engine be
365 * functional. The caller should be aware of trying commands that require an
366 * operational ENGINE, and only use functional references in such situations. */
367int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)());
368
369/* This function tests if an ENGINE-specific command is usable as a "setting".
370 * Eg. in an application's config file that gets processed through
371 * ENGINE_ctrl_cmd_string(). If this returns zero, it is not available to
372 * ENGINE_ctrl_cmd_string(), only ENGINE_ctrl(). */
373int ENGINE_cmd_is_executable(ENGINE *e, int cmd);
374
375/* This function works like ENGINE_ctrl() with the exception of taking a
376 * command name instead of a command number, and can handle optional commands.
377 * See the comment on ENGINE_ctrl_cmd_string() for an explanation on how to
378 * use the cmd_name and cmd_optional. */
379int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name,
380 long i, void *p, void (*f)(), int cmd_optional);
381
382/* This function passes a command-name and argument to an ENGINE. The cmd_name
383 * is converted to a command number and the control command is called using
384 * 'arg' as an argument (unless the ENGINE doesn't support such a command, in
385 * which case no control command is called). The command is checked for input
386 * flags, and if necessary the argument will be converted to a numeric value. If
387 * cmd_optional is non-zero, then if the ENGINE doesn't support the given
388 * cmd_name the return value will be success anyway. This function is intended
389 * for applications to use so that users (or config files) can supply
390 * engine-specific config data to the ENGINE at run-time to control behaviour of
391 * specific engines. As such, it shouldn't be used for calling ENGINE_ctrl()
392 * functions that return data, deal with binary data, or that are otherwise
393 * supposed to be used directly through ENGINE_ctrl() in application code. Any
394 * "return" data from an ENGINE_ctrl() operation in this function will be lost -
395 * the return value is interpreted as failure if the return value is zero,
396 * success otherwise, and this function returns a boolean value as a result. In
397 * other words, vendors of 'ENGINE'-enabled devices should write ENGINE
398 * implementations with parameterisations that work in this scheme, so that
399 * compliant ENGINE-based applications can work consistently with the same
400 * configuration for the same ENGINE-enabled devices, across applications. */
401int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg,
402 int cmd_optional);
403
404/* These functions are useful for manufacturing new ENGINE structures. They
405 * don't address reference counting at all - one uses them to populate an ENGINE
406 * structure with personalised implementations of things prior to using it
407 * directly or adding it to the builtin ENGINE list in OpenSSL. These are also
408 * here so that the ENGINE structure doesn't have to be exposed and break binary
409 * compatibility! */
170ENGINE *ENGINE_new(void); 410ENGINE *ENGINE_new(void);
171#endif
172int ENGINE_free(ENGINE *e); 411int ENGINE_free(ENGINE *e);
173int ENGINE_set_id(ENGINE *e, const char *id); 412int ENGINE_set_id(ENGINE *e, const char *id);
174int ENGINE_set_name(ENGINE *e, const char *name); 413int ENGINE_set_name(ENGINE *e, const char *name);
175int ENGINE_set_RSA(ENGINE *e, RSA_METHOD *rsa_meth); 414int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth);
176int ENGINE_set_DSA(ENGINE *e, DSA_METHOD *dsa_meth); 415int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth);
177int ENGINE_set_DH(ENGINE *e, DH_METHOD *dh_meth); 416int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth);
178int ENGINE_set_RAND(ENGINE *e, RAND_METHOD *rand_meth); 417int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth);
179int ENGINE_set_BN_mod_exp(ENGINE *e, BN_MOD_EXP bn_mod_exp); 418int ENGINE_set_destroy_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR destroy_f);
180int ENGINE_set_BN_mod_exp_crt(ENGINE *e, BN_MOD_EXP_CRT bn_mod_exp_crt);
181int ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f); 419int ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f);
182int ENGINE_set_finish_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f); 420int ENGINE_set_finish_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f);
183int ENGINE_set_ctrl_function(ENGINE *e, ENGINE_CTRL_FUNC_PTR ctrl_f); 421int ENGINE_set_ctrl_function(ENGINE *e, ENGINE_CTRL_FUNC_PTR ctrl_f);
422int ENGINE_set_load_privkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpriv_f);
423int ENGINE_set_load_pubkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpub_f);
424int ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f);
425int ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f);
426int ENGINE_set_flags(ENGINE *e, int flags);
427int ENGINE_set_cmd_defns(ENGINE *e, const ENGINE_CMD_DEFN *defns);
428/* These functions (and the "get" function lower down) allow control over any
429 * per-structure ENGINE data. */
430int ENGINE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
431 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
432int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg);
184 433
185/* These return values from within the ENGINE structure. These can 434/* This function cleans up anything that needs it. Eg. the ENGINE_add() function
186 * be useful with functional references as well as structural 435 * automatically ensures the list cleanup function is registered to be called
187 * references - it depends which you obtained. Using the result 436 * from ENGINE_cleanup(). Similarly, all ENGINE_register_*** functions ensure
188 * for functional purposes if you only obtained a structural 437 * ENGINE_cleanup() will clean up after them. */
189 * reference may be problematic! */ 438void ENGINE_cleanup(void);
190const char *ENGINE_get_id(ENGINE *e); 439
191const char *ENGINE_get_name(ENGINE *e); 440/* These return values from within the ENGINE structure. These can be useful
192RSA_METHOD *ENGINE_get_RSA(ENGINE *e); 441 * with functional references as well as structural references - it depends
193DSA_METHOD *ENGINE_get_DSA(ENGINE *e); 442 * which you obtained. Using the result for functional purposes if you only
194DH_METHOD *ENGINE_get_DH(ENGINE *e); 443 * obtained a structural reference may be problematic! */
195RAND_METHOD *ENGINE_get_RAND(ENGINE *e); 444const char *ENGINE_get_id(const ENGINE *e);
196BN_MOD_EXP ENGINE_get_BN_mod_exp(ENGINE *e); 445const char *ENGINE_get_name(const ENGINE *e);
197BN_MOD_EXP_CRT ENGINE_get_BN_mod_exp_crt(ENGINE *e); 446const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e);
198ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(ENGINE *e); 447const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e);
199ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(ENGINE *e); 448const DH_METHOD *ENGINE_get_DH(const ENGINE *e);
200ENGINE_CTRL_FUNC_PTR ENGINE_get_ctrl_function(ENGINE *e); 449const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e);
201 450ENGINE_GEN_INT_FUNC_PTR ENGINE_get_destroy_function(const ENGINE *e);
202/* ENGINE_new is normally passed a NULL in the first parameter because 451ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const ENGINE *e);
203 * the calling code doesn't have access to the definition of the ENGINE 452ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(const ENGINE *e);
204 * structure (for good reason). However, if the caller wishes to use 453ENGINE_CTRL_FUNC_PTR ENGINE_get_ctrl_function(const ENGINE *e);
205 * its own memory allocation or use a static array, the following call 454ENGINE_LOAD_KEY_PTR ENGINE_get_load_privkey_function(const ENGINE *e);
206 * should be used to check the amount of memory the ENGINE structure 455ENGINE_LOAD_KEY_PTR ENGINE_get_load_pubkey_function(const ENGINE *e);
207 * will occupy. This will make the code more future-proof. 456ENGINE_CIPHERS_PTR ENGINE_get_ciphers(const ENGINE *e);
208 * 457ENGINE_DIGESTS_PTR ENGINE_get_digests(const ENGINE *e);
209 * NB: I'm "#if 0"-ing this out because it's better to force the use of 458const EVP_CIPHER *ENGINE_get_cipher(ENGINE *e, int nid);
210 * internally allocated memory. See similar change in ENGINE_new(). 459const EVP_MD *ENGINE_get_digest(ENGINE *e, int nid);
211 */ 460const ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e);
212#if 0 461int ENGINE_get_flags(const ENGINE *e);
213int ENGINE_get_struct_size(void); 462void *ENGINE_get_ex_data(const ENGINE *e, int idx);
214#endif
215 463
216/* FUNCTIONAL functions. These functions deal with ENGINE structures 464/* FUNCTIONAL functions. These functions deal with ENGINE structures
217 * that have (or will) be initialised for use. Broadly speaking, the 465 * that have (or will) be initialised for use. Broadly speaking, the
@@ -233,20 +481,14 @@ int ENGINE_init(ENGINE *e);
233 * a corresponding call to ENGINE_free as it also releases a structural 481 * a corresponding call to ENGINE_free as it also releases a structural
234 * reference. */ 482 * reference. */
235int ENGINE_finish(ENGINE *e); 483int ENGINE_finish(ENGINE *e);
236/* Send control parametrised commands to the engine. The possibilities
237 * to send down an integer, a pointer to data or a function pointer are
238 * provided. Any of the parameters may or may not be NULL, depending
239 * on the command number */
240/* WARNING: This is currently experimental and may change radically! */
241int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)());
242 484
243/* The following functions handle keys that are stored in some secondary 485/* The following functions handle keys that are stored in some secondary
244 * location, handled by the engine. The storage may be on a card or 486 * location, handled by the engine. The storage may be on a card or
245 * whatever. */ 487 * whatever. */
246EVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id, 488EVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id,
247 const char *passphrase); 489 UI_METHOD *ui_method, void *callback_data);
248EVP_PKEY *ENGINE_load_public_key(ENGINE *e, const char *key_id, 490EVP_PKEY *ENGINE_load_public_key(ENGINE *e, const char *key_id,
249 const char *passphrase); 491 UI_METHOD *ui_method, void *callback_data);
250 492
251/* This returns a pointer for the current ENGINE structure that 493/* This returns a pointer for the current ENGINE structure that
252 * is (by default) performing any RSA operations. The value returned 494 * is (by default) performing any RSA operations. The value returned
@@ -257,117 +499,192 @@ ENGINE *ENGINE_get_default_RSA(void);
257ENGINE *ENGINE_get_default_DSA(void); 499ENGINE *ENGINE_get_default_DSA(void);
258ENGINE *ENGINE_get_default_DH(void); 500ENGINE *ENGINE_get_default_DH(void);
259ENGINE *ENGINE_get_default_RAND(void); 501ENGINE *ENGINE_get_default_RAND(void);
260ENGINE *ENGINE_get_default_BN_mod_exp(void); 502/* These functions can be used to get a functional reference to perform
261ENGINE *ENGINE_get_default_BN_mod_exp_crt(void); 503 * ciphering or digesting corresponding to "nid". */
504ENGINE *ENGINE_get_cipher_engine(int nid);
505ENGINE *ENGINE_get_digest_engine(int nid);
262 506
263/* This sets a new default ENGINE structure for performing RSA 507/* This sets a new default ENGINE structure for performing RSA
264 * operations. If the result is non-zero (success) then the ENGINE 508 * operations. If the result is non-zero (success) then the ENGINE
265 * structure will have had its reference count up'd so the caller 509 * structure will have had its reference count up'd so the caller
266 * should still free their own reference 'e'. */ 510 * should still free their own reference 'e'. */
267int ENGINE_set_default_RSA(ENGINE *e); 511int ENGINE_set_default_RSA(ENGINE *e);
512int ENGINE_set_default_string(ENGINE *e, const char *list);
268/* Same for the other "methods" */ 513/* Same for the other "methods" */
269int ENGINE_set_default_DSA(ENGINE *e); 514int ENGINE_set_default_DSA(ENGINE *e);
270int ENGINE_set_default_DH(ENGINE *e); 515int ENGINE_set_default_DH(ENGINE *e);
271int ENGINE_set_default_RAND(ENGINE *e); 516int ENGINE_set_default_RAND(ENGINE *e);
272int ENGINE_set_default_BN_mod_exp(ENGINE *e); 517int ENGINE_set_default_ciphers(ENGINE *e);
273int ENGINE_set_default_BN_mod_exp_crt(ENGINE *e); 518int ENGINE_set_default_digests(ENGINE *e);
274 519
275/* The combination "set" - the flags are bitwise "OR"d from the 520/* The combination "set" - the flags are bitwise "OR"d from the
276 * ENGINE_METHOD_*** defines above. */ 521 * ENGINE_METHOD_*** defines above. As with the "ENGINE_register_complete()"
522 * function, this function can result in unnecessary static linkage. If your
523 * application requires only specific functionality, consider using more
524 * selective functions. */
277int ENGINE_set_default(ENGINE *e, unsigned int flags); 525int ENGINE_set_default(ENGINE *e, unsigned int flags);
278 526
279/* Obligatory error function. */ 527void ENGINE_add_conf_module(void);
280void ERR_load_ENGINE_strings(void);
281 528
282/* 529/* Deprecated functions ... */
283 * Error codes for all engine functions. NB: We use "generic" 530/* int ENGINE_clear_defaults(void); */
284 * function names instead of per-implementation ones because this 531
285 * levels the playing field for externally implemented bootstrapped 532/**************************/
286 * support code. As the filename and line number is included, it's 533/* DYNAMIC ENGINE SUPPORT */
287 * more important to indicate the type of function, so that 534/**************************/
288 * bootstrapped code (that can't easily add its own errors in) can 535
289 * use the same error codes too. 536/* Binary/behaviour compatibility levels */
290 */ 537#define OSSL_DYNAMIC_VERSION (unsigned long)0x00010100
538/* Binary versions older than this are too old for us (whether we're a loader or
539 * a loadee) */
540#define OSSL_DYNAMIC_OLDEST (unsigned long)0x00010100
541
542/* When compiling an ENGINE entirely as an external shared library, loadable by
543 * the "dynamic" ENGINE, these types are needed. The 'dynamic_fns' structure
544 * type provides the calling application's (or library's) error functionality
545 * and memory management function pointers to the loaded library. These should
546 * be used/set in the loaded library code so that the loading application's
547 * 'state' will be used/changed in all operations. */
548typedef void *(*dyn_MEM_malloc_cb)(size_t);
549typedef void *(*dyn_MEM_realloc_cb)(void *, size_t);
550typedef void (*dyn_MEM_free_cb)(void *);
551typedef struct st_dynamic_MEM_fns {
552 dyn_MEM_malloc_cb malloc_cb;
553 dyn_MEM_realloc_cb realloc_cb;
554 dyn_MEM_free_cb free_cb;
555 } dynamic_MEM_fns;
556/* FIXME: Perhaps the memory and locking code (crypto.h) should declare and use
557 * these types so we (and any other dependant code) can simplify a bit?? */
558typedef void (*dyn_lock_locking_cb)(int,int,const char *,int);
559typedef int (*dyn_lock_add_lock_cb)(int*,int,int,const char *,int);
560typedef struct CRYPTO_dynlock_value *(*dyn_dynlock_create_cb)(
561 const char *,int);
562typedef void (*dyn_dynlock_lock_cb)(int,struct CRYPTO_dynlock_value *,
563 const char *,int);
564typedef void (*dyn_dynlock_destroy_cb)(struct CRYPTO_dynlock_value *,
565 const char *,int);
566typedef struct st_dynamic_LOCK_fns {
567 dyn_lock_locking_cb lock_locking_cb;
568 dyn_lock_add_lock_cb lock_add_lock_cb;
569 dyn_dynlock_create_cb dynlock_create_cb;
570 dyn_dynlock_lock_cb dynlock_lock_cb;
571 dyn_dynlock_destroy_cb dynlock_destroy_cb;
572 } dynamic_LOCK_fns;
573/* The top-level structure */
574typedef struct st_dynamic_fns {
575 const ERR_FNS *err_fns;
576 const CRYPTO_EX_DATA_IMPL *ex_data_fns;
577 dynamic_MEM_fns mem_fns;
578 dynamic_LOCK_fns lock_fns;
579 } dynamic_fns;
580
581/* The version checking function should be of this prototype. NB: The
582 * ossl_version value passed in is the OSSL_DYNAMIC_VERSION of the loading code.
583 * If this function returns zero, it indicates a (potential) version
584 * incompatibility and the loaded library doesn't believe it can proceed.
585 * Otherwise, the returned value is the (latest) version supported by the
586 * loading library. The loader may still decide that the loaded code's version
587 * is unsatisfactory and could veto the load. The function is expected to
588 * be implemented with the symbol name "v_check", and a default implementation
589 * can be fully instantiated with IMPLEMENT_DYNAMIC_CHECK_FN(). */
590typedef unsigned long (*dynamic_v_check_fn)(unsigned long ossl_version);
591#define IMPLEMENT_DYNAMIC_CHECK_FN() \
592 unsigned long v_check(unsigned long v) { \
593 if(v >= OSSL_DYNAMIC_OLDEST) return OSSL_DYNAMIC_VERSION; \
594 return 0; }
595
596/* This function is passed the ENGINE structure to initialise with its own
597 * function and command settings. It should not adjust the structural or
598 * functional reference counts. If this function returns zero, (a) the load will
599 * be aborted, (b) the previous ENGINE state will be memcpy'd back onto the
600 * structure, and (c) the shared library will be unloaded. So implementations
601 * should do their own internal cleanup in failure circumstances otherwise they
602 * could leak. The 'id' parameter, if non-NULL, represents the ENGINE id that
603 * the loader is looking for. If this is NULL, the shared library can choose to
604 * return failure or to initialise a 'default' ENGINE. If non-NULL, the shared
605 * library must initialise only an ENGINE matching the passed 'id'. The function
606 * is expected to be implemented with the symbol name "bind_engine". A standard
607 * implementation can be instantiated with IMPLEMENT_DYNAMIC_BIND_FN(fn) where
608 * the parameter 'fn' is a callback function that populates the ENGINE structure
609 * and returns an int value (zero for failure). 'fn' should have prototype;
610 * [static] int fn(ENGINE *e, const char *id); */
611typedef int (*dynamic_bind_engine)(ENGINE *e, const char *id,
612 const dynamic_fns *fns);
613#define IMPLEMENT_DYNAMIC_BIND_FN(fn) \
614 int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns) { \
615 if(!CRYPTO_set_mem_functions(fns->mem_fns.malloc_cb, \
616 fns->mem_fns.realloc_cb, fns->mem_fns.free_cb)) \
617 return 0; \
618 CRYPTO_set_locking_callback(fns->lock_fns.lock_locking_cb); \
619 CRYPTO_set_add_lock_callback(fns->lock_fns.lock_add_lock_cb); \
620 CRYPTO_set_dynlock_create_callback(fns->lock_fns.dynlock_create_cb); \
621 CRYPTO_set_dynlock_lock_callback(fns->lock_fns.dynlock_lock_cb); \
622 CRYPTO_set_dynlock_destroy_callback(fns->lock_fns.dynlock_destroy_cb); \
623 if(!CRYPTO_set_ex_data_implementation(fns->ex_data_fns)) \
624 return 0; \
625 if(!ERR_set_implementation(fns->err_fns)) return 0; \
626 if(!fn(e,id)) return 0; \
627 return 1; }
291 628
292/* BEGIN ERROR CODES */ 629/* BEGIN ERROR CODES */
293/* The following lines are auto generated by the script mkerr.pl. Any changes 630/* The following lines are auto generated by the script mkerr.pl. Any changes
294 * made after this point may be overwritten when the script is next run. 631 * made after this point may be overwritten when the script is next run.
295 */ 632 */
633void ERR_load_ENGINE_strings(void);
296 634
297/* Error codes for the ENGINE functions. */ 635/* Error codes for the ENGINE functions. */
298 636
299/* Function codes. */ 637/* Function codes. */
300#define ENGINE_F_ATALLA_FINISH 135 638#define ENGINE_F_DYNAMIC_CTRL 180
301#define ENGINE_F_ATALLA_INIT 136 639#define ENGINE_F_DYNAMIC_GET_DATA_CTX 181
302#define ENGINE_F_ATALLA_MOD_EXP 137 640#define ENGINE_F_DYNAMIC_LOAD 182
303#define ENGINE_F_ATALLA_RSA_MOD_EXP 138
304#define ENGINE_F_CSWIFT_DSA_SIGN 133
305#define ENGINE_F_CSWIFT_DSA_VERIFY 134
306#define ENGINE_F_CSWIFT_FINISH 100
307#define ENGINE_F_CSWIFT_INIT 101
308#define ENGINE_F_CSWIFT_MOD_EXP 102
309#define ENGINE_F_CSWIFT_MOD_EXP_CRT 103
310#define ENGINE_F_CSWIFT_RSA_MOD_EXP 104
311#define ENGINE_F_ENGINE_ADD 105 641#define ENGINE_F_ENGINE_ADD 105
312#define ENGINE_F_ENGINE_BY_ID 106 642#define ENGINE_F_ENGINE_BY_ID 106
643#define ENGINE_F_ENGINE_CMD_IS_EXECUTABLE 170
313#define ENGINE_F_ENGINE_CTRL 142 644#define ENGINE_F_ENGINE_CTRL 142
645#define ENGINE_F_ENGINE_CTRL_CMD 178
646#define ENGINE_F_ENGINE_CTRL_CMD_STRING 171
314#define ENGINE_F_ENGINE_FINISH 107 647#define ENGINE_F_ENGINE_FINISH 107
315#define ENGINE_F_ENGINE_FREE 108 648#define ENGINE_F_ENGINE_FREE 108
316#define ENGINE_F_ENGINE_GET_BN_MOD_EXP 109 649#define ENGINE_F_ENGINE_GET_CIPHER 185
317#define ENGINE_F_ENGINE_GET_BN_MOD_EXP_CRT 110 650#define ENGINE_F_ENGINE_GET_DEFAULT_TYPE 177
318#define ENGINE_F_ENGINE_GET_CTRL_FUNCTION 144 651#define ENGINE_F_ENGINE_GET_DIGEST 186
319#define ENGINE_F_ENGINE_GET_DH 111
320#define ENGINE_F_ENGINE_GET_DSA 112
321#define ENGINE_F_ENGINE_GET_FINISH_FUNCTION 145
322#define ENGINE_F_ENGINE_GET_ID 113
323#define ENGINE_F_ENGINE_GET_INIT_FUNCTION 146
324#define ENGINE_F_ENGINE_GET_NAME 114
325#define ENGINE_F_ENGINE_GET_NEXT 115 652#define ENGINE_F_ENGINE_GET_NEXT 115
326#define ENGINE_F_ENGINE_GET_PREV 116 653#define ENGINE_F_ENGINE_GET_PREV 116
327#define ENGINE_F_ENGINE_GET_RAND 117
328#define ENGINE_F_ENGINE_GET_RSA 118
329#define ENGINE_F_ENGINE_INIT 119 654#define ENGINE_F_ENGINE_INIT 119
330#define ENGINE_F_ENGINE_LIST_ADD 120 655#define ENGINE_F_ENGINE_LIST_ADD 120
331#define ENGINE_F_ENGINE_LIST_REMOVE 121 656#define ENGINE_F_ENGINE_LIST_REMOVE 121
332#define ENGINE_F_ENGINE_LOAD_PRIVATE_KEY 150 657#define ENGINE_F_ENGINE_LOAD_PRIVATE_KEY 150
333#define ENGINE_F_ENGINE_LOAD_PUBLIC_KEY 151 658#define ENGINE_F_ENGINE_LOAD_PUBLIC_KEY 151
659#define ENGINE_F_ENGINE_MODULE_INIT 187
334#define ENGINE_F_ENGINE_NEW 122 660#define ENGINE_F_ENGINE_NEW 122
335#define ENGINE_F_ENGINE_REMOVE 123 661#define ENGINE_F_ENGINE_REMOVE 123
336#define ENGINE_F_ENGINE_SET_BN_MOD_EXP 124 662#define ENGINE_F_ENGINE_SET_DEFAULT_STRING 189
337#define ENGINE_F_ENGINE_SET_BN_MOD_EXP_CRT 125
338#define ENGINE_F_ENGINE_SET_CTRL_FUNCTION 147
339#define ENGINE_F_ENGINE_SET_DEFAULT_TYPE 126 663#define ENGINE_F_ENGINE_SET_DEFAULT_TYPE 126
340#define ENGINE_F_ENGINE_SET_DH 127
341#define ENGINE_F_ENGINE_SET_DSA 128
342#define ENGINE_F_ENGINE_SET_FINISH_FUNCTION 148
343#define ENGINE_F_ENGINE_SET_ID 129 664#define ENGINE_F_ENGINE_SET_ID 129
344#define ENGINE_F_ENGINE_SET_INIT_FUNCTION 149
345#define ENGINE_F_ENGINE_SET_NAME 130 665#define ENGINE_F_ENGINE_SET_NAME 130
346#define ENGINE_F_ENGINE_SET_RAND 131 666#define ENGINE_F_ENGINE_TABLE_REGISTER 184
347#define ENGINE_F_ENGINE_SET_RSA 132
348#define ENGINE_F_ENGINE_UNLOAD_KEY 152 667#define ENGINE_F_ENGINE_UNLOAD_KEY 152
349#define ENGINE_F_HWCRHK_CTRL 143 668#define ENGINE_F_INT_CTRL_HELPER 172
350#define ENGINE_F_HWCRHK_FINISH 135 669#define ENGINE_F_INT_ENGINE_CONFIGURE 188
351#define ENGINE_F_HWCRHK_GET_PASS 155
352#define ENGINE_F_HWCRHK_INIT 136
353#define ENGINE_F_HWCRHK_LOAD_PRIVKEY 153
354#define ENGINE_F_HWCRHK_LOAD_PUBKEY 154
355#define ENGINE_F_HWCRHK_MOD_EXP 137
356#define ENGINE_F_HWCRHK_MOD_EXP_CRT 138
357#define ENGINE_F_HWCRHK_RAND_BYTES 139
358#define ENGINE_F_HWCRHK_RSA_MOD_EXP 140
359#define ENGINE_F_LOG_MESSAGE 141 670#define ENGINE_F_LOG_MESSAGE 141
671#define ENGINE_F_SET_DATA_CTX 183
360 672
361/* Reason codes. */ 673/* Reason codes. */
362#define ENGINE_R_ALREADY_LOADED 100 674#define ENGINE_R_ALREADY_LOADED 100
363#define ENGINE_R_BIO_WAS_FREED 121 675#define ENGINE_R_ARGUMENT_IS_NOT_A_NUMBER 133
364#define ENGINE_R_BN_CTX_FULL 101 676#define ENGINE_R_CMD_NOT_EXECUTABLE 134
365#define ENGINE_R_BN_EXPAND_FAIL 102 677#define ENGINE_R_COMMAND_TAKES_INPUT 135
366#define ENGINE_R_CHIL_ERROR 123 678#define ENGINE_R_COMMAND_TAKES_NO_INPUT 136
367#define ENGINE_R_CONFLICTING_ENGINE_ID 103 679#define ENGINE_R_CONFLICTING_ENGINE_ID 103
368#define ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED 119 680#define ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED 119
681#define ENGINE_R_DH_NOT_IMPLEMENTED 139
682#define ENGINE_R_DSA_NOT_IMPLEMENTED 140
369#define ENGINE_R_DSO_FAILURE 104 683#define ENGINE_R_DSO_FAILURE 104
684#define ENGINE_R_DSO_NOT_FOUND 132
685#define ENGINE_R_ENGINES_SECTION_ERROR 148
370#define ENGINE_R_ENGINE_IS_NOT_IN_LIST 105 686#define ENGINE_R_ENGINE_IS_NOT_IN_LIST 105
687#define ENGINE_R_ENGINE_SECTION_ERROR 149
371#define ENGINE_R_FAILED_LOADING_PRIVATE_KEY 128 688#define ENGINE_R_FAILED_LOADING_PRIVATE_KEY 128
372#define ENGINE_R_FAILED_LOADING_PUBLIC_KEY 129 689#define ENGINE_R_FAILED_LOADING_PUBLIC_KEY 129
373#define ENGINE_R_FINISH_FAILED 106 690#define ENGINE_R_FINISH_FAILED 106
@@ -375,24 +692,26 @@ void ERR_load_ENGINE_strings(void);
375#define ENGINE_R_ID_OR_NAME_MISSING 108 692#define ENGINE_R_ID_OR_NAME_MISSING 108
376#define ENGINE_R_INIT_FAILED 109 693#define ENGINE_R_INIT_FAILED 109
377#define ENGINE_R_INTERNAL_LIST_ERROR 110 694#define ENGINE_R_INTERNAL_LIST_ERROR 110
378#define ENGINE_R_MISSING_KEY_COMPONENTS 111 695#define ENGINE_R_INVALID_ARGUMENT 143
696#define ENGINE_R_INVALID_CMD_NAME 137
697#define ENGINE_R_INVALID_CMD_NUMBER 138
698#define ENGINE_R_INVALID_INIT_VALUE 151
699#define ENGINE_R_INVALID_STRING 150
379#define ENGINE_R_NOT_INITIALISED 117 700#define ENGINE_R_NOT_INITIALISED 117
380#define ENGINE_R_NOT_LOADED 112 701#define ENGINE_R_NOT_LOADED 112
381#define ENGINE_R_NO_CALLBACK 127
382#define ENGINE_R_NO_CONTROL_FUNCTION 120 702#define ENGINE_R_NO_CONTROL_FUNCTION 120
383#define ENGINE_R_NO_KEY 124 703#define ENGINE_R_NO_INDEX 144
384#define ENGINE_R_NO_LOAD_FUNCTION 125 704#define ENGINE_R_NO_LOAD_FUNCTION 125
385#define ENGINE_R_NO_REFERENCE 130 705#define ENGINE_R_NO_REFERENCE 130
386#define ENGINE_R_NO_SUCH_ENGINE 116 706#define ENGINE_R_NO_SUCH_ENGINE 116
387#define ENGINE_R_NO_UNLOAD_FUNCTION 126 707#define ENGINE_R_NO_UNLOAD_FUNCTION 126
388#define ENGINE_R_PROVIDE_PARAMETERS 113 708#define ENGINE_R_PROVIDE_PARAMETERS 113
389#define ENGINE_R_REQUEST_FAILED 114 709#define ENGINE_R_RSA_NOT_IMPLEMENTED 141
390#define ENGINE_R_REQUEST_FALLBACK 118 710#define ENGINE_R_UNIMPLEMENTED_CIPHER 146
391#define ENGINE_R_SIZE_TOO_LARGE_OR_TOO_SMALL 122 711#define ENGINE_R_UNIMPLEMENTED_DIGEST 147
392#define ENGINE_R_UNIT_FAILURE 115 712#define ENGINE_R_VERSION_INCOMPATIBILITY 145
393 713
394#ifdef __cplusplus 714#ifdef __cplusplus
395} 715}
396#endif 716#endif
397#endif 717#endif
398
diff --git a/src/lib/libcrypto/engine/enginetest.c b/src/lib/libcrypto/engine/enginetest.c
index a5a3c47fcb..87fa8c57b7 100644
--- a/src/lib/libcrypto/engine/enginetest.c
+++ b/src/lib/libcrypto/engine/enginetest.c
@@ -3,7 +3,7 @@
3 * project 2000. 3 * project 2000.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. 6 * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
@@ -56,8 +56,11 @@
56 * 56 *
57 */ 57 */
58 58
59#include <openssl/e_os2.h>
59#include <stdio.h> 60#include <stdio.h>
60#include <string.h> 61#include <string.h>
62#include <openssl/buffer.h>
63#include <openssl/crypto.h>
61#include <openssl/engine.h> 64#include <openssl/engine.h>
62#include <openssl/err.h> 65#include <openssl/err.h>
63 66
@@ -76,6 +79,9 @@ static void display_engine_list()
76 h = ENGINE_get_next(h); 79 h = ENGINE_get_next(h);
77 } 80 }
78 printf("end of list\n"); 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);
79 } 85 }
80 86
81int main(int argc, char *argv[]) 87int main(int argc, char *argv[])
@@ -91,6 +97,18 @@ int main(int argc, char *argv[])
91 ENGINE *new_h3 = NULL; 97 ENGINE *new_h3 = NULL;
92 ENGINE *new_h4 = NULL; 98 ENGINE *new_h4 = NULL;
93 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);
94 ERR_load_crypto_strings(); 112 ERR_load_crypto_strings();
95 113
96 memset(block, 0, 512 * sizeof(ENGINE *)); 114 memset(block, 0, 512 * sizeof(ENGINE *));
@@ -124,6 +142,8 @@ int main(int argc, char *argv[])
124 printf("Remove failed!\n"); 142 printf("Remove failed!\n");
125 goto end; 143 goto end;
126 } 144 }
145 if (ptr)
146 ENGINE_free(ptr);
127 display_engine_list(); 147 display_engine_list();
128 if(!ENGINE_add(new_h3) || !ENGINE_add(new_h2)) 148 if(!ENGINE_add(new_h3) || !ENGINE_add(new_h2))
129 { 149 {
@@ -158,12 +178,7 @@ int main(int argc, char *argv[])
158 } 178 }
159 else 179 else
160 printf("Remove that should fail did.\n"); 180 printf("Remove that should fail did.\n");
161 if(!ENGINE_remove(new_h1)) 181 ERR_clear_error();
162 {
163 printf("Remove failed!\n");
164 goto end;
165 }
166 display_engine_list();
167 if(!ENGINE_remove(new_h3)) 182 if(!ENGINE_remove(new_h3))
168 { 183 {
169 printf("Remove failed!\n"); 184 printf("Remove failed!\n");
@@ -183,6 +198,8 @@ int main(int argc, char *argv[])
183 if(!ENGINE_remove(ptr)) 198 if(!ENGINE_remove(ptr))
184 printf("Remove failed!i - probably no hardware " 199 printf("Remove failed!i - probably no hardware "
185 "support present.\n"); 200 "support present.\n");
201 if (ptr)
202 ENGINE_free(ptr);
186 display_engine_list(); 203 display_engine_list();
187 if(!ENGINE_add(new_h1) || !ENGINE_remove(new_h1)) 204 if(!ENGINE_add(new_h1) || !ENGINE_remove(new_h1))
188 { 205 {
@@ -195,9 +212,9 @@ int main(int argc, char *argv[])
195 for(loop = 0; loop < 512; loop++) 212 for(loop = 0; loop < 512; loop++)
196 { 213 {
197 sprintf(buf, "id%i", loop); 214 sprintf(buf, "id%i", loop);
198 id = strdup(buf); 215 id = BUF_strdup(buf);
199 sprintf(buf, "Fake engine type %i", loop); 216 sprintf(buf, "Fake engine type %i", loop);
200 name = strdup(buf); 217 name = BUF_strdup(buf);
201 if(((block[loop] = ENGINE_new()) == NULL) || 218 if(((block[loop] = ENGINE_new()) == NULL) ||
202 !ENGINE_set_id(block[loop], id) || 219 !ENGINE_set_id(block[loop], id) ||
203 !ENGINE_set_name(block[loop], name)) 220 !ENGINE_set_name(block[loop], name))
@@ -228,12 +245,13 @@ cleanup_loop:
228 printf("\nRemove failed!\n"); 245 printf("\nRemove failed!\n");
229 goto end; 246 goto end;
230 } 247 }
248 ENGINE_free(ptr);
231 printf("."); fflush(stdout); 249 printf("."); fflush(stdout);
232 } 250 }
233 for(loop = 0; loop < 512; loop++) 251 for(loop = 0; loop < 512; loop++)
234 { 252 {
235 free((char *)(ENGINE_get_id(block[loop]))); 253 OPENSSL_free((void *)ENGINE_get_id(block[loop]));
236 free((char *)(ENGINE_get_name(block[loop]))); 254 OPENSSL_free((void *)ENGINE_get_name(block[loop]));
237 } 255 }
238 printf("\nTests completed happily\n"); 256 printf("\nTests completed happily\n");
239 to_return = 0; 257 to_return = 0;
@@ -247,5 +265,10 @@ end:
247 for(loop = 0; loop < 512; loop++) 265 for(loop = 0; loop < 512; loop++)
248 if(block[loop]) 266 if(block[loop])
249 ENGINE_free(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);
250 return to_return; 273 return to_return;
251 } 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..959d8f1a61
--- /dev/null
+++ b/src/lib/libcrypto/engine/hw_4758_cca.c
@@ -0,0 +1,950 @@
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 def_CCA4758_LIB_NAME[] = CCA_LIB_NAME;
128static const char *CCA4758_LIB_NAME = def_CCA4758_LIB_NAME;
129#ifndef OPENSSL_NO_RSA
130static const char* n_keyRecordRead = CSNDKRR;
131static const char* n_digitalSignatureGenerate = CSNDDSG;
132static const char* n_digitalSignatureVerify = CSNDDSV;
133static const char* n_publicKeyExtract = CSNDPKX;
134static const char* n_pkaEncrypt = CSNDPKE;
135static const char* n_pkaDecrypt = CSNDPKD;
136#endif
137static const char* n_randomNumberGenerate = CSNBRNG;
138
139static int hndidx = -1;
140static DSO *dso = NULL;
141
142/* openssl engine initialization structures */
143/*------------------------------------------*/
144
145#define CCA4758_CMD_SO_PATH ENGINE_CMD_BASE
146static const ENGINE_CMD_DEFN cca4758_cmd_defns[] = {
147 {CCA4758_CMD_SO_PATH,
148 "SO_PATH",
149 "Specifies the path to the '4758cca' shared library",
150 ENGINE_CMD_FLAG_STRING},
151 {0, NULL, NULL, 0}
152 };
153
154#ifndef OPENSSL_NO_RSA
155static RSA_METHOD ibm_4758_cca_rsa =
156 {
157 "IBM 4758 CCA RSA method",
158 cca_rsa_pub_enc,
159 NULL,
160 NULL,
161 cca_rsa_priv_dec,
162 NULL, /*rsa_mod_exp,*/
163 NULL, /*mod_exp_mont,*/
164 NULL, /* init */
165 NULL, /* finish */
166 RSA_FLAG_SIGN_VER, /* flags */
167 NULL, /* app_data */
168 cca_rsa_sign, /* rsa_sign */
169 cca_rsa_verify /* rsa_verify */
170 };
171#endif
172
173static RAND_METHOD ibm_4758_cca_rand =
174 {
175 /* "IBM 4758 RAND method", */
176 NULL, /* seed */
177 cca_get_random_bytes, /* get random bytes from the card */
178 NULL, /* cleanup */
179 NULL, /* add */
180 cca_get_random_bytes, /* pseudo rand */
181 cca_random_status, /* status */
182 };
183
184static const char *engine_4758_cca_id = "4758cca";
185static const char *engine_4758_cca_name = "IBM 4758 CCA hardware engine support";
186
187/* engine implementation */
188/*-----------------------*/
189static int bind_helper(ENGINE *e)
190 {
191 if(!ENGINE_set_id(e, engine_4758_cca_id) ||
192 !ENGINE_set_name(e, engine_4758_cca_name) ||
193#ifndef OPENSSL_NO_RSA
194 !ENGINE_set_RSA(e, &ibm_4758_cca_rsa) ||
195#endif
196 !ENGINE_set_RAND(e, &ibm_4758_cca_rand) ||
197 !ENGINE_set_destroy_function(e, ibm_4758_cca_destroy) ||
198 !ENGINE_set_init_function(e, ibm_4758_cca_init) ||
199 !ENGINE_set_finish_function(e, ibm_4758_cca_finish) ||
200 !ENGINE_set_ctrl_function(e, ibm_4758_cca_ctrl) ||
201 !ENGINE_set_load_privkey_function(e, ibm_4758_load_privkey) ||
202 !ENGINE_set_load_pubkey_function(e, ibm_4758_load_pubkey) ||
203 !ENGINE_set_cmd_defns(e, cca4758_cmd_defns))
204 return 0;
205 /* Ensure the error handling is set up */
206 ERR_load_CCA4758_strings();
207 return 1;
208 }
209
210static ENGINE *engine_4758_cca(void)
211 {
212 ENGINE *ret = ENGINE_new();
213 if(!ret)
214 return NULL;
215 if(!bind_helper(ret))
216 {
217 ENGINE_free(ret);
218 return NULL;
219 }
220 return ret;
221 }
222
223void ENGINE_load_4758cca(void)
224 {
225 ENGINE *e_4758 = engine_4758_cca();
226 if (!e_4758) return;
227 ENGINE_add(e_4758);
228 ENGINE_free(e_4758);
229 ERR_clear_error();
230 }
231
232static int ibm_4758_cca_destroy(ENGINE *e)
233 {
234 ERR_unload_CCA4758_strings();
235 return 1;
236 }
237
238static int ibm_4758_cca_init(ENGINE *e)
239 {
240 if(dso)
241 {
242 CCA4758err(CCA4758_F_IBM_4758_CCA_INIT,CCA4758_R_ALREADY_LOADED);
243 goto err;
244 }
245
246 dso = DSO_load(NULL, CCA4758_LIB_NAME , NULL, 0);
247 if(!dso)
248 {
249 CCA4758err(CCA4758_F_IBM_4758_CCA_INIT,CCA4758_R_DSO_FAILURE);
250 goto err;
251 }
252
253#ifndef OPENSSL_NO_RSA
254 if(!(keyRecordRead = (F_KEYRECORDREAD)
255 DSO_bind_func(dso, n_keyRecordRead)) ||
256 !(randomNumberGenerate = (F_RANDOMNUMBERGENERATE)
257 DSO_bind_func(dso, n_randomNumberGenerate)) ||
258 !(digitalSignatureGenerate = (F_DIGITALSIGNATUREGENERATE)
259 DSO_bind_func(dso, n_digitalSignatureGenerate)) ||
260 !(digitalSignatureVerify = (F_DIGITALSIGNATUREVERIFY)
261 DSO_bind_func(dso, n_digitalSignatureVerify)) ||
262 !(publicKeyExtract = (F_PUBLICKEYEXTRACT)
263 DSO_bind_func(dso, n_publicKeyExtract)) ||
264 !(pkaEncrypt = (F_PKAENCRYPT)
265 DSO_bind_func(dso, n_pkaEncrypt)) ||
266 !(pkaDecrypt = (F_PKADECRYPT)
267 DSO_bind_func(dso, n_pkaDecrypt)))
268 {
269 CCA4758err(CCA4758_F_IBM_4758_CCA_INIT,CCA4758_R_DSO_FAILURE);
270 goto err;
271 }
272#else
273 if(!(randomNumberGenerate = (F_RANDOMNUMBERGENERATE)
274 DSO_bind_func(dso, n_randomNumberGenerate)))
275 {
276 CCA4758err(CCA4758_F_IBM_4758_CCA_INIT,CCA4758_R_DSO_FAILURE);
277 goto err;
278 }
279#endif
280
281 hndidx = RSA_get_ex_new_index(0, "IBM 4758 CCA RSA key handle",
282 NULL, NULL, cca_ex_free);
283
284 return 1;
285err:
286 if(dso)
287 DSO_free(dso);
288 dso = NULL;
289
290 keyRecordRead = (F_KEYRECORDREAD)NULL;
291 randomNumberGenerate = (F_RANDOMNUMBERGENERATE)NULL;
292 digitalSignatureGenerate = (F_DIGITALSIGNATUREGENERATE)NULL;
293 digitalSignatureVerify = (F_DIGITALSIGNATUREVERIFY)NULL;
294 publicKeyExtract = (F_PUBLICKEYEXTRACT)NULL;
295 pkaEncrypt = (F_PKAENCRYPT)NULL;
296 pkaDecrypt = (F_PKADECRYPT)NULL;
297 return 0;
298 }
299
300static int ibm_4758_cca_finish(ENGINE *e)
301 {
302 if(dso)
303 {
304 CCA4758err(CCA4758_F_IBM_4758_CCA_FINISH,
305 CCA4758_R_NOT_LOADED);
306 return 0;
307 }
308 if(!DSO_free(dso))
309 {
310 CCA4758err(CCA4758_F_IBM_4758_CCA_FINISH,
311 CCA4758_R_UNIT_FAILURE);
312 return 0;
313 }
314 dso = NULL;
315 keyRecordRead = (F_KEYRECORDREAD)NULL;
316 randomNumberGenerate = (F_RANDOMNUMBERGENERATE)NULL;
317 digitalSignatureGenerate = (F_DIGITALSIGNATUREGENERATE)NULL;
318 digitalSignatureVerify = (F_DIGITALSIGNATUREVERIFY)NULL;
319 publicKeyExtract = (F_PUBLICKEYEXTRACT)NULL;
320 pkaEncrypt = (F_PKAENCRYPT)NULL;
321 pkaDecrypt = (F_PKADECRYPT)NULL;
322 return 1;
323 }
324
325static int ibm_4758_cca_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
326 {
327 int initialised = ((dso == NULL) ? 0 : 1);
328 switch(cmd)
329 {
330 case CCA4758_CMD_SO_PATH:
331 if(p == NULL)
332 {
333 CCA4758err(CCA4758_F_IBM_4758_CCA_CTRL,
334 ERR_R_PASSED_NULL_PARAMETER);
335 return 0;
336 }
337 if(initialised)
338 {
339 CCA4758err(CCA4758_F_IBM_4758_CCA_CTRL,
340 CCA4758_R_ALREADY_LOADED);
341 return 0;
342 }
343 CCA4758_LIB_NAME = (const char *)p;
344 return 1;
345 default:
346 break;
347 }
348 CCA4758err(CCA4758_F_IBM_4758_CCA_CTRL,
349 CCA4758_R_COMMAND_NOT_IMPLEMENTED);
350 return 0;
351 }
352
353#ifndef OPENSSL_NO_RSA
354
355#define MAX_CCA_PKA_TOKEN_SIZE 2500
356
357static EVP_PKEY *ibm_4758_load_privkey(ENGINE* e, const char* key_id,
358 UI_METHOD *ui_method, void *callback_data)
359 {
360 RSA *rtmp = NULL;
361 EVP_PKEY *res = NULL;
362 unsigned char* keyToken = NULL;
363 unsigned char pubKeyToken[MAX_CCA_PKA_TOKEN_SIZE];
364 long pubKeyTokenLength = MAX_CCA_PKA_TOKEN_SIZE;
365 long keyTokenLength = MAX_CCA_PKA_TOKEN_SIZE;
366 long returnCode;
367 long reasonCode;
368 long exitDataLength = 0;
369 long ruleArrayLength = 0;
370 unsigned char exitData[8];
371 unsigned char ruleArray[8];
372 unsigned char keyLabel[64];
373 long keyLabelLength = strlen(key_id);
374 unsigned char modulus[256];
375 long modulusFieldLength = sizeof(modulus);
376 long modulusLength = 0;
377 unsigned char exponent[256];
378 long exponentLength = sizeof(exponent);
379
380 if (keyLabelLength > sizeof(keyLabel))
381 {
382 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY,
383 CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
384 return NULL;
385 }
386
387 memset(keyLabel,' ', sizeof(keyLabel));
388 memcpy(keyLabel, key_id, keyLabelLength);
389
390 keyToken = OPENSSL_malloc(MAX_CCA_PKA_TOKEN_SIZE + sizeof(long));
391 if (!keyToken)
392 {
393 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY,
394 ERR_R_MALLOC_FAILURE);
395 goto err;
396 }
397
398 keyRecordRead(&returnCode, &reasonCode, &exitDataLength,
399 exitData, &ruleArrayLength, ruleArray, keyLabel,
400 &keyTokenLength, keyToken+sizeof(long));
401
402 if (returnCode)
403 {
404 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY,
405 CCA4758_R_FAILED_LOADING_PRIVATE_KEY);
406 goto err;
407 }
408
409 publicKeyExtract(&returnCode, &reasonCode, &exitDataLength,
410 exitData, &ruleArrayLength, ruleArray, &keyTokenLength,
411 keyToken+sizeof(long), &pubKeyTokenLength, pubKeyToken);
412
413 if (returnCode)
414 {
415 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY,
416 CCA4758_R_FAILED_LOADING_PRIVATE_KEY);
417 goto err;
418 }
419
420 if (!getModulusAndExponent(pubKeyToken, &exponentLength,
421 exponent, &modulusLength, &modulusFieldLength,
422 modulus))
423 {
424 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY,
425 CCA4758_R_FAILED_LOADING_PRIVATE_KEY);
426 goto err;
427 }
428
429 (*(long*)keyToken) = keyTokenLength;
430 rtmp = RSA_new_method(e);
431 RSA_set_ex_data(rtmp, hndidx, (char *)keyToken);
432
433 rtmp->e = BN_bin2bn(exponent, exponentLength, NULL);
434 rtmp->n = BN_bin2bn(modulus, modulusFieldLength, NULL);
435 rtmp->flags |= RSA_FLAG_EXT_PKEY;
436
437 res = EVP_PKEY_new();
438 EVP_PKEY_assign_RSA(res, rtmp);
439
440 return res;
441err:
442 if (keyToken)
443 OPENSSL_free(keyToken);
444 if (res)
445 EVP_PKEY_free(res);
446 if (rtmp)
447 RSA_free(rtmp);
448 return NULL;
449 }
450
451static EVP_PKEY *ibm_4758_load_pubkey(ENGINE* e, const char* key_id,
452 UI_METHOD *ui_method, void *callback_data)
453 {
454 RSA *rtmp = NULL;
455 EVP_PKEY *res = NULL;
456 unsigned char* keyToken = NULL;
457 long keyTokenLength = MAX_CCA_PKA_TOKEN_SIZE;
458 long returnCode;
459 long reasonCode;
460 long exitDataLength = 0;
461 long ruleArrayLength = 0;
462 unsigned char exitData[8];
463 unsigned char ruleArray[8];
464 unsigned char keyLabel[64];
465 long keyLabelLength = strlen(key_id);
466 unsigned char modulus[512];
467 long modulusFieldLength = sizeof(modulus);
468 long modulusLength = 0;
469 unsigned char exponent[512];
470 long exponentLength = sizeof(exponent);
471
472 if (keyLabelLength > sizeof(keyLabel))
473 {
474 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY,
475 CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
476 return NULL;
477 }
478
479 memset(keyLabel,' ', sizeof(keyLabel));
480 memcpy(keyLabel, key_id, keyLabelLength);
481
482 keyToken = OPENSSL_malloc(MAX_CCA_PKA_TOKEN_SIZE + sizeof(long));
483 if (!keyToken)
484 {
485 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PUBKEY,
486 ERR_R_MALLOC_FAILURE);
487 goto err;
488 }
489
490 keyRecordRead(&returnCode, &reasonCode, &exitDataLength, exitData,
491 &ruleArrayLength, ruleArray, keyLabel, &keyTokenLength,
492 keyToken+sizeof(long));
493
494 if (returnCode)
495 {
496 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY,
497 ERR_R_MALLOC_FAILURE);
498 goto err;
499 }
500
501 if (!getModulusAndExponent(keyToken+sizeof(long), &exponentLength,
502 exponent, &modulusLength, &modulusFieldLength, modulus))
503 {
504 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY,
505 CCA4758_R_FAILED_LOADING_PUBLIC_KEY);
506 goto err;
507 }
508
509 (*(long*)keyToken) = keyTokenLength;
510 rtmp = RSA_new_method(e);
511 RSA_set_ex_data(rtmp, hndidx, (char *)keyToken);
512 rtmp->e = BN_bin2bn(exponent, exponentLength, NULL);
513 rtmp->n = BN_bin2bn(modulus, modulusFieldLength, NULL);
514 rtmp->flags |= RSA_FLAG_EXT_PKEY;
515 res = EVP_PKEY_new();
516 EVP_PKEY_assign_RSA(res, rtmp);
517
518 return res;
519err:
520 if (keyToken)
521 OPENSSL_free(keyToken);
522 if (res)
523 EVP_PKEY_free(res);
524 if (rtmp)
525 RSA_free(rtmp);
526 return NULL;
527 }
528
529static int cca_rsa_pub_enc(int flen, const unsigned char *from,
530 unsigned char *to, RSA *rsa,int padding)
531 {
532 long returnCode;
533 long reasonCode;
534 long lflen = flen;
535 long exitDataLength = 0;
536 unsigned char exitData[8];
537 long ruleArrayLength = 1;
538 unsigned char ruleArray[8] = "PKCS-1.2";
539 long dataStructureLength = 0;
540 unsigned char dataStructure[8];
541 long outputLength = RSA_size(rsa);
542 long keyTokenLength;
543 unsigned char* keyToken = (unsigned char*)RSA_get_ex_data(rsa, hndidx);
544
545 keyTokenLength = *(long*)keyToken;
546 keyToken+=sizeof(long);
547
548 pkaEncrypt(&returnCode, &reasonCode, &exitDataLength, exitData,
549 &ruleArrayLength, ruleArray, &lflen, (unsigned char*)from,
550 &dataStructureLength, dataStructure, &keyTokenLength,
551 keyToken, &outputLength, to);
552
553 if (returnCode || reasonCode)
554 return -(returnCode << 16 | reasonCode);
555 return outputLength;
556 }
557
558static int cca_rsa_priv_dec(int flen, const unsigned char *from,
559 unsigned char *to, RSA *rsa,int padding)
560 {
561 long returnCode;
562 long reasonCode;
563 long lflen = flen;
564 long exitDataLength = 0;
565 unsigned char exitData[8];
566 long ruleArrayLength = 1;
567 unsigned char ruleArray[8] = "PKCS-1.2";
568 long dataStructureLength = 0;
569 unsigned char dataStructure[8];
570 long outputLength = RSA_size(rsa);
571 long keyTokenLength;
572 unsigned char* keyToken = (unsigned char*)RSA_get_ex_data(rsa, hndidx);
573
574 keyTokenLength = *(long*)keyToken;
575 keyToken+=sizeof(long);
576
577 pkaDecrypt(&returnCode, &reasonCode, &exitDataLength, exitData,
578 &ruleArrayLength, ruleArray, &lflen, (unsigned char*)from,
579 &dataStructureLength, dataStructure, &keyTokenLength,
580 keyToken, &outputLength, to);
581
582 return (returnCode | reasonCode) ? 0 : 1;
583 }
584
585#define SSL_SIG_LEN 36
586
587static int cca_rsa_verify(int type, const unsigned char *m, unsigned int m_len,
588 unsigned char *sigbuf, unsigned int siglen, const RSA *rsa)
589 {
590 long returnCode;
591 long reasonCode;
592 long lsiglen = siglen;
593 long exitDataLength = 0;
594 unsigned char exitData[8];
595 long ruleArrayLength = 1;
596 unsigned char ruleArray[8] = "PKCS-1.1";
597 long keyTokenLength;
598 unsigned char* keyToken = (unsigned char*)RSA_get_ex_data(rsa, hndidx);
599 long length = SSL_SIG_LEN;
600 long keyLength ;
601 unsigned char *hashBuffer = NULL;
602 X509_SIG sig;
603 ASN1_TYPE parameter;
604 X509_ALGOR algorithm;
605 ASN1_OCTET_STRING digest;
606
607 keyTokenLength = *(long*)keyToken;
608 keyToken+=sizeof(long);
609
610 if (type == NID_md5 || type == NID_sha1)
611 {
612 sig.algor = &algorithm;
613 algorithm.algorithm = OBJ_nid2obj(type);
614
615 if (!algorithm.algorithm)
616 {
617 CCA4758err(CCA4758_F_IBM_4758_CCA_VERIFY,
618 CCA4758_R_UNKNOWN_ALGORITHM_TYPE);
619 return 0;
620 }
621
622 if (!algorithm.algorithm->length)
623 {
624 CCA4758err(CCA4758_F_IBM_4758_CCA_VERIFY,
625 CCA4758_R_ASN1_OID_UNKNOWN_FOR_MD);
626 return 0;
627 }
628
629 parameter.type = V_ASN1_NULL;
630 parameter.value.ptr = NULL;
631 algorithm.parameter = &parameter;
632
633 sig.digest = &digest;
634 sig.digest->data = (unsigned char*)m;
635 sig.digest->length = m_len;
636
637 length = i2d_X509_SIG(&sig, NULL);
638 }
639
640 keyLength = RSA_size(rsa);
641
642 if (length - RSA_PKCS1_PADDING > keyLength)
643 {
644 CCA4758err(CCA4758_F_IBM_4758_CCA_VERIFY,
645 CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
646 return 0;
647 }
648
649 switch (type)
650 {
651 case NID_md5_sha1 :
652 if (m_len != SSL_SIG_LEN)
653 {
654 CCA4758err(CCA4758_F_IBM_4758_CCA_VERIFY,
655 CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
656 return 0;
657 }
658
659 hashBuffer = (unsigned char *)m;
660 length = m_len;
661 break;
662 case NID_md5 :
663 {
664 unsigned char *ptr;
665 ptr = hashBuffer = OPENSSL_malloc(
666 (unsigned int)keyLength+1);
667 if (!hashBuffer)
668 {
669 CCA4758err(CCA4758_F_IBM_4758_CCA_VERIFY,
670 ERR_R_MALLOC_FAILURE);
671 return 0;
672 }
673
674 i2d_X509_SIG(&sig, &ptr);
675 }
676 break;
677 case NID_sha1 :
678 {
679 unsigned char *ptr;
680 ptr = hashBuffer = OPENSSL_malloc(
681 (unsigned int)keyLength+1);
682 if (!hashBuffer)
683 {
684 CCA4758err(CCA4758_F_IBM_4758_CCA_VERIFY,
685 ERR_R_MALLOC_FAILURE);
686 return 0;
687 }
688 i2d_X509_SIG(&sig, &ptr);
689 }
690 break;
691 default:
692 return 0;
693 }
694
695 digitalSignatureVerify(&returnCode, &reasonCode, &exitDataLength,
696 exitData, &ruleArrayLength, ruleArray, &keyTokenLength,
697 keyToken, &length, hashBuffer, &lsiglen, sigbuf);
698
699 if (type == NID_sha1 || type == NID_md5)
700 {
701 memset(hashBuffer, keyLength+1, 0);
702 OPENSSL_free(hashBuffer);
703 }
704
705 return ((returnCode || reasonCode) ? 0 : 1);
706 }
707
708#define SSL_SIG_LEN 36
709
710static int cca_rsa_sign(int type, const unsigned char *m, unsigned int m_len,
711 unsigned char *sigret, unsigned int *siglen, const RSA *rsa)
712 {
713 long returnCode;
714 long reasonCode;
715 long exitDataLength = 0;
716 unsigned char exitData[8];
717 long ruleArrayLength = 1;
718 unsigned char ruleArray[8] = "PKCS-1.1";
719 long outputLength=256;
720 long outputBitLength;
721 long keyTokenLength;
722 unsigned char *hashBuffer = NULL;
723 unsigned char* keyToken = (unsigned char*)RSA_get_ex_data(rsa, hndidx);
724 long length = SSL_SIG_LEN;
725 long keyLength ;
726 X509_SIG sig;
727 ASN1_TYPE parameter;
728 X509_ALGOR algorithm;
729 ASN1_OCTET_STRING digest;
730
731 keyTokenLength = *(long*)keyToken;
732 keyToken+=sizeof(long);
733
734 if (type == NID_md5 || type == NID_sha1)
735 {
736 sig.algor = &algorithm;
737 algorithm.algorithm = OBJ_nid2obj(type);
738
739 if (!algorithm.algorithm)
740 {
741 CCA4758err(CCA4758_F_IBM_4758_CCA_SIGN,
742 CCA4758_R_UNKNOWN_ALGORITHM_TYPE);
743 return 0;
744 }
745
746 if (!algorithm.algorithm->length)
747 {
748 CCA4758err(CCA4758_F_IBM_4758_CCA_SIGN,
749 CCA4758_R_ASN1_OID_UNKNOWN_FOR_MD);
750 return 0;
751 }
752
753 parameter.type = V_ASN1_NULL;
754 parameter.value.ptr = NULL;
755 algorithm.parameter = &parameter;
756
757 sig.digest = &digest;
758 sig.digest->data = (unsigned char*)m;
759 sig.digest->length = m_len;
760
761 length = i2d_X509_SIG(&sig, NULL);
762 }
763
764 keyLength = RSA_size(rsa);
765
766 if (length - RSA_PKCS1_PADDING > keyLength)
767 {
768 CCA4758err(CCA4758_F_IBM_4758_CCA_SIGN,
769 CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
770 return 0;
771 }
772
773 switch (type)
774 {
775 case NID_md5_sha1 :
776 if (m_len != SSL_SIG_LEN)
777 {
778 CCA4758err(CCA4758_F_IBM_4758_CCA_SIGN,
779 CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
780 return 0;
781 }
782 hashBuffer = (unsigned char*)m;
783 length = m_len;
784 break;
785 case NID_md5 :
786 {
787 unsigned char *ptr;
788 ptr = hashBuffer = OPENSSL_malloc(
789 (unsigned int)keyLength+1);
790 if (!hashBuffer)
791 {
792 CCA4758err(CCA4758_F_IBM_4758_CCA_VERIFY,
793 ERR_R_MALLOC_FAILURE);
794 return 0;
795 }
796 i2d_X509_SIG(&sig, &ptr);
797 }
798 break;
799 case NID_sha1 :
800 {
801 unsigned char *ptr;
802 ptr = hashBuffer = OPENSSL_malloc(
803 (unsigned int)keyLength+1);
804 if (!hashBuffer)
805 {
806 CCA4758err(CCA4758_F_IBM_4758_CCA_VERIFY,
807 ERR_R_MALLOC_FAILURE);
808 return 0;
809 }
810 i2d_X509_SIG(&sig, &ptr);
811 }
812 break;
813 default:
814 return 0;
815 }
816
817 digitalSignatureGenerate(&returnCode, &reasonCode, &exitDataLength,
818 exitData, &ruleArrayLength, ruleArray, &keyTokenLength,
819 keyToken, &length, hashBuffer, &outputLength, &outputBitLength,
820 sigret);
821
822 if (type == NID_sha1 || type == NID_md5)
823 {
824 memset(hashBuffer, keyLength+1, 0);
825 OPENSSL_free(hashBuffer);
826 }
827
828 *siglen = outputLength;
829
830 return ((returnCode || reasonCode) ? 0 : 1);
831 }
832
833static int getModulusAndExponent(const unsigned char*token, long *exponentLength,
834 unsigned char *exponent, long *modulusLength, long *modulusFieldLength,
835 unsigned char *modulus)
836 {
837 unsigned long len;
838
839 if (*token++ != (char)0x1E) /* internal PKA token? */
840 return 0;
841
842 if (*token++) /* token version must be zero */
843 return 0;
844
845 len = *token++;
846 len = len << 8;
847 len |= (unsigned char)*token++;
848
849 token += 4; /* skip reserved bytes */
850
851 if (*token++ == (char)0x04)
852 {
853 if (*token++) /* token version must be zero */
854 return 0;
855
856 len = *token++;
857 len = len << 8;
858 len |= (unsigned char)*token++;
859
860 token+=2; /* skip reserved section */
861
862 len = *token++;
863 len = len << 8;
864 len |= (unsigned char)*token++;
865
866 *exponentLength = len;
867
868 len = *token++;
869 len = len << 8;
870 len |= (unsigned char)*token++;
871
872 *modulusLength = len;
873
874 len = *token++;
875 len = len << 8;
876 len |= (unsigned char)*token++;
877
878 *modulusFieldLength = len;
879
880 memcpy(exponent, token, *exponentLength);
881 token+= *exponentLength;
882
883 memcpy(modulus, token, *modulusFieldLength);
884 return 1;
885 }
886 return 0;
887 }
888
889#endif /* OPENSSL_NO_RSA */
890
891static int cca_random_status(void)
892 {
893 return 1;
894 }
895
896static int cca_get_random_bytes(unsigned char* buf, int num)
897 {
898 long ret_code;
899 long reason_code;
900 long exit_data_length;
901 unsigned char exit_data[4];
902 unsigned char form[] = "RANDOM ";
903 unsigned char rand_buf[8];
904
905 while(num >= sizeof(rand_buf))
906 {
907 randomNumberGenerate(&ret_code, &reason_code, &exit_data_length,
908 exit_data, form, rand_buf);
909 if (ret_code)
910 return 0;
911 num -= sizeof(rand_buf);
912 memcpy(buf, rand_buf, sizeof(rand_buf));
913 buf += sizeof(rand_buf);
914 }
915
916 if (num)
917 {
918 randomNumberGenerate(&ret_code, &reason_code, NULL, NULL,
919 form, rand_buf);
920 if (ret_code)
921 return 0;
922 memcpy(buf, rand_buf, num);
923 }
924
925 return 1;
926 }
927
928static void cca_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad, int idx,
929 long argl, void *argp)
930 {
931 if (item)
932 OPENSSL_free(item);
933 }
934
935/* Goo to handle building as a dynamic engine */
936#ifdef ENGINE_DYNAMIC_SUPPORT
937static int bind_fn(ENGINE *e, const char *id)
938 {
939 if(id && (strcmp(id, engine_cswift_id) != 0))
940 return 0;
941 if(!bind_helper(e))
942 return 0;
943 return 1;
944 }
945IMPLEMENT_DYNAMIC_CHECK_FN()
946IMPLEMENT_DYNAMIC_BIND_FN(bind_fn)
947#endif /* ENGINE_DYNAMIC_SUPPORT */
948
949#endif /* !OPENSSL_NO_HW_4758_CCA */
950#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..cf4507cff1
--- /dev/null
+++ b/src/lib/libcrypto/engine/hw_aep.c
@@ -0,0 +1,1101 @@
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#ifndef OPENSSL_SYS_MSDOS
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
75#ifndef OPENSSL_NO_HW
76#ifndef OPENSSL_NO_HW_AEP
77#ifdef FLAT_INC
78#include "aep.h"
79#else
80#include "vendor_defns/aep.h"
81#endif
82
83#define AEP_LIB_NAME "aep engine"
84#define FAIL_TO_SW 0x10101010
85
86#include "hw_aep_err.c"
87
88static int aep_init(ENGINE *e);
89static int aep_finish(ENGINE *e);
90static int aep_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)());
91static int aep_destroy(ENGINE *e);
92
93static AEP_RV aep_get_connection(AEP_CONNECTION_HNDL_PTR hConnection);
94static AEP_RV aep_return_connection(AEP_CONNECTION_HNDL hConnection);
95static AEP_RV aep_close_connection(AEP_CONNECTION_HNDL hConnection);
96static AEP_RV aep_close_all_connections(int use_engine_lock, int *in_use);
97
98/* BIGNUM stuff */
99static int aep_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
100 const BIGNUM *m, BN_CTX *ctx);
101
102static AEP_RV aep_mod_exp_crt(BIGNUM *r,const BIGNUM *a, const BIGNUM *p,
103 const BIGNUM *q, const BIGNUM *dmp1,const BIGNUM *dmq1,
104 const BIGNUM *iqmp, BN_CTX *ctx);
105
106/* RSA stuff */
107#ifndef OPENSSL_NO_RSA
108static int aep_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa);
109#endif
110
111/* This function is aliased to mod_exp (with the mont stuff dropped). */
112static int aep_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
113 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
114
115/* DSA stuff */
116#ifndef OPENSSL_NO_DSA
117static int aep_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,
118 BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
119 BN_CTX *ctx, BN_MONT_CTX *in_mont);
120
121static int aep_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a,
122 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
123 BN_MONT_CTX *m_ctx);
124#endif
125
126/* DH stuff */
127/* This function is aliased to mod_exp (with the DH and mont dropped). */
128#ifndef OPENSSL_NO_DH
129static int aep_mod_exp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a,
130 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
131#endif
132
133/* rand stuff */
134#ifdef AEPRAND
135static int aep_rand(unsigned char *buf, int num);
136static int aep_rand_status(void);
137#endif
138
139/* Bignum conversion stuff */
140static AEP_RV GetBigNumSize(AEP_VOID_PTR ArbBigNum, AEP_U32* BigNumSize);
141static AEP_RV MakeAEPBigNum(AEP_VOID_PTR ArbBigNum, AEP_U32 BigNumSize,
142 unsigned char* AEP_BigNum);
143static AEP_RV ConvertAEPBigNum(void* ArbBigNum, AEP_U32 BigNumSize,
144 unsigned char* AEP_BigNum);
145
146/* The definitions for control commands specific to this engine */
147#define AEP_CMD_SO_PATH ENGINE_CMD_BASE
148static const ENGINE_CMD_DEFN aep_cmd_defns[] =
149 {
150 { AEP_CMD_SO_PATH,
151 "SO_PATH",
152 "Specifies the path to the 'aep' shared library",
153 ENGINE_CMD_FLAG_STRING
154 },
155 {0, NULL, NULL, 0}
156 };
157
158#ifndef OPENSSL_NO_RSA
159/* Our internal RSA_METHOD that we provide pointers to */
160static RSA_METHOD aep_rsa =
161 {
162 "Aep RSA method",
163 NULL, /*rsa_pub_encrypt*/
164 NULL, /*rsa_pub_decrypt*/
165 NULL, /*rsa_priv_encrypt*/
166 NULL, /*rsa_priv_encrypt*/
167 aep_rsa_mod_exp, /*rsa_mod_exp*/
168 aep_mod_exp_mont, /*bn_mod_exp*/
169 NULL, /*init*/
170 NULL, /*finish*/
171 0, /*flags*/
172 NULL, /*app_data*/
173 NULL, /*rsa_sign*/
174 NULL /*rsa_verify*/
175 };
176#endif
177
178#ifndef OPENSSL_NO_DSA
179/* Our internal DSA_METHOD that we provide pointers to */
180static DSA_METHOD aep_dsa =
181 {
182 "Aep DSA method",
183 NULL, /* dsa_do_sign */
184 NULL, /* dsa_sign_setup */
185 NULL, /* dsa_do_verify */
186 aep_dsa_mod_exp, /* dsa_mod_exp */
187 aep_mod_exp_dsa, /* bn_mod_exp */
188 NULL, /* init */
189 NULL, /* finish */
190 0, /* flags */
191 NULL /* app_data */
192 };
193#endif
194
195#ifndef OPENSSL_NO_DH
196/* Our internal DH_METHOD that we provide pointers to */
197static DH_METHOD aep_dh =
198 {
199 "Aep DH method",
200 NULL,
201 NULL,
202 aep_mod_exp_dh,
203 NULL,
204 NULL,
205 0,
206 NULL
207 };
208#endif
209
210#ifdef AEPRAND
211/* our internal RAND_method that we provide pointers to */
212static RAND_METHOD aep_random =
213 {
214 /*"AEP RAND method", */
215 NULL,
216 aep_rand,
217 NULL,
218 NULL,
219 aep_rand,
220 aep_rand_status,
221 };
222#endif
223
224/*Define an array of structures to hold connections*/
225static AEP_CONNECTION_ENTRY aep_app_conn_table[MAX_PROCESS_CONNECTIONS];
226
227/*Used to determine if this is a new process*/
228static pid_t recorded_pid = 0;
229
230#ifdef AEPRAND
231static AEP_U8 rand_block[RAND_BLK_SIZE];
232static AEP_U32 rand_block_bytes = 0;
233#endif
234
235/* Constants used when creating the ENGINE */
236static const char *engine_aep_id = "aep";
237static const char *engine_aep_name = "Aep hardware engine support";
238
239static int max_key_len = 2176;
240
241
242/* This internal function is used by ENGINE_aep() and possibly by the
243 * "dynamic" ENGINE support too */
244static int bind_aep(ENGINE *e)
245 {
246#ifndef OPENSSL_NO_RSA
247 const RSA_METHOD *meth1;
248#endif
249#ifndef OPENSSL_NO_DSA
250 const DSA_METHOD *meth2;
251#endif
252#ifndef OPENSSL_NO_DH
253 const DH_METHOD *meth3;
254#endif
255
256 if(!ENGINE_set_id(e, engine_aep_id) ||
257 !ENGINE_set_name(e, engine_aep_name) ||
258#ifndef OPENSSL_NO_RSA
259 !ENGINE_set_RSA(e, &aep_rsa) ||
260#endif
261#ifndef OPENSSL_NO_DSA
262 !ENGINE_set_DSA(e, &aep_dsa) ||
263#endif
264#ifndef OPENSSL_NO_DH
265 !ENGINE_set_DH(e, &aep_dh) ||
266#endif
267#ifdef AEPRAND
268 !ENGINE_set_RAND(e, &aep_random) ||
269#endif
270 !ENGINE_set_init_function(e, aep_init) ||
271 !ENGINE_set_destroy_function(e, aep_destroy) ||
272 !ENGINE_set_finish_function(e, aep_finish) ||
273 !ENGINE_set_ctrl_function(e, aep_ctrl) ||
274 !ENGINE_set_cmd_defns(e, aep_cmd_defns))
275 return 0;
276
277#ifndef OPENSSL_NO_RSA
278 /* We know that the "PKCS1_SSLeay()" functions hook properly
279 * to the aep-specific mod_exp and mod_exp_crt so we use
280 * those functions. NB: We don't use ENGINE_openssl() or
281 * anything "more generic" because something like the RSAref
282 * code may not hook properly, and if you own one of these
283 * cards then you have the right to do RSA operations on it
284 * anyway! */
285 meth1 = RSA_PKCS1_SSLeay();
286 aep_rsa.rsa_pub_enc = meth1->rsa_pub_enc;
287 aep_rsa.rsa_pub_dec = meth1->rsa_pub_dec;
288 aep_rsa.rsa_priv_enc = meth1->rsa_priv_enc;
289 aep_rsa.rsa_priv_dec = meth1->rsa_priv_dec;
290#endif
291
292
293#ifndef OPENSSL_NO_DSA
294 /* Use the DSA_OpenSSL() method and just hook the mod_exp-ish
295 * bits. */
296 meth2 = DSA_OpenSSL();
297 aep_dsa.dsa_do_sign = meth2->dsa_do_sign;
298 aep_dsa.dsa_sign_setup = meth2->dsa_sign_setup;
299 aep_dsa.dsa_do_verify = meth2->dsa_do_verify;
300
301 aep_dsa = *DSA_get_default_method();
302 aep_dsa.dsa_mod_exp = aep_dsa_mod_exp;
303 aep_dsa.bn_mod_exp = aep_mod_exp_dsa;
304#endif
305
306#ifndef OPENSSL_NO_DH
307 /* Much the same for Diffie-Hellman */
308 meth3 = DH_OpenSSL();
309 aep_dh.generate_key = meth3->generate_key;
310 aep_dh.compute_key = meth3->compute_key;
311 aep_dh.bn_mod_exp = meth3->bn_mod_exp;
312#endif
313
314 /* Ensure the aep error handling is set up */
315 ERR_load_AEPHK_strings();
316
317 return 1;
318}
319
320#ifdef ENGINE_DYNAMIC_SUPPORT
321static int bind_helper(ENGINE *e, const char *id)
322 {
323 if(id && (strcmp(id, engine_aep_id) != 0))
324 return 0;
325 if(!bind_aep(e))
326 return 0;
327 return 1;
328 }
329IMPLEMENT_DYNAMIC_CHECK_FN()
330IMPLEMENT_DYNAMIC_BIND_FN(bind_helper)
331#else
332static ENGINE *engine_aep(void)
333 {
334 ENGINE *ret = ENGINE_new();
335 if(!ret)
336 return NULL;
337 if(!bind_aep(ret))
338 {
339 ENGINE_free(ret);
340 return NULL;
341 }
342 return ret;
343 }
344
345void ENGINE_load_aep(void)
346 {
347 /* Copied from eng_[openssl|dyn].c */
348 ENGINE *toadd = engine_aep();
349 if(!toadd) return;
350 ENGINE_add(toadd);
351 ENGINE_free(toadd);
352 ERR_clear_error();
353 }
354#endif
355
356/* This is a process-global DSO handle used for loading and unloading
357 * the Aep library. NB: This is only set (or unset) during an
358 * init() or finish() call (reference counts permitting) and they're
359 * operating with global locks, so this should be thread-safe
360 * implicitly. */
361static DSO *aep_dso = NULL;
362
363/* These are the static string constants for the DSO file name and the function
364 * symbol names to bind to.
365*/
366static const char *AEP_LIBNAME = "aep";
367
368static const char *AEP_F1 = "AEP_ModExp";
369static const char *AEP_F2 = "AEP_ModExpCrt";
370#ifdef AEPRAND
371static const char *AEP_F3 = "AEP_GenRandom";
372#endif
373static const char *AEP_F4 = "AEP_Finalize";
374static const char *AEP_F5 = "AEP_Initialize";
375static const char *AEP_F6 = "AEP_OpenConnection";
376static const char *AEP_F7 = "AEP_SetBNCallBacks";
377static const char *AEP_F8 = "AEP_CloseConnection";
378
379/* These are the function pointers that are (un)set when the library has
380 * successfully (un)loaded. */
381static t_AEP_OpenConnection *p_AEP_OpenConnection = NULL;
382static t_AEP_CloseConnection *p_AEP_CloseConnection = NULL;
383static t_AEP_ModExp *p_AEP_ModExp = NULL;
384static t_AEP_ModExpCrt *p_AEP_ModExpCrt = NULL;
385#ifdef AEPRAND
386static t_AEP_GenRandom *p_AEP_GenRandom = NULL;
387#endif
388static t_AEP_Initialize *p_AEP_Initialize = NULL;
389static t_AEP_Finalize *p_AEP_Finalize = NULL;
390static t_AEP_SetBNCallBacks *p_AEP_SetBNCallBacks = NULL;
391
392/* (de)initialisation functions. */
393static int aep_init(ENGINE *e)
394 {
395 t_AEP_ModExp *p1;
396 t_AEP_ModExpCrt *p2;
397#ifdef AEPRAND
398 t_AEP_GenRandom *p3;
399#endif
400 t_AEP_Finalize *p4;
401 t_AEP_Initialize *p5;
402 t_AEP_OpenConnection *p6;
403 t_AEP_SetBNCallBacks *p7;
404 t_AEP_CloseConnection *p8;
405
406 int to_return = 0;
407
408 if(aep_dso != NULL)
409 {
410 AEPHKerr(AEPHK_F_AEP_INIT,AEPHK_R_ALREADY_LOADED);
411 goto err;
412 }
413 /* Attempt to load libaep.so. */
414
415 aep_dso = DSO_load(NULL, AEP_LIBNAME, NULL, 0);
416
417 if(aep_dso == NULL)
418 {
419 AEPHKerr(AEPHK_F_AEP_INIT,AEPHK_R_NOT_LOADED);
420 goto err;
421 }
422
423 if( !(p1 = (t_AEP_ModExp *) DSO_bind_func( aep_dso,AEP_F1)) ||
424 !(p2 = (t_AEP_ModExpCrt*) DSO_bind_func( aep_dso,AEP_F2)) ||
425#ifdef AEPRAND
426 !(p3 = (t_AEP_GenRandom*) DSO_bind_func( aep_dso,AEP_F3)) ||
427#endif
428 !(p4 = (t_AEP_Finalize*) DSO_bind_func( aep_dso,AEP_F4)) ||
429 !(p5 = (t_AEP_Initialize*) DSO_bind_func( aep_dso,AEP_F5)) ||
430 !(p6 = (t_AEP_OpenConnection*) DSO_bind_func( aep_dso,AEP_F6)) ||
431 !(p7 = (t_AEP_SetBNCallBacks*) DSO_bind_func( aep_dso,AEP_F7)) ||
432 !(p8 = (t_AEP_CloseConnection*) DSO_bind_func( aep_dso,AEP_F8)))
433 {
434 AEPHKerr(AEPHK_F_AEP_INIT,AEPHK_R_NOT_LOADED);
435 goto err;
436 }
437
438 /* Copy the pointers */
439
440 p_AEP_ModExp = p1;
441 p_AEP_ModExpCrt = p2;
442#ifdef AEPRAND
443 p_AEP_GenRandom = p3;
444#endif
445 p_AEP_Finalize = p4;
446 p_AEP_Initialize = p5;
447 p_AEP_OpenConnection = p6;
448 p_AEP_SetBNCallBacks = p7;
449 p_AEP_CloseConnection = p8;
450
451 to_return = 1;
452
453 return to_return;
454
455 err:
456
457 if(aep_dso)
458 DSO_free(aep_dso);
459
460 p_AEP_OpenConnection = NULL;
461 p_AEP_ModExp = NULL;
462 p_AEP_ModExpCrt = NULL;
463#ifdef AEPRAND
464 p_AEP_GenRandom = NULL;
465#endif
466 p_AEP_Initialize = NULL;
467 p_AEP_Finalize = NULL;
468 p_AEP_SetBNCallBacks = NULL;
469 p_AEP_CloseConnection = NULL;
470
471 return to_return;
472 }
473
474/* Destructor (complements the "ENGINE_aep()" constructor) */
475static int aep_destroy(ENGINE *e)
476 {
477 ERR_unload_AEPHK_strings();
478 return 1;
479 }
480
481static int aep_finish(ENGINE *e)
482 {
483 int to_return = 0, in_use;
484 AEP_RV rv;
485
486 if(aep_dso == NULL)
487 {
488 AEPHKerr(AEPHK_F_AEP_FINISH,AEPHK_R_NOT_LOADED);
489 goto err;
490 }
491
492 rv = aep_close_all_connections(0, &in_use);
493 if (rv != AEP_R_OK)
494 {
495 AEPHKerr(AEPHK_F_AEP_FINISH,AEPHK_R_CLOSE_HANDLES_FAILED);
496 goto err;
497 }
498 if (in_use)
499 {
500 AEPHKerr(AEPHK_F_AEP_FINISH,AEPHK_R_CONNECTIONS_IN_USE);
501 goto err;
502 }
503
504 rv = p_AEP_Finalize();
505 if (rv != AEP_R_OK)
506 {
507 AEPHKerr(AEPHK_F_AEP_FINISH,AEPHK_R_FINALIZE_FAILED);
508 goto err;
509 }
510
511 if(!DSO_free(aep_dso))
512 {
513 AEPHKerr(AEPHK_F_AEP_FINISH,AEPHK_R_UNIT_FAILURE);
514 goto err;
515 }
516
517 aep_dso = NULL;
518 p_AEP_CloseConnection = NULL;
519 p_AEP_OpenConnection = NULL;
520 p_AEP_ModExp = NULL;
521 p_AEP_ModExpCrt = NULL;
522#ifdef AEPRAND
523 p_AEP_GenRandom = NULL;
524#endif
525 p_AEP_Initialize = NULL;
526 p_AEP_Finalize = NULL;
527 p_AEP_SetBNCallBacks = NULL;
528
529 to_return = 1;
530 err:
531 return to_return;
532 }
533
534static int aep_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
535 {
536 int initialised = ((aep_dso == NULL) ? 0 : 1);
537 switch(cmd)
538 {
539 case AEP_CMD_SO_PATH:
540 if(p == NULL)
541 {
542 AEPHKerr(AEPHK_F_AEP_CTRL,
543 ERR_R_PASSED_NULL_PARAMETER);
544 return 0;
545 }
546 if(initialised)
547 {
548 AEPHKerr(AEPHK_F_AEP_CTRL,
549 AEPHK_R_ALREADY_LOADED);
550 return 0;
551 }
552 AEP_LIBNAME = (const char *)p;
553 return 1;
554 default:
555 break;
556 }
557 AEPHKerr(AEPHK_F_AEP_CTRL,AEPHK_R_CTRL_COMMAND_NOT_IMPLEMENTED);
558 return 0;
559 }
560
561static int aep_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
562 const BIGNUM *m, BN_CTX *ctx)
563 {
564 int to_return = 0;
565 int r_len = 0;
566 AEP_CONNECTION_HNDL hConnection;
567 AEP_RV rv;
568
569 r_len = BN_num_bits(m);
570
571 /* Perform in software if modulus is too large for hardware. */
572
573 if (r_len > max_key_len){
574 AEPHKerr(AEPHK_F_AEP_MOD_EXP, AEPHK_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
575 return BN_mod_exp(r, a, p, m, ctx);
576 }
577
578 /*Grab a connection from the pool*/
579 rv = aep_get_connection(&hConnection);
580 if (rv != AEP_R_OK)
581 {
582 AEPHKerr(AEPHK_F_AEP_MOD_EXP,AEPHK_R_GET_HANDLE_FAILED);
583 return BN_mod_exp(r, a, p, m, ctx);
584 }
585
586 /*To the card with the mod exp*/
587 rv = p_AEP_ModExp(hConnection,(void*)a, (void*)p,(void*)m, (void*)r,NULL);
588
589 if (rv != AEP_R_OK)
590 {
591 AEPHKerr(AEPHK_F_AEP_MOD_EXP,AEPHK_R_MOD_EXP_FAILED);
592 rv = aep_close_connection(hConnection);
593 return BN_mod_exp(r, a, p, m, ctx);
594 }
595
596 /*Return the connection to the pool*/
597 rv = aep_return_connection(hConnection);
598 if (rv != AEP_R_OK)
599 {
600 AEPHKerr(AEPHK_F_AEP_RAND,AEPHK_R_RETURN_CONNECTION_FAILED);
601 goto err;
602 }
603
604 to_return = 1;
605 err:
606 return to_return;
607 }
608
609static AEP_RV aep_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
610 const BIGNUM *q, const BIGNUM *dmp1,
611 const BIGNUM *dmq1,const BIGNUM *iqmp, BN_CTX *ctx)
612 {
613 AEP_RV rv = AEP_R_OK;
614 AEP_CONNECTION_HNDL hConnection;
615
616 /*Grab a connection from the pool*/
617 rv = aep_get_connection(&hConnection);
618 if (rv != AEP_R_OK)
619 {
620 AEPHKerr(AEPHK_F_AEP_MOD_EXP_CRT,AEPHK_R_GET_HANDLE_FAILED);
621 return FAIL_TO_SW;
622 }
623
624 /*To the card with the mod exp*/
625 rv = p_AEP_ModExpCrt(hConnection,(void*)a, (void*)p, (void*)q, (void*)dmp1,(void*)dmq1,
626 (void*)iqmp,(void*)r,NULL);
627 if (rv != AEP_R_OK)
628 {
629 AEPHKerr(AEPHK_F_AEP_MOD_EXP_CRT,AEPHK_R_MOD_EXP_CRT_FAILED);
630 rv = aep_close_connection(hConnection);
631 return FAIL_TO_SW;
632 }
633
634 /*Return the connection to the pool*/
635 rv = aep_return_connection(hConnection);
636 if (rv != AEP_R_OK)
637 {
638 AEPHKerr(AEPHK_F_AEP_RAND,AEPHK_R_RETURN_CONNECTION_FAILED);
639 goto err;
640 }
641
642 err:
643 return rv;
644 }
645
646
647#ifdef AEPRAND
648static int aep_rand(unsigned char *buf,int len )
649 {
650 AEP_RV rv = AEP_R_OK;
651 AEP_CONNECTION_HNDL hConnection;
652
653 CRYPTO_w_lock(CRYPTO_LOCK_RAND);
654
655 /*Can the request be serviced with what's already in the buffer?*/
656 if (len <= rand_block_bytes)
657 {
658 memcpy(buf, &rand_block[RAND_BLK_SIZE - rand_block_bytes], len);
659 rand_block_bytes -= len;
660 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
661 }
662 else
663 /*If not the get another block of random bytes*/
664 {
665 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
666
667 rv = aep_get_connection(&hConnection);
668 if (rv != AEP_R_OK)
669 {
670 AEPHKerr(AEPHK_F_AEP_RAND,AEPHK_R_GET_HANDLE_FAILED);
671 goto err_nounlock;
672 }
673
674 if (len > RAND_BLK_SIZE)
675 {
676 rv = p_AEP_GenRandom(hConnection, len, 2, buf, NULL);
677 if (rv != AEP_R_OK)
678 {
679 AEPHKerr(AEPHK_F_AEP_RAND,AEPHK_R_GET_RANDOM_FAILED);
680 goto err_nounlock;
681 }
682 }
683 else
684 {
685 CRYPTO_w_lock(CRYPTO_LOCK_RAND);
686
687 rv = p_AEP_GenRandom(hConnection, RAND_BLK_SIZE, 2, &rand_block[0], NULL);
688 if (rv != AEP_R_OK)
689 {
690 AEPHKerr(AEPHK_F_AEP_RAND,AEPHK_R_GET_RANDOM_FAILED);
691
692 goto err;
693 }
694
695 rand_block_bytes = RAND_BLK_SIZE;
696
697 memcpy(buf, &rand_block[RAND_BLK_SIZE - rand_block_bytes], len);
698 rand_block_bytes -= len;
699
700 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
701 }
702
703 rv = aep_return_connection(hConnection);
704 if (rv != AEP_R_OK)
705 {
706 AEPHKerr(AEPHK_F_AEP_RAND,AEPHK_R_RETURN_CONNECTION_FAILED);
707
708 goto err_nounlock;
709 }
710 }
711
712 return 1;
713 err:
714 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
715 err_nounlock:
716 return 0;
717 }
718
719static int aep_rand_status(void)
720{
721 return 1;
722}
723#endif
724
725#ifndef OPENSSL_NO_RSA
726static int aep_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
727 {
728 BN_CTX *ctx = NULL;
729 int to_return = 0;
730 AEP_RV rv = AEP_R_OK;
731
732 if ((ctx = BN_CTX_new()) == NULL)
733 goto err;
734
735 if (!aep_dso)
736 {
737 AEPHKerr(AEPHK_F_AEP_RSA_MOD_EXP,AEPHK_R_NOT_LOADED);
738 goto err;
739 }
740
741 /*See if we have all the necessary bits for a crt*/
742 if (rsa->q && rsa->dmp1 && rsa->dmq1 && rsa->iqmp)
743 {
744 rv = aep_mod_exp_crt(r0,I,rsa->p,rsa->q, rsa->dmp1,rsa->dmq1,rsa->iqmp,ctx);
745
746 if (rv == FAIL_TO_SW){
747 const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
748 to_return = (*meth->rsa_mod_exp)(r0, I, rsa);
749 goto err;
750 }
751 else if (rv != AEP_R_OK)
752 goto err;
753 }
754 else
755 {
756 if (!rsa->d || !rsa->n)
757 {
758 AEPHKerr(AEPHK_F_AEP_RSA_MOD_EXP,AEPHK_R_MISSING_KEY_COMPONENTS);
759 goto err;
760 }
761
762 rv = aep_mod_exp(r0,I,rsa->d,rsa->n,ctx);
763 if (rv != AEP_R_OK)
764 goto err;
765
766 }
767
768 to_return = 1;
769
770 err:
771 if(ctx)
772 BN_CTX_free(ctx);
773 return to_return;
774}
775#endif
776
777#ifndef OPENSSL_NO_DSA
778static int aep_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,
779 BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
780 BN_CTX *ctx, BN_MONT_CTX *in_mont)
781 {
782 BIGNUM t;
783 int to_return = 0;
784 BN_init(&t);
785
786 /* let rr = a1 ^ p1 mod m */
787 if (!aep_mod_exp(rr,a1,p1,m,ctx)) goto end;
788 /* let t = a2 ^ p2 mod m */
789 if (!aep_mod_exp(&t,a2,p2,m,ctx)) goto end;
790 /* let rr = rr * t mod m */
791 if (!BN_mod_mul(rr,rr,&t,m,ctx)) goto end;
792 to_return = 1;
793 end:
794 BN_free(&t);
795 return to_return;
796 }
797
798static int aep_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a,
799 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
800 BN_MONT_CTX *m_ctx)
801 {
802 return aep_mod_exp(r, a, p, m, ctx);
803 }
804#endif
805
806/* This function is aliased to mod_exp (with the mont stuff dropped). */
807static int aep_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
808 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
809 {
810 return aep_mod_exp(r, a, p, m, ctx);
811 }
812
813#ifndef OPENSSL_NO_DH
814/* This function is aliased to mod_exp (with the dh and mont dropped). */
815static int aep_mod_exp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a,
816 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
817 BN_MONT_CTX *m_ctx)
818 {
819 return aep_mod_exp(r, a, p, m, ctx);
820 }
821#endif
822
823static AEP_RV aep_get_connection(AEP_CONNECTION_HNDL_PTR phConnection)
824 {
825 int count;
826 AEP_RV rv = AEP_R_OK;
827
828 /*Get the current process id*/
829 pid_t curr_pid;
830
831 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
832
833 curr_pid = getpid();
834
835 /*Check if this is the first time this is being called from the current
836 process*/
837 if (recorded_pid != curr_pid)
838 {
839 /*Remember our pid so we can check if we're in a new process*/
840 recorded_pid = curr_pid;
841
842 /*Call Finalize to make sure we have not inherited some data
843 from a parent process*/
844 p_AEP_Finalize();
845
846 /*Initialise the AEP API*/
847 rv = p_AEP_Initialize(NULL);
848
849 if (rv != AEP_R_OK)
850 {
851 AEPHKerr(AEPHK_F_AEP_GET_CONNECTION,AEPHK_R_INIT_FAILURE);
852 recorded_pid = 0;
853 goto end;
854 }
855
856 /*Set the AEP big num call back functions*/
857 rv = p_AEP_SetBNCallBacks(&GetBigNumSize, &MakeAEPBigNum,
858 &ConvertAEPBigNum);
859
860 if (rv != AEP_R_OK)
861 {
862 AEPHKerr(AEPHK_F_AEP_GET_CONNECTION,AEPHK_R_SETBNCALLBACK_FAILURE);
863 recorded_pid = 0;
864 goto end;
865 }
866
867#ifdef AEPRAND
868 /*Reset the rand byte count*/
869 rand_block_bytes = 0;
870#endif
871
872 /*Init the structures*/
873 for (count = 0;count < MAX_PROCESS_CONNECTIONS;count ++)
874 {
875 aep_app_conn_table[count].conn_state = NotConnected;
876 aep_app_conn_table[count].conn_hndl = 0;
877 }
878
879 /*Open a connection*/
880 rv = p_AEP_OpenConnection(phConnection);
881
882 if (rv != AEP_R_OK)
883 {
884 AEPHKerr(AEPHK_F_AEP_GET_CONNECTION,AEPHK_R_UNIT_FAILURE);
885 recorded_pid = 0;
886 goto end;
887 }
888
889 aep_app_conn_table[0].conn_state = InUse;
890 aep_app_conn_table[0].conn_hndl = *phConnection;
891 goto end;
892 }
893 /*Check the existing connections to see if we can find a free one*/
894 for (count = 0;count < MAX_PROCESS_CONNECTIONS;count ++)
895 {
896 if (aep_app_conn_table[count].conn_state == Connected)
897 {
898 aep_app_conn_table[count].conn_state = InUse;
899 *phConnection = aep_app_conn_table[count].conn_hndl;
900 goto end;
901 }
902 }
903 /*If no connections available, we're going to have to try
904 to open a new one*/
905 for (count = 0;count < MAX_PROCESS_CONNECTIONS;count ++)
906 {
907 if (aep_app_conn_table[count].conn_state == NotConnected)
908 {
909 /*Open a connection*/
910 rv = p_AEP_OpenConnection(phConnection);
911
912 if (rv != AEP_R_OK)
913 {
914 AEPHKerr(AEPHK_F_AEP_GET_CONNECTION,AEPHK_R_UNIT_FAILURE);
915 goto end;
916 }
917
918 aep_app_conn_table[count].conn_state = InUse;
919 aep_app_conn_table[count].conn_hndl = *phConnection;
920 goto end;
921 }
922 }
923 rv = AEP_R_GENERAL_ERROR;
924 end:
925 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
926 return rv;
927 }
928
929
930static AEP_RV aep_return_connection(AEP_CONNECTION_HNDL hConnection)
931 {
932 int count;
933
934 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
935
936 /*Find the connection item that matches this connection handle*/
937 for(count = 0;count < MAX_PROCESS_CONNECTIONS;count ++)
938 {
939 if (aep_app_conn_table[count].conn_hndl == hConnection)
940 {
941 aep_app_conn_table[count].conn_state = Connected;
942 break;
943 }
944 }
945
946 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
947
948 return AEP_R_OK;
949 }
950
951static AEP_RV aep_close_connection(AEP_CONNECTION_HNDL hConnection)
952 {
953 int count;
954 AEP_RV rv = AEP_R_OK;
955
956 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
957
958 /*Find the connection item that matches this connection handle*/
959 for(count = 0;count < MAX_PROCESS_CONNECTIONS;count ++)
960 {
961 if (aep_app_conn_table[count].conn_hndl == hConnection)
962 {
963 rv = p_AEP_CloseConnection(aep_app_conn_table[count].conn_hndl);
964 if (rv != AEP_R_OK)
965 goto end;
966 aep_app_conn_table[count].conn_state = NotConnected;
967 aep_app_conn_table[count].conn_hndl = 0;
968 break;
969 }
970 }
971
972 end:
973 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
974 return rv;
975 }
976
977static AEP_RV aep_close_all_connections(int use_engine_lock, int *in_use)
978 {
979 int count;
980 AEP_RV rv = AEP_R_OK;
981
982 *in_use = 0;
983 if (use_engine_lock) CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
984 for (count = 0;count < MAX_PROCESS_CONNECTIONS;count ++)
985 {
986 switch (aep_app_conn_table[count].conn_state)
987 {
988 case Connected:
989 rv = p_AEP_CloseConnection(aep_app_conn_table[count].conn_hndl);
990 if (rv != AEP_R_OK)
991 goto end;
992 aep_app_conn_table[count].conn_state = NotConnected;
993 aep_app_conn_table[count].conn_hndl = 0;
994 break;
995 case InUse:
996 (*in_use)++;
997 break;
998 case NotConnected:
999 break;
1000 }
1001 }
1002 end:
1003 if (use_engine_lock) CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
1004 return rv;
1005 }
1006
1007/*BigNum call back functions, used to convert OpenSSL bignums into AEP bignums.
1008 Note only 32bit Openssl build support*/
1009
1010static AEP_RV GetBigNumSize(AEP_VOID_PTR ArbBigNum, AEP_U32* BigNumSize)
1011 {
1012 BIGNUM* bn;
1013
1014 /*Cast the ArbBigNum pointer to our BIGNUM struct*/
1015 bn = (BIGNUM*) ArbBigNum;
1016
1017#ifdef SIXTY_FOUR_BIT_LONG
1018 *BigNumSize = bn->top << 3;
1019#else
1020 /*Size of the bignum in bytes is equal to the bn->top (no of 32 bit
1021 words) multiplies by 4*/
1022 *BigNumSize = bn->top << 2;
1023#endif
1024
1025 return AEP_R_OK;
1026 }
1027
1028static AEP_RV MakeAEPBigNum(AEP_VOID_PTR ArbBigNum, AEP_U32 BigNumSize,
1029 unsigned char* AEP_BigNum)
1030 {
1031 BIGNUM* bn;
1032
1033#ifndef SIXTY_FOUR_BIT_LONG
1034 unsigned char* buf;
1035 int i;
1036#endif
1037
1038 /*Cast the ArbBigNum pointer to our BIGNUM struct*/
1039 bn = (BIGNUM*) ArbBigNum;
1040
1041#ifdef SIXTY_FOUR_BIT_LONG
1042 memcpy(AEP_BigNum, bn->d, BigNumSize);
1043#else
1044 /*Must copy data into a (monotone) least significant byte first format
1045 performing endian conversion if necessary*/
1046 for(i=0;i<bn->top;i++)
1047 {
1048 buf = (unsigned char*)&bn->d[i];
1049
1050 *((AEP_U32*)AEP_BigNum) = (AEP_U32)
1051 ((unsigned) buf[1] << 8 | buf[0]) |
1052 ((unsigned) buf[3] << 8 | buf[2]) << 16;
1053
1054 AEP_BigNum += 4;
1055 }
1056#endif
1057
1058 return AEP_R_OK;
1059 }
1060
1061/*Turn an AEP Big Num back to a user big num*/
1062static AEP_RV ConvertAEPBigNum(void* ArbBigNum, AEP_U32 BigNumSize,
1063 unsigned char* AEP_BigNum)
1064 {
1065 BIGNUM* bn;
1066#ifndef SIXTY_FOUR_BIT_LONG
1067 int i;
1068#endif
1069
1070 bn = (BIGNUM*)ArbBigNum;
1071
1072 /*Expand the result bn so that it can hold our big num.
1073 Size is in bits*/
1074 bn_expand(bn, (int)(BigNumSize << 3));
1075
1076#ifdef SIXTY_FOUR_BIT_LONG
1077 bn->top = BigNumSize >> 3;
1078
1079 if((BigNumSize & 7) != 0)
1080 bn->top++;
1081
1082 memset(bn->d, 0, bn->top << 3);
1083
1084 memcpy(bn->d, AEP_BigNum, BigNumSize);
1085#else
1086 bn->top = BigNumSize >> 2;
1087
1088 for(i=0;i<bn->top;i++)
1089 {
1090 bn->d[i] = (AEP_U32)
1091 ((unsigned) AEP_BigNum[3] << 8 | AEP_BigNum[2]) << 16 |
1092 ((unsigned) AEP_BigNum[1] << 8 | AEP_BigNum[0]);
1093 AEP_BigNum += 4;
1094 }
1095#endif
1096
1097 return AEP_R_OK;
1098}
1099
1100#endif /* !OPENSSL_NO_HW_AEP */
1101#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
index 3bb992a193..696cfcf156 100644
--- a/src/lib/libcrypto/engine/hw_atalla.c
+++ b/src/lib/libcrypto/engine/hw_atalla.c
@@ -3,7 +3,7 @@
3 * project 2000. 3 * project 2000.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. 6 * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
@@ -60,11 +60,10 @@
60#include <openssl/crypto.h> 60#include <openssl/crypto.h>
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/dso.h> 62#include <openssl/dso.h>
63#include "engine_int.h"
64#include <openssl/engine.h> 63#include <openssl/engine.h>
65 64
66#ifndef NO_HW 65#ifndef OPENSSL_NO_HW
67#ifndef NO_HW_ATALLA 66#ifndef OPENSSL_NO_HW_ATALLA
68 67
69#ifdef FLAT_INC 68#ifdef FLAT_INC
70#include "atalla.h" 69#include "atalla.h"
@@ -72,19 +71,27 @@
72#include "vendor_defns/atalla.h" 71#include "vendor_defns/atalla.h"
73#endif 72#endif
74 73
75static int atalla_init(void); 74#define ATALLA_LIB_NAME "atalla engine"
76static int atalla_finish(void); 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)());
77 81
78/* BIGNUM stuff */ 82/* BIGNUM stuff */
79static int atalla_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p, 83static int atalla_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
80 const BIGNUM *m, BN_CTX *ctx); 84 const BIGNUM *m, BN_CTX *ctx);
81 85
86#ifndef OPENSSL_NO_RSA
82/* RSA stuff */ 87/* RSA stuff */
83static int atalla_rsa_mod_exp(BIGNUM *r0, BIGNUM *I, RSA *rsa); 88static int atalla_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa);
89#endif
84/* This function is aliased to mod_exp (with the mont stuff dropped). */ 90/* This function is aliased to mod_exp (with the mont stuff dropped). */
85static int atalla_mod_exp_mont(BIGNUM *r, BIGNUM *a, const BIGNUM *p, 91static int atalla_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
86 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); 92 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
87 93
94#ifndef OPENSSL_NO_DSA
88/* DSA stuff */ 95/* DSA stuff */
89static int atalla_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1, 96static int atalla_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,
90 BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m, 97 BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
@@ -92,13 +99,27 @@ static int atalla_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,
92static int atalla_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a, 99static int atalla_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a,
93 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, 100 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
94 BN_MONT_CTX *m_ctx); 101 BN_MONT_CTX *m_ctx);
102#endif
95 103
104#ifndef OPENSSL_NO_DH
96/* DH stuff */ 105/* DH stuff */
97/* This function is alised to mod_exp (with the DH and mont dropped). */ 106/* This function is alised to mod_exp (with the DH and mont dropped). */
98static int atalla_mod_exp_dh(DH *dh, BIGNUM *r, BIGNUM *a, const BIGNUM *p, 107static int atalla_mod_exp_dh(const DH *dh, BIGNUM *r,
108 const BIGNUM *a, const BIGNUM *p,
99 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); 109 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
110#endif
100 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 };
101 121
122#ifndef OPENSSL_NO_RSA
102/* Our internal RSA_METHOD that we provide pointers to */ 123/* Our internal RSA_METHOD that we provide pointers to */
103static RSA_METHOD atalla_rsa = 124static RSA_METHOD atalla_rsa =
104 { 125 {
@@ -116,7 +137,9 @@ static RSA_METHOD atalla_rsa =
116 NULL, 137 NULL,
117 NULL 138 NULL
118 }; 139 };
140#endif
119 141
142#ifndef OPENSSL_NO_DSA
120/* Our internal DSA_METHOD that we provide pointers to */ 143/* Our internal DSA_METHOD that we provide pointers to */
121static DSA_METHOD atalla_dsa = 144static DSA_METHOD atalla_dsa =
122 { 145 {
@@ -131,7 +154,9 @@ static DSA_METHOD atalla_dsa =
131 0, /* flags */ 154 0, /* flags */
132 NULL /* app_data */ 155 NULL /* app_data */
133 }; 156 };
157#endif
134 158
159#ifndef OPENSSL_NO_DH
135/* Our internal DH_METHOD that we provide pointers to */ 160/* Our internal DH_METHOD that we provide pointers to */
136static DH_METHOD atalla_dh = 161static DH_METHOD atalla_dh =
137 { 162 {
@@ -144,36 +169,44 @@ static DH_METHOD atalla_dh =
144 0, 169 0,
145 NULL 170 NULL
146 }; 171 };
172#endif
147 173
148/* Our ENGINE structure. */ 174/* Constants used when creating the ENGINE */
149static ENGINE engine_atalla = 175static const char *engine_atalla_id = "atalla";
150 { 176static const char *engine_atalla_name = "Atalla hardware engine support";
151 "atalla", 177
152 "Atalla hardware engine support", 178/* This internal function is used by ENGINE_atalla() and possibly by the
153 &atalla_rsa, 179 * "dynamic" ENGINE support too */
154 &atalla_dsa, 180static int bind_helper(ENGINE *e)
155 &atalla_dh,
156 NULL,
157 atalla_mod_exp,
158 NULL,
159 atalla_init,
160 atalla_finish,
161 NULL, /* no ctrl() */
162 NULL, /* no load_privkey() */
163 NULL, /* no load_pubkey() */
164 0, /* no flags */
165 0, 0, /* no references */
166 NULL, NULL /* unlinked */
167 };
168
169/* As this is only ever called once, there's no need for locking
170 * (indeed - the lock will already be held by our caller!!!) */
171ENGINE *ENGINE_atalla()
172 { 181 {
173 RSA_METHOD *meth1; 182#ifndef OPENSSL_NO_RSA
174 DSA_METHOD *meth2; 183 const RSA_METHOD *meth1;
175 DH_METHOD *meth3; 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;
176 208
209#ifndef OPENSSL_NO_RSA
177 /* We know that the "PKCS1_SSLeay()" functions hook properly 210 /* We know that the "PKCS1_SSLeay()" functions hook properly
178 * to the atalla-specific mod_exp and mod_exp_crt so we use 211 * to the atalla-specific mod_exp and mod_exp_crt so we use
179 * those functions. NB: We don't use ENGINE_openssl() or 212 * those functions. NB: We don't use ENGINE_openssl() or
@@ -186,19 +219,50 @@ ENGINE *ENGINE_atalla()
186 atalla_rsa.rsa_pub_dec = meth1->rsa_pub_dec; 219 atalla_rsa.rsa_pub_dec = meth1->rsa_pub_dec;
187 atalla_rsa.rsa_priv_enc = meth1->rsa_priv_enc; 220 atalla_rsa.rsa_priv_enc = meth1->rsa_priv_enc;
188 atalla_rsa.rsa_priv_dec = meth1->rsa_priv_dec; 221 atalla_rsa.rsa_priv_dec = meth1->rsa_priv_dec;
222#endif
189 223
224#ifndef OPENSSL_NO_DSA
190 /* Use the DSA_OpenSSL() method and just hook the mod_exp-ish 225 /* Use the DSA_OpenSSL() method and just hook the mod_exp-ish
191 * bits. */ 226 * bits. */
192 meth2 = DSA_OpenSSL(); 227 meth2 = DSA_OpenSSL();
193 atalla_dsa.dsa_do_sign = meth2->dsa_do_sign; 228 atalla_dsa.dsa_do_sign = meth2->dsa_do_sign;
194 atalla_dsa.dsa_sign_setup = meth2->dsa_sign_setup; 229 atalla_dsa.dsa_sign_setup = meth2->dsa_sign_setup;
195 atalla_dsa.dsa_do_verify = meth2->dsa_do_verify; 230 atalla_dsa.dsa_do_verify = meth2->dsa_do_verify;
231#endif
196 232
233#ifndef OPENSSL_NO_DH
197 /* Much the same for Diffie-Hellman */ 234 /* Much the same for Diffie-Hellman */
198 meth3 = DH_OpenSSL(); 235 meth3 = DH_OpenSSL();
199 atalla_dh.generate_key = meth3->generate_key; 236 atalla_dh.generate_key = meth3->generate_key;
200 atalla_dh.compute_key = meth3->compute_key; 237 atalla_dh.compute_key = meth3->compute_key;
201 return &engine_atalla; 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();
202 } 266 }
203 267
204/* This is a process-global DSO handle used for loading and unloading 268/* This is a process-global DSO handle used for loading and unloading
@@ -214,8 +278,32 @@ static tfnASI_GetHardwareConfig *p_Atalla_GetHardwareConfig = NULL;
214static tfnASI_RSAPrivateKeyOpFn *p_Atalla_RSAPrivateKeyOpFn = NULL; 278static tfnASI_RSAPrivateKeyOpFn *p_Atalla_RSAPrivateKeyOpFn = NULL;
215static tfnASI_GetPerformanceStatistics *p_Atalla_GetPerformanceStatistics = NULL; 279static tfnASI_GetPerformanceStatistics *p_Atalla_GetPerformanceStatistics = NULL;
216 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 def_ATALLA_LIBNAME[] = "atasi";
290static const char *ATALLA_LIBNAME = def_ATALLA_LIBNAME;
291static const char *ATALLA_F1 = "ASI_GetHardwareConfig";
292static const char *ATALLA_F2 = "ASI_RSAPrivateKeyOpFn";
293static const char *ATALLA_F3 = "ASI_GetPerformanceStatistics";
294
295/* Destructor (complements the "ENGINE_atalla()" constructor) */
296static int atalla_destroy(ENGINE *e)
297 {
298 /* Unload the atalla error strings so any error state including our
299 * functs or reasons won't lead to a segfault (they simply get displayed
300 * without corresponding string data because none will be found). */
301 ERR_unload_ATALLA_strings();
302 return 1;
303 }
304
217/* (de)initialisation functions. */ 305/* (de)initialisation functions. */
218static int atalla_init() 306static int atalla_init(ENGINE *e)
219 { 307 {
220 tfnASI_GetHardwareConfig *p1; 308 tfnASI_GetHardwareConfig *p1;
221 tfnASI_RSAPrivateKeyOpFn *p2; 309 tfnASI_RSAPrivateKeyOpFn *p2;
@@ -226,7 +314,7 @@ static int atalla_init()
226 314
227 if(atalla_dso != NULL) 315 if(atalla_dso != NULL)
228 { 316 {
229 ENGINEerr(ENGINE_F_ATALLA_INIT,ENGINE_R_ALREADY_LOADED); 317 ATALLAerr(ATALLA_F_ATALLA_INIT,ATALLA_R_ALREADY_LOADED);
230 goto err; 318 goto err;
231 } 319 }
232 /* Attempt to load libatasi.so/atasi.dll/whatever. Needs to be 320 /* Attempt to load libatasi.so/atasi.dll/whatever. Needs to be
@@ -236,11 +324,10 @@ static int atalla_init()
236 * drivers really use - for now a symbollic link needs to be 324 * drivers really use - for now a symbollic link needs to be
237 * created on the host system from libatasi.so to atasi.so on 325 * created on the host system from libatasi.so to atasi.so on
238 * unix variants. */ 326 * unix variants. */
239 atalla_dso = DSO_load(NULL, ATALLA_LIBNAME, NULL, 327 atalla_dso = DSO_load(NULL, ATALLA_LIBNAME, NULL, 0);
240 DSO_FLAG_NAME_TRANSLATION);
241 if(atalla_dso == NULL) 328 if(atalla_dso == NULL)
242 { 329 {
243 ENGINEerr(ENGINE_F_ATALLA_INIT,ENGINE_R_DSO_FAILURE); 330 ATALLAerr(ATALLA_F_ATALLA_INIT,ATALLA_R_NOT_LOADED);
244 goto err; 331 goto err;
245 } 332 }
246 if(!(p1 = (tfnASI_GetHardwareConfig *)DSO_bind_func( 333 if(!(p1 = (tfnASI_GetHardwareConfig *)DSO_bind_func(
@@ -250,7 +337,7 @@ static int atalla_init()
250 !(p3 = (tfnASI_GetPerformanceStatistics *)DSO_bind_func( 337 !(p3 = (tfnASI_GetPerformanceStatistics *)DSO_bind_func(
251 atalla_dso, ATALLA_F3))) 338 atalla_dso, ATALLA_F3)))
252 { 339 {
253 ENGINEerr(ENGINE_F_ATALLA_INIT,ENGINE_R_DSO_FAILURE); 340 ATALLAerr(ATALLA_F_ATALLA_INIT,ATALLA_R_NOT_LOADED);
254 goto err; 341 goto err;
255 } 342 }
256 /* Copy the pointers */ 343 /* Copy the pointers */
@@ -261,7 +348,7 @@ static int atalla_init()
261 * running. */ 348 * running. */
262 if(p1(0L, config_buf) != 0) 349 if(p1(0L, config_buf) != 0)
263 { 350 {
264 ENGINEerr(ENGINE_F_ATALLA_INIT,ENGINE_R_UNIT_FAILURE); 351 ATALLAerr(ATALLA_F_ATALLA_INIT,ATALLA_R_UNIT_FAILURE);
265 goto err; 352 goto err;
266 } 353 }
267 /* Everything's fine. */ 354 /* Everything's fine. */
@@ -275,16 +362,16 @@ err:
275 return 0; 362 return 0;
276 } 363 }
277 364
278static int atalla_finish() 365static int atalla_finish(ENGINE *e)
279 { 366 {
280 if(atalla_dso == NULL) 367 if(atalla_dso == NULL)
281 { 368 {
282 ENGINEerr(ENGINE_F_ATALLA_FINISH,ENGINE_R_NOT_LOADED); 369 ATALLAerr(ATALLA_F_ATALLA_FINISH,ATALLA_R_NOT_LOADED);
283 return 0; 370 return 0;
284 } 371 }
285 if(!DSO_free(atalla_dso)) 372 if(!DSO_free(atalla_dso))
286 { 373 {
287 ENGINEerr(ENGINE_F_ATALLA_FINISH,ENGINE_R_DSO_FAILURE); 374 ATALLAerr(ATALLA_F_ATALLA_FINISH,ATALLA_R_UNIT_FAILURE);
288 return 0; 375 return 0;
289 } 376 }
290 atalla_dso = NULL; 377 atalla_dso = NULL;
@@ -294,7 +381,32 @@ static int atalla_finish()
294 return 1; 381 return 1;
295 } 382 }
296 383
297static int atalla_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p, 384static int atalla_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
385 {
386 int initialised = ((atalla_dso == NULL) ? 0 : 1);
387 switch(cmd)
388 {
389 case ATALLA_CMD_SO_PATH:
390 if(p == NULL)
391 {
392 ATALLAerr(ATALLA_F_ATALLA_CTRL,ERR_R_PASSED_NULL_PARAMETER);
393 return 0;
394 }
395 if(initialised)
396 {
397 ATALLAerr(ATALLA_F_ATALLA_CTRL,ATALLA_R_ALREADY_LOADED);
398 return 0;
399 }
400 ATALLA_LIBNAME = (const char *)p;
401 return 1;
402 default:
403 break;
404 }
405 ATALLAerr(ATALLA_F_ATALLA_CTRL,ATALLA_R_CTRL_COMMAND_NOT_IMPLEMENTED);
406 return 0;
407 }
408
409static int atalla_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
298 const BIGNUM *m, BN_CTX *ctx) 410 const BIGNUM *m, BN_CTX *ctx)
299 { 411 {
300 /* I need somewhere to store temporary serialised values for 412 /* I need somewhere to store temporary serialised values for
@@ -313,26 +425,27 @@ static int atalla_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
313 to_return = 0; /* expect failure */ 425 to_return = 0; /* expect failure */
314 426
315 if(!atalla_dso) 427 if(!atalla_dso)
316 { 428 {
317 ENGINEerr(ENGINE_F_ATALLA_MOD_EXP,ENGINE_R_NOT_LOADED); 429 ATALLAerr(ATALLA_F_ATALLA_MOD_EXP,ATALLA_R_NOT_LOADED);
318 goto err; 430 goto err;
319 } 431 }
320 /* Prepare the params */ 432 /* Prepare the params */
433 BN_CTX_start(ctx);
321 modulus = BN_CTX_get(ctx); 434 modulus = BN_CTX_get(ctx);
322 exponent = BN_CTX_get(ctx); 435 exponent = BN_CTX_get(ctx);
323 argument = BN_CTX_get(ctx); 436 argument = BN_CTX_get(ctx);
324 result = BN_CTX_get(ctx); 437 result = BN_CTX_get(ctx);
325 if(!modulus || !exponent || !argument || !result) 438 if (!result)
326 { 439 {
327 ENGINEerr(ENGINE_F_ATALLA_MOD_EXP,ENGINE_R_BN_CTX_FULL); 440 ATALLAerr(ATALLA_F_ATALLA_MOD_EXP,ATALLA_R_BN_CTX_FULL);
328 goto err; 441 goto err;
329 } 442 }
330 if(!bn_wexpand(modulus, m->top) || !bn_wexpand(exponent, m->top) || 443 if(!bn_wexpand(modulus, m->top) || !bn_wexpand(exponent, m->top) ||
331 !bn_wexpand(argument, m->top) || !bn_wexpand(result, m->top)) 444 !bn_wexpand(argument, m->top) || !bn_wexpand(result, m->top))
332 { 445 {
333 ENGINEerr(ENGINE_F_ATALLA_MOD_EXP,ENGINE_R_BN_EXPAND_FAIL); 446 ATALLAerr(ATALLA_F_ATALLA_MOD_EXP,ATALLA_R_BN_EXPAND_FAIL);
334 goto err; 447 goto err;
335 } 448 }
336 /* Prepare the key-data */ 449 /* Prepare the key-data */
337 memset(&keydata, 0,sizeof keydata); 450 memset(&keydata, 0,sizeof keydata);
338 numbytes = BN_num_bytes(m); 451 numbytes = BN_num_bytes(m);
@@ -352,36 +465,34 @@ static int atalla_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
352 if(p_Atalla_RSAPrivateKeyOpFn(&keydata, (unsigned char *)result->d, 465 if(p_Atalla_RSAPrivateKeyOpFn(&keydata, (unsigned char *)result->d,
353 (unsigned char *)argument->d, 466 (unsigned char *)argument->d,
354 keydata.modulus.len) != 0) 467 keydata.modulus.len) != 0)
355 { 468 {
356 ENGINEerr(ENGINE_F_ATALLA_MOD_EXP,ENGINE_R_REQUEST_FAILED); 469 ATALLAerr(ATALLA_F_ATALLA_MOD_EXP,ATALLA_R_REQUEST_FAILED);
357 goto err; 470 goto err;
358 } 471 }
359 /* Convert the response */ 472 /* Convert the response */
360 BN_bin2bn((unsigned char *)result->d, numbytes, r); 473 BN_bin2bn((unsigned char *)result->d, numbytes, r);
361 to_return = 1; 474 to_return = 1;
362err: 475err:
363 if(modulus) ctx->tos--; 476 BN_CTX_end(ctx);
364 if(exponent) ctx->tos--;
365 if(argument) ctx->tos--;
366 if(result) ctx->tos--;
367 return to_return; 477 return to_return;
368 } 478 }
369 479
370static int atalla_rsa_mod_exp(BIGNUM *r0, BIGNUM *I, RSA *rsa) 480#ifndef OPENSSL_NO_RSA
481static int atalla_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
371 { 482 {
372 BN_CTX *ctx = NULL; 483 BN_CTX *ctx = NULL;
373 int to_return = 0; 484 int to_return = 0;
374 485
375 if(!atalla_dso) 486 if(!atalla_dso)
376 { 487 {
377 ENGINEerr(ENGINE_F_ATALLA_RSA_MOD_EXP,ENGINE_R_NOT_LOADED); 488 ATALLAerr(ATALLA_F_ATALLA_RSA_MOD_EXP,ATALLA_R_NOT_LOADED);
378 goto err; 489 goto err;
379 } 490 }
380 if((ctx = BN_CTX_new()) == NULL) 491 if((ctx = BN_CTX_new()) == NULL)
381 goto err; 492 goto err;
382 if(!rsa->d || !rsa->n) 493 if(!rsa->d || !rsa->n)
383 { 494 {
384 ENGINEerr(ENGINE_F_ATALLA_RSA_MOD_EXP,ENGINE_R_MISSING_KEY_COMPONENTS); 495 ATALLAerr(ATALLA_F_ATALLA_RSA_MOD_EXP,ATALLA_R_MISSING_KEY_COMPONENTS);
385 goto err; 496 goto err;
386 } 497 }
387 to_return = atalla_mod_exp(r0, I, rsa->d, rsa->n, ctx); 498 to_return = atalla_mod_exp(r0, I, rsa->d, rsa->n, ctx);
@@ -390,7 +501,9 @@ err:
390 BN_CTX_free(ctx); 501 BN_CTX_free(ctx);
391 return to_return; 502 return to_return;
392 } 503 }
504#endif
393 505
506#ifndef OPENSSL_NO_DSA
394/* This code was liberated and adapted from the commented-out code in 507/* This code was liberated and adapted from the commented-out code in
395 * dsa_ossl.c. Because of the unoptimised form of the Atalla acceleration 508 * dsa_ossl.c. Because of the unoptimised form of the Atalla acceleration
396 * (it doesn't have a CRT form for RSA), this function means that an 509 * (it doesn't have a CRT form for RSA), this function means that an
@@ -418,27 +531,45 @@ end:
418 return to_return; 531 return to_return;
419 } 532 }
420 533
421
422static int atalla_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a, 534static int atalla_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a,
423 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, 535 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
424 BN_MONT_CTX *m_ctx) 536 BN_MONT_CTX *m_ctx)
425 { 537 {
426 return atalla_mod_exp(r, a, p, m, ctx); 538 return atalla_mod_exp(r, a, p, m, ctx);
427 } 539 }
540#endif
428 541
429/* This function is aliased to mod_exp (with the mont stuff dropped). */ 542/* This function is aliased to mod_exp (with the mont stuff dropped). */
430static int atalla_mod_exp_mont(BIGNUM *r, BIGNUM *a, const BIGNUM *p, 543static int atalla_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
431 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx) 544 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
432 { 545 {
433 return atalla_mod_exp(r, a, p, m, ctx); 546 return atalla_mod_exp(r, a, p, m, ctx);
434 } 547 }
435 548
549#ifndef OPENSSL_NO_DH
436/* This function is aliased to mod_exp (with the dh and mont dropped). */ 550/* This function is aliased to mod_exp (with the dh and mont dropped). */
437static int atalla_mod_exp_dh(DH *dh, BIGNUM *r, BIGNUM *a, const BIGNUM *p, 551static int atalla_mod_exp_dh(const DH *dh, BIGNUM *r,
552 const BIGNUM *a, const BIGNUM *p,
438 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx) 553 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
439 { 554 {
440 return atalla_mod_exp(r, a, p, m, ctx); 555 return atalla_mod_exp(r, a, p, m, ctx);
441 } 556 }
557#endif
558
559/* This stuff is needed if this ENGINE is being compiled into a self-contained
560 * shared-library. */
561#ifdef ENGINE_DYNAMIC_SUPPORT
562static int bind_fn(ENGINE *e, const char *id)
563 {
564 if(id && (strcmp(id, engine_atalla_id) != 0))
565 return 0;
566 if(!bind_helper(e))
567 return 0;
568 return 1;
569 }
570IMPLEMENT_DYNAMIC_CHECK_FN()
571IMPLEMENT_DYNAMIC_BIND_FN(bind_fn)
572#endif /* ENGINE_DYNAMIC_SUPPORT */
442 573
443#endif /* !NO_HW_ATALLA */ 574#endif /* !OPENSSL_NO_HW_ATALLA */
444#endif /* !NO_HW */ 575#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..7c3728f395
--- /dev/null
+++ b/src/lib/libcrypto/engine/hw_cryptodev.c
@@ -0,0 +1,926 @@
1/*
2 * Copyright (c) 2002 Bob Beck <beck@openbsd.org>
3 * Copyright (c) 2002 Theo de Raadt
4 * 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 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of the author nor the names of contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 */
30
31#include <sys/types.h>
32#include <sys/param.h>
33#include <crypto/cryptodev.h>
34#include <sys/ioctl.h>
35#include <errno.h>
36#include <stdio.h>
37#include <unistd.h>
38#include <fcntl.h>
39#include <syslog.h>
40#include <stdarg.h>
41#include <ssl/objects.h>
42#include <ssl/engine.h>
43#include <ssl/evp.h>
44
45static int cryptodev_fd = -1;
46static int cryptodev_sessions = 0;
47static u_int32_t cryptodev_symfeat = 0;
48
49static int bn2crparam(const BIGNUM *a, struct crparam *crp);
50static int crparam2bn(struct crparam *crp, BIGNUM *a);
51static void zapparams(struct crypt_kop *kop);
52
53static int cryptodev_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa);
54static int cryptodev_bn_mod_exp(BIGNUM *r, const BIGNUM *a,
55 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
56static int cryptodev_dsa_bn_mod_exp(DSA *dsa, BIGNUM *r, BIGNUM *a,
57 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
58static DSA_SIG *cryptodev_dsa_do_sign(const unsigned char *dgst,
59 int dlen, DSA *dsa);
60static int cryptodev_dsa_verify(const unsigned char *dgst, int dgst_len,
61 DSA_SIG *sig, DSA *dsa);
62static int cryptodev_mod_exp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a,
63 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
64 BN_MONT_CTX *m_ctx);
65static int cryptodev_dh_compute_key(unsigned char *key,
66 const BIGNUM *pub_key, DH *dh);
67
68static const ENGINE_CMD_DEFN cryptodev_defns[] = {
69 { 0, NULL, NULL, 0 }
70};
71
72static struct {
73 int id;
74 int nid;
75 int ivmax;
76 int keylen;
77} ciphers[] = {
78 { CRYPTO_DES_CBC, NID_des_cbc, 8, 8, },
79 { CRYPTO_3DES_CBC, NID_des_ede3_cbc, 8, 24, },
80 { CRYPTO_AES_CBC, NID_undef, 8, 24, },
81 { CRYPTO_BLF_CBC, NID_bf_cbc, 8, 16, },
82 { CRYPTO_CAST_CBC, NID_cast5_cbc, 8, 8, },
83 { CRYPTO_SKIPJACK_CBC, NID_undef, 0, 0, },
84 { CRYPTO_ARC4, NID_rc4, 8, 16, },
85 { 0, NID_undef, 0, 0, },
86};
87
88static struct {
89 int id;
90 int nid;
91} digests[] = {
92 { CRYPTO_SHA1_HMAC, NID_hmacWithSHA1, },
93 { CRYPTO_RIPEMD160_HMAC, NID_ripemd160, },
94 { CRYPTO_MD5_KPDK, NID_undef, },
95 { CRYPTO_SHA1_KPDK, NID_undef, },
96 { CRYPTO_MD5, NID_md5, },
97 { CRYPTO_SHA1, NID_undef, },
98 { 0, NID_undef, },
99};
100
101/*
102 * Return 1 if /dev/crypto seems usable, 0 otherwise , also
103 * does most of the work of initting the device, if not already
104 * done.. This should leave is with global fd initialized with CRIOGET.
105 */
106static int
107check_dev_crypto()
108{
109 int fd;
110
111 if (cryptodev_fd == -1) {
112 if ((fd = open("/dev/crypto", O_RDWR, 0)) == -1)
113 return (0);
114 if (ioctl(fd, CRIOGET, &cryptodev_fd) == -1) {
115 close(fd);
116 return (0);
117 }
118 close(fd);
119 /* close on exec */
120 if (fcntl(cryptodev_fd, F_SETFD, 1) == -1) {
121 close(cryptodev_fd);
122 cryptodev_fd = -1;
123 return (0);
124 }
125 }
126 ioctl(cryptodev_fd, CIOCSYMFEAT, &cryptodev_symfeat);
127
128 return (1);
129}
130
131/*
132 * XXXX this needs to be set for each alg - and determined from
133 * a running card.
134 */
135static int
136cryptodev_max_iv(int cipher)
137{
138 int i;
139
140 for (i = 0; ciphers[i].id; i++)
141 if (ciphers[i].id == cipher)
142 return (ciphers[i].ivmax);
143 return (0);
144}
145
146/*
147 * XXXX this needs to be set for each alg - and determined from
148 * a running card. For now, fake it out - but most of these
149 * for real devices should return 1 for the supported key
150 * sizes the device can handle.
151 */
152static int
153cryptodev_key_length_valid(int cipher, int len)
154{
155 int i;
156
157 for (i = 0; ciphers[i].id; i++)
158 if (ciphers[i].id == cipher)
159 return (ciphers[i].keylen == len);
160 return (0);
161}
162
163/* convert libcrypto nids to cryptodev */
164static int
165cipher_nid_to_cryptodev(int nid)
166{
167 int i;
168
169 for (i = 0; ciphers[i].id; i++)
170 if (ciphers[i].nid == nid)
171 return (ciphers[i].id);
172 return (0);
173}
174
175/*
176 * Find out what ciphers /dev/crypto will let us have a session for.
177 * XXX note, that some of these openssl doesn't deal with yet!
178 * returning them here is harmless, as long as we return NULL
179 * when asked for a handler in the cryptodev_engine_ciphers routine
180 */
181static int
182get_cryptodev_ciphers(const int **cnids)
183{
184 static int nids[CRYPTO_ALGORITHM_MAX];
185 struct session_op sess;
186 int i, count = 0;
187
188 memset(&sess, 0, sizeof(sess));
189 sess.key = (caddr_t)"123456781234567812345678";
190
191 for (i = 0; ciphers[i].id && count < CRYPTO_ALGORITHM_MAX; i++) {
192 if (ciphers[i].nid == NID_undef)
193 continue;
194 sess.cipher = ciphers[i].id;
195 sess.keylen = ciphers[i].keylen;
196 sess.mac = 0;
197 if (ioctl(cryptodev_fd, CIOCGSESSION, &sess) != -1 &&
198 ioctl(cryptodev_fd, CIOCFSESSION, &sess.ses) != -1)
199 nids[count++] = ciphers[i].nid;
200 }
201 if (count > 0)
202 *cnids = nids;
203 else
204 *cnids = NULL;
205 return (count);
206}
207
208/*
209 * Find out what digests /dev/crypto will let us have a session for.
210 * XXX note, that some of these openssl doesn't deal with yet!
211 * returning them here is harmless, as long as we return NULL
212 * when asked for a handler in the cryptodev_engine_digests routine
213 */
214static int
215get_cryptodev_digests(const int **cnids)
216{
217 static int nids[CRYPTO_ALGORITHM_MAX];
218 struct session_op sess;
219 int i, count = 0;
220
221 memset(&sess, 0, sizeof(sess));
222 for (i = 0; digests[i].id && count < CRYPTO_ALGORITHM_MAX; i++) {
223 if (digests[i].nid == NID_undef)
224 continue;
225 sess.mac = digests[i].id;
226 sess.cipher = 0;
227 if (ioctl(cryptodev_fd, CIOCGSESSION, &sess) != -1 &&
228 ioctl(cryptodev_fd, CIOCFSESSION, &sess.ses) != -1)
229 nids[count++] = digests[i].nid;
230 }
231 if (count > 0)
232 *cnids = nids;
233 else
234 *cnids = NULL;
235 return (count);
236}
237
238/*
239 * Find the useable ciphers|digests from dev/crypto - this is the first
240 * thing called by the engine init crud which determines what it
241 * can use for ciphers from this engine. We want to return
242 * only what we can do, anythine else is handled by software.
243 *
244 * If we can't initialize the device to do anything useful for
245 * any reason, we want to return a NULL array, and 0 length,
246 * which forces everything to be done is software. By putting
247 * the initalization of the device in here, we ensure we can
248 * use this engine as the default, and if for whatever reason
249 * /dev/crypto won't do what we want it will just be done in
250 * software
251 *
252 * This can (should) be greatly expanded to perhaps take into
253 * account speed of the device, and what we want to do.
254 * (although the disabling of particular alg's could be controlled
255 * by the device driver with sysctl's.) - this is where we
256 * want most of the decisions made about what we actually want
257 * to use from /dev/crypto.
258 */
259int
260cryptodev_usable_ciphers(const int **nids)
261{
262 if (!check_dev_crypto()) {
263 *nids = NULL;
264 return (0);
265 }
266
267 /* find what the device can do. Unfortunately, we don't
268 * necessarily want all of these yet, because we aren't
269 * yet set up to do them
270 */
271 return (get_cryptodev_ciphers(nids));
272}
273
274int
275cryptodev_usable_digests(const int **nids)
276{
277#if 1
278 /*
279 * XXXX just disable all digests for now, because it sucks.
280 * we need a better way to decide this - i.e. I may not
281 * want digests on slow cards like hifn on fast machines,
282 * but might want them on slow or loaded machines, etc.
283 * will also want them when using crypto cards that don't
284 * suck moose gonads - would be nice to be able to decide something
285 * as reasonable default without having hackery that's card dependent.
286 * of course, the default should probably be just do everything,
287 * with perhaps a sysctl to turn algoritms off (or have them off
288 * by default) on cards that generally suck like the hifn.
289 */
290 *nids = NULL;
291 return (0);
292#endif
293
294 if (!check_dev_crypto()) {
295 *nids = NULL;
296 return (0);
297 }
298 return (get_cryptodev_digests(nids));
299}
300
301
302int
303cryptodev_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
304 const unsigned char *in, unsigned int inl)
305{
306 struct crypt_op cryp;
307 struct session_op *sess = ctx->cipher_data;
308 void *iiv;
309 unsigned char save_iv[EVP_MAX_IV_LENGTH];
310 struct syslog_data sd = SYSLOG_DATA_INIT;
311
312 if (cryptodev_fd == -1)
313 return (0);
314 if (sess == NULL)
315 return (0);
316 if (!inl)
317 return (1);
318 if ((inl % ctx->cipher->block_size) != 0)
319 return (0);
320
321 memset(&cryp, 0, sizeof(cryp));
322
323 cryp.ses = sess->ses;
324 cryp.flags = 0;
325 cryp.len = inl;
326 cryp.src = (caddr_t) in;
327 cryp.dst = (caddr_t) out;
328 cryp.mac = 0;
329
330 cryp.op = ctx->encrypt ? COP_ENCRYPT : COP_DECRYPT;
331
332 if (ctx->cipher->iv_len) {
333 cryp.iv = (caddr_t) ctx->iv;
334 if (!ctx->encrypt) {
335 iiv = (void *) in + inl - ctx->cipher->iv_len;
336 memcpy(save_iv, iiv, ctx->cipher->iv_len);
337 }
338 } else
339 cryp.iv = NULL;
340
341 if (ioctl(cryptodev_fd, CIOCCRYPT, &cryp) == -1) {
342 /* XXX need better errror handling
343 * this can fail for a number of different reasons.
344 */
345 syslog_r(LOG_ERR, &sd, "CIOCCRYPT failed (%m)");
346 return (0);
347 }
348
349 if (ctx->cipher->iv_len) {
350 if (ctx->encrypt)
351 iiv = (void *) out + inl - ctx->cipher->iv_len;
352 else
353 iiv = save_iv;
354 memcpy(ctx->iv, iiv, ctx->cipher->iv_len);
355 }
356 return (1);
357}
358
359int
360cryptodev_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
361 const unsigned char *iv, int enc)
362{
363 struct session_op *sess = ctx->cipher_data;
364 struct syslog_data sd = SYSLOG_DATA_INIT;
365 int cipher;
366
367 if ((cipher = cipher_nid_to_cryptodev(ctx->cipher->nid)) == NID_undef)
368 return (0);
369
370 if (!check_dev_crypto())
371 return (0);
372
373 if (ctx->cipher->iv_len > cryptodev_max_iv(cipher))
374 return (0);
375
376 if (!cryptodev_key_length_valid(cipher, ctx->key_len))
377 return (0);
378
379 memset(sess, 0, sizeof(struct session_op));
380
381 sess->key = (unsigned char *)key;
382 sess->keylen = ctx->key_len;
383 sess->cipher = cipher;
384
385 if (ioctl(cryptodev_fd, CIOCGSESSION, sess) == -1) {
386 syslog_r(LOG_ERR, &sd, "CIOCGSESSION failed (%m)");
387 return (0);
388 }
389 cryptodev_sessions++;
390 return (1);
391}
392
393/*
394 * free anything we allocated earlier when initting a
395 * session, and close the session.
396 */
397int
398cryptodev_cleanup(EVP_CIPHER_CTX *ctx)
399{
400 int ret = 0;
401 struct session_op *sess = ctx->cipher_data;
402 struct syslog_data sd = SYSLOG_DATA_INIT;
403
404 if (sess == NULL)
405 return (0);
406
407 /* XXX if this ioctl fails, someting's wrong. the invoker
408 * may have called us with a bogus ctx, or we could
409 * have a device that for whatever reason just doesn't
410 * want to play ball - it's not clear what's right
411 * here - should this be an error? should it just
412 * increase a counter, hmm. For right now, we return
413 * 0 - I don't believe that to be "right". we could
414 * call the gorpy openssl lib error handlers that
415 * print messages to users of the library. hmm..
416 */
417
418 if (ioctl(cryptodev_fd, CIOCFSESSION, &sess->ses) == -1) {
419 syslog_r(LOG_ERR, &sd, "CIOCFSESSION failed (%m)");
420 ret = 0;
421 } else {
422 cryptodev_sessions--;
423 ret = 1;
424 }
425 if (cryptodev_sessions == 0 && cryptodev_fd != -1 ) {
426 close(cryptodev_fd); /* XXX should this be closed? */
427 cryptodev_fd = -1;
428 }
429 return (ret);
430}
431
432/*
433 * libcrypto EVP stuff - this is how we get wired to EVP so the engine
434 * gets called when libcrypto requests a cipher NID.
435 */
436
437/* ARC4 (16 byte key) */
438const EVP_CIPHER cryptodev_arc4_cipher = {
439 NID_rc4,
440 1, 16, 0,
441 EVP_CIPH_VARIABLE_LENGTH,
442 cryptodev_init_key,
443 cryptodev_cipher,
444 cryptodev_cleanup,
445 sizeof(struct session_op),
446 NULL,
447 NULL,
448 NULL
449};
450
451/* DES CBC EVP */
452const EVP_CIPHER cryptodev_des_cbc = {
453 NID_des_cbc,
454 8, 8, 8,
455 EVP_CIPH_CBC_MODE,
456 cryptodev_init_key,
457 cryptodev_cipher,
458 cryptodev_cleanup,
459 sizeof(struct session_op),
460 EVP_CIPHER_set_asn1_iv,
461 EVP_CIPHER_get_asn1_iv,
462 NULL
463};
464
465/* 3DES CBC EVP */
466const EVP_CIPHER cryptodev_3des_cbc = {
467 NID_des_ede3_cbc,
468 8, 24, 8,
469 EVP_CIPH_CBC_MODE,
470 cryptodev_init_key,
471 cryptodev_cipher,
472 cryptodev_cleanup,
473 sizeof(struct session_op),
474 EVP_CIPHER_set_asn1_iv,
475 EVP_CIPHER_get_asn1_iv,
476 NULL
477};
478
479
480/*
481 * Registered by the ENGINE when used to find out how to deal with
482 * a particular NID in the ENGINE. this says what we'll do at the
483 * top level - note, that list is restricted by what we answer with
484 */
485int
486cryptodev_engine_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
487 const int **nids, int nid)
488{
489 if (!cipher)
490 return (cryptodev_usable_ciphers(nids));
491
492 switch (nid) {
493 case NID_rc4:
494 *cipher = &cryptodev_arc4_cipher;
495 break;
496 case NID_des_ede3_cbc:
497 *cipher = &cryptodev_3des_cbc;
498 break;
499 case NID_des_cbc:
500 *cipher = &cryptodev_des_cbc;
501 break;
502 default:
503 *cipher = NULL;
504 break;
505 }
506 return (*cipher != NULL);
507}
508
509int
510cryptodev_engine_digests(ENGINE *e, const EVP_MD **digest,
511 const int **nids, int nid)
512{
513 if (!digest)
514 return (cryptodev_usable_digests(nids));
515
516 switch (nid) {
517 case NID_md5:
518 *digest = NULL; /* need to make a clean md5 critter */
519 break;
520 default:
521 *digest = NULL;
522 break;
523 }
524 return (*digest != NULL);
525}
526
527
528/*
529 * Convert a BIGNUM to the representation that /dev/crypto needs.
530 * Upon completion of use, the caller is responsible for freeing
531 * crp->crp_p.
532 */
533static int
534bn2crparam(const BIGNUM *a, struct crparam *crp)
535{
536 int i, j, n;
537 ssize_t words, bytes, bits;
538 u_char *b;
539
540 crp->crp_p = NULL;
541 crp->crp_nbits = 0;
542
543 bits = BN_num_bits(a);
544 bytes = (bits + 7) / 8;
545
546 b = malloc(bytes);
547 if (b == NULL)
548 return (1);
549
550 crp->crp_p = b;
551 crp->crp_nbits = bits;
552
553 words = (bits + BN_BITS2 - 1) / BN_BITS2;
554
555 n = 0;
556 for (i = 0; i < words && n < bytes; i++) {
557 BN_ULONG word;
558
559 word = a->d[i];
560 for (j = 0 ; j < BN_BYTES && n < bytes; j++, n++) {
561 *b++ = (word & 0xff);
562 word >>= 8;
563 }
564 }
565 return (0);
566}
567
568/* Convert a /dev/crypto parameter to a BIGNUM */
569static int
570crparam2bn(struct crparam *crp, BIGNUM *a)
571{
572 int i, bytes;
573
574 bytes = (crp->crp_nbits + 7)/8;
575
576 BN_zero(a);
577 for (i = bytes - 1; i >= 0; i--) {
578 BN_lshift(a, a, 8);
579 BN_add_word(a, (u_char)crp->crp_p[i]);
580 }
581
582 return (0);
583}
584
585static void
586zapparams(struct crypt_kop *kop)
587{
588 int i;
589
590 for (i = 0; i <= kop->crk_iparams + kop->crk_oparams; i++) {
591 if (kop->crk_param[i].crp_p)
592 free(kop->crk_param[i].crp_p);
593 kop->crk_param[i].crp_p = NULL;
594 kop->crk_param[i].crp_nbits = 0;
595 }
596}
597
598static int
599cryptodev_sym(struct crypt_kop *kop, BIGNUM *r, BIGNUM *s)
600{
601 int ret = -1;
602
603 if (r) {
604 kop->crk_param[kop->crk_iparams].crp_p = malloc(256);
605 kop->crk_param[kop->crk_iparams].crp_nbits = 256 * 8;
606 kop->crk_oparams++;
607 }
608 if (s) {
609 kop->crk_param[kop->crk_iparams+1].crp_p = malloc(256);
610 kop->crk_param[kop->crk_iparams+1].crp_nbits = 256 * 8;
611 kop->crk_oparams++;
612 }
613
614 if (ioctl(cryptodev_fd, CIOCKEY, &kop) == 0) {
615 crparam2bn(&kop->crk_param[3], r);
616 ret = 0;
617 }
618 return (ret);
619}
620
621static int
622cryptodev_bn_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
623 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont)
624{
625 struct crypt_kop kop;
626 int ret = 0;
627
628 memset(&kop, 0, sizeof kop);
629 kop.crk_op = CRK_MOD_EXP;
630
631 /* inputs: a m p */
632 if (bn2crparam(a, &kop.crk_param[0]))
633 goto err;
634 if (bn2crparam(m, &kop.crk_param[1]))
635 goto err;
636 if (bn2crparam(p, &kop.crk_param[2]))
637 goto err;
638 kop.crk_iparams = 3;
639
640 if (cryptodev_sym(&kop, r, NULL) == -1) {
641 ret = BN_mod_exp(r, a, p, m, ctx);
642 }
643err:
644 zapparams(&kop);
645 return (ret);
646}
647
648
649static int
650cryptodev_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
651{
652 struct crypt_kop kop;
653 int ret = 0;
654
655 if (!rsa->p || !rsa->q || !rsa->dmp1 || !rsa->dmq1 || !rsa->iqmp) {
656 /* XXX 0 means failure?? */
657 goto err;
658 }
659
660 memset(&kop, 0, sizeof kop);
661 kop.crk_op = CRK_MOD_EXP_CRT;
662 /* inputs: rsa->p rsa->q I rsa->dmp1 rsa->dmq1 rsa->iqmp */
663 if (bn2crparam(rsa->p, &kop.crk_param[0]))
664 goto err;
665 if (bn2crparam(rsa->q, &kop.crk_param[1]))
666 goto err;
667 if (bn2crparam(I, &kop.crk_param[2]))
668 goto err;
669 if (bn2crparam(rsa->dmp1, &kop.crk_param[3]))
670 goto err;
671 if (bn2crparam(rsa->dmq1, &kop.crk_param[4]))
672 goto err;
673 if (bn2crparam(rsa->iqmp, &kop.crk_param[5]))
674 goto err;
675 kop.crk_iparams = 6;
676
677 if (cryptodev_sym(&kop, r0, NULL) == -1) {
678 const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
679
680 ret = (*meth->rsa_mod_exp)(r0, I, rsa);
681 }
682err:
683 zapparams(&kop);
684 return (ret);
685}
686
687static RSA_METHOD cryptodev_rsa = {
688 "cryptodev RSA method",
689 NULL, /* rsa_pub_enc */
690 NULL, /* rsa_pub_dec */
691 NULL, /* rsa_priv_enc */
692 NULL, /* rsa_priv_dec */
693 cryptodev_rsa_mod_exp, /* rsa_mod_exp */
694 cryptodev_bn_mod_exp, /* bn_mod_exp */
695 NULL, /* init */
696 NULL, /* finish */
697 0, /* flags */
698 NULL, /* app_data */
699 NULL, /* rsa_sign */
700 NULL /* rsa_verify */
701};
702
703static int
704cryptodev_dsa_bn_mod_exp(DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
705 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
706{
707 return (cryptodev_bn_mod_exp(r, a, p, m, ctx, m_ctx));
708}
709
710static DSA_SIG *
711cryptodev_dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
712{
713 struct crypt_kop kop;
714 BIGNUM *r = NULL, *s = NULL;
715 DSA_SIG *dsaret = NULL;
716
717 if ((r = BN_new()) == NULL)
718 goto err;
719 if ((s = BN_new()) == NULL) {
720 BN_free(r);
721 goto err;
722 }
723
724 memset(&kop, 0, sizeof kop);
725 kop.crk_op = CRK_DSA_SIGN;
726
727 /* inputs: dgst dsa->p dsa->q dsa->g dsa->priv_key */
728 kop.crk_param[0].crp_p = (caddr_t)dgst;
729 kop.crk_param[0].crp_nbits = dlen * 8;
730 if (bn2crparam(dsa->p, &kop.crk_param[1]))
731 goto err;
732 if (bn2crparam(dsa->q, &kop.crk_param[2]))
733 goto err;
734 if (bn2crparam(dsa->g, &kop.crk_param[3]))
735 goto err;
736 if (bn2crparam(dsa->priv_key, &kop.crk_param[4]))
737 goto err;
738 kop.crk_iparams = 5;
739
740 if (cryptodev_sym(&kop, r, s) == 0) {
741 dsaret = DSA_SIG_new();
742 dsaret->r = r;
743 dsaret->s = s;
744 } else {
745 const DSA_METHOD *meth = DSA_OpenSSL();
746
747 BN_free(r);
748 BN_free(s);
749 dsaret = (meth->dsa_do_sign)(dgst, dlen, dsa);
750 }
751err:
752 kop.crk_param[0].crp_p = NULL;
753 zapparams(&kop);
754 return (dsaret);
755}
756
757static int
758cryptodev_dsa_verify(const unsigned char *dgst, int dlen,
759 DSA_SIG *sig, DSA *dsa)
760{
761 struct crypt_kop kop;
762 int dsaret = 0;
763
764 memset(&kop, 0, sizeof kop);
765 kop.crk_op = CRK_DSA_VERIFY;
766
767 /* inputs: dgst dsa->p dsa->q dsa->g dsa->pub_key sig->r sig->s */
768 kop.crk_param[0].crp_p = (caddr_t)dgst;
769 kop.crk_param[0].crp_nbits = dlen * 8;
770 if (bn2crparam(dsa->p, &kop.crk_param[1]))
771 goto err;
772 if (bn2crparam(dsa->q, &kop.crk_param[2]))
773 goto err;
774 if (bn2crparam(dsa->g, &kop.crk_param[3]))
775 goto err;
776 if (bn2crparam(dsa->pub_key, &kop.crk_param[4]))
777 goto err;
778 if (bn2crparam(sig->r, &kop.crk_param[5]))
779 goto err;
780 if (bn2crparam(sig->s, &kop.crk_param[6]))
781 goto err;
782 kop.crk_iparams = 7;
783
784 if (cryptodev_sym(&kop, NULL, NULL) == 0) {
785 dsaret = kop.crk_status;
786 } else {
787 const DSA_METHOD *meth = DSA_OpenSSL();
788
789 dsaret = (meth->dsa_do_verify)(dgst, dlen, sig, dsa);
790 }
791err:
792 kop.crk_param[0].crp_p = NULL;
793 zapparams(&kop);
794 return (dsaret);
795}
796
797static DSA_METHOD cryptodev_dsa = {
798 "cryptodev DSA method",
799 cryptodev_dsa_do_sign,
800 NULL, /* dsa_sign_setup */
801 cryptodev_dsa_verify,
802 NULL, /* dsa_mod_exp */
803 cryptodev_dsa_bn_mod_exp, /* bn_mod_exp */
804 NULL, /* init */
805 NULL, /* finish */
806 0, /* flags */
807 NULL /* app_data */
808};
809
810static int
811cryptodev_mod_exp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a,
812 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
813 BN_MONT_CTX *m_ctx)
814{
815 return (cryptodev_bn_mod_exp(r, a, p, m, ctx, m_ctx));
816}
817
818static int
819cryptodev_dh_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh)
820{
821 struct crypt_kop kop;
822 int dhret = 0;
823 int keylen;
824
825 keylen = BN_num_bits(dh->p);
826
827 memset(&kop, 0, sizeof kop);
828 kop.crk_op = CRK_DH_COMPUTE_KEY;
829
830 /* inputs: dh->priv_key pub_key dh->p key */
831 if (bn2crparam(dh->priv_key, &kop.crk_param[0]))
832 goto err;
833 if (bn2crparam(pub_key, &kop.crk_param[1]))
834 goto err;
835 if (bn2crparam(dh->p, &kop.crk_param[2]))
836 goto err;
837 kop.crk_iparams = 3;
838
839 kop.crk_param[3].crp_p = key;
840 kop.crk_param[3].crp_nbits = keylen * 8;
841 kop.crk_oparams = 1;
842
843 if (ioctl(cryptodev_fd, CIOCKEY, &kop) == -1) {
844 const DH_METHOD *meth = DH_OpenSSL();
845
846 dhret = (meth->compute_key)(key, pub_key, dh);
847 }
848err:
849 kop.crk_param[3].crp_p = NULL;
850 zapparams(&kop);
851 return (dhret);
852}
853
854static DH_METHOD cryptodev_dh = {
855 "cryptodev DH method",
856 NULL, /* cryptodev_dh_generate_key */
857 cryptodev_dh_compute_key,
858 cryptodev_mod_exp_dh,
859 NULL,
860 NULL,
861 0, /* flags */
862 NULL /* app_data */
863};
864
865/*
866 * ctrl right now is just a wrapper that doesn't do much
867 * but I expect we'll want some options soon.
868 */
869static int
870cryptodev_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
871{
872 struct syslog_data sd = SYSLOG_DATA_INIT;
873
874 switch (cmd) {
875 default:
876 syslog_r(LOG_ERR, &sd,
877 "cryptodev_ctrl: unknown command %d", cmd);
878 break;
879 }
880 return (1);
881}
882
883void
884ENGINE_load_cryptodev(void)
885{
886 ENGINE *engine = ENGINE_new();
887 const RSA_METHOD *rsa_meth;
888 const DH_METHOD *dh_meth;
889
890 if (engine == NULL)
891 return;
892
893 if (!ENGINE_set_id(engine, "cryptodev") ||
894 !ENGINE_set_name(engine, "OpenBSD cryptodev engine") ||
895 !ENGINE_set_ciphers(engine, cryptodev_engine_ciphers) ||
896 !ENGINE_set_digests(engine, cryptodev_engine_digests) ||
897 !ENGINE_set_ctrl_function(engine, cryptodev_ctrl) ||
898 !ENGINE_set_cmd_defns(engine, cryptodev_defns)) {
899 ENGINE_free(engine);
900 return;
901 }
902
903 if ((cryptodev_symfeat & CRSFEAT_RSA) &&
904 ENGINE_set_RSA(engine, &cryptodev_rsa)) {
905 rsa_meth = RSA_PKCS1_SSLeay();
906 cryptodev_rsa.rsa_pub_enc = rsa_meth->rsa_pub_enc;
907 cryptodev_rsa.rsa_pub_dec = rsa_meth->rsa_pub_dec;
908 cryptodev_rsa.rsa_priv_enc = rsa_meth->rsa_priv_dec;
909 cryptodev_rsa.rsa_priv_dec = rsa_meth->rsa_priv_dec;
910 }
911
912 if ((cryptodev_symfeat & CRSFEAT_DSA) &&
913 ENGINE_set_DSA(engine, &cryptodev_dsa)) {
914 }
915
916 if ((cryptodev_symfeat & CRSFEAT_DH) &&
917 ENGINE_set_DH(engine, &cryptodev_dh)) {
918 dh_meth = DH_OpenSSL();
919 cryptodev_dh.generate_key = dh_meth->generate_key;
920 cryptodev_dh.compute_key = dh_meth->compute_key;
921 }
922
923 ENGINE_add(engine);
924 ENGINE_free(engine);
925 ERR_clear_error();
926}
diff --git a/src/lib/libcrypto/engine/hw_cswift.c b/src/lib/libcrypto/engine/hw_cswift.c
index 77608b8983..d8b380550f 100644
--- a/src/lib/libcrypto/engine/hw_cswift.c
+++ b/src/lib/libcrypto/engine/hw_cswift.c
@@ -3,7 +3,7 @@
3 * project 2000. 3 * project 2000.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. 6 * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
@@ -60,11 +60,10 @@
60#include <openssl/crypto.h> 60#include <openssl/crypto.h>
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/dso.h> 62#include <openssl/dso.h>
63#include "engine_int.h"
64#include <openssl/engine.h> 63#include <openssl/engine.h>
65 64
66#ifndef NO_HW 65#ifndef OPENSSL_NO_HW
67#ifndef NO_HW_CSWIFT 66#ifndef OPENSSL_NO_HW_CSWIFT
68 67
69/* Attribution notice: Rainbow have generously allowed me to reproduce 68/* Attribution notice: Rainbow have generously allowed me to reproduce
70 * the necessary definitions here from their API. This means the support 69 * the necessary definitions here from their API. This means the support
@@ -84,33 +83,55 @@
84#include "vendor_defns/cswift.h" 83#include "vendor_defns/cswift.h"
85#endif 84#endif
86 85
87static int cswift_init(void); 86#define CSWIFT_LIB_NAME "cswift engine"
88static int cswift_finish(void); 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)());
89 93
90/* BIGNUM stuff */ 94/* BIGNUM stuff */
91static int cswift_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p, 95static int cswift_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
92 const BIGNUM *m, BN_CTX *ctx); 96 const BIGNUM *m, BN_CTX *ctx);
93static int cswift_mod_exp_crt(BIGNUM *r, BIGNUM *a, const BIGNUM *p, 97static int cswift_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
94 const BIGNUM *q, const BIGNUM *dmp1, const BIGNUM *dmq1, 98 const BIGNUM *q, const BIGNUM *dmp1, const BIGNUM *dmq1,
95 const BIGNUM *iqmp, BN_CTX *ctx); 99 const BIGNUM *iqmp, BN_CTX *ctx);
96 100
101#ifndef OPENSSL_NO_RSA
97/* RSA stuff */ 102/* RSA stuff */
98static int cswift_rsa_mod_exp(BIGNUM *r0, BIGNUM *I, RSA *rsa); 103static int cswift_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa);
104#endif
99/* This function is aliased to mod_exp (with the mont stuff dropped). */ 105/* This function is aliased to mod_exp (with the mont stuff dropped). */
100static int cswift_mod_exp_mont(BIGNUM *r, BIGNUM *a, const BIGNUM *p, 106static int cswift_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
101 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); 107 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
102 108
109#ifndef OPENSSL_NO_DSA
103/* DSA stuff */ 110/* DSA stuff */
104static DSA_SIG *cswift_dsa_sign(const unsigned char *dgst, int dlen, DSA *dsa); 111static DSA_SIG *cswift_dsa_sign(const unsigned char *dgst, int dlen, DSA *dsa);
105static int cswift_dsa_verify(const unsigned char *dgst, int dgst_len, 112static int cswift_dsa_verify(const unsigned char *dgst, int dgst_len,
106 DSA_SIG *sig, DSA *dsa); 113 DSA_SIG *sig, DSA *dsa);
114#endif
107 115
116#ifndef OPENSSL_NO_DH
108/* DH stuff */ 117/* DH stuff */
109/* This function is alised to mod_exp (with the DH and mont dropped). */ 118/* This function is alised to mod_exp (with the DH and mont dropped). */
110static int cswift_mod_exp_dh(DH *dh, BIGNUM *r, BIGNUM *a, const BIGNUM *p, 119static int cswift_mod_exp_dh(const DH *dh, BIGNUM *r,
120 const BIGNUM *a, const BIGNUM *p,
111 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); 121 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
122#endif
112 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 };
113 133
134#ifndef OPENSSL_NO_RSA
114/* Our internal RSA_METHOD that we provide pointers to */ 135/* Our internal RSA_METHOD that we provide pointers to */
115static RSA_METHOD cswift_rsa = 136static RSA_METHOD cswift_rsa =
116 { 137 {
@@ -128,7 +149,9 @@ static RSA_METHOD cswift_rsa =
128 NULL, 149 NULL,
129 NULL 150 NULL
130 }; 151 };
152#endif
131 153
154#ifndef OPENSSL_NO_DSA
132/* Our internal DSA_METHOD that we provide pointers to */ 155/* Our internal DSA_METHOD that we provide pointers to */
133static DSA_METHOD cswift_dsa = 156static DSA_METHOD cswift_dsa =
134 { 157 {
@@ -143,7 +166,9 @@ static DSA_METHOD cswift_dsa =
143 0, /* flags */ 166 0, /* flags */
144 NULL /* app_data */ 167 NULL /* app_data */
145 }; 168 };
169#endif
146 170
171#ifndef OPENSSL_NO_DH
147/* Our internal DH_METHOD that we provide pointers to */ 172/* Our internal DH_METHOD that we provide pointers to */
148static DH_METHOD cswift_dh = 173static DH_METHOD cswift_dh =
149 { 174 {
@@ -156,35 +181,41 @@ static DH_METHOD cswift_dh =
156 0, 181 0,
157 NULL 182 NULL
158 }; 183 };
184#endif
159 185
160/* Our ENGINE structure. */ 186/* Constants used when creating the ENGINE */
161static ENGINE engine_cswift = 187static const char *engine_cswift_id = "cswift";
162 { 188static const char *engine_cswift_name = "CryptoSwift hardware engine support";
163 "cswift", 189
164 "CryptoSwift hardware engine support", 190/* This internal function is used by ENGINE_cswift() and possibly by the
165 &cswift_rsa, 191 * "dynamic" ENGINE support too */
166 &cswift_dsa, 192static int bind_helper(ENGINE *e)
167 &cswift_dh,
168 NULL,
169 cswift_mod_exp,
170 cswift_mod_exp_crt,
171 cswift_init,
172 cswift_finish,
173 NULL, /* no ctrl() */
174 NULL, /* no load_privkey() */
175 NULL, /* no load_pubkey() */
176 0, /* no flags */
177 0, 0, /* no references */
178 NULL, NULL /* unlinked */
179 };
180
181/* As this is only ever called once, there's no need for locking
182 * (indeed - the lock will already be held by our caller!!!) */
183ENGINE *ENGINE_cswift()
184 { 193 {
185 RSA_METHOD *meth1; 194#ifndef OPENSSL_NO_RSA
186 DH_METHOD *meth2; 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;
187 217
218#ifndef OPENSSL_NO_RSA
188 /* We know that the "PKCS1_SSLeay()" functions hook properly 219 /* We know that the "PKCS1_SSLeay()" functions hook properly
189 * to the cswift-specific mod_exp and mod_exp_crt so we use 220 * to the cswift-specific mod_exp and mod_exp_crt so we use
190 * those functions. NB: We don't use ENGINE_openssl() or 221 * those functions. NB: We don't use ENGINE_openssl() or
@@ -197,12 +228,41 @@ ENGINE *ENGINE_cswift()
197 cswift_rsa.rsa_pub_dec = meth1->rsa_pub_dec; 228 cswift_rsa.rsa_pub_dec = meth1->rsa_pub_dec;
198 cswift_rsa.rsa_priv_enc = meth1->rsa_priv_enc; 229 cswift_rsa.rsa_priv_enc = meth1->rsa_priv_enc;
199 cswift_rsa.rsa_priv_dec = meth1->rsa_priv_dec; 230 cswift_rsa.rsa_priv_dec = meth1->rsa_priv_dec;
231#endif
200 232
233#ifndef OPENSSL_NO_DH
201 /* Much the same for Diffie-Hellman */ 234 /* Much the same for Diffie-Hellman */
202 meth2 = DH_OpenSSL(); 235 meth2 = DH_OpenSSL();
203 cswift_dh.generate_key = meth2->generate_key; 236 cswift_dh.generate_key = meth2->generate_key;
204 cswift_dh.compute_key = meth2->compute_key; 237 cswift_dh.compute_key = meth2->compute_key;
205 return &engine_cswift; 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();
206 } 266 }
207 267
208/* This is a process-global DSO handle used for loading and unloading 268/* This is a process-global DSO handle used for loading and unloading
@@ -220,7 +280,8 @@ t_swSimpleRequest *p_CSwift_SimpleRequest = NULL;
220t_swReleaseAccContext *p_CSwift_ReleaseAccContext = NULL; 280t_swReleaseAccContext *p_CSwift_ReleaseAccContext = NULL;
221 281
222/* Used in the DSO operations. */ 282/* Used in the DSO operations. */
223static const char *CSWIFT_LIBNAME = "swift"; 283static const char def_CSWIFT_LIBNAME[] = "swift";
284static const char *CSWIFT_LIBNAME = def_CSWIFT_LIBNAME;
224static const char *CSWIFT_F1 = "swAcquireAccContext"; 285static const char *CSWIFT_F1 = "swAcquireAccContext";
225static const char *CSWIFT_F2 = "swAttachKeyParam"; 286static const char *CSWIFT_F2 = "swAttachKeyParam";
226static const char *CSWIFT_F3 = "swSimpleRequest"; 287static const char *CSWIFT_F3 = "swSimpleRequest";
@@ -249,8 +310,15 @@ static void release_context(SW_CONTEXT_HANDLE hac)
249 p_CSwift_ReleaseAccContext(hac); 310 p_CSwift_ReleaseAccContext(hac);
250 } 311 }
251 312
313/* Destructor (complements the "ENGINE_cswift()" constructor) */
314static int cswift_destroy(ENGINE *e)
315 {
316 ERR_unload_CSWIFT_strings();
317 return 1;
318 }
319
252/* (de)initialisation functions. */ 320/* (de)initialisation functions. */
253static int cswift_init() 321static int cswift_init(ENGINE *e)
254 { 322 {
255 SW_CONTEXT_HANDLE hac; 323 SW_CONTEXT_HANDLE hac;
256 t_swAcquireAccContext *p1; 324 t_swAcquireAccContext *p1;
@@ -260,15 +328,14 @@ static int cswift_init()
260 328
261 if(cswift_dso != NULL) 329 if(cswift_dso != NULL)
262 { 330 {
263 ENGINEerr(ENGINE_F_CSWIFT_INIT,ENGINE_R_ALREADY_LOADED); 331 CSWIFTerr(CSWIFT_F_CSWIFT_INIT,CSWIFT_R_ALREADY_LOADED);
264 goto err; 332 goto err;
265 } 333 }
266 /* Attempt to load libswift.so/swift.dll/whatever. */ 334 /* Attempt to load libswift.so/swift.dll/whatever. */
267 cswift_dso = DSO_load(NULL, CSWIFT_LIBNAME, NULL, 335 cswift_dso = DSO_load(NULL, CSWIFT_LIBNAME, NULL, 0);
268 DSO_FLAG_NAME_TRANSLATION);
269 if(cswift_dso == NULL) 336 if(cswift_dso == NULL)
270 { 337 {
271 ENGINEerr(ENGINE_F_CSWIFT_INIT,ENGINE_R_DSO_FAILURE); 338 CSWIFTerr(CSWIFT_F_CSWIFT_INIT,CSWIFT_R_NOT_LOADED);
272 goto err; 339 goto err;
273 } 340 }
274 if(!(p1 = (t_swAcquireAccContext *) 341 if(!(p1 = (t_swAcquireAccContext *)
@@ -280,7 +347,7 @@ static int cswift_init()
280 !(p4 = (t_swReleaseAccContext *) 347 !(p4 = (t_swReleaseAccContext *)
281 DSO_bind_func(cswift_dso, CSWIFT_F4))) 348 DSO_bind_func(cswift_dso, CSWIFT_F4)))
282 { 349 {
283 ENGINEerr(ENGINE_F_CSWIFT_INIT,ENGINE_R_DSO_FAILURE); 350 CSWIFTerr(CSWIFT_F_CSWIFT_INIT,CSWIFT_R_NOT_LOADED);
284 goto err; 351 goto err;
285 } 352 }
286 /* Copy the pointers */ 353 /* Copy the pointers */
@@ -292,7 +359,7 @@ static int cswift_init()
292 * accelerator! */ 359 * accelerator! */
293 if(!get_context(&hac)) 360 if(!get_context(&hac))
294 { 361 {
295 ENGINEerr(ENGINE_F_CSWIFT_INIT,ENGINE_R_UNIT_FAILURE); 362 CSWIFTerr(CSWIFT_F_CSWIFT_INIT,CSWIFT_R_UNIT_FAILURE);
296 goto err; 363 goto err;
297 } 364 }
298 release_context(hac); 365 release_context(hac);
@@ -308,16 +375,16 @@ err:
308 return 0; 375 return 0;
309 } 376 }
310 377
311static int cswift_finish() 378static int cswift_finish(ENGINE *e)
312 { 379 {
313 if(cswift_dso == NULL) 380 if(cswift_dso == NULL)
314 { 381 {
315 ENGINEerr(ENGINE_F_CSWIFT_FINISH,ENGINE_R_NOT_LOADED); 382 CSWIFTerr(CSWIFT_F_CSWIFT_FINISH,CSWIFT_R_NOT_LOADED);
316 return 0; 383 return 0;
317 } 384 }
318 if(!DSO_free(cswift_dso)) 385 if(!DSO_free(cswift_dso))
319 { 386 {
320 ENGINEerr(ENGINE_F_CSWIFT_FINISH,ENGINE_R_DSO_FAILURE); 387 CSWIFTerr(CSWIFT_F_CSWIFT_FINISH,CSWIFT_R_UNIT_FAILURE);
321 return 0; 388 return 0;
322 } 389 }
323 cswift_dso = NULL; 390 cswift_dso = NULL;
@@ -328,8 +395,33 @@ static int cswift_finish()
328 return 1; 395 return 1;
329 } 396 }
330 397
398static int cswift_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
399 {
400 int initialised = ((cswift_dso == NULL) ? 0 : 1);
401 switch(cmd)
402 {
403 case CSWIFT_CMD_SO_PATH:
404 if(p == NULL)
405 {
406 CSWIFTerr(CSWIFT_F_CSWIFT_CTRL,ERR_R_PASSED_NULL_PARAMETER);
407 return 0;
408 }
409 if(initialised)
410 {
411 CSWIFTerr(CSWIFT_F_CSWIFT_CTRL,CSWIFT_R_ALREADY_LOADED);
412 return 0;
413 }
414 CSWIFT_LIBNAME = (const char *)p;
415 return 1;
416 default:
417 break;
418 }
419 CSWIFTerr(CSWIFT_F_CSWIFT_CTRL,CSWIFT_R_CTRL_COMMAND_NOT_IMPLEMENTED);
420 return 0;
421 }
422
331/* Un petit mod_exp */ 423/* Un petit mod_exp */
332static int cswift_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p, 424static int cswift_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
333 const BIGNUM *m, BN_CTX *ctx) 425 const BIGNUM *m, BN_CTX *ctx)
334 { 426 {
335 /* I need somewhere to store temporary serialised values for 427 /* I need somewhere to store temporary serialised values for
@@ -353,24 +445,25 @@ static int cswift_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
353 445
354 if(!get_context(&hac)) 446 if(!get_context(&hac))
355 { 447 {
356 ENGINEerr(ENGINE_F_CSWIFT_MOD_EXP,ENGINE_R_GET_HANDLE_FAILED); 448 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP,CSWIFT_R_UNIT_FAILURE);
357 goto err; 449 goto err;
358 } 450 }
359 acquired = 1; 451 acquired = 1;
360 /* Prepare the params */ 452 /* Prepare the params */
453 BN_CTX_start(ctx);
361 modulus = BN_CTX_get(ctx); 454 modulus = BN_CTX_get(ctx);
362 exponent = BN_CTX_get(ctx); 455 exponent = BN_CTX_get(ctx);
363 argument = BN_CTX_get(ctx); 456 argument = BN_CTX_get(ctx);
364 result = BN_CTX_get(ctx); 457 result = BN_CTX_get(ctx);
365 if(!modulus || !exponent || !argument || !result) 458 if(!result)
366 { 459 {
367 ENGINEerr(ENGINE_F_CSWIFT_MOD_EXP,ENGINE_R_BN_CTX_FULL); 460 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP,CSWIFT_R_BN_CTX_FULL);
368 goto err; 461 goto err;
369 } 462 }
370 if(!bn_wexpand(modulus, m->top) || !bn_wexpand(exponent, p->top) || 463 if(!bn_wexpand(modulus, m->top) || !bn_wexpand(exponent, p->top) ||
371 !bn_wexpand(argument, a->top) || !bn_wexpand(result, m->top)) 464 !bn_wexpand(argument, a->top) || !bn_wexpand(result, m->top))
372 { 465 {
373 ENGINEerr(ENGINE_F_CSWIFT_MOD_EXP,ENGINE_R_BN_EXPAND_FAIL); 466 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP,CSWIFT_R_BN_EXPAND_FAIL);
374 goto err; 467 goto err;
375 } 468 }
376 sw_param.type = SW_ALG_EXP; 469 sw_param.type = SW_ALG_EXP;
@@ -387,13 +480,12 @@ static int cswift_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
387 case SW_OK: 480 case SW_OK:
388 break; 481 break;
389 case SW_ERR_INPUT_SIZE: 482 case SW_ERR_INPUT_SIZE:
390 ENGINEerr(ENGINE_F_CSWIFT_MOD_EXP, 483 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP,CSWIFT_R_BAD_KEY_SIZE);
391 ENGINE_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
392 goto err; 484 goto err;
393 default: 485 default:
394 { 486 {
395 char tmpbuf[20]; 487 char tmpbuf[20];
396 ENGINEerr(ENGINE_F_CSWIFT_MOD_EXP,ENGINE_R_REQUEST_FAILED); 488 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP,CSWIFT_R_REQUEST_FAILED);
397 sprintf(tmpbuf, "%ld", sw_status); 489 sprintf(tmpbuf, "%ld", sw_status);
398 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf); 490 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);
399 } 491 }
@@ -410,7 +502,7 @@ static int cswift_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
410 &res, 1)) != SW_OK) 502 &res, 1)) != SW_OK)
411 { 503 {
412 char tmpbuf[20]; 504 char tmpbuf[20];
413 ENGINEerr(ENGINE_F_CSWIFT_MOD_EXP,ENGINE_R_REQUEST_FAILED); 505 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP,CSWIFT_R_REQUEST_FAILED);
414 sprintf(tmpbuf, "%ld", sw_status); 506 sprintf(tmpbuf, "%ld", sw_status);
415 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf); 507 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);
416 goto err; 508 goto err;
@@ -421,15 +513,12 @@ static int cswift_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
421err: 513err:
422 if(acquired) 514 if(acquired)
423 release_context(hac); 515 release_context(hac);
424 if(modulus) ctx->tos--; 516 BN_CTX_end(ctx);
425 if(exponent) ctx->tos--;
426 if(argument) ctx->tos--;
427 if(result) ctx->tos--;
428 return to_return; 517 return to_return;
429 } 518 }
430 519
431/* Un petit mod_exp chinois */ 520/* Un petit mod_exp chinois */
432static int cswift_mod_exp_crt(BIGNUM *r, BIGNUM *a, const BIGNUM *p, 521static int cswift_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
433 const BIGNUM *q, const BIGNUM *dmp1, 522 const BIGNUM *q, const BIGNUM *dmp1,
434 const BIGNUM *dmq1, const BIGNUM *iqmp, BN_CTX *ctx) 523 const BIGNUM *dmq1, const BIGNUM *iqmp, BN_CTX *ctx)
435 { 524 {
@@ -449,11 +538,12 @@ static int cswift_mod_exp_crt(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
449 538
450 if(!get_context(&hac)) 539 if(!get_context(&hac))
451 { 540 {
452 ENGINEerr(ENGINE_F_CSWIFT_MOD_EXP_CRT,ENGINE_R_GET_HANDLE_FAILED); 541 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_UNIT_FAILURE);
453 goto err; 542 goto err;
454 } 543 }
455 acquired = 1; 544 acquired = 1;
456 /* Prepare the params */ 545 /* Prepare the params */
546 BN_CTX_start(ctx);
457 rsa_p = BN_CTX_get(ctx); 547 rsa_p = BN_CTX_get(ctx);
458 rsa_q = BN_CTX_get(ctx); 548 rsa_q = BN_CTX_get(ctx);
459 rsa_dmp1 = BN_CTX_get(ctx); 549 rsa_dmp1 = BN_CTX_get(ctx);
@@ -461,10 +551,9 @@ static int cswift_mod_exp_crt(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
461 rsa_iqmp = BN_CTX_get(ctx); 551 rsa_iqmp = BN_CTX_get(ctx);
462 argument = BN_CTX_get(ctx); 552 argument = BN_CTX_get(ctx);
463 result = BN_CTX_get(ctx); 553 result = BN_CTX_get(ctx);
464 if(!rsa_p || !rsa_q || !rsa_dmp1 || !rsa_dmq1 || !rsa_iqmp || 554 if(!result)
465 !argument || !result)
466 { 555 {
467 ENGINEerr(ENGINE_F_CSWIFT_MOD_EXP_CRT,ENGINE_R_BN_CTX_FULL); 556 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_BN_CTX_FULL);
468 goto err; 557 goto err;
469 } 558 }
470 if(!bn_wexpand(rsa_p, p->top) || !bn_wexpand(rsa_q, q->top) || 559 if(!bn_wexpand(rsa_p, p->top) || !bn_wexpand(rsa_q, q->top) ||
@@ -474,7 +563,7 @@ static int cswift_mod_exp_crt(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
474 !bn_wexpand(argument, a->top) || 563 !bn_wexpand(argument, a->top) ||
475 !bn_wexpand(result, p->top + q->top)) 564 !bn_wexpand(result, p->top + q->top))
476 { 565 {
477 ENGINEerr(ENGINE_F_CSWIFT_MOD_EXP_CRT,ENGINE_R_BN_EXPAND_FAIL); 566 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_BN_EXPAND_FAIL);
478 goto err; 567 goto err;
479 } 568 }
480 sw_param.type = SW_ALG_CRT; 569 sw_param.type = SW_ALG_CRT;
@@ -498,13 +587,12 @@ static int cswift_mod_exp_crt(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
498 case SW_OK: 587 case SW_OK:
499 break; 588 break;
500 case SW_ERR_INPUT_SIZE: 589 case SW_ERR_INPUT_SIZE:
501 ENGINEerr(ENGINE_F_CSWIFT_MOD_EXP_CRT, 590 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_BAD_KEY_SIZE);
502 ENGINE_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
503 goto err; 591 goto err;
504 default: 592 default:
505 { 593 {
506 char tmpbuf[20]; 594 char tmpbuf[20];
507 ENGINEerr(ENGINE_F_CSWIFT_MOD_EXP_CRT,ENGINE_R_REQUEST_FAILED); 595 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_REQUEST_FAILED);
508 sprintf(tmpbuf, "%ld", sw_status); 596 sprintf(tmpbuf, "%ld", sw_status);
509 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf); 597 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);
510 } 598 }
@@ -521,7 +609,7 @@ static int cswift_mod_exp_crt(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
521 &res, 1)) != SW_OK) 609 &res, 1)) != SW_OK)
522 { 610 {
523 char tmpbuf[20]; 611 char tmpbuf[20];
524 ENGINEerr(ENGINE_F_CSWIFT_MOD_EXP_CRT,ENGINE_R_REQUEST_FAILED); 612 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_REQUEST_FAILED);
525 sprintf(tmpbuf, "%ld", sw_status); 613 sprintf(tmpbuf, "%ld", sw_status);
526 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf); 614 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);
527 goto err; 615 goto err;
@@ -532,17 +620,12 @@ static int cswift_mod_exp_crt(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
532err: 620err:
533 if(acquired) 621 if(acquired)
534 release_context(hac); 622 release_context(hac);
535 if(rsa_p) ctx->tos--; 623 BN_CTX_end(ctx);
536 if(rsa_q) ctx->tos--;
537 if(rsa_dmp1) ctx->tos--;
538 if(rsa_dmq1) ctx->tos--;
539 if(rsa_iqmp) ctx->tos--;
540 if(argument) ctx->tos--;
541 if(result) ctx->tos--;
542 return to_return; 624 return to_return;
543 } 625 }
544 626
545static int cswift_rsa_mod_exp(BIGNUM *r0, BIGNUM *I, RSA *rsa) 627#ifndef OPENSSL_NO_RSA
628static int cswift_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
546 { 629 {
547 BN_CTX *ctx; 630 BN_CTX *ctx;
548 int to_return = 0; 631 int to_return = 0;
@@ -551,7 +634,7 @@ static int cswift_rsa_mod_exp(BIGNUM *r0, BIGNUM *I, RSA *rsa)
551 goto err; 634 goto err;
552 if(!rsa->p || !rsa->q || !rsa->dmp1 || !rsa->dmq1 || !rsa->iqmp) 635 if(!rsa->p || !rsa->q || !rsa->dmp1 || !rsa->dmq1 || !rsa->iqmp)
553 { 636 {
554 ENGINEerr(ENGINE_F_CSWIFT_RSA_MOD_EXP,ENGINE_R_MISSING_KEY_COMPONENTS); 637 CSWIFTerr(CSWIFT_F_CSWIFT_RSA_MOD_EXP,CSWIFT_R_MISSING_KEY_COMPONENTS);
555 goto err; 638 goto err;
556 } 639 }
557 to_return = cswift_mod_exp_crt(r0, I, rsa->p, rsa->q, rsa->dmp1, 640 to_return = cswift_mod_exp_crt(r0, I, rsa->p, rsa->q, rsa->dmp1,
@@ -561,14 +644,16 @@ err:
561 BN_CTX_free(ctx); 644 BN_CTX_free(ctx);
562 return to_return; 645 return to_return;
563 } 646 }
647#endif
564 648
565/* This function is aliased to mod_exp (with the mont stuff dropped). */ 649/* This function is aliased to mod_exp (with the mont stuff dropped). */
566static int cswift_mod_exp_mont(BIGNUM *r, BIGNUM *a, const BIGNUM *p, 650static int cswift_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
567 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx) 651 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
568 { 652 {
569 return cswift_mod_exp(r, a, p, m, ctx); 653 return cswift_mod_exp(r, a, p, m, ctx);
570 } 654 }
571 655
656#ifndef OPENSSL_NO_DSA
572static DSA_SIG *cswift_dsa_sign(const unsigned char *dgst, int dlen, DSA *dsa) 657static DSA_SIG *cswift_dsa_sign(const unsigned char *dgst, int dlen, DSA *dsa)
573 { 658 {
574 SW_CONTEXT_HANDLE hac; 659 SW_CONTEXT_HANDLE hac;
@@ -589,19 +674,20 @@ static DSA_SIG *cswift_dsa_sign(const unsigned char *dgst, int dlen, DSA *dsa)
589 goto err; 674 goto err;
590 if(!get_context(&hac)) 675 if(!get_context(&hac))
591 { 676 {
592 ENGINEerr(ENGINE_F_CSWIFT_DSA_SIGN,ENGINE_R_GET_HANDLE_FAILED); 677 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_SIGN,CSWIFT_R_UNIT_FAILURE);
593 goto err; 678 goto err;
594 } 679 }
595 acquired = 1; 680 acquired = 1;
596 /* Prepare the params */ 681 /* Prepare the params */
682 BN_CTX_start(ctx);
597 dsa_p = BN_CTX_get(ctx); 683 dsa_p = BN_CTX_get(ctx);
598 dsa_q = BN_CTX_get(ctx); 684 dsa_q = BN_CTX_get(ctx);
599 dsa_g = BN_CTX_get(ctx); 685 dsa_g = BN_CTX_get(ctx);
600 dsa_key = BN_CTX_get(ctx); 686 dsa_key = BN_CTX_get(ctx);
601 result = BN_CTX_get(ctx); 687 result = BN_CTX_get(ctx);
602 if(!dsa_p || !dsa_q || !dsa_g || !dsa_key || !result) 688 if(!result)
603 { 689 {
604 ENGINEerr(ENGINE_F_CSWIFT_DSA_SIGN,ENGINE_R_BN_CTX_FULL); 690 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_SIGN,CSWIFT_R_BN_CTX_FULL);
605 goto err; 691 goto err;
606 } 692 }
607 if(!bn_wexpand(dsa_p, dsa->p->top) || 693 if(!bn_wexpand(dsa_p, dsa->p->top) ||
@@ -610,7 +696,7 @@ static DSA_SIG *cswift_dsa_sign(const unsigned char *dgst, int dlen, DSA *dsa)
610 !bn_wexpand(dsa_key, dsa->priv_key->top) || 696 !bn_wexpand(dsa_key, dsa->priv_key->top) ||
611 !bn_wexpand(result, dsa->p->top)) 697 !bn_wexpand(result, dsa->p->top))
612 { 698 {
613 ENGINEerr(ENGINE_F_CSWIFT_DSA_SIGN,ENGINE_R_BN_EXPAND_FAIL); 699 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_SIGN,CSWIFT_R_BN_EXPAND_FAIL);
614 goto err; 700 goto err;
615 } 701 }
616 sw_param.type = SW_ALG_DSA; 702 sw_param.type = SW_ALG_DSA;
@@ -633,13 +719,12 @@ static DSA_SIG *cswift_dsa_sign(const unsigned char *dgst, int dlen, DSA *dsa)
633 case SW_OK: 719 case SW_OK:
634 break; 720 break;
635 case SW_ERR_INPUT_SIZE: 721 case SW_ERR_INPUT_SIZE:
636 ENGINEerr(ENGINE_F_CSWIFT_DSA_SIGN, 722 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_SIGN,CSWIFT_R_BAD_KEY_SIZE);
637 ENGINE_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
638 goto err; 723 goto err;
639 default: 724 default:
640 { 725 {
641 char tmpbuf[20]; 726 char tmpbuf[20];
642 ENGINEerr(ENGINE_F_CSWIFT_DSA_SIGN,ENGINE_R_REQUEST_FAILED); 727 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_SIGN,CSWIFT_R_REQUEST_FAILED);
643 sprintf(tmpbuf, "%ld", sw_status); 728 sprintf(tmpbuf, "%ld", sw_status);
644 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf); 729 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);
645 } 730 }
@@ -657,7 +742,7 @@ static DSA_SIG *cswift_dsa_sign(const unsigned char *dgst, int dlen, DSA *dsa)
657 if(sw_status != SW_OK) 742 if(sw_status != SW_OK)
658 { 743 {
659 char tmpbuf[20]; 744 char tmpbuf[20];
660 ENGINEerr(ENGINE_F_CSWIFT_DSA_SIGN,ENGINE_R_REQUEST_FAILED); 745 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_SIGN,CSWIFT_R_REQUEST_FAILED);
661 sprintf(tmpbuf, "%ld", sw_status); 746 sprintf(tmpbuf, "%ld", sw_status);
662 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf); 747 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);
663 goto err; 748 goto err;
@@ -672,13 +757,11 @@ static DSA_SIG *cswift_dsa_sign(const unsigned char *dgst, int dlen, DSA *dsa)
672err: 757err:
673 if(acquired) 758 if(acquired)
674 release_context(hac); 759 release_context(hac);
675 if(dsa_p) ctx->tos--;
676 if(dsa_q) ctx->tos--;
677 if(dsa_g) ctx->tos--;
678 if(dsa_key) ctx->tos--;
679 if(result) ctx->tos--;
680 if(ctx) 760 if(ctx)
761 {
762 BN_CTX_end(ctx);
681 BN_CTX_free(ctx); 763 BN_CTX_free(ctx);
764 }
682 return to_return; 765 return to_return;
683 } 766 }
684 767
@@ -703,19 +786,20 @@ static int cswift_dsa_verify(const unsigned char *dgst, int dgst_len,
703 goto err; 786 goto err;
704 if(!get_context(&hac)) 787 if(!get_context(&hac))
705 { 788 {
706 ENGINEerr(ENGINE_F_CSWIFT_DSA_VERIFY,ENGINE_R_GET_HANDLE_FAILED); 789 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_VERIFY,CSWIFT_R_UNIT_FAILURE);
707 goto err; 790 goto err;
708 } 791 }
709 acquired = 1; 792 acquired = 1;
710 /* Prepare the params */ 793 /* Prepare the params */
794 BN_CTX_start(ctx);
711 dsa_p = BN_CTX_get(ctx); 795 dsa_p = BN_CTX_get(ctx);
712 dsa_q = BN_CTX_get(ctx); 796 dsa_q = BN_CTX_get(ctx);
713 dsa_g = BN_CTX_get(ctx); 797 dsa_g = BN_CTX_get(ctx);
714 dsa_key = BN_CTX_get(ctx); 798 dsa_key = BN_CTX_get(ctx);
715 argument = BN_CTX_get(ctx); 799 argument = BN_CTX_get(ctx);
716 if(!dsa_p || !dsa_q || !dsa_g || !dsa_key || !argument) 800 if(!argument)
717 { 801 {
718 ENGINEerr(ENGINE_F_CSWIFT_DSA_VERIFY,ENGINE_R_BN_CTX_FULL); 802 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_VERIFY,CSWIFT_R_BN_CTX_FULL);
719 goto err; 803 goto err;
720 } 804 }
721 if(!bn_wexpand(dsa_p, dsa->p->top) || 805 if(!bn_wexpand(dsa_p, dsa->p->top) ||
@@ -724,7 +808,7 @@ static int cswift_dsa_verify(const unsigned char *dgst, int dgst_len,
724 !bn_wexpand(dsa_key, dsa->pub_key->top) || 808 !bn_wexpand(dsa_key, dsa->pub_key->top) ||
725 !bn_wexpand(argument, 40)) 809 !bn_wexpand(argument, 40))
726 { 810 {
727 ENGINEerr(ENGINE_F_CSWIFT_DSA_VERIFY,ENGINE_R_BN_EXPAND_FAIL); 811 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_VERIFY,CSWIFT_R_BN_EXPAND_FAIL);
728 goto err; 812 goto err;
729 } 813 }
730 sw_param.type = SW_ALG_DSA; 814 sw_param.type = SW_ALG_DSA;
@@ -747,13 +831,12 @@ static int cswift_dsa_verify(const unsigned char *dgst, int dgst_len,
747 case SW_OK: 831 case SW_OK:
748 break; 832 break;
749 case SW_ERR_INPUT_SIZE: 833 case SW_ERR_INPUT_SIZE:
750 ENGINEerr(ENGINE_F_CSWIFT_DSA_VERIFY, 834 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_VERIFY,CSWIFT_R_BAD_KEY_SIZE);
751 ENGINE_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
752 goto err; 835 goto err;
753 default: 836 default:
754 { 837 {
755 char tmpbuf[20]; 838 char tmpbuf[20];
756 ENGINEerr(ENGINE_F_CSWIFT_DSA_VERIFY,ENGINE_R_REQUEST_FAILED); 839 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_VERIFY,CSWIFT_R_REQUEST_FAILED);
757 sprintf(tmpbuf, "%ld", sw_status); 840 sprintf(tmpbuf, "%ld", sw_status);
758 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf); 841 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);
759 } 842 }
@@ -775,7 +858,7 @@ static int cswift_dsa_verify(const unsigned char *dgst, int dgst_len,
775 if(sw_status != SW_OK) 858 if(sw_status != SW_OK)
776 { 859 {
777 char tmpbuf[20]; 860 char tmpbuf[20];
778 ENGINEerr(ENGINE_F_CSWIFT_DSA_VERIFY,ENGINE_R_REQUEST_FAILED); 861 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_VERIFY,CSWIFT_R_REQUEST_FAILED);
779 sprintf(tmpbuf, "%ld", sw_status); 862 sprintf(tmpbuf, "%ld", sw_status);
780 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf); 863 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);
781 goto err; 864 goto err;
@@ -786,22 +869,39 @@ static int cswift_dsa_verify(const unsigned char *dgst, int dgst_len,
786err: 869err:
787 if(acquired) 870 if(acquired)
788 release_context(hac); 871 release_context(hac);
789 if(dsa_p) ctx->tos--;
790 if(dsa_q) ctx->tos--;
791 if(dsa_g) ctx->tos--;
792 if(dsa_key) ctx->tos--;
793 if(argument) ctx->tos--;
794 if(ctx) 872 if(ctx)
873 {
874 BN_CTX_end(ctx);
795 BN_CTX_free(ctx); 875 BN_CTX_free(ctx);
876 }
796 return to_return; 877 return to_return;
797 } 878 }
879#endif
798 880
881#ifndef OPENSSL_NO_DH
799/* This function is aliased to mod_exp (with the dh and mont dropped). */ 882/* This function is aliased to mod_exp (with the dh and mont dropped). */
800static int cswift_mod_exp_dh(DH *dh, BIGNUM *r, BIGNUM *a, const BIGNUM *p, 883static int cswift_mod_exp_dh(const DH *dh, BIGNUM *r,
884 const BIGNUM *a, const BIGNUM *p,
801 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx) 885 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
802 { 886 {
803 return cswift_mod_exp(r, a, p, m, ctx); 887 return cswift_mod_exp(r, a, p, m, ctx);
804 } 888 }
889#endif
890
891/* This stuff is needed if this ENGINE is being compiled into a self-contained
892 * shared-library. */
893#ifdef ENGINE_DYNAMIC_SUPPORT
894static int bind_fn(ENGINE *e, const char *id)
895 {
896 if(id && (strcmp(id, engine_cswift_id) != 0))
897 return 0;
898 if(!bind_helper(e))
899 return 0;
900 return 1;
901 }
902IMPLEMENT_DYNAMIC_CHECK_FN()
903IMPLEMENT_DYNAMIC_BIND_FN(bind_fn)
904#endif /* ENGINE_DYNAMIC_SUPPORT */
805 905
806#endif /* !NO_HW_CSWIFT */ 906#endif /* !OPENSSL_NO_HW_CSWIFT */
807#endif /* !NO_HW */ 907#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
index 41f5900676..4762a54e3d 100644
--- a/src/lib/libcrypto/engine/hw_ncipher.c
+++ b/src/lib/libcrypto/engine/hw_ncipher.c
@@ -4,7 +4,7 @@
4 * for the OpenSSL project 2000. 4 * for the OpenSSL project 2000.
5 */ 5 */
6/* ==================================================================== 6/* ====================================================================
7 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. 7 * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
@@ -58,15 +58,16 @@
58 */ 58 */
59 59
60#include <stdio.h> 60#include <stdio.h>
61#include <string.h>
61#include <openssl/crypto.h> 62#include <openssl/crypto.h>
62#include <openssl/pem.h> 63#include <openssl/pem.h>
63#include "cryptlib.h" 64#include "cryptlib.h"
64#include <openssl/dso.h> 65#include <openssl/dso.h>
65#include "engine_int.h"
66#include <openssl/engine.h> 66#include <openssl/engine.h>
67#include <openssl/ui.h>
67 68
68#ifndef NO_HW 69#ifndef OPENSSL_NO_HW
69#ifndef NO_HW_NCIPHER 70#ifndef OPENSSL_NO_HW_NCIPHER
70 71
71/* Attribution notice: nCipher have said several times that it's OK for 72/* Attribution notice: nCipher have said several times that it's OK for
72 * us to implement a general interface to their boxes, and recently declared 73 * us to implement a general interface to their boxes, and recently declared
@@ -82,9 +83,13 @@
82#include "vendor_defns/hwcryptohook.h" 83#include "vendor_defns/hwcryptohook.h"
83#endif 84#endif
84 85
85static int hwcrhk_init(void); 86#define HWCRHK_LIB_NAME "hwcrhk engine"
86static int hwcrhk_finish(void); 87#include "hw_ncipher_err.c"
87static int hwcrhk_ctrl(int cmd, long i, void *p, void (*f)()); 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)());
88 93
89/* Functions to handle mutexes */ 94/* Functions to handle mutexes */
90static int hwcrhk_mutex_init(HWCryptoHook_Mutex*, HWCryptoHook_CallerContext*); 95static int hwcrhk_mutex_init(HWCryptoHook_Mutex*, HWCryptoHook_CallerContext*);
@@ -93,39 +98,77 @@ static void hwcrhk_mutex_unlock(HWCryptoHook_Mutex*);
93static void hwcrhk_mutex_destroy(HWCryptoHook_Mutex*); 98static void hwcrhk_mutex_destroy(HWCryptoHook_Mutex*);
94 99
95/* BIGNUM stuff */ 100/* BIGNUM stuff */
96static int hwcrhk_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p, 101static int hwcrhk_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
97 const BIGNUM *m, BN_CTX *ctx); 102 const BIGNUM *m, BN_CTX *ctx);
98 103
104#ifndef OPENSSL_NO_RSA
99/* RSA stuff */ 105/* RSA stuff */
100static int hwcrhk_rsa_mod_exp(BIGNUM *r, BIGNUM *I, RSA *rsa); 106static int hwcrhk_rsa_mod_exp(BIGNUM *r, const BIGNUM *I, RSA *rsa);
107#endif
101/* This function is aliased to mod_exp (with the mont stuff dropped). */ 108/* This function is aliased to mod_exp (with the mont stuff dropped). */
102static int hwcrhk_mod_exp_mont(BIGNUM *r, BIGNUM *a, const BIGNUM *p, 109static int hwcrhk_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
103 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); 110 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
104 111
105/* DH stuff */ 112/* DH stuff */
106/* This function is alised to mod_exp (with the DH and mont dropped). */ 113/* This function is alised to mod_exp (with the DH and mont dropped). */
107static int hwcrhk_mod_exp_dh(DH *dh, BIGNUM *r, BIGNUM *a, const BIGNUM *p, 114static int hwcrhk_mod_exp_dh(const DH *dh, BIGNUM *r,
108 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); 115 const BIGNUM *a, const BIGNUM *p,
116 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
109 117
110/* RAND stuff */ 118/* RAND stuff */
111static int hwcrhk_rand_bytes(unsigned char *buf, int num); 119static int hwcrhk_rand_bytes(unsigned char *buf, int num);
112static int hwcrhk_rand_status(void); 120static int hwcrhk_rand_status(void);
113 121
114/* KM stuff */ 122/* KM stuff */
115static EVP_PKEY *hwcrhk_load_privkey(const char *key_id, 123static EVP_PKEY *hwcrhk_load_privkey(ENGINE *eng, const char *key_id,
116 const char *passphrase); 124 UI_METHOD *ui_method, void *callback_data);
117static EVP_PKEY *hwcrhk_load_pubkey(const char *key_id, 125static EVP_PKEY *hwcrhk_load_pubkey(ENGINE *eng, const char *key_id,
118 const char *passphrase); 126 UI_METHOD *ui_method, void *callback_data);
119static void hwcrhk_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad, 127static void hwcrhk_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad,
120 int index,long argl, void *argp); 128 int ind,long argl, void *argp);
121 129
122/* Interaction stuff */ 130/* Interaction stuff */
131static int hwcrhk_insert_card(const char *prompt_info,
132 const char *wrong_info,
133 HWCryptoHook_PassphraseContext *ppctx,
134 HWCryptoHook_CallerContext *cactx);
123static int hwcrhk_get_pass(const char *prompt_info, 135static int hwcrhk_get_pass(const char *prompt_info,
124 int *len_io, char *buf, 136 int *len_io, char *buf,
125 HWCryptoHook_PassphraseContext *ppctx, 137 HWCryptoHook_PassphraseContext *ppctx,
126 HWCryptoHook_CallerContext *cactx); 138 HWCryptoHook_CallerContext *cactx);
127static void hwcrhk_log_message(void *logstream, const char *message); 139static void hwcrhk_log_message(void *logstr, const char *message);
140
141/* The definitions for control commands specific to this engine */
142#define HWCRHK_CMD_SO_PATH ENGINE_CMD_BASE
143#define HWCRHK_CMD_FORK_CHECK (ENGINE_CMD_BASE + 1)
144#define HWCRHK_CMD_THREAD_LOCKING (ENGINE_CMD_BASE + 2)
145#define HWCRHK_CMD_SET_USER_INTERFACE (ENGINE_CMD_BASE + 3)
146#define HWCRHK_CMD_SET_CALLBACK_DATA (ENGINE_CMD_BASE + 4)
147static const ENGINE_CMD_DEFN hwcrhk_cmd_defns[] = {
148 {HWCRHK_CMD_SO_PATH,
149 "SO_PATH",
150 "Specifies the path to the 'hwcrhk' shared library",
151 ENGINE_CMD_FLAG_STRING},
152 {HWCRHK_CMD_FORK_CHECK,
153 "FORK_CHECK",
154 "Turns fork() checking on or off (boolean)",
155 ENGINE_CMD_FLAG_NUMERIC},
156 {HWCRHK_CMD_THREAD_LOCKING,
157 "THREAD_LOCKING",
158 "Turns thread-safe locking on or off (boolean)",
159 ENGINE_CMD_FLAG_NUMERIC},
160 {HWCRHK_CMD_SET_USER_INTERFACE,
161 "SET_USER_INTERFACE",
162 "Set the global user interface (internal)",
163 ENGINE_CMD_FLAG_INTERNAL},
164 {HWCRHK_CMD_SET_CALLBACK_DATA,
165 "SET_CALLBACK_DATA",
166 "Set the global user interface extra data (internal)",
167 ENGINE_CMD_FLAG_INTERNAL},
168 {0, NULL, NULL, 0}
169 };
128 170
171#ifndef OPENSSL_NO_RSA
129/* Our internal RSA_METHOD that we provide pointers to */ 172/* Our internal RSA_METHOD that we provide pointers to */
130static RSA_METHOD hwcrhk_rsa = 173static RSA_METHOD hwcrhk_rsa =
131 { 174 {
@@ -143,7 +186,9 @@ static RSA_METHOD hwcrhk_rsa =
143 NULL, 186 NULL,
144 NULL 187 NULL
145 }; 188 };
189#endif
146 190
191#ifndef OPENSSL_NO_DH
147/* Our internal DH_METHOD that we provide pointers to */ 192/* Our internal DH_METHOD that we provide pointers to */
148static DH_METHOD hwcrhk_dh = 193static DH_METHOD hwcrhk_dh =
149 { 194 {
@@ -156,6 +201,7 @@ static DH_METHOD hwcrhk_dh =
156 0, 201 0,
157 NULL 202 NULL
158 }; 203 };
204#endif
159 205
160static RAND_METHOD hwcrhk_rand = 206static RAND_METHOD hwcrhk_rand =
161 { 207 {
@@ -168,26 +214,9 @@ static RAND_METHOD hwcrhk_rand =
168 hwcrhk_rand_status, 214 hwcrhk_rand_status,
169 }; 215 };
170 216
171/* Our ENGINE structure. */ 217/* Constants used when creating the ENGINE */
172static ENGINE engine_hwcrhk = 218static const char *engine_hwcrhk_id = "chil";
173 { 219static const char *engine_hwcrhk_name = "nCipher hardware engine support";
174 "chil",
175 "nCipher hardware engine support",
176 &hwcrhk_rsa,
177 NULL,
178 &hwcrhk_dh,
179 &hwcrhk_rand,
180 hwcrhk_mod_exp,
181 NULL,
182 hwcrhk_init,
183 hwcrhk_finish,
184 hwcrhk_ctrl,
185 hwcrhk_load_privkey,
186 hwcrhk_load_pubkey,
187 0, /* no flags */
188 0, 0, /* no references */
189 NULL, NULL /* unlinked */
190 };
191 220
192/* Internal stuff for HWCryptoHook */ 221/* Internal stuff for HWCryptoHook */
193 222
@@ -204,7 +233,8 @@ struct HWCryptoHook_MutexValue
204 into HWCryptoHook_PassphraseContext */ 233 into HWCryptoHook_PassphraseContext */
205struct HWCryptoHook_PassphraseContextValue 234struct HWCryptoHook_PassphraseContextValue
206 { 235 {
207 void *any; 236 UI_METHOD *ui_method;
237 void *callback_data;
208 }; 238 };
209 239
210/* hwcryptohook.h has some typedefs that turn 240/* hwcryptohook.h has some typedefs that turn
@@ -212,7 +242,10 @@ struct HWCryptoHook_PassphraseContextValue
212 into HWCryptoHook_CallerContext */ 242 into HWCryptoHook_CallerContext */
213struct HWCryptoHook_CallerContextValue 243struct HWCryptoHook_CallerContextValue
214 { 244 {
215 void *any; 245 pem_password_cb *password_callback; /* Deprecated! Only present for
246 backward compatibility! */
247 UI_METHOD *ui_method;
248 void *callback_data;
216 }; 249 };
217 250
218/* The MPI structure in HWCryptoHook is pretty compatible with OpenSSL 251/* The MPI structure in HWCryptoHook is pretty compatible with OpenSSL
@@ -222,31 +255,27 @@ struct HWCryptoHook_CallerContextValue
222#define MPI2BN(bn, mp) \ 255#define MPI2BN(bn, mp) \
223 {mp.size = bn->dmax * sizeof(BN_ULONG); mp.buf = (unsigned char *)bn->d;} 256 {mp.size = bn->dmax * sizeof(BN_ULONG); mp.buf = (unsigned char *)bn->d;}
224 257
225#if 0 /* Card and password management is not yet supported */
226/* HWCryptoHook callbacks. insert_card() and get_pass() are not yet
227 defined, because we haven't quite decided on the proper form yet.
228 log_message() just adds an entry in the error stack. I don't know
229 if that's good or bad... */
230static int insert_card(const char *prompt_info,
231 const char *wrong_info,
232 HWCryptoHook_PassphraseContext *ppctx,
233 HWCryptoHook_CallerContext *cactx);
234static int get_pass(const char *prompt_info,
235 int *len_io, char *buf,
236 HWCryptoHook_PassphraseContext *ppctx,
237 HWCryptoHook_CallerContext *cactx);
238#endif
239
240static BIO *logstream = NULL; 258static BIO *logstream = NULL;
241static pem_password_cb *password_callback = NULL;
242#if 0
243static void *password_callback_userdata = NULL;
244#endif
245static int disable_mutex_callbacks = 0; 259static int disable_mutex_callbacks = 0;
246 260
261/* One might wonder why these are needed, since one can pass down at least
262 a UI_METHOD and a pointer to callback data to the key-loading functions.
263 The thing is that the ModExp and RSAImmed functions can load keys as well,
264 if the data they get is in a special, nCipher-defined format (hint: if you
265 look at the private exponent of the RSA data as a string, you'll see this
266 string: "nCipher KM tool key id", followed by some bytes, followed a key
267 identity string, followed by more bytes. This happens when you use "embed"
268 keys instead of "hwcrhk" keys). Unfortunately, those functions do not take
269 any passphrase or caller context, and our functions can't really take any
270 callback data either. Still, the "insert_card" and "get_passphrase"
271 callbacks may be called down the line, and will need to know what user
272 interface callbacks to call, and having callback data from the application
273 may be a nice thing as well, so we need to keep track of that globally. */
274static HWCryptoHook_CallerContext password_context = { NULL, NULL, NULL };
275
247/* Stuff to pass to the HWCryptoHook library */ 276/* Stuff to pass to the HWCryptoHook library */
248static HWCryptoHook_InitInfo hwcrhk_globals = { 277static HWCryptoHook_InitInfo hwcrhk_globals = {
249 0, /* Flags */ 278 HWCryptoHook_InitFlags_SimpleForkCheck, /* Flags */
250 &logstream, /* logstream */ 279 &logstream, /* logstream */
251 sizeof(BN_ULONG), /* limbsize */ 280 sizeof(BN_ULONG), /* limbsize */
252 0, /* mslimb first: false for BNs */ 281 0, /* mslimb first: false for BNs */
@@ -280,20 +309,42 @@ static HWCryptoHook_InitInfo hwcrhk_globals = {
280 0, /* hwcrhk_cv_destroy, */ 309 0, /* hwcrhk_cv_destroy, */
281 310
282 hwcrhk_get_pass, /* pass phrase */ 311 hwcrhk_get_pass, /* pass phrase */
283 0, /* insert_card, */ /* insert a card */ 312 hwcrhk_insert_card, /* insert a card */
284 hwcrhk_log_message /* Log message */ 313 hwcrhk_log_message /* Log message */
285}; 314};
286 315
287 316
288/* Now, to our own code */ 317/* Now, to our own code */
289 318
290/* As this is only ever called once, there's no need for locking 319/* This internal function is used by ENGINE_ncipher() and possibly by the
291 * (indeed - the lock will already be held by our caller!!!) */ 320 * "dynamic" ENGINE support too */
292ENGINE *ENGINE_ncipher() 321static int bind_helper(ENGINE *e)
293 { 322 {
294 RSA_METHOD *meth1; 323#ifndef OPENSSL_NO_RSA
295 DH_METHOD *meth2; 324 const RSA_METHOD *meth1;
325#endif
326#ifndef OPENSSL_NO_DH
327 const DH_METHOD *meth2;
328#endif
329 if(!ENGINE_set_id(e, engine_hwcrhk_id) ||
330 !ENGINE_set_name(e, engine_hwcrhk_name) ||
331#ifndef OPENSSL_NO_RSA
332 !ENGINE_set_RSA(e, &hwcrhk_rsa) ||
333#endif
334#ifndef OPENSSL_NO_DH
335 !ENGINE_set_DH(e, &hwcrhk_dh) ||
336#endif
337 !ENGINE_set_RAND(e, &hwcrhk_rand) ||
338 !ENGINE_set_destroy_function(e, hwcrhk_destroy) ||
339 !ENGINE_set_init_function(e, hwcrhk_init) ||
340 !ENGINE_set_finish_function(e, hwcrhk_finish) ||
341 !ENGINE_set_ctrl_function(e, hwcrhk_ctrl) ||
342 !ENGINE_set_load_privkey_function(e, hwcrhk_load_privkey) ||
343 !ENGINE_set_load_pubkey_function(e, hwcrhk_load_pubkey) ||
344 !ENGINE_set_cmd_defns(e, hwcrhk_cmd_defns))
345 return 0;
296 346
347#ifndef OPENSSL_NO_RSA
297 /* We know that the "PKCS1_SSLeay()" functions hook properly 348 /* We know that the "PKCS1_SSLeay()" functions hook properly
298 * to the cswift-specific mod_exp and mod_exp_crt so we use 349 * to the cswift-specific mod_exp and mod_exp_crt so we use
299 * those functions. NB: We don't use ENGINE_openssl() or 350 * those functions. NB: We don't use ENGINE_openssl() or
@@ -306,12 +357,41 @@ ENGINE *ENGINE_ncipher()
306 hwcrhk_rsa.rsa_pub_dec = meth1->rsa_pub_dec; 357 hwcrhk_rsa.rsa_pub_dec = meth1->rsa_pub_dec;
307 hwcrhk_rsa.rsa_priv_enc = meth1->rsa_priv_enc; 358 hwcrhk_rsa.rsa_priv_enc = meth1->rsa_priv_enc;
308 hwcrhk_rsa.rsa_priv_dec = meth1->rsa_priv_dec; 359 hwcrhk_rsa.rsa_priv_dec = meth1->rsa_priv_dec;
360#endif
309 361
362#ifndef OPENSSL_NO_DH
310 /* Much the same for Diffie-Hellman */ 363 /* Much the same for Diffie-Hellman */
311 meth2 = DH_OpenSSL(); 364 meth2 = DH_OpenSSL();
312 hwcrhk_dh.generate_key = meth2->generate_key; 365 hwcrhk_dh.generate_key = meth2->generate_key;
313 hwcrhk_dh.compute_key = meth2->compute_key; 366 hwcrhk_dh.compute_key = meth2->compute_key;
314 return &engine_hwcrhk; 367#endif
368
369 /* Ensure the hwcrhk error handling is set up */
370 ERR_load_HWCRHK_strings();
371 return 1;
372 }
373
374static ENGINE *engine_ncipher(void)
375 {
376 ENGINE *ret = ENGINE_new();
377 if(!ret)
378 return NULL;
379 if(!bind_helper(ret))
380 {
381 ENGINE_free(ret);
382 return NULL;
383 }
384 return ret;
385 }
386
387void ENGINE_load_chil(void)
388 {
389 /* Copied from eng_[openssl|dyn].c */
390 ENGINE *toadd = engine_ncipher();
391 if(!toadd) return;
392 ENGINE_add(toadd);
393 ENGINE_free(toadd);
394 ERR_clear_error();
315 } 395 }
316 396
317/* This is a process-global DSO handle used for loading and unloading 397/* This is a process-global DSO handle used for loading and unloading
@@ -321,30 +401,41 @@ ENGINE *ENGINE_ncipher()
321 * implicitly. */ 401 * implicitly. */
322static DSO *hwcrhk_dso = NULL; 402static DSO *hwcrhk_dso = NULL;
323static HWCryptoHook_ContextHandle hwcrhk_context = 0; 403static HWCryptoHook_ContextHandle hwcrhk_context = 0;
324static int hndidx = -1; /* Index for KM handle. Not really used yet. */ 404#ifndef OPENSSL_NO_RSA
405static int hndidx_rsa = -1; /* Index for KM handle. Not really used yet. */
406#endif
325 407
326/* These are the function pointers that are (un)set when the library has 408/* These are the function pointers that are (un)set when the library has
327 * successfully (un)loaded. */ 409 * successfully (un)loaded. */
328static HWCryptoHook_Init_t *p_hwcrhk_Init = NULL; 410static HWCryptoHook_Init_t *p_hwcrhk_Init = NULL;
329static HWCryptoHook_Finish_t *p_hwcrhk_Finish = NULL; 411static HWCryptoHook_Finish_t *p_hwcrhk_Finish = NULL;
330static HWCryptoHook_ModExp_t *p_hwcrhk_ModExp = NULL; 412static HWCryptoHook_ModExp_t *p_hwcrhk_ModExp = NULL;
413#ifndef OPENSSL_NO_RSA
331static HWCryptoHook_RSA_t *p_hwcrhk_RSA = NULL; 414static HWCryptoHook_RSA_t *p_hwcrhk_RSA = NULL;
415#endif
332static HWCryptoHook_RandomBytes_t *p_hwcrhk_RandomBytes = NULL; 416static HWCryptoHook_RandomBytes_t *p_hwcrhk_RandomBytes = NULL;
417#ifndef OPENSSL_NO_RSA
333static HWCryptoHook_RSALoadKey_t *p_hwcrhk_RSALoadKey = NULL; 418static HWCryptoHook_RSALoadKey_t *p_hwcrhk_RSALoadKey = NULL;
334static HWCryptoHook_RSAGetPublicKey_t *p_hwcrhk_RSAGetPublicKey = NULL; 419static HWCryptoHook_RSAGetPublicKey_t *p_hwcrhk_RSAGetPublicKey = NULL;
335static HWCryptoHook_RSAUnloadKey_t *p_hwcrhk_RSAUnloadKey = NULL; 420static HWCryptoHook_RSAUnloadKey_t *p_hwcrhk_RSAUnloadKey = NULL;
421#endif
336static HWCryptoHook_ModExpCRT_t *p_hwcrhk_ModExpCRT = NULL; 422static HWCryptoHook_ModExpCRT_t *p_hwcrhk_ModExpCRT = NULL;
337 423
338/* Used in the DSO operations. */ 424/* Used in the DSO operations. */
339static const char *HWCRHK_LIBNAME = "nfhwcrhk"; 425static const char def_HWCRHK_LIBNAME[] = "nfhwcrhk";
426static const char *HWCRHK_LIBNAME = def_HWCRHK_LIBNAME;
340static const char *n_hwcrhk_Init = "HWCryptoHook_Init"; 427static const char *n_hwcrhk_Init = "HWCryptoHook_Init";
341static const char *n_hwcrhk_Finish = "HWCryptoHook_Finish"; 428static const char *n_hwcrhk_Finish = "HWCryptoHook_Finish";
342static const char *n_hwcrhk_ModExp = "HWCryptoHook_ModExp"; 429static const char *n_hwcrhk_ModExp = "HWCryptoHook_ModExp";
430#ifndef OPENSSL_NO_RSA
343static const char *n_hwcrhk_RSA = "HWCryptoHook_RSA"; 431static const char *n_hwcrhk_RSA = "HWCryptoHook_RSA";
432#endif
344static const char *n_hwcrhk_RandomBytes = "HWCryptoHook_RandomBytes"; 433static const char *n_hwcrhk_RandomBytes = "HWCryptoHook_RandomBytes";
434#ifndef OPENSSL_NO_RSA
345static const char *n_hwcrhk_RSALoadKey = "HWCryptoHook_RSALoadKey"; 435static const char *n_hwcrhk_RSALoadKey = "HWCryptoHook_RSALoadKey";
346static const char *n_hwcrhk_RSAGetPublicKey = "HWCryptoHook_RSAGetPublicKey"; 436static const char *n_hwcrhk_RSAGetPublicKey = "HWCryptoHook_RSAGetPublicKey";
347static const char *n_hwcrhk_RSAUnloadKey = "HWCryptoHook_RSAUnloadKey"; 437static const char *n_hwcrhk_RSAUnloadKey = "HWCryptoHook_RSAUnloadKey";
438#endif
348static const char *n_hwcrhk_ModExpCRT = "HWCryptoHook_ModExpCRT"; 439static const char *n_hwcrhk_ModExpCRT = "HWCryptoHook_ModExpCRT";
349 440
350/* HWCryptoHook library functions and mechanics - these are used by the 441/* HWCryptoHook library functions and mechanics - these are used by the
@@ -353,16 +444,17 @@ static const char *n_hwcrhk_ModExpCRT = "HWCryptoHook_ModExpCRT";
353 * called, the checking and error handling is probably down there. */ 444 * called, the checking and error handling is probably down there. */
354 445
355/* utility function to obtain a context */ 446/* utility function to obtain a context */
356static int get_context(HWCryptoHook_ContextHandle *hac) 447static int get_context(HWCryptoHook_ContextHandle *hac,
448 HWCryptoHook_CallerContext *cac)
357 { 449 {
358 char tempbuf[1024]; 450 char tempbuf[1024];
359 HWCryptoHook_ErrMsgBuf rmsg; 451 HWCryptoHook_ErrMsgBuf rmsg;
360 452
361 rmsg.buf = tempbuf; 453 rmsg.buf = tempbuf;
362 rmsg.size = 1024; 454 rmsg.size = sizeof(tempbuf);
363 455
364 *hac = p_hwcrhk_Init(&hwcrhk_globals, sizeof(hwcrhk_globals), &rmsg, 456 *hac = p_hwcrhk_Init(&hwcrhk_globals, sizeof(hwcrhk_globals), &rmsg,
365 NULL); 457 cac);
366 if (!*hac) 458 if (!*hac)
367 return 0; 459 return 0;
368 return 1; 460 return 1;
@@ -374,30 +466,38 @@ static void release_context(HWCryptoHook_ContextHandle hac)
374 p_hwcrhk_Finish(hac); 466 p_hwcrhk_Finish(hac);
375 } 467 }
376 468
469/* Destructor (complements the "ENGINE_ncipher()" constructor) */
470static int hwcrhk_destroy(ENGINE *e)
471 {
472 ERR_unload_HWCRHK_strings();
473 return 1;
474 }
475
377/* (de)initialisation functions. */ 476/* (de)initialisation functions. */
378static int hwcrhk_init() 477static int hwcrhk_init(ENGINE *e)
379 { 478 {
380 HWCryptoHook_Init_t *p1; 479 HWCryptoHook_Init_t *p1;
381 HWCryptoHook_Finish_t *p2; 480 HWCryptoHook_Finish_t *p2;
382 HWCryptoHook_ModExp_t *p3; 481 HWCryptoHook_ModExp_t *p3;
482#ifndef OPENSSL_NO_RSA
383 HWCryptoHook_RSA_t *p4; 483 HWCryptoHook_RSA_t *p4;
384 HWCryptoHook_RSALoadKey_t *p5; 484 HWCryptoHook_RSALoadKey_t *p5;
385 HWCryptoHook_RSAGetPublicKey_t *p6; 485 HWCryptoHook_RSAGetPublicKey_t *p6;
386 HWCryptoHook_RSAUnloadKey_t *p7; 486 HWCryptoHook_RSAUnloadKey_t *p7;
487#endif
387 HWCryptoHook_RandomBytes_t *p8; 488 HWCryptoHook_RandomBytes_t *p8;
388 HWCryptoHook_ModExpCRT_t *p9; 489 HWCryptoHook_ModExpCRT_t *p9;
389 490
390 if(hwcrhk_dso != NULL) 491 if(hwcrhk_dso != NULL)
391 { 492 {
392 ENGINEerr(ENGINE_F_HWCRHK_INIT,ENGINE_R_ALREADY_LOADED); 493 HWCRHKerr(HWCRHK_F_HWCRHK_INIT,HWCRHK_R_ALREADY_LOADED);
393 goto err; 494 goto err;
394 } 495 }
395 /* Attempt to load libnfhwcrhk.so/nfhwcrhk.dll/whatever. */ 496 /* Attempt to load libnfhwcrhk.so/nfhwcrhk.dll/whatever. */
396 hwcrhk_dso = DSO_load(NULL, HWCRHK_LIBNAME, NULL, 497 hwcrhk_dso = DSO_load(NULL, HWCRHK_LIBNAME, NULL, 0);
397 DSO_FLAG_NAME_TRANSLATION);
398 if(hwcrhk_dso == NULL) 498 if(hwcrhk_dso == NULL)
399 { 499 {
400 ENGINEerr(ENGINE_F_HWCRHK_INIT,ENGINE_R_DSO_FAILURE); 500 HWCRHKerr(HWCRHK_F_HWCRHK_INIT,HWCRHK_R_DSO_FAILURE);
401 goto err; 501 goto err;
402 } 502 }
403 if(!(p1 = (HWCryptoHook_Init_t *) 503 if(!(p1 = (HWCryptoHook_Init_t *)
@@ -406,6 +506,7 @@ static int hwcrhk_init()
406 DSO_bind_func(hwcrhk_dso, n_hwcrhk_Finish)) || 506 DSO_bind_func(hwcrhk_dso, n_hwcrhk_Finish)) ||
407 !(p3 = (HWCryptoHook_ModExp_t *) 507 !(p3 = (HWCryptoHook_ModExp_t *)
408 DSO_bind_func(hwcrhk_dso, n_hwcrhk_ModExp)) || 508 DSO_bind_func(hwcrhk_dso, n_hwcrhk_ModExp)) ||
509#ifndef OPENSSL_NO_RSA
409 !(p4 = (HWCryptoHook_RSA_t *) 510 !(p4 = (HWCryptoHook_RSA_t *)
410 DSO_bind_func(hwcrhk_dso, n_hwcrhk_RSA)) || 511 DSO_bind_func(hwcrhk_dso, n_hwcrhk_RSA)) ||
411 !(p5 = (HWCryptoHook_RSALoadKey_t *) 512 !(p5 = (HWCryptoHook_RSALoadKey_t *)
@@ -414,22 +515,25 @@ static int hwcrhk_init()
414 DSO_bind_func(hwcrhk_dso, n_hwcrhk_RSAGetPublicKey)) || 515 DSO_bind_func(hwcrhk_dso, n_hwcrhk_RSAGetPublicKey)) ||
415 !(p7 = (HWCryptoHook_RSAUnloadKey_t *) 516 !(p7 = (HWCryptoHook_RSAUnloadKey_t *)
416 DSO_bind_func(hwcrhk_dso, n_hwcrhk_RSAUnloadKey)) || 517 DSO_bind_func(hwcrhk_dso, n_hwcrhk_RSAUnloadKey)) ||
518#endif
417 !(p8 = (HWCryptoHook_RandomBytes_t *) 519 !(p8 = (HWCryptoHook_RandomBytes_t *)
418 DSO_bind_func(hwcrhk_dso, n_hwcrhk_RandomBytes)) || 520 DSO_bind_func(hwcrhk_dso, n_hwcrhk_RandomBytes)) ||
419 !(p9 = (HWCryptoHook_ModExpCRT_t *) 521 !(p9 = (HWCryptoHook_ModExpCRT_t *)
420 DSO_bind_func(hwcrhk_dso, n_hwcrhk_ModExpCRT))) 522 DSO_bind_func(hwcrhk_dso, n_hwcrhk_ModExpCRT)))
421 { 523 {
422 ENGINEerr(ENGINE_F_HWCRHK_INIT,ENGINE_R_DSO_FAILURE); 524 HWCRHKerr(HWCRHK_F_HWCRHK_INIT,HWCRHK_R_DSO_FAILURE);
423 goto err; 525 goto err;
424 } 526 }
425 /* Copy the pointers */ 527 /* Copy the pointers */
426 p_hwcrhk_Init = p1; 528 p_hwcrhk_Init = p1;
427 p_hwcrhk_Finish = p2; 529 p_hwcrhk_Finish = p2;
428 p_hwcrhk_ModExp = p3; 530 p_hwcrhk_ModExp = p3;
531#ifndef OPENSSL_NO_RSA
429 p_hwcrhk_RSA = p4; 532 p_hwcrhk_RSA = p4;
430 p_hwcrhk_RSALoadKey = p5; 533 p_hwcrhk_RSALoadKey = p5;
431 p_hwcrhk_RSAGetPublicKey = p6; 534 p_hwcrhk_RSAGetPublicKey = p6;
432 p_hwcrhk_RSAUnloadKey = p7; 535 p_hwcrhk_RSAUnloadKey = p7;
536#endif
433 p_hwcrhk_RandomBytes = p8; 537 p_hwcrhk_RandomBytes = p8;
434 p_hwcrhk_ModExpCRT = p9; 538 p_hwcrhk_ModExpCRT = p9;
435 539
@@ -448,16 +552,18 @@ static int hwcrhk_init()
448 552
449 /* Try and get a context - if not, we may have a DSO but no 553 /* Try and get a context - if not, we may have a DSO but no
450 * accelerator! */ 554 * accelerator! */
451 if(!get_context(&hwcrhk_context)) 555 if(!get_context(&hwcrhk_context, &password_context))
452 { 556 {
453 ENGINEerr(ENGINE_F_HWCRHK_INIT,ENGINE_R_UNIT_FAILURE); 557 HWCRHKerr(HWCRHK_F_HWCRHK_INIT,HWCRHK_R_UNIT_FAILURE);
454 goto err; 558 goto err;
455 } 559 }
456 /* Everything's fine. */ 560 /* Everything's fine. */
457 if (hndidx == -1) 561#ifndef OPENSSL_NO_RSA
458 hndidx = RSA_get_ex_new_index(0, 562 if (hndidx_rsa == -1)
563 hndidx_rsa = RSA_get_ex_new_index(0,
459 "nFast HWCryptoHook RSA key handle", 564 "nFast HWCryptoHook RSA key handle",
460 NULL, NULL, hwcrhk_ex_free); 565 NULL, NULL, hwcrhk_ex_free);
566#endif
461 return 1; 567 return 1;
462err: 568err:
463 if(hwcrhk_dso) 569 if(hwcrhk_dso)
@@ -466,28 +572,30 @@ err:
466 p_hwcrhk_Init = NULL; 572 p_hwcrhk_Init = NULL;
467 p_hwcrhk_Finish = NULL; 573 p_hwcrhk_Finish = NULL;
468 p_hwcrhk_ModExp = NULL; 574 p_hwcrhk_ModExp = NULL;
575#ifndef OPENSSL_NO_RSA
469 p_hwcrhk_RSA = NULL; 576 p_hwcrhk_RSA = NULL;
470 p_hwcrhk_RSALoadKey = NULL; 577 p_hwcrhk_RSALoadKey = NULL;
471 p_hwcrhk_RSAGetPublicKey = NULL; 578 p_hwcrhk_RSAGetPublicKey = NULL;
472 p_hwcrhk_RSAUnloadKey = NULL; 579 p_hwcrhk_RSAUnloadKey = NULL;
580#endif
473 p_hwcrhk_ModExpCRT = NULL; 581 p_hwcrhk_ModExpCRT = NULL;
474 p_hwcrhk_RandomBytes = NULL; 582 p_hwcrhk_RandomBytes = NULL;
475 return 0; 583 return 0;
476 } 584 }
477 585
478static int hwcrhk_finish() 586static int hwcrhk_finish(ENGINE *e)
479 { 587 {
480 int to_return = 1; 588 int to_return = 1;
481 if(hwcrhk_dso == NULL) 589 if(hwcrhk_dso == NULL)
482 { 590 {
483 ENGINEerr(ENGINE_F_HWCRHK_FINISH,ENGINE_R_NOT_LOADED); 591 HWCRHKerr(HWCRHK_F_HWCRHK_FINISH,HWCRHK_R_NOT_LOADED);
484 to_return = 0; 592 to_return = 0;
485 goto err; 593 goto err;
486 } 594 }
487 release_context(hwcrhk_context); 595 release_context(hwcrhk_context);
488 if(!DSO_free(hwcrhk_dso)) 596 if(!DSO_free(hwcrhk_dso))
489 { 597 {
490 ENGINEerr(ENGINE_F_HWCRHK_FINISH,ENGINE_R_DSO_FAILURE); 598 HWCRHKerr(HWCRHK_F_HWCRHK_FINISH,HWCRHK_R_DSO_FAILURE);
491 to_return = 0; 599 to_return = 0;
492 goto err; 600 goto err;
493 } 601 }
@@ -498,21 +606,36 @@ static int hwcrhk_finish()
498 p_hwcrhk_Init = NULL; 606 p_hwcrhk_Init = NULL;
499 p_hwcrhk_Finish = NULL; 607 p_hwcrhk_Finish = NULL;
500 p_hwcrhk_ModExp = NULL; 608 p_hwcrhk_ModExp = NULL;
609#ifndef OPENSSL_NO_RSA
501 p_hwcrhk_RSA = NULL; 610 p_hwcrhk_RSA = NULL;
502 p_hwcrhk_RSALoadKey = NULL; 611 p_hwcrhk_RSALoadKey = NULL;
503 p_hwcrhk_RSAGetPublicKey = NULL; 612 p_hwcrhk_RSAGetPublicKey = NULL;
504 p_hwcrhk_RSAUnloadKey = NULL; 613 p_hwcrhk_RSAUnloadKey = NULL;
614#endif
505 p_hwcrhk_ModExpCRT = NULL; 615 p_hwcrhk_ModExpCRT = NULL;
506 p_hwcrhk_RandomBytes = NULL; 616 p_hwcrhk_RandomBytes = NULL;
507 return to_return; 617 return to_return;
508 } 618 }
509 619
510static int hwcrhk_ctrl(int cmd, long i, void *p, void (*f)()) 620static int hwcrhk_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
511 { 621 {
512 int to_return = 1; 622 int to_return = 1;
513 623
514 switch(cmd) 624 switch(cmd)
515 { 625 {
626 case HWCRHK_CMD_SO_PATH:
627 if(hwcrhk_dso)
628 {
629 HWCRHKerr(HWCRHK_F_HWCRHK_CTRL,HWCRHK_R_ALREADY_LOADED);
630 return 0;
631 }
632 if(p == NULL)
633 {
634 HWCRHKerr(HWCRHK_F_HWCRHK_CTRL,ERR_R_PASSED_NULL_PARAMETER);
635 return 0;
636 }
637 HWCRHK_LIBNAME = (const char *)p;
638 return 1;
516 case ENGINE_CTRL_SET_LOGSTREAM: 639 case ENGINE_CTRL_SET_LOGSTREAM:
517 { 640 {
518 BIO *bio = (BIO *)p; 641 BIO *bio = (BIO *)p;
@@ -526,18 +649,31 @@ static int hwcrhk_ctrl(int cmd, long i, void *p, void (*f)())
526 if (CRYPTO_add(&bio->references,1,CRYPTO_LOCK_BIO) > 1) 649 if (CRYPTO_add(&bio->references,1,CRYPTO_LOCK_BIO) > 1)
527 logstream = bio; 650 logstream = bio;
528 else 651 else
529 ENGINEerr(ENGINE_F_HWCRHK_CTRL,ENGINE_R_BIO_WAS_FREED); 652 HWCRHKerr(HWCRHK_F_HWCRHK_CTRL,HWCRHK_R_BIO_WAS_FREED);
530 } 653 }
531 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); 654 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
532 break; 655 break;
533 case ENGINE_CTRL_SET_PASSWORD_CALLBACK: 656 case ENGINE_CTRL_SET_PASSWORD_CALLBACK:
534 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); 657 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
535 password_callback = (pem_password_cb *)f; 658 password_context.password_callback = (pem_password_cb *)f;
659 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
660 break;
661 case ENGINE_CTRL_SET_USER_INTERFACE:
662 case HWCRHK_CMD_SET_USER_INTERFACE:
663 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
664 password_context.ui_method = (UI_METHOD *)p;
665 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
666 break;
667 case ENGINE_CTRL_SET_CALLBACK_DATA:
668 case HWCRHK_CMD_SET_CALLBACK_DATA:
669 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
670 password_context.callback_data = p;
536 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); 671 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
537 break; 672 break;
538 /* this enables or disables the "SimpleForkCheck" flag used in the 673 /* this enables or disables the "SimpleForkCheck" flag used in the
539 * initialisation structure. */ 674 * initialisation structure. */
540 case ENGINE_CTRL_CHIL_SET_FORKCHECK: 675 case ENGINE_CTRL_CHIL_SET_FORKCHECK:
676 case HWCRHK_CMD_FORK_CHECK:
541 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); 677 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
542 if(i) 678 if(i)
543 hwcrhk_globals.flags |= 679 hwcrhk_globals.flags |=
@@ -557,11 +693,16 @@ static int hwcrhk_ctrl(int cmd, long i, void *p, void (*f)())
557 disable_mutex_callbacks = 1; 693 disable_mutex_callbacks = 1;
558 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); 694 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
559 break; 695 break;
696 case HWCRHK_CMD_THREAD_LOCKING:
697 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
698 disable_mutex_callbacks = ((i == 0) ? 0 : 1);
699 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
700 break;
560 701
561 /* The command isn't understood by this engine */ 702 /* The command isn't understood by this engine */
562 default: 703 default:
563 ENGINEerr(ENGINE_F_HWCRHK_CTRL, 704 HWCRHKerr(HWCRHK_F_HWCRHK_CTRL,
564 ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED); 705 HWCRHK_R_CTRL_COMMAND_NOT_IMPLEMENTED);
565 to_return = 0; 706 to_return = 0;
566 break; 707 break;
567 } 708 }
@@ -569,44 +710,62 @@ static int hwcrhk_ctrl(int cmd, long i, void *p, void (*f)())
569 return to_return; 710 return to_return;
570 } 711 }
571 712
572static EVP_PKEY *hwcrhk_load_privkey(const char *key_id, 713static EVP_PKEY *hwcrhk_load_privkey(ENGINE *eng, const char *key_id,
573 const char *passphrase) 714 UI_METHOD *ui_method, void *callback_data)
574 { 715 {
716#ifndef OPENSSL_NO_RSA
575 RSA *rtmp = NULL; 717 RSA *rtmp = NULL;
718#endif
576 EVP_PKEY *res = NULL; 719 EVP_PKEY *res = NULL;
720#ifndef OPENSSL_NO_RSA
577 HWCryptoHook_MPI e, n; 721 HWCryptoHook_MPI e, n;
578 HWCryptoHook_RSAKeyHandle *hptr; 722 HWCryptoHook_RSAKeyHandle *hptr;
723#endif
724#if !defined(OPENSSL_NO_RSA)
725 char tempbuf[1024];
579 HWCryptoHook_ErrMsgBuf rmsg; 726 HWCryptoHook_ErrMsgBuf rmsg;
727#endif
728 HWCryptoHook_PassphraseContext ppctx;
729
730#if !defined(OPENSSL_NO_RSA)
731 rmsg.buf = tempbuf;
732 rmsg.size = sizeof(tempbuf);
733#endif
580 734
581 if(!hwcrhk_context) 735 if(!hwcrhk_context)
582 { 736 {
583 ENGINEerr(ENGINE_F_HWCRHK_LOAD_PRIVKEY, 737 HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PRIVKEY,
584 ENGINE_R_NOT_INITIALISED); 738 HWCRHK_R_NOT_INITIALISED);
585 goto err; 739 goto err;
586 } 740 }
741#ifndef OPENSSL_NO_RSA
587 hptr = OPENSSL_malloc(sizeof(HWCryptoHook_RSAKeyHandle)); 742 hptr = OPENSSL_malloc(sizeof(HWCryptoHook_RSAKeyHandle));
588 if (!hptr) 743 if (!hptr)
589 { 744 {
590 ENGINEerr(ENGINE_F_HWCRHK_LOAD_PRIVKEY, 745 HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PRIVKEY,
591 ERR_R_MALLOC_FAILURE); 746 ERR_R_MALLOC_FAILURE);
592 goto err; 747 goto err;
593 } 748 }
749 ppctx.ui_method = ui_method;
750 ppctx.callback_data = callback_data;
594 if (p_hwcrhk_RSALoadKey(hwcrhk_context, key_id, hptr, 751 if (p_hwcrhk_RSALoadKey(hwcrhk_context, key_id, hptr,
595 &rmsg, NULL)) 752 &rmsg, &ppctx))
596 { 753 {
597 ENGINEerr(ENGINE_F_HWCRHK_LOAD_PRIVKEY, 754 HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PRIVKEY,
598 ENGINE_R_CHIL_ERROR); 755 HWCRHK_R_CHIL_ERROR);
599 ERR_add_error_data(1,rmsg.buf); 756 ERR_add_error_data(1,rmsg.buf);
600 goto err; 757 goto err;
601 } 758 }
602 if (!*hptr) 759 if (!*hptr)
603 { 760 {
604 ENGINEerr(ENGINE_F_HWCRHK_LOAD_PRIVKEY, 761 HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PRIVKEY,
605 ENGINE_R_NO_KEY); 762 HWCRHK_R_NO_KEY);
606 goto err; 763 goto err;
607 } 764 }
608 rtmp = RSA_new_method(&engine_hwcrhk); 765#endif
609 RSA_set_ex_data(rtmp, hndidx, (char *)hptr); 766#ifndef OPENSSL_NO_RSA
767 rtmp = RSA_new_method(eng);
768 RSA_set_ex_data(rtmp, hndidx_rsa, (char *)hptr);
610 rtmp->e = BN_new(); 769 rtmp->e = BN_new();
611 rtmp->n = BN_new(); 770 rtmp->n = BN_new();
612 rtmp->flags |= RSA_FLAG_EXT_PKEY; 771 rtmp->flags |= RSA_FLAG_EXT_PKEY;
@@ -615,11 +774,11 @@ static EVP_PKEY *hwcrhk_load_privkey(const char *key_id,
615 if (p_hwcrhk_RSAGetPublicKey(*hptr, &n, &e, &rmsg) 774 if (p_hwcrhk_RSAGetPublicKey(*hptr, &n, &e, &rmsg)
616 != HWCRYPTOHOOK_ERROR_MPISIZE) 775 != HWCRYPTOHOOK_ERROR_MPISIZE)
617 { 776 {
618 ENGINEerr(ENGINE_F_HWCRHK_LOAD_PUBKEY,ENGINE_R_CHIL_ERROR); 777 HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PUBKEY,HWCRHK_R_CHIL_ERROR);
619 ERR_add_error_data(1,rmsg.buf); 778 ERR_add_error_data(1,rmsg.buf);
620 goto err; 779 goto err;
621 } 780 }
622 781
623 bn_expand2(rtmp->e, e.size/sizeof(BN_ULONG)); 782 bn_expand2(rtmp->e, e.size/sizeof(BN_ULONG));
624 bn_expand2(rtmp->n, n.size/sizeof(BN_ULONG)); 783 bn_expand2(rtmp->n, n.size/sizeof(BN_ULONG));
625 MPI2BN(rtmp->e, e); 784 MPI2BN(rtmp->e, e);
@@ -627,8 +786,8 @@ static EVP_PKEY *hwcrhk_load_privkey(const char *key_id,
627 786
628 if (p_hwcrhk_RSAGetPublicKey(*hptr, &n, &e, &rmsg)) 787 if (p_hwcrhk_RSAGetPublicKey(*hptr, &n, &e, &rmsg))
629 { 788 {
630 ENGINEerr(ENGINE_F_HWCRHK_LOAD_PUBKEY, 789 HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PUBKEY,
631 ENGINE_R_CHIL_ERROR); 790 HWCRHK_R_CHIL_ERROR);
632 ERR_add_error_data(1,rmsg.buf); 791 ERR_add_error_data(1,rmsg.buf);
633 goto err; 792 goto err;
634 } 793 }
@@ -639,23 +798,37 @@ static EVP_PKEY *hwcrhk_load_privkey(const char *key_id,
639 798
640 res = EVP_PKEY_new(); 799 res = EVP_PKEY_new();
641 EVP_PKEY_assign_RSA(res, rtmp); 800 EVP_PKEY_assign_RSA(res, rtmp);
801#endif
802
803 if (!res)
804 HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PUBKEY,
805 HWCRHK_R_PRIVATE_KEY_ALGORITHMS_DISABLED);
642 806
643 return res; 807 return res;
644 err: 808 err:
645 if (res) 809 if (res)
646 EVP_PKEY_free(res); 810 EVP_PKEY_free(res);
811#ifndef OPENSSL_NO_RSA
647 if (rtmp) 812 if (rtmp)
648 RSA_free(rtmp); 813 RSA_free(rtmp);
814#endif
649 return NULL; 815 return NULL;
650 } 816 }
651 817
652static EVP_PKEY *hwcrhk_load_pubkey(const char *key_id, const char *passphrase) 818static EVP_PKEY *hwcrhk_load_pubkey(ENGINE *eng, const char *key_id,
819 UI_METHOD *ui_method, void *callback_data)
653 { 820 {
654 EVP_PKEY *res = hwcrhk_load_privkey(key_id, passphrase); 821 EVP_PKEY *res = NULL;
822
823#ifndef OPENSSL_NO_RSA
824 res = hwcrhk_load_privkey(eng, key_id,
825 ui_method, callback_data);
826#endif
655 827
656 if (res) 828 if (res)
657 switch(res->type) 829 switch(res->type)
658 { 830 {
831#ifndef OPENSSL_NO_RSA
659 case EVP_PKEY_RSA: 832 case EVP_PKEY_RSA:
660 { 833 {
661 RSA *rsa = NULL; 834 RSA *rsa = NULL;
@@ -665,12 +838,16 @@ static EVP_PKEY *hwcrhk_load_pubkey(const char *key_id, const char *passphrase)
665 res->pkey.rsa = RSA_new(); 838 res->pkey.rsa = RSA_new();
666 res->pkey.rsa->n = rsa->n; 839 res->pkey.rsa->n = rsa->n;
667 res->pkey.rsa->e = rsa->e; 840 res->pkey.rsa->e = rsa->e;
841 rsa->n = NULL;
842 rsa->e = NULL;
668 CRYPTO_w_unlock(CRYPTO_LOCK_EVP_PKEY); 843 CRYPTO_w_unlock(CRYPTO_LOCK_EVP_PKEY);
669 RSA_free(rsa); 844 RSA_free(rsa);
670 } 845 }
846 break;
847#endif
671 default: 848 default:
672 ENGINEerr(ENGINE_F_HWCRHK_LOAD_PUBKEY, 849 HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PUBKEY,
673 ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED); 850 HWCRHK_R_CTRL_COMMAND_NOT_IMPLEMENTED);
674 goto err; 851 goto err;
675 } 852 }
676 853
@@ -682,7 +859,7 @@ static EVP_PKEY *hwcrhk_load_pubkey(const char *key_id, const char *passphrase)
682 } 859 }
683 860
684/* A little mod_exp */ 861/* A little mod_exp */
685static int hwcrhk_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p, 862static int hwcrhk_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
686 const BIGNUM *m, BN_CTX *ctx) 863 const BIGNUM *m, BN_CTX *ctx)
687 { 864 {
688 char tempbuf[1024]; 865 char tempbuf[1024];
@@ -695,11 +872,11 @@ static int hwcrhk_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
695 872
696 to_return = 0; /* expect failure */ 873 to_return = 0; /* expect failure */
697 rmsg.buf = tempbuf; 874 rmsg.buf = tempbuf;
698 rmsg.size = 1024; 875 rmsg.size = sizeof(tempbuf);
699 876
700 if(!hwcrhk_context) 877 if(!hwcrhk_context)
701 { 878 {
702 ENGINEerr(ENGINE_F_HWCRHK_MOD_EXP,ENGINE_R_NOT_INITIALISED); 879 HWCRHKerr(HWCRHK_F_HWCRHK_MOD_EXP,HWCRHK_R_NOT_INITIALISED);
703 goto err; 880 goto err;
704 } 881 }
705 /* Prepare the params */ 882 /* Prepare the params */
@@ -723,11 +900,11 @@ static int hwcrhk_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
723 might be a good thing. */ 900 might be a good thing. */
724 if(ret == HWCRYPTOHOOK_ERROR_FALLBACK) 901 if(ret == HWCRYPTOHOOK_ERROR_FALLBACK)
725 { 902 {
726 ENGINEerr(ENGINE_F_HWCRHK_MOD_EXP,ENGINE_R_REQUEST_FALLBACK); 903 HWCRHKerr(HWCRHK_F_HWCRHK_MOD_EXP,HWCRHK_R_REQUEST_FALLBACK);
727 } 904 }
728 else 905 else
729 { 906 {
730 ENGINEerr(ENGINE_F_HWCRHK_MOD_EXP,ENGINE_R_REQUEST_FAILED); 907 HWCRHKerr(HWCRHK_F_HWCRHK_MOD_EXP,HWCRHK_R_REQUEST_FAILED);
731 } 908 }
732 ERR_add_error_data(1,rmsg.buf); 909 ERR_add_error_data(1,rmsg.buf);
733 goto err; 910 goto err;
@@ -737,38 +914,39 @@ static int hwcrhk_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
737err: 914err:
738 return to_return; 915 return to_return;
739 } 916 }
740 917
741static int hwcrhk_rsa_mod_exp(BIGNUM *r, BIGNUM *I, RSA *rsa) 918#ifndef OPENSSL_NO_RSA
919static int hwcrhk_rsa_mod_exp(BIGNUM *r, const BIGNUM *I, RSA *rsa)
742 { 920 {
743 char tempbuf[1024]; 921 char tempbuf[1024];
744 HWCryptoHook_ErrMsgBuf rmsg; 922 HWCryptoHook_ErrMsgBuf rmsg;
745 HWCryptoHook_RSAKeyHandle *hptr; 923 HWCryptoHook_RSAKeyHandle *hptr;
746 int to_return = 0, ret; 924 int to_return = 0, ret;
747 925
926 rmsg.buf = tempbuf;
927 rmsg.size = sizeof(tempbuf);
928
748 if(!hwcrhk_context) 929 if(!hwcrhk_context)
749 { 930 {
750 ENGINEerr(ENGINE_F_HWCRHK_MOD_EXP,ENGINE_R_NOT_INITIALISED); 931 HWCRHKerr(HWCRHK_F_HWCRHK_MOD_EXP,HWCRHK_R_NOT_INITIALISED);
751 goto err; 932 goto err;
752 } 933 }
753 934
754 /* This provides support for nForce keys. Since that's opaque data 935 /* This provides support for nForce keys. Since that's opaque data
755 all we do is provide a handle to the proper key and let HWCryptoHook 936 all we do is provide a handle to the proper key and let HWCryptoHook
756 take care of the rest. */ 937 take care of the rest. */
757 if ((hptr = (HWCryptoHook_RSAKeyHandle *) RSA_get_ex_data(rsa, hndidx)) 938 if ((hptr = (HWCryptoHook_RSAKeyHandle *) RSA_get_ex_data(rsa, hndidx_rsa))
758 != NULL) 939 != NULL)
759 { 940 {
760 HWCryptoHook_MPI m_a, m_r; 941 HWCryptoHook_MPI m_a, m_r;
761 942
762 if(!rsa->n) 943 if(!rsa->n)
763 { 944 {
764 ENGINEerr(ENGINE_F_HWCRHK_RSA_MOD_EXP, 945 HWCRHKerr(HWCRHK_F_HWCRHK_RSA_MOD_EXP,
765 ENGINE_R_MISSING_KEY_COMPONENTS); 946 HWCRHK_R_MISSING_KEY_COMPONENTS);
766 goto err; 947 goto err;
767 } 948 }
768 949
769 rmsg.buf = tempbuf;
770 rmsg.size = 1024;
771
772 /* Prepare the params */ 950 /* Prepare the params */
773 bn_expand2(r, rsa->n->top); /* Check for error !! */ 951 bn_expand2(r, rsa->n->top); /* Check for error !! */
774 BN2MPI(m_a, I); 952 BN2MPI(m_a, I);
@@ -788,11 +966,13 @@ static int hwcrhk_rsa_mod_exp(BIGNUM *r, BIGNUM *I, RSA *rsa)
788 might be a good thing. */ 966 might be a good thing. */
789 if(ret == HWCRYPTOHOOK_ERROR_FALLBACK) 967 if(ret == HWCRYPTOHOOK_ERROR_FALLBACK)
790 { 968 {
791 ENGINEerr(ENGINE_F_HWCRHK_RSA_MOD_EXP,ENGINE_R_REQUEST_FALLBACK); 969 HWCRHKerr(HWCRHK_F_HWCRHK_RSA_MOD_EXP,
970 HWCRHK_R_REQUEST_FALLBACK);
792 } 971 }
793 else 972 else
794 { 973 {
795 ENGINEerr(ENGINE_F_HWCRHK_RSA_MOD_EXP,ENGINE_R_REQUEST_FAILED); 974 HWCRHKerr(HWCRHK_F_HWCRHK_RSA_MOD_EXP,
975 HWCRHK_R_REQUEST_FAILED);
796 } 976 }
797 ERR_add_error_data(1,rmsg.buf); 977 ERR_add_error_data(1,rmsg.buf);
798 goto err; 978 goto err;
@@ -804,14 +984,11 @@ static int hwcrhk_rsa_mod_exp(BIGNUM *r, BIGNUM *I, RSA *rsa)
804 984
805 if(!rsa->p || !rsa->q || !rsa->dmp1 || !rsa->dmq1 || !rsa->iqmp) 985 if(!rsa->p || !rsa->q || !rsa->dmp1 || !rsa->dmq1 || !rsa->iqmp)
806 { 986 {
807 ENGINEerr(ENGINE_F_HWCRHK_RSA_MOD_EXP, 987 HWCRHKerr(HWCRHK_F_HWCRHK_RSA_MOD_EXP,
808 ENGINE_R_MISSING_KEY_COMPONENTS); 988 HWCRHK_R_MISSING_KEY_COMPONENTS);
809 goto err; 989 goto err;
810 } 990 }
811 991
812 rmsg.buf = tempbuf;
813 rmsg.size = 1024;
814
815 /* Prepare the params */ 992 /* Prepare the params */
816 bn_expand2(r, rsa->n->top); /* Check for error !! */ 993 bn_expand2(r, rsa->n->top); /* Check for error !! */
817 BN2MPI(m_a, I); 994 BN2MPI(m_a, I);
@@ -837,11 +1014,13 @@ static int hwcrhk_rsa_mod_exp(BIGNUM *r, BIGNUM *I, RSA *rsa)
837 might be a good thing. */ 1014 might be a good thing. */
838 if(ret == HWCRYPTOHOOK_ERROR_FALLBACK) 1015 if(ret == HWCRYPTOHOOK_ERROR_FALLBACK)
839 { 1016 {
840 ENGINEerr(ENGINE_F_HWCRHK_RSA_MOD_EXP,ENGINE_R_REQUEST_FALLBACK); 1017 HWCRHKerr(HWCRHK_F_HWCRHK_RSA_MOD_EXP,
1018 HWCRHK_R_REQUEST_FALLBACK);
841 } 1019 }
842 else 1020 else
843 { 1021 {
844 ENGINEerr(ENGINE_F_HWCRHK_RSA_MOD_EXP,ENGINE_R_REQUEST_FAILED); 1022 HWCRHKerr(HWCRHK_F_HWCRHK_RSA_MOD_EXP,
1023 HWCRHK_R_REQUEST_FAILED);
845 } 1024 }
846 ERR_add_error_data(1,rmsg.buf); 1025 ERR_add_error_data(1,rmsg.buf);
847 goto err; 1026 goto err;
@@ -852,16 +1031,18 @@ static int hwcrhk_rsa_mod_exp(BIGNUM *r, BIGNUM *I, RSA *rsa)
852err: 1031err:
853 return to_return; 1032 return to_return;
854 } 1033 }
1034#endif
855 1035
856/* This function is aliased to mod_exp (with the mont stuff dropped). */ 1036/* This function is aliased to mod_exp (with the mont stuff dropped). */
857static int hwcrhk_mod_exp_mont(BIGNUM *r, BIGNUM *a, const BIGNUM *p, 1037static int hwcrhk_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
858 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx) 1038 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
859 { 1039 {
860 return hwcrhk_mod_exp(r, a, p, m, ctx); 1040 return hwcrhk_mod_exp(r, a, p, m, ctx);
861 } 1041 }
862 1042
863/* This function is aliased to mod_exp (with the dh and mont dropped). */ 1043/* This function is aliased to mod_exp (with the dh and mont dropped). */
864static int hwcrhk_mod_exp_dh(DH *dh, BIGNUM *r, BIGNUM *a, const BIGNUM *p, 1044static int hwcrhk_mod_exp_dh(const DH *dh, BIGNUM *r,
1045 const BIGNUM *a, const BIGNUM *p,
865 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx) 1046 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
866 { 1047 {
867 return hwcrhk_mod_exp(r, a, p, m, ctx); 1048 return hwcrhk_mod_exp(r, a, p, m, ctx);
@@ -876,11 +1057,11 @@ static int hwcrhk_rand_bytes(unsigned char *buf, int num)
876 int ret; 1057 int ret;
877 1058
878 rmsg.buf = tempbuf; 1059 rmsg.buf = tempbuf;
879 rmsg.size = 1024; 1060 rmsg.size = sizeof(tempbuf);
880 1061
881 if(!hwcrhk_context) 1062 if(!hwcrhk_context)
882 { 1063 {
883 ENGINEerr(ENGINE_F_HWCRHK_RAND_BYTES,ENGINE_R_NOT_INITIALISED); 1064 HWCRHKerr(HWCRHK_F_HWCRHK_RAND_BYTES,HWCRHK_R_NOT_INITIALISED);
884 goto err; 1065 goto err;
885 } 1066 }
886 1067
@@ -892,11 +1073,13 @@ static int hwcrhk_rand_bytes(unsigned char *buf, int num)
892 might be a good thing. */ 1073 might be a good thing. */
893 if(ret == HWCRYPTOHOOK_ERROR_FALLBACK) 1074 if(ret == HWCRYPTOHOOK_ERROR_FALLBACK)
894 { 1075 {
895 ENGINEerr(ENGINE_F_HWCRHK_RAND_BYTES,ENGINE_R_REQUEST_FALLBACK); 1076 HWCRHKerr(HWCRHK_F_HWCRHK_RAND_BYTES,
1077 HWCRHK_R_REQUEST_FALLBACK);
896 } 1078 }
897 else 1079 else
898 { 1080 {
899 ENGINEerr(ENGINE_F_HWCRHK_RAND_BYTES,ENGINE_R_REQUEST_FAILED); 1081 HWCRHKerr(HWCRHK_F_HWCRHK_RAND_BYTES,
1082 HWCRHK_R_REQUEST_FAILED);
900 } 1083 }
901 ERR_add_error_data(1,rmsg.buf); 1084 ERR_add_error_data(1,rmsg.buf);
902 goto err; 1085 goto err;
@@ -914,20 +1097,28 @@ static int hwcrhk_rand_status(void)
914/* This cleans up an RSA KM key, called when ex_data is freed */ 1097/* This cleans up an RSA KM key, called when ex_data is freed */
915 1098
916static void hwcrhk_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad, 1099static void hwcrhk_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad,
917 int index,long argl, void *argp) 1100 int ind,long argl, void *argp)
918{ 1101{
919 char tempbuf[1024]; 1102 char tempbuf[1024];
920 HWCryptoHook_ErrMsgBuf rmsg; 1103 HWCryptoHook_ErrMsgBuf rmsg;
1104#ifndef OPENSSL_NO_RSA
921 HWCryptoHook_RSAKeyHandle *hptr; 1105 HWCryptoHook_RSAKeyHandle *hptr;
1106#endif
1107#if !defined(OPENSSL_NO_RSA)
922 int ret; 1108 int ret;
1109#endif
923 1110
924 rmsg.buf = tempbuf; 1111 rmsg.buf = tempbuf;
925 rmsg.size = 1024; 1112 rmsg.size = sizeof(tempbuf);
926 1113
1114#ifndef OPENSSL_NO_RSA
927 hptr = (HWCryptoHook_RSAKeyHandle *) item; 1115 hptr = (HWCryptoHook_RSAKeyHandle *) item;
928 if(!hptr) return; 1116 if(hptr)
929 ret = p_hwcrhk_RSAUnloadKey(*hptr, NULL); 1117 {
930 OPENSSL_free(hptr); 1118 ret = p_hwcrhk_RSAUnloadKey(*hptr, NULL);
1119 OPENSSL_free(hptr);
1120 }
1121#endif
931} 1122}
932 1123
933/* Mutex calls: since the HWCryptoHook model closely follows the POSIX model 1124/* Mutex calls: since the HWCryptoHook model closely follows the POSIX model
@@ -939,17 +1130,17 @@ static int hwcrhk_mutex_init(HWCryptoHook_Mutex* mt,
939 { 1130 {
940 mt->lockid = CRYPTO_get_new_dynlockid(); 1131 mt->lockid = CRYPTO_get_new_dynlockid();
941 if (mt->lockid == 0) 1132 if (mt->lockid == 0)
942 return 0; 1133 return 1; /* failure */
943 return 1; 1134 return 0; /* success */
944 } 1135 }
945 1136
946static int hwcrhk_mutex_lock(HWCryptoHook_Mutex *mt) 1137static int hwcrhk_mutex_lock(HWCryptoHook_Mutex *mt)
947 { 1138 {
948 CRYPTO_w_lock(mt->lockid); 1139 CRYPTO_w_lock(mt->lockid);
949 return 1; 1140 return 0;
950 } 1141 }
951 1142
952void hwcrhk_mutex_unlock(HWCryptoHook_Mutex * mt) 1143static void hwcrhk_mutex_unlock(HWCryptoHook_Mutex * mt)
953 { 1144 {
954 CRYPTO_w_unlock(mt->lockid); 1145 CRYPTO_w_unlock(mt->lockid);
955 } 1146 }
@@ -964,50 +1155,146 @@ static int hwcrhk_get_pass(const char *prompt_info,
964 HWCryptoHook_PassphraseContext *ppctx, 1155 HWCryptoHook_PassphraseContext *ppctx,
965 HWCryptoHook_CallerContext *cactx) 1156 HWCryptoHook_CallerContext *cactx)
966 { 1157 {
967 int l = 0; 1158 pem_password_cb *callback = NULL;
968 char prompt[1024]; 1159 void *callback_data = NULL;
969 1160 UI_METHOD *ui_method = NULL;
970 if (password_callback == NULL) 1161
971 { 1162 if (cactx)
972 ENGINEerr(ENGINE_F_HWCRHK_GET_PASS,ENGINE_R_NO_CALLBACK); 1163 {
973 return -1; 1164 if (cactx->ui_method)
974 } 1165 ui_method = cactx->ui_method;
975 if (prompt_info) 1166 if (cactx->password_callback)
1167 callback = cactx->password_callback;
1168 if (cactx->callback_data)
1169 callback_data = cactx->callback_data;
1170 }
1171 if (ppctx)
976 { 1172 {
977 strncpy(prompt, "Card: \"", sizeof(prompt)); 1173 if (ppctx->ui_method)
978 l += 5; 1174 {
979 strncpy(prompt + l, prompt_info, sizeof(prompt) - l); 1175 ui_method = ppctx->ui_method;
980 l += strlen(prompt_info); 1176 callback = NULL;
981 if (l + 2 < sizeof(prompt)) 1177 }
982 { 1178 if (ppctx->callback_data)
983 strncpy(prompt + l, "\"\n", sizeof(prompt) - l); 1179 callback_data = ppctx->callback_data;
984 l += 2;
985 }
986 } 1180 }
987 if (l < sizeof(prompt) - 1) 1181 if (callback == NULL && ui_method == NULL)
988 { 1182 {
989 strncpy(prompt, "Enter Passphrase <enter to cancel>:", 1183 HWCRHKerr(HWCRHK_F_HWCRHK_GET_PASS,HWCRHK_R_NO_CALLBACK);
990 sizeof(prompt) - l); 1184 return -1;
991 l += 35;
992 } 1185 }
993 prompt[l] = '\0';
994 1186
995 /* I know, passing on the prompt instead of the user data *is* 1187 if (ui_method)
996 a bad thing. However, that's all we have right now. 1188 {
997 -- Richard Levitte */ 1189 UI *ui = UI_new_method(ui_method);
998 *len_io = password_callback(buf, *len_io, 0, prompt); 1190 if (ui)
1191 {
1192 int ok;
1193 char *prompt = UI_construct_prompt(ui,
1194 "pass phrase", prompt_info);
1195
1196 ok = UI_add_input_string(ui,prompt,
1197 UI_INPUT_FLAG_DEFAULT_PWD,
1198 buf,0,(*len_io) - 1);
1199 UI_add_user_data(ui, callback_data);
1200 UI_ctrl(ui, UI_CTRL_PRINT_ERRORS, 1, 0, 0);
1201
1202 if (ok >= 0)
1203 do
1204 {
1205 ok=UI_process(ui);
1206 }
1207 while (ok < 0 && UI_ctrl(ui, UI_CTRL_IS_REDOABLE, 0, 0, 0));
1208
1209 if (ok >= 0)
1210 *len_io = strlen(buf);
1211
1212 UI_free(ui);
1213 OPENSSL_free(prompt);
1214 }
1215 }
1216 else
1217 {
1218 *len_io = callback(buf, *len_io, 0, callback_data);
1219 }
999 if(!*len_io) 1220 if(!*len_io)
1000 return -1; 1221 return -1;
1001 return 0; 1222 return 0;
1002 } 1223 }
1003 1224
1004static void hwcrhk_log_message(void *logstream, const char *message) 1225static int hwcrhk_insert_card(const char *prompt_info,
1226 const char *wrong_info,
1227 HWCryptoHook_PassphraseContext *ppctx,
1228 HWCryptoHook_CallerContext *cactx)
1229 {
1230 int ok = -1;
1231 UI *ui;
1232 void *callback_data = NULL;
1233 UI_METHOD *ui_method = NULL;
1234
1235 if (cactx)
1236 {
1237 if (cactx->ui_method)
1238 ui_method = cactx->ui_method;
1239 if (cactx->callback_data)
1240 callback_data = cactx->callback_data;
1241 }
1242 if (ppctx)
1243 {
1244 if (ppctx->ui_method)
1245 ui_method = ppctx->ui_method;
1246 if (ppctx->callback_data)
1247 callback_data = ppctx->callback_data;
1248 }
1249 if (ui_method == NULL)
1250 {
1251 HWCRHKerr(HWCRHK_F_HWCRHK_INSERT_CARD,
1252 HWCRHK_R_NO_CALLBACK);
1253 return -1;
1254 }
1255
1256 ui = UI_new_method(ui_method);
1257
1258 if (ui)
1259 {
1260 char answer;
1261 char buf[BUFSIZ];
1262
1263 if (wrong_info)
1264 BIO_snprintf(buf, sizeof(buf)-1,
1265 "Current card: \"%s\"\n", wrong_info);
1266 ok = UI_dup_info_string(ui, buf);
1267 if (ok >= 0 && prompt_info)
1268 {
1269 BIO_snprintf(buf, sizeof(buf)-1,
1270 "Insert card \"%s\"", prompt_info);
1271 ok = UI_dup_input_boolean(ui, buf,
1272 "\n then hit <enter> or C<enter> to cancel\n",
1273 "\r\n", "Cc", UI_INPUT_FLAG_ECHO, &answer);
1274 }
1275 UI_add_user_data(ui, callback_data);
1276
1277 if (ok >= 0)
1278 ok = UI_process(ui);
1279 UI_free(ui);
1280
1281 if (ok == -2 || (ok >= 0 && answer == 'C'))
1282 ok = 1;
1283 else if (ok < 0)
1284 ok = -1;
1285 else
1286 ok = 0;
1287 }
1288 return ok;
1289 }
1290
1291static void hwcrhk_log_message(void *logstr, const char *message)
1005 { 1292 {
1006 BIO *lstream = NULL; 1293 BIO *lstream = NULL;
1007 1294
1008 CRYPTO_w_lock(CRYPTO_LOCK_BIO); 1295 CRYPTO_w_lock(CRYPTO_LOCK_BIO);
1009 if (logstream) 1296 if (logstr)
1010 lstream=*(BIO **)logstream; 1297 lstream=*(BIO **)logstr;
1011 if (lstream) 1298 if (lstream)
1012 { 1299 {
1013 BIO_write(lstream, message, strlen(message)); 1300 BIO_write(lstream, message, strlen(message));
@@ -1015,5 +1302,20 @@ static void hwcrhk_log_message(void *logstream, const char *message)
1015 CRYPTO_w_unlock(CRYPTO_LOCK_BIO); 1302 CRYPTO_w_unlock(CRYPTO_LOCK_BIO);
1016 } 1303 }
1017 1304
1018#endif /* !NO_HW_NCIPHER */ 1305/* This stuff is needed if this ENGINE is being compiled into a self-contained
1019#endif /* !NO_HW */ 1306 * shared-library. */
1307#ifdef ENGINE_DYNAMIC_SUPPORT
1308static int bind_fn(ENGINE *e, const char *id)
1309 {
1310 if(id && (strcmp(id, engine_hwcrhk_id) != 0))
1311 return 0;
1312 if(!bind_helper(e))
1313 return 0;
1314 return 1;
1315 }
1316IMPLEMENT_DYNAMIC_CHECK_FN()
1317IMPLEMENT_DYNAMIC_BIND_FN(bind_fn)
1318#endif /* ENGINE_DYNAMIC_SUPPORT */
1319
1320#endif /* !OPENSSL_NO_HW_NCIPHER */
1321#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..2672012154
--- /dev/null
+++ b/src/lib/libcrypto/engine/hw_nuron.c
@@ -0,0 +1,399 @@
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 def_NURON_LIBNAME[] = "nuronssl";
73static const char *NURON_LIBNAME = def_NURON_LIBNAME;
74static const char *NURON_F1 = "nuron_mod_exp";
75
76/* The definitions for control commands specific to this engine */
77#define NURON_CMD_SO_PATH ENGINE_CMD_BASE
78static const ENGINE_CMD_DEFN nuron_cmd_defns[] = {
79 {NURON_CMD_SO_PATH,
80 "SO_PATH",
81 "Specifies the path to the 'nuronssl' shared library",
82 ENGINE_CMD_FLAG_STRING},
83 {0, NULL, NULL, 0}
84 };
85
86typedef int tfnModExp(BIGNUM *r,const BIGNUM *a,const BIGNUM *p,const BIGNUM *m);
87static tfnModExp *pfnModExp = NULL;
88
89static DSO *pvDSOHandle = NULL;
90
91static int nuron_destroy(ENGINE *e)
92 {
93 ERR_unload_NURON_strings();
94 return 1;
95 }
96
97static int nuron_init(ENGINE *e)
98 {
99 if(pvDSOHandle != NULL)
100 {
101 NURONerr(NURON_F_NURON_INIT,NURON_R_ALREADY_LOADED);
102 return 0;
103 }
104
105 pvDSOHandle = DSO_load(NULL, NURON_LIBNAME, NULL,
106 DSO_FLAG_NAME_TRANSLATION_EXT_ONLY);
107 if(!pvDSOHandle)
108 {
109 NURONerr(NURON_F_NURON_INIT,NURON_R_DSO_NOT_FOUND);
110 return 0;
111 }
112
113 pfnModExp = (tfnModExp *)DSO_bind_func(pvDSOHandle, NURON_F1);
114 if(!pfnModExp)
115 {
116 NURONerr(NURON_F_NURON_INIT,NURON_R_DSO_FUNCTION_NOT_FOUND);
117 return 0;
118 }
119
120 return 1;
121 }
122
123static int nuron_finish(ENGINE *e)
124 {
125 if(pvDSOHandle == NULL)
126 {
127 NURONerr(NURON_F_NURON_FINISH,NURON_R_NOT_LOADED);
128 return 0;
129 }
130 if(!DSO_free(pvDSOHandle))
131 {
132 NURONerr(NURON_F_NURON_FINISH,NURON_R_DSO_FAILURE);
133 return 0;
134 }
135 pvDSOHandle=NULL;
136 pfnModExp=NULL;
137 return 1;
138 }
139
140static int nuron_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
141 {
142 int initialised = ((pvDSOHandle == NULL) ? 0 : 1);
143 switch(cmd)
144 {
145 case NURON_CMD_SO_PATH:
146 if(p == NULL)
147 {
148 NURONerr(NURON_F_NURON_CTRL,ERR_R_PASSED_NULL_PARAMETER);
149 return 0;
150 }
151 if(initialised)
152 {
153 NURONerr(NURON_F_NURON_CTRL,NURON_R_ALREADY_LOADED);
154 return 0;
155 }
156 NURON_LIBNAME = (const char *)p;
157 return 1;
158 default:
159 break;
160 }
161 NURONerr(NURON_F_NURON_CTRL,NURON_R_CTRL_COMMAND_NOT_IMPLEMENTED);
162 return 0;
163}
164
165static int nuron_mod_exp(BIGNUM *r,const BIGNUM *a,const BIGNUM *p,
166 const BIGNUM *m,BN_CTX *ctx)
167 {
168 if(!pvDSOHandle)
169 {
170 NURONerr(NURON_F_NURON_MOD_EXP,NURON_R_NOT_LOADED);
171 return 0;
172 }
173 return pfnModExp(r,a,p,m);
174 }
175
176#ifndef OPENSSL_NO_RSA
177static int nuron_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
178 {
179 return nuron_mod_exp(r0,I,rsa->d,rsa->n,NULL);
180 }
181#endif
182
183#ifndef OPENSSL_NO_DSA
184/* This code was liberated and adapted from the commented-out code in
185 * dsa_ossl.c. Because of the unoptimised form of the Atalla acceleration
186 * (it doesn't have a CRT form for RSA), this function means that an
187 * Atalla system running with a DSA server certificate can handshake
188 * around 5 or 6 times faster/more than an equivalent system running with
189 * RSA. Just check out the "signs" statistics from the RSA and DSA parts
190 * of "openssl speed -engine atalla dsa1024 rsa1024". */
191static int nuron_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,
192 BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
193 BN_CTX *ctx, BN_MONT_CTX *in_mont)
194 {
195 BIGNUM t;
196 int to_return = 0;
197
198 BN_init(&t);
199 /* let rr = a1 ^ p1 mod m */
200 if (!nuron_mod_exp(rr,a1,p1,m,ctx))
201 goto end;
202 /* let t = a2 ^ p2 mod m */
203 if (!nuron_mod_exp(&t,a2,p2,m,ctx))
204 goto end;
205 /* let rr = rr * t mod m */
206 if (!BN_mod_mul(rr,rr,&t,m,ctx))
207 goto end;
208 to_return = 1;
209end:
210 BN_free(&t);
211 return to_return;
212 }
213
214
215static int nuron_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a,
216 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
217 BN_MONT_CTX *m_ctx)
218 {
219 return nuron_mod_exp(r, a, p, m, ctx);
220 }
221#endif
222
223/* This function is aliased to mod_exp (with the mont stuff dropped). */
224static int nuron_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
225 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
226 {
227 return nuron_mod_exp(r, a, p, m, ctx);
228 }
229
230#ifndef OPENSSL_NO_DH
231/* This function is aliased to mod_exp (with the dh and mont dropped). */
232static int nuron_mod_exp_dh(const DH *dh, BIGNUM *r,
233 const BIGNUM *a, const BIGNUM *p,
234 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
235 {
236 return nuron_mod_exp(r, a, p, m, ctx);
237 }
238#endif
239
240#ifndef OPENSSL_NO_RSA
241static RSA_METHOD nuron_rsa =
242 {
243 "Nuron RSA method",
244 NULL,
245 NULL,
246 NULL,
247 NULL,
248 nuron_rsa_mod_exp,
249 nuron_mod_exp_mont,
250 NULL,
251 NULL,
252 0,
253 NULL,
254 NULL,
255 NULL
256 };
257#endif
258
259#ifndef OPENSSL_NO_DSA
260static DSA_METHOD nuron_dsa =
261 {
262 "Nuron DSA method",
263 NULL, /* dsa_do_sign */
264 NULL, /* dsa_sign_setup */
265 NULL, /* dsa_do_verify */
266 nuron_dsa_mod_exp, /* dsa_mod_exp */
267 nuron_mod_exp_dsa, /* bn_mod_exp */
268 NULL, /* init */
269 NULL, /* finish */
270 0, /* flags */
271 NULL /* app_data */
272 };
273#endif
274
275#ifndef OPENSSL_NO_DH
276static DH_METHOD nuron_dh =
277 {
278 "Nuron DH method",
279 NULL,
280 NULL,
281 nuron_mod_exp_dh,
282 NULL,
283 NULL,
284 0,
285 NULL
286 };
287#endif
288
289/* Constants used when creating the ENGINE */
290static const char *engine_nuron_id = "nuron";
291static const char *engine_nuron_name = "Nuron hardware engine support";
292
293/* This internal function is used by ENGINE_nuron() and possibly by the
294 * "dynamic" ENGINE support too */
295static int bind_helper(ENGINE *e)
296 {
297#ifndef OPENSSL_NO_RSA
298 const RSA_METHOD *meth1;
299#endif
300#ifndef OPENSSL_NO_DSA
301 const DSA_METHOD *meth2;
302#endif
303#ifndef OPENSSL_NO_DH
304 const DH_METHOD *meth3;
305#endif
306 if(!ENGINE_set_id(e, engine_nuron_id) ||
307 !ENGINE_set_name(e, engine_nuron_name) ||
308#ifndef OPENSSL_NO_RSA
309 !ENGINE_set_RSA(e, &nuron_rsa) ||
310#endif
311#ifndef OPENSSL_NO_DSA
312 !ENGINE_set_DSA(e, &nuron_dsa) ||
313#endif
314#ifndef OPENSSL_NO_DH
315 !ENGINE_set_DH(e, &nuron_dh) ||
316#endif
317 !ENGINE_set_destroy_function(e, nuron_destroy) ||
318 !ENGINE_set_init_function(e, nuron_init) ||
319 !ENGINE_set_finish_function(e, nuron_finish) ||
320 !ENGINE_set_ctrl_function(e, nuron_ctrl) ||
321 !ENGINE_set_cmd_defns(e, nuron_cmd_defns))
322 return 0;
323
324#ifndef OPENSSL_NO_RSA
325 /* We know that the "PKCS1_SSLeay()" functions hook properly
326 * to the nuron-specific mod_exp and mod_exp_crt so we use
327 * those functions. NB: We don't use ENGINE_openssl() or
328 * anything "more generic" because something like the RSAref
329 * code may not hook properly, and if you own one of these
330 * cards then you have the right to do RSA operations on it
331 * anyway! */
332 meth1=RSA_PKCS1_SSLeay();
333 nuron_rsa.rsa_pub_enc=meth1->rsa_pub_enc;
334 nuron_rsa.rsa_pub_dec=meth1->rsa_pub_dec;
335 nuron_rsa.rsa_priv_enc=meth1->rsa_priv_enc;
336 nuron_rsa.rsa_priv_dec=meth1->rsa_priv_dec;
337#endif
338
339#ifndef OPENSSL_NO_DSA
340 /* Use the DSA_OpenSSL() method and just hook the mod_exp-ish
341 * bits. */
342 meth2=DSA_OpenSSL();
343 nuron_dsa.dsa_do_sign=meth2->dsa_do_sign;
344 nuron_dsa.dsa_sign_setup=meth2->dsa_sign_setup;
345 nuron_dsa.dsa_do_verify=meth2->dsa_do_verify;
346#endif
347
348#ifndef OPENSSL_NO_DH
349 /* Much the same for Diffie-Hellman */
350 meth3=DH_OpenSSL();
351 nuron_dh.generate_key=meth3->generate_key;
352 nuron_dh.compute_key=meth3->compute_key;
353#endif
354
355 /* Ensure the nuron error handling is set up */
356 ERR_load_NURON_strings();
357 return 1;
358 }
359
360static ENGINE *engine_nuron(void)
361 {
362 ENGINE *ret = ENGINE_new();
363 if(!ret)
364 return NULL;
365 if(!bind_helper(ret))
366 {
367 ENGINE_free(ret);
368 return NULL;
369 }
370 return ret;
371 }
372
373void ENGINE_load_nuron(void)
374 {
375 /* Copied from eng_[openssl|dyn].c */
376 ENGINE *toadd = engine_nuron();
377 if(!toadd) return;
378 ENGINE_add(toadd);
379 ENGINE_free(toadd);
380 ERR_clear_error();
381 }
382
383/* This stuff is needed if this ENGINE is being compiled into a self-contained
384 * shared-library. */
385#ifdef ENGINE_DYNAMIC_SUPPORT
386static int bind_fn(ENGINE *e, const char *id)
387 {
388 if(id && (strcmp(id, engine_nuron_id) != 0))
389 return 0;
390 if(!bind_helper(e))
391 return 0;
392 return 1;
393 }
394IMPLEMENT_DYNAMIC_CHECK_FN()
395IMPLEMENT_DYNAMIC_BIND_FN(bind_fn)
396#endif /* ENGINE_DYNAMIC_SUPPORT */
397
398#endif /* !OPENSSL_NO_HW_NURON */
399#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..f946389b8a
--- /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..743c06043c
--- /dev/null
+++ b/src/lib/libcrypto/engine/hw_ubsec.c
@@ -0,0 +1,1041 @@
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#if 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#if 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 = "ubsec";
308static const char *UBSEC_F1 = "ubsec_bytes_to_bits";
309static const char *UBSEC_F2 = "ubsec_bits_to_bytes";
310static const char *UBSEC_F3 = "ubsec_open";
311static const char *UBSEC_F4 = "ubsec_close";
312#ifndef OPENSSL_NO_DH
313static const char *UBSEC_F5 = "diffie_hellman_generate_ioctl";
314static const char *UBSEC_F6 = "diffie_hellman_agree_ioctl";
315#endif
316/* #ifndef OPENSSL_NO_RSA */
317static const char *UBSEC_F7 = "rsa_mod_exp_ioctl";
318static const char *UBSEC_F8 = "rsa_mod_exp_crt_ioctl";
319/* #endif */
320#ifndef OPENSSL_NO_DSA
321static const char *UBSEC_F9 = "dsa_sign_ioctl";
322static const char *UBSEC_F10 = "dsa_verify_ioctl";
323#endif
324static const char *UBSEC_F11 = "math_accelerate_ioctl";
325static const char *UBSEC_F12 = "rng_ioctl";
326static const char *UBSEC_F13 = "ubsec_max_key_len_ioctl";
327
328/* Destructor (complements the "ENGINE_ubsec()" constructor) */
329static int ubsec_destroy(ENGINE *e)
330 {
331 ERR_unload_UBSEC_strings();
332 return 1;
333 }
334
335/* (de)initialisation functions. */
336static int ubsec_init(ENGINE *e)
337 {
338 t_UBSEC_ubsec_bytes_to_bits *p1;
339 t_UBSEC_ubsec_bits_to_bytes *p2;
340 t_UBSEC_ubsec_open *p3;
341 t_UBSEC_ubsec_close *p4;
342#ifndef OPENSSL_NO_DH
343 t_UBSEC_diffie_hellman_generate_ioctl *p5;
344 t_UBSEC_diffie_hellman_agree_ioctl *p6;
345#endif
346/* #ifndef OPENSSL_NO_RSA */
347 t_UBSEC_rsa_mod_exp_ioctl *p7;
348 t_UBSEC_rsa_mod_exp_crt_ioctl *p8;
349/* #endif */
350#ifndef OPENSSL_NO_DSA
351 t_UBSEC_dsa_sign_ioctl *p9;
352 t_UBSEC_dsa_verify_ioctl *p10;
353#endif
354 t_UBSEC_math_accelerate_ioctl *p11;
355 t_UBSEC_rng_ioctl *p12;
356 t_UBSEC_max_key_len_ioctl *p13;
357 int fd = 0;
358
359 if(ubsec_dso != NULL)
360 {
361 UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_ALREADY_LOADED);
362 goto err;
363 }
364 /*
365 * Attempt to load libubsec.so/ubsec.dll/whatever.
366 */
367 ubsec_dso = DSO_load(NULL, UBSEC_LIBNAME, NULL, 0);
368 if(ubsec_dso == NULL)
369 {
370 UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_DSO_FAILURE);
371 goto err;
372 }
373
374 if (
375 !(p1 = (t_UBSEC_ubsec_bytes_to_bits *) DSO_bind_func(ubsec_dso, UBSEC_F1)) ||
376 !(p2 = (t_UBSEC_ubsec_bits_to_bytes *) DSO_bind_func(ubsec_dso, UBSEC_F2)) ||
377 !(p3 = (t_UBSEC_ubsec_open *) DSO_bind_func(ubsec_dso, UBSEC_F3)) ||
378 !(p4 = (t_UBSEC_ubsec_close *) DSO_bind_func(ubsec_dso, UBSEC_F4)) ||
379#ifndef OPENSSL_NO_DH
380 !(p5 = (t_UBSEC_diffie_hellman_generate_ioctl *)
381 DSO_bind_func(ubsec_dso, UBSEC_F5)) ||
382 !(p6 = (t_UBSEC_diffie_hellman_agree_ioctl *)
383 DSO_bind_func(ubsec_dso, UBSEC_F6)) ||
384#endif
385/* #ifndef OPENSSL_NO_RSA */
386 !(p7 = (t_UBSEC_rsa_mod_exp_ioctl *) DSO_bind_func(ubsec_dso, UBSEC_F7)) ||
387 !(p8 = (t_UBSEC_rsa_mod_exp_crt_ioctl *) DSO_bind_func(ubsec_dso, UBSEC_F8)) ||
388/* #endif */
389#ifndef OPENSSL_NO_DSA
390 !(p9 = (t_UBSEC_dsa_sign_ioctl *) DSO_bind_func(ubsec_dso, UBSEC_F9)) ||
391 !(p10 = (t_UBSEC_dsa_verify_ioctl *) DSO_bind_func(ubsec_dso, UBSEC_F10)) ||
392#endif
393 !(p11 = (t_UBSEC_math_accelerate_ioctl *)
394 DSO_bind_func(ubsec_dso, UBSEC_F11)) ||
395 !(p12 = (t_UBSEC_rng_ioctl *) DSO_bind_func(ubsec_dso, UBSEC_F12)) ||
396 !(p13 = (t_UBSEC_max_key_len_ioctl *) DSO_bind_func(ubsec_dso, UBSEC_F13)))
397 {
398 UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_DSO_FAILURE);
399 goto err;
400 }
401
402 /* Copy the pointers */
403 p_UBSEC_ubsec_bytes_to_bits = p1;
404 p_UBSEC_ubsec_bits_to_bytes = p2;
405 p_UBSEC_ubsec_open = p3;
406 p_UBSEC_ubsec_close = p4;
407#ifndef OPENSSL_NO_DH
408 p_UBSEC_diffie_hellman_generate_ioctl = p5;
409 p_UBSEC_diffie_hellman_agree_ioctl = p6;
410#endif
411#ifndef OPENSSL_NO_RSA
412 p_UBSEC_rsa_mod_exp_ioctl = p7;
413 p_UBSEC_rsa_mod_exp_crt_ioctl = p8;
414#endif
415#ifndef OPENSSL_NO_DSA
416 p_UBSEC_dsa_sign_ioctl = p9;
417 p_UBSEC_dsa_verify_ioctl = p10;
418#endif
419 p_UBSEC_math_accelerate_ioctl = p11;
420 p_UBSEC_rng_ioctl = p12;
421 p_UBSEC_max_key_len_ioctl = p13;
422
423 /* Perform an open to see if there's actually any unit running. */
424 if (((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) > 0) && (p_UBSEC_max_key_len_ioctl(fd, &max_key_len) == 0))
425 {
426 p_UBSEC_ubsec_close(fd);
427 return 1;
428 }
429 else
430 {
431 UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_UNIT_FAILURE);
432 }
433
434err:
435 if(ubsec_dso)
436 DSO_free(ubsec_dso);
437 p_UBSEC_ubsec_bytes_to_bits = NULL;
438 p_UBSEC_ubsec_bits_to_bytes = NULL;
439 p_UBSEC_ubsec_open = NULL;
440 p_UBSEC_ubsec_close = NULL;
441#ifndef OPENSSL_NO_DH
442 p_UBSEC_diffie_hellman_generate_ioctl = NULL;
443 p_UBSEC_diffie_hellman_agree_ioctl = NULL;
444#endif
445#ifndef OPENSSL_NO_RSA
446 p_UBSEC_rsa_mod_exp_ioctl = NULL;
447 p_UBSEC_rsa_mod_exp_crt_ioctl = NULL;
448#endif
449#ifndef OPENSSL_NO_DSA
450 p_UBSEC_dsa_sign_ioctl = NULL;
451 p_UBSEC_dsa_verify_ioctl = NULL;
452#endif
453 p_UBSEC_math_accelerate_ioctl = NULL;
454 p_UBSEC_rng_ioctl = NULL;
455 p_UBSEC_max_key_len_ioctl = NULL;
456
457 return 0;
458 }
459
460static int ubsec_finish(ENGINE *e)
461 {
462 if(ubsec_dso == NULL)
463 {
464 UBSECerr(UBSEC_F_UBSEC_FINISH, UBSEC_R_NOT_LOADED);
465 return 0;
466 }
467 if(!DSO_free(ubsec_dso))
468 {
469 UBSECerr(UBSEC_F_UBSEC_FINISH, UBSEC_R_DSO_FAILURE);
470 return 0;
471 }
472 ubsec_dso = NULL;
473 p_UBSEC_ubsec_bytes_to_bits = NULL;
474 p_UBSEC_ubsec_bits_to_bytes = NULL;
475 p_UBSEC_ubsec_open = NULL;
476 p_UBSEC_ubsec_close = NULL;
477#ifndef OPENSSL_NO_DH
478 p_UBSEC_diffie_hellman_generate_ioctl = NULL;
479 p_UBSEC_diffie_hellman_agree_ioctl = NULL;
480#endif
481#ifndef OPENSSL_NO_RSA
482 p_UBSEC_rsa_mod_exp_ioctl = NULL;
483 p_UBSEC_rsa_mod_exp_crt_ioctl = NULL;
484#endif
485#ifndef OPENSSL_NO_DSA
486 p_UBSEC_dsa_sign_ioctl = NULL;
487 p_UBSEC_dsa_verify_ioctl = NULL;
488#endif
489 p_UBSEC_math_accelerate_ioctl = NULL;
490 p_UBSEC_rng_ioctl = NULL;
491 p_UBSEC_max_key_len_ioctl = NULL;
492 return 1;
493 }
494
495static int ubsec_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
496 {
497 int initialised = ((ubsec_dso == NULL) ? 0 : 1);
498 switch(cmd)
499 {
500 case UBSEC_CMD_SO_PATH:
501 if(p == NULL)
502 {
503 UBSECerr(UBSEC_F_UBSEC_CTRL,ERR_R_PASSED_NULL_PARAMETER);
504 return 0;
505 }
506 if(initialised)
507 {
508 UBSECerr(UBSEC_F_UBSEC_CTRL,UBSEC_R_ALREADY_LOADED);
509 return 0;
510 }
511 UBSEC_LIBNAME = (const char *)p;
512 return 1;
513 default:
514 break;
515 }
516 UBSECerr(UBSEC_F_UBSEC_CTRL,UBSEC_R_CTRL_COMMAND_NOT_IMPLEMENTED);
517 return 0;
518 }
519
520static int ubsec_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
521 const BIGNUM *m, BN_CTX *ctx)
522 {
523 int y_len = 0;
524 int fd;
525
526 if(ubsec_dso == NULL)
527 {
528 UBSECerr(UBSEC_F_UBSEC_MOD_EXP, UBSEC_R_NOT_LOADED);
529 return 0;
530 }
531
532 /* Check if hardware can't handle this argument. */
533 y_len = BN_num_bits(m);
534 if (y_len > max_key_len) {
535 UBSECerr(UBSEC_F_UBSEC_MOD_EXP, UBSEC_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
536 return BN_mod_exp(r, a, p, m, ctx);
537 }
538
539 if(!bn_wexpand(r, m->top))
540 {
541 UBSECerr(UBSEC_F_UBSEC_MOD_EXP, UBSEC_R_BN_EXPAND_FAIL);
542 return 0;
543 }
544 memset(r->d, 0, BN_num_bytes(m));
545
546 if ((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) <= 0) {
547 fd = 0;
548 UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_UNIT_FAILURE);
549 return BN_mod_exp(r, a, p, m, ctx);
550 }
551
552 if (p_UBSEC_rsa_mod_exp_ioctl(fd, (unsigned char *)a->d, BN_num_bits(a),
553 (unsigned char *)m->d, BN_num_bits(m), (unsigned char *)p->d,
554 BN_num_bits(p), (unsigned char *)r->d, &y_len) != 0)
555 {
556 UBSECerr(UBSEC_F_UBSEC_MOD_EXP, UBSEC_R_REQUEST_FAILED);
557 p_UBSEC_ubsec_close(fd);
558
559 return BN_mod_exp(r, a, p, m, ctx);
560 }
561
562 p_UBSEC_ubsec_close(fd);
563
564 r->top = (BN_num_bits(m)+BN_BITS2-1)/BN_BITS2;
565 return 1;
566 }
567
568#ifndef OPENSSL_NO_RSA
569static int ubsec_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
570 {
571 BN_CTX *ctx;
572 int to_return = 0;
573
574 if((ctx = BN_CTX_new()) == NULL)
575 goto err;
576
577 if(!rsa->p || !rsa->q || !rsa->dmp1 || !rsa->dmq1 || !rsa->iqmp)
578 {
579 UBSECerr(UBSEC_F_UBSEC_RSA_MOD_EXP, UBSEC_R_MISSING_KEY_COMPONENTS);
580 goto err;
581 }
582
583 to_return = ubsec_mod_exp_crt(r0, I, rsa->p, rsa->q, rsa->dmp1,
584 rsa->dmq1, rsa->iqmp, ctx);
585 if (to_return == FAIL_TO_SOFTWARE)
586 {
587 /*
588 * Do in software as hardware failed.
589 */
590 const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
591 to_return = (*meth->rsa_mod_exp)(r0, I, rsa);
592 }
593err:
594 if(ctx)
595 BN_CTX_free(ctx);
596 return to_return;
597 }
598#endif
599
600static int ubsec_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
601 const BIGNUM *q, const BIGNUM *dp,
602 const BIGNUM *dq, const BIGNUM *qinv, BN_CTX *ctx)
603 {
604 int y_len,
605 m_len,
606 fd;
607
608 m_len = BN_num_bytes(p) + BN_num_bytes(q) + 1;
609 y_len = BN_num_bits(p) + BN_num_bits(q);
610
611 /* Check if hardware can't handle this argument. */
612 if (y_len > max_key_len) {
613 UBSECerr(UBSEC_F_UBSEC_MOD_EXP, UBSEC_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
614 return FAIL_TO_SOFTWARE;
615 }
616
617 if (!bn_wexpand(r, p->top + q->top + 1)) {
618 UBSECerr(UBSEC_F_UBSEC_RSA_MOD_EXP_CRT, UBSEC_R_BN_EXPAND_FAIL);
619 return 0;
620 }
621
622 if ((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) <= 0) {
623 fd = 0;
624 UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_UNIT_FAILURE);
625 return FAIL_TO_SOFTWARE;
626 }
627
628 if (p_UBSEC_rsa_mod_exp_crt_ioctl(fd,
629 (unsigned char *)a->d, BN_num_bits(a),
630 (unsigned char *)qinv->d, BN_num_bits(qinv),
631 (unsigned char *)dp->d, BN_num_bits(dp),
632 (unsigned char *)p->d, BN_num_bits(p),
633 (unsigned char *)dq->d, BN_num_bits(dq),
634 (unsigned char *)q->d, BN_num_bits(q),
635 (unsigned char *)r->d, &y_len) != 0) {
636 UBSECerr(UBSEC_F_UBSEC_MOD_EXP, UBSEC_R_REQUEST_FAILED);
637 p_UBSEC_ubsec_close(fd);
638 return FAIL_TO_SOFTWARE;
639 }
640
641 p_UBSEC_ubsec_close(fd);
642
643 r->top = (BN_num_bits(p) + BN_num_bits(q) + BN_BITS2 - 1)/BN_BITS2;
644 return 1;
645}
646
647#ifndef OPENSSL_NO_DSA
648#if NOT_USED
649static int ubsec_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,
650 BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
651 BN_CTX *ctx, BN_MONT_CTX *in_mont)
652 {
653 BIGNUM t;
654 int to_return = 0;
655
656 BN_init(&t);
657 /* let rr = a1 ^ p1 mod m */
658 if (!ubsec_mod_exp(rr,a1,p1,m,ctx)) goto end;
659 /* let t = a2 ^ p2 mod m */
660 if (!ubsec_mod_exp(&t,a2,p2,m,ctx)) goto end;
661 /* let rr = rr * t mod m */
662 if (!BN_mod_mul(rr,rr,&t,m,ctx)) goto end;
663 to_return = 1;
664end:
665 BN_free(&t);
666 return to_return;
667 }
668
669static int ubsec_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a,
670 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
671 BN_MONT_CTX *m_ctx)
672 {
673 return ubsec_mod_exp(r, a, p, m, ctx);
674 }
675#endif
676#endif
677
678/*
679 * This function is aliased to mod_exp (with the mont stuff dropped).
680 */
681static int ubsec_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
682 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
683 {
684 int ret = 0;
685
686#ifndef OPENSSL_NO_RSA
687 /* Do in software if the key is too large for the hardware. */
688 if (BN_num_bits(m) > max_key_len)
689 {
690 const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
691 ret = (*meth->bn_mod_exp)(r, a, p, m, ctx, m_ctx);
692 }
693 else
694#endif
695 {
696 ret = ubsec_mod_exp(r, a, p, m, ctx);
697 }
698
699 return ret;
700 }
701
702#ifndef OPENSSL_NO_DH
703/* This function is aliased to mod_exp (with the dh and mont dropped). */
704static int ubsec_mod_exp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a,
705 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
706 BN_MONT_CTX *m_ctx)
707 {
708 return ubsec_mod_exp(r, a, p, m, ctx);
709 }
710#endif
711
712#ifndef OPENSSL_NO_DSA
713static DSA_SIG *ubsec_dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
714 {
715 DSA_SIG *to_return = NULL;
716 int s_len = 160, r_len = 160, d_len, fd;
717 BIGNUM m, *r=NULL, *s=NULL;
718
719 BN_init(&m);
720
721 s = BN_new();
722 r = BN_new();
723 if ((s == NULL) || (r==NULL))
724 goto err;
725
726 d_len = p_UBSEC_ubsec_bytes_to_bits((unsigned char *)dgst, dlen);
727
728 if(!bn_wexpand(r, (160+BN_BITS2-1)/BN_BITS2) ||
729 (!bn_wexpand(s, (160+BN_BITS2-1)/BN_BITS2))) {
730 UBSECerr(UBSEC_F_UBSEC_DSA_SIGN, UBSEC_R_BN_EXPAND_FAIL);
731 goto err;
732 }
733
734 if (BN_bin2bn(dgst,dlen,&m) == NULL) {
735 UBSECerr(UBSEC_F_UBSEC_DSA_SIGN, UBSEC_R_BN_EXPAND_FAIL);
736 goto err;
737 }
738
739 if ((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) <= 0) {
740 const DSA_METHOD *meth;
741 fd = 0;
742 UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_UNIT_FAILURE);
743 meth = DSA_OpenSSL();
744 to_return = meth->dsa_do_sign(dgst, dlen, dsa);
745 goto err;
746 }
747
748 if (p_UBSEC_dsa_sign_ioctl(fd, 0, /* compute hash before signing */
749 (unsigned char *)dgst, d_len,
750 NULL, 0, /* compute random value */
751 (unsigned char *)dsa->p->d, BN_num_bits(dsa->p),
752 (unsigned char *)dsa->q->d, BN_num_bits(dsa->q),
753 (unsigned char *)dsa->g->d, BN_num_bits(dsa->g),
754 (unsigned char *)dsa->priv_key->d, BN_num_bits(dsa->priv_key),
755 (unsigned char *)r->d, &r_len,
756 (unsigned char *)s->d, &s_len ) != 0) {
757 const DSA_METHOD *meth;
758
759 UBSECerr(UBSEC_F_UBSEC_DSA_SIGN, UBSEC_R_REQUEST_FAILED);
760 p_UBSEC_ubsec_close(fd);
761 meth = DSA_OpenSSL();
762 to_return = meth->dsa_do_sign(dgst, dlen, dsa);
763
764 goto err;
765 }
766
767 p_UBSEC_ubsec_close(fd);
768
769 r->top = (160+BN_BITS2-1)/BN_BITS2;
770 s->top = (160+BN_BITS2-1)/BN_BITS2;
771
772 to_return = DSA_SIG_new();
773 if(to_return == NULL) {
774 UBSECerr(UBSEC_F_UBSEC_DSA_SIGN, UBSEC_R_BN_EXPAND_FAIL);
775 goto err;
776 }
777
778 to_return->r = r;
779 to_return->s = s;
780
781err:
782 if (!to_return) {
783 if (r) BN_free(r);
784 if (s) BN_free(s);
785 }
786 BN_clear_free(&m);
787 return to_return;
788}
789
790static int ubsec_dsa_verify(const unsigned char *dgst, int dgst_len,
791 DSA_SIG *sig, DSA *dsa)
792 {
793 int v_len, d_len;
794 int to_return = 0;
795 int fd;
796 BIGNUM v;
797
798 BN_init(&v);
799
800 if(!bn_wexpand(&v, dsa->p->top)) {
801 UBSECerr(UBSEC_F_UBSEC_DSA_VERIFY ,UBSEC_R_BN_EXPAND_FAIL);
802 goto err;
803 }
804
805 v_len = BN_num_bits(dsa->p);
806
807 d_len = p_UBSEC_ubsec_bytes_to_bits((unsigned char *)dgst, dgst_len);
808
809 if ((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) <= 0) {
810 const DSA_METHOD *meth;
811 fd = 0;
812 UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_UNIT_FAILURE);
813 meth = DSA_OpenSSL();
814 to_return = meth->dsa_do_verify(dgst, dgst_len, sig, dsa);
815 goto err;
816 }
817
818 if (p_UBSEC_dsa_verify_ioctl(fd, 0, /* compute hash before signing */
819 (unsigned char *)dgst, d_len,
820 (unsigned char *)dsa->p->d, BN_num_bits(dsa->p),
821 (unsigned char *)dsa->q->d, BN_num_bits(dsa->q),
822 (unsigned char *)dsa->g->d, BN_num_bits(dsa->g),
823 (unsigned char *)dsa->pub_key->d, BN_num_bits(dsa->pub_key),
824 (unsigned char *)sig->r->d, BN_num_bits(sig->r),
825 (unsigned char *)sig->s->d, BN_num_bits(sig->s),
826 (unsigned char *)v.d, &v_len) != 0) {
827 const DSA_METHOD *meth;
828 UBSECerr(UBSEC_F_UBSEC_DSA_VERIFY , UBSEC_R_REQUEST_FAILED);
829 p_UBSEC_ubsec_close(fd);
830
831 meth = DSA_OpenSSL();
832 to_return = meth->dsa_do_verify(dgst, dgst_len, sig, dsa);
833
834 goto err;
835 }
836
837 p_UBSEC_ubsec_close(fd);
838
839 to_return = 1;
840err:
841 BN_clear_free(&v);
842 return to_return;
843 }
844#endif
845
846#ifndef OPENSSL_NO_DH
847static int ubsec_dh_compute_key (unsigned char *key,const BIGNUM *pub_key,DH *dh)
848 {
849 int ret = -1,
850 k_len,
851 fd;
852
853 k_len = BN_num_bits(dh->p);
854
855 if ((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) <= 0)
856 {
857 const DH_METHOD *meth;
858 ENGINEerr(UBSEC_F_UBSEC_INIT, UBSEC_R_UNIT_FAILURE);
859 meth = DH_OpenSSL();
860 ret = meth->compute_key(key, pub_key, dh);
861 goto err;
862 }
863
864 if (p_UBSEC_diffie_hellman_agree_ioctl(fd,
865 (unsigned char *)dh->priv_key->d, BN_num_bits(dh->priv_key),
866 (unsigned char *)pub_key->d, BN_num_bits(pub_key),
867 (unsigned char *)dh->p->d, BN_num_bits(dh->p),
868 key, &k_len) != 0)
869 {
870 /* Hardware's a no go, failover to software */
871 const DH_METHOD *meth;
872 ENGINEerr(UBSEC_F_UBSEC_DH_COMPUTE_KEY, UBSEC_R_REQUEST_FAILED);
873 p_UBSEC_ubsec_close(fd);
874
875 meth = DH_OpenSSL();
876 ret = meth->compute_key(key, pub_key, dh);
877
878 goto err;
879 }
880
881 p_UBSEC_ubsec_close(fd);
882
883 ret = p_UBSEC_ubsec_bits_to_bytes(k_len);
884err:
885 return ret;
886 }
887
888static int ubsec_dh_generate_key (DH *dh)
889 {
890 int ret = 0,
891 random_bits = 0,
892 pub_key_len = 0,
893 priv_key_len = 0,
894 fd;
895 BIGNUM *pub_key = NULL;
896 BIGNUM *priv_key = NULL;
897
898 /*
899 * How many bits should Random x be? dh_key.c
900 * sets the range from 0 to num_bits(modulus) ???
901 */
902
903 if (dh->priv_key == NULL)
904 {
905 priv_key = BN_new();
906 if (priv_key == NULL) goto err;
907 priv_key_len = BN_num_bits(dh->p);
908 bn_wexpand(priv_key, dh->p->top);
909 do
910 if (!BN_rand_range(priv_key, dh->p)) goto err;
911 while (BN_is_zero(priv_key));
912 random_bits = BN_num_bits(priv_key);
913 }
914 else
915 {
916 priv_key = dh->priv_key;
917 }
918
919 if (dh->pub_key == NULL)
920 {
921 pub_key = BN_new();
922 pub_key_len = BN_num_bits(dh->p);
923 bn_wexpand(pub_key, dh->p->top);
924 if(pub_key == NULL) goto err;
925 }
926 else
927 {
928 pub_key = dh->pub_key;
929 }
930
931 if ((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) <= 0)
932 {
933 const DH_METHOD *meth;
934 ENGINEerr(UBSEC_F_UBSEC_INIT, UBSEC_R_UNIT_FAILURE);
935 meth = DH_OpenSSL();
936 ret = meth->generate_key(dh);
937 goto err;
938 }
939
940 if (p_UBSEC_diffie_hellman_generate_ioctl(fd,
941 (unsigned char *)priv_key->d, &priv_key_len,
942 (unsigned char *)pub_key->d, &pub_key_len,
943 (unsigned char *)dh->g->d, BN_num_bits(dh->g),
944 (unsigned char *)dh->p->d, BN_num_bits(dh->p),
945 0, 0, random_bits) != 0)
946 {
947 /* Hardware's a no go, failover to software */
948 const DH_METHOD *meth;
949
950 ENGINEerr(UBSEC_F_UBSEC_DH_COMPUTE_KEY, UBSEC_R_REQUEST_FAILED);
951 p_UBSEC_ubsec_close(fd);
952
953 meth = DH_OpenSSL();
954 ret = meth->generate_key(dh);
955
956 goto err;
957 }
958
959 p_UBSEC_ubsec_close(fd);
960
961 dh->pub_key = pub_key;
962 dh->pub_key->top = (pub_key_len + BN_BITS2-1) / BN_BITS2;
963 dh->priv_key = priv_key;
964 dh->priv_key->top = (priv_key_len + BN_BITS2-1) / BN_BITS2;
965
966 ret = 1;
967err:
968 return ret;
969 }
970#endif
971
972#if NOT_USED
973static int ubsec_rand_bytes(unsigned char * buf,
974 int num)
975 {
976 int ret = 0,
977 fd;
978
979 if ((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) <= 0)
980 {
981 const RAND_METHOD *meth;
982 ENGINEerr(UBSEC_F_UBSEC_INIT, UBSEC_R_UNIT_FAILURE);
983 num = p_UBSEC_ubsec_bits_to_bytes(num);
984 meth = RAND_SSLeay();
985 meth->seed(buf, num);
986 ret = meth->bytes(buf, num);
987 goto err;
988 }
989
990 num *= 8; /* bytes to bits */
991
992 if (p_UBSEC_rng_ioctl(fd,
993 UBSEC_RNG_DIRECT,
994 buf,
995 &num) != 0)
996 {
997 /* Hardware's a no go, failover to software */
998 const RAND_METHOD *meth;
999
1000 ENGINEerr(UBSEC_F_UBSEC_RNG_BYTES, UBSEC_R_REQUEST_FAILED);
1001 p_UBSEC_ubsec_close(fd);
1002
1003 num = p_UBSEC_ubsec_bits_to_bytes(num);
1004 meth = RAND_SSLeay();
1005 meth->seed(buf, num);
1006 ret = meth->bytes(buf, num);
1007
1008 goto err;
1009 }
1010
1011 p_UBSEC_ubsec_close(fd);
1012
1013 ret = 1;
1014err:
1015 return(ret);
1016 }
1017
1018
1019static int ubsec_rand_status(void)
1020 {
1021 return 0;
1022 }
1023#endif
1024
1025/* This stuff is needed if this ENGINE is being compiled into a self-contained
1026 * shared-library. */
1027#ifdef ENGINE_DYNAMIC_SUPPORT
1028static int bind_fn(ENGINE *e, const char *id)
1029 {
1030 if(id && (strcmp(id, engine_ubsec_id) != 0))
1031 return 0;
1032 if(!bind_helper(e))
1033 return 0;
1034 return 1;
1035 }
1036IMPLEMENT_DYNAMIC_CHECK_FN()
1037IMPLEMENT_DYNAMIC_BIND_FN(bind_fn)
1038#endif /* ENGINE_DYNAMIC_SUPPORT */
1039
1040#endif /* !OPENSSL_NO_HW_UBSEC */
1041#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
new file mode 100644
index 0000000000..c5a50fc910
--- /dev/null
+++ b/src/lib/libcrypto/engine/tb_cipher.c
@@ -0,0 +1,145 @@
1/* ====================================================================
2 * Copyright (c) 2000 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 * licensing@OpenSSL.org.
25 *
26 * 5. Products derived from this software may not be called "OpenSSL"
27 * nor may "OpenSSL" appear in their names without prior written
28 * permission of the OpenSSL Project.
29 *
30 * 6. Redistributions of any form whatsoever must retain the following
31 * acknowledgment:
32 * "This product includes software developed by the OpenSSL Project
33 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
34 *
35 * 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#include <openssl/evp.h>
56#include <openssl/engine.h>
57#include "eng_int.h"
58
59/* If this symbol is defined then ENGINE_get_cipher_engine(), the function that
60 * is used by EVP to hook in cipher code and cache defaults (etc), will display
61 * brief debugging summaries to stderr with the 'nid'. */
62/* #define ENGINE_CIPHER_DEBUG */
63
64static ENGINE_TABLE *cipher_table = NULL;
65
66void ENGINE_unregister_ciphers(ENGINE *e)
67 {
68 engine_table_unregister(&cipher_table, e);
69 }
70
71static void engine_unregister_all_ciphers(void)
72 {
73 engine_table_cleanup(&cipher_table);
74 }
75
76int ENGINE_register_ciphers(ENGINE *e)
77 {
78 if(e->ciphers)
79 {
80 const int *nids;
81 int num_nids = e->ciphers(e, NULL, &nids, 0);
82 if(num_nids > 0)
83 return engine_table_register(&cipher_table,
84 &engine_unregister_all_ciphers, e, nids,
85 num_nids, 0);
86 }
87 return 1;
88 }
89
90void ENGINE_register_all_ciphers()
91 {
92 ENGINE *e;
93
94 for(e=ENGINE_get_first() ; e ; e=ENGINE_get_next(e))
95 ENGINE_register_ciphers(e);
96 }
97
98int ENGINE_set_default_ciphers(ENGINE *e)
99 {
100 if(e->ciphers)
101 {
102 const int *nids;
103 int num_nids = e->ciphers(e, NULL, &nids, 0);
104 if(num_nids > 0)
105 return engine_table_register(&cipher_table,
106 &engine_unregister_all_ciphers, e, nids,
107 num_nids, 1);
108 }
109 return 1;
110 }
111
112/* Exposed API function to get a functional reference from the implementation
113 * table (ie. try to get a functional reference from the tabled structural
114 * references) for a given cipher 'nid' */
115ENGINE *ENGINE_get_cipher_engine(int nid)
116 {
117 return engine_table_select(&cipher_table, nid);
118 }
119
120/* Obtains a cipher implementation from an ENGINE functional reference */
121const EVP_CIPHER *ENGINE_get_cipher(ENGINE *e, int nid)
122 {
123 const EVP_CIPHER *ret;
124 ENGINE_CIPHERS_PTR fn = ENGINE_get_ciphers(e);
125 if(!fn || !fn(e, &ret, NULL, nid))
126 {
127 ENGINEerr(ENGINE_F_ENGINE_GET_CIPHER,
128 ENGINE_R_UNIMPLEMENTED_CIPHER);
129 return NULL;
130 }
131 return ret;
132 }
133
134/* Gets the cipher callback from an ENGINE structure */
135ENGINE_CIPHERS_PTR ENGINE_get_ciphers(const ENGINE *e)
136 {
137 return e->ciphers;
138 }
139
140/* Sets the cipher callback in an ENGINE structure */
141int ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f)
142 {
143 e->ciphers = f;
144 return 1;
145 }
diff --git a/src/lib/libcrypto/engine/tb_dh.c b/src/lib/libcrypto/engine/tb_dh.c
new file mode 100644
index 0000000000..c9347235ea
--- /dev/null
+++ b/src/lib/libcrypto/engine/tb_dh.c
@@ -0,0 +1,120 @@
1/* ====================================================================
2 * Copyright (c) 2000 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 * licensing@OpenSSL.org.
25 *
26 * 5. Products derived from this software may not be called "OpenSSL"
27 * nor may "OpenSSL" appear in their names without prior written
28 * permission of the OpenSSL Project.
29 *
30 * 6. Redistributions of any form whatsoever must retain the following
31 * acknowledgment:
32 * "This product includes software developed by the OpenSSL Project
33 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
34 *
35 * 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#include <openssl/evp.h>
56#include <openssl/engine.h>
57#include "eng_int.h"
58
59/* If this symbol is defined then ENGINE_get_default_DH(), the function that is
60 * used by DH to hook in implementation code and cache defaults (etc), will
61 * display brief debugging summaries to stderr with the 'nid'. */
62/* #define ENGINE_DH_DEBUG */
63
64static ENGINE_TABLE *dh_table = NULL;
65static const int dummy_nid = 1;
66
67void ENGINE_unregister_DH(ENGINE *e)
68 {
69 engine_table_unregister(&dh_table, e);
70 }
71
72static void engine_unregister_all_DH(void)
73 {
74 engine_table_cleanup(&dh_table);
75 }
76
77int ENGINE_register_DH(ENGINE *e)
78 {
79 if(e->dh_meth)
80 return engine_table_register(&dh_table,
81 &engine_unregister_all_DH, e, &dummy_nid, 1, 0);
82 return 1;
83 }
84
85void ENGINE_register_all_DH()
86 {
87 ENGINE *e;
88
89 for(e=ENGINE_get_first() ; e ; e=ENGINE_get_next(e))
90 ENGINE_register_DH(e);
91 }
92
93int ENGINE_set_default_DH(ENGINE *e)
94 {
95 if(e->dh_meth)
96 return engine_table_register(&dh_table,
97 &engine_unregister_all_DH, e, &dummy_nid, 1, 1);
98 return 1;
99 }
100
101/* Exposed API function to get a functional reference from the implementation
102 * table (ie. try to get a functional reference from the tabled structural
103 * references). */
104ENGINE *ENGINE_get_default_DH(void)
105 {
106 return engine_table_select(&dh_table, dummy_nid);
107 }
108
109/* Obtains an DH implementation from an ENGINE functional reference */
110const DH_METHOD *ENGINE_get_DH(const ENGINE *e)
111 {
112 return e->dh_meth;
113 }
114
115/* Sets an DH implementation in an ENGINE structure */
116int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth)
117 {
118 e->dh_meth = dh_meth;
119 return 1;
120 }
diff --git a/src/lib/libcrypto/engine/tb_digest.c b/src/lib/libcrypto/engine/tb_digest.c
new file mode 100644
index 0000000000..2c4dd6f796
--- /dev/null
+++ b/src/lib/libcrypto/engine/tb_digest.c
@@ -0,0 +1,145 @@
1/* ====================================================================
2 * Copyright (c) 2000 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 * licensing@OpenSSL.org.
25 *
26 * 5. Products derived from this software may not be called "OpenSSL"
27 * nor may "OpenSSL" appear in their names without prior written
28 * permission of the OpenSSL Project.
29 *
30 * 6. Redistributions of any form whatsoever must retain the following
31 * acknowledgment:
32 * "This product includes software developed by the OpenSSL Project
33 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
34 *
35 * 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#include <openssl/evp.h>
56#include <openssl/engine.h>
57#include "eng_int.h"
58
59/* If this symbol is defined then ENGINE_get_digest_engine(), the function that
60 * is used by EVP to hook in digest code and cache defaults (etc), will display
61 * brief debugging summaries to stderr with the 'nid'. */
62/* #define ENGINE_DIGEST_DEBUG */
63
64static ENGINE_TABLE *digest_table = NULL;
65
66void ENGINE_unregister_digests(ENGINE *e)
67 {
68 engine_table_unregister(&digest_table, e);
69 }
70
71static void engine_unregister_all_digests(void)
72 {
73 engine_table_cleanup(&digest_table);
74 }
75
76int ENGINE_register_digests(ENGINE *e)
77 {
78 if(e->digests)
79 {
80 const int *nids;
81 int num_nids = e->digests(e, NULL, &nids, 0);
82 if(num_nids > 0)
83 return engine_table_register(&digest_table,
84 &engine_unregister_all_digests, e, nids,
85 num_nids, 0);
86 }
87 return 1;
88 }
89
90void ENGINE_register_all_digests()
91 {
92 ENGINE *e;
93
94 for(e=ENGINE_get_first() ; e ; e=ENGINE_get_next(e))
95 ENGINE_register_digests(e);
96 }
97
98int ENGINE_set_default_digests(ENGINE *e)
99 {
100 if(e->digests)
101 {
102 const int *nids;
103 int num_nids = e->digests(e, NULL, &nids, 0);
104 if(num_nids > 0)
105 return engine_table_register(&digest_table,
106 &engine_unregister_all_digests, e, nids,
107 num_nids, 1);
108 }
109 return 1;
110 }
111
112/* Exposed API function to get a functional reference from the implementation
113 * table (ie. try to get a functional reference from the tabled structural
114 * references) for a given digest 'nid' */
115ENGINE *ENGINE_get_digest_engine(int nid)
116 {
117 return engine_table_select(&digest_table, nid);
118 }
119
120/* Obtains a digest implementation from an ENGINE functional reference */
121const EVP_MD *ENGINE_get_digest(ENGINE *e, int nid)
122 {
123 const EVP_MD *ret;
124 ENGINE_DIGESTS_PTR fn = ENGINE_get_digests(e);
125 if(!fn || !fn(e, &ret, NULL, nid))
126 {
127 ENGINEerr(ENGINE_F_ENGINE_GET_DIGEST,
128 ENGINE_R_UNIMPLEMENTED_DIGEST);
129 return NULL;
130 }
131 return ret;
132 }
133
134/* Gets the digest callback from an ENGINE structure */
135ENGINE_DIGESTS_PTR ENGINE_get_digests(const ENGINE *e)
136 {
137 return e->digests;
138 }
139
140/* Sets the digest callback in an ENGINE structure */
141int ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f)
142 {
143 e->digests = f;
144 return 1;
145 }
diff --git a/src/lib/libcrypto/engine/tb_dsa.c b/src/lib/libcrypto/engine/tb_dsa.c
new file mode 100644
index 0000000000..e9209476b8
--- /dev/null
+++ b/src/lib/libcrypto/engine/tb_dsa.c
@@ -0,0 +1,120 @@
1/* ====================================================================
2 * Copyright (c) 2000 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 * licensing@OpenSSL.org.
25 *
26 * 5. Products derived from this software may not be called "OpenSSL"
27 * nor may "OpenSSL" appear in their names without prior written
28 * permission of the OpenSSL Project.
29 *
30 * 6. Redistributions of any form whatsoever must retain the following
31 * acknowledgment:
32 * "This product includes software developed by the OpenSSL Project
33 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
34 *
35 * 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#include <openssl/evp.h>
56#include <openssl/engine.h>
57#include "eng_int.h"
58
59/* If this symbol is defined then ENGINE_get_default_DSA(), the function that is
60 * used by DSA to hook in implementation code and cache defaults (etc), will
61 * display brief debugging summaries to stderr with the 'nid'. */
62/* #define ENGINE_DSA_DEBUG */
63
64static ENGINE_TABLE *dsa_table = NULL;
65static const int dummy_nid = 1;
66
67void ENGINE_unregister_DSA(ENGINE *e)
68 {
69 engine_table_unregister(&dsa_table, e);
70 }
71
72static void engine_unregister_all_DSA(void)
73 {
74 engine_table_cleanup(&dsa_table);
75 }
76
77int ENGINE_register_DSA(ENGINE *e)
78 {
79 if(e->dsa_meth)
80 return engine_table_register(&dsa_table,
81 &engine_unregister_all_DSA, e, &dummy_nid, 1, 0);
82 return 1;
83 }
84
85void ENGINE_register_all_DSA()
86 {
87 ENGINE *e;
88
89 for(e=ENGINE_get_first() ; e ; e=ENGINE_get_next(e))
90 ENGINE_register_DSA(e);
91 }
92
93int ENGINE_set_default_DSA(ENGINE *e)
94 {
95 if(e->dsa_meth)
96 return engine_table_register(&dsa_table,
97 &engine_unregister_all_DSA, e, &dummy_nid, 1, 0);
98 return 1;
99 }
100
101/* Exposed API function to get a functional reference from the implementation
102 * table (ie. try to get a functional reference from the tabled structural
103 * references). */
104ENGINE *ENGINE_get_default_DSA(void)
105 {
106 return engine_table_select(&dsa_table, dummy_nid);
107 }
108
109/* Obtains an DSA implementation from an ENGINE functional reference */
110const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e)
111 {
112 return e->dsa_meth;
113 }
114
115/* Sets an DSA implementation in an ENGINE structure */
116int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth)
117 {
118 e->dsa_meth = dsa_meth;
119 return 1;
120 }
diff --git a/src/lib/libcrypto/engine/tb_rand.c b/src/lib/libcrypto/engine/tb_rand.c
new file mode 100644
index 0000000000..0b1d031f1e
--- /dev/null
+++ b/src/lib/libcrypto/engine/tb_rand.c
@@ -0,0 +1,120 @@
1/* ====================================================================
2 * Copyright (c) 2000 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 * licensing@OpenSSL.org.
25 *
26 * 5. Products derived from this software may not be called "OpenSSL"
27 * nor may "OpenSSL" appear in their names without prior written
28 * permission of the OpenSSL Project.
29 *
30 * 6. Redistributions of any form whatsoever must retain the following
31 * acknowledgment:
32 * "This product includes software developed by the OpenSSL Project
33 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
34 *
35 * 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#include <openssl/evp.h>
56#include <openssl/engine.h>
57#include "eng_int.h"
58
59/* If this symbol is defined then ENGINE_get_default_RAND(), the function that is
60 * used by RAND to hook in implementation code and cache defaults (etc), will
61 * display brief debugging summaries to stderr with the 'nid'. */
62/* #define ENGINE_RAND_DEBUG */
63
64static ENGINE_TABLE *rand_table = NULL;
65static const int dummy_nid = 1;
66
67void ENGINE_unregister_RAND(ENGINE *e)
68 {
69 engine_table_unregister(&rand_table, e);
70 }
71
72static void engine_unregister_all_RAND(void)
73 {
74 engine_table_cleanup(&rand_table);
75 }
76
77int ENGINE_register_RAND(ENGINE *e)
78 {
79 if(e->rand_meth)
80 return engine_table_register(&rand_table,
81 &engine_unregister_all_RAND, e, &dummy_nid, 1, 0);
82 return 1;
83 }
84
85void ENGINE_register_all_RAND()
86 {
87 ENGINE *e;
88
89 for(e=ENGINE_get_first() ; e ; e=ENGINE_get_next(e))
90 ENGINE_register_RAND(e);
91 }
92
93int ENGINE_set_default_RAND(ENGINE *e)
94 {
95 if(e->rand_meth)
96 return engine_table_register(&rand_table,
97 &engine_unregister_all_RAND, e, &dummy_nid, 1, 1);
98 return 1;
99 }
100
101/* Exposed API function to get a functional reference from the implementation
102 * table (ie. try to get a functional reference from the tabled structural
103 * references). */
104ENGINE *ENGINE_get_default_RAND(void)
105 {
106 return engine_table_select(&rand_table, dummy_nid);
107 }
108
109/* Obtains an RAND implementation from an ENGINE functional reference */
110const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e)
111 {
112 return e->rand_meth;
113 }
114
115/* Sets an RAND implementation in an ENGINE structure */
116int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth)
117 {
118 e->rand_meth = rand_meth;
119 return 1;
120 }
diff --git a/src/lib/libcrypto/engine/tb_rsa.c b/src/lib/libcrypto/engine/tb_rsa.c
new file mode 100644
index 0000000000..f84fea3968
--- /dev/null
+++ b/src/lib/libcrypto/engine/tb_rsa.c
@@ -0,0 +1,120 @@
1/* ====================================================================
2 * Copyright (c) 2000 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 * licensing@OpenSSL.org.
25 *
26 * 5. Products derived from this software may not be called "OpenSSL"
27 * nor may "OpenSSL" appear in their names without prior written
28 * permission of the OpenSSL Project.
29 *
30 * 6. Redistributions of any form whatsoever must retain the following
31 * acknowledgment:
32 * "This product includes software developed by the OpenSSL Project
33 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
34 *
35 * 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#include <openssl/evp.h>
56#include <openssl/engine.h>
57#include "eng_int.h"
58
59/* If this symbol is defined then ENGINE_get_default_RSA(), the function that is
60 * used by RSA to hook in implementation code and cache defaults (etc), will
61 * display brief debugging summaries to stderr with the 'nid'. */
62/* #define ENGINE_RSA_DEBUG */
63
64static ENGINE_TABLE *rsa_table = NULL;
65static const int dummy_nid = 1;
66
67void ENGINE_unregister_RSA(ENGINE *e)
68 {
69 engine_table_unregister(&rsa_table, e);
70 }
71
72static void engine_unregister_all_RSA(void)
73 {
74 engine_table_cleanup(&rsa_table);
75 }
76
77int ENGINE_register_RSA(ENGINE *e)
78 {
79 if(e->rsa_meth)
80 return engine_table_register(&rsa_table,
81 &engine_unregister_all_RSA, e, &dummy_nid, 1, 0);
82 return 1;
83 }
84
85void ENGINE_register_all_RSA()
86 {
87 ENGINE *e;
88
89 for(e=ENGINE_get_first() ; e ; e=ENGINE_get_next(e))
90 ENGINE_register_RSA(e);
91 }
92
93int ENGINE_set_default_RSA(ENGINE *e)
94 {
95 if(e->rsa_meth)
96 return engine_table_register(&rsa_table,
97 &engine_unregister_all_RSA, e, &dummy_nid, 1, 1);
98 return 1;
99 }
100
101/* Exposed API function to get a functional reference from the implementation
102 * table (ie. try to get a functional reference from the tabled structural
103 * references). */
104ENGINE *ENGINE_get_default_RSA(void)
105 {
106 return engine_table_select(&rsa_table, dummy_nid);
107 }
108
109/* Obtains an RSA implementation from an ENGINE functional reference */
110const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e)
111 {
112 return e->rsa_meth;
113 }
114
115/* Sets an RSA implementation in an ENGINE structure */
116int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth)
117 {
118 e->rsa_meth = rsa_meth;
119 return 1;
120 }
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
index 8111649c54..149970d441 100644
--- a/src/lib/libcrypto/engine/vendor_defns/atalla.h
+++ b/src/lib/libcrypto/engine/vendor_defns/atalla.h
@@ -46,16 +46,3 @@ typedef int tfnASI_RSAPrivateKeyOpFn(RSAPrivateKey * rsaKey,
46 unsigned char *input, 46 unsigned char *input,
47 unsigned int modulus_len); 47 unsigned int modulus_len);
48 48
49/* These are the static string constants for the DSO file name and the function
50 * symbol names to bind to. Regrettably, the DSO name on *nix appears to be
51 * "atasi.so" rather than something more consistent like "libatasi.so". At the
52 * time of writing, I'm not sure what the file name on win32 is but clearly
53 * native name translation is not possible (eg libatasi.so on *nix, and
54 * atasi.dll on win32). For the purposes of testing, I have created a symbollic
55 * link called "libatasi.so" so that we can use native name-translation - a
56 * better solution will be needed. */
57static const char *ATALLA_LIBNAME = "atasi";
58static const char *ATALLA_F1 = "ASI_GetHardwareConfig";
59static const char *ATALLA_F2 = "ASI_RSAPrivateKeyOpFn";
60static const char *ATALLA_F3 = "ASI_GetPerformanceStatistics";
61
diff --git a/src/lib/libcrypto/engine/vendor_defns/cswift.h b/src/lib/libcrypto/engine/vendor_defns/cswift.h
index 0af14a1a92..60079326bb 100644
--- a/src/lib/libcrypto/engine/vendor_defns/cswift.h
+++ b/src/lib/libcrypto/engine/vendor_defns/cswift.h
@@ -32,12 +32,12 @@ typedef __uint32_t SW_U32;
32typedef unsigned long SW_U32; /* 32 bit integer */ 32typedef unsigned long SW_U32; /* 32 bit integer */
33#endif 33#endif
34 34
35#if defined(WIN32) 35#if defined(OPENSSL_SYS_WIN32)
36 typedef struct _SW_U64 { 36 typedef struct _SW_U64 {
37 SW_U32 low32; 37 SW_U32 low32;
38 SW_U32 high32; 38 SW_U32 high32;
39 } SW_U64; /* 64 bit integer */ 39 } SW_U64; /* 64 bit integer */
40#elif defined(MAC) 40#elif defined(OPENSSL_SYS_MACINTOSH_CLASSIC)
41 typedef longlong SW_U64 41 typedef longlong SW_U64
42#else /* Unix variants */ 42#else /* Unix variants */
43 typedef struct _SW_U64 { 43 typedef struct _SW_U64 {
@@ -156,6 +156,27 @@ typedef struct _SW_LARGENUMBER {
156 /* bytes in network (big endian) order */ 156 /* bytes in network (big endian) order */
157} SW_LARGENUMBER; 157} SW_LARGENUMBER;
158 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
159typedef struct _SW_CRT { 180typedef struct _SW_CRT {
160 SW_LARGENUMBER p; /* prime number p */ 181 SW_LARGENUMBER p; /* prime number p */
161 SW_LARGENUMBER q; /* prime number q */ 182 SW_LARGENUMBER q; /* prime number q */
@@ -196,16 +217,16 @@ typedef SW_U32 SW_CONTEXT_HANDLE; /* opaque context handle */
196 217
197/* Now the OpenSSL bits, these function types are the for the function 218/* Now the OpenSSL bits, these function types are the for the function
198 * pointers that will bound into the Rainbow shared libraries. */ 219 * pointers that will bound into the Rainbow shared libraries. */
199typedef SW_STATUS t_swAcquireAccContext(SW_CONTEXT_HANDLE *hac); 220typedef SW_STATUS SW_CALLCONV t_swAcquireAccContext(SW_CONTEXT_HANDLE *hac);
200typedef SW_STATUS t_swAttachKeyParam(SW_CONTEXT_HANDLE hac, 221typedef SW_STATUS SW_CALLCONV t_swAttachKeyParam(SW_CONTEXT_HANDLE hac,
201 SW_PARAM *key_params); 222 SW_PARAM *key_params);
202typedef SW_STATUS t_swSimpleRequest(SW_CONTEXT_HANDLE hac, 223typedef SW_STATUS SW_CALLCONV t_swSimpleRequest(SW_CONTEXT_HANDLE hac,
203 SW_COMMAND_CODE cmd, 224 SW_COMMAND_CODE cmd,
204 SW_LARGENUMBER pin[], 225 SW_LARGENUMBER pin[],
205 SW_U32 pin_count, 226 SW_U32 pin_count,
206 SW_LARGENUMBER pout[], 227 SW_LARGENUMBER pout[],
207 SW_U32 pout_count); 228 SW_U32 pout_count);
208typedef SW_STATUS t_swReleaseAccContext(SW_CONTEXT_HANDLE hac); 229typedef SW_STATUS SW_CALLCONV t_swReleaseAccContext(SW_CONTEXT_HANDLE hac);
209 230
210#ifdef __cplusplus 231#ifdef __cplusplus
211} 232}
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
index 58218d1cea..4e69b9fbab 100644
--- a/src/lib/libcrypto/err/Makefile.ssl
+++ b/src/lib/libcrypto/err/Makefile.ssl
@@ -5,13 +5,14 @@
5DIR= err 5DIR= err
6TOP= ../.. 6TOP= ../..
7CC= cc 7CC= cc
8INCLUDES= -I.. -I../../include 8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g 9CFLAG=-g
10INSTALL_PREFIX= 10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl 11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl 12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl 13MAKE= make -f Makefile.ssl
14MAKEDEPEND= $(TOP)/util/domd $(TOP) 14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
15MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
16AR= ar r 17AR= ar r
17 18
@@ -39,8 +40,7 @@ all: lib
39 40
40lib: $(LIBOBJ) 41lib: $(LIBOBJ)
41 $(AR) $(LIB) $(LIBOBJ) 42 $(AR) $(LIB) $(LIBOBJ)
42 @echo You may get an error following this line. Please ignore. 43 $(RANLIB) $(LIB) || echo Never mind.
43 - $(RANLIB) $(LIB)
44 @touch lib 44 @touch lib
45 45
46files: 46files:
@@ -79,39 +79,34 @@ clean:
79 79
80# DO NOT DELETE THIS LINE -- make depend depends on it. 80# DO NOT DELETE THIS LINE -- make depend depends on it.
81 81
82err.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 82err.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/buffer.h
83err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 83err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
84err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 84err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
85err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 85err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
86err.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 86err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
87err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 87err.o: ../../include/openssl/symhacks.h ../cryptlib.h err.c
88err.o: ../cryptlib.h
89err_all.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 88err_all.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
90err_all.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 89err_all.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
91err_all.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
92err_all.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h 90err_all.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
93err_all.o: ../../include/openssl/des.h ../../include/openssl/dh.h 91err_all.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
94err_all.o: ../../include/openssl/dsa.h ../../include/openssl/dso.h 92err_all.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
95err_all.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 93err_all.o: ../../include/openssl/ec.h ../../include/openssl/engine.h
96err_all.o: ../../include/openssl/engine.h ../../include/openssl/err.h 94err_all.o: ../../include/openssl/err.h ../../include/openssl/evp.h
97err_all.o: ../../include/openssl/evp.h ../../include/openssl/idea.h 95err_all.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
98err_all.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h 96err_all.o: ../../include/openssl/objects.h ../../include/openssl/ocsp.h
99err_all.o: ../../include/openssl/md4.h ../../include/openssl/md5.h 97err_all.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
100err_all.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h 98err_all.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem2.h
101err_all.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
102err_all.o: ../../include/openssl/opensslv.h ../../include/openssl/pem2.h
103err_all.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h 99err_all.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
104err_all.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h 100err_all.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
105err_all.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
106err_all.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
107err_all.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 101err_all.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
108err_all.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 102err_all.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
109err_all.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 103err_all.o: ../../include/openssl/ui.h ../../include/openssl/x509.h
110err_all.o: ../../include/openssl/x509v3.h 104err_all.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
111err_prn.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 105err_all.o: err_all.c
112err_prn.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 106err_prn.o: ../../e_os.h ../../include/openssl/bio.h
107err_prn.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
113err_prn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 108err_prn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
114err_prn.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 109err_prn.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
115err_prn.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 110err_prn.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
116err_prn.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 111err_prn.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
117err_prn.o: ../cryptlib.h 112err_prn.o: ../cryptlib.h err_prn.c
diff --git a/src/lib/libcrypto/err/err.c b/src/lib/libcrypto/err/err.c
index 839f4ab81a..04773d65a6 100644
--- a/src/lib/libcrypto/err/err.c
+++ b/src/lib/libcrypto/err/err.c
@@ -56,7 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58/* ==================================================================== 58/* ====================================================================
59 * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. 59 * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.
60 * 60 *
61 * Redistribution and use in source and binary forms, with or without 61 * Redistribution and use in source and binary forms, with or without
62 * modification, are permitted provided that the following conditions 62 * modification, are permitted provided that the following conditions
@@ -119,38 +119,28 @@
119#include <openssl/bio.h> 119#include <openssl/bio.h>
120#include <openssl/err.h> 120#include <openssl/err.h>
121 121
122static void err_load_strings(int lib, ERR_STRING_DATA *str);
122 123
123static LHASH *error_hash=NULL;
124static LHASH *thread_hash=NULL;
125
126static unsigned long err_hash(ERR_STRING_DATA *a);
127static int err_cmp(ERR_STRING_DATA *a, ERR_STRING_DATA *b);
128static unsigned long pid_hash(ERR_STATE *pid);
129static int pid_cmp(ERR_STATE *a,ERR_STATE *pid);
130static unsigned long get_error_values(int inc,const char **file,int *line,
131 const char **data,int *flags);
132static void ERR_STATE_free(ERR_STATE *s); 124static void ERR_STATE_free(ERR_STATE *s);
133#ifndef NO_ERR 125#ifndef OPENSSL_NO_ERR
134static ERR_STRING_DATA ERR_str_libraries[]= 126static ERR_STRING_DATA ERR_str_libraries[]=
135 { 127 {
136{ERR_PACK(ERR_LIB_NONE,0,0) ,"unknown library"}, 128{ERR_PACK(ERR_LIB_NONE,0,0) ,"unknown library"},
137{ERR_PACK(ERR_LIB_SYS,0,0) ,"system library"}, 129{ERR_PACK(ERR_LIB_SYS,0,0) ,"system library"},
138{ERR_PACK(ERR_LIB_BN,0,0) ,"bignum routines"}, 130{ERR_PACK(ERR_LIB_BN,0,0) ,"bignum routines"},
139{ERR_PACK(ERR_LIB_RSA,0,0) ,"rsa routines"}, 131{ERR_PACK(ERR_LIB_RSA,0,0) ,"rsa routines"},
140{ERR_PACK(ERR_LIB_DSA,0,0) ,"dsa routines"},
141{ERR_PACK(ERR_LIB_DH,0,0) ,"Diffie-Hellman routines"}, 132{ERR_PACK(ERR_LIB_DH,0,0) ,"Diffie-Hellman routines"},
142{ERR_PACK(ERR_LIB_EVP,0,0) ,"digital envelope routines"}, 133{ERR_PACK(ERR_LIB_EVP,0,0) ,"digital envelope routines"},
143{ERR_PACK(ERR_LIB_BUF,0,0) ,"memory buffer routines"}, 134{ERR_PACK(ERR_LIB_BUF,0,0) ,"memory buffer routines"},
144{ERR_PACK(ERR_LIB_BIO,0,0) ,"BIO routines"},
145{ERR_PACK(ERR_LIB_OBJ,0,0) ,"object identifier routines"}, 135{ERR_PACK(ERR_LIB_OBJ,0,0) ,"object identifier routines"},
146{ERR_PACK(ERR_LIB_PEM,0,0) ,"PEM routines"}, 136{ERR_PACK(ERR_LIB_PEM,0,0) ,"PEM routines"},
147{ERR_PACK(ERR_LIB_ASN1,0,0) ,"asn1 encoding routines"}, 137{ERR_PACK(ERR_LIB_DSA,0,0) ,"dsa routines"},
148{ERR_PACK(ERR_LIB_X509,0,0) ,"x509 certificate routines"}, 138{ERR_PACK(ERR_LIB_X509,0,0) ,"x509 certificate routines"},
139{ERR_PACK(ERR_LIB_ASN1,0,0) ,"asn1 encoding routines"},
149{ERR_PACK(ERR_LIB_CONF,0,0) ,"configuration file routines"}, 140{ERR_PACK(ERR_LIB_CONF,0,0) ,"configuration file routines"},
150{ERR_PACK(ERR_LIB_METH,0,0) ,"X509 lookup 'method' routines"}, 141{ERR_PACK(ERR_LIB_CRYPTO,0,0) ,"common libcrypto routines"},
142{ERR_PACK(ERR_LIB_EC,0,0) ,"elliptic curve routines"},
151{ERR_PACK(ERR_LIB_SSL,0,0) ,"SSL routines"}, 143{ERR_PACK(ERR_LIB_SSL,0,0) ,"SSL routines"},
152{ERR_PACK(ERR_LIB_RSAREF,0,0) ,"RSAref routines"},
153{ERR_PACK(ERR_LIB_PROXY,0,0) ,"Proxy routines"},
154{ERR_PACK(ERR_LIB_BIO,0,0) ,"BIO routines"}, 144{ERR_PACK(ERR_LIB_BIO,0,0) ,"BIO routines"},
155{ERR_PACK(ERR_LIB_PKCS7,0,0) ,"PKCS7 routines"}, 145{ERR_PACK(ERR_LIB_PKCS7,0,0) ,"PKCS7 routines"},
156{ERR_PACK(ERR_LIB_X509V3,0,0) ,"X509 V3 routines"}, 146{ERR_PACK(ERR_LIB_X509V3,0,0) ,"X509 V3 routines"},
@@ -158,6 +148,7 @@ static ERR_STRING_DATA ERR_str_libraries[]=
158{ERR_PACK(ERR_LIB_RAND,0,0) ,"random number generator"}, 148{ERR_PACK(ERR_LIB_RAND,0,0) ,"random number generator"},
159{ERR_PACK(ERR_LIB_DSO,0,0) ,"DSO support routines"}, 149{ERR_PACK(ERR_LIB_DSO,0,0) ,"DSO support routines"},
160{ERR_PACK(ERR_LIB_ENGINE,0,0) ,"engine routines"}, 150{ERR_PACK(ERR_LIB_ENGINE,0,0) ,"engine routines"},
151{ERR_PACK(ERR_LIB_OCSP,0,0) ,"OCSP routines"},
161{0,NULL}, 152{0,NULL},
162 }; 153 };
163 154
@@ -171,7 +162,7 @@ static ERR_STRING_DATA ERR_str_functs[]=
171 {ERR_PACK(0,SYS_F_BIND,0), "bind"}, 162 {ERR_PACK(0,SYS_F_BIND,0), "bind"},
172 {ERR_PACK(0,SYS_F_LISTEN,0), "listen"}, 163 {ERR_PACK(0,SYS_F_LISTEN,0), "listen"},
173 {ERR_PACK(0,SYS_F_ACCEPT,0), "accept"}, 164 {ERR_PACK(0,SYS_F_ACCEPT,0), "accept"},
174#ifdef WINDOWS 165#ifdef OPENSSL_SYS_WINDOWS
175 {ERR_PACK(0,SYS_F_WSASTARTUP,0), "WSAstartup"}, 166 {ERR_PACK(0,SYS_F_WSASTARTUP,0), "WSAstartup"},
176#endif 167#endif
177 {ERR_PACK(0,SYS_F_OPENDIR,0), "opendir"}, 168 {ERR_PACK(0,SYS_F_OPENDIR,0), "opendir"},
@@ -180,41 +171,325 @@ static ERR_STRING_DATA ERR_str_functs[]=
180 171
181static ERR_STRING_DATA ERR_str_reasons[]= 172static ERR_STRING_DATA ERR_str_reasons[]=
182 { 173 {
183{ERR_R_FATAL ,"fatal"},
184{ERR_R_SYS_LIB ,"system lib"}, 174{ERR_R_SYS_LIB ,"system lib"},
185{ERR_R_BN_LIB ,"BN lib"}, 175{ERR_R_BN_LIB ,"BN lib"},
186{ERR_R_RSA_LIB ,"RSA lib"}, 176{ERR_R_RSA_LIB ,"RSA lib"},
187{ERR_R_DH_LIB ,"DH lib"}, 177{ERR_R_DH_LIB ,"DH lib"},
188{ERR_R_EVP_LIB ,"EVP lib"}, 178{ERR_R_EVP_LIB ,"EVP lib"},
189{ERR_R_BUF_LIB ,"BUF lib"}, 179{ERR_R_BUF_LIB ,"BUF lib"},
190{ERR_R_BIO_LIB ,"BIO lib"},
191{ERR_R_OBJ_LIB ,"OBJ lib"}, 180{ERR_R_OBJ_LIB ,"OBJ lib"},
192{ERR_R_PEM_LIB ,"PEM lib"}, 181{ERR_R_PEM_LIB ,"PEM lib"},
182{ERR_R_DSA_LIB ,"DSA lib"},
193{ERR_R_X509_LIB ,"X509 lib"}, 183{ERR_R_X509_LIB ,"X509 lib"},
194{ERR_R_METH_LIB ,"METH lib"},
195{ERR_R_ASN1_LIB ,"ASN1 lib"}, 184{ERR_R_ASN1_LIB ,"ASN1 lib"},
196{ERR_R_CONF_LIB ,"CONF lib"}, 185{ERR_R_CONF_LIB ,"CONF lib"},
186{ERR_R_CRYPTO_LIB ,"CRYPTO lib"},
187{ERR_R_EC_LIB ,"EC lib"},
197{ERR_R_SSL_LIB ,"SSL lib"}, 188{ERR_R_SSL_LIB ,"SSL lib"},
198{ERR_R_PROXY_LIB ,"PROXY lib"},
199{ERR_R_BIO_LIB ,"BIO lib"}, 189{ERR_R_BIO_LIB ,"BIO lib"},
200{ERR_R_PKCS7_LIB ,"PKCS7 lib"}, 190{ERR_R_PKCS7_LIB ,"PKCS7 lib"},
191{ERR_R_X509V3_LIB ,"X509V3 lib"},
201{ERR_R_PKCS12_LIB ,"PKCS12 lib"}, 192{ERR_R_PKCS12_LIB ,"PKCS12 lib"},
202{ERR_R_MALLOC_FAILURE ,"Malloc failure"}, 193{ERR_R_RAND_LIB ,"RAND lib"},
203{ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED ,"called a function you should not call"}, 194{ERR_R_DSO_LIB ,"DSO lib"},
204{ERR_R_PASSED_NULL_PARAMETER ,"passed a null parameter"}, 195{ERR_R_ENGINE_LIB ,"ENGINE lib"},
196{ERR_R_OCSP_LIB ,"OCSP lib"},
197
205{ERR_R_NESTED_ASN1_ERROR ,"nested asn1 error"}, 198{ERR_R_NESTED_ASN1_ERROR ,"nested asn1 error"},
206{ERR_R_BAD_ASN1_OBJECT_HEADER ,"bad asn1 object header"}, 199{ERR_R_BAD_ASN1_OBJECT_HEADER ,"bad asn1 object header"},
207{ERR_R_BAD_GET_ASN1_OBJECT_CALL ,"bad get asn1 object call"}, 200{ERR_R_BAD_GET_ASN1_OBJECT_CALL ,"bad get asn1 object call"},
208{ERR_R_EXPECTING_AN_ASN1_SEQUENCE ,"expecting an asn1 sequence"}, 201{ERR_R_EXPECTING_AN_ASN1_SEQUENCE ,"expecting an asn1 sequence"},
209{ERR_R_ASN1_LENGTH_MISMATCH ,"asn1 length mismatch"}, 202{ERR_R_ASN1_LENGTH_MISMATCH ,"asn1 length mismatch"},
210{ERR_R_MISSING_ASN1_EOS ,"missing asn1 eos"}, 203{ERR_R_MISSING_ASN1_EOS ,"missing asn1 eos"},
211{ERR_R_DSO_LIB ,"DSO lib"}, 204
212{ERR_R_ENGINE_LIB ,"ENGINE lib"}, 205{ERR_R_FATAL ,"fatal"},
206{ERR_R_MALLOC_FAILURE ,"malloc failure"},
207{ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED ,"called a function you should not call"},
208{ERR_R_PASSED_NULL_PARAMETER ,"passed a null parameter"},
209{ERR_R_INTERNAL_ERROR ,"internal error"},
213 210
214{0,NULL}, 211{0,NULL},
215 }; 212 };
216 213
217 214
215/* Define the predeclared (but externally opaque) "ERR_FNS" type */
216struct st_ERR_FNS
217 {
218 /* Works on the "error_hash" string table */
219 LHASH *(*cb_err_get)(int create);
220 void (*cb_err_del)(void);
221 ERR_STRING_DATA *(*cb_err_get_item)(const ERR_STRING_DATA *);
222 ERR_STRING_DATA *(*cb_err_set_item)(ERR_STRING_DATA *);
223 ERR_STRING_DATA *(*cb_err_del_item)(ERR_STRING_DATA *);
224 /* Works on the "thread_hash" error-state table */
225 LHASH *(*cb_thread_get)(int create);
226 ERR_STATE *(*cb_thread_get_item)(const ERR_STATE *);
227 ERR_STATE *(*cb_thread_set_item)(ERR_STATE *);
228 void (*cb_thread_del_item)(const ERR_STATE *);
229 /* Returns the next available error "library" numbers */
230 int (*cb_get_next_lib)(void);
231 };
232
233/* Predeclarations of the "err_defaults" functions */
234static LHASH *int_err_get(int create);
235static void int_err_del(void);
236static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *);
237static ERR_STRING_DATA *int_err_set_item(ERR_STRING_DATA *);
238static ERR_STRING_DATA *int_err_del_item(ERR_STRING_DATA *);
239static LHASH *int_thread_get(int create);
240static ERR_STATE *int_thread_get_item(const ERR_STATE *);
241static ERR_STATE *int_thread_set_item(ERR_STATE *);
242static void int_thread_del_item(const ERR_STATE *);
243static int int_err_get_next_lib(void);
244/* The static ERR_FNS table using these defaults functions */
245static const ERR_FNS err_defaults =
246 {
247 int_err_get,
248 int_err_del,
249 int_err_get_item,
250 int_err_set_item,
251 int_err_del_item,
252 int_thread_get,
253 int_thread_get_item,
254 int_thread_set_item,
255 int_thread_del_item,
256 int_err_get_next_lib
257 };
258
259/* The replacable table of ERR_FNS functions we use at run-time */
260static const ERR_FNS *err_fns = NULL;
261
262/* Eg. rather than using "err_get()", use "ERRFN(err_get)()". */
263#define ERRFN(a) err_fns->cb_##a
264
265/* The internal state used by "err_defaults" - as such, the setting, reading,
266 * creating, and deleting of this data should only be permitted via the
267 * "err_defaults" functions. This way, a linked module can completely defer all
268 * ERR state operation (together with requisite locking) to the implementations
269 * and state in the loading application. */
270static LHASH *int_error_hash = NULL;
271static LHASH *int_thread_hash = NULL;
272static int int_err_library_number= ERR_LIB_USER;
273
274/* Internal function that checks whether "err_fns" is set and if not, sets it to
275 * the defaults. */
276static void err_fns_check(void)
277 {
278 if (err_fns) return;
279
280 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
281 if (!err_fns)
282 err_fns = &err_defaults;
283 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
284 }
285
286/* API functions to get or set the underlying ERR functions. */
287
288const ERR_FNS *ERR_get_implementation(void)
289 {
290 err_fns_check();
291 return err_fns;
292 }
293
294int ERR_set_implementation(const ERR_FNS *fns)
295 {
296 int ret = 0;
297
298 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
299 /* It's too late if 'err_fns' is non-NULL. BTW: not much point setting
300 * an error is there?! */
301 if (!err_fns)
302 {
303 err_fns = fns;
304 ret = 1;
305 }
306 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
307 return ret;
308 }
309
310/* These are the callbacks provided to "lh_new()" when creating the LHASH tables
311 * internal to the "err_defaults" implementation. */
312
313/* static unsigned long err_hash(ERR_STRING_DATA *a); */
314static unsigned long err_hash(const void *a_void);
315/* static int err_cmp(ERR_STRING_DATA *a, ERR_STRING_DATA *b); */
316static int err_cmp(const void *a_void, const void *b_void);
317/* static unsigned long pid_hash(ERR_STATE *pid); */
318static unsigned long pid_hash(const void *pid_void);
319/* static int pid_cmp(ERR_STATE *a,ERR_STATE *pid); */
320static int pid_cmp(const void *a_void,const void *pid_void);
321static unsigned long get_error_values(int inc,int top,const char **file,int *line,
322 const char **data,int *flags);
323
324/* The internal functions used in the "err_defaults" implementation */
325
326static LHASH *int_err_get(int create)
327 {
328 LHASH *ret = NULL;
329
330 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
331 if (!int_error_hash && create)
332 {
333 CRYPTO_push_info("int_err_get (err.c)");
334 int_error_hash = lh_new(err_hash, err_cmp);
335 CRYPTO_pop_info();
336 }
337 if (int_error_hash)
338 ret = int_error_hash;
339 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
340
341 return ret;
342 }
343
344static void int_err_del(void)
345 {
346 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
347 if (int_error_hash)
348 {
349 lh_free(int_error_hash);
350 int_error_hash = NULL;
351 }
352 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
353 }
354
355static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *d)
356 {
357 ERR_STRING_DATA *p;
358 LHASH *hash;
359
360 err_fns_check();
361 hash = ERRFN(err_get)(0);
362 if (!hash)
363 return NULL;
364
365 CRYPTO_r_lock(CRYPTO_LOCK_ERR);
366 p = (ERR_STRING_DATA *)lh_retrieve(hash, d);
367 CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
368
369 return p;
370 }
371
372static ERR_STRING_DATA *int_err_set_item(ERR_STRING_DATA *d)
373 {
374 ERR_STRING_DATA *p;
375 LHASH *hash;
376
377 err_fns_check();
378 hash = ERRFN(err_get)(1);
379 if (!hash)
380 return NULL;
381
382 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
383 p = (ERR_STRING_DATA *)lh_insert(hash, d);
384 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
385
386 return p;
387 }
388
389static ERR_STRING_DATA *int_err_del_item(ERR_STRING_DATA *d)
390 {
391 ERR_STRING_DATA *p;
392 LHASH *hash;
393
394 err_fns_check();
395 hash = ERRFN(err_get)(0);
396 if (!hash)
397 return NULL;
398
399 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
400 p = (ERR_STRING_DATA *)lh_delete(hash, d);
401 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
402
403 return p;
404 }
405
406static LHASH *int_thread_get(int create)
407 {
408 LHASH *ret = NULL;
409
410 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
411 if (!int_thread_hash && create)
412 {
413 CRYPTO_push_info("int_thread_get (err.c)");
414 int_thread_hash = lh_new(pid_hash, pid_cmp);
415 CRYPTO_pop_info();
416 }
417 if (int_thread_hash)
418 ret = int_thread_hash;
419 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
420 return ret;
421 }
422
423static ERR_STATE *int_thread_get_item(const ERR_STATE *d)
424 {
425 ERR_STATE *p;
426 LHASH *hash;
427
428 err_fns_check();
429 hash = ERRFN(thread_get)(0);
430 if (!hash)
431 return NULL;
432
433 CRYPTO_r_lock(CRYPTO_LOCK_ERR);
434 p = (ERR_STATE *)lh_retrieve(hash, d);
435 CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
436
437 return p;
438 }
439
440static ERR_STATE *int_thread_set_item(ERR_STATE *d)
441 {
442 ERR_STATE *p;
443 LHASH *hash;
444
445 err_fns_check();
446 hash = ERRFN(thread_get)(1);
447 if (!hash)
448 return NULL;
449
450 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
451 p = (ERR_STATE *)lh_insert(hash, d);
452 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
453
454 return p;
455 }
456
457static void int_thread_del_item(const ERR_STATE *d)
458 {
459 ERR_STATE *p;
460 LHASH *hash;
461
462 err_fns_check();
463 hash = ERRFN(thread_get)(0);
464 if (!hash)
465 return;
466
467 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
468 p = (ERR_STATE *)lh_delete(hash, d);
469 /* make sure we don't leak memory */
470 if (int_thread_hash && (lh_num_items(int_thread_hash) == 0))
471 {
472 lh_free(int_thread_hash);
473 int_thread_hash = NULL;
474 }
475 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
476
477 if (p)
478 ERR_STATE_free(p);
479 }
480
481static int int_err_get_next_lib(void)
482 {
483 int ret;
484
485 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
486 ret = int_err_library_number++;
487 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
488
489 return ret;
490 }
491
492
218#define NUM_SYS_STR_REASONS 127 493#define NUM_SYS_STR_REASONS 127
219#define LEN_SYS_STR_REASON 32 494#define LEN_SYS_STR_REASON 32
220 495
@@ -233,8 +508,11 @@ static void build_SYS_str_reasons()
233 /* OPENSSL_malloc cannot be used here, use static storage instead */ 508 /* OPENSSL_malloc cannot be used here, use static storage instead */
234 static char strerror_tab[NUM_SYS_STR_REASONS][LEN_SYS_STR_REASON]; 509 static char strerror_tab[NUM_SYS_STR_REASONS][LEN_SYS_STR_REASON];
235 int i; 510 int i;
511 static int init = 1;
512
513 if (!init) return;
236 514
237 CRYPTO_w_lock(CRYPTO_LOCK_ERR_HASH); 515 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
238 516
239 for (i = 1; i <= NUM_SYS_STR_REASONS; i++) 517 for (i = 1; i <= NUM_SYS_STR_REASONS; i++)
240 { 518 {
@@ -259,7 +537,9 @@ static void build_SYS_str_reasons()
259 /* Now we still have SYS_str_reasons[NUM_SYS_STR_REASONS] = {0, NULL}, 537 /* Now we still have SYS_str_reasons[NUM_SYS_STR_REASONS] = {0, NULL},
260 * as required by ERR_load_strings. */ 538 * as required by ERR_load_strings. */
261 539
262 CRYPTO_w_unlock(CRYPTO_LOCK_ERR_HASH); 540 init = 0;
541
542 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
263 } 543 }
264#endif 544#endif
265 545
@@ -276,7 +556,7 @@ static void ERR_STATE_free(ERR_STATE *s)
276 { 556 {
277 int i; 557 int i;
278 558
279 if(s == NULL) 559 if (s == NULL)
280 return; 560 return;
281 561
282 for (i=0; i<ERR_NUM_ERRORS; i++) 562 for (i=0; i<ERR_NUM_ERRORS; i++)
@@ -288,66 +568,46 @@ static void ERR_STATE_free(ERR_STATE *s)
288 568
289void ERR_load_ERR_strings(void) 569void ERR_load_ERR_strings(void)
290 { 570 {
291 static int init=1; 571 err_fns_check();
572#ifndef OPENSSL_NO_ERR
573 err_load_strings(0,ERR_str_libraries);
574 err_load_strings(0,ERR_str_reasons);
575 err_load_strings(ERR_LIB_SYS,ERR_str_functs);
576 build_SYS_str_reasons();
577 err_load_strings(ERR_LIB_SYS,SYS_str_reasons);
578#endif
579 }
292 580
293 if (init) 581static void err_load_strings(int lib, ERR_STRING_DATA *str)
582 {
583 while (str->error)
294 { 584 {
295 CRYPTO_w_lock(CRYPTO_LOCK_ERR); 585 str->error|=ERR_PACK(lib,0,0);
296 if (init == 0) 586 ERRFN(err_set_item)(str);
297 { 587 str++;
298 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
299 return;
300 }
301 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
302
303#ifndef NO_ERR
304 ERR_load_strings(0,ERR_str_libraries);
305 ERR_load_strings(0,ERR_str_reasons);
306 ERR_load_strings(ERR_LIB_SYS,ERR_str_functs);
307 build_SYS_str_reasons();
308 ERR_load_strings(ERR_LIB_SYS,SYS_str_reasons);
309#endif
310 init=0;
311 } 588 }
312 } 589 }
313 590
314void ERR_load_strings(int lib, ERR_STRING_DATA *str) 591void ERR_load_strings(int lib, ERR_STRING_DATA *str)
315 { 592 {
316 if (error_hash == NULL) 593 ERR_load_ERR_strings();
317 { 594 err_load_strings(lib, str);
318 CRYPTO_w_lock(CRYPTO_LOCK_ERR_HASH); 595 }
319 error_hash=lh_new(err_hash,err_cmp);
320 if (error_hash == NULL)
321 {
322 CRYPTO_w_unlock(CRYPTO_LOCK_ERR_HASH);
323 return;
324 }
325 CRYPTO_w_unlock(CRYPTO_LOCK_ERR_HASH);
326
327 ERR_load_ERR_strings();
328 }
329 596
330 CRYPTO_w_lock(CRYPTO_LOCK_ERR_HASH); 597void ERR_unload_strings(int lib, ERR_STRING_DATA *str)
598 {
331 while (str->error) 599 while (str->error)
332 { 600 {
333 str->error|=ERR_PACK(lib,0,0); 601 str->error|=ERR_PACK(lib,0,0);
334 lh_insert(error_hash,str); 602 ERRFN(err_del_item)(str);
335 str++; 603 str++;
336 } 604 }
337 CRYPTO_w_unlock(CRYPTO_LOCK_ERR_HASH);
338 } 605 }
339 606
340void ERR_free_strings(void) 607void ERR_free_strings(void)
341 { 608 {
342 CRYPTO_w_lock(CRYPTO_LOCK_ERR); 609 err_fns_check();
343 610 ERRFN(err_del)();
344 if (error_hash != NULL)
345 {
346 lh_free(error_hash);
347 error_hash=NULL;
348 }
349
350 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
351 } 611 }
352 612
353/********************************************************/ 613/********************************************************/
@@ -406,30 +666,40 @@ void ERR_clear_error(void)
406 666
407 667
408unsigned long ERR_get_error(void) 668unsigned long ERR_get_error(void)
409 { return(get_error_values(1,NULL,NULL,NULL,NULL)); } 669 { return(get_error_values(1,0,NULL,NULL,NULL,NULL)); }
410 670
411unsigned long ERR_get_error_line(const char **file, 671unsigned long ERR_get_error_line(const char **file,
412 int *line) 672 int *line)
413 { return(get_error_values(1,file,line,NULL,NULL)); } 673 { return(get_error_values(1,0,file,line,NULL,NULL)); }
414 674
415unsigned long ERR_get_error_line_data(const char **file, int *line, 675unsigned long ERR_get_error_line_data(const char **file, int *line,
416 const char **data, int *flags) 676 const char **data, int *flags)
417 { return(get_error_values(1,file,line, 677 { return(get_error_values(1,0,file,line,data,flags)); }
418 data,flags)); } 678
419 679
420unsigned long ERR_peek_error(void) 680unsigned long ERR_peek_error(void)
421 { return(get_error_values(0,NULL,NULL,NULL,NULL)); } 681 { return(get_error_values(0,0,NULL,NULL,NULL,NULL)); }
422 682
423unsigned long ERR_peek_error_line(const char **file, 683unsigned long ERR_peek_error_line(const char **file, int *line)
424 int *line) 684 { return(get_error_values(0,0,file,line,NULL,NULL)); }
425 { return(get_error_values(0,file,line,NULL,NULL)); }
426 685
427unsigned long ERR_peek_error_line_data(const char **file, int *line, 686unsigned long ERR_peek_error_line_data(const char **file, int *line,
428 const char **data, int *flags) 687 const char **data, int *flags)
429 { return(get_error_values(0,file,line, 688 { return(get_error_values(0,0,file,line,data,flags)); }
430 data,flags)); } 689
690
691unsigned long ERR_peek_last_error(void)
692 { return(get_error_values(0,1,NULL,NULL,NULL,NULL)); }
693
694unsigned long ERR_peek_last_error_line(const char **file, int *line)
695 { return(get_error_values(0,1,file,line,NULL,NULL)); }
696
697unsigned long ERR_peek_last_error_line_data(const char **file, int *line,
698 const char **data, int *flags)
699 { return(get_error_values(0,1,file,line,data,flags)); }
700
431 701
432static unsigned long get_error_values(int inc, const char **file, int *line, 702static unsigned long get_error_values(int inc, int top, const char **file, int *line,
433 const char **data, int *flags) 703 const char **data, int *flags)
434 { 704 {
435 int i=0; 705 int i=0;
@@ -438,8 +708,21 @@ static unsigned long get_error_values(int inc, const char **file, int *line,
438 708
439 es=ERR_get_state(); 709 es=ERR_get_state();
440 710
441 if (es->bottom == es->top) return(0); 711 if (inc && top)
442 i=(es->bottom+1)%ERR_NUM_ERRORS; 712 {
713 if (file) *file = "";
714 if (line) *line = 0;
715 if (data) *data = "";
716 if (flags) *flags = 0;
717
718 return ERR_R_INTERNAL_ERROR;
719 }
720
721 if (es->bottom == es->top) return 0;
722 if (top)
723 i=es->top; /* last error */
724 else
725 i=(es->bottom+1)%ERR_NUM_ERRORS; /* first error */
443 726
444 ret=es->err_buffer[i]; 727 ret=es->err_buffer[i];
445 if (inc) 728 if (inc)
@@ -482,7 +765,7 @@ static unsigned long get_error_values(int inc, const char **file, int *line,
482 if (flags != NULL) *flags=es->err_data_flags[i]; 765 if (flags != NULL) *flags=es->err_data_flags[i];
483 } 766 }
484 } 767 }
485 return(ret); 768 return ret;
486 } 769 }
487 770
488void ERR_error_string_n(unsigned long e, char *buf, size_t len) 771void ERR_error_string_n(unsigned long e, char *buf, size_t len)
@@ -544,58 +827,43 @@ char *ERR_error_string(unsigned long e, char *ret)
544 if (ret == NULL) ret=buf; 827 if (ret == NULL) ret=buf;
545 ERR_error_string_n(e, ret, 256); 828 ERR_error_string_n(e, ret, 256);
546 829
547 return(ret); 830 return ret;
548 } 831 }
549 832
550LHASH *ERR_get_string_table(void) 833LHASH *ERR_get_string_table(void)
551 { 834 {
552 return(error_hash); 835 err_fns_check();
836 return ERRFN(err_get)(0);
553 } 837 }
554 838
555/* not thread-safe */
556LHASH *ERR_get_err_state_table(void) 839LHASH *ERR_get_err_state_table(void)
557 { 840 {
558 return(thread_hash); 841 err_fns_check();
842 return ERRFN(thread_get)(0);
559 } 843 }
560 844
561const char *ERR_lib_error_string(unsigned long e) 845const char *ERR_lib_error_string(unsigned long e)
562 { 846 {
563 ERR_STRING_DATA d,*p=NULL; 847 ERR_STRING_DATA d,*p;
564 unsigned long l; 848 unsigned long l;
565 849
850 err_fns_check();
566 l=ERR_GET_LIB(e); 851 l=ERR_GET_LIB(e);
567 852 d.error=ERR_PACK(l,0,0);
568 CRYPTO_w_lock(CRYPTO_LOCK_ERR_HASH); 853 p=ERRFN(err_get_item)(&d);
569
570 if (error_hash != NULL)
571 {
572 d.error=ERR_PACK(l,0,0);
573 p=(ERR_STRING_DATA *)lh_retrieve(error_hash,&d);
574 }
575
576 CRYPTO_w_unlock(CRYPTO_LOCK_ERR_HASH);
577
578 return((p == NULL)?NULL:p->string); 854 return((p == NULL)?NULL:p->string);
579 } 855 }
580 856
581const char *ERR_func_error_string(unsigned long e) 857const char *ERR_func_error_string(unsigned long e)
582 { 858 {
583 ERR_STRING_DATA d,*p=NULL; 859 ERR_STRING_DATA d,*p;
584 unsigned long l,f; 860 unsigned long l,f;
585 861
862 err_fns_check();
586 l=ERR_GET_LIB(e); 863 l=ERR_GET_LIB(e);
587 f=ERR_GET_FUNC(e); 864 f=ERR_GET_FUNC(e);
588 865 d.error=ERR_PACK(l,f,0);
589 CRYPTO_w_lock(CRYPTO_LOCK_ERR_HASH); 866 p=ERRFN(err_get_item)(&d);
590
591 if (error_hash != NULL)
592 {
593 d.error=ERR_PACK(l,f,0);
594 p=(ERR_STRING_DATA *)lh_retrieve(error_hash,&d);
595 }
596
597 CRYPTO_w_unlock(CRYPTO_LOCK_ERR_HASH);
598
599 return((p == NULL)?NULL:p->string); 867 return((p == NULL)?NULL:p->string);
600 } 868 }
601 869
@@ -604,93 +872,73 @@ const char *ERR_reason_error_string(unsigned long e)
604 ERR_STRING_DATA d,*p=NULL; 872 ERR_STRING_DATA d,*p=NULL;
605 unsigned long l,r; 873 unsigned long l,r;
606 874
875 err_fns_check();
607 l=ERR_GET_LIB(e); 876 l=ERR_GET_LIB(e);
608 r=ERR_GET_REASON(e); 877 r=ERR_GET_REASON(e);
609 878 d.error=ERR_PACK(l,0,r);
610 CRYPTO_w_lock(CRYPTO_LOCK_ERR_HASH); 879 p=ERRFN(err_get_item)(&d);
611 880 if (!p)
612 if (error_hash != NULL)
613 { 881 {
614 d.error=ERR_PACK(l,0,r); 882 d.error=ERR_PACK(0,0,r);
615 p=(ERR_STRING_DATA *)lh_retrieve(error_hash,&d); 883 p=ERRFN(err_get_item)(&d);
616 if (p == NULL)
617 {
618 d.error=ERR_PACK(0,0,r);
619 p=(ERR_STRING_DATA *)lh_retrieve(error_hash,&d);
620 }
621 } 884 }
622
623 CRYPTO_w_unlock(CRYPTO_LOCK_ERR_HASH);
624
625 return((p == NULL)?NULL:p->string); 885 return((p == NULL)?NULL:p->string);
626 } 886 }
627 887
628static unsigned long err_hash(ERR_STRING_DATA *a) 888/* static unsigned long err_hash(ERR_STRING_DATA *a) */
889static unsigned long err_hash(const void *a_void)
629 { 890 {
630 unsigned long ret,l; 891 unsigned long ret,l;
631 892
632 l=a->error; 893 l=((ERR_STRING_DATA *)a_void)->error;
633 ret=l^ERR_GET_LIB(l)^ERR_GET_FUNC(l); 894 ret=l^ERR_GET_LIB(l)^ERR_GET_FUNC(l);
634 return(ret^ret%19*13); 895 return(ret^ret%19*13);
635 } 896 }
636 897
637static int err_cmp(ERR_STRING_DATA *a, ERR_STRING_DATA *b) 898/* static int err_cmp(ERR_STRING_DATA *a, ERR_STRING_DATA *b) */
899static int err_cmp(const void *a_void, const void *b_void)
638 { 900 {
639 return((int)(a->error-b->error)); 901 return((int)(((ERR_STRING_DATA *)a_void)->error -
902 ((ERR_STRING_DATA *)b_void)->error));
640 } 903 }
641 904
642static unsigned long pid_hash(ERR_STATE *a) 905/* static unsigned long pid_hash(ERR_STATE *a) */
906static unsigned long pid_hash(const void *a_void)
643 { 907 {
644 return(a->pid*13); 908 return(((ERR_STATE *)a_void)->pid*13);
645 } 909 }
646 910
647static int pid_cmp(ERR_STATE *a, ERR_STATE *b) 911/* static int pid_cmp(ERR_STATE *a, ERR_STATE *b) */
912static int pid_cmp(const void *a_void, const void *b_void)
648 { 913 {
649 return((int)((long)a->pid - (long)b->pid)); 914 return((int)((long)((ERR_STATE *)a_void)->pid -
915 (long)((ERR_STATE *)b_void)->pid));
650 } 916 }
651 917
652void ERR_remove_state(unsigned long pid) 918void ERR_remove_state(unsigned long pid)
653 { 919 {
654 ERR_STATE *p = NULL,tmp; 920 ERR_STATE tmp;
655 921
656 if (thread_hash == NULL) 922 err_fns_check();
657 return;
658 if (pid == 0) 923 if (pid == 0)
659 pid=(unsigned long)CRYPTO_thread_id(); 924 pid=(unsigned long)CRYPTO_thread_id();
660 tmp.pid=pid; 925 tmp.pid=pid;
661 CRYPTO_w_lock(CRYPTO_LOCK_ERR); 926 /* thread_del_item automatically destroys the LHASH if the number of
662 if (thread_hash) 927 * items reaches zero. */
663 { 928 ERRFN(thread_del_item)(&tmp);
664 p=(ERR_STATE *)lh_delete(thread_hash,&tmp);
665 if (lh_num_items(thread_hash) == 0)
666 {
667 /* make sure we don't leak memory */
668 lh_free(thread_hash);
669 thread_hash = NULL;
670 }
671 }
672 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
673
674 if (p != NULL) ERR_STATE_free(p);
675 } 929 }
676 930
677ERR_STATE *ERR_get_state(void) 931ERR_STATE *ERR_get_state(void)
678 { 932 {
679 static ERR_STATE fallback; 933 static ERR_STATE fallback;
680 ERR_STATE *ret=NULL,tmp,*tmpp=NULL; 934 ERR_STATE *ret,tmp,*tmpp=NULL;
681 int thread_state_exists;
682 int i; 935 int i;
683 unsigned long pid; 936 unsigned long pid;
684 937
938 err_fns_check();
685 pid=(unsigned long)CRYPTO_thread_id(); 939 pid=(unsigned long)CRYPTO_thread_id();
686 940 tmp.pid=pid;
687 CRYPTO_w_lock(CRYPTO_LOCK_ERR); 941 ret=ERRFN(thread_get_item)(&tmp);
688 if (thread_hash != NULL)
689 {
690 tmp.pid=pid;
691 ret=(ERR_STATE *)lh_retrieve(thread_hash,&tmp);
692 }
693 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
694 942
695 /* ret == the error state, if NULL, make a new one */ 943 /* ret == the error state, if NULL, make a new one */
696 if (ret == NULL) 944 if (ret == NULL)
@@ -705,42 +953,25 @@ ERR_STATE *ERR_get_state(void)
705 ret->err_data[i]=NULL; 953 ret->err_data[i]=NULL;
706 ret->err_data_flags[i]=0; 954 ret->err_data_flags[i]=0;
707 } 955 }
708 956 tmpp = ERRFN(thread_set_item)(ret);
709 CRYPTO_w_lock(CRYPTO_LOCK_ERR); 957 /* To check if insertion failed, do a get. */
710 958 if (ERRFN(thread_get_item)(ret) != ret)
711 /* no entry yet in thread_hash for current thread -
712 * thus, it may have changed since we last looked at it */
713 if (thread_hash == NULL)
714 thread_hash = lh_new(pid_hash, pid_cmp);
715 if (thread_hash == NULL)
716 thread_state_exists = 0; /* allocation error */
717 else
718 {
719 tmpp=(ERR_STATE *)lh_insert(thread_hash,ret);
720 thread_state_exists = 1;
721 }
722
723 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
724
725 if (!thread_state_exists)
726 { 959 {
727 ERR_STATE_free(ret); /* could not insert it */ 960 ERR_STATE_free(ret); /* could not insert it */
728 return(&fallback); 961 return(&fallback);
729 } 962 }
730 963 /* If a race occured in this function and we came second, tmpp
731 if (tmpp != NULL) /* old entry - should not happen */ 964 * is the first one that we just replaced. */
732 { 965 if (tmpp)
733 ERR_STATE_free(tmpp); 966 ERR_STATE_free(tmpp);
734 }
735 } 967 }
736 return(ret); 968 return ret;
737 } 969 }
738 970
739int ERR_get_next_error_library(void) 971int ERR_get_next_error_library(void)
740 { 972 {
741 static int value=ERR_LIB_USER; 973 err_fns_check();
742 974 return ERRFN(get_next_lib)();
743 return(value++);
744 } 975 }
745 976
746void ERR_set_error_data(char *data, int flags) 977void ERR_set_error_data(char *data, int flags)
@@ -786,7 +1017,7 @@ void ERR_add_error_data(int num, ...)
786 if (p == NULL) 1017 if (p == NULL)
787 { 1018 {
788 OPENSSL_free(str); 1019 OPENSSL_free(str);
789 return; 1020 goto err;
790 } 1021 }
791 else 1022 else
792 str=p; 1023 str=p;
@@ -796,6 +1027,6 @@ void ERR_add_error_data(int num, ...)
796 } 1027 }
797 ERR_set_error_data(str,ERR_TXT_MALLOCED|ERR_TXT_STRING); 1028 ERR_set_error_data(str,ERR_TXT_MALLOCED|ERR_TXT_STRING);
798 1029
1030err:
799 va_end(args); 1031 va_end(args);
800 } 1032 }
801
diff --git a/src/lib/libcrypto/err/err.h b/src/lib/libcrypto/err/err.h
index 7388a4a937..cc9bb649ea 100644
--- a/src/lib/libcrypto/err/err.h
+++ b/src/lib/libcrypto/err/err.h
@@ -59,15 +59,15 @@
59#ifndef HEADER_ERR_H 59#ifndef HEADER_ERR_H
60#define HEADER_ERR_H 60#define HEADER_ERR_H
61 61
62#ifndef NO_FP_API 62#ifndef OPENSSL_NO_FP_API
63#include <stdio.h> 63#include <stdio.h>
64#include <stdlib.h> 64#include <stdlib.h>
65#endif 65#endif
66 66
67#ifndef NO_BIO 67#ifndef OPENSSL_NO_BIO
68#include <openssl/bio.h> 68#include <openssl/bio.h>
69#endif 69#endif
70#ifndef NO_LHASH 70#ifndef OPENSSL_NO_LHASH
71#include <openssl/lhash.h> 71#include <openssl/lhash.h>
72#endif 72#endif
73 73
@@ -75,13 +75,7 @@
75extern "C" { 75extern "C" {
76#endif 76#endif
77 77
78/* The following is a bit of a trick to help the object files only contain 78#ifndef OPENSSL_NO_ERR
79 * the 'name of the file' string once. Since 'err.h' is protected by the
80 * HEADER_ERR_H stuff, this should be included only once per file. */
81
82#define ERR_file_name __FILE__
83
84#ifndef NO_ERR
85#define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,d,e) 79#define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,d,e)
86#else 80#else
87#define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,NULL,0) 81#define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,NULL,0)
@@ -116,16 +110,17 @@ typedef struct err_state_st
116#define ERR_LIB_PEM 9 110#define ERR_LIB_PEM 9
117#define ERR_LIB_DSA 10 111#define ERR_LIB_DSA 10
118#define ERR_LIB_X509 11 112#define ERR_LIB_X509 11
119#define ERR_LIB_METH 12 113/* #define ERR_LIB_METH 12 */
120#define ERR_LIB_ASN1 13 114#define ERR_LIB_ASN1 13
121#define ERR_LIB_CONF 14 115#define ERR_LIB_CONF 14
122#define ERR_LIB_CRYPTO 15 116#define ERR_LIB_CRYPTO 15
117#define ERR_LIB_EC 16
123#define ERR_LIB_SSL 20 118#define ERR_LIB_SSL 20
124#define ERR_LIB_SSL23 21 119/* #define ERR_LIB_SSL23 21 */
125#define ERR_LIB_SSL2 22 120/* #define ERR_LIB_SSL2 22 */
126#define ERR_LIB_SSL3 23 121/* #define ERR_LIB_SSL3 23 */
127#define ERR_LIB_RSAREF 30 122/* #define ERR_LIB_RSAREF 30 */
128#define ERR_LIB_PROXY 31 123/* #define ERR_LIB_PROXY 31 */
129#define ERR_LIB_BIO 32 124#define ERR_LIB_BIO 32
130#define ERR_LIB_PKCS7 33 125#define ERR_LIB_PKCS7 33
131#define ERR_LIB_X509V3 34 126#define ERR_LIB_X509V3 34
@@ -133,36 +128,37 @@ typedef struct err_state_st
133#define ERR_LIB_RAND 36 128#define ERR_LIB_RAND 36
134#define ERR_LIB_DSO 37 129#define ERR_LIB_DSO 37
135#define ERR_LIB_ENGINE 38 130#define ERR_LIB_ENGINE 38
131#define ERR_LIB_OCSP 39
132#define ERR_LIB_UI 40
133#define ERR_LIB_COMP 41
136 134
137#define ERR_LIB_USER 128 135#define ERR_LIB_USER 128
138 136
139#define SYSerr(f,r) ERR_PUT_error(ERR_LIB_SYS,(f),(r),ERR_file_name,__LINE__) 137#define SYSerr(f,r) ERR_PUT_error(ERR_LIB_SYS,(f),(r),__FILE__,__LINE__)
140#define BNerr(f,r) ERR_PUT_error(ERR_LIB_BN,(f),(r),ERR_file_name,__LINE__) 138#define BNerr(f,r) ERR_PUT_error(ERR_LIB_BN,(f),(r),__FILE__,__LINE__)
141#define RSAerr(f,r) ERR_PUT_error(ERR_LIB_RSA,(f),(r),ERR_file_name,__LINE__) 139#define RSAerr(f,r) ERR_PUT_error(ERR_LIB_RSA,(f),(r),__FILE__,__LINE__)
142#define DHerr(f,r) ERR_PUT_error(ERR_LIB_DH,(f),(r),ERR_file_name,__LINE__) 140#define DHerr(f,r) ERR_PUT_error(ERR_LIB_DH,(f),(r),__FILE__,__LINE__)
143#define EVPerr(f,r) ERR_PUT_error(ERR_LIB_EVP,(f),(r),ERR_file_name,__LINE__) 141#define EVPerr(f,r) ERR_PUT_error(ERR_LIB_EVP,(f),(r),__FILE__,__LINE__)
144#define BUFerr(f,r) ERR_PUT_error(ERR_LIB_BUF,(f),(r),ERR_file_name,__LINE__) 142#define BUFerr(f,r) ERR_PUT_error(ERR_LIB_BUF,(f),(r),__FILE__,__LINE__)
145#define BIOerr(f,r) ERR_PUT_error(ERR_LIB_BIO,(f),(r),ERR_file_name,__LINE__) 143#define OBJerr(f,r) ERR_PUT_error(ERR_LIB_OBJ,(f),(r),__FILE__,__LINE__)
146#define OBJerr(f,r) ERR_PUT_error(ERR_LIB_OBJ,(f),(r),ERR_file_name,__LINE__) 144#define PEMerr(f,r) ERR_PUT_error(ERR_LIB_PEM,(f),(r),__FILE__,__LINE__)
147#define PEMerr(f,r) ERR_PUT_error(ERR_LIB_PEM,(f),(r),ERR_file_name,__LINE__) 145#define DSAerr(f,r) ERR_PUT_error(ERR_LIB_DSA,(f),(r),__FILE__,__LINE__)
148#define DSAerr(f,r) ERR_PUT_error(ERR_LIB_DSA,(f),(r),ERR_file_name,__LINE__) 146#define X509err(f,r) ERR_PUT_error(ERR_LIB_X509,(f),(r),__FILE__,__LINE__)
149#define X509err(f,r) ERR_PUT_error(ERR_LIB_X509,(f),(r),ERR_file_name,__LINE__) 147#define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),__FILE__,__LINE__)
150#define METHerr(f,r) ERR_PUT_error(ERR_LIB_METH,(f),(r),ERR_file_name,__LINE__) 148#define CONFerr(f,r) ERR_PUT_error(ERR_LIB_CONF,(f),(r),__FILE__,__LINE__)
151#define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),ERR_file_name,__LINE__) 149#define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),__FILE__,__LINE__)
152#define CONFerr(f,r) ERR_PUT_error(ERR_LIB_CONF,(f),(r),ERR_file_name,__LINE__) 150#define ECerr(f,r) ERR_PUT_error(ERR_LIB_EC,(f),(r),__FILE__,__LINE__)
153#define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),ERR_file_name,__LINE__) 151#define SSLerr(f,r) ERR_PUT_error(ERR_LIB_SSL,(f),(r),__FILE__,__LINE__)
154#define SSLerr(f,r) ERR_PUT_error(ERR_LIB_SSL,(f),(r),ERR_file_name,__LINE__) 152#define BIOerr(f,r) ERR_PUT_error(ERR_LIB_BIO,(f),(r),__FILE__,__LINE__)
155#define SSL23err(f,r) ERR_PUT_error(ERR_LIB_SSL23,(f),(r),ERR_file_name,__LINE__) 153#define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),__FILE__,__LINE__)
156#define SSL2err(f,r) ERR_PUT_error(ERR_LIB_SSL2,(f),(r),ERR_file_name,__LINE__) 154#define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),__FILE__,__LINE__)
157#define SSL3err(f,r) ERR_PUT_error(ERR_LIB_SSL3,(f),(r),ERR_file_name,__LINE__) 155#define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),__FILE__,__LINE__)
158#define RSAREFerr(f,r) ERR_PUT_error(ERR_LIB_RSAREF,(f),(r),ERR_file_name,__LINE__) 156#define RANDerr(f,r) ERR_PUT_error(ERR_LIB_RAND,(f),(r),__FILE__,__LINE__)
159#define PROXYerr(f,r) ERR_PUT_error(ERR_LIB_PROXY,(f),(r),ERR_file_name,__LINE__) 157#define DSOerr(f,r) ERR_PUT_error(ERR_LIB_DSO,(f),(r),__FILE__,__LINE__)
160#define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),ERR_file_name,__LINE__) 158#define ENGINEerr(f,r) ERR_PUT_error(ERR_LIB_ENGINE,(f),(r),__FILE__,__LINE__)
161#define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),ERR_file_name,__LINE__) 159#define OCSPerr(f,r) ERR_PUT_error(ERR_LIB_OCSP,(f),(r),__FILE__,__LINE__)
162#define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),ERR_file_name,__LINE__) 160#define UIerr(f,r) ERR_PUT_error(ERR_LIB_UI,(f),(r),__FILE__,__LINE__)
163#define RANDerr(f,r) ERR_PUT_error(ERR_LIB_RAND,(f),(r),ERR_file_name,__LINE__) 161#define COMPerr(f,r) ERR_PUT_error(ERR_LIB_COMP,(f),(r),__FILE__,__LINE__)
164#define DSOerr(f,r) ERR_PUT_error(ERR_LIB_DSO,(f),(r),ERR_file_name,__LINE__)
165#define ENGINEerr(f,r) ERR_PUT_error(ERR_LIB_ENGINE,(f),(r),ERR_file_name,__LINE__)
166 162
167/* Borland C seems too stupid to be able to shift and do longs in 163/* Borland C seems too stupid to be able to shift and do longs in
168 * the pre-processor :-( */ 164 * the pre-processor :-( */
@@ -174,6 +170,7 @@ typedef struct err_state_st
174#define ERR_GET_REASON(l) (int)((l)&0xfffL) 170#define ERR_GET_REASON(l) (int)((l)&0xfffL)
175#define ERR_FATAL_ERROR(l) (int)((l)&ERR_R_FATAL) 171#define ERR_FATAL_ERROR(l) (int)((l)&ERR_R_FATAL)
176 172
173
177/* OS functions */ 174/* OS functions */
178#define SYS_F_FOPEN 1 175#define SYS_F_FOPEN 1
179#define SYS_F_CONNECT 2 176#define SYS_F_CONNECT 2
@@ -186,44 +183,51 @@ typedef struct err_state_st
186#define SYS_F_WSASTARTUP 9 /* Winsock stuff */ 183#define SYS_F_WSASTARTUP 9 /* Winsock stuff */
187#define SYS_F_OPENDIR 10 184#define SYS_F_OPENDIR 10
188 185
189#define ERR_R_FATAL 32 186
190/* reasons */ 187/* reasons */
191#define ERR_R_SYS_LIB ERR_LIB_SYS 188#define ERR_R_SYS_LIB ERR_LIB_SYS /* 2 */
192#define ERR_R_BN_LIB ERR_LIB_BN 189#define ERR_R_BN_LIB ERR_LIB_BN /* 3 */
193#define ERR_R_RSA_LIB ERR_LIB_RSA 190#define ERR_R_RSA_LIB ERR_LIB_RSA /* 4 */
194#define ERR_R_DSA_LIB ERR_LIB_DSA 191#define ERR_R_DH_LIB ERR_LIB_DH /* 5 */
195#define ERR_R_DH_LIB ERR_LIB_DH 192#define ERR_R_EVP_LIB ERR_LIB_EVP /* 6 */
196#define ERR_R_EVP_LIB ERR_LIB_EVP 193#define ERR_R_BUF_LIB ERR_LIB_BUF /* 7 */
197#define ERR_R_BUF_LIB ERR_LIB_BUF 194#define ERR_R_OBJ_LIB ERR_LIB_OBJ /* 8 */
198#define ERR_R_BIO_LIB ERR_LIB_BIO 195#define ERR_R_PEM_LIB ERR_LIB_PEM /* 9 */
199#define ERR_R_OBJ_LIB ERR_LIB_OBJ 196#define ERR_R_DSA_LIB ERR_LIB_DSA /* 10 */
200#define ERR_R_PEM_LIB ERR_LIB_PEM 197#define ERR_R_X509_LIB ERR_LIB_X509 /* 11 */
201#define ERR_R_X509_LIB ERR_LIB_X509 198#define ERR_R_ASN1_LIB ERR_LIB_ASN1 /* 13 */
202#define ERR_R_METH_LIB ERR_LIB_METH 199#define ERR_R_CONF_LIB ERR_LIB_CONF /* 14 */
203#define ERR_R_ASN1_LIB ERR_LIB_ASN1 200#define ERR_R_CRYPTO_LIB ERR_LIB_CRYPTO /* 15 */
204#define ERR_R_CONF_LIB ERR_LIB_CONF 201#define ERR_R_EC_LIB ERR_LIB_EC /* 16 */
205#define ERR_R_CRYPTO_LIB ERR_LIB_CRYPTO 202#define ERR_R_SSL_LIB ERR_LIB_SSL /* 20 */
206#define ERR_R_SSL_LIB ERR_LIB_SSL 203#define ERR_R_BIO_LIB ERR_LIB_BIO /* 32 */
207#define ERR_R_SSL23_LIB ERR_LIB_SSL23 204#define ERR_R_PKCS7_LIB ERR_LIB_PKCS7 /* 33 */
208#define ERR_R_SSL2_LIB ERR_LIB_SSL2 205#define ERR_R_X509V3_LIB ERR_LIB_X509V3 /* 34 */
209#define ERR_R_SSL3_LIB ERR_LIB_SSL3 206#define ERR_R_PKCS12_LIB ERR_LIB_PKCS12 /* 35 */
210#define ERR_R_PROXY_LIB ERR_LIB_PROXY 207#define ERR_R_RAND_LIB ERR_LIB_RAND /* 36 */
211#define ERR_R_BIO_LIB ERR_LIB_BIO 208#define ERR_R_DSO_LIB ERR_LIB_DSO /* 37 */
212#define ERR_R_PKCS7_LIB ERR_LIB_PKCS7 209#define ERR_R_ENGINE_LIB ERR_LIB_ENGINE /* 38 */
213#define ERR_R_PKCS12_LIB ERR_LIB_PKCS12 210#define ERR_R_OCSP_LIB ERR_LIB_OCSP /* 39 */
214#define ERR_R_DSO_LIB ERR_LIB_DSO 211#define ERR_R_UI_LIB ERR_LIB_UI /* 40 */
215#define ERR_R_ENGINE_LIB ERR_LIB_ENGINE 212#define ERR_R_COMP_LIB ERR_LIB_COMP /* 41 */
213
214#define ERR_R_NESTED_ASN1_ERROR 58
215#define ERR_R_BAD_ASN1_OBJECT_HEADER 59
216#define ERR_R_BAD_GET_ASN1_OBJECT_CALL 60
217#define ERR_R_EXPECTING_AN_ASN1_SEQUENCE 61
218#define ERR_R_ASN1_LENGTH_MISMATCH 62
219#define ERR_R_MISSING_ASN1_EOS 63
216 220
217/* fatal error */ 221/* fatal error */
222#define ERR_R_FATAL 64
218#define ERR_R_MALLOC_FAILURE (1|ERR_R_FATAL) 223#define ERR_R_MALLOC_FAILURE (1|ERR_R_FATAL)
219#define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED (2|ERR_R_FATAL) 224#define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED (2|ERR_R_FATAL)
220#define ERR_R_PASSED_NULL_PARAMETER (3|ERR_R_FATAL) 225#define ERR_R_PASSED_NULL_PARAMETER (3|ERR_R_FATAL)
221#define ERR_R_NESTED_ASN1_ERROR (4) 226#define ERR_R_INTERNAL_ERROR (4|ERR_R_FATAL)
222#define ERR_R_BAD_ASN1_OBJECT_HEADER (5) 227
223#define ERR_R_BAD_GET_ASN1_OBJECT_CALL (6) 228/* 99 is the maximum possible ERR_R_... code, higher values
224#define ERR_R_EXPECTING_AN_ASN1_SEQUENCE (7) 229 * are reserved for the individual libraries */
225#define ERR_R_ASN1_LENGTH_MISMATCH (8) 230
226#define ERR_R_MISSING_ASN1_EOS (9)
227 231
228typedef struct ERR_string_data_st 232typedef struct ERR_string_data_st
229 { 233 {
@@ -234,28 +238,35 @@ typedef struct ERR_string_data_st
234void ERR_put_error(int lib, int func,int reason,const char *file,int line); 238void ERR_put_error(int lib, int func,int reason,const char *file,int line);
235void ERR_set_error_data(char *data,int flags); 239void ERR_set_error_data(char *data,int flags);
236 240
237unsigned long ERR_get_error(void ); 241unsigned long ERR_get_error(void);
238unsigned long ERR_get_error_line(const char **file,int *line); 242unsigned long ERR_get_error_line(const char **file,int *line);
239unsigned long ERR_get_error_line_data(const char **file,int *line, 243unsigned long ERR_get_error_line_data(const char **file,int *line,
240 const char **data, int *flags); 244 const char **data, int *flags);
241unsigned long ERR_peek_error(void ); 245unsigned long ERR_peek_error(void);
242unsigned long ERR_peek_error_line(const char **file,int *line); 246unsigned long ERR_peek_error_line(const char **file,int *line);
243unsigned long ERR_peek_error_line_data(const char **file,int *line, 247unsigned long ERR_peek_error_line_data(const char **file,int *line,
244 const char **data,int *flags); 248 const char **data,int *flags);
249unsigned long ERR_peek_last_error(void);
250unsigned long ERR_peek_last_error_line(const char **file,int *line);
251unsigned long ERR_peek_last_error_line_data(const char **file,int *line,
252 const char **data,int *flags);
245void ERR_clear_error(void ); 253void ERR_clear_error(void );
246char *ERR_error_string(unsigned long e,char *buf); 254char *ERR_error_string(unsigned long e,char *buf);
247void ERR_error_string_n(unsigned long e, char *buf, size_t len); 255void ERR_error_string_n(unsigned long e, char *buf, size_t len);
248const char *ERR_lib_error_string(unsigned long e); 256const char *ERR_lib_error_string(unsigned long e);
249const char *ERR_func_error_string(unsigned long e); 257const char *ERR_func_error_string(unsigned long e);
250const char *ERR_reason_error_string(unsigned long e); 258const char *ERR_reason_error_string(unsigned long e);
251#ifndef NO_FP_API 259void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u),
260 void *u);
261#ifndef OPENSSL_NO_FP_API
252void ERR_print_errors_fp(FILE *fp); 262void ERR_print_errors_fp(FILE *fp);
253#endif 263#endif
254#ifndef NO_BIO 264#ifndef OPENSSL_NO_BIO
255void ERR_print_errors(BIO *bp); 265void ERR_print_errors(BIO *bp);
256void ERR_add_error_data(int num, ...); 266void ERR_add_error_data(int num, ...);
257#endif 267#endif
258void ERR_load_strings(int lib,ERR_STRING_DATA str[]); 268void ERR_load_strings(int lib,ERR_STRING_DATA str[]);
269void ERR_unload_strings(int lib,ERR_STRING_DATA str[]);
259void ERR_load_ERR_strings(void); 270void ERR_load_ERR_strings(void);
260void ERR_load_crypto_strings(void); 271void ERR_load_crypto_strings(void);
261void ERR_free_strings(void); 272void ERR_free_strings(void);
@@ -263,14 +274,22 @@ void ERR_free_strings(void);
263void ERR_remove_state(unsigned long pid); /* if zero we look it up */ 274void ERR_remove_state(unsigned long pid); /* if zero we look it up */
264ERR_STATE *ERR_get_state(void); 275ERR_STATE *ERR_get_state(void);
265 276
266#ifndef NO_LHASH 277#ifndef OPENSSL_NO_LHASH
267LHASH *ERR_get_string_table(void); 278LHASH *ERR_get_string_table(void);
268LHASH *ERR_get_err_state_table(void); /* even less thread-safe than 279LHASH *ERR_get_err_state_table(void);
269 * ERR_get_string_table :-) */
270#endif 280#endif
271 281
272int ERR_get_next_error_library(void); 282int ERR_get_next_error_library(void);
273 283
284/* This opaque type encapsulates the low-level error-state functions */
285typedef struct st_ERR_FNS ERR_FNS;
286/* An application can use this function and provide the return value to loaded
287 * modules that should use the application's ERR state/functionality */
288const ERR_FNS *ERR_get_implementation(void);
289/* A loaded module should call this function prior to any ERR operations using
290 * the application's "ERR_FNS". */
291int ERR_set_implementation(const ERR_FNS *fns);
292
274#ifdef __cplusplus 293#ifdef __cplusplus
275} 294}
276#endif 295#endif
diff --git a/src/lib/libcrypto/err/err_all.c b/src/lib/libcrypto/err/err_all.c
index b8315d8272..90029fd159 100644
--- a/src/lib/libcrypto/err/err_all.c
+++ b/src/lib/libcrypto/err/err_all.c
@@ -59,18 +59,18 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <openssl/asn1.h> 60#include <openssl/asn1.h>
61#include <openssl/bn.h> 61#include <openssl/bn.h>
62#ifndef OPENSSL_NO_EC
63#include <openssl/ec.h>
64#endif
62#include <openssl/buffer.h> 65#include <openssl/buffer.h>
63#include <openssl/bio.h> 66#include <openssl/bio.h>
64#ifndef NO_RSA 67#ifndef OPENSSL_NO_RSA
65#include <openssl/rsa.h> 68#include <openssl/rsa.h>
66#endif 69#endif
67#ifdef RSAref 70#ifndef OPENSSL_NO_DH
68#include <openssl/rsaref.h>
69#endif
70#ifndef NO_DH
71#include <openssl/dh.h> 71#include <openssl/dh.h>
72#endif 72#endif
73#ifndef NO_DSA 73#ifndef OPENSSL_NO_DSA
74#include <openssl/dsa.h> 74#include <openssl/dsa.h>
75#endif 75#endif
76#include <openssl/evp.h> 76#include <openssl/evp.h>
@@ -83,6 +83,7 @@
83#include <openssl/rand.h> 83#include <openssl/rand.h>
84#include <openssl/dso.h> 84#include <openssl/dso.h>
85#include <openssl/engine.h> 85#include <openssl/engine.h>
86#include <openssl/ocsp.h>
86#include <openssl/err.h> 87#include <openssl/err.h>
87 88
88void ERR_load_crypto_strings(void) 89void ERR_load_crypto_strings(void)
@@ -91,36 +92,38 @@ void ERR_load_crypto_strings(void)
91 92
92 if (done) return; 93 if (done) return;
93 done=1; 94 done=1;
94#ifndef NO_ERR 95#ifndef OPENSSL_NO_ERR
95 ERR_load_ASN1_strings(); 96 ERR_load_ERR_strings(); /* include error strings for SYSerr */
96 ERR_load_BN_strings(); 97 ERR_load_BN_strings();
97 ERR_load_BUF_strings(); 98#ifndef OPENSSL_NO_RSA
98 ERR_load_BIO_strings();
99 ERR_load_CONF_strings();
100#ifndef NO_RSA
101#ifdef RSAref
102 ERR_load_RSAREF_strings();
103#else
104 ERR_load_RSA_strings(); 99 ERR_load_RSA_strings();
105#endif 100#endif
106#endif 101#ifndef OPENSSL_NO_DH
107#ifndef NO_DH
108 ERR_load_DH_strings(); 102 ERR_load_DH_strings();
109#endif 103#endif
110#ifndef NO_DSA
111 ERR_load_DSA_strings();
112#endif
113 ERR_load_ERR_strings();
114 ERR_load_EVP_strings(); 104 ERR_load_EVP_strings();
105 ERR_load_BUF_strings();
115 ERR_load_OBJ_strings(); 106 ERR_load_OBJ_strings();
116 ERR_load_PEM_strings(); 107 ERR_load_PEM_strings();
108#ifndef OPENSSL_NO_DSA
109 ERR_load_DSA_strings();
110#endif
117 ERR_load_X509_strings(); 111 ERR_load_X509_strings();
118 ERR_load_X509V3_strings(); 112 ERR_load_ASN1_strings();
113 ERR_load_CONF_strings();
119 ERR_load_CRYPTO_strings(); 114 ERR_load_CRYPTO_strings();
120 ERR_load_PKCS7_strings(); 115#ifndef OPENSSL_NO_EC
116 ERR_load_EC_strings();
117#endif
118 /* skip ERR_load_SSL_strings() because it is not in this library */
119 ERR_load_BIO_strings();
120 ERR_load_PKCS7_strings();
121 ERR_load_X509V3_strings();
121 ERR_load_PKCS12_strings(); 122 ERR_load_PKCS12_strings();
122 ERR_load_RAND_strings(); 123 ERR_load_RAND_strings();
123 ERR_load_DSO_strings(); 124 ERR_load_DSO_strings();
124 ERR_load_ENGINE_strings(); 125 ERR_load_ENGINE_strings();
126 ERR_load_OCSP_strings();
127 ERR_load_UI_strings();
125#endif 128#endif
126 } 129 }
diff --git a/src/lib/libcrypto/err/err_prn.c b/src/lib/libcrypto/err/err_prn.c
index 6f60b016c3..c156663f0e 100644
--- a/src/lib/libcrypto/err/err_prn.c
+++ b/src/lib/libcrypto/err/err_prn.c
@@ -64,11 +64,12 @@
64#include <openssl/err.h> 64#include <openssl/err.h>
65#include <openssl/crypto.h> 65#include <openssl/crypto.h>
66 66
67#ifndef NO_FP_API 67void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u),
68void ERR_print_errors_fp(FILE *fp) 68 void *u)
69 { 69 {
70 unsigned long l; 70 unsigned long l;
71 char buf[200]; 71 char buf[256];
72 char buf2[4096];
72 const char *file,*data; 73 const char *file,*data;
73 int line,flags; 74 int line,flags;
74 unsigned long es; 75 unsigned long es;
@@ -77,31 +78,30 @@ void ERR_print_errors_fp(FILE *fp)
77 while ((l=ERR_get_error_line_data(&file,&line,&data,&flags)) != 0) 78 while ((l=ERR_get_error_line_data(&file,&line,&data,&flags)) != 0)
78 { 79 {
79 ERR_error_string_n(l, buf, sizeof buf); 80 ERR_error_string_n(l, buf, sizeof buf);
80 fprintf(fp,"%lu:%s:%s:%d:%s\n",es,buf, 81 BIO_snprintf(buf2, sizeof(buf2), "%lu:%s:%s:%d:%s\n", es, buf,
81 file,line,(flags&ERR_TXT_STRING)?data:""); 82 file, line, (flags & ERR_TXT_STRING) ? data : "");
83 cb(buf2, strlen(buf2), u);
82 } 84 }
83 } 85 }
86
87#ifndef OPENSSL_NO_FP_API
88static int print_fp(const char *str, size_t len, void *fp)
89 {
90 return fprintf((FILE *)fp, "%s", str);
91 }
92void ERR_print_errors_fp(FILE *fp)
93 {
94 ERR_print_errors_cb(print_fp, fp);
95 }
84#endif 96#endif
85 97
98static int print_bio(const char *str, size_t len, void *bp)
99 {
100 return BIO_write((BIO *)bp, str, len);
101 }
86void ERR_print_errors(BIO *bp) 102void ERR_print_errors(BIO *bp)
87 { 103 {
88 unsigned long l; 104 ERR_print_errors_cb(print_bio, bp);
89 char buf[256];
90 char buf2[256];
91 const char *file,*data;
92 int line,flags;
93 unsigned long es;
94
95 es=CRYPTO_thread_id();
96 while ((l=ERR_get_error_line_data(&file,&line,&data,&flags)) != 0)
97 {
98 ERR_error_string_n(l, buf, sizeof buf);
99 sprintf(buf2,"%lu:%s:%s:%d:",es,buf,
100 file,line);
101 BIO_write(bp,buf2,strlen(buf2));
102 if (flags & ERR_TXT_STRING)
103 BIO_write(bp,data,strlen(data));
104 BIO_write(bp,"\n",1);
105 }
106 } 105 }
107 106
107
diff --git a/src/lib/libcrypto/err/openssl.ec b/src/lib/libcrypto/err/openssl.ec
index 861d680e07..29a69dfdd4 100644
--- a/src/lib/libcrypto/err/openssl.ec
+++ b/src/lib/libcrypto/err/openssl.ec
@@ -1,29 +1,36 @@
1# crypto/err/openssl.ec
2
3# configuration file for util/mkerr.pl
4
5# files that may have to be rewritten by util/mkerr.pl
1L ERR NONE NONE 6L ERR NONE NONE
2L CRYPTO crypto/crypto.h crypto/cpt_err.c
3L BN crypto/bn/bn.h crypto/bn/bn_err.c 7L BN crypto/bn/bn.h crypto/bn/bn_err.c
4L RSA crypto/rsa/rsa.h crypto/rsa/rsa_err.c 8L RSA crypto/rsa/rsa.h crypto/rsa/rsa_err.c
5L DSA crypto/dsa/dsa.h crypto/dsa/dsa_err.c
6L DSO crypto/dso/dso.h crypto/dso/dso_err.c
7L DH crypto/dh/dh.h crypto/dh/dh_err.c 9L DH crypto/dh/dh.h crypto/dh/dh_err.c
8L EVP crypto/evp/evp.h crypto/evp/evp_err.c 10L EVP crypto/evp/evp.h crypto/evp/evp_err.c
9L BUF crypto/buffer/buffer.h crypto/buffer/buf_err.c 11L BUF crypto/buffer/buffer.h crypto/buffer/buf_err.c
10L BIO crypto/bio/bio.h crypto/bio/bio_err.c
11L OBJ crypto/objects/objects.h crypto/objects/obj_err.c 12L OBJ crypto/objects/objects.h crypto/objects/obj_err.c
12L PEM crypto/pem/pem.h crypto/pem/pem_err.c 13L PEM crypto/pem/pem.h crypto/pem/pem_err.c
14L DSA crypto/dsa/dsa.h crypto/dsa/dsa_err.c
13L X509 crypto/x509/x509.h crypto/x509/x509_err.c 15L X509 crypto/x509/x509.h crypto/x509/x509_err.c
14L NONE crypto/x509/x509_vfy.h NONE
15L X509V3 crypto/x509v3/x509v3.h crypto/x509v3/v3err.c
16#L METH crypto/meth/meth.h crypto/meth/meth_err.c
17L ASN1 crypto/asn1/asn1.h crypto/asn1/asn1_err.c 16L ASN1 crypto/asn1/asn1.h crypto/asn1/asn1_err.c
18L CONF crypto/conf/conf.h crypto/conf/conf_err.c 17L CONF crypto/conf/conf.h crypto/conf/conf_err.c
19#L PROXY crypto/proxy/proxy.h crypto/proxy/proxy_err.c 18L CRYPTO crypto/crypto.h crypto/cpt_err.c
19L EC crypto/ec/ec.h crypto/ec/ec_err.c
20L SSL ssl/ssl.h ssl/ssl_err.c
21L BIO crypto/bio/bio.h crypto/bio/bio_err.c
20L PKCS7 crypto/pkcs7/pkcs7.h crypto/pkcs7/pkcs7err.c 22L PKCS7 crypto/pkcs7/pkcs7.h crypto/pkcs7/pkcs7err.c
23L X509V3 crypto/x509v3/x509v3.h crypto/x509v3/v3err.c
21L PKCS12 crypto/pkcs12/pkcs12.h crypto/pkcs12/pk12err.c 24L PKCS12 crypto/pkcs12/pkcs12.h crypto/pkcs12/pk12err.c
22L RSAREF rsaref/rsaref.h rsaref/rsar_err.c
23L SSL ssl/ssl.h ssl/ssl_err.c
24L COMP crypto/comp/comp.h crypto/comp/comp_err.c
25L RAND crypto/rand/rand.h crypto/rand/rand_err.c 25L RAND crypto/rand/rand.h crypto/rand/rand_err.c
26L ENGINE crypto/engine/engine.h crypto/engine/engine_err.c 26L DSO crypto/dso/dso.h crypto/dso/dso_err.c
27L ENGINE crypto/engine/engine.h crypto/engine/eng_err.c
28L OCSP crypto/ocsp/ocsp.h crypto/ocsp/ocsp_err.c
29L UI crypto/ui/ui.h crypto/ui/ui_err.c
30
31# additional header files to be scanned for function names
32L NONE crypto/x509/x509_vfy.h NONE
33L NONE crypto/ec/ec_lcl.h NONE
27 34
28 35
29F RSAREF_F_RSA_BN2BIN 36F RSAREF_F_RSA_BN2BIN
diff --git a/src/lib/libcrypto/evp/Makefile.ssl b/src/lib/libcrypto/evp/Makefile.ssl
index 624168031d..4abe93dafe 100644
--- a/src/lib/libcrypto/evp/Makefile.ssl
+++ b/src/lib/libcrypto/evp/Makefile.ssl
@@ -5,26 +5,28 @@
5DIR= evp 5DIR= evp
6TOP= ../.. 6TOP= ../..
7CC= cc 7CC= cc
8INCLUDES= -I.. -I../../include 8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g 9CFLAG=-g
10INSTALL_PREFIX= 10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl 11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl 12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl 13MAKE= make -f Makefile.ssl
14MAKEDEPEND= $(TOP)/util/domd $(TOP) 14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
15MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
16AR= ar r 17AR= ar r
17 18
18CFLAGS= $(INCLUDES) $(CFLAG) 19CFLAGS= $(INCLUDES) $(CFLAG)
19 20
20GENERAL=Makefile 21GENERAL=Makefile
21TEST= 22TEST=evp_test.c
23TESTDATA=evptests.txt
22APPS= 24APPS=
23 25
24LIB=$(TOP)/libcrypto.a 26LIB=$(TOP)/libcrypto.a
25LIBSRC= encode.c digest.c evp_enc.c evp_key.c \ 27LIBSRC= encode.c digest.c evp_enc.c evp_key.c evp_acnf.c \
26 e_des.c e_bf.c e_idea.c e_des3.c \ 28 e_des.c e_bf.c e_idea.c e_des3.c \
27 e_rc4.c names.c \ 29 e_rc4.c e_aes.c names.c \
28 e_xcbc_d.c e_rc2.c e_cast.c e_rc5.c \ 30 e_xcbc_d.c e_rc2.c e_cast.c e_rc5.c \
29 m_null.c m_md2.c m_md4.c m_md5.c m_sha.c m_sha1.c \ 31 m_null.c m_md2.c m_md4.c m_md5.c m_sha.c m_sha1.c \
30 m_dss.c m_dss1.c m_mdc2.c m_ripemd.c \ 32 m_dss.c m_dss1.c m_mdc2.c m_ripemd.c \
@@ -33,9 +35,9 @@ LIBSRC= encode.c digest.c evp_enc.c evp_key.c \
33 c_all.c c_allc.c c_alld.c evp_lib.c bio_ok.c \ 35 c_all.c c_allc.c c_alld.c evp_lib.c bio_ok.c \
34 evp_pkey.c evp_pbe.c p5_crpt.c p5_crpt2.c 36 evp_pkey.c evp_pbe.c p5_crpt.c p5_crpt2.c
35 37
36LIBOBJ= encode.o digest.o evp_enc.o evp_key.o \ 38LIBOBJ= encode.o digest.o evp_enc.o evp_key.o evp_acnf.o \
37 e_des.o e_bf.o e_idea.o e_des3.o \ 39 e_des.o e_bf.o e_idea.o e_des3.o \
38 e_rc4.o names.o \ 40 e_rc4.o e_aes.o names.o \
39 e_xcbc_d.o e_rc2.o e_cast.o e_rc5.o \ 41 e_xcbc_d.o e_rc2.o e_cast.o e_rc5.o \
40 m_null.o m_md2.o m_md4.o m_md5.o m_sha.o m_sha1.o \ 42 m_null.o m_md2.o m_md4.o m_md5.o m_sha.o m_sha1.o \
41 m_dss.o m_dss1.o m_mdc2.o m_ripemd.o \ 43 m_dss.o m_dss1.o m_mdc2.o m_ripemd.o \
@@ -58,8 +60,7 @@ all: lib
58 60
59lib: $(LIBOBJ) 61lib: $(LIBOBJ)
60 $(AR) $(LIB) $(LIBOBJ) 62 $(AR) $(LIB) $(LIBOBJ)
61 @echo You may get an error following this line. Please ignore. 63 $(RANLIB) $(LIB) || echo Never mind.
62 - $(RANLIB) $(LIB)
63 @touch lib 64 @touch lib
64 65
65files: 66files:
@@ -69,6 +70,7 @@ links:
69 @$(SHELL) $(TOP)/util/point.sh Makefile.ssl Makefile 70 @$(SHELL) $(TOP)/util/point.sh Makefile.ssl Makefile
70 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) 71 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
71 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) 72 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
73 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TESTDATA)
72 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) 74 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
73 75
74install: 76install:
@@ -98,820 +100,563 @@ clean:
98 100
99# DO NOT DELETE THIS LINE -- make depend depends on it. 101# DO NOT DELETE THIS LINE -- make depend depends on it.
100 102
101bio_b64.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 103bio_b64.o: ../../e_os.h ../../include/openssl/asn1.h
102bio_b64.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 104bio_b64.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
103bio_b64.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 105bio_b64.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
104bio_b64.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 106bio_b64.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
105bio_b64.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 107bio_b64.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
106bio_b64.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
107bio_b64.o: ../../include/openssl/err.h ../../include/openssl/evp.h
108bio_b64.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
109bio_b64.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
110bio_b64.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
111bio_b64.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 108bio_b64.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
112bio_b64.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 109bio_b64.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
113bio_b64.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 110bio_b64.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
114bio_b64.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 111bio_b64.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
115bio_b64.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 112bio_b64.o: ../cryptlib.h bio_b64.c
116bio_b64.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 113bio_enc.o: ../../e_os.h ../../include/openssl/asn1.h
117bio_b64.o: ../../include/openssl/symhacks.h ../cryptlib.h 114bio_enc.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
118bio_enc.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 115bio_enc.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
119bio_enc.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 116bio_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
120bio_enc.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 117bio_enc.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
121bio_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
122bio_enc.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
123bio_enc.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
124bio_enc.o: ../../include/openssl/err.h ../../include/openssl/evp.h
125bio_enc.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
126bio_enc.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
127bio_enc.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
128bio_enc.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 118bio_enc.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
129bio_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 119bio_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
130bio_enc.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 120bio_enc.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
131bio_enc.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 121bio_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
132bio_enc.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 122bio_enc.o: ../cryptlib.h bio_enc.c
133bio_enc.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 123bio_md.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
134bio_enc.o: ../../include/openssl/symhacks.h ../cryptlib.h 124bio_md.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
135bio_md.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 125bio_md.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
136bio_md.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
137bio_md.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
138bio_md.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
139bio_md.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
140bio_md.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
141bio_md.o: ../../include/openssl/err.h ../../include/openssl/evp.h 126bio_md.o: ../../include/openssl/err.h ../../include/openssl/evp.h
142bio_md.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 127bio_md.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
143bio_md.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 128bio_md.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
144bio_md.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 129bio_md.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
145bio_md.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 130bio_md.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
146bio_md.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 131bio_md.o: ../../include/openssl/symhacks.h ../cryptlib.h bio_md.c
147bio_md.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 132bio_ok.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
148bio_md.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 133bio_ok.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
149bio_md.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 134bio_ok.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
150bio_md.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
151bio_md.o: ../../include/openssl/symhacks.h ../cryptlib.h
152bio_ok.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
153bio_ok.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
154bio_ok.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
155bio_ok.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
156bio_ok.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
157bio_ok.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
158bio_ok.o: ../../include/openssl/err.h ../../include/openssl/evp.h 135bio_ok.o: ../../include/openssl/err.h ../../include/openssl/evp.h
159bio_ok.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 136bio_ok.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
160bio_ok.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 137bio_ok.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
161bio_ok.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 138bio_ok.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
162bio_ok.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 139bio_ok.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
163bio_ok.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
164bio_ok.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
165bio_ok.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
166bio_ok.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
167bio_ok.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
168bio_ok.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 140bio_ok.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
169bio_ok.o: ../cryptlib.h 141bio_ok.o: ../cryptlib.h bio_ok.c
170c_all.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 142c_all.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
171c_all.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 143c_all.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
172c_all.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 144c_all.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
173c_all.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
174c_all.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
175c_all.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
176c_all.o: ../../include/openssl/err.h ../../include/openssl/evp.h 145c_all.o: ../../include/openssl/err.h ../../include/openssl/evp.h
177c_all.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 146c_all.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
178c_all.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 147c_all.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
179c_all.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 148c_all.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
180c_all.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 149c_all.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
181c_all.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 150c_all.o: ../../include/openssl/symhacks.h ../cryptlib.h c_all.c
182c_all.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 151c_allc.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
183c_all.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 152c_allc.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
184c_all.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 153c_allc.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
185c_all.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 154c_allc.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
186c_all.o: ../../include/openssl/symhacks.h ../cryptlib.h
187c_allc.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
188c_allc.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
189c_allc.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
190c_allc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
191c_allc.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
192c_allc.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
193c_allc.o: ../../include/openssl/err.h ../../include/openssl/evp.h 155c_allc.o: ../../include/openssl/err.h ../../include/openssl/evp.h
194c_allc.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 156c_allc.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
195c_allc.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 157c_allc.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
196c_allc.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 158c_allc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
197c_allc.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
198c_allc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
199c_allc.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h 159c_allc.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
200c_allc.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
201c_allc.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
202c_allc.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 160c_allc.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
203c_allc.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 161c_allc.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
204c_allc.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 162c_allc.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
205c_allc.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 163c_allc.o: ../../include/openssl/x509_vfy.h ../cryptlib.h c_allc.c
206c_alld.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 164c_alld.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
207c_alld.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 165c_alld.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
208c_alld.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 166c_alld.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
209c_alld.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 167c_alld.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
210c_alld.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
211c_alld.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
212c_alld.o: ../../include/openssl/err.h ../../include/openssl/evp.h 168c_alld.o: ../../include/openssl/err.h ../../include/openssl/evp.h
213c_alld.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 169c_alld.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
214c_alld.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 170c_alld.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
215c_alld.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 171c_alld.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
216c_alld.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
217c_alld.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
218c_alld.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h 172c_alld.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
219c_alld.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
220c_alld.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
221c_alld.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 173c_alld.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
222c_alld.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 174c_alld.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
223c_alld.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 175c_alld.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
224c_alld.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 176c_alld.o: ../../include/openssl/x509_vfy.h ../cryptlib.h c_alld.c
225digest.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 177digest.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
226digest.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 178digest.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
227digest.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 179digest.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
228digest.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 180digest.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
229digest.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 181digest.o: ../../include/openssl/engine.h ../../include/openssl/err.h
230digest.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 182digest.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
231digest.o: ../../include/openssl/err.h ../../include/openssl/evp.h
232digest.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
233digest.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
234digest.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
235digest.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 183digest.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
236digest.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 184digest.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
237digest.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 185digest.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
238digest.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
239digest.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 186digest.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
240digest.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 187digest.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
241digest.o: ../../include/openssl/symhacks.h ../cryptlib.h 188digest.o: ../../include/openssl/ui.h ../cryptlib.h digest.c
242e_bf.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 189e_aes.o: ../../include/openssl/aes.h ../../include/openssl/asn1.h
190e_aes.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
191e_aes.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
192e_aes.o: ../../include/openssl/err.h ../../include/openssl/evp.h
193e_aes.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
194e_aes.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
195e_aes.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
196e_aes.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
197e_aes.o: ../../include/openssl/symhacks.h e_aes.c evp_locl.h
198e_bf.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
243e_bf.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 199e_bf.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
244e_bf.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 200e_bf.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
245e_bf.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 201e_bf.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
246e_bf.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 202e_bf.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
247e_bf.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
248e_bf.o: ../../include/openssl/err.h ../../include/openssl/evp.h
249e_bf.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
250e_bf.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
251e_bf.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
252e_bf.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 203e_bf.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
253e_bf.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 204e_bf.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
254e_bf.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 205e_bf.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
255e_bf.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 206e_bf.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
256e_bf.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 207e_bf.o: ../cryptlib.h e_bf.c evp_locl.h
257e_bf.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 208e_cast.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
258e_bf.o: ../../include/openssl/symhacks.h ../cryptlib.h evp_locl.h 209e_cast.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
259e_cast.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 210e_cast.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
260e_cast.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 211e_cast.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
261e_cast.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 212e_cast.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
262e_cast.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
263e_cast.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
264e_cast.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
265e_cast.o: ../../include/openssl/err.h ../../include/openssl/evp.h
266e_cast.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
267e_cast.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
268e_cast.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
269e_cast.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 213e_cast.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
270e_cast.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 214e_cast.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
271e_cast.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 215e_cast.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
272e_cast.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 216e_cast.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
273e_cast.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 217e_cast.o: ../cryptlib.h e_cast.c evp_locl.h
274e_cast.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 218e_des.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
275e_cast.o: ../../include/openssl/symhacks.h ../cryptlib.h evp_locl.h 219e_des.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
276e_des.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
277e_des.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
278e_des.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
279e_des.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 220e_des.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
280e_des.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 221e_des.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
281e_des.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
282e_des.o: ../../include/openssl/err.h ../../include/openssl/evp.h 222e_des.o: ../../include/openssl/err.h ../../include/openssl/evp.h
283e_des.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 223e_des.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
284e_des.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 224e_des.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
285e_des.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 225e_des.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
286e_des.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 226e_des.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
287e_des.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 227e_des.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
288e_des.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 228e_des.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_des.c evp_locl.h
289e_des.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 229e_des3.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
290e_des.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 230e_des3.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
291e_des.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
292e_des.o: ../../include/openssl/symhacks.h ../cryptlib.h evp_locl.h
293e_des3.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
294e_des3.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
295e_des3.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
296e_des3.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 231e_des3.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
297e_des3.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 232e_des3.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
298e_des3.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
299e_des3.o: ../../include/openssl/err.h ../../include/openssl/evp.h 233e_des3.o: ../../include/openssl/err.h ../../include/openssl/evp.h
300e_des3.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 234e_des3.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
301e_des3.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 235e_des3.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
302e_des3.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 236e_des3.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
303e_des3.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 237e_des3.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
304e_des3.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 238e_des3.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
305e_des3.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 239e_des3.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_des3.c evp_locl.h
306e_des3.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 240e_idea.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
307e_des3.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 241e_idea.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
308e_des3.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 242e_idea.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
309e_des3.o: ../../include/openssl/symhacks.h ../cryptlib.h evp_locl.h
310e_idea.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
311e_idea.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
312e_idea.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
313e_idea.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
314e_idea.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
315e_idea.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
316e_idea.o: ../../include/openssl/err.h ../../include/openssl/evp.h 243e_idea.o: ../../include/openssl/err.h ../../include/openssl/evp.h
317e_idea.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 244e_idea.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
318e_idea.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
319e_idea.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
320e_idea.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 245e_idea.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
321e_idea.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 246e_idea.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
322e_idea.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 247e_idea.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
323e_idea.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 248e_idea.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
324e_idea.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 249e_idea.o: ../cryptlib.h e_idea.c evp_locl.h
325e_idea.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 250e_null.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
326e_idea.o: ../../include/openssl/symhacks.h ../cryptlib.h evp_locl.h 251e_null.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
327e_null.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 252e_null.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
328e_null.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
329e_null.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
330e_null.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
331e_null.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
332e_null.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
333e_null.o: ../../include/openssl/err.h ../../include/openssl/evp.h 253e_null.o: ../../include/openssl/err.h ../../include/openssl/evp.h
334e_null.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 254e_null.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
335e_null.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 255e_null.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
336e_null.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 256e_null.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
337e_null.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 257e_null.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
338e_null.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 258e_null.o: ../../include/openssl/symhacks.h ../cryptlib.h e_null.c
339e_null.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 259e_rc2.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
340e_null.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 260e_rc2.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
341e_null.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 261e_rc2.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
342e_null.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
343e_null.o: ../../include/openssl/symhacks.h ../cryptlib.h
344e_rc2.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
345e_rc2.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
346e_rc2.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
347e_rc2.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
348e_rc2.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
349e_rc2.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
350e_rc2.o: ../../include/openssl/err.h ../../include/openssl/evp.h 262e_rc2.o: ../../include/openssl/err.h ../../include/openssl/evp.h
351e_rc2.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 263e_rc2.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
352e_rc2.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 264e_rc2.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
353e_rc2.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 265e_rc2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
354e_rc2.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 266e_rc2.o: ../../include/openssl/rc2.h ../../include/openssl/safestack.h
355e_rc2.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 267e_rc2.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
356e_rc2.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 268e_rc2.o: ../cryptlib.h e_rc2.c evp_locl.h
357e_rc2.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 269e_rc4.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
358e_rc2.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 270e_rc4.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
359e_rc2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 271e_rc4.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
360e_rc2.o: ../../include/openssl/symhacks.h ../cryptlib.h evp_locl.h
361e_rc4.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
362e_rc4.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
363e_rc4.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
364e_rc4.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
365e_rc4.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
366e_rc4.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
367e_rc4.o: ../../include/openssl/err.h ../../include/openssl/evp.h 272e_rc4.o: ../../include/openssl/err.h ../../include/openssl/evp.h
368e_rc4.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 273e_rc4.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
369e_rc4.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 274e_rc4.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
370e_rc4.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 275e_rc4.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
371e_rc4.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 276e_rc4.o: ../../include/openssl/rc4.h ../../include/openssl/safestack.h
372e_rc4.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 277e_rc4.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
373e_rc4.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 278e_rc4.o: ../cryptlib.h e_rc4.c
374e_rc4.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 279e_rc5.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
375e_rc4.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 280e_rc5.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
376e_rc4.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 281e_rc5.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
377e_rc4.o: ../../include/openssl/symhacks.h ../cryptlib.h
378e_rc5.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
379e_rc5.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
380e_rc5.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
381e_rc5.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
382e_rc5.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
383e_rc5.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
384e_rc5.o: ../../include/openssl/err.h ../../include/openssl/evp.h 282e_rc5.o: ../../include/openssl/err.h ../../include/openssl/evp.h
385e_rc5.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 283e_rc5.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
386e_rc5.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 284e_rc5.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
387e_rc5.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 285e_rc5.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
388e_rc5.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 286e_rc5.o: ../../include/openssl/rc5.h ../../include/openssl/safestack.h
389e_rc5.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 287e_rc5.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
390e_rc5.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 288e_rc5.o: ../cryptlib.h e_rc5.c evp_locl.h
391e_rc5.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 289e_xcbc_d.o: ../../e_os.h ../../include/openssl/asn1.h
392e_rc5.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 290e_xcbc_d.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
393e_rc5.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 291e_xcbc_d.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
394e_rc5.o: ../../include/openssl/symhacks.h ../cryptlib.h evp_locl.h 292e_xcbc_d.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
395e_xcbc_d.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 293e_xcbc_d.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
396e_xcbc_d.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 294e_xcbc_d.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
397e_xcbc_d.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
398e_xcbc_d.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
399e_xcbc_d.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
400e_xcbc_d.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
401e_xcbc_d.o: ../../include/openssl/err.h ../../include/openssl/evp.h
402e_xcbc_d.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
403e_xcbc_d.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
404e_xcbc_d.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
405e_xcbc_d.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 295e_xcbc_d.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
406e_xcbc_d.o: ../../include/openssl/opensslconf.h 296e_xcbc_d.o: ../../include/openssl/opensslconf.h
407e_xcbc_d.o: ../../include/openssl/opensslv.h ../../include/openssl/rc2.h 297e_xcbc_d.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
408e_xcbc_d.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 298e_xcbc_d.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
409e_xcbc_d.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 299e_xcbc_d.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
410e_xcbc_d.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 300e_xcbc_d.o: ../../include/openssl/ui_compat.h ../cryptlib.h e_xcbc_d.c
411e_xcbc_d.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 301encode.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
412e_xcbc_d.o: ../cryptlib.h 302encode.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
413encode.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 303encode.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
414encode.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
415encode.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
416encode.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
417encode.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
418encode.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
419encode.o: ../../include/openssl/err.h ../../include/openssl/evp.h 304encode.o: ../../include/openssl/err.h ../../include/openssl/evp.h
420encode.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 305encode.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
421encode.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 306encode.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
422encode.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 307encode.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
423encode.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 308encode.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
424encode.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 309encode.o: ../../include/openssl/symhacks.h ../cryptlib.h encode.c
425encode.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 310evp_acnf.o: ../../e_os.h ../../include/openssl/asn1.h
426encode.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 311evp_acnf.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
427encode.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 312evp_acnf.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
428encode.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 313evp_acnf.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
429encode.o: ../../include/openssl/symhacks.h ../cryptlib.h 314evp_acnf.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
430evp_enc.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 315evp_acnf.o: ../../include/openssl/engine.h ../../include/openssl/err.h
431evp_enc.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 316evp_acnf.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
432evp_enc.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 317evp_acnf.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
433evp_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 318evp_acnf.o: ../../include/openssl/opensslconf.h
319evp_acnf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
320evp_acnf.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
321evp_acnf.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
322evp_acnf.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
323evp_acnf.o: ../cryptlib.h evp_acnf.c
324evp_enc.o: ../../e_os.h ../../include/openssl/asn1.h
325evp_enc.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
326evp_enc.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
434evp_enc.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 327evp_enc.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
435evp_enc.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 328evp_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
436evp_enc.o: ../../include/openssl/err.h ../../include/openssl/evp.h 329evp_enc.o: ../../include/openssl/err.h ../../include/openssl/evp.h
437evp_enc.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 330evp_enc.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
438evp_enc.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 331evp_enc.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
439evp_enc.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 332evp_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
440evp_enc.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 333evp_enc.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
441evp_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 334evp_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
442evp_enc.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 335evp_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
443evp_enc.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 336evp_enc.o: ../cryptlib.h evp_enc.c evp_locl.h
444evp_enc.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
445evp_enc.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
446evp_enc.o: ../../include/openssl/symhacks.h ../cryptlib.h evp_locl.h
447evp_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 337evp_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
448evp_err.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 338evp_err.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
449evp_err.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h 339evp_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
450evp_err.o: ../../include/openssl/des.h ../../include/openssl/dh.h 340evp_err.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
451evp_err.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
452evp_err.o: ../../include/openssl/err.h ../../include/openssl/evp.h
453evp_err.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
454evp_err.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
455evp_err.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
456evp_err.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 341evp_err.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
457evp_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 342evp_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
458evp_err.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 343evp_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
459evp_err.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 344evp_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
460evp_err.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 345evp_err.o: evp_err.c
461evp_err.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 346evp_key.o: ../../e_os.h ../../include/openssl/asn1.h
462evp_err.o: ../../include/openssl/symhacks.h 347evp_key.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
463evp_key.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 348evp_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
464evp_key.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
465evp_key.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
466evp_key.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
467evp_key.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 349evp_key.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
468evp_key.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 350evp_key.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
469evp_key.o: ../../include/openssl/err.h ../../include/openssl/evp.h 351evp_key.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
470evp_key.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
471evp_key.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
472evp_key.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
473evp_key.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 352evp_key.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
474evp_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 353evp_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
475evp_key.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h 354evp_key.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
476evp_key.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 355evp_key.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
477evp_key.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 356evp_key.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
478evp_key.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 357evp_key.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
479evp_key.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
480evp_key.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 358evp_key.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
481evp_key.o: ../cryptlib.h 359evp_key.o: ../cryptlib.h evp_key.c
482evp_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 360evp_lib.o: ../../e_os.h ../../include/openssl/asn1.h
483evp_lib.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 361evp_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
484evp_lib.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 362evp_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
485evp_lib.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 363evp_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
486evp_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 364evp_lib.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
487evp_lib.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
488evp_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h
489evp_lib.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
490evp_lib.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
491evp_lib.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
492evp_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 365evp_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
493evp_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 366evp_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
494evp_lib.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 367evp_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
495evp_lib.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 368evp_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
496evp_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 369evp_lib.o: ../cryptlib.h evp_lib.c
497evp_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 370evp_pbe.o: ../../e_os.h ../../include/openssl/asn1.h
498evp_lib.o: ../../include/openssl/symhacks.h ../cryptlib.h 371evp_pbe.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
499evp_pbe.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 372evp_pbe.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
500evp_pbe.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
501evp_pbe.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
502evp_pbe.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
503evp_pbe.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 373evp_pbe.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
504evp_pbe.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 374evp_pbe.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
505evp_pbe.o: ../../include/openssl/err.h ../../include/openssl/evp.h 375evp_pbe.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
506evp_pbe.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
507evp_pbe.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
508evp_pbe.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
509evp_pbe.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 376evp_pbe.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
510evp_pbe.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 377evp_pbe.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
511evp_pbe.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h 378evp_pbe.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
512evp_pbe.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 379evp_pbe.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
513evp_pbe.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 380evp_pbe.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
514evp_pbe.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 381evp_pbe.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
515evp_pbe.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 382evp_pbe.o: ../../include/openssl/x509_vfy.h ../cryptlib.h evp_pbe.c
516evp_pbe.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 383evp_pkey.o: ../../e_os.h ../../include/openssl/asn1.h
517evp_pbe.o: ../cryptlib.h 384evp_pkey.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
518evp_pkey.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 385evp_pkey.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
519evp_pkey.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
520evp_pkey.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
521evp_pkey.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
522evp_pkey.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 386evp_pkey.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
523evp_pkey.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 387evp_pkey.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
524evp_pkey.o: ../../include/openssl/err.h ../../include/openssl/evp.h 388evp_pkey.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
525evp_pkey.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
526evp_pkey.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
527evp_pkey.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
528evp_pkey.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 389evp_pkey.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
529evp_pkey.o: ../../include/openssl/opensslconf.h 390evp_pkey.o: ../../include/openssl/opensslconf.h
530evp_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 391evp_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
531evp_pkey.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h 392evp_pkey.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
532evp_pkey.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 393evp_pkey.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
533evp_pkey.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 394evp_pkey.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
534evp_pkey.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 395evp_pkey.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
535evp_pkey.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 396evp_pkey.o: ../../include/openssl/x509_vfy.h ../cryptlib.h evp_pkey.c
536evp_pkey.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 397m_dss.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
537evp_pkey.o: ../cryptlib.h 398m_dss.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
538m_dss.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 399m_dss.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
539m_dss.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 400m_dss.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
540m_dss.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
541m_dss.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
542m_dss.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
543m_dss.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
544m_dss.o: ../../include/openssl/err.h ../../include/openssl/evp.h 401m_dss.o: ../../include/openssl/err.h ../../include/openssl/evp.h
545m_dss.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 402m_dss.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
546m_dss.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 403m_dss.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
547m_dss.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 404m_dss.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
548m_dss.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 405m_dss.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
549m_dss.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
550m_dss.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
551m_dss.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
552m_dss.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
553m_dss.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 406m_dss.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
554m_dss.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 407m_dss.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
555m_dss.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 408m_dss.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
556m_dss.o: ../cryptlib.h 409m_dss.o: ../cryptlib.h m_dss.c
557m_dss1.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 410m_dss1.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
558m_dss1.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 411m_dss1.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
559m_dss1.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 412m_dss1.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
560m_dss1.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 413m_dss1.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
561m_dss1.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
562m_dss1.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
563m_dss1.o: ../../include/openssl/err.h ../../include/openssl/evp.h 414m_dss1.o: ../../include/openssl/err.h ../../include/openssl/evp.h
564m_dss1.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 415m_dss1.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
565m_dss1.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 416m_dss1.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
566m_dss1.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 417m_dss1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
567m_dss1.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 418m_dss1.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
568m_dss1.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
569m_dss1.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
570m_dss1.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
571m_dss1.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
572m_dss1.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 419m_dss1.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
573m_dss1.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 420m_dss1.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
574m_dss1.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 421m_dss1.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
575m_dss1.o: ../cryptlib.h 422m_dss1.o: ../cryptlib.h m_dss1.c
576m_md2.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 423m_md2.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
577m_md2.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 424m_md2.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
578m_md2.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 425m_md2.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
579m_md2.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 426m_md2.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
580m_md2.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
581m_md2.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
582m_md2.o: ../../include/openssl/err.h ../../include/openssl/evp.h 427m_md2.o: ../../include/openssl/err.h ../../include/openssl/evp.h
583m_md2.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 428m_md2.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
584m_md2.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
585m_md2.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
586m_md2.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 429m_md2.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
587m_md2.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 430m_md2.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
588m_md2.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h 431m_md2.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
589m_md2.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 432m_md2.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
590m_md2.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 433m_md2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
591m_md2.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 434m_md2.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
592m_md2.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 435m_md2.o: ../../include/openssl/x509_vfy.h ../cryptlib.h m_md2.c
593m_md2.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 436m_md4.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
594m_md2.o: ../cryptlib.h 437m_md4.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
595m_md4.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 438m_md4.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
596m_md4.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 439m_md4.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
597m_md4.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
598m_md4.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
599m_md4.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
600m_md4.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
601m_md4.o: ../../include/openssl/err.h ../../include/openssl/evp.h 440m_md4.o: ../../include/openssl/err.h ../../include/openssl/evp.h
602m_md4.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 441m_md4.o: ../../include/openssl/lhash.h ../../include/openssl/md4.h
603m_md4.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
604m_md4.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
605m_md4.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 442m_md4.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
606m_md4.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 443m_md4.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
607m_md4.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h 444m_md4.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
608m_md4.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 445m_md4.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
609m_md4.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 446m_md4.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
610m_md4.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 447m_md4.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
611m_md4.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 448m_md4.o: ../../include/openssl/x509_vfy.h ../cryptlib.h m_md4.c
612m_md4.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 449m_md5.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
613m_md4.o: ../cryptlib.h 450m_md5.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
614m_md5.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 451m_md5.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
615m_md5.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 452m_md5.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
616m_md5.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
617m_md5.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
618m_md5.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
619m_md5.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
620m_md5.o: ../../include/openssl/err.h ../../include/openssl/evp.h 453m_md5.o: ../../include/openssl/err.h ../../include/openssl/evp.h
621m_md5.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 454m_md5.o: ../../include/openssl/lhash.h ../../include/openssl/md5.h
622m_md5.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
623m_md5.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
624m_md5.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 455m_md5.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
625m_md5.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 456m_md5.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
626m_md5.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h 457m_md5.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
627m_md5.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 458m_md5.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
628m_md5.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 459m_md5.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
629m_md5.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 460m_md5.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
630m_md5.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 461m_md5.o: ../../include/openssl/x509_vfy.h ../cryptlib.h m_md5.c
631m_md5.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 462m_mdc2.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
632m_md5.o: ../cryptlib.h 463m_mdc2.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
633m_mdc2.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
634m_mdc2.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
635m_mdc2.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
636m_mdc2.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 464m_mdc2.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
637m_mdc2.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 465m_mdc2.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
638m_mdc2.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 466m_mdc2.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
639m_mdc2.o: ../../include/openssl/err.h ../../include/openssl/evp.h 467m_mdc2.o: ../../include/openssl/err.h ../../include/openssl/evp.h
640m_mdc2.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 468m_mdc2.o: ../../include/openssl/lhash.h ../../include/openssl/mdc2.h
641m_mdc2.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
642m_mdc2.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
643m_mdc2.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 469m_mdc2.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
644m_mdc2.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 470m_mdc2.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
645m_mdc2.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h 471m_mdc2.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
646m_mdc2.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 472m_mdc2.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
647m_mdc2.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 473m_mdc2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
648m_mdc2.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 474m_mdc2.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
649m_mdc2.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 475m_mdc2.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
650m_mdc2.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 476m_mdc2.o: ../../include/openssl/x509_vfy.h ../cryptlib.h m_mdc2.c
651m_mdc2.o: ../cryptlib.h 477m_null.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
652m_null.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 478m_null.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
653m_null.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 479m_null.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
654m_null.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 480m_null.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
655m_null.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
656m_null.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
657m_null.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
658m_null.o: ../../include/openssl/err.h ../../include/openssl/evp.h 481m_null.o: ../../include/openssl/err.h ../../include/openssl/evp.h
659m_null.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 482m_null.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
660m_null.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 483m_null.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
661m_null.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 484m_null.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
662m_null.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 485m_null.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
663m_null.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
664m_null.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
665m_null.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
666m_null.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
667m_null.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 486m_null.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
668m_null.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 487m_null.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
669m_null.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 488m_null.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
670m_null.o: ../cryptlib.h 489m_null.o: ../cryptlib.h m_null.c
671m_ripemd.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 490m_ripemd.o: ../../e_os.h ../../include/openssl/asn1.h
672m_ripemd.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 491m_ripemd.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
673m_ripemd.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 492m_ripemd.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
674m_ripemd.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
675m_ripemd.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 493m_ripemd.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
676m_ripemd.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 494m_ripemd.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
677m_ripemd.o: ../../include/openssl/err.h ../../include/openssl/evp.h 495m_ripemd.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
678m_ripemd.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
679m_ripemd.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
680m_ripemd.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
681m_ripemd.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 496m_ripemd.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
682m_ripemd.o: ../../include/openssl/opensslconf.h 497m_ripemd.o: ../../include/openssl/opensslconf.h
683m_ripemd.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 498m_ripemd.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
684m_ripemd.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 499m_ripemd.o: ../../include/openssl/pkcs7.h ../../include/openssl/ripemd.h
685m_ripemd.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
686m_ripemd.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 500m_ripemd.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
687m_ripemd.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 501m_ripemd.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
688m_ripemd.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 502m_ripemd.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
689m_ripemd.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 503m_ripemd.o: ../../include/openssl/x509_vfy.h ../cryptlib.h m_ripemd.c
690m_sha.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 504m_sha.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
691m_sha.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 505m_sha.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
692m_sha.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 506m_sha.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
693m_sha.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 507m_sha.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
694m_sha.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
695m_sha.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
696m_sha.o: ../../include/openssl/err.h ../../include/openssl/evp.h 508m_sha.o: ../../include/openssl/err.h ../../include/openssl/evp.h
697m_sha.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 509m_sha.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
698m_sha.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 510m_sha.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
699m_sha.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 511m_sha.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
700m_sha.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 512m_sha.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
701m_sha.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
702m_sha.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
703m_sha.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
704m_sha.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
705m_sha.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 513m_sha.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
706m_sha.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 514m_sha.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
707m_sha.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 515m_sha.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
708m_sha.o: ../cryptlib.h 516m_sha.o: ../cryptlib.h m_sha.c
709m_sha1.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 517m_sha1.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
710m_sha1.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 518m_sha1.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
711m_sha1.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 519m_sha1.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
712m_sha1.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 520m_sha1.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
713m_sha1.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
714m_sha1.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
715m_sha1.o: ../../include/openssl/err.h ../../include/openssl/evp.h 521m_sha1.o: ../../include/openssl/err.h ../../include/openssl/evp.h
716m_sha1.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 522m_sha1.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
717m_sha1.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 523m_sha1.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
718m_sha1.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 524m_sha1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
719m_sha1.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 525m_sha1.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
720m_sha1.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
721m_sha1.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
722m_sha1.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
723m_sha1.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
724m_sha1.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 526m_sha1.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
725m_sha1.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 527m_sha1.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
726m_sha1.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 528m_sha1.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
727m_sha1.o: ../cryptlib.h 529m_sha1.o: ../cryptlib.h m_sha1.c
728names.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 530names.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
729names.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 531names.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
730names.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 532names.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
731names.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 533names.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
732names.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
733names.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
734names.o: ../../include/openssl/err.h ../../include/openssl/evp.h 534names.o: ../../include/openssl/err.h ../../include/openssl/evp.h
735names.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 535names.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
736names.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 536names.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
737names.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 537names.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
738names.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 538names.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
739names.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
740names.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
741names.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
742names.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
743names.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 539names.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
744names.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 540names.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
745names.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 541names.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
746names.o: ../cryptlib.h 542names.o: ../cryptlib.h names.c
747p5_crpt.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 543p5_crpt.o: ../../e_os.h ../../include/openssl/asn1.h
748p5_crpt.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 544p5_crpt.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
749p5_crpt.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 545p5_crpt.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
750p5_crpt.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
751p5_crpt.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 546p5_crpt.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
752p5_crpt.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 547p5_crpt.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
753p5_crpt.o: ../../include/openssl/err.h ../../include/openssl/evp.h 548p5_crpt.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
754p5_crpt.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
755p5_crpt.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
756p5_crpt.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
757p5_crpt.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 549p5_crpt.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
758p5_crpt.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 550p5_crpt.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
759p5_crpt.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h 551p5_crpt.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
760p5_crpt.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 552p5_crpt.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
761p5_crpt.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 553p5_crpt.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
762p5_crpt.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 554p5_crpt.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
763p5_crpt.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 555p5_crpt.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p5_crpt.c
764p5_crpt.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 556p5_crpt2.o: ../../e_os.h ../../include/openssl/asn1.h
765p5_crpt.o: ../cryptlib.h 557p5_crpt2.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
766p5_crpt2.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 558p5_crpt2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
767p5_crpt2.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
768p5_crpt2.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
769p5_crpt2.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
770p5_crpt2.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 559p5_crpt2.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
771p5_crpt2.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 560p5_crpt2.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
772p5_crpt2.o: ../../include/openssl/err.h ../../include/openssl/evp.h 561p5_crpt2.o: ../../include/openssl/evp.h ../../include/openssl/hmac.h
773p5_crpt2.o: ../../include/openssl/hmac.h ../../include/openssl/idea.h 562p5_crpt2.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
774p5_crpt2.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
775p5_crpt2.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
776p5_crpt2.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
777p5_crpt2.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 563p5_crpt2.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
778p5_crpt2.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 564p5_crpt2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
779p5_crpt2.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 565p5_crpt2.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
780p5_crpt2.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 566p5_crpt2.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
781p5_crpt2.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 567p5_crpt2.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
782p5_crpt2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 568p5_crpt2.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
783p5_crpt2.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 569p5_crpt2.o: ../cryptlib.h p5_crpt2.c
784p5_crpt2.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 570p_dec.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
785p_dec.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 571p_dec.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
786p_dec.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 572p_dec.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
787p_dec.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 573p_dec.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
788p_dec.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
789p_dec.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
790p_dec.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
791p_dec.o: ../../include/openssl/err.h ../../include/openssl/evp.h 574p_dec.o: ../../include/openssl/err.h ../../include/openssl/evp.h
792p_dec.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 575p_dec.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
793p_dec.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 576p_dec.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
794p_dec.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 577p_dec.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
795p_dec.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
796p_dec.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
797p_dec.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h 578p_dec.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
798p_dec.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
799p_dec.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
800p_dec.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 579p_dec.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
801p_dec.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 580p_dec.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
802p_dec.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 581p_dec.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
803p_dec.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 582p_dec.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p_dec.c
804p_enc.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 583p_enc.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
805p_enc.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 584p_enc.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
806p_enc.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 585p_enc.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
807p_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 586p_enc.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
808p_enc.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
809p_enc.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
810p_enc.o: ../../include/openssl/err.h ../../include/openssl/evp.h 587p_enc.o: ../../include/openssl/err.h ../../include/openssl/evp.h
811p_enc.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 588p_enc.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
812p_enc.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 589p_enc.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
813p_enc.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 590p_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
814p_enc.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
815p_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
816p_enc.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h 591p_enc.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
817p_enc.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
818p_enc.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
819p_enc.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 592p_enc.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
820p_enc.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 593p_enc.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
821p_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 594p_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
822p_enc.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 595p_enc.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p_enc.c
823p_lib.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 596p_lib.o: ../../e_os.h ../../include/openssl/asn1.h
824p_lib.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h 597p_lib.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h
825p_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 598p_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
826p_lib.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h 599p_lib.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
827p_lib.o: ../../include/openssl/des.h ../../include/openssl/dh.h 600p_lib.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
828p_lib.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h 601p_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h
829p_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 602p_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
830p_lib.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
831p_lib.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
832p_lib.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
833p_lib.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
834p_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 603p_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
835p_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 604p_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
836p_lib.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 605p_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
837p_lib.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 606p_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
838p_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 607p_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
839p_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 608p_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
840p_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 609p_lib.o: ../cryptlib.h p_lib.c
841p_lib.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 610p_open.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
842p_open.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 611p_open.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
843p_open.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 612p_open.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
844p_open.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 613p_open.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
845p_open.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
846p_open.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
847p_open.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
848p_open.o: ../../include/openssl/err.h ../../include/openssl/evp.h 614p_open.o: ../../include/openssl/err.h ../../include/openssl/evp.h
849p_open.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 615p_open.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
850p_open.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 616p_open.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
851p_open.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 617p_open.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
852p_open.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 618p_open.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
853p_open.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
854p_open.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
855p_open.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
856p_open.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
857p_open.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 619p_open.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
858p_open.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 620p_open.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
859p_open.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 621p_open.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
860p_open.o: ../cryptlib.h 622p_open.o: ../cryptlib.h p_open.c
861p_seal.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 623p_seal.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
862p_seal.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 624p_seal.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
863p_seal.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 625p_seal.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
864p_seal.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 626p_seal.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
865p_seal.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
866p_seal.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
867p_seal.o: ../../include/openssl/err.h ../../include/openssl/evp.h 627p_seal.o: ../../include/openssl/err.h ../../include/openssl/evp.h
868p_seal.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 628p_seal.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
869p_seal.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 629p_seal.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
870p_seal.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 630p_seal.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
871p_seal.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
872p_seal.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
873p_seal.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h 631p_seal.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
874p_seal.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
875p_seal.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
876p_seal.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 632p_seal.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
877p_seal.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 633p_seal.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
878p_seal.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 634p_seal.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
879p_seal.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 635p_seal.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p_seal.c
880p_sign.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 636p_sign.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
881p_sign.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 637p_sign.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
882p_sign.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 638p_sign.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
883p_sign.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 639p_sign.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
884p_sign.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
885p_sign.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
886p_sign.o: ../../include/openssl/err.h ../../include/openssl/evp.h 640p_sign.o: ../../include/openssl/err.h ../../include/openssl/evp.h
887p_sign.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 641p_sign.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
888p_sign.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 642p_sign.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
889p_sign.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 643p_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
890p_sign.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 644p_sign.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
891p_sign.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
892p_sign.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
893p_sign.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
894p_sign.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
895p_sign.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 645p_sign.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
896p_sign.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 646p_sign.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
897p_sign.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 647p_sign.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
898p_sign.o: ../cryptlib.h 648p_sign.o: ../cryptlib.h p_sign.c
899p_verify.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 649p_verify.o: ../../e_os.h ../../include/openssl/asn1.h
900p_verify.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 650p_verify.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
901p_verify.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 651p_verify.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
902p_verify.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
903p_verify.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 652p_verify.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
904p_verify.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 653p_verify.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
905p_verify.o: ../../include/openssl/err.h ../../include/openssl/evp.h 654p_verify.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
906p_verify.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
907p_verify.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
908p_verify.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
909p_verify.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 655p_verify.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
910p_verify.o: ../../include/openssl/opensslconf.h 656p_verify.o: ../../include/openssl/opensslconf.h
911p_verify.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 657p_verify.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
912p_verify.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 658p_verify.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
913p_verify.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 659p_verify.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
914p_verify.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 660p_verify.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
915p_verify.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 661p_verify.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
916p_verify.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 662p_verify.o: ../cryptlib.h p_verify.c
917p_verify.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
diff --git a/src/lib/libcrypto/evp/bio_b64.c b/src/lib/libcrypto/evp/bio_b64.c
index af6fa2ae8f..f12eac1b55 100644
--- a/src/lib/libcrypto/evp/bio_b64.c
+++ b/src/lib/libcrypto/evp/bio_b64.c
@@ -465,7 +465,8 @@ static long b64_ctrl(BIO *b, int cmd, long num, void *ptr)
465 break; 465 break;
466 case BIO_CTRL_WPENDING: /* More to write in buffer */ 466 case BIO_CTRL_WPENDING: /* More to write in buffer */
467 ret=ctx->buf_len-ctx->buf_off; 467 ret=ctx->buf_len-ctx->buf_off;
468 if ((ret == 0) && (ctx->base64.num != 0)) 468 if ((ret == 0) && (ctx->encode != B64_NONE)
469 && (ctx->base64.num != 0))
469 ret=1; 470 ret=1;
470 else if (ret <= 0) 471 else if (ret <= 0)
471 ret=BIO_ctrl(b->next_bio,cmd,num,ptr); 472 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
@@ -500,7 +501,7 @@ again:
500 goto again; 501 goto again;
501 } 502 }
502 } 503 }
503 else if (ctx->base64.num != 0) 504 else if (ctx->encode != B64_NONE && ctx->base64.num != 0)
504 { 505 {
505 ctx->buf_off=0; 506 ctx->buf_off=0;
506 EVP_EncodeFinal(&(ctx->base64), 507 EVP_EncodeFinal(&(ctx->base64),
diff --git a/src/lib/libcrypto/evp/bio_enc.c b/src/lib/libcrypto/evp/bio_enc.c
index 831c71a2b5..05f4249458 100644
--- a/src/lib/libcrypto/evp/bio_enc.c
+++ b/src/lib/libcrypto/evp/bio_enc.c
@@ -71,6 +71,7 @@ static int enc_new(BIO *h);
71static int enc_free(BIO *data); 71static int enc_free(BIO *data);
72static long enc_callback_ctrl(BIO *h, int cmd, bio_info_cb *fps); 72static long enc_callback_ctrl(BIO *h, int cmd, bio_info_cb *fps);
73#define ENC_BLOCK_SIZE (1024*4) 73#define ENC_BLOCK_SIZE (1024*4)
74#define BUF_OFFSET EVP_MAX_BLOCK_LENGTH
74 75
75typedef struct enc_struct 76typedef struct enc_struct
76 { 77 {
@@ -80,7 +81,10 @@ typedef struct enc_struct
80 int finished; 81 int finished;
81 int ok; /* bad decrypt */ 82 int ok; /* bad decrypt */
82 EVP_CIPHER_CTX cipher; 83 EVP_CIPHER_CTX cipher;
83 char buf[ENC_BLOCK_SIZE+10]; 84 /* buf is larger than ENC_BLOCK_SIZE because EVP_DecryptUpdate
85 * can return up to a block more data than is presented to it
86 */
87 char buf[ENC_BLOCK_SIZE+BUF_OFFSET+2];
84 } BIO_ENC_CTX; 88 } BIO_ENC_CTX;
85 89
86static BIO_METHOD methods_enc= 90static BIO_METHOD methods_enc=
@@ -170,9 +174,9 @@ static int enc_read(BIO *b, char *out, int outl)
170 { 174 {
171 if (ctx->cont <= 0) break; 175 if (ctx->cont <= 0) break;
172 176
173 /* read in at offset 8, read the EVP_Cipher 177 /* read in at IV offset, read the EVP_Cipher
174 * documentation about why */ 178 * documentation about why */
175 i=BIO_read(b->next_bio,&(ctx->buf[8]),ENC_BLOCK_SIZE); 179 i=BIO_read(b->next_bio,&(ctx->buf[BUF_OFFSET]),ENC_BLOCK_SIZE);
176 180
177 if (i <= 0) 181 if (i <= 0)
178 { 182 {
@@ -180,7 +184,7 @@ static int enc_read(BIO *b, char *out, int outl)
180 if (!BIO_should_retry(b->next_bio)) 184 if (!BIO_should_retry(b->next_bio))
181 { 185 {
182 ctx->cont=i; 186 ctx->cont=i;
183 i=EVP_CipherFinal(&(ctx->cipher), 187 i=EVP_CipherFinal_ex(&(ctx->cipher),
184 (unsigned char *)ctx->buf, 188 (unsigned char *)ctx->buf,
185 &(ctx->buf_len)); 189 &(ctx->buf_len));
186 ctx->ok=i; 190 ctx->ok=i;
@@ -196,7 +200,7 @@ static int enc_read(BIO *b, char *out, int outl)
196 { 200 {
197 EVP_CipherUpdate(&(ctx->cipher), 201 EVP_CipherUpdate(&(ctx->cipher),
198 (unsigned char *)ctx->buf,&ctx->buf_len, 202 (unsigned char *)ctx->buf,&ctx->buf_len,
199 (unsigned char *)&(ctx->buf[8]),i); 203 (unsigned char *)&(ctx->buf[BUF_OFFSET]),i);
200 ctx->cont=1; 204 ctx->cont=1;
201 /* Note: it is possible for EVP_CipherUpdate to 205 /* Note: it is possible for EVP_CipherUpdate to
202 * decrypt zero bytes because this is or looks like 206 * decrypt zero bytes because this is or looks like
@@ -294,7 +298,7 @@ static long enc_ctrl(BIO *b, int cmd, long num, void *ptr)
294 case BIO_CTRL_RESET: 298 case BIO_CTRL_RESET:
295 ctx->ok=1; 299 ctx->ok=1;
296 ctx->finished=0; 300 ctx->finished=0;
297 EVP_CipherInit(&(ctx->cipher),NULL,NULL,NULL, 301 EVP_CipherInit_ex(&(ctx->cipher),NULL,NULL,NULL,NULL,
298 ctx->cipher.encrypt); 302 ctx->cipher.encrypt);
299 ret=BIO_ctrl(b->next_bio,cmd,num,ptr); 303 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
300 break; 304 break;
@@ -331,7 +335,7 @@ again:
331 { 335 {
332 ctx->finished=1; 336 ctx->finished=1;
333 ctx->buf_off=0; 337 ctx->buf_off=0;
334 ret=EVP_CipherFinal(&(ctx->cipher), 338 ret=EVP_CipherFinal_ex(&(ctx->cipher),
335 (unsigned char *)ctx->buf, 339 (unsigned char *)ctx->buf,
336 &(ctx->buf_len)); 340 &(ctx->buf_len));
337 ctx->ok=(int)ret; 341 ctx->ok=(int)ret;
@@ -417,7 +421,7 @@ void BIO_set_cipher(BIO *b, const EVP_CIPHER *c, unsigned char *k,
417 421
418 b->init=1; 422 b->init=1;
419 ctx=(BIO_ENC_CTX *)b->ptr; 423 ctx=(BIO_ENC_CTX *)b->ptr;
420 EVP_CipherInit(&(ctx->cipher),c,k,i,e); 424 EVP_CipherInit_ex(&(ctx->cipher),c,NULL, k,i,e);
421 425
422 if (b->callback != NULL) 426 if (b->callback != NULL)
423 b->callback(b,BIO_CB_CTRL,(const char *)c,BIO_CTRL_SET,e,1L); 427 b->callback(b,BIO_CB_CTRL,(const char *)c,BIO_CTRL_SET,e,1L);
diff --git a/src/lib/libcrypto/evp/bio_md.c b/src/lib/libcrypto/evp/bio_md.c
index 2373c247d8..c632dfb202 100644
--- a/src/lib/libcrypto/evp/bio_md.c
+++ b/src/lib/libcrypto/evp/bio_md.c
@@ -96,7 +96,7 @@ static int md_new(BIO *bi)
96 { 96 {
97 EVP_MD_CTX *ctx; 97 EVP_MD_CTX *ctx;
98 98
99 ctx=(EVP_MD_CTX *)OPENSSL_malloc(sizeof(EVP_MD_CTX)); 99 ctx=EVP_MD_CTX_create();
100 if (ctx == NULL) return(0); 100 if (ctx == NULL) return(0);
101 101
102 bi->init=0; 102 bi->init=0;
@@ -108,7 +108,7 @@ static int md_new(BIO *bi)
108static int md_free(BIO *a) 108static int md_free(BIO *a)
109 { 109 {
110 if (a == NULL) return(0); 110 if (a == NULL) return(0);
111 OPENSSL_free(a->ptr); 111 EVP_MD_CTX_destroy(a->ptr);
112 a->ptr=NULL; 112 a->ptr=NULL;
113 a->init=0; 113 a->init=0;
114 a->flags=0; 114 a->flags=0;
@@ -121,7 +121,7 @@ static int md_read(BIO *b, char *out, int outl)
121 EVP_MD_CTX *ctx; 121 EVP_MD_CTX *ctx;
122 122
123 if (out == NULL) return(0); 123 if (out == NULL) return(0);
124 ctx=(EVP_MD_CTX *)b->ptr; 124 ctx=b->ptr;
125 125
126 if ((ctx == NULL) || (b->next_bio == NULL)) return(0); 126 if ((ctx == NULL) || (b->next_bio == NULL)) return(0);
127 127
@@ -145,7 +145,7 @@ static int md_write(BIO *b, const char *in, int inl)
145 EVP_MD_CTX *ctx; 145 EVP_MD_CTX *ctx;
146 146
147 if ((in == NULL) || (inl <= 0)) return(0); 147 if ((in == NULL) || (inl <= 0)) return(0);
148 ctx=(EVP_MD_CTX *)b->ptr; 148 ctx=b->ptr;
149 149
150 if ((ctx != NULL) && (b->next_bio != NULL)) 150 if ((ctx != NULL) && (b->next_bio != NULL))
151 ret=BIO_write(b->next_bio,in,inl); 151 ret=BIO_write(b->next_bio,in,inl);
@@ -170,13 +170,13 @@ static long md_ctrl(BIO *b, int cmd, long num, void *ptr)
170 long ret=1; 170 long ret=1;
171 BIO *dbio; 171 BIO *dbio;
172 172
173 ctx=(EVP_MD_CTX *)b->ptr; 173 ctx=b->ptr;
174 174
175 switch (cmd) 175 switch (cmd)
176 { 176 {
177 case BIO_CTRL_RESET: 177 case BIO_CTRL_RESET:
178 if (b->init) 178 if (b->init)
179 EVP_DigestInit(ctx,ctx->digest); 179 EVP_DigestInit_ex(ctx,ctx->digest, NULL);
180 else 180 else
181 ret=0; 181 ret=0;
182 ret=BIO_ctrl(b->next_bio,cmd,num,ptr); 182 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
@@ -184,7 +184,7 @@ static long md_ctrl(BIO *b, int cmd, long num, void *ptr)
184 case BIO_C_GET_MD: 184 case BIO_C_GET_MD:
185 if (b->init) 185 if (b->init)
186 { 186 {
187 ppmd=(const EVP_MD **)ptr; 187 ppmd=ptr;
188 *ppmd=ctx->digest; 188 *ppmd=ctx->digest;
189 } 189 }
190 else 190 else
@@ -193,7 +193,7 @@ static long md_ctrl(BIO *b, int cmd, long num, void *ptr)
193 case BIO_C_GET_MD_CTX: 193 case BIO_C_GET_MD_CTX:
194 if (b->init) 194 if (b->init)
195 { 195 {
196 pctx=(EVP_MD_CTX **)ptr; 196 pctx=ptr;
197 *pctx=ctx; 197 *pctx=ctx;
198 } 198 }
199 else 199 else
@@ -206,14 +206,14 @@ static long md_ctrl(BIO *b, int cmd, long num, void *ptr)
206 break; 206 break;
207 207
208 case BIO_C_SET_MD: 208 case BIO_C_SET_MD:
209 md=(EVP_MD *)ptr; 209 md=ptr;
210 EVP_DigestInit(ctx,md); 210 EVP_DigestInit_ex(ctx,md, NULL);
211 b->init=1; 211 b->init=1;
212 break; 212 break;
213 case BIO_CTRL_DUP: 213 case BIO_CTRL_DUP:
214 dbio=(BIO *)ptr; 214 dbio=ptr;
215 dctx=(EVP_MD_CTX *)dbio->ptr; 215 dctx=dbio->ptr;
216 memcpy(dctx,ctx,sizeof(ctx)); 216 EVP_MD_CTX_copy_ex(dctx,ctx);
217 b->init=1; 217 b->init=1;
218 break; 218 break;
219 default: 219 default:
@@ -243,10 +243,10 @@ static int md_gets(BIO *bp, char *buf, int size)
243 unsigned int ret; 243 unsigned int ret;
244 244
245 245
246 ctx=(EVP_MD_CTX *)bp->ptr; 246 ctx=bp->ptr;
247 if (size < ctx->digest->md_size) 247 if (size < ctx->digest->md_size)
248 return(0); 248 return(0);
249 EVP_DigestFinal(ctx,(unsigned char *)buf,&ret); 249 EVP_DigestFinal_ex(ctx,(unsigned char *)buf,&ret);
250 return((int)ret); 250 return((int)ret);
251 } 251 }
252 252
diff --git a/src/lib/libcrypto/evp/bio_ok.c b/src/lib/libcrypto/evp/bio_ok.c
index e617ce1d43..3cbc6e7848 100644
--- a/src/lib/libcrypto/evp/bio_ok.c
+++ b/src/lib/libcrypto/evp/bio_ok.c
@@ -162,7 +162,7 @@ typedef struct ok_struct
162 EVP_MD_CTX md; 162 EVP_MD_CTX md;
163 int blockout; /* output block is ready */ 163 int blockout; /* output block is ready */
164 int sigio; /* must process signature */ 164 int sigio; /* must process signature */
165 char buf[IOBS]; 165 unsigned char buf[IOBS];
166 } BIO_OK_CTX; 166 } BIO_OK_CTX;
167 167
168static BIO_METHOD methods_ok= 168static BIO_METHOD methods_ok=
@@ -199,6 +199,8 @@ static int ok_new(BIO *bi)
199 ctx->blockout= 0; 199 ctx->blockout= 0;
200 ctx->sigio=1; 200 ctx->sigio=1;
201 201
202 EVP_MD_CTX_init(&ctx->md);
203
202 bi->init=0; 204 bi->init=0;
203 bi->ptr=(char *)ctx; 205 bi->ptr=(char *)ctx;
204 bi->flags=0; 206 bi->flags=0;
@@ -208,6 +210,7 @@ static int ok_new(BIO *bi)
208static int ok_free(BIO *a) 210static int ok_free(BIO *a)
209 { 211 {
210 if (a == NULL) return(0); 212 if (a == NULL) return(0);
213 EVP_MD_CTX_cleanup(&((BIO_OK_CTX *)a->ptr)->md);
211 memset(a->ptr,0,sizeof(BIO_OK_CTX)); 214 memset(a->ptr,0,sizeof(BIO_OK_CTX));
212 OPENSSL_free(a->ptr); 215 OPENSSL_free(a->ptr);
213 a->ptr=NULL; 216 a->ptr=NULL;
@@ -353,7 +356,7 @@ static long ok_ctrl(BIO *b, int cmd, long num, void *ptr)
353 long ret=1; 356 long ret=1;
354 int i; 357 int i;
355 358
356 ctx=(BIO_OK_CTX *)b->ptr; 359 ctx=b->ptr;
357 360
358 switch (cmd) 361 switch (cmd)
359 { 362 {
@@ -411,14 +414,14 @@ static long ok_ctrl(BIO *b, int cmd, long num, void *ptr)
411 ret=(long)ctx->cont; 414 ret=(long)ctx->cont;
412 break; 415 break;
413 case BIO_C_SET_MD: 416 case BIO_C_SET_MD:
414 md=(EVP_MD *)ptr; 417 md=ptr;
415 EVP_DigestInit(&(ctx->md),md); 418 EVP_DigestInit_ex(&ctx->md, md, NULL);
416 b->init=1; 419 b->init=1;
417 break; 420 break;
418 case BIO_C_GET_MD: 421 case BIO_C_GET_MD:
419 if (b->init) 422 if (b->init)
420 { 423 {
421 ppmd=(const EVP_MD **)ptr; 424 ppmd=ptr;
422 *ppmd=ctx->md.digest; 425 *ppmd=ctx->md.digest;
423 } 426 }
424 else 427 else
@@ -462,19 +465,22 @@ static void sig_out(BIO* b)
462 BIO_OK_CTX *ctx; 465 BIO_OK_CTX *ctx;
463 EVP_MD_CTX *md; 466 EVP_MD_CTX *md;
464 467
465 ctx=(BIO_OK_CTX *)b->ptr; 468 ctx=b->ptr;
466 md= &(ctx->md); 469 md=&ctx->md;
467 470
468 if(ctx->buf_len+ 2* md->digest->md_size > OK_BLOCK_SIZE) return; 471 if(ctx->buf_len+ 2* md->digest->md_size > OK_BLOCK_SIZE) return;
469 472
470 EVP_DigestInit(md, md->digest); 473 EVP_DigestInit_ex(md, md->digest, NULL);
471 RAND_pseudo_bytes(&(md->md.base[0]), md->digest->md_size); 474 /* FIXME: there's absolutely no guarantee this makes any sense at all,
472 memcpy(&(ctx->buf[ctx->buf_len]), &(md->md.base[0]), md->digest->md_size); 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);
473 longswap(&(ctx->buf[ctx->buf_len]), md->digest->md_size); 479 longswap(&(ctx->buf[ctx->buf_len]), md->digest->md_size);
474 ctx->buf_len+= md->digest->md_size; 480 ctx->buf_len+= md->digest->md_size;
475 481
476 EVP_DigestUpdate(md, WELLKNOWN, strlen(WELLKNOWN)); 482 EVP_DigestUpdate(md, WELLKNOWN, strlen(WELLKNOWN));
477 md->digest->final(&(ctx->buf[ctx->buf_len]), &(md->md.base[0])); 483 EVP_DigestFinal_ex(md, &(ctx->buf[ctx->buf_len]), NULL);
478 ctx->buf_len+= md->digest->md_size; 484 ctx->buf_len+= md->digest->md_size;
479 ctx->blockout= 1; 485 ctx->blockout= 1;
480 ctx->sigio= 0; 486 ctx->sigio= 0;
@@ -487,18 +493,18 @@ static void sig_in(BIO* b)
487 unsigned char tmp[EVP_MAX_MD_SIZE]; 493 unsigned char tmp[EVP_MAX_MD_SIZE];
488 int ret= 0; 494 int ret= 0;
489 495
490 ctx=(BIO_OK_CTX *)b->ptr; 496 ctx=b->ptr;
491 md= &(ctx->md); 497 md=&ctx->md;
492 498
493 if(ctx->buf_len- ctx->buf_off < 2* md->digest->md_size) return; 499 if(ctx->buf_len- ctx->buf_off < 2* md->digest->md_size) return;
494 500
495 EVP_DigestInit(md, md->digest); 501 EVP_DigestInit_ex(md, md->digest, NULL);
496 memcpy(&(md->md.base[0]), &(ctx->buf[ctx->buf_off]), md->digest->md_size); 502 memcpy(md->md_data, &(ctx->buf[ctx->buf_off]), md->digest->md_size);
497 longswap(&(md->md.base[0]), md->digest->md_size); 503 longswap(md->md_data, md->digest->md_size);
498 ctx->buf_off+= md->digest->md_size; 504 ctx->buf_off+= md->digest->md_size;
499 505
500 EVP_DigestUpdate(md, WELLKNOWN, strlen(WELLKNOWN)); 506 EVP_DigestUpdate(md, WELLKNOWN, strlen(WELLKNOWN));
501 md->digest->final(tmp, &(md->md.base[0])); 507 EVP_DigestFinal_ex(md, tmp, NULL);
502 ret= memcmp(&(ctx->buf[ctx->buf_off]), tmp, md->digest->md_size) == 0; 508 ret= memcmp(&(ctx->buf[ctx->buf_off]), tmp, md->digest->md_size) == 0;
503 ctx->buf_off+= md->digest->md_size; 509 ctx->buf_off+= md->digest->md_size;
504 if(ret == 1) 510 if(ret == 1)
@@ -523,15 +529,15 @@ static void block_out(BIO* b)
523 EVP_MD_CTX *md; 529 EVP_MD_CTX *md;
524 unsigned long tl; 530 unsigned long tl;
525 531
526 ctx=(BIO_OK_CTX *)b->ptr; 532 ctx=b->ptr;
527 md= &(ctx->md); 533 md=&ctx->md;
528 534
529 tl= ctx->buf_len- OK_BLOCK_BLOCK; 535 tl= ctx->buf_len- OK_BLOCK_BLOCK;
530 tl= swapem(tl); 536 tl= swapem(tl);
531 memcpy(ctx->buf, &tl, OK_BLOCK_BLOCK); 537 memcpy(ctx->buf, &tl, OK_BLOCK_BLOCK);
532 tl= swapem(tl); 538 tl= swapem(tl);
533 EVP_DigestUpdate(md, (unsigned char*) &(ctx->buf[OK_BLOCK_BLOCK]), tl); 539 EVP_DigestUpdate(md, (unsigned char*) &(ctx->buf[OK_BLOCK_BLOCK]), tl);
534 md->digest->final(&(ctx->buf[ctx->buf_len]), &(md->md.base[0])); 540 EVP_DigestFinal_ex(md, &(ctx->buf[ctx->buf_len]), NULL);
535 ctx->buf_len+= md->digest->md_size; 541 ctx->buf_len+= md->digest->md_size;
536 ctx->blockout= 1; 542 ctx->blockout= 1;
537 } 543 }
@@ -543,15 +549,15 @@ static void block_in(BIO* b)
543 long tl= 0; 549 long tl= 0;
544 unsigned char tmp[EVP_MAX_MD_SIZE]; 550 unsigned char tmp[EVP_MAX_MD_SIZE];
545 551
546 ctx=(BIO_OK_CTX *)b->ptr; 552 ctx=b->ptr;
547 md= &(ctx->md); 553 md=&ctx->md;
548 554
549 memcpy(&tl, ctx->buf, OK_BLOCK_BLOCK); 555 memcpy(&tl, ctx->buf, OK_BLOCK_BLOCK);
550 tl= swapem(tl); 556 tl= swapem(tl);
551 if (ctx->buf_len < tl+ OK_BLOCK_BLOCK+ md->digest->md_size) return; 557 if (ctx->buf_len < tl+ OK_BLOCK_BLOCK+ md->digest->md_size) return;
552 558
553 EVP_DigestUpdate(md, (unsigned char*) &(ctx->buf[OK_BLOCK_BLOCK]), tl); 559 EVP_DigestUpdate(md, (unsigned char*) &(ctx->buf[OK_BLOCK_BLOCK]), tl);
554 md->digest->final(tmp, &(md->md.base[0])); 560 EVP_DigestFinal_ex(md, tmp, NULL);
555 if(memcmp(&(ctx->buf[tl+ OK_BLOCK_BLOCK]), tmp, md->digest->md_size) == 0) 561 if(memcmp(&(ctx->buf[tl+ OK_BLOCK_BLOCK]), tmp, md->digest->md_size) == 0)
556 { 562 {
557 /* there might be parts from next block lurking around ! */ 563 /* there might be parts from next block lurking around ! */
diff --git a/src/lib/libcrypto/evp/c_all.c b/src/lib/libcrypto/evp/c_all.c
index 1e185830a3..3d390dfbf1 100644
--- a/src/lib/libcrypto/evp/c_all.c
+++ b/src/lib/libcrypto/evp/c_all.c
@@ -60,8 +60,16 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/evp.h> 61#include <openssl/evp.h>
62 62
63#undef OpenSSL_add_all_algorithms
64
63void OpenSSL_add_all_algorithms(void) 65void OpenSSL_add_all_algorithms(void)
64{ 66 {
67 OPENSSL_add_all_algorithms_noconf();
68 }
69
70void OPENSSL_add_all_algorithms_noconf(void)
71 {
65 OpenSSL_add_all_ciphers(); 72 OpenSSL_add_all_ciphers();
66 OpenSSL_add_all_digests(); 73 OpenSSL_add_all_digests();
67} 74 ENGINE_setup_openbsd();
75 }
diff --git a/src/lib/libcrypto/evp/c_allc.c b/src/lib/libcrypto/evp/c_allc.c
index f24d3756c9..37e6ab83a5 100644
--- a/src/lib/libcrypto/evp/c_allc.c
+++ b/src/lib/libcrypto/evp/c_allc.c
@@ -64,7 +64,8 @@
64 64
65void OpenSSL_add_all_ciphers(void) 65void OpenSSL_add_all_ciphers(void)
66 { 66 {
67#ifndef NO_DES 67
68#ifndef OPENSSL_NO_DES
68 EVP_add_cipher(EVP_des_cfb()); 69 EVP_add_cipher(EVP_des_cfb());
69 EVP_add_cipher(EVP_des_ede_cfb()); 70 EVP_add_cipher(EVP_des_ede_cfb());
70 EVP_add_cipher(EVP_des_ede3_cfb()); 71 EVP_add_cipher(EVP_des_ede3_cfb());
@@ -90,12 +91,12 @@ void OpenSSL_add_all_ciphers(void)
90 EVP_add_cipher(EVP_des_ede3()); 91 EVP_add_cipher(EVP_des_ede3());
91#endif 92#endif
92 93
93#ifndef NO_RC4 94#ifndef OPENSSL_NO_RC4
94 EVP_add_cipher(EVP_rc4()); 95 EVP_add_cipher(EVP_rc4());
95 EVP_add_cipher(EVP_rc4_40()); 96 EVP_add_cipher(EVP_rc4_40());
96#endif 97#endif
97 98
98#ifndef NO_IDEA 99#ifndef OPENSSL_NO_IDEA
99 EVP_add_cipher(EVP_idea_ecb()); 100 EVP_add_cipher(EVP_idea_ecb());
100 EVP_add_cipher(EVP_idea_cfb()); 101 EVP_add_cipher(EVP_idea_cfb());
101 EVP_add_cipher(EVP_idea_ofb()); 102 EVP_add_cipher(EVP_idea_ofb());
@@ -104,7 +105,7 @@ void OpenSSL_add_all_ciphers(void)
104 EVP_add_cipher_alias(SN_idea_cbc,"idea"); 105 EVP_add_cipher_alias(SN_idea_cbc,"idea");
105#endif 106#endif
106 107
107#ifndef NO_RC2 108#ifndef OPENSSL_NO_RC2
108 EVP_add_cipher(EVP_rc2_ecb()); 109 EVP_add_cipher(EVP_rc2_ecb());
109 EVP_add_cipher(EVP_rc2_cfb()); 110 EVP_add_cipher(EVP_rc2_cfb());
110 EVP_add_cipher(EVP_rc2_ofb()); 111 EVP_add_cipher(EVP_rc2_ofb());
@@ -115,7 +116,7 @@ void OpenSSL_add_all_ciphers(void)
115 EVP_add_cipher_alias(SN_rc2_cbc,"rc2"); 116 EVP_add_cipher_alias(SN_rc2_cbc,"rc2");
116#endif 117#endif
117 118
118#ifndef NO_BF 119#ifndef OPENSSL_NO_BF
119 EVP_add_cipher(EVP_bf_ecb()); 120 EVP_add_cipher(EVP_bf_ecb());
120 EVP_add_cipher(EVP_bf_cfb()); 121 EVP_add_cipher(EVP_bf_cfb());
121 EVP_add_cipher(EVP_bf_ofb()); 122 EVP_add_cipher(EVP_bf_ofb());
@@ -125,7 +126,7 @@ void OpenSSL_add_all_ciphers(void)
125 EVP_add_cipher_alias(SN_bf_cbc,"blowfish"); 126 EVP_add_cipher_alias(SN_bf_cbc,"blowfish");
126#endif 127#endif
127 128
128#ifndef NO_CAST 129#ifndef OPENSSL_NO_CAST
129 EVP_add_cipher(EVP_cast5_ecb()); 130 EVP_add_cipher(EVP_cast5_ecb());
130 EVP_add_cipher(EVP_cast5_cfb()); 131 EVP_add_cipher(EVP_cast5_cfb());
131 EVP_add_cipher(EVP_cast5_ofb()); 132 EVP_add_cipher(EVP_cast5_ofb());
@@ -136,7 +137,7 @@ void OpenSSL_add_all_ciphers(void)
136 EVP_add_cipher_alias(SN_cast5_cbc,"cast-cbc"); 137 EVP_add_cipher_alias(SN_cast5_cbc,"cast-cbc");
137#endif 138#endif
138 139
139#ifndef NO_RC5 140#ifndef OPENSSL_NO_RC5
140 EVP_add_cipher(EVP_rc5_32_12_16_ecb()); 141 EVP_add_cipher(EVP_rc5_32_12_16_ecb());
141 EVP_add_cipher(EVP_rc5_32_12_16_cfb()); 142 EVP_add_cipher(EVP_rc5_32_12_16_cfb());
142 EVP_add_cipher(EVP_rc5_32_12_16_ofb()); 143 EVP_add_cipher(EVP_rc5_32_12_16_ofb());
@@ -144,6 +145,21 @@ void OpenSSL_add_all_ciphers(void)
144 EVP_add_cipher_alias(SN_rc5_cbc,"rc5"); 145 EVP_add_cipher_alias(SN_rc5_cbc,"rc5");
145 EVP_add_cipher_alias(SN_rc5_cbc,"RC5"); 146 EVP_add_cipher_alias(SN_rc5_cbc,"RC5");
146#endif 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_alias(SN_aes_128_cbc,"AES128");
153 EVP_add_cipher_alias(SN_aes_128_cbc,"aes128");
154 EVP_add_cipher(EVP_aes_192_ecb());
155 EVP_add_cipher(EVP_aes_192_cbc());
156 EVP_add_cipher_alias(SN_aes_192_cbc,"AES192");
157 EVP_add_cipher_alias(SN_aes_192_cbc,"aes192");
158 EVP_add_cipher(EVP_aes_256_ecb());
159 EVP_add_cipher(EVP_aes_256_cbc());
160 EVP_add_cipher_alias(SN_aes_256_cbc,"AES256");
161 EVP_add_cipher_alias(SN_aes_256_cbc,"aes256");
162#endif
147 PKCS12_PBE_add(); 163 PKCS12_PBE_add();
148 PKCS5_PBE_add(); 164 PKCS5_PBE_add();
149 } 165 }
diff --git a/src/lib/libcrypto/evp/c_alld.c b/src/lib/libcrypto/evp/c_alld.c
index bbf059eb85..be91cdb037 100644
--- a/src/lib/libcrypto/evp/c_alld.c
+++ b/src/lib/libcrypto/evp/c_alld.c
@@ -64,38 +64,38 @@
64 64
65void OpenSSL_add_all_digests(void) 65void OpenSSL_add_all_digests(void)
66 { 66 {
67#ifndef NO_MD2 67#ifndef OPENSSL_NO_MD2
68 EVP_add_digest(EVP_md2()); 68 EVP_add_digest(EVP_md2());
69#endif 69#endif
70#ifndef NO_MD4 70#ifndef OPENSSL_NO_MD4
71 EVP_add_digest(EVP_md4()); 71 EVP_add_digest(EVP_md4());
72#endif 72#endif
73#ifndef NO_MD5 73#ifndef OPENSSL_NO_MD5
74 EVP_add_digest(EVP_md5()); 74 EVP_add_digest(EVP_md5());
75 EVP_add_digest_alias(SN_md5,"ssl2-md5"); 75 EVP_add_digest_alias(SN_md5,"ssl2-md5");
76 EVP_add_digest_alias(SN_md5,"ssl3-md5"); 76 EVP_add_digest_alias(SN_md5,"ssl3-md5");
77#endif 77#endif
78#ifndef NO_SHA 78#ifndef OPENSSL_NO_SHA
79 EVP_add_digest(EVP_sha()); 79 EVP_add_digest(EVP_sha());
80#ifndef NO_DSA 80#ifndef OPENSSL_NO_DSA
81 EVP_add_digest(EVP_dss()); 81 EVP_add_digest(EVP_dss());
82#endif 82#endif
83#endif 83#endif
84#ifndef NO_SHA 84#ifndef OPENSSL_NO_SHA
85 EVP_add_digest(EVP_sha1()); 85 EVP_add_digest(EVP_sha1());
86 EVP_add_digest_alias(SN_sha1,"ssl3-sha1"); 86 EVP_add_digest_alias(SN_sha1,"ssl3-sha1");
87 EVP_add_digest_alias(SN_sha1WithRSAEncryption,SN_sha1WithRSA); 87 EVP_add_digest_alias(SN_sha1WithRSAEncryption,SN_sha1WithRSA);
88#ifndef NO_DSA 88#ifndef OPENSSL_NO_DSA
89 EVP_add_digest(EVP_dss1()); 89 EVP_add_digest(EVP_dss1());
90 EVP_add_digest_alias(SN_dsaWithSHA1,SN_dsaWithSHA1_2); 90 EVP_add_digest_alias(SN_dsaWithSHA1,SN_dsaWithSHA1_2);
91 EVP_add_digest_alias(SN_dsaWithSHA1,"DSS1"); 91 EVP_add_digest_alias(SN_dsaWithSHA1,"DSS1");
92 EVP_add_digest_alias(SN_dsaWithSHA1,"dss1"); 92 EVP_add_digest_alias(SN_dsaWithSHA1,"dss1");
93#endif 93#endif
94#endif 94#endif
95#if !defined(NO_MDC2) && !defined(NO_DES) 95#if !defined(OPENSSL_NO_MDC2) && !defined(OPENSSL_NO_DES)
96 EVP_add_digest(EVP_mdc2()); 96 EVP_add_digest(EVP_mdc2());
97#endif 97#endif
98#ifndef NO_RIPEMD 98#ifndef OPENSSL_NO_RIPEMD
99 EVP_add_digest(EVP_ripemd160()); 99 EVP_add_digest(EVP_ripemd160());
100 EVP_add_digest_alias(SN_ripemd160,"ripemd"); 100 EVP_add_digest_alias(SN_ripemd160,"ripemd");
101 EVP_add_digest_alias(SN_ripemd160,"rmd160"); 101 EVP_add_digest_alias(SN_ripemd160,"rmd160");
diff --git a/src/lib/libcrypto/evp/digest.c b/src/lib/libcrypto/evp/digest.c
index c560733568..a969ac69ed 100644
--- a/src/lib/libcrypto/evp/digest.c
+++ b/src/lib/libcrypto/evp/digest.c
@@ -55,38 +55,258 @@
55 * copied and put under another distribution licence 55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58/* ====================================================================
59 * Copyright (c) 1998-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 */
58 111
59#include <stdio.h> 112#include <stdio.h>
60#include "cryptlib.h" 113#include "cryptlib.h"
61#include <openssl/objects.h> 114#include <openssl/objects.h>
62#include <openssl/evp.h> 115#include <openssl/evp.h>
116#include <openssl/engine.h>
117
118void EVP_MD_CTX_init(EVP_MD_CTX *ctx)
119 {
120 memset(ctx,'\0',sizeof *ctx);
121 }
122
123EVP_MD_CTX *EVP_MD_CTX_create(void)
124 {
125 EVP_MD_CTX *ctx=OPENSSL_malloc(sizeof *ctx);
126
127 EVP_MD_CTX_init(ctx);
128
129 return ctx;
130 }
131
132int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type)
133 {
134 EVP_MD_CTX_init(ctx);
135 return EVP_DigestInit_ex(ctx, type, NULL);
136 }
63 137
64void EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type) 138int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl)
65 { 139 {
66 ctx->digest=type; 140 EVP_MD_CTX_clear_flags(ctx,EVP_MD_CTX_FLAG_CLEANED);
67 type->init(&(ctx->md)); 141 /* Whether it's nice or not, "Inits" can be used on "Final"'d contexts
142 * so this context may already have an ENGINE! Try to avoid releasing
143 * the previous handle, re-querying for an ENGINE, and having a
144 * reinitialisation, when it may all be unecessary. */
145 if (ctx->engine && ctx->digest && (!type ||
146 (type && (type->type == ctx->digest->type))))
147 goto skip_to_init;
148 if (type)
149 {
150 /* Ensure an ENGINE left lying around from last time is cleared
151 * (the previous check attempted to avoid this if the same
152 * ENGINE and EVP_MD could be used). */
153 if(ctx->engine)
154 ENGINE_finish(ctx->engine);
155 if(impl)
156 {
157 if (!ENGINE_init(impl))
158 {
159 EVPerr(EVP_F_EVP_DIGESTINIT, EVP_R_INITIALIZATION_ERROR);
160 return 0;
161 }
162 }
163 else
164 /* Ask if an ENGINE is reserved for this job */
165 impl = ENGINE_get_digest_engine(type->type);
166 if(impl)
167 {
168 /* There's an ENGINE for this job ... (apparently) */
169 const EVP_MD *d = ENGINE_get_digest(impl, type->type);
170 if(!d)
171 {
172 /* Same comment from evp_enc.c */
173 EVPerr(EVP_F_EVP_DIGESTINIT, EVP_R_INITIALIZATION_ERROR);
174 return 0;
175 }
176 /* We'll use the ENGINE's private digest definition */
177 type = d;
178 /* Store the ENGINE functional reference so we know
179 * 'type' came from an ENGINE and we need to release
180 * it when done. */
181 ctx->engine = impl;
182 }
183 else
184 ctx->engine = NULL;
185 }
186 else if(!ctx->digest)
187 {
188 EVPerr(EVP_F_EVP_DIGESTINIT, EVP_R_NO_DIGEST_SET);
189 return 0;
190 }
191 if (ctx->digest != type)
192 {
193 if (ctx->digest && ctx->digest->ctx_size)
194 OPENSSL_free(ctx->md_data);
195 ctx->digest=type;
196 if (type->ctx_size)
197 ctx->md_data=OPENSSL_malloc(type->ctx_size);
198 }
199skip_to_init:
200 return ctx->digest->init(ctx);
68 } 201 }
69 202
70void EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *data, 203int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *data,
71 unsigned int count) 204 unsigned int count)
72 { 205 {
73 ctx->digest->update(&(ctx->md.base[0]),data,(unsigned long)count); 206 return ctx->digest->update(ctx,data,(unsigned long)count);
207 }
208
209/* The caller can assume that this removes any secret data from the context */
210int EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size)
211 {
212 int ret;
213 ret = EVP_DigestFinal_ex(ctx, md, size);
214 EVP_MD_CTX_cleanup(ctx);
215 return ret;
74 } 216 }
75 217
76void EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size) 218/* The caller can assume that this removes any secret data from the context */
219int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size)
77 { 220 {
78 ctx->digest->final(md,&(ctx->md.base[0])); 221 int ret;
222 ret=ctx->digest->final(ctx,md);
79 if (size != NULL) 223 if (size != NULL)
80 *size=ctx->digest->md_size; 224 *size=ctx->digest->md_size;
81 memset(&(ctx->md),0,sizeof(ctx->md)); 225 if (ctx->digest->cleanup)
226 {
227 ctx->digest->cleanup(ctx);
228 EVP_MD_CTX_set_flags(ctx,EVP_MD_CTX_FLAG_CLEANED);
229 }
230 memset(ctx->md_data,0,ctx->digest->ctx_size);
231 return ret;
232 }
233
234int EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in)
235 {
236 EVP_MD_CTX_init(out);
237 return EVP_MD_CTX_copy_ex(out, in);
238 }
239
240int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in)
241 {
242 if ((in == NULL) || (in->digest == NULL))
243 {
244 EVPerr(EVP_F_EVP_MD_CTX_COPY,EVP_R_INPUT_NOT_INITIALIZED);
245 return 0;
246 }
247 /* Make sure it's safe to copy a digest context using an ENGINE */
248 if (in->engine && !ENGINE_init(in->engine))
249 {
250 EVPerr(EVP_F_EVP_MD_CTX_COPY,ERR_R_ENGINE_LIB);
251 return 0;
252 }
253
254 EVP_MD_CTX_cleanup(out);
255 memcpy(out,in,sizeof *out);
256
257 if (out->digest->ctx_size)
258 {
259 out->md_data=OPENSSL_malloc(out->digest->ctx_size);
260 memcpy(out->md_data,in->md_data,out->digest->ctx_size);
261 }
262
263 if (out->digest->copy)
264 return out->digest->copy(out,in);
265
266 return 1;
267 }
268
269int EVP_Digest(void *data, unsigned int count,
270 unsigned char *md, unsigned int *size, const EVP_MD *type, ENGINE *impl)
271 {
272 EVP_MD_CTX ctx;
273 int ret;
274
275 EVP_MD_CTX_init(&ctx);
276 EVP_MD_CTX_set_flags(&ctx,EVP_MD_CTX_FLAG_ONESHOT);
277 ret=EVP_DigestInit_ex(&ctx, type, impl)
278 && EVP_DigestUpdate(&ctx, data, count)
279 && EVP_DigestFinal_ex(&ctx, md, size);
280 EVP_MD_CTX_cleanup(&ctx);
281
282 return ret;
82 } 283 }
83 284
84int EVP_MD_CTX_copy(EVP_MD_CTX *out, EVP_MD_CTX *in) 285void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx)
85{ 286 {
86 if ((in == NULL) || (in->digest == NULL)) { 287 EVP_MD_CTX_cleanup(ctx);
87 EVPerr(EVP_F_EVP_MD_CTX_COPY,EVP_R_INPUT_NOT_INITIALIZED); 288 OPENSSL_free(ctx);
88 return 0; 289 }
89 } 290
90 memcpy((char *)out,(char *)in,in->digest->ctx_size); 291/* This call frees resources associated with the context */
91 return 1; 292int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx)
92} 293 {
294 /* Don't assume ctx->md_data was cleaned in EVP_Digest_Final,
295 * because sometimes only copies of the context are ever finalised.
296 */
297 if (ctx->digest && ctx->digest->cleanup
298 && !EVP_MD_CTX_test_flags(ctx,EVP_MD_CTX_FLAG_CLEANED))
299 ctx->digest->cleanup(ctx);
300 if (ctx->digest && ctx->digest->ctx_size && ctx->md_data)
301 {
302 memset(ctx->md_data,0,ctx->digest->ctx_size);
303 OPENSSL_free(ctx->md_data);
304 }
305 if(ctx->engine)
306 /* The EVP_MD we used belongs to an ENGINE, release the
307 * functional reference we held for this reason. */
308 ENGINE_finish(ctx->engine);
309 memset(ctx,'\0',sizeof *ctx);
310
311 return 1;
312 }
diff --git a/src/lib/libcrypto/evp/e_aes.c b/src/lib/libcrypto/evp/e_aes.c
new file mode 100644
index 0000000000..9d03a9602f
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_aes.c
@@ -0,0 +1,99 @@
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 */
50
51#ifndef OPENSSL_NO_AES
52#include <openssl/evp.h>
53#include <openssl/err.h>
54#include <string.h>
55#include <assert.h>
56#include <openssl/aes.h>
57#include "evp_locl.h"
58
59static int aes_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
60 const unsigned char *iv, int enc);
61
62typedef struct
63 {
64 AES_KEY ks;
65 } EVP_AES_KEY;
66
67#define data(ctx) EVP_C_DATA(EVP_AES_KEY,ctx)
68
69IMPLEMENT_BLOCK_CIPHER(aes_128, ks, AES, EVP_AES_KEY,
70 NID_aes_128, 16, 16, 16, 128,
71 0, aes_init_key, NULL,
72 EVP_CIPHER_set_asn1_iv,
73 EVP_CIPHER_get_asn1_iv,
74 NULL)
75IMPLEMENT_BLOCK_CIPHER(aes_192, ks, AES, EVP_AES_KEY,
76 NID_aes_192, 16, 24, 16, 128,
77 0, aes_init_key, NULL,
78 EVP_CIPHER_set_asn1_iv,
79 EVP_CIPHER_get_asn1_iv,
80 NULL)
81IMPLEMENT_BLOCK_CIPHER(aes_256, ks, AES, EVP_AES_KEY,
82 NID_aes_256, 16, 32, 16, 128,
83 0, aes_init_key, NULL,
84 EVP_CIPHER_set_asn1_iv,
85 EVP_CIPHER_get_asn1_iv,
86 NULL)
87
88static int aes_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
89 const unsigned char *iv, int enc) {
90
91 if (enc)
92 AES_set_encrypt_key(key, ctx->key_len * 8, ctx->cipher_data);
93 else
94 AES_set_decrypt_key(key, ctx->key_len * 8, ctx->cipher_data);
95
96 return 1;
97}
98
99#endif
diff --git a/src/lib/libcrypto/evp/e_bf.c b/src/lib/libcrypto/evp/e_bf.c
index 53559b0b65..e74337567b 100644
--- a/src/lib/libcrypto/evp/e_bf.c
+++ b/src/lib/libcrypto/evp/e_bf.c
@@ -56,24 +56,32 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_BF 59#ifndef OPENSSL_NO_BF
60#include <stdio.h> 60#include <stdio.h>
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/evp.h> 62#include <openssl/evp.h>
63#include "evp_locl.h" 63#include "evp_locl.h"
64#include <openssl/objects.h> 64#include <openssl/objects.h>
65#include <openssl/blowfish.h>
65 66
66static int bf_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 67static int bf_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
67 const unsigned char *iv, int enc); 68 const unsigned char *iv, int enc);
68 69
69IMPLEMENT_BLOCK_CIPHER(bf, bf_ks, BF, bf_ks, NID_bf, 8, 16, 8, 70typedef struct
71 {
72 BF_KEY ks;
73 } EVP_BF_KEY;
74
75#define data(ctx) EVP_C_DATA(EVP_BF_KEY,ctx)
76
77IMPLEMENT_BLOCK_CIPHER(bf, ks, BF, EVP_BF_KEY, NID_bf, 8, 16, 8, 64,
70 EVP_CIPH_VARIABLE_LENGTH, bf_init_key, NULL, 78 EVP_CIPH_VARIABLE_LENGTH, bf_init_key, NULL,
71 EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, NULL) 79 EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, NULL)
72 80
73static int bf_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 81static int bf_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
74 const unsigned char *iv, int enc) 82 const unsigned char *iv, int enc)
75 { 83 {
76 BF_set_key(&(ctx->c.bf_ks),EVP_CIPHER_CTX_key_length(ctx),key); 84 BF_set_key(&data(ctx)->ks,EVP_CIPHER_CTX_key_length(ctx),key);
77 return 1; 85 return 1;
78 } 86 }
79 87
diff --git a/src/lib/libcrypto/evp/e_cast.c b/src/lib/libcrypto/evp/e_cast.c
index e5af7fb4ed..3400fef187 100644
--- a/src/lib/libcrypto/evp/e_cast.c
+++ b/src/lib/libcrypto/evp/e_cast.c
@@ -56,26 +56,34 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_CAST 59#ifndef OPENSSL_NO_CAST
60 60
61#include <stdio.h> 61#include <stdio.h>
62#include "cryptlib.h" 62#include "cryptlib.h"
63#include <openssl/evp.h> 63#include <openssl/evp.h>
64#include <openssl/objects.h> 64#include <openssl/objects.h>
65#include "evp_locl.h" 65#include "evp_locl.h"
66#include <openssl/cast.h>
66 67
67static int cast_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 68static int cast_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
68 const unsigned char *iv,int enc); 69 const unsigned char *iv,int enc);
69 70
70IMPLEMENT_BLOCK_CIPHER(cast5, cast_ks, CAST, cast_ks, 71typedef struct
71 NID_cast5, 8, EVP_CAST5_KEY_SIZE, 8, 72 {
73 CAST_KEY ks;
74 } EVP_CAST_KEY;
75
76#define data(ctx) EVP_C_DATA(EVP_CAST_KEY,ctx)
77
78IMPLEMENT_BLOCK_CIPHER(cast5, ks, CAST, EVP_CAST_KEY,
79 NID_cast5, 8, CAST_KEY_LENGTH, 8, 64,
72 EVP_CIPH_VARIABLE_LENGTH, cast_init_key, NULL, 80 EVP_CIPH_VARIABLE_LENGTH, cast_init_key, NULL,
73 EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, NULL) 81 EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, NULL)
74 82
75static int cast_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 83static int cast_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
76 const unsigned char *iv, int enc) 84 const unsigned char *iv, int enc)
77 { 85 {
78 CAST_set_key(&(ctx->c.cast_ks),EVP_CIPHER_CTX_key_length(ctx),key); 86 CAST_set_key(&data(ctx)->ks,EVP_CIPHER_CTX_key_length(ctx),key);
79 return 1; 87 return 1;
80 } 88 }
81 89
diff --git a/src/lib/libcrypto/evp/e_des.c b/src/lib/libcrypto/evp/e_des.c
index f4e998b81c..105266a4b3 100644
--- a/src/lib/libcrypto/evp/e_des.c
+++ b/src/lib/libcrypto/evp/e_des.c
@@ -56,12 +56,13 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_DES 59#ifndef OPENSSL_NO_DES
60#include <stdio.h> 60#include <stdio.h>
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/evp.h> 62#include <openssl/evp.h>
63#include <openssl/objects.h> 63#include <openssl/objects.h>
64#include "evp_locl.h" 64#include "evp_locl.h"
65#include <openssl/des.h>
65 66
66static int des_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 67static int des_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
67 const unsigned char *iv, int enc); 68 const unsigned char *iv, int enc);
@@ -72,34 +73,34 @@ static int des_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
72 const unsigned char *in, unsigned int inl) 73 const unsigned char *in, unsigned int inl)
73{ 74{
74 BLOCK_CIPHER_ecb_loop() 75 BLOCK_CIPHER_ecb_loop()
75 des_ecb_encrypt((des_cblock *)(in + i), (des_cblock *)(out + i), ctx->c.des_ks, ctx->encrypt); 76 DES_ecb_encrypt((DES_cblock *)(in + i), (DES_cblock *)(out + i), ctx->cipher_data, ctx->encrypt);
76 return 1; 77 return 1;
77} 78}
78 79
79static int des_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 80static int des_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
80 const unsigned char *in, unsigned int inl) 81 const unsigned char *in, unsigned int inl)
81{ 82{
82 des_ofb64_encrypt(in, out, (long)inl, ctx->c.des_ks, (des_cblock *)ctx->iv, &ctx->num); 83 DES_ofb64_encrypt(in, out, (long)inl, ctx->cipher_data, (DES_cblock *)ctx->iv, &ctx->num);
83 return 1; 84 return 1;
84} 85}
85 86
86static int des_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 87static int des_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
87 const unsigned char *in, unsigned int inl) 88 const unsigned char *in, unsigned int inl)
88{ 89{
89 des_ncbc_encrypt(in, out, (long)inl, ctx->c.des_ks, 90 DES_ncbc_encrypt(in, out, (long)inl, ctx->cipher_data,
90 (des_cblock *)ctx->iv, ctx->encrypt); 91 (DES_cblock *)ctx->iv, ctx->encrypt);
91 return 1; 92 return 1;
92} 93}
93 94
94static int des_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 95static int des_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
95 const unsigned char *in, unsigned int inl) 96 const unsigned char *in, unsigned int inl)
96{ 97{
97 des_cfb64_encrypt(in, out, (long)inl, ctx->c.des_ks, 98 DES_cfb64_encrypt(in, out, (long)inl, ctx->cipher_data,
98 (des_cblock *)ctx->iv, &ctx->num, ctx->encrypt); 99 (DES_cblock *)ctx->iv, &ctx->num, ctx->encrypt);
99 return 1; 100 return 1;
100} 101}
101 102
102BLOCK_CIPHER_defs(des, des_ks, NID_des, 8, 8, 8, 103BLOCK_CIPHER_defs(des, DES_key_schedule, NID_des, 8, 8, 8, 64,
103 0, des_init_key, NULL, 104 0, des_init_key, NULL,
104 EVP_CIPHER_set_asn1_iv, 105 EVP_CIPHER_set_asn1_iv,
105 EVP_CIPHER_get_asn1_iv, 106 EVP_CIPHER_get_asn1_iv,
@@ -109,9 +110,9 @@ BLOCK_CIPHER_defs(des, des_ks, NID_des, 8, 8, 8,
109static int des_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 110static int des_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
110 const unsigned char *iv, int enc) 111 const unsigned char *iv, int enc)
111 { 112 {
112 des_cblock *deskey = (des_cblock *)key; 113 DES_cblock *deskey = (DES_cblock *)key;
113 114
114 des_set_key_unchecked(deskey,ctx->c.des_ks); 115 DES_set_key_unchecked(deskey,ctx->cipher_data);
115 return 1; 116 return 1;
116 } 117 }
117 118
diff --git a/src/lib/libcrypto/evp/e_des3.c b/src/lib/libcrypto/evp/e_des3.c
index a9aba4ae70..077860e7b6 100644
--- a/src/lib/libcrypto/evp/e_des3.c
+++ b/src/lib/libcrypto/evp/e_des3.c
@@ -56,12 +56,13 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_DES 59#ifndef OPENSSL_NO_DES
60#include <stdio.h> 60#include <stdio.h>
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/evp.h> 62#include <openssl/evp.h>
63#include <openssl/objects.h> 63#include <openssl/objects.h>
64#include "evp_locl.h" 64#include "evp_locl.h"
65#include <openssl/des.h>
65 66
66static int des_ede_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 67static int des_ede_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
67 const unsigned char *iv,int enc); 68 const unsigned char *iv,int enc);
@@ -69,60 +70,78 @@ static int des_ede_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
69static int des_ede3_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 70static int des_ede3_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
70 const unsigned char *iv,int enc); 71 const unsigned char *iv,int enc);
71 72
73typedef struct
74 {
75 DES_key_schedule ks1;/* key schedule */
76 DES_key_schedule ks2;/* key schedule (for ede) */
77 DES_key_schedule ks3;/* key schedule (for ede3) */
78 } DES_EDE_KEY;
79
80#define data(ctx) ((DES_EDE_KEY *)(ctx)->cipher_data)
81
72/* Because of various casts and different args can't use IMPLEMENT_BLOCK_CIPHER */ 82/* Because of various casts and different args can't use IMPLEMENT_BLOCK_CIPHER */
73 83
74static int des_ede_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 84static int des_ede_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
75 const unsigned char *in, unsigned int inl) 85 const unsigned char *in, unsigned int inl)
76{ 86{
77 BLOCK_CIPHER_ecb_loop() 87 BLOCK_CIPHER_ecb_loop()
78 des_ecb3_encrypt((des_cblock *)(in + i), (des_cblock *)(out + i), 88 DES_ecb3_encrypt((DES_cblock *)(in + i), (DES_cblock *)(out + i),
79 ctx->c.des_ede.ks1, ctx->c.des_ede.ks2, ctx->c.des_ede.ks3, 89 &data(ctx)->ks1, &data(ctx)->ks2,
80 ctx->encrypt); 90 &data(ctx)->ks3,
91 ctx->encrypt);
81 return 1; 92 return 1;
82} 93}
83 94
84static int des_ede_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 95static int des_ede_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
85 const unsigned char *in, unsigned int inl) 96 const unsigned char *in, unsigned int inl)
86{ 97{
87 des_ede3_ofb64_encrypt(in, out, (long)inl, 98 DES_ede3_ofb64_encrypt(in, out, (long)inl,
88 ctx->c.des_ede.ks1, ctx->c.des_ede.ks2, ctx->c.des_ede.ks3, 99 &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3,
89 (des_cblock *)ctx->iv, &ctx->num); 100 (DES_cblock *)ctx->iv, &ctx->num);
90 return 1; 101 return 1;
91} 102}
92 103
93static int des_ede_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 104static int des_ede_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
94 const unsigned char *in, unsigned int inl) 105 const unsigned char *in, unsigned int inl)
95{ 106{
96 des_ede3_cbc_encrypt(in, out, (long)inl, 107#ifdef KSSL_DEBUG
97 ctx->c.des_ede.ks1, ctx->c.des_ede.ks2, ctx->c.des_ede.ks3, 108 {
98 (des_cblock *)ctx->iv, ctx->encrypt); 109 int i;
110 char *cp;
111 printf("des_ede_cbc_cipher(ctx=%lx, buflen=%d)\n", ctx, ctx->buf_len);
112 printf("\t iv= ");
113 for(i=0;i<8;i++)
114 printf("%02X",ctx->iv[i]);
115 printf("\n");
116 }
117#endif /* KSSL_DEBUG */
118 DES_ede3_cbc_encrypt(in, out, (long)inl,
119 &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3,
120 (DES_cblock *)ctx->iv, ctx->encrypt);
99 return 1; 121 return 1;
100} 122}
101 123
102static int des_ede_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 124static int des_ede_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
103 const unsigned char *in, unsigned int inl) 125 const unsigned char *in, unsigned int inl)
104{ 126{
105 des_ede3_cfb64_encrypt(in, out, (long)inl, 127 DES_ede3_cfb64_encrypt(in, out, (long)inl,
106 ctx->c.des_ede.ks1, ctx->c.des_ede.ks2, ctx->c.des_ede.ks3, 128 &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3,
107 (des_cblock *)ctx->iv, &ctx->num, ctx->encrypt); 129 (DES_cblock *)ctx->iv, &ctx->num, ctx->encrypt);
108 return 1; 130 return 1;
109} 131}
110 132
111#define NID_des_ede_ecb NID_des_ede 133BLOCK_CIPHER_defs(des_ede, DES_EDE_KEY, NID_des_ede, 8, 16, 8, 64,
112
113BLOCK_CIPHER_defs(des_ede, des_ede, NID_des_ede, 8, 16, 8,
114 0, des_ede_init_key, NULL, 134 0, des_ede_init_key, NULL,
115 EVP_CIPHER_set_asn1_iv, 135 EVP_CIPHER_set_asn1_iv,
116 EVP_CIPHER_get_asn1_iv, 136 EVP_CIPHER_get_asn1_iv,
117 NULL) 137 NULL)
118 138
119#define NID_des_ede3_ecb NID_des_ede3
120#define des_ede3_cfb_cipher des_ede_cfb_cipher 139#define des_ede3_cfb_cipher des_ede_cfb_cipher
121#define des_ede3_ofb_cipher des_ede_ofb_cipher 140#define des_ede3_ofb_cipher des_ede_ofb_cipher
122#define des_ede3_cbc_cipher des_ede_cbc_cipher 141#define des_ede3_cbc_cipher des_ede_cbc_cipher
123#define des_ede3_ecb_cipher des_ede_ecb_cipher 142#define des_ede3_ecb_cipher des_ede_ecb_cipher
124 143
125BLOCK_CIPHER_defs(des_ede3, des_ede, NID_des_ede3, 8, 24, 8, 144BLOCK_CIPHER_defs(des_ede3, DES_EDE_KEY, NID_des_ede3, 8, 24, 8, 64,
126 0, des_ede3_init_key, NULL, 145 0, des_ede3_init_key, NULL,
127 EVP_CIPHER_set_asn1_iv, 146 EVP_CIPHER_set_asn1_iv,
128 EVP_CIPHER_get_asn1_iv, 147 EVP_CIPHER_get_asn1_iv,
@@ -131,34 +150,43 @@ BLOCK_CIPHER_defs(des_ede3, des_ede, NID_des_ede3, 8, 24, 8,
131static int des_ede_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 150static int des_ede_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
132 const unsigned char *iv, int enc) 151 const unsigned char *iv, int enc)
133 { 152 {
134 des_cblock *deskey = (des_cblock *)key; 153 DES_cblock *deskey = (DES_cblock *)key;
135 154
136 des_set_key_unchecked(&deskey[0],ctx->c.des_ede.ks1); 155 DES_set_key_unchecked(&deskey[0],&data(ctx)->ks1);
137 des_set_key_unchecked(&deskey[1],ctx->c.des_ede.ks2); 156 DES_set_key_unchecked(&deskey[1],&data(ctx)->ks2);
138 memcpy( (char *)ctx->c.des_ede.ks3, 157 memcpy(&data(ctx)->ks3,&data(ctx)->ks1,
139 (char *)ctx->c.des_ede.ks1, 158 sizeof(data(ctx)->ks1));
140 sizeof(ctx->c.des_ede.ks1));
141 return 1; 159 return 1;
142 } 160 }
143 161
144static int des_ede3_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 162static int des_ede3_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
145 const unsigned char *iv, int enc) 163 const unsigned char *iv, int enc)
146 { 164 {
147 des_cblock *deskey = (des_cblock *)key; 165 DES_cblock *deskey = (DES_cblock *)key;
166#ifdef KSSL_DEBUG
167 {
168 int i;
169 printf("des_ede3_init_key(ctx=%lx)\n", ctx);
170 printf("\tKEY= ");
171 for(i=0;i<24;i++) printf("%02X",key[i]); printf("\n");
172 printf("\t IV= ");
173 for(i=0;i<8;i++) printf("%02X",iv[i]); printf("\n");
174 }
175#endif /* KSSL_DEBUG */
148 176
149 des_set_key_unchecked(&deskey[0],ctx->c.des_ede.ks1); 177 DES_set_key_unchecked(&deskey[0],&data(ctx)->ks1);
150 des_set_key_unchecked(&deskey[1],ctx->c.des_ede.ks2); 178 DES_set_key_unchecked(&deskey[1],&data(ctx)->ks2);
151 des_set_key_unchecked(&deskey[2],ctx->c.des_ede.ks3); 179 DES_set_key_unchecked(&deskey[2],&data(ctx)->ks3);
152 180
153 return 1; 181 return 1;
154 } 182 }
155 183
156EVP_CIPHER *EVP_des_ede(void) 184const EVP_CIPHER *EVP_des_ede(void)
157{ 185{
158 return &des_ede_ecb; 186 return &des_ede_ecb;
159} 187}
160 188
161EVP_CIPHER *EVP_des_ede3(void) 189const EVP_CIPHER *EVP_des_ede3(void)
162{ 190{
163 return &des_ede3_ecb; 191 return &des_ede3_ecb;
164} 192}
diff --git a/src/lib/libcrypto/evp/e_idea.c b/src/lib/libcrypto/evp/e_idea.c
index 8d3c88deb7..ed838d3e62 100644
--- a/src/lib/libcrypto/evp/e_idea.c
+++ b/src/lib/libcrypto/evp/e_idea.c
@@ -56,13 +56,14 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_IDEA 59#ifndef OPENSSL_NO_IDEA
60 60
61#include <stdio.h> 61#include <stdio.h>
62#include "cryptlib.h" 62#include "cryptlib.h"
63#include <openssl/evp.h> 63#include <openssl/evp.h>
64#include <openssl/objects.h> 64#include <openssl/objects.h>
65#include "evp_locl.h" 65#include "evp_locl.h"
66#include <openssl/idea.h>
66 67
67static int idea_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 68static int idea_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
68 const unsigned char *iv,int enc); 69 const unsigned char *iv,int enc);
@@ -75,17 +76,22 @@ static int idea_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
75 const unsigned char *in, unsigned int inl) 76 const unsigned char *in, unsigned int inl)
76{ 77{
77 BLOCK_CIPHER_ecb_loop() 78 BLOCK_CIPHER_ecb_loop()
78 idea_ecb_encrypt(in + i, out + i, &ctx->c.idea_ks); 79 idea_ecb_encrypt(in + i, out + i, ctx->cipher_data);
79 return 1; 80 return 1;
80} 81}
81 82
82/* Can't use IMPLEMENT_BLOCK_CIPHER because idea_ecb_encrypt is different */ 83/* Can't use IMPLEMENT_BLOCK_CIPHER because idea_ecb_encrypt is different */
83 84
84BLOCK_CIPHER_func_cbc(idea, idea, idea_ks) 85typedef struct
85BLOCK_CIPHER_func_ofb(idea, idea, idea_ks) 86 {
86BLOCK_CIPHER_func_cfb(idea, idea, idea_ks) 87 IDEA_KEY_SCHEDULE ks;
88 } EVP_IDEA_KEY;
89
90BLOCK_CIPHER_func_cbc(idea, idea, EVP_IDEA_KEY, ks)
91BLOCK_CIPHER_func_ofb(idea, idea, 64, EVP_IDEA_KEY, ks)
92BLOCK_CIPHER_func_cfb(idea, idea, 64, EVP_IDEA_KEY, ks)
87 93
88BLOCK_CIPHER_defs(idea, idea_ks, NID_idea, 8, 16, 8, 94BLOCK_CIPHER_defs(idea, IDEA_KEY_SCHEDULE, NID_idea, 8, 16, 8, 64,
89 0, idea_init_key, NULL, 95 0, idea_init_key, NULL,
90 EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, NULL) 96 EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, NULL)
91 97
@@ -96,13 +102,13 @@ static int idea_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
96 if (EVP_CIPHER_CTX_mode(ctx) == EVP_CIPH_OFB_MODE) enc = 1; 102 if (EVP_CIPHER_CTX_mode(ctx) == EVP_CIPH_OFB_MODE) enc = 1;
97 else if (EVP_CIPHER_CTX_mode(ctx) == EVP_CIPH_CFB_MODE) enc = 1; 103 else if (EVP_CIPHER_CTX_mode(ctx) == EVP_CIPH_CFB_MODE) enc = 1;
98 } 104 }
99 if (enc) idea_set_encrypt_key(key,&(ctx->c.idea_ks)); 105 if (enc) idea_set_encrypt_key(key,ctx->cipher_data);
100 else 106 else
101 { 107 {
102 IDEA_KEY_SCHEDULE tmp; 108 IDEA_KEY_SCHEDULE tmp;
103 109
104 idea_set_encrypt_key(key,&tmp); 110 idea_set_encrypt_key(key,&tmp);
105 idea_set_decrypt_key(&tmp,&(ctx->c.idea_ks)); 111 idea_set_decrypt_key(&tmp,ctx->cipher_data);
106 memset((unsigned char *)&tmp,0, 112 memset((unsigned char *)&tmp,0,
107 sizeof(IDEA_KEY_SCHEDULE)); 113 sizeof(IDEA_KEY_SCHEDULE));
108 } 114 }
diff --git a/src/lib/libcrypto/evp/e_null.c b/src/lib/libcrypto/evp/e_null.c
index e0702cf818..2420d7e5af 100644
--- a/src/lib/libcrypto/evp/e_null.c
+++ b/src/lib/libcrypto/evp/e_null.c
@@ -65,7 +65,7 @@ static int null_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
65 const unsigned char *iv,int enc); 65 const unsigned char *iv,int enc);
66static int null_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 66static int null_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
67 const unsigned char *in, unsigned int inl); 67 const unsigned char *in, unsigned int inl);
68static EVP_CIPHER n_cipher= 68static const EVP_CIPHER n_cipher=
69 { 69 {
70 NID_undef, 70 NID_undef,
71 1,0,0, 71 1,0,0,
@@ -79,7 +79,7 @@ static EVP_CIPHER n_cipher=
79 NULL 79 NULL
80 }; 80 };
81 81
82EVP_CIPHER *EVP_enc_null(void) 82const EVP_CIPHER *EVP_enc_null(void)
83 { 83 {
84 return(&n_cipher); 84 return(&n_cipher);
85 } 85 }
@@ -87,7 +87,7 @@ EVP_CIPHER *EVP_enc_null(void)
87static int null_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 87static int null_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
88 const unsigned char *iv, int enc) 88 const unsigned char *iv, int enc)
89 { 89 {
90 memset(&(ctx->c),0,sizeof(ctx->c)); 90 /* memset(&(ctx->c),0,sizeof(ctx->c));*/
91 return 1; 91 return 1;
92 } 92 }
93 93
diff --git a/src/lib/libcrypto/evp/e_rc2.c b/src/lib/libcrypto/evp/e_rc2.c
index 3955c3ef84..4685198e2e 100644
--- a/src/lib/libcrypto/evp/e_rc2.c
+++ b/src/lib/libcrypto/evp/e_rc2.c
@@ -56,13 +56,14 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_RC2 59#ifndef OPENSSL_NO_RC2
60 60
61#include <stdio.h> 61#include <stdio.h>
62#include "cryptlib.h" 62#include "cryptlib.h"
63#include <openssl/evp.h> 63#include <openssl/evp.h>
64#include <openssl/objects.h> 64#include <openssl/objects.h>
65#include "evp_locl.h" 65#include "evp_locl.h"
66#include <openssl/rc2.h>
66 67
67static int rc2_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 68static int rc2_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
68 const unsigned char *iv,int enc); 69 const unsigned char *iv,int enc);
@@ -72,9 +73,17 @@ static int rc2_set_asn1_type_and_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
72static int rc2_get_asn1_type_and_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type); 73static int rc2_get_asn1_type_and_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
73static int rc2_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr); 74static int rc2_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr);
74 75
75IMPLEMENT_BLOCK_CIPHER(rc2, rc2.ks, RC2, rc2, NID_rc2, 76typedef struct
77 {
78 int key_bits; /* effective key bits */
79 RC2_KEY ks; /* key schedule */
80 } EVP_RC2_KEY;
81
82#define data(ctx) ((EVP_RC2_KEY *)(ctx)->cipher_data)
83
84IMPLEMENT_BLOCK_CIPHER(rc2, ks, RC2, EVP_RC2_KEY, NID_rc2,
76 8, 85 8,
77 EVP_RC2_KEY_SIZE, 8, 86 RC2_KEY_LENGTH, 8, 64,
78 EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT, 87 EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT,
79 rc2_init_key, NULL, 88 rc2_init_key, NULL,
80 rc2_set_asn1_type_and_iv, rc2_get_asn1_type_and_iv, 89 rc2_set_asn1_type_and_iv, rc2_get_asn1_type_and_iv,
@@ -84,7 +93,7 @@ IMPLEMENT_BLOCK_CIPHER(rc2, rc2.ks, RC2, rc2, NID_rc2,
84#define RC2_64_MAGIC 0x78 93#define RC2_64_MAGIC 0x78
85#define RC2_128_MAGIC 0x3a 94#define RC2_128_MAGIC 0x3a
86 95
87static EVP_CIPHER r2_64_cbc_cipher= 96static const EVP_CIPHER r2_64_cbc_cipher=
88 { 97 {
89 NID_rc2_64_cbc, 98 NID_rc2_64_cbc,
90 8,8 /* 64 bit */,8, 99 8,8 /* 64 bit */,8,
@@ -92,15 +101,14 @@ static EVP_CIPHER r2_64_cbc_cipher=
92 rc2_init_key, 101 rc2_init_key,
93 rc2_cbc_cipher, 102 rc2_cbc_cipher,
94 NULL, 103 NULL,
95 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ 104 sizeof(EVP_RC2_KEY),
96 sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2)),
97 rc2_set_asn1_type_and_iv, 105 rc2_set_asn1_type_and_iv,
98 rc2_get_asn1_type_and_iv, 106 rc2_get_asn1_type_and_iv,
99 rc2_ctrl, 107 rc2_ctrl,
100 NULL 108 NULL
101 }; 109 };
102 110
103static EVP_CIPHER r2_40_cbc_cipher= 111static const EVP_CIPHER r2_40_cbc_cipher=
104 { 112 {
105 NID_rc2_40_cbc, 113 NID_rc2_40_cbc,
106 8,5 /* 40 bit */,8, 114 8,5 /* 40 bit */,8,
@@ -108,20 +116,19 @@ static EVP_CIPHER r2_40_cbc_cipher=
108 rc2_init_key, 116 rc2_init_key,
109 rc2_cbc_cipher, 117 rc2_cbc_cipher,
110 NULL, 118 NULL,
111 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ 119 sizeof(EVP_RC2_KEY),
112 sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2)),
113 rc2_set_asn1_type_and_iv, 120 rc2_set_asn1_type_and_iv,
114 rc2_get_asn1_type_and_iv, 121 rc2_get_asn1_type_and_iv,
115 rc2_ctrl, 122 rc2_ctrl,
116 NULL 123 NULL
117 }; 124 };
118 125
119EVP_CIPHER *EVP_rc2_64_cbc(void) 126const EVP_CIPHER *EVP_rc2_64_cbc(void)
120 { 127 {
121 return(&r2_64_cbc_cipher); 128 return(&r2_64_cbc_cipher);
122 } 129 }
123 130
124EVP_CIPHER *EVP_rc2_40_cbc(void) 131const EVP_CIPHER *EVP_rc2_40_cbc(void)
125 { 132 {
126 return(&r2_40_cbc_cipher); 133 return(&r2_40_cbc_cipher);
127 } 134 }
@@ -129,8 +136,8 @@ EVP_CIPHER *EVP_rc2_40_cbc(void)
129static int rc2_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 136static int rc2_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
130 const unsigned char *iv, int enc) 137 const unsigned char *iv, int enc)
131 { 138 {
132 RC2_set_key(&(ctx->c.rc2.ks),EVP_CIPHER_CTX_key_length(ctx), 139 RC2_set_key(&data(ctx)->ks,EVP_CIPHER_CTX_key_length(ctx),
133 key,ctx->c.rc2.key_bits); 140 key,data(ctx)->key_bits);
134 return 1; 141 return 1;
135 } 142 }
136 143
@@ -173,7 +180,7 @@ static int rc2_get_asn1_type_and_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
173 key_bits =rc2_magic_to_meth((int)num); 180 key_bits =rc2_magic_to_meth((int)num);
174 if (!key_bits) 181 if (!key_bits)
175 return(-1); 182 return(-1);
176 if(i > 0) EVP_CipherInit(c, NULL, NULL, iv, -1); 183 if(i > 0) EVP_CipherInit_ex(c, NULL, NULL, NULL, iv, -1);
177 EVP_CIPHER_CTX_ctrl(c, EVP_CTRL_SET_RC2_KEY_BITS, key_bits, NULL); 184 EVP_CIPHER_CTX_ctrl(c, EVP_CTRL_SET_RC2_KEY_BITS, key_bits, NULL);
178 EVP_CIPHER_CTX_set_key_length(c, key_bits / 8); 185 EVP_CIPHER_CTX_set_key_length(c, key_bits / 8);
179 } 186 }
@@ -196,26 +203,26 @@ static int rc2_set_asn1_type_and_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
196 203
197static int rc2_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr) 204static int rc2_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)
198 { 205 {
199 switch(type) { 206 switch(type)
200 207 {
201 case EVP_CTRL_INIT: 208 case EVP_CTRL_INIT:
202 c->c.rc2.key_bits = EVP_CIPHER_CTX_key_length(c) * 8; 209 data(c)->key_bits = EVP_CIPHER_CTX_key_length(c) * 8;
203 return 1; 210 return 1;
204 211
205 case EVP_CTRL_GET_RC2_KEY_BITS: 212 case EVP_CTRL_GET_RC2_KEY_BITS:
206 *(int *)ptr = c->c.rc2.key_bits; 213 *(int *)ptr = data(c)->key_bits;
207 return 1; 214 return 1;
208 215
209 216 case EVP_CTRL_SET_RC2_KEY_BITS:
210 case EVP_CTRL_SET_RC2_KEY_BITS: 217 if(arg > 0)
211 if(arg > 0) { 218 {
212 c->c.rc2.key_bits = arg; 219 data(c)->key_bits = arg;
213 return 1; 220 return 1;
214 } 221 }
215 return 0; 222 return 0;
216 223
217 default: 224 default:
218 return -1; 225 return -1;
219 } 226 }
220 } 227 }
221 228
diff --git a/src/lib/libcrypto/evp/e_rc4.c b/src/lib/libcrypto/evp/e_rc4.c
index 1c1e3b3857..4064cc5fa0 100644
--- a/src/lib/libcrypto/evp/e_rc4.c
+++ b/src/lib/libcrypto/evp/e_rc4.c
@@ -56,18 +56,31 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_RC4 59#ifndef OPENSSL_NO_RC4
60 60
61#include <stdio.h> 61#include <stdio.h>
62#include "cryptlib.h" 62#include "cryptlib.h"
63#include <openssl/evp.h> 63#include <openssl/evp.h>
64#include <openssl/objects.h> 64#include <openssl/objects.h>
65#include <openssl/rc4.h>
66
67/* FIXME: surely this is available elsewhere? */
68#define EVP_RC4_KEY_SIZE 16
69
70typedef struct
71 {
72 /* FIXME: what is the key for? */
73 unsigned char key[EVP_RC4_KEY_SIZE];
74 RC4_KEY ks; /* working key */
75 } EVP_RC4_KEY;
76
77#define data(ctx) ((EVP_RC4_KEY *)(ctx)->cipher_data)
65 78
66static int rc4_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 79static int rc4_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
67 const unsigned char *iv,int enc); 80 const unsigned char *iv,int enc);
68static int rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 81static int rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
69 const unsigned char *in, unsigned int inl); 82 const unsigned char *in, unsigned int inl);
70static EVP_CIPHER r4_cipher= 83static const EVP_CIPHER r4_cipher=
71 { 84 {
72 NID_rc4, 85 NID_rc4,
73 1,EVP_RC4_KEY_SIZE,0, 86 1,EVP_RC4_KEY_SIZE,0,
@@ -75,14 +88,13 @@ static EVP_CIPHER r4_cipher=
75 rc4_init_key, 88 rc4_init_key,
76 rc4_cipher, 89 rc4_cipher,
77 NULL, 90 NULL,
78 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ 91 sizeof(EVP_RC4_KEY),
79 sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc4)),
80 NULL, 92 NULL,
81 NULL, 93 NULL,
82 NULL 94 NULL
83 }; 95 };
84 96
85static EVP_CIPHER r4_40_cipher= 97static const EVP_CIPHER r4_40_cipher=
86 { 98 {
87 NID_rc4_40, 99 NID_rc4_40,
88 1,5 /* 40 bit */,0, 100 1,5 /* 40 bit */,0,
@@ -90,19 +102,18 @@ static EVP_CIPHER r4_40_cipher=
90 rc4_init_key, 102 rc4_init_key,
91 rc4_cipher, 103 rc4_cipher,
92 NULL, 104 NULL,
93 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ 105 sizeof(EVP_RC4_KEY),
94 sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc4)),
95 NULL, 106 NULL,
96 NULL, 107 NULL,
97 NULL 108 NULL
98 }; 109 };
99 110
100EVP_CIPHER *EVP_rc4(void) 111const EVP_CIPHER *EVP_rc4(void)
101 { 112 {
102 return(&r4_cipher); 113 return(&r4_cipher);
103 } 114 }
104 115
105EVP_CIPHER *EVP_rc4_40(void) 116const EVP_CIPHER *EVP_rc4_40(void)
106 { 117 {
107 return(&r4_40_cipher); 118 return(&r4_40_cipher);
108 } 119 }
@@ -110,16 +121,16 @@ EVP_CIPHER *EVP_rc4_40(void)
110static 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,
111 const unsigned char *iv, int enc) 122 const unsigned char *iv, int enc)
112 { 123 {
113 memcpy(&(ctx->c.rc4.key[0]),key,EVP_CIPHER_CTX_key_length(ctx)); 124 memcpy(&data(ctx)->key[0],key,EVP_CIPHER_CTX_key_length(ctx));
114 RC4_set_key(&(ctx->c.rc4.ks),EVP_CIPHER_CTX_key_length(ctx), 125 RC4_set_key(&data(ctx)->ks,EVP_CIPHER_CTX_key_length(ctx),
115 ctx->c.rc4.key); 126 data(ctx)->key);
116 return 1; 127 return 1;
117 } 128 }
118 129
119static int rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 130static int rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
120 const unsigned char *in, unsigned int inl) 131 const unsigned char *in, unsigned int inl)
121 { 132 {
122 RC4(&(ctx->c.rc4.ks),inl,in,out); 133 RC4(&data(ctx)->ks,inl,in,out);
123 return 1; 134 return 1;
124 } 135 }
125#endif 136#endif
diff --git a/src/lib/libcrypto/evp/e_rc5.c b/src/lib/libcrypto/evp/e_rc5.c
index 5885f1826b..3c7713b181 100644
--- a/src/lib/libcrypto/evp/e_rc5.c
+++ b/src/lib/libcrypto/evp/e_rc5.c
@@ -56,62 +56,69 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_RC5 59#ifndef OPENSSL_NO_RC5
60 60
61#include <stdio.h> 61#include <stdio.h>
62#include "cryptlib.h" 62#include "cryptlib.h"
63#include <openssl/evp.h> 63#include <openssl/evp.h>
64#include <openssl/objects.h> 64#include <openssl/objects.h>
65#include "evp_locl.h" 65#include "evp_locl.h"
66#include <openssl/rc5.h>
66 67
67static int r_32_12_16_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 68static int r_32_12_16_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
68 const unsigned char *iv,int enc); 69 const unsigned char *iv,int enc);
69static int rc5_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr); 70static int rc5_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr);
70 71
71IMPLEMENT_BLOCK_CIPHER(rc5_32_12_16, rc5.ks, RC5_32, rc5, NID_rc5, 72typedef struct
72 8, EVP_RC5_32_12_16_KEY_SIZE, 8, 73 {
73 EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT, 74 int rounds; /* number of rounds */
74 r_32_12_16_init_key, NULL, 75 RC5_32_KEY ks; /* key schedule */
75 NULL, NULL, rc5_ctrl) 76 } EVP_RC5_KEY;
76 77
78#define data(ctx) EVP_C_DATA(EVP_RC5_KEY,ctx)
77 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)
78 85
79static int rc5_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr) 86static int rc5_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)
80 { 87 {
81 switch(type) { 88 switch(type)
82 89 {
83 case EVP_CTRL_INIT: 90 case EVP_CTRL_INIT:
84 c->c.rc5.rounds = RC5_12_ROUNDS; 91 data(c)->rounds = RC5_12_ROUNDS;
85 return 1; 92 return 1;
86 93
87 case EVP_CTRL_GET_RC5_ROUNDS: 94 case EVP_CTRL_GET_RC5_ROUNDS:
88 *(int *)ptr = c->c.rc5.rounds; 95 *(int *)ptr = data(c)->rounds;
89 return 1; 96 return 1;
90
91 97
92 case EVP_CTRL_SET_RC5_ROUNDS: 98 case EVP_CTRL_SET_RC5_ROUNDS:
93 switch(arg) { 99 switch(arg)
94 case RC5_8_ROUNDS: 100 {
95 case RC5_12_ROUNDS: 101 case RC5_8_ROUNDS:
96 case RC5_16_ROUNDS: 102 case RC5_12_ROUNDS:
97 c->c.rc5.rounds = arg; 103 case RC5_16_ROUNDS:
98 return 1; 104 data(c)->rounds = arg;
105 return 1;
99 106
100 default: 107 default:
101 EVPerr(EVP_F_RC5_CTRL, EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS); 108 EVPerr(EVP_F_RC5_CTRL, EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS);
102 return 0; 109 return 0;
103 } 110 }
104 111
105 default: 112 default:
106 return -1; 113 return -1;
107 } 114 }
108 } 115 }
109 116
110static int r_32_12_16_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 117static int r_32_12_16_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
111 const unsigned char *iv, int enc) 118 const unsigned char *iv, int enc)
112 { 119 {
113 RC5_32_set_key(&(ctx->c.rc5.ks),EVP_CIPHER_CTX_key_length(ctx), 120 RC5_32_set_key(&data(ctx)->ks,EVP_CIPHER_CTX_key_length(ctx),
114 key,ctx->c.rc5.rounds); 121 key,data(ctx)->rounds);
115 return 1; 122 return 1;
116 } 123 }
117 124
diff --git a/src/lib/libcrypto/evp/e_xcbc_d.c b/src/lib/libcrypto/evp/e_xcbc_d.c
index e5b15acc7d..a6f849e93d 100644
--- a/src/lib/libcrypto/evp/e_xcbc_d.c
+++ b/src/lib/libcrypto/evp/e_xcbc_d.c
@@ -56,17 +56,29 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_DES 59#ifndef OPENSSL_NO_DES
60#include <stdio.h> 60#include <stdio.h>
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/evp.h> 62#include <openssl/evp.h>
63#include <openssl/objects.h> 63#include <openssl/objects.h>
64#include <openssl/des.h>
64 65
65static int desx_cbc_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 66static int desx_cbc_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
66 const unsigned char *iv,int enc); 67 const unsigned char *iv,int enc);
67static int desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 68static int desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
68 const unsigned char *in, unsigned int inl); 69 const unsigned char *in, unsigned int inl);
69static EVP_CIPHER d_xcbc_cipher= 70
71
72typedef struct
73 {
74 DES_key_schedule ks;/* key schedule */
75 DES_cblock inw;
76 DES_cblock outw;
77 } DESX_CBC_KEY;
78
79#define data(ctx) ((DESX_CBC_KEY *)(ctx)->cipher_data)
80
81static const EVP_CIPHER d_xcbc_cipher=
70 { 82 {
71 NID_desx_cbc, 83 NID_desx_cbc,
72 8,24,8, 84 8,24,8,
@@ -74,14 +86,13 @@ static EVP_CIPHER d_xcbc_cipher=
74 desx_cbc_init_key, 86 desx_cbc_init_key,
75 desx_cbc_cipher, 87 desx_cbc_cipher,
76 NULL, 88 NULL,
77 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ 89 sizeof(DESX_CBC_KEY),
78 sizeof((((EVP_CIPHER_CTX *)NULL)->c.desx_cbc)),
79 EVP_CIPHER_set_asn1_iv, 90 EVP_CIPHER_set_asn1_iv,
80 EVP_CIPHER_get_asn1_iv, 91 EVP_CIPHER_get_asn1_iv,
81 NULL 92 NULL
82 }; 93 };
83 94
84EVP_CIPHER *EVP_desx_cbc(void) 95const EVP_CIPHER *EVP_desx_cbc(void)
85 { 96 {
86 return(&d_xcbc_cipher); 97 return(&d_xcbc_cipher);
87 } 98 }
@@ -89,11 +100,11 @@ EVP_CIPHER *EVP_desx_cbc(void)
89static int desx_cbc_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 100static int desx_cbc_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
90 const unsigned char *iv, int enc) 101 const unsigned char *iv, int enc)
91 { 102 {
92 des_cblock *deskey = (des_cblock *)key; 103 DES_cblock *deskey = (DES_cblock *)key;
93 104
94 des_set_key_unchecked(deskey,ctx->c.desx_cbc.ks); 105 DES_set_key_unchecked(deskey,&data(ctx)->ks);
95 memcpy(&(ctx->c.desx_cbc.inw[0]),&(key[8]),8); 106 memcpy(&data(ctx)->inw[0],&key[8],8);
96 memcpy(&(ctx->c.desx_cbc.outw[0]),&(key[16]),8); 107 memcpy(&data(ctx)->outw[0],&key[16],8);
97 108
98 return 1; 109 return 1;
99 } 110 }
@@ -101,11 +112,11 @@ static int desx_cbc_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
101static int desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 112static int desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
102 const unsigned char *in, unsigned int inl) 113 const unsigned char *in, unsigned int inl)
103 { 114 {
104 des_xcbc_encrypt(in,out,inl,ctx->c.desx_cbc.ks, 115 DES_xcbc_encrypt(in,out,inl,&data(ctx)->ks,
105 (des_cblock *)&(ctx->iv[0]), 116 (DES_cblock *)&(ctx->iv[0]),
106 &ctx->c.desx_cbc.inw, 117 &data(ctx)->inw,
107 &ctx->c.desx_cbc.outw, 118 &data(ctx)->outw,
108 ctx->encrypt); 119 ctx->encrypt);
109 return 1; 120 return 1;
110 } 121 }
111#endif 122#endif
diff --git a/src/lib/libcrypto/evp/encode.c b/src/lib/libcrypto/evp/encode.c
index 6ff9c1783c..12c6379df1 100644
--- a/src/lib/libcrypto/evp/encode.c
+++ b/src/lib/libcrypto/evp/encode.c
@@ -277,6 +277,13 @@ int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,
277 eof++; 277 eof++;
278 } 278 }
279 279
280 if (v == B64_CR)
281 {
282 ln = 0;
283 if (exp_nl)
284 continue;
285 }
286
280 /* eoln */ 287 /* eoln */
281 if (v == B64_EOLN) 288 if (v == B64_EOLN)
282 { 289 {
diff --git a/src/lib/libcrypto/evp/evp.h b/src/lib/libcrypto/evp/evp.h
index fd43127092..915fe62341 100644
--- a/src/lib/libcrypto/evp/evp.h
+++ b/src/lib/libcrypto/evp/evp.h
@@ -67,74 +67,30 @@
67# undef OPENSSL_ALGORITHM_DEFINES 67# undef OPENSSL_ALGORITHM_DEFINES
68#endif 68#endif
69 69
70#ifndef NO_BIO 70#include <openssl/ossl_typ.h>
71
72#include <openssl/symhacks.h>
73
74#ifndef OPENSSL_NO_BIO
71#include <openssl/bio.h> 75#include <openssl/bio.h>
72#endif 76#endif
73#ifndef NO_MD2
74#include <openssl/md2.h>
75#endif
76#ifndef NO_MD4
77#include <openssl/md4.h>
78#endif
79#ifndef NO_MD5
80#include <openssl/md5.h>
81#endif
82#ifndef NO_SHA
83#include <openssl/sha.h>
84#endif
85#ifndef NO_RIPEMD
86#include <openssl/ripemd.h>
87#endif
88#ifndef NO_DES
89#include <openssl/des.h>
90#endif
91#ifndef NO_RC4
92#include <openssl/rc4.h>
93#endif
94#ifndef NO_RC2
95#include <openssl/rc2.h>
96#endif
97#ifndef NO_RC5
98#include <openssl/rc5.h>
99#endif
100#ifndef NO_BF
101#include <openssl/blowfish.h>
102#endif
103#ifndef NO_CAST
104#include <openssl/cast.h>
105#endif
106#ifndef NO_IDEA
107#include <openssl/idea.h>
108#endif
109#ifndef NO_MDC2
110#include <openssl/mdc2.h>
111#endif
112 77
78/*
113#define EVP_RC2_KEY_SIZE 16 79#define EVP_RC2_KEY_SIZE 16
114#define EVP_RC4_KEY_SIZE 16 80#define EVP_RC4_KEY_SIZE 16
115#define EVP_BLOWFISH_KEY_SIZE 16 81#define EVP_BLOWFISH_KEY_SIZE 16
116#define EVP_CAST5_KEY_SIZE 16 82#define EVP_CAST5_KEY_SIZE 16
117#define EVP_RC5_32_12_16_KEY_SIZE 16 83#define EVP_RC5_32_12_16_KEY_SIZE 16
84*/
118#define EVP_MAX_MD_SIZE (16+20) /* The SSLv3 md5+sha1 type */ 85#define EVP_MAX_MD_SIZE (16+20) /* The SSLv3 md5+sha1 type */
119#define EVP_MAX_KEY_LENGTH 24 86#define EVP_MAX_KEY_LENGTH 32
120#define EVP_MAX_IV_LENGTH 8 87#define EVP_MAX_IV_LENGTH 16
88#define EVP_MAX_BLOCK_LENGTH 32
121 89
122#define PKCS5_SALT_LEN 8 90#define PKCS5_SALT_LEN 8
123/* Default PKCS#5 iteration count */ 91/* Default PKCS#5 iteration count */
124#define PKCS5_DEFAULT_ITER 2048 92#define PKCS5_DEFAULT_ITER 2048
125 93
126#ifndef NO_RSA
127#include <openssl/rsa.h>
128#endif
129
130#ifndef NO_DSA
131#include <openssl/dsa.h>
132#endif
133
134#ifndef NO_DH
135#include <openssl/dh.h>
136#endif
137
138#include <openssl/objects.h> 94#include <openssl/objects.h>
139 95
140#define EVP_PK_RSA 0x0001 96#define EVP_PK_RSA 0x0001
@@ -164,26 +120,26 @@ extern "C" {
164/* Type needs to be a bit field 120/* Type needs to be a bit field
165 * Sub-type needs to be for variations on the method, as in, can it do 121 * Sub-type needs to be for variations on the method, as in, can it do
166 * arbitrary encryption.... */ 122 * arbitrary encryption.... */
167typedef struct evp_pkey_st 123struct evp_pkey_st
168 { 124 {
169 int type; 125 int type;
170 int save_type; 126 int save_type;
171 int references; 127 int references;
172 union { 128 union {
173 char *ptr; 129 char *ptr;
174#ifndef NO_RSA 130#ifndef OPENSSL_NO_RSA
175 struct rsa_st *rsa; /* RSA */ 131 struct rsa_st *rsa; /* RSA */
176#endif 132#endif
177#ifndef NO_DSA 133#ifndef OPENSSL_NO_DSA
178 struct dsa_st *dsa; /* DSA */ 134 struct dsa_st *dsa; /* DSA */
179#endif 135#endif
180#ifndef NO_DH 136#ifndef OPENSSL_NO_DH
181 struct dh_st *dh; /* DH */ 137 struct dh_st *dh; /* DH */
182#endif 138#endif
183 } pkey; 139 } pkey;
184 int save_parameters; 140 int save_parameters;
185 STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */ 141 STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */
186 } EVP_PKEY; 142 } /* EVP_PKEY */;
187 143
188#define EVP_PKEY_MO_SIGN 0x0001 144#define EVP_PKEY_MO_SIGN 0x0001
189#define EVP_PKEY_MO_VERIFY 0x0002 145#define EVP_PKEY_MO_VERIFY 0x0002
@@ -258,27 +214,32 @@ typedef struct evp_pkey_method_st
258#endif 214#endif
259 215
260#ifndef EVP_MD 216#ifndef EVP_MD
261typedef struct env_md_st 217struct env_md_st
262 { 218 {
263 int type; 219 int type;
264 int pkey_type; 220 int pkey_type;
265 int md_size; 221 int md_size;
266 void (*init)(); 222 unsigned long flags;
267 void (*update)(); 223 int (*init)(EVP_MD_CTX *ctx);
268 void (*final)(); 224 int (*update)(EVP_MD_CTX *ctx,const void *data,unsigned long count);
269 225 int (*final)(EVP_MD_CTX *ctx,unsigned char *md);
226 int (*copy)(EVP_MD_CTX *to,const EVP_MD_CTX *from);
227 int (*cleanup)(EVP_MD_CTX *ctx);
228
229 /* FIXME: prototype these some day */
270 int (*sign)(); 230 int (*sign)();
271 int (*verify)(); 231 int (*verify)();
272 int required_pkey_type[5]; /*EVP_PKEY_xxx */ 232 int required_pkey_type[5]; /*EVP_PKEY_xxx */
273 int block_size; 233 int block_size;
274 int ctx_size; /* how big does the ctx need to be */ 234 int ctx_size; /* how big does the ctx->md_data need to be */
275 } EVP_MD; 235 } /* EVP_MD */;
276
277 236
237#define EVP_MD_FLAG_ONESHOT 0x0001 /* digest can only handle a single
238 * block */
278 239
279#define EVP_PKEY_NULL_method NULL,NULL,{0,0,0,0} 240#define EVP_PKEY_NULL_method NULL,NULL,{0,0,0,0}
280 241
281#ifndef NO_DSA 242#ifndef OPENSSL_NO_DSA
282#define EVP_PKEY_DSA_method DSA_sign,DSA_verify, \ 243#define EVP_PKEY_DSA_method DSA_sign,DSA_verify, \
283 {EVP_PKEY_DSA,EVP_PKEY_DSA2,EVP_PKEY_DSA3, \ 244 {EVP_PKEY_DSA,EVP_PKEY_DSA2,EVP_PKEY_DSA3, \
284 EVP_PKEY_DSA4,0} 245 EVP_PKEY_DSA4,0}
@@ -286,7 +247,7 @@ typedef struct env_md_st
286#define EVP_PKEY_DSA_method EVP_PKEY_NULL_method 247#define EVP_PKEY_DSA_method EVP_PKEY_NULL_method
287#endif 248#endif
288 249
289#ifndef NO_RSA 250#ifndef OPENSSL_NO_RSA
290#define EVP_PKEY_RSA_method RSA_sign,RSA_verify, \ 251#define EVP_PKEY_RSA_method RSA_sign,RSA_verify, \
291 {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0} 252 {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0}
292#define EVP_PKEY_RSA_ASN1_OCTET_STRING_method \ 253#define EVP_PKEY_RSA_ASN1_OCTET_STRING_method \
@@ -300,34 +261,20 @@ typedef struct env_md_st
300 261
301#endif /* !EVP_MD */ 262#endif /* !EVP_MD */
302 263
303typedef struct env_md_ctx_st 264struct env_md_ctx_st
304 { 265 {
305 const EVP_MD *digest; 266 const EVP_MD *digest;
306 union { 267 ENGINE *engine; /* functional reference if 'digest' is ENGINE-provided */
307 unsigned char base[4]; 268 unsigned long flags;
308#ifndef NO_MD2 269 void *md_data;
309 MD2_CTX md2; 270 } /* EVP_MD_CTX */;
310#endif 271
311#ifndef NO_MD5 272/* values for EVP_MD_CTX flags */
312 MD5_CTX md5;
313#endif
314#ifndef NO_MD4
315 MD4_CTX md4;
316#endif
317#ifndef NO_RIPEMD
318 RIPEMD160_CTX ripemd160;
319#endif
320#ifndef NO_SHA
321 SHA_CTX sha;
322#endif
323#ifndef NO_MDC2
324 MDC2_CTX mdc2;
325#endif
326 } md;
327 } EVP_MD_CTX;
328 273
329typedef struct evp_cipher_st EVP_CIPHER; 274#define EVP_MD_CTX_FLAG_ONESHOT 0x0001 /* digest update will be called
330typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX; 275 * once only */
276#define EVP_MD_CTX_FLAG_CLEANED 0x0002 /* context has already been
277 * cleaned */
331 278
332struct evp_cipher_st 279struct evp_cipher_st
333 { 280 {
@@ -341,12 +288,12 @@ struct evp_cipher_st
341 int (*do_cipher)(EVP_CIPHER_CTX *ctx, unsigned char *out, 288 int (*do_cipher)(EVP_CIPHER_CTX *ctx, unsigned char *out,
342 const unsigned char *in, unsigned int inl);/* encrypt/decrypt data */ 289 const unsigned char *in, unsigned int inl);/* encrypt/decrypt data */
343 int (*cleanup)(EVP_CIPHER_CTX *); /* cleanup ctx */ 290 int (*cleanup)(EVP_CIPHER_CTX *); /* cleanup ctx */
344 int ctx_size; /* how big the ctx needs to be */ 291 int ctx_size; /* how big ctx->cipher_data needs to be */
345 int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Populate a ASN1_TYPE with parameters */ 292 int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Populate a ASN1_TYPE with parameters */
346 int (*get_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Get parameters from a ASN1_TYPE */ 293 int (*get_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Get parameters from a ASN1_TYPE */
347 int (*ctrl)(EVP_CIPHER_CTX *, int type, int arg, void *ptr); /* Miscellaneous operations */ 294 int (*ctrl)(EVP_CIPHER_CTX *, int type, int arg, void *ptr); /* Miscellaneous operations */
348 void *app_data; /* Application data */ 295 void *app_data; /* Application data */
349 }; 296 } /* EVP_CIPHER */;
350 297
351/* Values for cipher flags */ 298/* Values for cipher flags */
352 299
@@ -368,6 +315,8 @@ struct evp_cipher_st
368#define EVP_CIPH_CTRL_INIT 0x40 315#define EVP_CIPH_CTRL_INIT 0x40
369/* Don't use standard key length function */ 316/* Don't use standard key length function */
370#define EVP_CIPH_CUSTOM_KEY_LENGTH 0x80 317#define EVP_CIPH_CUSTOM_KEY_LENGTH 0x80
318/* Don't use standard block padding */
319#define EVP_CIPH_NO_PADDING 0x100
371 320
372/* ctrl() values */ 321/* ctrl() values */
373 322
@@ -387,62 +336,23 @@ typedef struct evp_cipher_info_st
387struct evp_cipher_ctx_st 336struct evp_cipher_ctx_st
388 { 337 {
389 const EVP_CIPHER *cipher; 338 const EVP_CIPHER *cipher;
339 ENGINE *engine; /* functional reference if 'cipher' is ENGINE-provided */
390 int encrypt; /* encrypt or decrypt */ 340 int encrypt; /* encrypt or decrypt */
391 int buf_len; /* number we have left */ 341 int buf_len; /* number we have left */
392 342
393 unsigned char oiv[EVP_MAX_IV_LENGTH]; /* original iv */ 343 unsigned char oiv[EVP_MAX_IV_LENGTH]; /* original iv */
394 unsigned char iv[EVP_MAX_IV_LENGTH]; /* working iv */ 344 unsigned char iv[EVP_MAX_IV_LENGTH]; /* working iv */
395 unsigned char buf[EVP_MAX_IV_LENGTH]; /* saved partial block */ 345 unsigned char buf[EVP_MAX_BLOCK_LENGTH];/* saved partial block */
396 int num; /* used by cfb/ofb mode */ 346 int num; /* used by cfb/ofb mode */
397 347
398 void *app_data; /* application stuff */ 348 void *app_data; /* application stuff */
399 int key_len; /* May change for variable length cipher */ 349 int key_len; /* May change for variable length cipher */
400 union { 350 unsigned long flags; /* Various flags */
401#ifndef NO_RC4 351 void *cipher_data; /* per EVP data */
402 struct 352 int final_used;
403 { 353 int block_mask;
404 unsigned char key[EVP_RC4_KEY_SIZE]; 354 unsigned char final[EVP_MAX_BLOCK_LENGTH];/* possible final block */
405 RC4_KEY ks; /* working key */ 355 } /* EVP_CIPHER_CTX */;
406 } rc4;
407#endif
408#ifndef NO_DES
409 des_key_schedule des_ks;/* key schedule */
410 struct
411 {
412 des_key_schedule ks;/* key schedule */
413 des_cblock inw;
414 des_cblock outw;
415 } desx_cbc;
416 struct
417 {
418 des_key_schedule ks1;/* key schedule */
419 des_key_schedule ks2;/* key schedule (for ede) */
420 des_key_schedule ks3;/* key schedule (for ede3) */
421 } des_ede;
422#endif
423#ifndef NO_IDEA
424 IDEA_KEY_SCHEDULE idea_ks;/* key schedule */
425#endif
426#ifndef NO_RC2
427 struct {
428 int key_bits; /* effective key bits */
429 RC2_KEY ks;/* key schedule */
430 } rc2;
431#endif
432#ifndef NO_RC5
433 struct {
434 int rounds; /* number of rounds */
435 RC5_32_KEY ks;/* key schedule */
436 } rc5;
437#endif
438#ifndef NO_BF
439 BF_KEY bf_ks;/* key schedule */
440#endif
441#ifndef NO_CAST
442 CAST_KEY cast_ks;/* key schedule */
443#endif
444 } c;
445 };
446 356
447typedef struct evp_Encode_Ctx_st 357typedef struct evp_Encode_Ctx_st
448 { 358 {
@@ -459,20 +369,20 @@ typedef struct evp_Encode_Ctx_st
459 369
460/* Password based encryption function */ 370/* Password based encryption function */
461typedef int (EVP_PBE_KEYGEN)(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, 371typedef int (EVP_PBE_KEYGEN)(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
462 ASN1_TYPE *param, EVP_CIPHER *cipher, 372 ASN1_TYPE *param, const EVP_CIPHER *cipher,
463 EVP_MD *md, int en_de); 373 const EVP_MD *md, int en_de);
464 374
465#ifndef NO_RSA 375#ifndef OPENSSL_NO_RSA
466#define EVP_PKEY_assign_RSA(pkey,rsa) EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\ 376#define EVP_PKEY_assign_RSA(pkey,rsa) EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\
467 (char *)(rsa)) 377 (char *)(rsa))
468#endif 378#endif
469 379
470#ifndef NO_DSA 380#ifndef OPENSSL_NO_DSA
471#define EVP_PKEY_assign_DSA(pkey,dsa) EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\ 381#define EVP_PKEY_assign_DSA(pkey,dsa) EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\
472 (char *)(dsa)) 382 (char *)(dsa))
473#endif 383#endif
474 384
475#ifndef NO_DH 385#ifndef OPENSSL_NO_DH
476#define EVP_PKEY_assign_DH(pkey,dh) EVP_PKEY_assign((pkey),EVP_PKEY_DH,\ 386#define EVP_PKEY_assign_DH(pkey,dh) EVP_PKEY_assign((pkey),EVP_PKEY_DH,\
477 (char *)(dh)) 387 (char *)(dh))
478#endif 388#endif
@@ -484,6 +394,8 @@ typedef int (EVP_PBE_KEYGEN)(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
484#define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a)) 394#define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a))
485 395
486#define EVP_MD_type(e) ((e)->type) 396#define EVP_MD_type(e) ((e)->type)
397#define EVP_MD_nid(e) EVP_MD_type(e)
398#define EVP_MD_name(e) OBJ_nid2sn(EVP_MD_nid(e))
487#define EVP_MD_pkey_type(e) ((e)->pkey_type) 399#define EVP_MD_pkey_type(e) ((e)->pkey_type)
488#define EVP_MD_size(e) ((e)->md_size) 400#define EVP_MD_size(e) ((e)->md_size)
489#define EVP_MD_block_size(e) ((e)->block_size) 401#define EVP_MD_block_size(e) ((e)->block_size)
@@ -494,11 +406,12 @@ typedef int (EVP_PBE_KEYGEN)(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
494#define EVP_MD_CTX_type(e) EVP_MD_type((e)->digest) 406#define EVP_MD_CTX_type(e) EVP_MD_type((e)->digest)
495 407
496#define EVP_CIPHER_nid(e) ((e)->nid) 408#define EVP_CIPHER_nid(e) ((e)->nid)
409#define EVP_CIPHER_name(e) OBJ_nid2sn(EVP_CIPHER_nid(e))
497#define EVP_CIPHER_block_size(e) ((e)->block_size) 410#define EVP_CIPHER_block_size(e) ((e)->block_size)
498#define EVP_CIPHER_key_length(e) ((e)->key_len) 411#define EVP_CIPHER_key_length(e) ((e)->key_len)
499#define EVP_CIPHER_iv_length(e) ((e)->iv_len) 412#define EVP_CIPHER_iv_length(e) ((e)->iv_len)
500#define EVP_CIPHER_flags(e) ((e)->flags) 413#define EVP_CIPHER_flags(e) ((e)->flags)
501#define EVP_CIPHER_mode(e) ((e)->flags) & EVP_CIPH_MODE) 414#define EVP_CIPHER_mode(e) (((e)->flags) & EVP_CIPH_MODE)
502 415
503#define EVP_CIPHER_CTX_cipher(e) ((e)->cipher) 416#define EVP_CIPHER_CTX_cipher(e) ((e)->cipher)
504#define EVP_CIPHER_CTX_nid(e) ((e)->cipher->nid) 417#define EVP_CIPHER_CTX_nid(e) ((e)->cipher->nid)
@@ -514,8 +427,10 @@ typedef int (EVP_PBE_KEYGEN)(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
514#define EVP_ENCODE_LENGTH(l) (((l+2)/3*4)+(l/48+1)*2+80) 427#define EVP_ENCODE_LENGTH(l) (((l+2)/3*4)+(l/48+1)*2+80)
515#define EVP_DECODE_LENGTH(l) ((l+3)/4*3+80) 428#define EVP_DECODE_LENGTH(l) ((l+3)/4*3+80)
516 429
430#define EVP_SignInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c)
517#define EVP_SignInit(a,b) EVP_DigestInit(a,b) 431#define EVP_SignInit(a,b) EVP_DigestInit(a,b)
518#define EVP_SignUpdate(a,b,c) EVP_DigestUpdate(a,b,c) 432#define EVP_SignUpdate(a,b,c) EVP_DigestUpdate(a,b,c)
433#define EVP_VerifyInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c)
519#define EVP_VerifyInit(a,b) EVP_DigestInit(a,b) 434#define EVP_VerifyInit(a,b) EVP_DigestInit(a,b)
520#define EVP_VerifyUpdate(a,b,c) EVP_DigestUpdate(a,b,c) 435#define EVP_VerifyUpdate(a,b,c) EVP_DigestUpdate(a,b,c)
521#define EVP_OpenUpdate(a,b,c,d,e) EVP_DecryptUpdate(a,b,c,d,e) 436#define EVP_OpenUpdate(a,b,c,d,e) EVP_DecryptUpdate(a,b,c,d,e)
@@ -542,38 +457,61 @@ void BIO_set_md(BIO *,const EVP_MD *md);
542#define EVP_delete_digest_alias(alias) \ 457#define EVP_delete_digest_alias(alias) \
543 OBJ_NAME_remove(alias,OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS); 458 OBJ_NAME_remove(alias,OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS);
544 459
545 460void EVP_MD_CTX_init(EVP_MD_CTX *ctx);
546int EVP_MD_CTX_copy(EVP_MD_CTX *out,EVP_MD_CTX *in); 461int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx);
547void EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type); 462EVP_MD_CTX *EVP_MD_CTX_create(void);
548void EVP_DigestUpdate(EVP_MD_CTX *ctx,const void *d, 463void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx);
464int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out,const EVP_MD_CTX *in);
465#define EVP_MD_CTX_set_flags(ctx,flgs) ((ctx)->flags|=(flgs))
466#define EVP_MD_CTX_clear_flags(ctx,flgs) ((ctx)->flags&=~(flgs))
467#define EVP_MD_CTX_test_flags(ctx,flgs) ((ctx)->flags&(flgs))
468int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl);
469int EVP_DigestUpdate(EVP_MD_CTX *ctx,const void *d,
549 unsigned int cnt); 470 unsigned int cnt);
550void EVP_DigestFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s); 471int EVP_DigestFinal_ex(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s);
472int EVP_Digest(void *data, unsigned int count,
473 unsigned char *md, unsigned int *size, const EVP_MD *type, ENGINE *impl);
474
475int EVP_MD_CTX_copy(EVP_MD_CTX *out,const EVP_MD_CTX *in);
476int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type);
477int EVP_DigestFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s);
551 478
552int EVP_read_pw_string(char *buf,int length,const char *prompt,int verify); 479int EVP_read_pw_string(char *buf,int length,const char *prompt,int verify);
553void EVP_set_pw_prompt(char *prompt); 480void EVP_set_pw_prompt(char *prompt);
554char * EVP_get_pw_prompt(void); 481char * EVP_get_pw_prompt(void);
555 482
556int EVP_BytesToKey(const EVP_CIPHER *type, EVP_MD *md, 483int EVP_BytesToKey(const EVP_CIPHER *type,const EVP_MD *md,
557 const unsigned char *salt, const unsigned char *data, int datal, 484 const unsigned char *salt, const unsigned char *data,
558 int count, unsigned char *key, unsigned char *iv); 485 int datal, int count, unsigned char *key,unsigned char *iv);
559 486
560int EVP_EncryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *type, 487int EVP_EncryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher,
561 unsigned char *key, unsigned char *iv); 488 const unsigned char *key, const unsigned char *iv);
489int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl,
490 const unsigned char *key, const unsigned char *iv);
562int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, 491int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
563 int *outl, unsigned char *in, int inl); 492 int *outl, const unsigned char *in, int inl);
493int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
564int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); 494int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
565 495
566int EVP_DecryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *type, 496int EVP_DecryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher,
567 unsigned char *key, unsigned char *iv); 497 const unsigned char *key, const unsigned char *iv);
498int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl,
499 const unsigned char *key, const unsigned char *iv);
568int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, 500int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
569 int *outl, unsigned char *in, int inl); 501 int *outl, const unsigned char *in, int inl);
570int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl); 502int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
571 503int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
572int EVP_CipherInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *type, 504
573 unsigned char *key,unsigned char *iv,int enc); 505int EVP_CipherInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher,
506 const unsigned char *key,const unsigned char *iv,
507 int enc);
508int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl,
509 const unsigned char *key,const unsigned char *iv,
510 int enc);
574int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, 511int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
575 int *outl, unsigned char *in, int inl); 512 int *outl, const unsigned char *in, int inl);
576int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl); 513int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
514int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
577 515
578int EVP_SignFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s, 516int EVP_SignFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s,
579 EVP_PKEY *pkey); 517 EVP_PKEY *pkey);
@@ -581,11 +519,11 @@ int EVP_SignFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s,
581int EVP_VerifyFinal(EVP_MD_CTX *ctx,unsigned char *sigbuf, 519int EVP_VerifyFinal(EVP_MD_CTX *ctx,unsigned char *sigbuf,
582 unsigned int siglen,EVP_PKEY *pkey); 520 unsigned int siglen,EVP_PKEY *pkey);
583 521
584int EVP_OpenInit(EVP_CIPHER_CTX *ctx,EVP_CIPHER *type,unsigned char *ek, 522int EVP_OpenInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *type,unsigned char *ek,
585 int ekl,unsigned char *iv,EVP_PKEY *priv); 523 int ekl,unsigned char *iv,EVP_PKEY *priv);
586int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); 524int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
587 525
588int EVP_SealInit(EVP_CIPHER_CTX *ctx, EVP_CIPHER *type, unsigned char **ek, 526int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, unsigned char **ek,
589 int *ekl, unsigned char *iv,EVP_PKEY **pubk, int npubk); 527 int *ekl, unsigned char *iv,EVP_PKEY **pubk, int npubk);
590void EVP_SealFinal(EVP_CIPHER_CTX *ctx,unsigned char *out,int *outl); 528void EVP_SealFinal(EVP_CIPHER_CTX *ctx,unsigned char *out,int *outl);
591 529
@@ -602,14 +540,13 @@ int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned
602 char *out, int *outl); 540 char *out, int *outl);
603int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n); 541int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n);
604 542
605void ERR_load_EVP_strings(void );
606
607void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a); 543void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a);
608int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a); 544int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a);
609int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen); 545int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen);
546int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *c, int pad);
610int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr); 547int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);
611 548
612#ifndef NO_BIO 549#ifndef OPENSSL_NO_BIO
613BIO_METHOD *BIO_f_md(void); 550BIO_METHOD *BIO_f_md(void);
614BIO_METHOD *BIO_f_base64(void); 551BIO_METHOD *BIO_f_base64(void);
615BIO_METHOD *BIO_f_cipher(void); 552BIO_METHOD *BIO_f_cipher(void);
@@ -618,89 +555,117 @@ void BIO_set_cipher(BIO *b,const EVP_CIPHER *c,unsigned char *k,
618 unsigned char *i, int enc); 555 unsigned char *i, int enc);
619#endif 556#endif
620 557
621EVP_MD *EVP_md_null(void); 558const EVP_MD *EVP_md_null(void);
622#ifndef NO_MD2 559#ifndef OPENSSL_NO_MD2
623EVP_MD *EVP_md2(void); 560const EVP_MD *EVP_md2(void);
624#endif 561#endif
625#ifndef NO_MD4 562#ifndef OPENSSL_NO_MD4
626EVP_MD *EVP_md4(void); 563const EVP_MD *EVP_md4(void);
627#endif 564#endif
628#ifndef NO_MD5 565#ifndef OPENSSL_NO_MD5
629EVP_MD *EVP_md5(void); 566const EVP_MD *EVP_md5(void);
630#endif 567#endif
631#ifndef NO_SHA 568#ifndef OPENSSL_NO_SHA
632EVP_MD *EVP_sha(void); 569const EVP_MD *EVP_sha(void);
633EVP_MD *EVP_sha1(void); 570const EVP_MD *EVP_sha1(void);
634EVP_MD *EVP_dss(void); 571const EVP_MD *EVP_dss(void);
635EVP_MD *EVP_dss1(void); 572const EVP_MD *EVP_dss1(void);
636#endif 573#endif
637#ifndef NO_MDC2 574#ifndef OPENSSL_NO_MDC2
638EVP_MD *EVP_mdc2(void); 575const EVP_MD *EVP_mdc2(void);
639#endif 576#endif
640#ifndef NO_RIPEMD 577#ifndef OPENSSL_NO_RIPEMD
641EVP_MD *EVP_ripemd160(void); 578const EVP_MD *EVP_ripemd160(void);
642#endif 579#endif
643EVP_CIPHER *EVP_enc_null(void); /* does nothing :-) */ 580const EVP_CIPHER *EVP_enc_null(void); /* does nothing :-) */
644#ifndef NO_DES 581#ifndef OPENSSL_NO_DES
645EVP_CIPHER *EVP_des_ecb(void); 582const EVP_CIPHER *EVP_des_ecb(void);
646EVP_CIPHER *EVP_des_ede(void); 583const EVP_CIPHER *EVP_des_ede(void);
647EVP_CIPHER *EVP_des_ede3(void); 584const EVP_CIPHER *EVP_des_ede3(void);
648EVP_CIPHER *EVP_des_cfb(void); 585const EVP_CIPHER *EVP_des_cfb(void);
649EVP_CIPHER *EVP_des_ede_cfb(void); 586const EVP_CIPHER *EVP_des_ede_cfb(void);
650EVP_CIPHER *EVP_des_ede3_cfb(void); 587const EVP_CIPHER *EVP_des_ede3_cfb(void);
651EVP_CIPHER *EVP_des_ofb(void); 588const EVP_CIPHER *EVP_des_ofb(void);
652EVP_CIPHER *EVP_des_ede_ofb(void); 589const EVP_CIPHER *EVP_des_ede_ofb(void);
653EVP_CIPHER *EVP_des_ede3_ofb(void); 590const EVP_CIPHER *EVP_des_ede3_ofb(void);
654EVP_CIPHER *EVP_des_cbc(void); 591const EVP_CIPHER *EVP_des_cbc(void);
655EVP_CIPHER *EVP_des_ede_cbc(void); 592const EVP_CIPHER *EVP_des_ede_cbc(void);
656EVP_CIPHER *EVP_des_ede3_cbc(void); 593const EVP_CIPHER *EVP_des_ede3_cbc(void);
657EVP_CIPHER *EVP_desx_cbc(void); 594const EVP_CIPHER *EVP_desx_cbc(void);
658#endif 595/* This should now be supported through the dev_crypto ENGINE. But also, why are
659#ifndef NO_RC4 596 * rc4 and md5 declarations made here inside a "NO_DES" precompiler branch? */
660EVP_CIPHER *EVP_rc4(void); 597#if 0
661EVP_CIPHER *EVP_rc4_40(void); 598# ifdef OPENSSL_OPENBSD_DEV_CRYPTO
662#endif 599const EVP_CIPHER *EVP_dev_crypto_des_ede3_cbc(void);
663#ifndef NO_IDEA 600const EVP_CIPHER *EVP_dev_crypto_rc4(void);
664EVP_CIPHER *EVP_idea_ecb(void); 601const EVP_MD *EVP_dev_crypto_md5(void);
665EVP_CIPHER *EVP_idea_cfb(void); 602# endif
666EVP_CIPHER *EVP_idea_ofb(void); 603#endif
667EVP_CIPHER *EVP_idea_cbc(void); 604#endif
668#endif 605#ifndef OPENSSL_NO_RC4
669#ifndef NO_RC2 606const EVP_CIPHER *EVP_rc4(void);
670EVP_CIPHER *EVP_rc2_ecb(void); 607const EVP_CIPHER *EVP_rc4_40(void);
671EVP_CIPHER *EVP_rc2_cbc(void); 608#endif
672EVP_CIPHER *EVP_rc2_40_cbc(void); 609#ifndef OPENSSL_NO_IDEA
673EVP_CIPHER *EVP_rc2_64_cbc(void); 610const EVP_CIPHER *EVP_idea_ecb(void);
674EVP_CIPHER *EVP_rc2_cfb(void); 611const EVP_CIPHER *EVP_idea_cfb(void);
675EVP_CIPHER *EVP_rc2_ofb(void); 612const EVP_CIPHER *EVP_idea_ofb(void);
676#endif 613const EVP_CIPHER *EVP_idea_cbc(void);
677#ifndef NO_BF 614#endif
678EVP_CIPHER *EVP_bf_ecb(void); 615#ifndef OPENSSL_NO_RC2
679EVP_CIPHER *EVP_bf_cbc(void); 616const EVP_CIPHER *EVP_rc2_ecb(void);
680EVP_CIPHER *EVP_bf_cfb(void); 617const EVP_CIPHER *EVP_rc2_cbc(void);
681EVP_CIPHER *EVP_bf_ofb(void); 618const EVP_CIPHER *EVP_rc2_40_cbc(void);
682#endif 619const EVP_CIPHER *EVP_rc2_64_cbc(void);
683#ifndef NO_CAST 620const EVP_CIPHER *EVP_rc2_cfb(void);
684EVP_CIPHER *EVP_cast5_ecb(void); 621const EVP_CIPHER *EVP_rc2_ofb(void);
685EVP_CIPHER *EVP_cast5_cbc(void); 622#endif
686EVP_CIPHER *EVP_cast5_cfb(void); 623#ifndef OPENSSL_NO_BF
687EVP_CIPHER *EVP_cast5_ofb(void); 624const EVP_CIPHER *EVP_bf_ecb(void);
688#endif 625const EVP_CIPHER *EVP_bf_cbc(void);
689#ifndef NO_RC5 626const EVP_CIPHER *EVP_bf_cfb(void);
690EVP_CIPHER *EVP_rc5_32_12_16_cbc(void); 627const EVP_CIPHER *EVP_bf_ofb(void);
691EVP_CIPHER *EVP_rc5_32_12_16_ecb(void); 628#endif
692EVP_CIPHER *EVP_rc5_32_12_16_cfb(void); 629#ifndef OPENSSL_NO_CAST
693EVP_CIPHER *EVP_rc5_32_12_16_ofb(void); 630const EVP_CIPHER *EVP_cast5_ecb(void);
694#endif 631const EVP_CIPHER *EVP_cast5_cbc(void);
695void OpenSSL_add_all_algorithms(void); 632const EVP_CIPHER *EVP_cast5_cfb(void);
633const EVP_CIPHER *EVP_cast5_ofb(void);
634#endif
635#ifndef OPENSSL_NO_RC5
636const EVP_CIPHER *EVP_rc5_32_12_16_cbc(void);
637const EVP_CIPHER *EVP_rc5_32_12_16_ecb(void);
638const EVP_CIPHER *EVP_rc5_32_12_16_cfb(void);
639const EVP_CIPHER *EVP_rc5_32_12_16_ofb(void);
640#endif
641#ifndef OPENSSL_NO_AES
642const EVP_CIPHER *EVP_aes_128_ecb(void);
643const EVP_CIPHER *EVP_aes_128_cbc(void);
644const EVP_CIPHER *EVP_aes_192_ecb(void);
645const EVP_CIPHER *EVP_aes_192_cbc(void);
646const EVP_CIPHER *EVP_aes_256_ecb(void);
647const EVP_CIPHER *EVP_aes_256_cbc(void);
648#endif
649
650void OPENSSL_add_all_algorithms_noconf(void);
651void OPENSSL_add_all_algorithms_conf(void);
652
653#ifdef OPENSSL_LOAD_CONF
654#define OpenSSL_add_all_algorithms() \
655 OPENSSL_add_all_algorithms_conf()
656#else
657#define OpenSSL_add_all_algorithms() \
658 OPENSSL_add_all_algorithms_noconf()
659#endif
660
696void OpenSSL_add_all_ciphers(void); 661void OpenSSL_add_all_ciphers(void);
697void OpenSSL_add_all_digests(void); 662void OpenSSL_add_all_digests(void);
698#define SSLeay_add_all_algorithms() OpenSSL_add_all_algorithms() 663#define SSLeay_add_all_algorithms() OpenSSL_add_all_algorithms()
699#define SSLeay_add_all_ciphers() OpenSSL_add_all_ciphers() 664#define SSLeay_add_all_ciphers() OpenSSL_add_all_ciphers()
700#define SSLeay_add_all_digests() OpenSSL_add_all_digests() 665#define SSLeay_add_all_digests() OpenSSL_add_all_digests()
701 666
702int EVP_add_cipher(EVP_CIPHER *cipher); 667int EVP_add_cipher(const EVP_CIPHER *cipher);
703int EVP_add_digest(EVP_MD *digest); 668int EVP_add_digest(const EVP_MD *digest);
704 669
705const EVP_CIPHER *EVP_get_cipherbyname(const char *name); 670const EVP_CIPHER *EVP_get_cipherbyname(const char *name);
706const EVP_MD *EVP_get_digestbyname(const char *name); 671const EVP_MD *EVP_get_digestbyname(const char *name);
@@ -714,18 +679,24 @@ int EVP_PKEY_type(int type);
714int EVP_PKEY_bits(EVP_PKEY *pkey); 679int EVP_PKEY_bits(EVP_PKEY *pkey);
715int EVP_PKEY_size(EVP_PKEY *pkey); 680int EVP_PKEY_size(EVP_PKEY *pkey);
716int EVP_PKEY_assign(EVP_PKEY *pkey,int type,char *key); 681int EVP_PKEY_assign(EVP_PKEY *pkey,int type,char *key);
717#ifndef NO_RSA 682
718int EVP_PKEY_set1_RSA(EVP_PKEY *pkey,RSA *key); 683#ifndef OPENSSL_NO_RSA
719RSA * EVP_PKEY_get1_RSA(EVP_PKEY *pkey); 684struct rsa_st;
685int EVP_PKEY_set1_RSA(EVP_PKEY *pkey,struct rsa_st *key);
686struct rsa_st *EVP_PKEY_get1_RSA(EVP_PKEY *pkey);
720#endif 687#endif
721#ifndef NO_DSA 688#ifndef OPENSSL_NO_DSA
722int EVP_PKEY_set1_DSA(EVP_PKEY *pkey,DSA *key); 689struct dsa_st;
723DSA * EVP_PKEY_get1_DSA(EVP_PKEY *pkey); 690int EVP_PKEY_set1_DSA(EVP_PKEY *pkey,struct dsa_st *key);
691struct dsa_st *EVP_PKEY_get1_DSA(EVP_PKEY *pkey);
724#endif 692#endif
725#ifndef NO_DH 693#ifndef OPENSSL_NO_DH
726int EVP_PKEY_set1_DH(EVP_PKEY *pkey,DH *key); 694struct dh_st;
727DH * EVP_PKEY_get1_DH(EVP_PKEY *pkey); 695int EVP_PKEY_set1_DH(EVP_PKEY *pkey,struct dh_st *key);
696struct dh_st *EVP_PKEY_get1_DH(EVP_PKEY *pkey);
728#endif 697#endif
698
699
729EVP_PKEY * EVP_PKEY_new(void); 700EVP_PKEY * EVP_PKEY_new(void);
730void EVP_PKEY_free(EVP_PKEY *pkey); 701void EVP_PKEY_free(EVP_PKEY *pkey);
731EVP_PKEY * d2i_PublicKey(int type,EVP_PKEY **a, unsigned char **pp, 702EVP_PKEY * d2i_PublicKey(int type,EVP_PKEY **a, unsigned char **pp,
@@ -755,20 +726,20 @@ int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c,ASN1_TYPE *type);
755 726
756/* PKCS5 password based encryption */ 727/* PKCS5 password based encryption */
757int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, 728int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
758 ASN1_TYPE *param, EVP_CIPHER *cipher, EVP_MD *md, 729 ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md,
759 int en_de); 730 int en_de);
760int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen, 731int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,
761 unsigned char *salt, int saltlen, int iter, 732 unsigned char *salt, int saltlen, int iter,
762 int keylen, unsigned char *out); 733 int keylen, unsigned char *out);
763int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, 734int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
764 ASN1_TYPE *param, EVP_CIPHER *cipher, EVP_MD *md, 735 ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md,
765 int en_de); 736 int en_de);
766 737
767void PKCS5_PBE_add(void); 738void PKCS5_PBE_add(void);
768 739
769int EVP_PBE_CipherInit (ASN1_OBJECT *pbe_obj, const char *pass, int passlen, 740int EVP_PBE_CipherInit (ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
770 ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de); 741 ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de);
771int EVP_PBE_alg_add(int nid, EVP_CIPHER *cipher, EVP_MD *md, 742int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md,
772 EVP_PBE_KEYGEN *keygen); 743 EVP_PBE_KEYGEN *keygen);
773void EVP_PBE_cleanup(void); 744void EVP_PBE_cleanup(void);
774 745
@@ -776,6 +747,7 @@ void EVP_PBE_cleanup(void);
776/* The following lines are auto generated by the script mkerr.pl. Any changes 747/* The following lines are auto generated by the script mkerr.pl. Any changes
777 * made after this point may be overwritten when the script is next run. 748 * made after this point may be overwritten when the script is next run.
778 */ 749 */
750void ERR_load_EVP_strings(void);
779 751
780/* Error codes for the EVP functions. */ 752/* Error codes for the EVP functions. */
781 753
@@ -785,6 +757,8 @@ void EVP_PBE_cleanup(void);
785#define EVP_F_EVP_CIPHER_CTX_CTRL 124 757#define EVP_F_EVP_CIPHER_CTX_CTRL 124
786#define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH 122 758#define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH 122
787#define EVP_F_EVP_DECRYPTFINAL 101 759#define EVP_F_EVP_DECRYPTFINAL 101
760#define EVP_F_EVP_DIGESTINIT 128
761#define EVP_F_EVP_ENCRYPTFINAL 127
788#define EVP_F_EVP_MD_CTX_COPY 110 762#define EVP_F_EVP_MD_CTX_COPY 110
789#define EVP_F_EVP_OPENINIT 102 763#define EVP_F_EVP_OPENINIT 102
790#define EVP_F_EVP_PBE_ALG_ADD 115 764#define EVP_F_EVP_PBE_ALG_ADD 115
@@ -799,6 +773,7 @@ void EVP_PBE_cleanup(void);
799#define EVP_F_EVP_PKEY_GET1_DSA 120 773#define EVP_F_EVP_PKEY_GET1_DSA 120
800#define EVP_F_EVP_PKEY_GET1_RSA 121 774#define EVP_F_EVP_PKEY_GET1_RSA 121
801#define EVP_F_EVP_PKEY_NEW 106 775#define EVP_F_EVP_PKEY_NEW 106
776#define EVP_F_EVP_RIJNDAEL 126
802#define EVP_F_EVP_SIGNFINAL 107 777#define EVP_F_EVP_SIGNFINAL 107
803#define EVP_F_EVP_VERIFYFINAL 108 778#define EVP_F_EVP_VERIFYFINAL 108
804#define EVP_F_PKCS5_PBE_KEYIVGEN 117 779#define EVP_F_PKCS5_PBE_KEYIVGEN 117
@@ -807,12 +782,15 @@ void EVP_PBE_cleanup(void);
807#define EVP_F_RC5_CTRL 125 782#define EVP_F_RC5_CTRL 125
808 783
809/* Reason codes. */ 784/* Reason codes. */
785#define EVP_R_BAD_BLOCK_LENGTH 136
810#define EVP_R_BAD_DECRYPT 100 786#define EVP_R_BAD_DECRYPT 100
787#define EVP_R_BAD_KEY_LENGTH 137
811#define EVP_R_BN_DECODE_ERROR 112 788#define EVP_R_BN_DECODE_ERROR 112
812#define EVP_R_BN_PUBKEY_ERROR 113 789#define EVP_R_BN_PUBKEY_ERROR 113
813#define EVP_R_CIPHER_PARAMETER_ERROR 122 790#define EVP_R_CIPHER_PARAMETER_ERROR 122
814#define EVP_R_CTRL_NOT_IMPLEMENTED 132 791#define EVP_R_CTRL_NOT_IMPLEMENTED 132
815#define EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED 133 792#define EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED 133
793#define EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH 138
816#define EVP_R_DECODE_ERROR 114 794#define EVP_R_DECODE_ERROR 114
817#define EVP_R_DIFFERENT_KEY_TYPES 101 795#define EVP_R_DIFFERENT_KEY_TYPES 101
818#define EVP_R_ENCODE_ERROR 115 796#define EVP_R_ENCODE_ERROR 115
@@ -827,6 +805,7 @@ void EVP_PBE_cleanup(void);
827#define EVP_R_KEYGEN_FAILURE 120 805#define EVP_R_KEYGEN_FAILURE 120
828#define EVP_R_MISSING_PARAMETERS 103 806#define EVP_R_MISSING_PARAMETERS 103
829#define EVP_R_NO_CIPHER_SET 131 807#define EVP_R_NO_CIPHER_SET 131
808#define EVP_R_NO_DIGEST_SET 139
830#define EVP_R_NO_DSA_PARAMETERS 116 809#define EVP_R_NO_DSA_PARAMETERS 116
831#define EVP_R_NO_SIGN_FUNCTION_CONFIGURED 104 810#define EVP_R_NO_SIGN_FUNCTION_CONFIGURED 104
832#define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED 105 811#define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED 105
@@ -848,4 +827,3 @@ void EVP_PBE_cleanup(void);
848} 827}
849#endif 828#endif
850#endif 829#endif
851
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 e2687f9879..d28a7d266e 100644
--- a/src/lib/libcrypto/evp/evp_enc.c
+++ b/src/lib/libcrypto/evp/evp_enc.c
@@ -60,8 +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#include <openssl/engine.h>
63#include "evp_locl.h" 64#include "evp_locl.h"
64 65
66#include <assert.h>
67
65const char *EVP_version="EVP" OPENSSL_VERSION_PTEXT; 68const char *EVP_version="EVP" OPENSSL_VERSION_PTEXT;
66 69
67void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *ctx) 70void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *ctx)
@@ -70,23 +73,97 @@ void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *ctx)
70 /* ctx->cipher=NULL; */ 73 /* ctx->cipher=NULL; */
71 } 74 }
72 75
76
73int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, 77int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
74 unsigned char *key, unsigned char *iv, int enc) 78 const unsigned char *key, const unsigned char *iv, int enc)
75 { 79 {
76 if(enc && (enc != -1)) enc = 1; 80 if (cipher)
77 if (cipher) { 81 EVP_CIPHER_CTX_init(ctx);
82 return EVP_CipherInit_ex(ctx,cipher,NULL,key,iv,enc);
83 }
84
85int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl,
86 const unsigned char *key, const unsigned char *iv, int enc)
87 {
88 if (enc == -1)
89 enc = ctx->encrypt;
90 else
91 {
92 if (enc)
93 enc = 1;
94 ctx->encrypt = enc;
95 }
96 /* Whether it's nice or not, "Inits" can be used on "Final"'d contexts
97 * so this context may already have an ENGINE! Try to avoid releasing
98 * the previous handle, re-querying for an ENGINE, and having a
99 * reinitialisation, when it may all be unecessary. */
100 if (ctx->engine && ctx->cipher && (!cipher ||
101 (cipher && (cipher->nid == ctx->cipher->nid))))
102 goto skip_to_init;
103 if (cipher)
104 {
105 /* Ensure an ENGINE left lying around from last time is cleared
106 * (the previous check attempted to avoid this if the same
107 * ENGINE and EVP_CIPHER could be used). */
108 if(ctx->engine)
109 ENGINE_finish(ctx->engine);
110 if(impl)
111 {
112 if (!ENGINE_init(impl))
113 {
114 EVPerr(EVP_F_EVP_CIPHERINIT, EVP_R_INITIALIZATION_ERROR);
115 return 0;
116 }
117 }
118 else
119 /* Ask if an ENGINE is reserved for this job */
120 impl = ENGINE_get_cipher_engine(cipher->nid);
121 if(impl)
122 {
123 /* There's an ENGINE for this job ... (apparently) */
124 const EVP_CIPHER *c = ENGINE_get_cipher(impl, cipher->nid);
125 if(!c)
126 {
127 /* One positive side-effect of US's export
128 * control history, is that we should at least
129 * be able to avoid using US mispellings of
130 * "initialisation"? */
131 EVPerr(EVP_F_EVP_CIPHERINIT, EVP_R_INITIALIZATION_ERROR);
132 return 0;
133 }
134 /* We'll use the ENGINE's private cipher definition */
135 cipher = c;
136 /* Store the ENGINE functional reference so we know
137 * 'cipher' came from an ENGINE and we need to release
138 * it when done. */
139 ctx->engine = impl;
140 }
141 else
142 ctx->engine = NULL;
78 ctx->cipher=cipher; 143 ctx->cipher=cipher;
144 ctx->cipher_data=OPENSSL_malloc(ctx->cipher->ctx_size);
79 ctx->key_len = cipher->key_len; 145 ctx->key_len = cipher->key_len;
80 if(ctx->cipher->flags & EVP_CIPH_CTRL_INIT) { 146 ctx->flags = 0;
81 if(!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_INIT, 0, NULL)) { 147 if(ctx->cipher->flags & EVP_CIPH_CTRL_INIT)
148 {
149 if(!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_INIT, 0, NULL))
150 {
82 EVPerr(EVP_F_EVP_CIPHERINIT, EVP_R_INITIALIZATION_ERROR); 151 EVPerr(EVP_F_EVP_CIPHERINIT, EVP_R_INITIALIZATION_ERROR);
83 return 0; 152 return 0;
153 }
84 } 154 }
85 } 155 }
86 } else if(!ctx->cipher) { 156 else if(!ctx->cipher)
157 {
87 EVPerr(EVP_F_EVP_CIPHERINIT, EVP_R_NO_CIPHER_SET); 158 EVPerr(EVP_F_EVP_CIPHERINIT, EVP_R_NO_CIPHER_SET);
88 return 0; 159 return 0;
89 } 160 }
161skip_to_init:
162 /* we assume block size is a power of 2 in *cryptUpdate */
163 assert(ctx->cipher->block_size == 1
164 || ctx->cipher->block_size == 8
165 || ctx->cipher->block_size == 16);
166
90 if(!(EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_CUSTOM_IV)) { 167 if(!(EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_CUSTOM_IV)) {
91 switch(EVP_CIPHER_CTX_mode(ctx)) { 168 switch(EVP_CIPHER_CTX_mode(ctx)) {
92 169
@@ -114,68 +191,101 @@ int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
114 if(key || (ctx->cipher->flags & EVP_CIPH_ALWAYS_CALL_INIT)) { 191 if(key || (ctx->cipher->flags & EVP_CIPH_ALWAYS_CALL_INIT)) {
115 if(!ctx->cipher->init(ctx,key,iv,enc)) return 0; 192 if(!ctx->cipher->init(ctx,key,iv,enc)) return 0;
116 } 193 }
117 if(enc != -1) ctx->encrypt=enc;
118 ctx->buf_len=0; 194 ctx->buf_len=0;
195 ctx->final_used=0;
196 ctx->block_mask=ctx->cipher->block_size-1;
119 return 1; 197 return 1;
120 } 198 }
121 199
122int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, 200int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
123 unsigned char *in, int inl) 201 const unsigned char *in, int inl)
124 { 202 {
125 if (ctx->encrypt) 203 if (ctx->encrypt)
126 return EVP_EncryptUpdate(ctx,out,outl,in,inl); 204 return EVP_EncryptUpdate(ctx,out,outl,in,inl);
127 else return EVP_DecryptUpdate(ctx,out,outl,in,inl); 205 else return EVP_DecryptUpdate(ctx,out,outl,in,inl);
128 } 206 }
129 207
208int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
209 {
210 if (ctx->encrypt)
211 return EVP_EncryptFinal_ex(ctx,out,outl);
212 else return EVP_DecryptFinal_ex(ctx,out,outl);
213 }
214
130int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) 215int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
131 { 216 {
132 if (ctx->encrypt) 217 if (ctx->encrypt)
133 return EVP_EncryptFinal(ctx,out,outl); 218 return EVP_EncryptFinal(ctx,out,outl);
134 else return(EVP_DecryptFinal(ctx,out,outl)); 219 else return EVP_DecryptFinal(ctx,out,outl);
135 } 220 }
136 221
137int EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, 222int EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
138 unsigned char *key, unsigned char *iv) 223 const unsigned char *key, const unsigned char *iv)
139 { 224 {
140 return EVP_CipherInit(ctx, cipher, key, iv, 1); 225 return EVP_CipherInit(ctx, cipher, key, iv, 1);
141 } 226 }
142 227
228int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl,
229 const unsigned char *key, const unsigned char *iv)
230 {
231 return EVP_CipherInit_ex(ctx, cipher, impl, key, iv, 1);
232 }
233
143int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, 234int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
144 unsigned char *key, unsigned char *iv) 235 const unsigned char *key, const unsigned char *iv)
145 { 236 {
146 return EVP_CipherInit(ctx, cipher, key, iv, 0); 237 return EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, 0);
147 } 238 }
148 239
240int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl,
241 const unsigned char *key, const unsigned char *iv)
242 {
243 return EVP_CipherInit_ex(ctx, cipher, impl, key, iv, 0);
244 }
149 245
150int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, 246int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
151 unsigned char *in, int inl) 247 const unsigned char *in, int inl)
152 { 248 {
153 int i,j,bl; 249 int i,j,bl;
154 250
251 if(ctx->buf_len == 0 && (inl&(ctx->block_mask)) == 0)
252 {
253 if(ctx->cipher->do_cipher(ctx,out,in,inl))
254 {
255 *outl=inl;
256 return 1;
257 }
258 else
259 {
260 *outl=0;
261 return 0;
262 }
263 }
155 i=ctx->buf_len; 264 i=ctx->buf_len;
156 bl=ctx->cipher->block_size; 265 bl=ctx->cipher->block_size;
157 *outl=0;
158 if ((inl == 0) && (i != bl)) return 1;
159 if (i != 0) 266 if (i != 0)
160 { 267 {
161 if (i+inl < bl) 268 if (i+inl < bl)
162 { 269 {
163 memcpy(&(ctx->buf[i]),in,inl); 270 memcpy(&(ctx->buf[i]),in,inl);
164 ctx->buf_len+=inl; 271 ctx->buf_len+=inl;
272 *outl=0;
165 return 1; 273 return 1;
166 } 274 }
167 else 275 else
168 { 276 {
169 j=bl-i; 277 j=bl-i;
170 if (j != 0) memcpy(&(ctx->buf[i]),in,j); 278 memcpy(&(ctx->buf[i]),in,j);
171 if(!ctx->cipher->do_cipher(ctx,out,ctx->buf,bl)) return 0; 279 if(!ctx->cipher->do_cipher(ctx,out,ctx->buf,bl)) return 0;
172 inl-=j; 280 inl-=j;
173 in+=j; 281 in+=j;
174 out+=bl; 282 out+=bl;
175 *outl+=bl; 283 *outl=bl;
176 } 284 }
177 } 285 }
178 i=inl%bl; /* how much is left */ 286 else
287 *outl = 0;
288 i=inl&(bl-1);
179 inl-=i; 289 inl-=i;
180 if (inl > 0) 290 if (inl > 0)
181 { 291 {
@@ -191,107 +301,153 @@ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
191 301
192int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) 302int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
193 { 303 {
194 int i,n,b,bl; 304 int ret;
305 ret = EVP_EncryptFinal_ex(ctx, out, outl);
306 EVP_CIPHER_CTX_cleanup(ctx);
307 return ret;
308 }
309
310int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
311 {
312 int i,n,b,bl,ret;
195 313
196 b=ctx->cipher->block_size; 314 b=ctx->cipher->block_size;
197 if (b == 1) 315 if (b == 1)
198 { 316 {
317 EVP_CIPHER_CTX_cleanup(ctx);
199 *outl=0; 318 *outl=0;
200 return 1; 319 return 1;
201 } 320 }
202 bl=ctx->buf_len; 321 bl=ctx->buf_len;
322 if (ctx->flags & EVP_CIPH_NO_PADDING)
323 {
324 EVP_CIPHER_CTX_cleanup(ctx);
325 if(bl)
326 {
327 EVPerr(EVP_F_EVP_ENCRYPTFINAL,EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH);
328 return 0;
329 }
330 *outl = 0;
331 return 1;
332 }
333
203 n=b-bl; 334 n=b-bl;
204 for (i=bl; i<b; i++) 335 for (i=bl; i<b; i++)
205 ctx->buf[i]=n; 336 ctx->buf[i]=n;
206 if(!ctx->cipher->do_cipher(ctx,out,ctx->buf,b)) return 0; 337 ret=ctx->cipher->do_cipher(ctx,out,ctx->buf,b);
207 *outl=b; 338
208 return 1; 339 EVP_CIPHER_CTX_cleanup(ctx);
340
341 if(ret)
342 *outl=b;
343
344 return ret;
209 } 345 }
210 346
211int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, 347int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
212 unsigned char *in, int inl) 348 const unsigned char *in, int inl)
213 { 349 {
214 int b,bl,n; 350 int b, fix_len;
215 int keep_last=0;
216 351
217 *outl=0; 352 if (inl == 0)
218 if (inl == 0) return 1; 353 {
354 *outl=0;
355 return 1;
356 }
357
358 if (ctx->flags & EVP_CIPH_NO_PADDING)
359 return EVP_EncryptUpdate(ctx, out, outl, in, inl);
219 360
220 b=ctx->cipher->block_size; 361 b=ctx->cipher->block_size;
221 if (b > 1) 362
363 if(ctx->final_used)
222 { 364 {
223 /* Is the input a multiple of the block size? */ 365 memcpy(out,ctx->final,b);
224 bl=ctx->buf_len; 366 out+=b;
225 n=inl+bl; 367 fix_len = 1;
226 if (n%b == 0)
227 {
228 if (inl < b) /* must be 'just one' buff */
229 {
230 memcpy(&(ctx->buf[bl]),in,inl);
231 ctx->buf_len=b;
232 *outl=0;
233 return 1;
234 }
235 keep_last=1;
236 inl-=b; /* don't do the last block */
237 }
238 } 368 }
239 if(!EVP_EncryptUpdate(ctx,out,outl,in,inl)) return 0; 369 else
370 fix_len = 0;
371
372
373 if(!EVP_EncryptUpdate(ctx,out,outl,in,inl))
374 return 0;
240 375
241 /* if we have 'decrypted' a multiple of block size, make sure 376 /* if we have 'decrypted' a multiple of block size, make sure
242 * we have a copy of this last block */ 377 * we have a copy of this last block */
243 if (keep_last) 378 if (b > 1 && !ctx->buf_len)
244 { 379 {
245 memcpy(&(ctx->buf[0]),&(in[inl]),b); 380 *outl-=b;
246#ifdef DEBUG 381 ctx->final_used=1;
247 if (ctx->buf_len != 0) 382 memcpy(ctx->final,&out[*outl],b);
248 {
249 abort();
250 }
251#endif
252 ctx->buf_len=b;
253 } 383 }
384 else
385 ctx->final_used = 0;
386
387 if (fix_len)
388 *outl += b;
389
254 return 1; 390 return 1;
255 } 391 }
256 392
257int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) 393int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
258 { 394 {
395 int ret;
396 ret = EVP_DecryptFinal_ex(ctx, out, outl);
397 EVP_CIPHER_CTX_cleanup(ctx);
398 return ret;
399 }
400
401int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
402 {
259 int i,b; 403 int i,b;
260 int n; 404 int n;
261 405
262 *outl=0; 406 *outl=0;
263 b=ctx->cipher->block_size; 407 b=ctx->cipher->block_size;
408 if (ctx->flags & EVP_CIPH_NO_PADDING)
409 {
410 EVP_CIPHER_CTX_cleanup(ctx);
411 if(ctx->buf_len)
412 {
413 EVPerr(EVP_F_EVP_DECRYPTFINAL,EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH);
414 return 0;
415 }
416 *outl = 0;
417 return 1;
418 }
264 if (b > 1) 419 if (b > 1)
265 { 420 {
266 if (ctx->buf_len != b) 421 if (ctx->buf_len || !ctx->final_used)
267 { 422 {
423 EVP_CIPHER_CTX_cleanup(ctx);
268 EVPerr(EVP_F_EVP_DECRYPTFINAL,EVP_R_WRONG_FINAL_BLOCK_LENGTH); 424 EVPerr(EVP_F_EVP_DECRYPTFINAL,EVP_R_WRONG_FINAL_BLOCK_LENGTH);
269 return(0); 425 return(0);
270 } 426 }
271 if(!EVP_EncryptUpdate(ctx,ctx->buf,&n,ctx->buf,0)) return 0; 427 n=ctx->final[b-1];
272 if (n != b)
273 return(0);
274 n=ctx->buf[b-1];
275 if (n > b) 428 if (n > b)
276 { 429 {
430 EVP_CIPHER_CTX_cleanup(ctx);
277 EVPerr(EVP_F_EVP_DECRYPTFINAL,EVP_R_BAD_DECRYPT); 431 EVPerr(EVP_F_EVP_DECRYPTFINAL,EVP_R_BAD_DECRYPT);
278 return(0); 432 return(0);
279 } 433 }
280 for (i=0; i<n; i++) 434 for (i=0; i<n; i++)
281 { 435 {
282 if (ctx->buf[--b] != n) 436 if (ctx->final[--b] != n)
283 { 437 {
438 EVP_CIPHER_CTX_cleanup(ctx);
284 EVPerr(EVP_F_EVP_DECRYPTFINAL,EVP_R_BAD_DECRYPT); 439 EVPerr(EVP_F_EVP_DECRYPTFINAL,EVP_R_BAD_DECRYPT);
285 return(0); 440 return(0);
286 } 441 }
287 } 442 }
288 n=ctx->cipher->block_size-n; 443 n=ctx->cipher->block_size-n;
289 for (i=0; i<n; i++) 444 for (i=0; i<n; i++)
290 out[i]=ctx->buf[i]; 445 out[i]=ctx->final[i];
291 *outl=n; 446 *outl=n;
292 } 447 }
293 else 448 else
294 *outl=0; 449 *outl=0;
450 EVP_CIPHER_CTX_cleanup(ctx);
295 return(1); 451 return(1);
296 } 452 }
297 453
@@ -301,6 +457,11 @@ int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *c)
301 { 457 {
302 if(!c->cipher->cleanup(c)) return 0; 458 if(!c->cipher->cleanup(c)) return 0;
303 } 459 }
460 OPENSSL_free(c->cipher_data);
461 if (c->engine)
462 /* The EVP_CIPHER we used belongs to an ENGINE, release the
463 * functional reference we held for this reason. */
464 ENGINE_finish(c->engine);
304 memset(c,0,sizeof(EVP_CIPHER_CTX)); 465 memset(c,0,sizeof(EVP_CIPHER_CTX));
305 return 1; 466 return 1;
306 } 467 }
@@ -319,6 +480,13 @@ int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *c, int keylen)
319 return 0; 480 return 0;
320 } 481 }
321 482
483int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *ctx, int pad)
484 {
485 if (pad) ctx->flags &= ~EVP_CIPH_NO_PADDING;
486 else ctx->flags |= EVP_CIPH_NO_PADDING;
487 return 1;
488 }
489
322int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr) 490int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
323{ 491{
324 int ret; 492 int ret;
diff --git a/src/lib/libcrypto/evp/evp_err.c b/src/lib/libcrypto/evp/evp_err.c
index a01412a07c..3a23d21c21 100644
--- a/src/lib/libcrypto/evp/evp_err.c
+++ b/src/lib/libcrypto/evp/evp_err.c
@@ -63,7 +63,7 @@
63#include <openssl/evp.h> 63#include <openssl/evp.h>
64 64
65/* BEGIN ERROR CODES */ 65/* BEGIN ERROR CODES */
66#ifndef NO_ERR 66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA EVP_str_functs[]= 67static ERR_STRING_DATA EVP_str_functs[]=
68 { 68 {
69{ERR_PACK(0,EVP_F_D2I_PKEY,0), "D2I_PKEY"}, 69{ERR_PACK(0,EVP_F_D2I_PKEY,0), "D2I_PKEY"},
@@ -71,6 +71,8 @@ static ERR_STRING_DATA EVP_str_functs[]=
71{ERR_PACK(0,EVP_F_EVP_CIPHER_CTX_CTRL,0), "EVP_CIPHER_CTX_ctrl"}, 71{ERR_PACK(0,EVP_F_EVP_CIPHER_CTX_CTRL,0), "EVP_CIPHER_CTX_ctrl"},
72{ERR_PACK(0,EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH,0), "EVP_CIPHER_CTX_set_key_length"}, 72{ERR_PACK(0,EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH,0), "EVP_CIPHER_CTX_set_key_length"},
73{ERR_PACK(0,EVP_F_EVP_DECRYPTFINAL,0), "EVP_DecryptFinal"}, 73{ERR_PACK(0,EVP_F_EVP_DECRYPTFINAL,0), "EVP_DecryptFinal"},
74{ERR_PACK(0,EVP_F_EVP_DIGESTINIT,0), "EVP_DigestInit"},
75{ERR_PACK(0,EVP_F_EVP_ENCRYPTFINAL,0), "EVP_EncryptFinal"},
74{ERR_PACK(0,EVP_F_EVP_MD_CTX_COPY,0), "EVP_MD_CTX_copy"}, 76{ERR_PACK(0,EVP_F_EVP_MD_CTX_COPY,0), "EVP_MD_CTX_copy"},
75{ERR_PACK(0,EVP_F_EVP_OPENINIT,0), "EVP_OpenInit"}, 77{ERR_PACK(0,EVP_F_EVP_OPENINIT,0), "EVP_OpenInit"},
76{ERR_PACK(0,EVP_F_EVP_PBE_ALG_ADD,0), "EVP_PBE_alg_add"}, 78{ERR_PACK(0,EVP_F_EVP_PBE_ALG_ADD,0), "EVP_PBE_alg_add"},
@@ -85,6 +87,7 @@ static ERR_STRING_DATA EVP_str_functs[]=
85{ERR_PACK(0,EVP_F_EVP_PKEY_GET1_DSA,0), "EVP_PKEY_get1_DSA"}, 87{ERR_PACK(0,EVP_F_EVP_PKEY_GET1_DSA,0), "EVP_PKEY_get1_DSA"},
86{ERR_PACK(0,EVP_F_EVP_PKEY_GET1_RSA,0), "EVP_PKEY_get1_RSA"}, 88{ERR_PACK(0,EVP_F_EVP_PKEY_GET1_RSA,0), "EVP_PKEY_get1_RSA"},
87{ERR_PACK(0,EVP_F_EVP_PKEY_NEW,0), "EVP_PKEY_new"}, 89{ERR_PACK(0,EVP_F_EVP_PKEY_NEW,0), "EVP_PKEY_new"},
90{ERR_PACK(0,EVP_F_EVP_RIJNDAEL,0), "EVP_RIJNDAEL"},
88{ERR_PACK(0,EVP_F_EVP_SIGNFINAL,0), "EVP_SignFinal"}, 91{ERR_PACK(0,EVP_F_EVP_SIGNFINAL,0), "EVP_SignFinal"},
89{ERR_PACK(0,EVP_F_EVP_VERIFYFINAL,0), "EVP_VerifyFinal"}, 92{ERR_PACK(0,EVP_F_EVP_VERIFYFINAL,0), "EVP_VerifyFinal"},
90{ERR_PACK(0,EVP_F_PKCS5_PBE_KEYIVGEN,0), "PKCS5_PBE_keyivgen"}, 93{ERR_PACK(0,EVP_F_PKCS5_PBE_KEYIVGEN,0), "PKCS5_PBE_keyivgen"},
@@ -96,12 +99,15 @@ static ERR_STRING_DATA EVP_str_functs[]=
96 99
97static ERR_STRING_DATA EVP_str_reasons[]= 100static ERR_STRING_DATA EVP_str_reasons[]=
98 { 101 {
102{EVP_R_BAD_BLOCK_LENGTH ,"bad block length"},
99{EVP_R_BAD_DECRYPT ,"bad decrypt"}, 103{EVP_R_BAD_DECRYPT ,"bad decrypt"},
104{EVP_R_BAD_KEY_LENGTH ,"bad key length"},
100{EVP_R_BN_DECODE_ERROR ,"bn decode error"}, 105{EVP_R_BN_DECODE_ERROR ,"bn decode error"},
101{EVP_R_BN_PUBKEY_ERROR ,"bn pubkey error"}, 106{EVP_R_BN_PUBKEY_ERROR ,"bn pubkey error"},
102{EVP_R_CIPHER_PARAMETER_ERROR ,"cipher parameter error"}, 107{EVP_R_CIPHER_PARAMETER_ERROR ,"cipher parameter error"},
103{EVP_R_CTRL_NOT_IMPLEMENTED ,"ctrl not implemented"}, 108{EVP_R_CTRL_NOT_IMPLEMENTED ,"ctrl not implemented"},
104{EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED ,"ctrl operation not implemented"}, 109{EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED ,"ctrl operation not implemented"},
110{EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH ,"data not multiple of block length"},
105{EVP_R_DECODE_ERROR ,"decode error"}, 111{EVP_R_DECODE_ERROR ,"decode error"},
106{EVP_R_DIFFERENT_KEY_TYPES ,"different key types"}, 112{EVP_R_DIFFERENT_KEY_TYPES ,"different key types"},
107{EVP_R_ENCODE_ERROR ,"encode error"}, 113{EVP_R_ENCODE_ERROR ,"encode error"},
@@ -116,6 +122,7 @@ static ERR_STRING_DATA EVP_str_reasons[]=
116{EVP_R_KEYGEN_FAILURE ,"keygen failure"}, 122{EVP_R_KEYGEN_FAILURE ,"keygen failure"},
117{EVP_R_MISSING_PARAMETERS ,"missing parameters"}, 123{EVP_R_MISSING_PARAMETERS ,"missing parameters"},
118{EVP_R_NO_CIPHER_SET ,"no cipher set"}, 124{EVP_R_NO_CIPHER_SET ,"no cipher set"},
125{EVP_R_NO_DIGEST_SET ,"no digest set"},
119{EVP_R_NO_DSA_PARAMETERS ,"no dsa parameters"}, 126{EVP_R_NO_DSA_PARAMETERS ,"no dsa parameters"},
120{EVP_R_NO_SIGN_FUNCTION_CONFIGURED ,"no sign function configured"}, 127{EVP_R_NO_SIGN_FUNCTION_CONFIGURED ,"no sign function configured"},
121{EVP_R_NO_VERIFY_FUNCTION_CONFIGURED ,"no verify function configured"}, 128{EVP_R_NO_VERIFY_FUNCTION_CONFIGURED ,"no verify function configured"},
@@ -144,7 +151,7 @@ void ERR_load_EVP_strings(void)
144 if (init) 151 if (init)
145 { 152 {
146 init=0; 153 init=0;
147#ifndef NO_ERR 154#ifndef OPENSSL_NO_ERR
148 ERR_load_strings(ERR_LIB_EVP,EVP_str_functs); 155 ERR_load_strings(ERR_LIB_EVP,EVP_str_functs);
149 ERR_load_strings(ERR_LIB_EVP,EVP_str_reasons); 156 ERR_load_strings(ERR_LIB_EVP,EVP_str_reasons);
150#endif 157#endif
diff --git a/src/lib/libcrypto/evp/evp_key.c b/src/lib/libcrypto/evp/evp_key.c
index e7434ef9b2..4271393069 100644
--- a/src/lib/libcrypto/evp/evp_key.c
+++ b/src/lib/libcrypto/evp/evp_key.c
@@ -61,6 +61,7 @@
61#include <openssl/x509.h> 61#include <openssl/x509.h>
62#include <openssl/objects.h> 62#include <openssl/objects.h>
63#include <openssl/evp.h> 63#include <openssl/evp.h>
64#include <openssl/ui.h>
64 65
65/* should be init to zeros. */ 66/* should be init to zeros. */
66static char prompt_string[80]; 67static char prompt_string[80];
@@ -70,7 +71,10 @@ void EVP_set_pw_prompt(char *prompt)
70 if (prompt == NULL) 71 if (prompt == NULL)
71 prompt_string[0]='\0'; 72 prompt_string[0]='\0';
72 else 73 else
74 {
73 strncpy(prompt_string,prompt,79); 75 strncpy(prompt_string,prompt,79);
76 prompt_string[79]='\0';
77 }
74 } 78 }
75 79
76char *EVP_get_pw_prompt(void) 80char *EVP_get_pw_prompt(void)
@@ -86,18 +90,26 @@ char *EVP_get_pw_prompt(void)
86 * this function will fail */ 90 * this function will fail */
87int EVP_read_pw_string(char *buf, int len, const char *prompt, int verify) 91int EVP_read_pw_string(char *buf, int len, const char *prompt, int verify)
88 { 92 {
89#ifndef NO_DES 93 int ret;
94 char buff[BUFSIZ];
95 UI *ui;
96
90 if ((prompt == NULL) && (prompt_string[0] != '\0')) 97 if ((prompt == NULL) && (prompt_string[0] != '\0'))
91 prompt=prompt_string; 98 prompt=prompt_string;
92 return(des_read_pw_string(buf,len,prompt,verify)); 99 ui = UI_new();
93#else 100 UI_add_input_string(ui,prompt,0,buf,0,(len>=BUFSIZ)?BUFSIZ-1:len);
94 return -1; 101 if (verify)
95#endif 102 UI_add_verify_string(ui,prompt,0,
103 buff,0,(len>=BUFSIZ)?BUFSIZ-1:len,buf);
104 ret = UI_process(ui);
105 UI_free(ui);
106 memset(buff,0,BUFSIZ);
107 return ret;
96 } 108 }
97 109
98int EVP_BytesToKey(const EVP_CIPHER *type, EVP_MD *md, 110int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md,
99 const unsigned char *salt, const unsigned char *data, int datal, 111 const unsigned char *salt, const unsigned char *data, int datal,
100 int count, unsigned char *key, unsigned char *iv) 112 int count, unsigned char *key, unsigned char *iv)
101 { 113 {
102 EVP_MD_CTX c; 114 EVP_MD_CTX c;
103 unsigned char md_buf[EVP_MAX_MD_SIZE]; 115 unsigned char md_buf[EVP_MAX_MD_SIZE];
@@ -109,21 +121,22 @@ int EVP_BytesToKey(const EVP_CIPHER *type, EVP_MD *md,
109 121
110 if (data == NULL) return(nkey); 122 if (data == NULL) return(nkey);
111 123
124 EVP_MD_CTX_init(&c);
112 for (;;) 125 for (;;)
113 { 126 {
114 EVP_DigestInit(&c,md); 127 EVP_DigestInit_ex(&c,md, NULL);
115 if (addmd++) 128 if (addmd++)
116 EVP_DigestUpdate(&c,&(md_buf[0]),mds); 129 EVP_DigestUpdate(&c,&(md_buf[0]),mds);
117 EVP_DigestUpdate(&c,data,datal); 130 EVP_DigestUpdate(&c,data,datal);
118 if (salt != NULL) 131 if (salt != NULL)
119 EVP_DigestUpdate(&c,salt,PKCS5_SALT_LEN); 132 EVP_DigestUpdate(&c,salt,PKCS5_SALT_LEN);
120 EVP_DigestFinal(&c,&(md_buf[0]),&mds); 133 EVP_DigestFinal_ex(&c,&(md_buf[0]),&mds);
121 134
122 for (i=1; i<(unsigned int)count; i++) 135 for (i=1; i<(unsigned int)count; i++)
123 { 136 {
124 EVP_DigestInit(&c,md); 137 EVP_DigestInit_ex(&c,md, NULL);
125 EVP_DigestUpdate(&c,&(md_buf[0]),mds); 138 EVP_DigestUpdate(&c,&(md_buf[0]),mds);
126 EVP_DigestFinal(&c,&(md_buf[0]),&mds); 139 EVP_DigestFinal_ex(&c,&(md_buf[0]),&mds);
127 } 140 }
128 i=0; 141 i=0;
129 if (nkey) 142 if (nkey)
@@ -152,7 +165,7 @@ int EVP_BytesToKey(const EVP_CIPHER *type, EVP_MD *md,
152 } 165 }
153 if ((nkey == 0) && (niv == 0)) break; 166 if ((nkey == 0) && (niv == 0)) break;
154 } 167 }
155 memset(&c,0,sizeof(c)); 168 EVP_MD_CTX_cleanup(&c);
156 memset(&(md_buf[0]),0,EVP_MAX_MD_SIZE); 169 memset(&(md_buf[0]),0,EVP_MAX_MD_SIZE);
157 return(type->key_len); 170 return(type->key_len);
158 } 171 }
diff --git a/src/lib/libcrypto/evp/evp_locl.h b/src/lib/libcrypto/evp/evp_locl.h
index ce49d5b7d8..7b088b4848 100644
--- a/src/lib/libcrypto/evp/evp_locl.h
+++ b/src/lib/libcrypto/evp/evp_locl.h
@@ -61,50 +61,107 @@
61/* Wrapper functions for each cipher mode */ 61/* Wrapper functions for each cipher mode */
62 62
63#define BLOCK_CIPHER_ecb_loop() \ 63#define BLOCK_CIPHER_ecb_loop() \
64 unsigned int i; \ 64 unsigned int i, bl; \
65 if(inl < 8) return 1;\ 65 bl = ctx->cipher->block_size;\
66 inl -= 8; \ 66 if(inl < bl) return 1;\
67 for(i=0; i <= inl; i+=8) \ 67 inl -= bl; \
68 for(i=0; i <= inl; i+=bl) \
68 69
69#define BLOCK_CIPHER_func_ecb(cname, cprefix, kname) \ 70#define BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \
70static int cname##_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) \ 71static int cname##_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) \
71{\ 72{\
72 BLOCK_CIPHER_ecb_loop() \ 73 BLOCK_CIPHER_ecb_loop() \
73 cprefix##_ecb_encrypt(in + i, out + i, &ctx->c.kname, ctx->encrypt);\ 74 cprefix##_ecb_encrypt(in + i, out + i, &((kstruct *)ctx->cipher_data)->ksched, ctx->encrypt);\
74 return 1;\ 75 return 1;\
75} 76}
76 77
77#define BLOCK_CIPHER_func_ofb(cname, cprefix, kname) \ 78#define BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched) \
78static int cname##_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) \ 79static int cname##_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) \
79{\ 80{\
80 cprefix##_ofb64_encrypt(in, out, (long)inl, &ctx->c.kname, ctx->iv, &ctx->num);\ 81 cprefix##_ofb##cbits##_encrypt(in, out, (long)inl, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, &ctx->num);\
81 return 1;\ 82 return 1;\
82} 83}
83 84
84#define BLOCK_CIPHER_func_cbc(cname, cprefix, kname) \ 85#define BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \
85static int cname##_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) \ 86static int cname##_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) \
86{\ 87{\
87 cprefix##_cbc_encrypt(in, out, (long)inl, &ctx->c.kname, ctx->iv, ctx->encrypt);\ 88 cprefix##_cbc_encrypt(in, out, (long)inl, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, ctx->encrypt);\
88 return 1;\ 89 return 1;\
89} 90}
90 91
91#define BLOCK_CIPHER_func_cfb(cname, cprefix, kname) \ 92#define BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \
92static int cname##_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) \ 93static int cname##_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) \
93{\ 94{\
94 cprefix##_cfb64_encrypt(in, out, (long)inl, &ctx->c.kname, ctx->iv, &ctx->num, ctx->encrypt);\ 95 cprefix##_cfb##cbits##_encrypt(in, out, (long)inl, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, &ctx->num, ctx->encrypt);\
95 return 1;\ 96 return 1;\
96} 97}
97 98
98#define BLOCK_CIPHER_all_funcs(cname, cprefix, kname) \ 99#define BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \
99 BLOCK_CIPHER_func_cbc(cname, cprefix, kname) \ 100 BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \
100 BLOCK_CIPHER_func_cfb(cname, cprefix, kname) \ 101 BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \
101 BLOCK_CIPHER_func_ecb(cname, cprefix, kname) \ 102 BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \
102 BLOCK_CIPHER_func_ofb(cname, cprefix, kname) 103 BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched)
103 104
105#define BLOCK_CIPHER_def1(cname, nmode, mode, MODE, kstruct, nid, block_size, \
106 key_len, iv_len, flags, init_key, cleanup, \
107 set_asn1, get_asn1, ctrl) \
108static const EVP_CIPHER cname##_##mode = { \
109 nid##_##nmode, block_size, key_len, iv_len, \
110 flags | EVP_CIPH_##MODE##_MODE, \
111 init_key, \
112 cname##_##mode##_cipher, \
113 cleanup, \
114 sizeof(kstruct), \
115 set_asn1, get_asn1,\
116 ctrl, \
117 NULL \
118}; \
119const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
120
121#define BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, \
122 iv_len, flags, init_key, cleanup, set_asn1, \
123 get_asn1, ctrl) \
124BLOCK_CIPHER_def1(cname, cbc, cbc, CBC, kstruct, nid, block_size, key_len, \
125 iv_len, flags, init_key, cleanup, set_asn1, get_asn1, ctrl)
126
127#define BLOCK_CIPHER_def_cfb(cname, kstruct, nid, block_size, key_len, \
128 iv_len, cbits, flags, init_key, cleanup, \
129 set_asn1, get_asn1, ctrl) \
130BLOCK_CIPHER_def1(cname, cfb##cbits, cfb, CFB, kstruct, nid, block_size, \
131 key_len, iv_len, flags, init_key, cleanup, set_asn1, \
132 get_asn1, ctrl)
133
134#define BLOCK_CIPHER_def_ofb(cname, kstruct, nid, block_size, key_len, \
135 iv_len, cbits, flags, init_key, cleanup, \
136 set_asn1, get_asn1, ctrl) \
137BLOCK_CIPHER_def1(cname, ofb##cbits, ofb, OFB, kstruct, nid, block_size, \
138 key_len, iv_len, flags, init_key, cleanup, set_asn1, \
139 get_asn1, ctrl)
140
141#define BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, \
142 iv_len, flags, init_key, cleanup, set_asn1, \
143 get_asn1, ctrl) \
144BLOCK_CIPHER_def1(cname, ecb, ecb, ECB, kstruct, nid, block_size, key_len, \
145 iv_len, flags, init_key, cleanup, set_asn1, get_asn1, ctrl)
146
147#define BLOCK_CIPHER_defs(cname, kstruct, \
148 nid, block_size, key_len, iv_len, cbits, flags, \
149 init_key, cleanup, set_asn1, get_asn1, ctrl) \
150BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, iv_len, flags, \
151 init_key, cleanup, set_asn1, get_asn1, ctrl) \
152BLOCK_CIPHER_def_cfb(cname, kstruct, nid, block_size, key_len, iv_len, cbits, \
153 flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \
154BLOCK_CIPHER_def_ofb(cname, kstruct, nid, block_size, key_len, iv_len, cbits, \
155 flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \
156BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, iv_len, flags, \
157 init_key, cleanup, set_asn1, get_asn1, ctrl)
158
159
160/*
104#define BLOCK_CIPHER_defs(cname, kstruct, \ 161#define BLOCK_CIPHER_defs(cname, kstruct, \
105 nid, block_size, key_len, iv_len, flags,\ 162 nid, block_size, key_len, iv_len, flags,\
106 init_key, cleanup, set_asn1, get_asn1, ctrl)\ 163 init_key, cleanup, set_asn1, get_asn1, ctrl)\
107static EVP_CIPHER cname##_cbc = {\ 164static const EVP_CIPHER cname##_cbc = {\
108 nid##_cbc, block_size, key_len, iv_len, \ 165 nid##_cbc, block_size, key_len, iv_len, \
109 flags | EVP_CIPH_CBC_MODE,\ 166 flags | EVP_CIPH_CBC_MODE,\
110 init_key,\ 167 init_key,\
@@ -116,8 +173,8 @@ static EVP_CIPHER cname##_cbc = {\
116 ctrl, \ 173 ctrl, \
117 NULL \ 174 NULL \
118};\ 175};\
119EVP_CIPHER *EVP_##cname##_cbc(void) { return &cname##_cbc; }\ 176const EVP_CIPHER *EVP_##cname##_cbc(void) { return &cname##_cbc; }\
120static EVP_CIPHER cname##_cfb = {\ 177static const EVP_CIPHER cname##_cfb = {\
121 nid##_cfb64, 1, key_len, iv_len, \ 178 nid##_cfb64, 1, key_len, iv_len, \
122 flags | EVP_CIPH_CFB_MODE,\ 179 flags | EVP_CIPH_CFB_MODE,\
123 init_key,\ 180 init_key,\
@@ -129,8 +186,8 @@ static EVP_CIPHER cname##_cfb = {\
129 ctrl,\ 186 ctrl,\
130 NULL \ 187 NULL \
131};\ 188};\
132EVP_CIPHER *EVP_##cname##_cfb(void) { return &cname##_cfb; }\ 189const EVP_CIPHER *EVP_##cname##_cfb(void) { return &cname##_cfb; }\
133static EVP_CIPHER cname##_ofb = {\ 190static const EVP_CIPHER cname##_ofb = {\
134 nid##_ofb64, 1, key_len, iv_len, \ 191 nid##_ofb64, 1, key_len, iv_len, \
135 flags | EVP_CIPH_OFB_MODE,\ 192 flags | EVP_CIPH_OFB_MODE,\
136 init_key,\ 193 init_key,\
@@ -142,8 +199,8 @@ static EVP_CIPHER cname##_ofb = {\
142 ctrl,\ 199 ctrl,\
143 NULL \ 200 NULL \
144};\ 201};\
145EVP_CIPHER *EVP_##cname##_ofb(void) { return &cname##_ofb; }\ 202const EVP_CIPHER *EVP_##cname##_ofb(void) { return &cname##_ofb; }\
146static EVP_CIPHER cname##_ecb = {\ 203static const EVP_CIPHER cname##_ecb = {\
147 nid##_ecb, block_size, key_len, iv_len, \ 204 nid##_ecb, block_size, key_len, iv_len, \
148 flags | EVP_CIPH_ECB_MODE,\ 205 flags | EVP_CIPH_ECB_MODE,\
149 init_key,\ 206 init_key,\
@@ -155,14 +212,16 @@ static EVP_CIPHER cname##_ecb = {\
155 ctrl,\ 212 ctrl,\
156 NULL \ 213 NULL \
157};\ 214};\
158EVP_CIPHER *EVP_##cname##_ecb(void) { return &cname##_ecb; } 215const EVP_CIPHER *EVP_##cname##_ecb(void) { return &cname##_ecb; }
159 216*/
160
161 217
162#define IMPLEMENT_BLOCK_CIPHER(cname, kname, cprefix, kstruct, \ 218#define IMPLEMENT_BLOCK_CIPHER(cname, ksched, cprefix, kstruct, nid, \
163 nid, block_size, key_len, iv_len, flags, \ 219 block_size, key_len, iv_len, cbits, \
164 init_key, cleanup, set_asn1, get_asn1, ctrl) \ 220 flags, init_key, \
165 BLOCK_CIPHER_all_funcs(cname, cprefix, kname) \ 221 cleanup, set_asn1, get_asn1, ctrl) \
166 BLOCK_CIPHER_defs(cname, kstruct, nid, block_size, key_len, iv_len, flags,\ 222 BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \
167 init_key, cleanup, set_asn1, get_asn1, ctrl) 223 BLOCK_CIPHER_defs(cname, kstruct, nid, block_size, key_len, iv_len, \
224 cbits, flags, init_key, cleanup, set_asn1, \
225 get_asn1, ctrl)
168 226
227#define EVP_C_DATA(kstruct, ctx) ((kstruct *)(ctx)->cipher_data)
diff --git a/src/lib/libcrypto/evp/evp_pbe.c b/src/lib/libcrypto/evp/evp_pbe.c
index 224a422b12..06afb9d152 100644
--- a/src/lib/libcrypto/evp/evp_pbe.c
+++ b/src/lib/libcrypto/evp/evp_pbe.c
@@ -69,8 +69,8 @@ static STACK *pbe_algs;
69 69
70typedef struct { 70typedef struct {
71int pbe_nid; 71int pbe_nid;
72EVP_CIPHER *cipher; 72const EVP_CIPHER *cipher;
73EVP_MD *md; 73const EVP_MD *md;
74EVP_PBE_KEYGEN *keygen; 74EVP_PBE_KEYGEN *keygen;
75} EVP_PBE_CTL; 75} EVP_PBE_CTL;
76 76
@@ -112,7 +112,7 @@ static int pbe_cmp(const char * const *a, const char * const *b)
112 112
113/* Add a PBE algorithm */ 113/* Add a PBE algorithm */
114 114
115int EVP_PBE_alg_add (int nid, EVP_CIPHER *cipher, EVP_MD *md, 115int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md,
116 EVP_PBE_KEYGEN *keygen) 116 EVP_PBE_KEYGEN *keygen)
117{ 117{
118 EVP_PBE_CTL *pbe_tmp; 118 EVP_PBE_CTL *pbe_tmp;
diff --git a/src/lib/libcrypto/evp/evp_pkey.c b/src/lib/libcrypto/evp/evp_pkey.c
index 8df2874f3c..34b5b1d21c 100644
--- a/src/lib/libcrypto/evp/evp_pkey.c
+++ b/src/lib/libcrypto/evp/evp_pkey.c
@@ -62,17 +62,19 @@
62#include <openssl/x509.h> 62#include <openssl/x509.h>
63#include <openssl/rand.h> 63#include <openssl/rand.h>
64 64
65#ifndef OPENSSL_NO_DSA
65static int dsa_pkey2pkcs8(PKCS8_PRIV_KEY_INFO *p8inf, EVP_PKEY *pkey); 66static int dsa_pkey2pkcs8(PKCS8_PRIV_KEY_INFO *p8inf, EVP_PKEY *pkey);
67#endif
66 68
67/* Extract a private key from a PKCS8 structure */ 69/* Extract a private key from a PKCS8 structure */
68 70
69EVP_PKEY *EVP_PKCS82PKEY (PKCS8_PRIV_KEY_INFO *p8) 71EVP_PKEY *EVP_PKCS82PKEY (PKCS8_PRIV_KEY_INFO *p8)
70{ 72{
71 EVP_PKEY *pkey = NULL; 73 EVP_PKEY *pkey = NULL;
72#ifndef NO_RSA 74#ifndef OPENSSL_NO_RSA
73 RSA *rsa = NULL; 75 RSA *rsa = NULL;
74#endif 76#endif
75#ifndef NO_DSA 77#ifndef OPENSSL_NO_DSA
76 DSA *dsa = NULL; 78 DSA *dsa = NULL;
77 ASN1_INTEGER *privkey; 79 ASN1_INTEGER *privkey;
78 ASN1_TYPE *t1, *t2, *param = NULL; 80 ASN1_TYPE *t1, *t2, *param = NULL;
@@ -82,6 +84,7 @@ EVP_PKEY *EVP_PKCS82PKEY (PKCS8_PRIV_KEY_INFO *p8)
82#endif 84#endif
83 X509_ALGOR *a; 85 X509_ALGOR *a;
84 unsigned char *p; 86 unsigned char *p;
87 const unsigned char *cp;
85 int pkeylen; 88 int pkeylen;
86 char obj_tmp[80]; 89 char obj_tmp[80];
87 90
@@ -101,16 +104,17 @@ EVP_PKEY *EVP_PKCS82PKEY (PKCS8_PRIV_KEY_INFO *p8)
101 a = p8->pkeyalg; 104 a = p8->pkeyalg;
102 switch (OBJ_obj2nid(a->algorithm)) 105 switch (OBJ_obj2nid(a->algorithm))
103 { 106 {
104#ifndef NO_RSA 107#ifndef OPENSSL_NO_RSA
105 case NID_rsaEncryption: 108 case NID_rsaEncryption:
106 if (!(rsa = d2i_RSAPrivateKey (NULL, &p, pkeylen))) { 109 cp = p;
110 if (!(rsa = d2i_RSAPrivateKey (NULL,&cp, pkeylen))) {
107 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR); 111 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR);
108 return NULL; 112 return NULL;
109 } 113 }
110 EVP_PKEY_assign_RSA (pkey, rsa); 114 EVP_PKEY_assign_RSA (pkey, rsa);
111 break; 115 break;
112#endif 116#endif
113#ifndef NO_DSA 117#ifndef OPENSSL_NO_DSA
114 case NID_dsa: 118 case NID_dsa:
115 /* PKCS#8 DSA is weird: you just get a private key integer 119 /* PKCS#8 DSA is weird: you just get a private key integer
116 * and parameters in the AlgorithmIdentifier the pubkey must 120 * and parameters in the AlgorithmIdentifier the pubkey must
@@ -163,9 +167,9 @@ EVP_PKEY *EVP_PKCS82PKEY (PKCS8_PRIV_KEY_INFO *p8)
163 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR); 167 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR);
164 goto dsaerr; 168 goto dsaerr;
165 } 169 }
166 p = param->value.sequence->data; 170 cp = p = param->value.sequence->data;
167 plen = param->value.sequence->length; 171 plen = param->value.sequence->length;
168 if (!(dsa = d2i_DSAparams (NULL, &p, plen))) { 172 if (!(dsa = d2i_DSAparams (NULL, &cp, plen))) {
169 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR); 173 EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR);
170 goto dsaerr; 174 goto dsaerr;
171 } 175 }
@@ -239,7 +243,7 @@ PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8_broken(EVP_PKEY *pkey, int broken)
239 } 243 }
240 p8->pkey->type = V_ASN1_OCTET_STRING; 244 p8->pkey->type = V_ASN1_OCTET_STRING;
241 switch (EVP_PKEY_type(pkey->type)) { 245 switch (EVP_PKEY_type(pkey->type)) {
242#ifndef NO_RSA 246#ifndef OPENSSL_NO_RSA
243 case EVP_PKEY_RSA: 247 case EVP_PKEY_RSA:
244 248
245 if(p8->broken == PKCS8_NO_OCTET) p8->pkey->type = V_ASN1_SEQUENCE; 249 if(p8->broken == PKCS8_NO_OCTET) p8->pkey->type = V_ASN1_SEQUENCE;
@@ -254,7 +258,7 @@ PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8_broken(EVP_PKEY *pkey, int broken)
254 } 258 }
255 break; 259 break;
256#endif 260#endif
257#ifndef NO_DSA 261#ifndef OPENSSL_NO_DSA
258 case EVP_PKEY_DSA: 262 case EVP_PKEY_DSA:
259 if(!dsa_pkey2pkcs8(p8, pkey)) { 263 if(!dsa_pkey2pkcs8(p8, pkey)) {
260 PKCS8_PRIV_KEY_INFO_free (p8); 264 PKCS8_PRIV_KEY_INFO_free (p8);
@@ -296,7 +300,7 @@ PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken)
296 } 300 }
297} 301}
298 302
299#ifndef NO_DSA 303#ifndef OPENSSL_NO_DSA
300static int dsa_pkey2pkcs8(PKCS8_PRIV_KEY_INFO *p8, EVP_PKEY *pkey) 304static int dsa_pkey2pkcs8(PKCS8_PRIV_KEY_INFO *p8, EVP_PKEY *pkey)
301{ 305{
302 ASN1_STRING *params; 306 ASN1_STRING *params;
diff --git a/src/lib/libcrypto/evp/evp_test.c b/src/lib/libcrypto/evp/evp_test.c
new file mode 100644
index 0000000000..3607fe7776
--- /dev/null
+++ b/src/lib/libcrypto/evp/evp_test.c
@@ -0,0 +1,365 @@
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((char **)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 {
128 EVP_CIPHER_CTX ctx;
129 unsigned char out[4096];
130 int outl,outl2;
131
132 printf("Testing cipher %s\n",EVP_CIPHER_name(c));
133 hexdump(stdout,"Key",key,kn);
134 if(in)
135 hexdump(stdout,"IV",iv,in);
136 hexdump(stdout,"Plaintext",plaintext,pn);
137 hexdump(stdout,"Ciphertext",ciphertext,cn);
138
139 if(kn != c->key_len)
140 {
141 fprintf(stderr,"Key length doesn't match, got %d expected %d\n",kn,
142 c->key_len);
143 exit(5);
144 }
145 EVP_CIPHER_CTX_init(&ctx);
146 if(!EVP_EncryptInit_ex(&ctx,c,NULL,key,iv))
147 {
148 fprintf(stderr,"EncryptInit failed\n");
149 exit(10);
150 }
151 EVP_CIPHER_CTX_set_padding(&ctx,0);
152
153 if(!EVP_EncryptUpdate(&ctx,out,&outl,plaintext,pn))
154 {
155 fprintf(stderr,"Encrypt failed\n");
156 exit(6);
157 }
158 if(!EVP_EncryptFinal_ex(&ctx,out+outl,&outl2))
159 {
160 fprintf(stderr,"EncryptFinal failed\n");
161 exit(7);
162 }
163
164 if(outl+outl2 != cn)
165 {
166 fprintf(stderr,"Ciphertext length mismatch got %d expected %d\n",
167 outl+outl2,cn);
168 exit(8);
169 }
170
171 if(memcmp(out,ciphertext,cn))
172 {
173 fprintf(stderr,"Ciphertext mismatch\n");
174 hexdump(stderr,"Got",out,cn);
175 hexdump(stderr,"Expected",ciphertext,cn);
176 exit(9);
177 }
178
179 if(!EVP_DecryptInit_ex(&ctx,c,NULL,key,iv))
180 {
181 fprintf(stderr,"DecryptInit failed\n");
182 exit(11);
183 }
184 EVP_CIPHER_CTX_set_padding(&ctx,0);
185
186 if(!EVP_DecryptUpdate(&ctx,out,&outl,ciphertext,pn))
187 {
188 fprintf(stderr,"Decrypt failed\n");
189 exit(6);
190 }
191 if(!EVP_DecryptFinal_ex(&ctx,out+outl,&outl2))
192 {
193 fprintf(stderr,"DecryptFinal failed\n");
194 exit(7);
195 }
196
197 if(outl+outl2 != cn)
198 {
199 fprintf(stderr,"Plaintext length mismatch got %d expected %d\n",
200 outl+outl2,cn);
201 exit(8);
202 }
203
204 if(memcmp(out,plaintext,cn))
205 {
206 fprintf(stderr,"Plaintext mismatch\n");
207 hexdump(stderr,"Got",out,cn);
208 hexdump(stderr,"Expected",plaintext,cn);
209 exit(9);
210 }
211
212 printf("\n");
213 }
214
215static int test_cipher(const char *cipher,const unsigned char *key,int kn,
216 const unsigned char *iv,int in,
217 const unsigned char *plaintext,int pn,
218 const unsigned char *ciphertext,int cn)
219 {
220 const EVP_CIPHER *c;
221
222 c=EVP_get_cipherbyname(cipher);
223 if(!c)
224 return 0;
225
226 test1(c,key,kn,iv,in,plaintext,pn,ciphertext,cn);
227
228 return 1;
229 }
230
231static int test_digest(const char *digest,
232 const unsigned char *plaintext,int pn,
233 const unsigned char *ciphertext, unsigned int cn)
234 {
235 const EVP_MD *d;
236 EVP_MD_CTX ctx;
237 unsigned char md[EVP_MAX_MD_SIZE];
238 unsigned int mdn;
239
240 d=EVP_get_digestbyname(digest);
241 if(!d)
242 return 0;
243
244 printf("Testing digest %s\n",EVP_MD_name(d));
245 hexdump(stdout,"Plaintext",plaintext,pn);
246 hexdump(stdout,"Digest",ciphertext,cn);
247
248 EVP_MD_CTX_init(&ctx);
249 if(!EVP_DigestInit_ex(&ctx,d, NULL))
250 {
251 fprintf(stderr,"DigestInit failed\n");
252 exit(100);
253 }
254 if(!EVP_DigestUpdate(&ctx,plaintext,pn))
255 {
256 fprintf(stderr,"DigestUpdate failed\n");
257 exit(101);
258 }
259 if(!EVP_DigestFinal_ex(&ctx,md,&mdn))
260 {
261 fprintf(stderr,"DigestFinal failed\n");
262 exit(101);
263 }
264 EVP_MD_CTX_cleanup(&ctx);
265
266 if(mdn != cn)
267 {
268 fprintf(stderr,"Digest length mismatch, got %d expected %d\n",mdn,cn);
269 exit(102);
270 }
271
272 if(memcmp(md,ciphertext,cn))
273 {
274 fprintf(stderr,"Digest mismatch\n");
275 hexdump(stderr,"Got",md,cn);
276 hexdump(stderr,"Expected",ciphertext,cn);
277 exit(103);
278 }
279
280 printf("\n");
281
282 return 1;
283 }
284
285int main(int argc,char **argv)
286 {
287 const char *szTestFile;
288 FILE *f;
289
290 if(argc != 2)
291 {
292 fprintf(stderr,"%s <test file>\n",argv[0]);
293 exit(1);
294 }
295 CRYPTO_malloc_debug_init();
296 CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
297 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
298
299 szTestFile=argv[1];
300
301 f=fopen(szTestFile,"r");
302 if(!f)
303 {
304 perror(szTestFile);
305 exit(2);
306 }
307
308 /* Load up the software EVP_CIPHER and EVP_MD definitions */
309 OpenSSL_add_all_ciphers();
310 OpenSSL_add_all_digests();
311 /* Load all compiled-in ENGINEs */
312 ENGINE_load_builtin_engines();
313#if 0
314 OPENSSL_config();
315#endif
316 /* Register all available ENGINE implementations of ciphers and digests.
317 * This could perhaps be changed to "ENGINE_register_all_complete()"? */
318 ENGINE_register_all_ciphers();
319 ENGINE_register_all_digests();
320 /* If we add command-line options, this statement should be switchable.
321 * It'll prevent ENGINEs being ENGINE_init()ialised for cipher/digest use if
322 * they weren't already initialised. */
323 /* ENGINE_set_cipher_flags(ENGINE_CIPHER_FLAG_NOINIT); */
324
325 for( ; ; )
326 {
327 char line[4096];
328 char *p;
329 char *cipher;
330 unsigned char *iv,*key,*plaintext,*ciphertext;
331 int kn,in,pn,cn;
332
333 if(!fgets((char *)line,sizeof line,f))
334 break;
335 if(line[0] == '#' || line[0] == '\n')
336 continue;
337 p=line;
338 cipher=sstrsep(&p,":");
339 key=ustrsep(&p,":");
340 iv=ustrsep(&p,":");
341 plaintext=ustrsep(&p,":");
342 ciphertext=ustrsep(&p,"\n");
343
344 kn=convert(key);
345 in=convert(iv);
346 pn=convert(plaintext);
347 cn=convert(ciphertext);
348
349 if(!test_cipher(cipher,key,kn,iv,in,plaintext,pn,ciphertext,cn)
350 && !test_digest(cipher,plaintext,pn,ciphertext,cn))
351 {
352 fprintf(stderr,"Can't find %s\n",cipher);
353 exit(3);
354 }
355 }
356
357 ENGINE_cleanup();
358 EVP_cleanup();
359 CRYPTO_cleanup_all_ex_data();
360 ERR_remove_state(0);
361 ERR_free_strings();
362 CRYPTO_mem_leaks_fp(stderr);
363
364 return 0;
365 }
diff --git a/src/lib/libcrypto/evp/evptests.txt b/src/lib/libcrypto/evp/evptests.txt
new file mode 100644
index 0000000000..6c1529db37
--- /dev/null
+++ b/src/lib/libcrypto/evp/evptests.txt
@@ -0,0 +1,82 @@
1#cipher:key:iv:input:output
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
19
20# AES 192 ECB tests (from FIPS-197 test vectors, encrypt)
21
22AES-192-ECB:000102030405060708090A0B0C0D0E0F1011121314151617::00112233445566778899AABBCCDDEEFF:DDA97CA4864CDFE06EAF70A0EC0D7191
23
24# AES 256 ECB tests (from FIPS-197 test vectors, encrypt)
25
26AES-256-ECB:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F::00112233445566778899AABBCCDDEEFF:8EA2B7CA516745BFEAFC49904B496089
27
28# AES 128 ECB tests (from NIST test vectors, encrypt)
29
30#AES-128-ECB:00000000000000000000000000000000::00000000000000000000000000000000:C34C052CC0DA8D73451AFE5F03BE297F
31
32# AES 128 ECB tests (from NIST test vectors, decrypt)
33
34#AES-128-ECB:00000000000000000000000000000000::44416AC2D1F53C583303917E6BE9EBE0:00000000000000000000000000000000
35
36# AES 192 ECB tests (from NIST test vectors, decrypt)
37
38#AES-192-ECB:000000000000000000000000000000000000000000000000::48E31E9E256718F29229319C19F15BA4:00000000000000000000000000000000
39
40# AES 256 ECB tests (from NIST test vectors, decrypt)
41
42#AES-256-ECB:0000000000000000000000000000000000000000000000000000000000000000::058CCFFDBBCB382D1F6F56585D8A4ADE:00000000000000000000000000000000
43
44# AES 128 CBC tests (from NIST test vectors, encrypt)
45
46#AES-128-CBC:00000000000000000000000000000000:00000000000000000000000000000000:00000000000000000000000000000000:8A05FC5E095AF4848A08D328D3688E3D
47
48# AES 192 CBC tests (from NIST test vectors, encrypt)
49
50#AES-192-CBC:000000000000000000000000000000000000000000000000:00000000000000000000000000000000:00000000000000000000000000000000:7BD966D53AD8C1BB85D2ADFAE87BB104
51
52# AES 256 CBC tests (from NIST test vectors, encrypt)
53
54#AES-256-CBC:0000000000000000000000000000000000000000000000000000000000000000:00000000000000000000000000000000:00000000000000000000000000000000:FE3C53653E2F45B56FCD88B2CC898FF0
55
56# AES 128 CBC tests (from NIST test vectors, decrypt)
57
58#AES-128-CBC:00000000000000000000000000000000:00000000000000000000000000000000:FACA37E0B0C85373DF706E73F7C9AF86:00000000000000000000000000000000
59
60# DES ECB tests (from destest)
61
62DES-ECB:0000000000000000::0000000000000000:8CA64DE9C1B123A7
63DES-ECB:FFFFFFFFFFFFFFFF::FFFFFFFFFFFFFFFF:7359B2163E4EDC58
64DES-ECB:3000000000000000::1000000000000001:958E6E627A05557B
65DES-ECB:1111111111111111::1111111111111111:F40379AB9E0EC533
66DES-ECB:0123456789ABCDEF::1111111111111111:17668DFC7292532D
67DES-ECB:1111111111111111::0123456789ABCDEF:8A5AE1F81AB8F2DD
68DES-ECB:FEDCBA9876543210::0123456789ABCDEF:ED39D950FA74BCC4
69
70# DESX-CBC tests (from destest)
71DESX-CBC:0123456789abcdeff1e0d3c2b5a49786fedcba9876543210:fedcba9876543210:37363534333231204E6F77206973207468652074696D6520666F722000000000:846B2914851E9A2954732F8AA0A611C115CDC2D7951B1053A63C5E03B21AA3C4
72
73# DES EDE3 CBC tests (from destest)
74DES-EDE3-CBC:0123456789abcdeff1e0d3c2b5a49786fedcba9876543210:fedcba9876543210:37363534333231204E6F77206973207468652074696D6520666F722000000000:3FE301C962AC01D02213763C1CBD4CDC799657C064ECF5D41C673812CFDE9675
75
76# RC4 tests (from rc4test)
77RC4:0123456789abcdef0123456789abcdef::0123456789abcdef:75b7878099e0c596
78RC4:0123456789abcdef0123456789abcdef::0000000000000000:7494c2e7104b0879
79RC4:00000000000000000000000000000000::0000000000000000:de188941a3375d3a
80RC4:ef012345ef012345ef012345ef012345::0000000000000000000000000000000000000000:d6a141a7ec3c38dfbd615a1162e1c7ba36b67858
81RC4:0123456789abcdef0123456789abcdef::123456789ABCDEF0123456789ABCDEF0123456789ABCDEF012345678:66a0949f8af7d6891f7f832ba833c00c892ebe30143ce28740011ecf
82RC4:ef012345ef012345ef012345ef012345::00000000000000000000:d6a141a7ec3c38dfbd61
diff --git a/src/lib/libcrypto/evp/m_dss.c b/src/lib/libcrypto/evp/m_dss.c
index 8ea826868e..beb8d7fc5c 100644
--- a/src/lib/libcrypto/evp/m_dss.c
+++ b/src/lib/libcrypto/evp/m_dss.c
@@ -62,21 +62,33 @@
62#include <openssl/objects.h> 62#include <openssl/objects.h>
63#include <openssl/x509.h> 63#include <openssl/x509.h>
64 64
65#ifndef NO_SHA 65#ifndef OPENSSL_NO_SHA
66static EVP_MD dsa_md= 66static int init(EVP_MD_CTX *ctx)
67 { return SHA1_Init(ctx->md_data); }
68
69static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count)
70 { return SHA1_Update(ctx->md_data,data,count); }
71
72static int final(EVP_MD_CTX *ctx,unsigned char *md)
73 { return SHA1_Final(md,ctx->md_data); }
74
75static const EVP_MD dsa_md=
67 { 76 {
68 NID_dsaWithSHA, 77 NID_dsaWithSHA,
69 NID_dsaWithSHA, 78 NID_dsaWithSHA,
70 SHA_DIGEST_LENGTH, 79 SHA_DIGEST_LENGTH,
71 SHA1_Init, 80 0,
72 SHA1_Update, 81 init,
73 SHA1_Final, 82 update,
83 final,
84 NULL,
85 NULL,
74 EVP_PKEY_DSA_method, 86 EVP_PKEY_DSA_method,
75 SHA_CBLOCK, 87 SHA_CBLOCK,
76 sizeof(EVP_MD *)+sizeof(SHA_CTX), 88 sizeof(EVP_MD *)+sizeof(SHA_CTX),
77 }; 89 };
78 90
79EVP_MD *EVP_dss(void) 91const EVP_MD *EVP_dss(void)
80 { 92 {
81 return(&dsa_md); 93 return(&dsa_md);
82 } 94 }
diff --git a/src/lib/libcrypto/evp/m_dss1.c b/src/lib/libcrypto/evp/m_dss1.c
index 9d8d1ce23e..f5668ebda0 100644
--- a/src/lib/libcrypto/evp/m_dss1.c
+++ b/src/lib/libcrypto/evp/m_dss1.c
@@ -56,27 +56,39 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_SHA 59#ifndef OPENSSL_NO_SHA
60#include <stdio.h> 60#include <stdio.h>
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/evp.h> 62#include <openssl/evp.h>
63#include <openssl/objects.h> 63#include <openssl/objects.h>
64#include <openssl/x509.h> 64#include <openssl/x509.h>
65 65
66static EVP_MD dss1_md= 66static int init(EVP_MD_CTX *ctx)
67 { return SHA1_Init(ctx->md_data); }
68
69static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count)
70 { return SHA1_Update(ctx->md_data,data,count); }
71
72static int final(EVP_MD_CTX *ctx,unsigned char *md)
73 { return SHA1_Final(md,ctx->md_data); }
74
75static const EVP_MD dss1_md=
67 { 76 {
68 NID_dsa, 77 NID_dsa,
69 NID_dsaWithSHA1, 78 NID_dsaWithSHA1,
70 SHA_DIGEST_LENGTH, 79 SHA_DIGEST_LENGTH,
71 SHA1_Init, 80 0,
72 SHA1_Update, 81 init,
73 SHA1_Final, 82 update,
83 final,
84 NULL,
85 NULL,
74 EVP_PKEY_DSA_method, 86 EVP_PKEY_DSA_method,
75 SHA_CBLOCK, 87 SHA_CBLOCK,
76 sizeof(EVP_MD *)+sizeof(SHA_CTX), 88 sizeof(EVP_MD *)+sizeof(SHA_CTX),
77 }; 89 };
78 90
79EVP_MD *EVP_dss1(void) 91const EVP_MD *EVP_dss1(void)
80 { 92 {
81 return(&dss1_md); 93 return(&dss1_md);
82 } 94 }
diff --git a/src/lib/libcrypto/evp/m_md2.c b/src/lib/libcrypto/evp/m_md2.c
index 3281e91809..50914c83b3 100644
--- a/src/lib/libcrypto/evp/m_md2.c
+++ b/src/lib/libcrypto/evp/m_md2.c
@@ -56,27 +56,40 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_MD2 59#ifndef OPENSSL_NO_MD2
60#include <stdio.h> 60#include <stdio.h>
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/evp.h> 62#include <openssl/evp.h>
63#include <openssl/objects.h> 63#include <openssl/objects.h>
64#include <openssl/x509.h> 64#include <openssl/x509.h>
65#include <openssl/md2.h>
65 66
66static EVP_MD md2_md= 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=
67 { 77 {
68 NID_md2, 78 NID_md2,
69 NID_md2WithRSAEncryption, 79 NID_md2WithRSAEncryption,
70 MD2_DIGEST_LENGTH, 80 MD2_DIGEST_LENGTH,
71 MD2_Init, 81 0,
72 MD2_Update, 82 init,
73 MD2_Final, 83 update,
84 final,
85 NULL,
86 NULL,
74 EVP_PKEY_RSA_method, 87 EVP_PKEY_RSA_method,
75 MD2_BLOCK, 88 MD2_BLOCK,
76 sizeof(EVP_MD *)+sizeof(MD2_CTX), 89 sizeof(EVP_MD *)+sizeof(MD2_CTX),
77 }; 90 };
78 91
79EVP_MD *EVP_md2(void) 92const EVP_MD *EVP_md2(void)
80 { 93 {
81 return(&md2_md); 94 return(&md2_md);
82 } 95 }
diff --git a/src/lib/libcrypto/evp/m_md4.c b/src/lib/libcrypto/evp/m_md4.c
index 6a24ceb86d..e19b663754 100644
--- a/src/lib/libcrypto/evp/m_md4.c
+++ b/src/lib/libcrypto/evp/m_md4.c
@@ -56,27 +56,40 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_MD4 59#ifndef OPENSSL_NO_MD4
60#include <stdio.h> 60#include <stdio.h>
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/evp.h> 62#include <openssl/evp.h>
63#include <openssl/objects.h> 63#include <openssl/objects.h>
64#include <openssl/x509.h> 64#include <openssl/x509.h>
65#include <openssl/md4.h>
65 66
66static EVP_MD md4_md= 67static int init(EVP_MD_CTX *ctx)
68 { return MD4_Init(ctx->md_data); }
69
70static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count)
71 { return MD4_Update(ctx->md_data,data,count); }
72
73static int final(EVP_MD_CTX *ctx,unsigned char *md)
74 { return MD4_Final(md,ctx->md_data); }
75
76static const EVP_MD md4_md=
67 { 77 {
68 NID_md4, 78 NID_md4,
69 0, 79 NID_md4WithRSAEncryption,
70 MD4_DIGEST_LENGTH, 80 MD4_DIGEST_LENGTH,
71 MD4_Init, 81 0,
72 MD4_Update, 82 init,
73 MD4_Final, 83 update,
84 final,
85 NULL,
86 NULL,
74 EVP_PKEY_RSA_method, 87 EVP_PKEY_RSA_method,
75 MD4_CBLOCK, 88 MD4_CBLOCK,
76 sizeof(EVP_MD *)+sizeof(MD4_CTX), 89 sizeof(EVP_MD *)+sizeof(MD4_CTX),
77 }; 90 };
78 91
79EVP_MD *EVP_md4(void) 92const EVP_MD *EVP_md4(void)
80 { 93 {
81 return(&md4_md); 94 return(&md4_md);
82 } 95 }
diff --git a/src/lib/libcrypto/evp/m_md5.c b/src/lib/libcrypto/evp/m_md5.c
index 9fc9530127..b00a03e048 100644
--- a/src/lib/libcrypto/evp/m_md5.c
+++ b/src/lib/libcrypto/evp/m_md5.c
@@ -56,27 +56,40 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_MD5 59#ifndef OPENSSL_NO_MD5
60#include <stdio.h> 60#include <stdio.h>
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/evp.h> 62#include <openssl/evp.h>
63#include <openssl/objects.h> 63#include <openssl/objects.h>
64#include <openssl/x509.h> 64#include <openssl/x509.h>
65#include <openssl/md5.h>
65 66
66static EVP_MD md5_md= 67static int init(EVP_MD_CTX *ctx)
68 { return MD5_Init(ctx->md_data); }
69
70static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count)
71 { return MD5_Update(ctx->md_data,data,count); }
72
73static int final(EVP_MD_CTX *ctx,unsigned char *md)
74 { return MD5_Final(md,ctx->md_data); }
75
76static const EVP_MD md5_md=
67 { 77 {
68 NID_md5, 78 NID_md5,
69 NID_md5WithRSAEncryption, 79 NID_md5WithRSAEncryption,
70 MD5_DIGEST_LENGTH, 80 MD5_DIGEST_LENGTH,
71 MD5_Init, 81 0,
72 MD5_Update, 82 init,
73 MD5_Final, 83 update,
84 final,
85 NULL,
86 NULL,
74 EVP_PKEY_RSA_method, 87 EVP_PKEY_RSA_method,
75 MD5_CBLOCK, 88 MD5_CBLOCK,
76 sizeof(EVP_MD *)+sizeof(MD5_CTX), 89 sizeof(EVP_MD *)+sizeof(MD5_CTX),
77 }; 90 };
78 91
79EVP_MD *EVP_md5(void) 92const EVP_MD *EVP_md5(void)
80 { 93 {
81 return(&md5_md); 94 return(&md5_md);
82 } 95 }
diff --git a/src/lib/libcrypto/evp/m_mdc2.c b/src/lib/libcrypto/evp/m_mdc2.c
index 2c7f1ae515..9f6467c931 100644
--- a/src/lib/libcrypto/evp/m_mdc2.c
+++ b/src/lib/libcrypto/evp/m_mdc2.c
@@ -56,27 +56,40 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_MDC2 59#ifndef OPENSSL_NO_MDC2
60#include <stdio.h> 60#include <stdio.h>
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/evp.h> 62#include <openssl/evp.h>
63#include <openssl/objects.h> 63#include <openssl/objects.h>
64#include <openssl/x509.h> 64#include <openssl/x509.h>
65#include <openssl/mdc2.h>
65 66
66static EVP_MD mdc2_md= 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=
67 { 77 {
68 NID_mdc2, 78 NID_mdc2,
69 NID_mdc2WithRSA, 79 NID_mdc2WithRSA,
70 MDC2_DIGEST_LENGTH, 80 MDC2_DIGEST_LENGTH,
71 MDC2_Init, 81 0,
72 MDC2_Update, 82 init,
73 MDC2_Final, 83 update,
84 final,
85 NULL,
86 NULL,
74 EVP_PKEY_RSA_ASN1_OCTET_STRING_method, 87 EVP_PKEY_RSA_ASN1_OCTET_STRING_method,
75 MDC2_BLOCK, 88 MDC2_BLOCK,
76 sizeof(EVP_MD *)+sizeof(MDC2_CTX), 89 sizeof(EVP_MD *)+sizeof(MDC2_CTX),
77 }; 90 };
78 91
79EVP_MD *EVP_mdc2(void) 92const EVP_MD *EVP_mdc2(void)
80 { 93 {
81 return(&mdc2_md); 94 return(&mdc2_md);
82 } 95 }
diff --git a/src/lib/libcrypto/evp/m_null.c b/src/lib/libcrypto/evp/m_null.c
index e2dadf3dab..f6f0a1d2c0 100644
--- a/src/lib/libcrypto/evp/m_null.c
+++ b/src/lib/libcrypto/evp/m_null.c
@@ -62,25 +62,32 @@
62#include <openssl/objects.h> 62#include <openssl/objects.h>
63#include <openssl/x509.h> 63#include <openssl/x509.h>
64 64
65static void function(void) 65static int init(EVP_MD_CTX *ctx)
66 { 66 { return 1; }
67 } 67
68static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count)
69 { return 1; }
68 70
69static EVP_MD null_md= 71static int final(EVP_MD_CTX *ctx,unsigned char *md)
72 { return 1; }
73
74static const EVP_MD null_md=
70 { 75 {
71 NID_undef, 76 NID_undef,
72 NID_undef, 77 NID_undef,
73 0, 78 0,
74 function, 79 0,
75 function, 80 init,
76 function, 81 update,
77 82 final,
83 NULL,
84 NULL,
78 EVP_PKEY_NULL_method, 85 EVP_PKEY_NULL_method,
79 0, 86 0,
80 sizeof(EVP_MD *), 87 sizeof(EVP_MD *),
81 }; 88 };
82 89
83EVP_MD *EVP_md_null(void) 90const EVP_MD *EVP_md_null(void)
84 { 91 {
85 return(&null_md); 92 return(&null_md);
86 } 93 }
diff --git a/src/lib/libcrypto/evp/m_ripemd.c b/src/lib/libcrypto/evp/m_ripemd.c
index 3d781a4e8d..64725528dc 100644
--- a/src/lib/libcrypto/evp/m_ripemd.c
+++ b/src/lib/libcrypto/evp/m_ripemd.c
@@ -56,7 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_RIPEMD 59#ifndef OPENSSL_NO_RIPEMD
60#include <stdio.h> 60#include <stdio.h>
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/ripemd.h> 62#include <openssl/ripemd.h>
@@ -64,20 +64,32 @@
64#include <openssl/objects.h> 64#include <openssl/objects.h>
65#include <openssl/x509.h> 65#include <openssl/x509.h>
66 66
67static EVP_MD ripemd160_md= 67static int init(EVP_MD_CTX *ctx)
68 { return RIPEMD160_Init(ctx->md_data); }
69
70static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count)
71 { return RIPEMD160_Update(ctx->md_data,data,count); }
72
73static int final(EVP_MD_CTX *ctx,unsigned char *md)
74 { return RIPEMD160_Final(md,ctx->md_data); }
75
76static const EVP_MD ripemd160_md=
68 { 77 {
69 NID_ripemd160, 78 NID_ripemd160,
70 NID_ripemd160WithRSA, 79 NID_ripemd160WithRSA,
71 RIPEMD160_DIGEST_LENGTH, 80 RIPEMD160_DIGEST_LENGTH,
72 RIPEMD160_Init, 81 0,
73 RIPEMD160_Update, 82 init,
74 RIPEMD160_Final, 83 update,
84 final,
85 NULL,
86 NULL,
75 EVP_PKEY_RSA_method, 87 EVP_PKEY_RSA_method,
76 RIPEMD160_CBLOCK, 88 RIPEMD160_CBLOCK,
77 sizeof(EVP_MD *)+sizeof(RIPEMD160_CTX), 89 sizeof(EVP_MD *)+sizeof(RIPEMD160_CTX),
78 }; 90 };
79 91
80EVP_MD *EVP_ripemd160(void) 92const EVP_MD *EVP_ripemd160(void)
81 { 93 {
82 return(&ripemd160_md); 94 return(&ripemd160_md);
83 } 95 }
diff --git a/src/lib/libcrypto/evp/m_sha.c b/src/lib/libcrypto/evp/m_sha.c
index 6d35b71b85..10697c7ed3 100644
--- a/src/lib/libcrypto/evp/m_sha.c
+++ b/src/lib/libcrypto/evp/m_sha.c
@@ -56,27 +56,39 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_SHA 59#ifndef OPENSSL_NO_SHA
60#include <stdio.h> 60#include <stdio.h>
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/evp.h> 62#include <openssl/evp.h>
63#include <openssl/objects.h> 63#include <openssl/objects.h>
64#include <openssl/x509.h> 64#include <openssl/x509.h>
65 65
66static EVP_MD sha_md= 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=
67 { 76 {
68 NID_sha, 77 NID_sha,
69 NID_shaWithRSAEncryption, 78 NID_shaWithRSAEncryption,
70 SHA_DIGEST_LENGTH, 79 SHA_DIGEST_LENGTH,
71 SHA_Init, 80 0,
72 SHA_Update, 81 init,
73 SHA_Final, 82 update,
83 final,
84 NULL,
85 NULL,
74 EVP_PKEY_RSA_method, 86 EVP_PKEY_RSA_method,
75 SHA_CBLOCK, 87 SHA_CBLOCK,
76 sizeof(EVP_MD *)+sizeof(SHA_CTX), 88 sizeof(EVP_MD *)+sizeof(SHA_CTX),
77 }; 89 };
78 90
79EVP_MD *EVP_sha(void) 91const EVP_MD *EVP_sha(void)
80 { 92 {
81 return(&sha_md); 93 return(&sha_md);
82 } 94 }
diff --git a/src/lib/libcrypto/evp/m_sha1.c b/src/lib/libcrypto/evp/m_sha1.c
index 57a1ab0cce..d6be3502f0 100644
--- a/src/lib/libcrypto/evp/m_sha1.c
+++ b/src/lib/libcrypto/evp/m_sha1.c
@@ -56,27 +56,39 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_SHA 59#ifndef OPENSSL_NO_SHA
60#include <stdio.h> 60#include <stdio.h>
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/evp.h> 62#include <openssl/evp.h>
63#include <openssl/objects.h> 63#include <openssl/objects.h>
64#include <openssl/x509.h> 64#include <openssl/x509.h>
65 65
66static EVP_MD sha1_md= 66static int init(EVP_MD_CTX *ctx)
67 { return SHA1_Init(ctx->md_data); }
68
69static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count)
70 { return SHA1_Update(ctx->md_data,data,count); }
71
72static int final(EVP_MD_CTX *ctx,unsigned char *md)
73 { return SHA1_Final(md,ctx->md_data); }
74
75static const EVP_MD sha1_md=
67 { 76 {
68 NID_sha1, 77 NID_sha1,
69 NID_sha1WithRSAEncryption, 78 NID_sha1WithRSAEncryption,
70 SHA_DIGEST_LENGTH, 79 SHA_DIGEST_LENGTH,
71 SHA1_Init, 80 0,
72 SHA1_Update, 81 init,
73 SHA1_Final, 82 update,
83 final,
84 NULL,
85 NULL,
74 EVP_PKEY_RSA_method, 86 EVP_PKEY_RSA_method,
75 SHA_CBLOCK, 87 SHA_CBLOCK,
76 sizeof(EVP_MD *)+sizeof(SHA_CTX), 88 sizeof(EVP_MD *)+sizeof(SHA_CTX),
77 }; 89 };
78 90
79EVP_MD *EVP_sha1(void) 91const EVP_MD *EVP_sha1(void)
80 { 92 {
81 return(&sha1_md); 93 return(&sha1_md);
82 } 94 }
diff --git a/src/lib/libcrypto/evp/names.c b/src/lib/libcrypto/evp/names.c
index 620f43feaa..eb9f4329cd 100644
--- a/src/lib/libcrypto/evp/names.c
+++ b/src/lib/libcrypto/evp/names.c
@@ -62,7 +62,7 @@
62#include <openssl/objects.h> 62#include <openssl/objects.h>
63#include <openssl/x509.h> 63#include <openssl/x509.h>
64 64
65int EVP_add_cipher(EVP_CIPHER *c) 65int EVP_add_cipher(const EVP_CIPHER *c)
66 { 66 {
67 int r; 67 int r;
68 68
@@ -72,7 +72,7 @@ int EVP_add_cipher(EVP_CIPHER *c)
72 return(r); 72 return(r);
73 } 73 }
74 74
75int EVP_add_digest(EVP_MD *md) 75int EVP_add_digest(const EVP_MD *md)
76 { 76 {
77 int r; 77 int r;
78 const char *name; 78 const char *name;
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 6bfa2c5acb..113c60fedb 100644
--- a/src/lib/libcrypto/evp/p5_crpt.c
+++ b/src/lib/libcrypto/evp/p5_crpt.c
@@ -67,41 +67,41 @@
67 67
68void PKCS5_PBE_add(void) 68void PKCS5_PBE_add(void)
69{ 69{
70#ifndef NO_DES 70#ifndef OPENSSL_NO_DES
71# ifndef NO_MD5 71# ifndef OPENSSL_NO_MD5
72EVP_PBE_alg_add(NID_pbeWithMD5AndDES_CBC, EVP_des_cbc(), EVP_md5(), 72EVP_PBE_alg_add(NID_pbeWithMD5AndDES_CBC, EVP_des_cbc(), EVP_md5(),
73 PKCS5_PBE_keyivgen); 73 PKCS5_PBE_keyivgen);
74# endif 74# endif
75# ifndef NO_MD2 75# ifndef OPENSSL_NO_MD2
76EVP_PBE_alg_add(NID_pbeWithMD2AndDES_CBC, EVP_des_cbc(), EVP_md2(), 76EVP_PBE_alg_add(NID_pbeWithMD2AndDES_CBC, EVP_des_cbc(), EVP_md2(),
77 PKCS5_PBE_keyivgen); 77 PKCS5_PBE_keyivgen);
78# endif 78# endif
79# ifndef NO_SHA 79# ifndef OPENSSL_NO_SHA
80EVP_PBE_alg_add(NID_pbeWithSHA1AndDES_CBC, EVP_des_cbc(), EVP_sha1(), 80EVP_PBE_alg_add(NID_pbeWithSHA1AndDES_CBC, EVP_des_cbc(), EVP_sha1(),
81 PKCS5_PBE_keyivgen); 81 PKCS5_PBE_keyivgen);
82# endif 82# endif
83#endif 83#endif
84#ifndef NO_RC2 84#ifndef OPENSSL_NO_RC2
85# ifndef NO_MD5 85# ifndef OPENSSL_NO_MD5
86EVP_PBE_alg_add(NID_pbeWithMD5AndRC2_CBC, EVP_rc2_64_cbc(), EVP_md5(), 86EVP_PBE_alg_add(NID_pbeWithMD5AndRC2_CBC, EVP_rc2_64_cbc(), EVP_md5(),
87 PKCS5_PBE_keyivgen); 87 PKCS5_PBE_keyivgen);
88# endif 88# endif
89# ifndef NO_MD2 89# ifndef OPENSSL_NO_MD2
90EVP_PBE_alg_add(NID_pbeWithMD2AndRC2_CBC, EVP_rc2_64_cbc(), EVP_md2(), 90EVP_PBE_alg_add(NID_pbeWithMD2AndRC2_CBC, EVP_rc2_64_cbc(), EVP_md2(),
91 PKCS5_PBE_keyivgen); 91 PKCS5_PBE_keyivgen);
92# endif 92# endif
93# ifndef NO_SHA 93# ifndef OPENSSL_NO_SHA
94EVP_PBE_alg_add(NID_pbeWithSHA1AndRC2_CBC, EVP_rc2_64_cbc(), EVP_sha1(), 94EVP_PBE_alg_add(NID_pbeWithSHA1AndRC2_CBC, EVP_rc2_64_cbc(), EVP_sha1(),
95 PKCS5_PBE_keyivgen); 95 PKCS5_PBE_keyivgen);
96# endif 96# endif
97#endif 97#endif
98#ifndef NO_HMAC 98#ifndef OPENSSL_NO_HMAC
99EVP_PBE_alg_add(NID_pbes2, NULL, NULL, PKCS5_v2_PBE_keyivgen); 99EVP_PBE_alg_add(NID_pbes2, NULL, NULL, PKCS5_v2_PBE_keyivgen);
100#endif 100#endif
101} 101}
102 102
103int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen, 103int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen,
104 ASN1_TYPE *param, EVP_CIPHER *cipher, EVP_MD *md, 104 ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md,
105 int en_de) 105 int en_de)
106{ 106{
107 EVP_MD_CTX ctx; 107 EVP_MD_CTX ctx;
@@ -128,20 +128,22 @@ int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen,
128 if(!pass) passlen = 0; 128 if(!pass) passlen = 0;
129 else if(passlen == -1) passlen = strlen(pass); 129 else if(passlen == -1) passlen = strlen(pass);
130 130
131 EVP_DigestInit (&ctx, md); 131 EVP_MD_CTX_init(&ctx);
132 EVP_DigestUpdate (&ctx, pass, passlen); 132 EVP_DigestInit_ex(&ctx, md, NULL);
133 EVP_DigestUpdate (&ctx, salt, saltlen); 133 EVP_DigestUpdate(&ctx, pass, passlen);
134 EVP_DigestUpdate(&ctx, salt, saltlen);
134 PBEPARAM_free(pbe); 135 PBEPARAM_free(pbe);
135 EVP_DigestFinal (&ctx, md_tmp, NULL); 136 EVP_DigestFinal_ex(&ctx, md_tmp, NULL);
136 for (i = 1; i < iter; i++) { 137 for (i = 1; i < iter; i++) {
137 EVP_DigestInit(&ctx, md); 138 EVP_DigestInit_ex(&ctx, md, NULL);
138 EVP_DigestUpdate(&ctx, md_tmp, EVP_MD_size(md)); 139 EVP_DigestUpdate(&ctx, md_tmp, EVP_MD_size(md));
139 EVP_DigestFinal (&ctx, md_tmp, NULL); 140 EVP_DigestFinal_ex (&ctx, md_tmp, NULL);
140 } 141 }
141 memcpy (key, md_tmp, EVP_CIPHER_key_length(cipher)); 142 EVP_MD_CTX_cleanup(&ctx);
142 memcpy (iv, md_tmp + (16 - EVP_CIPHER_iv_length(cipher)), 143 memcpy(key, md_tmp, EVP_CIPHER_key_length(cipher));
144 memcpy(iv, md_tmp + (16 - EVP_CIPHER_iv_length(cipher)),
143 EVP_CIPHER_iv_length(cipher)); 145 EVP_CIPHER_iv_length(cipher));
144 EVP_CipherInit(cctx, cipher, key, iv, en_de); 146 EVP_CipherInit_ex(cctx, cipher, NULL, key, iv, en_de);
145 memset(md_tmp, 0, EVP_MAX_MD_SIZE); 147 memset(md_tmp, 0, EVP_MAX_MD_SIZE);
146 memset(key, 0, EVP_MAX_KEY_LENGTH); 148 memset(key, 0, EVP_MAX_KEY_LENGTH);
147 memset(iv, 0, EVP_MAX_IV_LENGTH); 149 memset(iv, 0, EVP_MAX_IV_LENGTH);
diff --git a/src/lib/libcrypto/evp/p5_crpt2.c b/src/lib/libcrypto/evp/p5_crpt2.c
index 717fad68ca..7881860b53 100644
--- a/src/lib/libcrypto/evp/p5_crpt2.c
+++ b/src/lib/libcrypto/evp/p5_crpt2.c
@@ -55,7 +55,7 @@
55 * Hudson (tjh@cryptsoft.com). 55 * Hudson (tjh@cryptsoft.com).
56 * 56 *
57 */ 57 */
58#if !defined(NO_HMAC) && !defined(NO_SHA) 58#if !defined(OPENSSL_NO_HMAC) && !defined(OPENSSL_NO_SHA)
59#include <stdio.h> 59#include <stdio.h>
60#include <stdlib.h> 60#include <stdlib.h>
61#include <openssl/x509.h> 61#include <openssl/x509.h>
@@ -84,6 +84,8 @@ int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,
84 int cplen, j, k, tkeylen; 84 int cplen, j, k, tkeylen;
85 unsigned long i = 1; 85 unsigned long i = 1;
86 HMAC_CTX hctx; 86 HMAC_CTX hctx;
87
88 HMAC_CTX_init(&hctx);
87 p = out; 89 p = out;
88 tkeylen = keylen; 90 tkeylen = keylen;
89 if(!pass) passlen = 0; 91 if(!pass) passlen = 0;
@@ -98,7 +100,7 @@ int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,
98 itmp[1] = (unsigned char)((i >> 16) & 0xff); 100 itmp[1] = (unsigned char)((i >> 16) & 0xff);
99 itmp[2] = (unsigned char)((i >> 8) & 0xff); 101 itmp[2] = (unsigned char)((i >> 8) & 0xff);
100 itmp[3] = (unsigned char)(i & 0xff); 102 itmp[3] = (unsigned char)(i & 0xff);
101 HMAC_Init(&hctx, pass, passlen, EVP_sha1()); 103 HMAC_Init_ex(&hctx, pass, passlen, EVP_sha1(), NULL);
102 HMAC_Update(&hctx, salt, saltlen); 104 HMAC_Update(&hctx, salt, saltlen);
103 HMAC_Update(&hctx, itmp, 4); 105 HMAC_Update(&hctx, itmp, 4);
104 HMAC_Final(&hctx, digtmp, NULL); 106 HMAC_Final(&hctx, digtmp, NULL);
@@ -112,7 +114,7 @@ int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,
112 i++; 114 i++;
113 p+= cplen; 115 p+= cplen;
114 } 116 }
115 HMAC_cleanup(&hctx); 117 HMAC_CTX_cleanup(&hctx);
116#ifdef DEBUG_PKCS5V2 118#ifdef DEBUG_PKCS5V2
117 fprintf(stderr, "Password:\n"); 119 fprintf(stderr, "Password:\n");
118 h__dump (pass, passlen); 120 h__dump (pass, passlen);
@@ -143,7 +145,7 @@ main()
143 */ 145 */
144 146
145int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, 147int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
146 ASN1_TYPE *param, EVP_CIPHER *c, EVP_MD *md, 148 ASN1_TYPE *param, const EVP_CIPHER *c, const EVP_MD *md,
147 int en_de) 149 int en_de)
148{ 150{
149 unsigned char *pbuf, *salt, key[EVP_MAX_KEY_LENGTH]; 151 unsigned char *pbuf, *salt, key[EVP_MAX_KEY_LENGTH];
@@ -181,7 +183,7 @@ int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
181 } 183 }
182 184
183 /* Fixup cipher based on AlgorithmIdentifier */ 185 /* Fixup cipher based on AlgorithmIdentifier */
184 EVP_CipherInit(ctx, cipher, NULL, NULL, en_de); 186 EVP_CipherInit_ex(ctx, cipher, NULL, NULL, NULL, en_de);
185 if(EVP_CIPHER_asn1_to_param(ctx, pbe2->encryption->parameter) < 0) { 187 if(EVP_CIPHER_asn1_to_param(ctx, pbe2->encryption->parameter) < 0) {
186 EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN, 188 EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN,
187 EVP_R_CIPHER_PARAMETER_ERROR); 189 EVP_R_CIPHER_PARAMETER_ERROR);
@@ -227,7 +229,7 @@ int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
227 saltlen = kdf->salt->value.octet_string->length; 229 saltlen = kdf->salt->value.octet_string->length;
228 iter = ASN1_INTEGER_get(kdf->iter); 230 iter = ASN1_INTEGER_get(kdf->iter);
229 PKCS5_PBKDF2_HMAC_SHA1(pass, passlen, salt, saltlen, iter, keylen, key); 231 PKCS5_PBKDF2_HMAC_SHA1(pass, passlen, salt, saltlen, iter, keylen, key);
230 EVP_CipherInit(ctx, NULL, key, NULL, en_de); 232 EVP_CipherInit_ex(ctx, NULL, NULL, key, NULL, en_de);
231 memset(key, 0, keylen); 233 memset(key, 0, keylen);
232 PBKDF2PARAM_free(kdf); 234 PBKDF2PARAM_free(kdf);
233 return 1; 235 return 1;
diff --git a/src/lib/libcrypto/evp/p_dec.c b/src/lib/libcrypto/evp/p_dec.c
index 57b5daa453..8af620400e 100644
--- a/src/lib/libcrypto/evp/p_dec.c
+++ b/src/lib/libcrypto/evp/p_dec.c
@@ -59,7 +59,7 @@
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/rand.h> 61#include <openssl/rand.h>
62#ifndef NO_RSA 62#ifndef OPENSSL_NO_RSA
63#include <openssl/rsa.h> 63#include <openssl/rsa.h>
64#endif 64#endif
65#include <openssl/evp.h> 65#include <openssl/evp.h>
@@ -71,12 +71,12 @@ int EVP_PKEY_decrypt(unsigned char *key, unsigned char *ek, int ekl,
71 { 71 {
72 int ret= -1; 72 int ret= -1;
73 73
74#ifndef NO_RSA 74#ifndef OPENSSL_NO_RSA
75 if (priv->type != EVP_PKEY_RSA) 75 if (priv->type != EVP_PKEY_RSA)
76 { 76 {
77#endif 77#endif
78 EVPerr(EVP_F_EVP_PKEY_DECRYPT,EVP_R_PUBLIC_KEY_NOT_RSA); 78 EVPerr(EVP_F_EVP_PKEY_DECRYPT,EVP_R_PUBLIC_KEY_NOT_RSA);
79#ifndef NO_RSA 79#ifndef OPENSSL_NO_RSA
80 goto err; 80 goto err;
81 } 81 }
82 82
diff --git a/src/lib/libcrypto/evp/p_enc.c b/src/lib/libcrypto/evp/p_enc.c
index 4cf6acaf5d..656883b996 100644
--- a/src/lib/libcrypto/evp/p_enc.c
+++ b/src/lib/libcrypto/evp/p_enc.c
@@ -59,7 +59,7 @@
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/rand.h> 61#include <openssl/rand.h>
62#ifndef NO_RSA 62#ifndef OPENSSL_NO_RSA
63#include <openssl/rsa.h> 63#include <openssl/rsa.h>
64#endif 64#endif
65#include <openssl/evp.h> 65#include <openssl/evp.h>
@@ -71,12 +71,12 @@ int EVP_PKEY_encrypt(unsigned char *ek, unsigned char *key, int key_len,
71 { 71 {
72 int ret=0; 72 int ret=0;
73 73
74#ifndef NO_RSA 74#ifndef OPENSSL_NO_RSA
75 if (pubk->type != EVP_PKEY_RSA) 75 if (pubk->type != EVP_PKEY_RSA)
76 { 76 {
77#endif 77#endif
78 EVPerr(EVP_F_EVP_PKEY_ENCRYPT,EVP_R_PUBLIC_KEY_NOT_RSA); 78 EVPerr(EVP_F_EVP_PKEY_ENCRYPT,EVP_R_PUBLIC_KEY_NOT_RSA);
79#ifndef NO_RSA 79#ifndef OPENSSL_NO_RSA
80 goto err; 80 goto err;
81 } 81 }
82 ret=RSA_public_encrypt(key_len,key,ek,pubk->pkey.rsa,RSA_PKCS1_PADDING); 82 ret=RSA_public_encrypt(key_len,key,ek,pubk->pkey.rsa,RSA_PKCS1_PADDING);
diff --git a/src/lib/libcrypto/evp/p_lib.c b/src/lib/libcrypto/evp/p_lib.c
index 62398ed74d..215b94292a 100644
--- a/src/lib/libcrypto/evp/p_lib.c
+++ b/src/lib/libcrypto/evp/p_lib.c
@@ -64,14 +64,15 @@
64#include <openssl/x509.h> 64#include <openssl/x509.h>
65 65
66static void EVP_PKEY_free_it(EVP_PKEY *x); 66static void EVP_PKEY_free_it(EVP_PKEY *x);
67
67int EVP_PKEY_bits(EVP_PKEY *pkey) 68int EVP_PKEY_bits(EVP_PKEY *pkey)
68 { 69 {
69#ifndef NO_RSA 70#ifndef OPENSSL_NO_RSA
70 if (pkey->type == EVP_PKEY_RSA) 71 if (pkey->type == EVP_PKEY_RSA)
71 return(BN_num_bits(pkey->pkey.rsa->n)); 72 return(BN_num_bits(pkey->pkey.rsa->n));
72 else 73 else
73#endif 74#endif
74#ifndef NO_DSA 75#ifndef OPENSSL_NO_DSA
75 if (pkey->type == EVP_PKEY_DSA) 76 if (pkey->type == EVP_PKEY_DSA)
76 return(BN_num_bits(pkey->pkey.dsa->p)); 77 return(BN_num_bits(pkey->pkey.dsa->p));
77#endif 78#endif
@@ -82,12 +83,12 @@ int EVP_PKEY_size(EVP_PKEY *pkey)
82 { 83 {
83 if (pkey == NULL) 84 if (pkey == NULL)
84 return(0); 85 return(0);
85#ifndef NO_RSA 86#ifndef OPENSSL_NO_RSA
86 if (pkey->type == EVP_PKEY_RSA) 87 if (pkey->type == EVP_PKEY_RSA)
87 return(RSA_size(pkey->pkey.rsa)); 88 return(RSA_size(pkey->pkey.rsa));
88 else 89 else
89#endif 90#endif
90#ifndef NO_DSA 91#ifndef OPENSSL_NO_DSA
91 if (pkey->type == EVP_PKEY_DSA) 92 if (pkey->type == EVP_PKEY_DSA)
92 return(DSA_size(pkey->pkey.dsa)); 93 return(DSA_size(pkey->pkey.dsa));
93#endif 94#endif
@@ -96,10 +97,10 @@ int EVP_PKEY_size(EVP_PKEY *pkey)
96 97
97int EVP_PKEY_save_parameters(EVP_PKEY *pkey, int mode) 98int EVP_PKEY_save_parameters(EVP_PKEY *pkey, int mode)
98 { 99 {
99#ifndef NO_DSA 100#ifndef OPENSSL_NO_DSA
100 if (pkey->type == EVP_PKEY_DSA) 101 if (pkey->type == EVP_PKEY_DSA)
101 { 102 {
102 int ret=pkey->save_parameters=mode; 103 int ret=pkey->save_parameters;
103 104
104 if (mode >= 0) 105 if (mode >= 0)
105 pkey->save_parameters=mode; 106 pkey->save_parameters=mode;
@@ -122,7 +123,7 @@ int EVP_PKEY_copy_parameters(EVP_PKEY *to, EVP_PKEY *from)
122 EVPerr(EVP_F_EVP_PKEY_COPY_PARAMETERS,EVP_R_MISSING_PARAMETERS); 123 EVPerr(EVP_F_EVP_PKEY_COPY_PARAMETERS,EVP_R_MISSING_PARAMETERS);
123 goto err; 124 goto err;
124 } 125 }
125#ifndef NO_DSA 126#ifndef OPENSSL_NO_DSA
126 if (to->type == EVP_PKEY_DSA) 127 if (to->type == EVP_PKEY_DSA)
127 { 128 {
128 BIGNUM *a; 129 BIGNUM *a;
@@ -147,7 +148,7 @@ err:
147 148
148int EVP_PKEY_missing_parameters(EVP_PKEY *pkey) 149int EVP_PKEY_missing_parameters(EVP_PKEY *pkey)
149 { 150 {
150#ifndef NO_DSA 151#ifndef OPENSSL_NO_DSA
151 if (pkey->type == EVP_PKEY_DSA) 152 if (pkey->type == EVP_PKEY_DSA)
152 { 153 {
153 DSA *dsa; 154 DSA *dsa;
@@ -162,7 +163,7 @@ int EVP_PKEY_missing_parameters(EVP_PKEY *pkey)
162 163
163int EVP_PKEY_cmp_parameters(EVP_PKEY *a, EVP_PKEY *b) 164int EVP_PKEY_cmp_parameters(EVP_PKEY *a, EVP_PKEY *b)
164 { 165 {
165#ifndef NO_DSA 166#ifndef OPENSSL_NO_DSA
166 if ((a->type == EVP_PKEY_DSA) && (b->type == EVP_PKEY_DSA)) 167 if ((a->type == EVP_PKEY_DSA) && (b->type == EVP_PKEY_DSA))
167 { 168 {
168 if ( BN_cmp(a->pkey.dsa->p,b->pkey.dsa->p) || 169 if ( BN_cmp(a->pkey.dsa->p,b->pkey.dsa->p) ||
@@ -205,11 +206,12 @@ int EVP_PKEY_assign(EVP_PKEY *pkey, int type, char *key)
205 return(key != NULL); 206 return(key != NULL);
206 } 207 }
207 208
208#ifndef NO_RSA 209#ifndef OPENSSL_NO_RSA
209int EVP_PKEY_set1_RSA(EVP_PKEY *pkey, RSA *key) 210int EVP_PKEY_set1_RSA(EVP_PKEY *pkey, RSA *key)
210{ 211{
211 int ret = EVP_PKEY_assign_RSA(pkey, key); 212 int ret = EVP_PKEY_assign_RSA(pkey, key);
212 if(ret) CRYPTO_add(&key->references, 1, CRYPTO_LOCK_RSA); 213 if(ret)
214 RSA_up_ref(key);
213 return ret; 215 return ret;
214} 216}
215 217
@@ -219,16 +221,17 @@ RSA *EVP_PKEY_get1_RSA(EVP_PKEY *pkey)
219 EVPerr(EVP_F_EVP_PKEY_GET1_RSA, EVP_R_EXPECTING_AN_RSA_KEY); 221 EVPerr(EVP_F_EVP_PKEY_GET1_RSA, EVP_R_EXPECTING_AN_RSA_KEY);
220 return NULL; 222 return NULL;
221 } 223 }
222 CRYPTO_add(&pkey->pkey.rsa->references, 1, CRYPTO_LOCK_RSA); 224 RSA_up_ref(pkey->pkey.rsa);
223 return pkey->pkey.rsa; 225 return pkey->pkey.rsa;
224} 226}
225#endif 227#endif
226 228
227#ifndef NO_DSA 229#ifndef OPENSSL_NO_DSA
228int EVP_PKEY_set1_DSA(EVP_PKEY *pkey, DSA *key) 230int EVP_PKEY_set1_DSA(EVP_PKEY *pkey, DSA *key)
229{ 231{
230 int ret = EVP_PKEY_assign_DSA(pkey, key); 232 int ret = EVP_PKEY_assign_DSA(pkey, key);
231 if(ret) CRYPTO_add(&key->references, 1, CRYPTO_LOCK_DSA); 233 if(ret)
234 DSA_up_ref(key);
232 return ret; 235 return ret;
233} 236}
234 237
@@ -238,17 +241,18 @@ DSA *EVP_PKEY_get1_DSA(EVP_PKEY *pkey)
238 EVPerr(EVP_F_EVP_PKEY_GET1_DSA, EVP_R_EXPECTING_A_DSA_KEY); 241 EVPerr(EVP_F_EVP_PKEY_GET1_DSA, EVP_R_EXPECTING_A_DSA_KEY);
239 return NULL; 242 return NULL;
240 } 243 }
241 CRYPTO_add(&pkey->pkey.dsa->references, 1, CRYPTO_LOCK_DSA); 244 DSA_up_ref(pkey->pkey.dsa);
242 return pkey->pkey.dsa; 245 return pkey->pkey.dsa;
243} 246}
244#endif 247#endif
245 248
246#ifndef NO_DH 249#ifndef OPENSSL_NO_DH
247 250
248int EVP_PKEY_set1_DH(EVP_PKEY *pkey, DH *key) 251int EVP_PKEY_set1_DH(EVP_PKEY *pkey, DH *key)
249{ 252{
250 int ret = EVP_PKEY_assign_DH(pkey, key); 253 int ret = EVP_PKEY_assign_DH(pkey, key);
251 if(ret) CRYPTO_add(&key->references, 1, CRYPTO_LOCK_DH); 254 if(ret)
255 DH_up_ref(key);
252 return ret; 256 return ret;
253} 257}
254 258
@@ -258,7 +262,7 @@ DH *EVP_PKEY_get1_DH(EVP_PKEY *pkey)
258 EVPerr(EVP_F_EVP_PKEY_GET1_DH, EVP_R_EXPECTING_A_DH_KEY); 262 EVPerr(EVP_F_EVP_PKEY_GET1_DH, EVP_R_EXPECTING_A_DH_KEY);
259 return NULL; 263 return NULL;
260 } 264 }
261 CRYPTO_add(&pkey->pkey.dh->references, 1, CRYPTO_LOCK_DH); 265 DH_up_ref(pkey->pkey.dh);
262 return pkey->pkey.dh; 266 return pkey->pkey.dh;
263} 267}
264#endif 268#endif
@@ -309,13 +313,13 @@ static void EVP_PKEY_free_it(EVP_PKEY *x)
309 { 313 {
310 switch (x->type) 314 switch (x->type)
311 { 315 {
312#ifndef NO_RSA 316#ifndef OPENSSL_NO_RSA
313 case EVP_PKEY_RSA: 317 case EVP_PKEY_RSA:
314 case EVP_PKEY_RSA2: 318 case EVP_PKEY_RSA2:
315 RSA_free(x->pkey.rsa); 319 RSA_free(x->pkey.rsa);
316 break; 320 break;
317#endif 321#endif
318#ifndef NO_DSA 322#ifndef OPENSSL_NO_DSA
319 case EVP_PKEY_DSA: 323 case EVP_PKEY_DSA:
320 case EVP_PKEY_DSA2: 324 case EVP_PKEY_DSA2:
321 case EVP_PKEY_DSA3: 325 case EVP_PKEY_DSA3:
@@ -323,7 +327,7 @@ static void EVP_PKEY_free_it(EVP_PKEY *x)
323 DSA_free(x->pkey.dsa); 327 DSA_free(x->pkey.dsa);
324 break; 328 break;
325#endif 329#endif
326#ifndef NO_DH 330#ifndef OPENSSL_NO_DH
327 case EVP_PKEY_DH: 331 case EVP_PKEY_DH:
328 DH_free(x->pkey.dh); 332 DH_free(x->pkey.dh);
329 break; 333 break;
diff --git a/src/lib/libcrypto/evp/p_open.c b/src/lib/libcrypto/evp/p_open.c
index 2760c00fec..6976f2a867 100644
--- a/src/lib/libcrypto/evp/p_open.c
+++ b/src/lib/libcrypto/evp/p_open.c
@@ -56,14 +56,14 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_RSA 59#ifndef OPENSSL_NO_RSA
60#include <stdio.h> 60#include <stdio.h>
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/evp.h> 62#include <openssl/evp.h>
63#include <openssl/objects.h> 63#include <openssl/objects.h>
64#include <openssl/x509.h> 64#include <openssl/x509.h>
65 65
66int EVP_OpenInit(EVP_CIPHER_CTX *ctx, EVP_CIPHER *type, unsigned char *ek, 66int EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, unsigned char *ek,
67 int ekl, unsigned char *iv, EVP_PKEY *priv) 67 int ekl, unsigned char *iv, EVP_PKEY *priv)
68 { 68 {
69 unsigned char *key=NULL; 69 unsigned char *key=NULL;
@@ -71,7 +71,7 @@ int EVP_OpenInit(EVP_CIPHER_CTX *ctx, EVP_CIPHER *type, unsigned char *ek,
71 71
72 if(type) { 72 if(type) {
73 EVP_CIPHER_CTX_init(ctx); 73 EVP_CIPHER_CTX_init(ctx);
74 if(!EVP_DecryptInit(ctx,type,NULL,NULL)) return 0; 74 if(!EVP_DecryptInit_ex(ctx,type,NULL, NULL,NULL)) return 0;
75 } 75 }
76 76
77 if(!priv) return 1; 77 if(!priv) return 1;
@@ -97,7 +97,7 @@ int EVP_OpenInit(EVP_CIPHER_CTX *ctx, EVP_CIPHER *type, unsigned char *ek,
97 /* ERROR */ 97 /* ERROR */
98 goto err; 98 goto err;
99 } 99 }
100 if(!EVP_DecryptInit(ctx,NULL,key,iv)) goto err; 100 if(!EVP_DecryptInit_ex(ctx,NULL,NULL,key,iv)) goto err;
101 101
102 ret=1; 102 ret=1;
103err: 103err:
@@ -110,11 +110,11 @@ int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
110 { 110 {
111 int i; 111 int i;
112 112
113 i=EVP_DecryptFinal(ctx,out,outl); 113 i=EVP_DecryptFinal_ex(ctx,out,outl);
114 EVP_DecryptInit(ctx,NULL,NULL,NULL); 114 EVP_DecryptInit_ex(ctx,NULL,NULL,NULL,NULL);
115 return(i); 115 return(i);
116 } 116 }
117#else /* !NO_RSA */ 117#else /* !OPENSSL_NO_RSA */
118 118
119# ifdef PEDANTIC 119# ifdef PEDANTIC
120static void *dummy=&dummy; 120static void *dummy=&dummy;
diff --git a/src/lib/libcrypto/evp/p_seal.c b/src/lib/libcrypto/evp/p_seal.c
index 2fd1d7e0c2..5570ca3745 100644
--- a/src/lib/libcrypto/evp/p_seal.c
+++ b/src/lib/libcrypto/evp/p_seal.c
@@ -59,14 +59,14 @@
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/rand.h> 61#include <openssl/rand.h>
62#ifndef NO_RSA 62#ifndef OPENSSL_NO_RSA
63#include <openssl/rsa.h> 63#include <openssl/rsa.h>
64#endif 64#endif
65#include <openssl/evp.h> 65#include <openssl/evp.h>
66#include <openssl/objects.h> 66#include <openssl/objects.h>
67#include <openssl/x509.h> 67#include <openssl/x509.h>
68 68
69int EVP_SealInit(EVP_CIPHER_CTX *ctx, EVP_CIPHER *type, unsigned char **ek, 69int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, unsigned char **ek,
70 int *ekl, unsigned char *iv, EVP_PKEY **pubk, int npubk) 70 int *ekl, unsigned char *iv, EVP_PKEY **pubk, int npubk)
71 { 71 {
72 unsigned char key[EVP_MAX_KEY_LENGTH]; 72 unsigned char key[EVP_MAX_KEY_LENGTH];
@@ -74,15 +74,16 @@ int EVP_SealInit(EVP_CIPHER_CTX *ctx, EVP_CIPHER *type, unsigned char **ek,
74 74
75 if(type) { 75 if(type) {
76 EVP_CIPHER_CTX_init(ctx); 76 EVP_CIPHER_CTX_init(ctx);
77 if(!EVP_EncryptInit(ctx,type,NULL,NULL)) return 0; 77 if(!EVP_EncryptInit_ex(ctx,type,NULL,NULL,NULL)) return 0;
78 } 78 }
79 if (npubk <= 0) return(0); 79 if ((npubk <= 0) || !pubk)
80 return 1;
80 if (RAND_bytes(key,EVP_MAX_KEY_LENGTH) <= 0) 81 if (RAND_bytes(key,EVP_MAX_KEY_LENGTH) <= 0)
81 return(0); 82 return 0;
82 if (EVP_CIPHER_CTX_iv_length(ctx)) 83 if (EVP_CIPHER_CTX_iv_length(ctx))
83 RAND_pseudo_bytes(iv,EVP_CIPHER_CTX_iv_length(ctx)); 84 RAND_pseudo_bytes(iv,EVP_CIPHER_CTX_iv_length(ctx));
84 85
85 if(!EVP_EncryptInit(ctx,NULL,key,iv)) return 0; 86 if(!EVP_EncryptInit_ex(ctx,NULL,NULL,key,iv)) return 0;
86 87
87 for (i=0; i<npubk; i++) 88 for (i=0; i<npubk; i++)
88 { 89 {
@@ -107,6 +108,6 @@ int inl;
107 108
108void EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) 109void EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
109 { 110 {
110 EVP_EncryptFinal(ctx,out,outl); 111 EVP_EncryptFinal_ex(ctx,out,outl);
111 EVP_EncryptInit(ctx,NULL,NULL,NULL); 112 EVP_EncryptInit_ex(ctx,NULL,NULL,NULL,NULL);
112 } 113 }
diff --git a/src/lib/libcrypto/evp/p_sign.c b/src/lib/libcrypto/evp/p_sign.c
index 1fa32ac17e..e4ae5906f5 100644
--- a/src/lib/libcrypto/evp/p_sign.c
+++ b/src/lib/libcrypto/evp/p_sign.c
@@ -65,7 +65,7 @@
65#ifdef undef 65#ifdef undef
66void EVP_SignInit(EVP_MD_CTX *ctx, EVP_MD *type) 66void EVP_SignInit(EVP_MD_CTX *ctx, EVP_MD *type)
67 { 67 {
68 EVP_DigestInit(ctx,type); 68 EVP_DigestInit_ex(ctx,type);
69 } 69 }
70 70
71void EVP_SignUpdate(EVP_MD_CTX *ctx, unsigned char *data, 71void EVP_SignUpdate(EVP_MD_CTX *ctx, unsigned char *data,
@@ -84,8 +84,10 @@ int EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, unsigned int *siglen,
84 MS_STATIC EVP_MD_CTX tmp_ctx; 84 MS_STATIC EVP_MD_CTX tmp_ctx;
85 85
86 *siglen=0; 86 *siglen=0;
87 EVP_MD_CTX_copy(&tmp_ctx,ctx); 87 EVP_MD_CTX_init(&tmp_ctx);
88 EVP_DigestFinal(&tmp_ctx,&(m[0]),&m_len); 88 EVP_MD_CTX_copy_ex(&tmp_ctx,ctx);
89 EVP_DigestFinal_ex(&tmp_ctx,&(m[0]),&m_len);
90 EVP_MD_CTX_cleanup(&tmp_ctx);
89 for (i=0; i<4; i++) 91 for (i=0; i<4; i++)
90 { 92 {
91 v=ctx->digest->required_pkey_type[i]; 93 v=ctx->digest->required_pkey_type[i];
diff --git a/src/lib/libcrypto/evp/p_verify.c b/src/lib/libcrypto/evp/p_verify.c
index dcb54f3abb..d854d743a5 100644
--- a/src/lib/libcrypto/evp/p_verify.c
+++ b/src/lib/libcrypto/evp/p_verify.c
@@ -85,8 +85,10 @@ int EVP_VerifyFinal(EVP_MD_CTX *ctx, unsigned char *sigbuf,
85 EVPerr(EVP_F_EVP_VERIFYFINAL,EVP_R_WRONG_PUBLIC_KEY_TYPE); 85 EVPerr(EVP_F_EVP_VERIFYFINAL,EVP_R_WRONG_PUBLIC_KEY_TYPE);
86 return(-1); 86 return(-1);
87 } 87 }
88 EVP_MD_CTX_copy(&tmp_ctx,ctx); 88 EVP_MD_CTX_init(&tmp_ctx);
89 EVP_DigestFinal(&tmp_ctx,&(m[0]),&m_len); 89 EVP_MD_CTX_copy_ex(&tmp_ctx,ctx);
90 EVP_DigestFinal_ex(&tmp_ctx,&(m[0]),&m_len);
91 EVP_MD_CTX_cleanup(&tmp_ctx);
90 if (ctx->digest->verify == NULL) 92 if (ctx->digest->verify == NULL)
91 { 93 {
92 EVPerr(EVP_F_EVP_VERIFYFINAL,EVP_R_NO_VERIFY_FUNCTION_CONFIGURED); 94 EVPerr(EVP_F_EVP_VERIFYFINAL,EVP_R_NO_VERIFY_FUNCTION_CONFIGURED);
diff --git a/src/lib/libcrypto/ex_data.c b/src/lib/libcrypto/ex_data.c
index 739e543d78..5b2e345c27 100644
--- a/src/lib/libcrypto/ex_data.c
+++ b/src/lib/libcrypto/ex_data.c
@@ -1,4 +1,33 @@
1/* crypto/ex_data.c */ 1/* crypto/ex_data.c */
2
3/*
4 * Overhaul notes;
5 *
6 * This code is now *mostly* thread-safe. It is now easier to understand in what
7 * ways it is safe and in what ways it is not, which is an improvement. Firstly,
8 * all per-class stacks and index-counters for ex_data are stored in the same
9 * global LHASH table (keyed by class). This hash table uses locking for all
10 * access with the exception of CRYPTO_cleanup_all_ex_data(), which must only be
11 * called when no other threads can possibly race against it (even if it was
12 * locked, the race would mean it's possible the hash table might have been
13 * recreated after the cleanup). As classes can only be added to the hash table,
14 * and within each class, the stack of methods can only be incremented, the
15 * locking mechanics are simpler than they would otherwise be. For example, the
16 * new/dup/free ex_data functions will lock the hash table, copy the method
17 * pointers it needs from the relevant class, then unlock the hash table before
18 * actually applying those method pointers to the task of the new/dup/free
19 * operations. As they can't be removed from the method-stack, only
20 * supplemented, there's no race conditions associated with using them outside
21 * the lock. The get/set_ex_data functions are not locked because they do not
22 * involve this global state at all - they operate directly with a previously
23 * obtained per-class method index and a particular "ex_data" variable. These
24 * variables are usually instantiated per-context (eg. each RSA structure has
25 * one) so locking on read/write access to that variable can be locked locally
26 * if required (eg. using the "RSA" lock to synchronise access to a
27 * per-RSA-structure ex_data variable if required).
28 * [Geoff]
29 */
30
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 31/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 32 * All rights reserved.
4 * 33 *
@@ -55,6 +84,59 @@
55 * copied and put under another distribution licence 84 * copied and put under another distribution licence
56 * [including the GNU Public Licence.] 85 * [including the GNU Public Licence.]
57 */ 86 */
87/* ====================================================================
88 * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.
89 *
90 * Redistribution and use in source and binary forms, with or without
91 * modification, are permitted provided that the following conditions
92 * are met:
93 *
94 * 1. Redistributions of source code must retain the above copyright
95 * notice, this list of conditions and the following disclaimer.
96 *
97 * 2. Redistributions in binary form must reproduce the above copyright
98 * notice, this list of conditions and the following disclaimer in
99 * the documentation and/or other materials provided with the
100 * distribution.
101 *
102 * 3. All advertising materials mentioning features or use of this
103 * software must display the following acknowledgment:
104 * "This product includes software developed by the OpenSSL Project
105 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
106 *
107 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
108 * endorse or promote products derived from this software without
109 * prior written permission. For written permission, please contact
110 * openssl-core@openssl.org.
111 *
112 * 5. Products derived from this software may not be called "OpenSSL"
113 * nor may "OpenSSL" appear in their names without prior written
114 * permission of the OpenSSL Project.
115 *
116 * 6. Redistributions of any form whatsoever must retain the following
117 * acknowledgment:
118 * "This product includes software developed by the OpenSSL Project
119 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
120 *
121 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
122 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
123 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
124 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
125 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
126 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
127 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
128 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
129 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
130 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
131 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
132 * OF THE POSSIBILITY OF SUCH DAMAGE.
133 * ====================================================================
134 *
135 * This product includes cryptographic software written by Eric Young
136 * (eay@cryptsoft.com). This product includes software written by Tim
137 * Hudson (tjh@cryptsoft.com).
138 *
139 */
58 140
59#include <stdio.h> 141#include <stdio.h>
60#include <stdlib.h> 142#include <stdlib.h>
@@ -63,47 +145,455 @@
63#include <openssl/lhash.h> 145#include <openssl/lhash.h>
64#include "cryptlib.h" 146#include "cryptlib.h"
65 147
66int CRYPTO_get_ex_new_index(int idx, STACK_OF(CRYPTO_EX_DATA_FUNCS) **skp, long argl, void *argp, 148/* What an "implementation of ex_data functionality" looks like */
67 CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) 149struct st_CRYPTO_EX_DATA_IMPL
150 {
151 /*********************/
152 /* GLOBAL OPERATIONS */
153 /* Return a new class index */
154 int (*cb_new_class)(void);
155 /* Cleanup all state used by the implementation */
156 void (*cb_cleanup)(void);
157 /************************/
158 /* PER-CLASS OPERATIONS */
159 /* Get a new method index within a class */
160 int (*cb_get_new_index)(int class_index, long argl, void *argp,
161 CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
162 CRYPTO_EX_free *free_func);
163 /* Initialise a new CRYPTO_EX_DATA of a given class */
164 int (*cb_new_ex_data)(int class_index, void *obj,
165 CRYPTO_EX_DATA *ad);
166 /* Duplicate a CRYPTO_EX_DATA of a given class onto a copy */
167 int (*cb_dup_ex_data)(int class_index, CRYPTO_EX_DATA *to,
168 CRYPTO_EX_DATA *from);
169 /* Cleanup a CRYPTO_EX_DATA of a given class */
170 void (*cb_free_ex_data)(int class_index, void *obj,
171 CRYPTO_EX_DATA *ad);
172 };
173
174/* The implementation we use at run-time */
175static const CRYPTO_EX_DATA_IMPL *impl = NULL;
176
177/* To call "impl" functions, use this macro rather than referring to 'impl' directly, eg.
178 * EX_IMPL(get_new_index)(...); */
179#define EX_IMPL(a) impl->cb_##a
180
181/* Predeclare the "default" ex_data implementation */
182static int int_new_class(void);
183static void int_cleanup(void);
184static int int_get_new_index(int class_index, long argl, void *argp,
185 CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
186 CRYPTO_EX_free *free_func);
187static int int_new_ex_data(int class_index, void *obj,
188 CRYPTO_EX_DATA *ad);
189static int int_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
190 CRYPTO_EX_DATA *from);
191static void int_free_ex_data(int class_index, void *obj,
192 CRYPTO_EX_DATA *ad);
193static CRYPTO_EX_DATA_IMPL impl_default =
194 {
195 int_new_class,
196 int_cleanup,
197 int_get_new_index,
198 int_new_ex_data,
199 int_dup_ex_data,
200 int_free_ex_data
201 };
202
203/* Internal function that checks whether "impl" is set and if not, sets it to
204 * the default. */
205static void impl_check(void)
68 { 206 {
69 int ret= -1; 207 CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA);
70 CRYPTO_EX_DATA_FUNCS *a; 208 if(!impl)
209 impl = &impl_default;
210 CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA);
211 }
212/* A macro wrapper for impl_check that first uses a non-locked test before
213 * invoking the function (which checks again inside a lock). */
214#define IMPL_CHECK if(!impl) impl_check();
71 215
72 MemCheck_off(); 216/* API functions to get/set the "ex_data" implementation */
73 if (*skp == NULL) 217const CRYPTO_EX_DATA_IMPL *CRYPTO_get_ex_data_implementation(void)
74 *skp=sk_CRYPTO_EX_DATA_FUNCS_new_null(); 218 {
75 if (*skp == NULL) 219 IMPL_CHECK
220 return impl;
221 }
222int CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i)
223 {
224 int toret = 0;
225 CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA);
226 if(!impl)
76 { 227 {
77 CRYPTOerr(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX,ERR_R_MALLOC_FAILURE); 228 impl = i;
78 goto err; 229 toret = 1;
79 } 230 }
80 a=(CRYPTO_EX_DATA_FUNCS *)OPENSSL_malloc(sizeof(CRYPTO_EX_DATA_FUNCS)); 231 CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA);
81 if (a == NULL) 232 return toret;
233 }
234
235/****************************************************************************/
236/* Interal (default) implementation of "ex_data" support. API functions are
237 * further down. */
238
239/* The type that represents what each "class" used to implement locally. A STACK
240 * of CRYPTO_EX_DATA_FUNCS plus a index-counter. The 'class_index' is the global
241 * value representing the class that is used to distinguish these items. */
242typedef struct st_ex_class_item {
243 int class_index;
244 STACK_OF(CRYPTO_EX_DATA_FUNCS) *meth;
245 int meth_num;
246} EX_CLASS_ITEM;
247
248/* When assigning new class indexes, this is our counter */
249static int ex_class = CRYPTO_EX_INDEX_USER;
250
251/* The global hash table of EX_CLASS_ITEM items */
252static LHASH *ex_data = NULL;
253
254/* The callbacks required in the "ex_data" hash table */
255static unsigned long ex_hash_cb(const void *a_void)
256 {
257 return ((const EX_CLASS_ITEM *)a_void)->class_index;
258 }
259static int ex_cmp_cb(const void *a_void, const void *b_void)
260 {
261 return (((const EX_CLASS_ITEM *)a_void)->class_index -
262 ((const EX_CLASS_ITEM *)b_void)->class_index);
263 }
264
265/* Internal functions used by the "impl_default" implementation to access the
266 * state */
267
268static int ex_data_check(void)
269 {
270 int toret = 1;
271 CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA);
272 if(!ex_data && ((ex_data = lh_new(ex_hash_cb, ex_cmp_cb)) == NULL))
273 toret = 0;
274 CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA);
275 return toret;
276 }
277/* This macros helps reduce the locking from repeated checks because the
278 * ex_data_check() function checks ex_data again inside a lock. */
279#define EX_DATA_CHECK(iffail) if(!ex_data && !ex_data_check()) {iffail}
280
281/* This "inner" callback is used by the callback function that follows it */
282static void def_cleanup_util_cb(CRYPTO_EX_DATA_FUNCS *funcs)
283 {
284 OPENSSL_free(funcs);
285 }
286
287/* This callback is used in lh_doall to destroy all EX_CLASS_ITEM values from
288 * "ex_data" prior to the ex_data hash table being itself destroyed. Doesn't do
289 * any locking. */
290static void def_cleanup_cb(const void *a_void)
291 {
292 EX_CLASS_ITEM *item = (EX_CLASS_ITEM *)a_void;
293 sk_CRYPTO_EX_DATA_FUNCS_pop_free(item->meth, def_cleanup_util_cb);
294 OPENSSL_free(item);
295 }
296
297/* Return the EX_CLASS_ITEM from the "ex_data" hash table that corresponds to a
298 * given class. Handles locking. */
299static EX_CLASS_ITEM *def_get_class(int class_index)
300 {
301 EX_CLASS_ITEM d, *p, *gen;
302 EX_DATA_CHECK(return NULL;)
303 d.class_index = class_index;
304 CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA);
305 p = lh_retrieve(ex_data, &d);
306 if(!p)
82 { 307 {
83 CRYPTOerr(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX,ERR_R_MALLOC_FAILURE); 308 gen = OPENSSL_malloc(sizeof(EX_CLASS_ITEM));
84 goto err; 309 if(gen)
310 {
311 gen->class_index = class_index;
312 gen->meth_num = 0;
313 gen->meth = sk_CRYPTO_EX_DATA_FUNCS_new_null();
314 if(!gen->meth)
315 OPENSSL_free(gen);
316 else
317 {
318 /* Because we're inside the ex_data lock, the
319 * return value from the insert will be NULL */
320 lh_insert(ex_data, gen);
321 p = gen;
322 }
323 }
324 }
325 CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA);
326 if(!p)
327 CRYPTOerr(CRYPTO_F_DEF_GET_CLASS,ERR_R_MALLOC_FAILURE);
328 return p;
329 }
330
331/* Add a new method to the given EX_CLASS_ITEM and return the corresponding
332 * index (or -1 for error). Handles locking. */
333static int def_add_index(EX_CLASS_ITEM *item, long argl, void *argp,
334 CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
335 CRYPTO_EX_free *free_func)
336 {
337 int toret = -1;
338 CRYPTO_EX_DATA_FUNCS *a = (CRYPTO_EX_DATA_FUNCS *)OPENSSL_malloc(
339 sizeof(CRYPTO_EX_DATA_FUNCS));
340 if(!a)
341 {
342 CRYPTOerr(CRYPTO_F_DEF_ADD_INDEX,ERR_R_MALLOC_FAILURE);
343 return -1;
85 } 344 }
86 a->argl=argl; 345 a->argl=argl;
87 a->argp=argp; 346 a->argp=argp;
88 a->new_func=new_func; 347 a->new_func=new_func;
89 a->dup_func=dup_func; 348 a->dup_func=dup_func;
90 a->free_func=free_func; 349 a->free_func=free_func;
91 while (sk_CRYPTO_EX_DATA_FUNCS_num(*skp) <= idx) 350 CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA);
351 while (sk_CRYPTO_EX_DATA_FUNCS_num(item->meth) <= item->meth_num)
92 { 352 {
93 if (!sk_CRYPTO_EX_DATA_FUNCS_push(*skp,NULL)) 353 if (!sk_CRYPTO_EX_DATA_FUNCS_push(item->meth, NULL))
94 { 354 {
95 CRYPTOerr(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX,ERR_R_MALLOC_FAILURE); 355 CRYPTOerr(CRYPTO_F_DEF_ADD_INDEX,ERR_R_MALLOC_FAILURE);
96 OPENSSL_free(a); 356 OPENSSL_free(a);
97 goto err; 357 goto err;
98 } 358 }
99 } 359 }
100 sk_CRYPTO_EX_DATA_FUNCS_set(*skp,idx, a); 360 toret = item->meth_num++;
101 ret=idx; 361 sk_CRYPTO_EX_DATA_FUNCS_set(item->meth, toret, a);
102err: 362err:
103 MemCheck_on(); 363 CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA);
104 return(ret); 364 return toret;
105 } 365 }
106 366
367/**************************************************************/
368/* The functions in the default CRYPTO_EX_DATA_IMPL structure */
369
370static int int_new_class(void)
371 {
372 int toret;
373 CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA);
374 toret = ex_class++;
375 CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA);
376 return toret;
377 }
378
379static void int_cleanup(void)
380 {
381 EX_DATA_CHECK(return;)
382 lh_doall(ex_data, def_cleanup_cb);
383 lh_free(ex_data);
384 ex_data = NULL;
385 impl = NULL;
386 }
387
388static int int_get_new_index(int class_index, long argl, void *argp,
389 CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
390 CRYPTO_EX_free *free_func)
391 {
392 EX_CLASS_ITEM *item = def_get_class(class_index);
393 if(!item)
394 return -1;
395 return def_add_index(item, argl, argp, new_func, dup_func, free_func);
396 }
397
398/* Thread-safe by copying a class's array of "CRYPTO_EX_DATA_FUNCS" entries in
399 * the lock, then using them outside the lock. NB: Thread-safety only applies to
400 * the global "ex_data" state (ie. class definitions), not thread-safe on 'ad'
401 * itself. */
402static int int_new_ex_data(int class_index, void *obj,
403 CRYPTO_EX_DATA *ad)
404 {
405 int mx,i;
406 void *ptr;
407 CRYPTO_EX_DATA_FUNCS **storage = NULL;
408 EX_CLASS_ITEM *item = def_get_class(class_index);
409 if(!item)
410 /* error is already set */
411 return 0;
412 ad->sk = NULL;
413 CRYPTO_r_lock(CRYPTO_LOCK_EX_DATA);
414 mx = sk_CRYPTO_EX_DATA_FUNCS_num(item->meth);
415 if(mx > 0)
416 {
417 storage = OPENSSL_malloc(mx * sizeof(CRYPTO_EX_DATA_FUNCS*));
418 if(!storage)
419 goto skip;
420 for(i = 0; i < mx; i++)
421 storage[i] = sk_CRYPTO_EX_DATA_FUNCS_value(item->meth,i);
422 }
423skip:
424 CRYPTO_r_unlock(CRYPTO_LOCK_EX_DATA);
425 if((mx > 0) && !storage)
426 {
427 CRYPTOerr(CRYPTO_F_INT_NEW_EX_DATA,ERR_R_MALLOC_FAILURE);
428 return 0;
429 }
430 for(i = 0; i < mx; i++)
431 {
432 if(storage[i] && storage[i]->new_func)
433 {
434 ptr = CRYPTO_get_ex_data(ad, i);
435 storage[i]->new_func(obj,ptr,ad,i,
436 storage[i]->argl,storage[i]->argp);
437 }
438 }
439 if(storage)
440 OPENSSL_free(storage);
441 return 1;
442 }
443
444/* Same thread-safety notes as for "int_new_ex_data" */
445static int int_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
446 CRYPTO_EX_DATA *from)
447 {
448 int mx, j, i;
449 char *ptr;
450 CRYPTO_EX_DATA_FUNCS **storage = NULL;
451 EX_CLASS_ITEM *item;
452 if(!from->sk)
453 /* 'to' should be "blank" which *is* just like 'from' */
454 return 1;
455 if((item = def_get_class(class_index)) == NULL)
456 return 0;
457 CRYPTO_r_lock(CRYPTO_LOCK_EX_DATA);
458 mx = sk_CRYPTO_EX_DATA_FUNCS_num(item->meth);
459 j = sk_num(from->sk);
460 if(j < mx)
461 mx = j;
462 if(mx > 0)
463 {
464 storage = OPENSSL_malloc(mx * sizeof(CRYPTO_EX_DATA_FUNCS*));
465 if(!storage)
466 goto skip;
467 for(i = 0; i < mx; i++)
468 storage[i] = sk_CRYPTO_EX_DATA_FUNCS_value(item->meth,i);
469 }
470skip:
471 CRYPTO_r_unlock(CRYPTO_LOCK_EX_DATA);
472 if((mx > 0) && !storage)
473 {
474 CRYPTOerr(CRYPTO_F_INT_DUP_EX_DATA,ERR_R_MALLOC_FAILURE);
475 return 0;
476 }
477 for(i = 0; i < mx; i++)
478 {
479 ptr = CRYPTO_get_ex_data(from, i);
480 if(storage[i] && storage[i]->dup_func)
481 storage[i]->dup_func(to,from,&ptr,i,
482 storage[i]->argl,storage[i]->argp);
483 CRYPTO_set_ex_data(to,i,ptr);
484 }
485 if(storage)
486 OPENSSL_free(storage);
487 return 1;
488 }
489
490/* Same thread-safety notes as for "int_new_ex_data" */
491static void int_free_ex_data(int class_index, void *obj,
492 CRYPTO_EX_DATA *ad)
493 {
494 int mx,i;
495 EX_CLASS_ITEM *item;
496 void *ptr;
497 CRYPTO_EX_DATA_FUNCS **storage = NULL;
498 if((item = def_get_class(class_index)) == NULL)
499 return;
500 CRYPTO_r_lock(CRYPTO_LOCK_EX_DATA);
501 mx = sk_CRYPTO_EX_DATA_FUNCS_num(item->meth);
502 if(mx > 0)
503 {
504 storage = OPENSSL_malloc(mx * sizeof(CRYPTO_EX_DATA_FUNCS*));
505 if(!storage)
506 goto skip;
507 for(i = 0; i < mx; i++)
508 storage[i] = sk_CRYPTO_EX_DATA_FUNCS_value(item->meth,i);
509 }
510skip:
511 CRYPTO_r_unlock(CRYPTO_LOCK_EX_DATA);
512 if((mx > 0) && !storage)
513 {
514 CRYPTOerr(CRYPTO_F_INT_FREE_EX_DATA,ERR_R_MALLOC_FAILURE);
515 return;
516 }
517 for(i = 0; i < mx; i++)
518 {
519 if(storage[i] && storage[i]->free_func)
520 {
521 ptr = CRYPTO_get_ex_data(ad,i);
522 storage[i]->free_func(obj,ptr,ad,i,
523 storage[i]->argl,storage[i]->argp);
524 }
525 }
526 if(storage)
527 OPENSSL_free(storage);
528 if(ad->sk)
529 {
530 sk_free(ad->sk);
531 ad->sk=NULL;
532 }
533 }
534
535/********************************************************************/
536/* API functions that defer all "state" operations to the "ex_data"
537 * implementation we have set. */
538
539/* Obtain an index for a new class (not the same as getting a new index within
540 * an existing class - this is actually getting a new *class*) */
541int CRYPTO_ex_data_new_class(void)
542 {
543 IMPL_CHECK
544 return EX_IMPL(new_class)();
545 }
546
547/* Release all "ex_data" state to prevent memory leaks. This can't be made
548 * thread-safe without overhauling a lot of stuff, and shouldn't really be
549 * called under potential race-conditions anyway (it's for program shutdown
550 * after all). */
551void CRYPTO_cleanup_all_ex_data(void)
552 {
553 IMPL_CHECK
554 EX_IMPL(cleanup)();
555 }
556
557/* Inside an existing class, get/register a new index. */
558int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,
559 CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
560 CRYPTO_EX_free *free_func)
561 {
562 int ret = -1;
563
564 IMPL_CHECK
565 ret = EX_IMPL(get_new_index)(class_index,
566 argl, argp, new_func, dup_func, free_func);
567 return ret;
568 }
569
570/* Initialise a new CRYPTO_EX_DATA for use in a particular class - including
571 * calling new() callbacks for each index in the class used by this variable */
572int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)
573 {
574 IMPL_CHECK
575 return EX_IMPL(new_ex_data)(class_index, obj, ad);
576 }
577
578/* Duplicate a CRYPTO_EX_DATA variable - including calling dup() callbacks for
579 * each index in the class used by this variable */
580int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
581 CRYPTO_EX_DATA *from)
582 {
583 IMPL_CHECK
584 return EX_IMPL(dup_ex_data)(class_index, to, from);
585 }
586
587/* Cleanup a CRYPTO_EX_DATA variable - including calling free() callbacks for
588 * each index in the class used by this variable */
589void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)
590 {
591 IMPL_CHECK
592 EX_IMPL(free_ex_data)(class_index, obj, ad);
593 }
594
595/* For a given CRYPTO_EX_DATA variable, set the value corresponding to a
596 * particular index in the class used by this variable */
107int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val) 597int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val)
108 { 598 {
109 int i; 599 int i;
@@ -131,7 +621,9 @@ int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val)
131 return(1); 621 return(1);
132 } 622 }
133 623
134void *CRYPTO_get_ex_data(CRYPTO_EX_DATA *ad, int idx) 624/* For a given CRYPTO_EX_DATA_ variable, get the value corresponding to a
625 * particular index in the class used by this variable */
626void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
135 { 627 {
136 if (ad->sk == NULL) 628 if (ad->sk == NULL)
137 return(0); 629 return(0);
@@ -141,83 +633,4 @@ void *CRYPTO_get_ex_data(CRYPTO_EX_DATA *ad, int idx)
141 return(sk_value(ad->sk,idx)); 633 return(sk_value(ad->sk,idx));
142 } 634 }
143 635
144/* The callback is called with the 'object', which is the original data object
145 * being duplicated, a pointer to the
146 * 'new' object to be inserted, the index, and the argi/argp
147 */
148int CRYPTO_dup_ex_data(STACK_OF(CRYPTO_EX_DATA_FUNCS) *meth, CRYPTO_EX_DATA *to,
149 CRYPTO_EX_DATA *from)
150 {
151 int i,j,m,r;
152 CRYPTO_EX_DATA_FUNCS *mm;
153 char *from_d;
154
155 if (meth == NULL) return(1);
156 if (from->sk == NULL) return(1);
157 m=sk_CRYPTO_EX_DATA_FUNCS_num(meth);
158 j=sk_num(from->sk);
159 for (i=0; i<j; i++)
160 {
161 from_d=CRYPTO_get_ex_data(from,i);
162 if (i < m)
163 {
164 mm=sk_CRYPTO_EX_DATA_FUNCS_value(meth,i);
165 if (mm->dup_func != NULL)
166 r=mm->dup_func(to,from,(char **)&from_d,i,
167 mm->argl,mm->argp);
168 }
169 CRYPTO_set_ex_data(to,i,from_d);
170 }
171 return(1);
172 }
173
174/* Call each free callback */
175void CRYPTO_free_ex_data(STACK_OF(CRYPTO_EX_DATA_FUNCS) *meth, void *obj, CRYPTO_EX_DATA *ad)
176 {
177 CRYPTO_EX_DATA_FUNCS *m;
178 void *ptr;
179 int i,max;
180
181 if (meth != NULL)
182 {
183 max=sk_CRYPTO_EX_DATA_FUNCS_num(meth);
184 for (i=0; i<max; i++)
185 {
186 m=sk_CRYPTO_EX_DATA_FUNCS_value(meth,i);
187 if ((m != NULL) && (m->free_func != NULL))
188 {
189 ptr=CRYPTO_get_ex_data(ad,i);
190 m->free_func(obj,ptr,ad,i,m->argl,m->argp);
191 }
192 }
193 }
194 if (ad->sk != NULL)
195 {
196 sk_free(ad->sk);
197 ad->sk=NULL;
198 }
199 }
200
201void CRYPTO_new_ex_data(STACK_OF(CRYPTO_EX_DATA_FUNCS) *meth, void *obj, CRYPTO_EX_DATA *ad)
202 {
203 CRYPTO_EX_DATA_FUNCS *m;
204 void *ptr;
205 int i,max;
206
207 ad->sk=NULL;
208 if (meth != NULL)
209 {
210 max=sk_CRYPTO_EX_DATA_FUNCS_num(meth);
211 for (i=0; i<max; i++)
212 {
213 m=sk_CRYPTO_EX_DATA_FUNCS_value(meth,i);
214 if ((m != NULL) && (m->new_func != NULL))
215 {
216 ptr=CRYPTO_get_ex_data(ad,i);
217 m->new_func(obj,ptr,ad,i,m->argl,m->argp);
218 }
219 }
220 }
221 }
222
223IMPLEMENT_STACK_OF(CRYPTO_EX_DATA_FUNCS) 636IMPLEMENT_STACK_OF(CRYPTO_EX_DATA_FUNCS)
diff --git a/src/lib/libcrypto/hmac/Makefile.ssl b/src/lib/libcrypto/hmac/Makefile.ssl
index 326339a90d..899d67c43b 100644
--- a/src/lib/libcrypto/hmac/Makefile.ssl
+++ b/src/lib/libcrypto/hmac/Makefile.ssl
@@ -11,7 +11,8 @@ INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl 11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl 12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl 13MAKE= make -f Makefile.ssl
14MAKEDEPEND= $(TOP)/util/domd $(TOP) 14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
15MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
16AR= ar r 17AR= ar r
17 18
@@ -39,8 +40,7 @@ all: lib
39 40
40lib: $(LIBOBJ) 41lib: $(LIBOBJ)
41 $(AR) $(LIB) $(LIBOBJ) 42 $(AR) $(LIB) $(LIBOBJ)
42 @echo You may get an error following this line. Please ignore. 43 $(RANLIB) $(LIB) || echo Never mind.
43 - $(RANLIB) $(LIB)
44 @touch lib 44 @touch lib
45 45
46files: 46files:
@@ -80,17 +80,10 @@ clean:
80# DO NOT DELETE THIS LINE -- make depend depends on it. 80# DO NOT DELETE THIS LINE -- make depend depends on it.
81 81
82hmac.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 82hmac.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
83hmac.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 83hmac.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
84hmac.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h 84hmac.o: ../../include/openssl/e_os2.h ../../include/openssl/evp.h
85hmac.o: ../../include/openssl/des.h ../../include/openssl/dh.h 85hmac.o: ../../include/openssl/hmac.h ../../include/openssl/obj_mac.h
86hmac.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
87hmac.o: ../../include/openssl/evp.h ../../include/openssl/hmac.h
88hmac.o: ../../include/openssl/idea.h ../../include/openssl/md2.h
89hmac.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
90hmac.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
91hmac.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 86hmac.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
92hmac.o: ../../include/openssl/opensslv.h ../../include/openssl/rc2.h 87hmac.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
93hmac.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 88hmac.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
94hmac.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 89hmac.o: ../../include/openssl/symhacks.h hmac.c
95hmac.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
96hmac.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
diff --git a/src/lib/libcrypto/hmac/hmac.c b/src/lib/libcrypto/hmac/hmac.c
index e1ec79e093..026dbe8f66 100644
--- a/src/lib/libcrypto/hmac/hmac.c
+++ b/src/lib/libcrypto/hmac/hmac.c
@@ -60,8 +60,8 @@
60#include <string.h> 60#include <string.h>
61#include <openssl/hmac.h> 61#include <openssl/hmac.h>
62 62
63void HMAC_Init(HMAC_CTX *ctx, const void *key, int len, 63void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
64 const EVP_MD *md) 64 const EVP_MD *md, ENGINE *impl)
65 { 65 {
66 int i,j,reset=0; 66 int i,j,reset=0;
67 unsigned char pad[HMAC_MAX_MD_CBLOCK]; 67 unsigned char pad[HMAC_MAX_MD_CBLOCK];
@@ -70,8 +70,9 @@ void HMAC_Init(HMAC_CTX *ctx, const void *key, int len,
70 { 70 {
71 reset=1; 71 reset=1;
72 ctx->md=md; 72 ctx->md=md;
73 EVP_MD_CTX_init(&ctx->md_ctx);
73 } 74 }
74 else 75 else
75 md=ctx->md; 76 md=ctx->md;
76 77
77 if (key != NULL) 78 if (key != NULL)
@@ -80,9 +81,9 @@ void HMAC_Init(HMAC_CTX *ctx, const void *key, int len,
80 j=EVP_MD_block_size(md); 81 j=EVP_MD_block_size(md);
81 if (j < len) 82 if (j < len)
82 { 83 {
83 EVP_DigestInit(&ctx->md_ctx,md); 84 EVP_DigestInit_ex(&ctx->md_ctx,md, impl);
84 EVP_DigestUpdate(&ctx->md_ctx,key,len); 85 EVP_DigestUpdate(&ctx->md_ctx,key,len);
85 EVP_DigestFinal(&(ctx->md_ctx),ctx->key, 86 EVP_DigestFinal_ex(&(ctx->md_ctx),ctx->key,
86 &ctx->key_length); 87 &ctx->key_length);
87 } 88 }
88 else 89 else
@@ -99,21 +100,28 @@ void HMAC_Init(HMAC_CTX *ctx, const void *key, int len,
99 { 100 {
100 for (i=0; i<HMAC_MAX_MD_CBLOCK; i++) 101 for (i=0; i<HMAC_MAX_MD_CBLOCK; i++)
101 pad[i]=0x36^ctx->key[i]; 102 pad[i]=0x36^ctx->key[i];
102 EVP_DigestInit(&ctx->i_ctx,md); 103 EVP_DigestInit_ex(&ctx->i_ctx,md, impl);
103 EVP_DigestUpdate(&ctx->i_ctx,pad,EVP_MD_block_size(md)); 104 EVP_DigestUpdate(&ctx->i_ctx,pad,EVP_MD_block_size(md));
104 105
105 for (i=0; i<HMAC_MAX_MD_CBLOCK; i++) 106 for (i=0; i<HMAC_MAX_MD_CBLOCK; i++)
106 pad[i]=0x5c^ctx->key[i]; 107 pad[i]=0x5c^ctx->key[i];
107 EVP_DigestInit(&ctx->o_ctx,md); 108 EVP_DigestInit_ex(&ctx->o_ctx,md, impl);
108 EVP_DigestUpdate(&ctx->o_ctx,pad,EVP_MD_block_size(md)); 109 EVP_DigestUpdate(&ctx->o_ctx,pad,EVP_MD_block_size(md));
109 } 110 }
111 EVP_MD_CTX_copy_ex(&ctx->md_ctx,&ctx->i_ctx);
112 }
110 113
111 memcpy(&ctx->md_ctx,&ctx->i_ctx,sizeof(ctx->i_ctx)); 114void HMAC_Init(HMAC_CTX *ctx, const void *key, int len,
115 const EVP_MD *md)
116 {
117 if(key && md)
118 HMAC_CTX_init(ctx);
119 HMAC_Init_ex(ctx,key,len,md, NULL);
112 } 120 }
113 121
114void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, int len) 122void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, int len)
115 { 123 {
116 EVP_DigestUpdate(&(ctx->md_ctx),data,len); 124 EVP_DigestUpdate(&ctx->md_ctx,data,len);
117 } 125 }
118 126
119void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len) 127void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len)
@@ -124,15 +132,25 @@ void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len)
124 132
125 j=EVP_MD_block_size(ctx->md); 133 j=EVP_MD_block_size(ctx->md);
126 134
127 EVP_DigestFinal(&(ctx->md_ctx),buf,&i); 135 EVP_DigestFinal_ex(&ctx->md_ctx,buf,&i);
128 memcpy(&(ctx->md_ctx),&(ctx->o_ctx),sizeof(ctx->o_ctx)); 136 EVP_MD_CTX_copy_ex(&ctx->md_ctx,&ctx->o_ctx);
129 EVP_DigestUpdate(&(ctx->md_ctx),buf,i); 137 EVP_DigestUpdate(&ctx->md_ctx,buf,i);
130 EVP_DigestFinal(&(ctx->md_ctx),md,len); 138 EVP_DigestFinal_ex(&ctx->md_ctx,md,len);
139 }
140
141void HMAC_CTX_init(HMAC_CTX *ctx)
142 {
143 EVP_MD_CTX_init(&ctx->i_ctx);
144 EVP_MD_CTX_init(&ctx->o_ctx);
145 EVP_MD_CTX_init(&ctx->md_ctx);
131 } 146 }
132 147
133void HMAC_cleanup(HMAC_CTX *ctx) 148void HMAC_CTX_cleanup(HMAC_CTX *ctx)
134 { 149 {
135 memset(ctx,0,sizeof(HMAC_CTX)); 150 EVP_MD_CTX_cleanup(&ctx->i_ctx);
151 EVP_MD_CTX_cleanup(&ctx->o_ctx);
152 EVP_MD_CTX_cleanup(&ctx->md_ctx);
153 memset(ctx,0,sizeof *ctx);
136 } 154 }
137 155
138unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len, 156unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len,
@@ -143,10 +161,11 @@ unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len,
143 static unsigned char m[EVP_MAX_MD_SIZE]; 161 static unsigned char m[EVP_MAX_MD_SIZE];
144 162
145 if (md == NULL) md=m; 163 if (md == NULL) md=m;
164 HMAC_CTX_init(&c);
146 HMAC_Init(&c,key,key_len,evp_md); 165 HMAC_Init(&c,key,key_len,evp_md);
147 HMAC_Update(&c,d,n); 166 HMAC_Update(&c,d,n);
148 HMAC_Final(&c,md,md_len); 167 HMAC_Final(&c,md,md_len);
149 HMAC_cleanup(&c); 168 HMAC_CTX_cleanup(&c);
150 return(md); 169 return(md);
151 } 170 }
152 171
diff --git a/src/lib/libcrypto/hmac/hmac.h b/src/lib/libcrypto/hmac/hmac.h
index 328bad2608..0364a1fcbd 100644
--- a/src/lib/libcrypto/hmac/hmac.h
+++ b/src/lib/libcrypto/hmac/hmac.h
@@ -58,7 +58,7 @@
58#ifndef HEADER_HMAC_H 58#ifndef HEADER_HMAC_H
59#define HEADER_HMAC_H 59#define HEADER_HMAC_H
60 60
61#ifdef NO_HMAC 61#ifdef OPENSSL_NO_HMAC
62#error HMAC is disabled. 62#error HMAC is disabled.
63#endif 63#endif
64 64
@@ -83,11 +83,17 @@ typedef struct hmac_ctx_st
83#define HMAC_size(e) (EVP_MD_size((e)->md)) 83#define HMAC_size(e) (EVP_MD_size((e)->md))
84 84
85 85
86void HMAC_CTX_init(HMAC_CTX *ctx);
87void HMAC_CTX_cleanup(HMAC_CTX *ctx);
88
89#define HMAC_cleanup(ctx) HMAC_CTX_cleanup(ctx) /* deprecated */
90
86void HMAC_Init(HMAC_CTX *ctx, const void *key, int len, 91void HMAC_Init(HMAC_CTX *ctx, const void *key, int len,
87 const EVP_MD *md); 92 const EVP_MD *md); /* deprecated */
93void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
94 const EVP_MD *md, ENGINE *impl);
88void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, int len); 95void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, int len);
89void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len); 96void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len);
90void HMAC_cleanup(HMAC_CTX *ctx);
91unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len, 97unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len,
92 const unsigned char *d, int n, unsigned char *md, 98 const unsigned char *d, int n, unsigned char *md,
93 unsigned int *md_len); 99 unsigned int *md_len);
diff --git a/src/lib/libcrypto/hmac/hmactest.c b/src/lib/libcrypto/hmac/hmactest.c
index 4b56b8ee13..96d3beb8e6 100644
--- a/src/lib/libcrypto/hmac/hmactest.c
+++ b/src/lib/libcrypto/hmac/hmactest.c
@@ -60,7 +60,7 @@
60#include <string.h> 60#include <string.h>
61#include <stdlib.h> 61#include <stdlib.h>
62 62
63#ifdef NO_HMAC 63#ifdef OPENSSL_NO_HMAC
64int main(int argc, char *argv[]) 64int main(int argc, char *argv[])
65{ 65{
66 printf("No HMAC support\n"); 66 printf("No HMAC support\n");
@@ -68,6 +68,7 @@ int main(int argc, char *argv[])
68} 68}
69#else 69#else
70#include <openssl/hmac.h> 70#include <openssl/hmac.h>
71#include <openssl/md5.h>
71 72
72#ifdef CHARSET_EBCDIC 73#ifdef CHARSET_EBCDIC
73#include <openssl/ebcdic.h> 74#include <openssl/ebcdic.h>
diff --git a/src/lib/libcrypto/idea/Makefile.ssl b/src/lib/libcrypto/idea/Makefile.ssl
index 30302e0b9f..217e6e0136 100644
--- a/src/lib/libcrypto/idea/Makefile.ssl
+++ b/src/lib/libcrypto/idea/Makefile.ssl
@@ -11,7 +11,8 @@ INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl 11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl 12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl 13MAKE= make -f Makefile.ssl
14MAKEDEPEND= $(TOP)/util/domd $(TOP) 14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
15MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
16AR= ar r 17AR= ar r
17 18
@@ -39,8 +40,7 @@ all: lib
39 40
40lib: $(LIBOBJ) 41lib: $(LIBOBJ)
41 $(AR) $(LIB) $(LIBOBJ) 42 $(AR) $(LIB) $(LIBOBJ)
42 @echo You may get an error following this line. Please ignore. 43 $(RANLIB) $(LIB) || echo Never mind.
43 - $(RANLIB) $(LIB)
44 @touch lib 44 @touch lib
45 45
46files: 46files:
@@ -80,12 +80,12 @@ clean:
80# DO NOT DELETE THIS LINE -- make depend depends on it. 80# DO NOT DELETE THIS LINE -- make depend depends on it.
81 81
82i_cbc.o: ../../include/openssl/idea.h ../../include/openssl/opensslconf.h 82i_cbc.o: ../../include/openssl/idea.h ../../include/openssl/opensslconf.h
83i_cbc.o: idea_lcl.h 83i_cbc.o: i_cbc.c idea_lcl.h
84i_cfb64.o: ../../include/openssl/idea.h ../../include/openssl/opensslconf.h 84i_cfb64.o: ../../include/openssl/idea.h ../../include/openssl/opensslconf.h
85i_cfb64.o: idea_lcl.h 85i_cfb64.o: i_cfb64.c idea_lcl.h
86i_ecb.o: ../../include/openssl/idea.h ../../include/openssl/opensslconf.h 86i_ecb.o: ../../include/openssl/idea.h ../../include/openssl/opensslconf.h
87i_ecb.o: ../../include/openssl/opensslv.h idea_lcl.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 88i_ofb64.o: ../../include/openssl/idea.h ../../include/openssl/opensslconf.h
89i_ofb64.o: idea_lcl.h 89i_ofb64.o: i_ofb64.c idea_lcl.h
90i_skey.o: ../../include/openssl/idea.h ../../include/openssl/opensslconf.h 90i_skey.o: ../../include/openssl/idea.h ../../include/openssl/opensslconf.h
91i_skey.o: idea_lcl.h 91i_skey.o: i_skey.c idea_lcl.h
diff --git a/src/lib/libcrypto/idea/idea.h b/src/lib/libcrypto/idea/idea.h
index f14adf8398..67132414ee 100644
--- a/src/lib/libcrypto/idea/idea.h
+++ b/src/lib/libcrypto/idea/idea.h
@@ -59,7 +59,7 @@
59#ifndef HEADER_IDEA_H 59#ifndef HEADER_IDEA_H
60#define HEADER_IDEA_H 60#define HEADER_IDEA_H
61 61
62#ifdef NO_IDEA 62#ifdef OPENSSL_NO_IDEA
63#error IDEA is disabled. 63#error IDEA is disabled.
64#endif 64#endif
65 65
diff --git a/src/lib/libcrypto/install.com b/src/lib/libcrypto/install.com
index ea97665471..b3d155e964 100644
--- a/src/lib/libcrypto/install.com
+++ b/src/lib/libcrypto/install.com
@@ -34,10 +34,12 @@ $ IF F$PARSE("WRK_SSLINCLUDE:") .EQS. "" THEN -
34$ 34$
35$ SDIRS := ,MD2,MD4,MD5,SHA,MDC2,HMAC,RIPEMD,- 35$ SDIRS := ,MD2,MD4,MD5,SHA,MDC2,HMAC,RIPEMD,-
36 DES,RC2,RC4,RC5,IDEA,BF,CAST,- 36 DES,RC2,RC4,RC5,IDEA,BF,CAST,-
37 BN,RSA,DSA,DH,DSO,ENGINE,- 37 BN,EC,RSA,DSA,DH,DSO,ENGINE,AES,-
38 BUFFER,BIO,STACK,LHASH,RAND,ERR,OBJECTS,- 38 BUFFER,BIO,STACK,LHASH,RAND,ERR,OBJECTS,-
39 EVP,ASN1,PEM,X509,X509V3,CONF,TXT_DB,PKCS7,PKCS12,COMP 39 EVP,ASN1,PEM,X509,X509V3,CONF,TXT_DB,PKCS7,PKCS12,COMP,OCSP,-
40$ EXHEADER_ := crypto.h,tmdiff.h,opensslv.h,opensslconf.h,ebcdic.h,symhacks.h 40 UI,KRB5
41$ EXHEADER_ := crypto.h,tmdiff.h,opensslv.h,opensslconf.h,ebcdic.h,-
42 symhacks.h,ossl_typ.h
41$ EXHEADER_MD2 := md2.h 43$ EXHEADER_MD2 := md2.h
42$ EXHEADER_MD4 := md4.h 44$ EXHEADER_MD4 := md4.h
43$ EXHEADER_MD5 := md5.h 45$ EXHEADER_MD5 := md5.h
@@ -45,7 +47,7 @@ $ EXHEADER_SHA := sha.h
45$ EXHEADER_MDC2 := mdc2.h 47$ EXHEADER_MDC2 := mdc2.h
46$ EXHEADER_HMAC := hmac.h 48$ EXHEADER_HMAC := hmac.h
47$ EXHEADER_RIPEMD := ripemd.h 49$ EXHEADER_RIPEMD := ripemd.h
48$ EXHEADER_DES := des.h 50$ EXHEADER_DES := des.h,des_old.h
49$ EXHEADER_RC2 := rc2.h 51$ EXHEADER_RC2 := rc2.h
50$ EXHEADER_RC4 := rc4.h 52$ EXHEADER_RC4 := rc4.h
51$ EXHEADER_RC5 := rc5.h 53$ EXHEADER_RC5 := rc5.h
@@ -53,11 +55,13 @@ $ EXHEADER_IDEA := idea.h
53$ EXHEADER_BF := blowfish.h 55$ EXHEADER_BF := blowfish.h
54$ EXHEADER_CAST := cast.h 56$ EXHEADER_CAST := cast.h
55$ EXHEADER_BN := bn.h 57$ EXHEADER_BN := bn.h
58$ EXHEADER_EC := ec.h
56$ EXHEADER_RSA := rsa.h 59$ EXHEADER_RSA := rsa.h
57$ EXHEADER_DSA := dsa.h 60$ EXHEADER_DSA := dsa.h
58$ EXHEADER_DH := dh.h 61$ EXHEADER_DH := dh.h
59$ EXHEADER_DSO := dso.h 62$ EXHEADER_DSO := dso.h
60$ EXHEADER_ENGINE := engine.h 63$ EXHEADER_ENGINE := engine.h
64$ EXHEADER_AES := aes.h
61$ EXHEADER_BUFFER := buffer.h 65$ EXHEADER_BUFFER := buffer.h
62$ EXHEADER_BIO := bio.h 66$ EXHEADER_BIO := bio.h
63$ EXHEADER_STACK := stack.h,safestack.h 67$ EXHEADER_STACK := stack.h,safestack.h
@@ -66,7 +70,7 @@ $ EXHEADER_RAND := rand.h
66$ EXHEADER_ERR := err.h 70$ EXHEADER_ERR := err.h
67$ EXHEADER_OBJECTS := objects.h,obj_mac.h 71$ EXHEADER_OBJECTS := objects.h,obj_mac.h
68$ EXHEADER_EVP := evp.h 72$ EXHEADER_EVP := evp.h
69$ EXHEADER_ASN1 := asn1.h,asn1_mac.h 73$ EXHEADER_ASN1 := asn1.h,asn1_mac.h,asn1t.h
70$ EXHEADER_PEM := pem.h,pem2.h 74$ EXHEADER_PEM := pem.h,pem2.h
71$ EXHEADER_X509 := x509.h,x509_vfy.h 75$ EXHEADER_X509 := x509.h,x509_vfy.h
72$ EXHEADER_X509V3 := x509v3.h 76$ EXHEADER_X509V3 := x509v3.h
@@ -75,6 +79,9 @@ $ EXHEADER_TXT_DB := txt_db.h
75$ EXHEADER_PKCS7 := pkcs7.h 79$ EXHEADER_PKCS7 := pkcs7.h
76$ EXHEADER_PKCS12 := pkcs12.h 80$ EXHEADER_PKCS12 := pkcs12.h
77$ EXHEADER_COMP := comp.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
78$ LIBS := LIBCRYPTO 85$ LIBS := LIBCRYPTO
79$ 86$
80$ VEXE_DIR := [-.VAX.EXE.CRYPTO] 87$ VEXE_DIR := [-.VAX.EXE.CRYPTO]
diff --git a/src/lib/libcrypto/krb5/Makefile.ssl b/src/lib/libcrypto/krb5/Makefile.ssl
new file mode 100644
index 0000000000..6dd4449e1e
--- /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 $(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) $(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/krb5/krb5_asn.c b/src/lib/libcrypto/krb5/krb5_asn.c
new file mode 100644
index 0000000000..1fb741d2a0
--- /dev/null
+++ b/src/lib/libcrypto/krb5/krb5_asn.c
@@ -0,0 +1,167 @@
1/* krb5_asn.c */
2/* Written by Vern Staats <staatsvr@asc.hpc.mil> for the OpenSSL project,
3** using ocsp/{*.h,*asn*.c} as a starting point
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#include <openssl/asn1.h>
59#include <openssl/asn1t.h>
60#include <openssl/krb5_asn.h>
61
62
63ASN1_SEQUENCE(KRB5_ENCDATA) = {
64 ASN1_EXP(KRB5_ENCDATA, etype, ASN1_INTEGER, 0),
65 ASN1_EXP_OPT(KRB5_ENCDATA, kvno, ASN1_INTEGER, 1),
66 ASN1_EXP(KRB5_ENCDATA, cipher, ASN1_OCTET_STRING,2)
67} ASN1_SEQUENCE_END(KRB5_ENCDATA)
68
69IMPLEMENT_ASN1_FUNCTIONS(KRB5_ENCDATA)
70
71
72ASN1_SEQUENCE(KRB5_PRINCNAME) = {
73 ASN1_EXP(KRB5_PRINCNAME, nametype, ASN1_INTEGER, 0),
74 ASN1_EXP_SEQUENCE_OF(KRB5_PRINCNAME, namestring, ASN1_GENERALSTRING, 1)
75} ASN1_SEQUENCE_END(KRB5_PRINCNAME)
76
77IMPLEMENT_ASN1_FUNCTIONS(KRB5_PRINCNAME)
78
79
80/* [APPLICATION 1] = 0x61 */
81ASN1_SEQUENCE(KRB5_TKTBODY) = {
82 ASN1_EXP(KRB5_TKTBODY, tktvno, ASN1_INTEGER, 0),
83 ASN1_EXP(KRB5_TKTBODY, realm, ASN1_GENERALSTRING, 1),
84 ASN1_EXP(KRB5_TKTBODY, sname, KRB5_PRINCNAME, 2),
85 ASN1_EXP(KRB5_TKTBODY, encdata, KRB5_ENCDATA, 3)
86} ASN1_SEQUENCE_END(KRB5_TKTBODY)
87
88IMPLEMENT_ASN1_FUNCTIONS(KRB5_TKTBODY)
89
90
91ASN1_ITEM_TEMPLATE(KRB5_TICKET) =
92 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_EXPTAG|ASN1_TFLG_APPLICATION, 1,
93 KRB5_TICKET, KRB5_TKTBODY)
94ASN1_ITEM_TEMPLATE_END(KRB5_TICKET)
95
96IMPLEMENT_ASN1_FUNCTIONS(KRB5_TICKET)
97
98
99/* [APPLICATION 14] = 0x6e */
100ASN1_SEQUENCE(KRB5_APREQBODY) = {
101 ASN1_EXP(KRB5_APREQBODY, pvno, ASN1_INTEGER, 0),
102 ASN1_EXP(KRB5_APREQBODY, msgtype, ASN1_INTEGER, 1),
103 ASN1_EXP(KRB5_APREQBODY, apoptions, ASN1_BIT_STRING, 2),
104 ASN1_EXP(KRB5_APREQBODY, ticket, KRB5_TICKET, 3),
105 ASN1_EXP(KRB5_APREQBODY, authenticator, KRB5_ENCDATA, 4),
106} ASN1_SEQUENCE_END(KRB5_APREQBODY)
107
108IMPLEMENT_ASN1_FUNCTIONS(KRB5_APREQBODY)
109
110ASN1_ITEM_TEMPLATE(KRB5_APREQ) =
111 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_EXPTAG|ASN1_TFLG_APPLICATION, 14,
112 KRB5_APREQ, KRB5_APREQBODY)
113ASN1_ITEM_TEMPLATE_END(KRB5_APREQ)
114
115IMPLEMENT_ASN1_FUNCTIONS(KRB5_APREQ)
116
117
118/* Authenticator stuff */
119
120ASN1_SEQUENCE(KRB5_CHECKSUM) = {
121 ASN1_EXP(KRB5_CHECKSUM, ctype, ASN1_INTEGER, 0),
122 ASN1_EXP(KRB5_CHECKSUM, checksum, ASN1_OCTET_STRING,1)
123} ASN1_SEQUENCE_END(KRB5_CHECKSUM)
124
125IMPLEMENT_ASN1_FUNCTIONS(KRB5_CHECKSUM)
126
127
128ASN1_SEQUENCE(KRB5_ENCKEY) = {
129 ASN1_EXP(KRB5_ENCKEY, ktype, ASN1_INTEGER, 0),
130 ASN1_EXP(KRB5_ENCKEY, keyvalue, ASN1_OCTET_STRING,1)
131} ASN1_SEQUENCE_END(KRB5_ENCKEY)
132
133IMPLEMENT_ASN1_FUNCTIONS(KRB5_ENCKEY)
134
135
136/* SEQ OF SEQ; see ASN1_EXP_SEQUENCE_OF_OPT() below */
137ASN1_SEQUENCE(KRB5_AUTHDATA) = {
138 ASN1_EXP(KRB5_AUTHDATA, adtype, ASN1_INTEGER, 0),
139 ASN1_EXP(KRB5_AUTHDATA, addata, ASN1_OCTET_STRING,1)
140} ASN1_SEQUENCE_END(KRB5_AUTHDATA)
141
142IMPLEMENT_ASN1_FUNCTIONS(KRB5_AUTHDATA)
143
144
145/* [APPLICATION 2] = 0x62 */
146ASN1_SEQUENCE(KRB5_AUTHENTBODY) = {
147 ASN1_EXP(KRB5_AUTHENTBODY, avno, ASN1_INTEGER, 0),
148 ASN1_EXP(KRB5_AUTHENTBODY, crealm, ASN1_GENERALSTRING, 1),
149 ASN1_EXP(KRB5_AUTHENTBODY, cname, KRB5_PRINCNAME, 2),
150 ASN1_EXP_OPT(KRB5_AUTHENTBODY, cksum, KRB5_CHECKSUM, 3),
151 ASN1_EXP(KRB5_AUTHENTBODY, cusec, ASN1_INTEGER, 4),
152 ASN1_EXP(KRB5_AUTHENTBODY, ctime, ASN1_GENERALIZEDTIME, 5),
153 ASN1_EXP_OPT(KRB5_AUTHENTBODY, subkey, KRB5_ENCKEY, 6),
154 ASN1_EXP_OPT(KRB5_AUTHENTBODY, seqnum, ASN1_INTEGER, 7),
155 ASN1_EXP_SEQUENCE_OF_OPT
156 (KRB5_AUTHENTBODY, authorization, KRB5_AUTHDATA, 8),
157} ASN1_SEQUENCE_END(KRB5_AUTHENTBODY)
158
159IMPLEMENT_ASN1_FUNCTIONS(KRB5_AUTHENTBODY)
160
161ASN1_ITEM_TEMPLATE(KRB5_AUTHENT) =
162 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_EXPTAG|ASN1_TFLG_APPLICATION, 2,
163 KRB5_AUTHENT, KRB5_AUTHENTBODY)
164ASN1_ITEM_TEMPLATE_END(KRB5_AUTHENT)
165
166IMPLEMENT_ASN1_FUNCTIONS(KRB5_AUTHENT)
167
diff --git a/src/lib/libcrypto/krb5/krb5_asn.h b/src/lib/libcrypto/krb5/krb5_asn.h
new file mode 100644
index 0000000000..3329477b07
--- /dev/null
+++ b/src/lib/libcrypto/krb5/krb5_asn.h
@@ -0,0 +1,256 @@
1/* krb5_asn.h */
2/* Written by Vern Staats <staatsvr@asc.hpc.mil> for the OpenSSL project,
3** using ocsp/{*.h,*asn*.c} as a starting point
4*/
5
6/* ====================================================================
7 * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in
18 * the documentation and/or other materials provided with the
19 * distribution.
20 *
21 * 3. All advertising materials mentioning features or use of this
22 * software must display the following acknowledgment:
23 * "This product includes software developed by the OpenSSL Project
24 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
25 *
26 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27 * endorse or promote products derived from this software without
28 * prior written permission. For written permission, please contact
29 * openssl-core@openssl.org.
30 *
31 * 5. Products derived from this software may not be called "OpenSSL"
32 * nor may "OpenSSL" appear in their names without prior written
33 * permission of the OpenSSL Project.
34 *
35 * 6. Redistributions of any form whatsoever must retain the following
36 * acknowledgment:
37 * "This product includes software developed by the OpenSSL Project
38 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
39 *
40 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
44 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51 * OF THE POSSIBILITY OF SUCH DAMAGE.
52 * ====================================================================
53 *
54 * This product includes cryptographic software written by Eric Young
55 * (eay@cryptsoft.com). This product includes software written by Tim
56 * Hudson (tjh@cryptsoft.com).
57 *
58 */
59
60#ifndef HEADER_KRB5_ASN_H
61#define HEADER_KRB5_ASN_H
62
63/*
64#include <krb5.h>
65*/
66#include <openssl/safestack.h>
67
68#ifdef __cplusplus
69extern "C" {
70#endif
71
72
73/* ASN.1 from Kerberos RFC 1510
74*/
75
76/* EncryptedData ::= SEQUENCE {
77** etype[0] INTEGER, -- EncryptionType
78** kvno[1] INTEGER OPTIONAL,
79** cipher[2] OCTET STRING -- ciphertext
80** }
81*/
82typedef struct krb5_encdata_st
83 {
84 ASN1_INTEGER *etype;
85 ASN1_INTEGER *kvno;
86 ASN1_OCTET_STRING *cipher;
87 } KRB5_ENCDATA;
88
89DECLARE_STACK_OF(KRB5_ENCDATA)
90
91/* PrincipalName ::= SEQUENCE {
92** name-type[0] INTEGER,
93** name-string[1] SEQUENCE OF GeneralString
94** }
95*/
96typedef struct krb5_princname_st
97 {
98 ASN1_INTEGER *nametype;
99 STACK_OF(ASN1_GENERALSTRING) *namestring;
100 } KRB5_PRINCNAME;
101
102DECLARE_STACK_OF(KRB5_PRINCNAME)
103
104
105/* Ticket ::= [APPLICATION 1] SEQUENCE {
106** tkt-vno[0] INTEGER,
107** realm[1] Realm,
108** sname[2] PrincipalName,
109** enc-part[3] EncryptedData
110** }
111*/
112typedef struct krb5_tktbody_st
113 {
114 ASN1_INTEGER *tktvno;
115 ASN1_GENERALSTRING *realm;
116 KRB5_PRINCNAME *sname;
117 KRB5_ENCDATA *encdata;
118 } KRB5_TKTBODY;
119
120typedef STACK_OF(KRB5_TKTBODY) KRB5_TICKET;
121DECLARE_STACK_OF(KRB5_TKTBODY)
122
123
124/* AP-REQ ::= [APPLICATION 14] SEQUENCE {
125** pvno[0] INTEGER,
126** msg-type[1] INTEGER,
127** ap-options[2] APOptions,
128** ticket[3] Ticket,
129** authenticator[4] EncryptedData
130** }
131**
132** APOptions ::= BIT STRING {
133** reserved(0), use-session-key(1), mutual-required(2) }
134*/
135typedef struct krb5_ap_req_st
136 {
137 ASN1_INTEGER *pvno;
138 ASN1_INTEGER *msgtype;
139 ASN1_BIT_STRING *apoptions;
140 KRB5_TICKET *ticket;
141 KRB5_ENCDATA *authenticator;
142 } KRB5_APREQBODY;
143
144typedef STACK_OF(KRB5_APREQBODY) KRB5_APREQ;
145DECLARE_STACK_OF(KRB5_APREQBODY)
146
147
148/* Authenticator Stuff */
149
150
151/* Checksum ::= SEQUENCE {
152** cksumtype[0] INTEGER,
153** checksum[1] OCTET STRING
154** }
155*/
156typedef struct krb5_checksum_st
157 {
158 ASN1_INTEGER *ctype;
159 ASN1_OCTET_STRING *checksum;
160 } KRB5_CHECKSUM;
161
162DECLARE_STACK_OF(KRB5_CHECKSUM)
163
164
165/* EncryptionKey ::= SEQUENCE {
166** keytype[0] INTEGER,
167** keyvalue[1] OCTET STRING
168** }
169*/
170typedef struct krb5_encryptionkey_st
171 {
172 ASN1_INTEGER *ktype;
173 ASN1_OCTET_STRING *keyvalue;
174 } KRB5_ENCKEY;
175
176DECLARE_STACK_OF(KRB5_ENCKEY)
177
178
179/* AuthorizationData ::= SEQUENCE OF SEQUENCE {
180** ad-type[0] INTEGER,
181** ad-data[1] OCTET STRING
182** }
183*/
184typedef struct krb5_authorization_st
185 {
186 ASN1_INTEGER *adtype;
187 ASN1_OCTET_STRING *addata;
188 } KRB5_AUTHDATA;
189
190DECLARE_STACK_OF(KRB5_AUTHDATA)
191
192
193/* -- Unencrypted authenticator
194** Authenticator ::= [APPLICATION 2] SEQUENCE {
195** authenticator-vno[0] INTEGER,
196** crealm[1] Realm,
197** cname[2] PrincipalName,
198** cksum[3] Checksum OPTIONAL,
199** cusec[4] INTEGER,
200** ctime[5] KerberosTime,
201** subkey[6] EncryptionKey OPTIONAL,
202** seq-number[7] INTEGER OPTIONAL,
203** authorization-data[8] AuthorizationData OPTIONAL
204** }
205*/
206typedef struct krb5_authenticator_st
207 {
208 ASN1_INTEGER *avno;
209 ASN1_GENERALSTRING *crealm;
210 KRB5_PRINCNAME *cname;
211 KRB5_CHECKSUM *cksum;
212 ASN1_INTEGER *cusec;
213 ASN1_GENERALIZEDTIME *ctime;
214 KRB5_ENCKEY *subkey;
215 ASN1_INTEGER *seqnum;
216 KRB5_AUTHDATA *authorization;
217 } KRB5_AUTHENTBODY;
218
219typedef STACK_OF(KRB5_AUTHENTBODY) KRB5_AUTHENT;
220DECLARE_STACK_OF(KRB5_AUTHENTBODY)
221
222
223/* DECLARE_ASN1_FUNCTIONS(type) = DECLARE_ASN1_FUNCTIONS_name(type, type) =
224** type *name##_new(void);
225** void name##_free(type *a);
226** DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name) =
227** DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) =
228** type *d2i_##name(type **a, unsigned char **in, long len);
229** int i2d_##name(type *a, unsigned char **out);
230** DECLARE_ASN1_ITEM(itname) = OPENSSL_EXTERN const ASN1_ITEM itname##_it
231*/
232
233DECLARE_ASN1_FUNCTIONS(KRB5_ENCDATA)
234DECLARE_ASN1_FUNCTIONS(KRB5_PRINCNAME)
235DECLARE_ASN1_FUNCTIONS(KRB5_TKTBODY)
236DECLARE_ASN1_FUNCTIONS(KRB5_APREQBODY)
237DECLARE_ASN1_FUNCTIONS(KRB5_TICKET)
238DECLARE_ASN1_FUNCTIONS(KRB5_APREQ)
239
240DECLARE_ASN1_FUNCTIONS(KRB5_CHECKSUM)
241DECLARE_ASN1_FUNCTIONS(KRB5_ENCKEY)
242DECLARE_ASN1_FUNCTIONS(KRB5_AUTHDATA)
243DECLARE_ASN1_FUNCTIONS(KRB5_AUTHENTBODY)
244DECLARE_ASN1_FUNCTIONS(KRB5_AUTHENT)
245
246
247/* BEGIN ERROR CODES */
248/* The following lines are auto generated by the script mkerr.pl. Any changes
249 * made after this point may be overwritten when the script is next run.
250 */
251
252#ifdef __cplusplus
253}
254#endif
255#endif
256
diff --git a/src/lib/libcrypto/lhash/Makefile.ssl b/src/lib/libcrypto/lhash/Makefile.ssl
index 79849d7d6e..1eef09f3fa 100644
--- a/src/lib/libcrypto/lhash/Makefile.ssl
+++ b/src/lib/libcrypto/lhash/Makefile.ssl
@@ -11,7 +11,8 @@ INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl 11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl 12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl 13MAKE= make -f Makefile.ssl
14MAKEDEPEND= $(TOP)/util/domd $(TOP) 14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
15MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
16AR= ar r 17AR= ar r
17 18
@@ -39,8 +40,7 @@ all: lib
39 40
40lib: $(LIBOBJ) 41lib: $(LIBOBJ)
41 $(AR) $(LIB) $(LIBOBJ) 42 $(AR) $(LIB) $(LIBOBJ)
42 @echo You may get an error following this line. Please ignore. 43 $(RANLIB) $(LIB) || echo Never mind.
43 - $(RANLIB) $(LIB)
44 @touch lib 44 @touch lib
45 45
46files: 46files:
@@ -79,14 +79,15 @@ clean:
79 79
80# DO NOT DELETE THIS LINE -- make depend depends on it. 80# DO NOT DELETE THIS LINE -- make depend depends on it.
81 81
82lh_stats.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 82lh_stats.o: ../../e_os.h ../../include/openssl/bio.h
83lh_stats.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 83lh_stats.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
84lh_stats.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 84lh_stats.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
85lh_stats.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 85lh_stats.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
86lh_stats.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 86lh_stats.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
87lh_stats.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 87lh_stats.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
88lh_stats.o: ../cryptlib.h 88lh_stats.o: ../cryptlib.h lh_stats.c
89lhash.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h 89lhash.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
90lhash.o: ../../include/openssl/lhash.h ../../include/openssl/opensslv.h 90lhash.o: ../../include/openssl/e_os2.h ../../include/openssl/lhash.h
91lhash.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
91lhash.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 92lhash.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
92lhash.o: ../../include/openssl/symhacks.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 ee0600060e..39ea2885f4 100644
--- a/src/lib/libcrypto/lhash/lh_stats.c
+++ b/src/lib/libcrypto/lhash/lh_stats.c
@@ -63,12 +63,12 @@
63 * and things should work as expected */ 63 * and things should work as expected */
64#include "cryptlib.h" 64#include "cryptlib.h"
65 65
66#ifndef NO_BIO 66#ifndef OPENSSL_NO_BIO
67#include <openssl/bio.h> 67#include <openssl/bio.h>
68#endif 68#endif
69#include <openssl/lhash.h> 69#include <openssl/lhash.h>
70 70
71#ifdef NO_BIO 71#ifdef OPENSSL_NO_BIO
72 72
73void lh_stats(LHASH *lh, FILE *out) 73void lh_stats(LHASH *lh, FILE *out)
74 { 74 {
@@ -88,7 +88,7 @@ void lh_stats(LHASH *lh, FILE *out)
88 fprintf(out,"num_retrieve = %lu\n",lh->num_retrieve); 88 fprintf(out,"num_retrieve = %lu\n",lh->num_retrieve);
89 fprintf(out,"num_retrieve_miss = %lu\n",lh->num_retrieve_miss); 89 fprintf(out,"num_retrieve_miss = %lu\n",lh->num_retrieve_miss);
90 fprintf(out,"num_hash_comps = %lu\n",lh->num_hash_comps); 90 fprintf(out,"num_hash_comps = %lu\n",lh->num_hash_comps);
91#ifdef DEBUG 91#if 0
92 fprintf(out,"p = %u\n",lh->p); 92 fprintf(out,"p = %u\n",lh->p);
93 fprintf(out,"pmax = %u\n",lh->pmax); 93 fprintf(out,"pmax = %u\n",lh->pmax);
94 fprintf(out,"up_load = %lu\n",lh->up_load); 94 fprintf(out,"up_load = %lu\n",lh->up_load);
@@ -138,8 +138,8 @@ void lh_node_usage_stats(LHASH *lh, FILE *out)
138 138
139#else 139#else
140 140
141#ifndef NO_FP_API 141#ifndef OPENSSL_NO_FP_API
142void lh_stats(LHASH *lh, FILE *fp) 142void lh_stats(const LHASH *lh, FILE *fp)
143 { 143 {
144 BIO *bp; 144 BIO *bp;
145 145
@@ -151,7 +151,7 @@ void lh_stats(LHASH *lh, FILE *fp)
151end:; 151end:;
152 } 152 }
153 153
154void lh_node_stats(LHASH *lh, FILE *fp) 154void lh_node_stats(const LHASH *lh, FILE *fp)
155 { 155 {
156 BIO *bp; 156 BIO *bp;
157 157
@@ -163,7 +163,7 @@ void lh_node_stats(LHASH *lh, FILE *fp)
163end:; 163end:;
164 } 164 }
165 165
166void lh_node_usage_stats(LHASH *lh, FILE *fp) 166void lh_node_usage_stats(const LHASH *lh, FILE *fp)
167 { 167 {
168 BIO *bp; 168 BIO *bp;
169 169
@@ -177,7 +177,7 @@ end:;
177 177
178#endif 178#endif
179 179
180void lh_stats_bio(LHASH *lh, BIO *out) 180void lh_stats_bio(const LHASH *lh, BIO *out)
181 { 181 {
182 char buf[128]; 182 char buf[128];
183 183
@@ -213,7 +213,7 @@ void lh_stats_bio(LHASH *lh, BIO *out)
213 BIO_puts(out,buf); 213 BIO_puts(out,buf);
214 sprintf(buf,"num_hash_comps = %lu\n",lh->num_hash_comps); 214 sprintf(buf,"num_hash_comps = %lu\n",lh->num_hash_comps);
215 BIO_puts(out,buf); 215 BIO_puts(out,buf);
216#ifdef DEBUG 216#if 0
217 sprintf(buf,"p = %u\n",lh->p); 217 sprintf(buf,"p = %u\n",lh->p);
218 BIO_puts(out,buf); 218 BIO_puts(out,buf);
219 sprintf(buf,"pmax = %u\n",lh->pmax); 219 sprintf(buf,"pmax = %u\n",lh->pmax);
@@ -225,7 +225,7 @@ void lh_stats_bio(LHASH *lh, BIO *out)
225#endif 225#endif
226 } 226 }
227 227
228void lh_node_stats_bio(LHASH *lh, BIO *out) 228void lh_node_stats_bio(const LHASH *lh, BIO *out)
229 { 229 {
230 LHASH_NODE *n; 230 LHASH_NODE *n;
231 unsigned int i,num; 231 unsigned int i,num;
@@ -240,7 +240,7 @@ void lh_node_stats_bio(LHASH *lh, BIO *out)
240 } 240 }
241 } 241 }
242 242
243void lh_node_usage_stats_bio(LHASH *lh, BIO *out) 243void lh_node_usage_stats_bio(const LHASH *lh, BIO *out)
244 { 244 {
245 LHASH_NODE *n; 245 LHASH_NODE *n;
246 unsigned long num; 246 unsigned long num;
diff --git a/src/lib/libcrypto/lhash/lh_test.c b/src/lib/libcrypto/lhash/lh_test.c
index 6008781e57..85700c859b 100644
--- a/src/lib/libcrypto/lhash/lh_test.c
+++ b/src/lib/libcrypto/lhash/lh_test.c
@@ -75,7 +75,6 @@ main()
75 buf[0]='\0'; 75 buf[0]='\0';
76 fgets(buf,256,stdin); 76 fgets(buf,256,stdin);
77 if (buf[0] == '\0') break; 77 if (buf[0] == '\0') break;
78 buf[256]='\0';
79 i=strlen(buf); 78 i=strlen(buf);
80 p=OPENSSL_malloc(i+1); 79 p=OPENSSL_malloc(i+1);
81 memcpy(p,buf,i+1); 80 memcpy(p,buf,i+1);
diff --git a/src/lib/libcrypto/lhash/lhash.c b/src/lib/libcrypto/lhash/lhash.c
index 7da14620a4..0a16fcf27d 100644
--- a/src/lib/libcrypto/lhash/lhash.c
+++ b/src/lib/libcrypto/lhash/lhash.c
@@ -109,9 +109,9 @@ const char *lh_version="lhash" OPENSSL_VERSION_PTEXT;
109 109
110static void expand(LHASH *lh); 110static void expand(LHASH *lh);
111static void contract(LHASH *lh); 111static void contract(LHASH *lh);
112static LHASH_NODE **getrn(LHASH *lh, void *data, unsigned long *rhash); 112static LHASH_NODE **getrn(LHASH *lh, const void *data, unsigned long *rhash);
113 113
114LHASH *lh_new(unsigned long (*h)(), int (*c)()) 114LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c)
115 { 115 {
116 LHASH *ret; 116 LHASH *ret;
117 int i; 117 int i;
@@ -122,8 +122,8 @@ LHASH *lh_new(unsigned long (*h)(), int (*c)())
122 goto err1; 122 goto err1;
123 for (i=0; i<MIN_NODES; i++) 123 for (i=0; i<MIN_NODES; i++)
124 ret->b[i]=NULL; 124 ret->b[i]=NULL;
125 ret->comp=((c == NULL)?(int (*)())strcmp:c); 125 ret->comp=((c == NULL)?(LHASH_COMP_FN_TYPE)strcmp:c);
126 ret->hash=((h == NULL)?(unsigned long (*)())lh_strhash:h); 126 ret->hash=((h == NULL)?(LHASH_HASH_FN_TYPE)lh_strhash:h);
127 ret->num_nodes=MIN_NODES/2; 127 ret->num_nodes=MIN_NODES/2;
128 ret->num_alloc_nodes=MIN_NODES; 128 ret->num_alloc_nodes=MIN_NODES;
129 ret->p=0; 129 ret->p=0;
@@ -176,11 +176,11 @@ void lh_free(LHASH *lh)
176 OPENSSL_free(lh); 176 OPENSSL_free(lh);
177 } 177 }
178 178
179void *lh_insert(LHASH *lh, void *data) 179void *lh_insert(LHASH *lh, const void *data)
180 { 180 {
181 unsigned long hash; 181 unsigned long hash;
182 LHASH_NODE *nn,**rn; 182 LHASH_NODE *nn,**rn;
183 void *ret; 183 const void *ret;
184 184
185 lh->error=0; 185 lh->error=0;
186 if (lh->up_load <= (lh->num_items*LH_LOAD_MULT/lh->num_nodes)) 186 if (lh->up_load <= (lh->num_items*LH_LOAD_MULT/lh->num_nodes))
@@ -197,7 +197,7 @@ void *lh_insert(LHASH *lh, void *data)
197 } 197 }
198 nn->data=data; 198 nn->data=data;
199 nn->next=NULL; 199 nn->next=NULL;
200#ifndef NO_HASH_COMP 200#ifndef OPENSSL_NO_HASH_COMP
201 nn->hash=hash; 201 nn->hash=hash;
202#endif 202#endif
203 *rn=nn; 203 *rn=nn;
@@ -211,14 +211,14 @@ void *lh_insert(LHASH *lh, void *data)
211 (*rn)->data=data; 211 (*rn)->data=data;
212 lh->num_replace++; 212 lh->num_replace++;
213 } 213 }
214 return(ret); 214 return((void *)ret);
215 } 215 }
216 216
217void *lh_delete(LHASH *lh, void *data) 217void *lh_delete(LHASH *lh, const void *data)
218 { 218 {
219 unsigned long hash; 219 unsigned long hash;
220 LHASH_NODE *nn,**rn; 220 LHASH_NODE *nn,**rn;
221 void *ret; 221 const void *ret;
222 222
223 lh->error=0; 223 lh->error=0;
224 rn=getrn(lh,data,&hash); 224 rn=getrn(lh,data,&hash);
@@ -242,14 +242,14 @@ void *lh_delete(LHASH *lh, void *data)
242 (lh->down_load >= (lh->num_items*LH_LOAD_MULT/lh->num_nodes))) 242 (lh->down_load >= (lh->num_items*LH_LOAD_MULT/lh->num_nodes)))
243 contract(lh); 243 contract(lh);
244 244
245 return(ret); 245 return((void *)ret);
246 } 246 }
247 247
248void *lh_retrieve(LHASH *lh, void *data) 248void *lh_retrieve(LHASH *lh, const void *data)
249 { 249 {
250 unsigned long hash; 250 unsigned long hash;
251 LHASH_NODE **rn; 251 LHASH_NODE **rn;
252 void *ret; 252 const void *ret;
253 253
254 lh->error=0; 254 lh->error=0;
255 rn=getrn(lh,data,&hash); 255 rn=getrn(lh,data,&hash);
@@ -264,15 +264,11 @@ void *lh_retrieve(LHASH *lh, void *data)
264 ret= (*rn)->data; 264 ret= (*rn)->data;
265 lh->num_retrieve++; 265 lh->num_retrieve++;
266 } 266 }
267 return(ret); 267 return((void *)ret);
268 }
269
270void lh_doall(LHASH *lh, void (*func)())
271 {
272 lh_doall_arg(lh,func,NULL);
273 } 268 }
274 269
275void lh_doall_arg(LHASH *lh, void (*func)(), void *arg) 270static void doall_util_fn(LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func,
271 LHASH_DOALL_ARG_FN_TYPE func_arg, void *arg)
276 { 272 {
277 int i; 273 int i;
278 LHASH_NODE *a,*n; 274 LHASH_NODE *a,*n;
@@ -287,12 +283,25 @@ void lh_doall_arg(LHASH *lh, void (*func)(), void *arg)
287 /* 28/05/91 - eay - n added so items can be deleted 283 /* 28/05/91 - eay - n added so items can be deleted
288 * via lh_doall */ 284 * via lh_doall */
289 n=a->next; 285 n=a->next;
290 func(a->data,arg); 286 if(use_arg)
287 func_arg(a->data,arg);
288 else
289 func(a->data);
291 a=n; 290 a=n;
292 } 291 }
293 } 292 }
294 } 293 }
295 294
295void lh_doall(LHASH *lh, LHASH_DOALL_FN_TYPE func)
296 {
297 doall_util_fn(lh, 0, func, (LHASH_DOALL_ARG_FN_TYPE)0, NULL);
298 }
299
300void lh_doall_arg(LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg)
301 {
302 doall_util_fn(lh, 1, (LHASH_DOALL_FN_TYPE)0, func, arg);
303 }
304
296static void expand(LHASH *lh) 305static void expand(LHASH *lh)
297 { 306 {
298 LHASH_NODE **n,**n1,**n2,*np; 307 LHASH_NODE **n,**n1,**n2,*np;
@@ -309,10 +318,10 @@ static void expand(LHASH *lh)
309 318
310 for (np= *n1; np != NULL; ) 319 for (np= *n1; np != NULL; )
311 { 320 {
312#ifndef NO_HASH_COMP 321#ifndef OPENSSL_NO_HASH_COMP
313 hash=np->hash; 322 hash=np->hash;
314#else 323#else
315 hash=(*(lh->hash))(np->data); 324 hash=lh->hash(np->data);
316 lh->num_hash_calls++; 325 lh->num_hash_calls++;
317#endif 326#endif
318 if ((hash%nni) != p) 327 if ((hash%nni) != p)
@@ -388,7 +397,7 @@ static void contract(LHASH *lh)
388 } 397 }
389 } 398 }
390 399
391static LHASH_NODE **getrn(LHASH *lh, void *data, unsigned long *rhash) 400static LHASH_NODE **getrn(LHASH *lh, const void *data, unsigned long *rhash)
392 { 401 {
393 LHASH_NODE **ret,*n1; 402 LHASH_NODE **ret,*n1;
394 unsigned long hash,nn; 403 unsigned long hash,nn;
@@ -406,7 +415,7 @@ static LHASH_NODE **getrn(LHASH *lh, void *data, unsigned long *rhash)
406 ret= &(lh->b[(int)nn]); 415 ret= &(lh->b[(int)nn]);
407 for (n1= *ret; n1 != NULL; n1=n1->next) 416 for (n1= *ret; n1 != NULL; n1=n1->next)
408 { 417 {
409#ifndef NO_HASH_COMP 418#ifndef OPENSSL_NO_HASH_COMP
410 lh->num_hash_comps++; 419 lh->num_hash_comps++;
411 if (n1->hash != hash) 420 if (n1->hash != hash)
412 { 421 {
@@ -415,7 +424,7 @@ static LHASH_NODE **getrn(LHASH *lh, void *data, unsigned long *rhash)
415 } 424 }
416#endif 425#endif
417 lh->num_comp_calls++; 426 lh->num_comp_calls++;
418 if ((*cf)(n1->data,data) == 0) 427 if(cf(n1->data,data) == 0)
419 break; 428 break;
420 ret= &(n1->next); 429 ret= &(n1->next);
421 } 430 }
@@ -455,7 +464,7 @@ unsigned long lh_strhash(const char *c)
455 return((ret>>16)^ret); 464 return((ret>>16)^ret);
456 } 465 }
457 466
458unsigned long lh_num_items(LHASH *lh) 467unsigned long lh_num_items(const LHASH *lh)
459 { 468 {
460 return lh ? lh->num_items : 0; 469 return lh ? lh->num_items : 0;
461 } 470 }
diff --git a/src/lib/libcrypto/lhash/lhash.h b/src/lib/libcrypto/lhash/lhash.h
index b8ff021906..dee8207333 100644
--- a/src/lib/libcrypto/lhash/lhash.h
+++ b/src/lib/libcrypto/lhash/lhash.h
@@ -63,11 +63,11 @@
63#ifndef HEADER_LHASH_H 63#ifndef HEADER_LHASH_H
64#define HEADER_LHASH_H 64#define HEADER_LHASH_H
65 65
66#ifndef NO_FP_API 66#ifndef OPENSSL_NO_FP_API
67#include <stdio.h> 67#include <stdio.h>
68#endif 68#endif
69 69
70#ifndef NO_BIO 70#ifndef OPENSSL_NO_BIO
71#include <openssl/bio.h> 71#include <openssl/bio.h>
72#endif 72#endif
73 73
@@ -77,18 +77,68 @@ extern "C" {
77 77
78typedef struct lhash_node_st 78typedef struct lhash_node_st
79 { 79 {
80 void *data; 80 const void *data;
81 struct lhash_node_st *next; 81 struct lhash_node_st *next;
82#ifndef NO_HASH_COMP 82#ifndef OPENSSL_NO_HASH_COMP
83 unsigned long hash; 83 unsigned long hash;
84#endif 84#endif
85 } LHASH_NODE; 85 } LHASH_NODE;
86 86
87typedef int (*LHASH_COMP_FN_TYPE)(const void *, const void *);
88typedef unsigned long (*LHASH_HASH_FN_TYPE)(const void *);
89typedef void (*LHASH_DOALL_FN_TYPE)(const void *);
90typedef void (*LHASH_DOALL_ARG_FN_TYPE)(const void *, void *);
91
92/* Macros for declaring and implementing type-safe wrappers for LHASH callbacks.
93 * This way, callbacks can be provided to LHASH structures without function
94 * pointer casting and the macro-defined callbacks provide per-variable casting
95 * before deferring to the underlying type-specific callbacks. NB: It is
96 * possible to place a "static" in front of both the DECLARE and IMPLEMENT
97 * macros if the functions are strictly internal. */
98
99/* First: "hash" functions */
100#define DECLARE_LHASH_HASH_FN(f_name,o_type) \
101 unsigned long f_name##_LHASH_HASH(const void *);
102#define IMPLEMENT_LHASH_HASH_FN(f_name,o_type) \
103 unsigned long f_name##_LHASH_HASH(const void *arg) { \
104 o_type a = (o_type)arg; \
105 return f_name(a); }
106#define LHASH_HASH_FN(f_name) f_name##_LHASH_HASH
107
108/* Second: "compare" functions */
109#define DECLARE_LHASH_COMP_FN(f_name,o_type) \
110 int f_name##_LHASH_COMP(const void *, const void *);
111#define IMPLEMENT_LHASH_COMP_FN(f_name,o_type) \
112 int f_name##_LHASH_COMP(const void *arg1, const void *arg2) { \
113 o_type a = (o_type)arg1; \
114 o_type b = (o_type)arg2; \
115 return f_name(a,b); }
116#define LHASH_COMP_FN(f_name) f_name##_LHASH_COMP
117
118/* Third: "doall" functions */
119#define DECLARE_LHASH_DOALL_FN(f_name,o_type) \
120 void f_name##_LHASH_DOALL(const void *);
121#define IMPLEMENT_LHASH_DOALL_FN(f_name,o_type) \
122 void f_name##_LHASH_DOALL(const void *arg) { \
123 o_type a = (o_type)arg; \
124 f_name(a); }
125#define LHASH_DOALL_FN(f_name) f_name##_LHASH_DOALL
126
127/* Fourth: "doall_arg" functions */
128#define DECLARE_LHASH_DOALL_ARG_FN(f_name,o_type,a_type) \
129 void f_name##_LHASH_DOALL_ARG(const void *, void *);
130#define IMPLEMENT_LHASH_DOALL_ARG_FN(f_name,o_type,a_type) \
131 void f_name##_LHASH_DOALL_ARG(const void *arg1, void *arg2) { \
132 o_type a = (o_type)arg1; \
133 a_type b = (a_type)arg2; \
134 f_name(a,b); }
135#define LHASH_DOALL_ARG_FN(f_name) f_name##_LHASH_DOALL_ARG
136
87typedef struct lhash_st 137typedef struct lhash_st
88 { 138 {
89 LHASH_NODE **b; 139 LHASH_NODE **b;
90 int (*comp)(); 140 LHASH_COMP_FN_TYPE comp;
91 unsigned long (*hash)(); 141 LHASH_HASH_FN_TYPE hash;
92 unsigned int num_nodes; 142 unsigned int num_nodes;
93 unsigned int num_alloc_nodes; 143 unsigned int num_alloc_nodes;
94 unsigned int p; 144 unsigned int p;
@@ -120,26 +170,26 @@ typedef struct lhash_st
120 * in lh_insert(). */ 170 * in lh_insert(). */
121#define lh_error(lh) ((lh)->error) 171#define lh_error(lh) ((lh)->error)
122 172
123LHASH *lh_new(unsigned long (*h)(/* void *a */), int (*c)(/* void *a,void *b */)); 173LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c);
124void lh_free(LHASH *lh); 174void lh_free(LHASH *lh);
125void *lh_insert(LHASH *lh, void *data); 175void *lh_insert(LHASH *lh, const void *data);
126void *lh_delete(LHASH *lh, void *data); 176void *lh_delete(LHASH *lh, const void *data);
127void *lh_retrieve(LHASH *lh, void *data); 177void *lh_retrieve(LHASH *lh, const void *data);
128 void lh_doall(LHASH *lh, void (*func)(/*void *b*/)); 178void lh_doall(LHASH *lh, LHASH_DOALL_FN_TYPE func);
129void lh_doall_arg(LHASH *lh, void (*func)(/*void *a,void *b*/),void *arg); 179void lh_doall_arg(LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg);
130unsigned long lh_strhash(const char *c); 180unsigned long lh_strhash(const char *c);
131unsigned long lh_num_items(LHASH *lh); 181unsigned long lh_num_items(const LHASH *lh);
132 182
133#ifndef NO_FP_API 183#ifndef OPENSSL_NO_FP_API
134void lh_stats(LHASH *lh, FILE *out); 184void lh_stats(const LHASH *lh, FILE *out);
135void lh_node_stats(LHASH *lh, FILE *out); 185void lh_node_stats(const LHASH *lh, FILE *out);
136void lh_node_usage_stats(LHASH *lh, FILE *out); 186void lh_node_usage_stats(const LHASH *lh, FILE *out);
137#endif 187#endif
138 188
139#ifndef NO_BIO 189#ifndef OPENSSL_NO_BIO
140void lh_stats_bio(LHASH *lh, BIO *out); 190void lh_stats_bio(const LHASH *lh, BIO *out);
141void lh_node_stats_bio(LHASH *lh, BIO *out); 191void lh_node_stats_bio(const LHASH *lh, BIO *out);
142void lh_node_usage_stats_bio(LHASH *lh, BIO *out); 192void lh_node_usage_stats_bio(const LHASH *lh, BIO *out);
143#endif 193#endif
144#ifdef __cplusplus 194#ifdef __cplusplus
145} 195}
diff --git a/src/lib/libcrypto/md2/Makefile.ssl b/src/lib/libcrypto/md2/Makefile.ssl
index 269628d739..05a77ae4a5 100644
--- a/src/lib/libcrypto/md2/Makefile.ssl
+++ b/src/lib/libcrypto/md2/Makefile.ssl
@@ -2,7 +2,7 @@
2# SSLeay/crypto/md/Makefile 2# SSLeay/crypto/md/Makefile
3# 3#
4 4
5DIR= md 5DIR= md2
6TOP= ../.. 6TOP= ../..
7CC= cc 7CC= cc
8INCLUDES= 8INCLUDES=
@@ -11,7 +11,8 @@ INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl 11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl 12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl 13MAKE= make -f Makefile.ssl
14MAKEDEPEND= $(TOP)/util/domd $(TOP) 14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
15MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
16AR= ar r 17AR= ar r
17 18
@@ -39,8 +40,7 @@ all: lib
39 40
40lib: $(LIBOBJ) 41lib: $(LIBOBJ)
41 $(AR) $(LIB) $(LIBOBJ) 42 $(AR) $(LIB) $(LIBOBJ)
42 @echo You may get an error following this line. Please ignore. 43 $(RANLIB) $(LIB) || echo Never mind.
43 - $(RANLIB) $(LIB)
44 @touch lib 44 @touch lib
45 45
46files: 46files:
@@ -80,11 +80,11 @@ clean:
80# DO NOT DELETE THIS LINE -- make depend depends on it. 80# DO NOT DELETE THIS LINE -- make depend depends on it.
81 81
82md2_dgst.o: ../../include/openssl/md2.h ../../include/openssl/opensslconf.h 82md2_dgst.o: ../../include/openssl/md2.h ../../include/openssl/opensslconf.h
83md2_dgst.o: ../../include/openssl/opensslv.h 83md2_dgst.o: ../../include/openssl/opensslv.h md2_dgst.c
84md2_one.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 84md2_one.o: ../../e_os.h ../../include/openssl/bio.h
85md2_one.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 85md2_one.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
86md2_one.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 86md2_one.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
87md2_one.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h 87md2_one.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
88md2_one.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 88md2_one.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
89md2_one.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 89md2_one.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
90md2_one.o: ../../include/openssl/symhacks.h ../cryptlib.h 90md2_one.o: ../../include/openssl/symhacks.h ../cryptlib.h md2_one.c
diff --git a/src/lib/libcrypto/md2/md2.h b/src/lib/libcrypto/md2/md2.h
index a00bd162b3..ad9241455c 100644
--- a/src/lib/libcrypto/md2/md2.h
+++ b/src/lib/libcrypto/md2/md2.h
@@ -59,7 +59,7 @@
59#ifndef HEADER_MD2_H 59#ifndef HEADER_MD2_H
60#define HEADER_MD2_H 60#define HEADER_MD2_H
61 61
62#ifdef NO_MD2 62#ifdef OPENSSL_NO_MD2
63#error MD2 is disabled. 63#error MD2 is disabled.
64#endif 64#endif
65 65
@@ -80,9 +80,9 @@ typedef struct MD2state_st
80 } MD2_CTX; 80 } MD2_CTX;
81 81
82const char *MD2_options(void); 82const char *MD2_options(void);
83void MD2_Init(MD2_CTX *c); 83int MD2_Init(MD2_CTX *c);
84void MD2_Update(MD2_CTX *c, const unsigned char *data, unsigned long len); 84int MD2_Update(MD2_CTX *c, const unsigned char *data, unsigned long len);
85void MD2_Final(unsigned char *md, MD2_CTX *c); 85int MD2_Final(unsigned char *md, MD2_CTX *c);
86unsigned char *MD2(const unsigned char *d, unsigned long n,unsigned char *md); 86unsigned char *MD2(const unsigned char *d, unsigned long n,unsigned char *md);
87#ifdef __cplusplus 87#ifdef __cplusplus
88} 88}
diff --git a/src/lib/libcrypto/md2/md2_dgst.c b/src/lib/libcrypto/md2/md2_dgst.c
index 608baefa8f..e25dd00e02 100644
--- a/src/lib/libcrypto/md2/md2_dgst.c
+++ b/src/lib/libcrypto/md2/md2_dgst.c
@@ -115,19 +115,20 @@ const char *MD2_options(void)
115 return("md2(int)"); 115 return("md2(int)");
116 } 116 }
117 117
118void MD2_Init(MD2_CTX *c) 118int MD2_Init(MD2_CTX *c)
119 { 119 {
120 c->num=0; 120 c->num=0;
121 memset(c->state,0,MD2_BLOCK*sizeof(MD2_INT)); 121 memset(c->state,0,MD2_BLOCK*sizeof(MD2_INT));
122 memset(c->cksm,0,MD2_BLOCK*sizeof(MD2_INT)); 122 memset(c->cksm,0,MD2_BLOCK*sizeof(MD2_INT));
123 memset(c->data,0,MD2_BLOCK); 123 memset(c->data,0,MD2_BLOCK);
124 return 1;
124 } 125 }
125 126
126void MD2_Update(MD2_CTX *c, const unsigned char *data, unsigned long len) 127int MD2_Update(MD2_CTX *c, const unsigned char *data, unsigned long len)
127 { 128 {
128 register UCHAR *p; 129 register UCHAR *p;
129 130
130 if (len == 0) return; 131 if (len == 0) return 1;
131 132
132 p=c->data; 133 p=c->data;
133 if (c->num != 0) 134 if (c->num != 0)
@@ -146,7 +147,7 @@ void MD2_Update(MD2_CTX *c, const unsigned char *data, unsigned long len)
146 memcpy(&(p[c->num]),data,(int)len); 147 memcpy(&(p[c->num]),data,(int)len);
147 /* data+=len; */ 148 /* data+=len; */
148 c->num+=(int)len; 149 c->num+=(int)len;
149 return; 150 return 1;
150 } 151 }
151 } 152 }
152 /* we now can process the input data in blocks of MD2_BLOCK 153 /* we now can process the input data in blocks of MD2_BLOCK
@@ -159,6 +160,7 @@ void MD2_Update(MD2_CTX *c, const unsigned char *data, unsigned long len)
159 } 160 }
160 memcpy(p,data,(int)len); 161 memcpy(p,data,(int)len);
161 c->num=(int)len; 162 c->num=(int)len;
163 return 1;
162 } 164 }
163 165
164static void md2_block(MD2_CTX *c, const unsigned char *d) 166static void md2_block(MD2_CTX *c, const unsigned char *d)
@@ -197,7 +199,7 @@ static void md2_block(MD2_CTX *c, const unsigned char *d)
197 memset(state,0,48*sizeof(MD2_INT)); 199 memset(state,0,48*sizeof(MD2_INT));
198 } 200 }
199 201
200void MD2_Final(unsigned char *md, MD2_CTX *c) 202int MD2_Final(unsigned char *md, MD2_CTX *c)
201 { 203 {
202 int i,v; 204 int i,v;
203 register UCHAR *cp; 205 register UCHAR *cp;
@@ -219,5 +221,6 @@ void MD2_Final(unsigned char *md, MD2_CTX *c)
219 for (i=0; i<16; i++) 221 for (i=0; i<16; i++)
220 md[i]=(UCHAR)(p1[i]&0xff); 222 md[i]=(UCHAR)(p1[i]&0xff);
221 memset((char *)&c,0,sizeof(c)); 223 memset((char *)&c,0,sizeof(c));
224 return 1;
222 } 225 }
223 226
diff --git a/src/lib/libcrypto/md2/md2test.c b/src/lib/libcrypto/md2/md2test.c
index e3f4fb4c34..7d3664faf5 100644
--- a/src/lib/libcrypto/md2/md2test.c
+++ b/src/lib/libcrypto/md2/md2test.c
@@ -59,15 +59,16 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <stdlib.h> 60#include <stdlib.h>
61#include <string.h> 61#include <string.h>
62#include <openssl/md2.h>
62 63
63#ifdef NO_MD2 64#ifdef OPENSSL_NO_MD2
64int main(int argc, char *argv[]) 65int main(int argc, char *argv[])
65{ 66{
66 printf("No MD2 support\n"); 67 printf("No MD2 support\n");
67 return(0); 68 return(0);
68} 69}
69#else 70#else
70#include <openssl/md2.h> 71#include <openssl/evp.h>
71 72
72#ifdef CHARSET_EBCDIC 73#ifdef CHARSET_EBCDIC
73#include <openssl/ebcdic.h> 74#include <openssl/ebcdic.h>
@@ -100,13 +101,15 @@ int main(int argc, char *argv[])
100 int i,err=0; 101 int i,err=0;
101 char **P,**R; 102 char **P,**R;
102 char *p; 103 char *p;
104 unsigned char md[MD2_DIGEST_LENGTH];
103 105
104 P=test; 106 P=test;
105 R=ret; 107 R=ret;
106 i=1; 108 i=1;
107 while (*P != NULL) 109 while (*P != NULL)
108 { 110 {
109 p=pt(MD2((unsigned char *)*P,(unsigned long)strlen(*P),NULL)); 111 EVP_Digest((unsigned char *)*P,(unsigned long)strlen(*P),md,NULL,EVP_md2(), NULL);
112 p=pt(md);
110 if (strcmp(p,*R) != 0) 113 if (strcmp(p,*R) != 0)
111 { 114 {
112 printf("error calculating MD2 on '%s'\n",*P); 115 printf("error calculating MD2 on '%s'\n",*P);
diff --git a/src/lib/libcrypto/md32_common.h b/src/lib/libcrypto/md32_common.h
index 1a404a458d..353d2b96ad 100644
--- a/src/lib/libcrypto/md32_common.h
+++ b/src/lib/libcrypto/md32_common.h
@@ -179,7 +179,7 @@
179 */ 179 */
180#undef ROTATE 180#undef ROTATE
181#ifndef PEDANTIC 181#ifndef PEDANTIC
182# if defined(_MSC_VER) 182# if 0 /* defined(_MSC_VER) */
183# define ROTATE(a,n) _lrotl(a,n) 183# define ROTATE(a,n) _lrotl(a,n)
184# elif defined(__MWERKS__) 184# elif defined(__MWERKS__)
185# if defined(__POWERPC__) 185# if defined(__POWERPC__)
@@ -190,7 +190,7 @@
190# else 190# else
191# define ROTATE(a,n) __rol(a,n) 191# define ROTATE(a,n) __rol(a,n)
192# endif 192# endif
193# elif defined(__GNUC__) && __GNUC__>=2 && !defined(NO_ASM) && !defined(NO_INLINE_ASM) 193# elif defined(__GNUC__) && __GNUC__>=2 && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM)
194 /* 194 /*
195 * Some GNU C inline assembler templates. Note that these are 195 * Some GNU C inline assembler templates. Note that these are
196 * rotates by *constant* number of bits! But that's exactly 196 * rotates by *constant* number of bits! But that's exactly
@@ -198,7 +198,7 @@
198 * 198 *
199 * <appro@fy.chalmers.se> 199 * <appro@fy.chalmers.se>
200 */ 200 */
201# if defined(__i386) 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" \
@@ -222,9 +222,9 @@
222 * Engage compiler specific "fetch in reverse byte order" 222 * Engage compiler specific "fetch in reverse byte order"
223 * intrinsic function if available. 223 * intrinsic function if available.
224 */ 224 */
225# if defined(__GNUC__) && __GNUC__>=2 && !defined(NO_ASM) && !defined(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_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" \
@@ -240,7 +240,7 @@
240 l; \ 240 l; \
241 }) 241 })
242 242
243# elif defined(__sparc) && defined(ULTRASPARC) 243# elif defined(__sparc) && defined(OPENSSL_SYS_ULTRASPARC)
244# define LE_FETCH32(a) ({ register unsigned int l; \ 244# define LE_FETCH32(a) ({ register unsigned int l; \
245 asm ( \ 245 asm ( \
246 "lda [%1]#ASI_PRIMARY_LITTLE,%0"\ 246 "lda [%1]#ASI_PRIMARY_LITTLE,%0"\
@@ -410,14 +410,14 @@
410 * Time for some action:-) 410 * Time for some action:-)
411 */ 411 */
412 412
413void HASH_UPDATE (HASH_CTX *c, const void *data_, unsigned long len) 413int HASH_UPDATE (HASH_CTX *c, const void *data_, unsigned long len)
414 { 414 {
415 const unsigned char *data=data_; 415 const unsigned char *data=data_;
416 register HASH_LONG * p; 416 register HASH_LONG * p;
417 register unsigned long l; 417 register unsigned long l;
418 int sw,sc,ew,ec; 418 int sw,sc,ew,ec;
419 419
420 if (len==0) return; 420 if (len==0) return 1;
421 421
422 l=(c->Nl+(len<<3))&0xffffffffL; 422 l=(c->Nl+(len<<3))&0xffffffffL;
423 /* 95-05-24 eay Fixed a bug with the overflow handling, thanks to 423 /* 95-05-24 eay Fixed a bug with the overflow handling, thanks to
@@ -466,7 +466,7 @@ void HASH_UPDATE (HASH_CTX *c, const void *data_, unsigned long len)
466 HOST_c2l_p(data,l,ec); p[sw]=l; 466 HOST_c2l_p(data,l,ec); p[sw]=l;
467 } 467 }
468 } 468 }
469 return; 469 return 1;
470 } 470 }
471 } 471 }
472 472
@@ -520,6 +520,7 @@ void HASH_UPDATE (HASH_CTX *c, const void *data_, unsigned long len)
520 HOST_c2l_p(data,l,ec); 520 HOST_c2l_p(data,l,ec);
521 *p=l; 521 *p=l;
522 } 522 }
523 return 1;
523 } 524 }
524 525
525 526
@@ -543,7 +544,7 @@ void HASH_TRANSFORM (HASH_CTX *c, const unsigned char *data)
543 } 544 }
544 545
545 546
546void HASH_FINAL (unsigned char *md, HASH_CTX *c) 547int HASH_FINAL (unsigned char *md, HASH_CTX *c)
547 { 548 {
548 register HASH_LONG *p; 549 register HASH_LONG *p;
549 register unsigned long l; 550 register unsigned long l;
@@ -604,4 +605,5 @@ void HASH_FINAL (unsigned char *md, HASH_CTX *c)
604 * but I'm not worried :-) 605 * but I'm not worried :-)
605 memset((void *)c,0,sizeof(HASH_CTX)); 606 memset((void *)c,0,sizeof(HASH_CTX));
606 */ 607 */
608 return 1;
607 } 609 }
diff --git a/src/lib/libcrypto/md4/Makefile.ssl b/src/lib/libcrypto/md4/Makefile.ssl
index 646607274e..58c2b20a78 100644
--- a/src/lib/libcrypto/md4/Makefile.ssl
+++ b/src/lib/libcrypto/md4/Makefile.ssl
@@ -12,7 +12,8 @@ INSTALL_PREFIX=
12OPENSSLDIR= /usr/local/ssl 12OPENSSLDIR= /usr/local/ssl
13INSTALLTOP=/usr/local/ssl 13INSTALLTOP=/usr/local/ssl
14MAKE= make -f Makefile.ssl 14MAKE= make -f Makefile.ssl
15MAKEDEPEND= $(TOP)/util/domd $(TOP) 15MAKEDEPPROG= makedepend
16MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl 17MAKEFILE= Makefile.ssl
17AR= ar r 18AR= ar r
18 19
@@ -40,8 +41,7 @@ all: lib
40 41
41lib: $(LIBOBJ) 42lib: $(LIBOBJ)
42 $(AR) $(LIB) $(LIBOBJ) 43 $(AR) $(LIB) $(LIBOBJ)
43 @echo You may get an error following this line. Please ignore. 44 $(RANLIB) $(LIB) || echo Never mind.
44 - $(RANLIB) $(LIB)
45 @touch lib 45 @touch lib
46 46
47files: 47files:
@@ -80,6 +80,9 @@ clean:
80 80
81# DO NOT DELETE THIS LINE -- make depend depends on it. 81# DO NOT DELETE THIS LINE -- make depend depends on it.
82 82
83md4_dgst.o: ../../include/openssl/md4.h ../../include/openssl/opensslconf.h 83md4_dgst.o: ../../include/openssl/e_os2.h ../../include/openssl/md4.h
84md4_dgst.o: ../../include/openssl/opensslv.h ../md32_common.h md4_locl.h 84md4_dgst.o: ../../include/openssl/opensslconf.h
85md4_one.o: ../../include/openssl/md4.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.h b/src/lib/libcrypto/md4/md4.h
index c794e186db..7a7b23682f 100644
--- a/src/lib/libcrypto/md4/md4.h
+++ b/src/lib/libcrypto/md4/md4.h
@@ -59,11 +59,13 @@
59#ifndef HEADER_MD4_H 59#ifndef HEADER_MD4_H
60#define HEADER_MD4_H 60#define HEADER_MD4_H
61 61
62#include <openssl/e_os2.h>
63
62#ifdef __cplusplus 64#ifdef __cplusplus
63extern "C" { 65extern "C" {
64#endif 66#endif
65 67
66#ifdef NO_MD4 68#ifdef OPENSSL_NO_MD4
67#error MD4 is disabled. 69#error MD4 is disabled.
68#endif 70#endif
69 71
@@ -74,9 +76,9 @@ extern "C" {
74 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 76 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
75 */ 77 */
76 78
77#if defined(WIN16) || defined(__LP32__) 79#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__)
78#define MD4_LONG unsigned long 80#define MD4_LONG unsigned long
79#elif defined(_CRAY) || defined(__ILP64__) 81#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)
80#define MD4_LONG unsigned long 82#define MD4_LONG unsigned long
81#define MD4_LONG_LOG2 3 83#define MD4_LONG_LOG2 3
82/* 84/*
@@ -102,9 +104,9 @@ typedef struct MD4state_st
102 int num; 104 int num;
103 } MD4_CTX; 105 } MD4_CTX;
104 106
105void MD4_Init(MD4_CTX *c); 107int MD4_Init(MD4_CTX *c);
106void MD4_Update(MD4_CTX *c, const void *data, unsigned long len); 108int MD4_Update(MD4_CTX *c, const void *data, unsigned long len);
107void MD4_Final(unsigned char *md, MD4_CTX *c); 109int MD4_Final(unsigned char *md, MD4_CTX *c);
108unsigned char *MD4(const unsigned char *d, unsigned long n, unsigned char *md); 110unsigned char *MD4(const unsigned char *d, unsigned long n, unsigned char *md);
109void MD4_Transform(MD4_CTX *c, const unsigned char *b); 111void MD4_Transform(MD4_CTX *c, const unsigned char *b);
110#ifdef __cplusplus 112#ifdef __cplusplus
diff --git a/src/lib/libcrypto/md4/md4_dgst.c b/src/lib/libcrypto/md4/md4_dgst.c
index 81488ae2e2..6446f5f5e7 100644
--- a/src/lib/libcrypto/md4/md4_dgst.c
+++ b/src/lib/libcrypto/md4/md4_dgst.c
@@ -70,7 +70,7 @@ const char *MD4_version="MD4" OPENSSL_VERSION_PTEXT;
70#define INIT_DATA_C (unsigned long)0x98badcfeL 70#define INIT_DATA_C (unsigned long)0x98badcfeL
71#define INIT_DATA_D (unsigned long)0x10325476L 71#define INIT_DATA_D (unsigned long)0x10325476L
72 72
73void MD4_Init(MD4_CTX *c) 73int MD4_Init(MD4_CTX *c)
74 { 74 {
75 c->A=INIT_DATA_A; 75 c->A=INIT_DATA_A;
76 c->B=INIT_DATA_B; 76 c->B=INIT_DATA_B;
@@ -79,6 +79,7 @@ void MD4_Init(MD4_CTX *c)
79 c->Nl=0; 79 c->Nl=0;
80 c->Nh=0; 80 c->Nh=0;
81 c->num=0; 81 c->num=0;
82 return 1;
82 } 83 }
83 84
84#ifndef md4_block_host_order 85#ifndef md4_block_host_order
diff --git a/src/lib/libcrypto/md4/md4_locl.h b/src/lib/libcrypto/md4/md4_locl.h
index 0a2b39018d..a8d31d7a73 100644
--- a/src/lib/libcrypto/md4/md4_locl.h
+++ b/src/lib/libcrypto/md4/md4_locl.h
@@ -68,7 +68,7 @@
68void md4_block_host_order (MD4_CTX *c, const void *p,int num); 68void md4_block_host_order (MD4_CTX *c, const void *p,int num);
69void md4_block_data_order (MD4_CTX *c, const void *p,int num); 69void md4_block_data_order (MD4_CTX *c, const void *p,int num);
70 70
71#if defined(__i386) || defined(_M_IX86) || defined(__INTEL__) 71#if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__)
72/* 72/*
73 * *_block_host_order is expected to handle aligned data while 73 * *_block_host_order is expected to handle aligned data while
74 * *_block_data_order - unaligned. As algorithm and host (x86) 74 * *_block_data_order - unaligned. As algorithm and host (x86)
diff --git a/src/lib/libcrypto/md4/md4test.c b/src/lib/libcrypto/md4/md4test.c
index 97e6e21efd..e0fdc42282 100644
--- a/src/lib/libcrypto/md4/md4test.c
+++ b/src/lib/libcrypto/md4/md4test.c
@@ -60,13 +60,14 @@
60#include <string.h> 60#include <string.h>
61#include <stdlib.h> 61#include <stdlib.h>
62 62
63#ifdef NO_MD4 63#ifdef OPENSSL_NO_MD4
64int main(int argc, char *argv[]) 64int main(int argc, char *argv[])
65{ 65{
66 printf("No MD4 support\n"); 66 printf("No MD4 support\n");
67 return(0); 67 return(0);
68} 68}
69#else 69#else
70#include <openssl/evp.h>
70#include <openssl/md4.h> 71#include <openssl/md4.h>
71 72
72static char *test[]={ 73static char *test[]={
@@ -96,13 +97,15 @@ int main(int argc, char *argv[])
96 int i,err=0; 97 int i,err=0;
97 unsigned char **P,**R; 98 unsigned char **P,**R;
98 char *p; 99 char *p;
100 unsigned char md[MD4_DIGEST_LENGTH];
99 101
100 P=(unsigned char **)test; 102 P=(unsigned char **)test;
101 R=(unsigned char **)ret; 103 R=(unsigned char **)ret;
102 i=1; 104 i=1;
103 while (*P != NULL) 105 while (*P != NULL)
104 { 106 {
105 p=pt(MD4(&(P[0][0]),(unsigned long)strlen((char *)*P),NULL)); 107 EVP_Digest(&(P[0][0]),(unsigned long)strlen((char *)*P),md,NULL,EVP_md4(), NULL);
108 p=pt(md);
106 if (strcmp(p,(char *)*R) != 0) 109 if (strcmp(p,(char *)*R) != 0)
107 { 110 {
108 printf("error calculating MD4 on '%s'\n",*P); 111 printf("error calculating MD4 on '%s'\n",*P);
diff --git a/src/lib/libcrypto/md5/Makefile.ssl b/src/lib/libcrypto/md5/Makefile.ssl
index 784215579b..f9a1190efb 100644
--- a/src/lib/libcrypto/md5/Makefile.ssl
+++ b/src/lib/libcrypto/md5/Makefile.ssl
@@ -12,7 +12,8 @@ INSTALL_PREFIX=
12OPENSSLDIR= /usr/local/ssl 12OPENSSLDIR= /usr/local/ssl
13INSTALLTOP=/usr/local/ssl 13INSTALLTOP=/usr/local/ssl
14MAKE= make -f Makefile.ssl 14MAKE= make -f Makefile.ssl
15MAKEDEPEND= $(TOP)/util/domd $(TOP) 15MAKEDEPPROG= makedepend
16MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl 17MAKEFILE= Makefile.ssl
17AR= ar r 18AR= ar r
18 19
@@ -50,8 +51,7 @@ all: lib
50 51
51lib: $(LIBOBJ) 52lib: $(LIBOBJ)
52 $(AR) $(LIB) $(LIBOBJ) 53 $(AR) $(LIB) $(LIBOBJ)
53 @echo You may get an error following this line. Please ignore. 54 $(RANLIB) $(LIB) || echo Never mind.
54 - $(RANLIB) $(LIB)
55 @touch lib 55 @touch lib
56 56
57# elf 57# elf
@@ -130,5 +130,6 @@ clean:
130# DO NOT DELETE THIS LINE -- make depend depends on it. 130# DO NOT DELETE THIS LINE -- make depend depends on it.
131 131
132md5_dgst.o: ../../include/openssl/md5.h ../../include/openssl/opensslconf.h 132md5_dgst.o: ../../include/openssl/md5.h ../../include/openssl/opensslconf.h
133md5_dgst.o: ../../include/openssl/opensslv.h ../md32_common.h md5_locl.h 133md5_dgst.o: ../../include/openssl/opensslv.h ../md32_common.h md5_dgst.c
134md5_one.o: ../../include/openssl/md5.h 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
index ca4257f134..a599ed5660 100644
--- a/src/lib/libcrypto/md5/asm/md5-sparcv9.S
+++ b/src/lib/libcrypto/md5/asm/md5-sparcv9.S
@@ -24,12 +24,12 @@
24 * 24 *
25 * To compile with SC4.x/SC5.x: 25 * To compile with SC4.x/SC5.x:
26 * 26 *
27 * cc -xarch=v[9|8plus] -DULTRASPARC -DMD5_BLOCK_DATA_ORDER \ 27 * cc -xarch=v[9|8plus] -DOPENSSL_SYSNAME_ULTRASPARC -DMD5_BLOCK_DATA_ORDER \
28 * -c md5-sparcv9.S 28 * -c md5-sparcv9.S
29 * 29 *
30 * and with gcc: 30 * and with gcc:
31 * 31 *
32 * gcc -mcpu=ultrasparc -DULTRASPARC -DMD5_BLOCK_DATA_ORDER \ 32 * gcc -mcpu=ultrasparc -DOPENSSL_SYSNAME_ULTRASPARC -DMD5_BLOCK_DATA_ORDER \
33 * -c md5-sparcv9.S 33 * -c md5-sparcv9.S
34 * 34 *
35 * or if above fails (it does if you have gas): 35 * or if above fails (it does if you have gas):
@@ -72,7 +72,7 @@
72#define Dval R8 72#define Dval R8
73 73
74#if defined(MD5_BLOCK_DATA_ORDER) 74#if defined(MD5_BLOCK_DATA_ORDER)
75# if defined(ULTRASPARC) 75# if defined(OPENSSL_SYSNAME_ULTRASPARC)
76# define LOAD lda 76# define LOAD lda
77# define X(i) [%i1+i*4]%asi 77# define X(i) [%i1+i*4]%asi
78# define md5_block md5_block_asm_data_order_aligned 78# define md5_block md5_block_asm_data_order_aligned
@@ -1012,7 +1012,7 @@ md5_block:
1012 st B,[Bptr] 1012 st B,[Bptr]
1013 nop != 1013 nop !=
1014 1014
1015#ifdef ULTRASPARC 1015#ifdef OPENSSL_SYSNAME_ULTRASPARC
1016 bg,a,pt %icc,.Lmd5_block_loop 1016 bg,a,pt %icc,.Lmd5_block_loop
1017#else 1017#else
1018 bg,a .Lmd5_block_loop 1018 bg,a .Lmd5_block_loop
diff --git a/src/lib/libcrypto/md5/md5.h b/src/lib/libcrypto/md5/md5.h
index d10bc8397f..52cb753e6a 100644
--- a/src/lib/libcrypto/md5/md5.h
+++ b/src/lib/libcrypto/md5/md5.h
@@ -63,7 +63,7 @@
63extern "C" { 63extern "C" {
64#endif 64#endif
65 65
66#ifdef NO_MD5 66#ifdef OPENSSL_NO_MD5
67#error MD5 is disabled. 67#error MD5 is disabled.
68#endif 68#endif
69 69
@@ -74,9 +74,9 @@ extern "C" {
74 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 74 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
75 */ 75 */
76 76
77#if defined(WIN16) || defined(__LP32__) 77#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__)
78#define MD5_LONG unsigned long 78#define MD5_LONG unsigned long
79#elif defined(_CRAY) || defined(__ILP64__) 79#elif defined(OENSSL_SYS_CRAY) || defined(__ILP64__)
80#define MD5_LONG unsigned long 80#define MD5_LONG unsigned long
81#define MD5_LONG_LOG2 3 81#define MD5_LONG_LOG2 3
82/* 82/*
@@ -102,9 +102,9 @@ typedef struct MD5state_st
102 int num; 102 int num;
103 } MD5_CTX; 103 } MD5_CTX;
104 104
105void MD5_Init(MD5_CTX *c); 105int MD5_Init(MD5_CTX *c);
106void MD5_Update(MD5_CTX *c, const void *data, unsigned long len); 106int MD5_Update(MD5_CTX *c, const void *data, unsigned long len);
107void MD5_Final(unsigned char *md, MD5_CTX *c); 107int MD5_Final(unsigned char *md, MD5_CTX *c);
108unsigned char *MD5(const unsigned char *d, unsigned long n, unsigned char *md); 108unsigned char *MD5(const unsigned char *d, unsigned long n, unsigned char *md);
109void MD5_Transform(MD5_CTX *c, const unsigned char *b); 109void MD5_Transform(MD5_CTX *c, const unsigned char *b);
110#ifdef __cplusplus 110#ifdef __cplusplus
diff --git a/src/lib/libcrypto/md5/md5_dgst.c b/src/lib/libcrypto/md5/md5_dgst.c
index 23d196b8d4..c38a3f021e 100644
--- a/src/lib/libcrypto/md5/md5_dgst.c
+++ b/src/lib/libcrypto/md5/md5_dgst.c
@@ -70,7 +70,7 @@ const char *MD5_version="MD5" OPENSSL_VERSION_PTEXT;
70#define INIT_DATA_C (unsigned long)0x98badcfeL 70#define INIT_DATA_C (unsigned long)0x98badcfeL
71#define INIT_DATA_D (unsigned long)0x10325476L 71#define INIT_DATA_D (unsigned long)0x10325476L
72 72
73void MD5_Init(MD5_CTX *c) 73int MD5_Init(MD5_CTX *c)
74 { 74 {
75 c->A=INIT_DATA_A; 75 c->A=INIT_DATA_A;
76 c->B=INIT_DATA_B; 76 c->B=INIT_DATA_B;
@@ -79,6 +79,7 @@ void MD5_Init(MD5_CTX *c)
79 c->Nl=0; 79 c->Nl=0;
80 c->Nh=0; 80 c->Nh=0;
81 c->num=0; 81 c->num=0;
82 return 1;
82 } 83 }
83 84
84#ifndef md5_block_host_order 85#ifndef md5_block_host_order
diff --git a/src/lib/libcrypto/md5/md5_locl.h b/src/lib/libcrypto/md5/md5_locl.h
index c912484122..34c5257306 100644
--- a/src/lib/libcrypto/md5/md5_locl.h
+++ b/src/lib/libcrypto/md5/md5_locl.h
@@ -66,9 +66,9 @@
66#endif 66#endif
67 67
68#ifdef MD5_ASM 68#ifdef MD5_ASM
69# if defined(__i386) || defined(_M_IX86) || defined(__INTEL__) 69# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__)
70# define md5_block_host_order md5_block_asm_host_order 70# define md5_block_host_order md5_block_asm_host_order
71# elif defined(__sparc) && defined(ULTRASPARC) 71# elif defined(__sparc) && defined(OPENSSL_SYS_ULTRASPARC)
72 void md5_block_asm_data_order_aligned (MD5_CTX *c, const MD5_LONG *p,int num); 72 void md5_block_asm_data_order_aligned (MD5_CTX *c, const MD5_LONG *p,int num);
73# define HASH_BLOCK_DATA_ORDER_ALIGNED md5_block_asm_data_order_aligned 73# define HASH_BLOCK_DATA_ORDER_ALIGNED md5_block_asm_data_order_aligned
74# endif 74# endif
@@ -77,7 +77,7 @@
77void md5_block_host_order (MD5_CTX *c, const void *p,int num); 77void md5_block_host_order (MD5_CTX *c, const void *p,int num);
78void md5_block_data_order (MD5_CTX *c, const void *p,int num); 78void md5_block_data_order (MD5_CTX *c, const void *p,int num);
79 79
80#if defined(__i386) || defined(_M_IX86) || defined(__INTEL__) 80#if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__)
81/* 81/*
82 * *_block_host_order is expected to handle aligned data while 82 * *_block_host_order is expected to handle aligned data while
83 * *_block_data_order - unaligned. As algorithm and host (x86) 83 * *_block_data_order - unaligned. As algorithm and host (x86)
diff --git a/src/lib/libcrypto/md5/md5test.c b/src/lib/libcrypto/md5/md5test.c
index 6bd8656302..862b89658a 100644
--- a/src/lib/libcrypto/md5/md5test.c
+++ b/src/lib/libcrypto/md5/md5test.c
@@ -60,13 +60,14 @@
60#include <string.h> 60#include <string.h>
61#include <stdlib.h> 61#include <stdlib.h>
62 62
63#ifdef NO_MD5 63#ifdef OPENSSL_NO_MD5
64int main(int argc, char *argv[]) 64int main(int argc, char *argv[])
65{ 65{
66 printf("No MD5 support\n"); 66 printf("No MD5 support\n");
67 return(0); 67 return(0);
68} 68}
69#else 69#else
70#include <openssl/evp.h>
70#include <openssl/md5.h> 71#include <openssl/md5.h>
71 72
72static char *test[]={ 73static char *test[]={
@@ -96,13 +97,15 @@ int main(int argc, char *argv[])
96 int i,err=0; 97 int i,err=0;
97 unsigned char **P,**R; 98 unsigned char **P,**R;
98 char *p; 99 char *p;
100 unsigned char md[MD5_DIGEST_LENGTH];
99 101
100 P=(unsigned char **)test; 102 P=(unsigned char **)test;
101 R=(unsigned char **)ret; 103 R=(unsigned char **)ret;
102 i=1; 104 i=1;
103 while (*P != NULL) 105 while (*P != NULL)
104 { 106 {
105 p=pt(MD5(&(P[0][0]),(unsigned long)strlen((char *)*P),NULL)); 107 EVP_Digest(&(P[0][0]),(unsigned long)strlen((char *)*P),md,NULL,EVP_md5(), NULL);
108 p=pt(md);
106 if (strcmp(p,(char *)*R) != 0) 109 if (strcmp(p,(char *)*R) != 0)
107 { 110 {
108 printf("error calculating MD5 on '%s'\n",*P); 111 printf("error calculating MD5 on '%s'\n",*P);
diff --git a/src/lib/libcrypto/mdc2/Makefile.ssl b/src/lib/libcrypto/mdc2/Makefile.ssl
index a9b06b02bd..941d96c9e9 100644
--- a/src/lib/libcrypto/mdc2/Makefile.ssl
+++ b/src/lib/libcrypto/mdc2/Makefile.ssl
@@ -11,7 +11,8 @@ INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl 11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl 12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl 13MAKE= make -f Makefile.ssl
14MAKEDEPEND= $(TOP)/util/domd $(TOP) 14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
15MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
16AR= ar r 17AR= ar r
17 18
@@ -39,8 +40,7 @@ all: lib
39 40
40lib: $(LIBOBJ) 41lib: $(LIBOBJ)
41 $(AR) $(LIB) $(LIBOBJ) 42 $(AR) $(LIB) $(LIBOBJ)
42 @echo You may get an error following this line. Please ignore. 43 $(RANLIB) $(LIB) || echo Never mind.
43 - $(RANLIB) $(LIB)
44 @touch lib 44 @touch lib
45 45
46files: 46files:
@@ -79,13 +79,20 @@ clean:
79 79
80# DO NOT DELETE THIS LINE -- make depend depends on it. 80# DO NOT DELETE THIS LINE -- make depend depends on it.
81 81
82mdc2_one.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 82mdc2_one.o: ../../e_os.h ../../include/openssl/bio.h
83mdc2_one.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 83mdc2_one.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
84mdc2_one.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 84mdc2_one.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
85mdc2_one.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 85mdc2_one.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
86mdc2_one.o: ../../include/openssl/mdc2.h ../../include/openssl/opensslconf.h 86mdc2_one.o: ../../include/openssl/lhash.h ../../include/openssl/mdc2.h
87mdc2_one.o: ../../include/openssl/opensslconf.h
87mdc2_one.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 88mdc2_one.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
88mdc2_one.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 89mdc2_one.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
89mdc2_one.o: ../cryptlib.h 90mdc2_one.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
90mdc2dgst.o: ../../include/openssl/des.h ../../include/openssl/e_os2.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
91mdc2dgst.o: ../../include/openssl/mdc2.h ../../include/openssl/opensslconf.h 94mdc2dgst.o: ../../include/openssl/mdc2.h ../../include/openssl/opensslconf.h
95mdc2dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
96mdc2dgst.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
97mdc2dgst.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
98mdc2dgst.o: mdc2dgst.c
diff --git a/src/lib/libcrypto/mdc2/mdc2.h b/src/lib/libcrypto/mdc2/mdc2.h
index 5da8da72f5..793a8a0f13 100644
--- a/src/lib/libcrypto/mdc2/mdc2.h
+++ b/src/lib/libcrypto/mdc2/mdc2.h
@@ -65,7 +65,7 @@
65extern "C" { 65extern "C" {
66#endif 66#endif
67 67
68#ifdef NO_MDC2 68#ifdef OPENSSL_NO_MDC2
69#error MDC2 is disabled. 69#error MDC2 is disabled.
70#endif 70#endif
71 71
@@ -76,14 +76,14 @@ typedef struct mdc2_ctx_st
76 { 76 {
77 int num; 77 int num;
78 unsigned char data[MDC2_BLOCK]; 78 unsigned char data[MDC2_BLOCK];
79 des_cblock h,hh; 79 DES_cblock h,hh;
80 int pad_type; /* either 1 or 2, default 1 */ 80 int pad_type; /* either 1 or 2, default 1 */
81 } MDC2_CTX; 81 } MDC2_CTX;
82 82
83 83
84void MDC2_Init(MDC2_CTX *c); 84int MDC2_Init(MDC2_CTX *c);
85void MDC2_Update(MDC2_CTX *c, const unsigned char *data, unsigned long len); 85int MDC2_Update(MDC2_CTX *c, const unsigned char *data, unsigned long len);
86void MDC2_Final(unsigned char *md, MDC2_CTX *c); 86int MDC2_Final(unsigned char *md, MDC2_CTX *c);
87unsigned char *MDC2(const unsigned char *d, unsigned long n, 87unsigned char *MDC2(const unsigned char *d, unsigned long n,
88 unsigned char *md); 88 unsigned char *md);
89 89
diff --git a/src/lib/libcrypto/mem.c b/src/lib/libcrypto/mem.c
index 3b5b2bbc68..effec714e8 100644
--- a/src/lib/libcrypto/mem.c
+++ b/src/lib/libcrypto/mem.c
@@ -70,14 +70,36 @@ static int allow_customize_debug = 1;/* exchanging memory-related functions at
70 * problems when malloc/free pairs 70 * problems when malloc/free pairs
71 * don't match etc. */ 71 * don't match etc. */
72 72
73/* may be changed as long as `allow_customize' is set */ 73
74static void *(*malloc_locked_func)(size_t) = malloc; 74
75static void (*free_locked_func)(void *) = free; 75/* the following pointers may be changed as long as 'allow_customize' is set */
76
76static void *(*malloc_func)(size_t) = malloc; 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
77static void *(*realloc_func)(void *, size_t)= realloc; 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
78static void (*free_func)(void *) = free; 90static void (*free_func)(void *) = free;
79 91
80/* may be changed as long as `allow_customize_debug' is set */ 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 */
81/* XXX use correct function pointer types */ 103/* XXX use correct function pointer types */
82#ifdef CRYPTO_MDEBUG 104#ifdef CRYPTO_MDEBUG
83/* use default functions from mem_dbg.c */ 105/* use default functions from mem_dbg.c */
@@ -105,12 +127,29 @@ int CRYPTO_set_mem_functions(void *(*m)(size_t), void *(*r)(void *, size_t),
105 { 127 {
106 if (!allow_customize) 128 if (!allow_customize)
107 return 0; 129 return 0;
108 if ((m == NULL) || (r == NULL) || (f == NULL)) 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))
109 return 0; 148 return 0;
110 malloc_func=m; 149 malloc_func=0; malloc_ex_func=m;
111 realloc_func=r; 150 realloc_func=0; realloc_ex_func=r;
112 free_func=f; 151 free_func=f;
113 malloc_locked_func=m; 152 malloc_locked_func=0; malloc_locked_ex_func=m;
114 free_locked_func=f; 153 free_locked_func=f;
115 return 1; 154 return 1;
116 } 155 }
@@ -121,11 +160,24 @@ int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*f)(void *))
121 return 0; 160 return 0;
122 if ((m == NULL) || (f == NULL)) 161 if ((m == NULL) || (f == NULL))
123 return 0; 162 return 0;
124 malloc_locked_func=m; 163 malloc_locked_func=m; malloc_locked_ex_func=default_malloc_locked_ex;
125 free_locked_func=f; 164 free_locked_func=f;
126 return 1; 165 return 1;
127 } 166 }
128 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
129int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int), 181int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int),
130 void (*r)(void *,void *,int,const char *,int,int), 182 void (*r)(void *,void *,int,const char *,int,int),
131 void (*f)(void *,int), 183 void (*f)(void *,int),
@@ -142,17 +194,42 @@ int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int),
142 return 1; 194 return 1;
143 } 195 }
144 196
197
145void CRYPTO_get_mem_functions(void *(**m)(size_t), void *(**r)(void *, size_t), 198void CRYPTO_get_mem_functions(void *(**m)(size_t), void *(**r)(void *, size_t),
146 void (**f)(void *)) 199 void (**f)(void *))
147 { 200 {
148 if (m != NULL) *m=malloc_func; 201 if (m != NULL) *m = (malloc_ex_func == default_malloc_ex) ?
149 if (r != NULL) *r=realloc_func; 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;
150 if (f != NULL) *f=free_func; 217 if (f != NULL) *f=free_func;
151 } 218 }
152 219
153void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *)) 220void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *))
154 { 221 {
155 if (m != NULL) *m=malloc_locked_func; 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;
156 if (f != NULL) *f=free_locked_func; 233 if (f != NULL) *f=free_locked_func;
157 } 234 }
158 235
@@ -180,9 +257,9 @@ void *CRYPTO_malloc_locked(int num, const char *file, int line)
180 allow_customize_debug = 0; 257 allow_customize_debug = 0;
181 malloc_debug_func(NULL, num, file, line, 0); 258 malloc_debug_func(NULL, num, file, line, 0);
182 } 259 }
183 ret = malloc_locked_func(num); 260 ret = malloc_locked_ex_func(num,file,line);
184#ifdef LEVITTE_DEBUG 261#ifdef LEVITTE_DEBUG_MEM
185 fprintf(stderr, "LEVITTE_DEBUG: > 0x%p (%d)\n", ret, num); 262 fprintf(stderr, "LEVITTE_DEBUG_MEM: > 0x%p (%d)\n", ret, num);
186#endif 263#endif
187 if (malloc_debug_func != NULL) 264 if (malloc_debug_func != NULL)
188 malloc_debug_func(ret, num, file, line, 1); 265 malloc_debug_func(ret, num, file, line, 1);
@@ -194,8 +271,8 @@ void CRYPTO_free_locked(void *str)
194 { 271 {
195 if (free_debug_func != NULL) 272 if (free_debug_func != NULL)
196 free_debug_func(str, 0); 273 free_debug_func(str, 0);
197#ifdef LEVITTE_DEBUG 274#ifdef LEVITTE_DEBUG_MEM
198 fprintf(stderr, "LEVITTE_DEBUG: < 0x%p\n", str); 275 fprintf(stderr, "LEVITTE_DEBUG_MEM: < 0x%p\n", str);
199#endif 276#endif
200 free_locked_func(str); 277 free_locked_func(str);
201 if (free_debug_func != NULL) 278 if (free_debug_func != NULL)
@@ -212,9 +289,9 @@ void *CRYPTO_malloc(int num, const char *file, int line)
212 allow_customize_debug = 0; 289 allow_customize_debug = 0;
213 malloc_debug_func(NULL, num, file, line, 0); 290 malloc_debug_func(NULL, num, file, line, 0);
214 } 291 }
215 ret = malloc_func(num); 292 ret = malloc_ex_func(num,file,line);
216#ifdef LEVITTE_DEBUG 293#ifdef LEVITTE_DEBUG_MEM
217 fprintf(stderr, "LEVITTE_DEBUG: > 0x%p (%d)\n", ret, num); 294 fprintf(stderr, "LEVITTE_DEBUG_MEM: > 0x%p (%d)\n", ret, num);
218#endif 295#endif
219 if (malloc_debug_func != NULL) 296 if (malloc_debug_func != NULL)
220 malloc_debug_func(ret, num, file, line, 1); 297 malloc_debug_func(ret, num, file, line, 1);
@@ -228,9 +305,9 @@ void *CRYPTO_realloc(void *str, int num, const char *file, int line)
228 305
229 if (realloc_debug_func != NULL) 306 if (realloc_debug_func != NULL)
230 realloc_debug_func(str, NULL, num, file, line, 0); 307 realloc_debug_func(str, NULL, num, file, line, 0);
231 ret = realloc_func(str,num); 308 ret = realloc_ex_func(str,num,file,line);
232#ifdef LEVITTE_DEBUG 309#ifdef LEVITTE_DEBUG_MEM
233 fprintf(stderr, "LEVITTE_DEBUG: | 0x%p -> 0x%p (%d)\n", str, ret, num); 310 fprintf(stderr, "LEVITTE_DEBUG_MEM: | 0x%p -> 0x%p (%d)\n", str, ret, num);
234#endif 311#endif
235 if (realloc_debug_func != NULL) 312 if (realloc_debug_func != NULL)
236 realloc_debug_func(str, ret, num, file, line, 1); 313 realloc_debug_func(str, ret, num, file, line, 1);
@@ -242,8 +319,8 @@ void CRYPTO_free(void *str)
242 { 319 {
243 if (free_debug_func != NULL) 320 if (free_debug_func != NULL)
244 free_debug_func(str, 0); 321 free_debug_func(str, 0);
245#ifdef LEVITTE_DEBUG 322#ifdef LEVITTE_DEBUG_MEM
246 fprintf(stderr, "LEVITTE_DEBUG: < 0x%p\n", str); 323 fprintf(stderr, "LEVITTE_DEBUG_MEM: < 0x%p\n", str);
247#endif 324#endif
248 free_func(str); 325 free_func(str);
249 if (free_debug_func != NULL) 326 if (free_debug_func != NULL)
diff --git a/src/lib/libcrypto/mem_dbg.c b/src/lib/libcrypto/mem_dbg.c
index ef19d8f844..1c4e04f51f 100644
--- a/src/lib/libcrypto/mem_dbg.c
+++ b/src/lib/libcrypto/mem_dbg.c
@@ -235,37 +235,43 @@ long CRYPTO_dbg_get_options(void)
235 return options; 235 return options;
236 } 236 }
237 237
238static int mem_cmp(MEM *a, MEM *b) 238/* static int mem_cmp(MEM *a, MEM *b) */
239static int mem_cmp(const void *a_void, const void *b_void)
239 { 240 {
240 return((char *)a->addr - (char *)b->addr); 241 return((const char *)((const MEM *)a_void)->addr
242 - (const char *)((const MEM *)b_void)->addr);
241 } 243 }
242 244
243static unsigned long mem_hash(MEM *a) 245/* static unsigned long mem_hash(MEM *a) */
246static unsigned long mem_hash(const void *a_void)
244 { 247 {
245 unsigned long ret; 248 unsigned long ret;
246 249
247 ret=(unsigned long)a->addr; 250 ret=(unsigned long)((const MEM *)a_void)->addr;
248 251
249 ret=ret*17851+(ret>>14)*7+(ret>>4)*251; 252 ret=ret*17851+(ret>>14)*7+(ret>>4)*251;
250 return(ret); 253 return(ret);
251 } 254 }
252 255
253static int app_info_cmp(APP_INFO *a, APP_INFO *b) 256/* static int app_info_cmp(APP_INFO *a, APP_INFO *b) */
257static int app_info_cmp(const void *a_void, const void *b_void)
254 { 258 {
255 return(a->thread != b->thread); 259 return(((const APP_INFO *)a_void)->thread
260 != ((const APP_INFO *)b_void)->thread);
256 } 261 }
257 262
258static unsigned long app_info_hash(APP_INFO *a) 263/* static unsigned long app_info_hash(APP_INFO *a) */
264static unsigned long app_info_hash(const void *a_void)
259 { 265 {
260 unsigned long ret; 266 unsigned long ret;
261 267
262 ret=(unsigned long)a->thread; 268 ret=(unsigned long)((const APP_INFO *)a_void)->thread;
263 269
264 ret=ret*17851+(ret>>14)*7+(ret>>4)*251; 270 ret=ret*17851+(ret>>14)*7+(ret>>4)*251;
265 return(ret); 271 return(ret);
266 } 272 }
267 273
268static APP_INFO *pop_info() 274static APP_INFO *pop_info(void)
269 { 275 {
270 APP_INFO tmp; 276 APP_INFO tmp;
271 APP_INFO *ret = NULL; 277 APP_INFO *ret = NULL;
@@ -282,7 +288,7 @@ static APP_INFO *pop_info()
282 next->references++; 288 next->references++;
283 lh_insert(amih,(char *)next); 289 lh_insert(amih,(char *)next);
284 } 290 }
285#ifdef LEVITTE_DEBUG 291#ifdef LEVITTE_DEBUG_MEM
286 if (ret->thread != tmp.thread) 292 if (ret->thread != tmp.thread)
287 { 293 {
288 fprintf(stderr, "pop_info(): deleted info has other thread ID (%lu) than the current thread (%lu)!!!!\n", 294 fprintf(stderr, "pop_info(): deleted info has other thread ID (%lu) than the current thread (%lu)!!!!\n",
@@ -318,7 +324,7 @@ int CRYPTO_push_info_(const char *info, const char *file, int line)
318 } 324 }
319 if (amih == NULL) 325 if (amih == NULL)
320 { 326 {
321 if ((amih=lh_new(app_info_hash,app_info_cmp)) == NULL) 327 if ((amih=lh_new(app_info_hash, app_info_cmp)) == NULL)
322 { 328 {
323 OPENSSL_free(ami); 329 OPENSSL_free(ami);
324 ret=0; 330 ret=0;
@@ -335,7 +341,7 @@ int CRYPTO_push_info_(const char *info, const char *file, int line)
335 341
336 if ((amim=(APP_INFO *)lh_insert(amih,(char *)ami)) != NULL) 342 if ((amim=(APP_INFO *)lh_insert(amih,(char *)ami)) != NULL)
337 { 343 {
338#ifdef LEVITTE_DEBUG 344#ifdef LEVITTE_DEBUG_MEM
339 if (ami->thread != amim->thread) 345 if (ami->thread != amim->thread)
340 { 346 {
341 fprintf(stderr, "CRYPTO_push_info(): previous info has other thread ID (%lu) than the current thread (%lu)!!!!\n", 347 fprintf(stderr, "CRYPTO_push_info(): previous info has other thread ID (%lu) than the current thread (%lu)!!!!\n",
@@ -411,7 +417,7 @@ void CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line,
411 } 417 }
412 if (mh == NULL) 418 if (mh == NULL)
413 { 419 {
414 if ((mh=lh_new(mem_hash,mem_cmp)) == NULL) 420 if ((mh=lh_new(mem_hash, mem_cmp)) == NULL)
415 { 421 {
416 OPENSSL_free(addr); 422 OPENSSL_free(addr);
417 OPENSSL_free(m); 423 OPENSSL_free(m);
@@ -435,8 +441,8 @@ void CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line,
435 m->order=order; 441 m->order=order;
436 } 442 }
437 m->order=order++; 443 m->order=order++;
438#ifdef LEVITTE_DEBUG 444#ifdef LEVITTE_DEBUG_MEM
439 fprintf(stderr, "LEVITTE_DEBUG: [%5d] %c 0x%p (%d)\n", 445 fprintf(stderr, "LEVITTE_DEBUG_MEM: [%5d] %c 0x%p (%d)\n",
440 m->order, 446 m->order,
441 (before_p & 128) ? '*' : '+', 447 (before_p & 128) ? '*' : '+',
442 m->addr, m->num); 448 m->addr, m->num);
@@ -491,8 +497,8 @@ void CRYPTO_dbg_free(void *addr, int before_p)
491 mp=(MEM *)lh_delete(mh,(char *)&m); 497 mp=(MEM *)lh_delete(mh,(char *)&m);
492 if (mp != NULL) 498 if (mp != NULL)
493 { 499 {
494#ifdef LEVITTE_DEBUG 500#ifdef LEVITTE_DEBUG_MEM
495 fprintf(stderr, "LEVITTE_DEBUG: [%5d] - 0x%p (%d)\n", 501 fprintf(stderr, "LEVITTE_DEBUG_MEM: [%5d] - 0x%p (%d)\n",
496 mp->order, mp->addr, mp->num); 502 mp->order, mp->addr, mp->num);
497#endif 503#endif
498 if (mp->app_info != NULL) 504 if (mp->app_info != NULL)
@@ -516,8 +522,8 @@ void CRYPTO_dbg_realloc(void *addr1, void *addr2, int num,
516 { 522 {
517 MEM m,*mp; 523 MEM m,*mp;
518 524
519#ifdef LEVITTE_DEBUG 525#ifdef LEVITTE_DEBUG_MEM
520 fprintf(stderr, "LEVITTE_DEBUG: --> CRYPTO_dbg_malloc(addr1 = %p, addr2 = %p, num = %d, file = \"%s\", line = %d, before_p = %d)\n", 526 fprintf(stderr, "LEVITTE_DEBUG_MEM: --> CRYPTO_dbg_malloc(addr1 = %p, addr2 = %p, num = %d, file = \"%s\", line = %d, before_p = %d)\n",
521 addr1, addr2, num, file, line, before_p); 527 addr1, addr2, num, file, line, before_p);
522#endif 528#endif
523 529
@@ -543,8 +549,8 @@ void CRYPTO_dbg_realloc(void *addr1, void *addr2, int num,
543 mp=(MEM *)lh_delete(mh,(char *)&m); 549 mp=(MEM *)lh_delete(mh,(char *)&m);
544 if (mp != NULL) 550 if (mp != NULL)
545 { 551 {
546#ifdef LEVITTE_DEBUG 552#ifdef LEVITTE_DEBUG_MEM
547 fprintf(stderr, "LEVITTE_DEBUG: [%5d] * 0x%p (%d) -> 0x%p (%d)\n", 553 fprintf(stderr, "LEVITTE_DEBUG_MEM: [%5d] * 0x%p (%d) -> 0x%p (%d)\n",
548 mp->order, 554 mp->order,
549 mp->addr, mp->num, 555 mp->addr, mp->num,
550 addr2, num); 556 addr2, num);
@@ -570,7 +576,7 @@ typedef struct mem_leak_st
570 long bytes; 576 long bytes;
571 } MEM_LEAK; 577 } MEM_LEAK;
572 578
573static void print_leak(MEM *m, MEM_LEAK *l) 579static void print_leak(const MEM *m, MEM_LEAK *l)
574 { 580 {
575 char buf[1024]; 581 char buf[1024];
576 char *bufp = buf; 582 char *bufp = buf;
@@ -646,7 +652,7 @@ static void print_leak(MEM *m, MEM_LEAK *l)
646 } 652 }
647 while(amip && amip->thread == ti); 653 while(amip && amip->thread == ti);
648 654
649#ifdef LEVITTE_DEBUG 655#ifdef LEVITTE_DEBUG_MEM
650 if (amip) 656 if (amip)
651 { 657 {
652 fprintf(stderr, "Thread switch detected in backtrace!!!!\n"); 658 fprintf(stderr, "Thread switch detected in backtrace!!!!\n");
@@ -655,6 +661,8 @@ static void print_leak(MEM *m, MEM_LEAK *l)
655#endif 661#endif
656 } 662 }
657 663
664static IMPLEMENT_LHASH_DOALL_ARG_FN(print_leak, const MEM *, MEM_LEAK *)
665
658void CRYPTO_mem_leaks(BIO *b) 666void CRYPTO_mem_leaks(BIO *b)
659 { 667 {
660 MEM_LEAK ml; 668 MEM_LEAK ml;
@@ -669,7 +677,8 @@ void CRYPTO_mem_leaks(BIO *b)
669 ml.bytes=0; 677 ml.bytes=0;
670 ml.chunks=0; 678 ml.chunks=0;
671 if (mh != NULL) 679 if (mh != NULL)
672 lh_doall_arg(mh,(void (*)())print_leak,(char *)&ml); 680 lh_doall_arg(mh, LHASH_DOALL_ARG_FN(print_leak),
681 (char *)&ml);
673 if (ml.chunks != 0) 682 if (ml.chunks != 0)
674 { 683 {
675 sprintf(buf,"%ld bytes leaked in %d chunks\n", 684 sprintf(buf,"%ld bytes leaked in %d chunks\n",
@@ -722,14 +731,19 @@ void CRYPTO_mem_leaks(BIO *b)
722 MemCheck_on(); /* release MALLOC2 lock */ 731 MemCheck_on(); /* release MALLOC2 lock */
723 } 732 }
724 733
725#ifndef NO_FP_API 734#ifndef OPENSSL_NO_FP_API
726void CRYPTO_mem_leaks_fp(FILE *fp) 735void CRYPTO_mem_leaks_fp(FILE *fp)
727 { 736 {
728 BIO *b; 737 BIO *b;
729 738
730 if (mh == NULL) return; 739 if (mh == NULL) return;
731 if ((b=BIO_new(BIO_s_file())) == NULL) 740 /* Need to turn off memory checking when allocated BIOs ... especially
732 return; 741 * as we're creating them at a time when we're trying to check we've not
742 * left anything un-free()'d!! */
743 MemCheck_off();
744 b = BIO_new(BIO_s_file());
745 MemCheck_on();
746 if(!b) return;
733 BIO_set_fp(b,fp,BIO_NOCLOSE); 747 BIO_set_fp(b,fp,BIO_NOCLOSE);
734 CRYPTO_mem_leaks(b); 748 CRYPTO_mem_leaks(b);
735 BIO_free(b); 749 BIO_free(b);
@@ -741,16 +755,20 @@ void CRYPTO_mem_leaks_fp(FILE *fp)
741/* FIXME: We really don't allow much to the callback. For example, it has 755/* FIXME: We really don't allow much to the callback. For example, it has
742 no chance of reaching the info stack for the item it processes. Should 756 no chance of reaching the info stack for the item it processes. Should
743 it really be this way? -- Richard Levitte */ 757 it really be this way? -- Richard Levitte */
744static void cb_leak(MEM *m, 758/* NB: The prototypes have been typedef'd to CRYPTO_MEM_LEAK_CB inside crypto.h
745 void (**cb)(unsigned long, const char *, int, int, void *)) 759 * If this code is restructured, remove the callback type if it is no longer
760 * needed. -- Geoff Thorpe */
761static void cb_leak(const MEM *m, CRYPTO_MEM_LEAK_CB **cb)
746 { 762 {
747 (**cb)(m->order,m->file,m->line,m->num,m->addr); 763 (**cb)(m->order,m->file,m->line,m->num,m->addr);
748 } 764 }
749 765
750void CRYPTO_mem_leaks_cb(void (*cb)(unsigned long, const char *, int, int, void *)) 766static IMPLEMENT_LHASH_DOALL_ARG_FN(cb_leak, const MEM *, CRYPTO_MEM_LEAK_CB **)
767
768void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb)
751 { 769 {
752 if (mh == NULL) return; 770 if (mh == NULL) return;
753 CRYPTO_w_lock(CRYPTO_LOCK_MALLOC2); 771 CRYPTO_w_lock(CRYPTO_LOCK_MALLOC2);
754 lh_doall_arg(mh,(void (*)())cb_leak,(void *)&cb); 772 lh_doall_arg(mh, LHASH_DOALL_ARG_FN(cb_leak), &cb);
755 CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC2); 773 CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC2);
756 } 774 }
diff --git a/src/lib/libcrypto/o_time.c b/src/lib/libcrypto/o_time.c
new file mode 100644
index 0000000000..1bc0297b36
--- /dev/null
+++ b/src/lib/libcrypto/o_time.c
@@ -0,0 +1,203 @@
1/* crypto/o_time.c -*- mode:C; c-file-style: "eay" -*- */
2/* Written by Richard Levitte (richard@levitte.org) 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 <openssl/e_os2.h>
60#include <string.h>
61#include "o_time.h"
62
63#ifdef OPENSSL_SYS_VMS
64# include <libdtdef.h>
65# include <lib$routines.h>
66# include <lnmdef.h>
67# include <starlet.h>
68# include <descrip.h>
69# include <stdlib.h>
70#endif
71
72struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result)
73 {
74 struct tm *ts = NULL;
75
76#if defined(OPENSSL_THREADS) && !defined(OPENSSL_SYS_WIN32) && !defined(OPENSSL_SYS_OS2) && !defined(__CYGWIN32__) && (!defined(OPENSSL_SYS_VMS) || defined(gmtime_r)) && !defined(OPENSSL_SYS_MACOSX)
77 /* should return &data, but doesn't on some systems,
78 so we don't even look at the return value */
79 gmtime_r(timer,result);
80 ts = result;
81#elif !defined(OPENSSL_SYS_VMS)
82 ts = gmtime(timer);
83 memcpy(result, ts, sizeof(struct tm));
84 ts = result;
85#endif
86#ifdef OPENSSL_SYS_VMS
87 if (ts == NULL)
88 {
89 static $DESCRIPTOR(tabnam,"LNM$DCL_LOGICAL");
90 static $DESCRIPTOR(lognam,"SYS$TIMEZONE_DIFFERENTIAL");
91 char logvalue[256];
92 unsigned int reslen = 0;
93 struct {
94 short buflen;
95 short code;
96 void *bufaddr;
97 unsigned int *reslen;
98 } itemlist[] = {
99 { 0, LNM$_STRING, 0, 0 },
100 { 0, 0, 0, 0 },
101 };
102 int status;
103 time_t t;
104
105 /* Get the value for SYS$TIMEZONE_DIFFERENTIAL */
106 itemlist[0].buflen = sizeof(logvalue);
107 itemlist[0].bufaddr = logvalue;
108 itemlist[0].reslen = &reslen;
109 status = sys$trnlnm(0, &tabnam, &lognam, 0, itemlist);
110 if (!(status & 1))
111 return NULL;
112 logvalue[reslen] = '\0';
113
114 /* Get the numerical value of the equivalence string */
115 status = atoi(logvalue);
116
117 /* and use it to move time to GMT */
118 t = *timer - status;
119
120 /* then convert the result to the time structure */
121#ifndef OPENSSL_THREADS
122 ts=(struct tm *)localtime(&t);
123#else
124 /* Since there was no gmtime_r() to do this stuff for us,
125 we have to do it the hard way. */
126 {
127 /* The VMS epoch is the astronomical Smithsonian date,
128 if I remember correctly, which is November 17, 1858.
129 Furthermore, time is measure in thenths of microseconds
130 and stored in quadwords (64 bit integers). unix_epoch
131 below is January 1st 1970 expressed as a VMS time. The
132 following code was used to get this number:
133
134 #include <stdio.h>
135 #include <stdlib.h>
136 #include <lib$routines.h>
137 #include <starlet.h>
138
139 main()
140 {
141 unsigned long systime[2];
142 unsigned short epoch_values[7] =
143 { 1970, 1, 1, 0, 0, 0, 0 };
144
145 lib$cvt_vectim(epoch_values, systime);
146
147 printf("%u %u", systime[0], systime[1]);
148 }
149 */
150 unsigned long unix_epoch[2] = { 1273708544, 8164711 };
151 unsigned long deltatime[2];
152 unsigned long systime[2];
153 struct vms_vectime
154 {
155 short year, month, day, hour, minute, second,
156 centi_second;
157 } time_values;
158 long operation;
159
160 /* Turn the number of seconds since January 1st 1970 to
161 an internal delta time.
162 Note that lib$cvt_to_internal_time() will assume
163 that t is signed, and will therefore break on 32-bit
164 systems some time in 2038.
165 */
166 operation = LIB$K_DELTA_SECONDS;
167 status = lib$cvt_to_internal_time(&operation,
168 &t, deltatime);
169
170 /* Add the delta time with the Unix epoch and we have
171 the current UTC time in internal format */
172 status = lib$add_times(unix_epoch, deltatime, systime);
173
174 /* Turn the internal time into a time vector */
175 status = sys$numtim(&time_values, systime);
176
177 /* Fill in the struct tm with the result */
178 result->tm_sec = time_values.second;
179 result->tm_min = time_values.minute;
180 result->tm_hour = time_values.hour;
181 result->tm_mday = time_values.day;
182 result->tm_mon = time_values.month - 1;
183 result->tm_year = time_values.year - 1900;
184
185 operation = LIB$K_DAY_OF_WEEK;
186 status = lib$cvt_from_internal_time(&operation,
187 &result->tm_wday, systime);
188 result->tm_wday %= 7;
189
190 operation = LIB$K_DAY_OF_YEAR;
191 status = lib$cvt_from_internal_time(&operation,
192 &result->tm_yday, systime);
193 result->tm_yday--;
194
195 result->tm_isdst = 0; /* There's no way to know... */
196
197 ts = result;
198#endif
199 }
200 }
201#endif
202 return ts;
203 }
diff --git a/src/lib/libcrypto/o_time.h b/src/lib/libcrypto/o_time.h
new file mode 100644
index 0000000000..e66044626d
--- /dev/null
+++ b/src/lib/libcrypto/o_time.h
@@ -0,0 +1,66 @@
1/* crypto/o_time.h -*- mode:C; c-file-style: "eay" -*- */
2/* Written by Richard Levitte (richard@levitte.org) 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#ifndef HEADER_O_TIME_H
60#define HEADER_O_TIME_H
61
62#include <time.h>
63
64struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result);
65
66#endif
diff --git a/src/lib/libcrypto/objects/Makefile.ssl b/src/lib/libcrypto/objects/Makefile.ssl
index 6746ad21e7..7962a089db 100644
--- a/src/lib/libcrypto/objects/Makefile.ssl
+++ b/src/lib/libcrypto/objects/Makefile.ssl
@@ -5,15 +5,17 @@
5DIR= objects 5DIR= objects
6TOP= ../.. 6TOP= ../..
7CC= cc 7CC= cc
8INCLUDES= -I.. -I../../include 8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g 9CFLAG=-g
10INSTALL_PREFIX= 10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl 11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl 12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl 13MAKE= make -f Makefile.ssl
14MAKEDEPEND= $(TOP)/util/domd $(TOP) 14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
15MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
16AR= ar r 17AR= ar r
18PERL= perl
17 19
18CFLAGS= $(INCLUDES) $(CFLAG) 20CFLAGS= $(INCLUDES) $(CFLAG)
19 21
@@ -39,10 +41,16 @@ all: obj_dat.h lib
39 41
40lib: $(LIBOBJ) 42lib: $(LIBOBJ)
41 $(AR) $(LIB) $(LIBOBJ) 43 $(AR) $(LIB) $(LIBOBJ)
42 @echo You may get an error following this line. Please ignore. 44 $(RANLIB) $(LIB) || echo Never mind.
43 - $(RANLIB) $(LIB)
44 @touch lib 45 @touch lib
45 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
46files: 54files:
47 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO 55 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
48 56
@@ -81,32 +89,35 @@ clean:
81 89
82o_names.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 90o_names.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
83o_names.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h 91o_names.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
84o_names.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 92o_names.o: ../../include/openssl/e_os2.h ../../include/openssl/lhash.h
85o_names.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 93o_names.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
86o_names.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 94o_names.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
95o_names.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
87o_names.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 96o_names.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
88obj_dat.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 97o_names.o: o_names.c
89obj_dat.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 98obj_dat.o: ../../e_os.h ../../include/openssl/asn1.h
90obj_dat.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 99obj_dat.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
100obj_dat.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
91obj_dat.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 101obj_dat.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
92obj_dat.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 102obj_dat.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
93obj_dat.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 103obj_dat.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
94obj_dat.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 104obj_dat.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
95obj_dat.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 105obj_dat.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
96obj_dat.o: ../cryptlib.h obj_dat.h 106obj_dat.o: ../../include/openssl/symhacks.h ../cryptlib.h obj_dat.c obj_dat.h
97obj_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 107obj_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
98obj_err.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h 108obj_err.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
99obj_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 109obj_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
100obj_err.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 110obj_err.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
101obj_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 111obj_err.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
112obj_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
102obj_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 113obj_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
103obj_err.o: ../../include/openssl/symhacks.h 114obj_err.o: ../../include/openssl/symhacks.h obj_err.c
104obj_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 115obj_lib.o: ../../e_os.h ../../include/openssl/asn1.h
105obj_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 116obj_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
106obj_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 117obj_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
107obj_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 118obj_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
108obj_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 119obj_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
109obj_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 120obj_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
110obj_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 121obj_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
111obj_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 122obj_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
112obj_lib.o: ../cryptlib.h 123obj_lib.o: ../../include/openssl/symhacks.h ../cryptlib.h obj_lib.c
diff --git a/src/lib/libcrypto/objects/o_names.c b/src/lib/libcrypto/objects/o_names.c
index dca988230e..2b80243256 100644
--- a/src/lib/libcrypto/objects/o_names.c
+++ b/src/lib/libcrypto/objects/o_names.c
@@ -5,6 +5,18 @@
5#include <openssl/lhash.h> 5#include <openssl/lhash.h>
6#include <openssl/objects.h> 6#include <openssl/objects.h>
7#include <openssl/safestack.h> 7#include <openssl/safestack.h>
8#include <openssl/e_os2.h>
9
10/* Later versions of DEC C has started to add lnkage information to certain
11 * functions, which makes it tricky to use them as values to regular function
12 * pointers. One way is to define a macro that takes care of casting them
13 * correctly.
14 */
15#ifdef OPENSSL_SYS_VMS_DECC
16# define OPENSSL_strcmp (int (*)(const char *,const char *))strcmp
17#else
18# define OPENSSL_strcmp strcmp
19#endif
8 20
9/* I use the ex_data stuff to manage the identifiers for the obj_name_types 21/* I use the ex_data stuff to manage the identifiers for the obj_name_types
10 * that applications may define. I only really use the free function field. 22 * that applications may define. I only really use the free function field.
@@ -14,9 +26,9 @@ static int names_type_num=OBJ_NAME_TYPE_NUM;
14 26
15typedef struct name_funcs_st 27typedef struct name_funcs_st
16 { 28 {
17 unsigned long (*hash_func)(); 29 unsigned long (*hash_func)(const char *name);
18 int (*cmp_func)(); 30 int (*cmp_func)(const char *a,const char *b);
19 void (*free_func)(); 31 void (*free_func)(const char *, int, const char *);
20 } NAME_FUNCS; 32 } NAME_FUNCS;
21 33
22DECLARE_STACK_OF(NAME_FUNCS) 34DECLARE_STACK_OF(NAME_FUNCS)
@@ -24,20 +36,26 @@ IMPLEMENT_STACK_OF(NAME_FUNCS)
24 36
25static STACK_OF(NAME_FUNCS) *name_funcs_stack; 37static STACK_OF(NAME_FUNCS) *name_funcs_stack;
26 38
27static unsigned long obj_name_hash(OBJ_NAME *a); 39/* The LHASH callbacks now use the raw "void *" prototypes and do per-variable
28static int obj_name_cmp(OBJ_NAME *a,OBJ_NAME *b); 40 * casting in the functions. This prevents function pointer casting without the
41 * need for macro-generated wrapper functions. */
42
43/* static unsigned long obj_name_hash(OBJ_NAME *a); */
44static unsigned long obj_name_hash(const void *a_void);
45/* static int obj_name_cmp(OBJ_NAME *a,OBJ_NAME *b); */
46static int obj_name_cmp(const void *a_void,const void *b_void);
29 47
30int OBJ_NAME_init(void) 48int OBJ_NAME_init(void)
31 { 49 {
32 if (names_lh != NULL) return(1); 50 if (names_lh != NULL) return(1);
33 MemCheck_off(); 51 MemCheck_off();
34 names_lh=lh_new(obj_name_hash,obj_name_cmp); 52 names_lh=lh_new(obj_name_hash, obj_name_cmp);
35 MemCheck_on(); 53 MemCheck_on();
36 return(names_lh != NULL); 54 return(names_lh != NULL);
37 } 55 }
38 56
39int OBJ_NAME_new_index(unsigned long (*hash_func)(const char *), 57int OBJ_NAME_new_index(unsigned long (*hash_func)(const char *),
40 int (*cmp_func)(const void *, const void *), 58 int (*cmp_func)(const char *, const char *),
41 void (*free_func)(const char *, int, const char *)) 59 void (*free_func)(const char *, int, const char *))
42 { 60 {
43 int ret; 61 int ret;
@@ -62,12 +80,12 @@ int OBJ_NAME_new_index(unsigned long (*hash_func)(const char *),
62 MemCheck_off(); 80 MemCheck_off();
63 name_funcs = OPENSSL_malloc(sizeof(NAME_FUNCS)); 81 name_funcs = OPENSSL_malloc(sizeof(NAME_FUNCS));
64 name_funcs->hash_func = lh_strhash; 82 name_funcs->hash_func = lh_strhash;
65 name_funcs->cmp_func = (int (*)())strcmp; 83 name_funcs->cmp_func = OPENSSL_strcmp;
66 name_funcs->free_func = 0; /* NULL is often declared to 84 name_funcs->free_func = 0; /* NULL is often declared to
67 * ((void *)0), which according 85 * ((void *)0), which according
68 * to Compaq C is not really 86 * to Compaq C is not really
69 * compatible with a function 87 * compatible with a function
70 * pointer. -- Richard Levitte*/ 88 * pointer. -- Richard Levitte*/
71 sk_NAME_FUNCS_push(name_funcs_stack,name_funcs); 89 sk_NAME_FUNCS_push(name_funcs_stack,name_funcs);
72 MemCheck_on(); 90 MemCheck_on();
73 } 91 }
@@ -81,9 +99,12 @@ int OBJ_NAME_new_index(unsigned long (*hash_func)(const char *),
81 return(ret); 99 return(ret);
82 } 100 }
83 101
84static int obj_name_cmp(OBJ_NAME *a, OBJ_NAME *b) 102/* static int obj_name_cmp(OBJ_NAME *a, OBJ_NAME *b) */
103static int obj_name_cmp(const void *a_void, const void *b_void)
85 { 104 {
86 int ret; 105 int ret;
106 OBJ_NAME *a = (OBJ_NAME *)a_void;
107 OBJ_NAME *b = (OBJ_NAME *)b_void;
87 108
88 ret=a->type-b->type; 109 ret=a->type-b->type;
89 if (ret == 0) 110 if (ret == 0)
@@ -91,8 +112,8 @@ static int obj_name_cmp(OBJ_NAME *a, OBJ_NAME *b)
91 if ((name_funcs_stack != NULL) 112 if ((name_funcs_stack != NULL)
92 && (sk_NAME_FUNCS_num(name_funcs_stack) > a->type)) 113 && (sk_NAME_FUNCS_num(name_funcs_stack) > a->type))
93 { 114 {
94 ret=sk_NAME_FUNCS_value(name_funcs_stack,a->type) 115 ret=sk_NAME_FUNCS_value(name_funcs_stack,
95 ->cmp_func(a->name,b->name); 116 a->type)->cmp_func(a->name,b->name);
96 } 117 }
97 else 118 else
98 ret=strcmp(a->name,b->name); 119 ret=strcmp(a->name,b->name);
@@ -100,14 +121,16 @@ static int obj_name_cmp(OBJ_NAME *a, OBJ_NAME *b)
100 return(ret); 121 return(ret);
101 } 122 }
102 123
103static unsigned long obj_name_hash(OBJ_NAME *a) 124/* static unsigned long obj_name_hash(OBJ_NAME *a) */
125static unsigned long obj_name_hash(const void *a_void)
104 { 126 {
105 unsigned long ret; 127 unsigned long ret;
128 OBJ_NAME *a = (OBJ_NAME *)a_void;
106 129
107 if ((name_funcs_stack != NULL) && (sk_NAME_FUNCS_num(name_funcs_stack) > a->type)) 130 if ((name_funcs_stack != NULL) && (sk_NAME_FUNCS_num(name_funcs_stack) > a->type))
108 { 131 {
109 ret=sk_NAME_FUNCS_value(name_funcs_stack,a->type) 132 ret=sk_NAME_FUNCS_value(name_funcs_stack,
110 ->hash_func(a->name); 133 a->type)->hash_func(a->name);
111 } 134 }
112 else 135 else
113 { 136 {
@@ -132,7 +155,7 @@ const char *OBJ_NAME_get(const char *name, int type)
132 on.type=type; 155 on.type=type;
133 156
134 for (;;) 157 for (;;)
135 { 158 {
136 ret=(OBJ_NAME *)lh_retrieve(names_lh,&on); 159 ret=(OBJ_NAME *)lh_retrieve(names_lh,&on);
137 if (ret == NULL) return(NULL); 160 if (ret == NULL) return(NULL);
138 if ((ret->alias) && !alias) 161 if ((ret->alias) && !alias)
@@ -179,8 +202,8 @@ int OBJ_NAME_add(const char *name, int type, const char *data)
179 * function should get three arguments... 202 * function should get three arguments...
180 * -- Richard Levitte 203 * -- Richard Levitte
181 */ 204 */
182 sk_NAME_FUNCS_value(name_funcs_stack,ret->type) 205 sk_NAME_FUNCS_value(name_funcs_stack,
183 ->free_func(ret->name,ret->type,ret->data); 206 ret->type)->free_func(ret->name,ret->type,ret->data);
184 } 207 }
185 OPENSSL_free(ret); 208 OPENSSL_free(ret);
186 } 209 }
@@ -214,8 +237,8 @@ int OBJ_NAME_remove(const char *name, int type)
214 * function should get three arguments... 237 * function should get three arguments...
215 * -- Richard Levitte 238 * -- Richard Levitte
216 */ 239 */
217 sk_NAME_FUNCS_value(name_funcs_stack,ret->type) 240 sk_NAME_FUNCS_value(name_funcs_stack,
218 ->free_func(ret->name,ret->type,ret->data); 241 ret->type)->free_func(ret->name,ret->type,ret->data);
219 } 242 }
220 OPENSSL_free(ret); 243 OPENSSL_free(ret);
221 return(1); 244 return(1);
@@ -224,12 +247,82 @@ int OBJ_NAME_remove(const char *name, int type)
224 return(0); 247 return(0);
225 } 248 }
226 249
250struct doall
251 {
252 int type;
253 void (*fn)(const OBJ_NAME *,void *arg);
254 void *arg;
255 };
256
257static void do_all_fn(const OBJ_NAME *name,struct doall *d)
258 {
259 if(name->type == d->type)
260 d->fn(name,d->arg);
261 }
262
263static IMPLEMENT_LHASH_DOALL_ARG_FN(do_all_fn, const OBJ_NAME *, struct doall *)
264
265void OBJ_NAME_do_all(int type,void (*fn)(const OBJ_NAME *,void *arg),void *arg)
266 {
267 struct doall d;
268
269 d.type=type;
270 d.fn=fn;
271 d.arg=arg;
272
273 lh_doall_arg(names_lh,LHASH_DOALL_ARG_FN(do_all_fn),&d);
274 }
275
276struct doall_sorted
277 {
278 int type;
279 int n;
280 const OBJ_NAME **names;
281 };
282
283static void do_all_sorted_fn(const OBJ_NAME *name,void *d_)
284 {
285 struct doall_sorted *d=d_;
286
287 if(name->type != d->type)
288 return;
289
290 d->names[d->n++]=name;
291 }
292
293static int do_all_sorted_cmp(const void *n1_,const void *n2_)
294 {
295 const OBJ_NAME * const *n1=n1_;
296 const OBJ_NAME * const *n2=n2_;
297
298 return strcmp((*n1)->name,(*n2)->name);
299 }
300
301void OBJ_NAME_do_all_sorted(int type,void (*fn)(const OBJ_NAME *,void *arg),
302 void *arg)
303 {
304 struct doall_sorted d;
305 int n;
306
307 d.type=type;
308 d.names=OPENSSL_malloc(lh_num_items(names_lh)*sizeof *d.names);
309 d.n=0;
310 OBJ_NAME_do_all(type,do_all_sorted_fn,&d);
311
312 qsort((void *)d.names,d.n,sizeof *d.names,do_all_sorted_cmp);
313
314 for(n=0 ; n < d.n ; ++n)
315 fn(d.names[n],arg);
316
317 OPENSSL_free((void *)d.names);
318 }
319
227static int free_type; 320static int free_type;
228 321
229static void names_lh_free(OBJ_NAME *onp, int type) 322static void names_lh_free(OBJ_NAME *onp)
230{ 323{
231 if(onp == NULL) 324 if(onp == NULL)
232 return; 325 return;
233 326
234 if ((free_type < 0) || (free_type == onp->type)) 327 if ((free_type < 0) || (free_type == onp->type))
235 { 328 {
@@ -237,6 +330,8 @@ static void names_lh_free(OBJ_NAME *onp, int type)
237 } 330 }
238 } 331 }
239 332
333static IMPLEMENT_LHASH_DOALL_FN(names_lh_free, OBJ_NAME *)
334
240static void name_funcs_free(NAME_FUNCS *ptr) 335static void name_funcs_free(NAME_FUNCS *ptr)
241 { 336 {
242 OPENSSL_free(ptr); 337 OPENSSL_free(ptr);
@@ -252,7 +347,7 @@ void OBJ_NAME_cleanup(int type)
252 down_load=names_lh->down_load; 347 down_load=names_lh->down_load;
253 names_lh->down_load=0; 348 names_lh->down_load=0;
254 349
255 lh_doall(names_lh,names_lh_free); 350 lh_doall(names_lh,LHASH_DOALL_FN(names_lh_free));
256 if (type < 0) 351 if (type < 0)
257 { 352 {
258 lh_free(names_lh); 353 lh_free(names_lh);
diff --git a/src/lib/libcrypto/objects/obj_dat.c b/src/lib/libcrypto/objects/obj_dat.c
index 4b1bb9583a..8779ba7d1d 100644
--- a/src/lib/libcrypto/objects/obj_dat.c
+++ b/src/lib/libcrypto/objects/obj_dat.c
@@ -64,7 +64,7 @@
64#include <openssl/objects.h> 64#include <openssl/objects.h>
65 65
66/* obj_dat.h is generated from objects.h by obj_dat.pl */ 66/* obj_dat.h is generated from objects.h by obj_dat.pl */
67#ifndef NO_OBJECT 67#ifndef OPENSSL_NO_OBJECT
68#include "obj_dat.h" 68#include "obj_dat.h"
69#else 69#else
70/* You will have to load all the objects needed manually in the application */ 70/* You will have to load all the objects needed manually in the application */
@@ -108,12 +108,14 @@ static int ln_cmp(const void *a, const void *b)
108 return(strcmp((*ap)->ln,(*bp)->ln)); 108 return(strcmp((*ap)->ln,(*bp)->ln));
109 } 109 }
110 110
111static unsigned long add_hash(ADDED_OBJ *ca) 111/* static unsigned long add_hash(ADDED_OBJ *ca) */
112static unsigned long add_hash(const void *ca_void)
112 { 113 {
113 ASN1_OBJECT *a; 114 const ASN1_OBJECT *a;
114 int i; 115 int i;
115 unsigned long ret=0; 116 unsigned long ret=0;
116 unsigned char *p; 117 unsigned char *p;
118 ADDED_OBJ *ca = (ADDED_OBJ *)ca_void;
117 119
118 a=ca->obj; 120 a=ca->obj;
119 switch (ca->type) 121 switch (ca->type)
@@ -142,10 +144,13 @@ static unsigned long add_hash(ADDED_OBJ *ca)
142 return(ret); 144 return(ret);
143 } 145 }
144 146
145static int add_cmp(ADDED_OBJ *ca, ADDED_OBJ *cb) 147/* static int add_cmp(ADDED_OBJ *ca, ADDED_OBJ *cb) */
148static int add_cmp(const void *ca_void, const void *cb_void)
146 { 149 {
147 ASN1_OBJECT *a,*b; 150 ASN1_OBJECT *a,*b;
148 int i; 151 int i;
152 ADDED_OBJ *ca = (ADDED_OBJ *)ca_void;
153 ADDED_OBJ *cb = (ADDED_OBJ *)cb_void;
149 154
150 i=ca->type-cb->type; 155 i=ca->type-cb->type;
151 if (i) return(i); 156 if (i) return(i);
@@ -171,7 +176,6 @@ static int add_cmp(ADDED_OBJ *ca, ADDED_OBJ *cb)
171 /* abort(); */ 176 /* abort(); */
172 return 0; 177 return 0;
173 } 178 }
174 return(1); /* should not get here */
175 } 179 }
176 180
177static int init_added(void) 181static int init_added(void)
@@ -199,13 +203,17 @@ static void cleanup3(ADDED_OBJ *a)
199 OPENSSL_free(a); 203 OPENSSL_free(a);
200 } 204 }
201 205
206static IMPLEMENT_LHASH_DOALL_FN(cleanup1, ADDED_OBJ *)
207static IMPLEMENT_LHASH_DOALL_FN(cleanup2, ADDED_OBJ *)
208static IMPLEMENT_LHASH_DOALL_FN(cleanup3, ADDED_OBJ *)
209
202void OBJ_cleanup(void) 210void OBJ_cleanup(void)
203 { 211 {
204 if (added == NULL) return; 212 if (added == NULL) return;
205 added->down_load=0; 213 added->down_load=0;
206 lh_doall(added,cleanup1); /* zero counters */ 214 lh_doall(added,LHASH_DOALL_FN(cleanup1)); /* zero counters */
207 lh_doall(added,cleanup2); /* set counters */ 215 lh_doall(added,LHASH_DOALL_FN(cleanup2)); /* set counters */
208 lh_doall(added,cleanup3); /* free objects */ 216 lh_doall(added,LHASH_DOALL_FN(cleanup3)); /* free objects */
209 lh_free(added); 217 lh_free(added);
210 added=NULL; 218 added=NULL;
211 } 219 }
@@ -219,7 +227,7 @@ int OBJ_new_nid(int num)
219 return(i); 227 return(i);
220 } 228 }
221 229
222int OBJ_add_object(ASN1_OBJECT *obj) 230int OBJ_add_object(const ASN1_OBJECT *obj)
223 { 231 {
224 ASN1_OBJECT *o; 232 ASN1_OBJECT *o;
225 ADDED_OBJ *ao[4]={NULL,NULL,NULL,NULL},*aop; 233 ADDED_OBJ *ao[4]={NULL,NULL,NULL,NULL},*aop;
@@ -355,7 +363,7 @@ const char *OBJ_nid2ln(int n)
355 } 363 }
356 } 364 }
357 365
358int OBJ_obj2nid(ASN1_OBJECT *a) 366int OBJ_obj2nid(const ASN1_OBJECT *a)
359 { 367 {
360 ASN1_OBJECT **op; 368 ASN1_OBJECT **op;
361 ADDED_OBJ ad,*adp; 369 ADDED_OBJ ad,*adp;
@@ -368,7 +376,7 @@ int OBJ_obj2nid(ASN1_OBJECT *a)
368 if (added != NULL) 376 if (added != NULL)
369 { 377 {
370 ad.type=ADDED_DATA; 378 ad.type=ADDED_DATA;
371 ad.obj=a; 379 ad.obj=(ASN1_OBJECT *)a; /* XXX: ugly but harmless */
372 adp=(ADDED_OBJ *)lh_retrieve(added,&ad); 380 adp=(ADDED_OBJ *)lh_retrieve(added,&ad);
373 if (adp != NULL) return (adp->obj->nid); 381 if (adp != NULL) return (adp->obj->nid);
374 } 382 }
@@ -422,7 +430,7 @@ ASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name)
422 return op; 430 return op;
423 } 431 }
424 432
425int OBJ_obj2txt(char *buf, int buf_len, ASN1_OBJECT *a, int no_name) 433int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
426{ 434{
427 int i,idx=0,n=0,len,nid; 435 int i,idx=0,n=0,len,nid;
428 unsigned long l; 436 unsigned long l;
@@ -437,8 +445,7 @@ int OBJ_obj2txt(char *buf, int buf_len, ASN1_OBJECT *a, int no_name)
437 return(0); 445 return(0);
438 } 446 }
439 447
440 nid=OBJ_obj2nid(a); 448 if (no_name || (nid=OBJ_obj2nid(a)) == NID_undef) {
441 if ((nid == NID_undef) || no_name) {
442 len=a->length; 449 len=a->length;
443 p=a->data; 450 p=a->data;
444 451
@@ -488,7 +495,7 @@ int OBJ_obj2txt(char *buf, int buf_len, ASN1_OBJECT *a, int no_name)
488 return(n); 495 return(n);
489} 496}
490 497
491int OBJ_txt2nid(char *s) 498int OBJ_txt2nid(const char *s)
492{ 499{
493 ASN1_OBJECT *obj; 500 ASN1_OBJECT *obj;
494 int nid; 501 int nid;
@@ -547,10 +554,11 @@ static int obj_cmp(const void *ap, const void *bp)
547 return(memcmp(a->data,b->data,a->length)); 554 return(memcmp(a->data,b->data,a->length));
548 } 555 }
549 556
550char *OBJ_bsearch(char *key, char *base, int num, int size, int (*cmp)(const void *, const void *)) 557const char *OBJ_bsearch(const char *key, const char *base, int num, int size,
558 int (*cmp)(const void *, const void *))
551 { 559 {
552 int l,h,i,c; 560 int l,h,i,c;
553 char *p; 561 const char *p;
554 562
555 if (num == 0) return(NULL); 563 if (num == 0) return(NULL);
556 l=0; 564 l=0;
@@ -629,7 +637,7 @@ int OBJ_create_objects(BIO *in)
629 /* return(num); */ 637 /* return(num); */
630 } 638 }
631 639
632int OBJ_create(char *oid, char *sn, char *ln) 640int OBJ_create(const char *oid, const char *sn, const char *ln)
633 { 641 {
634 int ok=0; 642 int ok=0;
635 ASN1_OBJECT *op=NULL; 643 ASN1_OBJECT *op=NULL;
@@ -645,6 +653,8 @@ int OBJ_create(char *oid, char *sn, char *ln)
645 return(0); 653 return(0);
646 } 654 }
647 i=a2d_ASN1_OBJECT(buf,i,oid,-1); 655 i=a2d_ASN1_OBJECT(buf,i,oid,-1);
656 if (i == 0)
657 goto err;
648 op=(ASN1_OBJECT *)ASN1_OBJECT_create(OBJ_new_nid(1),buf,i,sn,ln); 658 op=(ASN1_OBJECT *)ASN1_OBJECT_create(OBJ_new_nid(1),buf,i,sn,ln);
649 if (op == NULL) 659 if (op == NULL)
650 goto err; 660 goto err;
diff --git a/src/lib/libcrypto/objects/obj_dat.h b/src/lib/libcrypto/objects/obj_dat.h
new file mode 100644
index 0000000000..39cfcda783
--- /dev/null
+++ b/src/lib/libcrypto/objects/obj_dat.h
@@ -0,0 +1,2842 @@
1/* crypto/objects/obj_dat.h */
2
3/* THIS FILE IS GENERATED FROM objects.h by obj_dat.pl via the
4 * following command:
5 * perl obj_dat.pl obj_mac.h obj_dat.h
6 */
7
8/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
9 * All rights reserved.
10 *
11 * This package is an SSL implementation written
12 * by Eric Young (eay@cryptsoft.com).
13 * The implementation was written so as to conform with Netscapes SSL.
14 *
15 * This library is free for commercial and non-commercial use as long as
16 * the following conditions are aheared to. The following conditions
17 * apply to all code found in this distribution, be it the RC4, RSA,
18 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
19 * included with this distribution is covered by the same copyright terms
20 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
21 *
22 * Copyright remains Eric Young's, and as such any Copyright notices in
23 * the code are not to be removed.
24 * If this package is used in a product, Eric Young should be given attribution
25 * as the author of the parts of the library used.
26 * This can be in the form of a textual message at program startup or
27 * in documentation (online or textual) provided with the package.
28 *
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
31 * are met:
32 * 1. Redistributions of source code must retain the copyright
33 * notice, this list of conditions and the following disclaimer.
34 * 2. Redistributions in binary form must reproduce the above copyright
35 * notice, this list of conditions and the following disclaimer in the
36 * documentation and/or other materials provided with the distribution.
37 * 3. All advertising materials mentioning features or use of this software
38 * must display the following acknowledgement:
39 * "This product includes cryptographic software written by
40 * Eric Young (eay@cryptsoft.com)"
41 * The word 'cryptographic' can be left out if the rouines from the library
42 * being used are not cryptographic related :-).
43 * 4. If you include any Windows specific code (or a derivative thereof) from
44 * the apps directory (application code) you must include an acknowledgement:
45 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
46 *
47 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
48 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
50 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
51 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
53 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
54 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
55 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
56 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
57 * SUCH DAMAGE.
58 *
59 * The licence and distribution terms for any publically available version or
60 * derivative of this code cannot be changed. i.e. this code cannot simply be
61 * copied and put under another distribution licence
62 * [including the GNU Public Licence.]
63 */
64
65#define NUM_NID 510
66#define NUM_SN 507
67#define NUM_LN 507
68#define NUM_OBJ 481
69
70static unsigned char lvalues[3881]={
710x00, /* [ 0] OBJ_undef */
720x2A,0x86,0x48,0x86,0xF7,0x0D, /* [ 1] OBJ_rsadsi */
730x2A,0x86,0x48,0x86,0xF7,0x0D,0x01, /* [ 7] OBJ_pkcs */
740x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x02, /* [ 14] OBJ_md2 */
750x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x05, /* [ 22] OBJ_md5 */
760x2A,0x86,0x48,0x86,0xF7,0x0D,0x03,0x04, /* [ 30] OBJ_rc4 */
770x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,/* [ 38] OBJ_rsaEncryption */
780x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x02,/* [ 47] OBJ_md2WithRSAEncryption */
790x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x04,/* [ 56] OBJ_md5WithRSAEncryption */
800x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x05,0x01,/* [ 65] OBJ_pbeWithMD2AndDES_CBC */
810x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x05,0x03,/* [ 74] OBJ_pbeWithMD5AndDES_CBC */
820x55, /* [ 83] OBJ_X500 */
830x55,0x04, /* [ 84] OBJ_X509 */
840x55,0x04,0x03, /* [ 86] OBJ_commonName */
850x55,0x04,0x06, /* [ 89] OBJ_countryName */
860x55,0x04,0x07, /* [ 92] OBJ_localityName */
870x55,0x04,0x08, /* [ 95] OBJ_stateOrProvinceName */
880x55,0x04,0x0A, /* [ 98] OBJ_organizationName */
890x55,0x04,0x0B, /* [101] OBJ_organizationalUnitName */
900x55,0x08,0x01,0x01, /* [104] OBJ_rsa */
910x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x07, /* [108] OBJ_pkcs7 */
920x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x07,0x01,/* [116] OBJ_pkcs7_data */
930x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x07,0x02,/* [125] OBJ_pkcs7_signed */
940x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x07,0x03,/* [134] OBJ_pkcs7_enveloped */
950x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x07,0x04,/* [143] OBJ_pkcs7_signedAndEnveloped */
960x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x07,0x05,/* [152] OBJ_pkcs7_digest */
970x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x07,0x06,/* [161] OBJ_pkcs7_encrypted */
980x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x03, /* [170] OBJ_pkcs3 */
990x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x03,0x01,/* [178] OBJ_dhKeyAgreement */
1000x2B,0x0E,0x03,0x02,0x06, /* [187] OBJ_des_ecb */
1010x2B,0x0E,0x03,0x02,0x09, /* [192] OBJ_des_cfb64 */
1020x2B,0x0E,0x03,0x02,0x07, /* [197] OBJ_des_cbc */
1030x2B,0x0E,0x03,0x02,0x11, /* [202] OBJ_des_ede_ecb */
1040x2B,0x06,0x01,0x04,0x01,0x81,0x3C,0x07,0x01,0x01,0x02,/* [207] OBJ_idea_cbc */
1050x2A,0x86,0x48,0x86,0xF7,0x0D,0x03,0x02, /* [218] OBJ_rc2_cbc */
1060x2B,0x0E,0x03,0x02,0x12, /* [226] OBJ_sha */
1070x2B,0x0E,0x03,0x02,0x0F, /* [231] OBJ_shaWithRSAEncryption */
1080x2A,0x86,0x48,0x86,0xF7,0x0D,0x03,0x07, /* [236] OBJ_des_ede3_cbc */
1090x2B,0x0E,0x03,0x02,0x08, /* [244] OBJ_des_ofb64 */
1100x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09, /* [249] OBJ_pkcs9 */
1110x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x01,/* [257] OBJ_pkcs9_emailAddress */
1120x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x02,/* [266] OBJ_pkcs9_unstructuredName */
1130x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x03,/* [275] OBJ_pkcs9_contentType */
1140x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x04,/* [284] OBJ_pkcs9_messageDigest */
1150x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x05,/* [293] OBJ_pkcs9_signingTime */
1160x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x06,/* [302] OBJ_pkcs9_countersignature */
1170x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x07,/* [311] OBJ_pkcs9_challengePassword */
1180x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x08,/* [320] OBJ_pkcs9_unstructuredAddress */
1190x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x09,/* [329] OBJ_pkcs9_extCertAttributes */
1200x60,0x86,0x48,0x01,0x86,0xF8,0x42, /* [338] OBJ_netscape */
1210x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01, /* [345] OBJ_netscape_cert_extension */
1220x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x02, /* [353] OBJ_netscape_data_type */
1230x2B,0x0E,0x03,0x02,0x1A, /* [361] OBJ_sha1 */
1240x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x05,/* [366] OBJ_sha1WithRSAEncryption */
1250x2B,0x0E,0x03,0x02,0x0D, /* [375] OBJ_dsaWithSHA */
1260x2B,0x0E,0x03,0x02,0x0C, /* [380] OBJ_dsa_2 */
1270x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x05,0x0B,/* [385] OBJ_pbeWithSHA1AndRC2_CBC */
1280x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x05,0x0C,/* [394] OBJ_id_pbkdf2 */
1290x2B,0x0E,0x03,0x02,0x1B, /* [403] OBJ_dsaWithSHA1_2 */
1300x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x01,/* [408] OBJ_netscape_cert_type */
1310x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x02,/* [417] OBJ_netscape_base_url */
1320x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x03,/* [426] OBJ_netscape_revocation_url */
1330x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x04,/* [435] OBJ_netscape_ca_revocation_url */
1340x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x07,/* [444] OBJ_netscape_renewal_url */
1350x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x08,/* [453] OBJ_netscape_ca_policy_url */
1360x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x0C,/* [462] OBJ_netscape_ssl_server_name */
1370x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x0D,/* [471] OBJ_netscape_comment */
1380x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x02,0x05,/* [480] OBJ_netscape_cert_sequence */
1390x55,0x1D, /* [489] OBJ_id_ce */
1400x55,0x1D,0x0E, /* [491] OBJ_subject_key_identifier */
1410x55,0x1D,0x0F, /* [494] OBJ_key_usage */
1420x55,0x1D,0x10, /* [497] OBJ_private_key_usage_period */
1430x55,0x1D,0x11, /* [500] OBJ_subject_alt_name */
1440x55,0x1D,0x12, /* [503] OBJ_issuer_alt_name */
1450x55,0x1D,0x13, /* [506] OBJ_basic_constraints */
1460x55,0x1D,0x14, /* [509] OBJ_crl_number */
1470x55,0x1D,0x20, /* [512] OBJ_certificate_policies */
1480x55,0x1D,0x23, /* [515] OBJ_authority_key_identifier */
1490x2B,0x06,0x01,0x04,0x01,0x97,0x55,0x01,0x02,/* [518] OBJ_bf_cbc */
1500x55,0x08,0x03,0x65, /* [527] OBJ_mdc2 */
1510x55,0x08,0x03,0x64, /* [531] OBJ_mdc2WithRSA */
1520x55,0x04,0x2A, /* [535] OBJ_givenName */
1530x55,0x04,0x04, /* [538] OBJ_surname */
1540x55,0x04,0x2B, /* [541] OBJ_initials */
1550x55,0x1D,0x1F, /* [544] OBJ_crl_distribution_points */
1560x2B,0x0E,0x03,0x02,0x03, /* [547] OBJ_md5WithRSA */
1570x55,0x04,0x05, /* [552] OBJ_serialNumber */
1580x55,0x04,0x0C, /* [555] OBJ_title */
1590x55,0x04,0x0D, /* [558] OBJ_description */
1600x2A,0x86,0x48,0x86,0xF6,0x7D,0x07,0x42,0x0A,/* [561] OBJ_cast5_cbc */
1610x2A,0x86,0x48,0x86,0xF6,0x7D,0x07,0x42,0x0C,/* [570] OBJ_pbeWithMD5AndCast5_CBC */
1620x2A,0x86,0x48,0xCE,0x38,0x04,0x03, /* [579] OBJ_dsaWithSHA1 */
1630x2B,0x0E,0x03,0x02,0x1D, /* [586] OBJ_sha1WithRSA */
1640x2A,0x86,0x48,0xCE,0x38,0x04,0x01, /* [591] OBJ_dsa */
1650x2B,0x24,0x03,0x02,0x01, /* [598] OBJ_ripemd160 */
1660x2B,0x24,0x03,0x03,0x01,0x02, /* [603] OBJ_ripemd160WithRSA */
1670x2A,0x86,0x48,0x86,0xF7,0x0D,0x03,0x08, /* [609] OBJ_rc5_cbc */
1680x29,0x01,0x01,0x85,0x1A,0x01, /* [617] OBJ_rle_compression */
1690x29,0x01,0x01,0x85,0x1A,0x02, /* [623] OBJ_zlib_compression */
1700x55,0x1D,0x25, /* [629] OBJ_ext_key_usage */
1710x2B,0x06,0x01,0x05,0x05,0x07, /* [632] OBJ_id_pkix */
1720x2B,0x06,0x01,0x05,0x05,0x07,0x03, /* [638] OBJ_id_kp */
1730x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x01, /* [645] OBJ_server_auth */
1740x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x02, /* [653] OBJ_client_auth */
1750x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x03, /* [661] OBJ_code_sign */
1760x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x04, /* [669] OBJ_email_protect */
1770x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x08, /* [677] OBJ_time_stamp */
1780x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x15,/* [685] OBJ_ms_code_ind */
1790x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x16,/* [695] OBJ_ms_code_com */
1800x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x0A,0x03,0x01,/* [705] OBJ_ms_ctl_sign */
1810x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x0A,0x03,0x03,/* [715] OBJ_ms_sgc */
1820x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x0A,0x03,0x04,/* [725] OBJ_ms_efs */
1830x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x04,0x01,/* [735] OBJ_ns_sgc */
1840x55,0x1D,0x1B, /* [744] OBJ_delta_crl */
1850x55,0x1D,0x15, /* [747] OBJ_crl_reason */
1860x55,0x1D,0x18, /* [750] OBJ_invalidity_date */
1870x2B,0x65,0x01,0x04,0x01, /* [753] OBJ_sxnet */
1880x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x01,0x01,/* [758] OBJ_pbe_WithSHA1And128BitRC4 */
1890x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x01,0x02,/* [768] OBJ_pbe_WithSHA1And40BitRC4 */
1900x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x01,0x03,/* [778] OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC */
1910x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x01,0x04,/* [788] OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC */
1920x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x01,0x05,/* [798] OBJ_pbe_WithSHA1And128BitRC2_CBC */
1930x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x01,0x06,/* [808] OBJ_pbe_WithSHA1And40BitRC2_CBC */
1940x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x0A,0x01,0x01,/* [818] OBJ_keyBag */
1950x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x0A,0x01,0x02,/* [829] OBJ_pkcs8ShroudedKeyBag */
1960x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x0A,0x01,0x03,/* [840] OBJ_certBag */
1970x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x0A,0x01,0x04,/* [851] OBJ_crlBag */
1980x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x0A,0x01,0x05,/* [862] OBJ_secretBag */
1990x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x0A,0x01,0x06,/* [873] OBJ_safeContentsBag */
2000x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x14,/* [884] OBJ_friendlyName */
2010x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x15,/* [893] OBJ_localKeyID */
2020x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x16,0x01,/* [902] OBJ_x509Certificate */
2030x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x16,0x02,/* [912] OBJ_sdsiCertificate */
2040x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x17,0x01,/* [922] OBJ_x509Crl */
2050x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x05,0x0D,/* [932] OBJ_pbes2 */
2060x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x05,0x0E,/* [941] OBJ_pbmac1 */
2070x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x07, /* [950] OBJ_hmacWithSHA1 */
2080x2B,0x06,0x01,0x05,0x05,0x07,0x02,0x01, /* [958] OBJ_id_qt_cps */
2090x2B,0x06,0x01,0x05,0x05,0x07,0x02,0x02, /* [966] OBJ_id_qt_unotice */
2100x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x0F,/* [974] OBJ_SMIMECapabilities */
2110x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x05,0x04,/* [983] OBJ_pbeWithMD2AndRC2_CBC */
2120x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x05,0x06,/* [992] OBJ_pbeWithMD5AndRC2_CBC */
2130x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x05,0x0A,/* [1001] OBJ_pbeWithSHA1AndDES_CBC */
2140x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x0E,/* [1010] OBJ_ms_ext_req */
2150x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x0E,/* [1020] OBJ_ext_req */
2160x55,0x04,0x29, /* [1029] OBJ_name */
2170x55,0x04,0x2E, /* [1032] OBJ_dnQualifier */
2180x2B,0x06,0x01,0x05,0x05,0x07,0x01, /* [1035] OBJ_id_pe */
2190x2B,0x06,0x01,0x05,0x05,0x07,0x30, /* [1042] OBJ_id_ad */
2200x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x01, /* [1049] OBJ_info_access */
2210x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01, /* [1057] OBJ_ad_OCSP */
2220x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x02, /* [1065] OBJ_ad_ca_issuers */
2230x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x09, /* [1073] OBJ_OCSP_sign */
2240x28, /* [1081] OBJ_iso */
2250x2A, /* [1082] OBJ_member_body */
2260x2A,0x86,0x48, /* [1083] OBJ_ISO_US */
2270x2A,0x86,0x48,0xCE,0x38, /* [1086] OBJ_X9_57 */
2280x2A,0x86,0x48,0xCE,0x38,0x04, /* [1091] OBJ_X9cm */
2290x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01, /* [1097] OBJ_pkcs1 */
2300x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x05, /* [1105] OBJ_pkcs5 */
2310x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,/* [1113] OBJ_SMIME */
2320x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x00,/* [1122] OBJ_id_smime_mod */
2330x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x01,/* [1132] OBJ_id_smime_ct */
2340x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,/* [1142] OBJ_id_smime_aa */
2350x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x03,/* [1152] OBJ_id_smime_alg */
2360x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x04,/* [1162] OBJ_id_smime_cd */
2370x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x05,/* [1172] OBJ_id_smime_spq */
2380x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x06,/* [1182] OBJ_id_smime_cti */
2390x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x00,0x01,/* [1192] OBJ_id_smime_mod_cms */
2400x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x00,0x02,/* [1203] OBJ_id_smime_mod_ess */
2410x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x00,0x03,/* [1214] OBJ_id_smime_mod_oid */
2420x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x00,0x04,/* [1225] OBJ_id_smime_mod_msg_v3 */
2430x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x00,0x05,/* [1236] OBJ_id_smime_mod_ets_eSignature_88 */
2440x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x00,0x06,/* [1247] OBJ_id_smime_mod_ets_eSignature_97 */
2450x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x00,0x07,/* [1258] OBJ_id_smime_mod_ets_eSigPolicy_88 */
2460x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x00,0x08,/* [1269] OBJ_id_smime_mod_ets_eSigPolicy_97 */
2470x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x01,0x01,/* [1280] OBJ_id_smime_ct_receipt */
2480x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x01,0x02,/* [1291] OBJ_id_smime_ct_authData */
2490x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x01,0x03,/* [1302] OBJ_id_smime_ct_publishCert */
2500x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x01,0x04,/* [1313] OBJ_id_smime_ct_TSTInfo */
2510x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x01,0x05,/* [1324] OBJ_id_smime_ct_TDTInfo */
2520x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x01,0x06,/* [1335] OBJ_id_smime_ct_contentInfo */
2530x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x01,0x07,/* [1346] OBJ_id_smime_ct_DVCSRequestData */
2540x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x01,0x08,/* [1357] OBJ_id_smime_ct_DVCSResponseData */
2550x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x01,/* [1368] OBJ_id_smime_aa_receiptRequest */
2560x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x02,/* [1379] OBJ_id_smime_aa_securityLabel */
2570x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x03,/* [1390] OBJ_id_smime_aa_mlExpandHistory */
2580x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x04,/* [1401] OBJ_id_smime_aa_contentHint */
2590x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x05,/* [1412] OBJ_id_smime_aa_msgSigDigest */
2600x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x06,/* [1423] OBJ_id_smime_aa_encapContentType */
2610x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x07,/* [1434] OBJ_id_smime_aa_contentIdentifier */
2620x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x08,/* [1445] OBJ_id_smime_aa_macValue */
2630x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x09,/* [1456] OBJ_id_smime_aa_equivalentLabels */
2640x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x0A,/* [1467] OBJ_id_smime_aa_contentReference */
2650x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x0B,/* [1478] OBJ_id_smime_aa_encrypKeyPref */
2660x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x0C,/* [1489] OBJ_id_smime_aa_signingCertificate */
2670x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x0D,/* [1500] OBJ_id_smime_aa_smimeEncryptCerts */
2680x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x0E,/* [1511] OBJ_id_smime_aa_timeStampToken */
2690x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x0F,/* [1522] OBJ_id_smime_aa_ets_sigPolicyId */
2700x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x10,/* [1533] OBJ_id_smime_aa_ets_commitmentType */
2710x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x11,/* [1544] OBJ_id_smime_aa_ets_signerLocation */
2720x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x12,/* [1555] OBJ_id_smime_aa_ets_signerAttr */
2730x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x13,/* [1566] OBJ_id_smime_aa_ets_otherSigCert */
2740x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x14,/* [1577] OBJ_id_smime_aa_ets_contentTimestamp */
2750x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x15,/* [1588] OBJ_id_smime_aa_ets_CertificateRefs */
2760x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x16,/* [1599] OBJ_id_smime_aa_ets_RevocationRefs */
2770x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x17,/* [1610] OBJ_id_smime_aa_ets_certValues */
2780x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x18,/* [1621] OBJ_id_smime_aa_ets_revocationValues */
2790x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x19,/* [1632] OBJ_id_smime_aa_ets_escTimeStamp */
2800x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x1A,/* [1643] OBJ_id_smime_aa_ets_certCRLTimestamp */
2810x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x1B,/* [1654] OBJ_id_smime_aa_ets_archiveTimeStamp */
2820x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x1C,/* [1665] OBJ_id_smime_aa_signatureType */
2830x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x1D,/* [1676] OBJ_id_smime_aa_dvcs_dvc */
2840x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x03,0x01,/* [1687] OBJ_id_smime_alg_ESDHwith3DES */
2850x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x03,0x02,/* [1698] OBJ_id_smime_alg_ESDHwithRC2 */
2860x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x03,0x03,/* [1709] OBJ_id_smime_alg_3DESwrap */
2870x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x03,0x04,/* [1720] OBJ_id_smime_alg_RC2wrap */
2880x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x03,0x05,/* [1731] OBJ_id_smime_alg_ESDH */
2890x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x03,0x06,/* [1742] OBJ_id_smime_alg_CMS3DESwrap */
2900x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x03,0x07,/* [1753] OBJ_id_smime_alg_CMSRC2wrap */
2910x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x04,0x01,/* [1764] OBJ_id_smime_cd_ldap */
2920x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x05,0x01,/* [1775] OBJ_id_smime_spq_ets_sqt_uri */
2930x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x05,0x02,/* [1786] OBJ_id_smime_spq_ets_sqt_unotice */
2940x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x06,0x01,/* [1797] OBJ_id_smime_cti_ets_proofOfOrigin */
2950x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x06,0x02,/* [1808] OBJ_id_smime_cti_ets_proofOfReceipt */
2960x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x06,0x03,/* [1819] OBJ_id_smime_cti_ets_proofOfDelivery */
2970x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x06,0x04,/* [1830] OBJ_id_smime_cti_ets_proofOfSender */
2980x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x06,0x05,/* [1841] OBJ_id_smime_cti_ets_proofOfApproval */
2990x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x06,0x06,/* [1852] OBJ_id_smime_cti_ets_proofOfCreation */
3000x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x04, /* [1863] OBJ_md4 */
3010x2B,0x06,0x01,0x05,0x05,0x07,0x00, /* [1871] OBJ_id_pkix_mod */
3020x2B,0x06,0x01,0x05,0x05,0x07,0x02, /* [1878] OBJ_id_qt */
3030x2B,0x06,0x01,0x05,0x05,0x07,0x04, /* [1885] OBJ_id_it */
3040x2B,0x06,0x01,0x05,0x05,0x07,0x05, /* [1892] OBJ_id_pkip */
3050x2B,0x06,0x01,0x05,0x05,0x07,0x06, /* [1899] OBJ_id_alg */
3060x2B,0x06,0x01,0x05,0x05,0x07,0x07, /* [1906] OBJ_id_cmc */
3070x2B,0x06,0x01,0x05,0x05,0x07,0x08, /* [1913] OBJ_id_on */
3080x2B,0x06,0x01,0x05,0x05,0x07,0x09, /* [1920] OBJ_id_pda */
3090x2B,0x06,0x01,0x05,0x05,0x07,0x0A, /* [1927] OBJ_id_aca */
3100x2B,0x06,0x01,0x05,0x05,0x07,0x0B, /* [1934] OBJ_id_qcs */
3110x2B,0x06,0x01,0x05,0x05,0x07,0x0C, /* [1941] OBJ_id_cct */
3120x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x01, /* [1948] OBJ_id_pkix1_explicit_88 */
3130x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x02, /* [1956] OBJ_id_pkix1_implicit_88 */
3140x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x03, /* [1964] OBJ_id_pkix1_explicit_93 */
3150x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x04, /* [1972] OBJ_id_pkix1_implicit_93 */
3160x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x05, /* [1980] OBJ_id_mod_crmf */
3170x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x06, /* [1988] OBJ_id_mod_cmc */
3180x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x07, /* [1996] OBJ_id_mod_kea_profile_88 */
3190x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x08, /* [2004] OBJ_id_mod_kea_profile_93 */
3200x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x09, /* [2012] OBJ_id_mod_cmp */
3210x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x0A, /* [2020] OBJ_id_mod_qualified_cert_88 */
3220x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x0B, /* [2028] OBJ_id_mod_qualified_cert_93 */
3230x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x0C, /* [2036] OBJ_id_mod_attribute_cert */
3240x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x0D, /* [2044] OBJ_id_mod_timestamp_protocol */
3250x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x0E, /* [2052] OBJ_id_mod_ocsp */
3260x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x0F, /* [2060] OBJ_id_mod_dvcs */
3270x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x10, /* [2068] OBJ_id_mod_cmp2000 */
3280x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x02, /* [2076] OBJ_biometricInfo */
3290x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x03, /* [2084] OBJ_qcStatements */
3300x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x04, /* [2092] OBJ_ac_auditEntity */
3310x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x05, /* [2100] OBJ_ac_targeting */
3320x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x06, /* [2108] OBJ_aaControls */
3330x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x07, /* [2116] OBJ_sbqp_ipAddrBlock */
3340x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x08, /* [2124] OBJ_sbqp_autonomousSysNum */
3350x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x09, /* [2132] OBJ_sbqp_routerIdentifier */
3360x2B,0x06,0x01,0x05,0x05,0x07,0x02,0x03, /* [2140] OBJ_textNotice */
3370x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x05, /* [2148] OBJ_ipsecEndSystem */
3380x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x06, /* [2156] OBJ_ipsecTunnel */
3390x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x07, /* [2164] OBJ_ipsecUser */
3400x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x0A, /* [2172] OBJ_dvcs */
3410x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x01, /* [2180] OBJ_id_it_caProtEncCert */
3420x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x02, /* [2188] OBJ_id_it_signKeyPairTypes */
3430x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x03, /* [2196] OBJ_id_it_encKeyPairTypes */
3440x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x04, /* [2204] OBJ_id_it_preferredSymmAlg */
3450x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x05, /* [2212] OBJ_id_it_caKeyUpdateInfo */
3460x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x06, /* [2220] OBJ_id_it_currentCRL */
3470x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x07, /* [2228] OBJ_id_it_unsupportedOIDs */
3480x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x08, /* [2236] OBJ_id_it_subscriptionRequest */
3490x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x09, /* [2244] OBJ_id_it_subscriptionResponse */
3500x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x0A, /* [2252] OBJ_id_it_keyPairParamReq */
3510x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x0B, /* [2260] OBJ_id_it_keyPairParamRep */
3520x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x0C, /* [2268] OBJ_id_it_revPassphrase */
3530x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x0D, /* [2276] OBJ_id_it_implicitConfirm */
3540x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x0E, /* [2284] OBJ_id_it_confirmWaitTime */
3550x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x0F, /* [2292] OBJ_id_it_origPKIMessage */
3560x2B,0x06,0x01,0x05,0x05,0x07,0x05,0x01, /* [2300] OBJ_id_regCtrl */
3570x2B,0x06,0x01,0x05,0x05,0x07,0x05,0x02, /* [2308] OBJ_id_regInfo */
3580x2B,0x06,0x01,0x05,0x05,0x07,0x05,0x01,0x01,/* [2316] OBJ_id_regCtrl_regToken */
3590x2B,0x06,0x01,0x05,0x05,0x07,0x05,0x01,0x02,/* [2325] OBJ_id_regCtrl_authenticator */
3600x2B,0x06,0x01,0x05,0x05,0x07,0x05,0x01,0x03,/* [2334] OBJ_id_regCtrl_pkiPublicationInfo */
3610x2B,0x06,0x01,0x05,0x05,0x07,0x05,0x01,0x04,/* [2343] OBJ_id_regCtrl_pkiArchiveOptions */
3620x2B,0x06,0x01,0x05,0x05,0x07,0x05,0x01,0x05,/* [2352] OBJ_id_regCtrl_oldCertID */
3630x2B,0x06,0x01,0x05,0x05,0x07,0x05,0x01,0x06,/* [2361] OBJ_id_regCtrl_protocolEncrKey */
3640x2B,0x06,0x01,0x05,0x05,0x07,0x05,0x02,0x01,/* [2370] OBJ_id_regInfo_utf8Pairs */
3650x2B,0x06,0x01,0x05,0x05,0x07,0x05,0x02,0x02,/* [2379] OBJ_id_regInfo_certReq */
3660x2B,0x06,0x01,0x05,0x05,0x07,0x06,0x01, /* [2388] OBJ_id_alg_des40 */
3670x2B,0x06,0x01,0x05,0x05,0x07,0x06,0x02, /* [2396] OBJ_id_alg_noSignature */
3680x2B,0x06,0x01,0x05,0x05,0x07,0x06,0x03, /* [2404] OBJ_id_alg_dh_sig_hmac_sha1 */
3690x2B,0x06,0x01,0x05,0x05,0x07,0x06,0x04, /* [2412] OBJ_id_alg_dh_pop */
3700x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x01, /* [2420] OBJ_id_cmc_statusInfo */
3710x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x02, /* [2428] OBJ_id_cmc_identification */
3720x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x03, /* [2436] OBJ_id_cmc_identityProof */
3730x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x04, /* [2444] OBJ_id_cmc_dataReturn */
3740x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x05, /* [2452] OBJ_id_cmc_transactionId */
3750x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x06, /* [2460] OBJ_id_cmc_senderNonce */
3760x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x07, /* [2468] OBJ_id_cmc_recipientNonce */
3770x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x08, /* [2476] OBJ_id_cmc_addExtensions */
3780x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x09, /* [2484] OBJ_id_cmc_encryptedPOP */
3790x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x0A, /* [2492] OBJ_id_cmc_decryptedPOP */
3800x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x0B, /* [2500] OBJ_id_cmc_lraPOPWitness */
3810x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x0F, /* [2508] OBJ_id_cmc_getCert */
3820x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x10, /* [2516] OBJ_id_cmc_getCRL */
3830x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x11, /* [2524] OBJ_id_cmc_revokeRequest */
3840x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x12, /* [2532] OBJ_id_cmc_regInfo */
3850x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x13, /* [2540] OBJ_id_cmc_responseInfo */
3860x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x15, /* [2548] OBJ_id_cmc_queryPending */
3870x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x16, /* [2556] OBJ_id_cmc_popLinkRandom */
3880x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x17, /* [2564] OBJ_id_cmc_popLinkWitness */
3890x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x18, /* [2572] OBJ_id_cmc_confirmCertAcceptance */
3900x2B,0x06,0x01,0x05,0x05,0x07,0x08,0x01, /* [2580] OBJ_id_on_personalData */
3910x2B,0x06,0x01,0x05,0x05,0x07,0x09,0x01, /* [2588] OBJ_id_pda_dateOfBirth */
3920x2B,0x06,0x01,0x05,0x05,0x07,0x09,0x02, /* [2596] OBJ_id_pda_placeOfBirth */
3930x2B,0x06,0x01,0x05,0x05,0x07,0x09,0x03, /* [2604] OBJ_id_pda_gender */
3940x2B,0x06,0x01,0x05,0x05,0x07,0x09,0x04, /* [2612] OBJ_id_pda_countryOfCitizenship */
3950x2B,0x06,0x01,0x05,0x05,0x07,0x09,0x05, /* [2620] OBJ_id_pda_countryOfResidence */
3960x2B,0x06,0x01,0x05,0x05,0x07,0x0A,0x01, /* [2628] OBJ_id_aca_authenticationInfo */
3970x2B,0x06,0x01,0x05,0x05,0x07,0x0A,0x02, /* [2636] OBJ_id_aca_accessIdentity */
3980x2B,0x06,0x01,0x05,0x05,0x07,0x0A,0x03, /* [2644] OBJ_id_aca_chargingIdentity */
3990x2B,0x06,0x01,0x05,0x05,0x07,0x0A,0x04, /* [2652] OBJ_id_aca_group */
4000x2B,0x06,0x01,0x05,0x05,0x07,0x0A,0x05, /* [2660] OBJ_id_aca_role */
4010x2B,0x06,0x01,0x05,0x05,0x07,0x0B,0x01, /* [2668] OBJ_id_qcs_pkixQCSyntax_v1 */
4020x2B,0x06,0x01,0x05,0x05,0x07,0x0C,0x01, /* [2676] OBJ_id_cct_crs */
4030x2B,0x06,0x01,0x05,0x05,0x07,0x0C,0x02, /* [2684] OBJ_id_cct_PKIData */
4040x2B,0x06,0x01,0x05,0x05,0x07,0x0C,0x03, /* [2692] OBJ_id_cct_PKIResponse */
4050x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x03, /* [2700] OBJ_ad_timeStamping */
4060x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x04, /* [2708] OBJ_ad_dvcs */
4070x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x01,/* [2716] OBJ_id_pkix_OCSP_basic */
4080x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x02,/* [2725] OBJ_id_pkix_OCSP_Nonce */
4090x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x03,/* [2734] OBJ_id_pkix_OCSP_CrlID */
4100x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x04,/* [2743] OBJ_id_pkix_OCSP_acceptableResponses */
4110x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x05,/* [2752] OBJ_id_pkix_OCSP_noCheck */
4120x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x06,/* [2761] OBJ_id_pkix_OCSP_archiveCutoff */
4130x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x07,/* [2770] OBJ_id_pkix_OCSP_serviceLocator */
4140x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x08,/* [2779] OBJ_id_pkix_OCSP_extendedStatus */
4150x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x09,/* [2788] OBJ_id_pkix_OCSP_valid */
4160x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x0A,/* [2797] OBJ_id_pkix_OCSP_path */
4170x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x0B,/* [2806] OBJ_id_pkix_OCSP_trustRoot */
4180x2B,0x0E,0x03,0x02, /* [2815] OBJ_algorithm */
4190x2B,0x0E,0x03,0x02,0x0B, /* [2819] OBJ_rsaSignature */
4200x55,0x08, /* [2824] OBJ_X500algorithms */
4210x2B, /* [2826] OBJ_org */
4220x2B,0x06, /* [2827] OBJ_dod */
4230x2B,0x06,0x01, /* [2829] OBJ_iana */
4240x2B,0x06,0x01,0x01, /* [2832] OBJ_Directory */
4250x2B,0x06,0x01,0x02, /* [2836] OBJ_Management */
4260x2B,0x06,0x01,0x03, /* [2840] OBJ_Experimental */
4270x2B,0x06,0x01,0x04, /* [2844] OBJ_Private */
4280x2B,0x06,0x01,0x05, /* [2848] OBJ_Security */
4290x2B,0x06,0x01,0x06, /* [2852] OBJ_SNMPv2 */
4300x2B,0x06,0x01,0x07, /* [2856] OBJ_Mail */
4310x2B,0x06,0x01,0x04,0x01, /* [2860] OBJ_Enterprises */
4320x2B,0x06,0x01,0x04,0x01,0x8B,0x3A,0x82,0x58,/* [2865] OBJ_dcObject */
4330x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x19,/* [2874] OBJ_domainComponent */
4340x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x0D,/* [2884] OBJ_Domain */
4350x50, /* [2894] OBJ_joint_iso_ccitt */
4360x55,0x01,0x05, /* [2895] OBJ_selected_attribute_types */
4370x55,0x01,0x05,0x37, /* [2898] OBJ_clearance */
4380x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x03,/* [2902] OBJ_md4WithRSAEncryption */
4390x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x0A, /* [2911] OBJ_ac_proxying */
4400x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x0B, /* [2919] OBJ_sinfo_access */
4410x2B,0x06,0x01,0x05,0x05,0x07,0x0A,0x06, /* [2927] OBJ_id_aca_encAttrs */
4420x55,0x04,0x48, /* [2935] OBJ_role */
4430x55,0x1D,0x24, /* [2938] OBJ_policy_constraints */
4440x55,0x1D,0x37, /* [2941] OBJ_target_information */
4450x55,0x1D,0x38, /* [2944] OBJ_no_rev_avail */
4460x00, /* [2947] OBJ_ccitt */
4470x2A,0x86,0x48,0xCE,0x3D, /* [2948] OBJ_ansi_X9_62 */
4480x2A,0x86,0x48,0xCE,0x3D,0x01,0x01, /* [2953] OBJ_X9_62_prime_field */
4490x2A,0x86,0x48,0xCE,0x3D,0x01,0x02, /* [2960] OBJ_X9_62_characteristic_two_field */
4500x2A,0x86,0x48,0xCE,0x3D,0x02,0x01, /* [2967] OBJ_X9_62_id_ecPublicKey */
4510x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x01, /* [2974] OBJ_X9_62_prime192v1 */
4520x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x02, /* [2982] OBJ_X9_62_prime192v2 */
4530x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x03, /* [2990] OBJ_X9_62_prime192v3 */
4540x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x04, /* [2998] OBJ_X9_62_prime239v1 */
4550x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x05, /* [3006] OBJ_X9_62_prime239v2 */
4560x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x06, /* [3014] OBJ_X9_62_prime239v3 */
4570x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x07, /* [3022] OBJ_X9_62_prime256v1 */
4580x2A,0x86,0x48,0xCE,0x3D,0x04,0x01, /* [3030] OBJ_ecdsa_with_SHA1 */
4590x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x11,0x01,/* [3037] OBJ_ms_csp_name */
4600x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x01,/* [3046] OBJ_aes_128_ecb */
4610x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x02,/* [3055] OBJ_aes_128_cbc */
4620x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x03,/* [3064] OBJ_aes_128_ofb128 */
4630x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x04,/* [3073] OBJ_aes_128_cfb128 */
4640x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x15,/* [3082] OBJ_aes_192_ecb */
4650x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x16,/* [3091] OBJ_aes_192_cbc */
4660x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x17,/* [3100] OBJ_aes_192_ofb128 */
4670x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x18,/* [3109] OBJ_aes_192_cfb128 */
4680x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x29,/* [3118] OBJ_aes_256_ecb */
4690x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x2A,/* [3127] OBJ_aes_256_cbc */
4700x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x2B,/* [3136] OBJ_aes_256_ofb128 */
4710x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x2C,/* [3145] OBJ_aes_256_cfb128 */
4720x55,0x1D,0x17, /* [3154] OBJ_hold_instruction_code */
4730x2A,0x86,0x48,0xCE,0x38,0x02,0x01, /* [3157] OBJ_hold_instruction_none */
4740x2A,0x86,0x48,0xCE,0x38,0x02,0x02, /* [3164] OBJ_hold_instruction_call_issuer */
4750x2A,0x86,0x48,0xCE,0x38,0x02,0x03, /* [3171] OBJ_hold_instruction_reject */
4760x09, /* [3178] OBJ_data */
4770x09,0x92,0x26, /* [3179] OBJ_pss */
4780x09,0x92,0x26,0x89,0x93,0xF2,0x2C, /* [3182] OBJ_ucl */
4790x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64, /* [3189] OBJ_pilot */
4800x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,/* [3197] OBJ_pilotAttributeType */
4810x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x03,/* [3206] OBJ_pilotAttributeSyntax */
4820x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,/* [3215] OBJ_pilotObjectClass */
4830x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x0A,/* [3224] OBJ_pilotGroups */
4840x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x03,0x04,/* [3233] OBJ_iA5StringSyntax */
4850x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x03,0x05,/* [3243] OBJ_caseIgnoreIA5StringSyntax */
4860x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x03,/* [3253] OBJ_pilotObject */
4870x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x04,/* [3263] OBJ_pilotPerson */
4880x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x05,/* [3273] OBJ_account */
4890x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x06,/* [3283] OBJ_document */
4900x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x07,/* [3293] OBJ_room */
4910x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x09,/* [3303] OBJ_documentSeries */
4920x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x0E,/* [3313] OBJ_rFC822localPart */
4930x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x0F,/* [3323] OBJ_dNSDomain */
4940x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x11,/* [3333] OBJ_domainRelatedObject */
4950x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x12,/* [3343] OBJ_friendlyCountry */
4960x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x13,/* [3353] OBJ_simpleSecurityObject */
4970x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x14,/* [3363] OBJ_pilotOrganization */
4980x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x15,/* [3373] OBJ_pilotDSA */
4990x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x16,/* [3383] OBJ_qualityLabelledData */
5000x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x01,/* [3393] OBJ_userId */
5010x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x02,/* [3403] OBJ_textEncodedORAddress */
5020x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x03,/* [3413] OBJ_rfc822Mailbox */
5030x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x04,/* [3423] OBJ_info */
5040x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x05,/* [3433] OBJ_favouriteDrink */
5050x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x06,/* [3443] OBJ_roomNumber */
5060x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x07,/* [3453] OBJ_photo */
5070x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x08,/* [3463] OBJ_userClass */
5080x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x09,/* [3473] OBJ_host */
5090x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x0A,/* [3483] OBJ_manager */
5100x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x0B,/* [3493] OBJ_documentIdentifier */
5110x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x0C,/* [3503] OBJ_documentTitle */
5120x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x0D,/* [3513] OBJ_documentVersion */
5130x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x0E,/* [3523] OBJ_documentAuthor */
5140x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x0F,/* [3533] OBJ_documentLocation */
5150x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x14,/* [3543] OBJ_homeTelephoneNumber */
5160x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x15,/* [3553] OBJ_secretary */
5170x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x16,/* [3563] OBJ_otherMailbox */
5180x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x17,/* [3573] OBJ_lastModifiedTime */
5190x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x18,/* [3583] OBJ_lastModifiedBy */
5200x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x1A,/* [3593] OBJ_aRecord */
5210x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x1B,/* [3603] OBJ_pilotAttributeType27 */
5220x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x1C,/* [3613] OBJ_mXRecord */
5230x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x1D,/* [3623] OBJ_nSRecord */
5240x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x1E,/* [3633] OBJ_sOARecord */
5250x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x1F,/* [3643] OBJ_cNAMERecord */
5260x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x25,/* [3653] OBJ_associatedDomain */
5270x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x26,/* [3663] OBJ_associatedName */
5280x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x27,/* [3673] OBJ_homePostalAddress */
5290x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x28,/* [3683] OBJ_personalTitle */
5300x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x29,/* [3693] OBJ_mobileTelephoneNumber */
5310x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x2A,/* [3703] OBJ_pagerTelephoneNumber */
5320x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x2B,/* [3713] OBJ_friendlyCountryName */
5330x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x2D,/* [3723] OBJ_organizationalStatus */
5340x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x2E,/* [3733] OBJ_janetMailbox */
5350x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x2F,/* [3743] OBJ_mailPreferenceOption */
5360x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x30,/* [3753] OBJ_buildingName */
5370x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x31,/* [3763] OBJ_dSAQuality */
5380x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x32,/* [3773] OBJ_singleLevelQuality */
5390x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x33,/* [3783] OBJ_subtreeMinimumQuality */
5400x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x34,/* [3793] OBJ_subtreeMaximumQuality */
5410x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x35,/* [3803] OBJ_personalSignature */
5420x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x36,/* [3813] OBJ_dITRedirect */
5430x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x37,/* [3823] OBJ_audio */
5440x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x38,/* [3833] OBJ_documentPublisher */
5450x55,0x04,0x2D, /* [3843] OBJ_x500UniqueIdentifier */
5460x2B,0x06,0x01,0x07,0x01, /* [3846] OBJ_mime_mhs */
5470x2B,0x06,0x01,0x07,0x01,0x01, /* [3851] OBJ_mime_mhs_headings */
5480x2B,0x06,0x01,0x07,0x01,0x02, /* [3857] OBJ_mime_mhs_bodies */
5490x2B,0x06,0x01,0x07,0x01,0x01,0x01, /* [3863] OBJ_id_hex_partial_message */
5500x2B,0x06,0x01,0x07,0x01,0x01,0x02, /* [3870] OBJ_id_hex_multipart_message */
5510x55,0x04,0x2C, /* [3877] OBJ_generationQualifier */
552};
553
554static ASN1_OBJECT nid_objs[NUM_NID]={
555{"UNDEF","undefined",NID_undef,1,&(lvalues[0]),0},
556{"rsadsi","RSA Data Security, Inc.",NID_rsadsi,6,&(lvalues[1]),0},
557{"pkcs","RSA Data Security, Inc. PKCS",NID_pkcs,7,&(lvalues[7]),0},
558{"MD2","md2",NID_md2,8,&(lvalues[14]),0},
559{"MD5","md5",NID_md5,8,&(lvalues[22]),0},
560{"RC4","rc4",NID_rc4,8,&(lvalues[30]),0},
561{"rsaEncryption","rsaEncryption",NID_rsaEncryption,9,&(lvalues[38]),0},
562{"RSA-MD2","md2WithRSAEncryption",NID_md2WithRSAEncryption,9,
563 &(lvalues[47]),0},
564{"RSA-MD5","md5WithRSAEncryption",NID_md5WithRSAEncryption,9,
565 &(lvalues[56]),0},
566{"PBE-MD2-DES","pbeWithMD2AndDES-CBC",NID_pbeWithMD2AndDES_CBC,9,
567 &(lvalues[65]),0},
568{"PBE-MD5-DES","pbeWithMD5AndDES-CBC",NID_pbeWithMD5AndDES_CBC,9,
569 &(lvalues[74]),0},
570{"X500","directory services (X.500)",NID_X500,1,&(lvalues[83]),0},
571{"X509","X509",NID_X509,2,&(lvalues[84]),0},
572{"CN","commonName",NID_commonName,3,&(lvalues[86]),0},
573{"C","countryName",NID_countryName,3,&(lvalues[89]),0},
574{"L","localityName",NID_localityName,3,&(lvalues[92]),0},
575{"ST","stateOrProvinceName",NID_stateOrProvinceName,3,&(lvalues[95]),0},
576{"O","organizationName",NID_organizationName,3,&(lvalues[98]),0},
577{"OU","organizationalUnitName",NID_organizationalUnitName,3,
578 &(lvalues[101]),0},
579{"RSA","rsa",NID_rsa,4,&(lvalues[104]),0},
580{"pkcs7","pkcs7",NID_pkcs7,8,&(lvalues[108]),0},
581{"pkcs7-data","pkcs7-data",NID_pkcs7_data,9,&(lvalues[116]),0},
582{"pkcs7-signedData","pkcs7-signedData",NID_pkcs7_signed,9,
583 &(lvalues[125]),0},
584{"pkcs7-envelopedData","pkcs7-envelopedData",NID_pkcs7_enveloped,9,
585 &(lvalues[134]),0},
586{"pkcs7-signedAndEnvelopedData","pkcs7-signedAndEnvelopedData",
587 NID_pkcs7_signedAndEnveloped,9,&(lvalues[143]),0},
588{"pkcs7-digestData","pkcs7-digestData",NID_pkcs7_digest,9,
589 &(lvalues[152]),0},
590{"pkcs7-encryptedData","pkcs7-encryptedData",NID_pkcs7_encrypted,9,
591 &(lvalues[161]),0},
592{"pkcs3","pkcs3",NID_pkcs3,8,&(lvalues[170]),0},
593{"dhKeyAgreement","dhKeyAgreement",NID_dhKeyAgreement,9,
594 &(lvalues[178]),0},
595{"DES-ECB","des-ecb",NID_des_ecb,5,&(lvalues[187]),0},
596{"DES-CFB","des-cfb",NID_des_cfb64,5,&(lvalues[192]),0},
597{"DES-CBC","des-cbc",NID_des_cbc,5,&(lvalues[197]),0},
598{"DES-EDE","des-ede",NID_des_ede_ecb,5,&(lvalues[202]),0},
599{"DES-EDE3","des-ede3",NID_des_ede3_ecb,0,NULL},
600{"IDEA-CBC","idea-cbc",NID_idea_cbc,11,&(lvalues[207]),0},
601{"IDEA-CFB","idea-cfb",NID_idea_cfb64,0,NULL},
602{"IDEA-ECB","idea-ecb",NID_idea_ecb,0,NULL},
603{"RC2-CBC","rc2-cbc",NID_rc2_cbc,8,&(lvalues[218]),0},
604{"RC2-ECB","rc2-ecb",NID_rc2_ecb,0,NULL},
605{"RC2-CFB","rc2-cfb",NID_rc2_cfb64,0,NULL},
606{"RC2-OFB","rc2-ofb",NID_rc2_ofb64,0,NULL},
607{"SHA","sha",NID_sha,5,&(lvalues[226]),0},
608{"RSA-SHA","shaWithRSAEncryption",NID_shaWithRSAEncryption,5,
609 &(lvalues[231]),0},
610{"DES-EDE-CBC","des-ede-cbc",NID_des_ede_cbc,0,NULL},
611{"DES-EDE3-CBC","des-ede3-cbc",NID_des_ede3_cbc,8,&(lvalues[236]),0},
612{"DES-OFB","des-ofb",NID_des_ofb64,5,&(lvalues[244]),0},
613{"IDEA-OFB","idea-ofb",NID_idea_ofb64,0,NULL},
614{"pkcs9","pkcs9",NID_pkcs9,8,&(lvalues[249]),0},
615{"emailAddress","emailAddress",NID_pkcs9_emailAddress,9,
616 &(lvalues[257]),0},
617{"unstructuredName","unstructuredName",NID_pkcs9_unstructuredName,9,
618 &(lvalues[266]),0},
619{"contentType","contentType",NID_pkcs9_contentType,9,&(lvalues[275]),0},
620{"messageDigest","messageDigest",NID_pkcs9_messageDigest,9,
621 &(lvalues[284]),0},
622{"signingTime","signingTime",NID_pkcs9_signingTime,9,&(lvalues[293]),0},
623{"countersignature","countersignature",NID_pkcs9_countersignature,9,
624 &(lvalues[302]),0},
625{"challengePassword","challengePassword",NID_pkcs9_challengePassword,
626 9,&(lvalues[311]),0},
627{"unstructuredAddress","unstructuredAddress",
628 NID_pkcs9_unstructuredAddress,9,&(lvalues[320]),0},
629{"extendedCertificateAttributes","extendedCertificateAttributes",
630 NID_pkcs9_extCertAttributes,9,&(lvalues[329]),0},
631{"Netscape","Netscape Communications Corp.",NID_netscape,7,
632 &(lvalues[338]),0},
633{"nsCertExt","Netscape Certificate Extension",
634 NID_netscape_cert_extension,8,&(lvalues[345]),0},
635{"nsDataType","Netscape Data Type",NID_netscape_data_type,8,
636 &(lvalues[353]),0},
637{"DES-EDE-CFB","des-ede-cfb",NID_des_ede_cfb64,0,NULL},
638{"DES-EDE3-CFB","des-ede3-cfb",NID_des_ede3_cfb64,0,NULL},
639{"DES-EDE-OFB","des-ede-ofb",NID_des_ede_ofb64,0,NULL},
640{"DES-EDE3-OFB","des-ede3-ofb",NID_des_ede3_ofb64,0,NULL},
641{"SHA1","sha1",NID_sha1,5,&(lvalues[361]),0},
642{"RSA-SHA1","sha1WithRSAEncryption",NID_sha1WithRSAEncryption,9,
643 &(lvalues[366]),0},
644{"DSA-SHA","dsaWithSHA",NID_dsaWithSHA,5,&(lvalues[375]),0},
645{"DSA-old","dsaEncryption-old",NID_dsa_2,5,&(lvalues[380]),0},
646{"PBE-SHA1-RC2-64","pbeWithSHA1AndRC2-CBC",NID_pbeWithSHA1AndRC2_CBC,
647 9,&(lvalues[385]),0},
648{"PBKDF2","PBKDF2",NID_id_pbkdf2,9,&(lvalues[394]),0},
649{"DSA-SHA1-old","dsaWithSHA1-old",NID_dsaWithSHA1_2,5,&(lvalues[403]),0},
650{"nsCertType","Netscape Cert Type",NID_netscape_cert_type,9,
651 &(lvalues[408]),0},
652{"nsBaseUrl","Netscape Base Url",NID_netscape_base_url,9,
653 &(lvalues[417]),0},
654{"nsRevocationUrl","Netscape Revocation Url",
655 NID_netscape_revocation_url,9,&(lvalues[426]),0},
656{"nsCaRevocationUrl","Netscape CA Revocation Url",
657 NID_netscape_ca_revocation_url,9,&(lvalues[435]),0},
658{"nsRenewalUrl","Netscape Renewal Url",NID_netscape_renewal_url,9,
659 &(lvalues[444]),0},
660{"nsCaPolicyUrl","Netscape CA Policy Url",NID_netscape_ca_policy_url,
661 9,&(lvalues[453]),0},
662{"nsSslServerName","Netscape SSL Server Name",
663 NID_netscape_ssl_server_name,9,&(lvalues[462]),0},
664{"nsComment","Netscape Comment",NID_netscape_comment,9,&(lvalues[471]),0},
665{"nsCertSequence","Netscape Certificate Sequence",
666 NID_netscape_cert_sequence,9,&(lvalues[480]),0},
667{"DESX-CBC","desx-cbc",NID_desx_cbc,0,NULL},
668{"id-ce","id-ce",NID_id_ce,2,&(lvalues[489]),0},
669{"subjectKeyIdentifier","X509v3 Subject Key Identifier",
670 NID_subject_key_identifier,3,&(lvalues[491]),0},
671{"keyUsage","X509v3 Key Usage",NID_key_usage,3,&(lvalues[494]),0},
672{"privateKeyUsagePeriod","X509v3 Private Key Usage Period",
673 NID_private_key_usage_period,3,&(lvalues[497]),0},
674{"subjectAltName","X509v3 Subject Alternative Name",
675 NID_subject_alt_name,3,&(lvalues[500]),0},
676{"issuerAltName","X509v3 Issuer Alternative Name",NID_issuer_alt_name,
677 3,&(lvalues[503]),0},
678{"basicConstraints","X509v3 Basic Constraints",NID_basic_constraints,
679 3,&(lvalues[506]),0},
680{"crlNumber","X509v3 CRL Number",NID_crl_number,3,&(lvalues[509]),0},
681{"certificatePolicies","X509v3 Certificate Policies",
682 NID_certificate_policies,3,&(lvalues[512]),0},
683{"authorityKeyIdentifier","X509v3 Authority Key Identifier",
684 NID_authority_key_identifier,3,&(lvalues[515]),0},
685{"BF-CBC","bf-cbc",NID_bf_cbc,9,&(lvalues[518]),0},
686{"BF-ECB","bf-ecb",NID_bf_ecb,0,NULL},
687{"BF-CFB","bf-cfb",NID_bf_cfb64,0,NULL},
688{"BF-OFB","bf-ofb",NID_bf_ofb64,0,NULL},
689{"MDC2","mdc2",NID_mdc2,4,&(lvalues[527]),0},
690{"RSA-MDC2","mdc2WithRSA",NID_mdc2WithRSA,4,&(lvalues[531]),0},
691{"RC4-40","rc4-40",NID_rc4_40,0,NULL},
692{"RC2-40-CBC","rc2-40-cbc",NID_rc2_40_cbc,0,NULL},
693{"gn","givenName",NID_givenName,3,&(lvalues[535]),0},
694{"SN","surname",NID_surname,3,&(lvalues[538]),0},
695{"initials","initials",NID_initials,3,&(lvalues[541]),0},
696{NULL,NULL,NID_undef,0,NULL},
697{"crlDistributionPoints","X509v3 CRL Distribution Points",
698 NID_crl_distribution_points,3,&(lvalues[544]),0},
699{"RSA-NP-MD5","md5WithRSA",NID_md5WithRSA,5,&(lvalues[547]),0},
700{"serialNumber","serialNumber",NID_serialNumber,3,&(lvalues[552]),0},
701{"title","title",NID_title,3,&(lvalues[555]),0},
702{"description","description",NID_description,3,&(lvalues[558]),0},
703{"CAST5-CBC","cast5-cbc",NID_cast5_cbc,9,&(lvalues[561]),0},
704{"CAST5-ECB","cast5-ecb",NID_cast5_ecb,0,NULL},
705{"CAST5-CFB","cast5-cfb",NID_cast5_cfb64,0,NULL},
706{"CAST5-OFB","cast5-ofb",NID_cast5_ofb64,0,NULL},
707{"pbeWithMD5AndCast5CBC","pbeWithMD5AndCast5CBC",
708 NID_pbeWithMD5AndCast5_CBC,9,&(lvalues[570]),0},
709{"DSA-SHA1","dsaWithSHA1",NID_dsaWithSHA1,7,&(lvalues[579]),0},
710{"MD5-SHA1","md5-sha1",NID_md5_sha1,0,NULL},
711{"RSA-SHA1-2","sha1WithRSA",NID_sha1WithRSA,5,&(lvalues[586]),0},
712{"DSA","dsaEncryption",NID_dsa,7,&(lvalues[591]),0},
713{"RIPEMD160","ripemd160",NID_ripemd160,5,&(lvalues[598]),0},
714{NULL,NULL,NID_undef,0,NULL},
715{"RSA-RIPEMD160","ripemd160WithRSA",NID_ripemd160WithRSA,6,
716 &(lvalues[603]),0},
717{"RC5-CBC","rc5-cbc",NID_rc5_cbc,8,&(lvalues[609]),0},
718{"RC5-ECB","rc5-ecb",NID_rc5_ecb,0,NULL},
719{"RC5-CFB","rc5-cfb",NID_rc5_cfb64,0,NULL},
720{"RC5-OFB","rc5-ofb",NID_rc5_ofb64,0,NULL},
721{"RLE","run length compression",NID_rle_compression,6,&(lvalues[617]),0},
722{"ZLIB","zlib compression",NID_zlib_compression,6,&(lvalues[623]),0},
723{"extendedKeyUsage","X509v3 Extended Key Usage",NID_ext_key_usage,3,
724 &(lvalues[629]),0},
725{"PKIX","PKIX",NID_id_pkix,6,&(lvalues[632]),0},
726{"id-kp","id-kp",NID_id_kp,7,&(lvalues[638]),0},
727{"serverAuth","TLS Web Server Authentication",NID_server_auth,8,
728 &(lvalues[645]),0},
729{"clientAuth","TLS Web Client Authentication",NID_client_auth,8,
730 &(lvalues[653]),0},
731{"codeSigning","Code Signing",NID_code_sign,8,&(lvalues[661]),0},
732{"emailProtection","E-mail Protection",NID_email_protect,8,
733 &(lvalues[669]),0},
734{"timeStamping","Time Stamping",NID_time_stamp,8,&(lvalues[677]),0},
735{"msCodeInd","Microsoft Individual Code Signing",NID_ms_code_ind,10,
736 &(lvalues[685]),0},
737{"msCodeCom","Microsoft Commercial Code Signing",NID_ms_code_com,10,
738 &(lvalues[695]),0},
739{"msCTLSign","Microsoft Trust List Signing",NID_ms_ctl_sign,10,
740 &(lvalues[705]),0},
741{"msSGC","Microsoft Server Gated Crypto",NID_ms_sgc,10,&(lvalues[715]),0},
742{"msEFS","Microsoft Encrypted File System",NID_ms_efs,10,
743 &(lvalues[725]),0},
744{"nsSGC","Netscape Server Gated Crypto",NID_ns_sgc,9,&(lvalues[735]),0},
745{"deltaCRL","X509v3 Delta CRL Indicator",NID_delta_crl,3,
746 &(lvalues[744]),0},
747{"CRLReason","X509v3 CRL Reason Code",NID_crl_reason,3,&(lvalues[747]),0},
748{"invalidityDate","Invalidity Date",NID_invalidity_date,3,
749 &(lvalues[750]),0},
750{"SXNetID","Strong Extranet ID",NID_sxnet,5,&(lvalues[753]),0},
751{"PBE-SHA1-RC4-128","pbeWithSHA1And128BitRC4",
752 NID_pbe_WithSHA1And128BitRC4,10,&(lvalues[758]),0},
753{"PBE-SHA1-RC4-40","pbeWithSHA1And40BitRC4",
754 NID_pbe_WithSHA1And40BitRC4,10,&(lvalues[768]),0},
755{"PBE-SHA1-3DES","pbeWithSHA1And3-KeyTripleDES-CBC",
756 NID_pbe_WithSHA1And3_Key_TripleDES_CBC,10,&(lvalues[778]),0},
757{"PBE-SHA1-2DES","pbeWithSHA1And2-KeyTripleDES-CBC",
758 NID_pbe_WithSHA1And2_Key_TripleDES_CBC,10,&(lvalues[788]),0},
759{"PBE-SHA1-RC2-128","pbeWithSHA1And128BitRC2-CBC",
760 NID_pbe_WithSHA1And128BitRC2_CBC,10,&(lvalues[798]),0},
761{"PBE-SHA1-RC2-40","pbeWithSHA1And40BitRC2-CBC",
762 NID_pbe_WithSHA1And40BitRC2_CBC,10,&(lvalues[808]),0},
763{"keyBag","keyBag",NID_keyBag,11,&(lvalues[818]),0},
764{"pkcs8ShroudedKeyBag","pkcs8ShroudedKeyBag",NID_pkcs8ShroudedKeyBag,
765 11,&(lvalues[829]),0},
766{"certBag","certBag",NID_certBag,11,&(lvalues[840]),0},
767{"crlBag","crlBag",NID_crlBag,11,&(lvalues[851]),0},
768{"secretBag","secretBag",NID_secretBag,11,&(lvalues[862]),0},
769{"safeContentsBag","safeContentsBag",NID_safeContentsBag,11,
770 &(lvalues[873]),0},
771{"friendlyName","friendlyName",NID_friendlyName,9,&(lvalues[884]),0},
772{"localKeyID","localKeyID",NID_localKeyID,9,&(lvalues[893]),0},
773{"x509Certificate","x509Certificate",NID_x509Certificate,10,
774 &(lvalues[902]),0},
775{"sdsiCertificate","sdsiCertificate",NID_sdsiCertificate,10,
776 &(lvalues[912]),0},
777{"x509Crl","x509Crl",NID_x509Crl,10,&(lvalues[922]),0},
778{"PBES2","PBES2",NID_pbes2,9,&(lvalues[932]),0},
779{"PBMAC1","PBMAC1",NID_pbmac1,9,&(lvalues[941]),0},
780{"hmacWithSHA1","hmacWithSHA1",NID_hmacWithSHA1,8,&(lvalues[950]),0},
781{"id-qt-cps","Policy Qualifier CPS",NID_id_qt_cps,8,&(lvalues[958]),0},
782{"id-qt-unotice","Policy Qualifier User Notice",NID_id_qt_unotice,8,
783 &(lvalues[966]),0},
784{"RC2-64-CBC","rc2-64-cbc",NID_rc2_64_cbc,0,NULL},
785{"SMIME-CAPS","S/MIME Capabilities",NID_SMIMECapabilities,9,
786 &(lvalues[974]),0},
787{"PBE-MD2-RC2-64","pbeWithMD2AndRC2-CBC",NID_pbeWithMD2AndRC2_CBC,9,
788 &(lvalues[983]),0},
789{"PBE-MD5-RC2-64","pbeWithMD5AndRC2-CBC",NID_pbeWithMD5AndRC2_CBC,9,
790 &(lvalues[992]),0},
791{"PBE-SHA1-DES","pbeWithSHA1AndDES-CBC",NID_pbeWithSHA1AndDES_CBC,9,
792 &(lvalues[1001]),0},
793{"msExtReq","Microsoft Extension Request",NID_ms_ext_req,10,
794 &(lvalues[1010]),0},
795{"extReq","Extension Request",NID_ext_req,9,&(lvalues[1020]),0},
796{"name","name",NID_name,3,&(lvalues[1029]),0},
797{"dnQualifier","dnQualifier",NID_dnQualifier,3,&(lvalues[1032]),0},
798{"id-pe","id-pe",NID_id_pe,7,&(lvalues[1035]),0},
799{"id-ad","id-ad",NID_id_ad,7,&(lvalues[1042]),0},
800{"authorityInfoAccess","Authority Information Access",NID_info_access,
801 8,&(lvalues[1049]),0},
802{"OCSP","OCSP",NID_ad_OCSP,8,&(lvalues[1057]),0},
803{"caIssuers","CA Issuers",NID_ad_ca_issuers,8,&(lvalues[1065]),0},
804{"OCSPSigning","OCSP Signing",NID_OCSP_sign,8,&(lvalues[1073]),0},
805{"ISO","iso",NID_iso,1,&(lvalues[1081]),0},
806{"member-body","ISO Member Body",NID_member_body,1,&(lvalues[1082]),0},
807{"ISO-US","ISO US Member Body",NID_ISO_US,3,&(lvalues[1083]),0},
808{"X9-57","X9.57",NID_X9_57,5,&(lvalues[1086]),0},
809{"X9cm","X9.57 CM ?",NID_X9cm,6,&(lvalues[1091]),0},
810{"pkcs1","pkcs1",NID_pkcs1,8,&(lvalues[1097]),0},
811{"pkcs5","pkcs5",NID_pkcs5,8,&(lvalues[1105]),0},
812{"SMIME","S/MIME",NID_SMIME,9,&(lvalues[1113]),0},
813{"id-smime-mod","id-smime-mod",NID_id_smime_mod,10,&(lvalues[1122]),0},
814{"id-smime-ct","id-smime-ct",NID_id_smime_ct,10,&(lvalues[1132]),0},
815{"id-smime-aa","id-smime-aa",NID_id_smime_aa,10,&(lvalues[1142]),0},
816{"id-smime-alg","id-smime-alg",NID_id_smime_alg,10,&(lvalues[1152]),0},
817{"id-smime-cd","id-smime-cd",NID_id_smime_cd,10,&(lvalues[1162]),0},
818{"id-smime-spq","id-smime-spq",NID_id_smime_spq,10,&(lvalues[1172]),0},
819{"id-smime-cti","id-smime-cti",NID_id_smime_cti,10,&(lvalues[1182]),0},
820{"id-smime-mod-cms","id-smime-mod-cms",NID_id_smime_mod_cms,11,
821 &(lvalues[1192]),0},
822{"id-smime-mod-ess","id-smime-mod-ess",NID_id_smime_mod_ess,11,
823 &(lvalues[1203]),0},
824{"id-smime-mod-oid","id-smime-mod-oid",NID_id_smime_mod_oid,11,
825 &(lvalues[1214]),0},
826{"id-smime-mod-msg-v3","id-smime-mod-msg-v3",NID_id_smime_mod_msg_v3,
827 11,&(lvalues[1225]),0},
828{"id-smime-mod-ets-eSignature-88","id-smime-mod-ets-eSignature-88",
829 NID_id_smime_mod_ets_eSignature_88,11,&(lvalues[1236]),0},
830{"id-smime-mod-ets-eSignature-97","id-smime-mod-ets-eSignature-97",
831 NID_id_smime_mod_ets_eSignature_97,11,&(lvalues[1247]),0},
832{"id-smime-mod-ets-eSigPolicy-88","id-smime-mod-ets-eSigPolicy-88",
833 NID_id_smime_mod_ets_eSigPolicy_88,11,&(lvalues[1258]),0},
834{"id-smime-mod-ets-eSigPolicy-97","id-smime-mod-ets-eSigPolicy-97",
835 NID_id_smime_mod_ets_eSigPolicy_97,11,&(lvalues[1269]),0},
836{"id-smime-ct-receipt","id-smime-ct-receipt",NID_id_smime_ct_receipt,
837 11,&(lvalues[1280]),0},
838{"id-smime-ct-authData","id-smime-ct-authData",
839 NID_id_smime_ct_authData,11,&(lvalues[1291]),0},
840{"id-smime-ct-publishCert","id-smime-ct-publishCert",
841 NID_id_smime_ct_publishCert,11,&(lvalues[1302]),0},
842{"id-smime-ct-TSTInfo","id-smime-ct-TSTInfo",NID_id_smime_ct_TSTInfo,
843 11,&(lvalues[1313]),0},
844{"id-smime-ct-TDTInfo","id-smime-ct-TDTInfo",NID_id_smime_ct_TDTInfo,
845 11,&(lvalues[1324]),0},
846{"id-smime-ct-contentInfo","id-smime-ct-contentInfo",
847 NID_id_smime_ct_contentInfo,11,&(lvalues[1335]),0},
848{"id-smime-ct-DVCSRequestData","id-smime-ct-DVCSRequestData",
849 NID_id_smime_ct_DVCSRequestData,11,&(lvalues[1346]),0},
850{"id-smime-ct-DVCSResponseData","id-smime-ct-DVCSResponseData",
851 NID_id_smime_ct_DVCSResponseData,11,&(lvalues[1357]),0},
852{"id-smime-aa-receiptRequest","id-smime-aa-receiptRequest",
853 NID_id_smime_aa_receiptRequest,11,&(lvalues[1368]),0},
854{"id-smime-aa-securityLabel","id-smime-aa-securityLabel",
855 NID_id_smime_aa_securityLabel,11,&(lvalues[1379]),0},
856{"id-smime-aa-mlExpandHistory","id-smime-aa-mlExpandHistory",
857 NID_id_smime_aa_mlExpandHistory,11,&(lvalues[1390]),0},
858{"id-smime-aa-contentHint","id-smime-aa-contentHint",
859 NID_id_smime_aa_contentHint,11,&(lvalues[1401]),0},
860{"id-smime-aa-msgSigDigest","id-smime-aa-msgSigDigest",
861 NID_id_smime_aa_msgSigDigest,11,&(lvalues[1412]),0},
862{"id-smime-aa-encapContentType","id-smime-aa-encapContentType",
863 NID_id_smime_aa_encapContentType,11,&(lvalues[1423]),0},
864{"id-smime-aa-contentIdentifier","id-smime-aa-contentIdentifier",
865 NID_id_smime_aa_contentIdentifier,11,&(lvalues[1434]),0},
866{"id-smime-aa-macValue","id-smime-aa-macValue",
867 NID_id_smime_aa_macValue,11,&(lvalues[1445]),0},
868{"id-smime-aa-equivalentLabels","id-smime-aa-equivalentLabels",
869 NID_id_smime_aa_equivalentLabels,11,&(lvalues[1456]),0},
870{"id-smime-aa-contentReference","id-smime-aa-contentReference",
871 NID_id_smime_aa_contentReference,11,&(lvalues[1467]),0},
872{"id-smime-aa-encrypKeyPref","id-smime-aa-encrypKeyPref",
873 NID_id_smime_aa_encrypKeyPref,11,&(lvalues[1478]),0},
874{"id-smime-aa-signingCertificate","id-smime-aa-signingCertificate",
875 NID_id_smime_aa_signingCertificate,11,&(lvalues[1489]),0},
876{"id-smime-aa-smimeEncryptCerts","id-smime-aa-smimeEncryptCerts",
877 NID_id_smime_aa_smimeEncryptCerts,11,&(lvalues[1500]),0},
878{"id-smime-aa-timeStampToken","id-smime-aa-timeStampToken",
879 NID_id_smime_aa_timeStampToken,11,&(lvalues[1511]),0},
880{"id-smime-aa-ets-sigPolicyId","id-smime-aa-ets-sigPolicyId",
881 NID_id_smime_aa_ets_sigPolicyId,11,&(lvalues[1522]),0},
882{"id-smime-aa-ets-commitmentType","id-smime-aa-ets-commitmentType",
883 NID_id_smime_aa_ets_commitmentType,11,&(lvalues[1533]),0},
884{"id-smime-aa-ets-signerLocation","id-smime-aa-ets-signerLocation",
885 NID_id_smime_aa_ets_signerLocation,11,&(lvalues[1544]),0},
886{"id-smime-aa-ets-signerAttr","id-smime-aa-ets-signerAttr",
887 NID_id_smime_aa_ets_signerAttr,11,&(lvalues[1555]),0},
888{"id-smime-aa-ets-otherSigCert","id-smime-aa-ets-otherSigCert",
889 NID_id_smime_aa_ets_otherSigCert,11,&(lvalues[1566]),0},
890{"id-smime-aa-ets-contentTimestamp",
891 "id-smime-aa-ets-contentTimestamp",
892 NID_id_smime_aa_ets_contentTimestamp,11,&(lvalues[1577]),0},
893{"id-smime-aa-ets-CertificateRefs","id-smime-aa-ets-CertificateRefs",
894 NID_id_smime_aa_ets_CertificateRefs,11,&(lvalues[1588]),0},
895{"id-smime-aa-ets-RevocationRefs","id-smime-aa-ets-RevocationRefs",
896 NID_id_smime_aa_ets_RevocationRefs,11,&(lvalues[1599]),0},
897{"id-smime-aa-ets-certValues","id-smime-aa-ets-certValues",
898 NID_id_smime_aa_ets_certValues,11,&(lvalues[1610]),0},
899{"id-smime-aa-ets-revocationValues",
900 "id-smime-aa-ets-revocationValues",
901 NID_id_smime_aa_ets_revocationValues,11,&(lvalues[1621]),0},
902{"id-smime-aa-ets-escTimeStamp","id-smime-aa-ets-escTimeStamp",
903 NID_id_smime_aa_ets_escTimeStamp,11,&(lvalues[1632]),0},
904{"id-smime-aa-ets-certCRLTimestamp",
905 "id-smime-aa-ets-certCRLTimestamp",
906 NID_id_smime_aa_ets_certCRLTimestamp,11,&(lvalues[1643]),0},
907{"id-smime-aa-ets-archiveTimeStamp",
908 "id-smime-aa-ets-archiveTimeStamp",
909 NID_id_smime_aa_ets_archiveTimeStamp,11,&(lvalues[1654]),0},
910{"id-smime-aa-signatureType","id-smime-aa-signatureType",
911 NID_id_smime_aa_signatureType,11,&(lvalues[1665]),0},
912{"id-smime-aa-dvcs-dvc","id-smime-aa-dvcs-dvc",
913 NID_id_smime_aa_dvcs_dvc,11,&(lvalues[1676]),0},
914{"id-smime-alg-ESDHwith3DES","id-smime-alg-ESDHwith3DES",
915 NID_id_smime_alg_ESDHwith3DES,11,&(lvalues[1687]),0},
916{"id-smime-alg-ESDHwithRC2","id-smime-alg-ESDHwithRC2",
917 NID_id_smime_alg_ESDHwithRC2,11,&(lvalues[1698]),0},
918{"id-smime-alg-3DESwrap","id-smime-alg-3DESwrap",
919 NID_id_smime_alg_3DESwrap,11,&(lvalues[1709]),0},
920{"id-smime-alg-RC2wrap","id-smime-alg-RC2wrap",
921 NID_id_smime_alg_RC2wrap,11,&(lvalues[1720]),0},
922{"id-smime-alg-ESDH","id-smime-alg-ESDH",NID_id_smime_alg_ESDH,11,
923 &(lvalues[1731]),0},
924{"id-smime-alg-CMS3DESwrap","id-smime-alg-CMS3DESwrap",
925 NID_id_smime_alg_CMS3DESwrap,11,&(lvalues[1742]),0},
926{"id-smime-alg-CMSRC2wrap","id-smime-alg-CMSRC2wrap",
927 NID_id_smime_alg_CMSRC2wrap,11,&(lvalues[1753]),0},
928{"id-smime-cd-ldap","id-smime-cd-ldap",NID_id_smime_cd_ldap,11,
929 &(lvalues[1764]),0},
930{"id-smime-spq-ets-sqt-uri","id-smime-spq-ets-sqt-uri",
931 NID_id_smime_spq_ets_sqt_uri,11,&(lvalues[1775]),0},
932{"id-smime-spq-ets-sqt-unotice","id-smime-spq-ets-sqt-unotice",
933 NID_id_smime_spq_ets_sqt_unotice,11,&(lvalues[1786]),0},
934{"id-smime-cti-ets-proofOfOrigin","id-smime-cti-ets-proofOfOrigin",
935 NID_id_smime_cti_ets_proofOfOrigin,11,&(lvalues[1797]),0},
936{"id-smime-cti-ets-proofOfReceipt","id-smime-cti-ets-proofOfReceipt",
937 NID_id_smime_cti_ets_proofOfReceipt,11,&(lvalues[1808]),0},
938{"id-smime-cti-ets-proofOfDelivery",
939 "id-smime-cti-ets-proofOfDelivery",
940 NID_id_smime_cti_ets_proofOfDelivery,11,&(lvalues[1819]),0},
941{"id-smime-cti-ets-proofOfSender","id-smime-cti-ets-proofOfSender",
942 NID_id_smime_cti_ets_proofOfSender,11,&(lvalues[1830]),0},
943{"id-smime-cti-ets-proofOfApproval",
944 "id-smime-cti-ets-proofOfApproval",
945 NID_id_smime_cti_ets_proofOfApproval,11,&(lvalues[1841]),0},
946{"id-smime-cti-ets-proofOfCreation",
947 "id-smime-cti-ets-proofOfCreation",
948 NID_id_smime_cti_ets_proofOfCreation,11,&(lvalues[1852]),0},
949{"MD4","md4",NID_md4,8,&(lvalues[1863]),0},
950{"id-pkix-mod","id-pkix-mod",NID_id_pkix_mod,7,&(lvalues[1871]),0},
951{"id-qt","id-qt",NID_id_qt,7,&(lvalues[1878]),0},
952{"id-it","id-it",NID_id_it,7,&(lvalues[1885]),0},
953{"id-pkip","id-pkip",NID_id_pkip,7,&(lvalues[1892]),0},
954{"id-alg","id-alg",NID_id_alg,7,&(lvalues[1899]),0},
955{"id-cmc","id-cmc",NID_id_cmc,7,&(lvalues[1906]),0},
956{"id-on","id-on",NID_id_on,7,&(lvalues[1913]),0},
957{"id-pda","id-pda",NID_id_pda,7,&(lvalues[1920]),0},
958{"id-aca","id-aca",NID_id_aca,7,&(lvalues[1927]),0},
959{"id-qcs","id-qcs",NID_id_qcs,7,&(lvalues[1934]),0},
960{"id-cct","id-cct",NID_id_cct,7,&(lvalues[1941]),0},
961{"id-pkix1-explicit-88","id-pkix1-explicit-88",
962 NID_id_pkix1_explicit_88,8,&(lvalues[1948]),0},
963{"id-pkix1-implicit-88","id-pkix1-implicit-88",
964 NID_id_pkix1_implicit_88,8,&(lvalues[1956]),0},
965{"id-pkix1-explicit-93","id-pkix1-explicit-93",
966 NID_id_pkix1_explicit_93,8,&(lvalues[1964]),0},
967{"id-pkix1-implicit-93","id-pkix1-implicit-93",
968 NID_id_pkix1_implicit_93,8,&(lvalues[1972]),0},
969{"id-mod-crmf","id-mod-crmf",NID_id_mod_crmf,8,&(lvalues[1980]),0},
970{"id-mod-cmc","id-mod-cmc",NID_id_mod_cmc,8,&(lvalues[1988]),0},
971{"id-mod-kea-profile-88","id-mod-kea-profile-88",
972 NID_id_mod_kea_profile_88,8,&(lvalues[1996]),0},
973{"id-mod-kea-profile-93","id-mod-kea-profile-93",
974 NID_id_mod_kea_profile_93,8,&(lvalues[2004]),0},
975{"id-mod-cmp","id-mod-cmp",NID_id_mod_cmp,8,&(lvalues[2012]),0},
976{"id-mod-qualified-cert-88","id-mod-qualified-cert-88",
977 NID_id_mod_qualified_cert_88,8,&(lvalues[2020]),0},
978{"id-mod-qualified-cert-93","id-mod-qualified-cert-93",
979 NID_id_mod_qualified_cert_93,8,&(lvalues[2028]),0},
980{"id-mod-attribute-cert","id-mod-attribute-cert",
981 NID_id_mod_attribute_cert,8,&(lvalues[2036]),0},
982{"id-mod-timestamp-protocol","id-mod-timestamp-protocol",
983 NID_id_mod_timestamp_protocol,8,&(lvalues[2044]),0},
984{"id-mod-ocsp","id-mod-ocsp",NID_id_mod_ocsp,8,&(lvalues[2052]),0},
985{"id-mod-dvcs","id-mod-dvcs",NID_id_mod_dvcs,8,&(lvalues[2060]),0},
986{"id-mod-cmp2000","id-mod-cmp2000",NID_id_mod_cmp2000,8,
987 &(lvalues[2068]),0},
988{"biometricInfo","Biometric Info",NID_biometricInfo,8,&(lvalues[2076]),0},
989{"qcStatements","qcStatements",NID_qcStatements,8,&(lvalues[2084]),0},
990{"ac-auditEntity","ac-auditEntity",NID_ac_auditEntity,8,
991 &(lvalues[2092]),0},
992{"ac-targeting","ac-targeting",NID_ac_targeting,8,&(lvalues[2100]),0},
993{"aaControls","aaControls",NID_aaControls,8,&(lvalues[2108]),0},
994{"sbqp-ipAddrBlock","sbqp-ipAddrBlock",NID_sbqp_ipAddrBlock,8,
995 &(lvalues[2116]),0},
996{"sbqp-autonomousSysNum","sbqp-autonomousSysNum",
997 NID_sbqp_autonomousSysNum,8,&(lvalues[2124]),0},
998{"sbqp-routerIdentifier","sbqp-routerIdentifier",
999 NID_sbqp_routerIdentifier,8,&(lvalues[2132]),0},
1000{"textNotice","textNotice",NID_textNotice,8,&(lvalues[2140]),0},
1001{"ipsecEndSystem","IPSec End System",NID_ipsecEndSystem,8,
1002 &(lvalues[2148]),0},
1003{"ipsecTunnel","IPSec Tunnel",NID_ipsecTunnel,8,&(lvalues[2156]),0},
1004{"ipsecUser","IPSec User",NID_ipsecUser,8,&(lvalues[2164]),0},
1005{"DVCS","dvcs",NID_dvcs,8,&(lvalues[2172]),0},
1006{"id-it-caProtEncCert","id-it-caProtEncCert",NID_id_it_caProtEncCert,
1007 8,&(lvalues[2180]),0},
1008{"id-it-signKeyPairTypes","id-it-signKeyPairTypes",
1009 NID_id_it_signKeyPairTypes,8,&(lvalues[2188]),0},
1010{"id-it-encKeyPairTypes","id-it-encKeyPairTypes",
1011 NID_id_it_encKeyPairTypes,8,&(lvalues[2196]),0},
1012{"id-it-preferredSymmAlg","id-it-preferredSymmAlg",
1013 NID_id_it_preferredSymmAlg,8,&(lvalues[2204]),0},
1014{"id-it-caKeyUpdateInfo","id-it-caKeyUpdateInfo",
1015 NID_id_it_caKeyUpdateInfo,8,&(lvalues[2212]),0},
1016{"id-it-currentCRL","id-it-currentCRL",NID_id_it_currentCRL,8,
1017 &(lvalues[2220]),0},
1018{"id-it-unsupportedOIDs","id-it-unsupportedOIDs",
1019 NID_id_it_unsupportedOIDs,8,&(lvalues[2228]),0},
1020{"id-it-subscriptionRequest","id-it-subscriptionRequest",
1021 NID_id_it_subscriptionRequest,8,&(lvalues[2236]),0},
1022{"id-it-subscriptionResponse","id-it-subscriptionResponse",
1023 NID_id_it_subscriptionResponse,8,&(lvalues[2244]),0},
1024{"id-it-keyPairParamReq","id-it-keyPairParamReq",
1025 NID_id_it_keyPairParamReq,8,&(lvalues[2252]),0},
1026{"id-it-keyPairParamRep","id-it-keyPairParamRep",
1027 NID_id_it_keyPairParamRep,8,&(lvalues[2260]),0},
1028{"id-it-revPassphrase","id-it-revPassphrase",NID_id_it_revPassphrase,
1029 8,&(lvalues[2268]),0},
1030{"id-it-implicitConfirm","id-it-implicitConfirm",
1031 NID_id_it_implicitConfirm,8,&(lvalues[2276]),0},
1032{"id-it-confirmWaitTime","id-it-confirmWaitTime",
1033 NID_id_it_confirmWaitTime,8,&(lvalues[2284]),0},
1034{"id-it-origPKIMessage","id-it-origPKIMessage",
1035 NID_id_it_origPKIMessage,8,&(lvalues[2292]),0},
1036{"id-regCtrl","id-regCtrl",NID_id_regCtrl,8,&(lvalues[2300]),0},
1037{"id-regInfo","id-regInfo",NID_id_regInfo,8,&(lvalues[2308]),0},
1038{"id-regCtrl-regToken","id-regCtrl-regToken",NID_id_regCtrl_regToken,
1039 9,&(lvalues[2316]),0},
1040{"id-regCtrl-authenticator","id-regCtrl-authenticator",
1041 NID_id_regCtrl_authenticator,9,&(lvalues[2325]),0},
1042{"id-regCtrl-pkiPublicationInfo","id-regCtrl-pkiPublicationInfo",
1043 NID_id_regCtrl_pkiPublicationInfo,9,&(lvalues[2334]),0},
1044{"id-regCtrl-pkiArchiveOptions","id-regCtrl-pkiArchiveOptions",
1045 NID_id_regCtrl_pkiArchiveOptions,9,&(lvalues[2343]),0},
1046{"id-regCtrl-oldCertID","id-regCtrl-oldCertID",
1047 NID_id_regCtrl_oldCertID,9,&(lvalues[2352]),0},
1048{"id-regCtrl-protocolEncrKey","id-regCtrl-protocolEncrKey",
1049 NID_id_regCtrl_protocolEncrKey,9,&(lvalues[2361]),0},
1050{"id-regInfo-utf8Pairs","id-regInfo-utf8Pairs",
1051 NID_id_regInfo_utf8Pairs,9,&(lvalues[2370]),0},
1052{"id-regInfo-certReq","id-regInfo-certReq",NID_id_regInfo_certReq,9,
1053 &(lvalues[2379]),0},
1054{"id-alg-des40","id-alg-des40",NID_id_alg_des40,8,&(lvalues[2388]),0},
1055{"id-alg-noSignature","id-alg-noSignature",NID_id_alg_noSignature,8,
1056 &(lvalues[2396]),0},
1057{"id-alg-dh-sig-hmac-sha1","id-alg-dh-sig-hmac-sha1",
1058 NID_id_alg_dh_sig_hmac_sha1,8,&(lvalues[2404]),0},
1059{"id-alg-dh-pop","id-alg-dh-pop",NID_id_alg_dh_pop,8,&(lvalues[2412]),0},
1060{"id-cmc-statusInfo","id-cmc-statusInfo",NID_id_cmc_statusInfo,8,
1061 &(lvalues[2420]),0},
1062{"id-cmc-identification","id-cmc-identification",
1063 NID_id_cmc_identification,8,&(lvalues[2428]),0},
1064{"id-cmc-identityProof","id-cmc-identityProof",
1065 NID_id_cmc_identityProof,8,&(lvalues[2436]),0},
1066{"id-cmc-dataReturn","id-cmc-dataReturn",NID_id_cmc_dataReturn,8,
1067 &(lvalues[2444]),0},
1068{"id-cmc-transactionId","id-cmc-transactionId",
1069 NID_id_cmc_transactionId,8,&(lvalues[2452]),0},
1070{"id-cmc-senderNonce","id-cmc-senderNonce",NID_id_cmc_senderNonce,8,
1071 &(lvalues[2460]),0},
1072{"id-cmc-recipientNonce","id-cmc-recipientNonce",
1073 NID_id_cmc_recipientNonce,8,&(lvalues[2468]),0},
1074{"id-cmc-addExtensions","id-cmc-addExtensions",
1075 NID_id_cmc_addExtensions,8,&(lvalues[2476]),0},
1076{"id-cmc-encryptedPOP","id-cmc-encryptedPOP",NID_id_cmc_encryptedPOP,
1077 8,&(lvalues[2484]),0},
1078{"id-cmc-decryptedPOP","id-cmc-decryptedPOP",NID_id_cmc_decryptedPOP,
1079 8,&(lvalues[2492]),0},
1080{"id-cmc-lraPOPWitness","id-cmc-lraPOPWitness",
1081 NID_id_cmc_lraPOPWitness,8,&(lvalues[2500]),0},
1082{"id-cmc-getCert","id-cmc-getCert",NID_id_cmc_getCert,8,
1083 &(lvalues[2508]),0},
1084{"id-cmc-getCRL","id-cmc-getCRL",NID_id_cmc_getCRL,8,&(lvalues[2516]),0},
1085{"id-cmc-revokeRequest","id-cmc-revokeRequest",
1086 NID_id_cmc_revokeRequest,8,&(lvalues[2524]),0},
1087{"id-cmc-regInfo","id-cmc-regInfo",NID_id_cmc_regInfo,8,
1088 &(lvalues[2532]),0},
1089{"id-cmc-responseInfo","id-cmc-responseInfo",NID_id_cmc_responseInfo,
1090 8,&(lvalues[2540]),0},
1091{"id-cmc-queryPending","id-cmc-queryPending",NID_id_cmc_queryPending,
1092 8,&(lvalues[2548]),0},
1093{"id-cmc-popLinkRandom","id-cmc-popLinkRandom",
1094 NID_id_cmc_popLinkRandom,8,&(lvalues[2556]),0},
1095{"id-cmc-popLinkWitness","id-cmc-popLinkWitness",
1096 NID_id_cmc_popLinkWitness,8,&(lvalues[2564]),0},
1097{"id-cmc-confirmCertAcceptance","id-cmc-confirmCertAcceptance",
1098 NID_id_cmc_confirmCertAcceptance,8,&(lvalues[2572]),0},
1099{"id-on-personalData","id-on-personalData",NID_id_on_personalData,8,
1100 &(lvalues[2580]),0},
1101{"id-pda-dateOfBirth","id-pda-dateOfBirth",NID_id_pda_dateOfBirth,8,
1102 &(lvalues[2588]),0},
1103{"id-pda-placeOfBirth","id-pda-placeOfBirth",NID_id_pda_placeOfBirth,
1104 8,&(lvalues[2596]),0},
1105{NULL,NULL,NID_undef,0,NULL},
1106{"id-pda-gender","id-pda-gender",NID_id_pda_gender,8,&(lvalues[2604]),0},
1107{"id-pda-countryOfCitizenship","id-pda-countryOfCitizenship",
1108 NID_id_pda_countryOfCitizenship,8,&(lvalues[2612]),0},
1109{"id-pda-countryOfResidence","id-pda-countryOfResidence",
1110 NID_id_pda_countryOfResidence,8,&(lvalues[2620]),0},
1111{"id-aca-authenticationInfo","id-aca-authenticationInfo",
1112 NID_id_aca_authenticationInfo,8,&(lvalues[2628]),0},
1113{"id-aca-accessIdentity","id-aca-accessIdentity",
1114 NID_id_aca_accessIdentity,8,&(lvalues[2636]),0},
1115{"id-aca-chargingIdentity","id-aca-chargingIdentity",
1116 NID_id_aca_chargingIdentity,8,&(lvalues[2644]),0},
1117{"id-aca-group","id-aca-group",NID_id_aca_group,8,&(lvalues[2652]),0},
1118{"id-aca-role","id-aca-role",NID_id_aca_role,8,&(lvalues[2660]),0},
1119{"id-qcs-pkixQCSyntax-v1","id-qcs-pkixQCSyntax-v1",
1120 NID_id_qcs_pkixQCSyntax_v1,8,&(lvalues[2668]),0},
1121{"id-cct-crs","id-cct-crs",NID_id_cct_crs,8,&(lvalues[2676]),0},
1122{"id-cct-PKIData","id-cct-PKIData",NID_id_cct_PKIData,8,
1123 &(lvalues[2684]),0},
1124{"id-cct-PKIResponse","id-cct-PKIResponse",NID_id_cct_PKIResponse,8,
1125 &(lvalues[2692]),0},
1126{"ad_timestamping","AD Time Stamping",NID_ad_timeStamping,8,
1127 &(lvalues[2700]),0},
1128{"AD_DVCS","ad dvcs",NID_ad_dvcs,8,&(lvalues[2708]),0},
1129{"basicOCSPResponse","Basic OCSP Response",NID_id_pkix_OCSP_basic,9,
1130 &(lvalues[2716]),0},
1131{"Nonce","OCSP Nonce",NID_id_pkix_OCSP_Nonce,9,&(lvalues[2725]),0},
1132{"CrlID","OCSP CRL ID",NID_id_pkix_OCSP_CrlID,9,&(lvalues[2734]),0},
1133{"acceptableResponses","Acceptable OCSP Responses",
1134 NID_id_pkix_OCSP_acceptableResponses,9,&(lvalues[2743]),0},
1135{"noCheck","OCSP No Check",NID_id_pkix_OCSP_noCheck,9,&(lvalues[2752]),0},
1136{"archiveCutoff","OCSP Archive Cutoff",NID_id_pkix_OCSP_archiveCutoff,
1137 9,&(lvalues[2761]),0},
1138{"serviceLocator","OCSP Service Locator",
1139 NID_id_pkix_OCSP_serviceLocator,9,&(lvalues[2770]),0},
1140{"extendedStatus","Extended OCSP Status",
1141 NID_id_pkix_OCSP_extendedStatus,9,&(lvalues[2779]),0},
1142{"valid","valid",NID_id_pkix_OCSP_valid,9,&(lvalues[2788]),0},
1143{"path","path",NID_id_pkix_OCSP_path,9,&(lvalues[2797]),0},
1144{"trustRoot","Trust Root",NID_id_pkix_OCSP_trustRoot,9,
1145 &(lvalues[2806]),0},
1146{"algorithm","algorithm",NID_algorithm,4,&(lvalues[2815]),0},
1147{"rsaSignature","rsaSignature",NID_rsaSignature,5,&(lvalues[2819]),0},
1148{"X500algorithms","directory services - algorithms",
1149 NID_X500algorithms,2,&(lvalues[2824]),0},
1150{"ORG","org",NID_org,1,&(lvalues[2826]),0},
1151{"DOD","dod",NID_dod,2,&(lvalues[2827]),0},
1152{"IANA","iana",NID_iana,3,&(lvalues[2829]),0},
1153{"directory","Directory",NID_Directory,4,&(lvalues[2832]),0},
1154{"mgmt","Management",NID_Management,4,&(lvalues[2836]),0},
1155{"experimental","Experimental",NID_Experimental,4,&(lvalues[2840]),0},
1156{"private","Private",NID_Private,4,&(lvalues[2844]),0},
1157{"security","Security",NID_Security,4,&(lvalues[2848]),0},
1158{"snmpv2","SNMPv2",NID_SNMPv2,4,&(lvalues[2852]),0},
1159{"Mail","Mail",NID_Mail,4,&(lvalues[2856]),0},
1160{"enterprises","Enterprises",NID_Enterprises,5,&(lvalues[2860]),0},
1161{"dcobject","dcObject",NID_dcObject,9,&(lvalues[2865]),0},
1162{"DC","domainComponent",NID_domainComponent,10,&(lvalues[2874]),0},
1163{"domain","Domain",NID_Domain,10,&(lvalues[2884]),0},
1164{"JOINT-ISO-CCITT","joint-iso-ccitt",NID_joint_iso_ccitt,1,
1165 &(lvalues[2894]),0},
1166{"selected-attribute-types","Selected Attribute Types",
1167 NID_selected_attribute_types,3,&(lvalues[2895]),0},
1168{"clearance","clearance",NID_clearance,4,&(lvalues[2898]),0},
1169{"RSA-MD4","md4WithRSAEncryption",NID_md4WithRSAEncryption,9,
1170 &(lvalues[2902]),0},
1171{"ac-proxying","ac-proxying",NID_ac_proxying,8,&(lvalues[2911]),0},
1172{"subjectInfoAccess","Subject Information Access",NID_sinfo_access,8,
1173 &(lvalues[2919]),0},
1174{"id-aca-encAttrs","id-aca-encAttrs",NID_id_aca_encAttrs,8,
1175 &(lvalues[2927]),0},
1176{"role","role",NID_role,3,&(lvalues[2935]),0},
1177{"policyConstraints","X509v3 Policy Constraints",
1178 NID_policy_constraints,3,&(lvalues[2938]),0},
1179{"targetInformation","X509v3 AC Targeting",NID_target_information,3,
1180 &(lvalues[2941]),0},
1181{"noRevAvail","X509v3 No Revocation Available",NID_no_rev_avail,3,
1182 &(lvalues[2944]),0},
1183{"CCITT","ccitt",NID_ccitt,1,&(lvalues[2947]),0},
1184{"ansi-X9-62","ANSI X9.62",NID_ansi_X9_62,5,&(lvalues[2948]),0},
1185{"prime-field","prime-field",NID_X9_62_prime_field,7,&(lvalues[2953]),0},
1186{"characteristic-two-field","characteristic-two-field",
1187 NID_X9_62_characteristic_two_field,7,&(lvalues[2960]),0},
1188{"id-ecPublicKey","id-ecPublicKey",NID_X9_62_id_ecPublicKey,7,
1189 &(lvalues[2967]),0},
1190{"prime192v1","prime192v1",NID_X9_62_prime192v1,8,&(lvalues[2974]),0},
1191{"prime192v2","prime192v2",NID_X9_62_prime192v2,8,&(lvalues[2982]),0},
1192{"prime192v3","prime192v3",NID_X9_62_prime192v3,8,&(lvalues[2990]),0},
1193{"prime239v1","prime239v1",NID_X9_62_prime239v1,8,&(lvalues[2998]),0},
1194{"prime239v2","prime239v2",NID_X9_62_prime239v2,8,&(lvalues[3006]),0},
1195{"prime239v3","prime239v3",NID_X9_62_prime239v3,8,&(lvalues[3014]),0},
1196{"prime256v1","prime256v1",NID_X9_62_prime256v1,8,&(lvalues[3022]),0},
1197{"ecdsa-with-SHA1","ecdsa-with-SHA1",NID_ecdsa_with_SHA1,7,
1198 &(lvalues[3030]),0},
1199{"CSPName","Microsoft CSP Name",NID_ms_csp_name,9,&(lvalues[3037]),0},
1200{"AES-128-ECB","aes-128-ecb",NID_aes_128_ecb,9,&(lvalues[3046]),0},
1201{"AES-128-CBC","aes-128-cbc",NID_aes_128_cbc,9,&(lvalues[3055]),0},
1202{"AES-128-OFB","aes-128-ofb",NID_aes_128_ofb128,9,&(lvalues[3064]),0},
1203{"AES-128-CFB","aes-128-cfb",NID_aes_128_cfb128,9,&(lvalues[3073]),0},
1204{"AES-192-ECB","aes-192-ecb",NID_aes_192_ecb,9,&(lvalues[3082]),0},
1205{"AES-192-CBC","aes-192-cbc",NID_aes_192_cbc,9,&(lvalues[3091]),0},
1206{"AES-192-OFB","aes-192-ofb",NID_aes_192_ofb128,9,&(lvalues[3100]),0},
1207{"AES-192-CFB","aes-192-cfb",NID_aes_192_cfb128,9,&(lvalues[3109]),0},
1208{"AES-256-ECB","aes-256-ecb",NID_aes_256_ecb,9,&(lvalues[3118]),0},
1209{"AES-256-CBC","aes-256-cbc",NID_aes_256_cbc,9,&(lvalues[3127]),0},
1210{"AES-256-OFB","aes-256-ofb",NID_aes_256_ofb128,9,&(lvalues[3136]),0},
1211{"AES-256-CFB","aes-256-cfb",NID_aes_256_cfb128,9,&(lvalues[3145]),0},
1212{"holdInstructionCode","Hold Instruction Code",
1213 NID_hold_instruction_code,3,&(lvalues[3154]),0},
1214{"holdInstructionNone","Hold Instruction None",
1215 NID_hold_instruction_none,7,&(lvalues[3157]),0},
1216{"holdInstructionCallIssuer","Hold Instruction Call Issuer",
1217 NID_hold_instruction_call_issuer,7,&(lvalues[3164]),0},
1218{"holdInstructionReject","Hold Instruction Reject",
1219 NID_hold_instruction_reject,7,&(lvalues[3171]),0},
1220{"data","data",NID_data,1,&(lvalues[3178]),0},
1221{"pss","pss",NID_pss,3,&(lvalues[3179]),0},
1222{"ucl","ucl",NID_ucl,7,&(lvalues[3182]),0},
1223{"pilot","pilot",NID_pilot,8,&(lvalues[3189]),0},
1224{"pilotAttributeType","pilotAttributeType",NID_pilotAttributeType,9,
1225 &(lvalues[3197]),0},
1226{"pilotAttributeSyntax","pilotAttributeSyntax",
1227 NID_pilotAttributeSyntax,9,&(lvalues[3206]),0},
1228{"pilotObjectClass","pilotObjectClass",NID_pilotObjectClass,9,
1229 &(lvalues[3215]),0},
1230{"pilotGroups","pilotGroups",NID_pilotGroups,9,&(lvalues[3224]),0},
1231{"iA5StringSyntax","iA5StringSyntax",NID_iA5StringSyntax,10,
1232 &(lvalues[3233]),0},
1233{"caseIgnoreIA5StringSyntax","caseIgnoreIA5StringSyntax",
1234 NID_caseIgnoreIA5StringSyntax,10,&(lvalues[3243]),0},
1235{"pilotObject","pilotObject",NID_pilotObject,10,&(lvalues[3253]),0},
1236{"pilotPerson","pilotPerson",NID_pilotPerson,10,&(lvalues[3263]),0},
1237{"account","account",NID_account,10,&(lvalues[3273]),0},
1238{"document","document",NID_document,10,&(lvalues[3283]),0},
1239{"room","room",NID_room,10,&(lvalues[3293]),0},
1240{"documentSeries","documentSeries",NID_documentSeries,10,
1241 &(lvalues[3303]),0},
1242{"rFC822localPart","rFC822localPart",NID_rFC822localPart,10,
1243 &(lvalues[3313]),0},
1244{"dNSDomain","dNSDomain",NID_dNSDomain,10,&(lvalues[3323]),0},
1245{"domainRelatedObject","domainRelatedObject",NID_domainRelatedObject,
1246 10,&(lvalues[3333]),0},
1247{"friendlyCountry","friendlyCountry",NID_friendlyCountry,10,
1248 &(lvalues[3343]),0},
1249{"simpleSecurityObject","simpleSecurityObject",
1250 NID_simpleSecurityObject,10,&(lvalues[3353]),0},
1251{"pilotOrganization","pilotOrganization",NID_pilotOrganization,10,
1252 &(lvalues[3363]),0},
1253{"pilotDSA","pilotDSA",NID_pilotDSA,10,&(lvalues[3373]),0},
1254{"qualityLabelledData","qualityLabelledData",NID_qualityLabelledData,
1255 10,&(lvalues[3383]),0},
1256{"UID","userId",NID_userId,10,&(lvalues[3393]),0},
1257{"textEncodedORAddress","textEncodedORAddress",
1258 NID_textEncodedORAddress,10,&(lvalues[3403]),0},
1259{"mail","rfc822Mailbox",NID_rfc822Mailbox,10,&(lvalues[3413]),0},
1260{"info","info",NID_info,10,&(lvalues[3423]),0},
1261{"favouriteDrink","favouriteDrink",NID_favouriteDrink,10,
1262 &(lvalues[3433]),0},
1263{"roomNumber","roomNumber",NID_roomNumber,10,&(lvalues[3443]),0},
1264{"photo","photo",NID_photo,10,&(lvalues[3453]),0},
1265{"userClass","userClass",NID_userClass,10,&(lvalues[3463]),0},
1266{"host","host",NID_host,10,&(lvalues[3473]),0},
1267{"manager","manager",NID_manager,10,&(lvalues[3483]),0},
1268{"documentIdentifier","documentIdentifier",NID_documentIdentifier,10,
1269 &(lvalues[3493]),0},
1270{"documentTitle","documentTitle",NID_documentTitle,10,&(lvalues[3503]),0},
1271{"documentVersion","documentVersion",NID_documentVersion,10,
1272 &(lvalues[3513]),0},
1273{"documentAuthor","documentAuthor",NID_documentAuthor,10,
1274 &(lvalues[3523]),0},
1275{"documentLocation","documentLocation",NID_documentLocation,10,
1276 &(lvalues[3533]),0},
1277{"homeTelephoneNumber","homeTelephoneNumber",NID_homeTelephoneNumber,
1278 10,&(lvalues[3543]),0},
1279{"secretary","secretary",NID_secretary,10,&(lvalues[3553]),0},
1280{"otherMailbox","otherMailbox",NID_otherMailbox,10,&(lvalues[3563]),0},
1281{"lastModifiedTime","lastModifiedTime",NID_lastModifiedTime,10,
1282 &(lvalues[3573]),0},
1283{"lastModifiedBy","lastModifiedBy",NID_lastModifiedBy,10,
1284 &(lvalues[3583]),0},
1285{"aRecord","aRecord",NID_aRecord,10,&(lvalues[3593]),0},
1286{"pilotAttributeType27","pilotAttributeType27",
1287 NID_pilotAttributeType27,10,&(lvalues[3603]),0},
1288{"mXRecord","mXRecord",NID_mXRecord,10,&(lvalues[3613]),0},
1289{"nSRecord","nSRecord",NID_nSRecord,10,&(lvalues[3623]),0},
1290{"sOARecord","sOARecord",NID_sOARecord,10,&(lvalues[3633]),0},
1291{"cNAMERecord","cNAMERecord",NID_cNAMERecord,10,&(lvalues[3643]),0},
1292{"associatedDomain","associatedDomain",NID_associatedDomain,10,
1293 &(lvalues[3653]),0},
1294{"associatedName","associatedName",NID_associatedName,10,
1295 &(lvalues[3663]),0},
1296{"homePostalAddress","homePostalAddress",NID_homePostalAddress,10,
1297 &(lvalues[3673]),0},
1298{"personalTitle","personalTitle",NID_personalTitle,10,&(lvalues[3683]),0},
1299{"mobileTelephoneNumber","mobileTelephoneNumber",
1300 NID_mobileTelephoneNumber,10,&(lvalues[3693]),0},
1301{"pagerTelephoneNumber","pagerTelephoneNumber",
1302 NID_pagerTelephoneNumber,10,&(lvalues[3703]),0},
1303{"friendlyCountryName","friendlyCountryName",NID_friendlyCountryName,
1304 10,&(lvalues[3713]),0},
1305{"organizationalStatus","organizationalStatus",
1306 NID_organizationalStatus,10,&(lvalues[3723]),0},
1307{"janetMailbox","janetMailbox",NID_janetMailbox,10,&(lvalues[3733]),0},
1308{"mailPreferenceOption","mailPreferenceOption",
1309 NID_mailPreferenceOption,10,&(lvalues[3743]),0},
1310{"buildingName","buildingName",NID_buildingName,10,&(lvalues[3753]),0},
1311{"dSAQuality","dSAQuality",NID_dSAQuality,10,&(lvalues[3763]),0},
1312{"singleLevelQuality","singleLevelQuality",NID_singleLevelQuality,10,
1313 &(lvalues[3773]),0},
1314{"subtreeMinimumQuality","subtreeMinimumQuality",
1315 NID_subtreeMinimumQuality,10,&(lvalues[3783]),0},
1316{"subtreeMaximumQuality","subtreeMaximumQuality",
1317 NID_subtreeMaximumQuality,10,&(lvalues[3793]),0},
1318{"personalSignature","personalSignature",NID_personalSignature,10,
1319 &(lvalues[3803]),0},
1320{"dITRedirect","dITRedirect",NID_dITRedirect,10,&(lvalues[3813]),0},
1321{"audio","audio",NID_audio,10,&(lvalues[3823]),0},
1322{"documentPublisher","documentPublisher",NID_documentPublisher,10,
1323 &(lvalues[3833]),0},
1324{"x500UniqueIdentifier","x500UniqueIdentifier",
1325 NID_x500UniqueIdentifier,3,&(lvalues[3843]),0},
1326{"mime-mhs","MIME MHS",NID_mime_mhs,5,&(lvalues[3846]),0},
1327{"mime-mhs-headings","mime-mhs-headings",NID_mime_mhs_headings,6,
1328 &(lvalues[3851]),0},
1329{"mime-mhs-bodies","mime-mhs-bodies",NID_mime_mhs_bodies,6,
1330 &(lvalues[3857]),0},
1331{"id-hex-partial-message","id-hex-partial-message",
1332 NID_id_hex_partial_message,7,&(lvalues[3863]),0},
1333{"id-hex-multipart-message","id-hex-multipart-message",
1334 NID_id_hex_multipart_message,7,&(lvalues[3870]),0},
1335{"generationQualifier","generationQualifier",NID_generationQualifier,
1336 3,&(lvalues[3877]),0},
1337};
1338
1339static ASN1_OBJECT *sn_objs[NUM_SN]={
1340&(nid_objs[364]),/* "AD_DVCS" */
1341&(nid_objs[419]),/* "AES-128-CBC" */
1342&(nid_objs[421]),/* "AES-128-CFB" */
1343&(nid_objs[418]),/* "AES-128-ECB" */
1344&(nid_objs[420]),/* "AES-128-OFB" */
1345&(nid_objs[423]),/* "AES-192-CBC" */
1346&(nid_objs[425]),/* "AES-192-CFB" */
1347&(nid_objs[422]),/* "AES-192-ECB" */
1348&(nid_objs[424]),/* "AES-192-OFB" */
1349&(nid_objs[427]),/* "AES-256-CBC" */
1350&(nid_objs[429]),/* "AES-256-CFB" */
1351&(nid_objs[426]),/* "AES-256-ECB" */
1352&(nid_objs[428]),/* "AES-256-OFB" */
1353&(nid_objs[91]),/* "BF-CBC" */
1354&(nid_objs[93]),/* "BF-CFB" */
1355&(nid_objs[92]),/* "BF-ECB" */
1356&(nid_objs[94]),/* "BF-OFB" */
1357&(nid_objs[14]),/* "C" */
1358&(nid_objs[108]),/* "CAST5-CBC" */
1359&(nid_objs[110]),/* "CAST5-CFB" */
1360&(nid_objs[109]),/* "CAST5-ECB" */
1361&(nid_objs[111]),/* "CAST5-OFB" */
1362&(nid_objs[404]),/* "CCITT" */
1363&(nid_objs[13]),/* "CN" */
1364&(nid_objs[141]),/* "CRLReason" */
1365&(nid_objs[417]),/* "CSPName" */
1366&(nid_objs[367]),/* "CrlID" */
1367&(nid_objs[391]),/* "DC" */
1368&(nid_objs[31]),/* "DES-CBC" */
1369&(nid_objs[30]),/* "DES-CFB" */
1370&(nid_objs[29]),/* "DES-ECB" */
1371&(nid_objs[32]),/* "DES-EDE" */
1372&(nid_objs[43]),/* "DES-EDE-CBC" */
1373&(nid_objs[60]),/* "DES-EDE-CFB" */
1374&(nid_objs[62]),/* "DES-EDE-OFB" */
1375&(nid_objs[33]),/* "DES-EDE3" */
1376&(nid_objs[44]),/* "DES-EDE3-CBC" */
1377&(nid_objs[61]),/* "DES-EDE3-CFB" */
1378&(nid_objs[63]),/* "DES-EDE3-OFB" */
1379&(nid_objs[45]),/* "DES-OFB" */
1380&(nid_objs[80]),/* "DESX-CBC" */
1381&(nid_objs[380]),/* "DOD" */
1382&(nid_objs[116]),/* "DSA" */
1383&(nid_objs[66]),/* "DSA-SHA" */
1384&(nid_objs[113]),/* "DSA-SHA1" */
1385&(nid_objs[70]),/* "DSA-SHA1-old" */
1386&(nid_objs[67]),/* "DSA-old" */
1387&(nid_objs[297]),/* "DVCS" */
1388&(nid_objs[381]),/* "IANA" */
1389&(nid_objs[34]),/* "IDEA-CBC" */
1390&(nid_objs[35]),/* "IDEA-CFB" */
1391&(nid_objs[36]),/* "IDEA-ECB" */
1392&(nid_objs[46]),/* "IDEA-OFB" */
1393&(nid_objs[181]),/* "ISO" */
1394&(nid_objs[183]),/* "ISO-US" */
1395&(nid_objs[393]),/* "JOINT-ISO-CCITT" */
1396&(nid_objs[15]),/* "L" */
1397&(nid_objs[ 3]),/* "MD2" */
1398&(nid_objs[257]),/* "MD4" */
1399&(nid_objs[ 4]),/* "MD5" */
1400&(nid_objs[114]),/* "MD5-SHA1" */
1401&(nid_objs[95]),/* "MDC2" */
1402&(nid_objs[388]),/* "Mail" */
1403&(nid_objs[57]),/* "Netscape" */
1404&(nid_objs[366]),/* "Nonce" */
1405&(nid_objs[17]),/* "O" */
1406&(nid_objs[178]),/* "OCSP" */
1407&(nid_objs[180]),/* "OCSPSigning" */
1408&(nid_objs[379]),/* "ORG" */
1409&(nid_objs[18]),/* "OU" */
1410&(nid_objs[ 9]),/* "PBE-MD2-DES" */
1411&(nid_objs[168]),/* "PBE-MD2-RC2-64" */
1412&(nid_objs[10]),/* "PBE-MD5-DES" */
1413&(nid_objs[169]),/* "PBE-MD5-RC2-64" */
1414&(nid_objs[147]),/* "PBE-SHA1-2DES" */
1415&(nid_objs[146]),/* "PBE-SHA1-3DES" */
1416&(nid_objs[170]),/* "PBE-SHA1-DES" */
1417&(nid_objs[148]),/* "PBE-SHA1-RC2-128" */
1418&(nid_objs[149]),/* "PBE-SHA1-RC2-40" */
1419&(nid_objs[68]),/* "PBE-SHA1-RC2-64" */
1420&(nid_objs[144]),/* "PBE-SHA1-RC4-128" */
1421&(nid_objs[145]),/* "PBE-SHA1-RC4-40" */
1422&(nid_objs[161]),/* "PBES2" */
1423&(nid_objs[69]),/* "PBKDF2" */
1424&(nid_objs[162]),/* "PBMAC1" */
1425&(nid_objs[127]),/* "PKIX" */
1426&(nid_objs[98]),/* "RC2-40-CBC" */
1427&(nid_objs[166]),/* "RC2-64-CBC" */
1428&(nid_objs[37]),/* "RC2-CBC" */
1429&(nid_objs[39]),/* "RC2-CFB" */
1430&(nid_objs[38]),/* "RC2-ECB" */
1431&(nid_objs[40]),/* "RC2-OFB" */
1432&(nid_objs[ 5]),/* "RC4" */
1433&(nid_objs[97]),/* "RC4-40" */
1434&(nid_objs[120]),/* "RC5-CBC" */
1435&(nid_objs[122]),/* "RC5-CFB" */
1436&(nid_objs[121]),/* "RC5-ECB" */
1437&(nid_objs[123]),/* "RC5-OFB" */
1438&(nid_objs[117]),/* "RIPEMD160" */
1439&(nid_objs[124]),/* "RLE" */
1440&(nid_objs[19]),/* "RSA" */
1441&(nid_objs[ 7]),/* "RSA-MD2" */
1442&(nid_objs[396]),/* "RSA-MD4" */
1443&(nid_objs[ 8]),/* "RSA-MD5" */
1444&(nid_objs[96]),/* "RSA-MDC2" */
1445&(nid_objs[104]),/* "RSA-NP-MD5" */
1446&(nid_objs[119]),/* "RSA-RIPEMD160" */
1447&(nid_objs[42]),/* "RSA-SHA" */
1448&(nid_objs[65]),/* "RSA-SHA1" */
1449&(nid_objs[115]),/* "RSA-SHA1-2" */
1450&(nid_objs[41]),/* "SHA" */
1451&(nid_objs[64]),/* "SHA1" */
1452&(nid_objs[188]),/* "SMIME" */
1453&(nid_objs[167]),/* "SMIME-CAPS" */
1454&(nid_objs[100]),/* "SN" */
1455&(nid_objs[16]),/* "ST" */
1456&(nid_objs[143]),/* "SXNetID" */
1457&(nid_objs[458]),/* "UID" */
1458&(nid_objs[ 0]),/* "UNDEF" */
1459&(nid_objs[11]),/* "X500" */
1460&(nid_objs[378]),/* "X500algorithms" */
1461&(nid_objs[12]),/* "X509" */
1462&(nid_objs[184]),/* "X9-57" */
1463&(nid_objs[185]),/* "X9cm" */
1464&(nid_objs[125]),/* "ZLIB" */
1465&(nid_objs[478]),/* "aRecord" */
1466&(nid_objs[289]),/* "aaControls" */
1467&(nid_objs[287]),/* "ac-auditEntity" */
1468&(nid_objs[397]),/* "ac-proxying" */
1469&(nid_objs[288]),/* "ac-targeting" */
1470&(nid_objs[368]),/* "acceptableResponses" */
1471&(nid_objs[446]),/* "account" */
1472&(nid_objs[363]),/* "ad_timestamping" */
1473&(nid_objs[376]),/* "algorithm" */
1474&(nid_objs[405]),/* "ansi-X9-62" */
1475&(nid_objs[370]),/* "archiveCutoff" */
1476&(nid_objs[484]),/* "associatedDomain" */
1477&(nid_objs[485]),/* "associatedName" */
1478&(nid_objs[501]),/* "audio" */
1479&(nid_objs[177]),/* "authorityInfoAccess" */
1480&(nid_objs[90]),/* "authorityKeyIdentifier" */
1481&(nid_objs[87]),/* "basicConstraints" */
1482&(nid_objs[365]),/* "basicOCSPResponse" */
1483&(nid_objs[285]),/* "biometricInfo" */
1484&(nid_objs[494]),/* "buildingName" */
1485&(nid_objs[483]),/* "cNAMERecord" */
1486&(nid_objs[179]),/* "caIssuers" */
1487&(nid_objs[443]),/* "caseIgnoreIA5StringSyntax" */
1488&(nid_objs[152]),/* "certBag" */
1489&(nid_objs[89]),/* "certificatePolicies" */
1490&(nid_objs[54]),/* "challengePassword" */
1491&(nid_objs[407]),/* "characteristic-two-field" */
1492&(nid_objs[395]),/* "clearance" */
1493&(nid_objs[130]),/* "clientAuth" */
1494&(nid_objs[131]),/* "codeSigning" */
1495&(nid_objs[50]),/* "contentType" */
1496&(nid_objs[53]),/* "countersignature" */
1497&(nid_objs[153]),/* "crlBag" */
1498&(nid_objs[103]),/* "crlDistributionPoints" */
1499&(nid_objs[88]),/* "crlNumber" */
1500&(nid_objs[500]),/* "dITRedirect" */
1501&(nid_objs[451]),/* "dNSDomain" */
1502&(nid_objs[495]),/* "dSAQuality" */
1503&(nid_objs[434]),/* "data" */
1504&(nid_objs[390]),/* "dcobject" */
1505&(nid_objs[140]),/* "deltaCRL" */
1506&(nid_objs[107]),/* "description" */
1507&(nid_objs[28]),/* "dhKeyAgreement" */
1508&(nid_objs[382]),/* "directory" */
1509&(nid_objs[174]),/* "dnQualifier" */
1510&(nid_objs[447]),/* "document" */
1511&(nid_objs[471]),/* "documentAuthor" */
1512&(nid_objs[468]),/* "documentIdentifier" */
1513&(nid_objs[472]),/* "documentLocation" */
1514&(nid_objs[502]),/* "documentPublisher" */
1515&(nid_objs[449]),/* "documentSeries" */
1516&(nid_objs[469]),/* "documentTitle" */
1517&(nid_objs[470]),/* "documentVersion" */
1518&(nid_objs[392]),/* "domain" */
1519&(nid_objs[452]),/* "domainRelatedObject" */
1520&(nid_objs[416]),/* "ecdsa-with-SHA1" */
1521&(nid_objs[48]),/* "emailAddress" */
1522&(nid_objs[132]),/* "emailProtection" */
1523&(nid_objs[389]),/* "enterprises" */
1524&(nid_objs[384]),/* "experimental" */
1525&(nid_objs[172]),/* "extReq" */
1526&(nid_objs[56]),/* "extendedCertificateAttributes" */
1527&(nid_objs[126]),/* "extendedKeyUsage" */
1528&(nid_objs[372]),/* "extendedStatus" */
1529&(nid_objs[462]),/* "favouriteDrink" */
1530&(nid_objs[453]),/* "friendlyCountry" */
1531&(nid_objs[490]),/* "friendlyCountryName" */
1532&(nid_objs[156]),/* "friendlyName" */
1533&(nid_objs[509]),/* "generationQualifier" */
1534&(nid_objs[99]),/* "gn" */
1535&(nid_objs[163]),/* "hmacWithSHA1" */
1536&(nid_objs[432]),/* "holdInstructionCallIssuer" */
1537&(nid_objs[430]),/* "holdInstructionCode" */
1538&(nid_objs[431]),/* "holdInstructionNone" */
1539&(nid_objs[433]),/* "holdInstructionReject" */
1540&(nid_objs[486]),/* "homePostalAddress" */
1541&(nid_objs[473]),/* "homeTelephoneNumber" */
1542&(nid_objs[466]),/* "host" */
1543&(nid_objs[442]),/* "iA5StringSyntax" */
1544&(nid_objs[266]),/* "id-aca" */
1545&(nid_objs[355]),/* "id-aca-accessIdentity" */
1546&(nid_objs[354]),/* "id-aca-authenticationInfo" */
1547&(nid_objs[356]),/* "id-aca-chargingIdentity" */
1548&(nid_objs[399]),/* "id-aca-encAttrs" */
1549&(nid_objs[357]),/* "id-aca-group" */
1550&(nid_objs[358]),/* "id-aca-role" */
1551&(nid_objs[176]),/* "id-ad" */
1552&(nid_objs[262]),/* "id-alg" */
1553&(nid_objs[323]),/* "id-alg-des40" */
1554&(nid_objs[326]),/* "id-alg-dh-pop" */
1555&(nid_objs[325]),/* "id-alg-dh-sig-hmac-sha1" */
1556&(nid_objs[324]),/* "id-alg-noSignature" */
1557&(nid_objs[268]),/* "id-cct" */
1558&(nid_objs[361]),/* "id-cct-PKIData" */
1559&(nid_objs[362]),/* "id-cct-PKIResponse" */
1560&(nid_objs[360]),/* "id-cct-crs" */
1561&(nid_objs[81]),/* "id-ce" */
1562&(nid_objs[263]),/* "id-cmc" */
1563&(nid_objs[334]),/* "id-cmc-addExtensions" */
1564&(nid_objs[346]),/* "id-cmc-confirmCertAcceptance" */
1565&(nid_objs[330]),/* "id-cmc-dataReturn" */
1566&(nid_objs[336]),/* "id-cmc-decryptedPOP" */
1567&(nid_objs[335]),/* "id-cmc-encryptedPOP" */
1568&(nid_objs[339]),/* "id-cmc-getCRL" */
1569&(nid_objs[338]),/* "id-cmc-getCert" */
1570&(nid_objs[328]),/* "id-cmc-identification" */
1571&(nid_objs[329]),/* "id-cmc-identityProof" */
1572&(nid_objs[337]),/* "id-cmc-lraPOPWitness" */
1573&(nid_objs[344]),/* "id-cmc-popLinkRandom" */
1574&(nid_objs[345]),/* "id-cmc-popLinkWitness" */
1575&(nid_objs[343]),/* "id-cmc-queryPending" */
1576&(nid_objs[333]),/* "id-cmc-recipientNonce" */
1577&(nid_objs[341]),/* "id-cmc-regInfo" */
1578&(nid_objs[342]),/* "id-cmc-responseInfo" */
1579&(nid_objs[340]),/* "id-cmc-revokeRequest" */
1580&(nid_objs[332]),/* "id-cmc-senderNonce" */
1581&(nid_objs[327]),/* "id-cmc-statusInfo" */
1582&(nid_objs[331]),/* "id-cmc-transactionId" */
1583&(nid_objs[408]),/* "id-ecPublicKey" */
1584&(nid_objs[508]),/* "id-hex-multipart-message" */
1585&(nid_objs[507]),/* "id-hex-partial-message" */
1586&(nid_objs[260]),/* "id-it" */
1587&(nid_objs[302]),/* "id-it-caKeyUpdateInfo" */
1588&(nid_objs[298]),/* "id-it-caProtEncCert" */
1589&(nid_objs[311]),/* "id-it-confirmWaitTime" */
1590&(nid_objs[303]),/* "id-it-currentCRL" */
1591&(nid_objs[300]),/* "id-it-encKeyPairTypes" */
1592&(nid_objs[310]),/* "id-it-implicitConfirm" */
1593&(nid_objs[308]),/* "id-it-keyPairParamRep" */
1594&(nid_objs[307]),/* "id-it-keyPairParamReq" */
1595&(nid_objs[312]),/* "id-it-origPKIMessage" */
1596&(nid_objs[301]),/* "id-it-preferredSymmAlg" */
1597&(nid_objs[309]),/* "id-it-revPassphrase" */
1598&(nid_objs[299]),/* "id-it-signKeyPairTypes" */
1599&(nid_objs[305]),/* "id-it-subscriptionRequest" */
1600&(nid_objs[306]),/* "id-it-subscriptionResponse" */
1601&(nid_objs[304]),/* "id-it-unsupportedOIDs" */
1602&(nid_objs[128]),/* "id-kp" */
1603&(nid_objs[280]),/* "id-mod-attribute-cert" */
1604&(nid_objs[274]),/* "id-mod-cmc" */
1605&(nid_objs[277]),/* "id-mod-cmp" */
1606&(nid_objs[284]),/* "id-mod-cmp2000" */
1607&(nid_objs[273]),/* "id-mod-crmf" */
1608&(nid_objs[283]),/* "id-mod-dvcs" */
1609&(nid_objs[275]),/* "id-mod-kea-profile-88" */
1610&(nid_objs[276]),/* "id-mod-kea-profile-93" */
1611&(nid_objs[282]),/* "id-mod-ocsp" */
1612&(nid_objs[278]),/* "id-mod-qualified-cert-88" */
1613&(nid_objs[279]),/* "id-mod-qualified-cert-93" */
1614&(nid_objs[281]),/* "id-mod-timestamp-protocol" */
1615&(nid_objs[264]),/* "id-on" */
1616&(nid_objs[347]),/* "id-on-personalData" */
1617&(nid_objs[265]),/* "id-pda" */
1618&(nid_objs[352]),/* "id-pda-countryOfCitizenship" */
1619&(nid_objs[353]),/* "id-pda-countryOfResidence" */
1620&(nid_objs[348]),/* "id-pda-dateOfBirth" */
1621&(nid_objs[351]),/* "id-pda-gender" */
1622&(nid_objs[349]),/* "id-pda-placeOfBirth" */
1623&(nid_objs[175]),/* "id-pe" */
1624&(nid_objs[261]),/* "id-pkip" */
1625&(nid_objs[258]),/* "id-pkix-mod" */
1626&(nid_objs[269]),/* "id-pkix1-explicit-88" */
1627&(nid_objs[271]),/* "id-pkix1-explicit-93" */
1628&(nid_objs[270]),/* "id-pkix1-implicit-88" */
1629&(nid_objs[272]),/* "id-pkix1-implicit-93" */
1630&(nid_objs[267]),/* "id-qcs" */
1631&(nid_objs[359]),/* "id-qcs-pkixQCSyntax-v1" */
1632&(nid_objs[259]),/* "id-qt" */
1633&(nid_objs[164]),/* "id-qt-cps" */
1634&(nid_objs[165]),/* "id-qt-unotice" */
1635&(nid_objs[313]),/* "id-regCtrl" */
1636&(nid_objs[316]),/* "id-regCtrl-authenticator" */
1637&(nid_objs[319]),/* "id-regCtrl-oldCertID" */
1638&(nid_objs[318]),/* "id-regCtrl-pkiArchiveOptions" */
1639&(nid_objs[317]),/* "id-regCtrl-pkiPublicationInfo" */
1640&(nid_objs[320]),/* "id-regCtrl-protocolEncrKey" */
1641&(nid_objs[315]),/* "id-regCtrl-regToken" */
1642&(nid_objs[314]),/* "id-regInfo" */
1643&(nid_objs[322]),/* "id-regInfo-certReq" */
1644&(nid_objs[321]),/* "id-regInfo-utf8Pairs" */
1645&(nid_objs[191]),/* "id-smime-aa" */
1646&(nid_objs[215]),/* "id-smime-aa-contentHint" */
1647&(nid_objs[218]),/* "id-smime-aa-contentIdentifier" */
1648&(nid_objs[221]),/* "id-smime-aa-contentReference" */
1649&(nid_objs[240]),/* "id-smime-aa-dvcs-dvc" */
1650&(nid_objs[217]),/* "id-smime-aa-encapContentType" */
1651&(nid_objs[222]),/* "id-smime-aa-encrypKeyPref" */
1652&(nid_objs[220]),/* "id-smime-aa-equivalentLabels" */
1653&(nid_objs[232]),/* "id-smime-aa-ets-CertificateRefs" */
1654&(nid_objs[233]),/* "id-smime-aa-ets-RevocationRefs" */
1655&(nid_objs[238]),/* "id-smime-aa-ets-archiveTimeStamp" */
1656&(nid_objs[237]),/* "id-smime-aa-ets-certCRLTimestamp" */
1657&(nid_objs[234]),/* "id-smime-aa-ets-certValues" */
1658&(nid_objs[227]),/* "id-smime-aa-ets-commitmentType" */
1659&(nid_objs[231]),/* "id-smime-aa-ets-contentTimestamp" */
1660&(nid_objs[236]),/* "id-smime-aa-ets-escTimeStamp" */
1661&(nid_objs[230]),/* "id-smime-aa-ets-otherSigCert" */
1662&(nid_objs[235]),/* "id-smime-aa-ets-revocationValues" */
1663&(nid_objs[226]),/* "id-smime-aa-ets-sigPolicyId" */
1664&(nid_objs[229]),/* "id-smime-aa-ets-signerAttr" */
1665&(nid_objs[228]),/* "id-smime-aa-ets-signerLocation" */
1666&(nid_objs[219]),/* "id-smime-aa-macValue" */
1667&(nid_objs[214]),/* "id-smime-aa-mlExpandHistory" */
1668&(nid_objs[216]),/* "id-smime-aa-msgSigDigest" */
1669&(nid_objs[212]),/* "id-smime-aa-receiptRequest" */
1670&(nid_objs[213]),/* "id-smime-aa-securityLabel" */
1671&(nid_objs[239]),/* "id-smime-aa-signatureType" */
1672&(nid_objs[223]),/* "id-smime-aa-signingCertificate" */
1673&(nid_objs[224]),/* "id-smime-aa-smimeEncryptCerts" */
1674&(nid_objs[225]),/* "id-smime-aa-timeStampToken" */
1675&(nid_objs[192]),/* "id-smime-alg" */
1676&(nid_objs[243]),/* "id-smime-alg-3DESwrap" */
1677&(nid_objs[246]),/* "id-smime-alg-CMS3DESwrap" */
1678&(nid_objs[247]),/* "id-smime-alg-CMSRC2wrap" */
1679&(nid_objs[245]),/* "id-smime-alg-ESDH" */
1680&(nid_objs[241]),/* "id-smime-alg-ESDHwith3DES" */
1681&(nid_objs[242]),/* "id-smime-alg-ESDHwithRC2" */
1682&(nid_objs[244]),/* "id-smime-alg-RC2wrap" */
1683&(nid_objs[193]),/* "id-smime-cd" */
1684&(nid_objs[248]),/* "id-smime-cd-ldap" */
1685&(nid_objs[190]),/* "id-smime-ct" */
1686&(nid_objs[210]),/* "id-smime-ct-DVCSRequestData" */
1687&(nid_objs[211]),/* "id-smime-ct-DVCSResponseData" */
1688&(nid_objs[208]),/* "id-smime-ct-TDTInfo" */
1689&(nid_objs[207]),/* "id-smime-ct-TSTInfo" */
1690&(nid_objs[205]),/* "id-smime-ct-authData" */
1691&(nid_objs[209]),/* "id-smime-ct-contentInfo" */
1692&(nid_objs[206]),/* "id-smime-ct-publishCert" */
1693&(nid_objs[204]),/* "id-smime-ct-receipt" */
1694&(nid_objs[195]),/* "id-smime-cti" */
1695&(nid_objs[255]),/* "id-smime-cti-ets-proofOfApproval" */
1696&(nid_objs[256]),/* "id-smime-cti-ets-proofOfCreation" */
1697&(nid_objs[253]),/* "id-smime-cti-ets-proofOfDelivery" */
1698&(nid_objs[251]),/* "id-smime-cti-ets-proofOfOrigin" */
1699&(nid_objs[252]),/* "id-smime-cti-ets-proofOfReceipt" */
1700&(nid_objs[254]),/* "id-smime-cti-ets-proofOfSender" */
1701&(nid_objs[189]),/* "id-smime-mod" */
1702&(nid_objs[196]),/* "id-smime-mod-cms" */
1703&(nid_objs[197]),/* "id-smime-mod-ess" */
1704&(nid_objs[202]),/* "id-smime-mod-ets-eSigPolicy-88" */
1705&(nid_objs[203]),/* "id-smime-mod-ets-eSigPolicy-97" */
1706&(nid_objs[200]),/* "id-smime-mod-ets-eSignature-88" */
1707&(nid_objs[201]),/* "id-smime-mod-ets-eSignature-97" */
1708&(nid_objs[199]),/* "id-smime-mod-msg-v3" */
1709&(nid_objs[198]),/* "id-smime-mod-oid" */
1710&(nid_objs[194]),/* "id-smime-spq" */
1711&(nid_objs[250]),/* "id-smime-spq-ets-sqt-unotice" */
1712&(nid_objs[249]),/* "id-smime-spq-ets-sqt-uri" */
1713&(nid_objs[461]),/* "info" */
1714&(nid_objs[101]),/* "initials" */
1715&(nid_objs[142]),/* "invalidityDate" */
1716&(nid_objs[294]),/* "ipsecEndSystem" */
1717&(nid_objs[295]),/* "ipsecTunnel" */
1718&(nid_objs[296]),/* "ipsecUser" */
1719&(nid_objs[86]),/* "issuerAltName" */
1720&(nid_objs[492]),/* "janetMailbox" */
1721&(nid_objs[150]),/* "keyBag" */
1722&(nid_objs[83]),/* "keyUsage" */
1723&(nid_objs[477]),/* "lastModifiedBy" */
1724&(nid_objs[476]),/* "lastModifiedTime" */
1725&(nid_objs[157]),/* "localKeyID" */
1726&(nid_objs[480]),/* "mXRecord" */
1727&(nid_objs[460]),/* "mail" */
1728&(nid_objs[493]),/* "mailPreferenceOption" */
1729&(nid_objs[467]),/* "manager" */
1730&(nid_objs[182]),/* "member-body" */
1731&(nid_objs[51]),/* "messageDigest" */
1732&(nid_objs[383]),/* "mgmt" */
1733&(nid_objs[504]),/* "mime-mhs" */
1734&(nid_objs[506]),/* "mime-mhs-bodies" */
1735&(nid_objs[505]),/* "mime-mhs-headings" */
1736&(nid_objs[488]),/* "mobileTelephoneNumber" */
1737&(nid_objs[136]),/* "msCTLSign" */
1738&(nid_objs[135]),/* "msCodeCom" */
1739&(nid_objs[134]),/* "msCodeInd" */
1740&(nid_objs[138]),/* "msEFS" */
1741&(nid_objs[171]),/* "msExtReq" */
1742&(nid_objs[137]),/* "msSGC" */
1743&(nid_objs[481]),/* "nSRecord" */
1744&(nid_objs[173]),/* "name" */
1745&(nid_objs[369]),/* "noCheck" */
1746&(nid_objs[403]),/* "noRevAvail" */
1747&(nid_objs[72]),/* "nsBaseUrl" */
1748&(nid_objs[76]),/* "nsCaPolicyUrl" */
1749&(nid_objs[74]),/* "nsCaRevocationUrl" */
1750&(nid_objs[58]),/* "nsCertExt" */
1751&(nid_objs[79]),/* "nsCertSequence" */
1752&(nid_objs[71]),/* "nsCertType" */
1753&(nid_objs[78]),/* "nsComment" */
1754&(nid_objs[59]),/* "nsDataType" */
1755&(nid_objs[75]),/* "nsRenewalUrl" */
1756&(nid_objs[73]),/* "nsRevocationUrl" */
1757&(nid_objs[139]),/* "nsSGC" */
1758&(nid_objs[77]),/* "nsSslServerName" */
1759&(nid_objs[491]),/* "organizationalStatus" */
1760&(nid_objs[475]),/* "otherMailbox" */
1761&(nid_objs[489]),/* "pagerTelephoneNumber" */
1762&(nid_objs[374]),/* "path" */
1763&(nid_objs[112]),/* "pbeWithMD5AndCast5CBC" */
1764&(nid_objs[499]),/* "personalSignature" */
1765&(nid_objs[487]),/* "personalTitle" */
1766&(nid_objs[464]),/* "photo" */
1767&(nid_objs[437]),/* "pilot" */
1768&(nid_objs[439]),/* "pilotAttributeSyntax" */
1769&(nid_objs[438]),/* "pilotAttributeType" */
1770&(nid_objs[479]),/* "pilotAttributeType27" */
1771&(nid_objs[456]),/* "pilotDSA" */
1772&(nid_objs[441]),/* "pilotGroups" */
1773&(nid_objs[444]),/* "pilotObject" */
1774&(nid_objs[440]),/* "pilotObjectClass" */
1775&(nid_objs[455]),/* "pilotOrganization" */
1776&(nid_objs[445]),/* "pilotPerson" */
1777&(nid_objs[ 2]),/* "pkcs" */
1778&(nid_objs[186]),/* "pkcs1" */
1779&(nid_objs[27]),/* "pkcs3" */
1780&(nid_objs[187]),/* "pkcs5" */
1781&(nid_objs[20]),/* "pkcs7" */
1782&(nid_objs[21]),/* "pkcs7-data" */
1783&(nid_objs[25]),/* "pkcs7-digestData" */
1784&(nid_objs[26]),/* "pkcs7-encryptedData" */
1785&(nid_objs[23]),/* "pkcs7-envelopedData" */
1786&(nid_objs[24]),/* "pkcs7-signedAndEnvelopedData" */
1787&(nid_objs[22]),/* "pkcs7-signedData" */
1788&(nid_objs[151]),/* "pkcs8ShroudedKeyBag" */
1789&(nid_objs[47]),/* "pkcs9" */
1790&(nid_objs[401]),/* "policyConstraints" */
1791&(nid_objs[406]),/* "prime-field" */
1792&(nid_objs[409]),/* "prime192v1" */
1793&(nid_objs[410]),/* "prime192v2" */
1794&(nid_objs[411]),/* "prime192v3" */
1795&(nid_objs[412]),/* "prime239v1" */
1796&(nid_objs[413]),/* "prime239v2" */
1797&(nid_objs[414]),/* "prime239v3" */
1798&(nid_objs[415]),/* "prime256v1" */
1799&(nid_objs[385]),/* "private" */
1800&(nid_objs[84]),/* "privateKeyUsagePeriod" */
1801&(nid_objs[435]),/* "pss" */
1802&(nid_objs[286]),/* "qcStatements" */
1803&(nid_objs[457]),/* "qualityLabelledData" */
1804&(nid_objs[450]),/* "rFC822localPart" */
1805&(nid_objs[400]),/* "role" */
1806&(nid_objs[448]),/* "room" */
1807&(nid_objs[463]),/* "roomNumber" */
1808&(nid_objs[ 6]),/* "rsaEncryption" */
1809&(nid_objs[377]),/* "rsaSignature" */
1810&(nid_objs[ 1]),/* "rsadsi" */
1811&(nid_objs[482]),/* "sOARecord" */
1812&(nid_objs[155]),/* "safeContentsBag" */
1813&(nid_objs[291]),/* "sbqp-autonomousSysNum" */
1814&(nid_objs[290]),/* "sbqp-ipAddrBlock" */
1815&(nid_objs[292]),/* "sbqp-routerIdentifier" */
1816&(nid_objs[159]),/* "sdsiCertificate" */
1817&(nid_objs[154]),/* "secretBag" */
1818&(nid_objs[474]),/* "secretary" */
1819&(nid_objs[386]),/* "security" */
1820&(nid_objs[394]),/* "selected-attribute-types" */
1821&(nid_objs[105]),/* "serialNumber" */
1822&(nid_objs[129]),/* "serverAuth" */
1823&(nid_objs[371]),/* "serviceLocator" */
1824&(nid_objs[52]),/* "signingTime" */
1825&(nid_objs[454]),/* "simpleSecurityObject" */
1826&(nid_objs[496]),/* "singleLevelQuality" */
1827&(nid_objs[387]),/* "snmpv2" */
1828&(nid_objs[85]),/* "subjectAltName" */
1829&(nid_objs[398]),/* "subjectInfoAccess" */
1830&(nid_objs[82]),/* "subjectKeyIdentifier" */
1831&(nid_objs[498]),/* "subtreeMaximumQuality" */
1832&(nid_objs[497]),/* "subtreeMinimumQuality" */
1833&(nid_objs[402]),/* "targetInformation" */
1834&(nid_objs[459]),/* "textEncodedORAddress" */
1835&(nid_objs[293]),/* "textNotice" */
1836&(nid_objs[133]),/* "timeStamping" */
1837&(nid_objs[106]),/* "title" */
1838&(nid_objs[375]),/* "trustRoot" */
1839&(nid_objs[436]),/* "ucl" */
1840&(nid_objs[55]),/* "unstructuredAddress" */
1841&(nid_objs[49]),/* "unstructuredName" */
1842&(nid_objs[465]),/* "userClass" */
1843&(nid_objs[373]),/* "valid" */
1844&(nid_objs[503]),/* "x500UniqueIdentifier" */
1845&(nid_objs[158]),/* "x509Certificate" */
1846&(nid_objs[160]),/* "x509Crl" */
1847};
1848
1849static ASN1_OBJECT *ln_objs[NUM_LN]={
1850&(nid_objs[363]),/* "AD Time Stamping" */
1851&(nid_objs[405]),/* "ANSI X9.62" */
1852&(nid_objs[368]),/* "Acceptable OCSP Responses" */
1853&(nid_objs[177]),/* "Authority Information Access" */
1854&(nid_objs[365]),/* "Basic OCSP Response" */
1855&(nid_objs[285]),/* "Biometric Info" */
1856&(nid_objs[179]),/* "CA Issuers" */
1857&(nid_objs[131]),/* "Code Signing" */
1858&(nid_objs[382]),/* "Directory" */
1859&(nid_objs[392]),/* "Domain" */
1860&(nid_objs[132]),/* "E-mail Protection" */
1861&(nid_objs[389]),/* "Enterprises" */
1862&(nid_objs[384]),/* "Experimental" */
1863&(nid_objs[372]),/* "Extended OCSP Status" */
1864&(nid_objs[172]),/* "Extension Request" */
1865&(nid_objs[432]),/* "Hold Instruction Call Issuer" */
1866&(nid_objs[430]),/* "Hold Instruction Code" */
1867&(nid_objs[431]),/* "Hold Instruction None" */
1868&(nid_objs[433]),/* "Hold Instruction Reject" */
1869&(nid_objs[294]),/* "IPSec End System" */
1870&(nid_objs[295]),/* "IPSec Tunnel" */
1871&(nid_objs[296]),/* "IPSec User" */
1872&(nid_objs[182]),/* "ISO Member Body" */
1873&(nid_objs[183]),/* "ISO US Member Body" */
1874&(nid_objs[142]),/* "Invalidity Date" */
1875&(nid_objs[504]),/* "MIME MHS" */
1876&(nid_objs[388]),/* "Mail" */
1877&(nid_objs[383]),/* "Management" */
1878&(nid_objs[417]),/* "Microsoft CSP Name" */
1879&(nid_objs[135]),/* "Microsoft Commercial Code Signing" */
1880&(nid_objs[138]),/* "Microsoft Encrypted File System" */
1881&(nid_objs[171]),/* "Microsoft Extension Request" */
1882&(nid_objs[134]),/* "Microsoft Individual Code Signing" */
1883&(nid_objs[137]),/* "Microsoft Server Gated Crypto" */
1884&(nid_objs[136]),/* "Microsoft Trust List Signing" */
1885&(nid_objs[72]),/* "Netscape Base Url" */
1886&(nid_objs[76]),/* "Netscape CA Policy Url" */
1887&(nid_objs[74]),/* "Netscape CA Revocation Url" */
1888&(nid_objs[71]),/* "Netscape Cert Type" */
1889&(nid_objs[58]),/* "Netscape Certificate Extension" */
1890&(nid_objs[79]),/* "Netscape Certificate Sequence" */
1891&(nid_objs[78]),/* "Netscape Comment" */
1892&(nid_objs[57]),/* "Netscape Communications Corp." */
1893&(nid_objs[59]),/* "Netscape Data Type" */
1894&(nid_objs[75]),/* "Netscape Renewal Url" */
1895&(nid_objs[73]),/* "Netscape Revocation Url" */
1896&(nid_objs[77]),/* "Netscape SSL Server Name" */
1897&(nid_objs[139]),/* "Netscape Server Gated Crypto" */
1898&(nid_objs[178]),/* "OCSP" */
1899&(nid_objs[370]),/* "OCSP Archive Cutoff" */
1900&(nid_objs[367]),/* "OCSP CRL ID" */
1901&(nid_objs[369]),/* "OCSP No Check" */
1902&(nid_objs[366]),/* "OCSP Nonce" */
1903&(nid_objs[371]),/* "OCSP Service Locator" */
1904&(nid_objs[180]),/* "OCSP Signing" */
1905&(nid_objs[161]),/* "PBES2" */
1906&(nid_objs[69]),/* "PBKDF2" */
1907&(nid_objs[162]),/* "PBMAC1" */
1908&(nid_objs[127]),/* "PKIX" */
1909&(nid_objs[164]),/* "Policy Qualifier CPS" */
1910&(nid_objs[165]),/* "Policy Qualifier User Notice" */
1911&(nid_objs[385]),/* "Private" */
1912&(nid_objs[ 1]),/* "RSA Data Security, Inc." */
1913&(nid_objs[ 2]),/* "RSA Data Security, Inc. PKCS" */
1914&(nid_objs[188]),/* "S/MIME" */
1915&(nid_objs[167]),/* "S/MIME Capabilities" */
1916&(nid_objs[387]),/* "SNMPv2" */
1917&(nid_objs[386]),/* "Security" */
1918&(nid_objs[394]),/* "Selected Attribute Types" */
1919&(nid_objs[143]),/* "Strong Extranet ID" */
1920&(nid_objs[398]),/* "Subject Information Access" */
1921&(nid_objs[130]),/* "TLS Web Client Authentication" */
1922&(nid_objs[129]),/* "TLS Web Server Authentication" */
1923&(nid_objs[133]),/* "Time Stamping" */
1924&(nid_objs[375]),/* "Trust Root" */
1925&(nid_objs[12]),/* "X509" */
1926&(nid_objs[402]),/* "X509v3 AC Targeting" */
1927&(nid_objs[90]),/* "X509v3 Authority Key Identifier" */
1928&(nid_objs[87]),/* "X509v3 Basic Constraints" */
1929&(nid_objs[103]),/* "X509v3 CRL Distribution Points" */
1930&(nid_objs[88]),/* "X509v3 CRL Number" */
1931&(nid_objs[141]),/* "X509v3 CRL Reason Code" */
1932&(nid_objs[89]),/* "X509v3 Certificate Policies" */
1933&(nid_objs[140]),/* "X509v3 Delta CRL Indicator" */
1934&(nid_objs[126]),/* "X509v3 Extended Key Usage" */
1935&(nid_objs[86]),/* "X509v3 Issuer Alternative Name" */
1936&(nid_objs[83]),/* "X509v3 Key Usage" */
1937&(nid_objs[403]),/* "X509v3 No Revocation Available" */
1938&(nid_objs[401]),/* "X509v3 Policy Constraints" */
1939&(nid_objs[84]),/* "X509v3 Private Key Usage Period" */
1940&(nid_objs[85]),/* "X509v3 Subject Alternative Name" */
1941&(nid_objs[82]),/* "X509v3 Subject Key Identifier" */
1942&(nid_objs[184]),/* "X9.57" */
1943&(nid_objs[185]),/* "X9.57 CM ?" */
1944&(nid_objs[478]),/* "aRecord" */
1945&(nid_objs[289]),/* "aaControls" */
1946&(nid_objs[287]),/* "ac-auditEntity" */
1947&(nid_objs[397]),/* "ac-proxying" */
1948&(nid_objs[288]),/* "ac-targeting" */
1949&(nid_objs[446]),/* "account" */
1950&(nid_objs[364]),/* "ad dvcs" */
1951&(nid_objs[419]),/* "aes-128-cbc" */
1952&(nid_objs[421]),/* "aes-128-cfb" */
1953&(nid_objs[418]),/* "aes-128-ecb" */
1954&(nid_objs[420]),/* "aes-128-ofb" */
1955&(nid_objs[423]),/* "aes-192-cbc" */
1956&(nid_objs[425]),/* "aes-192-cfb" */
1957&(nid_objs[422]),/* "aes-192-ecb" */
1958&(nid_objs[424]),/* "aes-192-ofb" */
1959&(nid_objs[427]),/* "aes-256-cbc" */
1960&(nid_objs[429]),/* "aes-256-cfb" */
1961&(nid_objs[426]),/* "aes-256-ecb" */
1962&(nid_objs[428]),/* "aes-256-ofb" */
1963&(nid_objs[376]),/* "algorithm" */
1964&(nid_objs[484]),/* "associatedDomain" */
1965&(nid_objs[485]),/* "associatedName" */
1966&(nid_objs[501]),/* "audio" */
1967&(nid_objs[91]),/* "bf-cbc" */
1968&(nid_objs[93]),/* "bf-cfb" */
1969&(nid_objs[92]),/* "bf-ecb" */
1970&(nid_objs[94]),/* "bf-ofb" */
1971&(nid_objs[494]),/* "buildingName" */
1972&(nid_objs[483]),/* "cNAMERecord" */
1973&(nid_objs[443]),/* "caseIgnoreIA5StringSyntax" */
1974&(nid_objs[108]),/* "cast5-cbc" */
1975&(nid_objs[110]),/* "cast5-cfb" */
1976&(nid_objs[109]),/* "cast5-ecb" */
1977&(nid_objs[111]),/* "cast5-ofb" */
1978&(nid_objs[404]),/* "ccitt" */
1979&(nid_objs[152]),/* "certBag" */
1980&(nid_objs[54]),/* "challengePassword" */
1981&(nid_objs[407]),/* "characteristic-two-field" */
1982&(nid_objs[395]),/* "clearance" */
1983&(nid_objs[13]),/* "commonName" */
1984&(nid_objs[50]),/* "contentType" */
1985&(nid_objs[53]),/* "countersignature" */
1986&(nid_objs[14]),/* "countryName" */
1987&(nid_objs[153]),/* "crlBag" */
1988&(nid_objs[500]),/* "dITRedirect" */
1989&(nid_objs[451]),/* "dNSDomain" */
1990&(nid_objs[495]),/* "dSAQuality" */
1991&(nid_objs[434]),/* "data" */
1992&(nid_objs[390]),/* "dcObject" */
1993&(nid_objs[31]),/* "des-cbc" */
1994&(nid_objs[30]),/* "des-cfb" */
1995&(nid_objs[29]),/* "des-ecb" */
1996&(nid_objs[32]),/* "des-ede" */
1997&(nid_objs[43]),/* "des-ede-cbc" */
1998&(nid_objs[60]),/* "des-ede-cfb" */
1999&(nid_objs[62]),/* "des-ede-ofb" */
2000&(nid_objs[33]),/* "des-ede3" */
2001&(nid_objs[44]),/* "des-ede3-cbc" */
2002&(nid_objs[61]),/* "des-ede3-cfb" */
2003&(nid_objs[63]),/* "des-ede3-ofb" */
2004&(nid_objs[45]),/* "des-ofb" */
2005&(nid_objs[107]),/* "description" */
2006&(nid_objs[80]),/* "desx-cbc" */
2007&(nid_objs[28]),/* "dhKeyAgreement" */
2008&(nid_objs[11]),/* "directory services (X.500)" */
2009&(nid_objs[378]),/* "directory services - algorithms" */
2010&(nid_objs[174]),/* "dnQualifier" */
2011&(nid_objs[447]),/* "document" */
2012&(nid_objs[471]),/* "documentAuthor" */
2013&(nid_objs[468]),/* "documentIdentifier" */
2014&(nid_objs[472]),/* "documentLocation" */
2015&(nid_objs[502]),/* "documentPublisher" */
2016&(nid_objs[449]),/* "documentSeries" */
2017&(nid_objs[469]),/* "documentTitle" */
2018&(nid_objs[470]),/* "documentVersion" */
2019&(nid_objs[380]),/* "dod" */
2020&(nid_objs[391]),/* "domainComponent" */
2021&(nid_objs[452]),/* "domainRelatedObject" */
2022&(nid_objs[116]),/* "dsaEncryption" */
2023&(nid_objs[67]),/* "dsaEncryption-old" */
2024&(nid_objs[66]),/* "dsaWithSHA" */
2025&(nid_objs[113]),/* "dsaWithSHA1" */
2026&(nid_objs[70]),/* "dsaWithSHA1-old" */
2027&(nid_objs[297]),/* "dvcs" */
2028&(nid_objs[416]),/* "ecdsa-with-SHA1" */
2029&(nid_objs[48]),/* "emailAddress" */
2030&(nid_objs[56]),/* "extendedCertificateAttributes" */
2031&(nid_objs[462]),/* "favouriteDrink" */
2032&(nid_objs[453]),/* "friendlyCountry" */
2033&(nid_objs[490]),/* "friendlyCountryName" */
2034&(nid_objs[156]),/* "friendlyName" */
2035&(nid_objs[509]),/* "generationQualifier" */
2036&(nid_objs[99]),/* "givenName" */
2037&(nid_objs[163]),/* "hmacWithSHA1" */
2038&(nid_objs[486]),/* "homePostalAddress" */
2039&(nid_objs[473]),/* "homeTelephoneNumber" */
2040&(nid_objs[466]),/* "host" */
2041&(nid_objs[442]),/* "iA5StringSyntax" */
2042&(nid_objs[381]),/* "iana" */
2043&(nid_objs[266]),/* "id-aca" */
2044&(nid_objs[355]),/* "id-aca-accessIdentity" */
2045&(nid_objs[354]),/* "id-aca-authenticationInfo" */
2046&(nid_objs[356]),/* "id-aca-chargingIdentity" */
2047&(nid_objs[399]),/* "id-aca-encAttrs" */
2048&(nid_objs[357]),/* "id-aca-group" */
2049&(nid_objs[358]),/* "id-aca-role" */
2050&(nid_objs[176]),/* "id-ad" */
2051&(nid_objs[262]),/* "id-alg" */
2052&(nid_objs[323]),/* "id-alg-des40" */
2053&(nid_objs[326]),/* "id-alg-dh-pop" */
2054&(nid_objs[325]),/* "id-alg-dh-sig-hmac-sha1" */
2055&(nid_objs[324]),/* "id-alg-noSignature" */
2056&(nid_objs[268]),/* "id-cct" */
2057&(nid_objs[361]),/* "id-cct-PKIData" */
2058&(nid_objs[362]),/* "id-cct-PKIResponse" */
2059&(nid_objs[360]),/* "id-cct-crs" */
2060&(nid_objs[81]),/* "id-ce" */
2061&(nid_objs[263]),/* "id-cmc" */
2062&(nid_objs[334]),/* "id-cmc-addExtensions" */
2063&(nid_objs[346]),/* "id-cmc-confirmCertAcceptance" */
2064&(nid_objs[330]),/* "id-cmc-dataReturn" */
2065&(nid_objs[336]),/* "id-cmc-decryptedPOP" */
2066&(nid_objs[335]),/* "id-cmc-encryptedPOP" */
2067&(nid_objs[339]),/* "id-cmc-getCRL" */
2068&(nid_objs[338]),/* "id-cmc-getCert" */
2069&(nid_objs[328]),/* "id-cmc-identification" */
2070&(nid_objs[329]),/* "id-cmc-identityProof" */
2071&(nid_objs[337]),/* "id-cmc-lraPOPWitness" */
2072&(nid_objs[344]),/* "id-cmc-popLinkRandom" */
2073&(nid_objs[345]),/* "id-cmc-popLinkWitness" */
2074&(nid_objs[343]),/* "id-cmc-queryPending" */
2075&(nid_objs[333]),/* "id-cmc-recipientNonce" */
2076&(nid_objs[341]),/* "id-cmc-regInfo" */
2077&(nid_objs[342]),/* "id-cmc-responseInfo" */
2078&(nid_objs[340]),/* "id-cmc-revokeRequest" */
2079&(nid_objs[332]),/* "id-cmc-senderNonce" */
2080&(nid_objs[327]),/* "id-cmc-statusInfo" */
2081&(nid_objs[331]),/* "id-cmc-transactionId" */
2082&(nid_objs[408]),/* "id-ecPublicKey" */
2083&(nid_objs[508]),/* "id-hex-multipart-message" */
2084&(nid_objs[507]),/* "id-hex-partial-message" */
2085&(nid_objs[260]),/* "id-it" */
2086&(nid_objs[302]),/* "id-it-caKeyUpdateInfo" */
2087&(nid_objs[298]),/* "id-it-caProtEncCert" */
2088&(nid_objs[311]),/* "id-it-confirmWaitTime" */
2089&(nid_objs[303]),/* "id-it-currentCRL" */
2090&(nid_objs[300]),/* "id-it-encKeyPairTypes" */
2091&(nid_objs[310]),/* "id-it-implicitConfirm" */
2092&(nid_objs[308]),/* "id-it-keyPairParamRep" */
2093&(nid_objs[307]),/* "id-it-keyPairParamReq" */
2094&(nid_objs[312]),/* "id-it-origPKIMessage" */
2095&(nid_objs[301]),/* "id-it-preferredSymmAlg" */
2096&(nid_objs[309]),/* "id-it-revPassphrase" */
2097&(nid_objs[299]),/* "id-it-signKeyPairTypes" */
2098&(nid_objs[305]),/* "id-it-subscriptionRequest" */
2099&(nid_objs[306]),/* "id-it-subscriptionResponse" */
2100&(nid_objs[304]),/* "id-it-unsupportedOIDs" */
2101&(nid_objs[128]),/* "id-kp" */
2102&(nid_objs[280]),/* "id-mod-attribute-cert" */
2103&(nid_objs[274]),/* "id-mod-cmc" */
2104&(nid_objs[277]),/* "id-mod-cmp" */
2105&(nid_objs[284]),/* "id-mod-cmp2000" */
2106&(nid_objs[273]),/* "id-mod-crmf" */
2107&(nid_objs[283]),/* "id-mod-dvcs" */
2108&(nid_objs[275]),/* "id-mod-kea-profile-88" */
2109&(nid_objs[276]),/* "id-mod-kea-profile-93" */
2110&(nid_objs[282]),/* "id-mod-ocsp" */
2111&(nid_objs[278]),/* "id-mod-qualified-cert-88" */
2112&(nid_objs[279]),/* "id-mod-qualified-cert-93" */
2113&(nid_objs[281]),/* "id-mod-timestamp-protocol" */
2114&(nid_objs[264]),/* "id-on" */
2115&(nid_objs[347]),/* "id-on-personalData" */
2116&(nid_objs[265]),/* "id-pda" */
2117&(nid_objs[352]),/* "id-pda-countryOfCitizenship" */
2118&(nid_objs[353]),/* "id-pda-countryOfResidence" */
2119&(nid_objs[348]),/* "id-pda-dateOfBirth" */
2120&(nid_objs[351]),/* "id-pda-gender" */
2121&(nid_objs[349]),/* "id-pda-placeOfBirth" */
2122&(nid_objs[175]),/* "id-pe" */
2123&(nid_objs[261]),/* "id-pkip" */
2124&(nid_objs[258]),/* "id-pkix-mod" */
2125&(nid_objs[269]),/* "id-pkix1-explicit-88" */
2126&(nid_objs[271]),/* "id-pkix1-explicit-93" */
2127&(nid_objs[270]),/* "id-pkix1-implicit-88" */
2128&(nid_objs[272]),/* "id-pkix1-implicit-93" */
2129&(nid_objs[267]),/* "id-qcs" */
2130&(nid_objs[359]),/* "id-qcs-pkixQCSyntax-v1" */
2131&(nid_objs[259]),/* "id-qt" */
2132&(nid_objs[313]),/* "id-regCtrl" */
2133&(nid_objs[316]),/* "id-regCtrl-authenticator" */
2134&(nid_objs[319]),/* "id-regCtrl-oldCertID" */
2135&(nid_objs[318]),/* "id-regCtrl-pkiArchiveOptions" */
2136&(nid_objs[317]),/* "id-regCtrl-pkiPublicationInfo" */
2137&(nid_objs[320]),/* "id-regCtrl-protocolEncrKey" */
2138&(nid_objs[315]),/* "id-regCtrl-regToken" */
2139&(nid_objs[314]),/* "id-regInfo" */
2140&(nid_objs[322]),/* "id-regInfo-certReq" */
2141&(nid_objs[321]),/* "id-regInfo-utf8Pairs" */
2142&(nid_objs[191]),/* "id-smime-aa" */
2143&(nid_objs[215]),/* "id-smime-aa-contentHint" */
2144&(nid_objs[218]),/* "id-smime-aa-contentIdentifier" */
2145&(nid_objs[221]),/* "id-smime-aa-contentReference" */
2146&(nid_objs[240]),/* "id-smime-aa-dvcs-dvc" */
2147&(nid_objs[217]),/* "id-smime-aa-encapContentType" */
2148&(nid_objs[222]),/* "id-smime-aa-encrypKeyPref" */
2149&(nid_objs[220]),/* "id-smime-aa-equivalentLabels" */
2150&(nid_objs[232]),/* "id-smime-aa-ets-CertificateRefs" */
2151&(nid_objs[233]),/* "id-smime-aa-ets-RevocationRefs" */
2152&(nid_objs[238]),/* "id-smime-aa-ets-archiveTimeStamp" */
2153&(nid_objs[237]),/* "id-smime-aa-ets-certCRLTimestamp" */
2154&(nid_objs[234]),/* "id-smime-aa-ets-certValues" */
2155&(nid_objs[227]),/* "id-smime-aa-ets-commitmentType" */
2156&(nid_objs[231]),/* "id-smime-aa-ets-contentTimestamp" */
2157&(nid_objs[236]),/* "id-smime-aa-ets-escTimeStamp" */
2158&(nid_objs[230]),/* "id-smime-aa-ets-otherSigCert" */
2159&(nid_objs[235]),/* "id-smime-aa-ets-revocationValues" */
2160&(nid_objs[226]),/* "id-smime-aa-ets-sigPolicyId" */
2161&(nid_objs[229]),/* "id-smime-aa-ets-signerAttr" */
2162&(nid_objs[228]),/* "id-smime-aa-ets-signerLocation" */
2163&(nid_objs[219]),/* "id-smime-aa-macValue" */
2164&(nid_objs[214]),/* "id-smime-aa-mlExpandHistory" */
2165&(nid_objs[216]),/* "id-smime-aa-msgSigDigest" */
2166&(nid_objs[212]),/* "id-smime-aa-receiptRequest" */
2167&(nid_objs[213]),/* "id-smime-aa-securityLabel" */
2168&(nid_objs[239]),/* "id-smime-aa-signatureType" */
2169&(nid_objs[223]),/* "id-smime-aa-signingCertificate" */
2170&(nid_objs[224]),/* "id-smime-aa-smimeEncryptCerts" */
2171&(nid_objs[225]),/* "id-smime-aa-timeStampToken" */
2172&(nid_objs[192]),/* "id-smime-alg" */
2173&(nid_objs[243]),/* "id-smime-alg-3DESwrap" */
2174&(nid_objs[246]),/* "id-smime-alg-CMS3DESwrap" */
2175&(nid_objs[247]),/* "id-smime-alg-CMSRC2wrap" */
2176&(nid_objs[245]),/* "id-smime-alg-ESDH" */
2177&(nid_objs[241]),/* "id-smime-alg-ESDHwith3DES" */
2178&(nid_objs[242]),/* "id-smime-alg-ESDHwithRC2" */
2179&(nid_objs[244]),/* "id-smime-alg-RC2wrap" */
2180&(nid_objs[193]),/* "id-smime-cd" */
2181&(nid_objs[248]),/* "id-smime-cd-ldap" */
2182&(nid_objs[190]),/* "id-smime-ct" */
2183&(nid_objs[210]),/* "id-smime-ct-DVCSRequestData" */
2184&(nid_objs[211]),/* "id-smime-ct-DVCSResponseData" */
2185&(nid_objs[208]),/* "id-smime-ct-TDTInfo" */
2186&(nid_objs[207]),/* "id-smime-ct-TSTInfo" */
2187&(nid_objs[205]),/* "id-smime-ct-authData" */
2188&(nid_objs[209]),/* "id-smime-ct-contentInfo" */
2189&(nid_objs[206]),/* "id-smime-ct-publishCert" */
2190&(nid_objs[204]),/* "id-smime-ct-receipt" */
2191&(nid_objs[195]),/* "id-smime-cti" */
2192&(nid_objs[255]),/* "id-smime-cti-ets-proofOfApproval" */
2193&(nid_objs[256]),/* "id-smime-cti-ets-proofOfCreation" */
2194&(nid_objs[253]),/* "id-smime-cti-ets-proofOfDelivery" */
2195&(nid_objs[251]),/* "id-smime-cti-ets-proofOfOrigin" */
2196&(nid_objs[252]),/* "id-smime-cti-ets-proofOfReceipt" */
2197&(nid_objs[254]),/* "id-smime-cti-ets-proofOfSender" */
2198&(nid_objs[189]),/* "id-smime-mod" */
2199&(nid_objs[196]),/* "id-smime-mod-cms" */
2200&(nid_objs[197]),/* "id-smime-mod-ess" */
2201&(nid_objs[202]),/* "id-smime-mod-ets-eSigPolicy-88" */
2202&(nid_objs[203]),/* "id-smime-mod-ets-eSigPolicy-97" */
2203&(nid_objs[200]),/* "id-smime-mod-ets-eSignature-88" */
2204&(nid_objs[201]),/* "id-smime-mod-ets-eSignature-97" */
2205&(nid_objs[199]),/* "id-smime-mod-msg-v3" */
2206&(nid_objs[198]),/* "id-smime-mod-oid" */
2207&(nid_objs[194]),/* "id-smime-spq" */
2208&(nid_objs[250]),/* "id-smime-spq-ets-sqt-unotice" */
2209&(nid_objs[249]),/* "id-smime-spq-ets-sqt-uri" */
2210&(nid_objs[34]),/* "idea-cbc" */
2211&(nid_objs[35]),/* "idea-cfb" */
2212&(nid_objs[36]),/* "idea-ecb" */
2213&(nid_objs[46]),/* "idea-ofb" */
2214&(nid_objs[461]),/* "info" */
2215&(nid_objs[101]),/* "initials" */
2216&(nid_objs[181]),/* "iso" */
2217&(nid_objs[492]),/* "janetMailbox" */
2218&(nid_objs[393]),/* "joint-iso-ccitt" */
2219&(nid_objs[150]),/* "keyBag" */
2220&(nid_objs[477]),/* "lastModifiedBy" */
2221&(nid_objs[476]),/* "lastModifiedTime" */
2222&(nid_objs[157]),/* "localKeyID" */
2223&(nid_objs[15]),/* "localityName" */
2224&(nid_objs[480]),/* "mXRecord" */
2225&(nid_objs[493]),/* "mailPreferenceOption" */
2226&(nid_objs[467]),/* "manager" */
2227&(nid_objs[ 3]),/* "md2" */
2228&(nid_objs[ 7]),/* "md2WithRSAEncryption" */
2229&(nid_objs[257]),/* "md4" */
2230&(nid_objs[396]),/* "md4WithRSAEncryption" */
2231&(nid_objs[ 4]),/* "md5" */
2232&(nid_objs[114]),/* "md5-sha1" */
2233&(nid_objs[104]),/* "md5WithRSA" */
2234&(nid_objs[ 8]),/* "md5WithRSAEncryption" */
2235&(nid_objs[95]),/* "mdc2" */
2236&(nid_objs[96]),/* "mdc2WithRSA" */
2237&(nid_objs[51]),/* "messageDigest" */
2238&(nid_objs[506]),/* "mime-mhs-bodies" */
2239&(nid_objs[505]),/* "mime-mhs-headings" */
2240&(nid_objs[488]),/* "mobileTelephoneNumber" */
2241&(nid_objs[481]),/* "nSRecord" */
2242&(nid_objs[173]),/* "name" */
2243&(nid_objs[379]),/* "org" */
2244&(nid_objs[17]),/* "organizationName" */
2245&(nid_objs[491]),/* "organizationalStatus" */
2246&(nid_objs[18]),/* "organizationalUnitName" */
2247&(nid_objs[475]),/* "otherMailbox" */
2248&(nid_objs[489]),/* "pagerTelephoneNumber" */
2249&(nid_objs[374]),/* "path" */
2250&(nid_objs[ 9]),/* "pbeWithMD2AndDES-CBC" */
2251&(nid_objs[168]),/* "pbeWithMD2AndRC2-CBC" */
2252&(nid_objs[112]),/* "pbeWithMD5AndCast5CBC" */
2253&(nid_objs[10]),/* "pbeWithMD5AndDES-CBC" */
2254&(nid_objs[169]),/* "pbeWithMD5AndRC2-CBC" */
2255&(nid_objs[148]),/* "pbeWithSHA1And128BitRC2-CBC" */
2256&(nid_objs[144]),/* "pbeWithSHA1And128BitRC4" */
2257&(nid_objs[147]),/* "pbeWithSHA1And2-KeyTripleDES-CBC" */
2258&(nid_objs[146]),/* "pbeWithSHA1And3-KeyTripleDES-CBC" */
2259&(nid_objs[149]),/* "pbeWithSHA1And40BitRC2-CBC" */
2260&(nid_objs[145]),/* "pbeWithSHA1And40BitRC4" */
2261&(nid_objs[170]),/* "pbeWithSHA1AndDES-CBC" */
2262&(nid_objs[68]),/* "pbeWithSHA1AndRC2-CBC" */
2263&(nid_objs[499]),/* "personalSignature" */
2264&(nid_objs[487]),/* "personalTitle" */
2265&(nid_objs[464]),/* "photo" */
2266&(nid_objs[437]),/* "pilot" */
2267&(nid_objs[439]),/* "pilotAttributeSyntax" */
2268&(nid_objs[438]),/* "pilotAttributeType" */
2269&(nid_objs[479]),/* "pilotAttributeType27" */
2270&(nid_objs[456]),/* "pilotDSA" */
2271&(nid_objs[441]),/* "pilotGroups" */
2272&(nid_objs[444]),/* "pilotObject" */
2273&(nid_objs[440]),/* "pilotObjectClass" */
2274&(nid_objs[455]),/* "pilotOrganization" */
2275&(nid_objs[445]),/* "pilotPerson" */
2276&(nid_objs[186]),/* "pkcs1" */
2277&(nid_objs[27]),/* "pkcs3" */
2278&(nid_objs[187]),/* "pkcs5" */
2279&(nid_objs[20]),/* "pkcs7" */
2280&(nid_objs[21]),/* "pkcs7-data" */
2281&(nid_objs[25]),/* "pkcs7-digestData" */
2282&(nid_objs[26]),/* "pkcs7-encryptedData" */
2283&(nid_objs[23]),/* "pkcs7-envelopedData" */
2284&(nid_objs[24]),/* "pkcs7-signedAndEnvelopedData" */
2285&(nid_objs[22]),/* "pkcs7-signedData" */
2286&(nid_objs[151]),/* "pkcs8ShroudedKeyBag" */
2287&(nid_objs[47]),/* "pkcs9" */
2288&(nid_objs[406]),/* "prime-field" */
2289&(nid_objs[409]),/* "prime192v1" */
2290&(nid_objs[410]),/* "prime192v2" */
2291&(nid_objs[411]),/* "prime192v3" */
2292&(nid_objs[412]),/* "prime239v1" */
2293&(nid_objs[413]),/* "prime239v2" */
2294&(nid_objs[414]),/* "prime239v3" */
2295&(nid_objs[415]),/* "prime256v1" */
2296&(nid_objs[435]),/* "pss" */
2297&(nid_objs[286]),/* "qcStatements" */
2298&(nid_objs[457]),/* "qualityLabelledData" */
2299&(nid_objs[450]),/* "rFC822localPart" */
2300&(nid_objs[98]),/* "rc2-40-cbc" */
2301&(nid_objs[166]),/* "rc2-64-cbc" */
2302&(nid_objs[37]),/* "rc2-cbc" */
2303&(nid_objs[39]),/* "rc2-cfb" */
2304&(nid_objs[38]),/* "rc2-ecb" */
2305&(nid_objs[40]),/* "rc2-ofb" */
2306&(nid_objs[ 5]),/* "rc4" */
2307&(nid_objs[97]),/* "rc4-40" */
2308&(nid_objs[120]),/* "rc5-cbc" */
2309&(nid_objs[122]),/* "rc5-cfb" */
2310&(nid_objs[121]),/* "rc5-ecb" */
2311&(nid_objs[123]),/* "rc5-ofb" */
2312&(nid_objs[460]),/* "rfc822Mailbox" */
2313&(nid_objs[117]),/* "ripemd160" */
2314&(nid_objs[119]),/* "ripemd160WithRSA" */
2315&(nid_objs[400]),/* "role" */
2316&(nid_objs[448]),/* "room" */
2317&(nid_objs[463]),/* "roomNumber" */
2318&(nid_objs[19]),/* "rsa" */
2319&(nid_objs[ 6]),/* "rsaEncryption" */
2320&(nid_objs[377]),/* "rsaSignature" */
2321&(nid_objs[124]),/* "run length compression" */
2322&(nid_objs[482]),/* "sOARecord" */
2323&(nid_objs[155]),/* "safeContentsBag" */
2324&(nid_objs[291]),/* "sbqp-autonomousSysNum" */
2325&(nid_objs[290]),/* "sbqp-ipAddrBlock" */
2326&(nid_objs[292]),/* "sbqp-routerIdentifier" */
2327&(nid_objs[159]),/* "sdsiCertificate" */
2328&(nid_objs[154]),/* "secretBag" */
2329&(nid_objs[474]),/* "secretary" */
2330&(nid_objs[105]),/* "serialNumber" */
2331&(nid_objs[41]),/* "sha" */
2332&(nid_objs[64]),/* "sha1" */
2333&(nid_objs[115]),/* "sha1WithRSA" */
2334&(nid_objs[65]),/* "sha1WithRSAEncryption" */
2335&(nid_objs[42]),/* "shaWithRSAEncryption" */
2336&(nid_objs[52]),/* "signingTime" */
2337&(nid_objs[454]),/* "simpleSecurityObject" */
2338&(nid_objs[496]),/* "singleLevelQuality" */
2339&(nid_objs[16]),/* "stateOrProvinceName" */
2340&(nid_objs[498]),/* "subtreeMaximumQuality" */
2341&(nid_objs[497]),/* "subtreeMinimumQuality" */
2342&(nid_objs[100]),/* "surname" */
2343&(nid_objs[459]),/* "textEncodedORAddress" */
2344&(nid_objs[293]),/* "textNotice" */
2345&(nid_objs[106]),/* "title" */
2346&(nid_objs[436]),/* "ucl" */
2347&(nid_objs[ 0]),/* "undefined" */
2348&(nid_objs[55]),/* "unstructuredAddress" */
2349&(nid_objs[49]),/* "unstructuredName" */
2350&(nid_objs[465]),/* "userClass" */
2351&(nid_objs[458]),/* "userId" */
2352&(nid_objs[373]),/* "valid" */
2353&(nid_objs[503]),/* "x500UniqueIdentifier" */
2354&(nid_objs[158]),/* "x509Certificate" */
2355&(nid_objs[160]),/* "x509Crl" */
2356&(nid_objs[125]),/* "zlib compression" */
2357};
2358
2359static ASN1_OBJECT *obj_objs[NUM_OBJ]={
2360&(nid_objs[ 0]),/* OBJ_undef 0 */
2361&(nid_objs[404]),/* OBJ_ccitt 0 */
2362&(nid_objs[434]),/* OBJ_data 0 9 */
2363&(nid_objs[181]),/* OBJ_iso 1 */
2364&(nid_objs[182]),/* OBJ_member_body 1 2 */
2365&(nid_objs[379]),/* OBJ_org 1 3 */
2366&(nid_objs[393]),/* OBJ_joint_iso_ccitt 2 */
2367&(nid_objs[11]),/* OBJ_X500 2 5 */
2368&(nid_objs[380]),/* OBJ_dod 1 3 6 */
2369&(nid_objs[12]),/* OBJ_X509 2 5 4 */
2370&(nid_objs[378]),/* OBJ_X500algorithms 2 5 8 */
2371&(nid_objs[81]),/* OBJ_id_ce 2 5 29 */
2372&(nid_objs[435]),/* OBJ_pss 0 9 2342 */
2373&(nid_objs[183]),/* OBJ_ISO_US 1 2 840 */
2374&(nid_objs[381]),/* OBJ_iana 1 3 6 1 */
2375&(nid_objs[394]),/* OBJ_selected_attribute_types 2 5 1 5 */
2376&(nid_objs[13]),/* OBJ_commonName 2 5 4 3 */
2377&(nid_objs[100]),/* OBJ_surname 2 5 4 4 */
2378&(nid_objs[105]),/* OBJ_serialNumber 2 5 4 5 */
2379&(nid_objs[14]),/* OBJ_countryName 2 5 4 6 */
2380&(nid_objs[15]),/* OBJ_localityName 2 5 4 7 */
2381&(nid_objs[16]),/* OBJ_stateOrProvinceName 2 5 4 8 */
2382&(nid_objs[17]),/* OBJ_organizationName 2 5 4 10 */
2383&(nid_objs[18]),/* OBJ_organizationalUnitName 2 5 4 11 */
2384&(nid_objs[106]),/* OBJ_title 2 5 4 12 */
2385&(nid_objs[107]),/* OBJ_description 2 5 4 13 */
2386&(nid_objs[173]),/* OBJ_name 2 5 4 41 */
2387&(nid_objs[99]),/* OBJ_givenName 2 5 4 42 */
2388&(nid_objs[101]),/* OBJ_initials 2 5 4 43 */
2389&(nid_objs[509]),/* OBJ_generationQualifier 2 5 4 44 */
2390&(nid_objs[503]),/* OBJ_x500UniqueIdentifier 2 5 4 45 */
2391&(nid_objs[174]),/* OBJ_dnQualifier 2 5 4 46 */
2392&(nid_objs[400]),/* OBJ_role 2 5 4 72 */
2393&(nid_objs[82]),/* OBJ_subject_key_identifier 2 5 29 14 */
2394&(nid_objs[83]),/* OBJ_key_usage 2 5 29 15 */
2395&(nid_objs[84]),/* OBJ_private_key_usage_period 2 5 29 16 */
2396&(nid_objs[85]),/* OBJ_subject_alt_name 2 5 29 17 */
2397&(nid_objs[86]),/* OBJ_issuer_alt_name 2 5 29 18 */
2398&(nid_objs[87]),/* OBJ_basic_constraints 2 5 29 19 */
2399&(nid_objs[88]),/* OBJ_crl_number 2 5 29 20 */
2400&(nid_objs[141]),/* OBJ_crl_reason 2 5 29 21 */
2401&(nid_objs[430]),/* OBJ_hold_instruction_code 2 5 29 23 */
2402&(nid_objs[142]),/* OBJ_invalidity_date 2 5 29 24 */
2403&(nid_objs[140]),/* OBJ_delta_crl 2 5 29 27 */
2404&(nid_objs[103]),/* OBJ_crl_distribution_points 2 5 29 31 */
2405&(nid_objs[89]),/* OBJ_certificate_policies 2 5 29 32 */
2406&(nid_objs[90]),/* OBJ_authority_key_identifier 2 5 29 35 */
2407&(nid_objs[401]),/* OBJ_policy_constraints 2 5 29 36 */
2408&(nid_objs[126]),/* OBJ_ext_key_usage 2 5 29 37 */
2409&(nid_objs[402]),/* OBJ_target_information 2 5 29 55 */
2410&(nid_objs[403]),/* OBJ_no_rev_avail 2 5 29 56 */
2411&(nid_objs[382]),/* OBJ_Directory 1 3 6 1 1 */
2412&(nid_objs[383]),/* OBJ_Management 1 3 6 1 2 */
2413&(nid_objs[384]),/* OBJ_Experimental 1 3 6 1 3 */
2414&(nid_objs[385]),/* OBJ_Private 1 3 6 1 4 */
2415&(nid_objs[386]),/* OBJ_Security 1 3 6 1 5 */
2416&(nid_objs[387]),/* OBJ_SNMPv2 1 3 6 1 6 */
2417&(nid_objs[388]),/* OBJ_Mail 1 3 6 1 7 */
2418&(nid_objs[376]),/* OBJ_algorithm 1 3 14 3 2 */
2419&(nid_objs[395]),/* OBJ_clearance 2 5 1 5 55 */
2420&(nid_objs[19]),/* OBJ_rsa 2 5 8 1 1 */
2421&(nid_objs[96]),/* OBJ_mdc2WithRSA 2 5 8 3 100 */
2422&(nid_objs[95]),/* OBJ_mdc2 2 5 8 3 101 */
2423&(nid_objs[184]),/* OBJ_X9_57 1 2 840 10040 */
2424&(nid_objs[405]),/* OBJ_ansi_X9_62 1 2 840 10045 */
2425&(nid_objs[389]),/* OBJ_Enterprises 1 3 6 1 4 1 */
2426&(nid_objs[504]),/* OBJ_mime_mhs 1 3 6 1 7 1 */
2427&(nid_objs[104]),/* OBJ_md5WithRSA 1 3 14 3 2 3 */
2428&(nid_objs[29]),/* OBJ_des_ecb 1 3 14 3 2 6 */
2429&(nid_objs[31]),/* OBJ_des_cbc 1 3 14 3 2 7 */
2430&(nid_objs[45]),/* OBJ_des_ofb64 1 3 14 3 2 8 */
2431&(nid_objs[30]),/* OBJ_des_cfb64 1 3 14 3 2 9 */
2432&(nid_objs[377]),/* OBJ_rsaSignature 1 3 14 3 2 11 */
2433&(nid_objs[67]),/* OBJ_dsa_2 1 3 14 3 2 12 */
2434&(nid_objs[66]),/* OBJ_dsaWithSHA 1 3 14 3 2 13 */
2435&(nid_objs[42]),/* OBJ_shaWithRSAEncryption 1 3 14 3 2 15 */
2436&(nid_objs[32]),/* OBJ_des_ede_ecb 1 3 14 3 2 17 */
2437&(nid_objs[41]),/* OBJ_sha 1 3 14 3 2 18 */
2438&(nid_objs[64]),/* OBJ_sha1 1 3 14 3 2 26 */
2439&(nid_objs[70]),/* OBJ_dsaWithSHA1_2 1 3 14 3 2 27 */
2440&(nid_objs[115]),/* OBJ_sha1WithRSA 1 3 14 3 2 29 */
2441&(nid_objs[117]),/* OBJ_ripemd160 1 3 36 3 2 1 */
2442&(nid_objs[143]),/* OBJ_sxnet 1 3 101 1 4 1 */
2443&(nid_objs[124]),/* OBJ_rle_compression 1 1 1 1 666 1 */
2444&(nid_objs[125]),/* OBJ_zlib_compression 1 1 1 1 666 2 */
2445&(nid_objs[ 1]),/* OBJ_rsadsi 1 2 840 113549 */
2446&(nid_objs[185]),/* OBJ_X9cm 1 2 840 10040 4 */
2447&(nid_objs[127]),/* OBJ_id_pkix 1 3 6 1 5 5 7 */
2448&(nid_objs[505]),/* OBJ_mime_mhs_headings 1 3 6 1 7 1 1 */
2449&(nid_objs[506]),/* OBJ_mime_mhs_bodies 1 3 6 1 7 1 2 */
2450&(nid_objs[119]),/* OBJ_ripemd160WithRSA 1 3 36 3 3 1 2 */
2451&(nid_objs[436]),/* OBJ_ucl 0 9 2342 19200300 */
2452&(nid_objs[ 2]),/* OBJ_pkcs 1 2 840 113549 1 */
2453&(nid_objs[431]),/* OBJ_hold_instruction_none 1 2 840 10040 2 1 */
2454&(nid_objs[432]),/* OBJ_hold_instruction_call_issuer 1 2 840 10040 2 2 */
2455&(nid_objs[433]),/* OBJ_hold_instruction_reject 1 2 840 10040 2 3 */
2456&(nid_objs[116]),/* OBJ_dsa 1 2 840 10040 4 1 */
2457&(nid_objs[113]),/* OBJ_dsaWithSHA1 1 2 840 10040 4 3 */
2458&(nid_objs[406]),/* OBJ_X9_62_prime_field 1 2 840 10045 1 1 */
2459&(nid_objs[407]),/* OBJ_X9_62_characteristic_two_field 1 2 840 10045 1 2 */
2460&(nid_objs[408]),/* OBJ_X9_62_id_ecPublicKey 1 2 840 10045 2 1 */
2461&(nid_objs[416]),/* OBJ_ecdsa_with_SHA1 1 2 840 10045 4 1 */
2462&(nid_objs[258]),/* OBJ_id_pkix_mod 1 3 6 1 5 5 7 0 */
2463&(nid_objs[175]),/* OBJ_id_pe 1 3 6 1 5 5 7 1 */
2464&(nid_objs[259]),/* OBJ_id_qt 1 3 6 1 5 5 7 2 */
2465&(nid_objs[128]),/* OBJ_id_kp 1 3 6 1 5 5 7 3 */
2466&(nid_objs[260]),/* OBJ_id_it 1 3 6 1 5 5 7 4 */
2467&(nid_objs[261]),/* OBJ_id_pkip 1 3 6 1 5 5 7 5 */
2468&(nid_objs[262]),/* OBJ_id_alg 1 3 6 1 5 5 7 6 */
2469&(nid_objs[263]),/* OBJ_id_cmc 1 3 6 1 5 5 7 7 */
2470&(nid_objs[264]),/* OBJ_id_on 1 3 6 1 5 5 7 8 */
2471&(nid_objs[265]),/* OBJ_id_pda 1 3 6 1 5 5 7 9 */
2472&(nid_objs[266]),/* OBJ_id_aca 1 3 6 1 5 5 7 10 */
2473&(nid_objs[267]),/* OBJ_id_qcs 1 3 6 1 5 5 7 11 */
2474&(nid_objs[268]),/* OBJ_id_cct 1 3 6 1 5 5 7 12 */
2475&(nid_objs[176]),/* OBJ_id_ad 1 3 6 1 5 5 7 48 */
2476&(nid_objs[507]),/* OBJ_id_hex_partial_message 1 3 6 1 7 1 1 1 */
2477&(nid_objs[508]),/* OBJ_id_hex_multipart_message 1 3 6 1 7 1 1 2 */
2478&(nid_objs[57]),/* OBJ_netscape 2 16 840 1 113730 */
2479&(nid_objs[437]),/* OBJ_pilot 0 9 2342 19200300 100 */
2480&(nid_objs[186]),/* OBJ_pkcs1 1 2 840 113549 1 1 */
2481&(nid_objs[27]),/* OBJ_pkcs3 1 2 840 113549 1 3 */
2482&(nid_objs[187]),/* OBJ_pkcs5 1 2 840 113549 1 5 */
2483&(nid_objs[20]),/* OBJ_pkcs7 1 2 840 113549 1 7 */
2484&(nid_objs[47]),/* OBJ_pkcs9 1 2 840 113549 1 9 */
2485&(nid_objs[ 3]),/* OBJ_md2 1 2 840 113549 2 2 */
2486&(nid_objs[257]),/* OBJ_md4 1 2 840 113549 2 4 */
2487&(nid_objs[ 4]),/* OBJ_md5 1 2 840 113549 2 5 */
2488&(nid_objs[163]),/* OBJ_hmacWithSHA1 1 2 840 113549 2 7 */
2489&(nid_objs[37]),/* OBJ_rc2_cbc 1 2 840 113549 3 2 */
2490&(nid_objs[ 5]),/* OBJ_rc4 1 2 840 113549 3 4 */
2491&(nid_objs[44]),/* OBJ_des_ede3_cbc 1 2 840 113549 3 7 */
2492&(nid_objs[120]),/* OBJ_rc5_cbc 1 2 840 113549 3 8 */
2493&(nid_objs[409]),/* OBJ_X9_62_prime192v1 1 2 840 10045 3 1 1 */
2494&(nid_objs[410]),/* OBJ_X9_62_prime192v2 1 2 840 10045 3 1 2 */
2495&(nid_objs[411]),/* OBJ_X9_62_prime192v3 1 2 840 10045 3 1 3 */
2496&(nid_objs[412]),/* OBJ_X9_62_prime239v1 1 2 840 10045 3 1 4 */
2497&(nid_objs[413]),/* OBJ_X9_62_prime239v2 1 2 840 10045 3 1 5 */
2498&(nid_objs[414]),/* OBJ_X9_62_prime239v3 1 2 840 10045 3 1 6 */
2499&(nid_objs[415]),/* OBJ_X9_62_prime256v1 1 2 840 10045 3 1 7 */
2500&(nid_objs[269]),/* OBJ_id_pkix1_explicit_88 1 3 6 1 5 5 7 0 1 */
2501&(nid_objs[270]),/* OBJ_id_pkix1_implicit_88 1 3 6 1 5 5 7 0 2 */
2502&(nid_objs[271]),/* OBJ_id_pkix1_explicit_93 1 3 6 1 5 5 7 0 3 */
2503&(nid_objs[272]),/* OBJ_id_pkix1_implicit_93 1 3 6 1 5 5 7 0 4 */
2504&(nid_objs[273]),/* OBJ_id_mod_crmf 1 3 6 1 5 5 7 0 5 */
2505&(nid_objs[274]),/* OBJ_id_mod_cmc 1 3 6 1 5 5 7 0 6 */
2506&(nid_objs[275]),/* OBJ_id_mod_kea_profile_88 1 3 6 1 5 5 7 0 7 */
2507&(nid_objs[276]),/* OBJ_id_mod_kea_profile_93 1 3 6 1 5 5 7 0 8 */
2508&(nid_objs[277]),/* OBJ_id_mod_cmp 1 3 6 1 5 5 7 0 9 */
2509&(nid_objs[278]),/* OBJ_id_mod_qualified_cert_88 1 3 6 1 5 5 7 0 10 */
2510&(nid_objs[279]),/* OBJ_id_mod_qualified_cert_93 1 3 6 1 5 5 7 0 11 */
2511&(nid_objs[280]),/* OBJ_id_mod_attribute_cert 1 3 6 1 5 5 7 0 12 */
2512&(nid_objs[281]),/* OBJ_id_mod_timestamp_protocol 1 3 6 1 5 5 7 0 13 */
2513&(nid_objs[282]),/* OBJ_id_mod_ocsp 1 3 6 1 5 5 7 0 14 */
2514&(nid_objs[283]),/* OBJ_id_mod_dvcs 1 3 6 1 5 5 7 0 15 */
2515&(nid_objs[284]),/* OBJ_id_mod_cmp2000 1 3 6 1 5 5 7 0 16 */
2516&(nid_objs[177]),/* OBJ_info_access 1 3 6 1 5 5 7 1 1 */
2517&(nid_objs[285]),/* OBJ_biometricInfo 1 3 6 1 5 5 7 1 2 */
2518&(nid_objs[286]),/* OBJ_qcStatements 1 3 6 1 5 5 7 1 3 */
2519&(nid_objs[287]),/* OBJ_ac_auditEntity 1 3 6 1 5 5 7 1 4 */
2520&(nid_objs[288]),/* OBJ_ac_targeting 1 3 6 1 5 5 7 1 5 */
2521&(nid_objs[289]),/* OBJ_aaControls 1 3 6 1 5 5 7 1 6 */
2522&(nid_objs[290]),/* OBJ_sbqp_ipAddrBlock 1 3 6 1 5 5 7 1 7 */
2523&(nid_objs[291]),/* OBJ_sbqp_autonomousSysNum 1 3 6 1 5 5 7 1 8 */
2524&(nid_objs[292]),/* OBJ_sbqp_routerIdentifier 1 3 6 1 5 5 7 1 9 */
2525&(nid_objs[397]),/* OBJ_ac_proxying 1 3 6 1 5 5 7 1 10 */
2526&(nid_objs[398]),/* OBJ_sinfo_access 1 3 6 1 5 5 7 1 11 */
2527&(nid_objs[164]),/* OBJ_id_qt_cps 1 3 6 1 5 5 7 2 1 */
2528&(nid_objs[165]),/* OBJ_id_qt_unotice 1 3 6 1 5 5 7 2 2 */
2529&(nid_objs[293]),/* OBJ_textNotice 1 3 6 1 5 5 7 2 3 */
2530&(nid_objs[129]),/* OBJ_server_auth 1 3 6 1 5 5 7 3 1 */
2531&(nid_objs[130]),/* OBJ_client_auth 1 3 6 1 5 5 7 3 2 */
2532&(nid_objs[131]),/* OBJ_code_sign 1 3 6 1 5 5 7 3 3 */
2533&(nid_objs[132]),/* OBJ_email_protect 1 3 6 1 5 5 7 3 4 */
2534&(nid_objs[294]),/* OBJ_ipsecEndSystem 1 3 6 1 5 5 7 3 5 */
2535&(nid_objs[295]),/* OBJ_ipsecTunnel 1 3 6 1 5 5 7 3 6 */
2536&(nid_objs[296]),/* OBJ_ipsecUser 1 3 6 1 5 5 7 3 7 */
2537&(nid_objs[133]),/* OBJ_time_stamp 1 3 6 1 5 5 7 3 8 */
2538&(nid_objs[180]),/* OBJ_OCSP_sign 1 3 6 1 5 5 7 3 9 */
2539&(nid_objs[297]),/* OBJ_dvcs 1 3 6 1 5 5 7 3 10 */
2540&(nid_objs[298]),/* OBJ_id_it_caProtEncCert 1 3 6 1 5 5 7 4 1 */
2541&(nid_objs[299]),/* OBJ_id_it_signKeyPairTypes 1 3 6 1 5 5 7 4 2 */
2542&(nid_objs[300]),/* OBJ_id_it_encKeyPairTypes 1 3 6 1 5 5 7 4 3 */
2543&(nid_objs[301]),/* OBJ_id_it_preferredSymmAlg 1 3 6 1 5 5 7 4 4 */
2544&(nid_objs[302]),/* OBJ_id_it_caKeyUpdateInfo 1 3 6 1 5 5 7 4 5 */
2545&(nid_objs[303]),/* OBJ_id_it_currentCRL 1 3 6 1 5 5 7 4 6 */
2546&(nid_objs[304]),/* OBJ_id_it_unsupportedOIDs 1 3 6 1 5 5 7 4 7 */
2547&(nid_objs[305]),/* OBJ_id_it_subscriptionRequest 1 3 6 1 5 5 7 4 8 */
2548&(nid_objs[306]),/* OBJ_id_it_subscriptionResponse 1 3 6 1 5 5 7 4 9 */
2549&(nid_objs[307]),/* OBJ_id_it_keyPairParamReq 1 3 6 1 5 5 7 4 10 */
2550&(nid_objs[308]),/* OBJ_id_it_keyPairParamRep 1 3 6 1 5 5 7 4 11 */
2551&(nid_objs[309]),/* OBJ_id_it_revPassphrase 1 3 6 1 5 5 7 4 12 */
2552&(nid_objs[310]),/* OBJ_id_it_implicitConfirm 1 3 6 1 5 5 7 4 13 */
2553&(nid_objs[311]),/* OBJ_id_it_confirmWaitTime 1 3 6 1 5 5 7 4 14 */
2554&(nid_objs[312]),/* OBJ_id_it_origPKIMessage 1 3 6 1 5 5 7 4 15 */
2555&(nid_objs[313]),/* OBJ_id_regCtrl 1 3 6 1 5 5 7 5 1 */
2556&(nid_objs[314]),/* OBJ_id_regInfo 1 3 6 1 5 5 7 5 2 */
2557&(nid_objs[323]),/* OBJ_id_alg_des40 1 3 6 1 5 5 7 6 1 */
2558&(nid_objs[324]),/* OBJ_id_alg_noSignature 1 3 6 1 5 5 7 6 2 */
2559&(nid_objs[325]),/* OBJ_id_alg_dh_sig_hmac_sha1 1 3 6 1 5 5 7 6 3 */
2560&(nid_objs[326]),/* OBJ_id_alg_dh_pop 1 3 6 1 5 5 7 6 4 */
2561&(nid_objs[327]),/* OBJ_id_cmc_statusInfo 1 3 6 1 5 5 7 7 1 */
2562&(nid_objs[328]),/* OBJ_id_cmc_identification 1 3 6 1 5 5 7 7 2 */
2563&(nid_objs[329]),/* OBJ_id_cmc_identityProof 1 3 6 1 5 5 7 7 3 */
2564&(nid_objs[330]),/* OBJ_id_cmc_dataReturn 1 3 6 1 5 5 7 7 4 */
2565&(nid_objs[331]),/* OBJ_id_cmc_transactionId 1 3 6 1 5 5 7 7 5 */
2566&(nid_objs[332]),/* OBJ_id_cmc_senderNonce 1 3 6 1 5 5 7 7 6 */
2567&(nid_objs[333]),/* OBJ_id_cmc_recipientNonce 1 3 6 1 5 5 7 7 7 */
2568&(nid_objs[334]),/* OBJ_id_cmc_addExtensions 1 3 6 1 5 5 7 7 8 */
2569&(nid_objs[335]),/* OBJ_id_cmc_encryptedPOP 1 3 6 1 5 5 7 7 9 */
2570&(nid_objs[336]),/* OBJ_id_cmc_decryptedPOP 1 3 6 1 5 5 7 7 10 */
2571&(nid_objs[337]),/* OBJ_id_cmc_lraPOPWitness 1 3 6 1 5 5 7 7 11 */
2572&(nid_objs[338]),/* OBJ_id_cmc_getCert 1 3 6 1 5 5 7 7 15 */
2573&(nid_objs[339]),/* OBJ_id_cmc_getCRL 1 3 6 1 5 5 7 7 16 */
2574&(nid_objs[340]),/* OBJ_id_cmc_revokeRequest 1 3 6 1 5 5 7 7 17 */
2575&(nid_objs[341]),/* OBJ_id_cmc_regInfo 1 3 6 1 5 5 7 7 18 */
2576&(nid_objs[342]),/* OBJ_id_cmc_responseInfo 1 3 6 1 5 5 7 7 19 */
2577&(nid_objs[343]),/* OBJ_id_cmc_queryPending 1 3 6 1 5 5 7 7 21 */
2578&(nid_objs[344]),/* OBJ_id_cmc_popLinkRandom 1 3 6 1 5 5 7 7 22 */
2579&(nid_objs[345]),/* OBJ_id_cmc_popLinkWitness 1 3 6 1 5 5 7 7 23 */
2580&(nid_objs[346]),/* OBJ_id_cmc_confirmCertAcceptance 1 3 6 1 5 5 7 7 24 */
2581&(nid_objs[347]),/* OBJ_id_on_personalData 1 3 6 1 5 5 7 8 1 */
2582&(nid_objs[348]),/* OBJ_id_pda_dateOfBirth 1 3 6 1 5 5 7 9 1 */
2583&(nid_objs[349]),/* OBJ_id_pda_placeOfBirth 1 3 6 1 5 5 7 9 2 */
2584&(nid_objs[351]),/* OBJ_id_pda_gender 1 3 6 1 5 5 7 9 3 */
2585&(nid_objs[352]),/* OBJ_id_pda_countryOfCitizenship 1 3 6 1 5 5 7 9 4 */
2586&(nid_objs[353]),/* OBJ_id_pda_countryOfResidence 1 3 6 1 5 5 7 9 5 */
2587&(nid_objs[354]),/* OBJ_id_aca_authenticationInfo 1 3 6 1 5 5 7 10 1 */
2588&(nid_objs[355]),/* OBJ_id_aca_accessIdentity 1 3 6 1 5 5 7 10 2 */
2589&(nid_objs[356]),/* OBJ_id_aca_chargingIdentity 1 3 6 1 5 5 7 10 3 */
2590&(nid_objs[357]),/* OBJ_id_aca_group 1 3 6 1 5 5 7 10 4 */
2591&(nid_objs[358]),/* OBJ_id_aca_role 1 3 6 1 5 5 7 10 5 */
2592&(nid_objs[399]),/* OBJ_id_aca_encAttrs 1 3 6 1 5 5 7 10 6 */
2593&(nid_objs[359]),/* OBJ_id_qcs_pkixQCSyntax_v1 1 3 6 1 5 5 7 11 1 */
2594&(nid_objs[360]),/* OBJ_id_cct_crs 1 3 6 1 5 5 7 12 1 */
2595&(nid_objs[361]),/* OBJ_id_cct_PKIData 1 3 6 1 5 5 7 12 2 */
2596&(nid_objs[362]),/* OBJ_id_cct_PKIResponse 1 3 6 1 5 5 7 12 3 */
2597&(nid_objs[178]),/* OBJ_ad_OCSP 1 3 6 1 5 5 7 48 1 */
2598&(nid_objs[179]),/* OBJ_ad_ca_issuers 1 3 6 1 5 5 7 48 2 */
2599&(nid_objs[363]),/* OBJ_ad_timeStamping 1 3 6 1 5 5 7 48 3 */
2600&(nid_objs[364]),/* OBJ_ad_dvcs 1 3 6 1 5 5 7 48 4 */
2601&(nid_objs[58]),/* OBJ_netscape_cert_extension 2 16 840 1 113730 1 */
2602&(nid_objs[59]),/* OBJ_netscape_data_type 2 16 840 1 113730 2 */
2603&(nid_objs[438]),/* OBJ_pilotAttributeType 0 9 2342 19200300 100 1 */
2604&(nid_objs[439]),/* OBJ_pilotAttributeSyntax 0 9 2342 19200300 100 3 */
2605&(nid_objs[440]),/* OBJ_pilotObjectClass 0 9 2342 19200300 100 4 */
2606&(nid_objs[441]),/* OBJ_pilotGroups 0 9 2342 19200300 100 10 */
2607&(nid_objs[108]),/* OBJ_cast5_cbc 1 2 840 113533 7 66 10 */
2608&(nid_objs[112]),/* OBJ_pbeWithMD5AndCast5_CBC 1 2 840 113533 7 66 12 */
2609&(nid_objs[ 6]),/* OBJ_rsaEncryption 1 2 840 113549 1 1 1 */
2610&(nid_objs[ 7]),/* OBJ_md2WithRSAEncryption 1 2 840 113549 1 1 2 */
2611&(nid_objs[396]),/* OBJ_md4WithRSAEncryption 1 2 840 113549 1 1 3 */
2612&(nid_objs[ 8]),/* OBJ_md5WithRSAEncryption 1 2 840 113549 1 1 4 */
2613&(nid_objs[65]),/* OBJ_sha1WithRSAEncryption 1 2 840 113549 1 1 5 */
2614&(nid_objs[28]),/* OBJ_dhKeyAgreement 1 2 840 113549 1 3 1 */
2615&(nid_objs[ 9]),/* OBJ_pbeWithMD2AndDES_CBC 1 2 840 113549 1 5 1 */
2616&(nid_objs[10]),/* OBJ_pbeWithMD5AndDES_CBC 1 2 840 113549 1 5 3 */
2617&(nid_objs[168]),/* OBJ_pbeWithMD2AndRC2_CBC 1 2 840 113549 1 5 4 */
2618&(nid_objs[169]),/* OBJ_pbeWithMD5AndRC2_CBC 1 2 840 113549 1 5 6 */
2619&(nid_objs[170]),/* OBJ_pbeWithSHA1AndDES_CBC 1 2 840 113549 1 5 10 */
2620&(nid_objs[68]),/* OBJ_pbeWithSHA1AndRC2_CBC 1 2 840 113549 1 5 11 */
2621&(nid_objs[69]),/* OBJ_id_pbkdf2 1 2 840 113549 1 5 12 */
2622&(nid_objs[161]),/* OBJ_pbes2 1 2 840 113549 1 5 13 */
2623&(nid_objs[162]),/* OBJ_pbmac1 1 2 840 113549 1 5 14 */
2624&(nid_objs[21]),/* OBJ_pkcs7_data 1 2 840 113549 1 7 1 */
2625&(nid_objs[22]),/* OBJ_pkcs7_signed 1 2 840 113549 1 7 2 */
2626&(nid_objs[23]),/* OBJ_pkcs7_enveloped 1 2 840 113549 1 7 3 */
2627&(nid_objs[24]),/* OBJ_pkcs7_signedAndEnveloped 1 2 840 113549 1 7 4 */
2628&(nid_objs[25]),/* OBJ_pkcs7_digest 1 2 840 113549 1 7 5 */
2629&(nid_objs[26]),/* OBJ_pkcs7_encrypted 1 2 840 113549 1 7 6 */
2630&(nid_objs[48]),/* OBJ_pkcs9_emailAddress 1 2 840 113549 1 9 1 */
2631&(nid_objs[49]),/* OBJ_pkcs9_unstructuredName 1 2 840 113549 1 9 2 */
2632&(nid_objs[50]),/* OBJ_pkcs9_contentType 1 2 840 113549 1 9 3 */
2633&(nid_objs[51]),/* OBJ_pkcs9_messageDigest 1 2 840 113549 1 9 4 */
2634&(nid_objs[52]),/* OBJ_pkcs9_signingTime 1 2 840 113549 1 9 5 */
2635&(nid_objs[53]),/* OBJ_pkcs9_countersignature 1 2 840 113549 1 9 6 */
2636&(nid_objs[54]),/* OBJ_pkcs9_challengePassword 1 2 840 113549 1 9 7 */
2637&(nid_objs[55]),/* OBJ_pkcs9_unstructuredAddress 1 2 840 113549 1 9 8 */
2638&(nid_objs[56]),/* OBJ_pkcs9_extCertAttributes 1 2 840 113549 1 9 9 */
2639&(nid_objs[172]),/* OBJ_ext_req 1 2 840 113549 1 9 14 */
2640&(nid_objs[167]),/* OBJ_SMIMECapabilities 1 2 840 113549 1 9 15 */
2641&(nid_objs[188]),/* OBJ_SMIME 1 2 840 113549 1 9 16 */
2642&(nid_objs[156]),/* OBJ_friendlyName 1 2 840 113549 1 9 20 */
2643&(nid_objs[157]),/* OBJ_localKeyID 1 2 840 113549 1 9 21 */
2644&(nid_objs[417]),/* OBJ_ms_csp_name 1 3 6 1 4 1 311 17 1 */
2645&(nid_objs[390]),/* OBJ_dcObject 1 3 6 1 4 1 1466 344 */
2646&(nid_objs[91]),/* OBJ_bf_cbc 1 3 6 1 4 1 3029 1 2 */
2647&(nid_objs[315]),/* OBJ_id_regCtrl_regToken 1 3 6 1 5 5 7 5 1 1 */
2648&(nid_objs[316]),/* OBJ_id_regCtrl_authenticator 1 3 6 1 5 5 7 5 1 2 */
2649&(nid_objs[317]),/* OBJ_id_regCtrl_pkiPublicationInfo 1 3 6 1 5 5 7 5 1 3 */
2650&(nid_objs[318]),/* OBJ_id_regCtrl_pkiArchiveOptions 1 3 6 1 5 5 7 5 1 4 */
2651&(nid_objs[319]),/* OBJ_id_regCtrl_oldCertID 1 3 6 1 5 5 7 5 1 5 */
2652&(nid_objs[320]),/* OBJ_id_regCtrl_protocolEncrKey 1 3 6 1 5 5 7 5 1 6 */
2653&(nid_objs[321]),/* OBJ_id_regInfo_utf8Pairs 1 3 6 1 5 5 7 5 2 1 */
2654&(nid_objs[322]),/* OBJ_id_regInfo_certReq 1 3 6 1 5 5 7 5 2 2 */
2655&(nid_objs[365]),/* OBJ_id_pkix_OCSP_basic 1 3 6 1 5 5 7 48 1 1 */
2656&(nid_objs[366]),/* OBJ_id_pkix_OCSP_Nonce 1 3 6 1 5 5 7 48 1 2 */
2657&(nid_objs[367]),/* OBJ_id_pkix_OCSP_CrlID 1 3 6 1 5 5 7 48 1 3 */
2658&(nid_objs[368]),/* OBJ_id_pkix_OCSP_acceptableResponses 1 3 6 1 5 5 7 48 1 4 */
2659&(nid_objs[369]),/* OBJ_id_pkix_OCSP_noCheck 1 3 6 1 5 5 7 48 1 5 */
2660&(nid_objs[370]),/* OBJ_id_pkix_OCSP_archiveCutoff 1 3 6 1 5 5 7 48 1 6 */
2661&(nid_objs[371]),/* OBJ_id_pkix_OCSP_serviceLocator 1 3 6 1 5 5 7 48 1 7 */
2662&(nid_objs[372]),/* OBJ_id_pkix_OCSP_extendedStatus 1 3 6 1 5 5 7 48 1 8 */
2663&(nid_objs[373]),/* OBJ_id_pkix_OCSP_valid 1 3 6 1 5 5 7 48 1 9 */
2664&(nid_objs[374]),/* OBJ_id_pkix_OCSP_path 1 3 6 1 5 5 7 48 1 10 */
2665&(nid_objs[375]),/* OBJ_id_pkix_OCSP_trustRoot 1 3 6 1 5 5 7 48 1 11 */
2666&(nid_objs[418]),/* OBJ_aes_128_ecb 2 16 840 1 101 3 4 1 1 */
2667&(nid_objs[419]),/* OBJ_aes_128_cbc 2 16 840 1 101 3 4 1 2 */
2668&(nid_objs[420]),/* OBJ_aes_128_ofb128 2 16 840 1 101 3 4 1 3 */
2669&(nid_objs[421]),/* OBJ_aes_128_cfb128 2 16 840 1 101 3 4 1 4 */
2670&(nid_objs[422]),/* OBJ_aes_192_ecb 2 16 840 1 101 3 4 1 21 */
2671&(nid_objs[423]),/* OBJ_aes_192_cbc 2 16 840 1 101 3 4 1 22 */
2672&(nid_objs[424]),/* OBJ_aes_192_ofb128 2 16 840 1 101 3 4 1 23 */
2673&(nid_objs[425]),/* OBJ_aes_192_cfb128 2 16 840 1 101 3 4 1 24 */
2674&(nid_objs[426]),/* OBJ_aes_256_ecb 2 16 840 1 101 3 4 1 41 */
2675&(nid_objs[427]),/* OBJ_aes_256_cbc 2 16 840 1 101 3 4 1 42 */
2676&(nid_objs[428]),/* OBJ_aes_256_ofb128 2 16 840 1 101 3 4 1 43 */
2677&(nid_objs[429]),/* OBJ_aes_256_cfb128 2 16 840 1 101 3 4 1 44 */
2678&(nid_objs[71]),/* OBJ_netscape_cert_type 2 16 840 1 113730 1 1 */
2679&(nid_objs[72]),/* OBJ_netscape_base_url 2 16 840 1 113730 1 2 */
2680&(nid_objs[73]),/* OBJ_netscape_revocation_url 2 16 840 1 113730 1 3 */
2681&(nid_objs[74]),/* OBJ_netscape_ca_revocation_url 2 16 840 1 113730 1 4 */
2682&(nid_objs[75]),/* OBJ_netscape_renewal_url 2 16 840 1 113730 1 7 */
2683&(nid_objs[76]),/* OBJ_netscape_ca_policy_url 2 16 840 1 113730 1 8 */
2684&(nid_objs[77]),/* OBJ_netscape_ssl_server_name 2 16 840 1 113730 1 12 */
2685&(nid_objs[78]),/* OBJ_netscape_comment 2 16 840 1 113730 1 13 */
2686&(nid_objs[79]),/* OBJ_netscape_cert_sequence 2 16 840 1 113730 2 5 */
2687&(nid_objs[139]),/* OBJ_ns_sgc 2 16 840 1 113730 4 1 */
2688&(nid_objs[458]),/* OBJ_userId 0 9 2342 19200300 100 1 1 */
2689&(nid_objs[459]),/* OBJ_textEncodedORAddress 0 9 2342 19200300 100 1 2 */
2690&(nid_objs[460]),/* OBJ_rfc822Mailbox 0 9 2342 19200300 100 1 3 */
2691&(nid_objs[461]),/* OBJ_info 0 9 2342 19200300 100 1 4 */
2692&(nid_objs[462]),/* OBJ_favouriteDrink 0 9 2342 19200300 100 1 5 */
2693&(nid_objs[463]),/* OBJ_roomNumber 0 9 2342 19200300 100 1 6 */
2694&(nid_objs[464]),/* OBJ_photo 0 9 2342 19200300 100 1 7 */
2695&(nid_objs[465]),/* OBJ_userClass 0 9 2342 19200300 100 1 8 */
2696&(nid_objs[466]),/* OBJ_host 0 9 2342 19200300 100 1 9 */
2697&(nid_objs[467]),/* OBJ_manager 0 9 2342 19200300 100 1 10 */
2698&(nid_objs[468]),/* OBJ_documentIdentifier 0 9 2342 19200300 100 1 11 */
2699&(nid_objs[469]),/* OBJ_documentTitle 0 9 2342 19200300 100 1 12 */
2700&(nid_objs[470]),/* OBJ_documentVersion 0 9 2342 19200300 100 1 13 */
2701&(nid_objs[471]),/* OBJ_documentAuthor 0 9 2342 19200300 100 1 14 */
2702&(nid_objs[472]),/* OBJ_documentLocation 0 9 2342 19200300 100 1 15 */
2703&(nid_objs[473]),/* OBJ_homeTelephoneNumber 0 9 2342 19200300 100 1 20 */
2704&(nid_objs[474]),/* OBJ_secretary 0 9 2342 19200300 100 1 21 */
2705&(nid_objs[475]),/* OBJ_otherMailbox 0 9 2342 19200300 100 1 22 */
2706&(nid_objs[476]),/* OBJ_lastModifiedTime 0 9 2342 19200300 100 1 23 */
2707&(nid_objs[477]),/* OBJ_lastModifiedBy 0 9 2342 19200300 100 1 24 */
2708&(nid_objs[391]),/* OBJ_domainComponent 0 9 2342 19200300 100 1 25 */
2709&(nid_objs[478]),/* OBJ_aRecord 0 9 2342 19200300 100 1 26 */
2710&(nid_objs[479]),/* OBJ_pilotAttributeType27 0 9 2342 19200300 100 1 27 */
2711&(nid_objs[480]),/* OBJ_mXRecord 0 9 2342 19200300 100 1 28 */
2712&(nid_objs[481]),/* OBJ_nSRecord 0 9 2342 19200300 100 1 29 */
2713&(nid_objs[482]),/* OBJ_sOARecord 0 9 2342 19200300 100 1 30 */
2714&(nid_objs[483]),/* OBJ_cNAMERecord 0 9 2342 19200300 100 1 31 */
2715&(nid_objs[484]),/* OBJ_associatedDomain 0 9 2342 19200300 100 1 37 */
2716&(nid_objs[485]),/* OBJ_associatedName 0 9 2342 19200300 100 1 38 */
2717&(nid_objs[486]),/* OBJ_homePostalAddress 0 9 2342 19200300 100 1 39 */
2718&(nid_objs[487]),/* OBJ_personalTitle 0 9 2342 19200300 100 1 40 */
2719&(nid_objs[488]),/* OBJ_mobileTelephoneNumber 0 9 2342 19200300 100 1 41 */
2720&(nid_objs[489]),/* OBJ_pagerTelephoneNumber 0 9 2342 19200300 100 1 42 */
2721&(nid_objs[490]),/* OBJ_friendlyCountryName 0 9 2342 19200300 100 1 43 */
2722&(nid_objs[491]),/* OBJ_organizationalStatus 0 9 2342 19200300 100 1 45 */
2723&(nid_objs[492]),/* OBJ_janetMailbox 0 9 2342 19200300 100 1 46 */
2724&(nid_objs[493]),/* OBJ_mailPreferenceOption 0 9 2342 19200300 100 1 47 */
2725&(nid_objs[494]),/* OBJ_buildingName 0 9 2342 19200300 100 1 48 */
2726&(nid_objs[495]),/* OBJ_dSAQuality 0 9 2342 19200300 100 1 49 */
2727&(nid_objs[496]),/* OBJ_singleLevelQuality 0 9 2342 19200300 100 1 50 */
2728&(nid_objs[497]),/* OBJ_subtreeMinimumQuality 0 9 2342 19200300 100 1 51 */
2729&(nid_objs[498]),/* OBJ_subtreeMaximumQuality 0 9 2342 19200300 100 1 52 */
2730&(nid_objs[499]),/* OBJ_personalSignature 0 9 2342 19200300 100 1 53 */
2731&(nid_objs[500]),/* OBJ_dITRedirect 0 9 2342 19200300 100 1 54 */
2732&(nid_objs[501]),/* OBJ_audio 0 9 2342 19200300 100 1 55 */
2733&(nid_objs[502]),/* OBJ_documentPublisher 0 9 2342 19200300 100 1 56 */
2734&(nid_objs[442]),/* OBJ_iA5StringSyntax 0 9 2342 19200300 100 3 4 */
2735&(nid_objs[443]),/* OBJ_caseIgnoreIA5StringSyntax 0 9 2342 19200300 100 3 5 */
2736&(nid_objs[444]),/* OBJ_pilotObject 0 9 2342 19200300 100 4 3 */
2737&(nid_objs[445]),/* OBJ_pilotPerson 0 9 2342 19200300 100 4 4 */
2738&(nid_objs[446]),/* OBJ_account 0 9 2342 19200300 100 4 5 */
2739&(nid_objs[447]),/* OBJ_document 0 9 2342 19200300 100 4 6 */
2740&(nid_objs[448]),/* OBJ_room 0 9 2342 19200300 100 4 7 */
2741&(nid_objs[449]),/* OBJ_documentSeries 0 9 2342 19200300 100 4 9 */
2742&(nid_objs[392]),/* OBJ_Domain 0 9 2342 19200300 100 4 13 */
2743&(nid_objs[450]),/* OBJ_rFC822localPart 0 9 2342 19200300 100 4 14 */
2744&(nid_objs[451]),/* OBJ_dNSDomain 0 9 2342 19200300 100 4 15 */
2745&(nid_objs[452]),/* OBJ_domainRelatedObject 0 9 2342 19200300 100 4 17 */
2746&(nid_objs[453]),/* OBJ_friendlyCountry 0 9 2342 19200300 100 4 18 */
2747&(nid_objs[454]),/* OBJ_simpleSecurityObject 0 9 2342 19200300 100 4 19 */
2748&(nid_objs[455]),/* OBJ_pilotOrganization 0 9 2342 19200300 100 4 20 */
2749&(nid_objs[456]),/* OBJ_pilotDSA 0 9 2342 19200300 100 4 21 */
2750&(nid_objs[457]),/* OBJ_qualityLabelledData 0 9 2342 19200300 100 4 22 */
2751&(nid_objs[189]),/* OBJ_id_smime_mod 1 2 840 113549 1 9 16 0 */
2752&(nid_objs[190]),/* OBJ_id_smime_ct 1 2 840 113549 1 9 16 1 */
2753&(nid_objs[191]),/* OBJ_id_smime_aa 1 2 840 113549 1 9 16 2 */
2754&(nid_objs[192]),/* OBJ_id_smime_alg 1 2 840 113549 1 9 16 3 */
2755&(nid_objs[193]),/* OBJ_id_smime_cd 1 2 840 113549 1 9 16 4 */
2756&(nid_objs[194]),/* OBJ_id_smime_spq 1 2 840 113549 1 9 16 5 */
2757&(nid_objs[195]),/* OBJ_id_smime_cti 1 2 840 113549 1 9 16 6 */
2758&(nid_objs[158]),/* OBJ_x509Certificate 1 2 840 113549 1 9 22 1 */
2759&(nid_objs[159]),/* OBJ_sdsiCertificate 1 2 840 113549 1 9 22 2 */
2760&(nid_objs[160]),/* OBJ_x509Crl 1 2 840 113549 1 9 23 1 */
2761&(nid_objs[144]),/* OBJ_pbe_WithSHA1And128BitRC4 1 2 840 113549 1 12 1 1 */
2762&(nid_objs[145]),/* OBJ_pbe_WithSHA1And40BitRC4 1 2 840 113549 1 12 1 2 */
2763&(nid_objs[146]),/* OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC 1 2 840 113549 1 12 1 3 */
2764&(nid_objs[147]),/* OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC 1 2 840 113549 1 12 1 4 */
2765&(nid_objs[148]),/* OBJ_pbe_WithSHA1And128BitRC2_CBC 1 2 840 113549 1 12 1 5 */
2766&(nid_objs[149]),/* OBJ_pbe_WithSHA1And40BitRC2_CBC 1 2 840 113549 1 12 1 6 */
2767&(nid_objs[171]),/* OBJ_ms_ext_req 1 3 6 1 4 1 311 2 1 14 */
2768&(nid_objs[134]),/* OBJ_ms_code_ind 1 3 6 1 4 1 311 2 1 21 */
2769&(nid_objs[135]),/* OBJ_ms_code_com 1 3 6 1 4 1 311 2 1 22 */
2770&(nid_objs[136]),/* OBJ_ms_ctl_sign 1 3 6 1 4 1 311 10 3 1 */
2771&(nid_objs[137]),/* OBJ_ms_sgc 1 3 6 1 4 1 311 10 3 3 */
2772&(nid_objs[138]),/* OBJ_ms_efs 1 3 6 1 4 1 311 10 3 4 */
2773&(nid_objs[196]),/* OBJ_id_smime_mod_cms 1 2 840 113549 1 9 16 0 1 */
2774&(nid_objs[197]),/* OBJ_id_smime_mod_ess 1 2 840 113549 1 9 16 0 2 */
2775&(nid_objs[198]),/* OBJ_id_smime_mod_oid 1 2 840 113549 1 9 16 0 3 */
2776&(nid_objs[199]),/* OBJ_id_smime_mod_msg_v3 1 2 840 113549 1 9 16 0 4 */
2777&(nid_objs[200]),/* OBJ_id_smime_mod_ets_eSignature_88 1 2 840 113549 1 9 16 0 5 */
2778&(nid_objs[201]),/* OBJ_id_smime_mod_ets_eSignature_97 1 2 840 113549 1 9 16 0 6 */
2779&(nid_objs[202]),/* OBJ_id_smime_mod_ets_eSigPolicy_88 1 2 840 113549 1 9 16 0 7 */
2780&(nid_objs[203]),/* OBJ_id_smime_mod_ets_eSigPolicy_97 1 2 840 113549 1 9 16 0 8 */
2781&(nid_objs[204]),/* OBJ_id_smime_ct_receipt 1 2 840 113549 1 9 16 1 1 */
2782&(nid_objs[205]),/* OBJ_id_smime_ct_authData 1 2 840 113549 1 9 16 1 2 */
2783&(nid_objs[206]),/* OBJ_id_smime_ct_publishCert 1 2 840 113549 1 9 16 1 3 */
2784&(nid_objs[207]),/* OBJ_id_smime_ct_TSTInfo 1 2 840 113549 1 9 16 1 4 */
2785&(nid_objs[208]),/* OBJ_id_smime_ct_TDTInfo 1 2 840 113549 1 9 16 1 5 */
2786&(nid_objs[209]),/* OBJ_id_smime_ct_contentInfo 1 2 840 113549 1 9 16 1 6 */
2787&(nid_objs[210]),/* OBJ_id_smime_ct_DVCSRequestData 1 2 840 113549 1 9 16 1 7 */
2788&(nid_objs[211]),/* OBJ_id_smime_ct_DVCSResponseData 1 2 840 113549 1 9 16 1 8 */
2789&(nid_objs[212]),/* OBJ_id_smime_aa_receiptRequest 1 2 840 113549 1 9 16 2 1 */
2790&(nid_objs[213]),/* OBJ_id_smime_aa_securityLabel 1 2 840 113549 1 9 16 2 2 */
2791&(nid_objs[214]),/* OBJ_id_smime_aa_mlExpandHistory 1 2 840 113549 1 9 16 2 3 */
2792&(nid_objs[215]),/* OBJ_id_smime_aa_contentHint 1 2 840 113549 1 9 16 2 4 */
2793&(nid_objs[216]),/* OBJ_id_smime_aa_msgSigDigest 1 2 840 113549 1 9 16 2 5 */
2794&(nid_objs[217]),/* OBJ_id_smime_aa_encapContentType 1 2 840 113549 1 9 16 2 6 */
2795&(nid_objs[218]),/* OBJ_id_smime_aa_contentIdentifier 1 2 840 113549 1 9 16 2 7 */
2796&(nid_objs[219]),/* OBJ_id_smime_aa_macValue 1 2 840 113549 1 9 16 2 8 */
2797&(nid_objs[220]),/* OBJ_id_smime_aa_equivalentLabels 1 2 840 113549 1 9 16 2 9 */
2798&(nid_objs[221]),/* OBJ_id_smime_aa_contentReference 1 2 840 113549 1 9 16 2 10 */
2799&(nid_objs[222]),/* OBJ_id_smime_aa_encrypKeyPref 1 2 840 113549 1 9 16 2 11 */
2800&(nid_objs[223]),/* OBJ_id_smime_aa_signingCertificate 1 2 840 113549 1 9 16 2 12 */
2801&(nid_objs[224]),/* OBJ_id_smime_aa_smimeEncryptCerts 1 2 840 113549 1 9 16 2 13 */
2802&(nid_objs[225]),/* OBJ_id_smime_aa_timeStampToken 1 2 840 113549 1 9 16 2 14 */
2803&(nid_objs[226]),/* OBJ_id_smime_aa_ets_sigPolicyId 1 2 840 113549 1 9 16 2 15 */
2804&(nid_objs[227]),/* OBJ_id_smime_aa_ets_commitmentType 1 2 840 113549 1 9 16 2 16 */
2805&(nid_objs[228]),/* OBJ_id_smime_aa_ets_signerLocation 1 2 840 113549 1 9 16 2 17 */
2806&(nid_objs[229]),/* OBJ_id_smime_aa_ets_signerAttr 1 2 840 113549 1 9 16 2 18 */
2807&(nid_objs[230]),/* OBJ_id_smime_aa_ets_otherSigCert 1 2 840 113549 1 9 16 2 19 */
2808&(nid_objs[231]),/* OBJ_id_smime_aa_ets_contentTimestamp 1 2 840 113549 1 9 16 2 20 */
2809&(nid_objs[232]),/* OBJ_id_smime_aa_ets_CertificateRefs 1 2 840 113549 1 9 16 2 21 */
2810&(nid_objs[233]),/* OBJ_id_smime_aa_ets_RevocationRefs 1 2 840 113549 1 9 16 2 22 */
2811&(nid_objs[234]),/* OBJ_id_smime_aa_ets_certValues 1 2 840 113549 1 9 16 2 23 */
2812&(nid_objs[235]),/* OBJ_id_smime_aa_ets_revocationValues 1 2 840 113549 1 9 16 2 24 */
2813&(nid_objs[236]),/* OBJ_id_smime_aa_ets_escTimeStamp 1 2 840 113549 1 9 16 2 25 */
2814&(nid_objs[237]),/* OBJ_id_smime_aa_ets_certCRLTimestamp 1 2 840 113549 1 9 16 2 26 */
2815&(nid_objs[238]),/* OBJ_id_smime_aa_ets_archiveTimeStamp 1 2 840 113549 1 9 16 2 27 */
2816&(nid_objs[239]),/* OBJ_id_smime_aa_signatureType 1 2 840 113549 1 9 16 2 28 */
2817&(nid_objs[240]),/* OBJ_id_smime_aa_dvcs_dvc 1 2 840 113549 1 9 16 2 29 */
2818&(nid_objs[241]),/* OBJ_id_smime_alg_ESDHwith3DES 1 2 840 113549 1 9 16 3 1 */
2819&(nid_objs[242]),/* OBJ_id_smime_alg_ESDHwithRC2 1 2 840 113549 1 9 16 3 2 */
2820&(nid_objs[243]),/* OBJ_id_smime_alg_3DESwrap 1 2 840 113549 1 9 16 3 3 */
2821&(nid_objs[244]),/* OBJ_id_smime_alg_RC2wrap 1 2 840 113549 1 9 16 3 4 */
2822&(nid_objs[245]),/* OBJ_id_smime_alg_ESDH 1 2 840 113549 1 9 16 3 5 */
2823&(nid_objs[246]),/* OBJ_id_smime_alg_CMS3DESwrap 1 2 840 113549 1 9 16 3 6 */
2824&(nid_objs[247]),/* OBJ_id_smime_alg_CMSRC2wrap 1 2 840 113549 1 9 16 3 7 */
2825&(nid_objs[248]),/* OBJ_id_smime_cd_ldap 1 2 840 113549 1 9 16 4 1 */
2826&(nid_objs[249]),/* OBJ_id_smime_spq_ets_sqt_uri 1 2 840 113549 1 9 16 5 1 */
2827&(nid_objs[250]),/* OBJ_id_smime_spq_ets_sqt_unotice 1 2 840 113549 1 9 16 5 2 */
2828&(nid_objs[251]),/* OBJ_id_smime_cti_ets_proofOfOrigin 1 2 840 113549 1 9 16 6 1 */
2829&(nid_objs[252]),/* OBJ_id_smime_cti_ets_proofOfReceipt 1 2 840 113549 1 9 16 6 2 */
2830&(nid_objs[253]),/* OBJ_id_smime_cti_ets_proofOfDelivery 1 2 840 113549 1 9 16 6 3 */
2831&(nid_objs[254]),/* OBJ_id_smime_cti_ets_proofOfSender 1 2 840 113549 1 9 16 6 4 */
2832&(nid_objs[255]),/* OBJ_id_smime_cti_ets_proofOfApproval 1 2 840 113549 1 9 16 6 5 */
2833&(nid_objs[256]),/* OBJ_id_smime_cti_ets_proofOfCreation 1 2 840 113549 1 9 16 6 6 */
2834&(nid_objs[150]),/* OBJ_keyBag 1 2 840 113549 1 12 10 1 1 */
2835&(nid_objs[151]),/* OBJ_pkcs8ShroudedKeyBag 1 2 840 113549 1 12 10 1 2 */
2836&(nid_objs[152]),/* OBJ_certBag 1 2 840 113549 1 12 10 1 3 */
2837&(nid_objs[153]),/* OBJ_crlBag 1 2 840 113549 1 12 10 1 4 */
2838&(nid_objs[154]),/* OBJ_secretBag 1 2 840 113549 1 12 10 1 5 */
2839&(nid_objs[155]),/* OBJ_safeContentsBag 1 2 840 113549 1 12 10 1 6 */
2840&(nid_objs[34]),/* OBJ_idea_cbc 1 3 6 1 4 1 188 7 1 1 2 */
2841};
2842
diff --git a/src/lib/libcrypto/objects/obj_dat.pl b/src/lib/libcrypto/objects/obj_dat.pl
index 11066df680..5dfb84ea00 100644
--- a/src/lib/libcrypto/objects/obj_dat.pl
+++ b/src/lib/libcrypto/objects/obj_dat.pl
@@ -164,7 +164,13 @@ foreach (sort obj_cmp @a)
164 } 164 }
165 165
166print OUT <<'EOF'; 166print OUT <<'EOF';
167/* lib/obj/obj_dat.h */ 167/* crypto/objects/obj_dat.h */
168
169/* THIS FILE IS GENERATED FROM objects.h by obj_dat.pl via the
170 * following command:
171 * perl obj_dat.pl obj_mac.h obj_dat.h
172 */
173
168/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) 174/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
169 * All rights reserved. 175 * All rights reserved.
170 * 176 *
@@ -222,11 +228,6 @@ print OUT <<'EOF';
222 * [including the GNU Public Licence.] 228 * [including the GNU Public Licence.]
223 */ 229 */
224 230
225/* THIS FILE IS GENERATED FROM Objects.h by obj_dat.pl via the
226 * following command:
227 * perl obj_dat.pl objects.h obj_dat.h
228 */
229
230EOF 231EOF
231 232
232printf OUT "#define NUM_NID %d\n",$n; 233printf OUT "#define NUM_NID %d\n",$n;
diff --git a/src/lib/libcrypto/objects/obj_err.c b/src/lib/libcrypto/objects/obj_err.c
index 7aec0ed47a..80ab6855af 100644
--- a/src/lib/libcrypto/objects/obj_err.c
+++ b/src/lib/libcrypto/objects/obj_err.c
@@ -63,7 +63,7 @@
63#include <openssl/objects.h> 63#include <openssl/objects.h>
64 64
65/* BEGIN ERROR CODES */ 65/* BEGIN ERROR CODES */
66#ifndef NO_ERR 66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA OBJ_str_functs[]= 67static ERR_STRING_DATA OBJ_str_functs[]=
68 { 68 {
69{ERR_PACK(0,OBJ_F_OBJ_CREATE,0), "OBJ_create"}, 69{ERR_PACK(0,OBJ_F_OBJ_CREATE,0), "OBJ_create"},
@@ -90,7 +90,7 @@ void ERR_load_OBJ_strings(void)
90 if (init) 90 if (init)
91 { 91 {
92 init=0; 92 init=0;
93#ifndef NO_ERR 93#ifndef OPENSSL_NO_ERR
94 ERR_load_strings(ERR_LIB_OBJ,OBJ_str_functs); 94 ERR_load_strings(ERR_LIB_OBJ,OBJ_str_functs);
95 ERR_load_strings(ERR_LIB_OBJ,OBJ_str_reasons); 95 ERR_load_strings(ERR_LIB_OBJ,OBJ_str_reasons);
96#endif 96#endif
diff --git a/src/lib/libcrypto/objects/obj_lib.c b/src/lib/libcrypto/objects/obj_lib.c
index 0c71639eba..b0b0f2ff24 100644
--- a/src/lib/libcrypto/objects/obj_lib.c
+++ b/src/lib/libcrypto/objects/obj_lib.c
@@ -62,7 +62,7 @@
62#include <openssl/objects.h> 62#include <openssl/objects.h>
63#include <openssl/buffer.h> 63#include <openssl/buffer.h>
64 64
65ASN1_OBJECT *OBJ_dup(ASN1_OBJECT *o) 65ASN1_OBJECT *OBJ_dup(const ASN1_OBJECT *o)
66 { 66 {
67 ASN1_OBJECT *r; 67 ASN1_OBJECT *r;
68 int i; 68 int i;
@@ -70,7 +70,8 @@ ASN1_OBJECT *OBJ_dup(ASN1_OBJECT *o)
70 70
71 if (o == NULL) return(NULL); 71 if (o == NULL) return(NULL);
72 if (!(o->flags & ASN1_OBJECT_FLAG_DYNAMIC)) 72 if (!(o->flags & ASN1_OBJECT_FLAG_DYNAMIC))
73 return(o); 73 return((ASN1_OBJECT *)o); /* XXX: ugh! Why? What kind of
74 duplication is this??? */
74 75
75 r=ASN1_OBJECT_new(); 76 r=ASN1_OBJECT_new();
76 if (r == NULL) 77 if (r == NULL)
@@ -116,7 +117,7 @@ err:
116 return(NULL); 117 return(NULL);
117 } 118 }
118 119
119int OBJ_cmp(ASN1_OBJECT *a, ASN1_OBJECT *b) 120int OBJ_cmp(const ASN1_OBJECT *a, const ASN1_OBJECT *b)
120 { 121 {
121 int ret; 122 int ret;
122 123
diff --git a/src/lib/libcrypto/objects/obj_mac.h b/src/lib/libcrypto/objects/obj_mac.h
index 401b1e5a1b..6d77fcba3f 100644
--- a/src/lib/libcrypto/objects/obj_mac.h
+++ b/src/lib/libcrypto/objects/obj_mac.h
@@ -1,4 +1,10 @@
1/* lib/obj/obj_mac.h */ 1/* crypto/objects/obj_mac.h */
2
3/* THIS FILE IS GENERATED FROM objects.txt by objects.pl via the
4 * following command:
5 * perl objects.pl objects.txt obj_mac.num obj_mac.h
6 */
7
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) 8/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 9 * All rights reserved.
4 * 10 *
@@ -56,26 +62,40 @@
56 * [including the GNU Public Licence.] 62 * [including the GNU Public Licence.]
57 */ 63 */
58 64
59/* THIS FILE IS GENERATED FROM objects.txt by objects.pl via the
60 * following command:
61 * perl objects.pl objects.txt obj_mac.num obj_mac.h
62 */
63
64#define SN_undef "UNDEF" 65#define SN_undef "UNDEF"
65#define LN_undef "undefined" 66#define LN_undef "undefined"
66#define NID_undef 0 67#define NID_undef 0
67#define OBJ_undef 0L 68#define OBJ_undef 0L
68 69
70#define SN_ccitt "CCITT"
71#define LN_ccitt "ccitt"
72#define NID_ccitt 404
73#define OBJ_ccitt 0L
74
69#define SN_iso "ISO" 75#define SN_iso "ISO"
70#define LN_iso "iso" 76#define LN_iso "iso"
71#define NID_iso 181 77#define NID_iso 181
72#define OBJ_iso 1L 78#define OBJ_iso 1L
73 79
80#define SN_joint_iso_ccitt "JOINT-ISO-CCITT"
81#define LN_joint_iso_ccitt "joint-iso-ccitt"
82#define NID_joint_iso_ccitt 393
83#define OBJ_joint_iso_ccitt 2L
84
74#define SN_member_body "member-body" 85#define SN_member_body "member-body"
75#define LN_member_body "ISO Member Body" 86#define LN_member_body "ISO Member Body"
76#define NID_member_body 182 87#define NID_member_body 182
77#define OBJ_member_body OBJ_iso,2L 88#define OBJ_member_body OBJ_iso,2L
78 89
90#define SN_selected_attribute_types "selected-attribute-types"
91#define LN_selected_attribute_types "Selected Attribute Types"
92#define NID_selected_attribute_types 394
93#define OBJ_selected_attribute_types OBJ_joint_iso_ccitt,5L,1L,5L
94
95#define SN_clearance "clearance"
96#define NID_clearance 395
97#define OBJ_clearance OBJ_selected_attribute_types,55L
98
79#define SN_ISO_US "ISO-US" 99#define SN_ISO_US "ISO-US"
80#define LN_ISO_US "ISO US Member Body" 100#define LN_ISO_US "ISO US Member Body"
81#define NID_ISO_US 183 101#define NID_ISO_US 183
@@ -101,6 +121,67 @@
101#define NID_dsaWithSHA1 113 121#define NID_dsaWithSHA1 113
102#define OBJ_dsaWithSHA1 OBJ_X9cm,3L 122#define OBJ_dsaWithSHA1 OBJ_X9cm,3L
103 123
124#define SN_ansi_X9_62 "ansi-X9-62"
125#define LN_ansi_X9_62 "ANSI X9.62"
126#define NID_ansi_X9_62 405
127#define OBJ_ansi_X9_62 OBJ_ISO_US,10045L
128
129#define OBJ_X9_62_id_fieldType OBJ_ansi_X9_62,1L
130
131#define SN_X9_62_prime_field "prime-field"
132#define NID_X9_62_prime_field 406
133#define OBJ_X9_62_prime_field OBJ_X9_62_id_fieldType,1L
134
135#define SN_X9_62_characteristic_two_field "characteristic-two-field"
136#define NID_X9_62_characteristic_two_field 407
137#define OBJ_X9_62_characteristic_two_field OBJ_X9_62_id_fieldType,2L
138
139#define OBJ_X9_62_id_publicKeyType OBJ_ansi_X9_62,2L
140
141#define SN_X9_62_id_ecPublicKey "id-ecPublicKey"
142#define NID_X9_62_id_ecPublicKey 408
143#define OBJ_X9_62_id_ecPublicKey OBJ_X9_62_id_publicKeyType,1L
144
145#define OBJ_X9_62_ellipticCurve OBJ_ansi_X9_62,3L
146
147#define OBJ_X9_62_c_TwoCurve OBJ_X9_62_ellipticCurve,0L
148
149#define OBJ_X9_62_primeCurve OBJ_X9_62_ellipticCurve,1L
150
151#define SN_X9_62_prime192v1 "prime192v1"
152#define NID_X9_62_prime192v1 409
153#define OBJ_X9_62_prime192v1 OBJ_X9_62_primeCurve,1L
154
155#define SN_X9_62_prime192v2 "prime192v2"
156#define NID_X9_62_prime192v2 410
157#define OBJ_X9_62_prime192v2 OBJ_X9_62_primeCurve,2L
158
159#define SN_X9_62_prime192v3 "prime192v3"
160#define NID_X9_62_prime192v3 411
161#define OBJ_X9_62_prime192v3 OBJ_X9_62_primeCurve,3L
162
163#define SN_X9_62_prime239v1 "prime239v1"
164#define NID_X9_62_prime239v1 412
165#define OBJ_X9_62_prime239v1 OBJ_X9_62_primeCurve,4L
166
167#define SN_X9_62_prime239v2 "prime239v2"
168#define NID_X9_62_prime239v2 413
169#define OBJ_X9_62_prime239v2 OBJ_X9_62_primeCurve,5L
170
171#define SN_X9_62_prime239v3 "prime239v3"
172#define NID_X9_62_prime239v3 414
173#define OBJ_X9_62_prime239v3 OBJ_X9_62_primeCurve,6L
174
175#define SN_X9_62_prime256v1 "prime256v1"
176#define NID_X9_62_prime256v1 415
177#define OBJ_X9_62_prime256v1 OBJ_X9_62_primeCurve,7L
178
179#define OBJ_X9_62_id_ecSigType OBJ_ansi_X9_62,4L
180
181#define SN_ecdsa_with_SHA1 "ecdsa-with-SHA1"
182#define NID_ecdsa_with_SHA1 416
183#define OBJ_ecdsa_with_SHA1 OBJ_X9_62_id_ecSigType,1L
184
104#define SN_cast5_cbc "CAST5-CBC" 185#define SN_cast5_cbc "CAST5-CBC"
105#define LN_cast5_cbc "cast5-cbc" 186#define LN_cast5_cbc "cast5-cbc"
106#define NID_cast5_cbc 108 187#define NID_cast5_cbc 108
@@ -145,6 +226,11 @@
145#define NID_md2WithRSAEncryption 7 226#define NID_md2WithRSAEncryption 7
146#define OBJ_md2WithRSAEncryption OBJ_pkcs1,2L 227#define OBJ_md2WithRSAEncryption OBJ_pkcs1,2L
147 228
229#define SN_md4WithRSAEncryption "RSA-MD4"
230#define LN_md4WithRSAEncryption "md4WithRSAEncryption"
231#define NID_md4WithRSAEncryption 396
232#define OBJ_md4WithRSAEncryption OBJ_pkcs1,3L
233
148#define SN_md5WithRSAEncryption "RSA-MD5" 234#define SN_md5WithRSAEncryption "RSA-MD5"
149#define LN_md5WithRSAEncryption "md5WithRSAEncryption" 235#define LN_md5WithRSAEncryption "md5WithRSAEncryption"
150#define NID_md5WithRSAEncryption 8 236#define NID_md5WithRSAEncryption 8
@@ -241,7 +327,6 @@
241#define NID_pkcs9 47 327#define NID_pkcs9 47
242#define OBJ_pkcs9 OBJ_pkcs,9L 328#define OBJ_pkcs9 OBJ_pkcs,9L
243 329
244#define SN_pkcs9_emailAddress "Email"
245#define LN_pkcs9_emailAddress "emailAddress" 330#define LN_pkcs9_emailAddress "emailAddress"
246#define NID_pkcs9_emailAddress 48 331#define NID_pkcs9_emailAddress 48
247#define OBJ_pkcs9_emailAddress OBJ_pkcs9,1L 332#define OBJ_pkcs9_emailAddress OBJ_pkcs9,1L
@@ -573,6 +658,11 @@
573#define NID_localKeyID 157 658#define NID_localKeyID 157
574#define OBJ_localKeyID OBJ_pkcs9,21L 659#define OBJ_localKeyID OBJ_pkcs9,21L
575 660
661#define SN_ms_csp_name "CSPName"
662#define LN_ms_csp_name "Microsoft CSP Name"
663#define NID_ms_csp_name 417
664#define OBJ_ms_csp_name 1L,3L,6L,1L,4L,1L,311L,17L,1L
665
576#define OBJ_certTypes OBJ_pkcs9,22L 666#define OBJ_certTypes OBJ_pkcs9,22L
577 667
578#define LN_x509Certificate "x509Certificate" 668#define LN_x509Certificate "x509Certificate"
@@ -956,6 +1046,15 @@
956#define NID_sbqp_routerIdentifier 292 1046#define NID_sbqp_routerIdentifier 292
957#define OBJ_sbqp_routerIdentifier OBJ_id_pe,9L 1047#define OBJ_sbqp_routerIdentifier OBJ_id_pe,9L
958 1048
1049#define SN_ac_proxying "ac-proxying"
1050#define NID_ac_proxying 397
1051#define OBJ_ac_proxying OBJ_id_pe,10L
1052
1053#define SN_sinfo_access "subjectInfoAccess"
1054#define LN_sinfo_access "Subject Information Access"
1055#define NID_sinfo_access 398
1056#define OBJ_sinfo_access OBJ_id_pe,11L
1057
959#define SN_id_qt_cps "id-qt-cps" 1058#define SN_id_qt_cps "id-qt-cps"
960#define LN_id_qt_cps "Policy Qualifier CPS" 1059#define LN_id_qt_cps "Policy Qualifier CPS"
961#define NID_id_qt_cps 164 1060#define NID_id_qt_cps 164
@@ -1228,21 +1327,17 @@
1228#define NID_id_pda_placeOfBirth 349 1327#define NID_id_pda_placeOfBirth 349
1229#define OBJ_id_pda_placeOfBirth OBJ_id_pda,2L 1328#define OBJ_id_pda_placeOfBirth OBJ_id_pda,2L
1230 1329
1231#define SN_id_pda_pseudonym "id-pda-pseudonym"
1232#define NID_id_pda_pseudonym 350
1233#define OBJ_id_pda_pseudonym OBJ_id_pda,3L
1234
1235#define SN_id_pda_gender "id-pda-gender" 1330#define SN_id_pda_gender "id-pda-gender"
1236#define NID_id_pda_gender 351 1331#define NID_id_pda_gender 351
1237#define OBJ_id_pda_gender OBJ_id_pda,4L 1332#define OBJ_id_pda_gender OBJ_id_pda,3L
1238 1333
1239#define SN_id_pda_countryOfCitizenship "id-pda-countryOfCitizenship" 1334#define SN_id_pda_countryOfCitizenship "id-pda-countryOfCitizenship"
1240#define NID_id_pda_countryOfCitizenship 352 1335#define NID_id_pda_countryOfCitizenship 352
1241#define OBJ_id_pda_countryOfCitizenship OBJ_id_pda,5L 1336#define OBJ_id_pda_countryOfCitizenship OBJ_id_pda,4L
1242 1337
1243#define SN_id_pda_countryOfResidence "id-pda-countryOfResidence" 1338#define SN_id_pda_countryOfResidence "id-pda-countryOfResidence"
1244#define NID_id_pda_countryOfResidence 353 1339#define NID_id_pda_countryOfResidence 353
1245#define OBJ_id_pda_countryOfResidence OBJ_id_pda,6L 1340#define OBJ_id_pda_countryOfResidence OBJ_id_pda,5L
1246 1341
1247#define SN_id_aca_authenticationInfo "id-aca-authenticationInfo" 1342#define SN_id_aca_authenticationInfo "id-aca-authenticationInfo"
1248#define NID_id_aca_authenticationInfo 354 1343#define NID_id_aca_authenticationInfo 354
@@ -1264,6 +1359,10 @@
1264#define NID_id_aca_role 358 1359#define NID_id_aca_role 358
1265#define OBJ_id_aca_role OBJ_id_aca,5L 1360#define OBJ_id_aca_role OBJ_id_aca,5L
1266 1361
1362#define SN_id_aca_encAttrs "id-aca-encAttrs"
1363#define NID_id_aca_encAttrs 399
1364#define OBJ_id_aca_encAttrs OBJ_id_aca,6L
1365
1267#define SN_id_qcs_pkixQCSyntax_v1 "id-qcs-pkixQCSyntax-v1" 1366#define SN_id_qcs_pkixQCSyntax_v1 "id-qcs-pkixQCSyntax-v1"
1268#define NID_id_qcs_pkixQCSyntax_v1 359 1367#define NID_id_qcs_pkixQCSyntax_v1 359
1269#define OBJ_id_qcs_pkixQCSyntax_v1 OBJ_id_qcs,1L 1368#define OBJ_id_qcs_pkixQCSyntax_v1 OBJ_id_qcs,1L
@@ -1323,6 +1422,7 @@
1323#define OBJ_id_pkix_OCSP_acceptableResponses OBJ_id_pkix_OCSP,4L 1422#define OBJ_id_pkix_OCSP_acceptableResponses OBJ_id_pkix_OCSP,4L
1324 1423
1325#define SN_id_pkix_OCSP_noCheck "noCheck" 1424#define SN_id_pkix_OCSP_noCheck "noCheck"
1425#define LN_id_pkix_OCSP_noCheck "OCSP No Check"
1326#define NID_id_pkix_OCSP_noCheck 369 1426#define NID_id_pkix_OCSP_noCheck 369
1327#define OBJ_id_pkix_OCSP_noCheck OBJ_id_pkix_OCSP,5L 1427#define OBJ_id_pkix_OCSP_noCheck OBJ_id_pkix_OCSP,5L
1328 1428
@@ -1403,14 +1503,14 @@
1403#define NID_shaWithRSAEncryption 42 1503#define NID_shaWithRSAEncryption 42
1404#define OBJ_shaWithRSAEncryption OBJ_algorithm,15L 1504#define OBJ_shaWithRSAEncryption OBJ_algorithm,15L
1405 1505
1406#define SN_des_ede "DES-EDE" 1506#define SN_des_ede_ecb "DES-EDE"
1407#define LN_des_ede "des-ede" 1507#define LN_des_ede_ecb "des-ede"
1408#define NID_des_ede 32 1508#define NID_des_ede_ecb 32
1409#define OBJ_des_ede OBJ_algorithm,17L 1509#define OBJ_des_ede_ecb OBJ_algorithm,17L
1410 1510
1411#define SN_des_ede3 "DES-EDE3" 1511#define SN_des_ede3_ecb "DES-EDE3"
1412#define LN_des_ede3 "des-ede3" 1512#define LN_des_ede3_ecb "des-ede3"
1413#define NID_des_ede3 33 1513#define NID_des_ede3_ecb 33
1414 1514
1415#define SN_des_ede_cbc "DES-EDE-CBC" 1515#define SN_des_ede_cbc "DES-EDE-CBC"
1416#define LN_des_ede_cbc "des-ede-cbc" 1516#define LN_des_ede_cbc "des-ede-cbc"
@@ -1485,12 +1585,11 @@
1485#define NID_commonName 13 1585#define NID_commonName 13
1486#define OBJ_commonName OBJ_X509,3L 1586#define OBJ_commonName OBJ_X509,3L
1487 1587
1488#define SN_surname "S" 1588#define SN_surname "SN"
1489#define LN_surname "surname" 1589#define LN_surname "surname"
1490#define NID_surname 100 1590#define NID_surname 100
1491#define OBJ_surname OBJ_X509,4L 1591#define OBJ_surname OBJ_X509,4L
1492 1592
1493#define SN_serialNumber "SN"
1494#define LN_serialNumber "serialNumber" 1593#define LN_serialNumber "serialNumber"
1495#define NID_serialNumber 105 1594#define NID_serialNumber 105
1496#define OBJ_serialNumber OBJ_X509,5L 1595#define OBJ_serialNumber OBJ_X509,5L
@@ -1520,12 +1619,10 @@
1520#define NID_organizationalUnitName 18 1619#define NID_organizationalUnitName 18
1521#define OBJ_organizationalUnitName OBJ_X509,11L 1620#define OBJ_organizationalUnitName OBJ_X509,11L
1522 1621
1523#define SN_title "T"
1524#define LN_title "title" 1622#define LN_title "title"
1525#define NID_title 106 1623#define NID_title 106
1526#define OBJ_title OBJ_X509,12L 1624#define OBJ_title OBJ_X509,12L
1527 1625
1528#define SN_description "D"
1529#define LN_description "description" 1626#define LN_description "description"
1530#define NID_description 107 1627#define NID_description 107
1531#define OBJ_description OBJ_X509,13L 1628#define OBJ_description OBJ_X509,13L
@@ -1535,26 +1632,33 @@
1535#define NID_name 173 1632#define NID_name 173
1536#define OBJ_name OBJ_X509,41L 1633#define OBJ_name OBJ_X509,41L
1537 1634
1538#define SN_givenName "G" 1635#define SN_givenName "gn"
1539#define LN_givenName "givenName" 1636#define LN_givenName "givenName"
1540#define NID_givenName 99 1637#define NID_givenName 99
1541#define OBJ_givenName OBJ_X509,42L 1638#define OBJ_givenName OBJ_X509,42L
1542 1639
1543#define SN_initials "I"
1544#define LN_initials "initials" 1640#define LN_initials "initials"
1545#define NID_initials 101 1641#define NID_initials 101
1546#define OBJ_initials OBJ_X509,43L 1642#define OBJ_initials OBJ_X509,43L
1547 1643
1548#define SN_uniqueIdentifier "UID" 1644#define LN_generationQualifier "generationQualifier"
1549#define LN_uniqueIdentifier "uniqueIdentifier" 1645#define NID_generationQualifier 509
1550#define NID_uniqueIdentifier 102 1646#define OBJ_generationQualifier OBJ_X509,44L
1551#define OBJ_uniqueIdentifier OBJ_X509,45L 1647
1648#define LN_x500UniqueIdentifier "x500UniqueIdentifier"
1649#define NID_x500UniqueIdentifier 503
1650#define OBJ_x500UniqueIdentifier OBJ_X509,45L
1552 1651
1553#define SN_dnQualifier "dnQualifier" 1652#define SN_dnQualifier "dnQualifier"
1554#define LN_dnQualifier "dnQualifier" 1653#define LN_dnQualifier "dnQualifier"
1555#define NID_dnQualifier 174 1654#define NID_dnQualifier 174
1556#define OBJ_dnQualifier OBJ_X509,46L 1655#define OBJ_dnQualifier OBJ_X509,46L
1557 1656
1657#define SN_role "role"
1658#define LN_role "role"
1659#define NID_role 400
1660#define OBJ_role OBJ_X509,72L
1661
1558#define SN_X500algorithms "X500algorithms" 1662#define SN_X500algorithms "X500algorithms"
1559#define LN_X500algorithms "directory services - algorithms" 1663#define LN_X500algorithms "directory services - algorithms"
1560#define NID_X500algorithms 378 1664#define NID_X500algorithms 378
@@ -1644,11 +1748,26 @@
1644#define NID_authority_key_identifier 90 1748#define NID_authority_key_identifier 90
1645#define OBJ_authority_key_identifier OBJ_id_ce,35L 1749#define OBJ_authority_key_identifier OBJ_id_ce,35L
1646 1750
1751#define SN_policy_constraints "policyConstraints"
1752#define LN_policy_constraints "X509v3 Policy Constraints"
1753#define NID_policy_constraints 401
1754#define OBJ_policy_constraints OBJ_id_ce,36L
1755
1647#define SN_ext_key_usage "extendedKeyUsage" 1756#define SN_ext_key_usage "extendedKeyUsage"
1648#define LN_ext_key_usage "X509v3 Extended Key Usage" 1757#define LN_ext_key_usage "X509v3 Extended Key Usage"
1649#define NID_ext_key_usage 126 1758#define NID_ext_key_usage 126
1650#define OBJ_ext_key_usage OBJ_id_ce,37L 1759#define OBJ_ext_key_usage OBJ_id_ce,37L
1651 1760
1761#define SN_target_information "targetInformation"
1762#define LN_target_information "X509v3 AC Targeting"
1763#define NID_target_information 402
1764#define OBJ_target_information OBJ_id_ce,55L
1765
1766#define SN_no_rev_avail "noRevAvail"
1767#define LN_no_rev_avail "X509v3 No Revocation Available"
1768#define NID_no_rev_avail 403
1769#define OBJ_no_rev_avail OBJ_id_ce,56L
1770
1652#define SN_netscape "Netscape" 1771#define SN_netscape "Netscape"
1653#define LN_netscape "Netscape Communications Corp." 1772#define LN_netscape "Netscape Communications Corp."
1654#define NID_netscape 57 1773#define NID_netscape 57
@@ -1761,7 +1880,6 @@
1761#define NID_SNMPv2 387 1880#define NID_SNMPv2 387
1762#define OBJ_SNMPv2 OBJ_internet,6L 1881#define OBJ_SNMPv2 OBJ_internet,6L
1763 1882
1764#define SN_Mail "mail"
1765#define LN_Mail "Mail" 1883#define LN_Mail "Mail"
1766#define NID_Mail 388 1884#define NID_Mail 388
1767#define OBJ_Mail OBJ_internet,7L 1885#define OBJ_Mail OBJ_internet,7L
@@ -1769,22 +1887,37 @@
1769#define SN_Enterprises "enterprises" 1887#define SN_Enterprises "enterprises"
1770#define LN_Enterprises "Enterprises" 1888#define LN_Enterprises "Enterprises"
1771#define NID_Enterprises 389 1889#define NID_Enterprises 389
1772#define OBJ_Enterprises OBJ_private,1L 1890#define OBJ_Enterprises OBJ_Private,1L
1773 1891
1774#define SN_dcObject "dcobject" 1892#define SN_dcObject "dcobject"
1775#define LN_dcObject "dcObject" 1893#define LN_dcObject "dcObject"
1776#define NID_dcObject 390 1894#define NID_dcObject 390
1777#define OBJ_dcObject OBJ_enterprises,1466L,344L 1895#define OBJ_dcObject OBJ_Enterprises,1466L,344L
1778 1896
1779#define SN_domainComponent "DC" 1897#define SN_mime_mhs "mime-mhs"
1780#define LN_domainComponent "domainComponent" 1898#define LN_mime_mhs "MIME MHS"
1781#define NID_domainComponent 391 1899#define NID_mime_mhs 504
1782#define OBJ_domainComponent 0L,9L,2342L,19200300L,100L,1L,25L 1900#define OBJ_mime_mhs OBJ_Mail,1L
1783 1901
1784#define SN_Domain "domain" 1902#define SN_mime_mhs_headings "mime-mhs-headings"
1785#define LN_Domain "Domain" 1903#define LN_mime_mhs_headings "mime-mhs-headings"
1786#define NID_Domain 392 1904#define NID_mime_mhs_headings 505
1787#define OBJ_Domain 0L,9L,2342L,19200300L,100L,4L,13L 1905#define OBJ_mime_mhs_headings OBJ_mime_mhs,1L
1906
1907#define SN_mime_mhs_bodies "mime-mhs-bodies"
1908#define LN_mime_mhs_bodies "mime-mhs-bodies"
1909#define NID_mime_mhs_bodies 506
1910#define OBJ_mime_mhs_bodies OBJ_mime_mhs,2L
1911
1912#define SN_id_hex_partial_message "id-hex-partial-message"
1913#define LN_id_hex_partial_message "id-hex-partial-message"
1914#define NID_id_hex_partial_message 507
1915#define OBJ_id_hex_partial_message OBJ_mime_mhs_headings,1L
1916
1917#define SN_id_hex_multipart_message "id-hex-multipart-message"
1918#define LN_id_hex_multipart_message "id-hex-multipart-message"
1919#define NID_id_hex_multipart_message 508
1920#define OBJ_id_hex_multipart_message OBJ_mime_mhs_headings,2L
1788 1921
1789#define SN_rle_compression "RLE" 1922#define SN_rle_compression "RLE"
1790#define LN_rle_compression "run length compression" 1923#define LN_rle_compression "run length compression"
@@ -1796,3 +1929,379 @@
1796#define NID_zlib_compression 125 1929#define NID_zlib_compression 125
1797#define OBJ_zlib_compression 1L,1L,1L,1L,666L,2L 1930#define OBJ_zlib_compression 1L,1L,1L,1L,666L,2L
1798 1931
1932#define OBJ_csor 2L,16L,840L,1L,101L,3L
1933
1934#define OBJ_nistAlgorithms OBJ_csor,4L
1935
1936#define OBJ_aes OBJ_nistAlgorithms,1L
1937
1938#define SN_aes_128_ecb "AES-128-ECB"
1939#define LN_aes_128_ecb "aes-128-ecb"
1940#define NID_aes_128_ecb 418
1941#define OBJ_aes_128_ecb OBJ_aes,1L
1942
1943#define SN_aes_128_cbc "AES-128-CBC"
1944#define LN_aes_128_cbc "aes-128-cbc"
1945#define NID_aes_128_cbc 419
1946#define OBJ_aes_128_cbc OBJ_aes,2L
1947
1948#define SN_aes_128_ofb128 "AES-128-OFB"
1949#define LN_aes_128_ofb128 "aes-128-ofb"
1950#define NID_aes_128_ofb128 420
1951#define OBJ_aes_128_ofb128 OBJ_aes,3L
1952
1953#define SN_aes_128_cfb128 "AES-128-CFB"
1954#define LN_aes_128_cfb128 "aes-128-cfb"
1955#define NID_aes_128_cfb128 421
1956#define OBJ_aes_128_cfb128 OBJ_aes,4L
1957
1958#define SN_aes_192_ecb "AES-192-ECB"
1959#define LN_aes_192_ecb "aes-192-ecb"
1960#define NID_aes_192_ecb 422
1961#define OBJ_aes_192_ecb OBJ_aes,21L
1962
1963#define SN_aes_192_cbc "AES-192-CBC"
1964#define LN_aes_192_cbc "aes-192-cbc"
1965#define NID_aes_192_cbc 423
1966#define OBJ_aes_192_cbc OBJ_aes,22L
1967
1968#define SN_aes_192_ofb128 "AES-192-OFB"
1969#define LN_aes_192_ofb128 "aes-192-ofb"
1970#define NID_aes_192_ofb128 424
1971#define OBJ_aes_192_ofb128 OBJ_aes,23L
1972
1973#define SN_aes_192_cfb128 "AES-192-CFB"
1974#define LN_aes_192_cfb128 "aes-192-cfb"
1975#define NID_aes_192_cfb128 425
1976#define OBJ_aes_192_cfb128 OBJ_aes,24L
1977
1978#define SN_aes_256_ecb "AES-256-ECB"
1979#define LN_aes_256_ecb "aes-256-ecb"
1980#define NID_aes_256_ecb 426
1981#define OBJ_aes_256_ecb OBJ_aes,41L
1982
1983#define SN_aes_256_cbc "AES-256-CBC"
1984#define LN_aes_256_cbc "aes-256-cbc"
1985#define NID_aes_256_cbc 427
1986#define OBJ_aes_256_cbc OBJ_aes,42L
1987
1988#define SN_aes_256_ofb128 "AES-256-OFB"
1989#define LN_aes_256_ofb128 "aes-256-ofb"
1990#define NID_aes_256_ofb128 428
1991#define OBJ_aes_256_ofb128 OBJ_aes,43L
1992
1993#define SN_aes_256_cfb128 "AES-256-CFB"
1994#define LN_aes_256_cfb128 "aes-256-cfb"
1995#define NID_aes_256_cfb128 429
1996#define OBJ_aes_256_cfb128 OBJ_aes,44L
1997
1998#define SN_hold_instruction_code "holdInstructionCode"
1999#define LN_hold_instruction_code "Hold Instruction Code"
2000#define NID_hold_instruction_code 430
2001#define OBJ_hold_instruction_code OBJ_id_ce,23L
2002
2003#define OBJ_holdInstruction OBJ_X9_57,2L
2004
2005#define SN_hold_instruction_none "holdInstructionNone"
2006#define LN_hold_instruction_none "Hold Instruction None"
2007#define NID_hold_instruction_none 431
2008#define OBJ_hold_instruction_none OBJ_holdInstruction,1L
2009
2010#define SN_hold_instruction_call_issuer "holdInstructionCallIssuer"
2011#define LN_hold_instruction_call_issuer "Hold Instruction Call Issuer"
2012#define NID_hold_instruction_call_issuer 432
2013#define OBJ_hold_instruction_call_issuer OBJ_holdInstruction,2L
2014
2015#define SN_hold_instruction_reject "holdInstructionReject"
2016#define LN_hold_instruction_reject "Hold Instruction Reject"
2017#define NID_hold_instruction_reject 433
2018#define OBJ_hold_instruction_reject OBJ_holdInstruction,3L
2019
2020#define SN_data "data"
2021#define NID_data 434
2022#define OBJ_data OBJ_ccitt,9L
2023
2024#define SN_pss "pss"
2025#define NID_pss 435
2026#define OBJ_pss OBJ_data,2342L
2027
2028#define SN_ucl "ucl"
2029#define NID_ucl 436
2030#define OBJ_ucl OBJ_pss,19200300L
2031
2032#define SN_pilot "pilot"
2033#define NID_pilot 437
2034#define OBJ_pilot OBJ_ucl,100L
2035
2036#define LN_pilotAttributeType "pilotAttributeType"
2037#define NID_pilotAttributeType 438
2038#define OBJ_pilotAttributeType OBJ_pilot,1L
2039
2040#define LN_pilotAttributeSyntax "pilotAttributeSyntax"
2041#define NID_pilotAttributeSyntax 439
2042#define OBJ_pilotAttributeSyntax OBJ_pilot,3L
2043
2044#define LN_pilotObjectClass "pilotObjectClass"
2045#define NID_pilotObjectClass 440
2046#define OBJ_pilotObjectClass OBJ_pilot,4L
2047
2048#define LN_pilotGroups "pilotGroups"
2049#define NID_pilotGroups 441
2050#define OBJ_pilotGroups OBJ_pilot,10L
2051
2052#define LN_iA5StringSyntax "iA5StringSyntax"
2053#define NID_iA5StringSyntax 442
2054#define OBJ_iA5StringSyntax OBJ_pilotAttributeSyntax,4L
2055
2056#define LN_caseIgnoreIA5StringSyntax "caseIgnoreIA5StringSyntax"
2057#define NID_caseIgnoreIA5StringSyntax 443
2058#define OBJ_caseIgnoreIA5StringSyntax OBJ_pilotAttributeSyntax,5L
2059
2060#define LN_pilotObject "pilotObject"
2061#define NID_pilotObject 444
2062#define OBJ_pilotObject OBJ_pilotObjectClass,3L
2063
2064#define LN_pilotPerson "pilotPerson"
2065#define NID_pilotPerson 445
2066#define OBJ_pilotPerson OBJ_pilotObjectClass,4L
2067
2068#define SN_account "account"
2069#define NID_account 446
2070#define OBJ_account OBJ_pilotObjectClass,5L
2071
2072#define SN_document "document"
2073#define NID_document 447
2074#define OBJ_document OBJ_pilotObjectClass,6L
2075
2076#define SN_room "room"
2077#define NID_room 448
2078#define OBJ_room OBJ_pilotObjectClass,7L
2079
2080#define LN_documentSeries "documentSeries"
2081#define NID_documentSeries 449
2082#define OBJ_documentSeries OBJ_pilotObjectClass,9L
2083
2084#define SN_Domain "domain"
2085#define LN_Domain "Domain"
2086#define NID_Domain 392
2087#define OBJ_Domain OBJ_pilotObjectClass,13L
2088
2089#define LN_rFC822localPart "rFC822localPart"
2090#define NID_rFC822localPart 450
2091#define OBJ_rFC822localPart OBJ_pilotObjectClass,14L
2092
2093#define LN_dNSDomain "dNSDomain"
2094#define NID_dNSDomain 451
2095#define OBJ_dNSDomain OBJ_pilotObjectClass,15L
2096
2097#define LN_domainRelatedObject "domainRelatedObject"
2098#define NID_domainRelatedObject 452
2099#define OBJ_domainRelatedObject OBJ_pilotObjectClass,17L
2100
2101#define LN_friendlyCountry "friendlyCountry"
2102#define NID_friendlyCountry 453
2103#define OBJ_friendlyCountry OBJ_pilotObjectClass,18L
2104
2105#define LN_simpleSecurityObject "simpleSecurityObject"
2106#define NID_simpleSecurityObject 454
2107#define OBJ_simpleSecurityObject OBJ_pilotObjectClass,19L
2108
2109#define LN_pilotOrganization "pilotOrganization"
2110#define NID_pilotOrganization 455
2111#define OBJ_pilotOrganization OBJ_pilotObjectClass,20L
2112
2113#define LN_pilotDSA "pilotDSA"
2114#define NID_pilotDSA 456
2115#define OBJ_pilotDSA OBJ_pilotObjectClass,21L
2116
2117#define LN_qualityLabelledData "qualityLabelledData"
2118#define NID_qualityLabelledData 457
2119#define OBJ_qualityLabelledData OBJ_pilotObjectClass,22L
2120
2121#define SN_userId "UID"
2122#define LN_userId "userId"
2123#define NID_userId 458
2124#define OBJ_userId OBJ_pilotAttributeType,1L
2125
2126#define LN_textEncodedORAddress "textEncodedORAddress"
2127#define NID_textEncodedORAddress 459
2128#define OBJ_textEncodedORAddress OBJ_pilotAttributeType,2L
2129
2130#define SN_rfc822Mailbox "mail"
2131#define LN_rfc822Mailbox "rfc822Mailbox"
2132#define NID_rfc822Mailbox 460
2133#define OBJ_rfc822Mailbox OBJ_pilotAttributeType,3L
2134
2135#define SN_info "info"
2136#define NID_info 461
2137#define OBJ_info OBJ_pilotAttributeType,4L
2138
2139#define LN_favouriteDrink "favouriteDrink"
2140#define NID_favouriteDrink 462
2141#define OBJ_favouriteDrink OBJ_pilotAttributeType,5L
2142
2143#define LN_roomNumber "roomNumber"
2144#define NID_roomNumber 463
2145#define OBJ_roomNumber OBJ_pilotAttributeType,6L
2146
2147#define SN_photo "photo"
2148#define NID_photo 464
2149#define OBJ_photo OBJ_pilotAttributeType,7L
2150
2151#define LN_userClass "userClass"
2152#define NID_userClass 465
2153#define OBJ_userClass OBJ_pilotAttributeType,8L
2154
2155#define SN_host "host"
2156#define NID_host 466
2157#define OBJ_host OBJ_pilotAttributeType,9L
2158
2159#define SN_manager "manager"
2160#define NID_manager 467
2161#define OBJ_manager OBJ_pilotAttributeType,10L
2162
2163#define LN_documentIdentifier "documentIdentifier"
2164#define NID_documentIdentifier 468
2165#define OBJ_documentIdentifier OBJ_pilotAttributeType,11L
2166
2167#define LN_documentTitle "documentTitle"
2168#define NID_documentTitle 469
2169#define OBJ_documentTitle OBJ_pilotAttributeType,12L
2170
2171#define LN_documentVersion "documentVersion"
2172#define NID_documentVersion 470
2173#define OBJ_documentVersion OBJ_pilotAttributeType,13L
2174
2175#define LN_documentAuthor "documentAuthor"
2176#define NID_documentAuthor 471
2177#define OBJ_documentAuthor OBJ_pilotAttributeType,14L
2178
2179#define LN_documentLocation "documentLocation"
2180#define NID_documentLocation 472
2181#define OBJ_documentLocation OBJ_pilotAttributeType,15L
2182
2183#define LN_homeTelephoneNumber "homeTelephoneNumber"
2184#define NID_homeTelephoneNumber 473
2185#define OBJ_homeTelephoneNumber OBJ_pilotAttributeType,20L
2186
2187#define SN_secretary "secretary"
2188#define NID_secretary 474
2189#define OBJ_secretary OBJ_pilotAttributeType,21L
2190
2191#define LN_otherMailbox "otherMailbox"
2192#define NID_otherMailbox 475
2193#define OBJ_otherMailbox OBJ_pilotAttributeType,22L
2194
2195#define LN_lastModifiedTime "lastModifiedTime"
2196#define NID_lastModifiedTime 476
2197#define OBJ_lastModifiedTime OBJ_pilotAttributeType,23L
2198
2199#define LN_lastModifiedBy "lastModifiedBy"
2200#define NID_lastModifiedBy 477
2201#define OBJ_lastModifiedBy OBJ_pilotAttributeType,24L
2202
2203#define SN_domainComponent "DC"
2204#define LN_domainComponent "domainComponent"
2205#define NID_domainComponent 391
2206#define OBJ_domainComponent OBJ_pilotAttributeType,25L
2207
2208#define LN_aRecord "aRecord"
2209#define NID_aRecord 478
2210#define OBJ_aRecord OBJ_pilotAttributeType,26L
2211
2212#define LN_pilotAttributeType27 "pilotAttributeType27"
2213#define NID_pilotAttributeType27 479
2214#define OBJ_pilotAttributeType27 OBJ_pilotAttributeType,27L
2215
2216#define LN_mXRecord "mXRecord"
2217#define NID_mXRecord 480
2218#define OBJ_mXRecord OBJ_pilotAttributeType,28L
2219
2220#define LN_nSRecord "nSRecord"
2221#define NID_nSRecord 481
2222#define OBJ_nSRecord OBJ_pilotAttributeType,29L
2223
2224#define LN_sOARecord "sOARecord"
2225#define NID_sOARecord 482
2226#define OBJ_sOARecord OBJ_pilotAttributeType,30L
2227
2228#define LN_cNAMERecord "cNAMERecord"
2229#define NID_cNAMERecord 483
2230#define OBJ_cNAMERecord OBJ_pilotAttributeType,31L
2231
2232#define LN_associatedDomain "associatedDomain"
2233#define NID_associatedDomain 484
2234#define OBJ_associatedDomain OBJ_pilotAttributeType,37L
2235
2236#define LN_associatedName "associatedName"
2237#define NID_associatedName 485
2238#define OBJ_associatedName OBJ_pilotAttributeType,38L
2239
2240#define LN_homePostalAddress "homePostalAddress"
2241#define NID_homePostalAddress 486
2242#define OBJ_homePostalAddress OBJ_pilotAttributeType,39L
2243
2244#define LN_personalTitle "personalTitle"
2245#define NID_personalTitle 487
2246#define OBJ_personalTitle OBJ_pilotAttributeType,40L
2247
2248#define LN_mobileTelephoneNumber "mobileTelephoneNumber"
2249#define NID_mobileTelephoneNumber 488
2250#define OBJ_mobileTelephoneNumber OBJ_pilotAttributeType,41L
2251
2252#define LN_pagerTelephoneNumber "pagerTelephoneNumber"
2253#define NID_pagerTelephoneNumber 489
2254#define OBJ_pagerTelephoneNumber OBJ_pilotAttributeType,42L
2255
2256#define LN_friendlyCountryName "friendlyCountryName"
2257#define NID_friendlyCountryName 490
2258#define OBJ_friendlyCountryName OBJ_pilotAttributeType,43L
2259
2260#define LN_organizationalStatus "organizationalStatus"
2261#define NID_organizationalStatus 491
2262#define OBJ_organizationalStatus OBJ_pilotAttributeType,45L
2263
2264#define LN_janetMailbox "janetMailbox"
2265#define NID_janetMailbox 492
2266#define OBJ_janetMailbox OBJ_pilotAttributeType,46L
2267
2268#define LN_mailPreferenceOption "mailPreferenceOption"
2269#define NID_mailPreferenceOption 493
2270#define OBJ_mailPreferenceOption OBJ_pilotAttributeType,47L
2271
2272#define LN_buildingName "buildingName"
2273#define NID_buildingName 494
2274#define OBJ_buildingName OBJ_pilotAttributeType,48L
2275
2276#define LN_dSAQuality "dSAQuality"
2277#define NID_dSAQuality 495
2278#define OBJ_dSAQuality OBJ_pilotAttributeType,49L
2279
2280#define LN_singleLevelQuality "singleLevelQuality"
2281#define NID_singleLevelQuality 496
2282#define OBJ_singleLevelQuality OBJ_pilotAttributeType,50L
2283
2284#define LN_subtreeMinimumQuality "subtreeMinimumQuality"
2285#define NID_subtreeMinimumQuality 497
2286#define OBJ_subtreeMinimumQuality OBJ_pilotAttributeType,51L
2287
2288#define LN_subtreeMaximumQuality "subtreeMaximumQuality"
2289#define NID_subtreeMaximumQuality 498
2290#define OBJ_subtreeMaximumQuality OBJ_pilotAttributeType,52L
2291
2292#define LN_personalSignature "personalSignature"
2293#define NID_personalSignature 499
2294#define OBJ_personalSignature OBJ_pilotAttributeType,53L
2295
2296#define LN_dITRedirect "dITRedirect"
2297#define NID_dITRedirect 500
2298#define OBJ_dITRedirect OBJ_pilotAttributeType,54L
2299
2300#define SN_audio "audio"
2301#define NID_audio 501
2302#define OBJ_audio OBJ_pilotAttributeType,55L
2303
2304#define LN_documentPublisher "documentPublisher"
2305#define NID_documentPublisher 502
2306#define OBJ_documentPublisher OBJ_pilotAttributeType,56L
2307
diff --git a/src/lib/libcrypto/objects/obj_mac.num b/src/lib/libcrypto/objects/obj_mac.num
index d73a51370f..02b39062fe 100644
--- a/src/lib/libcrypto/objects/obj_mac.num
+++ b/src/lib/libcrypto/objects/obj_mac.num
@@ -30,8 +30,8 @@ dhKeyAgreement 28
30des_ecb 29 30des_ecb 29
31des_cfb64 30 31des_cfb64 30
32des_cbc 31 32des_cbc 31
33des_ede 32 33des_ede_ecb 32
34des_ede3 33 34des_ede3_ecb 33
35idea_cbc 34 35idea_cbc 34
36idea_cfb64 35 36idea_cfb64 35
37idea_ecb 36 37idea_ecb 36
@@ -390,3 +390,120 @@ Enterprises 389
390dcObject 390 390dcObject 390
391domainComponent 391 391domainComponent 391
392Domain 392 392Domain 392
393joint_iso_ccitt 393
394selected_attribute_types 394
395clearance 395
396md4WithRSAEncryption 396
397ac_proxying 397
398sinfo_access 398
399id_aca_encAttrs 399
400role 400
401policy_constraints 401
402target_information 402
403no_rev_avail 403
404ccitt 404
405ansi_X9_62 405
406X9_62_prime_field 406
407X9_62_characteristic_two_field 407
408X9_62_id_ecPublicKey 408
409X9_62_prime192v1 409
410X9_62_prime192v2 410
411X9_62_prime192v3 411
412X9_62_prime239v1 412
413X9_62_prime239v2 413
414X9_62_prime239v3 414
415X9_62_prime256v1 415
416ecdsa_with_SHA1 416
417ms_csp_name 417
418aes_128_ecb 418
419aes_128_cbc 419
420aes_128_ofb128 420
421aes_128_cfb128 421
422aes_192_ecb 422
423aes_192_cbc 423
424aes_192_ofb128 424
425aes_192_cfb128 425
426aes_256_ecb 426
427aes_256_cbc 427
428aes_256_ofb128 428
429aes_256_cfb128 429
430hold_instruction_code 430
431hold_instruction_none 431
432hold_instruction_call_issuer 432
433hold_instruction_reject 433
434data 434
435pss 435
436ucl 436
437pilot 437
438pilotAttributeType 438
439pilotAttributeSyntax 439
440pilotObjectClass 440
441pilotGroups 441
442iA5StringSyntax 442
443caseIgnoreIA5StringSyntax 443
444pilotObject 444
445pilotPerson 445
446account 446
447document 447
448room 448
449documentSeries 449
450rFC822localPart 450
451dNSDomain 451
452domainRelatedObject 452
453friendlyCountry 453
454simpleSecurityObject 454
455pilotOrganization 455
456pilotDSA 456
457qualityLabelledData 457
458userId 458
459textEncodedORAddress 459
460rfc822Mailbox 460
461info 461
462favouriteDrink 462
463roomNumber 463
464photo 464
465userClass 465
466host 466
467manager 467
468documentIdentifier 468
469documentTitle 469
470documentVersion 470
471documentAuthor 471
472documentLocation 472
473homeTelephoneNumber 473
474secretary 474
475otherMailbox 475
476lastModifiedTime 476
477lastModifiedBy 477
478aRecord 478
479pilotAttributeType27 479
480mXRecord 480
481nSRecord 481
482sOARecord 482
483cNAMERecord 483
484associatedDomain 484
485associatedName 485
486homePostalAddress 486
487personalTitle 487
488mobileTelephoneNumber 488
489pagerTelephoneNumber 489
490friendlyCountryName 490
491organizationalStatus 491
492janetMailbox 492
493mailPreferenceOption 493
494buildingName 494
495dSAQuality 495
496singleLevelQuality 496
497subtreeMinimumQuality 497
498subtreeMaximumQuality 498
499personalSignature 499
500dITRedirect 500
501audio 501
502documentPublisher 502
503x500UniqueIdentifier 503
504mime_mhs 504
505mime_mhs_headings 505
506mime_mhs_bodies 506
507id_hex_partial_message 507
508id_hex_multipart_message 508
509generationQualifier 509
diff --git a/src/lib/libcrypto/objects/objects.h b/src/lib/libcrypto/objects/objects.h
index c099e2e84e..de10532813 100644
--- a/src/lib/libcrypto/objects/objects.h
+++ b/src/lib/libcrypto/objects/objects.h
@@ -452,54 +452,54 @@
452#define LN_desx_cbc "desx-cbc" 452#define LN_desx_cbc "desx-cbc"
453#define NID_desx_cbc 80 453#define NID_desx_cbc 80
454 454
455#define SN_ld_ce "ld-ce" 455#define SN_id_ce "id-ce"
456#define NID_ld_ce 81 456#define NID_id_ce 81
457#define OBJ_ld_ce 2L,5L,29L 457#define OBJ_id_ce 2L,5L,29L
458 458
459#define SN_subject_key_identifier "subjectKeyIdentifier" 459#define SN_subject_key_identifier "subjectKeyIdentifier"
460#define LN_subject_key_identifier "X509v3 Subject Key Identifier" 460#define LN_subject_key_identifier "X509v3 Subject Key Identifier"
461#define NID_subject_key_identifier 82 461#define NID_subject_key_identifier 82
462#define OBJ_subject_key_identifier OBJ_ld_ce,14L 462#define OBJ_subject_key_identifier OBJ_id_ce,14L
463 463
464#define SN_key_usage "keyUsage" 464#define SN_key_usage "keyUsage"
465#define LN_key_usage "X509v3 Key Usage" 465#define LN_key_usage "X509v3 Key Usage"
466#define NID_key_usage 83 466#define NID_key_usage 83
467#define OBJ_key_usage OBJ_ld_ce,15L 467#define OBJ_key_usage OBJ_id_ce,15L
468 468
469#define SN_private_key_usage_period "privateKeyUsagePeriod" 469#define SN_private_key_usage_period "privateKeyUsagePeriod"
470#define LN_private_key_usage_period "X509v3 Private Key Usage Period" 470#define LN_private_key_usage_period "X509v3 Private Key Usage Period"
471#define NID_private_key_usage_period 84 471#define NID_private_key_usage_period 84
472#define OBJ_private_key_usage_period OBJ_ld_ce,16L 472#define OBJ_private_key_usage_period OBJ_id_ce,16L
473 473
474#define SN_subject_alt_name "subjectAltName" 474#define SN_subject_alt_name "subjectAltName"
475#define LN_subject_alt_name "X509v3 Subject Alternative Name" 475#define LN_subject_alt_name "X509v3 Subject Alternative Name"
476#define NID_subject_alt_name 85 476#define NID_subject_alt_name 85
477#define OBJ_subject_alt_name OBJ_ld_ce,17L 477#define OBJ_subject_alt_name OBJ_id_ce,17L
478 478
479#define SN_issuer_alt_name "issuerAltName" 479#define SN_issuer_alt_name "issuerAltName"
480#define LN_issuer_alt_name "X509v3 Issuer Alternative Name" 480#define LN_issuer_alt_name "X509v3 Issuer Alternative Name"
481#define NID_issuer_alt_name 86 481#define NID_issuer_alt_name 86
482#define OBJ_issuer_alt_name OBJ_ld_ce,18L 482#define OBJ_issuer_alt_name OBJ_id_ce,18L
483 483
484#define SN_basic_constraints "basicConstraints" 484#define SN_basic_constraints "basicConstraints"
485#define LN_basic_constraints "X509v3 Basic Constraints" 485#define LN_basic_constraints "X509v3 Basic Constraints"
486#define NID_basic_constraints 87 486#define NID_basic_constraints 87
487#define OBJ_basic_constraints OBJ_ld_ce,19L 487#define OBJ_basic_constraints OBJ_id_ce,19L
488 488
489#define SN_crl_number "crlNumber" 489#define SN_crl_number "crlNumber"
490#define LN_crl_number "X509v3 CRL Number" 490#define LN_crl_number "X509v3 CRL Number"
491#define NID_crl_number 88 491#define NID_crl_number 88
492#define OBJ_crl_number OBJ_ld_ce,20L 492#define OBJ_crl_number OBJ_id_ce,20L
493 493
494#define SN_certificate_policies "certificatePolicies" 494#define SN_certificate_policies "certificatePolicies"
495#define LN_certificate_policies "X509v3 Certificate Policies" 495#define LN_certificate_policies "X509v3 Certificate Policies"
496#define NID_certificate_policies 89 496#define NID_certificate_policies 89
497#define OBJ_certificate_policies OBJ_ld_ce,32L 497#define OBJ_certificate_policies OBJ_id_ce,32L
498 498
499#define SN_authority_key_identifier "authorityKeyIdentifier" 499#define SN_authority_key_identifier "authorityKeyIdentifier"
500#define LN_authority_key_identifier "X509v3 Authority Key Identifier" 500#define LN_authority_key_identifier "X509v3 Authority Key Identifier"
501#define NID_authority_key_identifier 90 501#define NID_authority_key_identifier 90
502#define OBJ_authority_key_identifier OBJ_ld_ce,35L 502#define OBJ_authority_key_identifier OBJ_id_ce,35L
503 503
504#define SN_bf_cbc "BF-CBC" 504#define SN_bf_cbc "BF-CBC"
505#define LN_bf_cbc "bf-cbc" 505#define LN_bf_cbc "bf-cbc"
@@ -560,7 +560,7 @@
560#define SN_crl_distribution_points "crlDistributionPoints" 560#define SN_crl_distribution_points "crlDistributionPoints"
561#define LN_crl_distribution_points "X509v3 CRL Distribution Points" 561#define LN_crl_distribution_points "X509v3 CRL Distribution Points"
562#define NID_crl_distribution_points 103 562#define NID_crl_distribution_points 103
563#define OBJ_crl_distribution_points OBJ_ld_ce,31L 563#define OBJ_crl_distribution_points OBJ_id_ce,31L
564 564
565#define SN_md5WithRSA "RSA-NP-MD5" 565#define SN_md5WithRSA "RSA-NP-MD5"
566#define LN_md5WithRSA "md5WithRSA" 566#define LN_md5WithRSA "md5WithRSA"
@@ -677,7 +677,7 @@
677#define SN_ext_key_usage "extendedKeyUsage" 677#define SN_ext_key_usage "extendedKeyUsage"
678#define LN_ext_key_usage "X509v3 Extended Key Usage" 678#define LN_ext_key_usage "X509v3 Extended Key Usage"
679#define NID_ext_key_usage 126 679#define NID_ext_key_usage 126
680#define OBJ_ext_key_usage OBJ_ld_ce,37 680#define OBJ_ext_key_usage OBJ_id_ce,37
681 681
682#define SN_id_pkix "PKIX" 682#define SN_id_pkix "PKIX"
683#define NID_id_pkix 127 683#define NID_id_pkix 127
@@ -751,17 +751,17 @@
751#define SN_delta_crl "deltaCRL" 751#define SN_delta_crl "deltaCRL"
752#define LN_delta_crl "X509v3 Delta CRL Indicator" 752#define LN_delta_crl "X509v3 Delta CRL Indicator"
753#define NID_delta_crl 140 753#define NID_delta_crl 140
754#define OBJ_delta_crl OBJ_ld_ce,27L 754#define OBJ_delta_crl OBJ_id_ce,27L
755 755
756#define SN_crl_reason "CRLReason" 756#define SN_crl_reason "CRLReason"
757#define LN_crl_reason "CRL Reason Code" 757#define LN_crl_reason "CRL Reason Code"
758#define NID_crl_reason 141 758#define NID_crl_reason 141
759#define OBJ_crl_reason OBJ_ld_ce,21L 759#define OBJ_crl_reason OBJ_id_ce,21L
760 760
761#define SN_invalidity_date "invalidityDate" 761#define SN_invalidity_date "invalidityDate"
762#define LN_invalidity_date "Invalidity Date" 762#define LN_invalidity_date "Invalidity Date"
763#define NID_invalidity_date 142 763#define NID_invalidity_date 142
764#define OBJ_invalidity_date OBJ_ld_ce,24L 764#define OBJ_invalidity_date OBJ_id_ce,24L
765 765
766#define SN_sxnet "SXNetID" 766#define SN_sxnet "SXNetID"
767#define LN_sxnet "Strong Extranet ID" 767#define LN_sxnet "Strong Extranet ID"
@@ -985,31 +985,35 @@ typedef struct obj_name_st
985 985
986 986
987int OBJ_NAME_init(void); 987int OBJ_NAME_init(void);
988int OBJ_NAME_new_index(unsigned long (*hash_func)(const char *),int (*cmp_func)(const void *, const void *), 988int OBJ_NAME_new_index(unsigned long (*hash_func)(const char *),
989 void (*free_func)(const char *, int, const char *)); 989 int (*cmp_func)(const char *, const char *),
990 void (*free_func)(const char *, int, const char *));
990const char *OBJ_NAME_get(const char *name,int type); 991const char *OBJ_NAME_get(const char *name,int type);
991int OBJ_NAME_add(const char *name,int type,const char *data); 992int OBJ_NAME_add(const char *name,int type,const char *data);
992int OBJ_NAME_remove(const char *name,int type); 993int OBJ_NAME_remove(const char *name,int type);
993void OBJ_NAME_cleanup(int type); /* -1 for everything */ 994void OBJ_NAME_cleanup(int type); /* -1 for everything */
995void OBJ_NAME_do_all(int type,void (*fn)(const OBJ_NAME *,void *arg),
996 void *arg);
997void OBJ_NAME_do_all_sorted(int type,void (*fn)(const OBJ_NAME *,void *arg),
998 void *arg);
994 999
995ASN1_OBJECT * OBJ_dup(ASN1_OBJECT *o); 1000ASN1_OBJECT * OBJ_dup(const ASN1_OBJECT *o);
996ASN1_OBJECT * OBJ_nid2obj(int n); 1001ASN1_OBJECT * OBJ_nid2obj(int n);
997const char * OBJ_nid2ln(int n); 1002const char * OBJ_nid2ln(int n);
998const char * OBJ_nid2sn(int n); 1003const char * OBJ_nid2sn(int n);
999int OBJ_obj2nid(ASN1_OBJECT *o); 1004int OBJ_obj2nid(const ASN1_OBJECT *o);
1000ASN1_OBJECT * OBJ_txt2obj(const char *s, int no_name); 1005ASN1_OBJECT * OBJ_txt2obj(const char *s, int no_name);
1001int OBJ_obj2txt(char *buf, int buf_len, ASN1_OBJECT *a, int no_name); 1006int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name);
1002int OBJ_txt2nid(char *s); 1007int OBJ_txt2nid(const char *s);
1003int OBJ_ln2nid(const char *s); 1008int OBJ_ln2nid(const char *s);
1004int OBJ_sn2nid(const char *s); 1009int OBJ_sn2nid(const char *s);
1005int OBJ_cmp(ASN1_OBJECT *a,ASN1_OBJECT *b); 1010int OBJ_cmp(const ASN1_OBJECT *a,const ASN1_OBJECT *b);
1006char * OBJ_bsearch(char *key,char *base,int num,int size,int (*cmp)(const void *, const void *)); 1011const char * OBJ_bsearch(const char *key,const char *base,int num,int size,
1007 1012 int (*cmp)(const void *, const void *));
1008void ERR_load_OBJ_strings(void );
1009 1013
1010int OBJ_new_nid(int num); 1014int OBJ_new_nid(int num);
1011int OBJ_add_object(ASN1_OBJECT *obj); 1015int OBJ_add_object(const ASN1_OBJECT *obj);
1012int OBJ_create(char *oid,char *sn,char *ln); 1016int OBJ_create(const char *oid,const char *sn,const char *ln);
1013void OBJ_cleanup(void ); 1017void OBJ_cleanup(void );
1014int OBJ_create_objects(BIO *in); 1018int OBJ_create_objects(BIO *in);
1015 1019
@@ -1017,6 +1021,7 @@ int OBJ_create_objects(BIO *in);
1017/* The following lines are auto generated by the script mkerr.pl. Any changes 1021/* The following lines are auto generated by the script mkerr.pl. Any changes
1018 * made after this point may be overwritten when the script is next run. 1022 * made after this point may be overwritten when the script is next run.
1019 */ 1023 */
1024void ERR_load_OBJ_strings(void);
1020 1025
1021/* Error codes for the OBJ functions. */ 1026/* Error codes for the OBJ functions. */
1022 1027
@@ -1035,4 +1040,3 @@ int OBJ_create_objects(BIO *in);
1035} 1040}
1036#endif 1041#endif
1037#endif 1042#endif
1038
diff --git a/src/lib/libcrypto/objects/objects.pl b/src/lib/libcrypto/objects/objects.pl
index c956bbb841..76c06cc8f9 100644
--- a/src/lib/libcrypto/objects/objects.pl
+++ b/src/lib/libcrypto/objects/objects.pl
@@ -9,7 +9,9 @@ while(<NUMIN>)
9 $o++; 9 $o++;
10 s/#.*$//; 10 s/#.*$//;
11 next if /^\s*$/; 11 next if /^\s*$/;
12 $_ = 'X'.$_;
12 ($Cname,$mynum) = split; 13 ($Cname,$mynum) = split;
14 $Cname =~ s/^X//;
13 if (defined($nidn{$mynum})) 15 if (defined($nidn{$mynum}))
14 { die "$ARGV[1]:$o:There's already an object with NID ",$mynum," on line ",$order{$mynum},"\n"; } 16 { die "$ARGV[1]:$o:There's already an object with NID ",$mynum," on line ",$order{$mynum},"\n"; }
15 $nid{$Cname} = $mynum; 17 $nid{$Cname} = $mynum;
@@ -114,7 +116,13 @@ close NUMOUT;
114 116
115open (OUT,">$ARGV[2]") || die "Can't open output file $ARGV[2]"; 117open (OUT,">$ARGV[2]") || die "Can't open output file $ARGV[2]";
116print OUT <<'EOF'; 118print OUT <<'EOF';
117/* lib/obj/obj_mac.h */ 119/* crypto/objects/obj_mac.h */
120
121/* THIS FILE IS GENERATED FROM objects.txt by objects.pl via the
122 * following command:
123 * perl objects.pl objects.txt obj_mac.num obj_mac.h
124 */
125
118/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) 126/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
119 * All rights reserved. 127 * All rights reserved.
120 * 128 *
@@ -172,11 +180,6 @@ print OUT <<'EOF';
172 * [including the GNU Public Licence.] 180 * [including the GNU Public Licence.]
173 */ 181 */
174 182
175/* THIS FILE IS GENERATED FROM objects.txt by objects.pl via the
176 * following command:
177 * perl objects.pl objects.txt obj_mac.num obj_mac.h
178 */
179
180#define SN_undef "UNDEF" 183#define SN_undef "UNDEF"
181#define LN_undef "undefined" 184#define LN_undef "undefined"
182#define NID_undef 0 185#define NID_undef 0
@@ -207,6 +210,8 @@ sub process_oid
207 if (!($a[0] =~ /^[0-9]+$/)) 210 if (!($a[0] =~ /^[0-9]+$/))
208 { 211 {
209 $a[0] =~ s/-/_/g; 212 $a[0] =~ s/-/_/g;
213 if (!defined($obj{$a[0]}))
214 { die "$ARGV[0]:$o:Undefined identifier ",$a[0],"\n"; }
210 $pref_oid = "OBJ_" . $a[0]; 215 $pref_oid = "OBJ_" . $a[0];
211 $pref_sep = ","; 216 $pref_sep = ",";
212 shift @a; 217 shift @a;
diff --git a/src/lib/libcrypto/objects/objects.txt b/src/lib/libcrypto/objects/objects.txt
index 3d443cf884..65d0b15629 100644
--- a/src/lib/libcrypto/objects/objects.txt
+++ b/src/lib/libcrypto/objects/objects.txt
@@ -1,7 +1,15 @@
10 : CCITT : ccitt
2
11 : ISO : iso 31 : ISO : iso
2 4
52 : JOINT-ISO-CCITT : joint-iso-ccitt
6
3iso 2 : member-body : ISO Member Body 7iso 2 : member-body : ISO Member Body
4 8
9joint-iso-ccitt 5 1 5 : selected-attribute-types : Selected Attribute Types
10
11selected-attribute-types 55 : clearance
12
5member-body 840 : ISO-US : ISO US Member Body 13member-body 840 : ISO-US : ISO US Member Body
6ISO-US 10040 : X9-57 : X9.57 14ISO-US 10040 : X9-57 : X9.57
7X9-57 4 : X9cm : X9.57 CM ? 15X9-57 4 : X9cm : X9.57 CM ?
@@ -10,6 +18,32 @@ X9-57 4 : X9cm : X9.57 CM ?
10X9cm 1 : DSA : dsaEncryption 18X9cm 1 : DSA : dsaEncryption
11X9cm 3 : DSA-SHA1 : dsaWithSHA1 19X9cm 3 : DSA-SHA1 : dsaWithSHA1
12 20
21
22ISO-US 10045 : ansi-X9-62 : ANSI X9.62
23!module X9-62
24!Alias id-fieldType ansi-X9-62 1
25X9-62_id-fieldType 1 : prime-field
26X9-62_id-fieldType 2 : characteristic-two-field
27# ... characteristic-two-field OID subtree
28!Alias id-publicKeyType ansi-X9-62 2
29X9-62_id-publicKeyType 1 : id-ecPublicKey
30!Alias ellipticCurve ansi-X9-62 3
31!Alias c-TwoCurve X9-62_ellipticCurve 0
32# ... characteristic 2 curve OIDs
33!Alias primeCurve X9-62_ellipticCurve 1
34X9-62_primeCurve 1 : prime192v1
35X9-62_primeCurve 2 : prime192v2
36X9-62_primeCurve 3 : prime192v3
37X9-62_primeCurve 4 : prime239v1
38X9-62_primeCurve 5 : prime239v2
39X9-62_primeCurve 6 : prime239v3
40X9-62_primeCurve 7 : prime256v1
41!Alias id-ecSigType ansi-X9-62 4
42!global
43X9-62_id-ecSigType 1 : ecdsa-with-SHA1
44
45
46
13ISO-US 113533 7 66 10 : CAST5-CBC : cast5-cbc 47ISO-US 113533 7 66 10 : CAST5-CBC : cast5-cbc
14 : CAST5-ECB : cast5-ecb 48 : CAST5-ECB : cast5-ecb
15!Cname cast5-cfb64 49!Cname cast5-cfb64
@@ -26,6 +60,7 @@ rsadsi 1 : pkcs : RSA Data Security, Inc. PKCS
26pkcs 1 : pkcs1 60pkcs 1 : pkcs1
27pkcs1 1 : : rsaEncryption 61pkcs1 1 : : rsaEncryption
28pkcs1 2 : RSA-MD2 : md2WithRSAEncryption 62pkcs1 2 : RSA-MD2 : md2WithRSAEncryption
63pkcs1 3 : RSA-MD4 : md4WithRSAEncryption
29pkcs1 4 : RSA-MD5 : md5WithRSAEncryption 64pkcs1 4 : RSA-MD5 : md5WithRSAEncryption
30pkcs1 5 : RSA-SHA1 : sha1WithRSAEncryption 65pkcs1 5 : RSA-SHA1 : sha1WithRSAEncryption
31 66
@@ -61,7 +96,7 @@ pkcs7 6 : : pkcs7-encryptedData
61 96
62pkcs 9 : pkcs9 97pkcs 9 : pkcs9
63!module pkcs9 98!module pkcs9
64pkcs9 1 : Email : emailAddress 99pkcs9 1 : : emailAddress
65pkcs9 2 : : unstructuredName 100pkcs9 2 : : unstructuredName
66pkcs9 3 : : contentType 101pkcs9 3 : : contentType
67pkcs9 4 : : messageDigest 102pkcs9 4 : : messageDigest
@@ -173,6 +208,8 @@ id-smime-cti 6 : id-smime-cti-ets-proofOfCreation
173 208
174pkcs9 20 : : friendlyName 209pkcs9 20 : : friendlyName
175pkcs9 21 : : localKeyID 210pkcs9 21 : : localKeyID
211!Cname ms-csp-name
2121 3 6 1 4 1 311 17 1 : CSPName : Microsoft CSP Name
176!Alias certTypes pkcs9 22 213!Alias certTypes pkcs9 22
177certTypes 1 : : x509Certificate 214certTypes 1 : : x509Certificate
178certTypes 2 : : sdsiCertificate 215certTypes 2 : : sdsiCertificate
@@ -302,6 +339,9 @@ id-pe 6 : aaControls
302id-pe 7 : sbqp-ipAddrBlock 339id-pe 7 : sbqp-ipAddrBlock
303id-pe 8 : sbqp-autonomousSysNum 340id-pe 8 : sbqp-autonomousSysNum
304id-pe 9 : sbqp-routerIdentifier 341id-pe 9 : sbqp-routerIdentifier
342id-pe 10 : ac-proxying
343!Cname sinfo-access
344id-pe 11 : subjectInfoAccess : Subject Information Access
305 345
306# PKIX policyQualifiers for Internet policy qualifiers 346# PKIX policyQualifiers for Internet policy qualifiers
307id-qt 1 : id-qt-cps : Policy Qualifier CPS 347id-qt 1 : id-qt-cps : Policy Qualifier CPS
@@ -396,17 +436,18 @@ id-on 1 : id-on-personalData
396# personal data attributes 436# personal data attributes
397id-pda 1 : id-pda-dateOfBirth 437id-pda 1 : id-pda-dateOfBirth
398id-pda 2 : id-pda-placeOfBirth 438id-pda 2 : id-pda-placeOfBirth
399id-pda 3 : id-pda-pseudonym 439id-pda 3 : id-pda-gender
400id-pda 4 : id-pda-gender 440id-pda 4 : id-pda-countryOfCitizenship
401id-pda 5 : id-pda-countryOfCitizenship 441id-pda 5 : id-pda-countryOfResidence
402id-pda 6 : id-pda-countryOfResidence
403 442
404# attribute certificate attributes 443# attribute certificate attributes
405id-aca 1 : id-aca-authenticationInfo 444id-aca 1 : id-aca-authenticationInfo
406id-aca 2 : id-aca-accessIdentity 445id-aca 2 : id-aca-accessIdentity
407id-aca 3 : id-aca-chargingIdentity 446id-aca 3 : id-aca-chargingIdentity
408id-aca 4 : id-aca-group 447id-aca 4 : id-aca-group
448# attention : the following seems to be obsolete, replace by 'role'
409id-aca 5 : id-aca-role 449id-aca 5 : id-aca-role
450id-aca 6 : id-aca-encAttrs
410 451
411# qualified certificate statements 452# qualified certificate statements
412id-qcs 1 : id-qcs-pkixQCSyntax-v1 453id-qcs 1 : id-qcs-pkixQCSyntax-v1
@@ -434,7 +475,7 @@ id-pkix-OCSP 1 : basicOCSPResponse : Basic OCSP Response
434id-pkix-OCSP 2 : Nonce : OCSP Nonce 475id-pkix-OCSP 2 : Nonce : OCSP Nonce
435id-pkix-OCSP 3 : CrlID : OCSP CRL ID 476id-pkix-OCSP 3 : CrlID : OCSP CRL ID
436id-pkix-OCSP 4 : acceptableResponses : Acceptable OCSP Responses 477id-pkix-OCSP 4 : acceptableResponses : Acceptable OCSP Responses
437id-pkix-OCSP 5 : noCheck 478id-pkix-OCSP 5 : noCheck : OCSP No Check
438id-pkix-OCSP 6 : archiveCutoff : OCSP Archive Cutoff 479id-pkix-OCSP 6 : archiveCutoff : OCSP Archive Cutoff
439id-pkix-OCSP 7 : serviceLocator : OCSP Service Locator 480id-pkix-OCSP 7 : serviceLocator : OCSP Service Locator
440id-pkix-OCSP 8 : extendedStatus : Extended OCSP Status 481id-pkix-OCSP 8 : extendedStatus : Extended OCSP Status
@@ -456,7 +497,9 @@ algorithm 11 : rsaSignature
456algorithm 12 : DSA-old : dsaEncryption-old 497algorithm 12 : DSA-old : dsaEncryption-old
457algorithm 13 : DSA-SHA : dsaWithSHA 498algorithm 13 : DSA-SHA : dsaWithSHA
458algorithm 15 : RSA-SHA : shaWithRSAEncryption 499algorithm 15 : RSA-SHA : shaWithRSAEncryption
500!Cname des-ede-ecb
459algorithm 17 : DES-EDE : des-ede 501algorithm 17 : DES-EDE : des-ede
502!Cname des-ede3-ecb
460 : DES-EDE3 : des-ede3 503 : DES-EDE3 : des-ede3
461 : DES-EDE-CBC : des-ede-cbc 504 : DES-EDE-CBC : des-ede-cbc
462!Cname des-ede-cfb64 505!Cname des-ede-cfb64
@@ -484,20 +527,22 @@ algorithm 29 : RSA-SHA1-2 : sha1WithRSA
484 527
485X500 4 : X509 528X500 4 : X509
486X509 3 : CN : commonName 529X509 3 : CN : commonName
487X509 4 : S : surname 530X509 4 : SN : surname
488X509 5 : SN : serialNumber 531X509 5 : : serialNumber
489X509 6 : C : countryName 532X509 6 : C : countryName
490X509 7 : L : localityName 533X509 7 : L : localityName
491X509 8 : ST : stateOrProvinceName 534X509 8 : ST : stateOrProvinceName
492X509 10 : O : organizationName 535X509 10 : O : organizationName
493X509 11 : OU : organizationalUnitName 536X509 11 : OU : organizationalUnitName
494X509 12 : T : title 537X509 12 : : title
495X509 13 : D : description 538X509 13 : : description
496X509 41 : name : name 539X509 41 : name : name
497X509 42 : G : givenName 540X509 42 : gn : givenName
498X509 43 : I : initials 541X509 43 : : initials
499X509 45 : UID : uniqueIdentifier 542X509 44 : : generationQualifier
543X509 45 : : x500UniqueIdentifier
500X509 46 : dnQualifier : dnQualifier 544X509 46 : dnQualifier : dnQualifier
545X509 72 : role : role
501 546
502X500 8 : X500algorithms : directory services - algorithms 547X500 8 : X500algorithms : directory services - algorithms
503X500algorithms 1 1 : RSA : rsa 548X500algorithms 1 1 : RSA : rsa
@@ -531,8 +576,14 @@ id-ce 31 : crlDistributionPoints : X509v3 CRL Distribution Points
531id-ce 32 : certificatePolicies : X509v3 Certificate Policies 576id-ce 32 : certificatePolicies : X509v3 Certificate Policies
532!Cname authority-key-identifier 577!Cname authority-key-identifier
533id-ce 35 : authorityKeyIdentifier : X509v3 Authority Key Identifier 578id-ce 35 : authorityKeyIdentifier : X509v3 Authority Key Identifier
579!Cname policy-constraints
580id-ce 36 : policyConstraints : X509v3 Policy Constraints
534!Cname ext-key-usage 581!Cname ext-key-usage
535id-ce 37 : extendedKeyUsage : X509v3 Extended Key Usage 582id-ce 37 : extendedKeyUsage : X509v3 Extended Key Usage
583!Cname target-information
584id-ce 55 : targetInformation : X509v3 AC Targeting
585!Cname no-rev-avail
586id-ce 56 : noRevAvail : X509v3 No Revocation Available
536 587
537!Cname netscape 588!Cname netscape
5382 16 840 1 113730 : Netscape : Netscape Communications Corp. 5892 16 840 1 113730 : Netscape : Netscape Communications Corp.
@@ -573,17 +624,24 @@ internet 3 : experimental : Experimental
573internet 4 : private : Private 624internet 4 : private : Private
574internet 5 : security : Security 625internet 5 : security : Security
575internet 6 : snmpv2 : SNMPv2 626internet 6 : snmpv2 : SNMPv2
576internet 7 : mail : Mail 627# Documents refer to "internet 7" as "mail". This however leads to ambiguities
628# with RFC2798, Section 9.1.3, where "mail" is defined as the short name for
629# rfc822Mailbox. The short name is therefore here left out for a reason.
630# Subclasses of "mail", e.g. "MIME MHS" don't consitute a problem, as
631# references are realized via long name "Mail" (with capital M).
632internet 7 : : Mail
577 633
578private 1 : enterprises : Enterprises 634Private 1 : enterprises : Enterprises
579 635
580# RFC 2247 636# RFC 2247
581enterprises 1466 344 : dcobject : dcObject 637Enterprises 1466 344 : dcobject : dcObject
582 638
583# Stray OIDs we don't know the full name of each step for 639# RFC 1495
584# RFC 2247 640Mail 1 : mime-mhs : MIME MHS
5850 9 2342 19200300 100 1 25 : DC : domainComponent 641mime-mhs 1 : mime-mhs-headings : mime-mhs-headings
5860 9 2342 19200300 100 4 13 : domain : Domain 642mime-mhs 2 : mime-mhs-bodies : mime-mhs-bodies
643mime-mhs-headings 1 : id-hex-partial-message : id-hex-partial-message
644mime-mhs-headings 2 : id-hex-multipart-message : id-hex-multipart-message
587 645
588# What the hell are these OIDs, really? 646# What the hell are these OIDs, really?
589!Cname rle-compression 647!Cname rle-compression
@@ -591,3 +649,116 @@ enterprises 1466 344 : dcobject : dcObject
591!Cname zlib-compression 649!Cname zlib-compression
5921 1 1 1 666 2 : ZLIB : zlib compression 6501 1 1 1 666 2 : ZLIB : zlib compression
593 651
652# AES aka Rijndael
653
654!Alias csor 2 16 840 1 101 3
655!Alias nistAlgorithms csor 4
656!Alias aes nistAlgorithms 1
657
658aes 1 : AES-128-ECB : aes-128-ecb
659aes 2 : AES-128-CBC : aes-128-cbc
660!Cname aes-128-ofb128
661aes 3 : AES-128-OFB : aes-128-ofb
662!Cname aes-128-cfb128
663aes 4 : AES-128-CFB : aes-128-cfb
664
665aes 21 : AES-192-ECB : aes-192-ecb
666aes 22 : AES-192-CBC : aes-192-cbc
667!Cname aes-192-ofb128
668aes 23 : AES-192-OFB : aes-192-ofb
669!Cname aes-192-cfb128
670aes 24 : AES-192-CFB : aes-192-cfb
671
672aes 41 : AES-256-ECB : aes-256-ecb
673aes 42 : AES-256-CBC : aes-256-cbc
674!Cname aes-256-ofb128
675aes 43 : AES-256-OFB : aes-256-ofb
676!Cname aes-256-cfb128
677aes 44 : AES-256-CFB : aes-256-cfb
678
679# Hold instruction CRL entry extension
680!Cname hold-instruction-code
681id-ce 23 : holdInstructionCode : Hold Instruction Code
682!Alias holdInstruction X9-57 2
683!Cname hold-instruction-none
684holdInstruction 1 : holdInstructionNone : Hold Instruction None
685!Cname hold-instruction-call-issuer
686holdInstruction 2 : holdInstructionCallIssuer : Hold Instruction Call Issuer
687!Cname hold-instruction-reject
688holdInstruction 3 : holdInstructionReject : Hold Instruction Reject
689
690# OID's from CCITT. Most of this is defined in RFC 1274. A couple of
691# them are also mentioned in RFC 2247
692ccitt 9 : data
693data 2342 : pss
694pss 19200300 : ucl
695ucl 100 : pilot
696pilot 1 : : pilotAttributeType
697pilot 3 : : pilotAttributeSyntax
698pilot 4 : : pilotObjectClass
699pilot 10 : : pilotGroups
700pilotAttributeSyntax 4 : : iA5StringSyntax
701pilotAttributeSyntax 5 : : caseIgnoreIA5StringSyntax
702pilotObjectClass 3 : : pilotObject
703pilotObjectClass 4 : : pilotPerson
704pilotObjectClass 5 : account
705pilotObjectClass 6 : document
706pilotObjectClass 7 : room
707pilotObjectClass 9 : : documentSeries
708pilotObjectClass 13 : domain : Domain
709pilotObjectClass 14 : : rFC822localPart
710pilotObjectClass 15 : : dNSDomain
711pilotObjectClass 17 : : domainRelatedObject
712pilotObjectClass 18 : : friendlyCountry
713pilotObjectClass 19 : : simpleSecurityObject
714pilotObjectClass 20 : : pilotOrganization
715pilotObjectClass 21 : : pilotDSA
716pilotObjectClass 22 : : qualityLabelledData
717pilotAttributeType 1 : UID : userId
718pilotAttributeType 2 : : textEncodedORAddress
719pilotAttributeType 3 : mail : rfc822Mailbox
720pilotAttributeType 4 : info
721pilotAttributeType 5 : : favouriteDrink
722pilotAttributeType 6 : : roomNumber
723pilotAttributeType 7 : photo
724pilotAttributeType 8 : : userClass
725pilotAttributeType 9 : host
726pilotAttributeType 10 : manager
727pilotAttributeType 11 : : documentIdentifier
728pilotAttributeType 12 : : documentTitle
729pilotAttributeType 13 : : documentVersion
730pilotAttributeType 14 : : documentAuthor
731pilotAttributeType 15 : : documentLocation
732pilotAttributeType 20 : : homeTelephoneNumber
733pilotAttributeType 21 : secretary
734pilotAttributeType 22 : : otherMailbox
735pilotAttributeType 23 : : lastModifiedTime
736pilotAttributeType 24 : : lastModifiedBy
737pilotAttributeType 25 : DC : domainComponent
738pilotAttributeType 26 : : aRecord
739pilotAttributeType 27 : : pilotAttributeType27
740pilotAttributeType 28 : : mXRecord
741pilotAttributeType 29 : : nSRecord
742pilotAttributeType 30 : : sOARecord
743pilotAttributeType 31 : : cNAMERecord
744pilotAttributeType 37 : : associatedDomain
745pilotAttributeType 38 : : associatedName
746pilotAttributeType 39 : : homePostalAddress
747pilotAttributeType 40 : : personalTitle
748pilotAttributeType 41 : : mobileTelephoneNumber
749pilotAttributeType 42 : : pagerTelephoneNumber
750pilotAttributeType 43 : : friendlyCountryName
751# The following clashes with 2.5.4.45, so commented away
752#pilotAttributeType 44 : uid : uniqueIdentifier
753pilotAttributeType 45 : : organizationalStatus
754pilotAttributeType 46 : : janetMailbox
755pilotAttributeType 47 : : mailPreferenceOption
756pilotAttributeType 48 : : buildingName
757pilotAttributeType 49 : : dSAQuality
758pilotAttributeType 50 : : singleLevelQuality
759pilotAttributeType 51 : : subtreeMinimumQuality
760pilotAttributeType 52 : : subtreeMaximumQuality
761pilotAttributeType 53 : : personalSignature
762pilotAttributeType 54 : : dITRedirect
763pilotAttributeType 55 : audio
764pilotAttributeType 56 : : documentPublisher
diff --git a/src/lib/libcrypto/ocsp/Makefile.ssl b/src/lib/libcrypto/ocsp/Makefile.ssl
new file mode 100644
index 0000000000..b69abdc1c7
--- /dev/null
+++ b/src/lib/libcrypto/ocsp/Makefile.ssl
@@ -0,0 +1,221 @@
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 $(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) $(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/asn1.h ../../include/openssl/asn1t.h
86ocsp_asn.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
87ocsp_asn.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
88ocsp_asn.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
89ocsp_asn.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
90ocsp_asn.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
91ocsp_asn.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
92ocsp_asn.o: ../../include/openssl/ocsp.h ../../include/openssl/opensslconf.h
93ocsp_asn.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
94ocsp_asn.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
95ocsp_asn.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
96ocsp_asn.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
97ocsp_asn.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
98ocsp_asn.o: ../../include/openssl/x509v3.h ocsp_asn.c
99ocsp_cl.o: ../../e_os.h ../../include/openssl/asn1.h
100ocsp_cl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
101ocsp_cl.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
102ocsp_cl.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
103ocsp_cl.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
104ocsp_cl.o: ../../include/openssl/err.h ../../include/openssl/evp.h
105ocsp_cl.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
106ocsp_cl.o: ../../include/openssl/objects.h ../../include/openssl/ocsp.h
107ocsp_cl.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
108ocsp_cl.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h
109ocsp_cl.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h
110ocsp_cl.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
111ocsp_cl.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
112ocsp_cl.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
113ocsp_cl.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
114ocsp_cl.o: ../../include/openssl/x509v3.h ../cryptlib.h ocsp_cl.c
115ocsp_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
116ocsp_err.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
117ocsp_err.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
118ocsp_err.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
119ocsp_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
120ocsp_err.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
121ocsp_err.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
122ocsp_err.o: ../../include/openssl/ocsp.h ../../include/openssl/opensslconf.h
123ocsp_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
124ocsp_err.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
125ocsp_err.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
126ocsp_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
127ocsp_err.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
128ocsp_err.o: ../../include/openssl/x509v3.h ocsp_err.c
129ocsp_ext.o: ../../e_os.h ../../include/openssl/asn1.h
130ocsp_ext.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
131ocsp_ext.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
132ocsp_ext.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
133ocsp_ext.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
134ocsp_ext.o: ../../include/openssl/err.h ../../include/openssl/evp.h
135ocsp_ext.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
136ocsp_ext.o: ../../include/openssl/objects.h ../../include/openssl/ocsp.h
137ocsp_ext.o: ../../include/openssl/opensslconf.h
138ocsp_ext.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
139ocsp_ext.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
140ocsp_ext.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
141ocsp_ext.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
142ocsp_ext.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
143ocsp_ext.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
144ocsp_ext.o: ../cryptlib.h ocsp_ext.c
145ocsp_ht.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
146ocsp_ht.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
147ocsp_ht.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
148ocsp_ht.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
149ocsp_ht.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
150ocsp_ht.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
151ocsp_ht.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
152ocsp_ht.o: ../../include/openssl/ocsp.h ../../include/openssl/opensslconf.h
153ocsp_ht.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
154ocsp_ht.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
155ocsp_ht.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
156ocsp_ht.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
157ocsp_ht.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
158ocsp_ht.o: ../../include/openssl/x509v3.h ocsp_ht.c
159ocsp_lib.o: ../../e_os.h ../../include/openssl/asn1.h
160ocsp_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
161ocsp_lib.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
162ocsp_lib.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
163ocsp_lib.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
164ocsp_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h
165ocsp_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
166ocsp_lib.o: ../../include/openssl/objects.h ../../include/openssl/ocsp.h
167ocsp_lib.o: ../../include/openssl/opensslconf.h
168ocsp_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
169ocsp_lib.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
170ocsp_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
171ocsp_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
172ocsp_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
173ocsp_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
174ocsp_lib.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
175ocsp_lib.o: ../cryptlib.h ocsp_lib.c
176ocsp_prn.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
177ocsp_prn.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
178ocsp_prn.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
179ocsp_prn.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
180ocsp_prn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
181ocsp_prn.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
182ocsp_prn.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
183ocsp_prn.o: ../../include/openssl/ocsp.h ../../include/openssl/opensslconf.h
184ocsp_prn.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
185ocsp_prn.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
186ocsp_prn.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
187ocsp_prn.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
188ocsp_prn.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
189ocsp_prn.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
190ocsp_prn.o: ../../include/openssl/x509v3.h ocsp_prn.c
191ocsp_srv.o: ../../e_os.h ../../include/openssl/asn1.h
192ocsp_srv.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
193ocsp_srv.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
194ocsp_srv.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
195ocsp_srv.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
196ocsp_srv.o: ../../include/openssl/err.h ../../include/openssl/evp.h
197ocsp_srv.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
198ocsp_srv.o: ../../include/openssl/objects.h ../../include/openssl/ocsp.h
199ocsp_srv.o: ../../include/openssl/opensslconf.h
200ocsp_srv.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
201ocsp_srv.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
202ocsp_srv.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
203ocsp_srv.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
204ocsp_srv.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
205ocsp_srv.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
206ocsp_srv.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
207ocsp_srv.o: ../cryptlib.h ocsp_srv.c
208ocsp_vfy.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
209ocsp_vfy.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
210ocsp_vfy.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
211ocsp_vfy.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
212ocsp_vfy.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
213ocsp_vfy.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
214ocsp_vfy.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
215ocsp_vfy.o: ../../include/openssl/ocsp.h ../../include/openssl/opensslconf.h
216ocsp_vfy.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
217ocsp_vfy.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
218ocsp_vfy.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
219ocsp_vfy.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
220ocsp_vfy.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
221ocsp_vfy.o: ../../include/openssl/x509v3.h ocsp_vfy.c
diff --git a/src/lib/libcrypto/ocsp/ocsp.h b/src/lib/libcrypto/ocsp/ocsp.h
new file mode 100644
index 0000000000..fab3c03182
--- /dev/null
+++ b/src/lib/libcrypto/ocsp/ocsp.h
@@ -0,0 +1,619 @@
1/* ocsp.h */
2/* Written by Tom Titchener <Tom_Titchener@groove.net> for the OpenSSL
3 * project. */
4
5/* History:
6 This file was transfered to Richard Levitte from CertCo by Kathy
7 Weinhold in mid-spring 2000 to be included in OpenSSL or released
8 as a patch kit. */
9
10/* ====================================================================
11 * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 *
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 *
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in
22 * the documentation and/or other materials provided with the
23 * distribution.
24 *
25 * 3. All advertising materials mentioning features or use of this
26 * software must display the following acknowledgment:
27 * "This product includes software developed by the OpenSSL Project
28 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
29 *
30 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
31 * endorse or promote products derived from this software without
32 * prior written permission. For written permission, please contact
33 * openssl-core@openssl.org.
34 *
35 * 5. Products derived from this software may not be called "OpenSSL"
36 * nor may "OpenSSL" appear in their names without prior written
37 * permission of the OpenSSL Project.
38 *
39 * 6. Redistributions of any form whatsoever must retain the following
40 * acknowledgment:
41 * "This product includes software developed by the OpenSSL Project
42 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
43 *
44 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
45 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
46 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
47 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
48 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
49 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
50 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
51 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
53 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
54 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
55 * OF THE POSSIBILITY OF SUCH DAMAGE.
56 * ====================================================================
57 *
58 * This product includes cryptographic software written by Eric Young
59 * (eay@cryptsoft.com). This product includes software written by Tim
60 * Hudson (tjh@cryptsoft.com).
61 *
62 */
63
64#ifndef HEADER_OCSP_H
65#define HEADER_OCSP_H
66
67#include <openssl/x509.h>
68#include <openssl/x509v3.h>
69#include <openssl/safestack.h>
70
71#ifdef __cplusplus
72extern "C" {
73#endif
74
75/* Various flags and values */
76
77#define OCSP_DEFAULT_NONCE_LENGTH 16
78
79#define OCSP_NOCERTS 0x1
80#define OCSP_NOINTERN 0x2
81#define OCSP_NOSIGS 0x4
82#define OCSP_NOCHAIN 0x8
83#define OCSP_NOVERIFY 0x10
84#define OCSP_NOEXPLICIT 0x20
85#define OCSP_NOCASIGN 0x40
86#define OCSP_NODELEGATED 0x80
87#define OCSP_NOCHECKS 0x100
88#define OCSP_TRUSTOTHER 0x200
89#define OCSP_RESPID_KEY 0x400
90#define OCSP_NOTIME 0x800
91
92/* CertID ::= SEQUENCE {
93 * hashAlgorithm AlgorithmIdentifier,
94 * issuerNameHash OCTET STRING, -- Hash of Issuer's DN
95 * issuerKeyHash OCTET STRING, -- Hash of Issuers public key (excluding the tag & length fields)
96 * serialNumber CertificateSerialNumber }
97 */
98typedef struct ocsp_cert_id_st
99 {
100 X509_ALGOR *hashAlgorithm;
101 ASN1_OCTET_STRING *issuerNameHash;
102 ASN1_OCTET_STRING *issuerKeyHash;
103 ASN1_INTEGER *serialNumber;
104 } OCSP_CERTID;
105
106DECLARE_STACK_OF(OCSP_CERTID)
107
108/* Request ::= SEQUENCE {
109 * reqCert CertID,
110 * singleRequestExtensions [0] EXPLICIT Extensions OPTIONAL }
111 */
112typedef struct ocsp_one_request_st
113 {
114 OCSP_CERTID *reqCert;
115 STACK_OF(X509_EXTENSION) *singleRequestExtensions;
116 } OCSP_ONEREQ;
117
118DECLARE_STACK_OF(OCSP_ONEREQ)
119DECLARE_ASN1_SET_OF(OCSP_ONEREQ)
120
121
122/* TBSRequest ::= SEQUENCE {
123 * version [0] EXPLICIT Version DEFAULT v1,
124 * requestorName [1] EXPLICIT GeneralName OPTIONAL,
125 * requestList SEQUENCE OF Request,
126 * requestExtensions [2] EXPLICIT Extensions OPTIONAL }
127 */
128typedef struct ocsp_req_info_st
129 {
130 ASN1_INTEGER *version;
131 GENERAL_NAME *requestorName;
132 STACK_OF(OCSP_ONEREQ) *requestList;
133 STACK_OF(X509_EXTENSION) *requestExtensions;
134 } OCSP_REQINFO;
135
136/* Signature ::= SEQUENCE {
137 * signatureAlgorithm AlgorithmIdentifier,
138 * signature BIT STRING,
139 * certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }
140 */
141typedef struct ocsp_signature_st
142 {
143 X509_ALGOR *signatureAlgorithm;
144 ASN1_BIT_STRING *signature;
145 STACK_OF(X509) *certs;
146 } OCSP_SIGNATURE;
147
148/* OCSPRequest ::= SEQUENCE {
149 * tbsRequest TBSRequest,
150 * optionalSignature [0] EXPLICIT Signature OPTIONAL }
151 */
152typedef struct ocsp_request_st
153 {
154 OCSP_REQINFO *tbsRequest;
155 OCSP_SIGNATURE *optionalSignature; /* OPTIONAL */
156 } OCSP_REQUEST;
157
158/* OCSPResponseStatus ::= ENUMERATED {
159 * successful (0), --Response has valid confirmations
160 * malformedRequest (1), --Illegal confirmation request
161 * internalError (2), --Internal error in issuer
162 * tryLater (3), --Try again later
163 * --(4) is not used
164 * sigRequired (5), --Must sign the request
165 * unauthorized (6) --Request unauthorized
166 * }
167 */
168#define OCSP_RESPONSE_STATUS_SUCCESSFUL 0
169#define OCSP_RESPONSE_STATUS_MALFORMEDREQUEST 1
170#define OCSP_RESPONSE_STATUS_INTERNALERROR 2
171#define OCSP_RESPONSE_STATUS_TRYLATER 3
172#define OCSP_RESPONSE_STATUS_SIGREQUIRED 5
173#define OCSP_RESPONSE_STATUS_UNAUTHORIZED 6
174
175/* ResponseBytes ::= SEQUENCE {
176 * responseType OBJECT IDENTIFIER,
177 * response OCTET STRING }
178 */
179typedef struct ocsp_resp_bytes_st
180 {
181 ASN1_OBJECT *responseType;
182 ASN1_OCTET_STRING *response;
183 } OCSP_RESPBYTES;
184
185/* OCSPResponse ::= SEQUENCE {
186 * responseStatus OCSPResponseStatus,
187 * responseBytes [0] EXPLICIT ResponseBytes OPTIONAL }
188 */
189typedef struct ocsp_response_st
190 {
191 ASN1_ENUMERATED *responseStatus;
192 OCSP_RESPBYTES *responseBytes;
193 } OCSP_RESPONSE;
194
195/* ResponderID ::= CHOICE {
196 * byName [1] Name,
197 * byKey [2] KeyHash }
198 */
199#define V_OCSP_RESPID_NAME 0
200#define V_OCSP_RESPID_KEY 1
201typedef struct ocsp_responder_id_st
202 {
203 int type;
204 union {
205 X509_NAME* byName;
206 ASN1_OCTET_STRING *byKey;
207 } value;
208 } OCSP_RESPID;
209/* KeyHash ::= OCTET STRING --SHA-1 hash of responder's public key
210 * --(excluding the tag and length fields)
211 */
212
213/* RevokedInfo ::= SEQUENCE {
214 * revocationTime GeneralizedTime,
215 * revocationReason [0] EXPLICIT CRLReason OPTIONAL }
216 */
217typedef struct ocsp_revoked_info_st
218 {
219 ASN1_GENERALIZEDTIME *revocationTime;
220 ASN1_ENUMERATED *revocationReason;
221 } OCSP_REVOKEDINFO;
222
223/* CertStatus ::= CHOICE {
224 * good [0] IMPLICIT NULL,
225 * revoked [1] IMPLICIT RevokedInfo,
226 * unknown [2] IMPLICIT UnknownInfo }
227 */
228#define V_OCSP_CERTSTATUS_GOOD 0
229#define V_OCSP_CERTSTATUS_REVOKED 1
230#define V_OCSP_CERTSTATUS_UNKNOWN 2
231typedef struct ocsp_cert_status_st
232 {
233 int type;
234 union {
235 ASN1_NULL *good;
236 OCSP_REVOKEDINFO *revoked;
237 ASN1_NULL *unknown;
238 } value;
239 } OCSP_CERTSTATUS;
240
241/* SingleResponse ::= SEQUENCE {
242 * certID CertID,
243 * certStatus CertStatus,
244 * thisUpdate GeneralizedTime,
245 * nextUpdate [0] EXPLICIT GeneralizedTime OPTIONAL,
246 * singleExtensions [1] EXPLICIT Extensions OPTIONAL }
247 */
248typedef struct ocsp_single_response_st
249 {
250 OCSP_CERTID *certId;
251 OCSP_CERTSTATUS *certStatus;
252 ASN1_GENERALIZEDTIME *thisUpdate;
253 ASN1_GENERALIZEDTIME *nextUpdate;
254 STACK_OF(X509_EXTENSION) *singleExtensions;
255 } OCSP_SINGLERESP;
256
257DECLARE_STACK_OF(OCSP_SINGLERESP)
258DECLARE_ASN1_SET_OF(OCSP_SINGLERESP)
259
260/* ResponseData ::= SEQUENCE {
261 * version [0] EXPLICIT Version DEFAULT v1,
262 * responderID ResponderID,
263 * producedAt GeneralizedTime,
264 * responses SEQUENCE OF SingleResponse,
265 * responseExtensions [1] EXPLICIT Extensions OPTIONAL }
266 */
267typedef struct ocsp_response_data_st
268 {
269 ASN1_INTEGER *version;
270 OCSP_RESPID *responderId;
271 ASN1_GENERALIZEDTIME *producedAt;
272 STACK_OF(OCSP_SINGLERESP) *responses;
273 STACK_OF(X509_EXTENSION) *responseExtensions;
274 } OCSP_RESPDATA;
275
276/* BasicOCSPResponse ::= SEQUENCE {
277 * tbsResponseData ResponseData,
278 * signatureAlgorithm AlgorithmIdentifier,
279 * signature BIT STRING,
280 * certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }
281 */
282 /* Note 1:
283 The value for "signature" is specified in the OCSP rfc2560 as follows:
284 "The value for the signature SHALL be computed on the hash of the DER
285 encoding ResponseData." This means that you must hash the DER-encoded
286 tbsResponseData, and then run it through a crypto-signing function, which
287 will (at least w/RSA) do a hash-'n'-private-encrypt operation. This seems
288 a bit odd, but that's the spec. Also note that the data structures do not
289 leave anywhere to independently specify the algorithm used for the initial
290 hash. So, we look at the signature-specification algorithm, and try to do
291 something intelligent. -- Kathy Weinhold, CertCo */
292 /* Note 2:
293 It seems that the mentioned passage from RFC 2560 (section 4.2.1) is open
294 for interpretation. I've done tests against another responder, and found
295 that it doesn't do the double hashing that the RFC seems to say one
296 should. Therefore, all relevant functions take a flag saying which
297 variant should be used. -- Richard Levitte, OpenSSL team and CeloCom */
298typedef struct ocsp_basic_response_st
299 {
300 OCSP_RESPDATA *tbsResponseData;
301 X509_ALGOR *signatureAlgorithm;
302 ASN1_BIT_STRING *signature;
303 STACK_OF(X509) *certs;
304 } OCSP_BASICRESP;
305
306/*
307 * CRLReason ::= ENUMERATED {
308 * unspecified (0),
309 * keyCompromise (1),
310 * cACompromise (2),
311 * affiliationChanged (3),
312 * superseded (4),
313 * cessationOfOperation (5),
314 * certificateHold (6),
315 * removeFromCRL (8) }
316 */
317#define OCSP_REVOKED_STATUS_NOSTATUS -1
318#define OCSP_REVOKED_STATUS_UNSPECIFIED 0
319#define OCSP_REVOKED_STATUS_KEYCOMPROMISE 1
320#define OCSP_REVOKED_STATUS_CACOMPROMISE 2
321#define OCSP_REVOKED_STATUS_AFFILIATIONCHANGED 3
322#define OCSP_REVOKED_STATUS_SUPERSEDED 4
323#define OCSP_REVOKED_STATUS_CESSATIONOFOPERATION 5
324#define OCSP_REVOKED_STATUS_CERTIFICATEHOLD 6
325#define OCSP_REVOKED_STATUS_REMOVEFROMCRL 8
326
327/* CrlID ::= SEQUENCE {
328 * crlUrl [0] EXPLICIT IA5String OPTIONAL,
329 * crlNum [1] EXPLICIT INTEGER OPTIONAL,
330 * crlTime [2] EXPLICIT GeneralizedTime OPTIONAL }
331 */
332typedef struct ocsp_crl_id_st
333 {
334 ASN1_IA5STRING *crlUrl;
335 ASN1_INTEGER *crlNum;
336 ASN1_GENERALIZEDTIME *crlTime;
337 } OCSP_CRLID;
338
339/* ServiceLocator ::= SEQUENCE {
340 * issuer Name,
341 * locator AuthorityInfoAccessSyntax OPTIONAL }
342 */
343typedef struct ocsp_service_locator_st
344 {
345 X509_NAME* issuer;
346 STACK_OF(ACCESS_DESCRIPTION) *locator;
347 } OCSP_SERVICELOC;
348
349#define PEM_STRING_OCSP_REQUEST "OCSP REQUEST"
350#define PEM_STRING_OCSP_RESPONSE "OCSP RESPONSE"
351
352#define d2i_OCSP_REQUEST_bio(bp,p) (OCSP_REQUEST*)ASN1_d2i_bio((char*(*)()) \
353 OCSP_REQUEST_new,(char *(*)())d2i_OCSP_REQUEST, (bp),\
354 (unsigned char **)(p))
355
356#define d2i_OCSP_RESPONSE_bio(bp,p) (OCSP_RESPONSE*)ASN1_d2i_bio((char*(*)())\
357 OCSP_REQUEST_new,(char *(*)())d2i_OCSP_RESPONSE, (bp),\
358 (unsigned char **)(p))
359
360#define PEM_read_bio_OCSP_REQUEST(bp,x,cb) (OCSP_REQUEST *)PEM_ASN1_read_bio( \
361 (char *(*)())d2i_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,bp,(char **)x,cb,NULL)
362
363#define PEM_read_bio_OCSP_RESPONSE(bp,x,cb)(OCSP_RESPONSE *)PEM_ASN1_read_bio(\
364 (char *(*)())d2i_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,bp,(char **)x,cb,NULL)
365
366#define PEM_write_bio_OCSP_REQUEST(bp,o) \
367 PEM_ASN1_write_bio((int (*)())i2d_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,\
368 bp,(char *)o, NULL,NULL,0,NULL,NULL)
369
370#define PEM_write_bio_OCSP_RESPONSE(bp,o) \
371 PEM_ASN1_write_bio((int (*)())i2d_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,\
372 bp,(char *)o, NULL,NULL,0,NULL,NULL)
373
374#define i2d_OCSP_RESPONSE_bio(bp,o) ASN1_i2d_bio(i2d_OCSP_RESPONSE,bp,\
375 (unsigned char *)o)
376
377#define i2d_OCSP_REQUEST_bio(bp,o) ASN1_i2d_bio(i2d_OCSP_REQUEST,bp,\
378 (unsigned char *)o)
379
380#define OCSP_REQUEST_sign(o,pkey,md) \
381 ASN1_item_sign(ASN1_ITEM_rptr(OCSP_REQINFO),\
382 o->optionalSignature->signatureAlgorithm,NULL,\
383 o->optionalSignature->signature,o->tbsRequest,pkey,md)
384
385#define OCSP_BASICRESP_sign(o,pkey,md,d) \
386 ASN1_item_sign(ASN1_ITEM_rptr(OCSP_RESPDATA),o->signatureAlgorithm,NULL,\
387 o->signature,o->tbsResponseData,pkey,md)
388
389#define OCSP_REQUEST_verify(a,r) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_REQINFO),\
390 a->optionalSignature->signatureAlgorithm,\
391 a->optionalSignature->signature,a->tbsRequest,r)
392
393#define OCSP_BASICRESP_verify(a,r,d) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_RESPDATA),\
394 a->signatureAlgorithm,a->signature,a->tbsResponseData,r)
395
396#define ASN1_BIT_STRING_digest(data,type,md,len) \
397 ASN1_item_digest(ASN1_ITEM_rptr(ASN1_BIT_STRING),type,data,md,len)
398
399#define OCSP_CERTID_dup(cid) (OCSP_CERTID*)ASN1_dup((int(*)())i2d_OCSP_CERTID,\
400 (char *(*)())d2i_OCSP_CERTID,(char *)(cid))
401
402#define OCSP_CERTSTATUS_dup(cs)\
403 (OCSP_CERTSTATUS*)ASN1_dup((int(*)())i2d_OCSP_CERTSTATUS,\
404 (char *(*)())d2i_OCSP_CERTSTATUS,(char *)(cs))
405
406OCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, char *path, OCSP_REQUEST *req);
407
408OCSP_CERTID *OCSP_cert_to_id(const EVP_MD *dgst, X509 *subject, X509 *issuer);
409
410OCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst,
411 X509_NAME *issuerName,
412 ASN1_BIT_STRING* issuerKey,
413 ASN1_INTEGER *serialNumber);
414
415OCSP_ONEREQ *OCSP_request_add0_id(OCSP_REQUEST *req, OCSP_CERTID *cid);
416
417int OCSP_request_add1_nonce(OCSP_REQUEST *req, unsigned char *val, int len);
418int OCSP_basic_add1_nonce(OCSP_BASICRESP *resp, unsigned char *val, int len);
419int OCSP_check_nonce(OCSP_REQUEST *req, OCSP_BASICRESP *bs);
420int OCSP_copy_nonce(OCSP_BASICRESP *resp, OCSP_REQUEST *req);
421
422int OCSP_request_set1_name(OCSP_REQUEST *req, X509_NAME *nm);
423int OCSP_request_add1_cert(OCSP_REQUEST *req, X509 *cert);
424
425int OCSP_request_sign(OCSP_REQUEST *req,
426 X509 *signer,
427 EVP_PKEY *key,
428 const EVP_MD *dgst,
429 STACK_OF(X509) *certs,
430 unsigned long flags);
431
432int OCSP_response_status(OCSP_RESPONSE *resp);
433OCSP_BASICRESP *OCSP_response_get1_basic(OCSP_RESPONSE *resp);
434
435int OCSP_resp_count(OCSP_BASICRESP *bs);
436OCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx);
437int OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last);
438int OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason,
439 ASN1_GENERALIZEDTIME **revtime,
440 ASN1_GENERALIZEDTIME **thisupd,
441 ASN1_GENERALIZEDTIME **nextupd);
442int OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status,
443 int *reason,
444 ASN1_GENERALIZEDTIME **revtime,
445 ASN1_GENERALIZEDTIME **thisupd,
446 ASN1_GENERALIZEDTIME **nextupd);
447int OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd,
448 ASN1_GENERALIZEDTIME *nextupd,
449 long sec, long maxsec);
450
451int OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) *certs, X509_STORE *store, unsigned long flags);
452
453int OCSP_parse_url(char *url, char **phost, char **pport, char **ppath, int *pssl);
454
455int OCSP_id_issuer_cmp(OCSP_CERTID *a, OCSP_CERTID *b);
456int OCSP_id_cmp(OCSP_CERTID *a, OCSP_CERTID *b);
457
458int OCSP_request_onereq_count(OCSP_REQUEST *req);
459OCSP_ONEREQ *OCSP_request_onereq_get0(OCSP_REQUEST *req, int i);
460OCSP_CERTID *OCSP_onereq_get0_id(OCSP_ONEREQ *one);
461int OCSP_id_get0_info(ASN1_OCTET_STRING **piNameHash, ASN1_OBJECT **pmd,
462 ASN1_OCTET_STRING **pikeyHash,
463 ASN1_INTEGER **pserial, OCSP_CERTID *cid);
464int OCSP_request_is_signed(OCSP_REQUEST *req);
465OCSP_RESPONSE *OCSP_response_create(int status, OCSP_BASICRESP *bs);
466OCSP_SINGLERESP *OCSP_basic_add1_status(OCSP_BASICRESP *rsp,
467 OCSP_CERTID *cid,
468 int status, int reason,
469 ASN1_TIME *revtime,
470 ASN1_TIME *thisupd, ASN1_TIME *nextupd);
471int OCSP_basic_add1_cert(OCSP_BASICRESP *resp, X509 *cert);
472int OCSP_basic_sign(OCSP_BASICRESP *brsp,
473 X509 *signer, EVP_PKEY *key, const EVP_MD *dgst,
474 STACK_OF(X509) *certs, unsigned long flags);
475
476ASN1_STRING *ASN1_STRING_encode(ASN1_STRING *s, int (*i2d)(),
477 char *data, STACK_OF(ASN1_OBJECT) *sk);
478
479X509_EXTENSION *OCSP_crlID_new(char *url, long *n, char *tim);
480
481X509_EXTENSION *OCSP_accept_responses_new(char **oids);
482
483X509_EXTENSION *OCSP_archive_cutoff_new(char* tim);
484
485X509_EXTENSION *OCSP_url_svcloc_new(X509_NAME* issuer, char **urls);
486
487int OCSP_REQUEST_get_ext_count(OCSP_REQUEST *x);
488int OCSP_REQUEST_get_ext_by_NID(OCSP_REQUEST *x, int nid, int lastpos);
489int OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, ASN1_OBJECT *obj, int lastpos);
490int OCSP_REQUEST_get_ext_by_critical(OCSP_REQUEST *x, int crit, int lastpos);
491X509_EXTENSION *OCSP_REQUEST_get_ext(OCSP_REQUEST *x, int loc);
492X509_EXTENSION *OCSP_REQUEST_delete_ext(OCSP_REQUEST *x, int loc);
493void *OCSP_REQUEST_get1_ext_d2i(OCSP_REQUEST *x, int nid, int *crit, int *idx);
494int OCSP_REQUEST_add1_ext_i2d(OCSP_REQUEST *x, int nid, void *value, int crit,
495 unsigned long flags);
496int OCSP_REQUEST_add_ext(OCSP_REQUEST *x, X509_EXTENSION *ex, int loc);
497
498int OCSP_ONEREQ_get_ext_count(OCSP_ONEREQ *x);
499int OCSP_ONEREQ_get_ext_by_NID(OCSP_ONEREQ *x, int nid, int lastpos);
500int OCSP_ONEREQ_get_ext_by_OBJ(OCSP_ONEREQ *x, ASN1_OBJECT *obj, int lastpos);
501int OCSP_ONEREQ_get_ext_by_critical(OCSP_ONEREQ *x, int crit, int lastpos);
502X509_EXTENSION *OCSP_ONEREQ_get_ext(OCSP_ONEREQ *x, int loc);
503X509_EXTENSION *OCSP_ONEREQ_delete_ext(OCSP_ONEREQ *x, int loc);
504void *OCSP_ONEREQ_get1_ext_d2i(OCSP_ONEREQ *x, int nid, int *crit, int *idx);
505int OCSP_ONEREQ_add1_ext_i2d(OCSP_ONEREQ *x, int nid, void *value, int crit,
506 unsigned long flags);
507int OCSP_ONEREQ_add_ext(OCSP_ONEREQ *x, X509_EXTENSION *ex, int loc);
508
509int OCSP_BASICRESP_get_ext_count(OCSP_BASICRESP *x);
510int OCSP_BASICRESP_get_ext_by_NID(OCSP_BASICRESP *x, int nid, int lastpos);
511int OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, ASN1_OBJECT *obj, int lastpos);
512int OCSP_BASICRESP_get_ext_by_critical(OCSP_BASICRESP *x, int crit, int lastpos);
513X509_EXTENSION *OCSP_BASICRESP_get_ext(OCSP_BASICRESP *x, int loc);
514X509_EXTENSION *OCSP_BASICRESP_delete_ext(OCSP_BASICRESP *x, int loc);
515void *OCSP_BASICRESP_get1_ext_d2i(OCSP_BASICRESP *x, int nid, int *crit, int *idx);
516int OCSP_BASICRESP_add1_ext_i2d(OCSP_BASICRESP *x, int nid, void *value, int crit,
517 unsigned long flags);
518int OCSP_BASICRESP_add_ext(OCSP_BASICRESP *x, X509_EXTENSION *ex, int loc);
519
520int OCSP_SINGLERESP_get_ext_count(OCSP_SINGLERESP *x);
521int OCSP_SINGLERESP_get_ext_by_NID(OCSP_SINGLERESP *x, int nid, int lastpos);
522int OCSP_SINGLERESP_get_ext_by_OBJ(OCSP_SINGLERESP *x, ASN1_OBJECT *obj, int lastpos);
523int OCSP_SINGLERESP_get_ext_by_critical(OCSP_SINGLERESP *x, int crit, int lastpos);
524X509_EXTENSION *OCSP_SINGLERESP_get_ext(OCSP_SINGLERESP *x, int loc);
525X509_EXTENSION *OCSP_SINGLERESP_delete_ext(OCSP_SINGLERESP *x, int loc);
526void *OCSP_SINGLERESP_get1_ext_d2i(OCSP_SINGLERESP *x, int nid, int *crit, int *idx);
527int OCSP_SINGLERESP_add1_ext_i2d(OCSP_SINGLERESP *x, int nid, void *value, int crit,
528 unsigned long flags);
529int OCSP_SINGLERESP_add_ext(OCSP_SINGLERESP *x, X509_EXTENSION *ex, int loc);
530
531DECLARE_ASN1_FUNCTIONS(OCSP_SINGLERESP)
532DECLARE_ASN1_FUNCTIONS(OCSP_CERTSTATUS)
533DECLARE_ASN1_FUNCTIONS(OCSP_REVOKEDINFO)
534DECLARE_ASN1_FUNCTIONS(OCSP_BASICRESP)
535DECLARE_ASN1_FUNCTIONS(OCSP_RESPDATA)
536DECLARE_ASN1_FUNCTIONS(OCSP_RESPID)
537DECLARE_ASN1_FUNCTIONS(OCSP_RESPONSE)
538DECLARE_ASN1_FUNCTIONS(OCSP_RESPBYTES)
539DECLARE_ASN1_FUNCTIONS(OCSP_ONEREQ)
540DECLARE_ASN1_FUNCTIONS(OCSP_CERTID)
541DECLARE_ASN1_FUNCTIONS(OCSP_REQUEST)
542DECLARE_ASN1_FUNCTIONS(OCSP_SIGNATURE)
543DECLARE_ASN1_FUNCTIONS(OCSP_REQINFO)
544DECLARE_ASN1_FUNCTIONS(OCSP_CRLID)
545DECLARE_ASN1_FUNCTIONS(OCSP_SERVICELOC)
546
547char *OCSP_response_status_str(long s);
548char *OCSP_cert_status_str(long s);
549char *OCSP_crl_reason_str(long s);
550
551int OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST* a, unsigned long flags);
552int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* o, unsigned long flags);
553
554int OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs,
555 X509_STORE *st, unsigned long flags);
556
557/* BEGIN ERROR CODES */
558/* The following lines are auto generated by the script mkerr.pl. Any changes
559 * made after this point may be overwritten when the script is next run.
560 */
561void ERR_load_OCSP_strings(void);
562
563/* Error codes for the OCSP functions. */
564
565/* Function codes. */
566#define OCSP_F_ASN1_STRING_ENCODE 100
567#define OCSP_F_CERT_ID_NEW 101
568#define OCSP_F_D2I_OCSP_NONCE 102
569#define OCSP_F_OCSP_BASIC_ADD1_STATUS 103
570#define OCSP_F_OCSP_BASIC_SIGN 104
571#define OCSP_F_OCSP_BASIC_VERIFY 105
572#define OCSP_F_OCSP_CHECK_DELEGATED 106
573#define OCSP_F_OCSP_CHECK_IDS 107
574#define OCSP_F_OCSP_CHECK_ISSUER 108
575#define OCSP_F_OCSP_CHECK_VALIDITY 115
576#define OCSP_F_OCSP_MATCH_ISSUERID 109
577#define OCSP_F_OCSP_PARSE_URL 114
578#define OCSP_F_OCSP_REQUEST_SIGN 110
579#define OCSP_F_OCSP_REQUEST_VERIFY 116
580#define OCSP_F_OCSP_RESPONSE_GET1_BASIC 111
581#define OCSP_F_OCSP_SENDREQ_BIO 112
582#define OCSP_F_REQUEST_VERIFY 113
583
584/* Reason codes. */
585#define OCSP_R_BAD_DATA 100
586#define OCSP_R_CERTIFICATE_VERIFY_ERROR 101
587#define OCSP_R_DIGEST_ERR 102
588#define OCSP_R_ERROR_IN_NEXTUPDATE_FIELD 122
589#define OCSP_R_ERROR_IN_THISUPDATE_FIELD 123
590#define OCSP_R_ERROR_PARSING_URL 121
591#define OCSP_R_MISSING_OCSPSIGNING_USAGE 103
592#define OCSP_R_NEXTUPDATE_BEFORE_THISUPDATE 124
593#define OCSP_R_NOT_BASIC_RESPONSE 104
594#define OCSP_R_NO_CERTIFICATES_IN_CHAIN 105
595#define OCSP_R_NO_CONTENT 106
596#define OCSP_R_NO_PUBLIC_KEY 107
597#define OCSP_R_NO_RESPONSE_DATA 108
598#define OCSP_R_NO_REVOKED_TIME 109
599#define OCSP_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 110
600#define OCSP_R_REQUEST_NOT_SIGNED 128
601#define OCSP_R_RESPONSE_CONTAINS_NO_REVOCATION_DATA 111
602#define OCSP_R_ROOT_CA_NOT_TRUSTED 112
603#define OCSP_R_SERVER_READ_ERROR 113
604#define OCSP_R_SERVER_RESPONSE_ERROR 114
605#define OCSP_R_SERVER_RESPONSE_PARSE_ERROR 115
606#define OCSP_R_SERVER_WRITE_ERROR 116
607#define OCSP_R_SIGNATURE_FAILURE 117
608#define OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND 118
609#define OCSP_R_STATUS_EXPIRED 125
610#define OCSP_R_STATUS_NOT_YET_VALID 126
611#define OCSP_R_STATUS_TOO_OLD 127
612#define OCSP_R_UNKNOWN_MESSAGE_DIGEST 119
613#define OCSP_R_UNKNOWN_NID 120
614#define OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE 129
615
616#ifdef __cplusplus
617}
618#endif
619#endif
diff --git a/src/lib/libcrypto/ocsp/ocsp_asn.c b/src/lib/libcrypto/ocsp/ocsp_asn.c
new file mode 100644
index 0000000000..8c148cda6a
--- /dev/null
+++ b/src/lib/libcrypto/ocsp/ocsp_asn.c
@@ -0,0 +1,182 @@
1/* ocsp_asn.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) 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#include <openssl/asn1.h>
59#include <openssl/asn1t.h>
60#include <openssl/ocsp.h>
61
62ASN1_SEQUENCE(OCSP_SIGNATURE) = {
63 ASN1_SIMPLE(OCSP_SIGNATURE, signatureAlgorithm, X509_ALGOR),
64 ASN1_SIMPLE(OCSP_SIGNATURE, signature, ASN1_BIT_STRING),
65 ASN1_EXP_SEQUENCE_OF(OCSP_SIGNATURE, certs, X509, 0)
66} ASN1_SEQUENCE_END(OCSP_SIGNATURE)
67
68IMPLEMENT_ASN1_FUNCTIONS(OCSP_SIGNATURE)
69
70ASN1_SEQUENCE(OCSP_CERTID) = {
71 ASN1_SIMPLE(OCSP_CERTID, hashAlgorithm, X509_ALGOR),
72 ASN1_SIMPLE(OCSP_CERTID, issuerNameHash, ASN1_OCTET_STRING),
73 ASN1_SIMPLE(OCSP_CERTID, issuerKeyHash, ASN1_OCTET_STRING),
74 ASN1_SIMPLE(OCSP_CERTID, serialNumber, ASN1_INTEGER)
75} ASN1_SEQUENCE_END(OCSP_CERTID)
76
77IMPLEMENT_ASN1_FUNCTIONS(OCSP_CERTID)
78
79ASN1_SEQUENCE(OCSP_ONEREQ) = {
80 ASN1_SIMPLE(OCSP_ONEREQ, reqCert, OCSP_CERTID),
81 ASN1_EXP_SEQUENCE_OF_OPT(OCSP_ONEREQ, singleRequestExtensions, X509_EXTENSION, 0)
82} ASN1_SEQUENCE_END(OCSP_ONEREQ)
83
84IMPLEMENT_ASN1_FUNCTIONS(OCSP_ONEREQ)
85
86ASN1_SEQUENCE(OCSP_REQINFO) = {
87 ASN1_EXP_OPT(OCSP_REQINFO, version, ASN1_INTEGER, 0),
88 ASN1_EXP_OPT(OCSP_REQINFO, requestorName, GENERAL_NAME, 1),
89 ASN1_SEQUENCE_OF(OCSP_REQINFO, requestList, OCSP_ONEREQ),
90 ASN1_EXP_SEQUENCE_OF_OPT(OCSP_REQINFO, requestExtensions, X509_EXTENSION, 2)
91} ASN1_SEQUENCE_END(OCSP_REQINFO)
92
93IMPLEMENT_ASN1_FUNCTIONS(OCSP_REQINFO)
94
95ASN1_SEQUENCE(OCSP_REQUEST) = {
96 ASN1_SIMPLE(OCSP_REQUEST, tbsRequest, OCSP_REQINFO),
97 ASN1_EXP_OPT(OCSP_REQUEST, optionalSignature, OCSP_SIGNATURE, 0)
98} ASN1_SEQUENCE_END(OCSP_REQUEST)
99
100IMPLEMENT_ASN1_FUNCTIONS(OCSP_REQUEST)
101
102/* OCSP_RESPONSE templates */
103
104ASN1_SEQUENCE(OCSP_RESPBYTES) = {
105 ASN1_SIMPLE(OCSP_RESPBYTES, responseType, ASN1_OBJECT),
106 ASN1_SIMPLE(OCSP_RESPBYTES, response, ASN1_OCTET_STRING)
107} ASN1_SEQUENCE_END(OCSP_RESPBYTES)
108
109IMPLEMENT_ASN1_FUNCTIONS(OCSP_RESPBYTES)
110
111ASN1_SEQUENCE(OCSP_RESPONSE) = {
112 ASN1_SIMPLE(OCSP_RESPONSE, responseStatus, ASN1_ENUMERATED),
113 ASN1_EXP_OPT(OCSP_RESPONSE, responseBytes, OCSP_RESPBYTES, 0)
114} ASN1_SEQUENCE_END(OCSP_RESPONSE)
115
116IMPLEMENT_ASN1_FUNCTIONS(OCSP_RESPONSE)
117
118ASN1_CHOICE(OCSP_RESPID) = {
119 ASN1_EXP(OCSP_RESPID, value.byName, X509_NAME, 1),
120 ASN1_IMP(OCSP_RESPID, value.byKey, ASN1_OCTET_STRING, 2)
121} ASN1_CHOICE_END(OCSP_RESPID)
122
123IMPLEMENT_ASN1_FUNCTIONS(OCSP_RESPID)
124
125ASN1_SEQUENCE(OCSP_REVOKEDINFO) = {
126 ASN1_SIMPLE(OCSP_REVOKEDINFO, revocationTime, ASN1_GENERALIZEDTIME),
127 ASN1_EXP_OPT(OCSP_REVOKEDINFO, revocationReason, ASN1_ENUMERATED, 0)
128} ASN1_SEQUENCE_END(OCSP_REVOKEDINFO)
129
130IMPLEMENT_ASN1_FUNCTIONS(OCSP_REVOKEDINFO)
131
132ASN1_CHOICE(OCSP_CERTSTATUS) = {
133 ASN1_IMP(OCSP_CERTSTATUS, value.good, ASN1_NULL, 0),
134 ASN1_IMP(OCSP_CERTSTATUS, value.revoked, OCSP_REVOKEDINFO, 1),
135 ASN1_IMP(OCSP_CERTSTATUS, value.unknown, ASN1_NULL, 2)
136} ASN1_CHOICE_END(OCSP_CERTSTATUS)
137
138IMPLEMENT_ASN1_FUNCTIONS(OCSP_CERTSTATUS)
139
140ASN1_SEQUENCE(OCSP_SINGLERESP) = {
141 ASN1_SIMPLE(OCSP_SINGLERESP, certId, OCSP_CERTID),
142 ASN1_SIMPLE(OCSP_SINGLERESP, certStatus, OCSP_CERTSTATUS),
143 ASN1_SIMPLE(OCSP_SINGLERESP, thisUpdate, ASN1_GENERALIZEDTIME),
144 ASN1_EXP_OPT(OCSP_SINGLERESP, nextUpdate, ASN1_GENERALIZEDTIME, 0),
145 ASN1_EXP_SEQUENCE_OF_OPT(OCSP_SINGLERESP, singleExtensions, X509_EXTENSION, 1)
146} ASN1_SEQUENCE_END(OCSP_SINGLERESP)
147
148IMPLEMENT_ASN1_FUNCTIONS(OCSP_SINGLERESP)
149
150ASN1_SEQUENCE(OCSP_RESPDATA) = {
151 ASN1_EXP_OPT(OCSP_RESPDATA, version, ASN1_INTEGER, 0),
152 ASN1_SIMPLE(OCSP_RESPDATA, responderId, OCSP_RESPID),
153 ASN1_SIMPLE(OCSP_RESPDATA, producedAt, ASN1_GENERALIZEDTIME),
154 ASN1_SEQUENCE_OF(OCSP_RESPDATA, responses, OCSP_SINGLERESP),
155 ASN1_EXP_SEQUENCE_OF_OPT(OCSP_RESPDATA, responseExtensions, X509_EXTENSION, 1)
156} ASN1_SEQUENCE_END(OCSP_RESPDATA)
157
158IMPLEMENT_ASN1_FUNCTIONS(OCSP_RESPDATA)
159
160ASN1_SEQUENCE(OCSP_BASICRESP) = {
161 ASN1_SIMPLE(OCSP_BASICRESP, tbsResponseData, OCSP_RESPDATA),
162 ASN1_SIMPLE(OCSP_BASICRESP, signatureAlgorithm, X509_ALGOR),
163 ASN1_SIMPLE(OCSP_BASICRESP, signature, ASN1_BIT_STRING),
164 ASN1_EXP_SEQUENCE_OF_OPT(OCSP_BASICRESP, certs, X509, 0)
165} ASN1_SEQUENCE_END(OCSP_BASICRESP)
166
167IMPLEMENT_ASN1_FUNCTIONS(OCSP_BASICRESP)
168
169ASN1_SEQUENCE(OCSP_CRLID) = {
170 ASN1_EXP_OPT(OCSP_CRLID, crlUrl, ASN1_IA5STRING, 0),
171 ASN1_EXP_OPT(OCSP_CRLID, crlNum, ASN1_INTEGER, 1),
172 ASN1_EXP_OPT(OCSP_CRLID, crlTime, ASN1_GENERALIZEDTIME, 2)
173} ASN1_SEQUENCE_END(OCSP_CRLID)
174
175IMPLEMENT_ASN1_FUNCTIONS(OCSP_CRLID)
176
177ASN1_SEQUENCE(OCSP_SERVICELOC) = {
178 ASN1_SIMPLE(OCSP_SERVICELOC, issuer, X509_NAME),
179 ASN1_SEQUENCE_OF_OPT(OCSP_SERVICELOC, locator, ACCESS_DESCRIPTION)
180} ASN1_SEQUENCE_END(OCSP_SERVICELOC)
181
182IMPLEMENT_ASN1_FUNCTIONS(OCSP_SERVICELOC)
diff --git a/src/lib/libcrypto/ocsp/ocsp_cl.c b/src/lib/libcrypto/ocsp/ocsp_cl.c
new file mode 100644
index 0000000000..9b3e6dd8ca
--- /dev/null
+++ b/src/lib/libcrypto/ocsp/ocsp_cl.c
@@ -0,0 +1,370 @@
1/* ocsp_cl.c */
2/* Written by Tom Titchener <Tom_Titchener@groove.net> for the OpenSSL
3 * project. */
4
5/* History:
6 This file was transfered to Richard Levitte from CertCo by Kathy
7 Weinhold in mid-spring 2000 to be included in OpenSSL or released
8 as a patch kit. */
9
10/* ====================================================================
11 * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 *
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 *
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in
22 * the documentation and/or other materials provided with the
23 * distribution.
24 *
25 * 3. All advertising materials mentioning features or use of this
26 * software must display the following acknowledgment:
27 * "This product includes software developed by the OpenSSL Project
28 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
29 *
30 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
31 * endorse or promote products derived from this software without
32 * prior written permission. For written permission, please contact
33 * openssl-core@openssl.org.
34 *
35 * 5. Products derived from this software may not be called "OpenSSL"
36 * nor may "OpenSSL" appear in their names without prior written
37 * permission of the OpenSSL Project.
38 *
39 * 6. Redistributions of any form whatsoever must retain the following
40 * acknowledgment:
41 * "This product includes software developed by the OpenSSL Project
42 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
43 *
44 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
45 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
46 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
47 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
48 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
49 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
50 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
51 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
53 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
54 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
55 * OF THE POSSIBILITY OF SUCH DAMAGE.
56 * ====================================================================
57 *
58 * This product includes cryptographic software written by Eric Young
59 * (eay@cryptsoft.com). This product includes software written by Tim
60 * Hudson (tjh@cryptsoft.com).
61 *
62 */
63
64#include <stdio.h>
65#include <time.h>
66#include <cryptlib.h>
67#include <openssl/objects.h>
68#include <openssl/rand.h>
69#include <openssl/x509.h>
70#include <openssl/pem.h>
71#include <openssl/x509v3.h>
72#include <openssl/ocsp.h>
73
74/* Utility functions related to sending OCSP requests and extracting
75 * relevant information from the response.
76 */
77
78/* Add an OCSP_CERTID to an OCSP request. Return new OCSP_ONEREQ
79 * pointer: useful if we want to add extensions.
80 */
81
82OCSP_ONEREQ *OCSP_request_add0_id(OCSP_REQUEST *req, OCSP_CERTID *cid)
83 {
84 OCSP_ONEREQ *one = NULL;
85
86 if (!(one = OCSP_ONEREQ_new())) goto err;
87 if (one->reqCert) OCSP_CERTID_free(one->reqCert);
88 one->reqCert = cid;
89 if (req &&
90 !sk_OCSP_ONEREQ_push(req->tbsRequest->requestList, one))
91 goto err;
92 return one;
93err:
94 OCSP_ONEREQ_free(one);
95 return NULL;
96 }
97
98/* Set requestorName from an X509_NAME structure */
99
100int OCSP_request_set1_name(OCSP_REQUEST *req, X509_NAME *nm)
101 {
102 GENERAL_NAME *gen;
103 gen = GENERAL_NAME_new();
104 if (!X509_NAME_set(&gen->d.directoryName, nm))
105 {
106 GENERAL_NAME_free(gen);
107 return 0;
108 }
109 gen->type = GEN_DIRNAME;
110 if (req->tbsRequest->requestorName)
111 GENERAL_NAME_free(req->tbsRequest->requestorName);
112 req->tbsRequest->requestorName = gen;
113 return 1;
114 }
115
116
117/* Add a certificate to an OCSP request */
118
119int OCSP_request_add1_cert(OCSP_REQUEST *req, X509 *cert)
120 {
121 OCSP_SIGNATURE *sig;
122 if (!req->optionalSignature)
123 req->optionalSignature = OCSP_SIGNATURE_new();
124 sig = req->optionalSignature;
125 if (!sig) return 0;
126 if (!cert) return 1;
127 if (!sig->certs && !(sig->certs = sk_X509_new_null()))
128 return 0;
129
130 if(!sk_X509_push(sig->certs, cert)) return 0;
131 CRYPTO_add(&cert->references, 1, CRYPTO_LOCK_X509);
132 return 1;
133 }
134
135/* Sign an OCSP request set the requestorName to the subjec
136 * name of an optional signers certificate and include one
137 * or more optional certificates in the request. Behaves
138 * like PKCS7_sign().
139 */
140
141int OCSP_request_sign(OCSP_REQUEST *req,
142 X509 *signer,
143 EVP_PKEY *key,
144 const EVP_MD *dgst,
145 STACK_OF(X509) *certs,
146 unsigned long flags)
147 {
148 int i;
149 OCSP_SIGNATURE *sig;
150 X509 *x;
151
152 if (!OCSP_request_set1_name(req, X509_get_subject_name(signer)))
153 goto err;
154
155 if (!(req->optionalSignature = sig = OCSP_SIGNATURE_new())) goto err;
156 if (!dgst) dgst = EVP_sha1();
157 if (key)
158 {
159 if (!X509_check_private_key(signer, key))
160 {
161 OCSPerr(OCSP_F_OCSP_REQUEST_SIGN, OCSP_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE);
162 goto err;
163 }
164 if (!OCSP_REQUEST_sign(req, key, dgst)) goto err;
165 }
166
167 if (!(flags & OCSP_NOCERTS))
168 {
169 if(!OCSP_request_add1_cert(req, signer)) goto err;
170 for (i = 0; i < sk_X509_num(certs); i++)
171 {
172 x = sk_X509_value(certs, i);
173 if (!OCSP_request_add1_cert(req, x)) goto err;
174 }
175 }
176
177 return 1;
178err:
179 OCSP_SIGNATURE_free(req->optionalSignature);
180 req->optionalSignature = NULL;
181 return 0;
182 }
183
184/* Get response status */
185
186int OCSP_response_status(OCSP_RESPONSE *resp)
187 {
188 return ASN1_ENUMERATED_get(resp->responseStatus);
189 }
190
191/* Extract basic response from OCSP_RESPONSE or NULL if
192 * no basic response present.
193 */
194
195
196OCSP_BASICRESP *OCSP_response_get1_basic(OCSP_RESPONSE *resp)
197 {
198 OCSP_RESPBYTES *rb;
199 rb = resp->responseBytes;
200 if (!rb)
201 {
202 OCSPerr(OCSP_F_OCSP_RESPONSE_GET1_BASIC, OCSP_R_NO_RESPONSE_DATA);
203 return NULL;
204 }
205 if (OBJ_obj2nid(rb->responseType) != NID_id_pkix_OCSP_basic)
206 {
207 OCSPerr(OCSP_F_OCSP_RESPONSE_GET1_BASIC, OCSP_R_NOT_BASIC_RESPONSE);
208 return NULL;
209 }
210
211 return ASN1_item_unpack(rb->response, ASN1_ITEM_rptr(OCSP_BASICRESP));
212 }
213
214/* Return number of OCSP_SINGLERESP reponses present in
215 * a basic response.
216 */
217
218int OCSP_resp_count(OCSP_BASICRESP *bs)
219 {
220 if (!bs) return -1;
221 return sk_OCSP_SINGLERESP_num(bs->tbsResponseData->responses);
222 }
223
224/* Extract an OCSP_SINGLERESP response with a given index */
225
226OCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx)
227 {
228 if (!bs) return NULL;
229 return sk_OCSP_SINGLERESP_value(bs->tbsResponseData->responses, idx);
230 }
231
232/* Look single response matching a given certificate ID */
233
234int OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last)
235 {
236 int i;
237 STACK_OF(OCSP_SINGLERESP) *sresp;
238 OCSP_SINGLERESP *single;
239 if (!bs) return -1;
240 if (last < 0) last = 0;
241 else last++;
242 sresp = bs->tbsResponseData->responses;
243 for (i = last; i < sk_OCSP_SINGLERESP_num(sresp); i++)
244 {
245 single = sk_OCSP_SINGLERESP_value(sresp, i);
246 if (!OCSP_id_cmp(id, single->certId)) return i;
247 }
248 return -1;
249 }
250
251/* Extract status information from an OCSP_SINGLERESP structure.
252 * Note: the revtime and reason values are only set if the
253 * certificate status is revoked. Returns numerical value of
254 * status.
255 */
256
257int OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason,
258 ASN1_GENERALIZEDTIME **revtime,
259 ASN1_GENERALIZEDTIME **thisupd,
260 ASN1_GENERALIZEDTIME **nextupd)
261 {
262 int ret;
263 OCSP_CERTSTATUS *cst;
264 if(!single) return -1;
265 cst = single->certStatus;
266 ret = cst->type;
267 if (ret == V_OCSP_CERTSTATUS_REVOKED)
268 {
269 OCSP_REVOKEDINFO *rev = cst->value.revoked;
270 if (revtime) *revtime = rev->revocationTime;
271 if (reason)
272 {
273 if(rev->revocationReason)
274 *reason = ASN1_ENUMERATED_get(rev->revocationReason);
275 else *reason = -1;
276 }
277 }
278 if(thisupd) *thisupd = single->thisUpdate;
279 if(nextupd) *nextupd = single->nextUpdate;
280 return ret;
281 }
282
283/* This function combines the previous ones: look up a certificate ID and
284 * if found extract status information. Return 0 is successful.
285 */
286
287int OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status,
288 int *reason,
289 ASN1_GENERALIZEDTIME **revtime,
290 ASN1_GENERALIZEDTIME **thisupd,
291 ASN1_GENERALIZEDTIME **nextupd)
292 {
293 int i;
294 OCSP_SINGLERESP *single;
295 i = OCSP_resp_find(bs, id, -1);
296 /* Maybe check for multiple responses and give an error? */
297 if(i < 0) return 0;
298 single = OCSP_resp_get0(bs, i);
299 i = OCSP_single_get0_status(single, reason, revtime, thisupd, nextupd);
300 if(status) *status = i;
301 return 1;
302 }
303
304/* Check validity of thisUpdate and nextUpdate fields. It is possible that the request will
305 * take a few seconds to process and/or the time wont be totally accurate. Therefore to avoid
306 * rejecting otherwise valid time we allow the times to be within 'nsec' of the current time.
307 * Also to avoid accepting very old responses without a nextUpdate field an optional maxage
308 * parameter specifies the maximum age the thisUpdate field can be.
309 */
310
311int OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd, ASN1_GENERALIZEDTIME *nextupd, long nsec, long maxsec)
312 {
313 int ret = 1;
314 time_t t_now, t_tmp;
315 time(&t_now);
316 /* Check thisUpdate is valid and not more than nsec in the future */
317 if (!ASN1_GENERALIZEDTIME_check(thisupd))
318 {
319 OCSPerr(OCSP_F_OCSP_CHECK_VALIDITY, OCSP_R_ERROR_IN_THISUPDATE_FIELD);
320 ret = 0;
321 }
322 else
323 {
324 t_tmp = t_now + nsec;
325 if (X509_cmp_time(thisupd, &t_tmp) > 0)
326 {
327 OCSPerr(OCSP_F_OCSP_CHECK_VALIDITY, OCSP_R_STATUS_NOT_YET_VALID);
328 ret = 0;
329 }
330
331 /* If maxsec specified check thisUpdate is not more than maxsec in the past */
332 if (maxsec >= 0)
333 {
334 t_tmp = t_now - maxsec;
335 if (X509_cmp_time(thisupd, &t_tmp) < 0)
336 {
337 OCSPerr(OCSP_F_OCSP_CHECK_VALIDITY, OCSP_R_STATUS_TOO_OLD);
338 ret = 0;
339 }
340 }
341 }
342
343
344 if (!nextupd) return ret;
345
346 /* Check nextUpdate is valid and not more than nsec in the past */
347 if (!ASN1_GENERALIZEDTIME_check(nextupd))
348 {
349 OCSPerr(OCSP_F_OCSP_CHECK_VALIDITY, OCSP_R_ERROR_IN_NEXTUPDATE_FIELD);
350 ret = 0;
351 }
352 else
353 {
354 t_tmp = t_now - nsec;
355 if (X509_cmp_time(nextupd, &t_tmp) < 0)
356 {
357 OCSPerr(OCSP_F_OCSP_CHECK_VALIDITY, OCSP_R_STATUS_EXPIRED);
358 ret = 0;
359 }
360 }
361
362 /* Also don't allow nextUpdate to precede thisUpdate */
363 if (ASN1_STRING_cmp(nextupd, thisupd) < 0)
364 {
365 OCSPerr(OCSP_F_OCSP_CHECK_VALIDITY, OCSP_R_NEXTUPDATE_BEFORE_THISUPDATE);
366 ret = 0;
367 }
368
369 return ret;
370 }
diff --git a/src/lib/libcrypto/ocsp/ocsp_err.c b/src/lib/libcrypto/ocsp/ocsp_err.c
new file mode 100644
index 0000000000..4c4d8306f8
--- /dev/null
+++ b/src/lib/libcrypto/ocsp/ocsp_err.c
@@ -0,0 +1,139 @@
1/* crypto/ocsp/ocsp_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 <openssl/ocsp.h>
64
65/* BEGIN ERROR CODES */
66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA OCSP_str_functs[]=
68 {
69{ERR_PACK(0,OCSP_F_ASN1_STRING_ENCODE,0), "ASN1_STRING_encode"},
70{ERR_PACK(0,OCSP_F_CERT_ID_NEW,0), "CERT_ID_NEW"},
71{ERR_PACK(0,OCSP_F_D2I_OCSP_NONCE,0), "D2I_OCSP_NONCE"},
72{ERR_PACK(0,OCSP_F_OCSP_BASIC_ADD1_STATUS,0), "OCSP_basic_add1_status"},
73{ERR_PACK(0,OCSP_F_OCSP_BASIC_SIGN,0), "OCSP_basic_sign"},
74{ERR_PACK(0,OCSP_F_OCSP_BASIC_VERIFY,0), "OCSP_basic_verify"},
75{ERR_PACK(0,OCSP_F_OCSP_CHECK_DELEGATED,0), "OCSP_CHECK_DELEGATED"},
76{ERR_PACK(0,OCSP_F_OCSP_CHECK_IDS,0), "OCSP_CHECK_IDS"},
77{ERR_PACK(0,OCSP_F_OCSP_CHECK_ISSUER,0), "OCSP_CHECK_ISSUER"},
78{ERR_PACK(0,OCSP_F_OCSP_CHECK_VALIDITY,0), "OCSP_check_validity"},
79{ERR_PACK(0,OCSP_F_OCSP_MATCH_ISSUERID,0), "OCSP_MATCH_ISSUERID"},
80{ERR_PACK(0,OCSP_F_OCSP_PARSE_URL,0), "OCSP_parse_url"},
81{ERR_PACK(0,OCSP_F_OCSP_REQUEST_SIGN,0), "OCSP_request_sign"},
82{ERR_PACK(0,OCSP_F_OCSP_REQUEST_VERIFY,0), "OCSP_request_verify"},
83{ERR_PACK(0,OCSP_F_OCSP_RESPONSE_GET1_BASIC,0), "OCSP_response_get1_basic"},
84{ERR_PACK(0,OCSP_F_OCSP_SENDREQ_BIO,0), "OCSP_sendreq_bio"},
85{ERR_PACK(0,OCSP_F_REQUEST_VERIFY,0), "REQUEST_VERIFY"},
86{0,NULL}
87 };
88
89static ERR_STRING_DATA OCSP_str_reasons[]=
90 {
91{OCSP_R_BAD_DATA ,"bad data"},
92{OCSP_R_CERTIFICATE_VERIFY_ERROR ,"certificate verify error"},
93{OCSP_R_DIGEST_ERR ,"digest err"},
94{OCSP_R_ERROR_IN_NEXTUPDATE_FIELD ,"error in nextupdate field"},
95{OCSP_R_ERROR_IN_THISUPDATE_FIELD ,"error in thisupdate field"},
96{OCSP_R_ERROR_PARSING_URL ,"error parsing url"},
97{OCSP_R_MISSING_OCSPSIGNING_USAGE ,"missing ocspsigning usage"},
98{OCSP_R_NEXTUPDATE_BEFORE_THISUPDATE ,"nextupdate before thisupdate"},
99{OCSP_R_NOT_BASIC_RESPONSE ,"not basic response"},
100{OCSP_R_NO_CERTIFICATES_IN_CHAIN ,"no certificates in chain"},
101{OCSP_R_NO_CONTENT ,"no content"},
102{OCSP_R_NO_PUBLIC_KEY ,"no public key"},
103{OCSP_R_NO_RESPONSE_DATA ,"no response data"},
104{OCSP_R_NO_REVOKED_TIME ,"no revoked time"},
105{OCSP_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE,"private key does not match certificate"},
106{OCSP_R_REQUEST_NOT_SIGNED ,"request not signed"},
107{OCSP_R_RESPONSE_CONTAINS_NO_REVOCATION_DATA,"response contains no revocation data"},
108{OCSP_R_ROOT_CA_NOT_TRUSTED ,"root ca not trusted"},
109{OCSP_R_SERVER_READ_ERROR ,"server read error"},
110{OCSP_R_SERVER_RESPONSE_ERROR ,"server response error"},
111{OCSP_R_SERVER_RESPONSE_PARSE_ERROR ,"server response parse error"},
112{OCSP_R_SERVER_WRITE_ERROR ,"server write error"},
113{OCSP_R_SIGNATURE_FAILURE ,"signature failure"},
114{OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND ,"signer certificate not found"},
115{OCSP_R_STATUS_EXPIRED ,"status expired"},
116{OCSP_R_STATUS_NOT_YET_VALID ,"status not yet valid"},
117{OCSP_R_STATUS_TOO_OLD ,"status too old"},
118{OCSP_R_UNKNOWN_MESSAGE_DIGEST ,"unknown message digest"},
119{OCSP_R_UNKNOWN_NID ,"unknown nid"},
120{OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE ,"unsupported requestorname type"},
121{0,NULL}
122 };
123
124#endif
125
126void ERR_load_OCSP_strings(void)
127 {
128 static int init=1;
129
130 if (init)
131 {
132 init=0;
133#ifndef OPENSSL_NO_ERR
134 ERR_load_strings(ERR_LIB_OCSP,OCSP_str_functs);
135 ERR_load_strings(ERR_LIB_OCSP,OCSP_str_reasons);
136#endif
137
138 }
139 }
diff --git a/src/lib/libcrypto/ocsp/ocsp_ext.c b/src/lib/libcrypto/ocsp/ocsp_ext.c
new file mode 100644
index 0000000000..d6c8899f58
--- /dev/null
+++ b/src/lib/libcrypto/ocsp/ocsp_ext.c
@@ -0,0 +1,528 @@
1/* ocsp_ext.c */
2/* Written by Tom Titchener <Tom_Titchener@groove.net> for the OpenSSL
3 * project. */
4
5/* History:
6 This file was transfered to Richard Levitte from CertCo by Kathy
7 Weinhold in mid-spring 2000 to be included in OpenSSL or released
8 as a patch kit. */
9
10/* ====================================================================
11 * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 *
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 *
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in
22 * the documentation and/or other materials provided with the
23 * distribution.
24 *
25 * 3. All advertising materials mentioning features or use of this
26 * software must display the following acknowledgment:
27 * "This product includes software developed by the OpenSSL Project
28 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
29 *
30 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
31 * endorse or promote products derived from this software without
32 * prior written permission. For written permission, please contact
33 * openssl-core@openssl.org.
34 *
35 * 5. Products derived from this software may not be called "OpenSSL"
36 * nor may "OpenSSL" appear in their names without prior written
37 * permission of the OpenSSL Project.
38 *
39 * 6. Redistributions of any form whatsoever must retain the following
40 * acknowledgment:
41 * "This product includes software developed by the OpenSSL Project
42 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
43 *
44 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
45 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
46 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
47 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
48 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
49 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
50 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
51 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
53 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
54 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
55 * OF THE POSSIBILITY OF SUCH DAMAGE.
56 * ====================================================================
57 *
58 * This product includes cryptographic software written by Eric Young
59 * (eay@cryptsoft.com). This product includes software written by Tim
60 * Hudson (tjh@cryptsoft.com).
61 *
62 */
63
64#include <stdio.h>
65#include <cryptlib.h>
66#include <openssl/objects.h>
67#include <openssl/x509.h>
68#include <openssl/ocsp.h>
69#include <openssl/rand.h>
70#include <openssl/x509v3.h>
71
72/* Standard wrapper functions for extensions */
73
74/* OCSP request extensions */
75
76int OCSP_REQUEST_get_ext_count(OCSP_REQUEST *x)
77 {
78 return(X509v3_get_ext_count(x->tbsRequest->requestExtensions));
79 }
80
81int OCSP_REQUEST_get_ext_by_NID(OCSP_REQUEST *x, int nid, int lastpos)
82 {
83 return(X509v3_get_ext_by_NID(x->tbsRequest->requestExtensions,nid,lastpos));
84 }
85
86int OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, ASN1_OBJECT *obj, int lastpos)
87 {
88 return(X509v3_get_ext_by_OBJ(x->tbsRequest->requestExtensions,obj,lastpos));
89 }
90
91int OCSP_REQUEST_get_ext_by_critical(OCSP_REQUEST *x, int crit, int lastpos)
92 {
93 return(X509v3_get_ext_by_critical(x->tbsRequest->requestExtensions,crit,lastpos));
94 }
95
96X509_EXTENSION *OCSP_REQUEST_get_ext(OCSP_REQUEST *x, int loc)
97 {
98 return(X509v3_get_ext(x->tbsRequest->requestExtensions,loc));
99 }
100
101X509_EXTENSION *OCSP_REQUEST_delete_ext(OCSP_REQUEST *x, int loc)
102 {
103 return(X509v3_delete_ext(x->tbsRequest->requestExtensions,loc));
104 }
105
106void *OCSP_REQUEST_get1_ext_d2i(OCSP_REQUEST *x, int nid, int *crit, int *idx)
107 {
108 return X509V3_get_d2i(x->tbsRequest->requestExtensions, nid, crit, idx);
109 }
110
111int OCSP_REQUEST_add1_ext_i2d(OCSP_REQUEST *x, int nid, void *value, int crit,
112 unsigned long flags)
113 {
114 return X509V3_add1_i2d(&x->tbsRequest->requestExtensions, nid, value, crit, flags);
115 }
116
117int OCSP_REQUEST_add_ext(OCSP_REQUEST *x, X509_EXTENSION *ex, int loc)
118 {
119 return(X509v3_add_ext(&(x->tbsRequest->requestExtensions),ex,loc) != NULL);
120 }
121
122/* Single extensions */
123
124int OCSP_ONEREQ_get_ext_count(OCSP_ONEREQ *x)
125 {
126 return(X509v3_get_ext_count(x->singleRequestExtensions));
127 }
128
129int OCSP_ONEREQ_get_ext_by_NID(OCSP_ONEREQ *x, int nid, int lastpos)
130 {
131 return(X509v3_get_ext_by_NID(x->singleRequestExtensions,nid,lastpos));
132 }
133
134int OCSP_ONEREQ_get_ext_by_OBJ(OCSP_ONEREQ *x, ASN1_OBJECT *obj, int lastpos)
135 {
136 return(X509v3_get_ext_by_OBJ(x->singleRequestExtensions,obj,lastpos));
137 }
138
139int OCSP_ONEREQ_get_ext_by_critical(OCSP_ONEREQ *x, int crit, int lastpos)
140 {
141 return(X509v3_get_ext_by_critical(x->singleRequestExtensions,crit,lastpos));
142 }
143
144X509_EXTENSION *OCSP_ONEREQ_get_ext(OCSP_ONEREQ *x, int loc)
145 {
146 return(X509v3_get_ext(x->singleRequestExtensions,loc));
147 }
148
149X509_EXTENSION *OCSP_ONEREQ_delete_ext(OCSP_ONEREQ *x, int loc)
150 {
151 return(X509v3_delete_ext(x->singleRequestExtensions,loc));
152 }
153
154void *OCSP_ONEREQ_get1_ext_d2i(OCSP_ONEREQ *x, int nid, int *crit, int *idx)
155 {
156 return X509V3_get_d2i(x->singleRequestExtensions, nid, crit, idx);
157 }
158
159int OCSP_ONEREQ_add1_ext_i2d(OCSP_ONEREQ *x, int nid, void *value, int crit,
160 unsigned long flags)
161 {
162 return X509V3_add1_i2d(&x->singleRequestExtensions, nid, value, crit, flags);
163 }
164
165int OCSP_ONEREQ_add_ext(OCSP_ONEREQ *x, X509_EXTENSION *ex, int loc)
166 {
167 return(X509v3_add_ext(&(x->singleRequestExtensions),ex,loc) != NULL);
168 }
169
170/* OCSP Basic response */
171
172int OCSP_BASICRESP_get_ext_count(OCSP_BASICRESP *x)
173 {
174 return(X509v3_get_ext_count(x->tbsResponseData->responseExtensions));
175 }
176
177int OCSP_BASICRESP_get_ext_by_NID(OCSP_BASICRESP *x, int nid, int lastpos)
178 {
179 return(X509v3_get_ext_by_NID(x->tbsResponseData->responseExtensions,nid,lastpos));
180 }
181
182int OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, ASN1_OBJECT *obj, int lastpos)
183 {
184 return(X509v3_get_ext_by_OBJ(x->tbsResponseData->responseExtensions,obj,lastpos));
185 }
186
187int OCSP_BASICRESP_get_ext_by_critical(OCSP_BASICRESP *x, int crit, int lastpos)
188 {
189 return(X509v3_get_ext_by_critical(x->tbsResponseData->responseExtensions,crit,lastpos));
190 }
191
192X509_EXTENSION *OCSP_BASICRESP_get_ext(OCSP_BASICRESP *x, int loc)
193 {
194 return(X509v3_get_ext(x->tbsResponseData->responseExtensions,loc));
195 }
196
197X509_EXTENSION *OCSP_BASICRESP_delete_ext(OCSP_BASICRESP *x, int loc)
198 {
199 return(X509v3_delete_ext(x->tbsResponseData->responseExtensions,loc));
200 }
201
202void *OCSP_BASICRESP_get1_ext_d2i(OCSP_BASICRESP *x, int nid, int *crit, int *idx)
203 {
204 return X509V3_get_d2i(x->tbsResponseData->responseExtensions, nid, crit, idx);
205 }
206
207int OCSP_BASICRESP_add1_ext_i2d(OCSP_BASICRESP *x, int nid, void *value, int crit,
208 unsigned long flags)
209 {
210 return X509V3_add1_i2d(&x->tbsResponseData->responseExtensions, nid, value, crit, flags);
211 }
212
213int OCSP_BASICRESP_add_ext(OCSP_BASICRESP *x, X509_EXTENSION *ex, int loc)
214 {
215 return(X509v3_add_ext(&(x->tbsResponseData->responseExtensions),ex,loc) != NULL);
216 }
217
218/* OCSP single response extensions */
219
220int OCSP_SINGLERESP_get_ext_count(OCSP_SINGLERESP *x)
221 {
222 return(X509v3_get_ext_count(x->singleExtensions));
223 }
224
225int OCSP_SINGLERESP_get_ext_by_NID(OCSP_SINGLERESP *x, int nid, int lastpos)
226 {
227 return(X509v3_get_ext_by_NID(x->singleExtensions,nid,lastpos));
228 }
229
230int OCSP_SINGLERESP_get_ext_by_OBJ(OCSP_SINGLERESP *x, ASN1_OBJECT *obj, int lastpos)
231 {
232 return(X509v3_get_ext_by_OBJ(x->singleExtensions,obj,lastpos));
233 }
234
235int OCSP_SINGLERESP_get_ext_by_critical(OCSP_SINGLERESP *x, int crit, int lastpos)
236 {
237 return(X509v3_get_ext_by_critical(x->singleExtensions,crit,lastpos));
238 }
239
240X509_EXTENSION *OCSP_SINGLERESP_get_ext(OCSP_SINGLERESP *x, int loc)
241 {
242 return(X509v3_get_ext(x->singleExtensions,loc));
243 }
244
245X509_EXTENSION *OCSP_SINGLERESP_delete_ext(OCSP_SINGLERESP *x, int loc)
246 {
247 return(X509v3_delete_ext(x->singleExtensions,loc));
248 }
249
250void *OCSP_SINGLERESP_get1_ext_d2i(OCSP_SINGLERESP *x, int nid, int *crit, int *idx)
251 {
252 return X509V3_get_d2i(x->singleExtensions, nid, crit, idx);
253 }
254
255int OCSP_SINGLERESP_add1_ext_i2d(OCSP_SINGLERESP *x, int nid, void *value, int crit,
256 unsigned long flags)
257 {
258 return X509V3_add1_i2d(&x->singleExtensions, nid, value, crit, flags);
259 }
260
261int OCSP_SINGLERESP_add_ext(OCSP_SINGLERESP *x, X509_EXTENSION *ex, int loc)
262 {
263 return(X509v3_add_ext(&(x->singleExtensions),ex,loc) != NULL);
264 }
265
266/* also CRL Entry Extensions */
267
268ASN1_STRING *ASN1_STRING_encode(ASN1_STRING *s, int (*i2d)(),
269 char *data, STACK_OF(ASN1_OBJECT) *sk)
270 {
271 int i;
272 unsigned char *p, *b = NULL;
273
274 if (data)
275 {
276 if ((i=i2d(data,NULL)) <= 0) goto err;
277 if (!(b=p=(unsigned char*)OPENSSL_malloc((unsigned int)i)))
278 goto err;
279 if (i2d(data, &p) <= 0) goto err;
280 }
281 else if (sk)
282 {
283 if ((i=i2d_ASN1_SET_OF_ASN1_OBJECT(sk,NULL,i2d,V_ASN1_SEQUENCE,
284 V_ASN1_UNIVERSAL,IS_SEQUENCE))<=0) goto err;
285 if (!(b=p=(unsigned char*)OPENSSL_malloc((unsigned int)i)))
286 goto err;
287 if (i2d_ASN1_SET_OF_ASN1_OBJECT(sk,&p,i2d,V_ASN1_SEQUENCE,
288 V_ASN1_UNIVERSAL,IS_SEQUENCE)<=0) goto err;
289 }
290 else
291 {
292 OCSPerr(OCSP_F_ASN1_STRING_ENCODE,OCSP_R_BAD_DATA);
293 goto err;
294 }
295 if (!s && !(s = ASN1_STRING_new())) goto err;
296 if (!(ASN1_STRING_set(s, b, i))) goto err;
297 OPENSSL_free(b);
298 return s;
299err:
300 if (b) OPENSSL_free(b);
301 return NULL;
302 }
303
304/* Nonce handling functions */
305
306/* Add a nonce to an extension stack. A nonce can be specificed or if NULL
307 * a random nonce will be generated.
308 */
309
310static int ocsp_add1_nonce(STACK_OF(X509_EXTENSION) **exts, unsigned char *val, int len)
311 {
312 unsigned char *tmpval;
313 ASN1_OCTET_STRING os;
314 int ret = 0;
315 if (len <= 0) len = OCSP_DEFAULT_NONCE_LENGTH;
316 if (val) tmpval = val;
317 else
318 {
319 if (!(tmpval = OPENSSL_malloc(len))) goto err;
320 RAND_pseudo_bytes(tmpval, len);
321 }
322 os.data = tmpval;
323 os.length = len;
324 if(!X509V3_add1_i2d(exts, NID_id_pkix_OCSP_Nonce,
325 &os, 0, X509V3_ADD_REPLACE))
326 goto err;
327 ret = 1;
328 err:
329 if(!val) OPENSSL_free(tmpval);
330 return ret;
331 }
332
333
334/* Add nonce to an OCSP request */
335
336int OCSP_request_add1_nonce(OCSP_REQUEST *req, unsigned char *val, int len)
337 {
338 return ocsp_add1_nonce(&req->tbsRequest->requestExtensions, val, len);
339 }
340
341/* Same as above but for a response */
342
343int OCSP_basic_add1_nonce(OCSP_BASICRESP *resp, unsigned char *val, int len)
344 {
345 return ocsp_add1_nonce(&resp->tbsResponseData->responseExtensions, val, len);
346 }
347
348/* Check nonce validity in a request and response.
349 * Return value reflects result:
350 * 1: nonces present and equal.
351 * 2: nonces both absent.
352 * 3: nonce present in response only.
353 * 0: nonces both present and not equal.
354 * -1: nonce in request only.
355 *
356 * For most responders clients can check return > 0.
357 * If responder doesn't handle nonces return != 0 may be
358 * necessary. return == 0 is always an error.
359 */
360
361int OCSP_check_nonce(OCSP_REQUEST *req, OCSP_BASICRESP *bs)
362 {
363 /*
364 * Since we are only interested in the presence or absence of
365 * the nonce and comparing its value there is no need to use
366 * the X509V3 routines: this way we can avoid them allocating an
367 * ASN1_OCTET_STRING structure for the value which would be
368 * freed immediately anyway.
369 */
370
371 int req_idx, resp_idx;
372 X509_EXTENSION *req_ext, *resp_ext;
373 req_idx = OCSP_REQUEST_get_ext_by_NID(req, NID_id_pkix_OCSP_Nonce, -1);
374 resp_idx = OCSP_BASICRESP_get_ext_by_NID(bs, NID_id_pkix_OCSP_Nonce, -1);
375 /* Check both absent */
376 if((req_idx < 0) && (resp_idx < 0))
377 return 2;
378 /* Check in request only */
379 if((req_idx >= 0) && (resp_idx < 0))
380 return -1;
381 /* Check in response but not request */
382 if((req_idx < 0) && (resp_idx >= 0))
383 return 3;
384 /* Otherwise nonce in request and response so retrieve the extensions */
385 req_ext = OCSP_REQUEST_get_ext(req, req_idx);
386 resp_ext = OCSP_BASICRESP_get_ext(bs, resp_idx);
387 if(ASN1_OCTET_STRING_cmp(req_ext->value, resp_ext->value))
388 return 0;
389 return 1;
390 }
391
392/* Copy the nonce value (if any) from an OCSP request to
393 * a response.
394 */
395
396int OCSP_copy_nonce(OCSP_BASICRESP *resp, OCSP_REQUEST *req)
397 {
398 X509_EXTENSION *req_ext;
399 int req_idx;
400 /* Check for nonce in request */
401 req_idx = OCSP_REQUEST_get_ext_by_NID(req, NID_id_pkix_OCSP_Nonce, -1);
402 /* If no nonce that's OK */
403 if (req_idx < 0) return 2;
404 req_ext = OCSP_REQUEST_get_ext(req, req_idx);
405 return OCSP_BASICRESP_add_ext(resp, req_ext, -1);
406 }
407
408X509_EXTENSION *OCSP_crlID_new(char *url, long *n, char *tim)
409 {
410 X509_EXTENSION *x = NULL;
411 OCSP_CRLID *cid = NULL;
412
413 if (!(cid = OCSP_CRLID_new())) goto err;
414 if (url)
415 {
416 if (!(cid->crlUrl = ASN1_IA5STRING_new())) goto err;
417 if (!(ASN1_STRING_set(cid->crlUrl, url, -1))) goto err;
418 }
419 if (n)
420 {
421 if (!(cid->crlNum = ASN1_INTEGER_new())) goto err;
422 if (!(ASN1_INTEGER_set(cid->crlNum, *n))) goto err;
423 }
424 if (tim)
425 {
426 if (!(cid->crlTime = ASN1_GENERALIZEDTIME_new())) goto err;
427 if (!(ASN1_GENERALIZEDTIME_set_string(cid->crlTime, tim)))
428 goto err;
429 }
430 if (!(x = X509_EXTENSION_new())) goto err;
431 if (!(x->object = OBJ_nid2obj(NID_id_pkix_OCSP_CrlID))) goto err;
432 if (!(ASN1_STRING_encode(x->value,i2d_OCSP_CRLID,(char*)cid,NULL)))
433 goto err;
434 OCSP_CRLID_free(cid);
435 return x;
436err:
437 if (x) X509_EXTENSION_free(x);
438 if (cid) OCSP_CRLID_free(cid);
439 return NULL;
440 }
441
442/* AcceptableResponses ::= SEQUENCE OF OBJECT IDENTIFIER */
443X509_EXTENSION *OCSP_accept_responses_new(char **oids)
444 {
445 int nid;
446 STACK_OF(ASN1_OBJECT) *sk = NULL;
447 ASN1_OBJECT *o = NULL;
448 X509_EXTENSION *x = NULL;
449
450 if (!(sk = sk_ASN1_OBJECT_new_null())) goto err;
451 while (oids && *oids)
452 {
453 if ((nid=OBJ_txt2nid(*oids))!=NID_undef&&(o=OBJ_nid2obj(nid)))
454 sk_ASN1_OBJECT_push(sk, o);
455 oids++;
456 }
457 if (!(x = X509_EXTENSION_new())) goto err;
458 if (!(x->object = OBJ_nid2obj(NID_id_pkix_OCSP_acceptableResponses)))
459 goto err;
460 if (!(ASN1_STRING_encode(x->value,i2d_ASN1_OBJECT,NULL,sk)))
461 goto err;
462 sk_ASN1_OBJECT_pop_free(sk, ASN1_OBJECT_free);
463 return x;
464err:
465 if (x) X509_EXTENSION_free(x);
466 if (sk) sk_ASN1_OBJECT_pop_free(sk, ASN1_OBJECT_free);
467 return NULL;
468 }
469
470/* ArchiveCutoff ::= GeneralizedTime */
471X509_EXTENSION *OCSP_archive_cutoff_new(char* tim)
472 {
473 X509_EXTENSION *x=NULL;
474 ASN1_GENERALIZEDTIME *gt = NULL;
475
476 if (!(gt = ASN1_GENERALIZEDTIME_new())) goto err;
477 if (!(ASN1_GENERALIZEDTIME_set_string(gt, tim))) goto err;
478 if (!(x = X509_EXTENSION_new())) goto err;
479 if (!(x->object=OBJ_nid2obj(NID_id_pkix_OCSP_archiveCutoff)))goto err;
480 if (!(ASN1_STRING_encode(x->value,i2d_ASN1_GENERALIZEDTIME,
481 (char*)gt,NULL))) goto err;
482 ASN1_GENERALIZEDTIME_free(gt);
483 return x;
484err:
485 if (gt) ASN1_GENERALIZEDTIME_free(gt);
486 if (x) X509_EXTENSION_free(x);
487 return NULL;
488 }
489
490/* per ACCESS_DESCRIPTION parameter are oids, of which there are currently
491 * two--NID_ad_ocsp, NID_id_ad_caIssuers--and GeneralName value. This
492 * method forces NID_ad_ocsp and uniformResourceLocator [6] IA5String.
493 */
494X509_EXTENSION *OCSP_url_svcloc_new(X509_NAME* issuer, char **urls)
495 {
496 X509_EXTENSION *x = NULL;
497 ASN1_IA5STRING *ia5 = NULL;
498 OCSP_SERVICELOC *sloc = NULL;
499 ACCESS_DESCRIPTION *ad = NULL;
500
501 if (!(sloc = OCSP_SERVICELOC_new())) goto err;
502 if (!(sloc->issuer = X509_NAME_dup(issuer))) goto err;
503 if (urls && *urls && !(sloc->locator = sk_ACCESS_DESCRIPTION_new_null())) goto err;
504 while (urls && *urls)
505 {
506 if (!(ad = ACCESS_DESCRIPTION_new())) goto err;
507 if (!(ad->method=OBJ_nid2obj(NID_ad_OCSP))) goto err;
508 if (!(ad->location = GENERAL_NAME_new())) goto err;
509 if (!(ia5 = ASN1_IA5STRING_new())) goto err;
510 if (!ASN1_STRING_set((ASN1_STRING*)ia5, *urls, -1)) goto err;
511 ad->location->type = GEN_URI;
512 ad->location->d.ia5 = ia5;
513 if (!sk_ACCESS_DESCRIPTION_push(sloc->locator, ad)) goto err;
514 urls++;
515 }
516 if (!(x = X509_EXTENSION_new())) goto err;
517 if (!(x->object = OBJ_nid2obj(NID_id_pkix_OCSP_serviceLocator)))
518 goto err;
519 if (!(ASN1_STRING_encode(x->value, i2d_OCSP_SERVICELOC,
520 (char*)sloc, NULL))) goto err;
521 OCSP_SERVICELOC_free(sloc);
522 return x;
523err:
524 if (x) X509_EXTENSION_free(x);
525 if (sloc) OCSP_SERVICELOC_free(sloc);
526 return NULL;
527 }
528
diff --git a/src/lib/libcrypto/ocsp/ocsp_ht.c b/src/lib/libcrypto/ocsp/ocsp_ht.c
new file mode 100644
index 0000000000..b78cd37092
--- /dev/null
+++ b/src/lib/libcrypto/ocsp/ocsp_ht.c
@@ -0,0 +1,164 @@
1/* ocsp_ht.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) 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 <openssl/asn1.h>
60#include <stdio.h>
61#include <stdlib.h>
62#include <ctype.h>
63#include <string.h>
64#include <openssl/ocsp.h>
65#include <openssl/err.h>
66#include <openssl/buffer.h>
67
68/* Quick and dirty HTTP OCSP request handler.
69 * Could make this a bit cleverer by adding
70 * support for non blocking BIOs and a few
71 * other refinements.
72 */
73
74OCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, char *path, OCSP_REQUEST *req)
75{
76 BIO *mem = NULL;
77 char tmpbuf[1024];
78 OCSP_RESPONSE *resp = NULL;
79 char *p, *q, *r;
80 int len, retcode;
81 static char req_txt[] =
82"POST %s HTTP/1.0\r\n\
83Content-Type: application/ocsp-request\r\n\
84Content-Length: %d\r\n\r\n";
85
86 len = i2d_OCSP_REQUEST(req, NULL);
87 if(BIO_printf(b, req_txt, path, len) < 0) {
88 OCSPerr(OCSP_F_OCSP_SENDREQ_BIO,OCSP_R_SERVER_WRITE_ERROR);
89 goto err;
90 }
91 if(i2d_OCSP_REQUEST_bio(b, req) <= 0) {
92 OCSPerr(OCSP_F_OCSP_SENDREQ_BIO,OCSP_R_SERVER_WRITE_ERROR);
93 goto err;
94 }
95 if(!(mem = BIO_new(BIO_s_mem()))) goto err;
96 /* Copy response to a memory BIO: socket bios can't do gets! */
97 while ((len = BIO_read(b, tmpbuf, 1024))) {
98 if(len < 0) {
99 OCSPerr(OCSP_F_OCSP_SENDREQ_BIO,OCSP_R_SERVER_READ_ERROR);
100 goto err;
101 }
102 BIO_write(mem, tmpbuf, len);
103 }
104 if(BIO_gets(mem, tmpbuf, 512) <= 0) {
105 OCSPerr(OCSP_F_OCSP_SENDREQ_BIO,OCSP_R_SERVER_RESPONSE_PARSE_ERROR);
106 goto err;
107 }
108 /* Parse the HTTP response. This will look like this:
109 * "HTTP/1.0 200 OK". We need to obtain the numeric code and
110 * informational message.
111 */
112
113 /* Skip to first white space (passed protocol info) */
114 for(p = tmpbuf; *p && !isspace((unsigned char)*p); p++) continue;
115 if(!*p) {
116 OCSPerr(OCSP_F_OCSP_SENDREQ_BIO,OCSP_R_SERVER_RESPONSE_PARSE_ERROR);
117 goto err;
118 }
119 /* Skip past white space to start of response code */
120 while(*p && isspace((unsigned char)*p)) p++;
121 if(!*p) {
122 OCSPerr(OCSP_F_OCSP_SENDREQ_BIO,OCSP_R_SERVER_RESPONSE_PARSE_ERROR);
123 goto err;
124 }
125 /* Find end of response code: first whitespace after start of code */
126 for(q = p; *q && !isspace((unsigned char)*q); q++) continue;
127 if(!*q) {
128 OCSPerr(OCSP_F_OCSP_SENDREQ_BIO,OCSP_R_SERVER_RESPONSE_PARSE_ERROR);
129 goto err;
130 }
131 /* Set end of response code and start of message */
132 *q++ = 0;
133 /* Attempt to parse numeric code */
134 retcode = strtoul(p, &r, 10);
135 if(*r) goto err;
136 /* Skip over any leading white space in message */
137 while(*q && isspace((unsigned char)*q)) q++;
138 if(!*q) goto err;
139 /* Finally zap any trailing white space in message (include CRLF) */
140 /* We know q has a non white space character so this is OK */
141 for(r = q + strlen(q) - 1; isspace((unsigned char)*r); r--) *r = 0;
142 if(retcode != 200) {
143 OCSPerr(OCSP_F_OCSP_SENDREQ_BIO,OCSP_R_SERVER_RESPONSE_ERROR);
144 ERR_add_error_data(4, "Code=", p, ",Reason=", q);
145 goto err;
146 }
147 /* Find blank line marking beginning of content */
148 while(BIO_gets(mem, tmpbuf, 512) > 0)
149 {
150 for(p = tmpbuf; *p && isspace((unsigned char)*p); p++) continue;
151 if(!*p) break;
152 }
153 if(*p) {
154 OCSPerr(OCSP_F_OCSP_SENDREQ_BIO,OCSP_R_NO_CONTENT);
155 goto err;
156 }
157 if(!(resp = d2i_OCSP_RESPONSE_bio(mem, NULL))) {
158 OCSPerr(OCSP_F_OCSP_SENDREQ_BIO,ERR_R_NESTED_ASN1_ERROR);
159 goto err;
160 }
161 err:
162 BIO_free(mem);
163 return resp;
164}
diff --git a/src/lib/libcrypto/ocsp/ocsp_lib.c b/src/lib/libcrypto/ocsp/ocsp_lib.c
new file mode 100644
index 0000000000..3875af165c
--- /dev/null
+++ b/src/lib/libcrypto/ocsp/ocsp_lib.c
@@ -0,0 +1,261 @@
1/* ocsp_lib.c */
2/* Written by Tom Titchener <Tom_Titchener@groove.net> for the OpenSSL
3 * project. */
4
5/* History:
6 This file was transfered to Richard Levitte from CertCo by Kathy
7 Weinhold in mid-spring 2000 to be included in OpenSSL or released
8 as a patch kit. */
9
10/* ====================================================================
11 * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 *
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 *
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in
22 * the documentation and/or other materials provided with the
23 * distribution.
24 *
25 * 3. All advertising materials mentioning features or use of this
26 * software must display the following acknowledgment:
27 * "This product includes software developed by the OpenSSL Project
28 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
29 *
30 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
31 * endorse or promote products derived from this software without
32 * prior written permission. For written permission, please contact
33 * openssl-core@openssl.org.
34 *
35 * 5. Products derived from this software may not be called "OpenSSL"
36 * nor may "OpenSSL" appear in their names without prior written
37 * permission of the OpenSSL Project.
38 *
39 * 6. Redistributions of any form whatsoever must retain the following
40 * acknowledgment:
41 * "This product includes software developed by the OpenSSL Project
42 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
43 *
44 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
45 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
46 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
47 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
48 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
49 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
50 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
51 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
53 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
54 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
55 * OF THE POSSIBILITY OF SUCH DAMAGE.
56 * ====================================================================
57 *
58 * This product includes cryptographic software written by Eric Young
59 * (eay@cryptsoft.com). This product includes software written by Tim
60 * Hudson (tjh@cryptsoft.com).
61 *
62 */
63
64#include <stdio.h>
65#include <cryptlib.h>
66#include <openssl/objects.h>
67#include <openssl/rand.h>
68#include <openssl/x509.h>
69#include <openssl/pem.h>
70#include <openssl/x509v3.h>
71#include <openssl/ocsp.h>
72
73/* Convert a certificate and its issuer to an OCSP_CERTID */
74
75OCSP_CERTID *OCSP_cert_to_id(const EVP_MD *dgst, X509 *subject, X509 *issuer)
76{
77 X509_NAME *iname;
78 ASN1_INTEGER *serial;
79 ASN1_BIT_STRING *ikey;
80#ifndef OPENSSL_NO_SHA1
81 if(!dgst) dgst = EVP_sha1();
82#endif
83 if (subject)
84 {
85 iname = X509_get_issuer_name(subject);
86 serial = X509_get_serialNumber(subject);
87 }
88 else
89 {
90 iname = X509_get_subject_name(issuer);
91 serial = NULL;
92 }
93 ikey = X509_get0_pubkey_bitstr(issuer);
94 return OCSP_cert_id_new(dgst, iname, ikey, serial);
95}
96
97
98OCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst,
99 X509_NAME *issuerName,
100 ASN1_BIT_STRING* issuerKey,
101 ASN1_INTEGER *serialNumber)
102 {
103 int nid;
104 unsigned int i;
105 X509_ALGOR *alg;
106 OCSP_CERTID *cid = NULL;
107 unsigned char md[EVP_MAX_MD_SIZE];
108
109 if (!(cid = OCSP_CERTID_new())) goto err;
110
111 alg = cid->hashAlgorithm;
112 if (alg->algorithm != NULL) ASN1_OBJECT_free(alg->algorithm);
113 if ((nid = EVP_MD_type(dgst)) == NID_undef)
114 {
115 OCSPerr(OCSP_F_CERT_ID_NEW,OCSP_R_UNKNOWN_NID);
116 goto err;
117 }
118 if (!(alg->algorithm=OBJ_nid2obj(nid))) goto err;
119 if ((alg->parameter=ASN1_TYPE_new()) == NULL) goto err;
120 alg->parameter->type=V_ASN1_NULL;
121
122 if (!X509_NAME_digest(issuerName, dgst, md, &i)) goto digerr;
123 if (!(ASN1_OCTET_STRING_set(cid->issuerNameHash, md, i))) goto err;
124
125 /* Calculate the issuerKey hash, excluding tag and length */
126 EVP_Digest(issuerKey->data, issuerKey->length, md, &i, dgst, NULL);
127
128 if (!(ASN1_OCTET_STRING_set(cid->issuerKeyHash, md, i))) goto err;
129
130 if (serialNumber)
131 {
132 ASN1_INTEGER_free(cid->serialNumber);
133 if (!(cid->serialNumber = ASN1_INTEGER_dup(serialNumber))) goto err;
134 }
135 return cid;
136digerr:
137 OCSPerr(OCSP_F_CERT_ID_NEW,OCSP_R_DIGEST_ERR);
138err:
139 if (cid) OCSP_CERTID_free(cid);
140 return NULL;
141 }
142
143int OCSP_id_issuer_cmp(OCSP_CERTID *a, OCSP_CERTID *b)
144 {
145 int ret;
146 ret = OBJ_cmp(a->hashAlgorithm->algorithm, b->hashAlgorithm->algorithm);
147 if (ret) return ret;
148 ret = ASN1_OCTET_STRING_cmp(a->issuerNameHash, b->issuerNameHash);
149 if (ret) return ret;
150 return ASN1_OCTET_STRING_cmp(a->issuerKeyHash, b->issuerKeyHash);
151 }
152
153int OCSP_id_cmp(OCSP_CERTID *a, OCSP_CERTID *b)
154 {
155 int ret;
156 ret = OCSP_id_issuer_cmp(a, b);
157 if (ret) return ret;
158 return ASN1_INTEGER_cmp(a->serialNumber, b->serialNumber);
159 }
160
161
162/* Parse a URL and split it up into host, port and path components and whether
163 * it is SSL.
164 */
165
166int OCSP_parse_url(char *url, char **phost, char **pport, char **ppath, int *pssl)
167 {
168 char *p, *buf;
169
170 char *host, *port;
171
172 /* dup the buffer since we are going to mess with it */
173 buf = BUF_strdup(url);
174 if (!buf) goto mem_err;
175
176 *phost = NULL;
177 *pport = NULL;
178 *ppath = NULL;
179
180 /* Check for initial colon */
181 p = strchr(buf, ':');
182
183 if (!p) goto parse_err;
184
185 *(p++) = '\0';
186
187 if (!strcmp(buf, "http"))
188 {
189 *pssl = 0;
190 port = "80";
191 }
192 else if (!strcmp(buf, "https"))
193 {
194 *pssl = 1;
195 port = "443";
196 }
197 else
198 goto parse_err;
199
200 /* Check for double slash */
201 if ((p[0] != '/') || (p[1] != '/'))
202 goto parse_err;
203
204 p += 2;
205
206 host = p;
207
208 /* Check for trailing part of path */
209
210 p = strchr(p, '/');
211
212 if (!p)
213 *ppath = BUF_strdup("/");
214 else
215 {
216 *ppath = BUF_strdup(p);
217 /* Set start of path to 0 so hostname is valid */
218 *p = '\0';
219 }
220
221 if (!*ppath) goto mem_err;
222
223 /* Look for optional ':' for port number */
224 if ((p = strchr(host, ':')))
225 {
226 *p = 0;
227 port = p + 1;
228 }
229 else
230 {
231 /* Not found: set default port */
232 if (*pssl) port = "443";
233 else port = "80";
234 }
235
236 *pport = BUF_strdup(port);
237 if (!*pport) goto mem_err;
238
239 *phost = BUF_strdup(host);
240
241 if (!*phost) goto mem_err;
242
243 OPENSSL_free(buf);
244
245 return 1;
246
247 mem_err:
248 OCSPerr(OCSP_F_OCSP_PARSE_URL, ERR_R_MALLOC_FAILURE);
249 goto err;
250
251 parse_err:
252 OCSPerr(OCSP_F_OCSP_PARSE_URL, OCSP_R_ERROR_PARSING_URL);
253
254
255 err:
256 if (*ppath) OPENSSL_free(*ppath);
257 if (*pport) OPENSSL_free(*pport);
258 if (*phost) OPENSSL_free(*phost);
259 return 0;
260
261 }
diff --git a/src/lib/libcrypto/ocsp/ocsp_prn.c b/src/lib/libcrypto/ocsp/ocsp_prn.c
new file mode 100644
index 0000000000..4b7bc28769
--- /dev/null
+++ b/src/lib/libcrypto/ocsp/ocsp_prn.c
@@ -0,0 +1,291 @@
1/* ocsp_prn.c */
2/* Written by Tom Titchener <Tom_Titchener@groove.net> for the OpenSSL
3 * project. */
4
5/* History:
6 This file was originally part of ocsp.c and was transfered to Richard
7 Levitte from CertCo by Kathy Weinhold in mid-spring 2000 to be included
8 in OpenSSL or released as a patch kit. */
9
10/* ====================================================================
11 * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 *
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 *
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in
22 * the documentation and/or other materials provided with the
23 * distribution.
24 *
25 * 3. All advertising materials mentioning features or use of this
26 * software must display the following acknowledgment:
27 * "This product includes software developed by the OpenSSL Project
28 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
29 *
30 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
31 * endorse or promote products derived from this software without
32 * prior written permission. For written permission, please contact
33 * openssl-core@openssl.org.
34 *
35 * 5. Products derived from this software may not be called "OpenSSL"
36 * nor may "OpenSSL" appear in their names without prior written
37 * permission of the OpenSSL Project.
38 *
39 * 6. Redistributions of any form whatsoever must retain the following
40 * acknowledgment:
41 * "This product includes software developed by the OpenSSL Project
42 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
43 *
44 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
45 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
46 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
47 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
48 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
49 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
50 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
51 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
53 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
54 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
55 * OF THE POSSIBILITY OF SUCH DAMAGE.
56 * ====================================================================
57 *
58 * This product includes cryptographic software written by Eric Young
59 * (eay@cryptsoft.com). This product includes software written by Tim
60 * Hudson (tjh@cryptsoft.com).
61 *
62 */
63
64#include <openssl/bio.h>
65#include <openssl/err.h>
66#include <openssl/ocsp.h>
67#include <openssl/pem.h>
68
69static int ocsp_certid_print(BIO *bp, OCSP_CERTID* a, int indent)
70 {
71 BIO_printf(bp, "%*sCertificate ID:\n", indent, "");
72 indent += 2;
73 BIO_printf(bp, "%*sHash Algorithm: ", indent, "");
74 i2a_ASN1_OBJECT(bp, a->hashAlgorithm->algorithm);
75 BIO_printf(bp, "\n%*sIssuer Name Hash: ", indent, "");
76 i2a_ASN1_STRING(bp, a->issuerNameHash, V_ASN1_OCTET_STRING);
77 BIO_printf(bp, "\n%*sIssuer Key Hash: ", indent, "");
78 i2a_ASN1_STRING(bp, a->issuerKeyHash, V_ASN1_OCTET_STRING);
79 BIO_printf(bp, "\n%*sSerial Number: ", indent, "");
80 i2a_ASN1_INTEGER(bp, a->serialNumber);
81 BIO_printf(bp, "\n");
82 return 1;
83 }
84
85typedef struct
86 {
87 long t;
88 char *m;
89 } OCSP_TBLSTR;
90
91static char *table2string(long s, OCSP_TBLSTR *ts, int len)
92{
93 OCSP_TBLSTR *p;
94 for (p=ts; p < ts + len; p++)
95 if (p->t == s)
96 return p->m;
97 return "(UNKNOWN)";
98}
99
100char *OCSP_response_status_str(long s)
101 {
102 static OCSP_TBLSTR rstat_tbl[] = {
103 { OCSP_RESPONSE_STATUS_SUCCESSFUL, "successful" },
104 { OCSP_RESPONSE_STATUS_MALFORMEDREQUEST, "malformedrequest" },
105 { OCSP_RESPONSE_STATUS_INTERNALERROR, "internalerror" },
106 { OCSP_RESPONSE_STATUS_TRYLATER, "trylater" },
107 { OCSP_RESPONSE_STATUS_SIGREQUIRED, "sigrequired" },
108 { OCSP_RESPONSE_STATUS_UNAUTHORIZED, "unauthorized" } };
109 return table2string(s, rstat_tbl, 6);
110 }
111
112char *OCSP_cert_status_str(long s)
113 {
114 static OCSP_TBLSTR cstat_tbl[] = {
115 { V_OCSP_CERTSTATUS_GOOD, "good" },
116 { V_OCSP_CERTSTATUS_REVOKED, "revoked" },
117 { V_OCSP_CERTSTATUS_UNKNOWN, "unknown" } };
118 return table2string(s, cstat_tbl, 3);
119 }
120
121char *OCSP_crl_reason_str(long s)
122 {
123 OCSP_TBLSTR reason_tbl[] = {
124 { OCSP_REVOKED_STATUS_UNSPECIFIED, "unspecified" },
125 { OCSP_REVOKED_STATUS_KEYCOMPROMISE, "keyCompromise" },
126 { OCSP_REVOKED_STATUS_CACOMPROMISE, "cACompromise" },
127 { OCSP_REVOKED_STATUS_AFFILIATIONCHANGED, "affiliationChanged" },
128 { OCSP_REVOKED_STATUS_SUPERSEDED, "superseded" },
129 { OCSP_REVOKED_STATUS_CESSATIONOFOPERATION, "cessationOfOperation" },
130 { OCSP_REVOKED_STATUS_CERTIFICATEHOLD, "certificateHold" },
131 { OCSP_REVOKED_STATUS_REMOVEFROMCRL, "removeFromCRL" } };
132 return table2string(s, reason_tbl, 8);
133 }
134
135int OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST* o, unsigned long flags)
136 {
137 int i;
138 long l;
139 OCSP_CERTID* cid = NULL;
140 OCSP_ONEREQ *one = NULL;
141 OCSP_REQINFO *inf = o->tbsRequest;
142 OCSP_SIGNATURE *sig = o->optionalSignature;
143
144 if (BIO_write(bp,"OCSP Request Data:\n",19) <= 0) goto err;
145 l=ASN1_INTEGER_get(inf->version);
146 if (BIO_printf(bp," Version: %lu (0x%lx)",l+1,l) <= 0) goto err;
147 if (inf->requestorName != NULL)
148 {
149 if (BIO_write(bp,"\n Requestor Name: ",21) <= 0)
150 goto err;
151 GENERAL_NAME_print(bp, inf->requestorName);
152 }
153 if (BIO_write(bp,"\n Requestor List:\n",21) <= 0) goto err;
154 for (i = 0; i < sk_OCSP_ONEREQ_num(inf->requestList); i++)
155 {
156 one = sk_OCSP_ONEREQ_value(inf->requestList, i);
157 cid = one->reqCert;
158 ocsp_certid_print(bp, cid, 8);
159 if (!X509V3_extensions_print(bp,
160 "Request Single Extensions",
161 one->singleRequestExtensions, flags, 8))
162 goto err;
163 }
164 if (!X509V3_extensions_print(bp, "Request Extensions",
165 inf->requestExtensions, flags, 4))
166 goto err;
167 if (sig)
168 {
169 X509_signature_print(bp, sig->signatureAlgorithm, sig->signature);
170 for (i=0; i<sk_X509_num(sig->certs); i++)
171 {
172 X509_print(bp, sk_X509_value(sig->certs,i));
173 PEM_write_bio_X509(bp,sk_X509_value(sig->certs,i));
174 }
175 }
176 return 1;
177err:
178 return 0;
179 }
180
181int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* o, unsigned long flags)
182 {
183 int i, ret = 0;
184 long l;
185 unsigned char *p;
186 OCSP_CERTID *cid = NULL;
187 OCSP_BASICRESP *br = NULL;
188 OCSP_RESPID *rid = NULL;
189 OCSP_RESPDATA *rd = NULL;
190 OCSP_CERTSTATUS *cst = NULL;
191 OCSP_REVOKEDINFO *rev = NULL;
192 OCSP_SINGLERESP *single = NULL;
193 OCSP_RESPBYTES *rb = o->responseBytes;
194
195 if (BIO_puts(bp,"OCSP Response Data:\n") <= 0) goto err;
196 l=ASN1_ENUMERATED_get(o->responseStatus);
197 if (BIO_printf(bp," OCSP Response Status: %s (0x%x)\n",
198 OCSP_response_status_str(l), l) <= 0) goto err;
199 if (rb == NULL) return 1;
200 if (BIO_puts(bp," Response Type: ") <= 0)
201 goto err;
202 if(i2a_ASN1_OBJECT(bp, rb->responseType) <= 0)
203 goto err;
204 if (OBJ_obj2nid(rb->responseType) != NID_id_pkix_OCSP_basic)
205 {
206 BIO_puts(bp," (unknown response type)\n");
207 return 1;
208 }
209
210 p = ASN1_STRING_data(rb->response);
211 i = ASN1_STRING_length(rb->response);
212 if (!(br = OCSP_response_get1_basic(o))) goto err;
213 rd = br->tbsResponseData;
214 l=ASN1_INTEGER_get(rd->version);
215 if (BIO_printf(bp,"\n Version: %lu (0x%lx)\n",
216 l+1,l) <= 0) goto err;
217 if (BIO_puts(bp," Responder Id: ") <= 0) goto err;
218
219 rid = rd->responderId;
220 switch (rid->type)
221 {
222 case V_OCSP_RESPID_NAME:
223 X509_NAME_print_ex(bp, rid->value.byName, 0, XN_FLAG_ONELINE);
224 break;
225 case V_OCSP_RESPID_KEY:
226 i2a_ASN1_STRING(bp, rid->value.byKey, V_ASN1_OCTET_STRING);
227 break;
228 }
229
230 if (BIO_printf(bp,"\n Produced At: ")<=0) goto err;
231 if (!ASN1_GENERALIZEDTIME_print(bp, rd->producedAt)) goto err;
232 if (BIO_printf(bp,"\n Responses:\n") <= 0) goto err;
233 for (i = 0; i < sk_OCSP_SINGLERESP_num(rd->responses); i++)
234 {
235 if (! sk_OCSP_SINGLERESP_value(rd->responses, i)) continue;
236 single = sk_OCSP_SINGLERESP_value(rd->responses, i);
237 cid = single->certId;
238 if(ocsp_certid_print(bp, cid, 4) <= 0) goto err;
239 cst = single->certStatus;
240 if (BIO_printf(bp," Cert Status: %s",
241 OCSP_cert_status_str(cst->type)) <= 0)
242 goto err;
243 if (cst->type == V_OCSP_CERTSTATUS_REVOKED)
244 {
245 rev = cst->value.revoked;
246 if (BIO_printf(bp, "\n Revocation Time: ") <= 0)
247 goto err;
248 if (!ASN1_GENERALIZEDTIME_print(bp,
249 rev->revocationTime))
250 goto err;
251 if (rev->revocationReason)
252 {
253 l=ASN1_ENUMERATED_get(rev->revocationReason);
254 if (BIO_printf(bp,
255 "\n Revocation Reason: %s (0x%x)",
256 OCSP_crl_reason_str(l), l) <= 0)
257 goto err;
258 }
259 }
260 if (BIO_printf(bp,"\n This Update: ") <= 0) goto err;
261 if (!ASN1_GENERALIZEDTIME_print(bp, single->thisUpdate))
262 goto err;
263 if (single->nextUpdate)
264 {
265 if (BIO_printf(bp,"\n Next Update: ") <= 0)goto err;
266 if (!ASN1_GENERALIZEDTIME_print(bp,single->nextUpdate))
267 goto err;
268 }
269 if (!BIO_write(bp,"\n",1)) goto err;
270 if (!X509V3_extensions_print(bp,
271 "Response Single Extensions",
272 single->singleExtensions, flags, 8))
273 goto err;
274 if (!BIO_write(bp,"\n",1)) goto err;
275 }
276 if (!X509V3_extensions_print(bp, "Response Extensions",
277 rd->responseExtensions, flags, 4))
278 if(X509_signature_print(bp, br->signatureAlgorithm, br->signature) <= 0)
279 goto err;
280
281 for (i=0; i<sk_X509_num(br->certs); i++)
282 {
283 X509_print(bp, sk_X509_value(br->certs,i));
284 PEM_write_bio_X509(bp,sk_X509_value(br->certs,i));
285 }
286
287 ret = 1;
288err:
289 OCSP_BASICRESP_free(br);
290 return ret;
291 }
diff --git a/src/lib/libcrypto/ocsp/ocsp_srv.c b/src/lib/libcrypto/ocsp/ocsp_srv.c
new file mode 100644
index 0000000000..fffa134e75
--- /dev/null
+++ b/src/lib/libcrypto/ocsp/ocsp_srv.c
@@ -0,0 +1,264 @@
1/* ocsp_srv.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
3 * project 2001.
4 */
5/* ====================================================================
6 * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * openssl-core@openssl.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59#include <stdio.h>
60#include <cryptlib.h>
61#include <openssl/objects.h>
62#include <openssl/rand.h>
63#include <openssl/x509.h>
64#include <openssl/pem.h>
65#include <openssl/x509v3.h>
66#include <openssl/ocsp.h>
67
68/* Utility functions related to sending OCSP responses and extracting
69 * relevant information from the request.
70 */
71
72int OCSP_request_onereq_count(OCSP_REQUEST *req)
73 {
74 return sk_OCSP_ONEREQ_num(req->tbsRequest->requestList);
75 }
76
77OCSP_ONEREQ *OCSP_request_onereq_get0(OCSP_REQUEST *req, int i)
78 {
79 return sk_OCSP_ONEREQ_value(req->tbsRequest->requestList, i);
80 }
81
82OCSP_CERTID *OCSP_onereq_get0_id(OCSP_ONEREQ *one)
83 {
84 return one->reqCert;
85 }
86
87int OCSP_id_get0_info(ASN1_OCTET_STRING **piNameHash, ASN1_OBJECT **pmd,
88 ASN1_OCTET_STRING **pikeyHash,
89 ASN1_INTEGER **pserial, OCSP_CERTID *cid)
90 {
91 if (!cid) return 0;
92 if (pmd) *pmd = cid->hashAlgorithm->algorithm;
93 if(piNameHash) *piNameHash = cid->issuerNameHash;
94 if (pikeyHash) *pikeyHash = cid->issuerKeyHash;
95 if (pserial) *pserial = cid->serialNumber;
96 return 1;
97 }
98
99int OCSP_request_is_signed(OCSP_REQUEST *req)
100 {
101 if(req->optionalSignature) return 1;
102 return 0;
103 }
104
105/* Create an OCSP response and encode an optional basic response */
106OCSP_RESPONSE *OCSP_response_create(int status, OCSP_BASICRESP *bs)
107 {
108 OCSP_RESPONSE *rsp = NULL;
109
110 if (!(rsp = OCSP_RESPONSE_new())) goto err;
111 if (!(ASN1_ENUMERATED_set(rsp->responseStatus, status))) goto err;
112 if (!bs) return rsp;
113 if (!(rsp->responseBytes = OCSP_RESPBYTES_new())) goto err;
114 rsp->responseBytes->responseType = OBJ_nid2obj(NID_id_pkix_OCSP_basic);
115 if (!ASN1_item_pack(bs, ASN1_ITEM_rptr(OCSP_BASICRESP), &rsp->responseBytes->response))
116 goto err;
117 return rsp;
118err:
119 if (rsp) OCSP_RESPONSE_free(rsp);
120 return NULL;
121 }
122
123
124OCSP_SINGLERESP *OCSP_basic_add1_status(OCSP_BASICRESP *rsp,
125 OCSP_CERTID *cid,
126 int status, int reason,
127 ASN1_TIME *revtime,
128 ASN1_TIME *thisupd, ASN1_TIME *nextupd)
129 {
130 OCSP_SINGLERESP *single = NULL;
131 OCSP_CERTSTATUS *cs;
132 OCSP_REVOKEDINFO *ri;
133
134 if(!rsp->tbsResponseData->responses &&
135 !(rsp->tbsResponseData->responses = sk_OCSP_SINGLERESP_new_null()))
136 goto err;
137
138 if (!(single = OCSP_SINGLERESP_new()))
139 goto err;
140
141
142
143 if (!ASN1_TIME_to_generalizedtime(thisupd, &single->thisUpdate))
144 goto err;
145 if (nextupd &&
146 !ASN1_TIME_to_generalizedtime(nextupd, &single->nextUpdate))
147 goto err;
148
149 OCSP_CERTID_free(single->certId);
150
151 if(!(single->certId = OCSP_CERTID_dup(cid)))
152 goto err;
153
154 cs = single->certStatus;
155 switch(cs->type = status)
156 {
157 case V_OCSP_CERTSTATUS_REVOKED:
158 if (!revtime)
159 {
160 OCSPerr(OCSP_F_OCSP_BASIC_ADD1_STATUS,OCSP_R_NO_REVOKED_TIME);
161 goto err;
162 }
163 if (!(cs->value.revoked = ri = OCSP_REVOKEDINFO_new())) goto err;
164 if (!ASN1_TIME_to_generalizedtime(revtime, &ri->revocationTime))
165 goto err;
166 if (reason != OCSP_REVOKED_STATUS_NOSTATUS)
167 {
168 if (!(ri->revocationReason = ASN1_ENUMERATED_new()))
169 goto err;
170 if (!(ASN1_ENUMERATED_set(ri->revocationReason,
171 reason)))
172 goto err;
173 }
174 break;
175
176 case V_OCSP_CERTSTATUS_GOOD:
177 cs->value.good = ASN1_NULL_new();
178 break;
179
180 case V_OCSP_CERTSTATUS_UNKNOWN:
181 cs->value.unknown = ASN1_NULL_new();
182 break;
183
184 default:
185 goto err;
186
187 }
188 if (!(sk_OCSP_SINGLERESP_push(rsp->tbsResponseData->responses, single)))
189 goto err;
190 return single;
191err:
192 OCSP_SINGLERESP_free(single);
193 return NULL;
194 }
195
196/* Add a certificate to an OCSP request */
197
198int OCSP_basic_add1_cert(OCSP_BASICRESP *resp, X509 *cert)
199 {
200 if (!resp->certs && !(resp->certs = sk_X509_new_null()))
201 return 0;
202
203 if(!sk_X509_push(resp->certs, cert)) return 0;
204 CRYPTO_add(&cert->references, 1, CRYPTO_LOCK_X509);
205 return 1;
206 }
207
208int OCSP_basic_sign(OCSP_BASICRESP *brsp,
209 X509 *signer, EVP_PKEY *key, const EVP_MD *dgst,
210 STACK_OF(X509) *certs, unsigned long flags)
211 {
212 int i;
213 OCSP_RESPID *rid;
214
215 if (!X509_check_private_key(signer, key))
216 {
217 OCSPerr(OCSP_F_OCSP_BASIC_SIGN, OCSP_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE);
218 goto err;
219 }
220
221 if(!(flags & OCSP_NOCERTS))
222 {
223 if(!OCSP_basic_add1_cert(brsp, signer))
224 goto err;
225 for (i = 0; i < sk_X509_num(certs); i++)
226 {
227 X509 *tmpcert = sk_X509_value(certs, i);
228 if(!OCSP_basic_add1_cert(brsp, tmpcert))
229 goto err;
230 }
231 }
232
233 rid = brsp->tbsResponseData->responderId;
234 if (flags & OCSP_RESPID_KEY)
235 {
236 unsigned char md[SHA_DIGEST_LENGTH];
237 X509_pubkey_digest(signer, EVP_sha1(), md, NULL);
238 if (!(rid->value.byKey = ASN1_OCTET_STRING_new()))
239 goto err;
240 if (!(ASN1_OCTET_STRING_set(rid->value.byKey, md, SHA_DIGEST_LENGTH)))
241 goto err;
242 rid->type = V_OCSP_RESPID_KEY;
243 }
244 else
245 {
246 if (!X509_NAME_set(&rid->value.byName,
247 X509_get_subject_name(signer)))
248 goto err;
249 rid->type = V_OCSP_RESPID_NAME;
250 }
251
252 if (!(flags & OCSP_NOTIME) &&
253 !X509_gmtime_adj(brsp->tbsResponseData->producedAt, 0))
254 goto err;
255
256 /* Right now, I think that not doing double hashing is the right
257 thing. -- Richard Levitte */
258
259 if (!OCSP_BASICRESP_sign(brsp, key, dgst, 0)) goto err;
260
261 return 1;
262err:
263 return 0;
264 }
diff --git a/src/lib/libcrypto/ocsp/ocsp_vfy.c b/src/lib/libcrypto/ocsp/ocsp_vfy.c
new file mode 100644
index 0000000000..1f5fda7ca3
--- /dev/null
+++ b/src/lib/libcrypto/ocsp/ocsp_vfy.c
@@ -0,0 +1,444 @@
1/* ocsp_vfy.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) 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 <openssl/ocsp.h>
60#include <openssl/err.h>
61#include <string.h>
62
63static int ocsp_find_signer(X509 **psigner, OCSP_BASICRESP *bs, STACK_OF(X509) *certs,
64 X509_STORE *st, unsigned long flags);
65static X509 *ocsp_find_signer_sk(STACK_OF(X509) *certs, OCSP_RESPID *id);
66static int ocsp_check_issuer(OCSP_BASICRESP *bs, STACK_OF(X509) *chain, unsigned long flags);
67static int ocsp_check_ids(STACK_OF(OCSP_SINGLERESP) *sresp, OCSP_CERTID **ret);
68static int ocsp_match_issuerid(X509 *cert, OCSP_CERTID *cid, STACK_OF(OCSP_SINGLERESP) *sresp);
69static int ocsp_check_delegated(X509 *x, int flags);
70static int ocsp_req_find_signer(X509 **psigner, OCSP_REQUEST *req, X509_NAME *nm, STACK_OF(X509) *certs,
71 X509_STORE *st, unsigned long flags);
72
73/* Verify a basic response message */
74
75int OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs,
76 X509_STORE *st, unsigned long flags)
77 {
78 X509 *signer, *x;
79 STACK_OF(X509) *chain = NULL;
80 X509_STORE_CTX ctx;
81 int i, ret = 0;
82 ret = ocsp_find_signer(&signer, bs, certs, st, flags);
83 if (!ret)
84 {
85 OCSPerr(OCSP_F_OCSP_BASIC_VERIFY, OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND);
86 goto end;
87 }
88 if ((ret == 2) && (flags & OCSP_TRUSTOTHER))
89 flags |= OCSP_NOVERIFY;
90 if (!(flags & OCSP_NOSIGS))
91 {
92 EVP_PKEY *skey;
93 skey = X509_get_pubkey(signer);
94 ret = OCSP_BASICRESP_verify(bs, skey, 0);
95 EVP_PKEY_free(skey);
96 if(ret <= 0)
97 {
98 OCSPerr(OCSP_F_OCSP_BASIC_VERIFY, OCSP_R_SIGNATURE_FAILURE);
99 goto end;
100 }
101 }
102 if (!(flags & OCSP_NOVERIFY))
103 {
104 int init_res;
105 if(flags & OCSP_NOCHAIN)
106 init_res = X509_STORE_CTX_init(&ctx, st, signer, NULL);
107 else
108 init_res = X509_STORE_CTX_init(&ctx, st, signer, bs->certs);
109 if(!init_res)
110 {
111 OCSPerr(OCSP_F_OCSP_BASIC_VERIFY,ERR_R_X509_LIB);
112 goto end;
113 }
114
115 X509_STORE_CTX_set_purpose(&ctx, X509_PURPOSE_OCSP_HELPER);
116 ret = X509_verify_cert(&ctx);
117 chain = X509_STORE_CTX_get1_chain(&ctx);
118 X509_STORE_CTX_cleanup(&ctx);
119 if (ret <= 0)
120 {
121 i = X509_STORE_CTX_get_error(&ctx);
122 OCSPerr(OCSP_F_OCSP_BASIC_VERIFY,OCSP_R_CERTIFICATE_VERIFY_ERROR);
123 ERR_add_error_data(2, "Verify error:",
124 X509_verify_cert_error_string(i));
125 goto end;
126 }
127 if(flags & OCSP_NOCHECKS)
128 {
129 ret = 1;
130 goto end;
131 }
132 /* At this point we have a valid certificate chain
133 * need to verify it against the OCSP issuer criteria.
134 */
135 ret = ocsp_check_issuer(bs, chain, flags);
136
137 /* If fatal error or valid match then finish */
138 if (ret != 0) goto end;
139
140 /* Easy case: explicitly trusted. Get root CA and
141 * check for explicit trust
142 */
143 if(flags & OCSP_NOEXPLICIT) goto end;
144
145 x = sk_X509_value(chain, sk_X509_num(chain) - 1);
146 if(X509_check_trust(x, NID_OCSP_sign, 0) != X509_TRUST_TRUSTED)
147 {
148 OCSPerr(OCSP_F_OCSP_BASIC_VERIFY,OCSP_R_ROOT_CA_NOT_TRUSTED);
149 goto end;
150 }
151 ret = 1;
152 }
153
154
155
156 end:
157 if(chain) sk_X509_pop_free(chain, X509_free);
158 return ret;
159 }
160
161
162static int ocsp_find_signer(X509 **psigner, OCSP_BASICRESP *bs, STACK_OF(X509) *certs,
163 X509_STORE *st, unsigned long flags)
164 {
165 X509 *signer;
166 OCSP_RESPID *rid = bs->tbsResponseData->responderId;
167 if ((signer = ocsp_find_signer_sk(certs, rid)))
168 {
169 *psigner = signer;
170 return 2;
171 }
172 if(!(flags & OCSP_NOINTERN) &&
173 (signer = ocsp_find_signer_sk(bs->certs, rid)))
174 {
175 *psigner = signer;
176 return 1;
177 }
178 /* Maybe lookup from store if by subject name */
179
180 *psigner = NULL;
181 return 0;
182 }
183
184
185static X509 *ocsp_find_signer_sk(STACK_OF(X509) *certs, OCSP_RESPID *id)
186 {
187 int i;
188 unsigned char tmphash[SHA_DIGEST_LENGTH], *keyhash;
189 X509 *x;
190
191 /* Easy if lookup by name */
192 if (id->type == V_OCSP_RESPID_NAME)
193 return X509_find_by_subject(certs, id->value.byName);
194
195 /* Lookup by key hash */
196
197 /* If key hash isn't SHA1 length then forget it */
198 if (id->value.byKey->length != SHA_DIGEST_LENGTH) return NULL;
199 keyhash = id->value.byKey->data;
200 /* Calculate hash of each key and compare */
201 for (i = 0; i < sk_X509_num(certs); i++)
202 {
203 x = sk_X509_value(certs, i);
204 X509_pubkey_digest(x, EVP_sha1(), tmphash, NULL);
205 if(!memcmp(keyhash, tmphash, SHA_DIGEST_LENGTH))
206 return x;
207 }
208 return NULL;
209 }
210
211
212static int ocsp_check_issuer(OCSP_BASICRESP *bs, STACK_OF(X509) *chain, unsigned long flags)
213 {
214 STACK_OF(OCSP_SINGLERESP) *sresp;
215 X509 *signer, *sca;
216 OCSP_CERTID *caid = NULL;
217 int i;
218 sresp = bs->tbsResponseData->responses;
219
220 if (sk_X509_num(chain) <= 0)
221 {
222 OCSPerr(OCSP_F_OCSP_CHECK_ISSUER, OCSP_R_NO_CERTIFICATES_IN_CHAIN);
223 return -1;
224 }
225
226 /* See if the issuer IDs match. */
227 i = ocsp_check_ids(sresp, &caid);
228
229 /* If ID mismatch or other error then return */
230 if (i <= 0) return i;
231
232 signer = sk_X509_value(chain, 0);
233 /* Check to see if OCSP responder CA matches request CA */
234 if (sk_X509_num(chain) > 1)
235 {
236 sca = sk_X509_value(chain, 1);
237 i = ocsp_match_issuerid(sca, caid, sresp);
238 if (i < 0) return i;
239 if (i)
240 {
241 /* We have a match, if extensions OK then success */
242 if (ocsp_check_delegated(signer, flags)) return 1;
243 return 0;
244 }
245 }
246
247 /* Otherwise check if OCSP request signed directly by request CA */
248 return ocsp_match_issuerid(signer, caid, sresp);
249 }
250
251
252/* Check the issuer certificate IDs for equality. If there is a mismatch with the same
253 * algorithm then there's no point trying to match any certificates against the issuer.
254 * If the issuer IDs all match then we just need to check equality against one of them.
255 */
256
257static int ocsp_check_ids(STACK_OF(OCSP_SINGLERESP) *sresp, OCSP_CERTID **ret)
258 {
259 OCSP_CERTID *tmpid, *cid;
260 int i, idcount;
261
262 idcount = sk_OCSP_SINGLERESP_num(sresp);
263 if (idcount <= 0)
264 {
265 OCSPerr(OCSP_F_OCSP_CHECK_IDS, OCSP_R_RESPONSE_CONTAINS_NO_REVOCATION_DATA);
266 return -1;
267 }
268
269 cid = sk_OCSP_SINGLERESP_value(sresp, 0)->certId;
270
271 *ret = NULL;
272
273 for (i = 1; i < idcount; i++)
274 {
275 tmpid = sk_OCSP_SINGLERESP_value(sresp, 0)->certId;
276 /* Check to see if IDs match */
277 if (OCSP_id_issuer_cmp(cid, tmpid))
278 {
279 /* If algoritm mismatch let caller deal with it */
280 if (OBJ_cmp(tmpid->hashAlgorithm->algorithm,
281 cid->hashAlgorithm->algorithm))
282 return 2;
283 /* Else mismatch */
284 return 0;
285 }
286 }
287
288 /* All IDs match: only need to check one ID */
289 *ret = cid;
290 return 1;
291 }
292
293
294static int ocsp_match_issuerid(X509 *cert, OCSP_CERTID *cid,
295 STACK_OF(OCSP_SINGLERESP) *sresp)
296 {
297 /* If only one ID to match then do it */
298 if(cid)
299 {
300 const EVP_MD *dgst;
301 X509_NAME *iname;
302 int mdlen;
303 unsigned char md[EVP_MAX_MD_SIZE];
304 if (!(dgst = EVP_get_digestbyobj(cid->hashAlgorithm->algorithm)))
305 {
306 OCSPerr(OCSP_F_OCSP_MATCH_ISSUERID, OCSP_R_UNKNOWN_MESSAGE_DIGEST);
307 return -1;
308 }
309
310 mdlen = EVP_MD_size(dgst);
311 if ((cid->issuerNameHash->length != mdlen) ||
312 (cid->issuerKeyHash->length != mdlen))
313 return 0;
314 iname = X509_get_subject_name(cert);
315 if (!X509_NAME_digest(iname, dgst, md, NULL))
316 return -1;
317 if (memcmp(md, cid->issuerNameHash->data, mdlen))
318 return 0;
319 X509_pubkey_digest(cert, EVP_sha1(), md, NULL);
320 if (memcmp(md, cid->issuerKeyHash->data, mdlen))
321 return 0;
322
323 return 1;
324
325 }
326 else
327 {
328 /* We have to match the whole lot */
329 int i, ret;
330 OCSP_CERTID *tmpid;
331 for (i = 0; i < sk_OCSP_SINGLERESP_num(sresp); i++)
332 {
333 tmpid = sk_OCSP_SINGLERESP_value(sresp, 0)->certId;
334 ret = ocsp_match_issuerid(cert, tmpid, NULL);
335 if (ret <= 0) return ret;
336 }
337 return 1;
338 }
339
340 }
341
342static int ocsp_check_delegated(X509 *x, int flags)
343 {
344 X509_check_purpose(x, -1, 0);
345 if ((x->ex_flags & EXFLAG_XKUSAGE) &&
346 (x->ex_xkusage & XKU_OCSP_SIGN))
347 return 1;
348 OCSPerr(OCSP_F_OCSP_CHECK_DELEGATED, OCSP_R_MISSING_OCSPSIGNING_USAGE);
349 return 0;
350 }
351
352/* Verify an OCSP request. This is fortunately much easier than OCSP
353 * response verify. Just find the signers certificate and verify it
354 * against a given trust value.
355 */
356
357int OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) *certs, X509_STORE *store, unsigned long flags)
358 {
359 X509 *signer;
360 X509_NAME *nm;
361 GENERAL_NAME *gen;
362 int ret;
363 X509_STORE_CTX ctx;
364 if (!req->optionalSignature)
365 {
366 OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY, OCSP_R_REQUEST_NOT_SIGNED);
367 return 0;
368 }
369 gen = req->tbsRequest->requestorName;
370 if (gen->type != GEN_DIRNAME)
371 {
372 OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY, OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE);
373 return 0;
374 }
375 nm = gen->d.directoryName;
376 ret = ocsp_req_find_signer(&signer, req, nm, certs, store, flags);
377 if (ret <= 0)
378 {
379 OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY, OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND);
380 return 0;
381 }
382 if ((ret == 2) && (flags & OCSP_TRUSTOTHER))
383 flags |= OCSP_NOVERIFY;
384 if (!(flags & OCSP_NOSIGS))
385 {
386 EVP_PKEY *skey;
387 skey = X509_get_pubkey(signer);
388 ret = OCSP_REQUEST_verify(req, skey);
389 EVP_PKEY_free(skey);
390 if(ret <= 0)
391 {
392 OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY, OCSP_R_SIGNATURE_FAILURE);
393 return 0;
394 }
395 }
396 if (!(flags & OCSP_NOVERIFY))
397 {
398 int init_res;
399 if(flags & OCSP_NOCHAIN)
400 init_res = X509_STORE_CTX_init(&ctx, store, signer, NULL);
401 else
402 init_res = X509_STORE_CTX_init(&ctx, store, signer,
403 req->optionalSignature->certs);
404 if(!init_res)
405 {
406 OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY,ERR_R_X509_LIB);
407 return 0;
408 }
409
410 X509_STORE_CTX_set_purpose(&ctx, X509_PURPOSE_OCSP_HELPER);
411 X509_STORE_CTX_set_trust(&ctx, X509_TRUST_OCSP_REQUEST);
412 ret = X509_verify_cert(&ctx);
413 X509_STORE_CTX_cleanup(&ctx);
414 if (ret <= 0)
415 {
416 ret = X509_STORE_CTX_get_error(&ctx);
417 OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY,OCSP_R_CERTIFICATE_VERIFY_ERROR);
418 ERR_add_error_data(2, "Verify error:",
419 X509_verify_cert_error_string(ret));
420 return 0;
421 }
422 }
423 return 1;
424 }
425
426static int ocsp_req_find_signer(X509 **psigner, OCSP_REQUEST *req, X509_NAME *nm, STACK_OF(X509) *certs,
427 X509_STORE *st, unsigned long flags)
428 {
429 X509 *signer;
430 if(!(flags & OCSP_NOINTERN))
431 {
432 signer = X509_find_by_subject(req->optionalSignature->certs, nm);
433 *psigner = signer;
434 return 1;
435 }
436
437 signer = X509_find_by_subject(certs, nm);
438 if (signer)
439 {
440 *psigner = signer;
441 return 2;
442 }
443 return 0;
444 }
diff --git a/src/lib/libcrypto/opensslconf.h.in b/src/lib/libcrypto/opensslconf.h.in
index 1b85ae5989..9082a16c46 100644
--- a/src/lib/libcrypto/opensslconf.h.in
+++ b/src/lib/libcrypto/opensslconf.h.in
@@ -9,8 +9,11 @@
9#endif 9#endif
10#endif 10#endif
11 11
12#undef OPENSSL_UNISTD
12#define OPENSSL_UNISTD <unistd.h> 13#define OPENSSL_UNISTD <unistd.h>
13 14
15#undef OPENSSL_EXPORT_VAR_AS_FUNCTION
16
14#if defined(HEADER_IDEA_H) && !defined(IDEA_INT) 17#if defined(HEADER_IDEA_H) && !defined(IDEA_INT)
15#define IDEA_INT unsigned int 18#define IDEA_INT unsigned int
16#endif 19#endif
@@ -44,7 +47,7 @@
44#endif 47#endif
45#endif 48#endif
46 49
47#if defined(HEADER_DES_H) && !defined(DES_LONG) 50#if (defined(HEADER_DES_H) || defined(HEADER_DES_OLD_H)) && !defined(DES_LONG)
48/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a 51/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
49 * %20 speed up (longs are 8 bytes, int's are 4). */ 52 * %20 speed up (longs are 8 bytes, int's are 4). */
50#ifndef DES_LONG 53#ifndef DES_LONG
@@ -144,7 +147,7 @@ YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
144# define DES_PTR 147# define DES_PTR
145# define DES_RISC2 148# define DES_RISC2
146# define DES_UNROLL 149# define DES_UNROLL
147#elif defined( i386 ) /* x86 boxes, should be gcc */ 150#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */
148# define DES_PTR 151# define DES_PTR
149# define DES_RISC1 152# define DES_RISC1
150# define DES_UNROLL 153# define DES_UNROLL
diff --git a/src/lib/libcrypto/opensslv.h b/src/lib/libcrypto/opensslv.h
index 4b25018e49..f45afe09f3 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 0x0090602fL 28#define OPENSSL_VERSION_NUMBER 0x00907000L
29#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.6b [engine] 9 Jul 2001" 29#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.7-dev XX xxx XXXX"
30#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT 30#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT
31 31
32 32
@@ -44,13 +44,13 @@
44 * 44 *
45 * libcrypto.so.0 45 * libcrypto.so.0
46 * 46 *
47 * On True64 it works a little bit differently. There, the shared library 47 * On Tru64 and IRIX 6.x it works a little bit differently. There, the
48 * version is stored in the file, and is actually a series of versions, 48 * shared library version is stored in the file, and is actually a series
49 * separated by colons. The rightmost version present in the library when 49 * of versions, separated by colons. The rightmost version present in the
50 * linking an application is stored in the application to be matched at 50 * library when linking an application is stored in the application to be
51 * run time. When the application is run, a check is done to see if the 51 * matched at run time. When the application is run, a check is done to
52 * library version stored in the application matches any of the versions 52 * see if the library version stored in the application matches any of the
53 * in the version string of the library itself. 53 * versions in the version string of the library itself.
54 * This version string can be constructed in any way, depending on what 54 * This version string can be constructed in any way, depending on what
55 * kind of matching is desired. However, to implement the same scheme as 55 * kind of matching is desired. However, to implement the same scheme as
56 * the one used in the other unixen, all compatible versions, from lowest 56 * the one used in the other unixen, all compatible versions, from lowest
@@ -73,13 +73,13 @@
73 * However, it's nice and more understandable if it actually does. 73 * However, it's nice and more understandable if it actually does.
74 * The current library version is stored in the macro SHLIB_VERSION_NUMBER, 74 * The current library version is stored in the macro SHLIB_VERSION_NUMBER,
75 * which is just a piece of text in the format "M.m.e" (Major, minor, edit). 75 * which is just a piece of text in the format "M.m.e" (Major, minor, edit).
76 * For the sake of True64 and any other OS that behaves in similar ways, 76 * For the sake of Tru64, IRIX, and any other OS that behaves in similar ways,
77 * we need to keep a history of version numbers, which is done in the 77 * we need to keep a history of version numbers, which is done in the
78 * macro SHLIB_VERSION_HISTORY. The numbers are separated by colons and 78 * macro SHLIB_VERSION_HISTORY. The numbers are separated by colons and
79 * should only keep the versions that are binary compatible with the current. 79 * should only keep the versions that are binary compatible with the current.
80 */ 80 */
81#define SHLIB_VERSION_HISTORY "" 81#define SHLIB_VERSION_HISTORY ""
82#define SHLIB_VERSION_NUMBER "0.9.6" 82#define SHLIB_VERSION_NUMBER "0.9.7"
83 83
84 84
85#endif /* HEADER_OPENSSLV_H */ 85#endif /* HEADER_OPENSSLV_H */
diff --git a/src/lib/libcrypto/ossl_typ.h b/src/lib/libcrypto/ossl_typ.h
new file mode 100644
index 0000000000..6bd42aee4d
--- /dev/null
+++ b/src/lib/libcrypto/ossl_typ.h
@@ -0,0 +1,120 @@
1/* ====================================================================
2 * Copyright (c) 1998-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_OPENSSL_TYPES_H
56#define HEADER_OPENSSL_TYPES_H
57
58#ifdef NO_ASN1_TYPEDEFS
59#define ASN1_INTEGER ASN1_STRING
60#define ASN1_ENUMERATED ASN1_STRING
61#define ASN1_BIT_STRING ASN1_STRING
62#define ASN1_OCTET_STRING ASN1_STRING
63#define ASN1_PRINTABLESTRING ASN1_STRING
64#define ASN1_T61STRING ASN1_STRING
65#define ASN1_IA5STRING ASN1_STRING
66#define ASN1_UTCTIME ASN1_STRING
67#define ASN1_GENERALIZEDTIME ASN1_STRING
68#define ASN1_TIME ASN1_STRING
69#define ASN1_GENERALSTRING ASN1_STRING
70#define ASN1_UNIVERSALSTRING ASN1_STRING
71#define ASN1_BMPSTRING ASN1_STRING
72#define ASN1_VISIBLESTRING ASN1_STRING
73#define ASN1_UTF8STRING ASN1_STRING
74#define ASN1_BOOLEAN int
75#define ASN1_NULL int
76#else
77typedef struct asn1_string_st ASN1_INTEGER;
78typedef struct asn1_string_st ASN1_ENUMERATED;
79typedef struct asn1_string_st ASN1_BIT_STRING;
80typedef struct asn1_string_st ASN1_OCTET_STRING;
81typedef struct asn1_string_st ASN1_PRINTABLESTRING;
82typedef struct asn1_string_st ASN1_T61STRING;
83typedef struct asn1_string_st ASN1_IA5STRING;
84typedef struct asn1_string_st ASN1_GENERALSTRING;
85typedef struct asn1_string_st ASN1_UNIVERSALSTRING;
86typedef struct asn1_string_st ASN1_BMPSTRING;
87typedef struct asn1_string_st ASN1_UTCTIME;
88typedef struct asn1_string_st ASN1_TIME;
89typedef struct asn1_string_st ASN1_GENERALIZEDTIME;
90typedef struct asn1_string_st ASN1_VISIBLESTRING;
91typedef struct asn1_string_st ASN1_UTF8STRING;
92typedef int ASN1_BOOLEAN;
93typedef int ASN1_NULL;
94#endif
95
96#ifdef OPENSSL_SYS_WIN32
97#undef X509_NAME
98#undef PKCS7_ISSUER_AND_SERIAL
99#endif
100
101typedef struct evp_cipher_st EVP_CIPHER;
102typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX;
103typedef struct env_md_st EVP_MD;
104typedef struct env_md_ctx_st EVP_MD_CTX;
105typedef struct evp_pkey_st EVP_PKEY;
106
107typedef struct x509_st X509;
108typedef struct X509_algor_st X509_ALGOR;
109typedef struct X509_crl_st X509_CRL;
110typedef struct X509_name_st X509_NAME;
111typedef struct x509_store_st X509_STORE;
112typedef struct x509_store_ctx_st X509_STORE_CTX;
113
114typedef struct engine_st ENGINE;
115
116 /* If placed in pkcs12.h, we end up with a circular depency with pkcs7.h */
117#define DECLARE_PKCS12_STACK_OF(type) /* Nothing */
118#define IMPLEMENT_PKCS12_STACK_OF(type) /* Nothing */
119
120#endif /* def HEADER_OPENSSL_TYPES_H */
diff --git a/src/lib/libcrypto/pem/Makefile.ssl b/src/lib/libcrypto/pem/Makefile.ssl
index 31db6b65a1..2153723509 100644
--- a/src/lib/libcrypto/pem/Makefile.ssl
+++ b/src/lib/libcrypto/pem/Makefile.ssl
@@ -5,13 +5,14 @@
5DIR= pem 5DIR= pem
6TOP= ../.. 6TOP= ../..
7CC= cc 7CC= cc
8INCLUDES= -I.. -I../../include 8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g 9CFLAG=-g
10INSTALL_PREFIX= 10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl 11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl 12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl 13MAKE= make -f Makefile.ssl
14MAKEDEPEND= $(TOP)/util/domd $(TOP) 14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
15MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
16AR= ar r 17AR= ar r
17 18
@@ -22,9 +23,11 @@ TEST=
22APPS= 23APPS=
23 24
24LIB=$(TOP)/libcrypto.a 25LIB=$(TOP)/libcrypto.a
25LIBSRC= pem_sign.c pem_seal.c pem_info.c pem_lib.c pem_all.c pem_err.c 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
26 28
27LIBOBJ= pem_sign.o pem_seal.o pem_info.o pem_lib.o pem_all.o pem_err.o 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
28 31
29SRC= $(LIBSRC) 32SRC= $(LIBSRC)
30 33
@@ -40,8 +43,7 @@ all: lib
40 43
41lib: $(LIBOBJ) 44lib: $(LIBOBJ)
42 $(AR) $(LIB) $(LIBOBJ) 45 $(AR) $(LIB) $(LIBOBJ)
43 @echo You may get an error following this line. Please ignore. 46 $(RANLIB) $(LIB) || echo Never mind.
44 - $(RANLIB) $(LIB)
45 @touch lib 47 @touch lib
46 48
47files: 49files:
@@ -80,125 +82,169 @@ clean:
80 82
81# DO NOT DELETE THIS LINE -- make depend depends on it. 83# DO NOT DELETE THIS LINE -- make depend depends on it.
82 84
83pem_all.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 85pem_all.o: ../../e_os.h ../../include/openssl/asn1.h
84pem_all.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 86pem_all.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
85pem_all.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 87pem_all.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
86pem_all.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
87pem_all.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 88pem_all.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
88pem_all.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 89pem_all.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
89pem_all.o: ../../include/openssl/err.h ../../include/openssl/evp.h 90pem_all.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
90pem_all.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
91pem_all.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
92pem_all.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
93pem_all.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 91pem_all.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
94pem_all.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 92pem_all.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
95pem_all.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h 93pem_all.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h
96pem_all.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h 94pem_all.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h
97pem_all.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 95pem_all.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
98pem_all.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 96pem_all.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
99pem_all.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 97pem_all.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
100pem_all.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 98pem_all.o: ../../include/openssl/x509_vfy.h ../cryptlib.h pem_all.c
101pem_all.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
102pem_all.o: ../cryptlib.h
103pem_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 99pem_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
104pem_err.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 100pem_err.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
105pem_err.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 101pem_err.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
106pem_err.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 102pem_err.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
107pem_err.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 103pem_err.o: ../../include/openssl/err.h ../../include/openssl/evp.h
108pem_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 104pem_err.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
109pem_err.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
110pem_err.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
111pem_err.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
112pem_err.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
113pem_err.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 105pem_err.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
114pem_err.o: ../../include/openssl/opensslv.h ../../include/openssl/pem.h 106pem_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
115pem_err.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h 107pem_err.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
116pem_err.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 108pem_err.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
117pem_err.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 109pem_err.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
118pem_err.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 110pem_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
119pem_err.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 111pem_err.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
120pem_err.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 112pem_err.o: pem_err.c
121pem_err.o: ../../include/openssl/x509_vfy.h 113pem_info.o: ../../e_os.h ../../include/openssl/asn1.h
122pem_info.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 114pem_info.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
123pem_info.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 115pem_info.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
124pem_info.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
125pem_info.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
126pem_info.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 116pem_info.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
127pem_info.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 117pem_info.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
128pem_info.o: ../../include/openssl/err.h ../../include/openssl/evp.h 118pem_info.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
129pem_info.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
130pem_info.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
131pem_info.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
132pem_info.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 119pem_info.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
133pem_info.o: ../../include/openssl/opensslconf.h 120pem_info.o: ../../include/openssl/opensslconf.h
134pem_info.o: ../../include/openssl/opensslv.h ../../include/openssl/pem.h 121pem_info.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
135pem_info.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h 122pem_info.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
136pem_info.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 123pem_info.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
137pem_info.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 124pem_info.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
138pem_info.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 125pem_info.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
139pem_info.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 126pem_info.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
140pem_info.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 127pem_info.o: ../cryptlib.h pem_info.c
141pem_info.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 128pem_lib.o: ../../e_os.h ../../include/openssl/asn1.h
142pem_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 129pem_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
143pem_lib.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 130pem_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
144pem_lib.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 131pem_lib.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
145pem_lib.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
146pem_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 132pem_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
147pem_lib.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 133pem_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
148pem_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h 134pem_lib.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
149pem_lib.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
150pem_lib.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
151pem_lib.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
152pem_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 135pem_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
153pem_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 136pem_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
154pem_lib.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h 137pem_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h
155pem_lib.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h 138pem_lib.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs12.h
156pem_lib.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h 139pem_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
157pem_lib.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 140pem_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
158pem_lib.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 141pem_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
159pem_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 142pem_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
160pem_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 143pem_lib.o: ../../include/openssl/ui_compat.h ../../include/openssl/x509.h
161pem_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 144pem_lib.o: ../../include/openssl/x509_vfy.h ../cryptlib.h pem_lib.c
162pem_lib.o: ../cryptlib.h 145pem_oth.o: ../../e_os.h ../../include/openssl/asn1.h
163pem_seal.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 146pem_oth.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
164pem_seal.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 147pem_oth.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
165pem_seal.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 148pem_oth.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
166pem_seal.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 149pem_oth.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
150pem_oth.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
151pem_oth.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
152pem_oth.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
153pem_oth.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h
154pem_oth.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h
155pem_oth.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
156pem_oth.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
157pem_oth.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
158pem_oth.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
159pem_oth.o: ../cryptlib.h pem_oth.c
160pem_pk8.o: ../../e_os.h ../../include/openssl/asn1.h
161pem_pk8.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
162pem_pk8.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
163pem_pk8.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
164pem_pk8.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
165pem_pk8.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
166pem_pk8.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
167pem_pk8.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
168pem_pk8.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h
169pem_pk8.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs12.h
170pem_pk8.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
171pem_pk8.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
172pem_pk8.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
173pem_pk8.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
174pem_pk8.o: ../../include/openssl/x509_vfy.h ../cryptlib.h pem_pk8.c
175pem_pkey.o: ../../e_os.h ../../include/openssl/asn1.h
176pem_pkey.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
177pem_pkey.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
178pem_pkey.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
179pem_pkey.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
180pem_pkey.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
181pem_pkey.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
182pem_pkey.o: ../../include/openssl/opensslconf.h
183pem_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
184pem_pkey.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
185pem_pkey.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
186pem_pkey.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
187pem_pkey.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
188pem_pkey.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
189pem_pkey.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
190pem_pkey.o: ../cryptlib.h pem_pkey.c
191pem_seal.o: ../../e_os.h ../../include/openssl/asn1.h
192pem_seal.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
193pem_seal.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
167pem_seal.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 194pem_seal.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
168pem_seal.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 195pem_seal.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
169pem_seal.o: ../../include/openssl/err.h ../../include/openssl/evp.h 196pem_seal.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
170pem_seal.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
171pem_seal.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
172pem_seal.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
173pem_seal.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 197pem_seal.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
174pem_seal.o: ../../include/openssl/opensslconf.h 198pem_seal.o: ../../include/openssl/opensslconf.h
175pem_seal.o: ../../include/openssl/opensslv.h ../../include/openssl/pem.h 199pem_seal.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
176pem_seal.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h 200pem_seal.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
177pem_seal.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h 201pem_seal.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
178pem_seal.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 202pem_seal.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
179pem_seal.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 203pem_seal.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
180pem_seal.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 204pem_seal.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
181pem_seal.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 205pem_seal.o: ../../include/openssl/x509_vfy.h ../cryptlib.h pem_seal.c
182pem_seal.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 206pem_sign.o: ../../e_os.h ../../include/openssl/asn1.h
183pem_seal.o: ../cryptlib.h 207pem_sign.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
184pem_sign.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 208pem_sign.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
185pem_sign.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
186pem_sign.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
187pem_sign.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
188pem_sign.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 209pem_sign.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
189pem_sign.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 210pem_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
190pem_sign.o: ../../include/openssl/err.h ../../include/openssl/evp.h 211pem_sign.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
191pem_sign.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
192pem_sign.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
193pem_sign.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
194pem_sign.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 212pem_sign.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
195pem_sign.o: ../../include/openssl/opensslconf.h 213pem_sign.o: ../../include/openssl/opensslconf.h
196pem_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/pem.h 214pem_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
197pem_sign.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h 215pem_sign.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
198pem_sign.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h 216pem_sign.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
199pem_sign.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 217pem_sign.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
200pem_sign.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 218pem_sign.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
201pem_sign.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 219pem_sign.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
202pem_sign.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 220pem_sign.o: ../../include/openssl/x509_vfy.h ../cryptlib.h pem_sign.c
203pem_sign.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 221pem_x509.o: ../../e_os.h ../../include/openssl/asn1.h
204pem_sign.o: ../cryptlib.h 222pem_x509.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
223pem_x509.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
224pem_x509.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
225pem_x509.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
226pem_x509.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
227pem_x509.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
228pem_x509.o: ../../include/openssl/opensslconf.h
229pem_x509.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
230pem_x509.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
231pem_x509.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
232pem_x509.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
233pem_x509.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
234pem_x509.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
235pem_x509.o: ../cryptlib.h pem_x509.c
236pem_xaux.o: ../../e_os.h ../../include/openssl/asn1.h
237pem_xaux.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
238pem_xaux.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
239pem_xaux.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
240pem_xaux.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
241pem_xaux.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
242pem_xaux.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
243pem_xaux.o: ../../include/openssl/opensslconf.h
244pem_xaux.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
245pem_xaux.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
246pem_xaux.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
247pem_xaux.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
248pem_xaux.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
249pem_xaux.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
250pem_xaux.o: ../cryptlib.h pem_xaux.c
diff --git a/src/lib/libcrypto/pem/pem.h b/src/lib/libcrypto/pem/pem.h
index 6d3c446577..3785fca77d 100644
--- a/src/lib/libcrypto/pem/pem.h
+++ b/src/lib/libcrypto/pem/pem.h
@@ -59,15 +59,16 @@
59#ifndef HEADER_PEM_H 59#ifndef HEADER_PEM_H
60#define HEADER_PEM_H 60#define HEADER_PEM_H
61 61
62#ifndef NO_BIO 62#ifndef OPENSSL_NO_BIO
63#include <openssl/bio.h> 63#include <openssl/bio.h>
64#endif 64#endif
65#ifndef NO_STACK 65#ifndef OPENSSL_NO_STACK
66#include <openssl/stack.h> 66#include <openssl/stack.h>
67#endif 67#endif
68#include <openssl/evp.h> 68#include <openssl/evp.h>
69#include <openssl/x509.h> 69#include <openssl/x509.h>
70#include <openssl/pem2.h> 70#include <openssl/pem2.h>
71#include <openssl/e_os2.h>
71 72
72#ifdef __cplusplus 73#ifdef __cplusplus
73extern "C" { 74extern "C" {
@@ -126,7 +127,8 @@ extern "C" {
126#define PEM_STRING_SSL_SESSION "SSL SESSION PARAMETERS" 127#define PEM_STRING_SSL_SESSION "SSL SESSION PARAMETERS"
127#define PEM_STRING_DSAPARAMS "DSA PARAMETERS" 128#define PEM_STRING_DSAPARAMS "DSA PARAMETERS"
128 129
129 130 /* Note that this structure is initialised by PEM_SealInit and cleaned up
131 by PEM_SealFinal (at least for now) */
130typedef struct PEM_Encode_Seal_st 132typedef struct PEM_Encode_Seal_st
131 { 133 {
132 EVP_ENCODE_CTX encode; 134 EVP_ENCODE_CTX encode;
@@ -171,7 +173,7 @@ typedef struct pem_ctx_st
171 int num_recipient; 173 int num_recipient;
172 PEM_USER **recipient; 174 PEM_USER **recipient;
173 175
174#ifndef NO_STACK 176#ifndef OPENSSL_NO_STACK
175 STACK *x509_chain; /* certificate chain */ 177 STACK *x509_chain; /* certificate chain */
176#else 178#else
177 char *x509_chain; /* certificate chain */ 179 char *x509_chain; /* certificate chain */
@@ -198,7 +200,7 @@ typedef struct pem_ctx_st
198 * IMPLEMENT_PEM_rw(...) or IMPLEMENT_PEM_rw_cb(...) 200 * IMPLEMENT_PEM_rw(...) or IMPLEMENT_PEM_rw_cb(...)
199 */ 201 */
200 202
201#ifdef NO_FP_API 203#ifdef OPENSSL_NO_FP_API
202 204
203#define IMPLEMENT_PEM_read_fp(name, type, str, asn1) /**/ 205#define IMPLEMENT_PEM_read_fp(name, type, str, asn1) /**/
204#define IMPLEMENT_PEM_write_fp(name, type, str, asn1) /**/ 206#define IMPLEMENT_PEM_write_fp(name, type, str, asn1) /**/
@@ -275,7 +277,7 @@ int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
275 277
276/* These are the same except they are for the declarations */ 278/* These are the same except they are for the declarations */
277 279
278#if defined(WIN16) || defined(NO_FP_API) 280#if defined(OPENSSL_SYS_WIN16) || defined(OPENSSL_NO_FP_API)
279 281
280#define DECLARE_PEM_read_fp(name, type) /**/ 282#define DECLARE_PEM_read_fp(name, type) /**/
281#define DECLARE_PEM_write_fp(name, type) /**/ 283#define DECLARE_PEM_write_fp(name, type) /**/
@@ -295,7 +297,7 @@ int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
295 297
296#endif 298#endif
297 299
298#ifndef NO_BIO 300#ifndef OPENSSL_NO_BIO
299#define DECLARE_PEM_read_bio(name, type) \ 301#define DECLARE_PEM_read_bio(name, type) \
300 type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u); 302 type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u);
301 303
@@ -483,11 +485,13 @@ int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher);
483int PEM_do_header (EVP_CIPHER_INFO *cipher, unsigned char *data,long *len, 485int PEM_do_header (EVP_CIPHER_INFO *cipher, unsigned char *data,long *len,
484 pem_password_cb *callback,void *u); 486 pem_password_cb *callback,void *u);
485 487
486#ifndef NO_BIO 488#ifndef OPENSSL_NO_BIO
487int PEM_read_bio(BIO *bp, char **name, char **header, 489int PEM_read_bio(BIO *bp, char **name, char **header,
488 unsigned char **data,long *len); 490 unsigned char **data,long *len);
489int PEM_write_bio(BIO *bp,const char *name,char *hdr,unsigned char *data, 491int PEM_write_bio(BIO *bp,const char *name,char *hdr,unsigned char *data,
490 long len); 492 long len);
493int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm, const char *name, BIO *bp,
494 pem_password_cb *cb, void *u);
491char * PEM_ASN1_read_bio(char *(*d2i)(),const char *name,BIO *bp,char **x, 495char * PEM_ASN1_read_bio(char *(*d2i)(),const char *name,BIO *bp,char **x,
492 pem_password_cb *cb, void *u); 496 pem_password_cb *cb, void *u);
493int PEM_ASN1_write_bio(int (*i2d)(),const char *name,BIO *bp,char *x, 497int PEM_ASN1_write_bio(int (*i2d)(),const char *name,BIO *bp,char *x,
@@ -498,7 +502,7 @@ int PEM_X509_INFO_write_bio(BIO *bp,X509_INFO *xi, EVP_CIPHER *enc,
498 unsigned char *kstr, int klen, pem_password_cb *cd, void *u); 502 unsigned char *kstr, int klen, pem_password_cb *cd, void *u);
499#endif 503#endif
500 504
501#ifndef WIN16 505#ifndef OPENSSL_SYS_WIN16
502int PEM_read(FILE *fp, char **name, char **header, 506int PEM_read(FILE *fp, char **name, char **header,
503 unsigned char **data,long *len); 507 unsigned char **data,long *len);
504int PEM_write(FILE *fp,char *name,char *hdr,unsigned char *data,long len); 508int PEM_write(FILE *fp,char *name,char *hdr,unsigned char *data,long len);
@@ -524,8 +528,7 @@ void PEM_SignUpdate(EVP_MD_CTX *ctx,unsigned char *d,unsigned int cnt);
524int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, 528int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,
525 unsigned int *siglen, EVP_PKEY *pkey); 529 unsigned int *siglen, EVP_PKEY *pkey);
526 530
527void ERR_load_PEM_strings(void); 531int PEM_def_callback(char *buf, int num, int w, void *key);
528
529void PEM_proc_type(char *buf, int type); 532void PEM_proc_type(char *buf, int type);
530void PEM_dek_info(char *buf, const char *type, int len, char *str); 533void PEM_dek_info(char *buf, const char *type, int len, char *str);
531 534
@@ -550,7 +553,7 @@ DECLARE_PEM_rw(PKCS8, X509_SIG)
550 553
551DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO) 554DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO)
552 555
553#ifndef NO_RSA 556#ifndef OPENSSL_NO_RSA
554 557
555DECLARE_PEM_rw_cb(RSAPrivateKey, RSA) 558DECLARE_PEM_rw_cb(RSAPrivateKey, RSA)
556 559
@@ -559,7 +562,7 @@ DECLARE_PEM_rw(RSA_PUBKEY, RSA)
559 562
560#endif 563#endif
561 564
562#ifndef NO_DSA 565#ifndef OPENSSL_NO_DSA
563 566
564DECLARE_PEM_rw_cb(DSAPrivateKey, DSA) 567DECLARE_PEM_rw_cb(DSAPrivateKey, DSA)
565 568
@@ -569,7 +572,7 @@ DECLARE_PEM_rw(DSAparams, DSA)
569 572
570#endif 573#endif
571 574
572#ifndef NO_DH 575#ifndef OPENSSL_NO_DH
573 576
574DECLARE_PEM_rw(DHparams, DH) 577DECLARE_PEM_rw(DHparams, DH)
575 578
@@ -614,6 +617,7 @@ int PEM_write_PKCS8PrivateKey(FILE *fp,EVP_PKEY *x,const EVP_CIPHER *enc,
614/* The following lines are auto generated by the script mkerr.pl. Any changes 617/* The following lines are auto generated by the script mkerr.pl. Any changes
615 * made after this point may be overwritten when the script is next run. 618 * made after this point may be overwritten when the script is next run.
616 */ 619 */
620void ERR_load_PEM_strings(void);
617 621
618/* Error codes for the PEM functions. */ 622/* Error codes for the PEM functions. */
619 623
@@ -664,4 +668,3 @@ int PEM_write_PKCS8PrivateKey(FILE *fp,EVP_PKEY *x,const EVP_CIPHER *enc,
664} 668}
665#endif 669#endif
666#endif 670#endif
667
diff --git a/src/lib/libcrypto/pem/pem_all.c b/src/lib/libcrypto/pem/pem_all.c
index dc9c35b4b4..e72b7134ce 100644
--- a/src/lib/libcrypto/pem/pem_all.c
+++ b/src/lib/libcrypto/pem/pem_all.c
@@ -65,17 +65,13 @@
65#include <openssl/pkcs7.h> 65#include <openssl/pkcs7.h>
66#include <openssl/pem.h> 66#include <openssl/pem.h>
67 67
68#ifndef NO_RSA 68#ifndef OPENSSL_NO_RSA
69static RSA *pkey_get_rsa(EVP_PKEY *key, RSA **rsa); 69static RSA *pkey_get_rsa(EVP_PKEY *key, RSA **rsa);
70#endif 70#endif
71#ifndef NO_DSA 71#ifndef OPENSSL_NO_DSA
72static DSA *pkey_get_dsa(EVP_PKEY *key, DSA **dsa); 72static DSA *pkey_get_dsa(EVP_PKEY *key, DSA **dsa);
73#endif 73#endif
74 74
75IMPLEMENT_PEM_rw(X509, X509, PEM_STRING_X509, X509)
76
77IMPLEMENT_PEM_rw(X509_AUX, X509, PEM_STRING_X509_TRUSTED, X509_AUX)
78
79IMPLEMENT_PEM_rw(X509_REQ, X509_REQ, PEM_STRING_X509_REQ, X509_REQ) 75IMPLEMENT_PEM_rw(X509_REQ, X509_REQ, PEM_STRING_X509_REQ, X509_REQ)
80 76
81IMPLEMENT_PEM_write(X509_REQ_NEW, X509_REQ, PEM_STRING_X509_REQ_OLD, X509_REQ) 77IMPLEMENT_PEM_write(X509_REQ_NEW, X509_REQ, PEM_STRING_X509_REQ_OLD, X509_REQ)
@@ -87,11 +83,8 @@ IMPLEMENT_PEM_rw(PKCS7, PKCS7, PEM_STRING_PKCS7, PKCS7)
87IMPLEMENT_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE, 83IMPLEMENT_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE,
88 PEM_STRING_X509, NETSCAPE_CERT_SEQUENCE) 84 PEM_STRING_X509, NETSCAPE_CERT_SEQUENCE)
89 85
90IMPLEMENT_PEM_rw(PKCS8, X509_SIG, PEM_STRING_PKCS8, X509_SIG)
91IMPLEMENT_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO, PEM_STRING_PKCS8INF,
92 PKCS8_PRIV_KEY_INFO)
93 86
94#ifndef NO_RSA 87#ifndef OPENSSL_NO_RSA
95 88
96/* We treat RSA or DSA private keys as a special case. 89/* We treat RSA or DSA private keys as a special case.
97 * 90 *
@@ -123,7 +116,7 @@ RSA *PEM_read_bio_RSAPrivateKey(BIO *bp, RSA **rsa, pem_password_cb *cb,
123 return pkey_get_rsa(pktmp, rsa); 116 return pkey_get_rsa(pktmp, rsa);
124} 117}
125 118
126#ifndef NO_FP_API 119#ifndef OPENSSL_NO_FP_API
127 120
128RSA *PEM_read_RSAPrivateKey(FILE *fp, RSA **rsa, pem_password_cb *cb, 121RSA *PEM_read_RSAPrivateKey(FILE *fp, RSA **rsa, pem_password_cb *cb,
129 void *u) 122 void *u)
@@ -141,7 +134,7 @@ IMPLEMENT_PEM_rw(RSA_PUBKEY, RSA, PEM_STRING_PUBLIC, RSA_PUBKEY)
141 134
142#endif 135#endif
143 136
144#ifndef NO_DSA 137#ifndef OPENSSL_NO_DSA
145 138
146static DSA *pkey_get_dsa(EVP_PKEY *key, DSA **dsa) 139static DSA *pkey_get_dsa(EVP_PKEY *key, DSA **dsa)
147{ 140{
@@ -168,7 +161,7 @@ DSA *PEM_read_bio_DSAPrivateKey(BIO *bp, DSA **dsa, pem_password_cb *cb,
168IMPLEMENT_PEM_write_cb(DSAPrivateKey, DSA, PEM_STRING_DSA, DSAPrivateKey) 161IMPLEMENT_PEM_write_cb(DSAPrivateKey, DSA, PEM_STRING_DSA, DSAPrivateKey)
169IMPLEMENT_PEM_rw(DSA_PUBKEY, DSA, PEM_STRING_PUBLIC, DSA_PUBKEY) 162IMPLEMENT_PEM_rw(DSA_PUBKEY, DSA, PEM_STRING_PUBLIC, DSA_PUBKEY)
170 163
171#ifndef NO_FP_API 164#ifndef OPENSSL_NO_FP_API
172 165
173DSA *PEM_read_DSAPrivateKey(FILE *fp, DSA **dsa, pem_password_cb *cb, 166DSA *PEM_read_DSAPrivateKey(FILE *fp, DSA **dsa, pem_password_cb *cb,
174 void *u) 167 void *u)
@@ -184,7 +177,7 @@ IMPLEMENT_PEM_rw(DSAparams, DSA, PEM_STRING_DSAPARAMS, DSAparams)
184 177
185#endif 178#endif
186 179
187#ifndef NO_DH 180#ifndef OPENSSL_NO_DH
188 181
189IMPLEMENT_PEM_rw(DHparams, DH, PEM_STRING_DHPARAMS, DHparams) 182IMPLEMENT_PEM_rw(DHparams, DH, PEM_STRING_DHPARAMS, DHparams)
190 183
@@ -197,7 +190,7 @@ IMPLEMENT_PEM_rw(DHparams, DH, PEM_STRING_DHPARAMS, DHparams)
197 * (When reading, parameter PEM_STRING_EVP_PKEY is a wildcard for anything 190 * (When reading, parameter PEM_STRING_EVP_PKEY is a wildcard for anything
198 * appropriate.) 191 * appropriate.)
199 */ 192 */
200IMPLEMENT_PEM_read(PrivateKey, EVP_PKEY, PEM_STRING_EVP_PKEY, PrivateKey)
201IMPLEMENT_PEM_write_cb(PrivateKey, EVP_PKEY, ((x->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA), PrivateKey) 193IMPLEMENT_PEM_write_cb(PrivateKey, EVP_PKEY, ((x->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA), PrivateKey)
202 194
203IMPLEMENT_PEM_rw(PUBKEY, EVP_PKEY, PEM_STRING_PUBLIC, PUBKEY) 195IMPLEMENT_PEM_rw(PUBKEY, EVP_PKEY, PEM_STRING_PUBLIC, PUBKEY)
196
diff --git a/src/lib/libcrypto/pem/pem_err.c b/src/lib/libcrypto/pem/pem_err.c
index 8b1789b11c..3b39b84d66 100644
--- a/src/lib/libcrypto/pem/pem_err.c
+++ b/src/lib/libcrypto/pem/pem_err.c
@@ -63,7 +63,7 @@
63#include <openssl/pem.h> 63#include <openssl/pem.h>
64 64
65/* BEGIN ERROR CODES */ 65/* BEGIN ERROR CODES */
66#ifndef NO_ERR 66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA PEM_str_functs[]= 67static ERR_STRING_DATA PEM_str_functs[]=
68 { 68 {
69{ERR_PACK(0,PEM_F_D2I_PKCS8PRIVATEKEY_BIO,0), "d2i_PKCS8PrivateKey_bio"}, 69{ERR_PACK(0,PEM_F_D2I_PKCS8PRIVATEKEY_BIO,0), "d2i_PKCS8PrivateKey_bio"},
@@ -122,7 +122,7 @@ void ERR_load_PEM_strings(void)
122 if (init) 122 if (init)
123 { 123 {
124 init=0; 124 init=0;
125#ifndef NO_ERR 125#ifndef OPENSSL_NO_ERR
126 ERR_load_strings(ERR_LIB_PEM,PEM_str_functs); 126 ERR_load_strings(ERR_LIB_PEM,PEM_str_functs);
127 ERR_load_strings(ERR_LIB_PEM,PEM_str_reasons); 127 ERR_load_strings(ERR_LIB_PEM,PEM_str_reasons);
128#endif 128#endif
diff --git a/src/lib/libcrypto/pem/pem_info.c b/src/lib/libcrypto/pem/pem_info.c
index f1694f1125..9a6dffb45c 100644
--- a/src/lib/libcrypto/pem/pem_info.c
+++ b/src/lib/libcrypto/pem/pem_info.c
@@ -64,7 +64,7 @@
64#include <openssl/x509.h> 64#include <openssl/x509.h>
65#include <openssl/pem.h> 65#include <openssl/pem.h>
66 66
67#ifndef NO_FP_API 67#ifndef OPENSSL_NO_FP_API
68STACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u) 68STACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u)
69 { 69 {
70 BIO *b; 70 BIO *b;
@@ -111,7 +111,7 @@ STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pe
111 i=PEM_read_bio(bp,&name,&header,&data,&len); 111 i=PEM_read_bio(bp,&name,&header,&data,&len);
112 if (i == 0) 112 if (i == 0)
113 { 113 {
114 error=ERR_GET_REASON(ERR_peek_error()); 114 error=ERR_GET_REASON(ERR_peek_last_error());
115 if (error == PEM_R_NO_START_LINE) 115 if (error == PEM_R_NO_START_LINE)
116 { 116 {
117 ERR_clear_error(); 117 ERR_clear_error();
@@ -155,7 +155,7 @@ start:
155 pp=(char **)&(xi->crl); 155 pp=(char **)&(xi->crl);
156 } 156 }
157 else 157 else
158#ifndef NO_RSA 158#ifndef OPENSSL_NO_RSA
159 if (strcmp(name,PEM_STRING_RSA) == 0) 159 if (strcmp(name,PEM_STRING_RSA) == 0)
160 { 160 {
161 d2i=(char *(*)())d2i_RSAPrivateKey; 161 d2i=(char *(*)())d2i_RSAPrivateKey;
@@ -179,7 +179,7 @@ start:
179 } 179 }
180 else 180 else
181#endif 181#endif
182#ifndef NO_DSA 182#ifndef OPENSSL_NO_DSA
183 if (strcmp(name,PEM_STRING_DSA) == 0) 183 if (strcmp(name,PEM_STRING_DSA) == 0)
184 { 184 {
185 d2i=(char *(*)())d2i_DSAPrivateKey; 185 d2i=(char *(*)())d2i_DSAPrivateKey;
@@ -326,7 +326,7 @@ int PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc,
326 /* create the right magic header stuff */ 326 /* create the right magic header stuff */
327 buf[0]='\0'; 327 buf[0]='\0';
328 PEM_proc_type(buf,PEM_TYPE_ENCRYPTED); 328 PEM_proc_type(buf,PEM_TYPE_ENCRYPTED);
329 PEM_dek_info(buf,objstr,8,(char *)iv); 329 PEM_dek_info(buf,objstr,enc->iv_len,(char *)iv);
330 330
331 /* use the normal code to write things out */ 331 /* use the normal code to write things out */
332 i=PEM_write_bio(bp,PEM_STRING_RSA,buf,data,i); 332 i=PEM_write_bio(bp,PEM_STRING_RSA,buf,data,i);
@@ -335,7 +335,7 @@ int PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc,
335 else 335 else
336 { 336 {
337 /* Add DSA/DH */ 337 /* Add DSA/DH */
338#ifndef NO_RSA 338#ifndef OPENSSL_NO_RSA
339 /* normal optionally encrypted stuff */ 339 /* normal optionally encrypted stuff */
340 if (PEM_write_bio_RSAPrivateKey(bp, 340 if (PEM_write_bio_RSAPrivateKey(bp,
341 xi->x_pkey->dec_pkey->pkey.rsa, 341 xi->x_pkey->dec_pkey->pkey.rsa,
@@ -346,7 +346,7 @@ int PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc,
346 } 346 }
347 347
348 /* if we have a certificate then write it out now */ 348 /* if we have a certificate then write it out now */
349 if ((xi->x509 != NULL) || (PEM_write_bio_X509(bp,xi->x509) <= 0)) 349 if ((xi->x509 != NULL) && (PEM_write_bio_X509(bp,xi->x509) <= 0))
350 goto err; 350 goto err;
351 351
352 /* we are ignoring anything else that is loaded into the X509_INFO 352 /* we are ignoring anything else that is loaded into the X509_INFO
diff --git a/src/lib/libcrypto/pem/pem_lib.c b/src/lib/libcrypto/pem/pem_lib.c
index a17c3ed57f..18b751a91a 100644
--- a/src/lib/libcrypto/pem/pem_lib.c
+++ b/src/lib/libcrypto/pem/pem_lib.c
@@ -65,7 +65,7 @@
65#include <openssl/x509.h> 65#include <openssl/x509.h>
66#include <openssl/pem.h> 66#include <openssl/pem.h>
67#include <openssl/pkcs12.h> 67#include <openssl/pkcs12.h>
68#ifndef NO_DES 68#ifndef OPENSSL_NO_DES
69#include <openssl/des.h> 69#include <openssl/des.h>
70#endif 70#endif
71 71
@@ -73,21 +73,12 @@ const char *PEM_version="PEM" OPENSSL_VERSION_PTEXT;
73 73
74#define MIN_LENGTH 4 74#define MIN_LENGTH 4
75 75
76static int def_callback(char *buf, int num, int w, void *userdata);
77static int load_iv(unsigned char **fromp,unsigned char *to, int num); 76static int load_iv(unsigned char **fromp,unsigned char *to, int num);
78static int check_pem(const char *nm, const char *name); 77static int check_pem(const char *nm, const char *name);
79static int do_pk8pkey(BIO *bp, EVP_PKEY *x, int isder, 78
80 int nid, const EVP_CIPHER *enc, 79int PEM_def_callback(char *buf, int num, int w, void *key)
81 char *kstr, int klen,
82 pem_password_cb *cb, void *u);
83static int do_pk8pkey_fp(FILE *bp, EVP_PKEY *x, int isder,
84 int nid, const EVP_CIPHER *enc,
85 char *kstr, int klen,
86 pem_password_cb *cb, void *u);
87
88static int def_callback(char *buf, int num, int w, void *key)
89 { 80 {
90#ifdef NO_FP_API 81#ifdef OPENSSL_NO_FP_API
91 /* We should not ever call the default callback routine from 82 /* We should not ever call the default callback routine from
92 * windows. */ 83 * windows. */
93 PEMerr(PEM_F_DEF_CALLBACK,ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); 84 PEMerr(PEM_F_DEF_CALLBACK,ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
@@ -164,7 +155,7 @@ void PEM_dek_info(char *buf, const char *type, int len, char *str)
164 buf[j+i*2+1]='\0'; 155 buf[j+i*2+1]='\0';
165 } 156 }
166 157
167#ifndef NO_FP_API 158#ifndef OPENSSL_NO_FP_API
168char *PEM_ASN1_read(char *(*d2i)(), const char *name, FILE *fp, char **x, 159char *PEM_ASN1_read(char *(*d2i)(), const char *name, FILE *fp, char **x,
169 pem_password_cb *cb, void *u) 160 pem_password_cb *cb, void *u)
170 { 161 {
@@ -224,14 +215,14 @@ static int check_pem(const char *nm, const char *name)
224 return 0; 215 return 0;
225} 216}
226 217
227char *PEM_ASN1_read_bio(char *(*d2i)(), const char *name, BIO *bp, char **x, 218int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm, const char *name, BIO *bp,
228 pem_password_cb *cb, void *u) 219 pem_password_cb *cb, void *u)
229 { 220 {
230 EVP_CIPHER_INFO cipher; 221 EVP_CIPHER_INFO cipher;
231 char *nm=NULL,*header=NULL; 222 char *nm=NULL,*header=NULL;
232 unsigned char *p=NULL,*data=NULL; 223 unsigned char *data=NULL;
233 long len; 224 long len;
234 char *ret=NULL; 225 int ret = 0;
235 226
236 for (;;) 227 for (;;)
237 { 228 {
@@ -239,7 +230,7 @@ char *PEM_ASN1_read_bio(char *(*d2i)(), const char *name, BIO *bp, char **x,
239 if(ERR_GET_REASON(ERR_peek_error()) == 230 if(ERR_GET_REASON(ERR_peek_error()) ==
240 PEM_R_NO_START_LINE) 231 PEM_R_NO_START_LINE)
241 ERR_add_error_data(2, "Expecting: ", name); 232 ERR_add_error_data(2, "Expecting: ", name);
242 return(NULL); 233 return 0;
243 } 234 }
244 if(check_pem(nm, name)) break; 235 if(check_pem(nm, name)) break;
245 OPENSSL_free(nm); 236 OPENSSL_free(nm);
@@ -248,54 +239,23 @@ char *PEM_ASN1_read_bio(char *(*d2i)(), const char *name, BIO *bp, char **x,
248 } 239 }
249 if (!PEM_get_EVP_CIPHER_INFO(header,&cipher)) goto err; 240 if (!PEM_get_EVP_CIPHER_INFO(header,&cipher)) goto err;
250 if (!PEM_do_header(&cipher,data,&len,cb,u)) goto err; 241 if (!PEM_do_header(&cipher,data,&len,cb,u)) goto err;
251 p=data; 242
252 if (strcmp(name,PEM_STRING_EVP_PKEY) == 0) { 243 *pdata = data;
253 if (strcmp(nm,PEM_STRING_RSA) == 0) 244 *plen = len;
254 ret=d2i(EVP_PKEY_RSA,x,&p,len); 245
255 else if (strcmp(nm,PEM_STRING_DSA) == 0) 246 if (pnm)
256 ret=d2i(EVP_PKEY_DSA,x,&p,len); 247 *pnm = nm;
257 else if (strcmp(nm,PEM_STRING_PKCS8INF) == 0) { 248
258 PKCS8_PRIV_KEY_INFO *p8inf; 249 ret = 1;
259 p8inf=d2i_PKCS8_PRIV_KEY_INFO( 250
260 (PKCS8_PRIV_KEY_INFO **) x, &p, len);
261 ret = (char *)EVP_PKCS82PKEY(p8inf);
262 PKCS8_PRIV_KEY_INFO_free(p8inf);
263 } else if (strcmp(nm,PEM_STRING_PKCS8) == 0) {
264 PKCS8_PRIV_KEY_INFO *p8inf;
265 X509_SIG *p8;
266 int klen;
267 char psbuf[PEM_BUFSIZE];
268 p8 = d2i_X509_SIG(NULL, &p, len);
269 if(!p8) goto p8err;
270 if (cb) klen=cb(psbuf,PEM_BUFSIZE,0,u);
271 else klen=def_callback(psbuf,PEM_BUFSIZE,0,u);
272 if (klen <= 0) {
273 PEMerr(PEM_F_PEM_ASN1_READ_BIO,
274 PEM_R_BAD_PASSWORD_READ);
275 goto err;
276 }
277 p8inf = M_PKCS8_decrypt(p8, psbuf, klen);
278 X509_SIG_free(p8);
279 if(!p8inf) goto p8err;
280 ret = (char *)EVP_PKCS82PKEY(p8inf);
281 if(x) {
282 if(*x) EVP_PKEY_free((EVP_PKEY *)*x);
283 *x = ret;
284 }
285 PKCS8_PRIV_KEY_INFO_free(p8inf);
286 }
287 } else ret=d2i(x,&p,len);
288p8err:
289 if (ret == NULL)
290 PEMerr(PEM_F_PEM_ASN1_READ_BIO,ERR_R_ASN1_LIB);
291err: 251err:
292 OPENSSL_free(nm); 252 if (!pnm) OPENSSL_free(nm);
293 OPENSSL_free(header); 253 OPENSSL_free(header);
294 OPENSSL_free(data); 254 if (!ret) OPENSSL_free(data);
295 return(ret); 255 return ret;
296 } 256 }
297 257
298#ifndef NO_FP_API 258#ifndef OPENSSL_NO_FP_API
299int PEM_ASN1_write(int (*i2d)(), const char *name, FILE *fp, char *x, 259int PEM_ASN1_write(int (*i2d)(), const char *name, FILE *fp, char *x,
300 const EVP_CIPHER *enc, unsigned char *kstr, int klen, 260 const EVP_CIPHER *enc, unsigned char *kstr, int klen,
301 pem_password_cb *callback, void *u) 261 pem_password_cb *callback, void *u)
@@ -358,7 +318,7 @@ int PEM_ASN1_write_bio(int (*i2d)(), const char *name, BIO *bp, char *x,
358 if (kstr == NULL) 318 if (kstr == NULL)
359 { 319 {
360 if (callback == NULL) 320 if (callback == NULL)
361 klen=def_callback(buf,PEM_BUFSIZE,1,u); 321 klen=PEM_def_callback(buf,PEM_BUFSIZE,1,u);
362 else 322 else
363 klen=(*callback)(buf,PEM_BUFSIZE,1,u); 323 klen=(*callback)(buf,PEM_BUFSIZE,1,u);
364 if (klen <= 0) 324 if (klen <= 0)
@@ -373,7 +333,7 @@ int PEM_ASN1_write_bio(int (*i2d)(), const char *name, BIO *bp, char *x,
373 kstr=(unsigned char *)buf; 333 kstr=(unsigned char *)buf;
374 } 334 }
375 RAND_add(data,i,0);/* put in the RSA key. */ 335 RAND_add(data,i,0);/* put in the RSA key. */
376 if (RAND_pseudo_bytes(iv,8) < 0) /* Generate a salt */ 336 if (RAND_pseudo_bytes(iv,enc->iv_len) < 0) /* Generate a salt */
377 goto err; 337 goto err;
378 /* The 'iv' is used as the iv and as a salt. It is 338 /* The 'iv' is used as the iv and as a salt. It is
379 * NOT taken from the BytesToKey function */ 339 * NOT taken from the BytesToKey function */
@@ -383,12 +343,14 @@ int PEM_ASN1_write_bio(int (*i2d)(), const char *name, BIO *bp, char *x,
383 343
384 buf[0]='\0'; 344 buf[0]='\0';
385 PEM_proc_type(buf,PEM_TYPE_ENCRYPTED); 345 PEM_proc_type(buf,PEM_TYPE_ENCRYPTED);
386 PEM_dek_info(buf,objstr,8,(char *)iv); 346 PEM_dek_info(buf,objstr,enc->iv_len,(char *)iv);
387 /* k=strlen(buf); */ 347 /* k=strlen(buf); */
388 348
389 EVP_EncryptInit(&ctx,enc,key,iv); 349 EVP_CIPHER_CTX_init(&ctx);
350 EVP_EncryptInit_ex(&ctx,enc,NULL,key,iv);
390 EVP_EncryptUpdate(&ctx,data,&j,data,i); 351 EVP_EncryptUpdate(&ctx,data,&j,data,i);
391 EVP_EncryptFinal(&ctx,&(data[j]),&i); 352 EVP_EncryptFinal_ex(&ctx,&(data[j]),&i);
353 EVP_CIPHER_CTX_cleanup(&ctx);
392 i+=j; 354 i+=j;
393 ret=1; 355 ret=1;
394 } 356 }
@@ -422,7 +384,7 @@ int PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *plen,
422 384
423 if (cipher->cipher == NULL) return(1); 385 if (cipher->cipher == NULL) return(1);
424 if (callback == NULL) 386 if (callback == NULL)
425 klen=def_callback(buf,PEM_BUFSIZE,0,u); 387 klen=PEM_def_callback(buf,PEM_BUFSIZE,0,u);
426 else 388 else
427 klen=callback(buf,PEM_BUFSIZE,0,u); 389 klen=callback(buf,PEM_BUFSIZE,0,u);
428 if (klen <= 0) 390 if (klen <= 0)
@@ -439,9 +401,10 @@ int PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *plen,
439 (unsigned char *)buf,klen,1,key,NULL); 401 (unsigned char *)buf,klen,1,key,NULL);
440 402
441 j=(int)len; 403 j=(int)len;
442 EVP_DecryptInit(&ctx,cipher->cipher,key,&(cipher->iv[0])); 404 EVP_CIPHER_CTX_init(&ctx);
405 EVP_DecryptInit_ex(&ctx,cipher->cipher,NULL, key,&(cipher->iv[0]));
443 EVP_DecryptUpdate(&ctx,data,&i,data,j); 406 EVP_DecryptUpdate(&ctx,data,&i,data,j);
444 o=EVP_DecryptFinal(&ctx,&(data[i]),&j); 407 o=EVP_DecryptFinal_ex(&ctx,&(data[i]),&j);
445 EVP_CIPHER_CTX_cleanup(&ctx); 408 EVP_CIPHER_CTX_cleanup(&ctx);
446 memset((char *)buf,0,sizeof(buf)); 409 memset((char *)buf,0,sizeof(buf));
447 memset((char *)key,0,sizeof(key)); 410 memset((char *)key,0,sizeof(key));
@@ -506,7 +469,7 @@ int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher)
506 PEMerr(PEM_F_PEM_GET_EVP_CIPHER_INFO,PEM_R_UNSUPPORTED_ENCRYPTION); 469 PEMerr(PEM_F_PEM_GET_EVP_CIPHER_INFO,PEM_R_UNSUPPORTED_ENCRYPTION);
507 return(0); 470 return(0);
508 } 471 }
509 if (!load_iv((unsigned char **)&header,&(cipher->iv[0]),8)) return(0); 472 if (!load_iv((unsigned char **)&header,&(cipher->iv[0]),enc->iv_len)) return(0);
510 473
511 return(1); 474 return(1);
512 } 475 }
@@ -540,7 +503,7 @@ static int load_iv(unsigned char **fromp, unsigned char *to, int num)
540 return(1); 503 return(1);
541 } 504 }
542 505
543#ifndef NO_FP_API 506#ifndef OPENSSL_NO_FP_API
544int PEM_write(FILE *fp, char *name, char *header, unsigned char *data, 507int PEM_write(FILE *fp, char *name, char *header, unsigned char *data,
545 long len) 508 long len)
546 { 509 {
@@ -614,7 +577,7 @@ err:
614 return(0); 577 return(0);
615 } 578 }
616 579
617#ifndef NO_FP_API 580#ifndef OPENSSL_NO_FP_API
618int PEM_read(FILE *fp, char **name, char **header, unsigned char **data, 581int PEM_read(FILE *fp, char **name, char **header, unsigned char **data,
619 long *len) 582 long *len)
620 { 583 {
@@ -794,170 +757,3 @@ err:
794 BUF_MEM_free(dataB); 757 BUF_MEM_free(dataB);
795 return(0); 758 return(0);
796 } 759 }
797
798/* These functions write a private key in PKCS#8 format: it is a "drop in"
799 * replacement for PEM_write_bio_PrivateKey() and friends. As usual if 'enc'
800 * is NULL then it uses the unencrypted private key form. The 'nid' versions
801 * uses PKCS#5 v1.5 PBE algorithms whereas the others use PKCS#5 v2.0.
802 */
803
804int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid,
805 char *kstr, int klen,
806 pem_password_cb *cb, void *u)
807{
808 return do_pk8pkey(bp, x, 0, nid, NULL, kstr, klen, cb, u);
809}
810
811int PEM_write_bio_PKCS8PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
812 char *kstr, int klen,
813 pem_password_cb *cb, void *u)
814{
815 return do_pk8pkey(bp, x, 0, -1, enc, kstr, klen, cb, u);
816}
817
818int i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
819 char *kstr, int klen,
820 pem_password_cb *cb, void *u)
821{
822 return do_pk8pkey(bp, x, 1, -1, enc, kstr, klen, cb, u);
823}
824
825int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid,
826 char *kstr, int klen,
827 pem_password_cb *cb, void *u)
828{
829 return do_pk8pkey(bp, x, 1, nid, NULL, kstr, klen, cb, u);
830}
831
832static int do_pk8pkey(BIO *bp, EVP_PKEY *x, int isder, int nid, const EVP_CIPHER *enc,
833 char *kstr, int klen,
834 pem_password_cb *cb, void *u)
835{
836 X509_SIG *p8;
837 PKCS8_PRIV_KEY_INFO *p8inf;
838 char buf[PEM_BUFSIZE];
839 int ret;
840 if(!(p8inf = EVP_PKEY2PKCS8(x))) {
841 PEMerr(PEM_F_PEM_WRITE_BIO_PKCS8PRIVATEKEY,
842 PEM_R_ERROR_CONVERTING_PRIVATE_KEY);
843 return 0;
844 }
845 if(enc || (nid != -1)) {
846 if(!kstr) {
847 if(!cb) klen = def_callback(buf, PEM_BUFSIZE, 1, u);
848 else klen = cb(buf, PEM_BUFSIZE, 1, u);
849 if(klen <= 0) {
850 PEMerr(PEM_F_PEM_WRITE_BIO_PKCS8PRIVATEKEY,
851 PEM_R_READ_KEY);
852 PKCS8_PRIV_KEY_INFO_free(p8inf);
853 return 0;
854 }
855
856 kstr = buf;
857 }
858 p8 = PKCS8_encrypt(nid, enc, kstr, klen, NULL, 0, 0, p8inf);
859 if(kstr == buf) memset(buf, 0, klen);
860 PKCS8_PRIV_KEY_INFO_free(p8inf);
861 if(isder) ret = i2d_PKCS8_bio(bp, p8);
862 else ret = PEM_write_bio_PKCS8(bp, p8);
863 X509_SIG_free(p8);
864 return ret;
865 } else {
866 if(isder) ret = i2d_PKCS8_PRIV_KEY_INFO_bio(bp, p8inf);
867 else ret = PEM_write_bio_PKCS8_PRIV_KEY_INFO(bp, p8inf);
868 PKCS8_PRIV_KEY_INFO_free(p8inf);
869 return ret;
870 }
871}
872
873/* Finally the DER version to read PKCS#8 encrypted private keys. It has to be
874 * here to access the default callback.
875 */
876
877EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u)
878{
879 PKCS8_PRIV_KEY_INFO *p8inf = NULL;
880 X509_SIG *p8 = NULL;
881 int klen;
882 EVP_PKEY *ret;
883 char psbuf[PEM_BUFSIZE];
884 p8 = d2i_PKCS8_bio(bp, NULL);
885 if(!p8) return NULL;
886 if (cb) klen=cb(psbuf,PEM_BUFSIZE,0,u);
887 else klen=def_callback(psbuf,PEM_BUFSIZE,0,u);
888 if (klen <= 0) {
889 PEMerr(PEM_F_D2I_PKCS8PRIVATEKEY_BIO, PEM_R_BAD_PASSWORD_READ);
890 X509_SIG_free(p8);
891 return NULL;
892 }
893 p8inf = M_PKCS8_decrypt(p8, psbuf, klen);
894 X509_SIG_free(p8);
895 if(!p8inf) return NULL;
896 ret = EVP_PKCS82PKEY(p8inf);
897 PKCS8_PRIV_KEY_INFO_free(p8inf);
898 if(!ret) return NULL;
899 if(x) {
900 if(*x) EVP_PKEY_free(*x);
901 *x = ret;
902 }
903 return ret;
904}
905
906#ifndef NO_FP_API
907
908int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
909 char *kstr, int klen,
910 pem_password_cb *cb, void *u)
911{
912 return do_pk8pkey_fp(fp, x, 1, -1, enc, kstr, klen, cb, u);
913}
914
915int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid,
916 char *kstr, int klen,
917 pem_password_cb *cb, void *u)
918{
919 return do_pk8pkey_fp(fp, x, 1, nid, NULL, kstr, klen, cb, u);
920}
921
922int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid,
923 char *kstr, int klen,
924 pem_password_cb *cb, void *u)
925{
926 return do_pk8pkey_fp(fp, x, 0, nid, NULL, kstr, klen, cb, u);
927}
928
929int PEM_write_PKCS8PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
930 char *kstr, int klen, pem_password_cb *cb, void *u)
931{
932 return do_pk8pkey_fp(fp, x, 0, -1, enc, kstr, klen, cb, u);
933}
934
935static int do_pk8pkey_fp(FILE *fp, EVP_PKEY *x, int isder, int nid, const EVP_CIPHER *enc,
936 char *kstr, int klen,
937 pem_password_cb *cb, void *u)
938{
939 BIO *bp;
940 int ret;
941 if(!(bp = BIO_new_fp(fp, BIO_NOCLOSE))) {
942 PEMerr(PEM_F_PEM_F_DO_PK8KEY_FP,ERR_R_BUF_LIB);
943 return(0);
944 }
945 ret = do_pk8pkey(bp, x, isder, nid, enc, kstr, klen, cb, u);
946 BIO_free(bp);
947 return ret;
948}
949
950EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u)
951{
952 BIO *bp;
953 EVP_PKEY *ret;
954 if(!(bp = BIO_new_fp(fp, BIO_NOCLOSE))) {
955 PEMerr(PEM_F_D2I_PKCS8PRIVATEKEY_FP,ERR_R_BUF_LIB);
956 return NULL;
957 }
958 ret = d2i_PKCS8PrivateKey_bio(bp, x, cb, u);
959 BIO_free(bp);
960 return ret;
961}
962
963#endif
diff --git a/src/lib/libcrypto/pem/pem_oth.c b/src/lib/libcrypto/pem/pem_oth.c
new file mode 100644
index 0000000000..8d9064ea7c
--- /dev/null
+++ b/src/lib/libcrypto/pem/pem_oth.c
@@ -0,0 +1,85 @@
1/* crypto/pem/pem_oth.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/objects.h>
63#include <openssl/evp.h>
64#include <openssl/rand.h>
65#include <openssl/x509.h>
66#include <openssl/pem.h>
67
68/* Handle 'other' PEMs: not private keys */
69
70char *PEM_ASN1_read_bio(char *(*d2i)(), const char *name, BIO *bp, char **x,
71 pem_password_cb *cb, void *u)
72 {
73 unsigned char *p=NULL,*data=NULL;
74 long len;
75 char *ret=NULL;
76
77 if (!PEM_bytes_read_bio(&data, &len, NULL, name, bp, cb, u))
78 return NULL;
79 p = data;
80 ret=d2i(x,&p,len);
81 if (ret == NULL)
82 PEMerr(PEM_F_PEM_ASN1_READ_BIO,ERR_R_ASN1_LIB);
83 OPENSSL_free(data);
84 return(ret);
85 }
diff --git a/src/lib/libcrypto/pem/pem_pk8.c b/src/lib/libcrypto/pem/pem_pk8.c
new file mode 100644
index 0000000000..f44182ffb5
--- /dev/null
+++ b/src/lib/libcrypto/pem/pem_pk8.c
@@ -0,0 +1,243 @@
1/* crypto/pem/pem_pkey.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/objects.h>
63#include <openssl/evp.h>
64#include <openssl/rand.h>
65#include <openssl/x509.h>
66#include <openssl/pkcs12.h>
67#include <openssl/pem.h>
68
69static int do_pk8pkey(BIO *bp, EVP_PKEY *x, int isder,
70 int nid, const EVP_CIPHER *enc,
71 char *kstr, int klen,
72 pem_password_cb *cb, void *u);
73static int do_pk8pkey_fp(FILE *bp, EVP_PKEY *x, int isder,
74 int nid, const EVP_CIPHER *enc,
75 char *kstr, int klen,
76 pem_password_cb *cb, void *u);
77
78/* These functions write a private key in PKCS#8 format: it is a "drop in"
79 * replacement for PEM_write_bio_PrivateKey() and friends. As usual if 'enc'
80 * is NULL then it uses the unencrypted private key form. The 'nid' versions
81 * uses PKCS#5 v1.5 PBE algorithms whereas the others use PKCS#5 v2.0.
82 */
83
84int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid,
85 char *kstr, int klen,
86 pem_password_cb *cb, void *u)
87{
88 return do_pk8pkey(bp, x, 0, nid, NULL, kstr, klen, cb, u);
89}
90
91int PEM_write_bio_PKCS8PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
92 char *kstr, int klen,
93 pem_password_cb *cb, void *u)
94{
95 return do_pk8pkey(bp, x, 0, -1, enc, kstr, klen, cb, u);
96}
97
98int i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
99 char *kstr, int klen,
100 pem_password_cb *cb, void *u)
101{
102 return do_pk8pkey(bp, x, 1, -1, enc, kstr, klen, cb, u);
103}
104
105int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid,
106 char *kstr, int klen,
107 pem_password_cb *cb, void *u)
108{
109 return do_pk8pkey(bp, x, 1, nid, NULL, kstr, klen, cb, u);
110}
111
112static int do_pk8pkey(BIO *bp, EVP_PKEY *x, int isder, int nid, const EVP_CIPHER *enc,
113 char *kstr, int klen,
114 pem_password_cb *cb, void *u)
115{
116 X509_SIG *p8;
117 PKCS8_PRIV_KEY_INFO *p8inf;
118 char buf[PEM_BUFSIZE];
119 int ret;
120 if(!(p8inf = EVP_PKEY2PKCS8(x))) {
121 PEMerr(PEM_F_PEM_WRITE_BIO_PKCS8PRIVATEKEY,
122 PEM_R_ERROR_CONVERTING_PRIVATE_KEY);
123 return 0;
124 }
125 if(enc || (nid != -1)) {
126 if(!kstr) {
127 if(!cb) klen = PEM_def_callback(buf, PEM_BUFSIZE, 1, u);
128 else klen = cb(buf, PEM_BUFSIZE, 1, u);
129 if(klen <= 0) {
130 PEMerr(PEM_F_PEM_WRITE_BIO_PKCS8PRIVATEKEY,
131 PEM_R_READ_KEY);
132 PKCS8_PRIV_KEY_INFO_free(p8inf);
133 return 0;
134 }
135
136 kstr = buf;
137 }
138 p8 = PKCS8_encrypt(nid, enc, kstr, klen, NULL, 0, 0, p8inf);
139 if(kstr == buf) memset(buf, 0, klen);
140 PKCS8_PRIV_KEY_INFO_free(p8inf);
141 if(isder) ret = i2d_PKCS8_bio(bp, p8);
142 else ret = PEM_write_bio_PKCS8(bp, p8);
143 X509_SIG_free(p8);
144 return ret;
145 } else {
146 if(isder) ret = i2d_PKCS8_PRIV_KEY_INFO_bio(bp, p8inf);
147 else ret = PEM_write_bio_PKCS8_PRIV_KEY_INFO(bp, p8inf);
148 PKCS8_PRIV_KEY_INFO_free(p8inf);
149 return ret;
150 }
151}
152
153EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u)
154{
155 PKCS8_PRIV_KEY_INFO *p8inf = NULL;
156 X509_SIG *p8 = NULL;
157 int klen;
158 EVP_PKEY *ret;
159 char psbuf[PEM_BUFSIZE];
160 p8 = d2i_PKCS8_bio(bp, NULL);
161 if(!p8) return NULL;
162 if (cb) klen=cb(psbuf,PEM_BUFSIZE,0,u);
163 else klen=PEM_def_callback(psbuf,PEM_BUFSIZE,0,u);
164 if (klen <= 0) {
165 PEMerr(PEM_F_D2I_PKCS8PRIVATEKEY_BIO, PEM_R_BAD_PASSWORD_READ);
166 X509_SIG_free(p8);
167 return NULL;
168 }
169 p8inf = PKCS8_decrypt(p8, psbuf, klen);
170 X509_SIG_free(p8);
171 if(!p8inf) return NULL;
172 ret = EVP_PKCS82PKEY(p8inf);
173 PKCS8_PRIV_KEY_INFO_free(p8inf);
174 if(!ret) return NULL;
175 if(x) {
176 if(*x) EVP_PKEY_free(*x);
177 *x = ret;
178 }
179 return ret;
180}
181
182#ifndef OPENSSL_NO_FP_API
183
184int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
185 char *kstr, int klen,
186 pem_password_cb *cb, void *u)
187{
188 return do_pk8pkey_fp(fp, x, 1, -1, enc, kstr, klen, cb, u);
189}
190
191int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid,
192 char *kstr, int klen,
193 pem_password_cb *cb, void *u)
194{
195 return do_pk8pkey_fp(fp, x, 1, nid, NULL, kstr, klen, cb, u);
196}
197
198int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid,
199 char *kstr, int klen,
200 pem_password_cb *cb, void *u)
201{
202 return do_pk8pkey_fp(fp, x, 0, nid, NULL, kstr, klen, cb, u);
203}
204
205int PEM_write_PKCS8PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
206 char *kstr, int klen, pem_password_cb *cb, void *u)
207{
208 return do_pk8pkey_fp(fp, x, 0, -1, enc, kstr, klen, cb, u);
209}
210
211static int do_pk8pkey_fp(FILE *fp, EVP_PKEY *x, int isder, int nid, const EVP_CIPHER *enc,
212 char *kstr, int klen,
213 pem_password_cb *cb, void *u)
214{
215 BIO *bp;
216 int ret;
217 if(!(bp = BIO_new_fp(fp, BIO_NOCLOSE))) {
218 PEMerr(PEM_F_PEM_F_DO_PK8KEY_FP,ERR_R_BUF_LIB);
219 return(0);
220 }
221 ret = do_pk8pkey(bp, x, isder, nid, enc, kstr, klen, cb, u);
222 BIO_free(bp);
223 return ret;
224}
225
226EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u)
227{
228 BIO *bp;
229 EVP_PKEY *ret;
230 if(!(bp = BIO_new_fp(fp, BIO_NOCLOSE))) {
231 PEMerr(PEM_F_D2I_PKCS8PRIVATEKEY_FP,ERR_R_BUF_LIB);
232 return NULL;
233 }
234 ret = d2i_PKCS8PrivateKey_bio(bp, x, cb, u);
235 BIO_free(bp);
236 return ret;
237}
238
239#endif
240
241IMPLEMENT_PEM_rw(PKCS8, X509_SIG, PEM_STRING_PKCS8, X509_SIG)
242IMPLEMENT_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO, PEM_STRING_PKCS8INF,
243 PKCS8_PRIV_KEY_INFO)
diff --git a/src/lib/libcrypto/pem/pem_pkey.c b/src/lib/libcrypto/pem/pem_pkey.c
new file mode 100644
index 0000000000..270892d72b
--- /dev/null
+++ b/src/lib/libcrypto/pem/pem_pkey.c
@@ -0,0 +1,139 @@
1/* crypto/pem/pem_pkey.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/objects.h>
63#include <openssl/evp.h>
64#include <openssl/rand.h>
65#include <openssl/x509.h>
66#include <openssl/pkcs12.h>
67#include <openssl/pem.h>
68
69
70EVP_PKEY *PEM_read_bio_PrivateKey(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u)
71 {
72 char *nm=NULL;
73 unsigned char *p=NULL,*data=NULL;
74 long len;
75 EVP_PKEY *ret=NULL;
76
77 if (!PEM_bytes_read_bio(&data, &len, &nm, PEM_STRING_EVP_PKEY, bp, cb, u))
78 return NULL;
79 p = data;
80
81 if (strcmp(nm,PEM_STRING_RSA) == 0)
82 ret=d2i_PrivateKey(EVP_PKEY_RSA,x,&p,len);
83 else if (strcmp(nm,PEM_STRING_DSA) == 0)
84 ret=d2i_PrivateKey(EVP_PKEY_DSA,x,&p,len);
85 else if (strcmp(nm,PEM_STRING_PKCS8INF) == 0) {
86 PKCS8_PRIV_KEY_INFO *p8inf;
87 p8inf=d2i_PKCS8_PRIV_KEY_INFO(NULL, &p, len);
88 ret = EVP_PKCS82PKEY(p8inf);
89 PKCS8_PRIV_KEY_INFO_free(p8inf);
90 } else if (strcmp(nm,PEM_STRING_PKCS8) == 0) {
91 PKCS8_PRIV_KEY_INFO *p8inf;
92 X509_SIG *p8;
93 int klen;
94 char psbuf[PEM_BUFSIZE];
95 p8 = d2i_X509_SIG(NULL, &p, len);
96 if(!p8) goto p8err;
97 if (cb) klen=cb(psbuf,PEM_BUFSIZE,0,u);
98 else klen=PEM_def_callback(psbuf,PEM_BUFSIZE,0,u);
99 if (klen <= 0) {
100 PEMerr(PEM_F_PEM_ASN1_READ_BIO,
101 PEM_R_BAD_PASSWORD_READ);
102 goto err;
103 }
104 p8inf = PKCS8_decrypt(p8, psbuf, klen);
105 X509_SIG_free(p8);
106 if(!p8inf) goto p8err;
107 ret = EVP_PKCS82PKEY(p8inf);
108 if(x) {
109 if(*x) EVP_PKEY_free((EVP_PKEY *)*x);
110 *x = ret;
111 }
112 PKCS8_PRIV_KEY_INFO_free(p8inf);
113 }
114p8err:
115 if (ret == NULL)
116 PEMerr(PEM_F_PEM_ASN1_READ_BIO,ERR_R_ASN1_LIB);
117err:
118 OPENSSL_free(nm);
119 OPENSSL_free(data);
120 return(ret);
121 }
122
123#ifndef OPENSSL_NO_FP_API
124EVP_PKEY *PEM_read_PrivateKey(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u)
125 {
126 BIO *b;
127 EVP_PKEY *ret;
128
129 if ((b=BIO_new(BIO_s_file())) == NULL)
130 {
131 PEMerr(PEM_F_PEM_ASN1_READ,ERR_R_BUF_LIB);
132 return(0);
133 }
134 BIO_set_fp(b,fp,BIO_NOCLOSE);
135 ret=PEM_read_bio_PrivateKey(b,x,cb,u);
136 BIO_free(b);
137 return(ret);
138 }
139#endif
diff --git a/src/lib/libcrypto/pem/pem_seal.c b/src/lib/libcrypto/pem/pem_seal.c
index 2a6c513348..ae463a301d 100644
--- a/src/lib/libcrypto/pem/pem_seal.c
+++ b/src/lib/libcrypto/pem/pem_seal.c
@@ -56,7 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_RSA 59#ifndef OPENSSL_NO_RSA
60#include <stdio.h> 60#include <stdio.h>
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/evp.h> 62#include <openssl/evp.h>
@@ -91,10 +91,13 @@ int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type, EVP_MD *md_type,
91 goto err; 91 goto err;
92 } 92 }
93 93
94 EVP_EncodeInit(&(ctx->encode)); 94 EVP_EncodeInit(&ctx->encode);
95 EVP_SignInit(&(ctx->md),md_type);
96 95
97 ret=EVP_SealInit(&(ctx->cipher),type,ek,ekl,iv,pubk,npubk); 96 EVP_MD_CTX_init(&ctx->md);
97 EVP_SignInit(&ctx->md,md_type);
98
99 EVP_CIPHER_CTX_init(&ctx->cipher);
100 ret=EVP_SealInit(&ctx->cipher,type,ek,ekl,iv,pubk,npubk);
98 if (!ret) goto err; 101 if (!ret) goto err;
99 102
100 /* base64 encode the keys */ 103 /* base64 encode the keys */
@@ -120,7 +123,7 @@ void PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl,
120 int i,j; 123 int i,j;
121 124
122 *outl=0; 125 *outl=0;
123 EVP_SignUpdate(&(ctx->md),in,inl); 126 EVP_SignUpdate(&ctx->md,in,inl);
124 for (;;) 127 for (;;)
125 { 128 {
126 if (inl <= 0) break; 129 if (inl <= 0) break;
@@ -128,8 +131,8 @@ void PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl,
128 i=1200; 131 i=1200;
129 else 132 else
130 i=inl; 133 i=inl;
131 EVP_EncryptUpdate(&(ctx->cipher),buffer,&j,in,i); 134 EVP_EncryptUpdate(&ctx->cipher,buffer,&j,in,i);
132 EVP_EncodeUpdate(&(ctx->encode),out,&j,buffer,j); 135 EVP_EncodeUpdate(&ctx->encode,out,&j,buffer,j);
133 *outl+=j; 136 *outl+=j;
134 out+=j; 137 out+=j;
135 in+=i; 138 in+=i;
@@ -158,24 +161,24 @@ int PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig, int *sigl,
158 goto err; 161 goto err;
159 } 162 }
160 163
161 EVP_EncryptFinal(&(ctx->cipher),s,(int *)&i); 164 EVP_EncryptFinal_ex(&ctx->cipher,s,(int *)&i);
162 EVP_EncodeUpdate(&(ctx->encode),out,&j,s,i); 165 EVP_EncodeUpdate(&ctx->encode,out,&j,s,i);
163 *outl=j; 166 *outl=j;
164 out+=j; 167 out+=j;
165 EVP_EncodeFinal(&(ctx->encode),out,&j); 168 EVP_EncodeFinal(&ctx->encode,out,&j);
166 *outl+=j; 169 *outl+=j;
167 170
168 if (!EVP_SignFinal(&(ctx->md),s,&i,priv)) goto err; 171 if (!EVP_SignFinal(&ctx->md,s,&i,priv)) goto err;
169 *sigl=EVP_EncodeBlock(sig,s,i); 172 *sigl=EVP_EncodeBlock(sig,s,i);
170 173
171 ret=1; 174 ret=1;
172err: 175err:
173 memset((char *)&(ctx->md),0,sizeof(ctx->md)); 176 EVP_MD_CTX_cleanup(&ctx->md);
174 memset((char *)&(ctx->cipher),0,sizeof(ctx->cipher)); 177 EVP_CIPHER_CTX_cleanup(&ctx->cipher);
175 if (s != NULL) OPENSSL_free(s); 178 if (s != NULL) OPENSSL_free(s);
176 return(ret); 179 return(ret);
177 } 180 }
178#else /* !NO_RSA */ 181#else /* !OPENSSL_NO_RSA */
179 182
180# if PEDANTIC 183# if PEDANTIC
181static void *dummy=&dummy; 184static void *dummy=&dummy;
diff --git a/src/lib/libcrypto/pem/pem_sign.c b/src/lib/libcrypto/pem/pem_sign.c
index 42d598dd78..c3b9808cb2 100644
--- a/src/lib/libcrypto/pem/pem_sign.c
+++ b/src/lib/libcrypto/pem/pem_sign.c
@@ -66,7 +66,7 @@
66 66
67void PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type) 67void PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type)
68 { 68 {
69 EVP_DigestInit(ctx,type); 69 EVP_DigestInit_ex(ctx, type, NULL);
70 } 70 }
71 71
72void PEM_SignUpdate(EVP_MD_CTX *ctx, unsigned char *data, 72void PEM_SignUpdate(EVP_MD_CTX *ctx, unsigned char *data,
diff --git a/src/lib/libcrypto/pem/pem_x509.c b/src/lib/libcrypto/pem/pem_x509.c
new file mode 100644
index 0000000000..19f88d8d3a
--- /dev/null
+++ b/src/lib/libcrypto/pem/pem_x509.c
@@ -0,0 +1,69 @@
1/* pem_x509.c */
2/* Written by Dr Stephen N 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 <stdio.h>
60#undef SSLEAY_MACROS
61#include "cryptlib.h"
62#include <openssl/bio.h>
63#include <openssl/evp.h>
64#include <openssl/x509.h>
65#include <openssl/pkcs7.h>
66#include <openssl/pem.h>
67
68IMPLEMENT_PEM_rw(X509, X509, PEM_STRING_X509, X509)
69
diff --git a/src/lib/libcrypto/pem/pem_xaux.c b/src/lib/libcrypto/pem/pem_xaux.c
new file mode 100644
index 0000000000..2f579b5421
--- /dev/null
+++ b/src/lib/libcrypto/pem/pem_xaux.c
@@ -0,0 +1,68 @@
1/* pem_xaux.c */
2/* Written by Dr Stephen N 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 <stdio.h>
60#undef SSLEAY_MACROS
61#include "cryptlib.h"
62#include <openssl/bio.h>
63#include <openssl/evp.h>
64#include <openssl/x509.h>
65#include <openssl/pkcs7.h>
66#include <openssl/pem.h>
67
68IMPLEMENT_PEM_rw(X509_AUX, X509, PEM_STRING_X509_TRUSTED, X509_AUX)
diff --git a/src/lib/libcrypto/perlasm/x86unix.pl b/src/lib/libcrypto/perlasm/x86unix.pl
index 10a7af8bff..9ceabf0705 100644
--- a/src/lib/libcrypto/perlasm/x86unix.pl
+++ b/src/lib/libcrypto/perlasm/x86unix.pl
@@ -3,6 +3,8 @@
3package x86unix; 3package x86unix;
4 4
5$label="L000"; 5$label="L000";
6$const="";
7$constl=0;
6 8
7$align=($main'aout)?"4":"16"; 9$align=($main'aout)?"4":"16";
8$under=($main'aout)?"_":""; 10$under=($main'aout)?"_":"";
@@ -162,6 +164,8 @@ sub main'dec { &out1("decl",@_); }
162sub main'inc { &out1("incl",@_); } 164sub main'inc { &out1("incl",@_); }
163sub main'push { &out1("pushl",@_); $stack+=4; } 165sub main'push { &out1("pushl",@_); $stack+=4; }
164sub main'pop { &out1("popl",@_); $stack-=4; } 166sub main'pop { &out1("popl",@_); $stack-=4; }
167sub main'pushf { &out0("pushf"); $stack+=4; }
168sub main'popf { &out0("popf"); $stack-=4; }
165sub main'not { &out1("notl",@_); } 169sub main'not { &out1("notl",@_); }
166sub main'call { &out1("call",$under.$_[0]); } 170sub main'call { &out1("call",$under.$_[0]); }
167sub main'ret { &out0("ret"); } 171sub main'ret { &out0("ret"); }
@@ -344,6 +348,7 @@ sub main'function_end
344.${func}_end: 348.${func}_end:
345EOF 349EOF
346 push(@out,$tmp); 350 push(@out,$tmp);
351
347 if ($main'cpp) 352 if ($main'cpp)
348 { push(@out,"\tSIZE($func,.${func}_end-$func)\n"); } 353 { push(@out,"\tSIZE($func,.${func}_end-$func)\n"); }
349 elsif ($main'gaswin) 354 elsif ($main'gaswin)
@@ -453,9 +458,87 @@ sub main'set_label
453 458
454sub main'file_end 459sub main'file_end
455 { 460 {
461 if ($const ne "")
462 {
463 push(@out,".section .rodata\n");
464 push(@out,$const);
465 $const="";
466 }
456 } 467 }
457 468
458sub main'data_word 469sub main'data_word
459 { 470 {
460 push(@out,"\t.long $_[0]\n"); 471 push(@out,"\t.long $_[0]\n");
461 } 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
index d745c53621..d62f7eb7dd 100644
--- a/src/lib/libcrypto/pkcs12/Makefile.ssl
+++ b/src/lib/libcrypto/pkcs12/Makefile.ssl
@@ -5,13 +5,14 @@
5DIR= pkcs12 5DIR= pkcs12
6TOP= ../.. 6TOP= ../..
7CC= cc 7CC= cc
8INCLUDES= -I.. -I../../include 8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g 9CFLAG=-g
10INSTALL_PREFIX= 10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl 11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl 12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl 13MAKE= make -f Makefile.ssl
14MAKEDEPEND= $(TOP)/util/domd $(TOP) 14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
15MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
16AR= ar r 17AR= ar r
17 18
@@ -22,12 +23,12 @@ TEST=
22APPS= 23APPS=
23 24
24LIB=$(TOP)/libcrypto.a 25LIB=$(TOP)/libcrypto.a
25LIBSRC= p12_add.c p12_attr.c p12_bags.c p12_crpt.c p12_crt.c p12_decr.c \ 26LIBSRC= p12_add.c p12_asn.c p12_attr.c p12_crpt.c p12_crt.c p12_decr.c \
26 p12_init.c p12_key.c p12_kiss.c p12_lib.c p12_mac.c p12_mutl.c\ 27 p12_init.c p12_key.c p12_kiss.c p12_mutl.c\
27 p12_sbag.c p12_utl.c p12_npas.c pk12err.c 28 p12_utl.c p12_npas.c pk12err.c p12_p8d.c p12_p8e.c
28LIBOBJ= p12_add.o p12_attr.o p12_bags.o p12_crpt.o p12_crt.o p12_decr.o \ 29LIBOBJ= p12_add.o p12_asn.o p12_attr.o p12_crpt.o p12_crt.o p12_decr.o \
29 p12_init.o p12_key.o p12_kiss.o p12_lib.o p12_mac.o p12_mutl.o\ 30 p12_init.o p12_key.o p12_kiss.o p12_mutl.o\
30 p12_sbag.o p12_utl.o p12_npas.o pk12err.o 31 p12_utl.o p12_npas.o pk12err.o p12_p8d.o p12_p8e.o
31 32
32SRC= $(LIBSRC) 33SRC= $(LIBSRC)
33 34
@@ -45,8 +46,7 @@ all: lib
45 46
46lib: $(LIBOBJ) 47lib: $(LIBOBJ)
47 $(AR) $(LIB) $(LIBOBJ) 48 $(AR) $(LIB) $(LIBOBJ)
48 @echo You may get an error following this line. Please ignore. 49 $(RANLIB) $(LIB) || echo Never mind.
49 - $(RANLIB) $(LIB)
50 @touch lib 50 @touch lib
51 51
52files: 52files:
@@ -85,316 +85,213 @@ clean:
85 85
86# DO NOT DELETE THIS LINE -- make depend depends on it. 86# DO NOT DELETE THIS LINE -- make depend depends on it.
87 87
88p12_add.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 88p12_add.o: ../../e_os.h ../../include/openssl/asn1.h
89p12_add.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 89p12_add.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
90p12_add.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 90p12_add.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
91p12_add.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
92p12_add.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 91p12_add.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
93p12_add.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 92p12_add.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
94p12_add.o: ../../include/openssl/err.h ../../include/openssl/evp.h 93p12_add.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
95p12_add.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
96p12_add.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
97p12_add.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
98p12_add.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 94p12_add.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
99p12_add.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 95p12_add.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
100p12_add.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h 96p12_add.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs12.h
101p12_add.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 97p12_add.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
102p12_add.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 98p12_add.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
103p12_add.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 99p12_add.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
104p12_add.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 100p12_add.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
105p12_add.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 101p12_add.o: ../cryptlib.h p12_add.c
106p12_add.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 102p12_asn.o: ../../e_os.h ../../include/openssl/asn1.h
107p12_attr.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 103p12_asn.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
108p12_attr.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 104p12_asn.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
109p12_attr.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 105p12_asn.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
110p12_attr.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 106p12_asn.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
107p12_asn.o: ../../include/openssl/err.h ../../include/openssl/evp.h
108p12_asn.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
109p12_asn.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
110p12_asn.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
111p12_asn.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
112p12_asn.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
113p12_asn.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
114p12_asn.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
115p12_asn.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p12_asn.c
116p12_attr.o: ../../e_os.h ../../include/openssl/asn1.h
117p12_attr.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
118p12_attr.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
111p12_attr.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 119p12_attr.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
112p12_attr.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 120p12_attr.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
113p12_attr.o: ../../include/openssl/err.h ../../include/openssl/evp.h 121p12_attr.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
114p12_attr.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
115p12_attr.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
116p12_attr.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
117p12_attr.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 122p12_attr.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
118p12_attr.o: ../../include/openssl/opensslconf.h 123p12_attr.o: ../../include/openssl/opensslconf.h
119p12_attr.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs12.h 124p12_attr.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
120p12_attr.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h 125p12_attr.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
121p12_attr.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 126p12_attr.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
122p12_attr.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 127p12_attr.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
123p12_attr.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 128p12_attr.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
124p12_attr.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 129p12_attr.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p12_attr.c
125p12_attr.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 130p12_crpt.o: ../../e_os.h ../../include/openssl/asn1.h
126p12_attr.o: ../cryptlib.h 131p12_crpt.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
127p12_bags.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 132p12_crpt.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
128p12_bags.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
129p12_bags.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
130p12_bags.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
131p12_bags.o: ../../include/openssl/des.h ../../include/openssl/dh.h
132p12_bags.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
133p12_bags.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
134p12_bags.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
135p12_bags.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
136p12_bags.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
137p12_bags.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
138p12_bags.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
139p12_bags.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs12.h
140p12_bags.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
141p12_bags.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
142p12_bags.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
143p12_bags.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
144p12_bags.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
145p12_bags.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
146p12_bags.o: ../cryptlib.h
147p12_crpt.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
148p12_crpt.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
149p12_crpt.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
150p12_crpt.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
151p12_crpt.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 133p12_crpt.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
152p12_crpt.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 134p12_crpt.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
153p12_crpt.o: ../../include/openssl/err.h ../../include/openssl/evp.h 135p12_crpt.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
154p12_crpt.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
155p12_crpt.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
156p12_crpt.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
157p12_crpt.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 136p12_crpt.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
158p12_crpt.o: ../../include/openssl/opensslconf.h 137p12_crpt.o: ../../include/openssl/opensslconf.h
159p12_crpt.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs12.h 138p12_crpt.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
160p12_crpt.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h 139p12_crpt.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
161p12_crpt.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 140p12_crpt.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
162p12_crpt.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 141p12_crpt.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
163p12_crpt.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 142p12_crpt.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
164p12_crpt.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 143p12_crpt.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p12_crpt.c
165p12_crpt.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 144p12_crt.o: ../../e_os.h ../../include/openssl/asn1.h
166p12_crpt.o: ../cryptlib.h 145p12_crt.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
167p12_crt.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 146p12_crt.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
168p12_crt.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
169p12_crt.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
170p12_crt.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
171p12_crt.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 147p12_crt.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
172p12_crt.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 148p12_crt.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
173p12_crt.o: ../../include/openssl/err.h ../../include/openssl/evp.h 149p12_crt.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
174p12_crt.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
175p12_crt.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
176p12_crt.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
177p12_crt.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 150p12_crt.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
178p12_crt.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 151p12_crt.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
179p12_crt.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h 152p12_crt.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs12.h
180p12_crt.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 153p12_crt.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
181p12_crt.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 154p12_crt.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
182p12_crt.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 155p12_crt.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
183p12_crt.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 156p12_crt.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
184p12_crt.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 157p12_crt.o: ../cryptlib.h p12_crt.c
185p12_crt.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 158p12_decr.o: ../../e_os.h ../../include/openssl/asn1.h
186p12_decr.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 159p12_decr.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
187p12_decr.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 160p12_decr.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
188p12_decr.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
189p12_decr.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
190p12_decr.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 161p12_decr.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
191p12_decr.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 162p12_decr.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
192p12_decr.o: ../../include/openssl/err.h ../../include/openssl/evp.h 163p12_decr.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
193p12_decr.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
194p12_decr.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
195p12_decr.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
196p12_decr.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 164p12_decr.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
197p12_decr.o: ../../include/openssl/opensslconf.h 165p12_decr.o: ../../include/openssl/opensslconf.h
198p12_decr.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs12.h 166p12_decr.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
199p12_decr.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h 167p12_decr.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
200p12_decr.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 168p12_decr.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
201p12_decr.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 169p12_decr.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
202p12_decr.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 170p12_decr.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
203p12_decr.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 171p12_decr.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p12_decr.c
204p12_decr.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 172p12_init.o: ../../e_os.h ../../include/openssl/asn1.h
205p12_decr.o: ../cryptlib.h 173p12_init.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
206p12_init.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 174p12_init.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
207p12_init.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
208p12_init.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
209p12_init.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
210p12_init.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 175p12_init.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
211p12_init.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 176p12_init.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
212p12_init.o: ../../include/openssl/err.h ../../include/openssl/evp.h 177p12_init.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
213p12_init.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
214p12_init.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
215p12_init.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
216p12_init.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 178p12_init.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
217p12_init.o: ../../include/openssl/opensslconf.h 179p12_init.o: ../../include/openssl/opensslconf.h
218p12_init.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs12.h 180p12_init.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
219p12_init.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h 181p12_init.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
220p12_init.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 182p12_init.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
221p12_init.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 183p12_init.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
222p12_init.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 184p12_init.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
223p12_init.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 185p12_init.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p12_init.c
224p12_init.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 186p12_key.o: ../../e_os.h ../../include/openssl/asn1.h
225p12_init.o: ../cryptlib.h 187p12_key.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
226p12_key.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 188p12_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
227p12_key.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
228p12_key.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
229p12_key.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
230p12_key.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 189p12_key.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
231p12_key.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 190p12_key.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
232p12_key.o: ../../include/openssl/err.h ../../include/openssl/evp.h 191p12_key.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
233p12_key.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
234p12_key.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
235p12_key.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
236p12_key.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 192p12_key.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
237p12_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 193p12_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
238p12_key.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h 194p12_key.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs12.h
239p12_key.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 195p12_key.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
240p12_key.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 196p12_key.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
241p12_key.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 197p12_key.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
242p12_key.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 198p12_key.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
243p12_key.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 199p12_key.o: ../cryptlib.h p12_key.c
244p12_key.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 200p12_kiss.o: ../../e_os.h ../../include/openssl/asn1.h
245p12_kiss.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 201p12_kiss.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
246p12_kiss.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 202p12_kiss.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
247p12_kiss.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
248p12_kiss.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
249p12_kiss.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 203p12_kiss.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
250p12_kiss.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 204p12_kiss.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
251p12_kiss.o: ../../include/openssl/err.h ../../include/openssl/evp.h 205p12_kiss.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
252p12_kiss.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
253p12_kiss.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
254p12_kiss.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
255p12_kiss.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 206p12_kiss.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
256p12_kiss.o: ../../include/openssl/opensslconf.h 207p12_kiss.o: ../../include/openssl/opensslconf.h
257p12_kiss.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs12.h 208p12_kiss.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
258p12_kiss.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h 209p12_kiss.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
259p12_kiss.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 210p12_kiss.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
260p12_kiss.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 211p12_kiss.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
261p12_kiss.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 212p12_kiss.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
262p12_kiss.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 213p12_kiss.o: ../../include/openssl/x509_vfy.h ../cryptlib.h p12_kiss.c
263p12_kiss.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 214p12_mutl.o: ../../e_os.h ../../include/openssl/asn1.h
264p12_kiss.o: ../cryptlib.h 215p12_mutl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
265p12_lib.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 216p12_mutl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
266p12_lib.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
267p12_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
268p12_lib.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
269p12_lib.o: ../../include/openssl/des.h ../../include/openssl/dh.h
270p12_lib.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
271p12_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
272p12_lib.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
273p12_lib.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
274p12_lib.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
275p12_lib.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
276p12_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
277p12_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs12.h
278p12_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
279p12_lib.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
280p12_lib.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
281p12_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
282p12_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
283p12_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
284p12_lib.o: ../cryptlib.h
285p12_mac.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
286p12_mac.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
287p12_mac.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
288p12_mac.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
289p12_mac.o: ../../include/openssl/des.h ../../include/openssl/dh.h
290p12_mac.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
291p12_mac.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
292p12_mac.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
293p12_mac.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
294p12_mac.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
295p12_mac.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
296p12_mac.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
297p12_mac.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs12.h
298p12_mac.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
299p12_mac.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
300p12_mac.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
301p12_mac.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
302p12_mac.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
303p12_mac.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
304p12_mac.o: ../cryptlib.h
305p12_mutl.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
306p12_mutl.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
307p12_mutl.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
308p12_mutl.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
309p12_mutl.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 217p12_mutl.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
310p12_mutl.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 218p12_mutl.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
311p12_mutl.o: ../../include/openssl/err.h ../../include/openssl/evp.h 219p12_mutl.o: ../../include/openssl/evp.h ../../include/openssl/hmac.h
312p12_mutl.o: ../../include/openssl/hmac.h ../../include/openssl/idea.h 220p12_mutl.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
313p12_mutl.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
314p12_mutl.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
315p12_mutl.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
316p12_mutl.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 221p12_mutl.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
317p12_mutl.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs12.h 222p12_mutl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
318p12_mutl.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h 223p12_mutl.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
319p12_mutl.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 224p12_mutl.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
320p12_mutl.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 225p12_mutl.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
321p12_mutl.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 226p12_mutl.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
322p12_mutl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 227p12_mutl.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
323p12_mutl.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 228p12_mutl.o: ../cryptlib.h p12_mutl.c
324p12_mutl.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
325p12_npas.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 229p12_npas.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
326p12_npas.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 230p12_npas.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
327p12_npas.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 231p12_npas.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
328p12_npas.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 232p12_npas.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
329p12_npas.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 233p12_npas.o: ../../include/openssl/err.h ../../include/openssl/evp.h
330p12_npas.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 234p12_npas.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
331p12_npas.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
332p12_npas.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
333p12_npas.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
334p12_npas.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
335p12_npas.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 235p12_npas.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
336p12_npas.o: ../../include/openssl/opensslv.h ../../include/openssl/pem.h 236p12_npas.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
337p12_npas.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs12.h 237p12_npas.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
338p12_npas.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h 238p12_npas.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
339p12_npas.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 239p12_npas.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
340p12_npas.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 240p12_npas.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
341p12_npas.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 241p12_npas.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
342p12_npas.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 242p12_npas.o: ../../include/openssl/x509_vfy.h p12_npas.c
343p12_npas.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 243p12_p8d.o: ../../e_os.h ../../include/openssl/asn1.h
344p12_sbag.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 244p12_p8d.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
345p12_sbag.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h 245p12_p8d.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
346p12_sbag.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 246p12_p8d.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
347p12_sbag.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h 247p12_p8d.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
348p12_sbag.o: ../../include/openssl/des.h ../../include/openssl/dh.h 248p12_p8d.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
349p12_sbag.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h 249p12_p8d.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
350p12_sbag.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 250p12_p8d.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
351p12_sbag.o: ../../include/openssl/evp.h ../../include/openssl/idea.h 251p12_p8d.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs12.h
352p12_sbag.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h 252p12_p8d.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
353p12_sbag.o: ../../include/openssl/md4.h ../../include/openssl/md5.h 253p12_p8d.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
354p12_sbag.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h 254p12_p8d.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
355p12_sbag.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 255p12_p8d.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
356p12_sbag.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs12.h 256p12_p8d.o: ../cryptlib.h p12_p8d.c
357p12_sbag.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h 257p12_p8e.o: ../../e_os.h ../../include/openssl/asn1.h
358p12_sbag.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 258p12_p8e.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
359p12_sbag.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 259p12_p8e.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
360p12_sbag.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 260p12_p8e.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
361p12_sbag.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 261p12_p8e.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
362p12_sbag.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 262p12_p8e.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
363p12_sbag.o: ../cryptlib.h 263p12_p8e.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
364p12_utl.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 264p12_p8e.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
365p12_utl.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 265p12_p8e.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs12.h
366p12_utl.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 266p12_p8e.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
367p12_utl.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 267p12_p8e.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
268p12_p8e.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
269p12_p8e.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
270p12_p8e.o: ../cryptlib.h p12_p8e.c
271p12_utl.o: ../../e_os.h ../../include/openssl/asn1.h
272p12_utl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
273p12_utl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
368p12_utl.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 274p12_utl.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
369p12_utl.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 275p12_utl.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
370p12_utl.o: ../../include/openssl/err.h ../../include/openssl/evp.h 276p12_utl.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
371p12_utl.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
372p12_utl.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
373p12_utl.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
374p12_utl.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 277p12_utl.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
375p12_utl.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 278p12_utl.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
376p12_utl.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h 279p12_utl.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs12.h
377p12_utl.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 280p12_utl.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
378p12_utl.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 281p12_utl.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
379p12_utl.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 282p12_utl.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
380p12_utl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 283p12_utl.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
381p12_utl.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 284p12_utl.o: ../cryptlib.h p12_utl.c
382p12_utl.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
383pk12err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 285pk12err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
384pk12err.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 286pk12err.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
385pk12err.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 287pk12err.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
386pk12err.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 288pk12err.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
387pk12err.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 289pk12err.o: ../../include/openssl/err.h ../../include/openssl/evp.h
388pk12err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 290pk12err.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
389pk12err.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
390pk12err.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
391pk12err.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
392pk12err.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
393pk12err.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 291pk12err.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
394pk12err.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs12.h 292pk12err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
395pk12err.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h 293pk12err.o: ../../include/openssl/pkcs12.h ../../include/openssl/pkcs7.h
396pk12err.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 294pk12err.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
397pk12err.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 295pk12err.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
398pk12err.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 296pk12err.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
399pk12err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 297pk12err.o: ../../include/openssl/x509_vfy.h pk12err.c
400pk12err.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
diff --git a/src/lib/libcrypto/pkcs12/p12_add.c b/src/lib/libcrypto/pkcs12/p12_add.c
index b563656895..1909f28506 100644
--- a/src/lib/libcrypto/pkcs12/p12_add.c
+++ b/src/lib/libcrypto/pkcs12/p12_add.c
@@ -62,21 +62,21 @@
62 62
63/* Pack an object into an OCTET STRING and turn into a safebag */ 63/* Pack an object into an OCTET STRING and turn into a safebag */
64 64
65PKCS12_SAFEBAG *PKCS12_pack_safebag (char *obj, int (*i2d)(), int nid1, 65PKCS12_SAFEBAG *PKCS12_item_pack_safebag(void *obj, const ASN1_ITEM *it, int nid1,
66 int nid2) 66 int nid2)
67{ 67{
68 PKCS12_BAGS *bag; 68 PKCS12_BAGS *bag;
69 PKCS12_SAFEBAG *safebag; 69 PKCS12_SAFEBAG *safebag;
70 if (!(bag = PKCS12_BAGS_new ())) { 70 if (!(bag = PKCS12_BAGS_new())) {
71 PKCS12err(PKCS12_F_PKCS12_PACK_SAFEBAG, ERR_R_MALLOC_FAILURE); 71 PKCS12err(PKCS12_F_PKCS12_PACK_SAFEBAG, ERR_R_MALLOC_FAILURE);
72 return NULL; 72 return NULL;
73 } 73 }
74 bag->type = OBJ_nid2obj(nid1); 74 bag->type = OBJ_nid2obj(nid1);
75 if (!ASN1_pack_string(obj, i2d, &bag->value.octet)) { 75 if (!ASN1_item_pack(obj, it, &bag->value.octet)) {
76 PKCS12err(PKCS12_F_PKCS12_PACK_SAFEBAG, ERR_R_MALLOC_FAILURE); 76 PKCS12err(PKCS12_F_PKCS12_PACK_SAFEBAG, ERR_R_MALLOC_FAILURE);
77 return NULL; 77 return NULL;
78 } 78 }
79 if (!(safebag = PKCS12_SAFEBAG_new ())) { 79 if (!(safebag = PKCS12_SAFEBAG_new())) {
80 PKCS12err(PKCS12_F_PKCS12_PACK_SAFEBAG, ERR_R_MALLOC_FAILURE); 80 PKCS12err(PKCS12_F_PKCS12_PACK_SAFEBAG, ERR_R_MALLOC_FAILURE);
81 return NULL; 81 return NULL;
82 } 82 }
@@ -87,7 +87,7 @@ PKCS12_SAFEBAG *PKCS12_pack_safebag (char *obj, int (*i2d)(), int nid1,
87 87
88/* Turn PKCS8 object into a keybag */ 88/* Turn PKCS8 object into a keybag */
89 89
90PKCS12_SAFEBAG *PKCS12_MAKE_KEYBAG (PKCS8_PRIV_KEY_INFO *p8) 90PKCS12_SAFEBAG *PKCS12_MAKE_KEYBAG(PKCS8_PRIV_KEY_INFO *p8)
91{ 91{
92 PKCS12_SAFEBAG *bag; 92 PKCS12_SAFEBAG *bag;
93 if (!(bag = PKCS12_SAFEBAG_new())) { 93 if (!(bag = PKCS12_SAFEBAG_new())) {
@@ -101,14 +101,14 @@ PKCS12_SAFEBAG *PKCS12_MAKE_KEYBAG (PKCS8_PRIV_KEY_INFO *p8)
101 101
102/* Turn PKCS8 object into a shrouded keybag */ 102/* Turn PKCS8 object into a shrouded keybag */
103 103
104PKCS12_SAFEBAG *PKCS12_MAKE_SHKEYBAG (int pbe_nid, const char *pass, 104PKCS12_SAFEBAG *PKCS12_MAKE_SHKEYBAG(int pbe_nid, const char *pass,
105 int passlen, unsigned char *salt, int saltlen, int iter, 105 int passlen, unsigned char *salt, int saltlen, int iter,
106 PKCS8_PRIV_KEY_INFO *p8) 106 PKCS8_PRIV_KEY_INFO *p8)
107{ 107{
108 PKCS12_SAFEBAG *bag; 108 PKCS12_SAFEBAG *bag;
109 109
110 /* Set up the safe bag */ 110 /* Set up the safe bag */
111 if (!(bag = PKCS12_SAFEBAG_new ())) { 111 if (!(bag = PKCS12_SAFEBAG_new())) {
112 PKCS12err(PKCS12_F_PKCS12_MAKE_SHKEYBAG, ERR_R_MALLOC_FAILURE); 112 PKCS12err(PKCS12_F_PKCS12_MAKE_SHKEYBAG, ERR_R_MALLOC_FAILURE);
113 return NULL; 113 return NULL;
114 } 114 }
@@ -125,7 +125,7 @@ PKCS12_SAFEBAG *PKCS12_MAKE_SHKEYBAG (int pbe_nid, const char *pass,
125} 125}
126 126
127/* Turn a stack of SAFEBAGS into a PKCS#7 data Contentinfo */ 127/* Turn a stack of SAFEBAGS into a PKCS#7 data Contentinfo */
128PKCS7 *PKCS12_pack_p7data (STACK_OF(PKCS12_SAFEBAG) *sk) 128PKCS7 *PKCS12_pack_p7data(STACK_OF(PKCS12_SAFEBAG) *sk)
129{ 129{
130 PKCS7 *p7; 130 PKCS7 *p7;
131 if (!(p7 = PKCS7_new())) { 131 if (!(p7 = PKCS7_new())) {
@@ -138,18 +138,23 @@ PKCS7 *PKCS12_pack_p7data (STACK_OF(PKCS12_SAFEBAG) *sk)
138 return NULL; 138 return NULL;
139 } 139 }
140 140
141 if (!ASN1_seq_pack_PKCS12_SAFEBAG(sk, i2d_PKCS12_SAFEBAG, 141 if (!ASN1_item_pack(sk, ASN1_ITEM_rptr(PKCS12_SAFEBAGS), &p7->d.data)) {
142 &p7->d.data->data,
143 &p7->d.data->length)) {
144 PKCS12err(PKCS12_F_PKCS12_PACK_P7DATA, PKCS12_R_CANT_PACK_STRUCTURE); 142 PKCS12err(PKCS12_F_PKCS12_PACK_P7DATA, PKCS12_R_CANT_PACK_STRUCTURE);
145 return NULL; 143 return NULL;
146 } 144 }
147 return p7; 145 return p7;
148} 146}
149 147
148/* Unpack SAFEBAGS from PKCS#7 data ContentInfo */
149STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7data(PKCS7 *p7)
150{
151 if(!PKCS7_type_is_data(p7)) return NULL;
152 return ASN1_item_unpack(p7->d.data, ASN1_ITEM_rptr(PKCS12_SAFEBAGS));
153}
154
150/* Turn a stack of SAFEBAGS into a PKCS#7 encrypted data ContentInfo */ 155/* Turn a stack of SAFEBAGS into a PKCS#7 encrypted data ContentInfo */
151 156
152PKCS7 *PKCS12_pack_p7encdata (int pbe_nid, const char *pass, int passlen, 157PKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen,
153 unsigned char *salt, int saltlen, int iter, 158 unsigned char *salt, int saltlen, int iter,
154 STACK_OF(PKCS12_SAFEBAG) *bags) 159 STACK_OF(PKCS12_SAFEBAG) *bags)
155{ 160{
@@ -164,7 +169,7 @@ PKCS7 *PKCS12_pack_p7encdata (int pbe_nid, const char *pass, int passlen,
164 PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE); 169 PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE);
165 return NULL; 170 return NULL;
166 } 171 }
167 if (!(pbe = PKCS5_pbe_set (pbe_nid, iter, salt, saltlen))) { 172 if (!(pbe = PKCS5_pbe_set(pbe_nid, iter, salt, saltlen))) {
168 PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, ERR_R_MALLOC_FAILURE); 173 PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, ERR_R_MALLOC_FAILURE);
169 return NULL; 174 return NULL;
170 } 175 }
@@ -172,8 +177,8 @@ PKCS7 *PKCS12_pack_p7encdata (int pbe_nid, const char *pass, int passlen,
172 p7->d.encrypted->enc_data->algorithm = pbe; 177 p7->d.encrypted->enc_data->algorithm = pbe;
173 M_ASN1_OCTET_STRING_free(p7->d.encrypted->enc_data->enc_data); 178 M_ASN1_OCTET_STRING_free(p7->d.encrypted->enc_data->enc_data);
174 if (!(p7->d.encrypted->enc_data->enc_data = 179 if (!(p7->d.encrypted->enc_data->enc_data =
175 PKCS12_i2d_encrypt (pbe, i2d_PKCS12_SAFEBAG, pass, passlen, 180 PKCS12_item_i2d_encrypt(pbe, ASN1_ITEM_rptr(PKCS12_SAFEBAGS), pass, passlen,
176 (char *)bags, 1))) { 181 bags, 1))) {
177 PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, PKCS12_R_ENCRYPT_ERROR); 182 PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, PKCS12_R_ENCRYPT_ERROR);
178 return NULL; 183 return NULL;
179 } 184 }
@@ -181,38 +186,30 @@ PKCS7 *PKCS12_pack_p7encdata (int pbe_nid, const char *pass, int passlen,
181 return p7; 186 return p7;
182} 187}
183 188
184X509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher, 189STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7encdata(PKCS7 *p7, const char *pass, int passlen)
185 const char *pass, int passlen,
186 unsigned char *salt, int saltlen, int iter,
187 PKCS8_PRIV_KEY_INFO *p8inf)
188{ 190{
189 X509_SIG *p8; 191 if(!PKCS7_type_is_encrypted(p7)) return NULL;
190 X509_ALGOR *pbe; 192 return PKCS12_item_decrypt_d2i(p7->d.encrypted->enc_data->algorithm,
191 193 ASN1_ITEM_rptr(PKCS12_SAFEBAGS),
192 if (!(p8 = X509_SIG_new())) { 194 pass, passlen,
193 PKCS12err(PKCS12_F_PKCS8_ENCRYPT, ERR_R_MALLOC_FAILURE); 195 p7->d.encrypted->enc_data->enc_data, 1);
194 goto err; 196}
195 }
196 197
197 if(pbe_nid == -1) pbe = PKCS5_pbe2_set(cipher, iter, salt, saltlen); 198PKCS8_PRIV_KEY_INFO *PKCS12_decrypt_skey(PKCS12_SAFEBAG *bag, const char *pass,
198 else pbe = PKCS5_pbe_set(pbe_nid, iter, salt, saltlen); 199 int passlen)
199 if(!pbe) { 200{
200 PKCS12err(PKCS12_F_PKCS8_ENCRYPT, ERR_R_ASN1_LIB); 201 return PKCS8_decrypt(bag->value.shkeybag, pass, passlen);
201 goto err; 202}
202 }
203 X509_ALGOR_free(p8->algor);
204 p8->algor = pbe;
205 M_ASN1_OCTET_STRING_free(p8->digest);
206 if (!(p8->digest =
207 PKCS12_i2d_encrypt (pbe, i2d_PKCS8_PRIV_KEY_INFO, pass, passlen,
208 (char *)p8inf, 0))) {
209 PKCS12err(PKCS12_F_PKCS8_ENCRYPT, PKCS12_R_ENCRYPT_ERROR);
210 goto err;
211 }
212 203
213 return p8; 204int PKCS12_pack_authsafes(PKCS12 *p12, STACK_OF(PKCS7) *safes)
205{
206 if(ASN1_item_pack(safes, ASN1_ITEM_rptr(PKCS12_AUTHSAFES),
207 &p12->authsafes->d.data))
208 return 1;
209 return 0;
210}
214 211
215 err: 212STACK_OF(PKCS7) *PKCS12_unpack_authsafes(PKCS12 *p12)
216 X509_SIG_free(p8); 213{
217 return NULL; 214 return ASN1_item_unpack(p12->authsafes->d.data, ASN1_ITEM_rptr(PKCS12_AUTHSAFES));
218} 215}
diff --git a/src/lib/libcrypto/pkcs12/p12_asn.c b/src/lib/libcrypto/pkcs12/p12_asn.c
new file mode 100644
index 0000000000..c327bdba03
--- /dev/null
+++ b/src/lib/libcrypto/pkcs12/p12_asn.c
@@ -0,0 +1,125 @@
1/* p12_asn.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/asn1t.h>
62#include <openssl/pkcs12.h>
63
64/* PKCS#12 ASN1 module */
65
66ASN1_SEQUENCE(PKCS12) = {
67 ASN1_SIMPLE(PKCS12, version, ASN1_INTEGER),
68 ASN1_SIMPLE(PKCS12, authsafes, PKCS7),
69 ASN1_OPT(PKCS12, mac, PKCS12_MAC_DATA)
70} ASN1_SEQUENCE_END(PKCS12)
71
72IMPLEMENT_ASN1_FUNCTIONS(PKCS12)
73
74ASN1_SEQUENCE(PKCS12_MAC_DATA) = {
75 ASN1_SIMPLE(PKCS12_MAC_DATA, dinfo, X509_SIG),
76 ASN1_SIMPLE(PKCS12_MAC_DATA, salt, ASN1_OCTET_STRING),
77 ASN1_OPT(PKCS12_MAC_DATA, iter, ASN1_INTEGER)
78} ASN1_SEQUENCE_END(PKCS12_MAC_DATA)
79
80IMPLEMENT_ASN1_FUNCTIONS(PKCS12_MAC_DATA)
81
82ASN1_ADB_TEMPLATE(bag_default) = ASN1_EXP(PKCS12_BAGS, value.other, ASN1_ANY, 0);
83
84ASN1_ADB(PKCS12_BAGS) = {
85 ADB_ENTRY(NID_x509Certificate, ASN1_EXP(PKCS12_BAGS, value.x509cert, ASN1_OCTET_STRING, 0)),
86 ADB_ENTRY(NID_x509Certificate, ASN1_EXP(PKCS12_BAGS, value.x509crl, ASN1_OCTET_STRING, 0)),
87 ADB_ENTRY(NID_x509Certificate, ASN1_EXP(PKCS12_BAGS, value.sdsicert, ASN1_IA5STRING, 0)),
88} ASN1_ADB_END(PKCS12_BAGS, 0, type, 0, &bag_default_tt, NULL);
89
90ASN1_SEQUENCE(PKCS12_BAGS) = {
91 ASN1_SIMPLE(PKCS12_BAGS, type, ASN1_OBJECT),
92 ASN1_ADB_OBJECT(PKCS12_BAGS),
93} ASN1_SEQUENCE_END(PKCS12_BAGS)
94
95IMPLEMENT_ASN1_FUNCTIONS(PKCS12_BAGS)
96
97ASN1_ADB_TEMPLATE(safebag_default) = ASN1_EXP(PKCS12_SAFEBAG, value.other, ASN1_ANY, 0);
98
99ASN1_ADB(PKCS12_SAFEBAG) = {
100 ADB_ENTRY(NID_keyBag, ASN1_EXP(PKCS12_SAFEBAG, value.keybag, PKCS8_PRIV_KEY_INFO, 0)),
101 ADB_ENTRY(NID_pkcs8ShroudedKeyBag, ASN1_EXP(PKCS12_SAFEBAG, value.keybag, X509_SIG, 0)),
102 ADB_ENTRY(NID_safeContentsBag, ASN1_EXP_SET_OF(PKCS12_SAFEBAG, value.safes, PKCS12_SAFEBAG, 0)),
103 ADB_ENTRY(NID_certBag, ASN1_EXP(PKCS12_SAFEBAG, value.bag, PKCS12_BAGS, 0)),
104 ADB_ENTRY(NID_crlBag, ASN1_EXP(PKCS12_SAFEBAG, value.bag, PKCS12_BAGS, 0)),
105 ADB_ENTRY(NID_secretBag, ASN1_EXP(PKCS12_SAFEBAG, value.bag, PKCS12_BAGS, 0))
106} ASN1_ADB_END(PKCS12_SAFEBAG, 0, type, 0, &safebag_default_tt, NULL);
107
108ASN1_SEQUENCE(PKCS12_SAFEBAG) = {
109 ASN1_SIMPLE(PKCS12_SAFEBAG, type, ASN1_OBJECT),
110 ASN1_ADB_OBJECT(PKCS12_SAFEBAG),
111 ASN1_SET_OF_OPT(PKCS12_SAFEBAG, attrib, X509_ATTRIBUTE)
112} ASN1_SEQUENCE_END(PKCS12_SAFEBAG)
113
114IMPLEMENT_ASN1_FUNCTIONS(PKCS12_SAFEBAG)
115
116/* SEQUENCE OF SafeBag */
117ASN1_ITEM_TEMPLATE(PKCS12_SAFEBAGS) =
118 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, PKCS12_SAFEBAGS, PKCS12_SAFEBAG)
119ASN1_ITEM_TEMPLATE_END(PKCS12_SAFEBAGS)
120
121/* Authsafes: SEQUENCE OF PKCS7 */
122ASN1_ITEM_TEMPLATE(PKCS12_AUTHSAFES) =
123 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, PKCS12_AUTHSAFES, PKCS7)
124ASN1_ITEM_TEMPLATE_END(PKCS12_AUTHSAFES)
125
diff --git a/src/lib/libcrypto/pkcs12/p12_attr.c b/src/lib/libcrypto/pkcs12/p12_attr.c
index a16a97d03d..026cf3826a 100644
--- a/src/lib/libcrypto/pkcs12/p12_attr.c
+++ b/src/lib/libcrypto/pkcs12/p12_attr.c
@@ -62,156 +62,63 @@
62 62
63/* Add a local keyid to a safebag */ 63/* Add a local keyid to a safebag */
64 64
65int PKCS12_add_localkeyid (PKCS12_SAFEBAG *bag, unsigned char *name, 65int PKCS12_add_localkeyid(PKCS12_SAFEBAG *bag, unsigned char *name,
66 int namelen) 66 int namelen)
67{ 67{
68 X509_ATTRIBUTE *attrib; 68 if (X509at_add1_attr_by_NID(&bag->attrib, NID_localKeyID,
69 ASN1_BMPSTRING *oct; 69 V_ASN1_OCTET_STRING, name, namelen))
70 ASN1_TYPE *keyid; 70 return 1;
71 if (!(keyid = ASN1_TYPE_new ())) { 71 else
72 PKCS12err(PKCS12_F_PKCS12_ADD_LOCALKEYID, ERR_R_MALLOC_FAILURE);
73 return 0;
74 }
75 keyid->type = V_ASN1_OCTET_STRING;
76 if (!(oct = M_ASN1_OCTET_STRING_new())) {
77 PKCS12err(PKCS12_F_PKCS12_ADD_LOCALKEYID, ERR_R_MALLOC_FAILURE);
78 return 0;
79 }
80 if (!M_ASN1_OCTET_STRING_set(oct, name, namelen)) {
81 PKCS12err(PKCS12_F_PKCS12_ADD_LOCALKEYID, ERR_R_MALLOC_FAILURE);
82 return 0;
83 }
84 keyid->value.octet_string = oct;
85 if (!(attrib = X509_ATTRIBUTE_new ())) {
86 PKCS12err(PKCS12_F_PKCS12_ADD_LOCALKEYID, ERR_R_MALLOC_FAILURE);
87 return 0;
88 }
89 attrib->object = OBJ_nid2obj(NID_localKeyID);
90 if (!(attrib->value.set = sk_ASN1_TYPE_new_null())) {
91 PKCS12err(PKCS12_F_PKCS12_ADD_LOCALKEYID, ERR_R_MALLOC_FAILURE);
92 return 0;
93 }
94 sk_ASN1_TYPE_push (attrib->value.set,keyid);
95 attrib->set = 1;
96 if (!bag->attrib && !(bag->attrib = sk_X509_ATTRIBUTE_new_null ())) {
97 PKCS12err(PKCS12_F_PKCS12_ADD_LOCALKEYID, ERR_R_MALLOC_FAILURE);
98 return 0; 72 return 0;
99 }
100 sk_X509_ATTRIBUTE_push (bag->attrib, attrib);
101 return 1;
102} 73}
103 74
104/* Add key usage to PKCS#8 structure */ 75/* Add key usage to PKCS#8 structure */
105 76
106int PKCS8_add_keyusage (PKCS8_PRIV_KEY_INFO *p8, int usage) 77int PKCS8_add_keyusage(PKCS8_PRIV_KEY_INFO *p8, int usage)
107{ 78{
108 X509_ATTRIBUTE *attrib;
109 ASN1_BIT_STRING *bstr;
110 ASN1_TYPE *keyid;
111 unsigned char us_val; 79 unsigned char us_val;
112 us_val = (unsigned char) usage; 80 us_val = (unsigned char) usage;
113 if (!(keyid = ASN1_TYPE_new ())) { 81 if (X509at_add1_attr_by_NID(&p8->attributes, NID_key_usage,
114 PKCS12err(PKCS12_F_PKCS8_ADD_KEYUSAGE, ERR_R_MALLOC_FAILURE); 82 V_ASN1_BIT_STRING, &us_val, 1))
115 return 0; 83 return 1;
116 } 84 else
117 keyid->type = V_ASN1_BIT_STRING;
118 if (!(bstr = M_ASN1_BIT_STRING_new())) {
119 PKCS12err(PKCS12_F_PKCS8_ADD_KEYUSAGE, ERR_R_MALLOC_FAILURE);
120 return 0;
121 }
122 if (!M_ASN1_BIT_STRING_set(bstr, &us_val, 1)) {
123 PKCS12err(PKCS12_F_PKCS8_ADD_KEYUSAGE, ERR_R_MALLOC_FAILURE);
124 return 0;
125 }
126 keyid->value.bit_string = bstr;
127 if (!(attrib = X509_ATTRIBUTE_new ())) {
128 PKCS12err(PKCS12_F_PKCS8_ADD_KEYUSAGE, ERR_R_MALLOC_FAILURE);
129 return 0;
130 }
131 attrib->object = OBJ_nid2obj(NID_key_usage);
132 if (!(attrib->value.set = sk_ASN1_TYPE_new_null())) {
133 PKCS12err(PKCS12_F_PKCS8_ADD_KEYUSAGE, ERR_R_MALLOC_FAILURE);
134 return 0; 85 return 0;
135 }
136 sk_ASN1_TYPE_push (attrib->value.set,keyid);
137 attrib->set = 1;
138 if (!p8->attributes
139 && !(p8->attributes = sk_X509_ATTRIBUTE_new_null ())) {
140 PKCS12err(PKCS12_F_PKCS8_ADD_KEYUSAGE, ERR_R_MALLOC_FAILURE);
141 return 0;
142 }
143 sk_X509_ATTRIBUTE_push (p8->attributes, attrib);
144 return 1;
145} 86}
146 87
147/* Add a friendlyname to a safebag */ 88/* Add a friendlyname to a safebag */
148 89
149int PKCS12_add_friendlyname_asc (PKCS12_SAFEBAG *bag, const char *name, 90int PKCS12_add_friendlyname_asc(PKCS12_SAFEBAG *bag, const char *name,
150 int namelen) 91 int namelen)
151{ 92{
152 unsigned char *uniname; 93 if (X509at_add1_attr_by_NID(&bag->attrib, NID_friendlyName,
153 int ret, unilen; 94 MBSTRING_ASC, (unsigned char *)name, namelen))
154 if (!asc2uni(name, namelen, &uniname, &unilen)) { 95 return 1;
155 PKCS12err(PKCS12_F_PKCS12_ADD_FRIENDLYNAME_ASC, 96 else
156 ERR_R_MALLOC_FAILURE);
157 return 0; 97 return 0;
158 }
159 ret = PKCS12_add_friendlyname_uni (bag, uniname, unilen);
160 OPENSSL_free(uniname);
161 return ret;
162} 98}
163
164 99
165int PKCS12_add_friendlyname_uni (PKCS12_SAFEBAG *bag, 100
101int PKCS12_add_friendlyname_uni(PKCS12_SAFEBAG *bag,
166 const unsigned char *name, int namelen) 102 const unsigned char *name, int namelen)
167{ 103{
168 X509_ATTRIBUTE *attrib; 104 if (X509at_add1_attr_by_NID(&bag->attrib, NID_friendlyName,
169 ASN1_BMPSTRING *bmp; 105 MBSTRING_BMP, name, namelen))
170 ASN1_TYPE *fname; 106 return 1;
171 /* Zap ending double null if included */ 107 else
172 if(!name[namelen - 1] && !name[namelen - 2]) namelen -= 2;
173 if (!(fname = ASN1_TYPE_new ())) {
174 PKCS12err(PKCS12_F_PKCS12_ADD_FRIENDLYNAME_UNI,
175 ERR_R_MALLOC_FAILURE);
176 return 0;
177 }
178 fname->type = V_ASN1_BMPSTRING;
179 if (!(bmp = M_ASN1_BMPSTRING_new())) {
180 PKCS12err(PKCS12_F_PKCS12_ADD_FRIENDLYNAME_UNI,
181 ERR_R_MALLOC_FAILURE);
182 return 0;
183 }
184 if (!(bmp->data = OPENSSL_malloc (namelen))) {
185 PKCS12err(PKCS12_F_PKCS12_ADD_FRIENDLYNAME_UNI,
186 ERR_R_MALLOC_FAILURE);
187 return 0; 108 return 0;
188 } 109}
189 memcpy (bmp->data, name, namelen); 110
190 bmp->length = namelen; 111int PKCS12_add_CSPName_asc(PKCS12_SAFEBAG *bag, const char *name,
191 fname->value.bmpstring = bmp; 112 int namelen)
192 if (!(attrib = X509_ATTRIBUTE_new ())) { 113{
193 PKCS12err(PKCS12_F_PKCS12_ADD_FRIENDLYNAME_UNI, 114 if (X509at_add1_attr_by_NID(&bag->attrib, NID_ms_csp_name,
194 ERR_R_MALLOC_FAILURE); 115 MBSTRING_ASC, (unsigned char *)name, namelen))
195 return 0; 116 return 1;
196 } 117 else
197 attrib->object = OBJ_nid2obj(NID_friendlyName);
198 if (!(attrib->value.set = sk_ASN1_TYPE_new_null())) {
199 PKCS12err(PKCS12_F_PKCS12_ADD_FRIENDLYNAME,
200 ERR_R_MALLOC_FAILURE);
201 return 0;
202 }
203 sk_ASN1_TYPE_push (attrib->value.set,fname);
204 attrib->set = 1;
205 if (!bag->attrib && !(bag->attrib = sk_X509_ATTRIBUTE_new_null ())) {
206 PKCS12err(PKCS12_F_PKCS12_ADD_FRIENDLYNAME_UNI,
207 ERR_R_MALLOC_FAILURE);
208 return 0; 118 return 0;
209 }
210 sk_X509_ATTRIBUTE_push (bag->attrib, attrib);
211 return PKCS12_OK;
212} 119}
213 120
214ASN1_TYPE *PKCS12_get_attr_gen (STACK_OF(X509_ATTRIBUTE) *attrs, int attr_nid) 121ASN1_TYPE *PKCS12_get_attr_gen(STACK_OF(X509_ATTRIBUTE) *attrs, int attr_nid)
215{ 122{
216 X509_ATTRIBUTE *attrib; 123 X509_ATTRIBUTE *attrib;
217 int i; 124 int i;
diff --git a/src/lib/libcrypto/pkcs12/p12_crpt.c b/src/lib/libcrypto/pkcs12/p12_crpt.c
index 7b96584f07..97be6a5fb5 100644
--- a/src/lib/libcrypto/pkcs12/p12_crpt.c
+++ b/src/lib/libcrypto/pkcs12/p12_crpt.c
@@ -64,19 +64,19 @@
64 64
65void PKCS12_PBE_add(void) 65void PKCS12_PBE_add(void)
66{ 66{
67#ifndef NO_RC4 67#ifndef OPENSSL_NO_RC4
68EVP_PBE_alg_add(NID_pbe_WithSHA1And128BitRC4, EVP_rc4(), EVP_sha1(), 68EVP_PBE_alg_add(NID_pbe_WithSHA1And128BitRC4, EVP_rc4(), EVP_sha1(),
69 PKCS12_PBE_keyivgen); 69 PKCS12_PBE_keyivgen);
70EVP_PBE_alg_add(NID_pbe_WithSHA1And40BitRC4, EVP_rc4_40(), EVP_sha1(), 70EVP_PBE_alg_add(NID_pbe_WithSHA1And40BitRC4, EVP_rc4_40(), EVP_sha1(),
71 PKCS12_PBE_keyivgen); 71 PKCS12_PBE_keyivgen);
72#endif 72#endif
73#ifndef NO_DES 73#ifndef OPENSSL_NO_DES
74EVP_PBE_alg_add(NID_pbe_WithSHA1And3_Key_TripleDES_CBC, 74EVP_PBE_alg_add(NID_pbe_WithSHA1And3_Key_TripleDES_CBC,
75 EVP_des_ede3_cbc(), EVP_sha1(), PKCS12_PBE_keyivgen); 75 EVP_des_ede3_cbc(), EVP_sha1(), PKCS12_PBE_keyivgen);
76EVP_PBE_alg_add(NID_pbe_WithSHA1And2_Key_TripleDES_CBC, 76EVP_PBE_alg_add(NID_pbe_WithSHA1And2_Key_TripleDES_CBC,
77 EVP_des_ede_cbc(), EVP_sha1(), PKCS12_PBE_keyivgen); 77 EVP_des_ede_cbc(), EVP_sha1(), PKCS12_PBE_keyivgen);
78#endif 78#endif
79#ifndef NO_RC2 79#ifndef OPENSSL_NO_RC2
80EVP_PBE_alg_add(NID_pbe_WithSHA1And128BitRC2_CBC, EVP_rc2_cbc(), 80EVP_PBE_alg_add(NID_pbe_WithSHA1And128BitRC2_CBC, EVP_rc2_cbc(),
81 EVP_sha1(), PKCS12_PBE_keyivgen); 81 EVP_sha1(), PKCS12_PBE_keyivgen);
82EVP_PBE_alg_add(NID_pbe_WithSHA1And40BitRC2_CBC, EVP_rc2_40_cbc(), 82EVP_PBE_alg_add(NID_pbe_WithSHA1And40BitRC2_CBC, EVP_rc2_40_cbc(),
@@ -85,7 +85,7 @@ EVP_PBE_alg_add(NID_pbe_WithSHA1And40BitRC2_CBC, EVP_rc2_40_cbc(),
85} 85}
86 86
87int PKCS12_PBE_keyivgen (EVP_CIPHER_CTX *ctx, const char *pass, int passlen, 87int PKCS12_PBE_keyivgen (EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
88 ASN1_TYPE *param, EVP_CIPHER *cipher, EVP_MD *md, int en_de) 88 ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md, int en_de)
89{ 89{
90 PBEPARAM *pbe; 90 PBEPARAM *pbe;
91 int saltlen, iter; 91 int saltlen, iter;
@@ -117,7 +117,7 @@ int PKCS12_PBE_keyivgen (EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
117 return 0; 117 return 0;
118 } 118 }
119 PBEPARAM_free(pbe); 119 PBEPARAM_free(pbe);
120 EVP_CipherInit(ctx, cipher, key, iv, en_de); 120 EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, en_de);
121 memset(key, 0, EVP_MAX_KEY_LENGTH); 121 memset(key, 0, EVP_MAX_KEY_LENGTH);
122 memset(iv, 0, EVP_MAX_IV_LENGTH); 122 memset(iv, 0, EVP_MAX_IV_LENGTH);
123 return 1; 123 return 1;
diff --git a/src/lib/libcrypto/pkcs12/p12_crt.c b/src/lib/libcrypto/pkcs12/p12_crt.c
index a8f7b48882..4c36c643ce 100644
--- a/src/lib/libcrypto/pkcs12/p12_crt.c
+++ b/src/lib/libcrypto/pkcs12/p12_crt.c
@@ -94,7 +94,7 @@ PKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert,
94 } 94 }
95 95
96 /* Add user certificate */ 96 /* Add user certificate */
97 if(!(bag = M_PKCS12_x5092certbag(cert))) return NULL; 97 if(!(bag = PKCS12_x5092certbag(cert))) return NULL;
98 if(name && !PKCS12_add_friendlyname(bag, name, -1)) return NULL; 98 if(name && !PKCS12_add_friendlyname(bag, name, -1)) return NULL;
99 X509_digest(cert, EVP_sha1(), keyid, &keyidlen); 99 X509_digest(cert, EVP_sha1(), keyid, &keyidlen);
100 if(!PKCS12_add_localkeyid(bag, keyid, keyidlen)) return NULL; 100 if(!PKCS12_add_localkeyid(bag, keyid, keyidlen)) return NULL;
@@ -108,7 +108,7 @@ PKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert,
108 if(ca) { 108 if(ca) {
109 for(i = 0; i < sk_X509_num(ca); i++) { 109 for(i = 0; i < sk_X509_num(ca); i++) {
110 tcert = sk_X509_value(ca, i); 110 tcert = sk_X509_value(ca, i);
111 if(!(bag = M_PKCS12_x5092certbag(tcert))) return NULL; 111 if(!(bag = PKCS12_x5092certbag(tcert))) return NULL;
112 if(!sk_PKCS12_SAFEBAG_push(bags, bag)) { 112 if(!sk_PKCS12_SAFEBAG_push(bags, bag)) {
113 PKCS12err(PKCS12_F_PKCS12_CREATE,ERR_R_MALLOC_FAILURE); 113 PKCS12err(PKCS12_F_PKCS12_CREATE,ERR_R_MALLOC_FAILURE);
114 return NULL; 114 return NULL;
@@ -152,7 +152,7 @@ PKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert,
152 152
153 if(!(p12 = PKCS12_init (NID_pkcs7_data))) return NULL; 153 if(!(p12 = PKCS12_init (NID_pkcs7_data))) return NULL;
154 154
155 if(!M_PKCS12_pack_authsafes (p12, safes)) return NULL; 155 if(!PKCS12_pack_authsafes (p12, safes)) return NULL;
156 156
157 sk_PKCS7_pop_free(safes, PKCS7_free); 157 sk_PKCS7_pop_free(safes, PKCS7_free);
158 158
diff --git a/src/lib/libcrypto/pkcs12/p12_decr.c b/src/lib/libcrypto/pkcs12/p12_decr.c
index 8cd7e2f414..394af368f4 100644
--- a/src/lib/libcrypto/pkcs12/p12_decr.c
+++ b/src/lib/libcrypto/pkcs12/p12_decr.c
@@ -68,7 +68,7 @@
68 * OPENSSL_malloc'ed buffer 68 * OPENSSL_malloc'ed buffer
69 */ 69 */
70 70
71unsigned char * PKCS12_pbe_crypt (X509_ALGOR *algor, const char *pass, 71unsigned char * PKCS12_pbe_crypt(X509_ALGOR *algor, const char *pass,
72 int passlen, unsigned char *in, int inlen, unsigned char **data, 72 int passlen, unsigned char *in, int inlen, unsigned char **data,
73 int *datalen, int en_de) 73 int *datalen, int en_de)
74{ 74{
@@ -76,47 +76,48 @@ unsigned char * PKCS12_pbe_crypt (X509_ALGOR *algor, const char *pass,
76 int outlen, i; 76 int outlen, i;
77 EVP_CIPHER_CTX ctx; 77 EVP_CIPHER_CTX ctx;
78 78
79 EVP_CIPHER_CTX_init(&ctx);
79 /* Decrypt data */ 80 /* Decrypt data */
80 if (!EVP_PBE_CipherInit (algor->algorithm, pass, passlen, 81 if (!EVP_PBE_CipherInit(algor->algorithm, pass, passlen,
81 algor->parameter, &ctx, en_de)) { 82 algor->parameter, &ctx, en_de)) {
82 PKCS12err(PKCS12_F_PKCS12_PBE_CRYPT,PKCS12_R_PKCS12_ALGOR_CIPHERINIT_ERROR); 83 PKCS12err(PKCS12_F_PKCS12_PBE_CRYPT,PKCS12_R_PKCS12_ALGOR_CIPHERINIT_ERROR);
83 return NULL; 84 return NULL;
84 } 85 }
85 86
86 if(!(out = OPENSSL_malloc (inlen + EVP_CIPHER_CTX_block_size(&ctx)))) { 87 if(!(out = OPENSSL_malloc(inlen + EVP_CIPHER_CTX_block_size(&ctx)))) {
87 PKCS12err(PKCS12_F_PKCS12_PBE_CRYPT,ERR_R_MALLOC_FAILURE); 88 PKCS12err(PKCS12_F_PKCS12_PBE_CRYPT,ERR_R_MALLOC_FAILURE);
88 return NULL; 89 goto err;
89 } 90 }
90 91
91 EVP_CipherUpdate (&ctx, out, &i, in, inlen); 92 EVP_CipherUpdate(&ctx, out, &i, in, inlen);
92 outlen = i; 93 outlen = i;
93 if(!EVP_CipherFinal (&ctx, out + i, &i)) { 94 if(!EVP_CipherFinal_ex(&ctx, out + i, &i)) {
94 OPENSSL_free (out); 95 OPENSSL_free(out);
96 out = NULL;
95 PKCS12err(PKCS12_F_PKCS12_PBE_CRYPT,PKCS12_R_PKCS12_CIPHERFINAL_ERROR); 97 PKCS12err(PKCS12_F_PKCS12_PBE_CRYPT,PKCS12_R_PKCS12_CIPHERFINAL_ERROR);
96 return NULL; 98 goto err;
97 } 99 }
98 outlen += i; 100 outlen += i;
99 if (datalen) *datalen = outlen; 101 if (datalen) *datalen = outlen;
100 if (data) *data = out; 102 if (data) *data = out;
103 err:
104 EVP_CIPHER_CTX_cleanup(&ctx);
101 return out; 105 return out;
102 106
103} 107}
104 108
105/* Decrypt an OCTET STRING and decode ASN1 structure 109/* Decrypt an OCTET STRING and decode ASN1 structure
106 * if seq & 1 'obj' is a stack of structures to be encoded 110 * if zbuf set zero buffer after use.
107 * if seq & 2 zero buffer after use
108 * as a sequence.
109 */ 111 */
110 112
111char * PKCS12_decrypt_d2i (X509_ALGOR *algor, char * (*d2i)(), 113void * PKCS12_item_decrypt_d2i(X509_ALGOR *algor, const ASN1_ITEM *it,
112 void (*free_func)(void *), const char *pass, int passlen, 114 const char *pass, int passlen, ASN1_OCTET_STRING *oct, int zbuf)
113 ASN1_OCTET_STRING *oct, int seq)
114{ 115{
115 unsigned char *out, *p; 116 unsigned char *out, *p;
116 char *ret; 117 void *ret;
117 int outlen; 118 int outlen;
118 119
119 if (!PKCS12_pbe_crypt (algor, pass, passlen, oct->data, oct->length, 120 if (!PKCS12_pbe_crypt(algor, pass, passlen, oct->data, oct->length,
120 &out, &outlen, 0)) { 121 &out, &outlen, 0)) {
121 PKCS12err(PKCS12_F_PKCS12_DECRYPT_D2I,PKCS12_R_PKCS12_PBE_CRYPT_ERROR); 122 PKCS12err(PKCS12_F_PKCS12_DECRYPT_D2I,PKCS12_R_PKCS12_PBE_CRYPT_ERROR);
122 return NULL; 123 return NULL;
@@ -134,53 +135,41 @@ char * PKCS12_decrypt_d2i (X509_ALGOR *algor, char * (*d2i)(),
134 fclose(op); 135 fclose(op);
135 } 136 }
136#endif 137#endif
137 if (seq & 1) ret = (char *) d2i_ASN1_SET(NULL, &p, outlen, d2i, 138 ret = ASN1_item_d2i(NULL, &p, outlen, it);
138 free_func, V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL); 139 if (zbuf) memset(out, 0, outlen);
139 else ret = d2i(NULL, &p, outlen);
140 if (seq & 2) memset(out, 0, outlen);
141 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);
142 OPENSSL_free (out); 141 OPENSSL_free(out);
143 return ret; 142 return ret;
144} 143}
145 144
146/* Encode ASN1 structure and encrypt, return OCTET STRING 145/* Encode ASN1 structure and encrypt, return OCTET STRING
147 * if 'seq' is non-zero 'obj' is a stack of structures to be encoded 146 * if zbuf set zero encoding.
148 * as a sequence
149 */ 147 */
150 148
151ASN1_OCTET_STRING *PKCS12_i2d_encrypt (X509_ALGOR *algor, int (*i2d)(), 149ASN1_OCTET_STRING *PKCS12_item_i2d_encrypt(X509_ALGOR *algor, const ASN1_ITEM *it,
152 const char *pass, int passlen, 150 const char *pass, int passlen,
153 char *obj, int seq) 151 void *obj, int zbuf)
154{ 152{
155 ASN1_OCTET_STRING *oct; 153 ASN1_OCTET_STRING *oct;
156 unsigned char *in, *p; 154 unsigned char *in = NULL;
157 int inlen; 155 int inlen;
158 if (!(oct = M_ASN1_OCTET_STRING_new ())) { 156 if (!(oct = M_ASN1_OCTET_STRING_new ())) {
159 PKCS12err(PKCS12_F_PKCS12_I2D_ENCRYPT,ERR_R_MALLOC_FAILURE); 157 PKCS12err(PKCS12_F_PKCS12_I2D_ENCRYPT,ERR_R_MALLOC_FAILURE);
160 return NULL; 158 return NULL;
161 } 159 }
162 if (seq) inlen = i2d_ASN1_SET((STACK *)obj, NULL, i2d, V_ASN1_SEQUENCE, 160 inlen = ASN1_item_i2d(obj, &in, it);
163 V_ASN1_UNIVERSAL, IS_SEQUENCE); 161 if (!in) {
164 else inlen = i2d (obj, NULL);
165 if (!inlen) {
166 PKCS12err(PKCS12_F_PKCS12_I2D_ENCRYPT,PKCS12_R_ENCODE_ERROR); 162 PKCS12err(PKCS12_F_PKCS12_I2D_ENCRYPT,PKCS12_R_ENCODE_ERROR);
167 return NULL; 163 return NULL;
168 } 164 }
169 if (!(in = OPENSSL_malloc (inlen))) { 165 if (!PKCS12_pbe_crypt(algor, pass, passlen, in, inlen, &oct->data,
170 PKCS12err(PKCS12_F_PKCS12_I2D_ENCRYPT,ERR_R_MALLOC_FAILURE);
171 return NULL;
172 }
173 p = in;
174 if (seq) i2d_ASN1_SET((STACK *)obj, &p, i2d, V_ASN1_SEQUENCE,
175 V_ASN1_UNIVERSAL, IS_SEQUENCE);
176 else i2d (obj, &p);
177 if (!PKCS12_pbe_crypt (algor, pass, passlen, in, inlen, &oct->data,
178 &oct->length, 1)) { 166 &oct->length, 1)) {
179 PKCS12err(PKCS12_F_PKCS12_I2D_ENCRYPT,PKCS12_R_ENCRYPT_ERROR); 167 PKCS12err(PKCS12_F_PKCS12_I2D_ENCRYPT,PKCS12_R_ENCRYPT_ERROR);
180 OPENSSL_free(in); 168 OPENSSL_free(in);
181 return NULL; 169 return NULL;
182 } 170 }
183 OPENSSL_free (in); 171 if (zbuf) memset(in, 0, inlen);
172 OPENSSL_free(in);
184 return oct; 173 return oct;
185} 174}
186 175
diff --git a/src/lib/libcrypto/pkcs12/p12_init.c b/src/lib/libcrypto/pkcs12/p12_init.c
index d5d4884c82..eb837a78cf 100644
--- a/src/lib/libcrypto/pkcs12/p12_init.c
+++ b/src/lib/libcrypto/pkcs12/p12_init.c
@@ -69,15 +69,7 @@ PKCS12 *PKCS12_init (int mode)
69 PKCS12err(PKCS12_F_PKCS12_INIT,ERR_R_MALLOC_FAILURE); 69 PKCS12err(PKCS12_F_PKCS12_INIT,ERR_R_MALLOC_FAILURE);
70 return NULL; 70 return NULL;
71 } 71 }
72 if (!(pkcs12->version = M_ASN1_INTEGER_new ())) {
73 PKCS12err(PKCS12_F_PKCS12_INIT,ERR_R_MALLOC_FAILURE);
74 return NULL;
75 }
76 ASN1_INTEGER_set(pkcs12->version, 3); 72 ASN1_INTEGER_set(pkcs12->version, 3);
77 if (!(pkcs12->authsafes = PKCS7_new())) {
78 PKCS12err(PKCS12_F_PKCS12_INIT,ERR_R_MALLOC_FAILURE);
79 return NULL;
80 }
81 pkcs12->authsafes->type = OBJ_nid2obj(mode); 73 pkcs12->authsafes->type = OBJ_nid2obj(mode);
82 switch (mode) { 74 switch (mode) {
83 case NID_pkcs7_data: 75 case NID_pkcs7_data:
diff --git a/src/lib/libcrypto/pkcs12/p12_key.c b/src/lib/libcrypto/pkcs12/p12_key.c
index a4fd5b98ec..0d39ebde8c 100644
--- a/src/lib/libcrypto/pkcs12/p12_key.c
+++ b/src/lib/libcrypto/pkcs12/p12_key.c
@@ -118,6 +118,7 @@ int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt,
118 } 118 }
119#endif 119#endif
120 120
121 EVP_MD_CTX_init(&ctx);
121#ifdef DEBUG_KEYGEN 122#ifdef DEBUG_KEYGEN
122 fprintf(stderr, "KEYGEN DEBUG\n"); 123 fprintf(stderr, "KEYGEN DEBUG\n");
123 fprintf(stderr, "ID %d, ITER %d\n", id, iter); 124 fprintf(stderr, "ID %d, ITER %d\n", id, iter);
@@ -147,14 +148,14 @@ int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt,
147 for (i = 0; i < Slen; i++) *p++ = salt[i % saltlen]; 148 for (i = 0; i < Slen; i++) *p++ = salt[i % saltlen];
148 for (i = 0; i < Plen; i++) *p++ = pass[i % passlen]; 149 for (i = 0; i < Plen; i++) *p++ = pass[i % passlen];
149 for (;;) { 150 for (;;) {
150 EVP_DigestInit (&ctx, md_type); 151 EVP_DigestInit_ex(&ctx, md_type, NULL);
151 EVP_DigestUpdate (&ctx, D, v); 152 EVP_DigestUpdate(&ctx, D, v);
152 EVP_DigestUpdate (&ctx, I, Ilen); 153 EVP_DigestUpdate(&ctx, I, Ilen);
153 EVP_DigestFinal (&ctx, Ai, NULL); 154 EVP_DigestFinal_ex(&ctx, Ai, NULL);
154 for (j = 1; j < iter; j++) { 155 for (j = 1; j < iter; j++) {
155 EVP_DigestInit (&ctx, md_type); 156 EVP_DigestInit_ex(&ctx, md_type, NULL);
156 EVP_DigestUpdate (&ctx, Ai, u); 157 EVP_DigestUpdate(&ctx, Ai, u);
157 EVP_DigestFinal (&ctx, Ai, NULL); 158 EVP_DigestFinal_ex(&ctx, Ai, NULL);
158 } 159 }
159 memcpy (out, Ai, min (n, u)); 160 memcpy (out, Ai, min (n, u));
160 if (u >= n) { 161 if (u >= n) {
@@ -164,6 +165,7 @@ int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt,
164 OPENSSL_free (I); 165 OPENSSL_free (I);
165 BN_free (Ij); 166 BN_free (Ij);
166 BN_free (Bpl1); 167 BN_free (Bpl1);
168 EVP_MD_CTX_cleanup(&ctx);
167#ifdef DEBUG_KEYGEN 169#ifdef DEBUG_KEYGEN
168 fprintf(stderr, "Output KEY (length %d)\n", tmpn); 170 fprintf(stderr, "Output KEY (length %d)\n", tmpn);
169 h__dump(tmpout, tmpn); 171 h__dump(tmpout, tmpn);
diff --git a/src/lib/libcrypto/pkcs12/p12_kiss.c b/src/lib/libcrypto/pkcs12/p12_kiss.c
index 5d67f19b45..885087ad00 100644
--- a/src/lib/libcrypto/pkcs12/p12_kiss.c
+++ b/src/lib/libcrypto/pkcs12/p12_kiss.c
@@ -151,14 +151,14 @@ static int parse_pk12 (PKCS12 *p12, const char *pass, int passlen,
151 ASN1_OCTET_STRING *keyid = NULL; 151 ASN1_OCTET_STRING *keyid = NULL;
152 152
153 char keymatch = 0; 153 char keymatch = 0;
154 if (!( asafes = M_PKCS12_unpack_authsafes (p12))) return 0; 154 if (!(asafes = PKCS12_unpack_authsafes (p12))) return 0;
155 for (i = 0; i < sk_PKCS7_num (asafes); i++) { 155 for (i = 0; i < sk_PKCS7_num (asafes); i++) {
156 p7 = sk_PKCS7_value (asafes, i); 156 p7 = sk_PKCS7_value (asafes, i);
157 bagnid = OBJ_obj2nid (p7->type); 157 bagnid = OBJ_obj2nid (p7->type);
158 if (bagnid == NID_pkcs7_data) { 158 if (bagnid == NID_pkcs7_data) {
159 bags = M_PKCS12_unpack_p7data(p7); 159 bags = PKCS12_unpack_p7data(p7);
160 } else if (bagnid == NID_pkcs7_encrypted) { 160 } else if (bagnid == NID_pkcs7_encrypted) {
161 bags = M_PKCS12_unpack_p7encdata(p7, pass, passlen); 161 bags = PKCS12_unpack_p7encdata(p7, pass, passlen);
162 } else continue; 162 } else continue;
163 if (!bags) { 163 if (!bags) {
164 sk_PKCS7_pop_free(asafes, PKCS7_free); 164 sk_PKCS7_pop_free(asafes, PKCS7_free);
@@ -237,7 +237,7 @@ static int parse_bag(PKCS12_SAFEBAG *bag, const char *pass, int passlen,
237 237
238 case NID_pkcs8ShroudedKeyBag: 238 case NID_pkcs8ShroudedKeyBag:
239 if (!lkey || !pkey) return 1; 239 if (!lkey || !pkey) return 1;
240 if (!(p8 = M_PKCS12_decrypt_skey(bag, pass, passlen))) 240 if (!(p8 = PKCS12_decrypt_skey(bag, pass, passlen)))
241 return 0; 241 return 0;
242 *pkey = EVP_PKCS82PKEY(p8); 242 *pkey = EVP_PKCS82PKEY(p8);
243 PKCS8_PRIV_KEY_INFO_free(p8); 243 PKCS8_PRIV_KEY_INFO_free(p8);
@@ -248,7 +248,7 @@ static int parse_bag(PKCS12_SAFEBAG *bag, const char *pass, int passlen,
248 case NID_certBag: 248 case NID_certBag:
249 if (M_PKCS12_cert_bag_type(bag) != NID_x509Certificate ) 249 if (M_PKCS12_cert_bag_type(bag) != NID_x509Certificate )
250 return 1; 250 return 1;
251 if (!(x509 = M_PKCS12_certbag2x509(bag))) return 0; 251 if (!(x509 = PKCS12_certbag2x509(bag))) return 0;
252 if(ckid) X509_keyid_set1(x509, ckid->data, ckid->length); 252 if(ckid) X509_keyid_set1(x509, ckid->data, ckid->length);
253 if(fname) { 253 if(fname) {
254 int len; 254 int len;
diff --git a/src/lib/libcrypto/pkcs12/p12_mutl.c b/src/lib/libcrypto/pkcs12/p12_mutl.c
index 13d866da51..0fb67f74b8 100644
--- a/src/lib/libcrypto/pkcs12/p12_mutl.c
+++ b/src/lib/libcrypto/pkcs12/p12_mutl.c
@@ -56,7 +56,7 @@
56 * 56 *
57 */ 57 */
58 58
59#ifndef NO_HMAC 59#ifndef OPENSSL_NO_HMAC
60#include <stdio.h> 60#include <stdio.h>
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/hmac.h> 62#include <openssl/hmac.h>
@@ -71,6 +71,7 @@ int PKCS12_gen_mac (PKCS12 *p12, const char *pass, int passlen,
71 HMAC_CTX hmac; 71 HMAC_CTX hmac;
72 unsigned char key[PKCS12_MAC_KEY_LENGTH], *salt; 72 unsigned char key[PKCS12_MAC_KEY_LENGTH], *salt;
73 int saltlen, iter; 73 int saltlen, iter;
74
74 salt = p12->mac->salt->data; 75 salt = p12->mac->salt->data;
75 saltlen = p12->mac->salt->length; 76 saltlen = p12->mac->salt->length;
76 if (!p12->mac->iter) iter = 1; 77 if (!p12->mac->iter) iter = 1;
@@ -85,10 +86,12 @@ int PKCS12_gen_mac (PKCS12 *p12, const char *pass, int passlen,
85 PKCS12err(PKCS12_F_PKCS12_GEN_MAC,PKCS12_R_KEY_GEN_ERROR); 86 PKCS12err(PKCS12_F_PKCS12_GEN_MAC,PKCS12_R_KEY_GEN_ERROR);
86 return 0; 87 return 0;
87 } 88 }
88 HMAC_Init (&hmac, key, PKCS12_MAC_KEY_LENGTH, md_type); 89 HMAC_CTX_init(&hmac);
89 HMAC_Update (&hmac, p12->authsafes->d.data->data, 90 HMAC_Init_ex(&hmac, key, PKCS12_MAC_KEY_LENGTH, md_type, NULL);
91 HMAC_Update(&hmac, p12->authsafes->d.data->data,
90 p12->authsafes->d.data->length); 92 p12->authsafes->d.data->length);
91 HMAC_Final (&hmac, mac, maclen); 93 HMAC_Final(&hmac, mac, maclen);
94 HMAC_CTX_cleanup(&hmac);
92 return 1; 95 return 1;
93} 96}
94 97
@@ -113,7 +116,7 @@ int PKCS12_verify_mac (PKCS12 *p12, const char *pass, int passlen)
113/* Set a mac */ 116/* Set a mac */
114 117
115int PKCS12_set_mac (PKCS12 *p12, const char *pass, int passlen, 118int PKCS12_set_mac (PKCS12 *p12, const char *pass, int passlen,
116 unsigned char *salt, int saltlen, int iter, EVP_MD *md_type) 119 unsigned char *salt, int saltlen, int iter, const EVP_MD *md_type)
117{ 120{
118 unsigned char mac[EVP_MAX_MD_SIZE]; 121 unsigned char mac[EVP_MAX_MD_SIZE];
119 unsigned int maclen; 122 unsigned int maclen;
@@ -137,7 +140,7 @@ int PKCS12_set_mac (PKCS12 *p12, const char *pass, int passlen,
137 140
138/* Set up a mac structure */ 141/* Set up a mac structure */
139int PKCS12_setup_mac (PKCS12 *p12, int iter, unsigned char *salt, int saltlen, 142int PKCS12_setup_mac (PKCS12 *p12, int iter, unsigned char *salt, int saltlen,
140 EVP_MD *md_type) 143 const EVP_MD *md_type)
141{ 144{
142 if (!(p12->mac = PKCS12_MAC_DATA_new())) return PKCS12_ERROR; 145 if (!(p12->mac = PKCS12_MAC_DATA_new())) return PKCS12_ERROR;
143 if (iter > 1) { 146 if (iter > 1) {
diff --git a/src/lib/libcrypto/pkcs12/p12_npas.c b/src/lib/libcrypto/pkcs12/p12_npas.c
index 84e31a7f21..a549433eeb 100644
--- a/src/lib/libcrypto/pkcs12/p12_npas.c
+++ b/src/lib/libcrypto/pkcs12/p12_npas.c
@@ -113,15 +113,15 @@ static int newpass_p12(PKCS12 *p12, char *oldpass, char *newpass)
113 unsigned char mac[EVP_MAX_MD_SIZE]; 113 unsigned char mac[EVP_MAX_MD_SIZE];
114 unsigned int maclen; 114 unsigned int maclen;
115 115
116 if (!(asafes = M_PKCS12_unpack_authsafes(p12))) return 0; 116 if (!(asafes = PKCS12_unpack_authsafes(p12))) return 0;
117 if(!(newsafes = sk_PKCS7_new_null())) return 0; 117 if(!(newsafes = sk_PKCS7_new_null())) return 0;
118 for (i = 0; i < sk_PKCS7_num (asafes); i++) { 118 for (i = 0; i < sk_PKCS7_num (asafes); i++) {
119 p7 = sk_PKCS7_value(asafes, i); 119 p7 = sk_PKCS7_value(asafes, i);
120 bagnid = OBJ_obj2nid(p7->type); 120 bagnid = OBJ_obj2nid(p7->type);
121 if (bagnid == NID_pkcs7_data) { 121 if (bagnid == NID_pkcs7_data) {
122 bags = M_PKCS12_unpack_p7data(p7); 122 bags = PKCS12_unpack_p7data(p7);
123 } else if (bagnid == NID_pkcs7_encrypted) { 123 } else if (bagnid == NID_pkcs7_encrypted) {
124 bags = M_PKCS12_unpack_p7encdata(p7, oldpass, -1); 124 bags = PKCS12_unpack_p7encdata(p7, oldpass, -1);
125 alg_get(p7->d.encrypted->enc_data->algorithm, 125 alg_get(p7->d.encrypted->enc_data->algorithm,
126 &pbe_nid, &pbe_iter, &pbe_saltlen); 126 &pbe_nid, &pbe_iter, &pbe_saltlen);
127 } else continue; 127 } else continue;
@@ -151,7 +151,7 @@ static int newpass_p12(PKCS12 *p12, char *oldpass, char *newpass)
151 151
152 p12_data_tmp = p12->authsafes->d.data; 152 p12_data_tmp = p12->authsafes->d.data;
153 if(!(p12->authsafes->d.data = ASN1_OCTET_STRING_new())) goto saferr; 153 if(!(p12->authsafes->d.data = ASN1_OCTET_STRING_new())) goto saferr;
154 if(!M_PKCS12_pack_authsafes(p12, newsafes)) goto saferr; 154 if(!PKCS12_pack_authsafes(p12, newsafes)) goto saferr;
155 155
156 if(!PKCS12_gen_mac(p12, newpass, -1, mac, &maclen)) goto saferr; 156 if(!PKCS12_gen_mac(p12, newpass, -1, mac, &maclen)) goto saferr;
157 if(!(macnew = ASN1_OCTET_STRING_new())) goto saferr; 157 if(!(macnew = ASN1_OCTET_STRING_new())) goto saferr;
@@ -194,7 +194,7 @@ static int newpass_bag(PKCS12_SAFEBAG *bag, char *oldpass, char *newpass)
194 194
195 if(M_PKCS12_bag_type(bag) != NID_pkcs8ShroudedKeyBag) return 1; 195 if(M_PKCS12_bag_type(bag) != NID_pkcs8ShroudedKeyBag) return 1;
196 196
197 if (!(p8 = M_PKCS12_decrypt_skey(bag, oldpass, -1))) return 0; 197 if (!(p8 = PKCS8_decrypt(bag->value.shkeybag, oldpass, -1))) return 0;
198 alg_get(bag->value.shkeybag->algor, &p8_nid, &p8_iter, &p8_saltlen); 198 alg_get(bag->value.shkeybag->algor, &p8_nid, &p8_iter, &p8_saltlen);
199 if(!(p8new = PKCS8_encrypt(p8_nid, NULL, newpass, -1, NULL, p8_saltlen, 199 if(!(p8new = PKCS8_encrypt(p8_nid, NULL, newpass, -1, NULL, p8_saltlen,
200 p8_iter, p8))) return 0; 200 p8_iter, p8))) return 0;
diff --git a/src/lib/libcrypto/pkcs12/p12_p8d.c b/src/lib/libcrypto/pkcs12/p12_p8d.c
new file mode 100644
index 0000000000..3c6f377933
--- /dev/null
+++ b/src/lib/libcrypto/pkcs12/p12_p8d.c
@@ -0,0 +1,68 @@
1/* p12_p8d.c */
2/* Written by Dr Stephen N 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 <stdio.h>
60#include "cryptlib.h"
61#include <openssl/pkcs12.h>
62
63PKCS8_PRIV_KEY_INFO *PKCS8_decrypt(X509_SIG *p8, const char *pass, int passlen)
64{
65 return PKCS12_item_decrypt_d2i(p8->algor, ASN1_ITEM_rptr(PKCS8_PRIV_KEY_INFO), pass,
66 passlen, p8->digest, 1);
67}
68
diff --git a/src/lib/libcrypto/pkcs12/p12_p8e.c b/src/lib/libcrypto/pkcs12/p12_p8e.c
new file mode 100644
index 0000000000..3d47956652
--- /dev/null
+++ b/src/lib/libcrypto/pkcs12/p12_p8e.c
@@ -0,0 +1,97 @@
1/* p12_p8e.c */
2/* Written by Dr Stephen N 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 <stdio.h>
60#include "cryptlib.h"
61#include <openssl/pkcs12.h>
62
63X509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher,
64 const char *pass, int passlen,
65 unsigned char *salt, int saltlen, int iter,
66 PKCS8_PRIV_KEY_INFO *p8inf)
67{
68 X509_SIG *p8 = NULL;
69 X509_ALGOR *pbe;
70
71 if (!(p8 = X509_SIG_new())) {
72 PKCS12err(PKCS12_F_PKCS8_ENCRYPT, ERR_R_MALLOC_FAILURE);
73 goto err;
74 }
75
76 if(pbe_nid == -1) pbe = PKCS5_pbe2_set(cipher, iter, salt, saltlen);
77 else pbe = PKCS5_pbe_set(pbe_nid, iter, salt, saltlen);
78 if(!pbe) {
79 PKCS12err(PKCS12_F_PKCS8_ENCRYPT, ERR_R_ASN1_LIB);
80 goto err;
81 }
82 X509_ALGOR_free(p8->algor);
83 p8->algor = pbe;
84 M_ASN1_OCTET_STRING_free(p8->digest);
85 p8->digest = PKCS12_item_i2d_encrypt(pbe, ASN1_ITEM_rptr(PKCS8_PRIV_KEY_INFO),
86 pass, passlen, p8inf, 1);
87 if(!p8->digest) {
88 PKCS12err(PKCS12_F_PKCS8_ENCRYPT, PKCS12_R_ENCRYPT_ERROR);
89 goto err;
90 }
91
92 return p8;
93
94 err:
95 X509_SIG_free(p8);
96 return NULL;
97}
diff --git a/src/lib/libcrypto/pkcs12/p12_utl.c b/src/lib/libcrypto/pkcs12/p12_utl.c
index 2f1d1e534f..243ec76be9 100644
--- a/src/lib/libcrypto/pkcs12/p12_utl.c
+++ b/src/lib/libcrypto/pkcs12/p12_utl.c
@@ -97,26 +97,50 @@ char *uni2asc(unsigned char *uni, int unilen)
97 97
98int i2d_PKCS12_bio(BIO *bp, PKCS12 *p12) 98int i2d_PKCS12_bio(BIO *bp, PKCS12 *p12)
99{ 99{
100 return ASN1_i2d_bio((int(*)())i2d_PKCS12, bp, (unsigned char *)p12); 100 return ASN1_item_i2d_bio(ASN1_ITEM_rptr(PKCS12), bp, p12);
101} 101}
102 102
103#ifndef NO_FP_API 103#ifndef OPENSSL_NO_FP_API
104int i2d_PKCS12_fp(FILE *fp, PKCS12 *p12) 104int i2d_PKCS12_fp(FILE *fp, PKCS12 *p12)
105{ 105{
106 return ASN1_i2d_fp((int(*)())i2d_PKCS12, fp, (unsigned char *)p12); 106 return ASN1_item_i2d_fp(ASN1_ITEM_rptr(PKCS12), fp, p12);
107} 107}
108#endif 108#endif
109 109
110PKCS12 *d2i_PKCS12_bio(BIO *bp, PKCS12 **p12) 110PKCS12 *d2i_PKCS12_bio(BIO *bp, PKCS12 **p12)
111{ 111{
112 return (PKCS12 *)ASN1_d2i_bio((char *(*)())PKCS12_new, 112 return ASN1_item_d2i_bio(ASN1_ITEM_rptr(PKCS12), bp, p12);
113 (char *(*)())d2i_PKCS12, bp, (unsigned char **)p12);
114} 113}
115#ifndef NO_FP_API 114#ifndef OPENSSL_NO_FP_API
116PKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12) 115PKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12)
117{ 116{
118 return (PKCS12 *)ASN1_d2i_fp((char *(*)())PKCS12_new, 117 return ASN1_item_d2i_fp(ASN1_ITEM_rptr(PKCS12), fp, p12);
119 (char *(*)())d2i_PKCS12, fp, (unsigned char **)(p12));
120} 118}
121#endif 119#endif
122 120
121PKCS12_SAFEBAG *PKCS12_x5092certbag(X509 *x509)
122{
123 return PKCS12_item_pack_safebag(x509, ASN1_ITEM_rptr(X509),
124 NID_x509Certificate, NID_certBag);
125}
126
127PKCS12_SAFEBAG *PKCS12_x509crl2certbag(X509_CRL *crl)
128{
129 return PKCS12_item_pack_safebag(crl, ASN1_ITEM_rptr(X509_CRL),
130 NID_x509Crl, NID_crlBag);
131}
132
133X509 *PKCS12_certbag2x509(PKCS12_SAFEBAG *bag)
134{
135 if(M_PKCS12_bag_type(bag) != NID_certBag) return NULL;
136 if(M_PKCS12_cert_bag_type(bag) != NID_x509Certificate) return NULL;
137 return ASN1_item_unpack(bag->value.bag->value.octet, ASN1_ITEM_rptr(X509));
138}
139
140X509_CRL *PKCS12_certbag2x509crl(PKCS12_SAFEBAG *bag)
141{
142 if(M_PKCS12_bag_type(bag) != NID_crlBag) return NULL;
143 if(M_PKCS12_cert_bag_type(bag) != NID_x509Crl) return NULL;
144 return ASN1_item_unpack(bag->value.bag->value.octet,
145 ASN1_ITEM_rptr(X509_CRL));
146}
diff --git a/src/lib/libcrypto/pkcs12/pk12err.c b/src/lib/libcrypto/pkcs12/pk12err.c
index 12db54f49e..10ab80502c 100644
--- a/src/lib/libcrypto/pkcs12/pk12err.c
+++ b/src/lib/libcrypto/pkcs12/pk12err.c
@@ -63,7 +63,7 @@
63#include <openssl/pkcs12.h> 63#include <openssl/pkcs12.h>
64 64
65/* BEGIN ERROR CODES */ 65/* BEGIN ERROR CODES */
66#ifndef NO_ERR 66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA PKCS12_str_functs[]= 67static ERR_STRING_DATA PKCS12_str_functs[]=
68 { 68 {
69{ERR_PACK(0,PKCS12_F_PARSE_BAGS,0), "PARSE_BAGS"}, 69{ERR_PACK(0,PKCS12_F_PARSE_BAGS,0), "PARSE_BAGS"},
@@ -130,7 +130,7 @@ void ERR_load_PKCS12_strings(void)
130 if (init) 130 if (init)
131 { 131 {
132 init=0; 132 init=0;
133#ifndef NO_ERR 133#ifndef OPENSSL_NO_ERR
134 ERR_load_strings(ERR_LIB_PKCS12,PKCS12_str_functs); 134 ERR_load_strings(ERR_LIB_PKCS12,PKCS12_str_functs);
135 ERR_load_strings(ERR_LIB_PKCS12,PKCS12_str_reasons); 135 ERR_load_strings(ERR_LIB_PKCS12,PKCS12_str_reasons);
136#endif 136#endif
diff --git a/src/lib/libcrypto/pkcs12/pkcs12.h b/src/lib/libcrypto/pkcs12/pkcs12.h
index e529154f26..1786b6d4f3 100644
--- a/src/lib/libcrypto/pkcs12/pkcs12.h
+++ b/src/lib/libcrypto/pkcs12/pkcs12.h
@@ -120,7 +120,6 @@ union {
120 ASN1_TYPE *other; 120 ASN1_TYPE *other;
121}value; 121}value;
122STACK_OF(X509_ATTRIBUTE) *attrib; 122STACK_OF(X509_ATTRIBUTE) *attrib;
123ASN1_TYPE *rest;
124} PKCS12_SAFEBAG; 123} PKCS12_SAFEBAG;
125 124
126DECLARE_STACK_OF(PKCS12_SAFEBAG) 125DECLARE_STACK_OF(PKCS12_SAFEBAG)
@@ -141,55 +140,25 @@ union {
141#define PKCS12_ERROR 0 140#define PKCS12_ERROR 0
142#define PKCS12_OK 1 141#define PKCS12_OK 1
143 142
144#define M_PKCS12_bag_type(bag) OBJ_obj2nid(bag->type) 143/* Compatibility macros */
145#define M_PKCS12_cert_bag_type(bag) OBJ_obj2nid(bag->value.bag->type)
146#define M_PKCS12_crl_bag_type M_PKCS12_cert_bag_type
147
148#define M_PKCS12_x5092certbag(x509) \
149PKCS12_pack_safebag((char *)(x509), i2d_X509, NID_x509Certificate, NID_certBag)
150
151#define M_PKCS12_x509crl2certbag(crl) \
152PKCS12_pack_safebag((char *)(crl), i2d_X509CRL, NID_x509Crl, NID_crlBag)
153
154#define M_PKCS12_certbag2x509(bg) \
155(X509 *) ASN1_unpack_string((bg)->value.bag->value.octet, \
156(char *(*)())d2i_X509)
157 144
158#define M_PKCS12_certbag2x509crl(bg) \ 145#define M_PKCS12_x5092certbag PKCS12_x5092certbag
159(X509CRL *) ASN1_unpack_string((bg)->value.bag->value.octet, \ 146#define M_PKCS12_x509crl2certbag PKCS12_x509crl2certbag
160(char *(*)())d2i_X509CRL)
161 147
162/*#define M_PKCS12_pkcs82rsa(p8) \ 148#define M_PKCS12_certbag2x509 PKCS12_certbag2x509
163(RSA *) ASN1_unpack_string((p8)->pkey, (char *(*)())d2i_RSAPrivateKey)*/ 149#define M_PKCS12_certbag2x509crl PKCS12_certbag2x509crl
164 150
165#define M_PKCS12_unpack_p7data(p7) \ 151#define M_PKCS12_unpack_p7data PKCS12_unpack_p7data
166ASN1_seq_unpack_PKCS12_SAFEBAG((p7)->d.data->data, p7->d.data->length, \ 152#define M_PKCS12_pack_authsafes PKCS12_pack_authsafes
167 d2i_PKCS12_SAFEBAG, PKCS12_SAFEBAG_free) 153#define M_PKCS12_unpack_authsafes PKCS12_unpack_authsafes
154#define M_PKCS12_unpack_p7encdata PKCS12_unpack_p7encdata
168 155
169#define M_PKCS12_pack_authsafes(p12, safes) \ 156#define M_PKCS12_decrypt_skey PKCS12_decrypt_skey
170ASN1_seq_pack_PKCS7((safes), i2d_PKCS7,\ 157#define M_PKCS8_decrypt PKCS8_decrypt
171 &(p12)->authsafes->d.data->data, &(p12)->authsafes->d.data->length)
172 158
173#define M_PKCS12_unpack_authsafes(p12) \ 159#define M_PKCS12_bag_type(bag) OBJ_obj2nid(bag->type)
174ASN1_seq_unpack_PKCS7((p12)->authsafes->d.data->data, \ 160#define M_PKCS12_cert_bag_type(bag) OBJ_obj2nid(bag->value.bag->type)
175 (p12)->authsafes->d.data->length, d2i_PKCS7, PKCS7_free) 161#define M_PKCS12_crl_bag_type M_PKCS12_cert_bag_type
176
177#define M_PKCS12_unpack_p7encdata(p7, pass, passlen) \
178PKCS12_decrypt_d2i_PKCS12_SAFEBAG((p7)->d.encrypted->enc_data->algorithm,\
179 d2i_PKCS12_SAFEBAG, PKCS12_SAFEBAG_free, \
180 (pass), (passlen), \
181 (p7)->d.encrypted->enc_data->enc_data, 3)
182
183#define M_PKCS12_decrypt_skey(bag, pass, passlen) \
184(PKCS8_PRIV_KEY_INFO *) PKCS12_decrypt_d2i((bag)->value.shkeybag->algor, \
185(char *(*)())d2i_PKCS8_PRIV_KEY_INFO, (void (*)(void *))PKCS8_PRIV_KEY_INFO_free, \
186 (pass), (passlen), \
187 (bag)->value.shkeybag->digest, 2)
188
189#define M_PKCS8_decrypt(p8, pass, passlen) \
190(PKCS8_PRIV_KEY_INFO *) PKCS12_decrypt_d2i((p8)->algor, \
191(char *(*)())d2i_PKCS8_PRIV_KEY_INFO, (void (*)(void *))PKCS8_PRIV_KEY_INFO_free,\
192 (pass), (passlen), (p8)->digest, 2)
193 162
194#define PKCS12_get_attr(bag, attr_nid) \ 163#define PKCS12_get_attr(bag, attr_nid) \
195 PKCS12_get_attr_gen(bag->attrib, attr_nid) 164 PKCS12_get_attr_gen(bag->attrib, attr_nid)
@@ -200,8 +169,17 @@ PKCS12_decrypt_d2i_PKCS12_SAFEBAG((p7)->d.encrypted->enc_data->algorithm,\
200#define PKCS12_mac_present(p12) ((p12)->mac ? 1 : 0) 169#define PKCS12_mac_present(p12) ((p12)->mac ? 1 : 0)
201 170
202 171
203PKCS12_SAFEBAG *PKCS12_pack_safebag(char *obj, int (*i2d)(), int nid1, int nid2); 172PKCS12_SAFEBAG *PKCS12_x5092certbag(X509 *x509);
173PKCS12_SAFEBAG *PKCS12_x509crl2certbag(X509_CRL *crl);
174X509 *PKCS12_certbag2x509(PKCS12_SAFEBAG *bag);
175X509_CRL *PKCS12_certbag2x509crl(PKCS12_SAFEBAG *bag);
176
177PKCS12_SAFEBAG *PKCS12_item_pack_safebag(void *obj, const ASN1_ITEM *it, int nid1,
178 int nid2);
204PKCS12_SAFEBAG *PKCS12_MAKE_KEYBAG(PKCS8_PRIV_KEY_INFO *p8); 179PKCS12_SAFEBAG *PKCS12_MAKE_KEYBAG(PKCS8_PRIV_KEY_INFO *p8);
180PKCS8_PRIV_KEY_INFO *PKCS8_decrypt(X509_SIG *p8, const char *pass, int passlen);
181PKCS8_PRIV_KEY_INFO *PKCS12_decrypt_skey(PKCS12_SAFEBAG *bag, const char *pass,
182 int passlen);
205X509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher, 183X509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher,
206 const char *pass, int passlen, 184 const char *pass, int passlen,
207 unsigned char *salt, int saltlen, int iter, 185 unsigned char *salt, int saltlen, int iter,
@@ -211,12 +189,20 @@ PKCS12_SAFEBAG *PKCS12_MAKE_SHKEYBAG(int pbe_nid, const char *pass,
211 int saltlen, int iter, 189 int saltlen, int iter,
212 PKCS8_PRIV_KEY_INFO *p8); 190 PKCS8_PRIV_KEY_INFO *p8);
213PKCS7 *PKCS12_pack_p7data(STACK_OF(PKCS12_SAFEBAG) *sk); 191PKCS7 *PKCS12_pack_p7data(STACK_OF(PKCS12_SAFEBAG) *sk);
192STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7data(PKCS7 *p7);
214PKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen, 193PKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen,
215 unsigned char *salt, int saltlen, int iter, 194 unsigned char *salt, int saltlen, int iter,
216 STACK_OF(PKCS12_SAFEBAG) *bags); 195 STACK_OF(PKCS12_SAFEBAG) *bags);
196STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7encdata(PKCS7 *p7, const char *pass, int passlen);
197
198int PKCS12_pack_authsafes(PKCS12 *p12, STACK_OF(PKCS7) *safes);
199STACK_OF(PKCS7) *PKCS12_unpack_authsafes(PKCS12 *p12);
200
217int PKCS12_add_localkeyid(PKCS12_SAFEBAG *bag, unsigned char *name, int namelen); 201int PKCS12_add_localkeyid(PKCS12_SAFEBAG *bag, unsigned char *name, int namelen);
218int PKCS12_add_friendlyname_asc(PKCS12_SAFEBAG *bag, const char *name, 202int PKCS12_add_friendlyname_asc(PKCS12_SAFEBAG *bag, const char *name,
219 int namelen); 203 int namelen);
204int PKCS12_add_CSPName_asc(PKCS12_SAFEBAG *bag, const char *name,
205 int namelen);
220int PKCS12_add_friendlyname_uni(PKCS12_SAFEBAG *bag, const unsigned char *name, 206int PKCS12_add_friendlyname_uni(PKCS12_SAFEBAG *bag, const unsigned char *name,
221 int namelen); 207 int namelen);
222int PKCS8_add_keyusage(PKCS8_PRIV_KEY_INFO *p8, int usage); 208int PKCS8_add_keyusage(PKCS8_PRIV_KEY_INFO *p8, int usage);
@@ -225,49 +211,38 @@ char *PKCS12_get_friendlyname(PKCS12_SAFEBAG *bag);
225unsigned char *PKCS12_pbe_crypt(X509_ALGOR *algor, const char *pass, 211unsigned char *PKCS12_pbe_crypt(X509_ALGOR *algor, const char *pass,
226 int passlen, unsigned char *in, int inlen, 212 int passlen, unsigned char *in, int inlen,
227 unsigned char **data, int *datalen, int en_de); 213 unsigned char **data, int *datalen, int en_de);
228char *PKCS12_decrypt_d2i(X509_ALGOR *algor, char *(*d2i)(), 214void * PKCS12_item_decrypt_d2i(X509_ALGOR *algor, const ASN1_ITEM *it,
229 void (*free_func)(void *), const char *pass, int passlen, 215 const char *pass, int passlen, ASN1_OCTET_STRING *oct, int zbuf);
230 ASN1_STRING *oct, int seq); 216ASN1_OCTET_STRING *PKCS12_item_i2d_encrypt(X509_ALGOR *algor, const ASN1_ITEM *it,
231ASN1_STRING *PKCS12_i2d_encrypt(X509_ALGOR *algor, int (*i2d)(), 217 const char *pass, int passlen,
232 const char *pass, int passlen, char *obj, 218 void *obj, int zbuf);
233 int seq);
234PKCS12 *PKCS12_init(int mode); 219PKCS12 *PKCS12_init(int mode);
235int PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt, 220int PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt,
236 int saltlen, int id, int iter, int n, 221 int saltlen, int id, int iter, int n,
237 unsigned char *out, const EVP_MD *md_type); 222 unsigned char *out, const EVP_MD *md_type);
238int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt, int saltlen, int id, int iter, int n, unsigned char *out, const EVP_MD *md_type); 223int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt, int saltlen, int id, int iter, int n, unsigned char *out, const EVP_MD *md_type);
239int PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, 224int PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
240 ASN1_TYPE *param, EVP_CIPHER *cipher, EVP_MD *md_type, 225 ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md_type,
241 int en_de); 226 int en_de);
242int PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen, 227int PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen,
243 unsigned char *mac, unsigned int *maclen); 228 unsigned char *mac, unsigned int *maclen);
244int PKCS12_verify_mac(PKCS12 *p12, const char *pass, int passlen); 229int PKCS12_verify_mac(PKCS12 *p12, const char *pass, int passlen);
245int PKCS12_set_mac(PKCS12 *p12, const char *pass, int passlen, 230int PKCS12_set_mac(PKCS12 *p12, const char *pass, int passlen,
246 unsigned char *salt, int saltlen, int iter, 231 unsigned char *salt, int saltlen, int iter,
247 EVP_MD *md_type); 232 const EVP_MD *md_type);
248int PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt, 233int PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt,
249 int saltlen, EVP_MD *md_type); 234 int saltlen, const EVP_MD *md_type);
250unsigned char *asc2uni(const char *asc, int asclen, unsigned char **uni, int *unilen); 235unsigned char *asc2uni(const char *asc, int asclen, unsigned char **uni, int *unilen);
251char *uni2asc(unsigned char *uni, int unilen); 236char *uni2asc(unsigned char *uni, int unilen);
252int i2d_PKCS12_BAGS(PKCS12_BAGS *a, unsigned char **pp); 237
253PKCS12_BAGS *PKCS12_BAGS_new(void); 238DECLARE_ASN1_FUNCTIONS(PKCS12)
254PKCS12_BAGS *d2i_PKCS12_BAGS(PKCS12_BAGS **a, unsigned char **pp, long length); 239DECLARE_ASN1_FUNCTIONS(PKCS12_MAC_DATA)
255void PKCS12_BAGS_free(PKCS12_BAGS *a); 240DECLARE_ASN1_FUNCTIONS(PKCS12_SAFEBAG)
256int i2d_PKCS12(PKCS12 *a, unsigned char **pp); 241DECLARE_ASN1_FUNCTIONS(PKCS12_BAGS)
257PKCS12 *d2i_PKCS12(PKCS12 **a, unsigned char **pp, long length); 242
258PKCS12 *PKCS12_new(void); 243DECLARE_ASN1_ITEM(PKCS12_SAFEBAGS)
259void PKCS12_free(PKCS12 *a); 244DECLARE_ASN1_ITEM(PKCS12_AUTHSAFES)
260int i2d_PKCS12_MAC_DATA(PKCS12_MAC_DATA *a, unsigned char **pp); 245
261PKCS12_MAC_DATA *PKCS12_MAC_DATA_new(void);
262PKCS12_MAC_DATA *d2i_PKCS12_MAC_DATA(PKCS12_MAC_DATA **a, unsigned char **pp,
263 long length);
264void PKCS12_MAC_DATA_free(PKCS12_MAC_DATA *a);
265int i2d_PKCS12_SAFEBAG(PKCS12_SAFEBAG *a, unsigned char **pp);
266PKCS12_SAFEBAG *PKCS12_SAFEBAG_new(void);
267PKCS12_SAFEBAG *d2i_PKCS12_SAFEBAG(PKCS12_SAFEBAG **a, unsigned char **pp,
268 long length);
269void PKCS12_SAFEBAG_free(PKCS12_SAFEBAG *a);
270void ERR_load_PKCS12_strings(void);
271void PKCS12_PBE_add(void); 246void PKCS12_PBE_add(void);
272int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert, 247int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert,
273 STACK_OF(X509) **ca); 248 STACK_OF(X509) **ca);
@@ -284,6 +259,7 @@ int PKCS12_newpass(PKCS12 *p12, char *oldpass, char *newpass);
284/* The following lines are auto generated by the script mkerr.pl. Any changes 259/* The following lines are auto generated by the script mkerr.pl. Any changes
285 * made after this point may be overwritten when the script is next run. 260 * made after this point may be overwritten when the script is next run.
286 */ 261 */
262void ERR_load_PKCS12_strings(void);
287 263
288/* Error codes for the PKCS12 functions. */ 264/* Error codes for the PKCS12 functions. */
289 265
@@ -342,4 +318,3 @@ int PKCS12_newpass(PKCS12 *p12, char *oldpass, char *newpass);
342} 318}
343#endif 319#endif
344#endif 320#endif
345
diff --git a/src/lib/libcrypto/pkcs7/Makefile.ssl b/src/lib/libcrypto/pkcs7/Makefile.ssl
index 37b72f0890..3f0c3452e5 100644
--- a/src/lib/libcrypto/pkcs7/Makefile.ssl
+++ b/src/lib/libcrypto/pkcs7/Makefile.ssl
@@ -5,13 +5,14 @@
5DIR= pkcs7 5DIR= pkcs7
6TOP= ../.. 6TOP= ../..
7CC= cc 7CC= cc
8INCLUDES= -I.. -I../../include 8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g 9CFLAG=-g
10INSTALL_PREFIX= 10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl 11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl 12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl 13MAKE= make -f Makefile.ssl
14MAKEDEPEND= $(TOP)/util/domd $(TOP) 14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
15MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
16AR= ar r 17AR= ar r
17 18
@@ -25,8 +26,10 @@ TEST=
25APPS= 26APPS=
26 27
27LIB=$(TOP)/libcrypto.a 28LIB=$(TOP)/libcrypto.a
28LIBSRC= pk7_lib.c pkcs7err.c pk7_doit.c pk7_smime.c pk7_attr.c pk7_mime.c 29LIBSRC= pk7_asn1.c pk7_lib.c pkcs7err.c pk7_doit.c pk7_smime.c pk7_attr.c \
29LIBOBJ= pk7_lib.o pkcs7err.o pk7_doit.o pk7_smime.o pk7_attr.o pk7_mime.o 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
30 33
31SRC= $(LIBSRC) 34SRC= $(LIBSRC)
32 35
@@ -58,8 +61,7 @@ verify: verify.o example.o lib
58 61
59lib: $(LIBOBJ) 62lib: $(LIBOBJ)
60 $(AR) $(LIB) $(LIBOBJ) 63 $(AR) $(LIB) $(LIBOBJ)
61 @echo You may get an error following this line. Please ignore. 64 $(RANLIB) $(LIB) || echo Never mind.
62 - $(RANLIB) $(LIB)
63 @touch lib 65 @touch lib
64 66
65files: 67files:
@@ -98,121 +100,96 @@ clean:
98 100
99# DO NOT DELETE THIS LINE -- make depend depends on it. 101# DO NOT DELETE THIS LINE -- make depend depends on it.
100 102
103pk7_asn1.o: ../../e_os.h ../../include/openssl/asn1.h
104pk7_asn1.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
105pk7_asn1.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
106pk7_asn1.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
107pk7_asn1.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
108pk7_asn1.o: ../../include/openssl/err.h ../../include/openssl/evp.h
109pk7_asn1.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
110pk7_asn1.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
111pk7_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
112pk7_asn1.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
113pk7_asn1.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
114pk7_asn1.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
115pk7_asn1.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
116pk7_asn1.o: ../cryptlib.h pk7_asn1.c
101pk7_attr.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 117pk7_attr.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
102pk7_attr.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 118pk7_attr.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
103pk7_attr.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 119pk7_attr.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
104pk7_attr.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 120pk7_attr.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
105pk7_attr.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 121pk7_attr.o: ../../include/openssl/err.h ../../include/openssl/evp.h
106pk7_attr.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 122pk7_attr.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
107pk7_attr.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
108pk7_attr.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
109pk7_attr.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
110pk7_attr.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
111pk7_attr.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 123pk7_attr.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
112pk7_attr.o: ../../include/openssl/opensslv.h ../../include/openssl/pem.h 124pk7_attr.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
113pk7_attr.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h 125pk7_attr.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
114pk7_attr.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 126pk7_attr.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
115pk7_attr.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 127pk7_attr.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
116pk7_attr.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 128pk7_attr.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
117pk7_attr.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 129pk7_attr.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
118pk7_attr.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 130pk7_attr.o: pk7_attr.c
119pk7_attr.o: ../../include/openssl/x509_vfy.h 131pk7_doit.o: ../../e_os.h ../../include/openssl/asn1.h
120pk7_doit.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 132pk7_doit.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
121pk7_doit.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 133pk7_doit.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
122pk7_doit.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 134pk7_doit.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
123pk7_doit.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h 135pk7_doit.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
124pk7_doit.o: ../../include/openssl/des.h ../../include/openssl/dh.h
125pk7_doit.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
126pk7_doit.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
127pk7_doit.o: ../../include/openssl/err.h ../../include/openssl/evp.h 136pk7_doit.o: ../../include/openssl/err.h ../../include/openssl/evp.h
128pk7_doit.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 137pk7_doit.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
129pk7_doit.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 138pk7_doit.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
130pk7_doit.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 139pk7_doit.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
131pk7_doit.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 140pk7_doit.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
132pk7_doit.o: ../../include/openssl/opensslconf.h 141pk7_doit.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
133pk7_doit.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 142pk7_doit.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
134pk7_doit.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h 143pk7_doit.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
135pk7_doit.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 144pk7_doit.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
136pk7_doit.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 145pk7_doit.o: ../cryptlib.h pk7_doit.c
137pk7_doit.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 146pk7_lib.o: ../../e_os.h ../../include/openssl/asn1.h
138pk7_doit.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 147pk7_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
139pk7_doit.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 148pk7_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
140pk7_doit.o: ../../include/openssl/x509v3.h ../cryptlib.h
141pk7_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
142pk7_lib.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
143pk7_lib.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
144pk7_lib.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
145pk7_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 149pk7_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
146pk7_lib.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 150pk7_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
147pk7_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h 151pk7_lib.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
148pk7_lib.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
149pk7_lib.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
150pk7_lib.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
151pk7_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 152pk7_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
152pk7_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 153pk7_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
153pk7_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h 154pk7_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
154pk7_lib.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 155pk7_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
155pk7_lib.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 156pk7_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
156pk7_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 157pk7_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
157pk7_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 158pk7_lib.o: ../../include/openssl/x509_vfy.h ../cryptlib.h pk7_lib.c
158pk7_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 159pk7_mime.o: ../../e_os.h ../../include/openssl/asn1.h
159pk7_lib.o: ../cryptlib.h 160pk7_mime.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
160pk7_mime.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 161pk7_mime.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
161pk7_mime.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
162pk7_mime.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
163pk7_mime.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
164pk7_mime.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 162pk7_mime.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
165pk7_mime.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 163pk7_mime.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
166pk7_mime.o: ../../include/openssl/err.h ../../include/openssl/evp.h 164pk7_mime.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
167pk7_mime.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
168pk7_mime.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
169pk7_mime.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
170pk7_mime.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 165pk7_mime.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
171pk7_mime.o: ../../include/openssl/opensslconf.h 166pk7_mime.o: ../../include/openssl/opensslconf.h
172pk7_mime.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 167pk7_mime.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
173pk7_mime.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h 168pk7_mime.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
174pk7_mime.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 169pk7_mime.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
175pk7_mime.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 170pk7_mime.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
176pk7_mime.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 171pk7_mime.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
177pk7_mime.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 172pk7_mime.o: ../../include/openssl/x509_vfy.h ../cryptlib.h pk7_mime.c
178pk7_mime.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 173pk7_smime.o: ../../e_os.h ../../include/openssl/asn1.h
179pk7_mime.o: ../cryptlib.h 174pk7_smime.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
180pk7_smime.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 175pk7_smime.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
181pk7_smime.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 176pk7_smime.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
182pk7_smime.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 177pk7_smime.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
183pk7_smime.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
184pk7_smime.o: ../../include/openssl/des.h ../../include/openssl/dh.h
185pk7_smime.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
186pk7_smime.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
187pk7_smime.o: ../../include/openssl/err.h ../../include/openssl/evp.h 178pk7_smime.o: ../../include/openssl/err.h ../../include/openssl/evp.h
188pk7_smime.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 179pk7_smime.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
189pk7_smime.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 180pk7_smime.o: ../../include/openssl/objects.h
190pk7_smime.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
191pk7_smime.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
192pk7_smime.o: ../../include/openssl/opensslconf.h 181pk7_smime.o: ../../include/openssl/opensslconf.h
193pk7_smime.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 182pk7_smime.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
194pk7_smime.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 183pk7_smime.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
195pk7_smime.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 184pk7_smime.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
196pk7_smime.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 185pk7_smime.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
197pk7_smime.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 186pk7_smime.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
198pk7_smime.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 187pk7_smime.o: ../../include/openssl/x509v3.h ../cryptlib.h pk7_smime.c
199pk7_smime.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
200pk7_smime.o: ../cryptlib.h
201pkcs7err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 188pkcs7err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
202pkcs7err.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 189pkcs7err.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
203pkcs7err.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
204pkcs7err.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
205pkcs7err.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
206pkcs7err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 190pkcs7err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
207pkcs7err.o: ../../include/openssl/evp.h ../../include/openssl/idea.h 191pkcs7err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
208pkcs7err.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h 192pkcs7err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
209pkcs7err.o: ../../include/openssl/md4.h ../../include/openssl/md5.h 193pkcs7err.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
210pkcs7err.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h 194pkcs7err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
211pkcs7err.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 195pkcs7err.o: pkcs7err.c
212pkcs7err.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
213pkcs7err.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
214pkcs7err.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
215pkcs7err.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
216pkcs7err.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
217pkcs7err.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
218pkcs7err.o: ../../include/openssl/x509_vfy.h
diff --git a/src/lib/libcrypto/pkcs7/bio_ber.c b/src/lib/libcrypto/pkcs7/bio_ber.c
index 5447e69818..42331f7ab0 100644
--- a/src/lib/libcrypto/pkcs7/bio_ber.c
+++ b/src/lib/libcrypto/pkcs7/bio_ber.c
@@ -339,7 +339,7 @@ static long ber_ctrl(BIO *b, int cmd, long num, char *ptr)
339 case BIO_CTRL_RESET: 339 case BIO_CTRL_RESET:
340 ctx->ok=1; 340 ctx->ok=1;
341 ctx->finished=0; 341 ctx->finished=0;
342 EVP_CipherInit(&(ctx->cipher),NULL,NULL,NULL, 342 EVP_CipherInit_ex(&(ctx->cipher),NULL,NULL,NULL,NULL,
343 ctx->cipher.berrypt); 343 ctx->cipher.berrypt);
344 ret=BIO_ctrl(b->next_bio,cmd,num,ptr); 344 ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
345 break; 345 break;
@@ -376,7 +376,7 @@ again:
376 { 376 {
377 ctx->finished=1; 377 ctx->finished=1;
378 ctx->buf_off=0; 378 ctx->buf_off=0;
379 ret=EVP_CipherFinal(&(ctx->cipher), 379 ret=EVP_CipherFinal_ex(&(ctx->cipher),
380 (unsigned char *)ctx->buf, 380 (unsigned char *)ctx->buf,
381 &(ctx->buf_len)); 381 &(ctx->buf_len));
382 ctx->ok=(int)ret; 382 ctx->ok=(int)ret;
@@ -458,7 +458,7 @@ void BIO_set_cipher(BIO *b, EVP_CIPHER *c, unsigned char *k, unsigned char *i,
458 458
459 b->init=1; 459 b->init=1;
460 ctx=(BIO_ENC_CTX *)b->ptr; 460 ctx=(BIO_ENC_CTX *)b->ptr;
461 EVP_CipherInit(&(ctx->cipher),c,k,i,e); 461 EVP_CipherInit_ex(&(ctx->cipher),c,NULL,k,i,e);
462 462
463 if (b->callback != NULL) 463 if (b->callback != NULL)
464 b->callback(b,BIO_CB_CTRL,(char *)c,BIO_CTRL_SET,e,1L); 464 b->callback(b,BIO_CB_CTRL,(char *)c,BIO_CTRL_SET,e,1L);
diff --git a/src/lib/libcrypto/pkcs7/enc.c b/src/lib/libcrypto/pkcs7/enc.c
index 2b56c2eff3..7417f8a4e0 100644
--- a/src/lib/libcrypto/pkcs7/enc.c
+++ b/src/lib/libcrypto/pkcs7/enc.c
@@ -128,7 +128,7 @@ char *argv[];
128 PKCS7_set_type(p7,NID_pkcs7_enveloped); 128 PKCS7_set_type(p7,NID_pkcs7_enveloped);
129#endif 129#endif
130 if(!cipher) { 130 if(!cipher) {
131#ifndef NO_DES 131#ifndef OPENSSL_NO_DES
132 cipher = EVP_des_ede3_cbc(); 132 cipher = EVP_des_ede3_cbc();
133#else 133#else
134 fprintf(stderr, "No cipher selected\n"); 134 fprintf(stderr, "No cipher selected\n");
diff --git a/src/lib/libcrypto/pkcs7/example.c b/src/lib/libcrypto/pkcs7/example.c
index f6656be28e..c993947cc3 100644
--- a/src/lib/libcrypto/pkcs7/example.c
+++ b/src/lib/libcrypto/pkcs7/example.c
@@ -3,6 +3,7 @@
3#include <string.h> 3#include <string.h>
4#include <openssl/pkcs7.h> 4#include <openssl/pkcs7.h>
5#include <openssl/asn1_mac.h> 5#include <openssl/asn1_mac.h>
6#include <openssl/x509.h>
6 7
7int add_signed_time(PKCS7_SIGNER_INFO *si) 8int add_signed_time(PKCS7_SIGNER_INFO *si)
8 { 9 {
diff --git a/src/lib/libcrypto/pkcs7/pk7_asn1.c b/src/lib/libcrypto/pkcs7/pk7_asn1.c
new file mode 100644
index 0000000000..46f0fc9375
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/pk7_asn1.c
@@ -0,0 +1,213 @@
1/* pk7_asn.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) 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/asn1t.h>
62#include <openssl/pkcs7.h>
63#include <openssl/x509.h>
64
65/* PKCS#7 ASN1 module */
66
67/* This is the ANY DEFINED BY table for the top level PKCS#7 structure */
68
69ASN1_ADB_TEMPLATE(p7default) = ASN1_EXP_OPT(PKCS7, d.other, ASN1_ANY, 0);
70
71ASN1_ADB(PKCS7) = {
72 ADB_ENTRY(NID_pkcs7_data, ASN1_EXP_OPT(PKCS7, d.data, ASN1_OCTET_STRING, 0)),
73 ADB_ENTRY(NID_pkcs7_signed, ASN1_EXP_OPT(PKCS7, d.sign, PKCS7_SIGNED, 0)),
74 ADB_ENTRY(NID_pkcs7_enveloped, ASN1_EXP_OPT(PKCS7, d.enveloped, PKCS7_ENVELOPE, 0)),
75 ADB_ENTRY(NID_pkcs7_signedAndEnveloped, ASN1_EXP_OPT(PKCS7, d.signed_and_enveloped, PKCS7_SIGN_ENVELOPE, 0)),
76 ADB_ENTRY(NID_pkcs7_digest, ASN1_EXP_OPT(PKCS7, d.digest, PKCS7_DIGEST, 0)),
77 ADB_ENTRY(NID_pkcs7_encrypted, ASN1_EXP_OPT(PKCS7, d.encrypted, PKCS7_ENCRYPT, 0))
78} ASN1_ADB_END(PKCS7, 0, type, 0, &p7default_tt, NULL);
79
80ASN1_SEQUENCE(PKCS7) = {
81 ASN1_SIMPLE(PKCS7, type, ASN1_OBJECT),
82 ASN1_ADB_OBJECT(PKCS7)
83}ASN1_SEQUENCE_END(PKCS7)
84
85IMPLEMENT_ASN1_FUNCTIONS(PKCS7)
86IMPLEMENT_ASN1_DUP_FUNCTION(PKCS7)
87
88ASN1_SEQUENCE(PKCS7_SIGNED) = {
89 ASN1_SIMPLE(PKCS7_SIGNED, version, ASN1_INTEGER),
90 ASN1_SET_OF(PKCS7_SIGNED, md_algs, X509_ALGOR),
91 ASN1_SIMPLE(PKCS7_SIGNED, contents, PKCS7),
92 ASN1_IMP_SEQUENCE_OF_OPT(PKCS7_SIGNED, cert, X509, 0),
93 ASN1_IMP_SET_OF_OPT(PKCS7_SIGNED, crl, X509_CRL, 1),
94 ASN1_SET_OF(PKCS7_SIGNED, signer_info, PKCS7_SIGNER_INFO)
95} ASN1_SEQUENCE_END(PKCS7_SIGNED)
96
97IMPLEMENT_ASN1_FUNCTIONS(PKCS7_SIGNED)
98
99/* Minor tweak to operation: free up EVP_PKEY */
100static int si_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it)
101{
102 if(operation == ASN1_OP_FREE_POST) {
103 PKCS7_SIGNER_INFO *si = (PKCS7_SIGNER_INFO *)*pval;
104 EVP_PKEY_free(si->pkey);
105 }
106 return 1;
107}
108
109ASN1_SEQUENCE_cb(PKCS7_SIGNER_INFO, si_cb) = {
110 ASN1_SIMPLE(PKCS7_SIGNER_INFO, version, ASN1_INTEGER),
111 ASN1_SIMPLE(PKCS7_SIGNER_INFO, issuer_and_serial, PKCS7_ISSUER_AND_SERIAL),
112 ASN1_SIMPLE(PKCS7_SIGNER_INFO, digest_alg, X509_ALGOR),
113 /* NB this should be a SET OF but we use a SEQUENCE OF so the
114 * original order * is retained when the structure is reencoded.
115 * Since the attributes are implicitly tagged this will not affect
116 * the encoding.
117 */
118 ASN1_IMP_SEQUENCE_OF_OPT(PKCS7_SIGNER_INFO, auth_attr, X509_ATTRIBUTE, 0),
119 ASN1_SIMPLE(PKCS7_SIGNER_INFO, digest_enc_alg, X509_ALGOR),
120 ASN1_SIMPLE(PKCS7_SIGNER_INFO, enc_digest, ASN1_OCTET_STRING),
121 ASN1_IMP_SET_OF_OPT(PKCS7_SIGNER_INFO, unauth_attr, X509_ATTRIBUTE, 1)
122} ASN1_SEQUENCE_END_cb(PKCS7_SIGNER_INFO, PKCS7_SIGNER_INFO)
123
124IMPLEMENT_ASN1_FUNCTIONS(PKCS7_SIGNER_INFO)
125
126ASN1_SEQUENCE(PKCS7_ISSUER_AND_SERIAL) = {
127 ASN1_SIMPLE(PKCS7_ISSUER_AND_SERIAL, issuer, X509_NAME),
128 ASN1_SIMPLE(PKCS7_ISSUER_AND_SERIAL, serial, ASN1_INTEGER)
129} ASN1_SEQUENCE_END(PKCS7_ISSUER_AND_SERIAL)
130
131IMPLEMENT_ASN1_FUNCTIONS(PKCS7_ISSUER_AND_SERIAL)
132
133ASN1_SEQUENCE(PKCS7_ENVELOPE) = {
134 ASN1_SIMPLE(PKCS7_ENVELOPE, version, ASN1_INTEGER),
135 ASN1_SET_OF(PKCS7_ENVELOPE, recipientinfo, PKCS7_RECIP_INFO),
136 ASN1_SIMPLE(PKCS7_ENVELOPE, enc_data, PKCS7_ENC_CONTENT)
137} ASN1_SEQUENCE_END(PKCS7_ENVELOPE)
138
139IMPLEMENT_ASN1_FUNCTIONS(PKCS7_ENVELOPE)
140
141/* Minor tweak to operation: free up X509 */
142static int ri_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it)
143{
144 if(operation == ASN1_OP_FREE_POST) {
145 PKCS7_RECIP_INFO *ri = (PKCS7_RECIP_INFO *)*pval;
146 X509_free(ri->cert);
147 }
148 return 1;
149}
150
151ASN1_SEQUENCE_cb(PKCS7_RECIP_INFO, ri_cb) = {
152 ASN1_SIMPLE(PKCS7_RECIP_INFO, version, ASN1_INTEGER),
153 ASN1_SIMPLE(PKCS7_RECIP_INFO, issuer_and_serial, PKCS7_ISSUER_AND_SERIAL),
154 ASN1_SIMPLE(PKCS7_RECIP_INFO, key_enc_algor, X509_ALGOR),
155 ASN1_SIMPLE(PKCS7_RECIP_INFO, enc_key, ASN1_OCTET_STRING)
156} ASN1_SEQUENCE_END_cb(PKCS7_RECIP_INFO, PKCS7_RECIP_INFO)
157
158IMPLEMENT_ASN1_FUNCTIONS(PKCS7_RECIP_INFO)
159
160ASN1_SEQUENCE(PKCS7_ENC_CONTENT) = {
161 ASN1_SIMPLE(PKCS7_ENC_CONTENT, content_type, ASN1_OBJECT),
162 ASN1_SIMPLE(PKCS7_ENC_CONTENT, algorithm, X509_ALGOR),
163 ASN1_IMP_OPT(PKCS7_ENC_CONTENT, enc_data, ASN1_OCTET_STRING, 0)
164} ASN1_SEQUENCE_END(PKCS7_ENC_CONTENT)
165
166IMPLEMENT_ASN1_FUNCTIONS(PKCS7_ENC_CONTENT)
167
168ASN1_SEQUENCE(PKCS7_SIGN_ENVELOPE) = {
169 ASN1_SIMPLE(PKCS7_SIGN_ENVELOPE, version, ASN1_INTEGER),
170 ASN1_SET_OF(PKCS7_SIGN_ENVELOPE, recipientinfo, PKCS7_RECIP_INFO),
171 ASN1_SET_OF(PKCS7_SIGN_ENVELOPE, md_algs, X509_ALGOR),
172 ASN1_SIMPLE(PKCS7_SIGN_ENVELOPE, enc_data, PKCS7_ENC_CONTENT),
173 ASN1_IMP_SET_OF_OPT(PKCS7_SIGN_ENVELOPE, cert, X509, 0),
174 ASN1_IMP_SET_OF_OPT(PKCS7_SIGN_ENVELOPE, crl, X509_CRL, 1),
175 ASN1_SET_OF(PKCS7_SIGN_ENVELOPE, signer_info, PKCS7_SIGNER_INFO)
176} ASN1_SEQUENCE_END(PKCS7_SIGN_ENVELOPE)
177
178IMPLEMENT_ASN1_FUNCTIONS(PKCS7_SIGN_ENVELOPE)
179
180ASN1_SEQUENCE(PKCS7_ENCRYPT) = {
181 ASN1_SIMPLE(PKCS7_ENCRYPT, version, ASN1_INTEGER),
182 ASN1_SIMPLE(PKCS7_ENCRYPT, enc_data, PKCS7_ENC_CONTENT)
183} ASN1_SEQUENCE_END(PKCS7_ENCRYPT)
184
185IMPLEMENT_ASN1_FUNCTIONS(PKCS7_ENCRYPT)
186
187ASN1_SEQUENCE(PKCS7_DIGEST) = {
188 ASN1_SIMPLE(PKCS7_DIGEST, version, ASN1_INTEGER),
189 ASN1_SIMPLE(PKCS7_DIGEST, md, X509_ALGOR),
190 ASN1_SIMPLE(PKCS7_DIGEST, contents, PKCS7),
191 ASN1_SIMPLE(PKCS7_DIGEST, digest, ASN1_OCTET_STRING)
192} ASN1_SEQUENCE_END(PKCS7_DIGEST)
193
194IMPLEMENT_ASN1_FUNCTIONS(PKCS7_DIGEST)
195
196/* Specials for authenticated attributes */
197
198/* When signing attributes we want to reorder them to match the sorted
199 * encoding.
200 */
201
202ASN1_ITEM_TEMPLATE(PKCS7_ATTR_SIGN) =
203 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SET_ORDER, 0, PKCS7_ATTRIBUTES, X509_ATTRIBUTE)
204ASN1_ITEM_TEMPLATE_END(PKCS7_ATTR_SIGN)
205
206/* When verifying attributes we need to use the received order. So
207 * we use SEQUENCE OF and tag it to SET OF
208 */
209
210ASN1_ITEM_TEMPLATE(PKCS7_ATTR_VERIFY) =
211 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_IMPTAG | ASN1_TFLG_UNIVERSAL,
212 V_ASN1_SET, PKCS7_ATTRIBUTES, X509_ATTRIBUTE)
213ASN1_ITEM_TEMPLATE_END(PKCS7_ATTR_VERIFY)
diff --git a/src/lib/libcrypto/pkcs7/pk7_attr.c b/src/lib/libcrypto/pkcs7/pk7_attr.c
index 6ae264cbf9..5ff5a88b5c 100644
--- a/src/lib/libcrypto/pkcs7/pk7_attr.c
+++ b/src/lib/libcrypto/pkcs7/pk7_attr.c
@@ -1,9 +1,59 @@
1/* pk7_attr.c */ 1/* pk7_attr.c */
2/* S/MIME code. 2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
3 * Copyright (C) 1997-8 Dr S N Henson (shenson@bigfoot.com) 3 * project 2001.
4 * All Rights Reserved. 4 */
5 * Redistribution of this code without the authors permission is expressly 5/* ====================================================================
6 * prohibited. 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 *
7 */ 57 */
8 58
9#include <stdio.h> 59#include <stdio.h>
diff --git a/src/lib/libcrypto/pkcs7/pk7_doit.c b/src/lib/libcrypto/pkcs7/pk7_doit.c
index bf43d030ad..4a4ff340ce 100644
--- a/src/lib/libcrypto/pkcs7/pk7_doit.c
+++ b/src/lib/libcrypto/pkcs7/pk7_doit.c
@@ -67,6 +67,38 @@ static int add_attribute(STACK_OF(X509_ATTRIBUTE) **sk, int nid, int atrtype,
67 void *value); 67 void *value);
68static ASN1_TYPE *get_attribute(STACK_OF(X509_ATTRIBUTE) *sk, int nid); 68static ASN1_TYPE *get_attribute(STACK_OF(X509_ATTRIBUTE) *sk, int nid);
69 69
70static int PKCS7_type_is_other(PKCS7* p7)
71 {
72 int isOther=1;
73
74 int nid=OBJ_obj2nid(p7->type);
75
76 switch( nid )
77 {
78 case NID_pkcs7_data:
79 case NID_pkcs7_signed:
80 case NID_pkcs7_enveloped:
81 case NID_pkcs7_signedAndEnveloped:
82 case NID_pkcs7_digest:
83 case NID_pkcs7_encrypted:
84 isOther=0;
85 break;
86 default:
87 isOther=1;
88 }
89
90 return isOther;
91
92 }
93
94static int PKCS7_type_is_octet_string(PKCS7* p7)
95 {
96 if ( 0==PKCS7_type_is_other(p7) )
97 return 0;
98
99 return (V_ASN1_OCTET_STRING==p7->d.other->type) ? 1 : 0;
100 }
101
70BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio) 102BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio)
71 { 103 {
72 int i,j; 104 int i,j;
@@ -165,7 +197,7 @@ BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio)
165 goto err; 197 goto err;
166 xalg->algorithm = OBJ_nid2obj(EVP_CIPHER_type(evp_cipher)); 198 xalg->algorithm = OBJ_nid2obj(EVP_CIPHER_type(evp_cipher));
167 if (ivlen > 0) RAND_pseudo_bytes(iv,ivlen); 199 if (ivlen > 0) RAND_pseudo_bytes(iv,ivlen);
168 EVP_CipherInit(ctx, evp_cipher, key, iv, 1); 200 EVP_CipherInit_ex(ctx, evp_cipher, NULL, key, iv, 1);
169 201
170 if (ivlen > 0) { 202 if (ivlen > 0) {
171 if (xalg->parameter == NULL) 203 if (xalg->parameter == NULL)
@@ -219,16 +251,23 @@ BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio)
219 } 251 }
220 252
221 if (bio == NULL) { 253 if (bio == NULL) {
222 if (p7->detached) 254 if (PKCS7_is_detached(p7))
223 bio=BIO_new(BIO_s_null()); 255 bio=BIO_new(BIO_s_null());
224 else { 256 else {
225 if (PKCS7_type_is_signed(p7) && 257 if (PKCS7_type_is_signed(p7) ) {
226 PKCS7_type_is_data(p7->d.sign->contents)) { 258 if ( PKCS7_type_is_data(p7->d.sign->contents)) {
227 ASN1_OCTET_STRING *os; 259 ASN1_OCTET_STRING *os;
228 os=p7->d.sign->contents->d.data; 260 os=p7->d.sign->contents->d.data;
229 if (os->length > 0) bio = 261 if (os->length > 0)
230 BIO_new_mem_buf(os->data, os->length); 262 bio = BIO_new_mem_buf(os->data, os->length);
231 } 263 }
264 else if ( PKCS7_type_is_octet_string(p7->d.sign->contents) ) {
265 ASN1_OCTET_STRING *os;
266 os=p7->d.sign->contents->d.other->value.octet_string;
267 if (os->length > 0)
268 bio = BIO_new_mem_buf(os->data, os->length);
269 }
270 }
232 if(bio == NULL) { 271 if(bio == NULL) {
233 bio=BIO_new(BIO_s_mem()); 272 bio=BIO_new(BIO_s_mem());
234 BIO_set_mem_eof_return(bio,0); 273 BIO_set_mem_eof_return(bio,0);
@@ -391,7 +430,7 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
391 430
392 evp_ctx=NULL; 431 evp_ctx=NULL;
393 BIO_get_cipher_ctx(etmp,&evp_ctx); 432 BIO_get_cipher_ctx(etmp,&evp_ctx);
394 EVP_CipherInit(evp_ctx,evp_cipher,NULL,NULL,0); 433 EVP_CipherInit_ex(evp_ctx,evp_cipher,NULL,NULL,NULL,0);
395 if (EVP_CIPHER_asn1_to_param(evp_ctx,enc_alg->parameter) < 0) 434 if (EVP_CIPHER_asn1_to_param(evp_ctx,enc_alg->parameter) < 0)
396 goto err; 435 goto err;
397 436
@@ -407,7 +446,7 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
407 goto err; 446 goto err;
408 } 447 }
409 } 448 }
410 EVP_CipherInit(evp_ctx,NULL,tmp,NULL,0); 449 EVP_CipherInit_ex(evp_ctx,NULL,NULL,tmp,NULL,0);
411 450
412 memset(tmp,0,jj); 451 memset(tmp,0,jj);
413 452
@@ -419,7 +458,7 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
419 } 458 }
420 459
421#if 1 460#if 1
422 if (p7->detached || (in_bio != NULL)) 461 if (PKCS7_is_detached(p7) || (in_bio != NULL))
423 { 462 {
424 bio=in_bio; 463 bio=in_bio;
425 } 464 }
@@ -471,10 +510,9 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
471 EVP_MD_CTX *mdc,ctx_tmp; 510 EVP_MD_CTX *mdc,ctx_tmp;
472 STACK_OF(X509_ATTRIBUTE) *sk; 511 STACK_OF(X509_ATTRIBUTE) *sk;
473 STACK_OF(PKCS7_SIGNER_INFO) *si_sk=NULL; 512 STACK_OF(PKCS7_SIGNER_INFO) *si_sk=NULL;
474 unsigned char *p,*pp=NULL;
475 int x;
476 ASN1_OCTET_STRING *os=NULL; 513 ASN1_OCTET_STRING *os=NULL;
477 514
515 EVP_MD_CTX_init(&ctx_tmp);
478 i=OBJ_obj2nid(p7->type); 516 i=OBJ_obj2nid(p7->type);
479 p7->state=PKCS7_S_HEADER; 517 p7->state=PKCS7_S_HEADER;
480 518
@@ -528,7 +566,7 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
528 BIO_get_md_ctx(btmp,&mdc); 566 BIO_get_md_ctx(btmp,&mdc);
529 if (mdc == NULL) 567 if (mdc == NULL)
530 { 568 {
531 PKCS7err(PKCS7_F_PKCS7_DATASIGN,PKCS7_R_INTERNAL_ERROR); 569 PKCS7err(PKCS7_F_PKCS7_DATASIGN,ERR_R_INTERNAL_ERROR);
532 goto err; 570 goto err;
533 } 571 }
534 if (EVP_MD_CTX_type(mdc) == j) 572 if (EVP_MD_CTX_type(mdc) == j)
@@ -539,7 +577,7 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
539 577
540 /* We now have the EVP_MD_CTX, lets do the 578 /* We now have the EVP_MD_CTX, lets do the
541 * signing. */ 579 * signing. */
542 memcpy(&ctx_tmp,mdc,sizeof(ctx_tmp)); 580 EVP_MD_CTX_copy_ex(&ctx_tmp,mdc);
543 if (!BUF_MEM_grow(buf,EVP_PKEY_size(si->pkey))) 581 if (!BUF_MEM_grow(buf,EVP_PKEY_size(si->pkey)))
544 { 582 {
545 PKCS7err(PKCS7_F_PKCS7_DATASIGN,ERR_R_BIO_LIB); 583 PKCS7err(PKCS7_F_PKCS7_DATASIGN,ERR_R_BIO_LIB);
@@ -552,43 +590,41 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
552 * attribute and only sign the attributes */ 590 * attribute and only sign the attributes */
553 if ((sk != NULL) && (sk_X509_ATTRIBUTE_num(sk) != 0)) 591 if ((sk != NULL) && (sk_X509_ATTRIBUTE_num(sk) != 0))
554 { 592 {
555 unsigned char md_data[EVP_MAX_MD_SIZE]; 593 unsigned char md_data[EVP_MAX_MD_SIZE], *abuf=NULL;
556 unsigned int md_len; 594 unsigned int md_len, alen;
557 ASN1_OCTET_STRING *digest; 595 ASN1_OCTET_STRING *digest;
558 ASN1_UTCTIME *sign_time; 596 ASN1_UTCTIME *sign_time;
559 const EVP_MD *md_tmp; 597 const EVP_MD *md_tmp;
560 598
561 /* Add signing time */ 599 /* Add signing time if not already present */
562 sign_time=X509_gmtime_adj(NULL,0); 600 if (!PKCS7_get_signed_attribute(si,
563 PKCS7_add_signed_attribute(si, 601 NID_pkcs9_signingTime))
564 NID_pkcs9_signingTime, 602 {
565 V_ASN1_UTCTIME,sign_time); 603 sign_time=X509_gmtime_adj(NULL,0);
604 PKCS7_add_signed_attribute(si,
605 NID_pkcs9_signingTime,
606 V_ASN1_UTCTIME,sign_time);
607 }
566 608
567 /* Add digest */ 609 /* Add digest */
568 md_tmp=EVP_MD_CTX_md(&ctx_tmp); 610 md_tmp=EVP_MD_CTX_md(&ctx_tmp);
569 EVP_DigestFinal(&ctx_tmp,md_data,&md_len); 611 EVP_DigestFinal_ex(&ctx_tmp,md_data,&md_len);
570 digest=M_ASN1_OCTET_STRING_new(); 612 digest=M_ASN1_OCTET_STRING_new();
571 M_ASN1_OCTET_STRING_set(digest,md_data,md_len); 613 M_ASN1_OCTET_STRING_set(digest,md_data,md_len);
572 PKCS7_add_signed_attribute(si, 614 PKCS7_add_signed_attribute(si,
573 NID_pkcs9_messageDigest, 615 NID_pkcs9_messageDigest,
574 V_ASN1_OCTET_STRING,digest); 616 V_ASN1_OCTET_STRING,digest);
575 617
576 /* Now sign the mess */ 618 /* Now sign the attributes */
577 EVP_SignInit(&ctx_tmp,md_tmp); 619 EVP_SignInit_ex(&ctx_tmp,md_tmp,NULL);
578 x=i2d_ASN1_SET_OF_X509_ATTRIBUTE(sk,NULL, 620 alen = ASN1_item_i2d((ASN1_VALUE *)sk,&abuf,
579 i2d_X509_ATTRIBUTE, 621 ASN1_ITEM_rptr(PKCS7_ATTR_SIGN));
580 V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET); 622 if(!abuf) goto err;
581 pp=(unsigned char *)OPENSSL_malloc(x); 623 EVP_SignUpdate(&ctx_tmp,abuf,alen);
582 p=pp; 624 OPENSSL_free(abuf);
583 i2d_ASN1_SET_OF_X509_ATTRIBUTE(sk,&p,
584 i2d_X509_ATTRIBUTE,
585 V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET);
586 EVP_SignUpdate(&ctx_tmp,pp,x);
587 OPENSSL_free(pp);
588 pp=NULL;
589 } 625 }
590 626
591#ifndef NO_DSA 627#ifndef OPENSSL_NO_DSA
592 if (si->pkey->type == EVP_PKEY_DSA) 628 if (si->pkey->type == EVP_PKEY_DSA)
593 ctx_tmp.digest=EVP_dss1(); 629 ctx_tmp.digest=EVP_dss1();
594#endif 630#endif
@@ -608,7 +644,7 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
608 } 644 }
609 } 645 }
610 646
611 if (!p7->detached) 647 if (!PKCS7_is_detached(p7))
612 { 648 {
613 btmp=BIO_find_type(bio,BIO_TYPE_MEM); 649 btmp=BIO_find_type(bio,BIO_TYPE_MEM);
614 if (btmp == NULL) 650 if (btmp == NULL)
@@ -629,11 +665,9 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
629 (unsigned char *)buf_mem->data,buf_mem->length); 665 (unsigned char *)buf_mem->data,buf_mem->length);
630#endif 666#endif
631 } 667 }
632 if (pp != NULL) OPENSSL_free(pp);
633 pp=NULL;
634
635 ret=1; 668 ret=1;
636err: 669err:
670 EVP_MD_CTX_cleanup(&ctx_tmp);
637 if (buf != NULL) BUF_MEM_free(buf); 671 if (buf != NULL) BUF_MEM_free(buf);
638 return(ret); 672 return(ret);
639 } 673 }
@@ -672,7 +706,11 @@ int PKCS7_dataVerify(X509_STORE *cert_store, X509_STORE_CTX *ctx, BIO *bio,
672 } 706 }
673 707
674 /* Lets verify */ 708 /* Lets verify */
675 X509_STORE_CTX_init(ctx,cert_store,x509,cert); 709 if(!X509_STORE_CTX_init(ctx,cert_store,x509,cert))
710 {
711 PKCS7err(PKCS7_F_PKCS7_DATAVERIFY,ERR_R_X509_LIB);
712 goto err;
713 }
676 X509_STORE_CTX_set_purpose(ctx, X509_PURPOSE_SMIME_SIGN); 714 X509_STORE_CTX_set_purpose(ctx, X509_PURPOSE_SMIME_SIGN);
677 i=X509_verify_cert(ctx); 715 i=X509_verify_cert(ctx);
678 if (i <= 0) 716 if (i <= 0)
@@ -693,13 +731,14 @@ int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si,
693 { 731 {
694 ASN1_OCTET_STRING *os; 732 ASN1_OCTET_STRING *os;
695 EVP_MD_CTX mdc_tmp,*mdc; 733 EVP_MD_CTX mdc_tmp,*mdc;
696 unsigned char *pp,*p;
697 int ret=0,i; 734 int ret=0,i;
698 int md_type; 735 int md_type;
699 STACK_OF(X509_ATTRIBUTE) *sk; 736 STACK_OF(X509_ATTRIBUTE) *sk;
700 BIO *btmp; 737 BIO *btmp;
701 EVP_PKEY *pkey; 738 EVP_PKEY *pkey;
702 739
740 EVP_MD_CTX_init(&mdc_tmp);
741
703 if (!PKCS7_type_is_signed(p7) && 742 if (!PKCS7_type_is_signed(p7) &&
704 !PKCS7_type_is_signedAndEnveloped(p7)) { 743 !PKCS7_type_is_signedAndEnveloped(p7)) {
705 PKCS7err(PKCS7_F_PKCS7_SIGNATUREVERIFY, 744 PKCS7err(PKCS7_F_PKCS7_SIGNATUREVERIFY,
@@ -723,7 +762,7 @@ int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si,
723 if (mdc == NULL) 762 if (mdc == NULL)
724 { 763 {
725 PKCS7err(PKCS7_F_PKCS7_SIGNATUREVERIFY, 764 PKCS7err(PKCS7_F_PKCS7_SIGNATUREVERIFY,
726 PKCS7_R_INTERNAL_ERROR); 765 ERR_R_INTERNAL_ERROR);
727 goto err; 766 goto err;
728 } 767 }
729 if (EVP_MD_CTX_type(mdc) == md_type) 768 if (EVP_MD_CTX_type(mdc) == md_type)
@@ -733,16 +772,16 @@ int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si,
733 772
734 /* mdc is the digest ctx that we want, unless there are attributes, 773 /* mdc is the digest ctx that we want, unless there are attributes,
735 * in which case the digest is the signed attributes */ 774 * in which case the digest is the signed attributes */
736 memcpy(&mdc_tmp,mdc,sizeof(mdc_tmp)); 775 EVP_MD_CTX_copy_ex(&mdc_tmp,mdc);
737 776
738 sk=si->auth_attr; 777 sk=si->auth_attr;
739 if ((sk != NULL) && (sk_X509_ATTRIBUTE_num(sk) != 0)) 778 if ((sk != NULL) && (sk_X509_ATTRIBUTE_num(sk) != 0))
740 { 779 {
741 unsigned char md_dat[EVP_MAX_MD_SIZE]; 780 unsigned char md_dat[EVP_MAX_MD_SIZE], *abuf = NULL;
742 unsigned int md_len; 781 unsigned int md_len, alen;
743 ASN1_OCTET_STRING *message_digest; 782 ASN1_OCTET_STRING *message_digest;
744 783
745 EVP_DigestFinal(&mdc_tmp,md_dat,&md_len); 784 EVP_DigestFinal_ex(&mdc_tmp,md_dat,&md_len);
746 message_digest=PKCS7_digest_from_attributes(sk); 785 message_digest=PKCS7_digest_from_attributes(sk);
747 if (!message_digest) 786 if (!message_digest)
748 { 787 {
@@ -767,20 +806,13 @@ for (ii=0; ii<md_len; ii++) printf("%02X",md_dat[ii]); printf(" calc\n");
767 goto err; 806 goto err;
768 } 807 }
769 808
770 EVP_VerifyInit(&mdc_tmp,EVP_get_digestbynid(md_type)); 809 EVP_VerifyInit_ex(&mdc_tmp,EVP_get_digestbynid(md_type), NULL);
771 /* Note: when forming the encoding of the attributes we 810
772 * shouldn't reorder them or this will break the signature. 811 alen = ASN1_item_i2d((ASN1_VALUE *)sk, &abuf,
773 * This is done by using the IS_SEQUENCE flag. 812 ASN1_ITEM_rptr(PKCS7_ATTR_VERIFY));
774 */ 813 EVP_VerifyUpdate(&mdc_tmp, abuf, alen);
775 i=i2d_ASN1_SET_OF_X509_ATTRIBUTE(sk,NULL,i2d_X509_ATTRIBUTE,
776 V_ASN1_SET,V_ASN1_UNIVERSAL, IS_SEQUENCE);
777 pp=OPENSSL_malloc(i);
778 p=pp;
779 i2d_ASN1_SET_OF_X509_ATTRIBUTE(sk,&p,i2d_X509_ATTRIBUTE,
780 V_ASN1_SET,V_ASN1_UNIVERSAL, IS_SEQUENCE);
781 EVP_VerifyUpdate(&mdc_tmp,pp,i);
782 814
783 OPENSSL_free(pp); 815 OPENSSL_free(abuf);
784 } 816 }
785 817
786 os=si->enc_digest; 818 os=si->enc_digest;
@@ -790,7 +822,7 @@ for (ii=0; ii<md_len; ii++) printf("%02X",md_dat[ii]); printf(" calc\n");
790 ret = -1; 822 ret = -1;
791 goto err; 823 goto err;
792 } 824 }
793#ifndef NO_DSA 825#ifndef OPENSSL_NO_DSA
794 if(pkey->type == EVP_PKEY_DSA) mdc_tmp.digest=EVP_dss1(); 826 if(pkey->type == EVP_PKEY_DSA) mdc_tmp.digest=EVP_dss1();
795#endif 827#endif
796 828
@@ -806,6 +838,7 @@ for (ii=0; ii<md_len; ii++) printf("%02X",md_dat[ii]); printf(" calc\n");
806 else 838 else
807 ret=1; 839 ret=1;
808err: 840err:
841 EVP_MD_CTX_cleanup(&mdc_tmp);
809 return(ret); 842 return(ret);
810 } 843 }
811 844
@@ -847,7 +880,7 @@ static ASN1_TYPE *get_attribute(STACK_OF(X509_ATTRIBUTE) *sk, int nid)
847 xa=sk_X509_ATTRIBUTE_value(sk,i); 880 xa=sk_X509_ATTRIBUTE_value(sk,i);
848 if (OBJ_cmp(xa->object,o) == 0) 881 if (OBJ_cmp(xa->object,o) == 0)
849 { 882 {
850 if (xa->set && sk_ASN1_TYPE_num(xa->value.set)) 883 if (!xa->single && sk_ASN1_TYPE_num(xa->value.set))
851 return(sk_ASN1_TYPE_value(xa->value.set,0)); 884 return(sk_ASN1_TYPE_value(xa->value.set,0));
852 else 885 else
853 return(NULL); 886 return(NULL);
diff --git a/src/lib/libcrypto/pkcs7/pk7_lib.c b/src/lib/libcrypto/pkcs7/pk7_lib.c
index 45973fe850..c00ed6833a 100644
--- a/src/lib/libcrypto/pkcs7/pk7_lib.c
+++ b/src/lib/libcrypto/pkcs7/pk7_lib.c
@@ -84,7 +84,11 @@ long PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg)
84 case PKCS7_OP_GET_DETACHED_SIGNATURE: 84 case PKCS7_OP_GET_DETACHED_SIGNATURE:
85 if (nid == NID_pkcs7_signed) 85 if (nid == NID_pkcs7_signed)
86 { 86 {
87 ret=p7->detached; 87 if(!p7->d.sign || !p7->d.sign->contents->d.ptr)
88 ret = 1;
89 else ret = 0;
90
91 p7->detached = ret;
88 } 92 }
89 else 93 else
90 { 94 {
@@ -144,7 +148,7 @@ int PKCS7_set_type(PKCS7 *p7, int type)
144 { 148 {
145 ASN1_OBJECT *obj; 149 ASN1_OBJECT *obj;
146 150
147 PKCS7_content_free(p7); 151 /*PKCS7_content_free(p7);*/
148 obj=OBJ_nid2obj(type); /* will not fail */ 152 obj=OBJ_nid2obj(type); /* will not fail */
149 153
150 switch (type) 154 switch (type)
@@ -165,18 +169,24 @@ int PKCS7_set_type(PKCS7 *p7, int type)
165 if ((p7->d.signed_and_enveloped=PKCS7_SIGN_ENVELOPE_new()) 169 if ((p7->d.signed_and_enveloped=PKCS7_SIGN_ENVELOPE_new())
166 == NULL) goto err; 170 == NULL) goto err;
167 ASN1_INTEGER_set(p7->d.signed_and_enveloped->version,1); 171 ASN1_INTEGER_set(p7->d.signed_and_enveloped->version,1);
172 p7->d.signed_and_enveloped->enc_data->content_type
173 = OBJ_nid2obj(NID_pkcs7_data);
168 break; 174 break;
169 case NID_pkcs7_enveloped: 175 case NID_pkcs7_enveloped:
170 p7->type=obj; 176 p7->type=obj;
171 if ((p7->d.enveloped=PKCS7_ENVELOPE_new()) 177 if ((p7->d.enveloped=PKCS7_ENVELOPE_new())
172 == NULL) goto err; 178 == NULL) goto err;
173 ASN1_INTEGER_set(p7->d.enveloped->version,0); 179 ASN1_INTEGER_set(p7->d.enveloped->version,0);
180 p7->d.enveloped->enc_data->content_type
181 = OBJ_nid2obj(NID_pkcs7_data);
174 break; 182 break;
175 case NID_pkcs7_encrypted: 183 case NID_pkcs7_encrypted:
176 p7->type=obj; 184 p7->type=obj;
177 if ((p7->d.encrypted=PKCS7_ENCRYPT_new()) 185 if ((p7->d.encrypted=PKCS7_ENCRYPT_new())
178 == NULL) goto err; 186 == NULL) goto err;
179 ASN1_INTEGER_set(p7->d.encrypted->version,0); 187 ASN1_INTEGER_set(p7->d.encrypted->version,0);
188 p7->d.encrypted->enc_data->content_type
189 = OBJ_nid2obj(NID_pkcs7_data);
180 break; 190 break;
181 191
182 case NID_pkcs7_digest: 192 case NID_pkcs7_digest:
@@ -295,7 +305,7 @@ int PKCS7_add_crl(PKCS7 *p7, X509_CRL *crl)
295 } 305 }
296 306
297int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey, 307int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey,
298 EVP_MD *dgst) 308 const EVP_MD *dgst)
299 { 309 {
300 char is_dsa; 310 char is_dsa;
301 if (pkey->type == EVP_PKEY_DSA) is_dsa = 1; 311 if (pkey->type == EVP_PKEY_DSA) is_dsa = 1;
@@ -343,7 +353,7 @@ err:
343 } 353 }
344 354
345PKCS7_SIGNER_INFO *PKCS7_add_signature(PKCS7 *p7, X509 *x509, EVP_PKEY *pkey, 355PKCS7_SIGNER_INFO *PKCS7_add_signature(PKCS7 *p7, X509 *x509, EVP_PKEY *pkey,
346 EVP_MD *dgst) 356 const EVP_MD *dgst)
347 { 357 {
348 PKCS7_SIGNER_INFO *si; 358 PKCS7_SIGNER_INFO *si;
349 359
@@ -415,9 +425,7 @@ int PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509)
415 M_ASN1_INTEGER_dup(X509_get_serialNumber(x509)); 425 M_ASN1_INTEGER_dup(X509_get_serialNumber(x509));
416 426
417 X509_ALGOR_free(p7i->key_enc_algor); 427 X509_ALGOR_free(p7i->key_enc_algor);
418 p7i->key_enc_algor=(X509_ALGOR *)ASN1_dup(i2d_X509_ALGOR, 428 p7i->key_enc_algor= X509_ALGOR_dup(x509->cert_info->key->algor);
419 (char *(*)())d2i_X509_ALGOR,
420 (char *)x509->cert_info->key->algor);
421 429
422 CRYPTO_add(&x509->references,1,CRYPTO_LOCK_X509); 430 CRYPTO_add(&x509->references,1,CRYPTO_LOCK_X509);
423 p7i->cert=x509; 431 p7i->cert=x509;
diff --git a/src/lib/libcrypto/pkcs7/pk7_smime.c b/src/lib/libcrypto/pkcs7/pk7_smime.c
index 3d3214f5ee..f0d071e282 100644
--- a/src/lib/libcrypto/pkcs7/pk7_smime.c
+++ b/src/lib/libcrypto/pkcs7/pk7_smime.c
@@ -115,17 +115,17 @@ PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs,
115 PKCS7err(PKCS7_F_PKCS7_SIGN,ERR_R_MALLOC_FAILURE); 115 PKCS7err(PKCS7_F_PKCS7_SIGN,ERR_R_MALLOC_FAILURE);
116 return NULL; 116 return NULL;
117 } 117 }
118#ifndef NO_DES 118#ifndef OPENSSL_NO_DES
119 PKCS7_simple_smimecap (smcap, NID_des_ede3_cbc, -1); 119 PKCS7_simple_smimecap (smcap, NID_des_ede3_cbc, -1);
120#endif 120#endif
121#ifndef NO_RC2 121#ifndef OPENSSL_NO_RC2
122 PKCS7_simple_smimecap (smcap, NID_rc2_cbc, 128); 122 PKCS7_simple_smimecap (smcap, NID_rc2_cbc, 128);
123 PKCS7_simple_smimecap (smcap, NID_rc2_cbc, 64); 123 PKCS7_simple_smimecap (smcap, NID_rc2_cbc, 64);
124#endif 124#endif
125#ifndef NO_DES 125#ifndef OPENSSL_NO_DES
126 PKCS7_simple_smimecap (smcap, NID_des_cbc, -1); 126 PKCS7_simple_smimecap (smcap, NID_des_cbc, -1);
127#endif 127#endif
128#ifndef NO_RC2 128#ifndef OPENSSL_NO_RC2
129 PKCS7_simple_smimecap (smcap, NID_rc2_cbc, 40); 129 PKCS7_simple_smimecap (smcap, NID_rc2_cbc, 40);
130#endif 130#endif
131 PKCS7_add_attrib_smimecap (si, smcap); 131 PKCS7_add_attrib_smimecap (si, smcap);
@@ -201,11 +201,20 @@ int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
201 if (!(flags & PKCS7_NOVERIFY)) for (k = 0; k < sk_X509_num(signers); k++) { 201 if (!(flags & PKCS7_NOVERIFY)) for (k = 0; k < sk_X509_num(signers); k++) {
202 signer = sk_X509_value (signers, k); 202 signer = sk_X509_value (signers, k);
203 if (!(flags & PKCS7_NOCHAIN)) { 203 if (!(flags & PKCS7_NOCHAIN)) {
204 X509_STORE_CTX_init(&cert_ctx, store, signer, 204 if(!X509_STORE_CTX_init(&cert_ctx, store, signer,
205 p7->d.sign->cert); 205 p7->d.sign->cert))
206 {
207 PKCS7err(PKCS7_F_PKCS7_VERIFY,ERR_R_X509_LIB);
208 sk_X509_free(signers);
209 return 0;
210 }
206 X509_STORE_CTX_set_purpose(&cert_ctx, 211 X509_STORE_CTX_set_purpose(&cert_ctx,
207 X509_PURPOSE_SMIME_SIGN); 212 X509_PURPOSE_SMIME_SIGN);
208 } else X509_STORE_CTX_init (&cert_ctx, store, signer, NULL); 213 } else if(!X509_STORE_CTX_init (&cert_ctx, store, signer, NULL)) {
214 PKCS7err(PKCS7_F_PKCS7_VERIFY,ERR_R_X509_LIB);
215 sk_X509_free(signers);
216 return 0;
217 }
209 i = X509_verify_cert(&cert_ctx); 218 i = X509_verify_cert(&cert_ctx);
210 if (i <= 0) j = X509_STORE_CTX_get_error(&cert_ctx); 219 if (i <= 0) j = X509_STORE_CTX_get_error(&cert_ctx);
211 X509_STORE_CTX_cleanup(&cert_ctx); 220 X509_STORE_CTX_cleanup(&cert_ctx);
@@ -327,7 +336,7 @@ STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags)
327 336
328/* Build a complete PKCS#7 enveloped data */ 337/* Build a complete PKCS#7 enveloped data */
329 338
330PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, EVP_CIPHER *cipher, 339PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher,
331 int flags) 340 int flags)
332{ 341{
333 PKCS7 *p7; 342 PKCS7 *p7;
diff --git a/src/lib/libcrypto/pkcs7/pkcs7.h b/src/lib/libcrypto/pkcs7/pkcs7.h
index 1b817e605d..5819700a85 100644
--- a/src/lib/libcrypto/pkcs7/pkcs7.h
+++ b/src/lib/libcrypto/pkcs7/pkcs7.h
@@ -59,16 +59,18 @@
59#ifndef HEADER_PKCS7_H 59#ifndef HEADER_PKCS7_H
60#define HEADER_PKCS7_H 60#define HEADER_PKCS7_H
61 61
62#include <openssl/asn1.h>
62#include <openssl/bio.h> 63#include <openssl/bio.h>
63#include <openssl/x509.h> 64#include <openssl/e_os2.h>
64 65
65#include <openssl/symhacks.h> 66#include <openssl/symhacks.h>
67#include <openssl/ossl_typ.h>
66 68
67#ifdef __cplusplus 69#ifdef __cplusplus
68extern "C" { 70extern "C" {
69#endif 71#endif
70 72
71#ifdef WIN32 73#ifdef OPENSSL_SYS_WIN32
72/* Under Win32 thes are defined in wincrypt.h */ 74/* Under Win32 thes are defined in wincrypt.h */
73#undef PKCS7_ISSUER_AND_SERIAL 75#undef PKCS7_ISSUER_AND_SERIAL
74#undef PKCS7_SIGNER_INFO 76#undef PKCS7_SIGNER_INFO
@@ -225,6 +227,7 @@ DECLARE_PKCS12_STACK_OF(PKCS7)
225#define PKCS7_get_attributes(si) ((si)->unauth_attr) 227#define PKCS7_get_attributes(si) ((si)->unauth_attr)
226 228
227#define PKCS7_type_is_signed(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_signed) 229#define PKCS7_type_is_signed(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_signed)
230#define PKCS7_type_is_encrypted(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_encrypted)
228#define PKCS7_type_is_enveloped(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_enveloped) 231#define PKCS7_type_is_enveloped(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_enveloped)
229#define PKCS7_type_is_signedAndEnveloped(a) \ 232#define PKCS7_type_is_signedAndEnveloped(a) \
230 (OBJ_obj2nid((a)->type) == NID_pkcs7_signedAndEnveloped) 233 (OBJ_obj2nid((a)->type) == NID_pkcs7_signedAndEnveloped)
@@ -235,6 +238,8 @@ DECLARE_PKCS12_STACK_OF(PKCS7)
235#define PKCS7_get_detached(p) \ 238#define PKCS7_get_detached(p) \
236 PKCS7_ctrl(p,PKCS7_OP_GET_DETACHED_SIGNATURE,0,NULL) 239 PKCS7_ctrl(p,PKCS7_OP_GET_DETACHED_SIGNATURE,0,NULL)
237 240
241#define PKCS7_is_detached(p7) (PKCS7_type_is_signed(p7) && PKCS7_get_detached(p7))
242
238#ifdef SSLEAY_MACROS 243#ifdef SSLEAY_MACROS
239#ifndef PKCS7_ISSUER_AND_SERIAL_digest 244#ifndef PKCS7_ISSUER_AND_SERIAL_digest
240#define PKCS7_ISSUER_AND_SERIAL_digest(data,type,md,len) \ 245#define PKCS7_ISSUER_AND_SERIAL_digest(data,type,md,len) \
@@ -268,19 +273,12 @@ DECLARE_PKCS12_STACK_OF(PKCS7)
268#define SMIME_BINARY PKCS7_BINARY 273#define SMIME_BINARY PKCS7_BINARY
269#define SMIME_NOATTR PKCS7_NOATTR 274#define SMIME_NOATTR PKCS7_NOATTR
270 275
271PKCS7_ISSUER_AND_SERIAL *PKCS7_ISSUER_AND_SERIAL_new(void ); 276DECLARE_ASN1_FUNCTIONS(PKCS7_ISSUER_AND_SERIAL)
272void PKCS7_ISSUER_AND_SERIAL_free(
273 PKCS7_ISSUER_AND_SERIAL *a);
274int i2d_PKCS7_ISSUER_AND_SERIAL(
275 PKCS7_ISSUER_AND_SERIAL *a,unsigned char **pp);
276PKCS7_ISSUER_AND_SERIAL *d2i_PKCS7_ISSUER_AND_SERIAL(
277 PKCS7_ISSUER_AND_SERIAL **a,
278 unsigned char **pp, long length);
279 277
280#ifndef SSLEAY_MACROS 278#ifndef SSLEAY_MACROS
281int PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data,const EVP_MD *type, 279int PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data,const EVP_MD *type,
282 unsigned char *md,unsigned int *len); 280 unsigned char *md,unsigned int *len);
283#ifndef NO_FP_API 281#ifndef OPENSSL_NO_FP_API
284PKCS7 *d2i_PKCS7_fp(FILE *fp,PKCS7 **p7); 282PKCS7 *d2i_PKCS7_fp(FILE *fp,PKCS7 **p7);
285int i2d_PKCS7_fp(FILE *fp,PKCS7 *p7); 283int i2d_PKCS7_fp(FILE *fp,PKCS7 *p7);
286#endif 284#endif
@@ -289,71 +287,18 @@ PKCS7 *d2i_PKCS7_bio(BIO *bp,PKCS7 **p7);
289int i2d_PKCS7_bio(BIO *bp,PKCS7 *p7); 287int i2d_PKCS7_bio(BIO *bp,PKCS7 *p7);
290#endif 288#endif
291 289
292PKCS7_SIGNER_INFO *PKCS7_SIGNER_INFO_new(void); 290DECLARE_ASN1_FUNCTIONS(PKCS7_SIGNER_INFO)
293void PKCS7_SIGNER_INFO_free(PKCS7_SIGNER_INFO *a); 291DECLARE_ASN1_FUNCTIONS(PKCS7_RECIP_INFO)
294int i2d_PKCS7_SIGNER_INFO(PKCS7_SIGNER_INFO *a, 292DECLARE_ASN1_FUNCTIONS(PKCS7_SIGNED)
295 unsigned char **pp); 293DECLARE_ASN1_FUNCTIONS(PKCS7_ENC_CONTENT)
296PKCS7_SIGNER_INFO *d2i_PKCS7_SIGNER_INFO(PKCS7_SIGNER_INFO **a, 294DECLARE_ASN1_FUNCTIONS(PKCS7_ENVELOPE)
297 unsigned char **pp,long length); 295DECLARE_ASN1_FUNCTIONS(PKCS7_SIGN_ENVELOPE)
298 296DECLARE_ASN1_FUNCTIONS(PKCS7_DIGEST)
299PKCS7_RECIP_INFO *PKCS7_RECIP_INFO_new(void); 297DECLARE_ASN1_FUNCTIONS(PKCS7_ENCRYPT)
300void PKCS7_RECIP_INFO_free(PKCS7_RECIP_INFO *a); 298DECLARE_ASN1_FUNCTIONS(PKCS7)
301int i2d_PKCS7_RECIP_INFO(PKCS7_RECIP_INFO *a,
302 unsigned char **pp);
303PKCS7_RECIP_INFO *d2i_PKCS7_RECIP_INFO(PKCS7_RECIP_INFO **a,
304 unsigned char **pp,long length);
305
306PKCS7_SIGNED *PKCS7_SIGNED_new(void);
307void PKCS7_SIGNED_free(PKCS7_SIGNED *a);
308int i2d_PKCS7_SIGNED(PKCS7_SIGNED *a,
309 unsigned char **pp);
310PKCS7_SIGNED *d2i_PKCS7_SIGNED(PKCS7_SIGNED **a,
311 unsigned char **pp,long length);
312
313PKCS7_ENC_CONTENT *PKCS7_ENC_CONTENT_new(void);
314void PKCS7_ENC_CONTENT_free(PKCS7_ENC_CONTENT *a);
315int i2d_PKCS7_ENC_CONTENT(PKCS7_ENC_CONTENT *a,
316 unsigned char **pp);
317PKCS7_ENC_CONTENT *d2i_PKCS7_ENC_CONTENT(PKCS7_ENC_CONTENT **a,
318 unsigned char **pp,long length);
319
320PKCS7_ENVELOPE *PKCS7_ENVELOPE_new(void);
321void PKCS7_ENVELOPE_free(PKCS7_ENVELOPE *a);
322int i2d_PKCS7_ENVELOPE(PKCS7_ENVELOPE *a,
323 unsigned char **pp);
324PKCS7_ENVELOPE *d2i_PKCS7_ENVELOPE(PKCS7_ENVELOPE **a,
325 unsigned char **pp,long length);
326
327PKCS7_SIGN_ENVELOPE *PKCS7_SIGN_ENVELOPE_new(void);
328void PKCS7_SIGN_ENVELOPE_free(PKCS7_SIGN_ENVELOPE *a);
329int i2d_PKCS7_SIGN_ENVELOPE(PKCS7_SIGN_ENVELOPE *a,
330 unsigned char **pp);
331PKCS7_SIGN_ENVELOPE *d2i_PKCS7_SIGN_ENVELOPE(PKCS7_SIGN_ENVELOPE **a,
332 unsigned char **pp,long length);
333
334PKCS7_DIGEST *PKCS7_DIGEST_new(void);
335void PKCS7_DIGEST_free(PKCS7_DIGEST *a);
336int i2d_PKCS7_DIGEST(PKCS7_DIGEST *a,
337 unsigned char **pp);
338PKCS7_DIGEST *d2i_PKCS7_DIGEST(PKCS7_DIGEST **a,
339 unsigned char **pp,long length);
340
341PKCS7_ENCRYPT *PKCS7_ENCRYPT_new(void);
342void PKCS7_ENCRYPT_free(PKCS7_ENCRYPT *a);
343int i2d_PKCS7_ENCRYPT(PKCS7_ENCRYPT *a,
344 unsigned char **pp);
345PKCS7_ENCRYPT *d2i_PKCS7_ENCRYPT(PKCS7_ENCRYPT **a,
346 unsigned char **pp,long length);
347
348PKCS7 *PKCS7_new(void);
349void PKCS7_free(PKCS7 *a);
350void PKCS7_content_free(PKCS7 *a);
351int i2d_PKCS7(PKCS7 *a,
352 unsigned char **pp);
353PKCS7 *d2i_PKCS7(PKCS7 **a,
354 unsigned char **pp,long length);
355 299
356void ERR_load_PKCS7_strings(void); 300DECLARE_ASN1_ITEM(PKCS7_ATTR_SIGN)
301DECLARE_ASN1_ITEM(PKCS7_ATTR_VERIFY)
357 302
358 303
359long PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg); 304long PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg);
@@ -361,7 +306,7 @@ long PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg);
361int PKCS7_set_type(PKCS7 *p7, int type); 306int PKCS7_set_type(PKCS7 *p7, int type);
362int PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data); 307int PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data);
363int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey, 308int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey,
364 EVP_MD *dgst); 309 const EVP_MD *dgst);
365int PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *p7i); 310int PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *p7i);
366int PKCS7_add_certificate(PKCS7 *p7, X509 *x509); 311int PKCS7_add_certificate(PKCS7 *p7, X509 *x509);
367int PKCS7_add_crl(PKCS7 *p7, X509_CRL *x509); 312int PKCS7_add_crl(PKCS7 *p7, X509_CRL *x509);
@@ -377,7 +322,7 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert);
377 322
378 323
379PKCS7_SIGNER_INFO *PKCS7_add_signature(PKCS7 *p7, X509 *x509, 324PKCS7_SIGNER_INFO *PKCS7_add_signature(PKCS7 *p7, X509 *x509,
380 EVP_PKEY *pkey, EVP_MD *dgst); 325 EVP_PKEY *pkey, const EVP_MD *dgst);
381X509 *PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si); 326X509 *PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si);
382STACK_OF(PKCS7_SIGNER_INFO) *PKCS7_get_signer_info(PKCS7 *p7); 327STACK_OF(PKCS7_SIGNER_INFO) *PKCS7_get_signer_info(PKCS7 *p7);
383 328
@@ -404,7 +349,7 @@ PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs,
404int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store, 349int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
405 BIO *indata, BIO *out, int flags); 350 BIO *indata, BIO *out, int flags);
406STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags); 351STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags);
407PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, EVP_CIPHER *cipher, 352PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher,
408 int flags); 353 int flags);
409int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, int flags); 354int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, int flags);
410 355
@@ -422,6 +367,7 @@ int SMIME_text(BIO *in, BIO *out);
422/* The following lines are auto generated by the script mkerr.pl. Any changes 367/* The following lines are auto generated by the script mkerr.pl. Any changes
423 * made after this point may be overwritten when the script is next run. 368 * made after this point may be overwritten when the script is next run.
424 */ 369 */
370void ERR_load_PKCS7_strings(void);
425 371
426/* Error codes for the PKCS7 functions. */ 372/* Error codes for the PKCS7 functions. */
427 373
@@ -462,7 +408,6 @@ int SMIME_text(BIO *in, BIO *out);
462#define PKCS7_R_DIGEST_FAILURE 101 408#define PKCS7_R_DIGEST_FAILURE 101
463#define PKCS7_R_ERROR_ADDING_RECIPIENT 120 409#define PKCS7_R_ERROR_ADDING_RECIPIENT 120
464#define PKCS7_R_ERROR_SETTING_CIPHER 121 410#define PKCS7_R_ERROR_SETTING_CIPHER 121
465#define PKCS7_R_INTERNAL_ERROR 102
466#define PKCS7_R_INVALID_MIME_TYPE 131 411#define PKCS7_R_INVALID_MIME_TYPE 131
467#define PKCS7_R_INVALID_NULL_POINTER 143 412#define PKCS7_R_INVALID_NULL_POINTER 143
468#define PKCS7_R_MIME_NO_CONTENT_TYPE 132 413#define PKCS7_R_MIME_NO_CONTENT_TYPE 132
@@ -502,4 +447,3 @@ int SMIME_text(BIO *in, BIO *out);
502} 447}
503#endif 448#endif
504#endif 449#endif
505
diff --git a/src/lib/libcrypto/pkcs7/pkcs7err.c b/src/lib/libcrypto/pkcs7/pkcs7err.c
index 8ded8913db..5e51527a40 100644
--- a/src/lib/libcrypto/pkcs7/pkcs7err.c
+++ b/src/lib/libcrypto/pkcs7/pkcs7err.c
@@ -63,7 +63,7 @@
63#include <openssl/pkcs7.h> 63#include <openssl/pkcs7.h>
64 64
65/* BEGIN ERROR CODES */ 65/* BEGIN ERROR CODES */
66#ifndef NO_ERR 66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA PKCS7_str_functs[]= 67static ERR_STRING_DATA PKCS7_str_functs[]=
68 { 68 {
69{ERR_PACK(0,PKCS7_F_B64_READ_PKCS7,0), "B64_READ_PKCS7"}, 69{ERR_PACK(0,PKCS7_F_B64_READ_PKCS7,0), "B64_READ_PKCS7"},
@@ -105,7 +105,6 @@ static ERR_STRING_DATA PKCS7_str_reasons[]=
105{PKCS7_R_DIGEST_FAILURE ,"digest failure"}, 105{PKCS7_R_DIGEST_FAILURE ,"digest failure"},
106{PKCS7_R_ERROR_ADDING_RECIPIENT ,"error adding recipient"}, 106{PKCS7_R_ERROR_ADDING_RECIPIENT ,"error adding recipient"},
107{PKCS7_R_ERROR_SETTING_CIPHER ,"error setting cipher"}, 107{PKCS7_R_ERROR_SETTING_CIPHER ,"error setting cipher"},
108{PKCS7_R_INTERNAL_ERROR ,"internal error"},
109{PKCS7_R_INVALID_MIME_TYPE ,"invalid mime type"}, 108{PKCS7_R_INVALID_MIME_TYPE ,"invalid mime type"},
110{PKCS7_R_INVALID_NULL_POINTER ,"invalid null pointer"}, 109{PKCS7_R_INVALID_NULL_POINTER ,"invalid null pointer"},
111{PKCS7_R_MIME_NO_CONTENT_TYPE ,"mime no content type"}, 110{PKCS7_R_MIME_NO_CONTENT_TYPE ,"mime no content type"},
@@ -152,7 +151,7 @@ void ERR_load_PKCS7_strings(void)
152 if (init) 151 if (init)
153 { 152 {
154 init=0; 153 init=0;
155#ifndef NO_ERR 154#ifndef OPENSSL_NO_ERR
156 ERR_load_strings(ERR_LIB_PKCS7,PKCS7_str_functs); 155 ERR_load_strings(ERR_LIB_PKCS7,PKCS7_str_functs);
157 ERR_load_strings(ERR_LIB_PKCS7,PKCS7_str_reasons); 156 ERR_load_strings(ERR_LIB_PKCS7,PKCS7_str_reasons);
158#endif 157#endif
diff --git a/src/lib/libcrypto/pkcs7/sign.c b/src/lib/libcrypto/pkcs7/sign.c
index 22290e192c..8b59885f7e 100644
--- a/src/lib/libcrypto/pkcs7/sign.c
+++ b/src/lib/libcrypto/pkcs7/sign.c
@@ -76,16 +76,16 @@ char *argv[];
76 int i; 76 int i;
77 int nodetach=0; 77 int nodetach=0;
78 78
79#ifndef NO_MD2 79#ifndef OPENSSL_NO_MD2
80 EVP_add_digest(EVP_md2()); 80 EVP_add_digest(EVP_md2());
81#endif 81#endif
82#ifndef NO_MD5 82#ifndef OPENSSL_NO_MD5
83 EVP_add_digest(EVP_md5()); 83 EVP_add_digest(EVP_md5());
84#endif 84#endif
85#ifndef NO_SHA1 85#ifndef OPENSSL_NO_SHA1
86 EVP_add_digest(EVP_sha1()); 86 EVP_add_digest(EVP_sha1());
87#endif 87#endif
88#ifndef NO_MDC2 88#ifndef OPENSSL_NO_MDC2
89 EVP_add_digest(EVP_mdc2()); 89 EVP_add_digest(EVP_mdc2());
90#endif 90#endif
91 91
diff --git a/src/lib/libcrypto/pkcs7/verify.c b/src/lib/libcrypto/pkcs7/verify.c
index 49fc8d8bed..5f7afe8933 100644
--- a/src/lib/libcrypto/pkcs7/verify.c
+++ b/src/lib/libcrypto/pkcs7/verify.c
@@ -85,16 +85,16 @@ char *argv[];
85 85
86 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); 86 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
87 bio_out=BIO_new_fp(stdout,BIO_NOCLOSE); 87 bio_out=BIO_new_fp(stdout,BIO_NOCLOSE);
88#ifndef NO_MD2 88#ifndef OPENSSL_NO_MD2
89 EVP_add_digest(EVP_md2()); 89 EVP_add_digest(EVP_md2());
90#endif 90#endif
91#ifndef NO_MD5 91#ifndef OPENSSL_NO_MD5
92 EVP_add_digest(EVP_md5()); 92 EVP_add_digest(EVP_md5());
93#endif 93#endif
94#ifndef NO_SHA1 94#ifndef OPENSSL_NO_SHA1
95 EVP_add_digest(EVP_sha1()); 95 EVP_add_digest(EVP_sha1());
96#endif 96#endif
97#ifndef NO_MDC2 97#ifndef OPENSSL_NO_MDC2
98 EVP_add_digest(EVP_mdc2()); 98 EVP_add_digest(EVP_mdc2());
99#endif 99#endif
100 100
diff --git a/src/lib/libcrypto/rand/Makefile.ssl b/src/lib/libcrypto/rand/Makefile.ssl
index 707eaac678..42623d18d8 100644
--- a/src/lib/libcrypto/rand/Makefile.ssl
+++ b/src/lib/libcrypto/rand/Makefile.ssl
@@ -11,7 +11,8 @@ INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl 11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl 12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl 13MAKE= make -f Makefile.ssl
14MAKEDEPEND= $(TOP)/util/domd $(TOP) 14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
15MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
16AR= ar r 17AR= ar r
17 18
@@ -22,8 +23,10 @@ TEST= randtest.c
22APPS= 23APPS=
23 24
24LIB=$(TOP)/libcrypto.a 25LIB=$(TOP)/libcrypto.a
25LIBSRC=md_rand.c randfile.c rand_lib.c rand_err.c rand_egd.c rand_win.c 26LIBSRC=md_rand.c randfile.c rand_lib.c rand_err.c rand_egd.c \
26LIBOBJ=md_rand.o randfile.o rand_lib.o rand_err.o rand_egd.o rand_win.o 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
27 30
28SRC= $(LIBSRC) 31SRC= $(LIBSRC)
29 32
@@ -39,8 +42,7 @@ all: lib
39 42
40lib: $(LIBOBJ) 43lib: $(LIBOBJ)
41 $(AR) $(LIB) $(LIBOBJ) 44 $(AR) $(LIB) $(LIBOBJ)
42 @echo You may get an error following this line. Please ignore. 45 $(RANLIB) $(LIB) || echo Never mind.
43 - $(RANLIB) $(LIB)
44 @touch lib 46 @touch lib
45 47
46files: 48files:
@@ -79,45 +81,77 @@ clean:
79 81
80# DO NOT DELETE THIS LINE -- make depend depends on it. 82# DO NOT DELETE THIS LINE -- make depend depends on it.
81 83
82md_rand.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h 84md_rand.o: ../../e_os.h ../../include/openssl/asn1.h
83md_rand.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 85md_rand.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
84md_rand.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 86md_rand.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
85md_rand.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 87md_rand.o: ../../include/openssl/err.h ../../include/openssl/evp.h
88md_rand.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
89md_rand.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
90md_rand.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
86md_rand.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h 91md_rand.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
87md_rand.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 92md_rand.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
88md_rand.o: ../../include/openssl/symhacks.h rand_lcl.h 93md_rand.o: ../../include/openssl/symhacks.h md_rand.c rand_lcl.h
89rand_egd.o: ../../include/openssl/opensslconf.h ../../include/openssl/rand.h 94rand_egd.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
95rand_egd.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
96rand_egd.o: rand_egd.c
90rand_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h 97rand_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
91rand_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 98rand_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
92rand_err.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 99rand_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
93rand_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 100rand_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
94rand_err.o: ../../include/openssl/symhacks.h 101rand_err.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
95rand_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 102rand_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
96rand_lib.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 103rand_err.o: rand_err.c
97rand_lib.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h 104rand_lib.o: ../../e_os.h ../../include/openssl/asn1.h
98rand_lib.o: ../../include/openssl/des.h ../../include/openssl/dh.h 105rand_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
99rand_lib.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h 106rand_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
100rand_lib.o: ../../include/openssl/engine.h ../../include/openssl/evp.h 107rand_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
101rand_lib.o: ../../include/openssl/idea.h ../../include/openssl/md2.h 108rand_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
102rand_lib.o: ../../include/openssl/md4.h ../../include/openssl/md5.h 109rand_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
103rand_lib.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h 110rand_lib.o: ../../include/openssl/opensslconf.h
104rand_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 111rand_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
105rand_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 112rand_lib.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
106rand_lib.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 113rand_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
107rand_lib.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 114rand_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
108rand_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 115rand_lib.o: ../cryptlib.h rand_lib.c
109rand_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 116rand_os2.o: ../../e_os.h ../../include/openssl/asn1.h
110rand_lib.o: ../../include/openssl/symhacks.h 117rand_os2.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
111rand_win.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 118rand_os2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
112rand_win.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 119rand_os2.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
120rand_os2.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
121rand_os2.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
122rand_os2.o: ../../include/openssl/opensslconf.h
123rand_os2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
124rand_os2.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
125rand_os2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
126rand_os2.o: ../../include/openssl/symhacks.h ../cryptlib.h rand_lcl.h
127rand_os2.o: rand_os2.c
128rand_unix.o: ../../e_os.h ../../include/openssl/asn1.h
129rand_unix.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
130rand_unix.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
131rand_unix.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
132rand_unix.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
133rand_unix.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
134rand_unix.o: ../../include/openssl/opensslconf.h
135rand_unix.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
136rand_unix.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
137rand_unix.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
138rand_unix.o: ../../include/openssl/symhacks.h ../cryptlib.h rand_lcl.h
139rand_unix.o: rand_unix.c
140rand_win.o: ../../e_os.h ../../include/openssl/asn1.h
141rand_win.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
142rand_win.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
113rand_win.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 143rand_win.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
114rand_win.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 144rand_win.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
115rand_win.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 145rand_win.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
116rand_win.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 146rand_win.o: ../../include/openssl/opensslconf.h
117rand_win.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 147rand_win.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
118rand_win.o: ../cryptlib.h rand_lcl.h 148rand_win.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
119randfile.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 149rand_win.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
150rand_win.o: ../../include/openssl/symhacks.h ../cryptlib.h rand_lcl.h
151rand_win.o: rand_win.c
152randfile.o: ../../e_os.h ../../include/openssl/crypto.h
120randfile.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h 153randfile.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
121randfile.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 154randfile.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
122randfile.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 155randfile.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
123randfile.o: ../../include/openssl/symhacks.h 156randfile.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
157randfile.o: randfile.c
diff --git a/src/lib/libcrypto/rand/md_rand.c b/src/lib/libcrypto/rand/md_rand.c
index 04b9d695b0..a00ed70718 100644
--- a/src/lib/libcrypto/rand/md_rand.c
+++ b/src/lib/libcrypto/rand/md_rand.c
@@ -56,7 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58/* ==================================================================== 58/* ====================================================================
59 * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. 59 * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.
60 * 60 *
61 * Redistribution and use in source and binary forms, with or without 61 * Redistribution and use in source and binary forms, with or without
62 * modification, are permitted provided that the following conditions 62 * modification, are permitted provided that the following conditions
@@ -119,7 +119,7 @@
119#include <stdio.h> 119#include <stdio.h>
120#include <string.h> 120#include <string.h>
121 121
122#include "openssl/e_os.h" 122#include "e_os.h"
123 123
124#include <openssl/rand.h> 124#include <openssl/rand.h>
125#include "rand_lcl.h" 125#include "rand_lcl.h"
@@ -144,6 +144,7 @@ static int initialized=0;
144static unsigned int crypto_lock_rand = 0; /* may be set only when a thread 144static unsigned int crypto_lock_rand = 0; /* may be set only when a thread
145 * holds CRYPTO_LOCK_RAND 145 * holds CRYPTO_LOCK_RAND
146 * (to prevent double locking) */ 146 * (to prevent double locking) */
147/* access to lockin_thread is synchronized by CRYPTO_LOCK_RAND2 */
147static unsigned long locking_thread = 0; /* valid iff crypto_lock_rand is set */ 148static unsigned long locking_thread = 0; /* valid iff crypto_lock_rand is set */
148 149
149 150
@@ -191,7 +192,7 @@ static void ssleay_rand_add(const void *buf, int num, double add)
191 int i,j,k,st_idx; 192 int i,j,k,st_idx;
192 long md_c[2]; 193 long md_c[2];
193 unsigned char local_md[MD_DIGEST_LENGTH]; 194 unsigned char local_md[MD_DIGEST_LENGTH];
194 MD_CTX m; 195 EVP_MD_CTX m;
195 int do_not_lock; 196 int do_not_lock;
196 197
197 /* 198 /*
@@ -210,7 +211,14 @@ static void ssleay_rand_add(const void *buf, int num, double add)
210 */ 211 */
211 212
212 /* check if we already have the lock */ 213 /* check if we already have the lock */
213 do_not_lock = crypto_lock_rand && (locking_thread == CRYPTO_thread_id()); 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;
214 222
215 if (!do_not_lock) CRYPTO_w_lock(CRYPTO_LOCK_RAND); 223 if (!do_not_lock) CRYPTO_w_lock(CRYPTO_LOCK_RAND);
216 st_idx=state_index; 224 st_idx=state_index;
@@ -246,6 +254,7 @@ static void ssleay_rand_add(const void *buf, int num, double add)
246 254
247 if (!do_not_lock) CRYPTO_w_unlock(CRYPTO_LOCK_RAND); 255 if (!do_not_lock) CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
248 256
257 EVP_MD_CTX_init(&m);
249 for (i=0; i<num; i+=MD_DIGEST_LENGTH) 258 for (i=0; i<num; i+=MD_DIGEST_LENGTH)
250 { 259 {
251 j=(num-i); 260 j=(num-i);
@@ -264,7 +273,7 @@ static void ssleay_rand_add(const void *buf, int num, double add)
264 273
265 MD_Update(&m,buf,j); 274 MD_Update(&m,buf,j);
266 MD_Update(&m,(unsigned char *)&(md_c[0]),sizeof(md_c)); 275 MD_Update(&m,(unsigned char *)&(md_c[0]),sizeof(md_c));
267 MD_Final(local_md,&m); 276 MD_Final(&m,local_md);
268 md_c[1]++; 277 md_c[1]++;
269 278
270 buf=(const char *)buf + j; 279 buf=(const char *)buf + j;
@@ -284,7 +293,7 @@ static void ssleay_rand_add(const void *buf, int num, double add)
284 st_idx=0; 293 st_idx=0;
285 } 294 }
286 } 295 }
287 memset((char *)&m,0,sizeof(m)); 296 EVP_MD_CTX_cleanup(&m);
288 297
289 if (!do_not_lock) CRYPTO_w_lock(CRYPTO_LOCK_RAND); 298 if (!do_not_lock) CRYPTO_w_lock(CRYPTO_LOCK_RAND);
290 /* Don't just copy back local_md into md -- this could mean that 299 /* Don't just copy back local_md into md -- this could mean that
@@ -299,7 +308,7 @@ static void ssleay_rand_add(const void *buf, int num, double add)
299 entropy += add; 308 entropy += add;
300 if (!do_not_lock) CRYPTO_w_unlock(CRYPTO_LOCK_RAND); 309 if (!do_not_lock) CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
301 310
302#if !defined(THREADS) && !defined(WIN32) 311#if !defined(OPENSSL_THREADS) && !defined(OPENSSL_SYS_WIN32)
303 assert(md_c[1] == md_count[1]); 312 assert(md_c[1] == md_count[1]);
304#endif 313#endif
305 } 314 }
@@ -317,7 +326,7 @@ static int ssleay_rand_bytes(unsigned char *buf, int num)
317 int ok; 326 int ok;
318 long md_c[2]; 327 long md_c[2];
319 unsigned char local_md[MD_DIGEST_LENGTH]; 328 unsigned char local_md[MD_DIGEST_LENGTH];
320 MD_CTX m; 329 EVP_MD_CTX m;
321#ifndef GETPID_IS_MEANINGLESS 330#ifndef GETPID_IS_MEANINGLESS
322 pid_t curr_pid = getpid(); 331 pid_t curr_pid = getpid();
323#endif 332#endif
@@ -336,7 +345,8 @@ static int ssleay_rand_bytes(unsigned char *buf, int num)
336 345
337 if (num <= 0) 346 if (num <= 0)
338 return 1; 347 return 1;
339 348
349 EVP_MD_CTX_init(&m);
340 /* round upwards to multiple of MD_DIGEST_LENGTH/2 */ 350 /* round upwards to multiple of MD_DIGEST_LENGTH/2 */
341 num_ceil = (1 + (num-1)/(MD_DIGEST_LENGTH/2)) * (MD_DIGEST_LENGTH/2); 351 num_ceil = (1 + (num-1)/(MD_DIGEST_LENGTH/2)) * (MD_DIGEST_LENGTH/2);
342 352
@@ -361,8 +371,10 @@ static int ssleay_rand_bytes(unsigned char *buf, int num)
361 CRYPTO_w_lock(CRYPTO_LOCK_RAND); 371 CRYPTO_w_lock(CRYPTO_LOCK_RAND);
362 372
363 /* prevent ssleay_rand_bytes() from trying to obtain the lock again */ 373 /* prevent ssleay_rand_bytes() from trying to obtain the lock again */
364 crypto_lock_rand = 1; 374 CRYPTO_w_lock(CRYPTO_LOCK_RAND2);
365 locking_thread = CRYPTO_thread_id(); 375 locking_thread = CRYPTO_thread_id();
376 CRYPTO_w_unlock(CRYPTO_LOCK_RAND2);
377 crypto_lock_rand = 1;
366 378
367 if (!initialized) 379 if (!initialized)
368 { 380 {
@@ -435,7 +447,6 @@ static int ssleay_rand_bytes(unsigned char *buf, int num)
435 447
436 /* before unlocking, we must clear 'crypto_lock_rand' */ 448 /* before unlocking, we must clear 'crypto_lock_rand' */
437 crypto_lock_rand = 0; 449 crypto_lock_rand = 0;
438 locking_thread = 0;
439 CRYPTO_w_unlock(CRYPTO_LOCK_RAND); 450 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
440 451
441 while (num > 0) 452 while (num > 0)
@@ -464,7 +475,7 @@ static int ssleay_rand_bytes(unsigned char *buf, int num)
464 } 475 }
465 else 476 else
466 MD_Update(&m,&(state[st_idx]),MD_DIGEST_LENGTH/2); 477 MD_Update(&m,&(state[st_idx]),MD_DIGEST_LENGTH/2);
467 MD_Final(local_md,&m); 478 MD_Final(&m,local_md);
468 479
469 for (i=0; i<MD_DIGEST_LENGTH/2; i++) 480 for (i=0; i<MD_DIGEST_LENGTH/2; i++)
470 { 481 {
@@ -481,10 +492,10 @@ static int ssleay_rand_bytes(unsigned char *buf, int num)
481 MD_Update(&m,local_md,MD_DIGEST_LENGTH); 492 MD_Update(&m,local_md,MD_DIGEST_LENGTH);
482 CRYPTO_w_lock(CRYPTO_LOCK_RAND); 493 CRYPTO_w_lock(CRYPTO_LOCK_RAND);
483 MD_Update(&m,md,MD_DIGEST_LENGTH); 494 MD_Update(&m,md,MD_DIGEST_LENGTH);
484 MD_Final(md,&m); 495 MD_Final(&m,md);
485 CRYPTO_w_unlock(CRYPTO_LOCK_RAND); 496 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
486 497
487 memset(&m,0,sizeof(m)); 498 EVP_MD_CTX_cleanup(&m);
488 if (ok) 499 if (ok)
489 return(1); 500 return(1);
490 else 501 else
@@ -521,15 +532,24 @@ static int ssleay_rand_status(void)
521 532
522 /* check if we already have the lock 533 /* check if we already have the lock
523 * (could happen if a RAND_poll() implementation calls RAND_status()) */ 534 * (could happen if a RAND_poll() implementation calls RAND_status()) */
524 do_not_lock = crypto_lock_rand && (locking_thread == CRYPTO_thread_id()); 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;
525 543
526 if (!do_not_lock) 544 if (!do_not_lock)
527 { 545 {
528 CRYPTO_w_lock(CRYPTO_LOCK_RAND); 546 CRYPTO_w_lock(CRYPTO_LOCK_RAND);
529 547
530 /* prevent ssleay_rand_bytes() from trying to obtain the lock again */ 548 /* prevent ssleay_rand_bytes() from trying to obtain the lock again */
531 crypto_lock_rand = 1; 549 CRYPTO_w_lock(CRYPTO_LOCK_RAND2);
532 locking_thread = CRYPTO_thread_id(); 550 locking_thread = CRYPTO_thread_id();
551 CRYPTO_w_unlock(CRYPTO_LOCK_RAND2);
552 crypto_lock_rand = 1;
533 } 553 }
534 554
535 if (!initialized) 555 if (!initialized)
@@ -544,7 +564,6 @@ static int ssleay_rand_status(void)
544 { 564 {
545 /* before unlocking, we must clear 'crypto_lock_rand' */ 565 /* before unlocking, we must clear 'crypto_lock_rand' */
546 crypto_lock_rand = 0; 566 crypto_lock_rand = 0;
547 locking_thread = 0;
548 567
549 CRYPTO_w_unlock(CRYPTO_LOCK_RAND); 568 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
550 } 569 }
diff --git a/src/lib/libcrypto/rand/rand.h b/src/lib/libcrypto/rand/rand.h
index 9c6052733e..e17aa7a9f7 100644
--- a/src/lib/libcrypto/rand/rand.h
+++ b/src/lib/libcrypto/rand/rand.h
@@ -60,6 +60,7 @@
60#define HEADER_RAND_H 60#define HEADER_RAND_H
61 61
62#include <stdlib.h> 62#include <stdlib.h>
63#include <openssl/ossl_typ.h>
63 64
64#ifdef __cplusplus 65#ifdef __cplusplus
65extern "C" { 66extern "C" {
@@ -79,10 +80,9 @@ typedef struct rand_meth_st
79extern int rand_predictable; 80extern int rand_predictable;
80#endif 81#endif
81 82
82struct engine_st; 83int RAND_set_rand_method(const RAND_METHOD *meth);
83 84const RAND_METHOD *RAND_get_rand_method(void);
84int RAND_set_rand_method(struct engine_st *meth); 85int RAND_set_rand_engine(ENGINE *engine);
85RAND_METHOD *RAND_get_rand_method(void );
86RAND_METHOD *RAND_SSLeay(void); 86RAND_METHOD *RAND_SSLeay(void);
87void RAND_cleanup(void ); 87void RAND_cleanup(void );
88int RAND_bytes(unsigned char *buf,int num); 88int RAND_bytes(unsigned char *buf,int num);
@@ -93,42 +93,34 @@ int RAND_load_file(const char *file,long max_bytes);
93int RAND_write_file(const char *file); 93int RAND_write_file(const char *file);
94const char *RAND_file_name(char *file,size_t num); 94const char *RAND_file_name(char *file,size_t num);
95int RAND_status(void); 95int RAND_status(void);
96int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes);
96int RAND_egd(const char *path); 97int RAND_egd(const char *path);
97int RAND_egd_bytes(const char *path,int bytes); 98int RAND_egd_bytes(const char *path,int bytes);
98void ERR_load_RAND_strings(void);
99int RAND_poll(void); 99int RAND_poll(void);
100 100
101#ifdef __cplusplus 101#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32)
102}
103#endif
104
105#if defined(WINDOWS) || defined(WIN32)
106#include <windows.h>
107
108#ifdef __cplusplus
109extern "C" {
110#endif
111 102
112void RAND_screen(void); 103void RAND_screen(void);
113int RAND_event(UINT, WPARAM, LPARAM); 104int RAND_event(UINT, WPARAM, LPARAM);
114 105
115#ifdef __cplusplus
116}
117#endif
118#endif 106#endif
119 107
120/* BEGIN ERROR CODES */ 108/* BEGIN ERROR CODES */
121/* The following lines are auto generated by the script mkerr.pl. Any changes 109/* The following lines are auto generated by the script mkerr.pl. Any changes
122 * made after this point may be overwritten when the script is next run. 110 * made after this point may be overwritten when the script is next run.
123 */ 111 */
112void ERR_load_RAND_strings(void);
124 113
125/* Error codes for the RAND functions. */ 114/* Error codes for the RAND functions. */
126 115
127/* Function codes. */ 116/* Function codes. */
117#define RAND_F_RAND_GET_RAND_METHOD 101
128#define RAND_F_SSLEAY_RAND_BYTES 100 118#define RAND_F_SSLEAY_RAND_BYTES 100
129 119
130/* Reason codes. */ 120/* Reason codes. */
131#define RAND_R_PRNG_NOT_SEEDED 100 121#define RAND_R_PRNG_NOT_SEEDED 100
132 122
123#ifdef __cplusplus
124}
125#endif
133#endif 126#endif
134
diff --git a/src/lib/libcrypto/rand/rand_egd.c b/src/lib/libcrypto/rand/rand_egd.c
index 79b5e6fa57..dd490c8254 100644
--- a/src/lib/libcrypto/rand/rand_egd.c
+++ b/src/lib/libcrypto/rand/rand_egd.c
@@ -1,5 +1,5 @@
1/* crypto/rand/rand_egd.c */ 1/* crypto/rand/rand_egd.c */
2/* Written by Ulf Moeller for the OpenSSL project. */ 2/* Written by Ulf Moeller and Lutz Jaenicke for the OpenSSL project. */
3/* ==================================================================== 3/* ====================================================================
4 * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. 4 * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
5 * 5 *
@@ -54,12 +54,51 @@
54 * 54 *
55 */ 55 */
56 56
57#include <openssl/e_os2.h>
57#include <openssl/rand.h> 58#include <openssl/rand.h>
58 59
59/* Query the EGD <URL: http://www.lothar.com/tech/crypto/>. 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.
60 */ 95 */
61 96
62#if defined(WIN32) || defined(VMS) || defined(__VMS) 97#if defined(OPENSSL_SYS_WIN32) || defined(VMS) || defined(__VMS)
98int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes)
99 {
100 return(-1);
101 }
63int RAND_egd(const char *path) 102int RAND_egd(const char *path)
64 { 103 {
65 return(-1); 104 return(-1);
@@ -75,7 +114,11 @@ int RAND_egd_bytes(const char *path,int bytes)
75#include <sys/types.h> 114#include <sys/types.h>
76#include <sys/socket.h> 115#include <sys/socket.h>
77#ifndef NO_SYS_UN_H 116#ifndef NO_SYS_UN_H
78#include <sys/un.h> 117# ifdef OPENSSL_SYS_VSWORKS
118# include <streams/un.h>
119# else
120# include <sys/un.h>
121# endif
79#else 122#else
80struct sockaddr_un { 123struct sockaddr_un {
81 short sun_family; /* AF_UNIX */ 124 short sun_family; /* AF_UNIX */
@@ -83,50 +126,20 @@ struct sockaddr_un {
83}; 126};
84#endif /* NO_SYS_UN_H */ 127#endif /* NO_SYS_UN_H */
85#include <string.h> 128#include <string.h>
129#include <errno.h>
86 130
87#ifndef offsetof 131#ifndef offsetof
88# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) 132# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
89#endif 133#endif
90 134
91int RAND_egd(const char *path) 135int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes)
92 {
93 int ret = -1;
94 struct sockaddr_un addr;
95 int len, num;
96 int fd = -1;
97 unsigned char buf[256];
98
99 memset(&addr, 0, sizeof(addr));
100 addr.sun_family = AF_UNIX;
101 if (strlen(path) > sizeof(addr.sun_path))
102 return (-1);
103 strcpy(addr.sun_path,path);
104 len = offsetof(struct sockaddr_un, sun_path) + strlen(path);
105 fd = socket(AF_UNIX, SOCK_STREAM, 0);
106 if (fd == -1) return (-1);
107 if (connect(fd, (struct sockaddr *)&addr, len) == -1) goto err;
108 buf[0] = 1;
109 buf[1] = 255;
110 write(fd, buf, 2);
111 if (read(fd, buf, 1) != 1) goto err;
112 if (buf[0] == 0) goto err;
113 num = read(fd, buf, 255);
114 if (num < 1) goto err;
115 RAND_seed(buf, num);
116 if (RAND_status() == 1)
117 ret = num;
118 err:
119 if (fd != -1) close(fd);
120 return(ret);
121 }
122
123int RAND_egd_bytes(const char *path,int bytes)
124 { 136 {
125 int ret = 0; 137 int ret = 0;
126 struct sockaddr_un addr; 138 struct sockaddr_un addr;
127 int len, num; 139 int len, num, numbytes;
128 int fd = -1; 140 int fd = -1;
129 unsigned char buf[255]; 141 int success;
142 unsigned char egdbuf[2], tempbuf[255], *retrievebuf;
130 143
131 memset(&addr, 0, sizeof(addr)); 144 memset(&addr, 0, sizeof(addr));
132 addr.sun_family = AF_UNIX; 145 addr.sun_family = AF_UNIX;
@@ -136,34 +149,126 @@ int RAND_egd_bytes(const char *path,int bytes)
136 len = offsetof(struct sockaddr_un, sun_path) + strlen(path); 149 len = offsetof(struct sockaddr_un, sun_path) + strlen(path);
137 fd = socket(AF_UNIX, SOCK_STREAM, 0); 150 fd = socket(AF_UNIX, SOCK_STREAM, 0);
138 if (fd == -1) return (-1); 151 if (fd == -1) return (-1);
139 if (connect(fd, (struct sockaddr *)&addr, len) == -1) goto err; 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 }
140 185
141 while(bytes > 0) 186 while(bytes > 0)
142 { 187 {
143 buf[0] = 1; 188 egdbuf[0] = 1;
144 buf[1] = bytes < 255 ? bytes : 255; 189 egdbuf[1] = bytes < 255 ? bytes : 255;
145 write(fd, buf, 2); 190 numbytes = 0;
146 if (read(fd, buf, 1) != 1) 191 while (numbytes != 2)
147 { 192 {
148 ret=-1; 193 num = write(fd, egdbuf + numbytes, 2 - numbytes);
149 goto err; 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 }
150 } 213 }
151 if(buf[0] == 0) 214 numbytes = 0;
152 goto err; 215 while (numbytes != 1)
153 num = read(fd, buf, buf[0]);
154 if (num < 1)
155 { 216 {
156 ret=-1; 217 num = read(fd, egdbuf, 1);
157 goto err; 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 }
158 } 237 }
159 RAND_seed(buf, num); 238 if(egdbuf[0] == 0)
160 if (RAND_status() != 1)
161 {
162 ret=-1;
163 goto err; 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 }
164 } 267 }
165 ret += num; 268 ret += egdbuf[0];
166 bytes-=num; 269 bytes -= egdbuf[0];
270 if (!buf)
271 RAND_seed(tempbuf, egdbuf[0]);
167 } 272 }
168 err: 273 err:
169 if (fd != -1) close(fd); 274 if (fd != -1) close(fd);
@@ -171,4 +276,23 @@ int RAND_egd_bytes(const char *path,int bytes)
171 } 276 }
172 277
173 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
174#endif 298#endif
diff --git a/src/lib/libcrypto/rand/rand_err.c b/src/lib/libcrypto/rand/rand_err.c
index 1af0aa0b8a..b77267e213 100644
--- a/src/lib/libcrypto/rand/rand_err.c
+++ b/src/lib/libcrypto/rand/rand_err.c
@@ -63,9 +63,10 @@
63#include <openssl/rand.h> 63#include <openssl/rand.h>
64 64
65/* BEGIN ERROR CODES */ 65/* BEGIN ERROR CODES */
66#ifndef NO_ERR 66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA RAND_str_functs[]= 67static ERR_STRING_DATA RAND_str_functs[]=
68 { 68 {
69{ERR_PACK(0,RAND_F_RAND_GET_RAND_METHOD,0), "RAND_get_rand_method"},
69{ERR_PACK(0,RAND_F_SSLEAY_RAND_BYTES,0), "SSLEAY_RAND_BYTES"}, 70{ERR_PACK(0,RAND_F_SSLEAY_RAND_BYTES,0), "SSLEAY_RAND_BYTES"},
70{0,NULL} 71{0,NULL}
71 }; 72 };
@@ -85,7 +86,7 @@ void ERR_load_RAND_strings(void)
85 if (init) 86 if (init)
86 { 87 {
87 init=0; 88 init=0;
88#ifndef NO_ERR 89#ifndef OPENSSL_NO_ERR
89 ERR_load_strings(ERR_LIB_RAND,RAND_str_functs); 90 ERR_load_strings(ERR_LIB_RAND,RAND_str_functs);
90 ERR_load_strings(ERR_LIB_RAND,RAND_str_reasons); 91 ERR_load_strings(ERR_LIB_RAND,RAND_str_reasons);
91#endif 92#endif
diff --git a/src/lib/libcrypto/rand/rand_lcl.h b/src/lib/libcrypto/rand/rand_lcl.h
index 120e9366d2..618a8ec899 100644
--- a/src/lib/libcrypto/rand/rand_lcl.h
+++ b/src/lib/libcrypto/rand/rand_lcl.h
@@ -1,4 +1,4 @@
1/* crypto/rand/md_rand.c */ 1/* crypto/rand/rand_lcl.h */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -112,72 +112,46 @@
112#ifndef HEADER_RAND_LCL_H 112#ifndef HEADER_RAND_LCL_H
113#define HEADER_RAND_LCL_H 113#define HEADER_RAND_LCL_H
114 114
115#define ENTROPY_NEEDED 20 /* require 160 bits = 20 bytes of randomness */ 115#define ENTROPY_NEEDED 32 /* require 256 bits = 32 bytes of randomness */
116 116
117 117
118#if !defined(USE_MD5_RAND) && !defined(USE_SHA1_RAND) && !defined(USE_MDC2_RAND) && !defined(USE_MD2_RAND) 118#if !defined(USE_MD5_RAND) && !defined(USE_SHA1_RAND) && !defined(USE_MDC2_RAND) && !defined(USE_MD2_RAND)
119#if !defined(NO_SHA) && !defined(NO_SHA1) 119#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA1)
120#define USE_SHA1_RAND 120#define USE_SHA1_RAND
121#elif !defined(NO_MD5) 121#elif !defined(OPENSSL_NO_MD5)
122#define USE_MD5_RAND 122#define USE_MD5_RAND
123#elif !defined(NO_MDC2) && !defined(NO_DES) 123#elif !defined(OPENSSL_NO_MDC2) && !defined(OPENSSL_NO_DES)
124#define USE_MDC2_RAND 124#define USE_MDC2_RAND
125#elif !defined(NO_MD2) 125#elif !defined(OPENSSL_NO_MD2)
126#define USE_MD2_RAND 126#define USE_MD2_RAND
127#else 127#else
128#error No message digest algorithm available 128#error No message digest algorithm available
129#endif 129#endif
130#endif 130#endif
131 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)
132#if defined(USE_MD5_RAND) 135#if defined(USE_MD5_RAND)
133#include <openssl/md5.h> 136#include <openssl/md5.h>
134#define MD_DIGEST_LENGTH MD5_DIGEST_LENGTH 137#define MD_DIGEST_LENGTH MD5_DIGEST_LENGTH
135#define MD(a,b,c) MD5(a,b,c) 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)
136#elif defined(USE_SHA1_RAND) 140#elif defined(USE_SHA1_RAND)
137#include <openssl/sha.h> 141#include <openssl/sha.h>
138#define MD_DIGEST_LENGTH SHA_DIGEST_LENGTH 142#define MD_DIGEST_LENGTH SHA_DIGEST_LENGTH
139#define MD(a,b,c) SHA1(a,b,c) 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)
140#elif defined(USE_MDC2_RAND) 145#elif defined(USE_MDC2_RAND)
141#include <openssl/mdc2.h> 146#include <openssl/mdc2.h>
142#define MD_DIGEST_LENGTH MDC2_DIGEST_LENGTH 147#define MD_DIGEST_LENGTH MDC2_DIGEST_LENGTH
143#define MD(a,b,c) MDC2(a,b,c) 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)
144#elif defined(USE_MD2_RAND) 150#elif defined(USE_MD2_RAND)
145#include <openssl/md2.h> 151#include <openssl/md2.h>
146#define MD_DIGEST_LENGTH MD2_DIGEST_LENGTH 152#define MD_DIGEST_LENGTH MD2_DIGEST_LENGTH
147#define MD(a,b,c) MD2(a,b,c) 153#define MD_Init(a) EVP_DigestInit_ex(a,EVP_md2(), NULL)
148#endif 154#define MD(a,b,c) EVP_Digest(a,b,c,NULL,EVP_md2(), NULL)
149#if defined(USE_MD5_RAND)
150#include <openssl/md5.h>
151#define MD_DIGEST_LENGTH MD5_DIGEST_LENGTH
152#define MD_CTX MD5_CTX
153#define MD_Init(a) MD5_Init(a)
154#define MD_Update(a,b,c) MD5_Update(a,b,c)
155#define MD_Final(a,b) MD5_Final(a,b)
156#define MD(a,b,c) MD5(a,b,c)
157#elif defined(USE_SHA1_RAND)
158#include <openssl/sha.h>
159#define MD_DIGEST_LENGTH SHA_DIGEST_LENGTH
160#define MD_CTX SHA_CTX
161#define MD_Init(a) SHA1_Init(a)
162#define MD_Update(a,b,c) SHA1_Update(a,b,c)
163#define MD_Final(a,b) SHA1_Final(a,b)
164#define MD(a,b,c) SHA1(a,b,c)
165#elif defined(USE_MDC2_RAND)
166#include <openssl/mdc2.h>
167#define MD_DIGEST_LENGTH MDC2_DIGEST_LENGTH
168#define MD_CTX MDC2_CTX
169#define MD_Init(a) MDC2_Init(a)
170#define MD_Update(a,b,c) MDC2_Update(a,b,c)
171#define MD_Final(a,b) MDC2_Final(a,b)
172#define MD(a,b,c) MDC2(a,b,c)
173#elif defined(USE_MD2_RAND)
174#include <openssl/md2.h>
175#define MD_DIGEST_LENGTH MD2_DIGEST_LENGTH
176#define MD_CTX MD2_CTX
177#define MD_Init(a) MD2_Init(a)
178#define MD_Update(a,b,c) MD2_Update(a,b,c)
179#define MD_Final(a,b) MD2_Final(a,b)
180#define MD(a,b,c) MD2(a,b,c)
181#endif 155#endif
182 156
183 157
diff --git a/src/lib/libcrypto/rand/rand_lib.c b/src/lib/libcrypto/rand/rand_lib.c
index 57eff0f132..5cf5dc1188 100644
--- a/src/lib/libcrypto/rand/rand_lib.c
+++ b/src/lib/libcrypto/rand/rand_lib.c
@@ -58,62 +58,92 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <time.h> 60#include <time.h>
61#include "cryptlib.h"
61#include <openssl/rand.h> 62#include <openssl/rand.h>
62#include <openssl/engine.h> 63#include <openssl/engine.h>
63 64
64static ENGINE *rand_engine=NULL; 65/* non-NULL if default_RAND_meth is ENGINE-provided */
66static ENGINE *funct_ref =NULL;
67static const RAND_METHOD *default_RAND_meth = NULL;
65 68
66#if 0 69int RAND_set_rand_method(const RAND_METHOD *meth)
67void RAND_set_rand_method(RAND_METHOD *meth)
68 { 70 {
69 rand_meth=meth; 71 if(funct_ref)
72 {
73 ENGINE_finish(funct_ref);
74 funct_ref = NULL;
75 }
76 default_RAND_meth = meth;
77 return 1;
70 } 78 }
71#else 79
72int RAND_set_rand_method(ENGINE *engine) 80const RAND_METHOD *RAND_get_rand_method(void)
73 { 81 {
74 ENGINE *mtmp; 82 if (!default_RAND_meth)
75 mtmp = rand_engine; 83 {
76 if (!ENGINE_init(engine)) 84 ENGINE *e = ENGINE_get_default_RAND();
77 return 0; 85 if(e)
78 rand_engine = engine; 86 {
79 /* SHOULD ERROR CHECK THIS!!! */ 87 default_RAND_meth = ENGINE_get_RAND(e);
80 ENGINE_finish(mtmp); 88 if(!default_RAND_meth)
81 return 1; 89 {
90 ENGINE_finish(e);
91 e = NULL;
92 }
93 }
94 if(e)
95 funct_ref = e;
96 else
97 default_RAND_meth = RAND_SSLeay();
98 }
99 return default_RAND_meth;
82 } 100 }
83#endif
84 101
85RAND_METHOD *RAND_get_rand_method(void) 102int RAND_set_rand_engine(ENGINE *engine)
86 { 103 {
87 if (rand_engine == NULL 104 const RAND_METHOD *tmp_meth = NULL;
88 && (rand_engine = ENGINE_get_default_RAND()) == NULL) 105 if(engine)
89 return NULL; 106 {
90 return ENGINE_get_RAND(rand_engine); 107 if(!ENGINE_init(engine))
108 return 0;
109 tmp_meth = ENGINE_get_RAND(engine);
110 if(!tmp_meth)
111 {
112 ENGINE_finish(engine);
113 return 0;
114 }
115 }
116 /* This function releases any prior ENGINE so call it first */
117 RAND_set_rand_method(tmp_meth);
118 funct_ref = engine;
119 return 1;
91 } 120 }
92 121
93void RAND_cleanup(void) 122void RAND_cleanup(void)
94 { 123 {
95 RAND_METHOD *meth = RAND_get_rand_method(); 124 const RAND_METHOD *meth = RAND_get_rand_method();
96 if (meth && meth->cleanup) 125 if (meth && meth->cleanup)
97 meth->cleanup(); 126 meth->cleanup();
127 RAND_set_rand_method(NULL);
98 } 128 }
99 129
100void RAND_seed(const void *buf, int num) 130void RAND_seed(const void *buf, int num)
101 { 131 {
102 RAND_METHOD *meth = RAND_get_rand_method(); 132 const RAND_METHOD *meth = RAND_get_rand_method();
103 if (meth && meth->seed) 133 if (meth && meth->seed)
104 meth->seed(buf,num); 134 meth->seed(buf,num);
105 } 135 }
106 136
107void RAND_add(const void *buf, int num, double entropy) 137void RAND_add(const void *buf, int num, double entropy)
108 { 138 {
109 RAND_METHOD *meth = RAND_get_rand_method(); 139 const RAND_METHOD *meth = RAND_get_rand_method();
110 if (meth && meth->add) 140 if (meth && meth->add)
111 meth->add(buf,num,entropy); 141 meth->add(buf,num,entropy);
112 } 142 }
113 143
114int RAND_bytes(unsigned char *buf, int num) 144int RAND_bytes(unsigned char *buf, int num)
115 { 145 {
116 RAND_METHOD *meth = RAND_get_rand_method(); 146 const RAND_METHOD *meth = RAND_get_rand_method();
117 if (meth && meth->bytes) 147 if (meth && meth->bytes)
118 return meth->bytes(buf,num); 148 return meth->bytes(buf,num);
119 return(-1); 149 return(-1);
@@ -121,7 +151,7 @@ int RAND_bytes(unsigned char *buf, int num)
121 151
122int RAND_pseudo_bytes(unsigned char *buf, int num) 152int RAND_pseudo_bytes(unsigned char *buf, int num)
123 { 153 {
124 RAND_METHOD *meth = RAND_get_rand_method(); 154 const RAND_METHOD *meth = RAND_get_rand_method();
125 if (meth && meth->pseudorand) 155 if (meth && meth->pseudorand)
126 return meth->pseudorand(buf,num); 156 return meth->pseudorand(buf,num);
127 return(-1); 157 return(-1);
@@ -129,7 +159,7 @@ int RAND_pseudo_bytes(unsigned char *buf, int num)
129 159
130int RAND_status(void) 160int RAND_status(void)
131 { 161 {
132 RAND_METHOD *meth = RAND_get_rand_method(); 162 const RAND_METHOD *meth = RAND_get_rand_method();
133 if (meth && meth->status) 163 if (meth && meth->status)
134 return meth->status(); 164 return meth->status();
135 return 0; 165 return 0;
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..0b29235130
--- /dev/null
+++ b/src/lib/libcrypto/rand/rand_unix.c
@@ -0,0 +1,274 @@
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#include "cryptlib.h"
113#include <openssl/rand.h>
114#include "rand_lcl.h"
115
116#if !(defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2))
117
118#include <sys/types.h>
119#include <sys/time.h>
120#include <sys/times.h>
121#include <fcntl.h>
122#include <unistd.h>
123#include <time.h>
124
125#ifdef __OpenBSD__
126#undef DEVRANDOM
127#define DEVRANDOM "/dev/arandom"
128int RAND_poll(void)
129{
130 unsigned long l;
131 pid_t curr_pid = getpid();
132 FILE *fh;
133
134 /* Use a random entropy pool device. Linux, FreeBSD and OpenBSD
135 * have this. Use /dev/urandom if you can as /dev/random may block
136 * if it runs out of random entries. */
137
138 if ((fh = fopen(DEVRANDOM, "r")) != NULL)
139 {
140 unsigned char tmpbuf[ENTROPY_NEEDED];
141 int n;
142
143 setvbuf(fh, NULL, _IONBF, 0);
144 n=fread((unsigned char *)tmpbuf,1,ENTROPY_NEEDED,fh);
145 fclose(fh);
146 RAND_add(tmpbuf,sizeof tmpbuf,n);
147 memset(tmpbuf,0,n);
148 }
149
150 /* put in some default random data, we need more than just this */
151 l=curr_pid;
152 RAND_add(&l,sizeof(l),0);
153 l=getuid();
154 RAND_add(&l,sizeof(l),0);
155
156 l=time(NULL);
157 RAND_add(&l,sizeof(l),0);
158
159 return 1;
160}
161#else
162int RAND_poll(void)
163{
164 unsigned long l;
165 pid_t curr_pid = getpid();
166#if defined(DEVRANDOM) || defined(DEVRANDOM_EGD)
167 unsigned char tmpbuf[ENTROPY_NEEDED];
168 int n = 0;
169#endif
170#ifdef DEVRANDOM
171 static const char *randomfiles[] = { DEVRANDOM, NULL };
172 const char **randomfile = NULL;
173 int fd;
174#endif
175#ifdef DEVRANDOM_EGD
176 static const char *egdsockets[] = { DEVRANDOM_EGD, NULL };
177 const char **egdsocket = NULL;
178#endif
179
180#ifdef DEVRANDOM
181 /* Use a random entropy pool device. Linux, FreeBSD and OpenBSD
182 * have this. Use /dev/urandom if you can as /dev/random may block
183 * if it runs out of random entries. */
184
185 for (randomfile = randomfiles; *randomfile && n < ENTROPY_NEEDED; randomfile++)
186 {
187 if ((fd = open(*randomfile, O_RDONLY|O_NONBLOCK
188#ifdef O_NOCTTY /* If it happens to be a TTY (god forbid), do not make it
189 our controlling tty */
190 |O_NOCTTY
191#endif
192#ifdef O_NOFOLLOW /* Fail if the file is a symbolic link */
193 |O_NOFOLLOW
194#endif
195 )) >= 0)
196 {
197 struct timeval t = { 0, 10*1000 }; /* Spend 10ms on
198 each file. */
199 int r;
200 fd_set fset;
201
202 do
203 {
204 FD_ZERO(&fset);
205 FD_SET(fd, &fset);
206 r = -1;
207
208 if (select(fd+1,&fset,NULL,NULL,&t) < 0)
209 t.tv_usec=0;
210 else if (FD_ISSET(fd, &fset))
211 {
212 r=read(fd,(unsigned char *)tmpbuf+n,
213 ENTROPY_NEEDED-n);
214 if (r > 0)
215 n += r;
216 }
217
218 /* Some Unixen will update t, some
219 won't. For those who won't, give
220 up here, otherwise, we will do
221 this once again for the remaining
222 time. */
223 if (t.tv_usec == 10*1000)
224 t.tv_usec=0;
225 }
226 while ((r > 0 || (errno == EINTR || errno == EAGAIN))
227 && t.tv_usec != 0 && n < ENTROPY_NEEDED);
228
229 close(fd);
230 }
231 }
232#endif
233
234#ifdef DEVRANDOM_EGD
235 /* Use an EGD socket to read entropy from an EGD or PRNGD entropy
236 * collecting daemon. */
237
238 for (egdsocket = egdsockets; *egdsocket && n < ENTROPY_NEEDED; egdsocket++)
239 {
240 int r;
241
242 r = RAND_query_egd_bytes(*egdsocket, (unsigned char *)tmpbuf+n,
243 ENTROPY_NEEDED-n);
244 if (r > 0)
245 n += r;
246 }
247#endif
248
249#if defined(DEVRANDOM) || defined(DEVRANDOM_EGD)
250 if (n > 0)
251 {
252 RAND_add(tmpbuf,sizeof tmpbuf,n);
253 memset(tmpbuf,0,n);
254 }
255#endif
256
257 /* put in some default random data, we need more than just this */
258 l=curr_pid;
259 RAND_add(&l,sizeof(l),0);
260 l=getuid();
261 RAND_add(&l,sizeof(l),0);
262
263 l=time(NULL);
264 RAND_add(&l,sizeof(l),0);
265
266#if defined(DEVRANDOM) || defined(DEVRANDOM_EGD)
267 return 1;
268#else
269 return 0;
270#endif
271}
272
273#endif
274#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
index 3d137badd0..c1b955b06f 100644
--- a/src/lib/libcrypto/rand/rand_win.c
+++ b/src/lib/libcrypto/rand/rand_win.c
@@ -113,7 +113,7 @@
113#include <openssl/rand.h> 113#include <openssl/rand.h>
114#include "rand_lcl.h" 114#include "rand_lcl.h"
115 115
116#if defined(WINDOWS) || defined(WIN32) 116#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32)
117#include <windows.h> 117#include <windows.h>
118#ifndef _WIN32_WINNT 118#ifndef _WIN32_WINNT
119# define _WIN32_WINNT 0x0400 119# define _WIN32_WINNT 0x0400
@@ -254,6 +254,10 @@ int RAND_poll(void)
254 * at random times on Windows 2000. Reported by Jeffrey Altman. 254 * at random times on Windows 2000. Reported by Jeffrey Altman.
255 * Only use it on NT. 255 * Only use it on NT.
256 */ 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
257 if ( osverinfo.dwPlatformId == VER_PLATFORM_WIN32_NT && 261 if ( osverinfo.dwPlatformId == VER_PLATFORM_WIN32_NT &&
258 osverinfo.dwMajorVersion < 5) 262 osverinfo.dwMajorVersion < 5)
259 { 263 {
@@ -290,6 +294,7 @@ int RAND_poll(void)
290 if (buf) 294 if (buf)
291 free(buf); 295 free(buf);
292 } 296 }
297#endif
293 298
294 if (advapi) 299 if (advapi)
295 { 300 {
@@ -310,8 +315,8 @@ int RAND_poll(void)
310 { 315 {
311 if (gen(hProvider, sizeof(buf), buf) != 0) 316 if (gen(hProvider, sizeof(buf), buf) != 0)
312 { 317 {
313 RAND_add(buf, sizeof(buf), sizeof(buf)); 318 RAND_add(buf, sizeof(buf), 0);
314#ifdef DEBUG 319#if 0
315 printf("randomness from PROV_RSA_FULL\n"); 320 printf("randomness from PROV_RSA_FULL\n");
316#endif 321#endif
317 } 322 }
@@ -324,7 +329,7 @@ int RAND_poll(void)
324 if (gen(hProvider, sizeof(buf), buf) != 0) 329 if (gen(hProvider, sizeof(buf), buf) != 0)
325 { 330 {
326 RAND_add(buf, sizeof(buf), sizeof(buf)); 331 RAND_add(buf, sizeof(buf), sizeof(buf));
327#ifdef DEBUG 332#if 0
328 printf("randomness from PROV_INTEL_SEC\n"); 333 printf("randomness from PROV_INTEL_SEC\n");
329#endif 334#endif
330 } 335 }
@@ -461,7 +466,7 @@ int RAND_poll(void)
461 hlist.th32ProcessID, 466 hlist.th32ProcessID,
462 hlist.th32HeapID)) 467 hlist.th32HeapID))
463 { 468 {
464 int entrycnt = 50; 469 int entrycnt = 80;
465 do 470 do
466 RAND_add(&hentry, 471 RAND_add(&hentry,
467 hentry.dwSize, 5); 472 hentry.dwSize, 5);
@@ -510,7 +515,7 @@ int RAND_poll(void)
510 FreeLibrary(kernel); 515 FreeLibrary(kernel);
511 } 516 }
512 517
513#ifdef DEBUG 518#if 0
514 printf("Exiting RAND_poll\n"); 519 printf("Exiting RAND_poll\n");
515#endif 520#endif
516 521
@@ -685,50 +690,4 @@ static void readscreen(void)
685 DeleteDC(hScrDC); 690 DeleteDC(hScrDC);
686} 691}
687 692
688#else /* Unix version */
689
690#include <time.h>
691
692int RAND_poll(void)
693{
694 unsigned long l;
695 pid_t curr_pid = getpid();
696#ifdef DEVRANDOM
697 FILE *fh;
698#endif
699
700#ifdef DEVRANDOM
701 /* Use a random entropy pool device. Linux, FreeBSD and OpenBSD
702 * have this. Use /dev/urandom if you can as /dev/random may block
703 * if it runs out of random entries. */
704
705 if ((fh = fopen(DEVRANDOM, "r")) != NULL)
706 {
707 unsigned char tmpbuf[ENTROPY_NEEDED];
708 int n;
709
710 setvbuf(fh, NULL, _IONBF, 0);
711 n=fread((unsigned char *)tmpbuf,1,ENTROPY_NEEDED,fh);
712 fclose(fh);
713 RAND_add(tmpbuf,sizeof tmpbuf,n);
714 memset(tmpbuf,0,n);
715 }
716#endif
717
718 /* put in some default random data, we need more than just this */
719 l=curr_pid;
720 RAND_add(&l,sizeof(l),0);
721 l=getuid();
722 RAND_add(&l,sizeof(l),0);
723
724 l=time(NULL);
725 RAND_add(&l,sizeof(l),0);
726
727#ifdef DEVRANDOM
728 return 1;
729#else
730 return 0;
731#endif
732}
733
734#endif 693#endif
diff --git a/src/lib/libcrypto/rand/randfile.c b/src/lib/libcrypto/rand/randfile.c
index c4eb79ac5f..4b221e08f5 100644
--- a/src/lib/libcrypto/rand/randfile.c
+++ b/src/lib/libcrypto/rand/randfile.c
@@ -61,7 +61,11 @@
61#include <stdlib.h> 61#include <stdlib.h>
62#include <string.h> 62#include <string.h>
63 63
64#ifdef VMS 64#include "e_os.h"
65#include <openssl/crypto.h>
66#include <openssl/rand.h>
67
68#ifdef OPENSSL_SYS_VMS
65#include <unixio.h> 69#include <unixio.h>
66#endif 70#endif
67#ifndef NO_SYS_TYPES_H 71#ifndef NO_SYS_TYPES_H
@@ -73,10 +77,6 @@
73# include <sys/stat.h> 77# include <sys/stat.h>
74#endif 78#endif
75 79
76#include "openssl/e_os.h"
77#include <openssl/crypto.h>
78#include <openssl/rand.h>
79
80#undef BUFSIZE 80#undef BUFSIZE
81#define BUFSIZE 1024 81#define BUFSIZE 1024
82#define RAND_DATA 1024 82#define RAND_DATA 1024
@@ -158,7 +158,7 @@ int RAND_write_file(const char *file)
158 } 158 }
159 } 159 }
160 160
161#if defined(O_CREAT) && !defined(WIN32) 161#if defined(O_CREAT) && !defined(OPENSSL_SYS_WIN32)
162 /* For some reason Win32 can't write to files created this way */ 162 /* For some reason Win32 can't write to files created this way */
163 163
164 /* chmod(..., 0600) is too late to protect the file, 164 /* chmod(..., 0600) is too late to protect the file,
@@ -190,7 +190,7 @@ int RAND_write_file(const char *file)
190 ret+=i; 190 ret+=i;
191 if (n <= 0) break; 191 if (n <= 0) break;
192 } 192 }
193#ifdef VMS 193#ifdef OPENSSL_SYS_VMS
194 /* Try to delete older versions of the file, until there aren't 194 /* Try to delete older versions of the file, until there aren't
195 any */ 195 any */
196 { 196 {
@@ -208,7 +208,7 @@ int RAND_write_file(const char *file)
208 some point... */ 208 some point... */
209 } 209 }
210 } 210 }
211#endif /* VMS */ 211#endif /* OPENSSL_SYS_VMS */
212 212
213 fclose(out); 213 fclose(out);
214 memset(buf,0,BUFSIZE); 214 memset(buf,0,BUFSIZE);
@@ -242,7 +242,7 @@ const char *RAND_file_name(char *buf, size_t size)
242 if (s && *s && strlen(s)+strlen(RFILE)+2 < size) 242 if (s && *s && strlen(s)+strlen(RFILE)+2 < size)
243 { 243 {
244 strlcpy(buf,s,size); 244 strlcpy(buf,s,size);
245#ifndef VMS 245#ifndef OPENSSL_SYS_VMS
246 strcat(buf,"/"); 246 strcat(buf,"/");
247#endif 247#endif
248 strlcat(buf,RFILE,size); 248 strlcat(buf,RFILE,size);
@@ -252,20 +252,20 @@ const char *RAND_file_name(char *buf, size_t size)
252 buf[0] = '\0'; /* no file name */ 252 buf[0] = '\0'; /* no file name */
253 } 253 }
254 254
255#ifdef DEVRANDOM 255#ifdef __OpenBSD__
256 /* given that all random loads just fail if the file can't be 256 /* given that all random loads just fail if the file can't be
257 * seen on a stat, we stat the file we're returning, if it 257 * seen on a stat, we stat the file we're returning, if it
258 * fails, use DEVRANDOM instead. this allows the user to 258 * fails, use /dev/arandom instead. this allows the user to
259 * use their own source for good random data, but defaults 259 * use their own source for good random data, but defaults
260 * to something hopefully decent if that isn't available. 260 * to something hopefully decent if that isn't available.
261 */ 261 */
262 262
263 if (!ok) 263 if (!ok)
264 if (strlcpy(buf,DEVRANDOM,size) >= size) { 264 if (strlcpy(buf,"/dev/arandom",size) >= size) {
265 return(NULL); 265 return(NULL);
266 } 266 }
267 if (stat(buf,&sb) == -1) 267 if (stat(buf,&sb) == -1)
268 if (strlcpy(buf,DEVRANDOM,size) >= size) { 268 if (strlcpy(buf,"/dev/arandom",size) >= size) {
269 return(NULL); 269 return(NULL);
270 } 270 }
271 271
diff --git a/src/lib/libcrypto/rand/randtest.c b/src/lib/libcrypto/rand/randtest.c
index da96e3f695..b64de616db 100644
--- a/src/lib/libcrypto/rand/randtest.c
+++ b/src/lib/libcrypto/rand/randtest.c
@@ -73,7 +73,13 @@ int main()
73 /*double d; */ 73 /*double d; */
74 long d; 74 long d;
75 75
76 RAND_pseudo_bytes(buf,2500); 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 }
77 83
78 n1=0; 84 n1=0;
79 for (i=0; i<16; i++) n2[i]=0; 85 for (i=0; i<16; i++) n2[i]=0;
@@ -201,6 +207,7 @@ int main()
201 err++; 207 err++;
202 } 208 }
203 printf("test 4 done\n"); 209 printf("test 4 done\n");
210 err:
204 err=((err)?1:0); 211 err=((err)?1:0);
205 exit(err); 212 exit(err);
206 return(err); 213 return(err);
diff --git a/src/lib/libcrypto/rc2/Makefile.ssl b/src/lib/libcrypto/rc2/Makefile.ssl
index 39813d68be..73ebbfa400 100644
--- a/src/lib/libcrypto/rc2/Makefile.ssl
+++ b/src/lib/libcrypto/rc2/Makefile.ssl
@@ -11,7 +11,8 @@ INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl 11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl 12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl 13MAKE= make -f Makefile.ssl
14MAKEDEPEND= $(TOP)/util/domd $(TOP) 14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
15MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
16AR= ar r 17AR= ar r
17 18
@@ -39,8 +40,7 @@ all: lib
39 40
40lib: $(LIBOBJ) 41lib: $(LIBOBJ)
41 $(AR) $(LIB) $(LIBOBJ) 42 $(AR) $(LIB) $(LIBOBJ)
42 @echo You may get an error following this line. Please ignore. 43 $(RANLIB) $(LIB) || echo Never mind.
43 - $(RANLIB) $(LIB)
44 @touch lib 44 @touch lib
45 45
46files: 46files:
@@ -80,12 +80,12 @@ clean:
80# DO NOT DELETE THIS LINE -- make depend depends on it. 80# DO NOT DELETE THIS LINE -- make depend depends on it.
81 81
82rc2_cbc.o: ../../include/openssl/opensslconf.h ../../include/openssl/rc2.h 82rc2_cbc.o: ../../include/openssl/opensslconf.h ../../include/openssl/rc2.h
83rc2_cbc.o: rc2_locl.h 83rc2_cbc.o: rc2_cbc.c rc2_locl.h
84rc2_ecb.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 84rc2_ecb.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
85rc2_ecb.o: ../../include/openssl/rc2.h rc2_locl.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 86rc2_skey.o: ../../include/openssl/opensslconf.h ../../include/openssl/rc2.h
87rc2_skey.o: rc2_locl.h 87rc2_skey.o: rc2_locl.h rc2_skey.c
88rc2cfb64.o: ../../include/openssl/opensslconf.h ../../include/openssl/rc2.h 88rc2cfb64.o: ../../include/openssl/opensslconf.h ../../include/openssl/rc2.h
89rc2cfb64.o: rc2_locl.h 89rc2cfb64.o: rc2_locl.h rc2cfb64.c
90rc2ofb64.o: ../../include/openssl/opensslconf.h ../../include/openssl/rc2.h 90rc2ofb64.o: ../../include/openssl/opensslconf.h ../../include/openssl/rc2.h
91rc2ofb64.o: rc2_locl.h 91rc2ofb64.o: rc2_locl.h rc2ofb64.c
diff --git a/src/lib/libcrypto/rc2/rc2.h b/src/lib/libcrypto/rc2/rc2.h
index 076c0a067c..7816b454dc 100644
--- a/src/lib/libcrypto/rc2/rc2.h
+++ b/src/lib/libcrypto/rc2/rc2.h
@@ -59,7 +59,7 @@
59#ifndef HEADER_RC2_H 59#ifndef HEADER_RC2_H
60#define HEADER_RC2_H 60#define HEADER_RC2_H
61 61
62#ifdef NO_RC2 62#ifdef OPENSSL_NO_RC2
63#error RC2 is disabled. 63#error RC2 is disabled.
64#endif 64#endif
65 65
diff --git a/src/lib/libcrypto/rc2/rc2speed.c b/src/lib/libcrypto/rc2/rc2speed.c
index 9f7f5ccfa3..47d34b444e 100644
--- a/src/lib/libcrypto/rc2/rc2speed.c
+++ b/src/lib/libcrypto/rc2/rc2speed.c
@@ -59,7 +59,7 @@
59/* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */ 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 */ 60/* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */
61 61
62#if !defined(MSDOS) && (!defined(VMS) || defined(__DECC)) 62#if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX)
63#define TIMES 63#define TIMES
64#endif 64#endif
65 65
@@ -82,7 +82,7 @@ OPENSSL_DECLARE_EXIT
82 The __TMS macro will show if it was. If it wasn't defined, we should 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 83 undefine TIMES, since that tells the rest of the program how things
84 should be handled. -- Richard Levitte */ 84 should be handled. -- Richard Levitte */
85#if defined(VMS) && defined(__DECC) && !defined(__TMS) 85#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
86#undef TIMES 86#undef TIMES
87#endif 87#endif
88 88
@@ -268,7 +268,7 @@ int main(int argc, char **argv)
268 printf("RC2 raw ecb bytes per sec = %12.2f (%9.3fuS)\n",b,8.0e6/b); 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); 269 printf("RC2 cbc bytes per sec = %12.2f (%9.3fuS)\n",c,8.0e6/c);
270 exit(0); 270 exit(0);
271#if defined(LINT) || defined(MSDOS) 271#if defined(LINT) || defined(OPENSSL_SYS_MSDOS)
272 return(0); 272 return(0);
273#endif 273#endif
274 } 274 }
diff --git a/src/lib/libcrypto/rc2/rc2test.c b/src/lib/libcrypto/rc2/rc2test.c
index 521269ded1..d9a2a0a1cb 100644
--- a/src/lib/libcrypto/rc2/rc2test.c
+++ b/src/lib/libcrypto/rc2/rc2test.c
@@ -63,7 +63,7 @@
63#include <string.h> 63#include <string.h>
64#include <stdlib.h> 64#include <stdlib.h>
65 65
66#ifdef NO_RC2 66#ifdef OPENSSL_NO_RC2
67int main(int argc, char *argv[]) 67int main(int argc, char *argv[])
68{ 68{
69 printf("No RC2 support\n"); 69 printf("No RC2 support\n");
diff --git a/src/lib/libcrypto/rc4/Makefile.ssl b/src/lib/libcrypto/rc4/Makefile.ssl
index e75858d3b9..25d9e4344c 100644
--- a/src/lib/libcrypto/rc4/Makefile.ssl
+++ b/src/lib/libcrypto/rc4/Makefile.ssl
@@ -12,7 +12,8 @@ INSTALL_PREFIX=
12OPENSSLDIR= /usr/local/ssl 12OPENSSLDIR= /usr/local/ssl
13INSTALLTOP=/usr/local/ssl 13INSTALLTOP=/usr/local/ssl
14MAKE= make -f Makefile.ssl 14MAKE= make -f Makefile.ssl
15MAKEDEPEND= $(TOP)/util/domd $(TOP) 15MAKEDEPPROG= makedepend
16MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl 17MAKEFILE= Makefile.ssl
17AR= ar r 18AR= ar r
18 19
@@ -47,8 +48,7 @@ all: lib
47 48
48lib: $(LIBOBJ) 49lib: $(LIBOBJ)
49 $(AR) $(LIB) $(LIBOBJ) 50 $(AR) $(LIB) $(LIBOBJ)
50 @echo You may get an error following this line. Please ignore. 51 $(RANLIB) $(LIB) || echo Never mind.
51 - $(RANLIB) $(LIB)
52 @touch lib 52 @touch lib
53 53
54# elf 54# elf
@@ -109,7 +109,7 @@ clean:
109# DO NOT DELETE THIS LINE -- make depend depends on it. 109# DO NOT DELETE THIS LINE -- make depend depends on it.
110 110
111rc4_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/rc4.h 111rc4_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/rc4.h
112rc4_enc.o: rc4_locl.h 112rc4_enc.o: rc4_enc.c rc4_locl.h
113rc4_skey.o: ../../include/openssl/opensslconf.h 113rc4_skey.o: ../../include/openssl/opensslconf.h
114rc4_skey.o: ../../include/openssl/opensslv.h ../../include/openssl/rc4.h 114rc4_skey.o: ../../include/openssl/opensslv.h ../../include/openssl/rc4.h
115rc4_skey.o: rc4_locl.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
index bfb0a3c1f9..c2165b0b75 100644
--- a/src/lib/libcrypto/rc4/rc4.c
+++ b/src/lib/libcrypto/rc4/rc4.c
@@ -141,7 +141,7 @@ bad:
141 } 141 }
142 } 142 }
143 143
144#ifdef MSDOS 144#ifdef OPENSSL_SYS_MSDOS
145 /* This should set the file to binary mode. */ 145 /* This should set the file to binary mode. */
146 { 146 {
147#include <fcntl.h> 147#include <fcntl.h>
@@ -162,7 +162,7 @@ bad:
162 keystr=buf; 162 keystr=buf;
163 } 163 }
164 164
165 MD5((unsigned char *)keystr,(unsigned long)strlen(keystr),md); 165 EVP_Digest((unsigned char *)keystr,(unsigned long)strlen(keystr),md,NULL,EVP_md5());
166 memset(keystr,0,strlen(keystr)); 166 memset(keystr,0,strlen(keystr));
167 RC4_set_key(&key,MD5_DIGEST_LENGTH,md); 167 RC4_set_key(&key,MD5_DIGEST_LENGTH,md);
168 168
diff --git a/src/lib/libcrypto/rc4/rc4.h b/src/lib/libcrypto/rc4/rc4.h
index 40251024a4..8722091f2e 100644
--- a/src/lib/libcrypto/rc4/rc4.h
+++ b/src/lib/libcrypto/rc4/rc4.h
@@ -59,7 +59,7 @@
59#ifndef HEADER_RC4_H 59#ifndef HEADER_RC4_H
60#define HEADER_RC4_H 60#define HEADER_RC4_H
61 61
62#ifdef NO_RC4 62#ifdef OPENSSL_NO_RC4
63#error RC4 is disabled. 63#error RC4 is disabled.
64#endif 64#endif
65 65
diff --git a/src/lib/libcrypto/rc4/rc4speed.c b/src/lib/libcrypto/rc4/rc4speed.c
index b448f4a5c6..ced98c52df 100644
--- a/src/lib/libcrypto/rc4/rc4speed.c
+++ b/src/lib/libcrypto/rc4/rc4speed.c
@@ -59,7 +59,7 @@
59/* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */ 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 */ 60/* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */
61 61
62#if !defined(MSDOS) && (!defined(VMS) || defined(__DECC)) 62#if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX)
63#define TIMES 63#define TIMES
64#endif 64#endif
65 65
@@ -82,7 +82,7 @@ OPENSSL_DECLARE_EXIT
82 The __TMS macro will show if it was. If it wasn't defined, we should 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 83 undefine TIMES, since that tells the rest of the program how things
84 should be handled. -- Richard Levitte */ 84 should be handled. -- Richard Levitte */
85#if defined(VMS) && defined(__DECC) && !defined(__TMS) 85#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
86#undef TIMES 86#undef TIMES
87#endif 87#endif
88 88
@@ -243,7 +243,7 @@ int main(int argc, char **argv)
243 printf("RC4 set_key per sec = %12.2f (%9.3fuS)\n",a,1.0e6/a); 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); 244 printf("RC4 bytes per sec = %12.2f (%9.3fuS)\n",c,8.0e6/c);
245 exit(0); 245 exit(0);
246#if defined(LINT) || defined(MSDOS) 246#if defined(LINT) || defined(OPENSSL_SYS_MSDOS)
247 return(0); 247 return(0);
248#endif 248#endif
249 } 249 }
diff --git a/src/lib/libcrypto/rc4/rc4test.c b/src/lib/libcrypto/rc4/rc4test.c
index 3914eb6c38..a28d457c8d 100644
--- a/src/lib/libcrypto/rc4/rc4test.c
+++ b/src/lib/libcrypto/rc4/rc4test.c
@@ -60,7 +60,7 @@
60#include <stdlib.h> 60#include <stdlib.h>
61#include <string.h> 61#include <string.h>
62 62
63#ifdef NO_RC4 63#ifdef OPENSSL_NO_RC4
64int main(int argc, char *argv[]) 64int main(int argc, char *argv[])
65{ 65{
66 printf("No RC4 support\n"); 66 printf("No RC4 support\n");
diff --git a/src/lib/libcrypto/rc5/Makefile.ssl b/src/lib/libcrypto/rc5/Makefile.ssl
index c8ee124776..25740ab961 100644
--- a/src/lib/libcrypto/rc5/Makefile.ssl
+++ b/src/lib/libcrypto/rc5/Makefile.ssl
@@ -12,7 +12,8 @@ INSTALL_PREFIX=
12OPENSSLDIR= /usr/local/ssl 12OPENSSLDIR= /usr/local/ssl
13INSTALLTOP=/usr/local/ssl 13INSTALLTOP=/usr/local/ssl
14MAKE= make -f Makefile.ssl 14MAKE= make -f Makefile.ssl
15MAKEDEPEND= $(TOP)/util/domd $(TOP) 15MAKEDEPPROG= makedepend
16MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl 17MAKEFILE= Makefile.ssl
17AR= ar r 18AR= ar r
18 19
@@ -44,8 +45,7 @@ all: lib
44 45
45lib: $(LIBOBJ) 46lib: $(LIBOBJ)
46 $(AR) $(LIB) $(LIBOBJ) 47 $(AR) $(LIB) $(LIBOBJ)
47 @echo You may get an error following this line. Please ignore. 48 $(RANLIB) $(LIB) || echo Never mind.
48 - $(RANLIB) $(LIB)
49 @touch lib 49 @touch lib
50 50
51# elf 51# elf
@@ -106,8 +106,8 @@ clean:
106# DO NOT DELETE THIS LINE -- make depend depends on it. 106# DO NOT DELETE THIS LINE -- make depend depends on it.
107 107
108rc5_ecb.o: ../../include/openssl/opensslv.h ../../include/openssl/rc5.h 108rc5_ecb.o: ../../include/openssl/opensslv.h ../../include/openssl/rc5.h
109rc5_ecb.o: rc5_locl.h 109rc5_ecb.o: rc5_ecb.c rc5_locl.h
110rc5_enc.o: ../../include/openssl/rc5.h 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 111rc5_skey.o: ../../include/openssl/rc5.h rc5_locl.h rc5_skey.c
112rc5cfb64.o: ../../include/openssl/rc5.h rc5_locl.h 112rc5cfb64.o: ../../include/openssl/rc5.h rc5_locl.h rc5cfb64.c
113rc5ofb64.o: ../../include/openssl/rc5.h rc5_locl.h 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
index fc4cea5e36..4adfd2db5a 100644
--- a/src/lib/libcrypto/rc5/rc5.h
+++ b/src/lib/libcrypto/rc5/rc5.h
@@ -63,7 +63,7 @@
63extern "C" { 63extern "C" {
64#endif 64#endif
65 65
66#ifdef NO_RC5 66#ifdef OPENSSL_NO_RC5
67#error RC5 is disabled. 67#error RC5 is disabled.
68#endif 68#endif
69 69
diff --git a/src/lib/libcrypto/rijndael/Makefile.ssl b/src/lib/libcrypto/rijndael/Makefile.ssl
new file mode 100644
index 0000000000..ddc480e9d7
--- /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 @$(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) $(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
index 1550c32ca1..a3a6563a5b 100644
--- a/src/lib/libcrypto/ripemd/Makefile.ssl
+++ b/src/lib/libcrypto/ripemd/Makefile.ssl
@@ -12,7 +12,8 @@ INSTALL_PREFIX=
12OPENSSLDIR= /usr/local/ssl 12OPENSSLDIR= /usr/local/ssl
13INSTALLTOP=/usr/local/ssl 13INSTALLTOP=/usr/local/ssl
14MAKE= make -f Makefile.ssl 14MAKE= make -f Makefile.ssl
15MAKEDEPEND= $(TOP)/util/domd $(TOP) 15MAKEDEPPROG= makedepend
16MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl 17MAKEFILE= Makefile.ssl
17AR= ar r 18AR= ar r
18 19
@@ -42,8 +43,7 @@ all: lib
42 43
43lib: $(LIBOBJ) 44lib: $(LIBOBJ)
44 $(AR) $(LIB) $(LIBOBJ) 45 $(AR) $(LIB) $(LIBOBJ)
45 @echo You may get an error following this line. Please ignore. 46 $(RANLIB) $(LIB) || echo Never mind.
46 - $(RANLIB) $(LIB)
47 @touch lib 47 @touch lib
48 48
49# elf 49# elf
@@ -103,7 +103,8 @@ clean:
103 103
104# DO NOT DELETE THIS LINE -- make depend depends on it. 104# DO NOT DELETE THIS LINE -- make depend depends on it.
105 105
106rmd_dgst.o: ../../include/openssl/opensslconf.h 106rmd_dgst.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
107rmd_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/ripemd.h 107rmd_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/ripemd.h
108rmd_dgst.o: ../md32_common.h rmd_locl.h rmdconst.h 108rmd_dgst.o: ../md32_common.h rmd_dgst.c rmd_locl.h rmdconst.h
109rmd_one.o: ../../include/openssl/ripemd.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/ripemd.h b/src/lib/libcrypto/ripemd/ripemd.h
index dd1627cf40..78d5f36560 100644
--- a/src/lib/libcrypto/ripemd/ripemd.h
+++ b/src/lib/libcrypto/ripemd/ripemd.h
@@ -59,17 +59,19 @@
59#ifndef HEADER_RIPEMD_H 59#ifndef HEADER_RIPEMD_H
60#define HEADER_RIPEMD_H 60#define HEADER_RIPEMD_H
61 61
62#include <openssl/e_os2.h>
63
62#ifdef __cplusplus 64#ifdef __cplusplus
63extern "C" { 65extern "C" {
64#endif 66#endif
65 67
66#ifdef NO_RIPEMD 68#ifdef OPENSSL_NO_RIPEMD
67#error RIPEMD is disabled. 69#error RIPEMD is disabled.
68#endif 70#endif
69 71
70#if defined(WIN16) || defined(__LP32__) 72#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__)
71#define RIPEMD160_LONG unsigned long 73#define RIPEMD160_LONG unsigned long
72#elif defined(_CRAY) || defined(__ILP64__) 74#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)
73#define RIPEMD160_LONG unsigned long 75#define RIPEMD160_LONG unsigned long
74#define RIPEMD160_LONG_LOG2 3 76#define RIPEMD160_LONG_LOG2 3
75#else 77#else
@@ -88,9 +90,9 @@ typedef struct RIPEMD160state_st
88 int num; 90 int num;
89 } RIPEMD160_CTX; 91 } RIPEMD160_CTX;
90 92
91void RIPEMD160_Init(RIPEMD160_CTX *c); 93int RIPEMD160_Init(RIPEMD160_CTX *c);
92void RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, unsigned long len); 94int RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, unsigned long len);
93void RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c); 95int RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c);
94unsigned char *RIPEMD160(const unsigned char *d, unsigned long n, 96unsigned char *RIPEMD160(const unsigned char *d, unsigned long n,
95 unsigned char *md); 97 unsigned char *md);
96void RIPEMD160_Transform(RIPEMD160_CTX *c, const unsigned char *b); 98void RIPEMD160_Transform(RIPEMD160_CTX *c, const unsigned char *b);
diff --git a/src/lib/libcrypto/ripemd/rmd_dgst.c b/src/lib/libcrypto/ripemd/rmd_dgst.c
index bdfae270b6..a3170f7c8a 100644
--- a/src/lib/libcrypto/ripemd/rmd_dgst.c
+++ b/src/lib/libcrypto/ripemd/rmd_dgst.c
@@ -69,7 +69,7 @@ const char *RMD160_version="RIPE-MD160" OPENSSL_VERSION_PTEXT;
69 void ripemd160_block(RIPEMD160_CTX *c, unsigned long *p,int num); 69 void ripemd160_block(RIPEMD160_CTX *c, unsigned long *p,int num);
70# endif 70# endif
71 71
72void RIPEMD160_Init(RIPEMD160_CTX *c) 72int RIPEMD160_Init(RIPEMD160_CTX *c)
73 { 73 {
74 c->A=RIPEMD160_A; 74 c->A=RIPEMD160_A;
75 c->B=RIPEMD160_B; 75 c->B=RIPEMD160_B;
@@ -79,6 +79,7 @@ void RIPEMD160_Init(RIPEMD160_CTX *c)
79 c->Nl=0; 79 c->Nl=0;
80 c->Nh=0; 80 c->Nh=0;
81 c->num=0; 81 c->num=0;
82 return 1;
82 } 83 }
83 84
84#ifndef ripemd160_block_host_order 85#ifndef ripemd160_block_host_order
diff --git a/src/lib/libcrypto/ripemd/rmd_locl.h b/src/lib/libcrypto/ripemd/rmd_locl.h
index f537b88867..7b835dfbd4 100644
--- a/src/lib/libcrypto/ripemd/rmd_locl.h
+++ b/src/lib/libcrypto/ripemd/rmd_locl.h
@@ -71,7 +71,7 @@
71 * <appro@fy.chalmers.se> 71 * <appro@fy.chalmers.se>
72 */ 72 */
73#ifdef RMD160_ASM 73#ifdef RMD160_ASM
74# if defined(__i386) || defined(_M_IX86) || defined(__INTEL__) 74# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__)
75# define ripemd160_block_host_order ripemd160_block_asm_host_order 75# define ripemd160_block_host_order ripemd160_block_asm_host_order
76# endif 76# endif
77#endif 77#endif
@@ -79,7 +79,7 @@
79void ripemd160_block_host_order (RIPEMD160_CTX *c, const void *p,int num); 79void ripemd160_block_host_order (RIPEMD160_CTX *c, const void *p,int num);
80void ripemd160_block_data_order (RIPEMD160_CTX *c, const void *p,int num); 80void ripemd160_block_data_order (RIPEMD160_CTX *c, const void *p,int num);
81 81
82#if defined(__i386) || defined(_M_IX86) || defined(__INTEL__) 82#if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__)
83#define ripemd160_block_data_order ripemd160_block_host_order 83#define ripemd160_block_data_order ripemd160_block_host_order
84#endif 84#endif
85 85
diff --git a/src/lib/libcrypto/ripemd/rmdtest.c b/src/lib/libcrypto/ripemd/rmdtest.c
index 5d79c99725..19e9741db2 100644
--- a/src/lib/libcrypto/ripemd/rmdtest.c
+++ b/src/lib/libcrypto/ripemd/rmdtest.c
@@ -59,15 +59,16 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <string.h> 60#include <string.h>
61#include <stdlib.h> 61#include <stdlib.h>
62#include <openssl/ripemd.h>
62 63
63#ifdef NO_RIPEMD 64#ifdef OPENSSL_NO_RIPEMD
64int main(int argc, char *argv[]) 65int main(int argc, char *argv[])
65{ 66{
66 printf("No ripemd support\n"); 67 printf("No ripemd support\n");
67 return(0); 68 return(0);
68} 69}
69#else 70#else
70#include <openssl/ripemd.h> 71#include <openssl/evp.h>
71 72
72#ifdef CHARSET_EBCDIC 73#ifdef CHARSET_EBCDIC
73#include <openssl/ebcdic.h> 74#include <openssl/ebcdic.h>
@@ -102,6 +103,7 @@ int main(int argc, char *argv[])
102 int i,err=0; 103 int i,err=0;
103 unsigned char **P,**R; 104 unsigned char **P,**R;
104 char *p; 105 char *p;
106 unsigned char md[RIPEMD160_DIGEST_LENGTH];
105 107
106 P=(unsigned char **)test; 108 P=(unsigned char **)test;
107 R=(unsigned char **)ret; 109 R=(unsigned char **)ret;
@@ -111,7 +113,8 @@ int main(int argc, char *argv[])
111#ifdef CHARSET_EBCDIC 113#ifdef CHARSET_EBCDIC
112 ebcdic2ascii((char *)*P, (char *)*P, strlen((char *)*P)); 114 ebcdic2ascii((char *)*P, (char *)*P, strlen((char *)*P));
113#endif 115#endif
114 p=pt(RIPEMD160(&(P[0][0]),(unsigned long)strlen((char *)*P),NULL)); 116 EVP_Digest(&(P[0][0]),(unsigned long)strlen((char *)*P),md,NULL,EVP_ripemd160(), NULL);
117 p=pt(md);
115 if (strcmp(p,(char *)*R) != 0) 118 if (strcmp(p,(char *)*R) != 0)
116 { 119 {
117 printf("error calculating RIPEMD160 on '%s'\n",*P); 120 printf("error calculating RIPEMD160 on '%s'\n",*P);
diff --git a/src/lib/libcrypto/rsa/Makefile.ssl b/src/lib/libcrypto/rsa/Makefile.ssl
index 2bee181d4e..8a9f7cbe0c 100644
--- a/src/lib/libcrypto/rsa/Makefile.ssl
+++ b/src/lib/libcrypto/rsa/Makefile.ssl
@@ -5,13 +5,14 @@
5DIR= rsa 5DIR= rsa
6TOP= ../.. 6TOP= ../..
7CC= cc 7CC= cc
8INCLUDES= -I.. -I../../include 8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g 9CFLAG=-g
10INSTALL_PREFIX= 10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl 11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl 12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl 13MAKE= make -f Makefile.ssl
14MAKEDEPEND= $(TOP)/util/domd $(TOP) 14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
15MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
16AR= ar r 17AR= ar r
17 18
@@ -23,9 +24,11 @@ APPS=
23 24
24LIB=$(TOP)/libcrypto.a 25LIB=$(TOP)/libcrypto.a
25LIBSRC= rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c rsa_saos.c rsa_err.c \ 26LIBSRC= rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c rsa_saos.c rsa_err.c \
26 rsa_pk1.c rsa_ssl.c rsa_none.c rsa_oaep.c rsa_chk.c rsa_null.c 27 rsa_pk1.c rsa_ssl.c rsa_none.c rsa_oaep.c rsa_chk.c rsa_null.c \
28 rsa_asn1.c
27LIBOBJ= rsa_eay.o rsa_gen.o rsa_lib.o rsa_sign.o rsa_saos.o rsa_err.o \ 29LIBOBJ= rsa_eay.o rsa_gen.o rsa_lib.o rsa_sign.o rsa_saos.o rsa_err.o \
28 rsa_pk1.o rsa_ssl.o rsa_none.o rsa_oaep.o rsa_chk.o rsa_null.o 30 rsa_pk1.o rsa_ssl.o rsa_none.o rsa_oaep.o rsa_chk.o rsa_null.o \
31 rsa_asn1.o
29 32
30SRC= $(LIBSRC) 33SRC= $(LIBSRC)
31 34
@@ -41,8 +44,7 @@ all: lib
41 44
42lib: $(LIBOBJ) 45lib: $(LIBOBJ)
43 $(AR) $(LIB) $(LIBOBJ) 46 $(AR) $(LIB) $(LIBOBJ)
44 @echo You may get an error following this line. Please ignore. 47 $(RANLIB) $(LIB) || echo Never mind.
45 - $(RANLIB) $(LIB)
46 @touch lib 48 @touch lib
47 49
48files: 50files:
@@ -81,141 +83,137 @@ clean:
81 83
82# DO NOT DELETE THIS LINE -- make depend depends on it. 84# DO NOT DELETE THIS LINE -- make depend depends on it.
83 85
84rsa_chk.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 86rsa_asn1.o: ../../e_os.h ../../include/openssl/asn1.h
85rsa_chk.o: ../../include/openssl/crypto.h ../../include/openssl/err.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
86rsa_chk.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 99rsa_chk.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
87rsa_chk.o: ../../include/openssl/opensslv.h ../../include/openssl/rsa.h 100rsa_chk.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
88rsa_chk.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 101rsa_chk.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
89rsa_chk.o: ../../include/openssl/symhacks.h 102rsa_chk.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
90rsa_eay.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 103rsa_chk.o: rsa_chk.c
91rsa_eay.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 104rsa_eay.o: ../../e_os.h ../../include/openssl/asn1.h
92rsa_eay.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 105rsa_eay.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
93rsa_eay.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 106rsa_eay.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
94rsa_eay.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 107rsa_eay.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
95rsa_eay.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 108rsa_eay.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
96rsa_eay.o: ../../include/openssl/engine.h ../../include/openssl/err.h 109rsa_eay.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
97rsa_eay.o: ../../include/openssl/evp.h ../../include/openssl/idea.h 110rsa_eay.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
98rsa_eay.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h 111rsa_eay.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
99rsa_eay.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
100rsa_eay.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
101rsa_eay.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
102rsa_eay.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
103rsa_eay.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
104rsa_eay.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
105rsa_eay.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 112rsa_eay.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
106rsa_eay.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 113rsa_eay.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
107rsa_eay.o: ../../include/openssl/symhacks.h ../cryptlib.h 114rsa_eay.o: ../../include/openssl/ui.h ../cryptlib.h rsa_eay.c
108rsa_err.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 115rsa_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
109rsa_err.o: ../../include/openssl/crypto.h ../../include/openssl/err.h 116rsa_err.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
117rsa_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
110rsa_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 118rsa_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
111rsa_err.o: ../../include/openssl/opensslv.h ../../include/openssl/rsa.h 119rsa_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
112rsa_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 120rsa_err.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
113rsa_err.o: ../../include/openssl/symhacks.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
114rsa_gen.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 124rsa_gen.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
115rsa_gen.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 125rsa_gen.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
116rsa_gen.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 126rsa_gen.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
117rsa_gen.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 127rsa_gen.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
118rsa_gen.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 128rsa_gen.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
119rsa_gen.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 129rsa_gen.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
120rsa_gen.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 130rsa_gen.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
121rsa_gen.o: ../cryptlib.h 131rsa_gen.o: ../cryptlib.h rsa_gen.c
122rsa_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 132rsa_lib.o: ../../e_os.h ../../include/openssl/asn1.h
123rsa_lib.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 133rsa_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
124rsa_lib.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 134rsa_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
125rsa_lib.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
126rsa_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 135rsa_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
127rsa_lib.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 136rsa_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
128rsa_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h 137rsa_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
129rsa_lib.o: ../../include/openssl/evp.h ../../include/openssl/idea.h 138rsa_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
130rsa_lib.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h 139rsa_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
131rsa_lib.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
132rsa_lib.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
133rsa_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
134rsa_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h
135rsa_lib.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
136rsa_lib.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
137rsa_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 140rsa_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
138rsa_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 141rsa_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
139rsa_lib.o: ../../include/openssl/symhacks.h ../cryptlib.h 142rsa_lib.o: ../../include/openssl/ui.h ../cryptlib.h rsa_lib.c
143rsa_none.o: ../../e_os.h ../../include/openssl/asn1.h
140rsa_none.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 144rsa_none.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
141rsa_none.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 145rsa_none.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
142rsa_none.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 146rsa_none.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
143rsa_none.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 147rsa_none.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
144rsa_none.o: ../../include/openssl/opensslconf.h 148rsa_none.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
145rsa_none.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 149rsa_none.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
146rsa_none.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 150rsa_none.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
147rsa_none.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 151rsa_none.o: ../../include/openssl/symhacks.h ../cryptlib.h rsa_none.c
148rsa_none.o: ../cryptlib.h 152rsa_null.o: ../../e_os.h ../../include/openssl/asn1.h
149rsa_null.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 153rsa_null.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
150rsa_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 154rsa_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
151rsa_null.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 155rsa_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
152rsa_null.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 156rsa_null.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
153rsa_null.o: ../../include/openssl/opensslconf.h 157rsa_null.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
154rsa_null.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 158rsa_null.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
155rsa_null.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 159rsa_null.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
156rsa_null.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 160rsa_null.o: ../../include/openssl/symhacks.h ../cryptlib.h rsa_null.c
157rsa_null.o: ../cryptlib.h 161rsa_oaep.o: ../../e_os.h ../../include/openssl/asn1.h
158rsa_oaep.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 162rsa_oaep.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
159rsa_oaep.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 163rsa_oaep.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
160rsa_oaep.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 164rsa_oaep.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
161rsa_oaep.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 165rsa_oaep.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
166rsa_oaep.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
162rsa_oaep.o: ../../include/openssl/opensslconf.h 167rsa_oaep.o: ../../include/openssl/opensslconf.h
163rsa_oaep.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h 168rsa_oaep.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
164rsa_oaep.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 169rsa_oaep.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
165rsa_oaep.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 170rsa_oaep.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
166rsa_oaep.o: ../../include/openssl/symhacks.h ../cryptlib.h 171rsa_oaep.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
172rsa_oaep.o: ../cryptlib.h rsa_oaep.c
173rsa_pk1.o: ../../e_os.h ../../include/openssl/asn1.h
167rsa_pk1.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 174rsa_pk1.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
168rsa_pk1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 175rsa_pk1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
169rsa_pk1.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 176rsa_pk1.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
170rsa_pk1.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 177rsa_pk1.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
171rsa_pk1.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 178rsa_pk1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
172rsa_pk1.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h 179rsa_pk1.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
173rsa_pk1.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 180rsa_pk1.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
174rsa_pk1.o: ../../include/openssl/symhacks.h ../cryptlib.h 181rsa_pk1.o: ../../include/openssl/symhacks.h ../cryptlib.h rsa_pk1.c
175rsa_saos.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 182rsa_saos.o: ../../e_os.h ../../include/openssl/asn1.h
176rsa_saos.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 183rsa_saos.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
177rsa_saos.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 184rsa_saos.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
178rsa_saos.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
179rsa_saos.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 185rsa_saos.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
180rsa_saos.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 186rsa_saos.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
181rsa_saos.o: ../../include/openssl/err.h ../../include/openssl/evp.h 187rsa_saos.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
182rsa_saos.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
183rsa_saos.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
184rsa_saos.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
185rsa_saos.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 188rsa_saos.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
186rsa_saos.o: ../../include/openssl/opensslconf.h 189rsa_saos.o: ../../include/openssl/opensslconf.h
187rsa_saos.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 190rsa_saos.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
188rsa_saos.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 191rsa_saos.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
189rsa_saos.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 192rsa_saos.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
190rsa_saos.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 193rsa_saos.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
191rsa_saos.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 194rsa_saos.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
192rsa_saos.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 195rsa_saos.o: ../cryptlib.h rsa_saos.c
193rsa_saos.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 196rsa_sign.o: ../../e_os.h ../../include/openssl/asn1.h
194rsa_sign.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 197rsa_sign.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
195rsa_sign.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 198rsa_sign.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
196rsa_sign.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
197rsa_sign.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
198rsa_sign.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 199rsa_sign.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
199rsa_sign.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 200rsa_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
200rsa_sign.o: ../../include/openssl/engine.h ../../include/openssl/err.h 201rsa_sign.o: ../../include/openssl/err.h ../../include/openssl/evp.h
201rsa_sign.o: ../../include/openssl/evp.h ../../include/openssl/idea.h 202rsa_sign.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
202rsa_sign.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
203rsa_sign.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
204rsa_sign.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
205rsa_sign.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 203rsa_sign.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
206rsa_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 204rsa_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
207rsa_sign.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h 205rsa_sign.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
208rsa_sign.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 206rsa_sign.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
209rsa_sign.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 207rsa_sign.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
210rsa_sign.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 208rsa_sign.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
211rsa_sign.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
212rsa_sign.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 209rsa_sign.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
213rsa_sign.o: ../cryptlib.h 210rsa_sign.o: ../cryptlib.h rsa_sign.c
211rsa_ssl.o: ../../e_os.h ../../include/openssl/asn1.h
214rsa_ssl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 212rsa_ssl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
215rsa_ssl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 213rsa_ssl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
216rsa_ssl.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 214rsa_ssl.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
217rsa_ssl.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 215rsa_ssl.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
218rsa_ssl.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 216rsa_ssl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
219rsa_ssl.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h 217rsa_ssl.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
220rsa_ssl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 218rsa_ssl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
221rsa_ssl.o: ../../include/openssl/symhacks.h ../cryptlib.h 219rsa_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 bda636a365..030a6c88e5 100644
--- a/src/lib/libcrypto/rsa/rsa.h
+++ b/src/lib/libcrypto/rsa/rsa.h
@@ -59,13 +59,16 @@
59#ifndef HEADER_RSA_H 59#ifndef HEADER_RSA_H
60#define HEADER_RSA_H 60#define HEADER_RSA_H
61 61
62#ifndef NO_BIO 62#include <openssl/asn1.h>
63
64#ifndef OPENSSL_NO_BIO
63#include <openssl/bio.h> 65#include <openssl/bio.h>
64#endif 66#endif
65#include <openssl/bn.h> 67#include <openssl/bn.h>
66#include <openssl/crypto.h> 68#include <openssl/crypto.h>
69#include <openssl/ossl_typ.h>
67 70
68#ifdef NO_RSA 71#ifdef OPENSSL_NO_RSA
69#error RSA is disabled. 72#error RSA is disabled.
70#endif 73#endif
71 74
@@ -78,16 +81,20 @@ typedef struct rsa_st RSA;
78typedef struct rsa_meth_st 81typedef struct rsa_meth_st
79 { 82 {
80 const char *name; 83 const char *name;
81 int (*rsa_pub_enc)(int flen,unsigned char *from,unsigned char *to, 84 int (*rsa_pub_enc)(int flen,const unsigned char *from,
85 unsigned char *to,
82 RSA *rsa,int padding); 86 RSA *rsa,int padding);
83 int (*rsa_pub_dec)(int flen,unsigned char *from,unsigned char *to, 87 int (*rsa_pub_dec)(int flen,const unsigned char *from,
88 unsigned char *to,
84 RSA *rsa,int padding); 89 RSA *rsa,int padding);
85 int (*rsa_priv_enc)(int flen,unsigned char *from,unsigned char *to, 90 int (*rsa_priv_enc)(int flen,const unsigned char *from,
91 unsigned char *to,
86 RSA *rsa,int padding); 92 RSA *rsa,int padding);
87 int (*rsa_priv_dec)(int flen,unsigned char *from,unsigned char *to, 93 int (*rsa_priv_dec)(int flen,const unsigned char *from,
94 unsigned char *to,
88 RSA *rsa,int padding); 95 RSA *rsa,int padding);
89 int (*rsa_mod_exp)(BIGNUM *r0,BIGNUM *I,RSA *rsa); /* Can be null */ 96 int (*rsa_mod_exp)(BIGNUM *r0,const BIGNUM *I,RSA *rsa); /* Can be null */
90 int (*bn_mod_exp)(BIGNUM *r, BIGNUM *a, const BIGNUM *p, 97 int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
91 const BIGNUM *m, BN_CTX *ctx, 98 const BIGNUM *m, BN_CTX *ctx,
92 BN_MONT_CTX *m_ctx); /* Can be null */ 99 BN_MONT_CTX *m_ctx); /* Can be null */
93 int (*init)(RSA *rsa); /* called at new */ 100 int (*init)(RSA *rsa); /* called at new */
@@ -101,10 +108,12 @@ typedef struct rsa_meth_st
101 * compatibility this functionality is only enabled if the RSA_FLAG_SIGN_VER 108 * compatibility this functionality is only enabled if the RSA_FLAG_SIGN_VER
102 * option is set in 'flags'. 109 * option is set in 'flags'.
103 */ 110 */
104 int (*rsa_sign)(int type, unsigned char *m, unsigned int m_len, 111 int (*rsa_sign)(int type,
105 unsigned char *sigret, unsigned int *siglen, RSA *rsa); 112 const unsigned char *m, unsigned int m_length,
106 int (*rsa_verify)(int dtype, unsigned char *m, unsigned int m_len, 113 unsigned char *sigret, unsigned int *siglen, const RSA *rsa);
107 unsigned char *sigbuf, unsigned int siglen, RSA *rsa); 114 int (*rsa_verify)(int dtype,
115 const unsigned char *m, unsigned int m_length,
116 unsigned char *sigbuf, unsigned int siglen, const RSA *rsa);
108 117
109 } RSA_METHOD; 118 } RSA_METHOD;
110 119
@@ -113,12 +122,10 @@ struct rsa_st
113 /* The first parameter is used to pickup errors where 122 /* The first parameter is used to pickup errors where
114 * this is passed instead of aEVP_PKEY, it is set to 0 */ 123 * this is passed instead of aEVP_PKEY, it is set to 0 */
115 int pad; 124 int pad;
116 int version; 125 long version;
117#if 0 126 const RSA_METHOD *meth;
118 RSA_METHOD *meth; 127 /* functional reference if 'meth' is ENGINE-provided */
119#else 128 ENGINE *engine;
120 struct engine_st *engine;
121#endif
122 BIGNUM *n; 129 BIGNUM *n;
123 BIGNUM *e; 130 BIGNUM *e;
124 BIGNUM *d; 131 BIGNUM *d;
@@ -172,121 +179,108 @@ struct rsa_st
172#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)
173 180
174RSA * RSA_new(void); 181RSA * RSA_new(void);
175#if 0 182RSA * RSA_new_method(ENGINE *engine);
176RSA * RSA_new_method(RSA_METHOD *method); 183int RSA_size(const RSA *);
177#else
178RSA * RSA_new_method(struct engine_st *engine);
179#endif
180int RSA_size(RSA *);
181RSA * RSA_generate_key(int bits, unsigned long e,void 184RSA * RSA_generate_key(int bits, unsigned long e,void
182 (*callback)(int,int,void *),void *cb_arg); 185 (*callback)(int,int,void *),void *cb_arg);
183int RSA_check_key(RSA *); 186int RSA_check_key(const RSA *);
184 /* next 4 return -1 on error */ 187 /* next 4 return -1 on error */
185int RSA_public_encrypt(int flen, unsigned char *from, 188int RSA_public_encrypt(int flen, const unsigned char *from,
186 unsigned char *to, RSA *rsa,int padding); 189 unsigned char *to, RSA *rsa,int padding);
187int RSA_private_encrypt(int flen, unsigned char *from, 190int RSA_private_encrypt(int flen, const unsigned char *from,
188 unsigned char *to, RSA *rsa,int padding); 191 unsigned char *to, RSA *rsa,int padding);
189int RSA_public_decrypt(int flen, unsigned char *from, 192int RSA_public_decrypt(int flen, const unsigned char *from,
190 unsigned char *to, RSA *rsa,int padding); 193 unsigned char *to, RSA *rsa,int padding);
191int RSA_private_decrypt(int flen, unsigned char *from, 194int RSA_private_decrypt(int flen, const unsigned char *from,
192 unsigned char *to, RSA *rsa,int padding); 195 unsigned char *to, RSA *rsa,int padding);
193void RSA_free (RSA *r); 196void RSA_free (RSA *r);
197/* "up" the RSA object's reference count */
198int RSA_up_ref(RSA *r);
194 199
195int RSA_flags(RSA *r); 200int RSA_flags(const RSA *r);
196 201
197void RSA_set_default_openssl_method(RSA_METHOD *meth); 202void RSA_set_default_method(const RSA_METHOD *meth);
198RSA_METHOD *RSA_get_default_openssl_method(void); 203const RSA_METHOD *RSA_get_default_method(void);
199RSA_METHOD *RSA_get_method(RSA *rsa); 204const RSA_METHOD *RSA_get_method(const RSA *rsa);
200#if 0 205int RSA_set_method(RSA *rsa, const RSA_METHOD *meth);
201RSA_METHOD *RSA_set_method(RSA *rsa, RSA_METHOD *meth);
202#else
203int RSA_set_method(RSA *rsa, struct engine_st *engine);
204#endif
205 206
206/* This function needs the memory locking malloc callbacks to be installed */ 207/* This function needs the memory locking malloc callbacks to be installed */
207int RSA_memory_lock(RSA *r); 208int RSA_memory_lock(RSA *r);
208 209
209/* If you have RSAref compiled in. */
210RSA_METHOD *RSA_PKCS1_RSAref(void);
211
212/* these are the actual SSLeay RSA functions */ 210/* these are the actual SSLeay RSA functions */
213RSA_METHOD *RSA_PKCS1_SSLeay(void); 211const RSA_METHOD *RSA_PKCS1_SSLeay(void);
214 212
215RSA_METHOD *RSA_null_method(void); 213const RSA_METHOD *RSA_null_method(void);
216 214
217void ERR_load_RSA_strings(void ); 215DECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPublicKey)
216DECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPrivateKey)
218 217
219RSA * d2i_RSAPublicKey(RSA **a, unsigned char **pp, long length); 218#ifndef OPENSSL_NO_FP_API
220int i2d_RSAPublicKey(RSA *a, unsigned char **pp); 219int RSA_print_fp(FILE *fp, const RSA *r,int offset);
221RSA * d2i_RSAPrivateKey(RSA **a, unsigned char **pp, long length);
222int i2d_RSAPrivateKey(RSA *a, unsigned char **pp);
223#ifndef NO_FP_API
224int RSA_print_fp(FILE *fp, RSA *r,int offset);
225#endif 220#endif
226 221
227#ifndef NO_BIO 222#ifndef OPENSSL_NO_BIO
228int RSA_print(BIO *bp, RSA *r,int offset); 223int RSA_print(BIO *bp, const RSA *r,int offset);
229#endif 224#endif
230 225
231int i2d_RSA_NET(RSA *a, unsigned char **pp, int (*cb)(), int sgckey); 226int i2d_RSA_NET(const RSA *a, unsigned char **pp, int (*cb)(), int sgckey);
232RSA *d2i_RSA_NET(RSA **a, unsigned char **pp, long length, int (*cb)(), int sgckey); 227RSA *d2i_RSA_NET(RSA **a, const unsigned char **pp, long length, int (*cb)(), int sgckey);
233RSA *d2i_RSA_NET_2(RSA **a, unsigned char **pp, long length, int (*cb)(), int sgckey);
234 228
235int i2d_Netscape_RSA(RSA *a, unsigned char **pp, int (*cb)()); 229int i2d_Netscape_RSA(const RSA *a, unsigned char **pp, int (*cb)());
236RSA *d2i_Netscape_RSA(RSA **a, unsigned char **pp, long length, int (*cb)()); 230RSA *d2i_Netscape_RSA(RSA **a, const unsigned char **pp, long length, int (*cb)());
237/* Naughty internal function required elsewhere, to handle a MS structure
238 * that is the same as the netscape one :-) */
239RSA *d2i_Netscape_RSA_2(RSA **a, unsigned char **pp, long length, int (*cb)());
240 231
241/* The following 2 functions sign and verify a X509_SIG ASN1 object 232/* The following 2 functions sign and verify a X509_SIG ASN1 object
242 * inside PKCS#1 padded RSA encryption */ 233 * inside PKCS#1 padded RSA encryption */
243int RSA_sign(int type, unsigned char *m, unsigned int m_len, 234int RSA_sign(int type, const unsigned char *m, unsigned int m_length,
244 unsigned char *sigret, unsigned int *siglen, RSA *rsa); 235 unsigned char *sigret, unsigned int *siglen, RSA *rsa);
245int RSA_verify(int type, unsigned char *m, unsigned int m_len, 236int RSA_verify(int type, const unsigned char *m, unsigned int m_length,
246 unsigned char *sigbuf, unsigned int siglen, RSA *rsa); 237 unsigned char *sigbuf, unsigned int siglen, RSA *rsa);
247 238
248/* The following 2 function sign and verify a ASN1_OCTET_STRING 239/* The following 2 function sign and verify a ASN1_OCTET_STRING
249 * object inside PKCS#1 padded RSA encryption */ 240 * object inside PKCS#1 padded RSA encryption */
250int RSA_sign_ASN1_OCTET_STRING(int type, unsigned char *m, unsigned int m_len, 241int RSA_sign_ASN1_OCTET_STRING(int type,
242 const unsigned char *m, unsigned int m_length,
251 unsigned char *sigret, unsigned int *siglen, RSA *rsa); 243 unsigned char *sigret, unsigned int *siglen, RSA *rsa);
252int RSA_verify_ASN1_OCTET_STRING(int type, unsigned char *m, unsigned int m_len, 244int RSA_verify_ASN1_OCTET_STRING(int type,
245 const unsigned char *m, unsigned int m_length,
253 unsigned char *sigbuf, unsigned int siglen, RSA *rsa); 246 unsigned char *sigbuf, unsigned int siglen, RSA *rsa);
254 247
255int RSA_blinding_on(RSA *rsa, BN_CTX *ctx); 248int RSA_blinding_on(RSA *rsa, BN_CTX *ctx);
256void RSA_blinding_off(RSA *rsa); 249void RSA_blinding_off(RSA *rsa);
257 250
258int RSA_padding_add_PKCS1_type_1(unsigned char *to,int tlen, 251int RSA_padding_add_PKCS1_type_1(unsigned char *to,int tlen,
259 unsigned char *f,int fl); 252 const unsigned char *f,int fl);
260int RSA_padding_check_PKCS1_type_1(unsigned char *to,int tlen, 253int RSA_padding_check_PKCS1_type_1(unsigned char *to,int tlen,
261 unsigned char *f,int fl,int rsa_len); 254 const unsigned char *f,int fl,int rsa_len);
262int RSA_padding_add_PKCS1_type_2(unsigned char *to,int tlen, 255int RSA_padding_add_PKCS1_type_2(unsigned char *to,int tlen,
263 unsigned char *f,int fl); 256 const unsigned char *f,int fl);
264int RSA_padding_check_PKCS1_type_2(unsigned char *to,int tlen, 257int RSA_padding_check_PKCS1_type_2(unsigned char *to,int tlen,
265 unsigned char *f,int fl,int rsa_len); 258 const unsigned char *f,int fl,int rsa_len);
266int RSA_padding_add_PKCS1_OAEP(unsigned char *to,int tlen, 259int RSA_padding_add_PKCS1_OAEP(unsigned char *to,int tlen,
267 unsigned char *f,int fl,unsigned char *p, 260 const unsigned char *f,int fl,
268 int pl); 261 const unsigned char *p,int pl);
269int RSA_padding_check_PKCS1_OAEP(unsigned char *to,int tlen, 262int RSA_padding_check_PKCS1_OAEP(unsigned char *to,int tlen,
270 unsigned char *f,int fl,int rsa_len, 263 const unsigned char *f,int fl,int rsa_len,
271 unsigned char *p,int pl); 264 const unsigned char *p,int pl);
272int RSA_padding_add_SSLv23(unsigned char *to,int tlen, 265int RSA_padding_add_SSLv23(unsigned char *to,int tlen,
273 unsigned char *f,int fl); 266 const unsigned char *f,int fl);
274int RSA_padding_check_SSLv23(unsigned char *to,int tlen, 267int RSA_padding_check_SSLv23(unsigned char *to,int tlen,
275 unsigned char *f,int fl,int rsa_len); 268 const unsigned char *f,int fl,int rsa_len);
276int RSA_padding_add_none(unsigned char *to,int tlen, 269int RSA_padding_add_none(unsigned char *to,int tlen,
277 unsigned char *f,int fl); 270 const unsigned char *f,int fl);
278int RSA_padding_check_none(unsigned char *to,int tlen, 271int RSA_padding_check_none(unsigned char *to,int tlen,
279 unsigned char *f,int fl,int rsa_len); 272 const unsigned char *f,int fl,int rsa_len);
280 273
281int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, 274int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
282 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); 275 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
283int RSA_set_ex_data(RSA *r,int idx,void *arg); 276int RSA_set_ex_data(RSA *r,int idx,void *arg);
284void *RSA_get_ex_data(RSA *r, int idx); 277void *RSA_get_ex_data(const RSA *r, int idx);
285 278
286/* BEGIN ERROR CODES */ 279/* BEGIN ERROR CODES */
287/* The following lines are auto generated by the script mkerr.pl. Any changes 280/* The following lines are auto generated by the script mkerr.pl. Any changes
288 * made after this point may be overwritten when the script is next run. 281 * made after this point may be overwritten when the script is next run.
289 */ 282 */
283void ERR_load_RSA_strings(void);
290 284
291/* Error codes for the RSA functions. */ 285/* Error codes for the RSA functions. */
292 286
@@ -328,6 +322,7 @@ void *RSA_get_ex_data(RSA *r, int idx);
328#define RSA_R_DATA_GREATER_THAN_MOD_LEN 108 322#define RSA_R_DATA_GREATER_THAN_MOD_LEN 108
329#define RSA_R_DATA_TOO_LARGE 109 323#define RSA_R_DATA_TOO_LARGE 109
330#define RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 110 324#define RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 110
325#define RSA_R_DATA_TOO_LARGE_FOR_MODULUS 132
331#define RSA_R_DATA_TOO_SMALL 111 326#define RSA_R_DATA_TOO_SMALL 111
332#define RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE 122 327#define RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE 122
333#define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY 112 328#define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY 112
@@ -354,4 +349,3 @@ void *RSA_get_ex_data(RSA *r, int idx);
354} 349}
355#endif 350#endif
356#endif 351#endif
357
diff --git a/src/lib/libcrypto/rsa/rsa_asn1.c b/src/lib/libcrypto/rsa/rsa_asn1.c
new file mode 100644
index 0000000000..1455a7e0e4
--- /dev/null
+++ b/src/lib/libcrypto/rsa/rsa_asn1.c
@@ -0,0 +1,121 @@
1/* rsa_asn1.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) 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/bn.h>
62#include <openssl/rsa.h>
63#include <openssl/asn1t.h>
64
65static ASN1_METHOD method={
66 (int (*)()) i2d_RSAPrivateKey,
67 (char *(*)())d2i_RSAPrivateKey,
68 (char *(*)())RSA_new,
69 (void (*)()) RSA_free};
70
71ASN1_METHOD *RSAPrivateKey_asn1_meth(void)
72 {
73 return(&method);
74 }
75
76/* Override the default free and new methods */
77static int rsa_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it)
78{
79 if(operation == ASN1_OP_NEW_PRE) {
80 *pval = (ASN1_VALUE *)RSA_new();
81 if(*pval) return 2;
82 return 0;
83 } else if(operation == ASN1_OP_FREE_PRE) {
84 RSA_free((RSA *)*pval);
85 *pval = NULL;
86 return 2;
87 }
88 return 1;
89}
90
91ASN1_SEQUENCE_cb(RSAPrivateKey, rsa_cb) = {
92 ASN1_SIMPLE(RSA, version, LONG),
93 ASN1_SIMPLE(RSA, n, BIGNUM),
94 ASN1_SIMPLE(RSA, e, BIGNUM),
95 ASN1_SIMPLE(RSA, d, BIGNUM),
96 ASN1_SIMPLE(RSA, p, BIGNUM),
97 ASN1_SIMPLE(RSA, q, BIGNUM),
98 ASN1_SIMPLE(RSA, dmp1, BIGNUM),
99 ASN1_SIMPLE(RSA, dmq1, BIGNUM),
100 ASN1_SIMPLE(RSA, iqmp, BIGNUM)
101} ASN1_SEQUENCE_END_cb(RSA, RSAPrivateKey)
102
103
104ASN1_SEQUENCE_cb(RSAPublicKey, rsa_cb) = {
105 ASN1_SIMPLE(RSA, n, BIGNUM),
106 ASN1_SIMPLE(RSA, e, BIGNUM),
107} ASN1_SEQUENCE_END_cb(RSA, RSAPublicKey)
108
109IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(RSA, RSAPrivateKey, RSAPrivateKey)
110
111IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(RSA, RSAPublicKey, RSAPublicKey)
112
113RSA *RSAPublicKey_dup(RSA *rsa)
114 {
115 return ASN1_item_dup(ASN1_ITEM_rptr(RSAPublicKey), rsa);
116 }
117
118RSA *RSAPrivateKey_dup(RSA *rsa)
119 {
120 return ASN1_item_dup(ASN1_ITEM_rptr(RSAPrivateKey), rsa);
121 }
diff --git a/src/lib/libcrypto/rsa/rsa_chk.c b/src/lib/libcrypto/rsa/rsa_chk.c
index 91b9115798..002f2cb487 100644
--- a/src/lib/libcrypto/rsa/rsa_chk.c
+++ b/src/lib/libcrypto/rsa/rsa_chk.c
@@ -53,7 +53,7 @@
53#include <openssl/rsa.h> 53#include <openssl/rsa.h>
54 54
55 55
56int RSA_check_key(RSA *key) 56int RSA_check_key(const RSA *key)
57 { 57 {
58 BIGNUM *i, *j, *k, *l, *m; 58 BIGNUM *i, *j, *k, *l, *m;
59 BN_CTX *ctx; 59 BN_CTX *ctx;
diff --git a/src/lib/libcrypto/rsa/rsa_eay.c b/src/lib/libcrypto/rsa/rsa_eay.c
index cde5ca27d5..d82dd15493 100644
--- a/src/lib/libcrypto/rsa/rsa_eay.c
+++ b/src/lib/libcrypto/rsa/rsa_eay.c
@@ -65,46 +65,46 @@
65 65
66#ifndef RSA_NULL 66#ifndef RSA_NULL
67 67
68static int RSA_eay_public_encrypt(int flen, unsigned char *from, 68static int RSA_eay_public_encrypt(int flen, const unsigned char *from,
69 unsigned char *to, RSA *rsa,int padding); 69 unsigned char *to, RSA *rsa,int padding);
70static int RSA_eay_private_encrypt(int flen, unsigned char *from, 70static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
71 unsigned char *to, RSA *rsa,int padding); 71 unsigned char *to, RSA *rsa,int padding);
72static int RSA_eay_public_decrypt(int flen, unsigned char *from, 72static int RSA_eay_public_decrypt(int flen, const unsigned char *from,
73 unsigned char *to, RSA *rsa,int padding); 73 unsigned char *to, RSA *rsa,int padding);
74static int RSA_eay_private_decrypt(int flen, unsigned char *from, 74static int RSA_eay_private_decrypt(int flen, const unsigned char *from,
75 unsigned char *to, RSA *rsa,int padding); 75 unsigned char *to, RSA *rsa,int padding);
76static int RSA_eay_mod_exp(BIGNUM *r0, BIGNUM *i, RSA *rsa); 76static int RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *i, RSA *rsa);
77static int RSA_eay_init(RSA *rsa); 77static int RSA_eay_init(RSA *rsa);
78static int RSA_eay_finish(RSA *rsa); 78static int RSA_eay_finish(RSA *rsa);
79static RSA_METHOD rsa_pkcs1_eay_meth={ 79static RSA_METHOD rsa_pkcs1_eay_meth={
80 "Eric Young's PKCS#1 RSA", 80 "Eric Young's PKCS#1 RSA",
81 RSA_eay_public_encrypt, 81 RSA_eay_public_encrypt,
82 RSA_eay_public_decrypt, 82 RSA_eay_public_decrypt, /* signature verification */
83 RSA_eay_private_encrypt, 83 RSA_eay_private_encrypt, /* signing */
84 RSA_eay_private_decrypt, 84 RSA_eay_private_decrypt,
85 RSA_eay_mod_exp, 85 RSA_eay_mod_exp,
86 BN_mod_exp_mont, 86 BN_mod_exp_mont, /* XXX probably we should not use Montgomery if e == 3 */
87 RSA_eay_init, 87 RSA_eay_init,
88 RSA_eay_finish, 88 RSA_eay_finish,
89 0, 89 0, /* flags */
90 NULL, 90 NULL,
91 0, /* rsa_sign */
92 0 /* rsa_verify */
91 }; 93 };
92 94
93RSA_METHOD *RSA_PKCS1_SSLeay(void) 95const RSA_METHOD *RSA_PKCS1_SSLeay(void)
94 { 96 {
95 return(&rsa_pkcs1_eay_meth); 97 return(&rsa_pkcs1_eay_meth);
96 } 98 }
97 99
98static int RSA_eay_public_encrypt(int flen, unsigned char *from, 100static int RSA_eay_public_encrypt(int flen, const unsigned char *from,
99 unsigned char *to, RSA *rsa, int padding) 101 unsigned char *to, RSA *rsa, int padding)
100 { 102 {
101 const RSA_METHOD *meth;
102 BIGNUM f,ret; 103 BIGNUM f,ret;
103 int i,j,k,num=0,r= -1; 104 int i,j,k,num=0,r= -1;
104 unsigned char *buf=NULL; 105 unsigned char *buf=NULL;
105 BN_CTX *ctx=NULL; 106 BN_CTX *ctx=NULL;
106 107
107 meth = ENGINE_get_RSA(rsa->engine);
108 BN_init(&f); 108 BN_init(&f);
109 BN_init(&ret); 109 BN_init(&ret);
110 if ((ctx=BN_CTX_new()) == NULL) goto err; 110 if ((ctx=BN_CTX_new()) == NULL) goto err;
@@ -120,7 +120,7 @@ static int RSA_eay_public_encrypt(int flen, unsigned char *from,
120 case RSA_PKCS1_PADDING: 120 case RSA_PKCS1_PADDING:
121 i=RSA_padding_add_PKCS1_type_2(buf,num,from,flen); 121 i=RSA_padding_add_PKCS1_type_2(buf,num,from,flen);
122 break; 122 break;
123#ifndef NO_SHA 123#ifndef OPENSSL_NO_SHA
124 case RSA_PKCS1_OAEP_PADDING: 124 case RSA_PKCS1_OAEP_PADDING:
125 i=RSA_padding_add_PKCS1_OAEP(buf,num,from,flen,NULL,0); 125 i=RSA_padding_add_PKCS1_OAEP(buf,num,from,flen,NULL,0);
126 break; 126 break;
@@ -139,6 +139,13 @@ static int RSA_eay_public_encrypt(int flen, unsigned char *from,
139 139
140 if (BN_bin2bn(buf,num,&f) == NULL) goto err; 140 if (BN_bin2bn(buf,num,&f) == NULL) goto err;
141 141
142 if (BN_ucmp(&f, rsa->n) >= 0)
143 {
144 /* usually the padding functions would catch this */
145 RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT,RSA_R_DATA_TOO_LARGE_FOR_MODULUS);
146 goto err;
147 }
148
142 if ((rsa->_method_mod_n == NULL) && (rsa->flags & RSA_FLAG_CACHE_PUBLIC)) 149 if ((rsa->_method_mod_n == NULL) && (rsa->flags & RSA_FLAG_CACHE_PUBLIC))
143 { 150 {
144 BN_MONT_CTX* bn_mont_ctx; 151 BN_MONT_CTX* bn_mont_ctx;
@@ -162,8 +169,8 @@ static int RSA_eay_public_encrypt(int flen, unsigned char *from,
162 if (bn_mont_ctx) 169 if (bn_mont_ctx)
163 BN_MONT_CTX_free(bn_mont_ctx); 170 BN_MONT_CTX_free(bn_mont_ctx);
164 } 171 }
165 172
166 if (!meth->bn_mod_exp(&ret,&f,rsa->e,rsa->n,ctx, 173 if (!rsa->meth->bn_mod_exp(&ret,&f,rsa->e,rsa->n,ctx,
167 rsa->_method_mod_n)) goto err; 174 rsa->_method_mod_n)) goto err;
168 175
169 /* put in leading 0 bytes if the number is less than the 176 /* put in leading 0 bytes if the number is less than the
@@ -186,16 +193,15 @@ err:
186 return(r); 193 return(r);
187 } 194 }
188 195
189static int RSA_eay_private_encrypt(int flen, unsigned char *from, 196/* signing */
197static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
190 unsigned char *to, RSA *rsa, int padding) 198 unsigned char *to, RSA *rsa, int padding)
191 { 199 {
192 const RSA_METHOD *meth;
193 BIGNUM f,ret; 200 BIGNUM f,ret;
194 int i,j,k,num=0,r= -1; 201 int i,j,k,num=0,r= -1;
195 unsigned char *buf=NULL; 202 unsigned char *buf=NULL;
196 BN_CTX *ctx=NULL; 203 BN_CTX *ctx=NULL;
197 204
198 meth = ENGINE_get_RSA(rsa->engine);
199 BN_init(&f); 205 BN_init(&f);
200 BN_init(&ret); 206 BN_init(&ret);
201 207
@@ -223,6 +229,13 @@ static int RSA_eay_private_encrypt(int flen, unsigned char *from,
223 if (i <= 0) goto err; 229 if (i <= 0) goto err;
224 230
225 if (BN_bin2bn(buf,num,&f) == NULL) goto err; 231 if (BN_bin2bn(buf,num,&f) == NULL) goto err;
232
233 if (BN_ucmp(&f, rsa->n) >= 0)
234 {
235 /* usually the padding functions would catch this */
236 RSAerr(RSA_F_RSA_EAY_PRIVATE_ENCRYPT,RSA_R_DATA_TOO_LARGE_FOR_MODULUS);
237 goto err;
238 }
226 239
227 if ((rsa->flags & RSA_FLAG_BLINDING) && (rsa->blinding == NULL)) 240 if ((rsa->flags & RSA_FLAG_BLINDING) && (rsa->blinding == NULL))
228 RSA_blinding_on(rsa,ctx); 241 RSA_blinding_on(rsa,ctx);
@@ -235,10 +248,10 @@ static int RSA_eay_private_encrypt(int flen, unsigned char *from,
235 (rsa->dmp1 != NULL) && 248 (rsa->dmp1 != NULL) &&
236 (rsa->dmq1 != NULL) && 249 (rsa->dmq1 != NULL) &&
237 (rsa->iqmp != NULL)) ) 250 (rsa->iqmp != NULL)) )
238 { if (!meth->rsa_mod_exp(&ret,&f,rsa)) goto err; } 251 { if (!rsa->meth->rsa_mod_exp(&ret,&f,rsa)) goto err; }
239 else 252 else
240 { 253 {
241 if (!meth->bn_mod_exp(&ret,&f,rsa->d,rsa->n,ctx,NULL)) goto err; 254 if (!rsa->meth->bn_mod_exp(&ret,&f,rsa->d,rsa->n,ctx,NULL)) goto err;
242 } 255 }
243 256
244 if (rsa->flags & RSA_FLAG_BLINDING) 257 if (rsa->flags & RSA_FLAG_BLINDING)
@@ -264,17 +277,15 @@ err:
264 return(r); 277 return(r);
265 } 278 }
266 279
267static int RSA_eay_private_decrypt(int flen, unsigned char *from, 280static int RSA_eay_private_decrypt(int flen, const unsigned char *from,
268 unsigned char *to, RSA *rsa, int padding) 281 unsigned char *to, RSA *rsa, int padding)
269 { 282 {
270 const RSA_METHOD *meth;
271 BIGNUM f,ret; 283 BIGNUM f,ret;
272 int j,num=0,r= -1; 284 int j,num=0,r= -1;
273 unsigned char *p; 285 unsigned char *p;
274 unsigned char *buf=NULL; 286 unsigned char *buf=NULL;
275 BN_CTX *ctx=NULL; 287 BN_CTX *ctx=NULL;
276 288
277 meth = ENGINE_get_RSA(rsa->engine);
278 BN_init(&f); 289 BN_init(&f);
279 BN_init(&ret); 290 BN_init(&ret);
280 ctx=BN_CTX_new(); 291 ctx=BN_CTX_new();
@@ -299,6 +310,12 @@ static int RSA_eay_private_decrypt(int flen, unsigned char *from,
299 /* make data into a big number */ 310 /* make data into a big number */
300 if (BN_bin2bn(from,(int)flen,&f) == NULL) goto err; 311 if (BN_bin2bn(from,(int)flen,&f) == NULL) goto err;
301 312
313 if (BN_ucmp(&f, rsa->n) >= 0)
314 {
315 RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT,RSA_R_DATA_TOO_LARGE_FOR_MODULUS);
316 goto err;
317 }
318
302 if ((rsa->flags & RSA_FLAG_BLINDING) && (rsa->blinding == NULL)) 319 if ((rsa->flags & RSA_FLAG_BLINDING) && (rsa->blinding == NULL))
303 RSA_blinding_on(rsa,ctx); 320 RSA_blinding_on(rsa,ctx);
304 if (rsa->flags & RSA_FLAG_BLINDING) 321 if (rsa->flags & RSA_FLAG_BLINDING)
@@ -311,10 +328,10 @@ static int RSA_eay_private_decrypt(int flen, unsigned char *from,
311 (rsa->dmp1 != NULL) && 328 (rsa->dmp1 != NULL) &&
312 (rsa->dmq1 != NULL) && 329 (rsa->dmq1 != NULL) &&
313 (rsa->iqmp != NULL)) ) 330 (rsa->iqmp != NULL)) )
314 { if (!meth->rsa_mod_exp(&ret,&f,rsa)) goto err; } 331 { if (!rsa->meth->rsa_mod_exp(&ret,&f,rsa)) goto err; }
315 else 332 else
316 { 333 {
317 if (!meth->bn_mod_exp(&ret,&f,rsa->d,rsa->n,ctx,NULL)) 334 if (!rsa->meth->bn_mod_exp(&ret,&f,rsa->d,rsa->n,ctx,NULL))
318 goto err; 335 goto err;
319 } 336 }
320 337
@@ -329,7 +346,7 @@ static int RSA_eay_private_decrypt(int flen, unsigned char *from,
329 case RSA_PKCS1_PADDING: 346 case RSA_PKCS1_PADDING:
330 r=RSA_padding_check_PKCS1_type_2(to,num,buf,j,num); 347 r=RSA_padding_check_PKCS1_type_2(to,num,buf,j,num);
331 break; 348 break;
332#ifndef NO_SHA 349#ifndef OPENSSL_NO_SHA
333 case RSA_PKCS1_OAEP_PADDING: 350 case RSA_PKCS1_OAEP_PADDING:
334 r=RSA_padding_check_PKCS1_OAEP(to,num,buf,j,num,NULL,0); 351 r=RSA_padding_check_PKCS1_OAEP(to,num,buf,j,num,NULL,0);
335 break; 352 break;
@@ -359,17 +376,16 @@ err:
359 return(r); 376 return(r);
360 } 377 }
361 378
362static int RSA_eay_public_decrypt(int flen, unsigned char *from, 379/* signature verification */
380static int RSA_eay_public_decrypt(int flen, const unsigned char *from,
363 unsigned char *to, RSA *rsa, int padding) 381 unsigned char *to, RSA *rsa, int padding)
364 { 382 {
365 const RSA_METHOD *meth;
366 BIGNUM f,ret; 383 BIGNUM f,ret;
367 int i,num=0,r= -1; 384 int i,num=0,r= -1;
368 unsigned char *p; 385 unsigned char *p;
369 unsigned char *buf=NULL; 386 unsigned char *buf=NULL;
370 BN_CTX *ctx=NULL; 387 BN_CTX *ctx=NULL;
371 388
372 meth = ENGINE_get_RSA(rsa->engine);
373 BN_init(&f); 389 BN_init(&f);
374 BN_init(&ret); 390 BN_init(&ret);
375 ctx=BN_CTX_new(); 391 ctx=BN_CTX_new();
@@ -392,6 +408,13 @@ static int RSA_eay_public_decrypt(int flen, unsigned char *from,
392 } 408 }
393 409
394 if (BN_bin2bn(from,flen,&f) == NULL) goto err; 410 if (BN_bin2bn(from,flen,&f) == NULL) goto err;
411
412 if (BN_ucmp(&f, rsa->n) >= 0)
413 {
414 RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT,RSA_R_DATA_TOO_LARGE_FOR_MODULUS);
415 goto err;
416 }
417
395 /* do the decrypt */ 418 /* do the decrypt */
396 if ((rsa->_method_mod_n == NULL) && (rsa->flags & RSA_FLAG_CACHE_PUBLIC)) 419 if ((rsa->_method_mod_n == NULL) && (rsa->flags & RSA_FLAG_CACHE_PUBLIC))
397 { 420 {
@@ -416,8 +439,8 @@ static int RSA_eay_public_decrypt(int flen, unsigned char *from,
416 if (bn_mont_ctx) 439 if (bn_mont_ctx)
417 BN_MONT_CTX_free(bn_mont_ctx); 440 BN_MONT_CTX_free(bn_mont_ctx);
418 } 441 }
419 442
420 if (!meth->bn_mod_exp(&ret,&f,rsa->e,rsa->n,ctx, 443 if (!rsa->meth->bn_mod_exp(&ret,&f,rsa->e,rsa->n,ctx,
421 rsa->_method_mod_n)) goto err; 444 rsa->_method_mod_n)) goto err;
422 445
423 p=buf; 446 p=buf;
@@ -450,14 +473,12 @@ err:
450 return(r); 473 return(r);
451 } 474 }
452 475
453static int RSA_eay_mod_exp(BIGNUM *r0, BIGNUM *I, RSA *rsa) 476static int RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
454 { 477 {
455 const RSA_METHOD *meth;
456 BIGNUM r1,m1,vrfy; 478 BIGNUM r1,m1,vrfy;
457 int ret=0; 479 int ret=0;
458 BN_CTX *ctx; 480 BN_CTX *ctx;
459 481
460 meth = ENGINE_get_RSA(rsa->engine);
461 if ((ctx=BN_CTX_new()) == NULL) goto err; 482 if ((ctx=BN_CTX_new()) == NULL) goto err;
462 BN_init(&m1); 483 BN_init(&m1);
463 BN_init(&r1); 484 BN_init(&r1);
@@ -515,11 +536,11 @@ static int RSA_eay_mod_exp(BIGNUM *r0, BIGNUM *I, RSA *rsa)
515 } 536 }
516 537
517 if (!BN_mod(&r1,I,rsa->q,ctx)) goto err; 538 if (!BN_mod(&r1,I,rsa->q,ctx)) goto err;
518 if (!meth->bn_mod_exp(&m1,&r1,rsa->dmq1,rsa->q,ctx, 539 if (!rsa->meth->bn_mod_exp(&m1,&r1,rsa->dmq1,rsa->q,ctx,
519 rsa->_method_mod_q)) goto err; 540 rsa->_method_mod_q)) goto err;
520 541
521 if (!BN_mod(&r1,I,rsa->p,ctx)) goto err; 542 if (!BN_mod(&r1,I,rsa->p,ctx)) goto err;
522 if (!meth->bn_mod_exp(r0,&r1,rsa->dmp1,rsa->p,ctx, 543 if (!rsa->meth->bn_mod_exp(r0,&r1,rsa->dmp1,rsa->p,ctx,
523 rsa->_method_mod_p)) goto err; 544 rsa->_method_mod_p)) goto err;
524 545
525 if (!BN_sub(r0,r0,&m1)) goto err; 546 if (!BN_sub(r0,r0,&m1)) goto err;
@@ -544,11 +565,20 @@ static int RSA_eay_mod_exp(BIGNUM *r0, BIGNUM *I, RSA *rsa)
544 565
545 if (rsa->e && rsa->n) 566 if (rsa->e && rsa->n)
546 { 567 {
547 if (!meth->bn_mod_exp(&vrfy,r0,rsa->e,rsa->n,ctx,NULL)) goto err; 568 if (!rsa->meth->bn_mod_exp(&vrfy,r0,rsa->e,rsa->n,ctx,NULL)) goto err;
548 if (BN_cmp(I, &vrfy) != 0) 569 /* If 'I' was greater than (or equal to) rsa->n, the operation
549 { 570 * will be equivalent to using 'I mod n'. However, the result of
550 if (!meth->bn_mod_exp(r0,I,rsa->d,rsa->n,ctx,NULL)) goto err; 571 * the verify will *always* be less than 'n' so we don't check
551 } 572 * for absolute equality, just congruency. */
573 if (!BN_sub(&vrfy, &vrfy, I)) goto err;
574 if (!BN_mod(&vrfy, &vrfy, rsa->n, ctx)) goto err;
575 if (vrfy.neg)
576 if (!BN_add(&vrfy, &vrfy, rsa->n)) goto err;
577 if (!BN_is_zero(&vrfy))
578 /* 'I' and 'vrfy' aren't congruent mod n. Don't leak
579 * miscalculated CRT output, just do a raw (slower)
580 * mod_exp and return that instead. */
581 if (!rsa->meth->bn_mod_exp(r0,I,rsa->d,rsa->n,ctx,NULL)) goto err;
552 } 582 }
553 ret=1; 583 ret=1;
554err: 584err:
diff --git a/src/lib/libcrypto/rsa/rsa_err.c b/src/lib/libcrypto/rsa/rsa_err.c
index 1cde7c0da4..a7766c3b76 100644
--- a/src/lib/libcrypto/rsa/rsa_err.c
+++ b/src/lib/libcrypto/rsa/rsa_err.c
@@ -63,7 +63,7 @@
63#include <openssl/rsa.h> 63#include <openssl/rsa.h>
64 64
65/* BEGIN ERROR CODES */ 65/* BEGIN ERROR CODES */
66#ifndef NO_ERR 66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA RSA_str_functs[]= 67static ERR_STRING_DATA RSA_str_functs[]=
68 { 68 {
69{ERR_PACK(0,RSA_F_MEMORY_LOCK,0), "MEMORY_LOCK"}, 69{ERR_PACK(0,RSA_F_MEMORY_LOCK,0), "MEMORY_LOCK"},
@@ -106,6 +106,7 @@ static ERR_STRING_DATA RSA_str_reasons[]=
106{RSA_R_DATA_GREATER_THAN_MOD_LEN ,"data greater than mod len"}, 106{RSA_R_DATA_GREATER_THAN_MOD_LEN ,"data greater than mod len"},
107{RSA_R_DATA_TOO_LARGE ,"data too large"}, 107{RSA_R_DATA_TOO_LARGE ,"data too large"},
108{RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE ,"data too large for key size"}, 108{RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE ,"data too large for key size"},
109{RSA_R_DATA_TOO_LARGE_FOR_MODULUS ,"data too large for modulus"},
109{RSA_R_DATA_TOO_SMALL ,"data too small"}, 110{RSA_R_DATA_TOO_SMALL ,"data too small"},
110{RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE ,"data too small for key size"}, 111{RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE ,"data too small for key size"},
111{RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY ,"digest too big for rsa key"}, 112{RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY ,"digest too big for rsa key"},
@@ -139,7 +140,7 @@ void ERR_load_RSA_strings(void)
139 if (init) 140 if (init)
140 { 141 {
141 init=0; 142 init=0;
142#ifndef NO_ERR 143#ifndef OPENSSL_NO_ERR
143 ERR_load_strings(ERR_LIB_RSA,RSA_str_functs); 144 ERR_load_strings(ERR_LIB_RSA,RSA_str_functs);
144 ERR_load_strings(ERR_LIB_RSA,RSA_str_reasons); 145 ERR_load_strings(ERR_LIB_RSA,RSA_str_reasons);
145#endif 146#endif
diff --git a/src/lib/libcrypto/rsa/rsa_lib.c b/src/lib/libcrypto/rsa/rsa_lib.c
index 94395cc22c..93235744f7 100644
--- a/src/lib/libcrypto/rsa/rsa_lib.c
+++ b/src/lib/libcrypto/rsa/rsa_lib.c
@@ -66,42 +66,26 @@
66 66
67const char *RSA_version="RSA" OPENSSL_VERSION_PTEXT; 67const char *RSA_version="RSA" OPENSSL_VERSION_PTEXT;
68 68
69static RSA_METHOD *default_RSA_meth=NULL; 69static const RSA_METHOD *default_RSA_meth=NULL;
70static int rsa_meth_num=0;
71static STACK_OF(CRYPTO_EX_DATA_FUNCS) *rsa_meth=NULL;
72 70
73RSA *RSA_new(void) 71RSA *RSA_new(void)
74 { 72 {
75 return(RSA_new_method(NULL)); 73 return(RSA_new_method(NULL));
76 } 74 }
77 75
78void RSA_set_default_openssl_method(RSA_METHOD *meth) 76void RSA_set_default_method(const RSA_METHOD *meth)
79 { 77 {
80 ENGINE *e; 78 default_RSA_meth = meth;
81 /* We'll need to notify the "openssl" ENGINE of this
82 * change too. We won't bother locking things down at
83 * our end as there was never any locking in these
84 * functions! */
85 if(default_RSA_meth != meth)
86 {
87 default_RSA_meth = meth;
88 e = ENGINE_by_id("openssl");
89 if(e)
90 {
91 ENGINE_set_RSA(e, meth);
92 ENGINE_free(e);
93 }
94 }
95 } 79 }
96 80
97RSA_METHOD *RSA_get_default_openssl_method(void) 81const RSA_METHOD *RSA_get_default_method(void)
98{ 82 {
99 if (default_RSA_meth == NULL) 83 if (default_RSA_meth == NULL)
100 { 84 {
101#ifdef RSA_NULL 85#ifdef RSA_NULL
102 default_RSA_meth=RSA_null_method(); 86 default_RSA_meth=RSA_null_method();
103#else 87#else
104#ifdef RSAref 88#if 0 /* was: #ifdef RSAref */
105 default_RSA_meth=RSA_PKCS1_RSAref(); 89 default_RSA_meth=RSA_PKCS1_RSAref();
106#else 90#else
107 default_RSA_meth=RSA_PKCS1_SSLeay(); 91 default_RSA_meth=RSA_PKCS1_SSLeay();
@@ -110,69 +94,66 @@ RSA_METHOD *RSA_get_default_openssl_method(void)
110 } 94 }
111 95
112 return default_RSA_meth; 96 return default_RSA_meth;
113} 97 }
114 98
115RSA_METHOD *RSA_get_method(RSA *rsa) 99const RSA_METHOD *RSA_get_method(const RSA *rsa)
116{ 100 {
117 return ENGINE_get_RSA(rsa->engine); 101 return rsa->meth;
118} 102 }
119 103
120#if 0 104int RSA_set_method(RSA *rsa, const RSA_METHOD *meth)
121RSA_METHOD *RSA_set_method(RSA *rsa, RSA_METHOD *meth) 105 {
122{ 106 /* NB: The caller is specifically setting a method, so it's not up to us
123 RSA_METHOD *mtmp; 107 * to deal with which ENGINE it comes from. */
108 const RSA_METHOD *mtmp;
124 mtmp = rsa->meth; 109 mtmp = rsa->meth;
125 if (mtmp->finish) mtmp->finish(rsa); 110 if (mtmp->finish) mtmp->finish(rsa);
111 if (rsa->engine)
112 {
113 ENGINE_finish(rsa->engine);
114 rsa->engine = NULL;
115 }
126 rsa->meth = meth; 116 rsa->meth = meth;
127 if (meth->init) meth->init(rsa); 117 if (meth->init) meth->init(rsa);
128 return mtmp;
129}
130#else
131int RSA_set_method(RSA *rsa, ENGINE *engine)
132{
133 ENGINE *mtmp;
134 RSA_METHOD *meth;
135 mtmp = rsa->engine;
136 meth = ENGINE_get_RSA(mtmp);
137 if (!ENGINE_init(engine))
138 return 0;
139 if (meth->finish) meth->finish(rsa);
140 rsa->engine = engine;
141 meth = ENGINE_get_RSA(engine);
142 if (meth->init) meth->init(rsa);
143 /* SHOULD ERROR CHECK THIS!!! */
144 ENGINE_finish(mtmp);
145 return 1; 118 return 1;
146} 119 }
147#endif
148 120
149#if 0
150RSA *RSA_new_method(RSA_METHOD *meth)
151#else
152RSA *RSA_new_method(ENGINE *engine) 121RSA *RSA_new_method(ENGINE *engine)
153#endif
154 { 122 {
155 RSA_METHOD *meth;
156 RSA *ret; 123 RSA *ret;
157 124
158 ret=(RSA *)OPENSSL_malloc(sizeof(RSA)); 125 ret=(RSA *)OPENSSL_malloc(sizeof(RSA));
159 if (ret == NULL) 126 if (ret == NULL)
160 { 127 {
161 RSAerr(RSA_F_RSA_NEW_METHOD,ERR_R_MALLOC_FAILURE); 128 RSAerr(RSA_F_RSA_NEW_METHOD,ERR_R_MALLOC_FAILURE);
162 return(NULL); 129 return NULL;
163 } 130 }
164 131
165 if (engine == NULL) 132 ret->meth = RSA_get_default_method();
133 if (engine)
166 { 134 {
167 if((ret->engine=ENGINE_get_default_RSA()) == NULL) 135 if (!ENGINE_init(engine))
168 { 136 {
137 RSAerr(RSA_F_RSA_NEW_METHOD, ERR_R_ENGINE_LIB);
169 OPENSSL_free(ret); 138 OPENSSL_free(ret);
170 return NULL; 139 return NULL;
171 } 140 }
141 ret->engine = engine;
172 } 142 }
173 else 143 else
174 ret->engine=engine; 144 ret->engine = ENGINE_get_default_RSA();
175 meth = ENGINE_get_RSA(ret->engine); 145 if(ret->engine)
146 {
147 ret->meth = ENGINE_get_RSA(ret->engine);
148 if(!ret->meth)
149 {
150 RSAerr(RSA_F_RSA_NEW_METHOD,
151 ERR_R_ENGINE_LIB);
152 ENGINE_finish(ret->engine);
153 OPENSSL_free(ret);
154 return NULL;
155 }
156 }
176 157
177 ret->pad=0; 158 ret->pad=0;
178 ret->version=0; 159 ret->version=0;
@@ -190,11 +171,13 @@ RSA *RSA_new_method(ENGINE *engine)
190 ret->_method_mod_q=NULL; 171 ret->_method_mod_q=NULL;
191 ret->blinding=NULL; 172 ret->blinding=NULL;
192 ret->bignum_data=NULL; 173 ret->bignum_data=NULL;
193 ret->flags=meth->flags; 174 ret->flags=ret->meth->flags;
194 CRYPTO_new_ex_data(rsa_meth,ret,&ret->ex_data); 175 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data);
195 if ((meth->init != NULL) && !meth->init(ret)) 176 if ((ret->meth->init != NULL) && !ret->meth->init(ret))
196 { 177 {
197 CRYPTO_free_ex_data(rsa_meth,ret,&ret->ex_data); 178 if (ret->engine)
179 ENGINE_finish(ret->engine);
180 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data);
198 OPENSSL_free(ret); 181 OPENSSL_free(ret);
199 ret=NULL; 182 ret=NULL;
200 } 183 }
@@ -203,7 +186,6 @@ RSA *RSA_new_method(ENGINE *engine)
203 186
204void RSA_free(RSA *r) 187void RSA_free(RSA *r)
205 { 188 {
206 RSA_METHOD *meth;
207 int i; 189 int i;
208 190
209 if (r == NULL) return; 191 if (r == NULL) return;
@@ -221,12 +203,12 @@ void RSA_free(RSA *r)
221 } 203 }
222#endif 204#endif
223 205
224 meth = ENGINE_get_RSA(r->engine); 206 if (r->meth->finish)
225 if (meth->finish != NULL) 207 r->meth->finish(r);
226 meth->finish(r); 208 if (r->engine)
227 ENGINE_finish(r->engine); 209 ENGINE_finish(r->engine);
228 210
229 CRYPTO_free_ex_data(rsa_meth,r,&r->ex_data); 211 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, r, &r->ex_data);
230 212
231 if (r->n != NULL) BN_clear_free(r->n); 213 if (r->n != NULL) BN_clear_free(r->n);
232 if (r->e != NULL) BN_clear_free(r->e); 214 if (r->e != NULL) BN_clear_free(r->e);
@@ -241,12 +223,27 @@ void RSA_free(RSA *r)
241 OPENSSL_free(r); 223 OPENSSL_free(r);
242 } 224 }
243 225
226int RSA_up_ref(RSA *r)
227 {
228 int i = CRYPTO_add(&r->references, 1, CRYPTO_LOCK_RSA);
229#ifdef REF_PRINT
230 REF_PRINT("RSA",r);
231#endif
232#ifdef REF_CHECK
233 if (i < 2)
234 {
235 fprintf(stderr, "RSA_up_ref, bad reference count\n");
236 abort();
237 }
238#endif
239 return ((i > 1) ? 1 : 0);
240 }
241
244int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, 242int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
245 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) 243 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
246 { 244 {
247 rsa_meth_num++; 245 return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_RSA, argl, argp,
248 return(CRYPTO_get_ex_new_index(rsa_meth_num-1, 246 new_func, dup_func, free_func);
249 &rsa_meth,argl,argp,new_func,dup_func,free_func));
250 } 247 }
251 248
252int RSA_set_ex_data(RSA *r, int idx, void *arg) 249int RSA_set_ex_data(RSA *r, int idx, void *arg)
@@ -254,47 +251,43 @@ int RSA_set_ex_data(RSA *r, int idx, void *arg)
254 return(CRYPTO_set_ex_data(&r->ex_data,idx,arg)); 251 return(CRYPTO_set_ex_data(&r->ex_data,idx,arg));
255 } 252 }
256 253
257void *RSA_get_ex_data(RSA *r, int idx) 254void *RSA_get_ex_data(const RSA *r, int idx)
258 { 255 {
259 return(CRYPTO_get_ex_data(&r->ex_data,idx)); 256 return(CRYPTO_get_ex_data(&r->ex_data,idx));
260 } 257 }
261 258
262int RSA_size(RSA *r) 259int RSA_size(const RSA *r)
263 { 260 {
264 return(BN_num_bytes(r->n)); 261 return(BN_num_bytes(r->n));
265 } 262 }
266 263
267int RSA_public_encrypt(int flen, unsigned char *from, unsigned char *to, 264int RSA_public_encrypt(int flen, const unsigned char *from, unsigned char *to,
268 RSA *rsa, int padding) 265 RSA *rsa, int padding)
269 { 266 {
270 return(ENGINE_get_RSA(rsa->engine)->rsa_pub_enc(flen, 267 return(rsa->meth->rsa_pub_enc(flen, from, to, rsa, padding));
271 from, to, rsa, padding));
272 } 268 }
273 269
274int RSA_private_encrypt(int flen, unsigned char *from, unsigned char *to, 270int RSA_private_encrypt(int flen, const unsigned char *from, unsigned char *to,
275 RSA *rsa, int padding) 271 RSA *rsa, int padding)
276 { 272 {
277 return(ENGINE_get_RSA(rsa->engine)->rsa_priv_enc(flen, 273 return(rsa->meth->rsa_priv_enc(flen, from, to, rsa, padding));
278 from, to, rsa, padding));
279 } 274 }
280 275
281int RSA_private_decrypt(int flen, unsigned char *from, unsigned char *to, 276int RSA_private_decrypt(int flen, const unsigned char *from, unsigned char *to,
282 RSA *rsa, int padding) 277 RSA *rsa, int padding)
283 { 278 {
284 return(ENGINE_get_RSA(rsa->engine)->rsa_priv_dec(flen, 279 return(rsa->meth->rsa_priv_dec(flen, from, to, rsa, padding));
285 from, to, rsa, padding));
286 } 280 }
287 281
288int RSA_public_decrypt(int flen, unsigned char *from, unsigned char *to, 282int RSA_public_decrypt(int flen, const unsigned char *from, unsigned char *to,
289 RSA *rsa, int padding) 283 RSA *rsa, int padding)
290 { 284 {
291 return(ENGINE_get_RSA(rsa->engine)->rsa_pub_dec(flen, 285 return(rsa->meth->rsa_pub_dec(flen, from, to, rsa, padding));
292 from, to, rsa, padding));
293 } 286 }
294 287
295int RSA_flags(RSA *r) 288int RSA_flags(const RSA *r)
296 { 289 {
297 return((r == NULL)?0:ENGINE_get_RSA(r->engine)->flags); 290 return((r == NULL)?0:r->meth->flags);
298 } 291 }
299 292
300void RSA_blinding_off(RSA *rsa) 293void RSA_blinding_off(RSA *rsa)
@@ -328,8 +321,7 @@ int RSA_blinding_on(RSA *rsa, BN_CTX *p_ctx)
328 if (!BN_rand_range(A,rsa->n)) goto err; 321 if (!BN_rand_range(A,rsa->n)) goto err;
329 if ((Ai=BN_mod_inverse(NULL,A,rsa->n,ctx)) == NULL) goto err; 322 if ((Ai=BN_mod_inverse(NULL,A,rsa->n,ctx)) == NULL) goto err;
330 323
331 if (!ENGINE_get_RSA(rsa->engine)->bn_mod_exp(A,A, 324 if (!rsa->meth->bn_mod_exp(A,A,rsa->e,rsa->n,ctx,rsa->_method_mod_n))
332 rsa->e,rsa->n,ctx,rsa->_method_mod_n))
333 goto err; 325 goto err;
334 rsa->blinding=BN_BLINDING_new(A,Ai,rsa->n); 326 rsa->blinding=BN_BLINDING_new(A,Ai,rsa->n);
335 rsa->flags|=RSA_FLAG_BLINDING; 327 rsa->flags|=RSA_FLAG_BLINDING;
@@ -385,4 +377,3 @@ int RSA_memory_lock(RSA *r)
385 r->bignum_data=p; 377 r->bignum_data=p;
386 return(1); 378 return(1);
387 } 379 }
388
diff --git a/src/lib/libcrypto/rsa/rsa_none.c b/src/lib/libcrypto/rsa/rsa_none.c
index f22fce5016..e6f3e627ca 100644
--- a/src/lib/libcrypto/rsa/rsa_none.c
+++ b/src/lib/libcrypto/rsa/rsa_none.c
@@ -62,8 +62,8 @@
62#include <openssl/rsa.h> 62#include <openssl/rsa.h>
63#include <openssl/rand.h> 63#include <openssl/rand.h>
64 64
65int RSA_padding_add_none(unsigned char *to, int tlen, unsigned char *from, 65int RSA_padding_add_none(unsigned char *to, int tlen,
66 int flen) 66 const unsigned char *from, int flen)
67 { 67 {
68 if (flen > tlen) 68 if (flen > tlen)
69 { 69 {
@@ -81,8 +81,8 @@ int RSA_padding_add_none(unsigned char *to, int tlen, unsigned char *from,
81 return(1); 81 return(1);
82 } 82 }
83 83
84int RSA_padding_check_none(unsigned char *to, int tlen, unsigned char *from, 84int RSA_padding_check_none(unsigned char *to, int tlen,
85 int flen, int num) 85 const unsigned char *from, int flen, int num)
86 { 86 {
87 87
88 if (flen > tlen) 88 if (flen > tlen)
diff --git a/src/lib/libcrypto/rsa/rsa_null.c b/src/lib/libcrypto/rsa/rsa_null.c
index 7b58a0eca3..64057fbdcf 100644
--- a/src/lib/libcrypto/rsa/rsa_null.c
+++ b/src/lib/libcrypto/rsa/rsa_null.c
@@ -69,16 +69,16 @@
69 * operations (like storing RSA keys) are permitted. 69 * operations (like storing RSA keys) are permitted.
70 */ 70 */
71 71
72static int RSA_null_public_encrypt(int flen, unsigned char *from, 72static int RSA_null_public_encrypt(int flen, const unsigned char *from,
73 unsigned char *to, RSA *rsa,int padding); 73 unsigned char *to, RSA *rsa,int padding);
74static int RSA_null_private_encrypt(int flen, unsigned char *from, 74static int RSA_null_private_encrypt(int flen, const unsigned char *from,
75 unsigned char *to, RSA *rsa,int padding); 75 unsigned char *to, RSA *rsa,int padding);
76static int RSA_null_public_decrypt(int flen, unsigned char *from, 76static int RSA_null_public_decrypt(int flen, const unsigned char *from,
77 unsigned char *to, RSA *rsa,int padding); 77 unsigned char *to, RSA *rsa,int padding);
78static int RSA_null_private_decrypt(int flen, unsigned char *from, 78static int RSA_null_private_decrypt(int flen, const unsigned char *from,
79 unsigned char *to, RSA *rsa,int padding); 79 unsigned char *to, RSA *rsa,int padding);
80#if 0 /* not currently used */ 80#if 0 /* not currently used */
81static int RSA_null_mod_exp(BIGNUM *r0, BIGNUM *i, RSA *rsa); 81static int RSA_null_mod_exp(const BIGNUM *r0, const BIGNUM *i, RSA *rsa);
82#endif 82#endif
83static int RSA_null_init(RSA *rsa); 83static int RSA_null_init(RSA *rsa);
84static int RSA_null_finish(RSA *rsa); 84static int RSA_null_finish(RSA *rsa);
@@ -88,40 +88,41 @@ static RSA_METHOD rsa_null_meth={
88 RSA_null_public_decrypt, 88 RSA_null_public_decrypt,
89 RSA_null_private_encrypt, 89 RSA_null_private_encrypt,
90 RSA_null_private_decrypt, 90 RSA_null_private_decrypt,
91 NULL, NULL, 91 NULL,
92 NULL,
92 RSA_null_init, 93 RSA_null_init,
93 RSA_null_finish, 94 RSA_null_finish,
94 0, 95 0,
95 NULL, 96 NULL,
96 }; 97 };
97 98
98RSA_METHOD *RSA_null_method(void) 99const RSA_METHOD *RSA_null_method(void)
99 { 100 {
100 return(&rsa_null_meth); 101 return(&rsa_null_meth);
101 } 102 }
102 103
103static int RSA_null_public_encrypt(int flen, unsigned char *from, 104static int RSA_null_public_encrypt(int flen, const unsigned char *from,
104 unsigned char *to, RSA *rsa, int padding) 105 unsigned char *to, RSA *rsa, int padding)
105 { 106 {
106 RSAerr(RSA_F_RSA_NULL, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED); 107 RSAerr(RSA_F_RSA_NULL, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
107 return -1; 108 return -1;
108 } 109 }
109 110
110static int RSA_null_private_encrypt(int flen, unsigned char *from, 111static int RSA_null_private_encrypt(int flen, const unsigned char *from,
111 unsigned char *to, RSA *rsa, int padding) 112 unsigned char *to, RSA *rsa, int padding)
112 { 113 {
113 RSAerr(RSA_F_RSA_NULL, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED); 114 RSAerr(RSA_F_RSA_NULL, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
114 return -1; 115 return -1;
115 } 116 }
116 117
117static int RSA_null_private_decrypt(int flen, unsigned char *from, 118static int RSA_null_private_decrypt(int flen, const unsigned char *from,
118 unsigned char *to, RSA *rsa, int padding) 119 unsigned char *to, RSA *rsa, int padding)
119 { 120 {
120 RSAerr(RSA_F_RSA_NULL, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED); 121 RSAerr(RSA_F_RSA_NULL, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
121 return -1; 122 return -1;
122 } 123 }
123 124
124static int RSA_null_public_decrypt(int flen, unsigned char *from, 125static int RSA_null_public_decrypt(int flen, const unsigned char *from,
125 unsigned char *to, RSA *rsa, int padding) 126 unsigned char *to, RSA *rsa, int padding)
126 { 127 {
127 RSAerr(RSA_F_RSA_NULL, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED); 128 RSAerr(RSA_F_RSA_NULL, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
diff --git a/src/lib/libcrypto/rsa/rsa_oaep.c b/src/lib/libcrypto/rsa/rsa_oaep.c
index 1849e55cd5..e3f7c608ec 100644
--- a/src/lib/libcrypto/rsa/rsa_oaep.c
+++ b/src/lib/libcrypto/rsa/rsa_oaep.c
@@ -2,167 +2,205 @@
2/* Written by Ulf Moeller. This software is distributed on an "AS IS" 2/* Written by Ulf Moeller. This software is distributed on an "AS IS"
3 basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. */ 3 basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. */
4 4
5/* EME_OAEP as defined in RFC 2437 (PKCS #1 v2.0) */ 5/* EME-OAEP as defined in RFC 2437 (PKCS #1 v2.0) */
6 6
7#if !defined(NO_SHA) && !defined(NO_SHA1) 7/* See Victor Shoup, "OAEP reconsidered," Nov. 2000,
8 * <URL: http://www.shoup.net/papers/oaep.ps.Z>
9 * for problems with the security proof for the
10 * original OAEP scheme, which EME-OAEP is based on.
11 *
12 * A new proof can be found in E. Fujisaki, T. Okamoto,
13 * D. Pointcheval, J. Stern, "RSA-OEAP is Still Alive!",
14 * Dec. 2000, <URL: http://eprint.iacr.org/2000/061/>.
15 * The new proof has stronger requirements for the
16 * underlying permutation: "partial-one-wayness" instead
17 * of one-wayness. For the RSA function, this is
18 * an equivalent notion.
19 */
20
21
22#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA1)
8#include <stdio.h> 23#include <stdio.h>
9#include "cryptlib.h" 24#include "cryptlib.h"
10#include <openssl/bn.h> 25#include <openssl/bn.h>
11#include <openssl/rsa.h> 26#include <openssl/rsa.h>
12#include <openssl/sha.h> 27#include <openssl/evp.h>
13#include <openssl/rand.h> 28#include <openssl/rand.h>
29#include <openssl/sha.h>
14 30
15int MGF1(unsigned char *mask, long len, unsigned char *seed, long seedlen); 31int MGF1(unsigned char *mask, long len,
32 const unsigned char *seed, long seedlen);
16 33
17int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen, 34int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen,
18 unsigned char *from, int flen, unsigned char *param, int plen) 35 const unsigned char *from, int flen,
19 { 36 const unsigned char *param, int plen)
20 int i, emlen = tlen - 1;
21 unsigned char *db, *seed;
22 unsigned char *dbmask, seedmask[SHA_DIGEST_LENGTH];
23
24 if (flen > emlen - 2 * SHA_DIGEST_LENGTH - 1)
25 { 37 {
26 RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_OAEP, 38 int i, emlen = tlen - 1;
27 RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE); 39 unsigned char *db, *seed;
28 return (0); 40 unsigned char *dbmask, seedmask[SHA_DIGEST_LENGTH];
29 }
30 41
31 if (emlen < 2 * SHA_DIGEST_LENGTH + 1) 42 if (flen > emlen - 2 * SHA_DIGEST_LENGTH - 1)
32 { 43 {
33 RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_OAEP, RSA_R_KEY_SIZE_TOO_SMALL); 44 RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_OAEP,
34 return (0); 45 RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE);
35 } 46 return 0;
36 47 }
37 dbmask = OPENSSL_malloc(emlen - SHA_DIGEST_LENGTH); 48
38 if (dbmask == NULL) 49 if (emlen < 2 * SHA_DIGEST_LENGTH + 1)
39 { 50 {
40 RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_OAEP, ERR_R_MALLOC_FAILURE); 51 RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_OAEP, RSA_R_KEY_SIZE_TOO_SMALL);
41 return (0); 52 return 0;
42 } 53 }
54
55 dbmask = OPENSSL_malloc(emlen - SHA_DIGEST_LENGTH);
56 if (dbmask == NULL)
57 {
58 RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_OAEP, ERR_R_MALLOC_FAILURE);
59 return 0;
60 }
43 61
44 to[0] = 0; 62 to[0] = 0;
45 seed = to + 1; 63 seed = to + 1;
46 db = to + SHA_DIGEST_LENGTH + 1; 64 db = to + SHA_DIGEST_LENGTH + 1;
47 65
48 SHA1(param, plen, db); 66 EVP_Digest((void *)param, plen, db, NULL, EVP_sha1(), NULL);
49 memset(db + SHA_DIGEST_LENGTH, 0, 67 memset(db + SHA_DIGEST_LENGTH, 0,
50 emlen - flen - 2 * SHA_DIGEST_LENGTH - 1); 68 emlen - flen - 2 * SHA_DIGEST_LENGTH - 1);
51 db[emlen - flen - SHA_DIGEST_LENGTH - 1] = 0x01; 69 db[emlen - flen - SHA_DIGEST_LENGTH - 1] = 0x01;
52 memcpy(db + emlen - flen - SHA_DIGEST_LENGTH, from, (unsigned int) flen); 70 memcpy(db + emlen - flen - SHA_DIGEST_LENGTH, from, (unsigned int) flen);
53 if (RAND_bytes(seed, SHA_DIGEST_LENGTH) <= 0) 71 if (RAND_bytes(seed, SHA_DIGEST_LENGTH) <= 0)
54 return (0); 72 return 0;
55#ifdef PKCS_TESTVECT 73#ifdef PKCS_TESTVECT
56 memcpy(seed, 74 memcpy(seed,
57 "\xaa\xfd\x12\xf6\x59\xca\xe6\x34\x89\xb4\x79\xe5\x07\x6d\xde\xc2\xf0\x6c\xb5\x8f", 75 "\xaa\xfd\x12\xf6\x59\xca\xe6\x34\x89\xb4\x79\xe5\x07\x6d\xde\xc2\xf0\x6c\xb5\x8f",
58 20); 76 20);
59#endif 77#endif
60 78
61 MGF1(dbmask, emlen - SHA_DIGEST_LENGTH, seed, SHA_DIGEST_LENGTH); 79 MGF1(dbmask, emlen - SHA_DIGEST_LENGTH, seed, SHA_DIGEST_LENGTH);
62 for (i = 0; i < emlen - SHA_DIGEST_LENGTH; i++) 80 for (i = 0; i < emlen - SHA_DIGEST_LENGTH; i++)
63 db[i] ^= dbmask[i]; 81 db[i] ^= dbmask[i];
64 82
65 MGF1(seedmask, SHA_DIGEST_LENGTH, db, emlen - SHA_DIGEST_LENGTH); 83 MGF1(seedmask, SHA_DIGEST_LENGTH, db, emlen - SHA_DIGEST_LENGTH);
66 for (i = 0; i < SHA_DIGEST_LENGTH; i++) 84 for (i = 0; i < SHA_DIGEST_LENGTH; i++)
67 seed[i] ^= seedmask[i]; 85 seed[i] ^= seedmask[i];
68 86
69 OPENSSL_free(dbmask); 87 OPENSSL_free(dbmask);
70 return (1); 88 return 1;
71 } 89 }
72 90
73int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen, 91int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen,
74 unsigned char *from, int flen, int num, unsigned char *param, 92 const unsigned char *from, int flen, int num,
75 int plen) 93 const unsigned char *param, int plen)
76 {
77 int i, dblen, mlen = -1;
78 unsigned char *maskeddb;
79 int lzero;
80 unsigned char *db = NULL, seed[SHA_DIGEST_LENGTH], phash[SHA_DIGEST_LENGTH];
81
82 if (--num < 2 * SHA_DIGEST_LENGTH + 1)
83 goto decoding_err;
84
85 lzero = num - flen;
86 if (lzero < 0)
87 goto decoding_err;
88 maskeddb = from - lzero + SHA_DIGEST_LENGTH;
89
90 dblen = num - SHA_DIGEST_LENGTH;
91 db = OPENSSL_malloc(dblen);
92 if (db == NULL)
93 { 94 {
94 RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_OAEP, ERR_R_MALLOC_FAILURE); 95 int i, dblen, mlen = -1;
95 return (-1); 96 const unsigned char *maskeddb;
96 } 97 int lzero;
98 unsigned char *db = NULL, seed[SHA_DIGEST_LENGTH], phash[SHA_DIGEST_LENGTH];
99 int bad = 0;
100
101 if (--num < 2 * SHA_DIGEST_LENGTH + 1)
102 /* 'num' is the length of the modulus, i.e. does not depend on the
103 * particular ciphertext. */
104 goto decoding_err;
105
106 lzero = num - flen;
107 if (lzero < 0)
108 {
109 /* lzero == -1 */
110
111 /* signalling this error immediately after detection might allow
112 * for side-channel attacks (e.g. timing if 'plen' is huge
113 * -- cf. James H. Manger, "A Chosen Ciphertext Attack on RSA Optimal
114 * Asymmetric Encryption Padding (OAEP) [...]", CRYPTO 2001),
115 * so we use a 'bad' flag */
116 bad = 1;
117 lzero = 0;
118 }
119 maskeddb = from - lzero + SHA_DIGEST_LENGTH;
120
121 dblen = num - SHA_DIGEST_LENGTH;
122 db = OPENSSL_malloc(dblen);
123 if (db == NULL)
124 {
125 RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_OAEP, ERR_R_MALLOC_FAILURE);
126 return -1;
127 }
97 128
98 MGF1(seed, SHA_DIGEST_LENGTH, maskeddb, dblen); 129 MGF1(seed, SHA_DIGEST_LENGTH, maskeddb, dblen);
99 for (i = lzero; i < SHA_DIGEST_LENGTH; i++) 130 for (i = lzero; i < SHA_DIGEST_LENGTH; i++)
100 seed[i] ^= from[i - lzero]; 131 seed[i] ^= from[i - lzero];
101 132
102 MGF1(db, dblen, seed, SHA_DIGEST_LENGTH); 133 MGF1(db, dblen, seed, SHA_DIGEST_LENGTH);
103 for (i = 0; i < dblen; i++) 134 for (i = 0; i < dblen; i++)
104 db[i] ^= maskeddb[i]; 135 db[i] ^= maskeddb[i];
105 136
106 SHA1(param, plen, phash); 137 EVP_Digest((void *)param, plen, phash, NULL, EVP_sha1(), NULL);
107 138
108 if (memcmp(db, phash, SHA_DIGEST_LENGTH) != 0) 139 if (memcmp(db, phash, SHA_DIGEST_LENGTH) != 0 || bad)
109 goto decoding_err; 140 goto decoding_err;
110 else
111 {
112 for (i = SHA_DIGEST_LENGTH; i < dblen; i++)
113 if (db[i] != 0x00)
114 break;
115 if (db[i] != 0x01 || i++ >= dblen)
116 goto decoding_err;
117 else 141 else
118 {
119 mlen = dblen - i;
120 if (tlen < mlen)
121 { 142 {
122 RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP, RSA_R_DATA_TOO_LARGE); 143 for (i = SHA_DIGEST_LENGTH; i < dblen; i++)
123 mlen = -1; 144 if (db[i] != 0x00)
145 break;
146 if (db[i] != 0x01 || i++ >= dblen)
147 goto decoding_err;
148 else
149 {
150 /* everything looks OK */
151
152 mlen = dblen - i;
153 if (tlen < mlen)
154 {
155 RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP, RSA_R_DATA_TOO_LARGE);
156 mlen = -1;
157 }
158 else
159 memcpy(to, db + i, mlen);
160 }
124 } 161 }
125 else 162 OPENSSL_free(db);
126 memcpy(to, db + i, mlen); 163 return mlen;
127 }
128 }
129 OPENSSL_free(db);
130 return (mlen);
131 164
132decoding_err: 165decoding_err:
133 /* to avoid chosen ciphertext attacks, the error message should not reveal 166 /* to avoid chosen ciphertext attacks, the error message should not reveal
134 * which kind of decoding error happened */ 167 * which kind of decoding error happened */
135 RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP, RSA_R_OAEP_DECODING_ERROR); 168 RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP, RSA_R_OAEP_DECODING_ERROR);
136 if (db != NULL) OPENSSL_free(db); 169 if (db != NULL) OPENSSL_free(db);
137 return -1; 170 return -1;
138 } 171 }
139 172
140int MGF1(unsigned char *mask, long len, unsigned char *seed, long seedlen) 173int MGF1(unsigned char *mask, long len,
141 { 174 const unsigned char *seed, long seedlen)
142 long i, outlen = 0;
143 unsigned char cnt[4];
144 SHA_CTX c;
145 unsigned char md[SHA_DIGEST_LENGTH];
146
147 for (i = 0; outlen < len; i++)
148 { 175 {
149 cnt[0] = (i >> 24) & 255, cnt[1] = (i >> 16) & 255, 176 long i, outlen = 0;
150 cnt[2] = (i >> 8) & 255, cnt[3] = i & 255; 177 unsigned char cnt[4];
151 SHA1_Init(&c); 178 EVP_MD_CTX c;
152 SHA1_Update(&c, seed, seedlen); 179 unsigned char md[SHA_DIGEST_LENGTH];
153 SHA1_Update(&c, cnt, 4); 180
154 if (outlen + SHA_DIGEST_LENGTH <= len) 181 EVP_MD_CTX_init(&c);
155 { 182 for (i = 0; outlen < len; i++)
156 SHA1_Final(mask + outlen, &c); 183 {
157 outlen += SHA_DIGEST_LENGTH; 184 cnt[0] = (unsigned char)((i >> 24) & 255);
158 } 185 cnt[1] = (unsigned char)((i >> 16) & 255);
159 else 186 cnt[2] = (unsigned char)((i >> 8)) & 255;
160 { 187 cnt[3] = (unsigned char)(i & 255);
161 SHA1_Final(md, &c); 188 EVP_DigestInit_ex(&c,EVP_sha1(), NULL);
162 memcpy(mask + outlen, md, len - outlen); 189 EVP_DigestUpdate(&c, seed, seedlen);
163 outlen = len; 190 EVP_DigestUpdate(&c, cnt, 4);
164 } 191 if (outlen + SHA_DIGEST_LENGTH <= len)
192 {
193 EVP_DigestFinal_ex(&c, mask + outlen, NULL);
194 outlen += SHA_DIGEST_LENGTH;
195 }
196 else
197 {
198 EVP_DigestFinal_ex(&c, md, NULL);
199 memcpy(mask + outlen, md, len - outlen);
200 outlen = len;
201 }
202 }
203 EVP_MD_CTX_cleanup(&c);
204 return 0;
165 } 205 }
166 return (0);
167 }
168#endif 206#endif
diff --git a/src/lib/libcrypto/rsa/rsa_pk1.c b/src/lib/libcrypto/rsa/rsa_pk1.c
index 48a32bc264..c1edd6764f 100644
--- a/src/lib/libcrypto/rsa/rsa_pk1.c
+++ b/src/lib/libcrypto/rsa/rsa_pk1.c
@@ -63,7 +63,7 @@
63#include <openssl/rand.h> 63#include <openssl/rand.h>
64 64
65int RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen, 65int RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen,
66 unsigned char *from, int flen) 66 const unsigned char *from, int flen)
67 { 67 {
68 int j; 68 int j;
69 unsigned char *p; 69 unsigned char *p;
@@ -89,10 +89,10 @@ int RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen,
89 } 89 }
90 90
91int RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen, 91int RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen,
92 unsigned char *from, int flen, int num) 92 const unsigned char *from, int flen, int num)
93 { 93 {
94 int i,j; 94 int i,j;
95 unsigned char *p; 95 const unsigned char *p;
96 96
97 p=from; 97 p=from;
98 if ((num != (flen+1)) || (*(p++) != 01)) 98 if ((num != (flen+1)) || (*(p++) != 01))
@@ -141,7 +141,7 @@ int RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen,
141 } 141 }
142 142
143int RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen, 143int RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen,
144 unsigned char *from, int flen) 144 const unsigned char *from, int flen)
145 { 145 {
146 int i,j; 146 int i,j;
147 unsigned char *p; 147 unsigned char *p;
@@ -179,10 +179,10 @@ int RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen,
179 } 179 }
180 180
181int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen, 181int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen,
182 unsigned char *from, int flen, int num) 182 const unsigned char *from, int flen, int num)
183 { 183 {
184 int i,j; 184 int i,j;
185 unsigned char *p; 185 const unsigned char *p;
186 186
187 p=from; 187 p=from;
188 if ((num != (flen+1)) || (*(p++) != 02)) 188 if ((num != (flen+1)) || (*(p++) != 02))
diff --git a/src/lib/libcrypto/rsa/rsa_saos.c b/src/lib/libcrypto/rsa/rsa_saos.c
index c77f4381ff..85adacc08f 100644
--- a/src/lib/libcrypto/rsa/rsa_saos.c
+++ b/src/lib/libcrypto/rsa/rsa_saos.c
@@ -63,8 +63,9 @@
63#include <openssl/objects.h> 63#include <openssl/objects.h>
64#include <openssl/x509.h> 64#include <openssl/x509.h>
65 65
66int RSA_sign_ASN1_OCTET_STRING(int type, unsigned char *m, unsigned int m_len, 66int RSA_sign_ASN1_OCTET_STRING(int type,
67 unsigned char *sigret, unsigned int *siglen, RSA *rsa) 67 const unsigned char *m, unsigned int m_len,
68 unsigned char *sigret, unsigned int *siglen, RSA *rsa)
68 { 69 {
69 ASN1_OCTET_STRING sig; 70 ASN1_OCTET_STRING sig;
70 int i,j,ret=1; 71 int i,j,ret=1;
@@ -72,7 +73,7 @@ int RSA_sign_ASN1_OCTET_STRING(int type, unsigned char *m, unsigned int m_len,
72 73
73 sig.type=V_ASN1_OCTET_STRING; 74 sig.type=V_ASN1_OCTET_STRING;
74 sig.length=m_len; 75 sig.length=m_len;
75 sig.data=m; 76 sig.data=(unsigned char *)m;
76 77
77 i=i2d_ASN1_OCTET_STRING(&sig,NULL); 78 i=i2d_ASN1_OCTET_STRING(&sig,NULL);
78 j=RSA_size(rsa); 79 j=RSA_size(rsa);
@@ -100,9 +101,10 @@ int RSA_sign_ASN1_OCTET_STRING(int type, unsigned char *m, unsigned int m_len,
100 return(ret); 101 return(ret);
101 } 102 }
102 103
103int RSA_verify_ASN1_OCTET_STRING(int dtype, unsigned char *m, 104int RSA_verify_ASN1_OCTET_STRING(int dtype,
104 unsigned int m_len, unsigned char *sigbuf, unsigned int siglen, 105 const unsigned char *m,
105 RSA *rsa) 106 unsigned int m_len, unsigned char *sigbuf, unsigned int siglen,
107 RSA *rsa)
106 { 108 {
107 int i,ret=0; 109 int i,ret=0;
108 unsigned char *p,*s; 110 unsigned char *p,*s;
diff --git a/src/lib/libcrypto/rsa/rsa_sign.c b/src/lib/libcrypto/rsa/rsa_sign.c
index cf00876292..2a440901de 100644
--- a/src/lib/libcrypto/rsa/rsa_sign.c
+++ b/src/lib/libcrypto/rsa/rsa_sign.c
@@ -67,16 +67,18 @@
67/* Size of an SSL signature: MD5+SHA1 */ 67/* Size of an SSL signature: MD5+SHA1 */
68#define SSL_SIG_LENGTH 36 68#define SSL_SIG_LENGTH 36
69 69
70int RSA_sign(int type, unsigned char *m, unsigned int m_len, 70int RSA_sign(int type, const unsigned char *m, unsigned int m_len,
71 unsigned char *sigret, unsigned int *siglen, RSA *rsa) 71 unsigned char *sigret, unsigned int *siglen, RSA *rsa)
72 { 72 {
73 X509_SIG sig; 73 X509_SIG sig;
74 ASN1_TYPE parameter; 74 ASN1_TYPE parameter;
75 int i,j,ret=1; 75 int i,j,ret=1;
76 unsigned char *p,*s = NULL; 76 unsigned char *p, *tmps = 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) 80 if((rsa->flags & RSA_FLAG_SIGN_VER)
81 && ENGINE_get_RSA(rsa->engine)->rsa_sign)
80 return ENGINE_get_RSA(rsa->engine)->rsa_sign(type, 82 return ENGINE_get_RSA(rsa->engine)->rsa_sign(type,
81 m, m_len, sigret, siglen, rsa); 83 m, m_len, sigret, siglen, rsa);
82 /* Special case: SSL signature, just check the length */ 84 /* Special case: SSL signature, just check the length */
@@ -105,7 +107,7 @@ int RSA_sign(int type, unsigned char *m, unsigned int m_len,
105 sig.algor->parameter= &parameter; 107 sig.algor->parameter= &parameter;
106 108
107 sig.digest= &digest; 109 sig.digest= &digest;
108 sig.digest->data=m; 110 sig.digest->data=(unsigned char *)m; /* TMP UGLY CAST */
109 sig.digest->length=m_len; 111 sig.digest->length=m_len;
110 112
111 i=i2d_X509_SIG(&sig,NULL); 113 i=i2d_X509_SIG(&sig,NULL);
@@ -117,14 +119,15 @@ int RSA_sign(int type, unsigned char *m, unsigned int m_len,
117 return(0); 119 return(0);
118 } 120 }
119 if(type != NID_md5_sha1) { 121 if(type != NID_md5_sha1) {
120 s=(unsigned char *)OPENSSL_malloc((unsigned int)j+1); 122 tmps=(unsigned char *)OPENSSL_malloc((unsigned int)j+1);
121 if (s == NULL) 123 if (tmps == NULL)
122 { 124 {
123 RSAerr(RSA_F_RSA_SIGN,ERR_R_MALLOC_FAILURE); 125 RSAerr(RSA_F_RSA_SIGN,ERR_R_MALLOC_FAILURE);
124 return(0); 126 return(0);
125 } 127 }
126 p=s; 128 p=tmps;
127 i2d_X509_SIG(&sig,&p); 129 i2d_X509_SIG(&sig,&p);
130 s=tmps;
128 } 131 }
129 i=RSA_private_encrypt(i,s,sigret,rsa,RSA_PKCS1_PADDING); 132 i=RSA_private_encrypt(i,s,sigret,rsa,RSA_PKCS1_PADDING);
130 if (i <= 0) 133 if (i <= 0)
@@ -133,13 +136,13 @@ int RSA_sign(int type, unsigned char *m, unsigned int m_len,
133 *siglen=i; 136 *siglen=i;
134 137
135 if(type != NID_md5_sha1) { 138 if(type != NID_md5_sha1) {
136 memset(s,0,(unsigned int)j+1); 139 memset(tmps,0,(unsigned int)j+1);
137 OPENSSL_free(s); 140 OPENSSL_free(tmps);
138 } 141 }
139 return(ret); 142 return(ret);
140 } 143 }
141 144
142int RSA_verify(int dtype, unsigned char *m, unsigned int m_len, 145int RSA_verify(int dtype, const unsigned char *m, unsigned int m_len,
143 unsigned char *sigbuf, unsigned int siglen, RSA *rsa) 146 unsigned char *sigbuf, unsigned int siglen, RSA *rsa)
144 { 147 {
145 int i,ret=0,sigtype; 148 int i,ret=0,sigtype;
@@ -152,7 +155,8 @@ int RSA_verify(int dtype, unsigned char *m, unsigned int m_len,
152 return(0); 155 return(0);
153 } 156 }
154 157
155 if(rsa->flags & RSA_FLAG_SIGN_VER) 158 if((rsa->flags & RSA_FLAG_SIGN_VER)
159 && ENGINE_get_RSA(rsa->engine)->rsa_verify)
156 return ENGINE_get_RSA(rsa->engine)->rsa_verify(dtype, 160 return ENGINE_get_RSA(rsa->engine)->rsa_verify(dtype,
157 m, m_len, sigbuf, siglen, rsa); 161 m, m_len, sigbuf, siglen, rsa);
158 162
@@ -196,9 +200,9 @@ int RSA_verify(int dtype, unsigned char *m, unsigned int m_len,
196 (sigtype == NID_md2WithRSAEncryption))) 200 (sigtype == NID_md2WithRSAEncryption)))
197 { 201 {
198 /* ok, we will let it through */ 202 /* ok, we will let it through */
199 #if !defined(NO_STDIO) && !defined(WIN16) 203#if !defined(OPENSSL_NO_STDIO) && !defined(OPENSSL_SYS_WIN16)
200 fprintf(stderr,"signature has problems, re-make with post SSLeay045\n"); 204 fprintf(stderr,"signature has problems, re-make with post SSLeay045\n");
201 #endif 205#endif
202 } 206 }
203 else 207 else
204 { 208 {
diff --git a/src/lib/libcrypto/rsa/rsa_ssl.c b/src/lib/libcrypto/rsa/rsa_ssl.c
index 482f4a8273..ea72629494 100644
--- a/src/lib/libcrypto/rsa/rsa_ssl.c
+++ b/src/lib/libcrypto/rsa/rsa_ssl.c
@@ -62,8 +62,8 @@
62#include <openssl/rsa.h> 62#include <openssl/rsa.h>
63#include <openssl/rand.h> 63#include <openssl/rand.h>
64 64
65int RSA_padding_add_SSLv23(unsigned char *to, int tlen, unsigned char *from, 65int RSA_padding_add_SSLv23(unsigned char *to, int tlen,
66 int flen) 66 const unsigned char *from, int flen)
67 { 67 {
68 int i,j; 68 int i,j;
69 unsigned char *p; 69 unsigned char *p;
@@ -102,11 +102,11 @@ int RSA_padding_add_SSLv23(unsigned char *to, int tlen, unsigned char *from,
102 return(1); 102 return(1);
103 } 103 }
104 104
105int RSA_padding_check_SSLv23(unsigned char *to, int tlen, unsigned char *from, 105int RSA_padding_check_SSLv23(unsigned char *to, int tlen,
106 int flen, int num) 106 const unsigned char *from, int flen, int num)
107 { 107 {
108 int i,j,k; 108 int i,j,k;
109 unsigned char *p; 109 const unsigned char *p;
110 110
111 p=from; 111 p=from;
112 if (flen < 10) 112 if (flen < 10)
diff --git a/src/lib/libcrypto/rsa/rsa_test.c b/src/lib/libcrypto/rsa/rsa_test.c
index e5ae0c1f69..b8b462d33b 100644
--- a/src/lib/libcrypto/rsa/rsa_test.c
+++ b/src/lib/libcrypto/rsa/rsa_test.c
@@ -3,12 +3,12 @@
3#include <stdio.h> 3#include <stdio.h>
4#include <string.h> 4#include <string.h>
5 5
6#include "openssl/e_os.h" 6#include "e_os.h"
7 7
8#include <openssl/crypto.h> 8#include <openssl/crypto.h>
9#include <openssl/err.h> 9#include <openssl/err.h>
10#include <openssl/rand.h> 10#include <openssl/rand.h>
11#ifdef NO_RSA 11#ifdef OPENSSL_NO_RSA
12int main(int argc, char *argv[]) 12int main(int argc, char *argv[])
13{ 13{
14 printf("No RSA support\n"); 14 printf("No RSA support\n");
@@ -16,6 +16,7 @@ int main(int argc, char *argv[])
16} 16}
17#else 17#else
18#include <openssl/rsa.h> 18#include <openssl/rsa.h>
19#include <openssl/engine.h>
19 20
20#define SetKey \ 21#define SetKey \
21 key->n = BN_bin2bn(n, sizeof(n)-1, key->n); \ 22 key->n = BN_bin2bn(n, sizeof(n)-1, key->n); \
@@ -219,10 +220,12 @@ int main(int argc, char *argv[])
219 int clen = 0; 220 int clen = 0;
220 int num; 221 int num;
221 222
223 CRYPTO_malloc_debug_init();
224 CRYPTO_dbg_set_options(V_CRYPTO_MDEBUG_ALL);
225 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
226
222 RAND_seed(rnd_seed, sizeof rnd_seed); /* or OAEP may fail */ 227 RAND_seed(rnd_seed, sizeof rnd_seed); /* or OAEP may fail */
223 228
224 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
225
226 plen = sizeof(ptext_ex) - 1; 229 plen = sizeof(ptext_ex) - 1;
227 230
228 for (v = 0; v < 3; v++) 231 for (v = 0; v < 3; v++)
@@ -305,9 +308,10 @@ int main(int argc, char *argv[])
305 RSA_free(key); 308 RSA_free(key);
306 } 309 }
307 310
311 CRYPTO_cleanup_all_ex_data();
308 ERR_remove_state(0); 312 ERR_remove_state(0);
309 313
310 CRYPTO_mem_leaks_fp(stdout); 314 CRYPTO_mem_leaks_fp(stderr);
311 315
312 return err; 316 return err;
313 } 317 }
diff --git a/src/lib/libcrypto/sha/Makefile.ssl b/src/lib/libcrypto/sha/Makefile.ssl
index 790e572fa2..f203ad7681 100644
--- a/src/lib/libcrypto/sha/Makefile.ssl
+++ b/src/lib/libcrypto/sha/Makefile.ssl
@@ -12,7 +12,8 @@ INSTALL_PREFIX=
12OPENSSLDIR= /usr/local/ssl 12OPENSSLDIR= /usr/local/ssl
13INSTALLTOP=/usr/local/ssl 13INSTALLTOP=/usr/local/ssl
14MAKE= make -f Makefile.ssl 14MAKE= make -f Makefile.ssl
15MAKEDEPEND= $(TOP)/util/domd $(TOP) 15MAKEDEPPROG= makedepend
16MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl 17MAKEFILE= Makefile.ssl
17AR= ar r 18AR= ar r
18 19
@@ -42,8 +43,7 @@ all: lib
42 43
43lib: $(LIBOBJ) 44lib: $(LIBOBJ)
44 $(AR) $(LIB) $(LIBOBJ) 45 $(AR) $(LIB) $(LIBOBJ)
45 @echo You may get an error following this line. Please ignore. 46 $(RANLIB) $(LIB) || echo Never mind.
46 - $(RANLIB) $(LIB)
47 @touch lib 47 @touch lib
48 48
49# elf 49# elf
@@ -103,11 +103,13 @@ clean:
103 103
104# DO NOT DELETE THIS LINE -- make depend depends on it. 104# DO NOT DELETE THIS LINE -- make depend depends on it.
105 105
106sha1_one.o: ../../include/openssl/sha.h 106sha1_one.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
107sha1dgst.o: ../../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
108sha1dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/sha.h 109sha1dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/sha.h
109sha1dgst.o: ../md32_common.h sha_locl.h 110sha1dgst.o: ../md32_common.h sha1dgst.c sha_locl.h
110sha_dgst.o: ../../include/openssl/opensslconf.h 111sha_dgst.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
111sha_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/sha.h 112sha_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/sha.h
112sha_dgst.o: ../md32_common.h sha_locl.h 113sha_dgst.o: ../md32_common.h sha_dgst.c sha_locl.h
113sha_one.o: ../../include/openssl/sha.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/sha.h b/src/lib/libcrypto/sha/sha.h
index 77f6d9695e..3fd54a10cc 100644
--- a/src/lib/libcrypto/sha/sha.h
+++ b/src/lib/libcrypto/sha/sha.h
@@ -59,11 +59,13 @@
59#ifndef HEADER_SHA_H 59#ifndef HEADER_SHA_H
60#define HEADER_SHA_H 60#define HEADER_SHA_H
61 61
62#include <openssl/e_os2.h>
63
62#ifdef __cplusplus 64#ifdef __cplusplus
63extern "C" { 65extern "C" {
64#endif 66#endif
65 67
66#if defined(NO_SHA) || (defined(NO_SHA0) && defined(NO_SHA1)) 68#if defined(OPENSSL_NO_SHA) || (defined(OPENSSL_NO_SHA0) && defined(OPENSSL_NO_SHA1))
67#error SHA is disabled. 69#error SHA is disabled.
68#endif 70#endif
69 71
@@ -74,9 +76,9 @@ extern "C" {
74 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 76 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
75 */ 77 */
76 78
77#if defined(WIN16) || defined(__LP32__) 79#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__)
78#define SHA_LONG unsigned long 80#define SHA_LONG unsigned long
79#elif defined(_CRAY) || defined(__ILP64__) 81#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)
80#define SHA_LONG unsigned long 82#define SHA_LONG unsigned long
81#define SHA_LONG_LOG2 3 83#define SHA_LONG_LOG2 3
82#else 84#else
@@ -98,17 +100,17 @@ typedef struct SHAstate_st
98 int num; 100 int num;
99 } SHA_CTX; 101 } SHA_CTX;
100 102
101#ifndef NO_SHA0 103#ifndef OPENSSL_NO_SHA0
102void SHA_Init(SHA_CTX *c); 104int SHA_Init(SHA_CTX *c);
103void SHA_Update(SHA_CTX *c, const void *data, unsigned long len); 105int SHA_Update(SHA_CTX *c, const void *data, unsigned long len);
104void SHA_Final(unsigned char *md, SHA_CTX *c); 106int SHA_Final(unsigned char *md, SHA_CTX *c);
105unsigned char *SHA(const unsigned char *d, unsigned long n,unsigned char *md); 107unsigned char *SHA(const unsigned char *d, unsigned long n,unsigned char *md);
106void SHA_Transform(SHA_CTX *c, const unsigned char *data); 108void SHA_Transform(SHA_CTX *c, const unsigned char *data);
107#endif 109#endif
108#ifndef NO_SHA1 110#ifndef OPENSSL_NO_SHA1
109void SHA1_Init(SHA_CTX *c); 111int SHA1_Init(SHA_CTX *c);
110void SHA1_Update(SHA_CTX *c, const void *data, unsigned long len); 112int SHA1_Update(SHA_CTX *c, const void *data, unsigned long len);
111void SHA1_Final(unsigned char *md, SHA_CTX *c); 113int SHA1_Final(unsigned char *md, SHA_CTX *c);
112unsigned char *SHA1(const unsigned char *d, unsigned long n,unsigned char *md); 114unsigned char *SHA1(const unsigned char *d, unsigned long n,unsigned char *md);
113void SHA1_Transform(SHA_CTX *c, const unsigned char *data); 115void SHA1_Transform(SHA_CTX *c, const unsigned char *data);
114#endif 116#endif
diff --git a/src/lib/libcrypto/sha/sha1_one.c b/src/lib/libcrypto/sha/sha1_one.c
index 861752eaa7..e6a24888ed 100644
--- a/src/lib/libcrypto/sha/sha1_one.c
+++ b/src/lib/libcrypto/sha/sha1_one.c
@@ -60,7 +60,7 @@
60#include <string.h> 60#include <string.h>
61#include <openssl/sha.h> 61#include <openssl/sha.h>
62 62
63#ifndef NO_SHA1 63#ifndef OPENSSL_NO_SHA1
64unsigned 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)
65 { 65 {
66 SHA_CTX c; 66 SHA_CTX c;
diff --git a/src/lib/libcrypto/sha/sha1dgst.c b/src/lib/libcrypto/sha/sha1dgst.c
index c09edb4cd7..182f65982a 100644
--- a/src/lib/libcrypto/sha/sha1dgst.c
+++ b/src/lib/libcrypto/sha/sha1dgst.c
@@ -56,7 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#if !defined(NO_SHA1) && !defined(NO_SHA) 59#if !defined(OPENSSL_NO_SHA1) && !defined(OPENSSL_NO_SHA)
60 60
61#undef SHA_0 61#undef SHA_0
62#define SHA_1 62#define SHA_1
diff --git a/src/lib/libcrypto/sha/sha1test.c b/src/lib/libcrypto/sha/sha1test.c
index 688d06c637..499a1cf5af 100644
--- a/src/lib/libcrypto/sha/sha1test.c
+++ b/src/lib/libcrypto/sha/sha1test.c
@@ -60,13 +60,14 @@
60#include <string.h> 60#include <string.h>
61#include <stdlib.h> 61#include <stdlib.h>
62 62
63#ifdef NO_SHA 63#ifdef OPENSSL_NO_SHA
64int main(int argc, char *argv[]) 64int main(int argc, char *argv[])
65{ 65{
66 printf("No SHA support\n"); 66 printf("No SHA support\n");
67 return(0); 67 return(0);
68} 68}
69#else 69#else
70#include <openssl/evp.h>
70#include <openssl/sha.h> 71#include <openssl/sha.h>
71 72
72#ifdef CHARSET_EBCDIC 73#ifdef CHARSET_EBCDIC
@@ -106,7 +107,7 @@ int main(int argc, char *argv[])
106 unsigned char **P,**R; 107 unsigned char **P,**R;
107 static unsigned char buf[1000]; 108 static unsigned char buf[1000];
108 char *p,*r; 109 char *p,*r;
109 SHA_CTX c; 110 EVP_MD_CTX c;
110 unsigned char md[SHA_DIGEST_LENGTH]; 111 unsigned char md[SHA_DIGEST_LENGTH];
111 112
112#ifdef CHARSET_EBCDIC 113#ifdef CHARSET_EBCDIC
@@ -114,12 +115,14 @@ int main(int argc, char *argv[])
114 ebcdic2ascii(test[1], test[1], strlen(test[1])); 115 ebcdic2ascii(test[1], test[1], strlen(test[1]));
115#endif 116#endif
116 117
118 EVP_MD_CTX_init(&c);
117 P=(unsigned char **)test; 119 P=(unsigned char **)test;
118 R=(unsigned char **)ret; 120 R=(unsigned char **)ret;
119 i=1; 121 i=1;
120 while (*P != NULL) 122 while (*P != NULL)
121 { 123 {
122 p=pt(SHA1(*P,(unsigned long)strlen((char *)*P),NULL)); 124 EVP_Digest(*P,(unsigned long)strlen((char *)*P),md,NULL,EVP_sha1(), NULL);
125 p=pt(md);
123 if (strcmp(p,(char *)*R) != 0) 126 if (strcmp(p,(char *)*R) != 0)
124 { 127 {
125 printf("error calculating SHA1 on '%s'\n",*P); 128 printf("error calculating SHA1 on '%s'\n",*P);
@@ -137,10 +140,10 @@ int main(int argc, char *argv[])
137#ifdef CHARSET_EBCDIC 140#ifdef CHARSET_EBCDIC
138 ebcdic2ascii(buf, buf, 1000); 141 ebcdic2ascii(buf, buf, 1000);
139#endif /*CHARSET_EBCDIC*/ 142#endif /*CHARSET_EBCDIC*/
140 SHA1_Init(&c); 143 EVP_DigestInit_ex(&c,EVP_sha1(), NULL);
141 for (i=0; i<1000; i++) 144 for (i=0; i<1000; i++)
142 SHA1_Update(&c,buf,1000); 145 EVP_DigestUpdate(&c,buf,1000);
143 SHA1_Final(md,&c); 146 EVP_DigestFinal_ex(&c,md,NULL);
144 p=pt(md); 147 p=pt(md);
145 148
146 r=bigret; 149 r=bigret;
@@ -153,6 +156,7 @@ int main(int argc, char *argv[])
153 else 156 else
154 printf("test 3 ok\n"); 157 printf("test 3 ok\n");
155 exit(err); 158 exit(err);
159 EVP_MD_CTX_cleanup(&c);
156 return(0); 160 return(0);
157 } 161 }
158 162
diff --git a/src/lib/libcrypto/sha/sha_dgst.c b/src/lib/libcrypto/sha/sha_dgst.c
index 894a96274a..5a4b3ab204 100644
--- a/src/lib/libcrypto/sha/sha_dgst.c
+++ b/src/lib/libcrypto/sha/sha_dgst.c
@@ -56,7 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#if !defined(NO_SHA0) && !defined(NO_SHA) 59#if !defined(OPENSSL_NO_SHA0) && !defined(OPENSSL_NO_SHA)
60 60
61#undef SHA_1 61#undef SHA_1
62#define SHA_0 62#define SHA_0
diff --git a/src/lib/libcrypto/sha/sha_locl.h b/src/lib/libcrypto/sha/sha_locl.h
index 2f8aef83f3..471dfb9f8f 100644
--- a/src/lib/libcrypto/sha/sha_locl.h
+++ b/src/lib/libcrypto/sha/sha_locl.h
@@ -115,7 +115,7 @@
115# endif 115# endif
116 116
117# ifdef SHA1_ASM 117# ifdef SHA1_ASM
118# if defined(__i386) || defined(_M_IX86) || defined(__INTEL__) 118# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__)
119# define sha1_block_host_order sha1_block_asm_host_order 119# define sha1_block_host_order sha1_block_asm_host_order
120# define DONT_IMPLEMENT_BLOCK_HOST_ORDER 120# define DONT_IMPLEMENT_BLOCK_HOST_ORDER
121# define sha1_block_data_order sha1_block_asm_data_order 121# define sha1_block_data_order sha1_block_asm_data_order
@@ -138,7 +138,7 @@
138#define INIT_DATA_h3 0x10325476UL 138#define INIT_DATA_h3 0x10325476UL
139#define INIT_DATA_h4 0xc3d2e1f0UL 139#define INIT_DATA_h4 0xc3d2e1f0UL
140 140
141void HASH_INIT (SHA_CTX *c) 141int HASH_INIT (SHA_CTX *c)
142 { 142 {
143 c->h0=INIT_DATA_h0; 143 c->h0=INIT_DATA_h0;
144 c->h1=INIT_DATA_h1; 144 c->h1=INIT_DATA_h1;
@@ -148,6 +148,7 @@ void HASH_INIT (SHA_CTX *c)
148 c->Nl=0; 148 c->Nl=0;
149 c->Nh=0; 149 c->Nh=0;
150 c->num=0; 150 c->num=0;
151 return 1;
151 } 152 }
152 153
153#define K_00_19 0x5a827999UL 154#define K_00_19 0x5a827999UL
diff --git a/src/lib/libcrypto/sha/sha_one.c b/src/lib/libcrypto/sha/sha_one.c
index 2d955de162..5426faae4a 100644
--- a/src/lib/libcrypto/sha/sha_one.c
+++ b/src/lib/libcrypto/sha/sha_one.c
@@ -60,7 +60,7 @@
60#include <string.h> 60#include <string.h>
61#include <openssl/sha.h> 61#include <openssl/sha.h>
62 62
63#ifndef NO_SHA0 63#ifndef OPENSSL_NO_SHA0
64unsigned char *SHA(const unsigned char *d, unsigned long n, unsigned char *md) 64unsigned char *SHA(const unsigned char *d, unsigned long n, unsigned char *md)
65 { 65 {
66 SHA_CTX c; 66 SHA_CTX c;
diff --git a/src/lib/libcrypto/sha/shatest.c b/src/lib/libcrypto/sha/shatest.c
index a5786bbf76..331294a74f 100644
--- a/src/lib/libcrypto/sha/shatest.c
+++ b/src/lib/libcrypto/sha/shatest.c
@@ -60,13 +60,14 @@
60#include <string.h> 60#include <string.h>
61#include <stdlib.h> 61#include <stdlib.h>
62 62
63#ifdef NO_SHA 63#ifdef OPENSSL_NO_SHA
64int main(int argc, char *argv[]) 64int main(int argc, char *argv[])
65{ 65{
66 printf("No SHA support\n"); 66 printf("No SHA support\n");
67 return(0); 67 return(0);
68} 68}
69#else 69#else
70#include <openssl/evp.h>
70#include <openssl/sha.h> 71#include <openssl/sha.h>
71 72
72#ifdef CHARSET_EBCDIC 73#ifdef CHARSET_EBCDIC
@@ -106,7 +107,7 @@ int main(int argc, char *argv[])
106 unsigned char **P,**R; 107 unsigned char **P,**R;
107 static unsigned char buf[1000]; 108 static unsigned char buf[1000];
108 char *p,*r; 109 char *p,*r;
109 SHA_CTX c; 110 EVP_MD_CTX c;
110 unsigned char md[SHA_DIGEST_LENGTH]; 111 unsigned char md[SHA_DIGEST_LENGTH];
111 112
112#ifdef CHARSET_EBCDIC 113#ifdef CHARSET_EBCDIC
@@ -114,12 +115,14 @@ int main(int argc, char *argv[])
114 ebcdic2ascii(test[1], test[1], strlen(test[1])); 115 ebcdic2ascii(test[1], test[1], strlen(test[1]));
115#endif 116#endif
116 117
118 EVP_MD_CTX_init(&c);
117 P=(unsigned char **)test; 119 P=(unsigned char **)test;
118 R=(unsigned char **)ret; 120 R=(unsigned char **)ret;
119 i=1; 121 i=1;
120 while (*P != NULL) 122 while (*P != NULL)
121 { 123 {
122 p=pt(SHA(*P,(unsigned long)strlen((char *)*P),NULL)); 124 EVP_Digest(*P,(unsigned long)strlen((char *)*P),md,NULL,EVP_sha(), NULL);
125 p=pt(md);
123 if (strcmp(p,(char *)*R) != 0) 126 if (strcmp(p,(char *)*R) != 0)
124 { 127 {
125 printf("error calculating SHA on '%s'\n",*P); 128 printf("error calculating SHA on '%s'\n",*P);
@@ -137,10 +140,10 @@ int main(int argc, char *argv[])
137#ifdef CHARSET_EBCDIC 140#ifdef CHARSET_EBCDIC
138 ebcdic2ascii(buf, buf, 1000); 141 ebcdic2ascii(buf, buf, 1000);
139#endif /*CHARSET_EBCDIC*/ 142#endif /*CHARSET_EBCDIC*/
140 SHA_Init(&c); 143 EVP_DigestInit_ex(&c,EVP_sha(), NULL);
141 for (i=0; i<1000; i++) 144 for (i=0; i<1000; i++)
142 SHA_Update(&c,buf,1000); 145 EVP_DigestUpdate(&c,buf,1000);
143 SHA_Final(md,&c); 146 EVP_DigestFinal_ex(&c,md,NULL);
144 p=pt(md); 147 p=pt(md);
145 148
146 r=bigret; 149 r=bigret;
@@ -152,6 +155,7 @@ int main(int argc, char *argv[])
152 } 155 }
153 else 156 else
154 printf("test 3 ok\n"); 157 printf("test 3 ok\n");
158 EVP_MD_CTX_cleanup(&c);
155 exit(err); 159 exit(err);
156 return(0); 160 return(0);
157 } 161 }
diff --git a/src/lib/libcrypto/stack/Makefile.ssl b/src/lib/libcrypto/stack/Makefile.ssl
index c916fd5451..23b24040bc 100644
--- a/src/lib/libcrypto/stack/Makefile.ssl
+++ b/src/lib/libcrypto/stack/Makefile.ssl
@@ -11,7 +11,8 @@ INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl 11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl 12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl 13MAKE= make -f Makefile.ssl
14MAKEDEPEND= $(TOP)/util/domd $(TOP) 14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
15MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
16AR= ar r 17AR= ar r
17 18
@@ -39,8 +40,7 @@ all: lib
39 40
40lib: $(LIBOBJ) 41lib: $(LIBOBJ)
41 $(AR) $(LIB) $(LIBOBJ) 42 $(AR) $(LIB) $(LIBOBJ)
42 @echo You may get an error following this line. Please ignore. 43 $(RANLIB) $(LIB) || echo Never mind.
43 - $(RANLIB) $(LIB)
44 @touch lib 44 @touch lib
45 45
46files: 46files:
@@ -79,10 +79,10 @@ clean:
79 79
80# DO NOT DELETE THIS LINE -- make depend depends on it. 80# DO NOT DELETE THIS LINE -- make depend depends on it.
81 81
82stack.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 82stack.o: ../../e_os.h ../../include/openssl/bio.h
83stack.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 83stack.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
84stack.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 84stack.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
85stack.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 85stack.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
86stack.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 86stack.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
87stack.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 87stack.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
88stack.o: ../cryptlib.h 88stack.o: ../cryptlib.h stack.c
diff --git a/src/lib/libcrypto/stack/safestack.h b/src/lib/libcrypto/stack/safestack.h
index 9fa63e1be5..ed9ed2c23a 100644
--- a/src/lib/libcrypto/stack/safestack.h
+++ b/src/lib/libcrypto/stack/safestack.h
@@ -224,6 +224,26 @@ STACK_OF(type) \
224#define sk_ACCESS_DESCRIPTION_pop(st) SKM_sk_pop(ACCESS_DESCRIPTION, (st)) 224#define sk_ACCESS_DESCRIPTION_pop(st) SKM_sk_pop(ACCESS_DESCRIPTION, (st))
225#define sk_ACCESS_DESCRIPTION_sort(st) SKM_sk_sort(ACCESS_DESCRIPTION, (st)) 225#define sk_ACCESS_DESCRIPTION_sort(st) SKM_sk_sort(ACCESS_DESCRIPTION, (st))
226 226
227#define sk_ASN1_GENERALSTRING_new(st) SKM_sk_new(ASN1_GENERALSTRING, (st))
228#define sk_ASN1_GENERALSTRING_new_null() SKM_sk_new_null(ASN1_GENERALSTRING)
229#define sk_ASN1_GENERALSTRING_free(st) SKM_sk_free(ASN1_GENERALSTRING, (st))
230#define sk_ASN1_GENERALSTRING_num(st) SKM_sk_num(ASN1_GENERALSTRING, (st))
231#define sk_ASN1_GENERALSTRING_value(st, i) SKM_sk_value(ASN1_GENERALSTRING, (st), (i))
232#define sk_ASN1_GENERALSTRING_set(st, i, val) SKM_sk_set(ASN1_GENERALSTRING, (st), (i), (val))
233#define sk_ASN1_GENERALSTRING_zero(st) SKM_sk_zero(ASN1_GENERALSTRING, (st))
234#define sk_ASN1_GENERALSTRING_push(st, val) SKM_sk_push(ASN1_GENERALSTRING, (st), (val))
235#define sk_ASN1_GENERALSTRING_unshift(st, val) SKM_sk_unshift(ASN1_GENERALSTRING, (st), (val))
236#define sk_ASN1_GENERALSTRING_find(st, val) SKM_sk_find(ASN1_GENERALSTRING, (st), (val))
237#define sk_ASN1_GENERALSTRING_delete(st, i) SKM_sk_delete(ASN1_GENERALSTRING, (st), (i))
238#define sk_ASN1_GENERALSTRING_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_GENERALSTRING, (st), (ptr))
239#define sk_ASN1_GENERALSTRING_insert(st, val, i) SKM_sk_insert(ASN1_GENERALSTRING, (st), (val), (i))
240#define sk_ASN1_GENERALSTRING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_GENERALSTRING, (st), (cmp))
241#define sk_ASN1_GENERALSTRING_dup(st) SKM_sk_dup(ASN1_GENERALSTRING, st)
242#define sk_ASN1_GENERALSTRING_pop_free(st, free_func) SKM_sk_pop_free(ASN1_GENERALSTRING, (st), (free_func))
243#define sk_ASN1_GENERALSTRING_shift(st) SKM_sk_shift(ASN1_GENERALSTRING, (st))
244#define sk_ASN1_GENERALSTRING_pop(st) SKM_sk_pop(ASN1_GENERALSTRING, (st))
245#define sk_ASN1_GENERALSTRING_sort(st) SKM_sk_sort(ASN1_GENERALSTRING, (st))
246
227#define sk_ASN1_INTEGER_new(st) SKM_sk_new(ASN1_INTEGER, (st)) 247#define sk_ASN1_INTEGER_new(st) SKM_sk_new(ASN1_INTEGER, (st))
228#define sk_ASN1_INTEGER_new_null() SKM_sk_new_null(ASN1_INTEGER) 248#define sk_ASN1_INTEGER_new_null() SKM_sk_new_null(ASN1_INTEGER)
229#define sk_ASN1_INTEGER_free(st) SKM_sk_free(ASN1_INTEGER, (st)) 249#define sk_ASN1_INTEGER_free(st) SKM_sk_free(ASN1_INTEGER, (st))
@@ -304,6 +324,26 @@ STACK_OF(type) \
304#define sk_ASN1_TYPE_pop(st) SKM_sk_pop(ASN1_TYPE, (st)) 324#define sk_ASN1_TYPE_pop(st) SKM_sk_pop(ASN1_TYPE, (st))
305#define sk_ASN1_TYPE_sort(st) SKM_sk_sort(ASN1_TYPE, (st)) 325#define sk_ASN1_TYPE_sort(st) SKM_sk_sort(ASN1_TYPE, (st))
306 326
327#define sk_ASN1_VALUE_new(st) SKM_sk_new(ASN1_VALUE, (st))
328#define sk_ASN1_VALUE_new_null() SKM_sk_new_null(ASN1_VALUE)
329#define sk_ASN1_VALUE_free(st) SKM_sk_free(ASN1_VALUE, (st))
330#define sk_ASN1_VALUE_num(st) SKM_sk_num(ASN1_VALUE, (st))
331#define sk_ASN1_VALUE_value(st, i) SKM_sk_value(ASN1_VALUE, (st), (i))
332#define sk_ASN1_VALUE_set(st, i, val) SKM_sk_set(ASN1_VALUE, (st), (i), (val))
333#define sk_ASN1_VALUE_zero(st) SKM_sk_zero(ASN1_VALUE, (st))
334#define sk_ASN1_VALUE_push(st, val) SKM_sk_push(ASN1_VALUE, (st), (val))
335#define sk_ASN1_VALUE_unshift(st, val) SKM_sk_unshift(ASN1_VALUE, (st), (val))
336#define sk_ASN1_VALUE_find(st, val) SKM_sk_find(ASN1_VALUE, (st), (val))
337#define sk_ASN1_VALUE_delete(st, i) SKM_sk_delete(ASN1_VALUE, (st), (i))
338#define sk_ASN1_VALUE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_VALUE, (st), (ptr))
339#define sk_ASN1_VALUE_insert(st, val, i) SKM_sk_insert(ASN1_VALUE, (st), (val), (i))
340#define sk_ASN1_VALUE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_VALUE, (st), (cmp))
341#define sk_ASN1_VALUE_dup(st) SKM_sk_dup(ASN1_VALUE, st)
342#define sk_ASN1_VALUE_pop_free(st, free_func) SKM_sk_pop_free(ASN1_VALUE, (st), (free_func))
343#define sk_ASN1_VALUE_shift(st) SKM_sk_shift(ASN1_VALUE, (st))
344#define sk_ASN1_VALUE_pop(st) SKM_sk_pop(ASN1_VALUE, (st))
345#define sk_ASN1_VALUE_sort(st) SKM_sk_sort(ASN1_VALUE, (st))
346
307#define sk_BIO_new(st) SKM_sk_new(BIO, (st)) 347#define sk_BIO_new(st) SKM_sk_new(BIO, (st))
308#define sk_BIO_new_null() SKM_sk_new_null(BIO) 348#define sk_BIO_new_null() SKM_sk_new_null(BIO)
309#define sk_BIO_free(st) SKM_sk_free(BIO, (st)) 349#define sk_BIO_free(st) SKM_sk_free(BIO, (st))
@@ -324,6 +364,46 @@ STACK_OF(type) \
324#define sk_BIO_pop(st) SKM_sk_pop(BIO, (st)) 364#define sk_BIO_pop(st) SKM_sk_pop(BIO, (st))
325#define sk_BIO_sort(st) SKM_sk_sort(BIO, (st)) 365#define sk_BIO_sort(st) SKM_sk_sort(BIO, (st))
326 366
367#define sk_CONF_IMODULE_new(st) SKM_sk_new(CONF_IMODULE, (st))
368#define sk_CONF_IMODULE_new_null() SKM_sk_new_null(CONF_IMODULE)
369#define sk_CONF_IMODULE_free(st) SKM_sk_free(CONF_IMODULE, (st))
370#define sk_CONF_IMODULE_num(st) SKM_sk_num(CONF_IMODULE, (st))
371#define sk_CONF_IMODULE_value(st, i) SKM_sk_value(CONF_IMODULE, (st), (i))
372#define sk_CONF_IMODULE_set(st, i, val) SKM_sk_set(CONF_IMODULE, (st), (i), (val))
373#define sk_CONF_IMODULE_zero(st) SKM_sk_zero(CONF_IMODULE, (st))
374#define sk_CONF_IMODULE_push(st, val) SKM_sk_push(CONF_IMODULE, (st), (val))
375#define sk_CONF_IMODULE_unshift(st, val) SKM_sk_unshift(CONF_IMODULE, (st), (val))
376#define sk_CONF_IMODULE_find(st, val) SKM_sk_find(CONF_IMODULE, (st), (val))
377#define sk_CONF_IMODULE_delete(st, i) SKM_sk_delete(CONF_IMODULE, (st), (i))
378#define sk_CONF_IMODULE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_IMODULE, (st), (ptr))
379#define sk_CONF_IMODULE_insert(st, val, i) SKM_sk_insert(CONF_IMODULE, (st), (val), (i))
380#define sk_CONF_IMODULE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_IMODULE, (st), (cmp))
381#define sk_CONF_IMODULE_dup(st) SKM_sk_dup(CONF_IMODULE, st)
382#define sk_CONF_IMODULE_pop_free(st, free_func) SKM_sk_pop_free(CONF_IMODULE, (st), (free_func))
383#define sk_CONF_IMODULE_shift(st) SKM_sk_shift(CONF_IMODULE, (st))
384#define sk_CONF_IMODULE_pop(st) SKM_sk_pop(CONF_IMODULE, (st))
385#define sk_CONF_IMODULE_sort(st) SKM_sk_sort(CONF_IMODULE, (st))
386
387#define sk_CONF_MODULE_new(st) SKM_sk_new(CONF_MODULE, (st))
388#define sk_CONF_MODULE_new_null() SKM_sk_new_null(CONF_MODULE)
389#define sk_CONF_MODULE_free(st) SKM_sk_free(CONF_MODULE, (st))
390#define sk_CONF_MODULE_num(st) SKM_sk_num(CONF_MODULE, (st))
391#define sk_CONF_MODULE_value(st, i) SKM_sk_value(CONF_MODULE, (st), (i))
392#define sk_CONF_MODULE_set(st, i, val) SKM_sk_set(CONF_MODULE, (st), (i), (val))
393#define sk_CONF_MODULE_zero(st) SKM_sk_zero(CONF_MODULE, (st))
394#define sk_CONF_MODULE_push(st, val) SKM_sk_push(CONF_MODULE, (st), (val))
395#define sk_CONF_MODULE_unshift(st, val) SKM_sk_unshift(CONF_MODULE, (st), (val))
396#define sk_CONF_MODULE_find(st, val) SKM_sk_find(CONF_MODULE, (st), (val))
397#define sk_CONF_MODULE_delete(st, i) SKM_sk_delete(CONF_MODULE, (st), (i))
398#define sk_CONF_MODULE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_MODULE, (st), (ptr))
399#define sk_CONF_MODULE_insert(st, val, i) SKM_sk_insert(CONF_MODULE, (st), (val), (i))
400#define sk_CONF_MODULE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_MODULE, (st), (cmp))
401#define sk_CONF_MODULE_dup(st) SKM_sk_dup(CONF_MODULE, st)
402#define sk_CONF_MODULE_pop_free(st, free_func) SKM_sk_pop_free(CONF_MODULE, (st), (free_func))
403#define sk_CONF_MODULE_shift(st) SKM_sk_shift(CONF_MODULE, (st))
404#define sk_CONF_MODULE_pop(st) SKM_sk_pop(CONF_MODULE, (st))
405#define sk_CONF_MODULE_sort(st) SKM_sk_sort(CONF_MODULE, (st))
406
327#define sk_CONF_VALUE_new(st) SKM_sk_new(CONF_VALUE, (st)) 407#define sk_CONF_VALUE_new(st) SKM_sk_new(CONF_VALUE, (st))
328#define sk_CONF_VALUE_new_null() SKM_sk_new_null(CONF_VALUE) 408#define sk_CONF_VALUE_new_null() SKM_sk_new_null(CONF_VALUE)
329#define sk_CONF_VALUE_free(st) SKM_sk_free(CONF_VALUE, (st)) 409#define sk_CONF_VALUE_free(st) SKM_sk_free(CONF_VALUE, (st))
@@ -404,6 +484,46 @@ STACK_OF(type) \
404#define sk_DIST_POINT_pop(st) SKM_sk_pop(DIST_POINT, (st)) 484#define sk_DIST_POINT_pop(st) SKM_sk_pop(DIST_POINT, (st))
405#define sk_DIST_POINT_sort(st) SKM_sk_sort(DIST_POINT, (st)) 485#define sk_DIST_POINT_sort(st) SKM_sk_sort(DIST_POINT, (st))
406 486
487#define sk_ENGINE_new(st) SKM_sk_new(ENGINE, (st))
488#define sk_ENGINE_new_null() SKM_sk_new_null(ENGINE)
489#define sk_ENGINE_free(st) SKM_sk_free(ENGINE, (st))
490#define sk_ENGINE_num(st) SKM_sk_num(ENGINE, (st))
491#define sk_ENGINE_value(st, i) SKM_sk_value(ENGINE, (st), (i))
492#define sk_ENGINE_set(st, i, val) SKM_sk_set(ENGINE, (st), (i), (val))
493#define sk_ENGINE_zero(st) SKM_sk_zero(ENGINE, (st))
494#define sk_ENGINE_push(st, val) SKM_sk_push(ENGINE, (st), (val))
495#define sk_ENGINE_unshift(st, val) SKM_sk_unshift(ENGINE, (st), (val))
496#define sk_ENGINE_find(st, val) SKM_sk_find(ENGINE, (st), (val))
497#define sk_ENGINE_delete(st, i) SKM_sk_delete(ENGINE, (st), (i))
498#define sk_ENGINE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ENGINE, (st), (ptr))
499#define sk_ENGINE_insert(st, val, i) SKM_sk_insert(ENGINE, (st), (val), (i))
500#define sk_ENGINE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ENGINE, (st), (cmp))
501#define sk_ENGINE_dup(st) SKM_sk_dup(ENGINE, st)
502#define sk_ENGINE_pop_free(st, free_func) SKM_sk_pop_free(ENGINE, (st), (free_func))
503#define sk_ENGINE_shift(st) SKM_sk_shift(ENGINE, (st))
504#define sk_ENGINE_pop(st) SKM_sk_pop(ENGINE, (st))
505#define sk_ENGINE_sort(st) SKM_sk_sort(ENGINE, (st))
506
507#define sk_ENGINE_CLEANUP_ITEM_new(st) SKM_sk_new(ENGINE_CLEANUP_ITEM, (st))
508#define sk_ENGINE_CLEANUP_ITEM_new_null() SKM_sk_new_null(ENGINE_CLEANUP_ITEM)
509#define sk_ENGINE_CLEANUP_ITEM_free(st) SKM_sk_free(ENGINE_CLEANUP_ITEM, (st))
510#define sk_ENGINE_CLEANUP_ITEM_num(st) SKM_sk_num(ENGINE_CLEANUP_ITEM, (st))
511#define sk_ENGINE_CLEANUP_ITEM_value(st, i) SKM_sk_value(ENGINE_CLEANUP_ITEM, (st), (i))
512#define sk_ENGINE_CLEANUP_ITEM_set(st, i, val) SKM_sk_set(ENGINE_CLEANUP_ITEM, (st), (i), (val))
513#define sk_ENGINE_CLEANUP_ITEM_zero(st) SKM_sk_zero(ENGINE_CLEANUP_ITEM, (st))
514#define sk_ENGINE_CLEANUP_ITEM_push(st, val) SKM_sk_push(ENGINE_CLEANUP_ITEM, (st), (val))
515#define sk_ENGINE_CLEANUP_ITEM_unshift(st, val) SKM_sk_unshift(ENGINE_CLEANUP_ITEM, (st), (val))
516#define sk_ENGINE_CLEANUP_ITEM_find(st, val) SKM_sk_find(ENGINE_CLEANUP_ITEM, (st), (val))
517#define sk_ENGINE_CLEANUP_ITEM_delete(st, i) SKM_sk_delete(ENGINE_CLEANUP_ITEM, (st), (i))
518#define sk_ENGINE_CLEANUP_ITEM_delete_ptr(st, ptr) SKM_sk_delete_ptr(ENGINE_CLEANUP_ITEM, (st), (ptr))
519#define sk_ENGINE_CLEANUP_ITEM_insert(st, val, i) SKM_sk_insert(ENGINE_CLEANUP_ITEM, (st), (val), (i))
520#define sk_ENGINE_CLEANUP_ITEM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ENGINE_CLEANUP_ITEM, (st), (cmp))
521#define sk_ENGINE_CLEANUP_ITEM_dup(st) SKM_sk_dup(ENGINE_CLEANUP_ITEM, st)
522#define sk_ENGINE_CLEANUP_ITEM_pop_free(st, free_func) SKM_sk_pop_free(ENGINE_CLEANUP_ITEM, (st), (free_func))
523#define sk_ENGINE_CLEANUP_ITEM_shift(st) SKM_sk_shift(ENGINE_CLEANUP_ITEM, (st))
524#define sk_ENGINE_CLEANUP_ITEM_pop(st) SKM_sk_pop(ENGINE_CLEANUP_ITEM, (st))
525#define sk_ENGINE_CLEANUP_ITEM_sort(st) SKM_sk_sort(ENGINE_CLEANUP_ITEM, (st))
526
407#define sk_GENERAL_NAME_new(st) SKM_sk_new(GENERAL_NAME, (st)) 527#define sk_GENERAL_NAME_new(st) SKM_sk_new(GENERAL_NAME, (st))
408#define sk_GENERAL_NAME_new_null() SKM_sk_new_null(GENERAL_NAME) 528#define sk_GENERAL_NAME_new_null() SKM_sk_new_null(GENERAL_NAME)
409#define sk_GENERAL_NAME_free(st) SKM_sk_free(GENERAL_NAME, (st)) 529#define sk_GENERAL_NAME_free(st) SKM_sk_free(GENERAL_NAME, (st))
@@ -424,6 +544,166 @@ STACK_OF(type) \
424#define sk_GENERAL_NAME_pop(st) SKM_sk_pop(GENERAL_NAME, (st)) 544#define sk_GENERAL_NAME_pop(st) SKM_sk_pop(GENERAL_NAME, (st))
425#define sk_GENERAL_NAME_sort(st) SKM_sk_sort(GENERAL_NAME, (st)) 545#define sk_GENERAL_NAME_sort(st) SKM_sk_sort(GENERAL_NAME, (st))
426 546
547#define sk_KRB5_APREQBODY_new(st) SKM_sk_new(KRB5_APREQBODY, (st))
548#define sk_KRB5_APREQBODY_new_null() SKM_sk_new_null(KRB5_APREQBODY)
549#define sk_KRB5_APREQBODY_free(st) SKM_sk_free(KRB5_APREQBODY, (st))
550#define sk_KRB5_APREQBODY_num(st) SKM_sk_num(KRB5_APREQBODY, (st))
551#define sk_KRB5_APREQBODY_value(st, i) SKM_sk_value(KRB5_APREQBODY, (st), (i))
552#define sk_KRB5_APREQBODY_set(st, i, val) SKM_sk_set(KRB5_APREQBODY, (st), (i), (val))
553#define sk_KRB5_APREQBODY_zero(st) SKM_sk_zero(KRB5_APREQBODY, (st))
554#define sk_KRB5_APREQBODY_push(st, val) SKM_sk_push(KRB5_APREQBODY, (st), (val))
555#define sk_KRB5_APREQBODY_unshift(st, val) SKM_sk_unshift(KRB5_APREQBODY, (st), (val))
556#define sk_KRB5_APREQBODY_find(st, val) SKM_sk_find(KRB5_APREQBODY, (st), (val))
557#define sk_KRB5_APREQBODY_delete(st, i) SKM_sk_delete(KRB5_APREQBODY, (st), (i))
558#define sk_KRB5_APREQBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_APREQBODY, (st), (ptr))
559#define sk_KRB5_APREQBODY_insert(st, val, i) SKM_sk_insert(KRB5_APREQBODY, (st), (val), (i))
560#define sk_KRB5_APREQBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_APREQBODY, (st), (cmp))
561#define sk_KRB5_APREQBODY_dup(st) SKM_sk_dup(KRB5_APREQBODY, st)
562#define sk_KRB5_APREQBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_APREQBODY, (st), (free_func))
563#define sk_KRB5_APREQBODY_shift(st) SKM_sk_shift(KRB5_APREQBODY, (st))
564#define sk_KRB5_APREQBODY_pop(st) SKM_sk_pop(KRB5_APREQBODY, (st))
565#define sk_KRB5_APREQBODY_sort(st) SKM_sk_sort(KRB5_APREQBODY, (st))
566
567#define sk_KRB5_AUTHDATA_new(st) SKM_sk_new(KRB5_AUTHDATA, (st))
568#define sk_KRB5_AUTHDATA_new_null() SKM_sk_new_null(KRB5_AUTHDATA)
569#define sk_KRB5_AUTHDATA_free(st) SKM_sk_free(KRB5_AUTHDATA, (st))
570#define sk_KRB5_AUTHDATA_num(st) SKM_sk_num(KRB5_AUTHDATA, (st))
571#define sk_KRB5_AUTHDATA_value(st, i) SKM_sk_value(KRB5_AUTHDATA, (st), (i))
572#define sk_KRB5_AUTHDATA_set(st, i, val) SKM_sk_set(KRB5_AUTHDATA, (st), (i), (val))
573#define sk_KRB5_AUTHDATA_zero(st) SKM_sk_zero(KRB5_AUTHDATA, (st))
574#define sk_KRB5_AUTHDATA_push(st, val) SKM_sk_push(KRB5_AUTHDATA, (st), (val))
575#define sk_KRB5_AUTHDATA_unshift(st, val) SKM_sk_unshift(KRB5_AUTHDATA, (st), (val))
576#define sk_KRB5_AUTHDATA_find(st, val) SKM_sk_find(KRB5_AUTHDATA, (st), (val))
577#define sk_KRB5_AUTHDATA_delete(st, i) SKM_sk_delete(KRB5_AUTHDATA, (st), (i))
578#define sk_KRB5_AUTHDATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_AUTHDATA, (st), (ptr))
579#define sk_KRB5_AUTHDATA_insert(st, val, i) SKM_sk_insert(KRB5_AUTHDATA, (st), (val), (i))
580#define sk_KRB5_AUTHDATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_AUTHDATA, (st), (cmp))
581#define sk_KRB5_AUTHDATA_dup(st) SKM_sk_dup(KRB5_AUTHDATA, st)
582#define sk_KRB5_AUTHDATA_pop_free(st, free_func) SKM_sk_pop_free(KRB5_AUTHDATA, (st), (free_func))
583#define sk_KRB5_AUTHDATA_shift(st) SKM_sk_shift(KRB5_AUTHDATA, (st))
584#define sk_KRB5_AUTHDATA_pop(st) SKM_sk_pop(KRB5_AUTHDATA, (st))
585#define sk_KRB5_AUTHDATA_sort(st) SKM_sk_sort(KRB5_AUTHDATA, (st))
586
587#define sk_KRB5_AUTHENTBODY_new(st) SKM_sk_new(KRB5_AUTHENTBODY, (st))
588#define sk_KRB5_AUTHENTBODY_new_null() SKM_sk_new_null(KRB5_AUTHENTBODY)
589#define sk_KRB5_AUTHENTBODY_free(st) SKM_sk_free(KRB5_AUTHENTBODY, (st))
590#define sk_KRB5_AUTHENTBODY_num(st) SKM_sk_num(KRB5_AUTHENTBODY, (st))
591#define sk_KRB5_AUTHENTBODY_value(st, i) SKM_sk_value(KRB5_AUTHENTBODY, (st), (i))
592#define sk_KRB5_AUTHENTBODY_set(st, i, val) SKM_sk_set(KRB5_AUTHENTBODY, (st), (i), (val))
593#define sk_KRB5_AUTHENTBODY_zero(st) SKM_sk_zero(KRB5_AUTHENTBODY, (st))
594#define sk_KRB5_AUTHENTBODY_push(st, val) SKM_sk_push(KRB5_AUTHENTBODY, (st), (val))
595#define sk_KRB5_AUTHENTBODY_unshift(st, val) SKM_sk_unshift(KRB5_AUTHENTBODY, (st), (val))
596#define sk_KRB5_AUTHENTBODY_find(st, val) SKM_sk_find(KRB5_AUTHENTBODY, (st), (val))
597#define sk_KRB5_AUTHENTBODY_delete(st, i) SKM_sk_delete(KRB5_AUTHENTBODY, (st), (i))
598#define sk_KRB5_AUTHENTBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_AUTHENTBODY, (st), (ptr))
599#define sk_KRB5_AUTHENTBODY_insert(st, val, i) SKM_sk_insert(KRB5_AUTHENTBODY, (st), (val), (i))
600#define sk_KRB5_AUTHENTBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_AUTHENTBODY, (st), (cmp))
601#define sk_KRB5_AUTHENTBODY_dup(st) SKM_sk_dup(KRB5_AUTHENTBODY, st)
602#define sk_KRB5_AUTHENTBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_AUTHENTBODY, (st), (free_func))
603#define sk_KRB5_AUTHENTBODY_shift(st) SKM_sk_shift(KRB5_AUTHENTBODY, (st))
604#define sk_KRB5_AUTHENTBODY_pop(st) SKM_sk_pop(KRB5_AUTHENTBODY, (st))
605#define sk_KRB5_AUTHENTBODY_sort(st) SKM_sk_sort(KRB5_AUTHENTBODY, (st))
606
607#define sk_KRB5_CHECKSUM_new(st) SKM_sk_new(KRB5_CHECKSUM, (st))
608#define sk_KRB5_CHECKSUM_new_null() SKM_sk_new_null(KRB5_CHECKSUM)
609#define sk_KRB5_CHECKSUM_free(st) SKM_sk_free(KRB5_CHECKSUM, (st))
610#define sk_KRB5_CHECKSUM_num(st) SKM_sk_num(KRB5_CHECKSUM, (st))
611#define sk_KRB5_CHECKSUM_value(st, i) SKM_sk_value(KRB5_CHECKSUM, (st), (i))
612#define sk_KRB5_CHECKSUM_set(st, i, val) SKM_sk_set(KRB5_CHECKSUM, (st), (i), (val))
613#define sk_KRB5_CHECKSUM_zero(st) SKM_sk_zero(KRB5_CHECKSUM, (st))
614#define sk_KRB5_CHECKSUM_push(st, val) SKM_sk_push(KRB5_CHECKSUM, (st), (val))
615#define sk_KRB5_CHECKSUM_unshift(st, val) SKM_sk_unshift(KRB5_CHECKSUM, (st), (val))
616#define sk_KRB5_CHECKSUM_find(st, val) SKM_sk_find(KRB5_CHECKSUM, (st), (val))
617#define sk_KRB5_CHECKSUM_delete(st, i) SKM_sk_delete(KRB5_CHECKSUM, (st), (i))
618#define sk_KRB5_CHECKSUM_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_CHECKSUM, (st), (ptr))
619#define sk_KRB5_CHECKSUM_insert(st, val, i) SKM_sk_insert(KRB5_CHECKSUM, (st), (val), (i))
620#define sk_KRB5_CHECKSUM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_CHECKSUM, (st), (cmp))
621#define sk_KRB5_CHECKSUM_dup(st) SKM_sk_dup(KRB5_CHECKSUM, st)
622#define sk_KRB5_CHECKSUM_pop_free(st, free_func) SKM_sk_pop_free(KRB5_CHECKSUM, (st), (free_func))
623#define sk_KRB5_CHECKSUM_shift(st) SKM_sk_shift(KRB5_CHECKSUM, (st))
624#define sk_KRB5_CHECKSUM_pop(st) SKM_sk_pop(KRB5_CHECKSUM, (st))
625#define sk_KRB5_CHECKSUM_sort(st) SKM_sk_sort(KRB5_CHECKSUM, (st))
626
627#define sk_KRB5_ENCDATA_new(st) SKM_sk_new(KRB5_ENCDATA, (st))
628#define sk_KRB5_ENCDATA_new_null() SKM_sk_new_null(KRB5_ENCDATA)
629#define sk_KRB5_ENCDATA_free(st) SKM_sk_free(KRB5_ENCDATA, (st))
630#define sk_KRB5_ENCDATA_num(st) SKM_sk_num(KRB5_ENCDATA, (st))
631#define sk_KRB5_ENCDATA_value(st, i) SKM_sk_value(KRB5_ENCDATA, (st), (i))
632#define sk_KRB5_ENCDATA_set(st, i, val) SKM_sk_set(KRB5_ENCDATA, (st), (i), (val))
633#define sk_KRB5_ENCDATA_zero(st) SKM_sk_zero(KRB5_ENCDATA, (st))
634#define sk_KRB5_ENCDATA_push(st, val) SKM_sk_push(KRB5_ENCDATA, (st), (val))
635#define sk_KRB5_ENCDATA_unshift(st, val) SKM_sk_unshift(KRB5_ENCDATA, (st), (val))
636#define sk_KRB5_ENCDATA_find(st, val) SKM_sk_find(KRB5_ENCDATA, (st), (val))
637#define sk_KRB5_ENCDATA_delete(st, i) SKM_sk_delete(KRB5_ENCDATA, (st), (i))
638#define sk_KRB5_ENCDATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_ENCDATA, (st), (ptr))
639#define sk_KRB5_ENCDATA_insert(st, val, i) SKM_sk_insert(KRB5_ENCDATA, (st), (val), (i))
640#define sk_KRB5_ENCDATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_ENCDATA, (st), (cmp))
641#define sk_KRB5_ENCDATA_dup(st) SKM_sk_dup(KRB5_ENCDATA, st)
642#define sk_KRB5_ENCDATA_pop_free(st, free_func) SKM_sk_pop_free(KRB5_ENCDATA, (st), (free_func))
643#define sk_KRB5_ENCDATA_shift(st) SKM_sk_shift(KRB5_ENCDATA, (st))
644#define sk_KRB5_ENCDATA_pop(st) SKM_sk_pop(KRB5_ENCDATA, (st))
645#define sk_KRB5_ENCDATA_sort(st) SKM_sk_sort(KRB5_ENCDATA, (st))
646
647#define sk_KRB5_ENCKEY_new(st) SKM_sk_new(KRB5_ENCKEY, (st))
648#define sk_KRB5_ENCKEY_new_null() SKM_sk_new_null(KRB5_ENCKEY)
649#define sk_KRB5_ENCKEY_free(st) SKM_sk_free(KRB5_ENCKEY, (st))
650#define sk_KRB5_ENCKEY_num(st) SKM_sk_num(KRB5_ENCKEY, (st))
651#define sk_KRB5_ENCKEY_value(st, i) SKM_sk_value(KRB5_ENCKEY, (st), (i))
652#define sk_KRB5_ENCKEY_set(st, i, val) SKM_sk_set(KRB5_ENCKEY, (st), (i), (val))
653#define sk_KRB5_ENCKEY_zero(st) SKM_sk_zero(KRB5_ENCKEY, (st))
654#define sk_KRB5_ENCKEY_push(st, val) SKM_sk_push(KRB5_ENCKEY, (st), (val))
655#define sk_KRB5_ENCKEY_unshift(st, val) SKM_sk_unshift(KRB5_ENCKEY, (st), (val))
656#define sk_KRB5_ENCKEY_find(st, val) SKM_sk_find(KRB5_ENCKEY, (st), (val))
657#define sk_KRB5_ENCKEY_delete(st, i) SKM_sk_delete(KRB5_ENCKEY, (st), (i))
658#define sk_KRB5_ENCKEY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_ENCKEY, (st), (ptr))
659#define sk_KRB5_ENCKEY_insert(st, val, i) SKM_sk_insert(KRB5_ENCKEY, (st), (val), (i))
660#define sk_KRB5_ENCKEY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_ENCKEY, (st), (cmp))
661#define sk_KRB5_ENCKEY_dup(st) SKM_sk_dup(KRB5_ENCKEY, st)
662#define sk_KRB5_ENCKEY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_ENCKEY, (st), (free_func))
663#define sk_KRB5_ENCKEY_shift(st) SKM_sk_shift(KRB5_ENCKEY, (st))
664#define sk_KRB5_ENCKEY_pop(st) SKM_sk_pop(KRB5_ENCKEY, (st))
665#define sk_KRB5_ENCKEY_sort(st) SKM_sk_sort(KRB5_ENCKEY, (st))
666
667#define sk_KRB5_PRINCNAME_new(st) SKM_sk_new(KRB5_PRINCNAME, (st))
668#define sk_KRB5_PRINCNAME_new_null() SKM_sk_new_null(KRB5_PRINCNAME)
669#define sk_KRB5_PRINCNAME_free(st) SKM_sk_free(KRB5_PRINCNAME, (st))
670#define sk_KRB5_PRINCNAME_num(st) SKM_sk_num(KRB5_PRINCNAME, (st))
671#define sk_KRB5_PRINCNAME_value(st, i) SKM_sk_value(KRB5_PRINCNAME, (st), (i))
672#define sk_KRB5_PRINCNAME_set(st, i, val) SKM_sk_set(KRB5_PRINCNAME, (st), (i), (val))
673#define sk_KRB5_PRINCNAME_zero(st) SKM_sk_zero(KRB5_PRINCNAME, (st))
674#define sk_KRB5_PRINCNAME_push(st, val) SKM_sk_push(KRB5_PRINCNAME, (st), (val))
675#define sk_KRB5_PRINCNAME_unshift(st, val) SKM_sk_unshift(KRB5_PRINCNAME, (st), (val))
676#define sk_KRB5_PRINCNAME_find(st, val) SKM_sk_find(KRB5_PRINCNAME, (st), (val))
677#define sk_KRB5_PRINCNAME_delete(st, i) SKM_sk_delete(KRB5_PRINCNAME, (st), (i))
678#define sk_KRB5_PRINCNAME_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_PRINCNAME, (st), (ptr))
679#define sk_KRB5_PRINCNAME_insert(st, val, i) SKM_sk_insert(KRB5_PRINCNAME, (st), (val), (i))
680#define sk_KRB5_PRINCNAME_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_PRINCNAME, (st), (cmp))
681#define sk_KRB5_PRINCNAME_dup(st) SKM_sk_dup(KRB5_PRINCNAME, st)
682#define sk_KRB5_PRINCNAME_pop_free(st, free_func) SKM_sk_pop_free(KRB5_PRINCNAME, (st), (free_func))
683#define sk_KRB5_PRINCNAME_shift(st) SKM_sk_shift(KRB5_PRINCNAME, (st))
684#define sk_KRB5_PRINCNAME_pop(st) SKM_sk_pop(KRB5_PRINCNAME, (st))
685#define sk_KRB5_PRINCNAME_sort(st) SKM_sk_sort(KRB5_PRINCNAME, (st))
686
687#define sk_KRB5_TKTBODY_new(st) SKM_sk_new(KRB5_TKTBODY, (st))
688#define sk_KRB5_TKTBODY_new_null() SKM_sk_new_null(KRB5_TKTBODY)
689#define sk_KRB5_TKTBODY_free(st) SKM_sk_free(KRB5_TKTBODY, (st))
690#define sk_KRB5_TKTBODY_num(st) SKM_sk_num(KRB5_TKTBODY, (st))
691#define sk_KRB5_TKTBODY_value(st, i) SKM_sk_value(KRB5_TKTBODY, (st), (i))
692#define sk_KRB5_TKTBODY_set(st, i, val) SKM_sk_set(KRB5_TKTBODY, (st), (i), (val))
693#define sk_KRB5_TKTBODY_zero(st) SKM_sk_zero(KRB5_TKTBODY, (st))
694#define sk_KRB5_TKTBODY_push(st, val) SKM_sk_push(KRB5_TKTBODY, (st), (val))
695#define sk_KRB5_TKTBODY_unshift(st, val) SKM_sk_unshift(KRB5_TKTBODY, (st), (val))
696#define sk_KRB5_TKTBODY_find(st, val) SKM_sk_find(KRB5_TKTBODY, (st), (val))
697#define sk_KRB5_TKTBODY_delete(st, i) SKM_sk_delete(KRB5_TKTBODY, (st), (i))
698#define sk_KRB5_TKTBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_TKTBODY, (st), (ptr))
699#define sk_KRB5_TKTBODY_insert(st, val, i) SKM_sk_insert(KRB5_TKTBODY, (st), (val), (i))
700#define sk_KRB5_TKTBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_TKTBODY, (st), (cmp))
701#define sk_KRB5_TKTBODY_dup(st) SKM_sk_dup(KRB5_TKTBODY, st)
702#define sk_KRB5_TKTBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_TKTBODY, (st), (free_func))
703#define sk_KRB5_TKTBODY_shift(st) SKM_sk_shift(KRB5_TKTBODY, (st))
704#define sk_KRB5_TKTBODY_pop(st) SKM_sk_pop(KRB5_TKTBODY, (st))
705#define sk_KRB5_TKTBODY_sort(st) SKM_sk_sort(KRB5_TKTBODY, (st))
706
427#define sk_MIME_HEADER_new(st) SKM_sk_new(MIME_HEADER, (st)) 707#define sk_MIME_HEADER_new(st) SKM_sk_new(MIME_HEADER, (st))
428#define sk_MIME_HEADER_new_null() SKM_sk_new_null(MIME_HEADER) 708#define sk_MIME_HEADER_new_null() SKM_sk_new_null(MIME_HEADER)
429#define sk_MIME_HEADER_free(st) SKM_sk_free(MIME_HEADER, (st)) 709#define sk_MIME_HEADER_free(st) SKM_sk_free(MIME_HEADER, (st))
@@ -484,6 +764,66 @@ STACK_OF(type) \
484#define sk_NAME_FUNCS_pop(st) SKM_sk_pop(NAME_FUNCS, (st)) 764#define sk_NAME_FUNCS_pop(st) SKM_sk_pop(NAME_FUNCS, (st))
485#define sk_NAME_FUNCS_sort(st) SKM_sk_sort(NAME_FUNCS, (st)) 765#define sk_NAME_FUNCS_sort(st) SKM_sk_sort(NAME_FUNCS, (st))
486 766
767#define sk_OCSP_CERTID_new(st) SKM_sk_new(OCSP_CERTID, (st))
768#define sk_OCSP_CERTID_new_null() SKM_sk_new_null(OCSP_CERTID)
769#define sk_OCSP_CERTID_free(st) SKM_sk_free(OCSP_CERTID, (st))
770#define sk_OCSP_CERTID_num(st) SKM_sk_num(OCSP_CERTID, (st))
771#define sk_OCSP_CERTID_value(st, i) SKM_sk_value(OCSP_CERTID, (st), (i))
772#define sk_OCSP_CERTID_set(st, i, val) SKM_sk_set(OCSP_CERTID, (st), (i), (val))
773#define sk_OCSP_CERTID_zero(st) SKM_sk_zero(OCSP_CERTID, (st))
774#define sk_OCSP_CERTID_push(st, val) SKM_sk_push(OCSP_CERTID, (st), (val))
775#define sk_OCSP_CERTID_unshift(st, val) SKM_sk_unshift(OCSP_CERTID, (st), (val))
776#define sk_OCSP_CERTID_find(st, val) SKM_sk_find(OCSP_CERTID, (st), (val))
777#define sk_OCSP_CERTID_delete(st, i) SKM_sk_delete(OCSP_CERTID, (st), (i))
778#define sk_OCSP_CERTID_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_CERTID, (st), (ptr))
779#define sk_OCSP_CERTID_insert(st, val, i) SKM_sk_insert(OCSP_CERTID, (st), (val), (i))
780#define sk_OCSP_CERTID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_CERTID, (st), (cmp))
781#define sk_OCSP_CERTID_dup(st) SKM_sk_dup(OCSP_CERTID, st)
782#define sk_OCSP_CERTID_pop_free(st, free_func) SKM_sk_pop_free(OCSP_CERTID, (st), (free_func))
783#define sk_OCSP_CERTID_shift(st) SKM_sk_shift(OCSP_CERTID, (st))
784#define sk_OCSP_CERTID_pop(st) SKM_sk_pop(OCSP_CERTID, (st))
785#define sk_OCSP_CERTID_sort(st) SKM_sk_sort(OCSP_CERTID, (st))
786
787#define sk_OCSP_ONEREQ_new(st) SKM_sk_new(OCSP_ONEREQ, (st))
788#define sk_OCSP_ONEREQ_new_null() SKM_sk_new_null(OCSP_ONEREQ)
789#define sk_OCSP_ONEREQ_free(st) SKM_sk_free(OCSP_ONEREQ, (st))
790#define sk_OCSP_ONEREQ_num(st) SKM_sk_num(OCSP_ONEREQ, (st))
791#define sk_OCSP_ONEREQ_value(st, i) SKM_sk_value(OCSP_ONEREQ, (st), (i))
792#define sk_OCSP_ONEREQ_set(st, i, val) SKM_sk_set(OCSP_ONEREQ, (st), (i), (val))
793#define sk_OCSP_ONEREQ_zero(st) SKM_sk_zero(OCSP_ONEREQ, (st))
794#define sk_OCSP_ONEREQ_push(st, val) SKM_sk_push(OCSP_ONEREQ, (st), (val))
795#define sk_OCSP_ONEREQ_unshift(st, val) SKM_sk_unshift(OCSP_ONEREQ, (st), (val))
796#define sk_OCSP_ONEREQ_find(st, val) SKM_sk_find(OCSP_ONEREQ, (st), (val))
797#define sk_OCSP_ONEREQ_delete(st, i) SKM_sk_delete(OCSP_ONEREQ, (st), (i))
798#define sk_OCSP_ONEREQ_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_ONEREQ, (st), (ptr))
799#define sk_OCSP_ONEREQ_insert(st, val, i) SKM_sk_insert(OCSP_ONEREQ, (st), (val), (i))
800#define sk_OCSP_ONEREQ_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_ONEREQ, (st), (cmp))
801#define sk_OCSP_ONEREQ_dup(st) SKM_sk_dup(OCSP_ONEREQ, st)
802#define sk_OCSP_ONEREQ_pop_free(st, free_func) SKM_sk_pop_free(OCSP_ONEREQ, (st), (free_func))
803#define sk_OCSP_ONEREQ_shift(st) SKM_sk_shift(OCSP_ONEREQ, (st))
804#define sk_OCSP_ONEREQ_pop(st) SKM_sk_pop(OCSP_ONEREQ, (st))
805#define sk_OCSP_ONEREQ_sort(st) SKM_sk_sort(OCSP_ONEREQ, (st))
806
807#define sk_OCSP_SINGLERESP_new(st) SKM_sk_new(OCSP_SINGLERESP, (st))
808#define sk_OCSP_SINGLERESP_new_null() SKM_sk_new_null(OCSP_SINGLERESP)
809#define sk_OCSP_SINGLERESP_free(st) SKM_sk_free(OCSP_SINGLERESP, (st))
810#define sk_OCSP_SINGLERESP_num(st) SKM_sk_num(OCSP_SINGLERESP, (st))
811#define sk_OCSP_SINGLERESP_value(st, i) SKM_sk_value(OCSP_SINGLERESP, (st), (i))
812#define sk_OCSP_SINGLERESP_set(st, i, val) SKM_sk_set(OCSP_SINGLERESP, (st), (i), (val))
813#define sk_OCSP_SINGLERESP_zero(st) SKM_sk_zero(OCSP_SINGLERESP, (st))
814#define sk_OCSP_SINGLERESP_push(st, val) SKM_sk_push(OCSP_SINGLERESP, (st), (val))
815#define sk_OCSP_SINGLERESP_unshift(st, val) SKM_sk_unshift(OCSP_SINGLERESP, (st), (val))
816#define sk_OCSP_SINGLERESP_find(st, val) SKM_sk_find(OCSP_SINGLERESP, (st), (val))
817#define sk_OCSP_SINGLERESP_delete(st, i) SKM_sk_delete(OCSP_SINGLERESP, (st), (i))
818#define sk_OCSP_SINGLERESP_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_SINGLERESP, (st), (ptr))
819#define sk_OCSP_SINGLERESP_insert(st, val, i) SKM_sk_insert(OCSP_SINGLERESP, (st), (val), (i))
820#define sk_OCSP_SINGLERESP_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_SINGLERESP, (st), (cmp))
821#define sk_OCSP_SINGLERESP_dup(st) SKM_sk_dup(OCSP_SINGLERESP, st)
822#define sk_OCSP_SINGLERESP_pop_free(st, free_func) SKM_sk_pop_free(OCSP_SINGLERESP, (st), (free_func))
823#define sk_OCSP_SINGLERESP_shift(st) SKM_sk_shift(OCSP_SINGLERESP, (st))
824#define sk_OCSP_SINGLERESP_pop(st) SKM_sk_pop(OCSP_SINGLERESP, (st))
825#define sk_OCSP_SINGLERESP_sort(st) SKM_sk_sort(OCSP_SINGLERESP, (st))
826
487#define sk_PKCS12_SAFEBAG_new(st) SKM_sk_new(PKCS12_SAFEBAG, (st)) 827#define sk_PKCS12_SAFEBAG_new(st) SKM_sk_new(PKCS12_SAFEBAG, (st))
488#define sk_PKCS12_SAFEBAG_new_null() SKM_sk_new_null(PKCS12_SAFEBAG) 828#define sk_PKCS12_SAFEBAG_new_null() SKM_sk_new_null(PKCS12_SAFEBAG)
489#define sk_PKCS12_SAFEBAG_free(st) SKM_sk_free(PKCS12_SAFEBAG, (st)) 829#define sk_PKCS12_SAFEBAG_free(st) SKM_sk_free(PKCS12_SAFEBAG, (st))
@@ -664,6 +1004,26 @@ STACK_OF(type) \
664#define sk_SXNETID_pop(st) SKM_sk_pop(SXNETID, (st)) 1004#define sk_SXNETID_pop(st) SKM_sk_pop(SXNETID, (st))
665#define sk_SXNETID_sort(st) SKM_sk_sort(SXNETID, (st)) 1005#define sk_SXNETID_sort(st) SKM_sk_sort(SXNETID, (st))
666 1006
1007#define sk_UI_STRING_new(st) SKM_sk_new(UI_STRING, (st))
1008#define sk_UI_STRING_new_null() SKM_sk_new_null(UI_STRING)
1009#define sk_UI_STRING_free(st) SKM_sk_free(UI_STRING, (st))
1010#define sk_UI_STRING_num(st) SKM_sk_num(UI_STRING, (st))
1011#define sk_UI_STRING_value(st, i) SKM_sk_value(UI_STRING, (st), (i))
1012#define sk_UI_STRING_set(st, i, val) SKM_sk_set(UI_STRING, (st), (i), (val))
1013#define sk_UI_STRING_zero(st) SKM_sk_zero(UI_STRING, (st))
1014#define sk_UI_STRING_push(st, val) SKM_sk_push(UI_STRING, (st), (val))
1015#define sk_UI_STRING_unshift(st, val) SKM_sk_unshift(UI_STRING, (st), (val))
1016#define sk_UI_STRING_find(st, val) SKM_sk_find(UI_STRING, (st), (val))
1017#define sk_UI_STRING_delete(st, i) SKM_sk_delete(UI_STRING, (st), (i))
1018#define sk_UI_STRING_delete_ptr(st, ptr) SKM_sk_delete_ptr(UI_STRING, (st), (ptr))
1019#define sk_UI_STRING_insert(st, val, i) SKM_sk_insert(UI_STRING, (st), (val), (i))
1020#define sk_UI_STRING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(UI_STRING, (st), (cmp))
1021#define sk_UI_STRING_dup(st) SKM_sk_dup(UI_STRING, st)
1022#define sk_UI_STRING_pop_free(st, free_func) SKM_sk_pop_free(UI_STRING, (st), (free_func))
1023#define sk_UI_STRING_shift(st) SKM_sk_shift(UI_STRING, (st))
1024#define sk_UI_STRING_pop(st) SKM_sk_pop(UI_STRING, (st))
1025#define sk_UI_STRING_sort(st) SKM_sk_sort(UI_STRING, (st))
1026
667#define sk_X509_new(st) SKM_sk_new(X509, (st)) 1027#define sk_X509_new(st) SKM_sk_new(X509, (st))
668#define sk_X509_new_null() SKM_sk_new_null(X509) 1028#define sk_X509_new_null() SKM_sk_new_null(X509)
669#define sk_X509_free(st) SKM_sk_free(X509, (st)) 1029#define sk_X509_free(st) SKM_sk_free(X509, (st))
@@ -998,6 +1358,24 @@ STACK_OF(type) \
998#define ASN1_seq_unpack_GENERAL_NAME(buf, len, d2i_func, free_func) \ 1358#define ASN1_seq_unpack_GENERAL_NAME(buf, len, d2i_func, free_func) \
999 SKM_ASN1_seq_unpack(GENERAL_NAME, (buf), (len), (d2i_func), (free_func)) 1359 SKM_ASN1_seq_unpack(GENERAL_NAME, (buf), (len), (d2i_func), (free_func))
1000 1360
1361#define d2i_ASN1_SET_OF_OCSP_ONEREQ(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
1362 SKM_ASN1_SET_OF_d2i(OCSP_ONEREQ, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))
1363#define i2d_ASN1_SET_OF_OCSP_ONEREQ(st, pp, i2d_func, ex_tag, ex_class, is_set) \
1364 SKM_ASN1_SET_OF_i2d(OCSP_ONEREQ, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
1365#define ASN1_seq_pack_OCSP_ONEREQ(st, i2d_func, buf, len) \
1366 SKM_ASN1_seq_pack(OCSP_ONEREQ, (st), (i2d_func), (buf), (len))
1367#define ASN1_seq_unpack_OCSP_ONEREQ(buf, len, d2i_func, free_func) \
1368 SKM_ASN1_seq_unpack(OCSP_ONEREQ, (buf), (len), (d2i_func), (free_func))
1369
1370#define d2i_ASN1_SET_OF_OCSP_SINGLERESP(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
1371 SKM_ASN1_SET_OF_d2i(OCSP_SINGLERESP, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))
1372#define i2d_ASN1_SET_OF_OCSP_SINGLERESP(st, pp, i2d_func, ex_tag, ex_class, is_set) \
1373 SKM_ASN1_SET_OF_i2d(OCSP_SINGLERESP, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
1374#define ASN1_seq_pack_OCSP_SINGLERESP(st, i2d_func, buf, len) \
1375 SKM_ASN1_seq_pack(OCSP_SINGLERESP, (st), (i2d_func), (buf), (len))
1376#define ASN1_seq_unpack_OCSP_SINGLERESP(buf, len, d2i_func, free_func) \
1377 SKM_ASN1_seq_unpack(OCSP_SINGLERESP, (buf), (len), (d2i_func), (free_func))
1378
1001#define d2i_ASN1_SET_OF_PKCS12_SAFEBAG(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ 1379#define d2i_ASN1_SET_OF_PKCS12_SAFEBAG(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
1002 SKM_ASN1_SET_OF_d2i(PKCS12_SAFEBAG, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) 1380 SKM_ASN1_SET_OF_d2i(PKCS12_SAFEBAG, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))
1003#define i2d_ASN1_SET_OF_PKCS12_SAFEBAG(st, pp, i2d_func, ex_tag, ex_class, is_set) \ 1381#define i2d_ASN1_SET_OF_PKCS12_SAFEBAG(st, pp, i2d_func, ex_tag, ex_class, is_set) \
diff --git a/src/lib/libcrypto/stack/stack.c b/src/lib/libcrypto/stack/stack.c
index 02857f0446..2496f28a8c 100644
--- a/src/lib/libcrypto/stack/stack.c
+++ b/src/lib/libcrypto/stack/stack.c
@@ -106,6 +106,8 @@ STACK *sk_dup(STACK *sk)
106 ret->comp=sk->comp; 106 ret->comp=sk->comp;
107 return(ret); 107 return(ret);
108err: 108err:
109 if(ret)
110 sk_free(ret);
109 return(NULL); 111 return(NULL);
110 } 112 }
111 113
@@ -120,9 +122,9 @@ STACK *sk_new(int (*c)(const char * const *, const char * const *))
120 int i; 122 int i;
121 123
122 if ((ret=(STACK *)OPENSSL_malloc(sizeof(STACK))) == NULL) 124 if ((ret=(STACK *)OPENSSL_malloc(sizeof(STACK))) == NULL)
123 goto err0; 125 goto err;
124 if ((ret->data=(char **)OPENSSL_malloc(sizeof(char *)*MIN_NODES)) == NULL) 126 if ((ret->data=(char **)OPENSSL_malloc(sizeof(char *)*MIN_NODES)) == NULL)
125 goto err1; 127 goto err;
126 for (i=0; i<MIN_NODES; i++) 128 for (i=0; i<MIN_NODES; i++)
127 ret->data[i]=NULL; 129 ret->data[i]=NULL;
128 ret->comp=c; 130 ret->comp=c;
@@ -130,9 +132,9 @@ STACK *sk_new(int (*c)(const char * const *, const char * const *))
130 ret->num=0; 132 ret->num=0;
131 ret->sorted=0; 133 ret->sorted=0;
132 return(ret); 134 return(ret);
133err1: 135err:
134 OPENSSL_free(ret); 136 if(ret)
135err0: 137 OPENSSL_free(ret);
136 return(NULL); 138 return(NULL);
137 } 139 }
138 140
@@ -316,7 +318,7 @@ char *sk_set(STACK *st, int i, char *value)
316 318
317void sk_sort(STACK *st) 319void sk_sort(STACK *st)
318 { 320 {
319 if (!st->sorted) 321 if (st && !st->sorted)
320 { 322 {
321 int (*comp_func)(const void *,const void *); 323 int (*comp_func)(const void *,const void *);
322 324
diff --git a/src/lib/libcrypto/symhacks.h b/src/lib/libcrypto/symhacks.h
index 358ad355bb..de0f452b47 100644
--- a/src/lib/libcrypto/symhacks.h
+++ b/src/lib/libcrypto/symhacks.h
@@ -55,10 +55,18 @@
55#ifndef HEADER_SYMHACKS_H 55#ifndef HEADER_SYMHACKS_H
56#define HEADER_SYMHACKS_H 56#define HEADER_SYMHACKS_H
57 57
58#include <openssl/e_os2.h>
59
58/* Hacks to solve the problem with linkers incapable of handling very long 60/* Hacks to solve the problem with linkers incapable of handling very long
59 symbol names. In the case of VMS, the limit is 31 characters on VMS for 61 symbol names. In the case of VMS, the limit is 31 characters on VMS for
60 VAX. */ 62 VAX. */
61#ifdef VMS 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
62 70
63/* Hack a long name in crypto/asn1/a_mbstr.c */ 71/* Hack a long name in crypto/asn1/a_mbstr.c */
64#undef ASN1_STRING_set_default_mask_asc 72#undef ASN1_STRING_set_default_mask_asc
@@ -121,33 +129,146 @@
121#define X509_REVOKED_get_ext_by_critical X509_REVOKED_get_ext_by_critic 129#define X509_REVOKED_get_ext_by_critical X509_REVOKED_get_ext_by_critic
122 130
123/* Hack some long CRYPTO names */ 131/* Hack some long CRYPTO names */
132#undef CRYPTO_set_dynlock_destroy_callback
124#define CRYPTO_set_dynlock_destroy_callback CRYPTO_set_dynlock_destroy_cb 133#define CRYPTO_set_dynlock_destroy_callback CRYPTO_set_dynlock_destroy_cb
134#undef CRYPTO_set_dynlock_create_callback
125#define CRYPTO_set_dynlock_create_callback CRYPTO_set_dynlock_create_cb 135#define CRYPTO_set_dynlock_create_callback CRYPTO_set_dynlock_create_cb
136#undef CRYPTO_set_dynlock_lock_callback
126#define CRYPTO_set_dynlock_lock_callback CRYPTO_set_dynlock_lock_cb 137#define CRYPTO_set_dynlock_lock_callback CRYPTO_set_dynlock_lock_cb
138#undef CRYPTO_get_dynlock_lock_callback
127#define CRYPTO_get_dynlock_lock_callback CRYPTO_get_dynlock_lock_cb 139#define CRYPTO_get_dynlock_lock_callback CRYPTO_get_dynlock_lock_cb
140#undef CRYPTO_get_dynlock_destroy_callback
128#define CRYPTO_get_dynlock_destroy_callback CRYPTO_get_dynlock_destroy_cb 141#define CRYPTO_get_dynlock_destroy_callback CRYPTO_get_dynlock_destroy_cb
142#undef CRYPTO_get_dynlock_create_callback
129#define CRYPTO_get_dynlock_create_callback CRYPTO_get_dynlock_create_cb 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
130 148
131/* Hack some long SSL names */ 149/* Hack some long SSL names */
150#undef SSL_CTX_set_default_verify_paths
132#define SSL_CTX_set_default_verify_paths SSL_CTX_set_def_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
133#define SSL_get_ex_data_X509_STORE_CTX_idx SSL_get_ex_d_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
134#define SSL_add_file_cert_subjects_to_stack SSL_add_file_cert_subjs_to_stk 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
135#define SSL_add_dir_cert_subjects_to_stack SSL_add_dir_cert_subjs_to_stk 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
136#define SSL_CTX_use_certificate_chain_file SSL_CTX_use_cert_chain_file 161#define SSL_CTX_use_certificate_chain_file SSL_CTX_use_cert_chain_file
162#undef SSL_CTX_set_cert_verify_callback
137#define SSL_CTX_set_cert_verify_callback SSL_CTX_set_cert_verify_cb 163#define SSL_CTX_set_cert_verify_callback SSL_CTX_set_cert_verify_cb
164#undef SSL_CTX_set_default_passwd_cb_userdata
138#define SSL_CTX_set_default_passwd_cb_userdata SSL_CTX_set_def_passwd_cb_ud 165#define SSL_CTX_set_default_passwd_cb_userdata SSL_CTX_set_def_passwd_cb_ud
139 166
140/* Hack some long ENGINE names */ 167/* Hack some long ENGINE names */
141#define ENGINE_get_default_BN_mod_exp_crt ENGINE_get_def_BN_mod_exp_crt 168#undef ENGINE_get_default_BN_mod_exp_crt
142#define ENGINE_set_default_BN_mod_exp_crt ENGINE_set_def_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
143 190
144#endif /* defined VMS */ 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 */
145 247
146 248
147/* Case insensiteve linking causes problems.... */ 249/* Case insensiteve linking causes problems.... */
148#if defined(WIN16) || defined(VMS) 250#if defined(OPENSSL_SYS_WIN16) || defined(OPENSSL_SYS_VMS)
149#undef ERR_load_CRYPTO_strings 251#undef ERR_load_CRYPTO_strings
150#define ERR_load_CRYPTO_strings ERR_load_CRYPTOlib_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
151#endif 272#endif
152 273
153 274
diff --git a/src/lib/libcrypto/threads/mttest.c b/src/lib/libcrypto/threads/mttest.c
index 019add4d9c..c474a63c74 100644
--- a/src/lib/libcrypto/threads/mttest.c
+++ b/src/lib/libcrypto/threads/mttest.c
@@ -63,7 +63,7 @@
63#ifdef LINUX 63#ifdef LINUX
64#include <typedefs.h> 64#include <typedefs.h>
65#endif 65#endif
66#ifdef WIN32 66#ifdef OPENSSL_SYS_WIN32
67#include <windows.h> 67#include <windows.h>
68#endif 68#endif
69#ifdef SOLARIS 69#ifdef SOLARIS
@@ -86,7 +86,7 @@
86#include <openssl/err.h> 86#include <openssl/err.h>
87#include <openssl/rand.h> 87#include <openssl/rand.h>
88 88
89#ifdef NO_FP_API 89#ifdef OPENSSL_NO_FP_API
90#define APPS_WIN16 90#define APPS_WIN16
91#include "../buffer/bss_file.c" 91#include "../buffer/bss_file.c"
92#endif 92#endif
@@ -692,7 +692,7 @@ int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx)
692 692
693#define THREAD_STACK_SIZE (16*1024) 693#define THREAD_STACK_SIZE (16*1024)
694 694
695#ifdef WIN32 695#ifdef OPENSSL_SYS_WIN32
696 696
697static HANDLE *lock_cs; 697static HANDLE *lock_cs;
698 698
@@ -783,7 +783,7 @@ void do_threads(SSL_CTX *s_ctx, SSL_CTX *c_ctx)
783 printf("win32 threads done - %.3f seconds\n",ret); 783 printf("win32 threads done - %.3f seconds\n",ret);
784 } 784 }
785 785
786#endif /* WIN32 */ 786#endif /* OPENSSL_SYS_WIN32 */
787 787
788#ifdef SOLARIS 788#ifdef SOLARIS
789 789
diff --git a/src/lib/libcrypto/threads/th-lock.c b/src/lib/libcrypto/threads/th-lock.c
index 553d2218de..a6a79b9f45 100644
--- a/src/lib/libcrypto/threads/th-lock.c
+++ b/src/lib/libcrypto/threads/th-lock.c
@@ -63,7 +63,7 @@
63#ifdef LINUX 63#ifdef LINUX
64#include <typedefs.h> 64#include <typedefs.h>
65#endif 65#endif
66#ifdef WIN32 66#ifdef OPENSSL_SYS_WIN32
67#include <windows.h> 67#include <windows.h>
68#endif 68#endif
69#ifdef SOLARIS 69#ifdef SOLARIS
@@ -105,7 +105,7 @@ static unsigned long pthreads_thread_id(void );
105 105
106#define THREAD_STACK_SIZE (16*1024) 106#define THREAD_STACK_SIZE (16*1024)
107 107
108#ifdef WIN32 108#ifdef OPENSSL_SYS_WIN32
109 109
110static HANDLE *lock_cs; 110static HANDLE *lock_cs;
111 111
@@ -146,7 +146,7 @@ void win32_locking_callback(int mode, int type, char *file, int line)
146 } 146 }
147 } 147 }
148 148
149#endif /* WIN32 */ 149#endif /* OPENSSL_SYS_WIN32 */
150 150
151#ifdef SOLARIS 151#ifdef SOLARIS
152 152
diff --git a/src/lib/libcrypto/tmdiff.c b/src/lib/libcrypto/tmdiff.c
index 7773928666..7ebf2b202a 100644
--- a/src/lib/libcrypto/tmdiff.c
+++ b/src/lib/libcrypto/tmdiff.c
@@ -61,16 +61,12 @@
61#include <openssl/tmdiff.h> 61#include <openssl/tmdiff.h>
62 62
63#ifdef TIMEB 63#ifdef TIMEB
64#undef WIN32 64#undef OPENSSL_SYS_WIN32
65#undef TIMES 65#undef TIMES
66#endif 66#endif
67 67
68#ifndef MSDOS 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# ifndef WIN32 69# define TIMES
70# if !defined(VMS) || defined(__DECC)
71# define TIMES
72# endif
73# endif
74#endif 70#endif
75 71
76#ifndef _IRIX 72#ifndef _IRIX
@@ -85,7 +81,7 @@
85 The __TMS macro will show if it was. If it wasn't defined, we should 81 The __TMS macro will show if it was. If it wasn't defined, we should
86 undefine TIMES, since that tells the rest of the program how things 82 undefine TIMES, since that tells the rest of the program how things
87 should be handled. -- Richard Levitte */ 83 should be handled. -- Richard Levitte */
88#if defined(VMS) && defined(__DECC) && !defined(__TMS) 84#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
89#undef TIMES 85#undef TIMES
90#endif 86#endif
91 87
@@ -95,11 +91,11 @@
95#include <sys/param.h> 91#include <sys/param.h>
96#endif 92#endif
97 93
98#ifndef TIMES 94#if !defined(TIMES) && !defined(OPENSSL_SYS_VXWORKS)
99#include <sys/timeb.h> 95#include <sys/timeb.h>
100#endif 96#endif
101 97
102#ifdef WIN32 98#ifdef OPENSSL_SYS_WIN32
103#include <windows.h> 99#include <windows.h>
104#endif 100#endif
105 101
@@ -121,11 +117,15 @@ typedef struct ms_tm
121#ifdef TIMES 117#ifdef TIMES
122 struct tms ms_tms; 118 struct tms ms_tms;
123#else 119#else
124# ifdef WIN32 120# ifdef OPENSSL_SYS_WIN32
125 HANDLE thread_id; 121 HANDLE thread_id;
126 FILETIME ms_win32; 122 FILETIME ms_win32;
127# else 123# else
124# ifdef OPENSSL_SYS_VSWORKS
125 unsigned long ticks;
126# else
128 struct timeb ms_timeb; 127 struct timeb ms_timeb;
128# endif
129# endif 129# endif
130#endif 130#endif
131 } MS_TM; 131 } MS_TM;
@@ -138,7 +138,7 @@ char *ms_time_new(void)
138 if (ret == NULL) 138 if (ret == NULL)
139 return(NULL); 139 return(NULL);
140 memset(ret,0,sizeof(MS_TM)); 140 memset(ret,0,sizeof(MS_TM));
141#ifdef WIN32 141#ifdef OPENSSL_SYS_WIN32
142 ret->thread_id=GetCurrentThread(); 142 ret->thread_id=GetCurrentThread();
143#endif 143#endif
144 return((char *)ret); 144 return((char *)ret);
@@ -153,17 +153,21 @@ void ms_time_free(char *a)
153void ms_time_get(char *a) 153void ms_time_get(char *a)
154 { 154 {
155 MS_TM *tm=(MS_TM *)a; 155 MS_TM *tm=(MS_TM *)a;
156#ifdef WIN32 156#ifdef OPENSSL_SYS_WIN32
157 FILETIME tmpa,tmpb,tmpc; 157 FILETIME tmpa,tmpb,tmpc;
158#endif 158#endif
159 159
160#ifdef TIMES 160#ifdef TIMES
161 times(&tm->ms_tms); 161 times(&tm->ms_tms);
162#else 162#else
163# ifdef WIN32 163# ifdef OPENSSL_SYS_WIN32
164 GetThreadTimes(tm->thread_id,&tmpa,&tmpb,&tmpc,&(tm->ms_win32)); 164 GetThreadTimes(tm->thread_id,&tmpa,&tmpb,&tmpc,&(tm->ms_win32));
165# else 165# else
166# ifdef OPENSSL_SYS_VSWORKS
167 tm->ticks = tickGet();
168# else
166 ftime(&tm->ms_timeb); 169 ftime(&tm->ms_timeb);
170# endif
167# endif 171# endif
168#endif 172#endif
169 } 173 }
@@ -177,7 +181,7 @@ double ms_time_diff(char *ap, char *bp)
177#ifdef TIMES 181#ifdef TIMES
178 ret=(b->ms_tms.tms_utime-a->ms_tms.tms_utime)/HZ; 182 ret=(b->ms_tms.tms_utime-a->ms_tms.tms_utime)/HZ;
179#else 183#else
180# ifdef WIN32 184# ifdef OPENSSL_SYS_WIN32
181 { 185 {
182#ifdef __GNUC__ 186#ifdef __GNUC__
183 signed long long la,lb; 187 signed long long la,lb;
@@ -193,10 +197,14 @@ double ms_time_diff(char *ap, char *bp)
193 ret=((double)(lb-la))/1e7; 197 ret=((double)(lb-la))/1e7;
194 } 198 }
195# else 199# else
200# ifdef OPENSSL_SYS_VSWORKS
201 ret = (double)(b->ticks - a->ticks) / (double)sysClkRateGet();
202# else
196 ret= (double)(b->ms_timeb.time-a->ms_timeb.time)+ 203 ret= (double)(b->ms_timeb.time-a->ms_timeb.time)+
197 (((double)b->ms_timeb.millitm)- 204 (((double)b->ms_timeb.millitm)-
198 ((double)a->ms_timeb.millitm))/1000.0; 205 ((double)a->ms_timeb.millitm))/1000.0;
199# endif 206# endif
207# endif
200#endif 208#endif
201 return((ret < 0.0000001)?0.0000001:ret); 209 return((ret < 0.0000001)?0.0000001:ret);
202 } 210 }
@@ -210,13 +218,17 @@ int ms_time_cmp(char *ap, char *bp)
210#ifdef TIMES 218#ifdef TIMES
211 d=(b->ms_tms.tms_utime-a->ms_tms.tms_utime)/HZ; 219 d=(b->ms_tms.tms_utime-a->ms_tms.tms_utime)/HZ;
212#else 220#else
213# ifdef WIN32 221# ifdef OPENSSL_SYS_WIN32
214 d =(b->ms_win32.dwHighDateTime&0x000fffff)*10+b->ms_win32.dwLowDateTime/1e7; 222 d =(b->ms_win32.dwHighDateTime&0x000fffff)*10+b->ms_win32.dwLowDateTime/1e7;
215 d-=(a->ms_win32.dwHighDateTime&0x000fffff)*10+a->ms_win32.dwLowDateTime/1e7; 223 d-=(a->ms_win32.dwHighDateTime&0x000fffff)*10+a->ms_win32.dwLowDateTime/1e7;
216# else 224# else
225# ifdef OPENSSL_SYS_VSWORKS
226 d = (b->ticks - a->ticks);
227# else
217 d= (double)(b->ms_timeb.time-a->ms_timeb.time)+ 228 d= (double)(b->ms_timeb.time-a->ms_timeb.time)+
218 (((double)b->ms_timeb.millitm)-(double)a->ms_timeb.millitm)/1000.0; 229 (((double)b->ms_timeb.millitm)-(double)a->ms_timeb.millitm)/1000.0;
219# endif 230# endif
231# endif
220#endif 232#endif
221 if (d == 0.0) 233 if (d == 0.0)
222 ret=0; 234 ret=0;
diff --git a/src/lib/libcrypto/txt_db/Makefile.ssl b/src/lib/libcrypto/txt_db/Makefile.ssl
index ee054e91f2..8af2fa4cd6 100644
--- a/src/lib/libcrypto/txt_db/Makefile.ssl
+++ b/src/lib/libcrypto/txt_db/Makefile.ssl
@@ -11,7 +11,8 @@ INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl 11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl 12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl 13MAKE= make -f Makefile.ssl
14MAKEDEPEND= $(TOP)/util/domd $(TOP) 14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
15MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
16AR= ar r 17AR= ar r
17 18
@@ -39,8 +40,7 @@ all: lib
39 40
40lib: $(LIBOBJ) 41lib: $(LIBOBJ)
41 $(AR) $(LIB) $(LIBOBJ) 42 $(AR) $(LIB) $(LIBOBJ)
42 @echo You may get an error following this line. Please ignore. 43 $(RANLIB) $(LIB) || echo Never mind.
43 - $(RANLIB) $(LIB)
44 @touch lib 44 @touch lib
45 45
46files: 46files:
@@ -79,10 +79,10 @@ clean:
79 79
80# DO NOT DELETE THIS LINE -- make depend depends on it. 80# DO NOT DELETE THIS LINE -- make depend depends on it.
81 81
82txt_db.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 82txt_db.o: ../../e_os.h ../../include/openssl/bio.h
83txt_db.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h 83txt_db.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
84txt_db.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 84txt_db.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
85txt_db.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 85txt_db.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
86txt_db.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 86txt_db.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
87txt_db.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 87txt_db.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
88txt_db.o: ../../include/openssl/txt_db.h ../cryptlib.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 3b04fe280c..e6334d6add 100644
--- a/src/lib/libcrypto/txt_db/txt_db.c
+++ b/src/lib/libcrypto/txt_db/txt_db.c
@@ -155,7 +155,7 @@ TXT_DB *TXT_DB_read(BIO *in, int num)
155 *(p++)='\0'; 155 *(p++)='\0';
156 if ((n != num) || (*f != '\0')) 156 if ((n != num) || (*f != '\0'))
157 { 157 {
158#if !defined(NO_STDIO) && !defined(WIN16) /* temporaty fix :-( */ 158#if !defined(OPENSSL_NO_STDIO) && !defined(OPENSSL_SYS_WIN16) /* temporaty fix :-( */
159 fprintf(stderr,"wrong number of fields on line %ld (looking for field %d, got %d, '%s' left)\n",ln,num,n,f); 159 fprintf(stderr,"wrong number of fields on line %ld (looking for field %d, got %d, '%s' left)\n",ln,num,n,f);
160#endif 160#endif
161 er=2; 161 er=2;
@@ -164,7 +164,7 @@ TXT_DB *TXT_DB_read(BIO *in, int num)
164 pp[n]=p; 164 pp[n]=p;
165 if (!sk_push(ret->data,(char *)pp)) 165 if (!sk_push(ret->data,(char *)pp))
166 { 166 {
167#if !defined(NO_STDIO) && !defined(WIN16) /* temporaty fix :-( */ 167#if !defined(OPENSSL_NO_STDIO) && !defined(OPENSSL_SYS_WIN16) /* temporaty fix :-( */
168 fprintf(stderr,"failure in sk_push\n"); 168 fprintf(stderr,"failure in sk_push\n");
169#endif 169#endif
170 er=2; 170 er=2;
@@ -176,7 +176,7 @@ err:
176 BUF_MEM_free(buf); 176 BUF_MEM_free(buf);
177 if (er) 177 if (er)
178 { 178 {
179#if !defined(NO_STDIO) && !defined(WIN16) 179#if !defined(OPENSSL_NO_STDIO) && !defined(OPENSSL_SYS_WIN16)
180 if (er == 1) fprintf(stderr,"OPENSSL_malloc failure\n"); 180 if (er == 1) fprintf(stderr,"OPENSSL_malloc failure\n");
181#endif 181#endif
182 if (ret->data != NULL) sk_free(ret->data); 182 if (ret->data != NULL) sk_free(ret->data);
@@ -211,7 +211,7 @@ char **TXT_DB_get_by_index(TXT_DB *db, int idx, char **value)
211 } 211 }
212 212
213int TXT_DB_create_index(TXT_DB *db, int field, int (*qual)(), 213int TXT_DB_create_index(TXT_DB *db, int field, int (*qual)(),
214 unsigned long (*hash)(), int (*cmp)()) 214 LHASH_HASH_FN_TYPE hash, LHASH_COMP_FN_TYPE cmp)
215 { 215 {
216 LHASH *idx; 216 LHASH *idx;
217 char *r; 217 char *r;
diff --git a/src/lib/libcrypto/txt_db/txt_db.h b/src/lib/libcrypto/txt_db/txt_db.h
index 342533d40d..563392aeff 100644
--- a/src/lib/libcrypto/txt_db/txt_db.h
+++ b/src/lib/libcrypto/txt_db/txt_db.h
@@ -59,7 +59,7 @@
59#ifndef HEADER_TXT_DB_H 59#ifndef HEADER_TXT_DB_H
60#define HEADER_TXT_DB_H 60#define HEADER_TXT_DB_H
61 61
62#ifndef NO_BIO 62#ifndef OPENSSL_NO_BIO
63#include <openssl/bio.h> 63#include <openssl/bio.h>
64#endif 64#endif
65#include <openssl/stack.h> 65#include <openssl/stack.h>
@@ -88,7 +88,7 @@ typedef struct txt_db_st
88 char **arg_row; 88 char **arg_row;
89 } TXT_DB; 89 } TXT_DB;
90 90
91#ifndef NO_BIO 91#ifndef OPENSSL_NO_BIO
92TXT_DB *TXT_DB_read(BIO *in, int num); 92TXT_DB *TXT_DB_read(BIO *in, int num);
93long TXT_DB_write(BIO *out, TXT_DB *db); 93long TXT_DB_write(BIO *out, TXT_DB *db);
94#else 94#else
@@ -96,7 +96,7 @@ TXT_DB *TXT_DB_read(char *in, int num);
96long TXT_DB_write(char *out, TXT_DB *db); 96long TXT_DB_write(char *out, TXT_DB *db);
97#endif 97#endif
98int TXT_DB_create_index(TXT_DB *db,int field,int (*qual)(), 98int TXT_DB_create_index(TXT_DB *db,int field,int (*qual)(),
99 unsigned long (*hash)(),int (*cmp)()); 99 LHASH_HASH_FN_TYPE hash, LHASH_COMP_FN_TYPE cmp);
100void TXT_DB_free(TXT_DB *db); 100void TXT_DB_free(TXT_DB *db);
101char **TXT_DB_get_by_index(TXT_DB *db, int idx, char **value); 101char **TXT_DB_get_by_index(TXT_DB *db, int idx, char **value);
102int TXT_DB_insert(TXT_DB *db,char **value); 102int TXT_DB_insert(TXT_DB *db,char **value);
diff --git a/src/lib/libcrypto/ui/Makefile.ssl b/src/lib/libcrypto/ui/Makefile.ssl
new file mode 100644
index 0000000000..d51c1ff67a
--- /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 @$(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) $(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.h b/src/lib/libcrypto/ui/ui.h
new file mode 100644
index 0000000000..735a2d988e
--- /dev/null
+++ b/src/lib/libcrypto/ui/ui.h
@@ -0,0 +1,387 @@
1/* crypto/ui/ui.h -*- mode:C; c-file-style: "eay" -*- */
2/* Written by Richard Levitte (richard@levitte.org) 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 * 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#ifndef HEADER_UI_H
60#define HEADER_UI_H
61
62#include <openssl/crypto.h>
63#include <openssl/safestack.h>
64
65#ifdef __cplusplus
66extern "C" {
67#endif
68
69/* The UI type is a holder for a specific user interface session. It can
70 contain an illimited number of informational or error strings as well
71 as things to prompt for, both passwords (noecho mode) and others (echo
72 mode), and verification of the same. All of these are called strings,
73 and are further described below. */
74typedef struct ui_st UI;
75
76/* All instances of UI have a reference to a method structure, which is a
77 ordered vector of functions that implement the lower level things to do.
78 There is an instruction on the implementation further down, in the section
79 for method implementors. */
80typedef struct ui_method_st UI_METHOD;
81
82
83/* All the following functions return -1 or NULL on error and in some cases
84 (UI_process()) -2 if interrupted or in some other way cancelled.
85 When everything is fine, they return 0, a positive value or a non-NULL
86 pointer, all depending on their purpose. */
87
88/* Creators and destructor. */
89UI *UI_new(void);
90UI *UI_new_method(const UI_METHOD *method);
91void UI_free(UI *ui);
92
93/* The following functions are used to add strings to be printed and prompt
94 strings to prompt for data. The names are UI_{add,dup}_<function>_string
95 and UI_{add,dup}_input_boolean.
96
97 UI_{add,dup}_<function>_string have the following meanings:
98 add add a text or prompt string. The pointers given to these
99 functions are used verbatim, no copying is done.
100 dup make a copy of the text or prompt string, then add the copy
101 to the collection of strings in the user interface.
102 <function>
103 The function is a name for the functionality that the given
104 string shall be used for. It can be one of:
105 input use the string as data prompt.
106 verify use the string as verification prompt. This
107 is used to verify a previous input.
108 info use the string for informational output.
109 error use the string for error output.
110 Honestly, there's currently no difference between info and error for the
111 moment.
112
113 UI_{add,dup}_input_boolean have the same semantics for "add" and "dup",
114 and are typically used when one wants to prompt for a yes/no response.
115
116
117 All of the functions in this group take a UI and a prompt string.
118 The string input and verify addition functions also take a flag argument,
119 a buffer for the result to end up with, a minimum input size and a maximum
120 input size (the result buffer MUST be large enough to be able to contain
121 the maximum number of characters). Additionally, the verify addition
122 functions takes another buffer to compare the result against.
123 The boolean input functions take an action description string (which should
124 be safe to ignore if the expected user action is obvious, for example with
125 a dialog box with an OK button and a Cancel button), a string of acceptable
126 characters to mean OK and to mean Cancel. The two last strings are checked
127 to make sure they don't have common characters. Additionally, the same
128 flag argument as for the string input is taken, as well as a result buffer.
129 The result buffer is required to be at least one byte long. Depending on
130 the answer, the first character from the OK or the Cancel character strings
131 will be stored in the first byte of the result buffer. No NUL will be
132 added, so the result is *not* a string.
133
134 On success, the all return an index of the added information. That index
135 is usefull when retrieving results with UI_get0_result(). */
136int UI_add_input_string(UI *ui, const char *prompt, int flags,
137 char *result_buf, int minsize, int maxsize);
138int UI_dup_input_string(UI *ui, const char *prompt, int flags,
139 char *result_buf, int minsize, int maxsize);
140int UI_add_verify_string(UI *ui, const char *prompt, int flags,
141 char *result_buf, int minsize, int maxsize, const char *test_buf);
142int UI_dup_verify_string(UI *ui, const char *prompt, int flags,
143 char *result_buf, int minsize, int maxsize, const char *test_buf);
144int UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc,
145 const char *ok_chars, const char *cancel_chars,
146 int flags, char *result_buf);
147int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc,
148 const char *ok_chars, const char *cancel_chars,
149 int flags, char *result_buf);
150int UI_add_info_string(UI *ui, const char *text);
151int UI_dup_info_string(UI *ui, const char *text);
152int UI_add_error_string(UI *ui, const char *text);
153int UI_dup_error_string(UI *ui, const char *text);
154
155/* These are the possible flags. They can be or'ed together. */
156/* Use to have echoing of input */
157#define UI_INPUT_FLAG_ECHO 0x01
158/* Use a default password. Where that password is found is completely
159 up to the application, it might for example be in the user data set
160 with UI_add_user_data(). It is not recommended to have more than
161 one input in each UI being marked with this flag, or the application
162 might get confused. */
163#define UI_INPUT_FLAG_DEFAULT_PWD 0x02
164
165/* The user of these routines may want to define flags of their own. The core
166 UI won't look at those, but will pass them on to the method routines. They
167 must use higher bits so they don't get confused with the UI bits above.
168 UI_INPUT_FLAG_USER_BASE tells which is the lowest bit to use. A good
169 example of use is this:
170
171 #define MY_UI_FLAG1 (0x01 << UI_INPUT_FLAG_USER_BASE)
172
173*/
174#define UI_INPUT_FLAG_USER_BASE 16
175
176
177/* The following function helps construct a prompt. object_desc is a
178 textual short description of the object, for example "pass phrase",
179 and object_name is the name of the object (might be a card name or
180 a file name.
181 The returned string shall always be allocated on the heap with
182 OPENSSL_malloc(), and need to be free'd with OPENSSL_free().
183
184 If the ui_method doesn't contain a pointer to a user-defined prompt
185 constructor, a default string is built, looking like this:
186
187 "Enter {object_desc} for {object_name}:"
188
189 So, if object_desc has the value "pass phrase" and object_name has
190 the value "foo.key", the resulting string is:
191
192 "Enter pass phrase for foo.key:"
193*/
194char *UI_construct_prompt(UI *ui_method,
195 const char *object_desc, const char *object_name);
196
197
198/* The following function is used to store a pointer to user-specific data.
199 Any previous such pointer will be returned and replaced.
200
201 For callback purposes, this function makes a lot more sense than using
202 ex_data, since the latter requires that different parts of OpenSSL or
203 applications share the same ex_data index.
204
205 Note that the UI_OpenSSL() method completely ignores the user data.
206 Other methods may not, however. */
207void *UI_add_user_data(UI *ui, void *user_data);
208/* We need a user data retrieving function as well. */
209void *UI_get0_user_data(UI *ui);
210
211/* Return the result associated with a prompt given with the index i. */
212const char *UI_get0_result(UI *ui, int i);
213
214/* When all strings have been added, process the whole thing. */
215int UI_process(UI *ui);
216
217/* Give a user interface parametrised control commands. This can be used to
218 send down an integer, a data pointer or a function pointer, as well as
219 be used to get information from a UI. */
220int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f)());
221
222/* The commands */
223/* Use UI_CONTROL_PRINT_ERRORS with the value 1 to have UI_process print the
224 OpenSSL error stack before printing any info or added error messages and
225 before any prompting. */
226#define UI_CTRL_PRINT_ERRORS 1
227/* Check if a UI_process() is possible to do again with the same instance of
228 a user interface. This makes UI_ctrl() return 1 if it is redoable, and 0
229 if not. */
230#define UI_CTRL_IS_REDOABLE 2
231
232
233/* Some methods may use extra data */
234#define UI_set_app_data(s,arg) UI_set_ex_data(s,0,arg)
235#define UI_get_app_data(s) UI_get_ex_data(s,0)
236int UI_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
237 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
238int UI_set_ex_data(UI *r,int idx,void *arg);
239void *UI_get_ex_data(UI *r, int idx);
240
241/* Use specific methods instead of the built-in one */
242void UI_set_default_method(const UI_METHOD *meth);
243const UI_METHOD *UI_get_default_method(void);
244const UI_METHOD *UI_get_method(UI *ui);
245const UI_METHOD *UI_set_method(UI *ui, const UI_METHOD *meth);
246
247/* The method with all the built-in thingies */
248UI_METHOD *UI_OpenSSL(void);
249
250
251/* ---------- For method writers ---------- */
252/* A method contains a number of functions that implement the low level
253 of the User Interface. The functions are:
254
255 an opener This function starts a session, maybe by opening
256 a channel to a tty, or by opening a window.
257 a writer This function is called to write a given string,
258 maybe to the tty, maybe as a field label in a
259 window.
260 a flusher This function is called to flush everything that
261 has been output so far. It can be used to actually
262 display a dialog box after it has been built.
263 a reader This function is called to read a given prompt,
264 maybe from the tty, maybe from a field in a
265 window. Note that it's called wth all string
266 structures, not only the prompt ones, so it must
267 check such things itself.
268 a closer This function closes the session, maybe by closing
269 the channel to the tty, or closing the window.
270
271 All these functions are expected to return:
272
273 0 on error.
274 1 on success.
275 -1 on out-of-band events, for example if some prompting has
276 been canceled (by pressing Ctrl-C, for example). This is
277 only checked when returned by the flusher or the reader.
278
279 The way this is used, the opener is first called, then the writer for all
280 strings, then the flusher, then the reader for all strings and finally the
281 closer. Note that if you want to prompt from a terminal or other command
282 line interface, the best is to have the reader also write the prompts
283 instead of having the writer do it. If you want to prompt from a dialog
284 box, the writer can be used to build up the contents of the box, and the
285 flusher to actually display the box and run the event loop until all data
286 has been given, after which the reader only grabs the given data and puts
287 them back into the UI strings.
288
289 All method functions take a UI as argument. Additionally, the writer and
290 the reader take a UI_STRING.
291*/
292
293/* The UI_STRING type is the data structure that contains all the needed info
294 about a string or a prompt, including test data for a verification prompt.
295*/
296DECLARE_STACK_OF(UI_STRING)
297typedef struct ui_string_st UI_STRING;
298
299/* The different types of strings that are currently supported.
300 This is only needed by method authors. */
301enum UI_string_types
302 {
303 UIT_NONE=0,
304 UIT_PROMPT, /* Prompt for a string */
305 UIT_VERIFY, /* Prompt for a string and verify */
306 UIT_BOOLEAN, /* Prompt for a yes/no response */
307 UIT_INFO, /* Send info to the user */
308 UIT_ERROR /* Send an error message to the user */
309 };
310
311/* Create and manipulate methods */
312UI_METHOD *UI_create_method(char *name);
313void UI_destroy_method(UI_METHOD *ui_method);
314int UI_method_set_opener(UI_METHOD *method, int (*opener)(UI *ui));
315int UI_method_set_writer(UI_METHOD *method, int (*writer)(UI *ui, UI_STRING *uis));
316int UI_method_set_flusher(UI_METHOD *method, int (*flusher)(UI *ui));
317int UI_method_set_reader(UI_METHOD *method, int (*reader)(UI *ui, UI_STRING *uis));
318int UI_method_set_closer(UI_METHOD *method, int (*closer)(UI *ui));
319int (*UI_method_get_opener(UI_METHOD *method))(UI*);
320int (*UI_method_get_writer(UI_METHOD *method))(UI*,UI_STRING*);
321int (*UI_method_get_flusher(UI_METHOD *method))(UI*);
322int (*UI_method_get_reader(UI_METHOD *method))(UI*,UI_STRING*);
323int (*UI_method_get_closer(UI_METHOD *method))(UI*);
324
325/* The following functions are helpers for method writers to access relevant
326 data from a UI_STRING. */
327
328/* Return type of the UI_STRING */
329enum UI_string_types UI_get_string_type(UI_STRING *uis);
330/* Return input flags of the UI_STRING */
331int UI_get_input_flags(UI_STRING *uis);
332/* Return the actual string to output (the prompt, info or error) */
333const char *UI_get0_output_string(UI_STRING *uis);
334/* Return the optional action string to output (the boolean promtp instruction) */
335const char *UI_get0_action_string(UI_STRING *uis);
336/* Return the result of a prompt */
337const char *UI_get0_result_string(UI_STRING *uis);
338/* Return the string to test the result against. Only useful with verifies. */
339const char *UI_get0_test_string(UI_STRING *uis);
340/* Return the required minimum size of the result */
341int UI_get_result_minsize(UI_STRING *uis);
342/* Return the required maximum size of the result */
343int UI_get_result_maxsize(UI_STRING *uis);
344/* Set the result of a UI_STRING. */
345int UI_set_result(UI *ui, UI_STRING *uis, const char *result);
346
347
348/* A couple of popular utility functions */
349int UI_UTIL_read_pw_string(char *buf,int length,const char *prompt,int verify);
350int UI_UTIL_read_pw(char *buf,char *buff,int size,const char *prompt,int verify);
351
352
353/* BEGIN ERROR CODES */
354/* The following lines are auto generated by the script mkerr.pl. Any changes
355 * made after this point may be overwritten when the script is next run.
356 */
357void ERR_load_UI_strings(void);
358
359/* Error codes for the UI functions. */
360
361/* Function codes. */
362#define UI_F_GENERAL_ALLOCATE_BOOLEAN 108
363#define UI_F_GENERAL_ALLOCATE_PROMPT 109
364#define UI_F_GENERAL_ALLOCATE_STRING 100
365#define UI_F_UI_CTRL 111
366#define UI_F_UI_DUP_ERROR_STRING 101
367#define UI_F_UI_DUP_INFO_STRING 102
368#define UI_F_UI_DUP_INPUT_BOOLEAN 110
369#define UI_F_UI_DUP_INPUT_STRING 103
370#define UI_F_UI_DUP_VERIFY_STRING 106
371#define UI_F_UI_GET0_RESULT 107
372#define UI_F_UI_NEW_METHOD 104
373#define UI_F_UI_SET_RESULT 105
374
375/* Reason codes. */
376#define UI_R_COMMON_OK_AND_CANCEL_CHARACTERS 104
377#define UI_R_INDEX_TOO_LARGE 102
378#define UI_R_INDEX_TOO_SMALL 103
379#define UI_R_NO_RESULT_BUFFER 105
380#define UI_R_RESULT_TOO_LARGE 100
381#define UI_R_RESULT_TOO_SMALL 101
382#define UI_R_UNKNOWN_CONTROL_COMMAND 106
383
384#ifdef __cplusplus
385}
386#endif
387#endif
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_compat.h b/src/lib/libcrypto/ui/ui_compat.h
new file mode 100644
index 0000000000..b35c9bb7fd
--- /dev/null
+++ b/src/lib/libcrypto/ui/ui_compat.h
@@ -0,0 +1,83 @@
1/* crypto/ui/ui.h -*- mode:C; c-file-style: "eay" -*- */
2/* Written by Richard Levitte (richard@levitte.org) 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 * 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#ifndef HEADER_UI_COMPAT_H
60#define HEADER_UI_COMPAT_H
61
62#include <openssl/opensslconf.h>
63#include <openssl/ui.h>
64
65#ifdef __cplusplus
66extern "C" {
67#endif
68
69/* The following functions were previously part of the DES section,
70 and are provided here for backward compatibility reasons. */
71
72#define des_read_pw_string(b,l,p,v) \
73 _ossl_old_des_read_pw_string((b),(l),(p),(v))
74#define des_read_pw(b,bf,s,p,v) \
75 _ossl_old_des_read_pw((b),(bf),(s),(p),(v))
76
77int _ossl_old_des_read_pw_string(char *buf,int length,const char *prompt,int verify);
78int _ossl_old_des_read_pw(char *buf,char *buff,int size,const char *prompt,int verify);
79
80#ifdef __cplusplus
81}
82#endif
83#endif
diff --git a/src/lib/libcrypto/ui/ui_err.c b/src/lib/libcrypto/ui/ui_err.c
new file mode 100644
index 0000000000..39a62ae737
--- /dev/null
+++ b/src/lib/libcrypto/ui/ui_err.c
@@ -0,0 +1,111 @@
1/* crypto/ui/ui_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 <openssl/ui.h>
64
65/* BEGIN ERROR CODES */
66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA UI_str_functs[]=
68 {
69{ERR_PACK(0,UI_F_GENERAL_ALLOCATE_BOOLEAN,0), "GENERAL_ALLOCATE_BOOLEAN"},
70{ERR_PACK(0,UI_F_GENERAL_ALLOCATE_PROMPT,0), "GENERAL_ALLOCATE_PROMPT"},
71{ERR_PACK(0,UI_F_GENERAL_ALLOCATE_STRING,0), "GENERAL_ALLOCATE_STRING"},
72{ERR_PACK(0,UI_F_UI_CTRL,0), "UI_ctrl"},
73{ERR_PACK(0,UI_F_UI_DUP_ERROR_STRING,0), "UI_dup_error_string"},
74{ERR_PACK(0,UI_F_UI_DUP_INFO_STRING,0), "UI_dup_info_string"},
75{ERR_PACK(0,UI_F_UI_DUP_INPUT_BOOLEAN,0), "UI_dup_input_boolean"},
76{ERR_PACK(0,UI_F_UI_DUP_INPUT_STRING,0), "UI_dup_input_string"},
77{ERR_PACK(0,UI_F_UI_DUP_VERIFY_STRING,0), "UI_dup_verify_string"},
78{ERR_PACK(0,UI_F_UI_GET0_RESULT,0), "UI_get0_result"},
79{ERR_PACK(0,UI_F_UI_NEW_METHOD,0), "UI_new_method"},
80{ERR_PACK(0,UI_F_UI_SET_RESULT,0), "UI_set_result"},
81{0,NULL}
82 };
83
84static ERR_STRING_DATA UI_str_reasons[]=
85 {
86{UI_R_COMMON_OK_AND_CANCEL_CHARACTERS ,"common ok and cancel characters"},
87{UI_R_INDEX_TOO_LARGE ,"index too large"},
88{UI_R_INDEX_TOO_SMALL ,"index too small"},
89{UI_R_NO_RESULT_BUFFER ,"no result buffer"},
90{UI_R_RESULT_TOO_LARGE ,"result too large"},
91{UI_R_RESULT_TOO_SMALL ,"result too small"},
92{UI_R_UNKNOWN_CONTROL_COMMAND ,"unknown control command"},
93{0,NULL}
94 };
95
96#endif
97
98void ERR_load_UI_strings(void)
99 {
100 static int init=1;
101
102 if (init)
103 {
104 init=0;
105#ifndef OPENSSL_NO_ERR
106 ERR_load_strings(ERR_LIB_UI,UI_str_functs);
107 ERR_load_strings(ERR_LIB_UI,UI_str_reasons);
108#endif
109
110 }
111 }
diff --git a/src/lib/libcrypto/ui/ui_lib.c b/src/lib/libcrypto/ui/ui_lib.c
new file mode 100644
index 0000000000..16946cad95
--- /dev/null
+++ b/src/lib/libcrypto/ui/ui_lib.c
@@ -0,0 +1,899 @@
1/* crypto/ui/ui_lib.c -*- mode:C; c-file-style: "eay" -*- */
2/* Written by Richard Levitte (richard@levitte.org) 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 * openssl-core@openssl.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59#include <string.h>
60#include <openssl/e_os2.h>
61#include <openssl/buffer.h>
62#include <openssl/ui.h>
63#include <openssl/err.h>
64#include "ui_locl.h"
65
66IMPLEMENT_STACK_OF(UI_STRING_ST)
67
68static const UI_METHOD *default_UI_meth=NULL;
69
70UI *UI_new(void)
71 {
72 return(UI_new_method(NULL));
73 }
74
75UI *UI_new_method(const UI_METHOD *method)
76 {
77 UI *ret;
78
79 ret=(UI *)OPENSSL_malloc(sizeof(UI));
80 if (ret == NULL)
81 {
82 UIerr(UI_F_UI_NEW_METHOD,ERR_R_MALLOC_FAILURE);
83 return NULL;
84 }
85 if (method == NULL)
86 ret->meth=UI_get_default_method();
87 else
88 ret->meth=method;
89
90 ret->strings=NULL;
91 ret->user_data=NULL;
92 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_UI, ret, &ret->ex_data);
93 return ret;
94 }
95
96static void free_string(UI_STRING *uis)
97 {
98 if (uis->flags & OUT_STRING_FREEABLE)
99 {
100 OPENSSL_free((char *)uis->out_string);
101 switch(uis->type)
102 {
103 case UIT_BOOLEAN:
104 OPENSSL_free((char *)uis->_.boolean_data.action_desc);
105 OPENSSL_free((char *)uis->_.boolean_data.ok_chars);
106 OPENSSL_free((char *)uis->_.boolean_data.cancel_chars);
107 break;
108 default:
109 break;
110 }
111 }
112 OPENSSL_free(uis);
113 }
114
115void UI_free(UI *ui)
116 {
117 if (ui == NULL)
118 return;
119 sk_UI_STRING_pop_free(ui->strings,free_string);
120 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_UI, ui, &ui->ex_data);
121 OPENSSL_free(ui);
122 }
123
124static int allocate_string_stack(UI *ui)
125 {
126 if (ui->strings == NULL)
127 {
128 ui->strings=sk_UI_STRING_new_null();
129 if (ui->strings == NULL)
130 {
131 return -1;
132 }
133 }
134 return 0;
135 }
136
137static UI_STRING *general_allocate_prompt(UI *ui, const char *prompt,
138 int prompt_freeable, enum UI_string_types type, int input_flags,
139 char *result_buf)
140 {
141 UI_STRING *ret = NULL;
142
143 if (prompt == NULL)
144 {
145 UIerr(UI_F_GENERAL_ALLOCATE_PROMPT,ERR_R_PASSED_NULL_PARAMETER);
146 }
147 else if (result_buf == NULL)
148 {
149 UIerr(UI_F_GENERAL_ALLOCATE_PROMPT,UI_R_NO_RESULT_BUFFER);
150 }
151 else if ((ret = (UI_STRING *)OPENSSL_malloc(sizeof(UI_STRING))))
152 {
153 ret->out_string=prompt;
154 ret->flags=prompt_freeable ? OUT_STRING_FREEABLE : 0;
155 ret->input_flags=input_flags;
156 ret->type=type;
157 ret->result_buf=result_buf;
158 }
159 return ret;
160 }
161
162static int general_allocate_string(UI *ui, const char *prompt,
163 int prompt_freeable, enum UI_string_types type, int input_flags,
164 char *result_buf, int minsize, int maxsize, const char *test_buf)
165 {
166 int ret = -1;
167 UI_STRING *s = general_allocate_prompt(ui, prompt, prompt_freeable,
168 type, input_flags, result_buf);
169
170 if (s)
171 {
172 if (allocate_string_stack(ui) >= 0)
173 {
174 s->_.string_data.result_minsize=minsize;
175 s->_.string_data.result_maxsize=maxsize;
176 s->_.string_data.test_buf=test_buf;
177 ret=sk_UI_STRING_push(ui->strings, s);
178 /* sk_push() returns 0 on error. Let's addapt that */
179 if (ret <= 0) ret--;
180 }
181 else
182 free_string(s);
183 }
184 return ret;
185 }
186
187static int general_allocate_boolean(UI *ui,
188 const char *prompt, const char *action_desc,
189 const char *ok_chars, const char *cancel_chars,
190 int prompt_freeable, enum UI_string_types type, int input_flags,
191 char *result_buf)
192 {
193 int ret = -1;
194 UI_STRING *s;
195 const char *p;
196
197 if (ok_chars == NULL)
198 {
199 UIerr(UI_F_GENERAL_ALLOCATE_BOOLEAN,ERR_R_PASSED_NULL_PARAMETER);
200 }
201 else if (cancel_chars == NULL)
202 {
203 UIerr(UI_F_GENERAL_ALLOCATE_BOOLEAN,ERR_R_PASSED_NULL_PARAMETER);
204 }
205 else
206 {
207 for(p = ok_chars; *p; p++)
208 {
209 if (strchr(cancel_chars, *p))
210 {
211 UIerr(UI_F_GENERAL_ALLOCATE_BOOLEAN,
212 UI_R_COMMON_OK_AND_CANCEL_CHARACTERS);
213 }
214 }
215
216 s = general_allocate_prompt(ui, prompt, prompt_freeable,
217 type, input_flags, result_buf);
218
219 if (s)
220 {
221 if (allocate_string_stack(ui) >= 0)
222 {
223 s->_.boolean_data.action_desc = action_desc;
224 s->_.boolean_data.ok_chars = ok_chars;
225 s->_.boolean_data.cancel_chars = cancel_chars;
226 ret=sk_UI_STRING_push(ui->strings, s);
227 /* sk_push() returns 0 on error.
228 Let's addapt that */
229 if (ret <= 0) ret--;
230 }
231 else
232 free_string(s);
233 }
234 }
235 return ret;
236 }
237
238/* Returns the index to the place in the stack or 0 for error. Uses a
239 direct reference to the prompt. */
240int UI_add_input_string(UI *ui, const char *prompt, int flags,
241 char *result_buf, int minsize, int maxsize)
242 {
243 return general_allocate_string(ui, prompt, 0,
244 UIT_PROMPT, flags, result_buf, minsize, maxsize, NULL);
245 }
246
247/* Same as UI_add_input_string(), excepts it takes a copy of the prompt */
248int UI_dup_input_string(UI *ui, const char *prompt, int flags,
249 char *result_buf, int minsize, int maxsize)
250 {
251 char *prompt_copy=NULL;
252
253 if (prompt)
254 {
255 prompt_copy=BUF_strdup(prompt);
256 if (prompt_copy == NULL)
257 {
258 UIerr(UI_F_UI_DUP_INPUT_STRING,ERR_R_MALLOC_FAILURE);
259 return 0;
260 }
261 }
262
263 return general_allocate_string(ui, prompt_copy, 1,
264 UIT_PROMPT, flags, result_buf, minsize, maxsize, NULL);
265 }
266
267int UI_add_verify_string(UI *ui, const char *prompt, int flags,
268 char *result_buf, int minsize, int maxsize, const char *test_buf)
269 {
270 return general_allocate_string(ui, prompt, 0,
271 UIT_VERIFY, flags, result_buf, minsize, maxsize, test_buf);
272 }
273
274int UI_dup_verify_string(UI *ui, const char *prompt, int flags,
275 char *result_buf, int minsize, int maxsize, const char *test_buf)
276 {
277 char *prompt_copy=NULL;
278
279 if (prompt)
280 {
281 prompt_copy=BUF_strdup(prompt);
282 if (prompt_copy == NULL)
283 {
284 UIerr(UI_F_UI_DUP_VERIFY_STRING,ERR_R_MALLOC_FAILURE);
285 return -1;
286 }
287 }
288
289 return general_allocate_string(ui, prompt_copy, 1,
290 UIT_VERIFY, flags, result_buf, minsize, maxsize, test_buf);
291 }
292
293int UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc,
294 const char *ok_chars, const char *cancel_chars,
295 int flags, char *result_buf)
296 {
297 return general_allocate_boolean(ui, prompt, action_desc,
298 ok_chars, cancel_chars, 0, UIT_BOOLEAN, flags, result_buf);
299 }
300
301int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc,
302 const char *ok_chars, const char *cancel_chars,
303 int flags, char *result_buf)
304 {
305 char *prompt_copy = NULL;
306 char *action_desc_copy = NULL;
307 char *ok_chars_copy = NULL;
308 char *cancel_chars_copy = NULL;
309
310 if (prompt)
311 {
312 prompt_copy=BUF_strdup(prompt);
313 if (prompt_copy == NULL)
314 {
315 UIerr(UI_F_UI_DUP_INPUT_BOOLEAN,ERR_R_MALLOC_FAILURE);
316 goto err;
317 }
318 }
319
320 if (action_desc)
321 {
322 action_desc_copy=BUF_strdup(action_desc);
323 if (action_desc_copy == NULL)
324 {
325 UIerr(UI_F_UI_DUP_INPUT_BOOLEAN,ERR_R_MALLOC_FAILURE);
326 goto err;
327 }
328 }
329
330 if (ok_chars)
331 {
332 ok_chars_copy=BUF_strdup(ok_chars);
333 if (ok_chars_copy == NULL)
334 {
335 UIerr(UI_F_UI_DUP_INPUT_BOOLEAN,ERR_R_MALLOC_FAILURE);
336 goto err;
337 }
338 }
339
340 if (cancel_chars)
341 {
342 cancel_chars_copy=BUF_strdup(cancel_chars);
343 if (cancel_chars_copy == NULL)
344 {
345 UIerr(UI_F_UI_DUP_INPUT_BOOLEAN,ERR_R_MALLOC_FAILURE);
346 goto err;
347 }
348 }
349
350 return general_allocate_boolean(ui, prompt_copy, action_desc_copy,
351 ok_chars_copy, cancel_chars_copy, 1, UIT_BOOLEAN, flags,
352 result_buf);
353 err:
354 if (prompt_copy) OPENSSL_free(prompt_copy);
355 if (action_desc_copy) OPENSSL_free(action_desc_copy);
356 if (ok_chars_copy) OPENSSL_free(ok_chars_copy);
357 if (cancel_chars_copy) OPENSSL_free(cancel_chars_copy);
358 return -1;
359 }
360
361int UI_add_info_string(UI *ui, const char *text)
362 {
363 return general_allocate_string(ui, text, 0, UIT_INFO, 0, NULL, 0, 0,
364 NULL);
365 }
366
367int UI_dup_info_string(UI *ui, const char *text)
368 {
369 char *text_copy=NULL;
370
371 if (text)
372 {
373 text_copy=BUF_strdup(text);
374 if (text_copy == NULL)
375 {
376 UIerr(UI_F_UI_DUP_INFO_STRING,ERR_R_MALLOC_FAILURE);
377 return -1;
378 }
379 }
380
381 return general_allocate_string(ui, text_copy, 1, UIT_INFO, 0, NULL,
382 0, 0, NULL);
383 }
384
385int UI_add_error_string(UI *ui, const char *text)
386 {
387 return general_allocate_string(ui, text, 0, UIT_ERROR, 0, NULL, 0, 0,
388 NULL);
389 }
390
391int UI_dup_error_string(UI *ui, const char *text)
392 {
393 char *text_copy=NULL;
394
395 if (text)
396 {
397 text_copy=BUF_strdup(text);
398 if (text_copy == NULL)
399 {
400 UIerr(UI_F_UI_DUP_ERROR_STRING,ERR_R_MALLOC_FAILURE);
401 return -1;
402 }
403 }
404 return general_allocate_string(ui, text_copy, 1, UIT_ERROR, 0, NULL,
405 0, 0, NULL);
406 }
407
408char *UI_construct_prompt(UI *ui, const char *object_desc,
409 const char *object_name)
410 {
411 char *prompt = NULL;
412
413 if (ui->meth->ui_construct_prompt)
414 prompt = ui->meth->ui_construct_prompt(ui,
415 object_desc, object_name);
416 else
417 {
418 char prompt1[] = "Enter ";
419 char prompt2[] = " for ";
420 char prompt3[] = ":";
421 int len = 0;
422
423 if (object_desc == NULL)
424 return NULL;
425 len = sizeof(prompt1) - 1 + strlen(object_desc);
426 if (object_name)
427 len += sizeof(prompt2) - 1 + strlen(object_name);
428 len += sizeof(prompt3) - 1;
429
430 prompt = (char *)OPENSSL_malloc(len + 1);
431 strcpy(prompt, prompt1);
432 strcat(prompt, object_desc);
433 if (object_name)
434 {
435 strcat(prompt, prompt2);
436 strcat(prompt, object_name);
437 }
438 strcat(prompt, prompt3);
439 }
440 return prompt;
441 }
442
443void *UI_add_user_data(UI *ui, void *user_data)
444 {
445 void *old_data = ui->user_data;
446 ui->user_data = user_data;
447 return old_data;
448 }
449
450void *UI_get0_user_data(UI *ui)
451 {
452 return ui->user_data;
453 }
454
455const char *UI_get0_result(UI *ui, int i)
456 {
457 if (i < 0)
458 {
459 UIerr(UI_F_UI_GET0_RESULT,UI_R_INDEX_TOO_SMALL);
460 return NULL;
461 }
462 if (i >= sk_UI_STRING_num(ui->strings))
463 {
464 UIerr(UI_F_UI_GET0_RESULT,UI_R_INDEX_TOO_LARGE);
465 return NULL;
466 }
467 return UI_get0_result_string(sk_UI_STRING_value(ui->strings, i));
468 }
469
470static int print_error(const char *str, size_t len, UI *ui)
471 {
472 UI_STRING uis;
473
474 memset(&uis, 0, sizeof(uis));
475 uis.type = UIT_ERROR;
476 uis.out_string = str;
477
478 if (ui->meth->ui_write_string
479 && !ui->meth->ui_write_string(ui, &uis))
480 return -1;
481 return 0;
482 }
483
484int UI_process(UI *ui)
485 {
486 int i, ok=0;
487
488 if (ui->meth->ui_open_session && !ui->meth->ui_open_session(ui))
489 return -1;
490
491 if (ui->flags & UI_FLAG_PRINT_ERRORS)
492 ERR_print_errors_cb(
493 (int (*)(const char *, size_t, void *))print_error,
494 (void *)ui);
495
496 for(i=0; i<sk_UI_STRING_num(ui->strings); i++)
497 {
498 if (ui->meth->ui_write_string
499 && !ui->meth->ui_write_string(ui,
500 sk_UI_STRING_value(ui->strings, i)))
501 {
502 ok=-1;
503 goto err;
504 }
505 }
506
507 if (ui->meth->ui_flush)
508 switch(ui->meth->ui_flush(ui))
509 {
510 case -1: /* Interrupt/Cancel/something... */
511 ok = -2;
512 goto err;
513 case 0: /* Errors */
514 ok = -1;
515 goto err;
516 default: /* Success */
517 ok = 0;
518 break;
519 }
520
521 for(i=0; i<sk_UI_STRING_num(ui->strings); i++)
522 {
523 if (ui->meth->ui_read_string)
524 {
525 switch(ui->meth->ui_read_string(ui,
526 sk_UI_STRING_value(ui->strings, i)))
527 {
528 case -1: /* Interrupt/Cancel/something... */
529 ok = -2;
530 goto err;
531 case 0: /* Errors */
532 ok = -1;
533 goto err;
534 default: /* Success */
535 ok = 0;
536 break;
537 }
538 }
539 }
540 err:
541 if (ui->meth->ui_close_session && !ui->meth->ui_close_session(ui))
542 return -1;
543 return ok;
544 }
545
546int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f)())
547 {
548 if (ui == NULL)
549 {
550 UIerr(UI_F_UI_CTRL,ERR_R_PASSED_NULL_PARAMETER);
551 return -1;
552 }
553 switch(cmd)
554 {
555 case UI_CTRL_PRINT_ERRORS:
556 {
557 int save_flag = !!(ui->flags & UI_FLAG_PRINT_ERRORS);
558 if (i)
559 ui->flags |= UI_FLAG_PRINT_ERRORS;
560 else
561 ui->flags &= ~UI_FLAG_PRINT_ERRORS;
562 return save_flag;
563 }
564 case UI_CTRL_IS_REDOABLE:
565 return !!(ui->flags & UI_FLAG_REDOABLE);
566 default:
567 break;
568 }
569 UIerr(UI_F_UI_CTRL,UI_R_UNKNOWN_CONTROL_COMMAND);
570 return -1;
571 }
572
573int UI_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
574 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
575 {
576 return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_UI, argl, argp,
577 new_func, dup_func, free_func);
578 }
579
580int UI_set_ex_data(UI *r, int idx, void *arg)
581 {
582 return(CRYPTO_set_ex_data(&r->ex_data,idx,arg));
583 }
584
585void *UI_get_ex_data(UI *r, int idx)
586 {
587 return(CRYPTO_get_ex_data(&r->ex_data,idx));
588 }
589
590void UI_set_default_method(const UI_METHOD *meth)
591 {
592 default_UI_meth=meth;
593 }
594
595const UI_METHOD *UI_get_default_method(void)
596 {
597 if (default_UI_meth == NULL)
598 {
599 default_UI_meth=UI_OpenSSL();
600 }
601 return default_UI_meth;
602 }
603
604const UI_METHOD *UI_get_method(UI *ui)
605 {
606 return ui->meth;
607 }
608
609const UI_METHOD *UI_set_method(UI *ui, const UI_METHOD *meth)
610 {
611 ui->meth=meth;
612 return ui->meth;
613 }
614
615
616UI_METHOD *UI_create_method(char *name)
617 {
618 UI_METHOD *ui_method = (UI_METHOD *)OPENSSL_malloc(sizeof(UI_METHOD));
619
620 if (ui_method)
621 memset(ui_method, 0, sizeof(*ui_method));
622 ui_method->name = BUF_strdup(name);
623 return ui_method;
624 }
625
626/* BIG FSCKING WARNING!!!! If you use this on a statically allocated method
627 (that is, it hasn't been allocated using UI_create_method(), you deserve
628 anything Murphy can throw at you and more! You have been warned. */
629void UI_destroy_method(UI_METHOD *ui_method)
630 {
631 OPENSSL_free(ui_method->name);
632 ui_method->name = NULL;
633 OPENSSL_free(ui_method);
634 }
635
636int UI_method_set_opener(UI_METHOD *method, int (*opener)(UI *ui))
637 {
638 if (method)
639 {
640 method->ui_open_session = opener;
641 return 0;
642 }
643 else
644 return -1;
645 }
646
647int UI_method_set_writer(UI_METHOD *method, int (*writer)(UI *ui, UI_STRING *uis))
648 {
649 if (method)
650 {
651 method->ui_write_string = writer;
652 return 0;
653 }
654 else
655 return -1;
656 }
657
658int UI_method_set_flusher(UI_METHOD *method, int (*flusher)(UI *ui))
659 {
660 if (method)
661 {
662 method->ui_flush = flusher;
663 return 0;
664 }
665 else
666 return -1;
667 }
668
669int UI_method_set_reader(UI_METHOD *method, int (*reader)(UI *ui, UI_STRING *uis))
670 {
671 if (method)
672 {
673 method->ui_read_string = reader;
674 return 0;
675 }
676 else
677 return -1;
678 }
679
680int UI_method_set_closer(UI_METHOD *method, int (*closer)(UI *ui))
681 {
682 if (method)
683 {
684 method->ui_close_session = closer;
685 return 0;
686 }
687 else
688 return -1;
689 }
690
691int (*UI_method_get_opener(UI_METHOD *method))(UI*)
692 {
693 if (method)
694 return method->ui_open_session;
695 else
696 return NULL;
697 }
698
699int (*UI_method_get_writer(UI_METHOD *method))(UI*,UI_STRING*)
700 {
701 if (method)
702 return method->ui_write_string;
703 else
704 return NULL;
705 }
706
707int (*UI_method_get_flusher(UI_METHOD *method))(UI*)
708 {
709 if (method)
710 return method->ui_flush;
711 else
712 return NULL;
713 }
714
715int (*UI_method_get_reader(UI_METHOD *method))(UI*,UI_STRING*)
716 {
717 if (method)
718 return method->ui_read_string;
719 else
720 return NULL;
721 }
722
723int (*UI_method_get_closer(UI_METHOD *method))(UI*)
724 {
725 if (method)
726 return method->ui_close_session;
727 else
728 return NULL;
729 }
730
731enum UI_string_types UI_get_string_type(UI_STRING *uis)
732 {
733 if (!uis)
734 return UIT_NONE;
735 return uis->type;
736 }
737
738int UI_get_input_flags(UI_STRING *uis)
739 {
740 if (!uis)
741 return 0;
742 return uis->input_flags;
743 }
744
745const char *UI_get0_output_string(UI_STRING *uis)
746 {
747 if (!uis)
748 return NULL;
749 return uis->out_string;
750 }
751
752const char *UI_get0_action_string(UI_STRING *uis)
753 {
754 if (!uis)
755 return NULL;
756 switch(uis->type)
757 {
758 case UIT_PROMPT:
759 case UIT_BOOLEAN:
760 return uis->_.boolean_data.action_desc;
761 default:
762 return NULL;
763 }
764 }
765
766const char *UI_get0_result_string(UI_STRING *uis)
767 {
768 if (!uis)
769 return NULL;
770 switch(uis->type)
771 {
772 case UIT_PROMPT:
773 case UIT_VERIFY:
774 return uis->result_buf;
775 default:
776 return NULL;
777 }
778 }
779
780const char *UI_get0_test_string(UI_STRING *uis)
781 {
782 if (!uis)
783 return NULL;
784 switch(uis->type)
785 {
786 case UIT_VERIFY:
787 return uis->_.string_data.test_buf;
788 default:
789 return NULL;
790 }
791 }
792
793int UI_get_result_minsize(UI_STRING *uis)
794 {
795 if (!uis)
796 return -1;
797 switch(uis->type)
798 {
799 case UIT_PROMPT:
800 case UIT_VERIFY:
801 return uis->_.string_data.result_minsize;
802 default:
803 return -1;
804 }
805 }
806
807int UI_get_result_maxsize(UI_STRING *uis)
808 {
809 if (!uis)
810 return -1;
811 switch(uis->type)
812 {
813 case UIT_PROMPT:
814 case UIT_VERIFY:
815 return uis->_.string_data.result_maxsize;
816 default:
817 return -1;
818 }
819 }
820
821int UI_set_result(UI *ui, UI_STRING *uis, const char *result)
822 {
823 int l = strlen(result);
824
825 ui->flags &= ~UI_FLAG_REDOABLE;
826
827 if (!uis)
828 return -1;
829 switch (uis->type)
830 {
831 case UIT_PROMPT:
832 case UIT_VERIFY:
833 {
834 char number1[20];
835 char number2[20];
836
837 BIO_snprintf(number1, sizeof(number1), "%d",
838 uis->_.string_data.result_minsize);
839 BIO_snprintf(number2, sizeof(number2), "%d",
840 uis->_.string_data.result_maxsize);
841
842 if (l < uis->_.string_data.result_minsize)
843 {
844 ui->flags |= UI_FLAG_REDOABLE;
845 UIerr(UI_F_UI_SET_RESULT,UI_R_RESULT_TOO_SMALL);
846 ERR_add_error_data(5,"You must type in ",
847 number1," to ",number2," characters");
848 return -1;
849 }
850 if (l > uis->_.string_data.result_maxsize)
851 {
852 ui->flags |= UI_FLAG_REDOABLE;
853 UIerr(UI_F_UI_SET_RESULT,UI_R_RESULT_TOO_LARGE);
854 ERR_add_error_data(5,"You must type in ",
855 number1," to ",number2," characters");
856 return -1;
857 }
858 }
859
860 if (!uis->result_buf)
861 {
862 UIerr(UI_F_UI_SET_RESULT,UI_R_NO_RESULT_BUFFER);
863 return -1;
864 }
865
866 strcpy(uis->result_buf, result);
867 break;
868 case UIT_BOOLEAN:
869 {
870 const char *p;
871
872 if (!uis->result_buf)
873 {
874 UIerr(UI_F_UI_SET_RESULT,UI_R_NO_RESULT_BUFFER);
875 return -1;
876 }
877
878 uis->result_buf[0] = '\0';
879 for(p = result; *p; p++)
880 {
881 if (strchr(uis->_.boolean_data.ok_chars, *p))
882 {
883 uis->result_buf[0] =
884 uis->_.boolean_data.ok_chars[0];
885 break;
886 }
887 if (strchr(uis->_.boolean_data.cancel_chars, *p))
888 {
889 uis->result_buf[0] =
890 uis->_.boolean_data.cancel_chars[0];
891 break;
892 }
893 }
894 default:
895 break;
896 }
897 }
898 return 0;
899 }
diff --git a/src/lib/libcrypto/ui/ui_locl.h b/src/lib/libcrypto/ui/ui_locl.h
new file mode 100644
index 0000000000..7d3a75a619
--- /dev/null
+++ b/src/lib/libcrypto/ui/ui_locl.h
@@ -0,0 +1,148 @@
1/* crypto/ui/ui.h -*- mode:C; c-file-style: "eay" -*- */
2/* Written by Richard Levitte (richard@levitte.org) 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 * 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#ifndef HEADER_UI_LOCL_H
60#define HEADER_UI_LOCL_H
61
62#include <openssl/ui.h>
63
64struct ui_method_st
65 {
66 char *name;
67
68 /* All the functions return 1 or non-NULL for success and 0 or NULL
69 for failure */
70
71 /* Open whatever channel for this, be it the console, an X window
72 or whatever.
73 This function should use the ex_data structure to save
74 intermediate data. */
75 int (*ui_open_session)(UI *ui);
76
77 int (*ui_write_string)(UI *ui, UI_STRING *uis);
78
79 /* Flush the output. If a GUI dialog box is used, this function can
80 be used to actually display it. */
81 int (*ui_flush)(UI *ui);
82
83 int (*ui_read_string)(UI *ui, UI_STRING *uis);
84
85 int (*ui_close_session)(UI *ui);
86
87 /* Construct a prompt in a user-defined manner. object_desc is a
88 textual short description of the object, for example "pass phrase",
89 and object_name is the name of the object (might be a card name or
90 a file name.
91 The returned string shall always be allocated on the heap with
92 OPENSSL_malloc(), and need to be free'd with OPENSSL_free(). */
93 char *(*ui_construct_prompt)(UI *ui, const char *object_desc,
94 const char *object_name);
95 };
96
97struct ui_string_st
98 {
99 enum UI_string_types type; /* Input */
100 const char *out_string; /* Input */
101 int input_flags; /* Flags from the user */
102
103 /* The following parameters are completely irrelevant for UIT_INFO,
104 and can therefore be set to 0 or NULL */
105 char *result_buf; /* Input and Output: If not NULL, user-defined
106 with size in result_maxsize. Otherwise, it
107 may be allocated by the UI routine, meaning
108 result_minsize is going to be overwritten.*/
109 union
110 {
111 struct
112 {
113 int result_minsize; /* Input: minimum required
114 size of the result.
115 */
116 int result_maxsize; /* Input: maximum permitted
117 size of the result */
118
119 const char *test_buf; /* Input: test string to verify
120 against */
121 } string_data;
122 struct
123 {
124 const char *action_desc; /* Input */
125 const char *ok_chars; /* Input */
126 const char *cancel_chars; /* Input */
127 } boolean_data;
128 } _;
129
130#define OUT_STRING_FREEABLE 0x01
131 int flags; /* flags for internal use */
132 };
133
134struct ui_st
135 {
136 const UI_METHOD *meth;
137 STACK_OF(UI_STRING) *strings; /* We might want to prompt for more
138 than one thing at a time, and
139 with different echoing status. */
140 void *user_data;
141 CRYPTO_EX_DATA ex_data;
142
143#define UI_FLAG_REDOABLE 0x0001
144#define UI_FLAG_PRINT_ERRORS 0x0100
145 int flags;
146 };
147
148#endif
diff --git a/src/lib/libcrypto/ui/ui_openssl.c b/src/lib/libcrypto/ui/ui_openssl.c
new file mode 100644
index 0000000000..3aa03f74aa
--- /dev/null
+++ b/src/lib/libcrypto/ui/ui_openssl.c
@@ -0,0 +1,661 @@
1/* crypto/ui/ui_openssl.c -*- mode:C; c-file-style: "eay" -*- */
2/* Written by Richard Levitte (richard@levitte.org) and others
3 * for the OpenSSL 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 * 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/* The lowest level part of this file was previously in crypto/des/read_pwd.c,
60 * Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
61 * All rights reserved.
62 *
63 * This package is an SSL implementation written
64 * by Eric Young (eay@cryptsoft.com).
65 * The implementation was written so as to conform with Netscapes SSL.
66 *
67 * This library is free for commercial and non-commercial use as long as
68 * the following conditions are aheared to. The following conditions
69 * apply to all code found in this distribution, be it the RC4, RSA,
70 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
71 * included with this distribution is covered by the same copyright terms
72 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
73 *
74 * Copyright remains Eric Young's, and as such any Copyright notices in
75 * the code are not to be removed.
76 * If this package is used in a product, Eric Young should be given attribution
77 * as the author of the parts of the library used.
78 * This can be in the form of a textual message at program startup or
79 * in documentation (online or textual) provided with the package.
80 *
81 * Redistribution and use in source and binary forms, with or without
82 * modification, are permitted provided that the following conditions
83 * are met:
84 * 1. Redistributions of source code must retain the copyright
85 * notice, this list of conditions and the following disclaimer.
86 * 2. Redistributions in binary form must reproduce the above copyright
87 * notice, this list of conditions and the following disclaimer in the
88 * documentation and/or other materials provided with the distribution.
89 * 3. All advertising materials mentioning features or use of this software
90 * must display the following acknowledgement:
91 * "This product includes cryptographic software written by
92 * Eric Young (eay@cryptsoft.com)"
93 * The word 'cryptographic' can be left out if the rouines from the library
94 * being used are not cryptographic related :-).
95 * 4. If you include any Windows specific code (or a derivative thereof) from
96 * the apps directory (application code) you must include an acknowledgement:
97 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
98 *
99 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
100 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
101 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
102 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
103 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
104 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
105 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
106 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
107 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
108 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
109 * SUCH DAMAGE.
110 *
111 * The licence and distribution terms for any publically available version or
112 * derivative of this code cannot be changed. i.e. this code cannot simply be
113 * copied and put under another distribution licence
114 * [including the GNU Public Licence.]
115 */
116
117
118#include <openssl/e_os2.h>
119
120#if !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VMS)
121# ifdef OPENSSL_UNISTD
122# include OPENSSL_UNISTD
123# else
124# include <unistd.h>
125# endif
126/* If unistd.h defines _POSIX_VERSION, we conclude that we
127 * are on a POSIX system and have sigaction and termios. */
128# if defined(_POSIX_VERSION)
129
130# define SIGACTION
131# if !defined(TERMIOS) && !defined(TERMIO) && !defined(SGTTY)
132# define TERMIOS
133# endif
134
135# endif
136#endif
137
138#ifdef WIN16TTY
139# undef OPENSSL_SYS_WIN16
140# undef WIN16
141# undef _WINDOWS
142# include <graph.h>
143#endif
144
145/* 06-Apr-92 Luke Brennan Support for VMS */
146#include "ui_locl.h"
147#include "cryptlib.h"
148#include <signal.h>
149#include <stdio.h>
150#include <string.h>
151#include <errno.h>
152
153#ifdef OPENSSL_SYS_VMS /* prototypes for sys$whatever */
154# include <starlet.h>
155# ifdef __DECC
156# pragma message disable DOLLARID
157# endif
158#endif
159
160#ifdef WIN_CONSOLE_BUG
161# include <windows.h>
162# include <wincon.h>
163#endif
164
165
166/* There are 5 types of terminal interface supported,
167 * TERMIO, TERMIOS, VMS, MSDOS and SGTTY
168 */
169
170#if defined(__sgi) && !defined(TERMIOS)
171# define TERMIOS
172# undef TERMIO
173# undef SGTTY
174#endif
175
176#if defined(linux) && !defined(TERMIO)
177# undef TERMIOS
178# define TERMIO
179# undef SGTTY
180#endif
181
182#ifdef _LIBC
183# undef TERMIOS
184# define TERMIO
185# undef SGTTY
186#endif
187
188#if !defined(TERMIO) && !defined(TERMIOS) && !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_MACINTOSH_CLASSIC) && !defined(MAC_OS_GUSI_SOURCE)
189# undef TERMIOS
190# undef TERMIO
191# define SGTTY
192#endif
193
194#if defined(OPENSSL_SYS_VSWORKS)
195#undef TERMIOS
196#undef TERMIO
197#undef SGTTY
198#endif
199
200#ifdef TERMIOS
201# include <termios.h>
202# define TTY_STRUCT struct termios
203# define TTY_FLAGS c_lflag
204# define TTY_get(tty,data) tcgetattr(tty,data)
205# define TTY_set(tty,data) tcsetattr(tty,TCSANOW,data)
206#endif
207
208#ifdef TERMIO
209# include <termio.h>
210# define TTY_STRUCT struct termio
211# define TTY_FLAGS c_lflag
212# define TTY_get(tty,data) ioctl(tty,TCGETA,data)
213# define TTY_set(tty,data) ioctl(tty,TCSETA,data)
214#endif
215
216#ifdef SGTTY
217# include <sgtty.h>
218# define TTY_STRUCT struct sgttyb
219# define TTY_FLAGS sg_flags
220# define TTY_get(tty,data) ioctl(tty,TIOCGETP,data)
221# define TTY_set(tty,data) ioctl(tty,TIOCSETP,data)
222#endif
223
224#if !defined(_LIBC) && !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_MACINTOSH_CLASSIC)
225# include <sys/ioctl.h>
226#endif
227
228#ifdef OPENSSL_SYS_MSDOS
229# include <conio.h>
230#endif
231
232#ifdef OPENSSL_SYS_VMS
233# include <ssdef.h>
234# include <iodef.h>
235# include <ttdef.h>
236# include <descrip.h>
237struct IOSB {
238 short iosb$w_value;
239 short iosb$w_count;
240 long iosb$l_info;
241 };
242#endif
243
244#if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) || defined(MAC_OS_GUSI_SOURCE)
245/*
246 * This one needs work. As a matter of fact the code is unoperational
247 * and this is only a trick to get it compiled.
248 * <appro@fy.chalmers.se>
249 */
250# define TTY_STRUCT int
251#endif
252
253#ifndef NX509_SIG
254# define NX509_SIG 32
255#endif
256
257
258/* Define globals. They are protected by a lock */
259#ifdef SIGACTION
260static struct sigaction savsig[NX509_SIG];
261#else
262static void (*savsig[NX509_SIG])(int );
263#endif
264
265#ifdef OPENSSL_SYS_VMS
266static struct IOSB iosb;
267static $DESCRIPTOR(terminal,"TT");
268static long tty_orig[3], tty_new[3]; /* XXX Is there any guarantee that this will always suffice for the actual structures? */
269static long status;
270static unsigned short channel = 0;
271#else
272#ifndef OPENSSL_SYS_MSDOS
273static TTY_STRUCT tty_orig,tty_new;
274#endif
275#endif
276static FILE *tty_in, *tty_out;
277static int is_a_tty;
278
279/* Declare static functions */
280static void read_till_nl(FILE *);
281static void recsig(int);
282static void pushsig(void);
283static void popsig(void);
284#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN16)
285static int noecho_fgets(char *buf, int size, FILE *tty);
286#endif
287static int read_string_inner(UI *ui, UI_STRING *uis, int echo, int strip_nl);
288
289static int read_string(UI *ui, UI_STRING *uis);
290static int write_string(UI *ui, UI_STRING *uis);
291
292static int open_console(UI *ui);
293static int echo_console(UI *ui);
294static int noecho_console(UI *ui);
295static int close_console(UI *ui);
296
297static UI_METHOD ui_openssl =
298 {
299 "OpenSSL default user interface",
300 open_console,
301 write_string,
302 NULL, /* No flusher is needed for command lines */
303 read_string,
304 close_console,
305 NULL
306 };
307
308/* The method with all the built-in thingies */
309UI_METHOD *UI_OpenSSL(void)
310 {
311 return &ui_openssl;
312 }
313
314/* The following function makes sure that info and error strings are printed
315 before any prompt. */
316static int write_string(UI *ui, UI_STRING *uis)
317 {
318 switch (UI_get_string_type(uis))
319 {
320 case UIT_ERROR:
321 case UIT_INFO:
322 fputs(UI_get0_output_string(uis), tty_out);
323 fflush(tty_out);
324 break;
325 default:
326 break;
327 }
328 return 1;
329 }
330
331static int read_string(UI *ui, UI_STRING *uis)
332 {
333 int ok = 0;
334
335 switch (UI_get_string_type(uis))
336 {
337 case UIT_BOOLEAN:
338 fputs(UI_get0_output_string(uis), tty_out);
339 fputs(UI_get0_action_string(uis), tty_out);
340 fflush(tty_out);
341 return read_string_inner(ui, uis,
342 UI_get_input_flags(uis) & UI_INPUT_FLAG_ECHO, 0);
343 case UIT_PROMPT:
344 fputs(UI_get0_output_string(uis), tty_out);
345 fflush(tty_out);
346 return read_string_inner(ui, uis,
347 UI_get_input_flags(uis) & UI_INPUT_FLAG_ECHO, 1);
348 case UIT_VERIFY:
349 fprintf(tty_out,"Verifying - %s",
350 UI_get0_output_string(uis));
351 fflush(tty_out);
352 if ((ok = read_string_inner(ui, uis,
353 UI_get_input_flags(uis) & UI_INPUT_FLAG_ECHO, 1)) <= 0)
354 return ok;
355 if (strcmp(UI_get0_result_string(uis),
356 UI_get0_test_string(uis)) != 0)
357 {
358 fprintf(tty_out,"Verify failure\n");
359 fflush(tty_out);
360 return 0;
361 }
362 break;
363 default:
364 break;
365 }
366 return 1;
367 }
368
369
370/* Internal functions to read a string without echoing */
371static void read_till_nl(FILE *in)
372 {
373#define SIZE 4
374 char buf[SIZE+1];
375
376 do {
377 fgets(buf,SIZE,in);
378 } while (strchr(buf,'\n') == NULL);
379 }
380
381static sig_atomic_t intr_signal;
382
383static int read_string_inner(UI *ui, UI_STRING *uis, int echo, int strip_nl)
384 {
385 static int ps;
386 int ok;
387 char result[BUFSIZ];
388 int maxsize = BUFSIZ-1;
389 char *p;
390
391#ifndef OPENSSL_SYS_WIN16
392 intr_signal=0;
393 ok=0;
394 ps=0;
395
396 pushsig();
397 ps=1;
398
399 if (!echo && !noecho_console(ui))
400 goto error;
401 ps=2;
402
403 result[0]='\0';
404#ifdef OPENSSL_SYS_MSDOS
405 if (!echo)
406 {
407 noecho_fgets(result,maxsize,tty_in);
408 p=result; /* FIXME: noecho_fgets doesn't return errors */
409 }
410 else
411 p=fgets(result,maxsize,tty_in);
412#else
413 p=fgets(result,maxsize,tty_in);
414#endif
415 if(!p)
416 goto error;
417 if (feof(tty_in)) goto error;
418 if (ferror(tty_in)) goto error;
419 if ((p=(char *)strchr(result,'\n')) != NULL)
420 {
421 if (strip_nl)
422 *p='\0';
423 }
424 else
425 read_till_nl(tty_in);
426 if (UI_set_result(ui, uis, result) >= 0)
427 ok=1;
428
429error:
430 if (intr_signal == SIGINT)
431 ok=-1;
432 if (!echo) fprintf(tty_out,"\n");
433 if (ps >= 2 && !echo && !echo_console(ui))
434 ok=0;
435
436 if (ps >= 1)
437 popsig();
438#else
439 ok=1;
440#endif
441
442 memset(result,0,BUFSIZ);
443 return ok;
444 }
445
446
447/* Internal functions to open, handle and close a channel to the console. */
448static int open_console(UI *ui)
449 {
450 CRYPTO_w_lock(CRYPTO_LOCK_UI);
451 is_a_tty = 1;
452
453#if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) || defined(OPENSSL_SYS_VSWORKS)
454 tty_in=stdin;
455 tty_out=stderr;
456#else
457# ifdef OPENSSL_SYS_MSDOS
458# define DEV_TTY "con"
459# else
460# define DEV_TTY "/dev/tty"
461# endif
462 if ((tty_in=fopen(DEV_TTY,"r")) == NULL)
463 tty_in=stdin;
464 if ((tty_out=fopen(DEV_TTY,"w")) == NULL)
465 tty_out=stderr;
466#endif
467
468#if defined(TTY_get) && !defined(VMS)
469 if (TTY_get(fileno(tty_in),&tty_orig) == -1)
470 {
471#ifdef ENOTTY
472 if (errno == ENOTTY)
473 is_a_tty=0;
474 else
475#endif
476#ifdef EINVAL
477 /* Ariel Glenn ariel@columbia.edu reports that solaris
478 * can return EINVAL instead. This should be ok */
479 if (errno == EINVAL)
480 is_a_tty=0;
481 else
482#endif
483 return 0;
484 }
485#endif
486#ifdef OPENSSL_SYS_VMS
487 status = sys$assign(&terminal,&channel,0,0);
488 if (status != SS$_NORMAL)
489 return 0;
490 status=sys$qiow(0,channel,IO$_SENSEMODE,&iosb,0,0,tty_orig,12,0,0,0,0);
491 if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL))
492 return 0;
493#endif
494 return 1;
495 }
496
497static int noecho_console(UI *ui)
498 {
499#ifdef TTY_FLAGS
500 memcpy(&(tty_new),&(tty_orig),sizeof(tty_orig));
501 tty_new.TTY_FLAGS &= ~ECHO;
502#endif
503
504#if defined(TTY_set) && !defined(OPENSSL_SYS_VMS)
505 if (is_a_tty && (TTY_set(fileno(tty_in),&tty_new) == -1))
506 return 0;
507#endif
508#ifdef OPENSSL_SYS_VMS
509 tty_new[0] = tty_orig[0];
510 tty_new[1] = tty_orig[1] | TT$M_NOECHO;
511 tty_new[2] = tty_orig[2];
512 status = sys$qiow(0,channel,IO$_SETMODE,&iosb,0,0,tty_new,12,0,0,0,0);
513 if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL))
514 return 0;
515#endif
516 return 1;
517 }
518
519static int echo_console(UI *ui)
520 {
521#if defined(TTY_set) && !defined(OPENSSL_SYS_VMS)
522 memcpy(&(tty_new),&(tty_orig),sizeof(tty_orig));
523 tty_new.TTY_FLAGS |= ECHO;
524#endif
525
526#if defined(TTY_set) && !defined(OPENSSL_SYS_VMS)
527 if (is_a_tty && (TTY_set(fileno(tty_in),&tty_new) == -1))
528 return 0;
529#endif
530#ifdef OPENSSL_SYS_VMS
531 tty_new[0] = tty_orig[0];
532 tty_new[1] = tty_orig[1] & ~TT$M_NOECHO;
533 tty_new[2] = tty_orig[2];
534 status = sys$qiow(0,channel,IO$_SETMODE,&iosb,0,0,tty_new,12,0,0,0,0);
535 if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL))
536 return 0;
537#endif
538 return 1;
539 }
540
541static int close_console(UI *ui)
542 {
543 if (tty_in != stderr) fclose(tty_in);
544 if (tty_out != stderr) fclose(tty_out);
545#ifdef OPENSSL_SYS_VMS
546 status = sys$dassgn(channel);
547#endif
548 CRYPTO_w_unlock(CRYPTO_LOCK_UI);
549
550 return 1;
551 }
552
553
554/* Internal functions to handle signals and act on them */
555static void pushsig(void)
556 {
557 int i;
558#ifdef SIGACTION
559 struct sigaction sa;
560
561 memset(&sa,0,sizeof sa);
562 sa.sa_handler=recsig;
563#endif
564
565 for (i=1; i<NX509_SIG; i++)
566 {
567#ifdef SIGUSR1
568 if (i == SIGUSR1)
569 continue;
570#endif
571#ifdef SIGUSR2
572 if (i == SIGUSR2)
573 continue;
574#endif
575#ifdef SIGKILL
576 if (i == SIGKILL) /* We can't make any action on that. */
577 continue;
578#endif
579#ifdef SIGACTION
580 sigaction(i,&sa,&savsig[i]);
581#else
582 savsig[i]=signal(i,recsig);
583#endif
584 }
585
586#ifdef SIGWINCH
587 signal(SIGWINCH,SIG_DFL);
588#endif
589 }
590
591static void popsig(void)
592 {
593 int i;
594
595 for (i=1; i<NX509_SIG; i++)
596 {
597#ifdef SIGUSR1
598 if (i == SIGUSR1)
599 continue;
600#endif
601#ifdef SIGUSR2
602 if (i == SIGUSR2)
603 continue;
604#endif
605#ifdef SIGACTION
606 sigaction(i,&savsig[i],NULL);
607#else
608 signal(i,savsig[i]);
609#endif
610 }
611 }
612
613static void recsig(int i)
614 {
615 intr_signal=i;
616 }
617
618/* Internal functions specific for Windows */
619#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN16)
620static int noecho_fgets(char *buf, int size, FILE *tty)
621 {
622 int i;
623 char *p;
624
625 p=buf;
626 for (;;)
627 {
628 if (size == 0)
629 {
630 *p='\0';
631 break;
632 }
633 size--;
634#ifdef WIN16TTY
635 i=_inchar();
636#else
637 i=getch();
638#endif
639 if (i == '\r') i='\n';
640 *(p++)=i;
641 if (i == '\n')
642 {
643 *p='\0';
644 break;
645 }
646 }
647#ifdef WIN_CONSOLE_BUG
648/* Win95 has several evil console bugs: one of these is that the
649 * last character read using getch() is passed to the next read: this is
650 * usually a CR so this can be trouble. No STDIO fix seems to work but
651 * flushing the console appears to do the trick.
652 */
653 {
654 HANDLE inh;
655 inh = GetStdHandle(STD_INPUT_HANDLE);
656 FlushConsoleInputBuffer(inh);
657 }
658#endif
659 return(strlen(buf));
660 }
661#endif
diff --git a/src/lib/libcrypto/ui/ui_util.c b/src/lib/libcrypto/ui/ui_util.c
new file mode 100644
index 0000000000..7c6f7d3a73
--- /dev/null
+++ b/src/lib/libcrypto/ui/ui_util.c
@@ -0,0 +1,86 @@
1/* crypto/ui/ui_util.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.h>
58
59int UI_UTIL_read_pw_string(char *buf,int length,const char *prompt,int verify)
60 {
61 char buff[BUFSIZ];
62 int ret;
63
64 ret=UI_UTIL_read_pw(buf,buff,(length>BUFSIZ)?BUFSIZ:length,prompt,verify);
65 memset(buff,0,BUFSIZ);
66 return(ret);
67 }
68
69int UI_UTIL_read_pw(char *buf,char *buff,int size,const char *prompt,int verify)
70 {
71 int ok = 0;
72 UI *ui;
73
74 ui = UI_new();
75 if (ui)
76 {
77 ok = UI_add_input_string(ui,prompt,0,buf,0,BUFSIZ-1);
78 if (ok == 0 && verify)
79 ok = UI_add_verify_string(ui,prompt,0,buff,0,BUFSIZ-1,
80 buf);
81 if (ok == 0)
82 ok=UI_process(ui);
83 UI_free(ui);
84 }
85 return(ok);
86 }
diff --git a/src/lib/libcrypto/uid.c b/src/lib/libcrypto/uid.c
index b5b61b76d4..d3d249c36f 100644
--- a/src/lib/libcrypto/uid.c
+++ b/src/lib/libcrypto/uid.c
@@ -54,17 +54,18 @@
54 */ 54 */
55 55
56#include <openssl/crypto.h> 56#include <openssl/crypto.h>
57#include <openssl/opensslconf.h>
57 58
58#if defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD__ > 2) 59#if defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD__ > 2)
59 60
60#include <unistd.h> 61#include OPENSSL_UNISTD
61 62
62int OPENSSL_issetugid(void) 63int OPENSSL_issetugid(void)
63 { 64 {
64 return issetugid(); 65 return issetugid();
65 } 66 }
66 67
67#elif defined(WIN32) 68#elif defined(OPENSSL_SYS_WIN32)
68 69
69int OPENSSL_issetugid(void) 70int OPENSSL_issetugid(void)
70 { 71 {
@@ -73,7 +74,7 @@ int OPENSSL_issetugid(void)
73 74
74#else 75#else
75 76
76#include <unistd.h> 77#include OPENSSL_UNISTD
77#include <sys/types.h> 78#include <sys/types.h>
78 79
79int OPENSSL_issetugid(void) 80int OPENSSL_issetugid(void)
diff --git a/src/lib/libcrypto/util/clean-depend.pl b/src/lib/libcrypto/util/clean-depend.pl
index 0193e726fe..6c485d1e2f 100644
--- a/src/lib/libcrypto/util/clean-depend.pl
+++ b/src/lib/libcrypto/util/clean-depend.pl
@@ -11,20 +11,36 @@ while(<STDIN>) {
11 11
12my %files; 12my %files;
13 13
14my $thisfile="";
14while(<STDIN>) { 15while(<STDIN>) {
15 my ($file,$deps)=/^(.*): (.*)$/; 16 my ($dummy, $file,$deps)=/^((.*):)? (.*)$/;
17 my $origfile="";
18 $thisfile=$file if defined $file;
16 next if !defined $deps; 19 next if !defined $deps;
20 $origfile=$thisfile;
21 $origfile=~s/\.o$/.c/;
17 my @deps=split ' ',$deps; 22 my @deps=split ' ',$deps;
18 @deps=grep(!/^\//,@deps); 23 @deps=grep(!/^\//,@deps);
19 @deps=grep(!/^\\$/,@deps); 24 @deps=grep(!/^\\$/,@deps);
20 push @{$files{$file}},@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;
21} 29}
22 30
23my $file; 31my $file;
24foreach $file (sort keys %files) { 32foreach $file (sort keys %files) {
25 my $len=0; 33 my $len=0;
26 my $dep; 34 my $dep;
35 my $origfile=$file;
36 $origfile=~s/\.o$/.c/;
37 $file=~s/^\.\///;
38 push @{$files{$file}},$origfile;
39 my $prevdep="";
27 foreach $dep (sort @{$files{$file}}) { 40 foreach $dep (sort @{$files{$file}}) {
41 $dep=~s/^\.\///;
42 next if $prevdep eq $dep; # to exterminate duplicates...
43 $prevdep = $dep;
28 $len=0 if $len+length($dep)+1 >= 80; 44 $len=0 if $len+length($dep)+1 >= 80;
29 if($len == 0) { 45 if($len == 0) {
30 print "\n$file:"; 46 print "\n$file:";
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/domd b/src/lib/libcrypto/util/domd
index 9f75131f22..aa99cb0523 100644
--- a/src/lib/libcrypto/util/domd
+++ b/src/lib/libcrypto/util/domd
@@ -4,8 +4,26 @@
4 4
5TOP=$1 5TOP=$1
6shift 6shift
7if [ "$1" = "-MD" ]; then
8 shift
9 MAKEDEPEND=$1
10 shift
11fi
12if [ "$MAKEDEPEND" = "" ]; then MAKEDEPEND=makedepend; fi
7 13
8cp Makefile.ssl Makefile.save 14cp Makefile.ssl Makefile.save
9makedepend -f Makefile.ssl $@ 15# fake the presence of Kerberos
10perl $TOP/util/clean-depend.pl < Makefile.ssl > Makefile.new 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
11mv Makefile.new Makefile.ssl 27mv Makefile.new Makefile.ssl
28# unfake the presence of Kerberos
29rm $TOP/krb5.h
diff --git a/src/lib/libcrypto/util/libeay.num b/src/lib/libcrypto/util/libeay.num
index 84ae840804..b74749e5de 100644
--- a/src/lib/libcrypto/util/libeay.num
+++ b/src/lib/libcrypto/util/libeay.num
@@ -15,28 +15,28 @@ ASN1_STRING_cmp 14 EXIST::FUNCTION:
15ASN1_STRING_dup 15 EXIST::FUNCTION: 15ASN1_STRING_dup 15 EXIST::FUNCTION:
16ASN1_STRING_free 16 EXIST::FUNCTION: 16ASN1_STRING_free 16 EXIST::FUNCTION:
17ASN1_STRING_new 17 EXIST::FUNCTION: 17ASN1_STRING_new 17 EXIST::FUNCTION:
18ASN1_STRING_print 18 EXIST::FUNCTION: 18ASN1_STRING_print 18 EXIST::FUNCTION:BIO
19ASN1_STRING_set 19 EXIST::FUNCTION: 19ASN1_STRING_set 19 EXIST::FUNCTION:
20ASN1_STRING_type_new 20 EXIST::FUNCTION: 20ASN1_STRING_type_new 20 EXIST::FUNCTION:
21ASN1_TYPE_free 21 EXIST::FUNCTION: 21ASN1_TYPE_free 21 EXIST::FUNCTION:
22ASN1_TYPE_new 22 EXIST::FUNCTION: 22ASN1_TYPE_new 22 EXIST::FUNCTION:
23ASN1_UNIVERSALSTRING_to_string 23 EXIST::FUNCTION: 23ASN1_UNIVERSALSTRING_to_string 23 EXIST::FUNCTION:
24ASN1_UTCTIME_check 24 EXIST::FUNCTION: 24ASN1_UTCTIME_check 24 EXIST::FUNCTION:
25ASN1_UTCTIME_print 25 EXIST::FUNCTION: 25ASN1_UTCTIME_print 25 EXIST::FUNCTION:BIO
26ASN1_UTCTIME_set 26 EXIST::FUNCTION: 26ASN1_UTCTIME_set 26 EXIST::FUNCTION:
27ASN1_check_infinite_end 27 EXIST::FUNCTION: 27ASN1_check_infinite_end 27 EXIST::FUNCTION:
28ASN1_d2i_bio 28 EXIST::FUNCTION: 28ASN1_d2i_bio 28 EXIST::FUNCTION:BIO
29ASN1_d2i_fp 29 EXIST::FUNCTION:FP_API 29ASN1_d2i_fp 29 EXIST::FUNCTION:FP_API
30ASN1_digest 30 EXIST::FUNCTION: 30ASN1_digest 30 EXIST::FUNCTION:EVP
31ASN1_dup 31 EXIST::FUNCTION: 31ASN1_dup 31 EXIST::FUNCTION:
32ASN1_get_object 32 EXIST::FUNCTION: 32ASN1_get_object 32 EXIST::FUNCTION:
33ASN1_i2d_bio 33 EXIST::FUNCTION: 33ASN1_i2d_bio 33 EXIST::FUNCTION:BIO
34ASN1_i2d_fp 34 EXIST::FUNCTION:FP_API 34ASN1_i2d_fp 34 EXIST::FUNCTION:FP_API
35ASN1_object_size 35 EXIST::FUNCTION: 35ASN1_object_size 35 EXIST::FUNCTION:
36ASN1_parse 36 EXIST::FUNCTION: 36ASN1_parse 36 EXIST::FUNCTION:BIO
37ASN1_put_object 37 EXIST::FUNCTION: 37ASN1_put_object 37 EXIST::FUNCTION:
38ASN1_sign 38 EXIST::FUNCTION: 38ASN1_sign 38 EXIST::FUNCTION:EVP
39ASN1_verify 39 EXIST::FUNCTION: 39ASN1_verify 39 EXIST::FUNCTION:EVP
40BF_cbc_encrypt 40 EXIST::FUNCTION:BF 40BF_cbc_encrypt 40 EXIST::FUNCTION:BF
41BF_cfb64_encrypt 41 EXIST::FUNCTION:BF 41BF_cfb64_encrypt 41 EXIST::FUNCTION:BF
42BF_ecb_encrypt 42 EXIST::FUNCTION:BF 42BF_ecb_encrypt 42 EXIST::FUNCTION:BF
@@ -52,10 +52,10 @@ BIO_int_ctrl 53 EXIST::FUNCTION:
52BIO_debug_callback 54 EXIST::FUNCTION: 52BIO_debug_callback 54 EXIST::FUNCTION:
53BIO_dump 55 EXIST::FUNCTION: 53BIO_dump 55 EXIST::FUNCTION:
54BIO_dup_chain 56 EXIST::FUNCTION: 54BIO_dup_chain 56 EXIST::FUNCTION:
55BIO_f_base64 57 EXIST::FUNCTION: 55BIO_f_base64 57 EXIST::FUNCTION:BIO
56BIO_f_buffer 58 EXIST::FUNCTION: 56BIO_f_buffer 58 EXIST::FUNCTION:
57BIO_f_cipher 59 EXIST::FUNCTION: 57BIO_f_cipher 59 EXIST::FUNCTION:BIO
58BIO_f_md 60 EXIST::FUNCTION: 58BIO_f_md 60 EXIST::FUNCTION:BIO
59BIO_f_null 61 EXIST::FUNCTION: 59BIO_f_null 61 EXIST::FUNCTION:
60BIO_f_proxy_server 62 NOEXIST::FUNCTION: 60BIO_f_proxy_server 62 NOEXIST::FUNCTION:
61BIO_fd_non_fatal_error 63 EXIST::FUNCTION: 61BIO_fd_non_fatal_error 63 EXIST::FUNCTION:
@@ -92,7 +92,7 @@ BIO_s_null 96 EXIST::FUNCTION:
92BIO_s_proxy_client 97 NOEXIST::FUNCTION: 92BIO_s_proxy_client 97 NOEXIST::FUNCTION:
93BIO_s_socket 98 EXIST::FUNCTION: 93BIO_s_socket 98 EXIST::FUNCTION:
94BIO_set 100 EXIST::FUNCTION: 94BIO_set 100 EXIST::FUNCTION:
95BIO_set_cipher 101 EXIST::FUNCTION: 95BIO_set_cipher 101 EXIST::FUNCTION:BIO
96BIO_set_tcp_ndelay 102 EXIST::FUNCTION: 96BIO_set_tcp_ndelay 102 EXIST::FUNCTION:
97BIO_sock_cleanup 103 EXIST::FUNCTION: 97BIO_sock_cleanup 103 EXIST::FUNCTION:
98BIO_sock_error 104 EXIST::FUNCTION: 98BIO_sock_error 104 EXIST::FUNCTION:
@@ -130,7 +130,7 @@ BN_is_prime 135 EXIST::FUNCTION:
130BN_lshift 136 EXIST::FUNCTION: 130BN_lshift 136 EXIST::FUNCTION:
131BN_lshift1 137 EXIST::FUNCTION: 131BN_lshift1 137 EXIST::FUNCTION:
132BN_mask_bits 138 EXIST::FUNCTION: 132BN_mask_bits 138 EXIST::FUNCTION:
133BN_mod 139 EXIST::FUNCTION: 133BN_mod 139 NOEXIST::FUNCTION:
134BN_mod_exp 140 EXIST::FUNCTION: 134BN_mod_exp 140 EXIST::FUNCTION:
135BN_mod_exp_mont 141 EXIST::FUNCTION: 135BN_mod_exp_mont 141 EXIST::FUNCTION:
136BN_mod_exp_simple 143 EXIST::FUNCTION: 136BN_mod_exp_simple 143 EXIST::FUNCTION:
@@ -196,30 +196,30 @@ DH_generate_key 203 EXIST::FUNCTION:DH
196DH_generate_parameters 204 EXIST::FUNCTION:DH 196DH_generate_parameters 204 EXIST::FUNCTION:DH
197DH_new 205 EXIST::FUNCTION:DH 197DH_new 205 EXIST::FUNCTION:DH
198DH_size 206 EXIST::FUNCTION:DH 198DH_size 206 EXIST::FUNCTION:DH
199DHparams_print 207 EXIST::FUNCTION:DH 199DHparams_print 207 EXIST::FUNCTION:BIO,DH
200DHparams_print_fp 208 EXIST::FUNCTION:DH,FP_API 200DHparams_print_fp 208 EXIST::FUNCTION:DH,FP_API
201DSA_free 209 EXIST::FUNCTION:DSA 201DSA_free 209 EXIST::FUNCTION:DSA
202DSA_generate_key 210 EXIST::FUNCTION:DSA 202DSA_generate_key 210 EXIST::FUNCTION:DSA
203DSA_generate_parameters 211 EXIST::FUNCTION:DSA 203DSA_generate_parameters 211 EXIST::FUNCTION:DSA
204DSA_is_prime 212 NOEXIST::FUNCTION: 204DSA_is_prime 212 NOEXIST::FUNCTION:
205DSA_new 213 EXIST::FUNCTION:DSA 205DSA_new 213 EXIST::FUNCTION:DSA
206DSA_print 214 EXIST::FUNCTION:DSA 206DSA_print 214 EXIST::FUNCTION:BIO,DSA
207DSA_print_fp 215 EXIST::FUNCTION:DSA,FP_API 207DSA_print_fp 215 EXIST::FUNCTION:DSA,FP_API
208DSA_sign 216 EXIST::FUNCTION:DSA 208DSA_sign 216 EXIST::FUNCTION:DSA
209DSA_sign_setup 217 EXIST::FUNCTION:DSA 209DSA_sign_setup 217 EXIST::FUNCTION:DSA
210DSA_size 218 EXIST::FUNCTION:DSA 210DSA_size 218 EXIST::FUNCTION:DSA
211DSA_verify 219 EXIST::FUNCTION:DSA 211DSA_verify 219 EXIST::FUNCTION:DSA
212DSAparams_print 220 EXIST::FUNCTION:DSA 212DSAparams_print 220 EXIST::FUNCTION:BIO,DSA
213DSAparams_print_fp 221 EXIST::FUNCTION:DSA,FP_API 213DSAparams_print_fp 221 EXIST::FUNCTION:DSA,FP_API
214ERR_clear_error 222 EXIST::FUNCTION: 214ERR_clear_error 222 EXIST::FUNCTION:
215ERR_error_string 223 EXIST::FUNCTION: 215ERR_error_string 223 EXIST::FUNCTION:
216ERR_free_strings 224 EXIST::FUNCTION: 216ERR_free_strings 224 EXIST::FUNCTION:
217ERR_func_error_string 225 EXIST::FUNCTION: 217ERR_func_error_string 225 EXIST::FUNCTION:
218ERR_get_err_state_table 226 EXIST::FUNCTION: 218ERR_get_err_state_table 226 EXIST::FUNCTION:LHASH
219ERR_get_error 227 EXIST::FUNCTION: 219ERR_get_error 227 EXIST::FUNCTION:
220ERR_get_error_line 228 EXIST::FUNCTION: 220ERR_get_error_line 228 EXIST::FUNCTION:
221ERR_get_state 229 EXIST::FUNCTION: 221ERR_get_state 229 EXIST::FUNCTION:
222ERR_get_string_table 230 EXIST::FUNCTION: 222ERR_get_string_table 230 EXIST::FUNCTION:LHASH
223ERR_lib_error_string 231 EXIST::FUNCTION: 223ERR_lib_error_string 231 EXIST::FUNCTION:
224ERR_load_ASN1_strings 232 EXIST::FUNCTION: 224ERR_load_ASN1_strings 232 EXIST::FUNCTION:
225ERR_load_BIO_strings 233 EXIST::FUNCTION: 225ERR_load_BIO_strings 233 EXIST::FUNCTION:
@@ -239,7 +239,7 @@ ERR_load_crypto_strings 246 EXIST::FUNCTION:
239ERR_load_strings 247 EXIST::FUNCTION: 239ERR_load_strings 247 EXIST::FUNCTION:
240ERR_peek_error 248 EXIST::FUNCTION: 240ERR_peek_error 248 EXIST::FUNCTION:
241ERR_peek_error_line 249 EXIST::FUNCTION: 241ERR_peek_error_line 249 EXIST::FUNCTION:
242ERR_print_errors 250 EXIST::FUNCTION: 242ERR_print_errors 250 EXIST::FUNCTION:BIO
243ERR_print_errors_fp 251 EXIST::FUNCTION:FP_API 243ERR_print_errors_fp 251 EXIST::FUNCTION:FP_API
244ERR_put_error 252 EXIST::FUNCTION: 244ERR_put_error 252 EXIST::FUNCTION:
245ERR_reason_error_string 253 EXIST::FUNCTION: 245ERR_reason_error_string 253 EXIST::FUNCTION:
@@ -340,8 +340,8 @@ NETSCAPE_SPKAC_free 347 EXIST::FUNCTION:
340NETSCAPE_SPKAC_new 348 EXIST::FUNCTION: 340NETSCAPE_SPKAC_new 348 EXIST::FUNCTION:
341NETSCAPE_SPKI_free 349 EXIST::FUNCTION: 341NETSCAPE_SPKI_free 349 EXIST::FUNCTION:
342NETSCAPE_SPKI_new 350 EXIST::FUNCTION: 342NETSCAPE_SPKI_new 350 EXIST::FUNCTION:
343NETSCAPE_SPKI_sign 351 EXIST::FUNCTION: 343NETSCAPE_SPKI_sign 351 EXIST::FUNCTION:EVP
344NETSCAPE_SPKI_verify 352 EXIST::FUNCTION: 344NETSCAPE_SPKI_verify 352 EXIST::FUNCTION:EVP
345OBJ_add_object 353 EXIST::FUNCTION: 345OBJ_add_object 353 EXIST::FUNCTION:
346OBJ_bsearch 354 EXIST::FUNCTION: 346OBJ_bsearch 354 EXIST::FUNCTION:
347OBJ_cleanup 355 EXIST::FUNCTION: 347OBJ_cleanup 355 EXIST::FUNCTION:
@@ -357,9 +357,9 @@ OBJ_obj2nid 364 EXIST::FUNCTION:
357OBJ_sn2nid 365 EXIST::FUNCTION: 357OBJ_sn2nid 365 EXIST::FUNCTION:
358OBJ_txt2nid 366 EXIST::FUNCTION: 358OBJ_txt2nid 366 EXIST::FUNCTION:
359PEM_ASN1_read 367 EXIST:!WIN16:FUNCTION: 359PEM_ASN1_read 367 EXIST:!WIN16:FUNCTION:
360PEM_ASN1_read_bio 368 EXIST::FUNCTION: 360PEM_ASN1_read_bio 368 EXIST::FUNCTION:BIO
361PEM_ASN1_write 369 EXIST:!WIN16:FUNCTION: 361PEM_ASN1_write 369 EXIST:!WIN16:FUNCTION:
362PEM_ASN1_write_bio 370 EXIST::FUNCTION: 362PEM_ASN1_write_bio 370 EXIST::FUNCTION:BIO
363PEM_SealFinal 371 EXIST::FUNCTION:RSA 363PEM_SealFinal 371 EXIST::FUNCTION:RSA
364PEM_SealInit 372 EXIST::FUNCTION:RSA 364PEM_SealInit 372 EXIST::FUNCTION:RSA
365PEM_SealUpdate 373 EXIST::FUNCTION:RSA 365PEM_SealUpdate 373 EXIST::FUNCTION:RSA
@@ -367,8 +367,8 @@ PEM_SignFinal 374 EXIST::FUNCTION:
367PEM_SignInit 375 EXIST::FUNCTION: 367PEM_SignInit 375 EXIST::FUNCTION:
368PEM_SignUpdate 376 EXIST::FUNCTION: 368PEM_SignUpdate 376 EXIST::FUNCTION:
369PEM_X509_INFO_read 377 EXIST:!WIN16:FUNCTION: 369PEM_X509_INFO_read 377 EXIST:!WIN16:FUNCTION:
370PEM_X509_INFO_read_bio 378 EXIST::FUNCTION: 370PEM_X509_INFO_read_bio 378 EXIST::FUNCTION:BIO
371PEM_X509_INFO_write_bio 379 EXIST::FUNCTION: 371PEM_X509_INFO_write_bio 379 EXIST::FUNCTION:BIO
372PEM_dek_info 380 EXIST::FUNCTION: 372PEM_dek_info 380 EXIST::FUNCTION:
373PEM_do_header 381 EXIST::FUNCTION: 373PEM_do_header 381 EXIST::FUNCTION:
374PEM_get_EVP_CIPHER_INFO 382 EXIST::FUNCTION: 374PEM_get_EVP_CIPHER_INFO 382 EXIST::FUNCTION:
@@ -383,7 +383,7 @@ PEM_read_RSAPrivateKey 390 EXIST:!WIN16:FUNCTION:RSA
383PEM_read_X509 391 EXIST:!WIN16:FUNCTION: 383PEM_read_X509 391 EXIST:!WIN16:FUNCTION:
384PEM_read_X509_CRL 392 EXIST:!WIN16:FUNCTION: 384PEM_read_X509_CRL 392 EXIST:!WIN16:FUNCTION:
385PEM_read_X509_REQ 393 EXIST:!WIN16:FUNCTION: 385PEM_read_X509_REQ 393 EXIST:!WIN16:FUNCTION:
386PEM_read_bio 394 EXIST::FUNCTION: 386PEM_read_bio 394 EXIST::FUNCTION:BIO
387PEM_read_bio_DHparams 395 EXIST::FUNCTION:DH 387PEM_read_bio_DHparams 395 EXIST::FUNCTION:DH
388PEM_read_bio_DSAPrivateKey 396 EXIST::FUNCTION:DSA 388PEM_read_bio_DSAPrivateKey 396 EXIST::FUNCTION:DSA
389PEM_read_bio_DSAparams 397 EXIST::FUNCTION:DSA 389PEM_read_bio_DSAparams 397 EXIST::FUNCTION:DSA
@@ -403,7 +403,7 @@ PEM_write_RSAPrivateKey 410 EXIST:!WIN16:FUNCTION:RSA
403PEM_write_X509 411 EXIST:!WIN16:FUNCTION: 403PEM_write_X509 411 EXIST:!WIN16:FUNCTION:
404PEM_write_X509_CRL 412 EXIST:!WIN16:FUNCTION: 404PEM_write_X509_CRL 412 EXIST:!WIN16:FUNCTION:
405PEM_write_X509_REQ 413 EXIST:!WIN16:FUNCTION: 405PEM_write_X509_REQ 413 EXIST:!WIN16:FUNCTION:
406PEM_write_bio 414 EXIST::FUNCTION: 406PEM_write_bio 414 EXIST::FUNCTION:BIO
407PEM_write_bio_DHparams 415 EXIST::FUNCTION:DH 407PEM_write_bio_DHparams 415 EXIST::FUNCTION:DH
408PEM_write_bio_DSAPrivateKey 416 EXIST::FUNCTION:DSA 408PEM_write_bio_DSAPrivateKey 416 EXIST::FUNCTION:DSA
409PEM_write_bio_DSAparams 417 EXIST::FUNCTION:DSA 409PEM_write_bio_DSAparams 417 EXIST::FUNCTION:DSA
@@ -457,7 +457,7 @@ RAND_bytes 464 EXIST::FUNCTION:
457RAND_cleanup 465 EXIST::FUNCTION: 457RAND_cleanup 465 EXIST::FUNCTION:
458RAND_file_name 466 EXIST::FUNCTION: 458RAND_file_name 466 EXIST::FUNCTION:
459RAND_load_file 467 EXIST::FUNCTION: 459RAND_load_file 467 EXIST::FUNCTION:
460RAND_screen 468 EXIST::FUNCTION: 460RAND_screen 468 EXIST:WIN32:FUNCTION:
461RAND_seed 469 EXIST::FUNCTION: 461RAND_seed 469 EXIST::FUNCTION:
462RAND_write_file 470 EXIST::FUNCTION: 462RAND_write_file 470 EXIST::FUNCTION:
463RC2_cbc_encrypt 471 EXIST::FUNCTION:RC2 463RC2_cbc_encrypt 471 EXIST::FUNCTION:RC2
@@ -477,8 +477,8 @@ RSA_free 484 EXIST::FUNCTION:RSA
477RSA_generate_key 485 EXIST::FUNCTION:RSA 477RSA_generate_key 485 EXIST::FUNCTION:RSA
478RSA_new 486 EXIST::FUNCTION:RSA 478RSA_new 486 EXIST::FUNCTION:RSA
479RSA_new_method 487 EXIST::FUNCTION:RSA 479RSA_new_method 487 EXIST::FUNCTION:RSA
480RSA_print 488 EXIST::FUNCTION:RSA 480RSA_print 488 EXIST::FUNCTION:BIO,RSA
481RSA_print_fp 489 EXIST::FUNCTION:RSA,FP_API 481RSA_print_fp 489 EXIST::FUNCTION:FP_API,RSA
482RSA_private_decrypt 490 EXIST::FUNCTION:RSA 482RSA_private_decrypt 490 EXIST::FUNCTION:RSA
483RSA_private_encrypt 491 EXIST::FUNCTION:RSA 483RSA_private_encrypt 491 EXIST::FUNCTION:RSA
484RSA_public_decrypt 492 EXIST::FUNCTION:RSA 484RSA_public_decrypt 492 EXIST::FUNCTION:RSA
@@ -489,23 +489,23 @@ RSA_sign_ASN1_OCTET_STRING 496 EXIST::FUNCTION:RSA
489RSA_size 497 EXIST::FUNCTION:RSA 489RSA_size 497 EXIST::FUNCTION:RSA
490RSA_verify 498 EXIST::FUNCTION:RSA 490RSA_verify 498 EXIST::FUNCTION:RSA
491RSA_verify_ASN1_OCTET_STRING 499 EXIST::FUNCTION:RSA 491RSA_verify_ASN1_OCTET_STRING 499 EXIST::FUNCTION:RSA
492SHA 500 EXIST::FUNCTION:SHA 492SHA 500 EXIST::FUNCTION:SHA,SHA0
493SHA1 501 EXIST::FUNCTION:SHA 493SHA1 501 EXIST::FUNCTION:SHA,SHA1
494SHA1_Final 502 EXIST::FUNCTION:SHA 494SHA1_Final 502 EXIST::FUNCTION:SHA,SHA1
495SHA1_Init 503 EXIST::FUNCTION:SHA 495SHA1_Init 503 EXIST::FUNCTION:SHA,SHA1
496SHA1_Update 504 EXIST::FUNCTION:SHA 496SHA1_Update 504 EXIST::FUNCTION:SHA,SHA1
497SHA_Final 505 EXIST::FUNCTION:SHA 497SHA_Final 505 EXIST::FUNCTION:SHA,SHA0
498SHA_Init 506 EXIST::FUNCTION:SHA 498SHA_Init 506 EXIST::FUNCTION:SHA,SHA0
499SHA_Update 507 EXIST::FUNCTION:SHA 499SHA_Update 507 EXIST::FUNCTION:SHA,SHA0
500OpenSSL_add_all_algorithms 508 EXIST::FUNCTION: 500OpenSSL_add_all_algorithms 508 NOEXIST::FUNCTION:
501OpenSSL_add_all_ciphers 509 EXIST::FUNCTION: 501OpenSSL_add_all_ciphers 509 EXIST::FUNCTION:
502OpenSSL_add_all_digests 510 EXIST::FUNCTION: 502OpenSSL_add_all_digests 510 EXIST::FUNCTION:
503TXT_DB_create_index 511 EXIST::FUNCTION: 503TXT_DB_create_index 511 EXIST::FUNCTION:
504TXT_DB_free 512 EXIST::FUNCTION: 504TXT_DB_free 512 EXIST::FUNCTION:
505TXT_DB_get_by_index 513 EXIST::FUNCTION: 505TXT_DB_get_by_index 513 EXIST::FUNCTION:
506TXT_DB_insert 514 EXIST::FUNCTION: 506TXT_DB_insert 514 EXIST::FUNCTION:
507TXT_DB_read 515 EXIST::FUNCTION: 507TXT_DB_read 515 EXIST::FUNCTION:BIO
508TXT_DB_write 516 EXIST::FUNCTION: 508TXT_DB_write 516 EXIST::FUNCTION:BIO
509X509_ALGOR_free 517 EXIST::FUNCTION: 509X509_ALGOR_free 517 EXIST::FUNCTION:
510X509_ALGOR_new 518 EXIST::FUNCTION: 510X509_ALGOR_new 518 EXIST::FUNCTION:
511X509_ATTRIBUTE_free 519 EXIST::FUNCTION: 511X509_ATTRIBUTE_free 519 EXIST::FUNCTION:
@@ -525,8 +525,8 @@ X509_CRL_get_ext_by_OBJ 532 EXIST::FUNCTION:
525X509_CRL_get_ext_by_critical 533 EXIST::FUNCTION: 525X509_CRL_get_ext_by_critical 533 EXIST::FUNCTION:
526X509_CRL_get_ext_count 534 EXIST::FUNCTION: 526X509_CRL_get_ext_count 534 EXIST::FUNCTION:
527X509_CRL_new 535 EXIST::FUNCTION: 527X509_CRL_new 535 EXIST::FUNCTION:
528X509_CRL_sign 536 EXIST::FUNCTION: 528X509_CRL_sign 536 EXIST::FUNCTION:EVP
529X509_CRL_verify 537 EXIST::FUNCTION: 529X509_CRL_verify 537 EXIST::FUNCTION:EVP
530X509_EXTENSION_create_by_NID 538 EXIST::FUNCTION: 530X509_EXTENSION_create_by_NID 538 EXIST::FUNCTION:
531X509_EXTENSION_create_by_OBJ 539 EXIST::FUNCTION: 531X509_EXTENSION_create_by_OBJ 539 EXIST::FUNCTION:
532X509_EXTENSION_dup 540 EXIST::FUNCTION: 532X509_EXTENSION_dup 540 EXIST::FUNCTION:
@@ -538,8 +538,8 @@ X509_EXTENSION_new 545 EXIST::FUNCTION:
538X509_EXTENSION_set_critical 546 EXIST::FUNCTION: 538X509_EXTENSION_set_critical 546 EXIST::FUNCTION:
539X509_EXTENSION_set_data 547 EXIST::FUNCTION: 539X509_EXTENSION_set_data 547 EXIST::FUNCTION:
540X509_EXTENSION_set_object 548 EXIST::FUNCTION: 540X509_EXTENSION_set_object 548 EXIST::FUNCTION:
541X509_INFO_free 549 EXIST::FUNCTION: 541X509_INFO_free 549 EXIST::FUNCTION:EVP
542X509_INFO_new 550 EXIST::FUNCTION: 542X509_INFO_new 550 EXIST::FUNCTION:EVP
543X509_LOOKUP_by_alias 551 EXIST::FUNCTION: 543X509_LOOKUP_by_alias 551 EXIST::FUNCTION:
544X509_LOOKUP_by_fingerprint 552 EXIST::FUNCTION: 544X509_LOOKUP_by_fingerprint 552 EXIST::FUNCTION:
545X509_LOOKUP_by_issuer_serial 553 EXIST::FUNCTION: 545X509_LOOKUP_by_issuer_serial 553 EXIST::FUNCTION:
@@ -563,7 +563,7 @@ X509_NAME_ENTRY_set_object 570 EXIST::FUNCTION:
563X509_NAME_add_entry 571 EXIST::FUNCTION: 563X509_NAME_add_entry 571 EXIST::FUNCTION:
564X509_NAME_cmp 572 EXIST::FUNCTION: 564X509_NAME_cmp 572 EXIST::FUNCTION:
565X509_NAME_delete_entry 573 EXIST::FUNCTION: 565X509_NAME_delete_entry 573 EXIST::FUNCTION:
566X509_NAME_digest 574 EXIST::FUNCTION: 566X509_NAME_digest 574 EXIST::FUNCTION:EVP
567X509_NAME_dup 575 EXIST::FUNCTION: 567X509_NAME_dup 575 EXIST::FUNCTION:
568X509_NAME_entry_count 576 EXIST::FUNCTION: 568X509_NAME_entry_count 576 EXIST::FUNCTION:
569X509_NAME_free 577 EXIST::FUNCTION: 569X509_NAME_free 577 EXIST::FUNCTION:
@@ -574,8 +574,8 @@ X509_NAME_get_text_by_NID 581 EXIST::FUNCTION:
574X509_NAME_get_text_by_OBJ 582 EXIST::FUNCTION: 574X509_NAME_get_text_by_OBJ 582 EXIST::FUNCTION:
575X509_NAME_hash 583 EXIST::FUNCTION: 575X509_NAME_hash 583 EXIST::FUNCTION:
576X509_NAME_new 584 EXIST::FUNCTION: 576X509_NAME_new 584 EXIST::FUNCTION:
577X509_NAME_oneline 585 EXIST::FUNCTION: 577X509_NAME_oneline 585 EXIST::FUNCTION:EVP
578X509_NAME_print 586 EXIST::FUNCTION: 578X509_NAME_print 586 EXIST::FUNCTION:BIO
579X509_NAME_set 587 EXIST::FUNCTION: 579X509_NAME_set 587 EXIST::FUNCTION:
580X509_OBJECT_free_contents 588 EXIST::FUNCTION: 580X509_OBJECT_free_contents 588 EXIST::FUNCTION:
581X509_OBJECT_retrieve_by_subject 589 EXIST::FUNCTION: 581X509_OBJECT_retrieve_by_subject 589 EXIST::FUNCTION:
@@ -592,14 +592,14 @@ X509_REQ_dup 599 EXIST::FUNCTION:
592X509_REQ_free 600 EXIST::FUNCTION: 592X509_REQ_free 600 EXIST::FUNCTION:
593X509_REQ_get_pubkey 601 EXIST::FUNCTION: 593X509_REQ_get_pubkey 601 EXIST::FUNCTION:
594X509_REQ_new 602 EXIST::FUNCTION: 594X509_REQ_new 602 EXIST::FUNCTION:
595X509_REQ_print 603 EXIST::FUNCTION: 595X509_REQ_print 603 EXIST::FUNCTION:BIO
596X509_REQ_print_fp 604 EXIST::FUNCTION:FP_API 596X509_REQ_print_fp 604 EXIST::FUNCTION:FP_API
597X509_REQ_set_pubkey 605 EXIST::FUNCTION: 597X509_REQ_set_pubkey 605 EXIST::FUNCTION:
598X509_REQ_set_subject_name 606 EXIST::FUNCTION: 598X509_REQ_set_subject_name 606 EXIST::FUNCTION:
599X509_REQ_set_version 607 EXIST::FUNCTION: 599X509_REQ_set_version 607 EXIST::FUNCTION:
600X509_REQ_sign 608 EXIST::FUNCTION: 600X509_REQ_sign 608 EXIST::FUNCTION:EVP
601X509_REQ_to_X509 609 EXIST::FUNCTION: 601X509_REQ_to_X509 609 EXIST::FUNCTION:
602X509_REQ_verify 610 EXIST::FUNCTION: 602X509_REQ_verify 610 EXIST::FUNCTION:EVP
603X509_REVOKED_add_ext 611 EXIST::FUNCTION: 603X509_REVOKED_add_ext 611 EXIST::FUNCTION:
604X509_REVOKED_delete_ext 612 EXIST::FUNCTION: 604X509_REVOKED_delete_ext 612 EXIST::FUNCTION:
605X509_REVOKED_free 613 EXIST::FUNCTION: 605X509_REVOKED_free 613 EXIST::FUNCTION:
@@ -618,9 +618,9 @@ X509_STORE_add_cert 624 EXIST::FUNCTION:
618X509_STORE_add_lookup 625 EXIST::FUNCTION: 618X509_STORE_add_lookup 625 EXIST::FUNCTION:
619X509_STORE_free 626 EXIST::FUNCTION: 619X509_STORE_free 626 EXIST::FUNCTION:
620X509_STORE_get_by_subject 627 EXIST::FUNCTION: 620X509_STORE_get_by_subject 627 EXIST::FUNCTION:
621X509_STORE_load_locations 628 EXIST::FUNCTION: 621X509_STORE_load_locations 628 EXIST::FUNCTION:STDIO
622X509_STORE_new 629 EXIST::FUNCTION: 622X509_STORE_new 629 EXIST::FUNCTION:
623X509_STORE_set_default_paths 630 EXIST::FUNCTION: 623X509_STORE_set_default_paths 630 EXIST::FUNCTION:STDIO
624X509_VAL_free 631 EXIST::FUNCTION: 624X509_VAL_free 631 EXIST::FUNCTION:
625X509_VAL_new 632 EXIST::FUNCTION: 625X509_VAL_new 632 EXIST::FUNCTION:
626X509_add_ext 633 EXIST::FUNCTION: 626X509_add_ext 633 EXIST::FUNCTION:
@@ -629,7 +629,7 @@ X509_certificate_type 635 EXIST::FUNCTION:
629X509_check_private_key 636 EXIST::FUNCTION: 629X509_check_private_key 636 EXIST::FUNCTION:
630X509_cmp_current_time 637 EXIST::FUNCTION: 630X509_cmp_current_time 637 EXIST::FUNCTION:
631X509_delete_ext 638 EXIST::FUNCTION: 631X509_delete_ext 638 EXIST::FUNCTION:
632X509_digest 639 EXIST::FUNCTION: 632X509_digest 639 EXIST::FUNCTION:EVP
633X509_dup 640 EXIST::FUNCTION: 633X509_dup 640 EXIST::FUNCTION:
634X509_free 641 EXIST::FUNCTION: 634X509_free 641 EXIST::FUNCTION:
635X509_get_default_cert_area 642 EXIST::FUNCTION: 635X509_get_default_cert_area 642 EXIST::FUNCTION:
@@ -653,9 +653,9 @@ X509_issuer_and_serial_cmp 659 EXIST::FUNCTION:
653X509_issuer_and_serial_hash 660 EXIST::FUNCTION: 653X509_issuer_and_serial_hash 660 EXIST::FUNCTION:
654X509_issuer_name_cmp 661 EXIST::FUNCTION: 654X509_issuer_name_cmp 661 EXIST::FUNCTION:
655X509_issuer_name_hash 662 EXIST::FUNCTION: 655X509_issuer_name_hash 662 EXIST::FUNCTION:
656X509_load_cert_file 663 EXIST::FUNCTION: 656X509_load_cert_file 663 EXIST::FUNCTION:STDIO
657X509_new 664 EXIST::FUNCTION: 657X509_new 664 EXIST::FUNCTION:
658X509_print 665 EXIST::FUNCTION: 658X509_print 665 EXIST::FUNCTION:BIO
659X509_print_fp 666 EXIST::FUNCTION:FP_API 659X509_print_fp 666 EXIST::FUNCTION:FP_API
660X509_set_issuer_name 667 EXIST::FUNCTION: 660X509_set_issuer_name 667 EXIST::FUNCTION:
661X509_set_notAfter 668 EXIST::FUNCTION: 661X509_set_notAfter 668 EXIST::FUNCTION:
@@ -664,11 +664,11 @@ X509_set_pubkey 670 EXIST::FUNCTION:
664X509_set_serialNumber 671 EXIST::FUNCTION: 664X509_set_serialNumber 671 EXIST::FUNCTION:
665X509_set_subject_name 672 EXIST::FUNCTION: 665X509_set_subject_name 672 EXIST::FUNCTION:
666X509_set_version 673 EXIST::FUNCTION: 666X509_set_version 673 EXIST::FUNCTION:
667X509_sign 674 EXIST::FUNCTION: 667X509_sign 674 EXIST::FUNCTION:EVP
668X509_subject_name_cmp 675 EXIST::FUNCTION: 668X509_subject_name_cmp 675 EXIST::FUNCTION:
669X509_subject_name_hash 676 EXIST::FUNCTION: 669X509_subject_name_hash 676 EXIST::FUNCTION:
670X509_to_X509_REQ 677 EXIST::FUNCTION: 670X509_to_X509_REQ 677 EXIST::FUNCTION:
671X509_verify 678 EXIST::FUNCTION: 671X509_verify 678 EXIST::FUNCTION:EVP
672X509_verify_cert 679 EXIST::FUNCTION: 672X509_verify_cert 679 EXIST::FUNCTION:
673X509_verify_cert_error_string 680 EXIST::FUNCTION: 673X509_verify_cert_error_string 680 EXIST::FUNCTION:
674X509v3_add_ext 681 EXIST::FUNCTION: 674X509v3_add_ext 681 EXIST::FUNCTION:
@@ -690,8 +690,8 @@ X509v3_pack_type_by_OBJ 696 NOEXIST::FUNCTION:
690X509v3_unpack_string 697 NOEXIST::FUNCTION: 690X509v3_unpack_string 697 NOEXIST::FUNCTION:
691_des_crypt 698 NOEXIST::FUNCTION: 691_des_crypt 698 NOEXIST::FUNCTION:
692a2d_ASN1_OBJECT 699 EXIST::FUNCTION: 692a2d_ASN1_OBJECT 699 EXIST::FUNCTION:
693a2i_ASN1_INTEGER 700 EXIST::FUNCTION: 693a2i_ASN1_INTEGER 700 EXIST::FUNCTION:BIO
694a2i_ASN1_STRING 701 EXIST::FUNCTION: 694a2i_ASN1_STRING 701 EXIST::FUNCTION:BIO
695asn1_Finish 702 EXIST::FUNCTION: 695asn1_Finish 702 EXIST::FUNCTION:
696asn1_GetSequence 703 EXIST::FUNCTION: 696asn1_GetSequence 703 EXIST::FUNCTION:
697bn_div_words 704 EXIST::FUNCTION: 697bn_div_words 704 EXIST::FUNCTION:
@@ -701,7 +701,7 @@ bn_mul_words 707 EXIST::FUNCTION:
701BN_uadd 708 EXIST::FUNCTION: 701BN_uadd 708 EXIST::FUNCTION:
702BN_usub 709 EXIST::FUNCTION: 702BN_usub 709 EXIST::FUNCTION:
703bn_sqr_words 710 EXIST::FUNCTION: 703bn_sqr_words 710 EXIST::FUNCTION:
704crypt 711 EXIST:!PERL5,!NeXT,!__FreeBSD__:FUNCTION:DES 704_ossl_old_crypt 711 EXIST:!NeXT,!PERL5,!__FreeBSD__:FUNCTION:DES
705d2i_ASN1_BIT_STRING 712 EXIST::FUNCTION: 705d2i_ASN1_BIT_STRING 712 EXIST::FUNCTION:
706d2i_ASN1_BOOLEAN 713 EXIST::FUNCTION: 706d2i_ASN1_BOOLEAN 713 EXIST::FUNCTION:
707d2i_ASN1_HEADER 714 EXIST::FUNCTION: 707d2i_ASN1_HEADER 714 EXIST::FUNCTION:
@@ -719,7 +719,7 @@ d2i_ASN1_bytes 725 EXIST::FUNCTION:
719d2i_ASN1_type_bytes 726 EXIST::FUNCTION: 719d2i_ASN1_type_bytes 726 EXIST::FUNCTION:
720d2i_DHparams 727 EXIST::FUNCTION:DH 720d2i_DHparams 727 EXIST::FUNCTION:DH
721d2i_DSAPrivateKey 728 EXIST::FUNCTION:DSA 721d2i_DSAPrivateKey 728 EXIST::FUNCTION:DSA
722d2i_DSAPrivateKey_bio 729 EXIST::FUNCTION:DSA 722d2i_DSAPrivateKey_bio 729 EXIST::FUNCTION:BIO,DSA
723d2i_DSAPrivateKey_fp 730 EXIST::FUNCTION:DSA,FP_API 723d2i_DSAPrivateKey_fp 730 EXIST::FUNCTION:DSA,FP_API
724d2i_DSAPublicKey 731 EXIST::FUNCTION:DSA 724d2i_DSAPublicKey 731 EXIST::FUNCTION:DSA
725d2i_DSAparams 732 EXIST::FUNCTION:DSA 725d2i_DSAparams 732 EXIST::FUNCTION:DSA
@@ -741,8 +741,8 @@ d2i_PKCS7_fp 747 EXIST::FUNCTION:FP_API
741d2i_PrivateKey 748 EXIST::FUNCTION: 741d2i_PrivateKey 748 EXIST::FUNCTION:
742d2i_PublicKey 749 EXIST::FUNCTION: 742d2i_PublicKey 749 EXIST::FUNCTION:
743d2i_RSAPrivateKey 750 EXIST::FUNCTION:RSA 743d2i_RSAPrivateKey 750 EXIST::FUNCTION:RSA
744d2i_RSAPrivateKey_bio 751 EXIST::FUNCTION:RSA 744d2i_RSAPrivateKey_bio 751 EXIST::FUNCTION:BIO,RSA
745d2i_RSAPrivateKey_fp 752 EXIST::FUNCTION:RSA,FP_API 745d2i_RSAPrivateKey_fp 752 EXIST::FUNCTION:FP_API,RSA
746d2i_RSAPublicKey 753 EXIST::FUNCTION:RSA 746d2i_RSAPublicKey 753 EXIST::FUNCTION:RSA
747d2i_X509 754 EXIST::FUNCTION: 747d2i_X509 754 EXIST::FUNCTION:
748d2i_X509_ALGOR 755 EXIST::FUNCTION: 748d2i_X509_ALGOR 755 EXIST::FUNCTION:
@@ -750,7 +750,7 @@ d2i_X509_ATTRIBUTE 756 EXIST::FUNCTION:
750d2i_X509_CINF 757 EXIST::FUNCTION: 750d2i_X509_CINF 757 EXIST::FUNCTION:
751d2i_X509_CRL 758 EXIST::FUNCTION: 751d2i_X509_CRL 758 EXIST::FUNCTION:
752d2i_X509_CRL_INFO 759 EXIST::FUNCTION: 752d2i_X509_CRL_INFO 759 EXIST::FUNCTION:
753d2i_X509_CRL_bio 760 EXIST::FUNCTION: 753d2i_X509_CRL_bio 760 EXIST::FUNCTION:BIO
754d2i_X509_CRL_fp 761 EXIST::FUNCTION:FP_API 754d2i_X509_CRL_fp 761 EXIST::FUNCTION:FP_API
755d2i_X509_EXTENSION 762 EXIST::FUNCTION: 755d2i_X509_EXTENSION 762 EXIST::FUNCTION:
756d2i_X509_NAME 763 EXIST::FUNCTION: 756d2i_X509_NAME 763 EXIST::FUNCTION:
@@ -759,54 +759,54 @@ d2i_X509_PKEY 765 EXIST::FUNCTION:
759d2i_X509_PUBKEY 766 EXIST::FUNCTION: 759d2i_X509_PUBKEY 766 EXIST::FUNCTION:
760d2i_X509_REQ 767 EXIST::FUNCTION: 760d2i_X509_REQ 767 EXIST::FUNCTION:
761d2i_X509_REQ_INFO 768 EXIST::FUNCTION: 761d2i_X509_REQ_INFO 768 EXIST::FUNCTION:
762d2i_X509_REQ_bio 769 EXIST::FUNCTION: 762d2i_X509_REQ_bio 769 EXIST::FUNCTION:BIO
763d2i_X509_REQ_fp 770 EXIST::FUNCTION:FP_API 763d2i_X509_REQ_fp 770 EXIST::FUNCTION:FP_API
764d2i_X509_REVOKED 771 EXIST::FUNCTION: 764d2i_X509_REVOKED 771 EXIST::FUNCTION:
765d2i_X509_SIG 772 EXIST::FUNCTION: 765d2i_X509_SIG 772 EXIST::FUNCTION:
766d2i_X509_VAL 773 EXIST::FUNCTION: 766d2i_X509_VAL 773 EXIST::FUNCTION:
767d2i_X509_bio 774 EXIST::FUNCTION: 767d2i_X509_bio 774 EXIST::FUNCTION:BIO
768d2i_X509_fp 775 EXIST::FUNCTION:FP_API 768d2i_X509_fp 775 EXIST::FUNCTION:FP_API
769des_cbc_cksum 777 EXIST::FUNCTION:DES 769DES_cbc_cksum 777 EXIST::FUNCTION:DES
770des_cbc_encrypt 778 EXIST::FUNCTION:DES 770DES_cbc_encrypt 778 EXIST::FUNCTION:DES
771des_cblock_print_file 779 NOEXIST::FUNCTION: 771DES_cblock_print_file 779 NOEXIST::FUNCTION:
772des_cfb64_encrypt 780 EXIST::FUNCTION:DES 772DES_cfb64_encrypt 780 EXIST::FUNCTION:DES
773des_cfb_encrypt 781 EXIST::FUNCTION:DES 773DES_cfb_encrypt 781 EXIST::FUNCTION:DES
774des_decrypt3 782 EXIST::FUNCTION:DES 774DES_decrypt3 782 EXIST::FUNCTION:DES
775des_ecb3_encrypt 783 EXIST::FUNCTION:DES 775DES_ecb3_encrypt 783 EXIST::FUNCTION:DES
776des_ecb_encrypt 784 EXIST::FUNCTION:DES 776DES_ecb_encrypt 784 EXIST::FUNCTION:DES
777des_ede3_cbc_encrypt 785 EXIST::FUNCTION:DES 777DES_ede3_cbc_encrypt 785 EXIST::FUNCTION:DES
778des_ede3_cfb64_encrypt 786 EXIST::FUNCTION:DES 778DES_ede3_cfb64_encrypt 786 EXIST::FUNCTION:DES
779des_ede3_ofb64_encrypt 787 EXIST::FUNCTION:DES 779DES_ede3_ofb64_encrypt 787 EXIST::FUNCTION:DES
780des_enc_read 788 EXIST::FUNCTION:DES 780DES_enc_read 788 EXIST::FUNCTION:DES
781des_enc_write 789 EXIST::FUNCTION:DES 781DES_enc_write 789 EXIST::FUNCTION:DES
782des_encrypt1 790 EXIST::FUNCTION:DES 782DES_encrypt1 790 EXIST::FUNCTION:DES
783des_encrypt2 791 EXIST::FUNCTION:DES 783DES_encrypt2 791 EXIST::FUNCTION:DES
784des_encrypt3 792 EXIST::FUNCTION:DES 784DES_encrypt3 792 EXIST::FUNCTION:DES
785des_fcrypt 793 EXIST::FUNCTION:DES 785DES_fcrypt 793 EXIST::FUNCTION:DES
786des_is_weak_key 794 EXIST::FUNCTION:DES 786DES_is_weak_key 794 EXIST::FUNCTION:DES
787des_key_sched 795 EXIST::FUNCTION:DES 787DES_key_sched 795 EXIST::FUNCTION:DES
788des_ncbc_encrypt 796 EXIST::FUNCTION:DES 788DES_ncbc_encrypt 796 EXIST::FUNCTION:DES
789des_ofb64_encrypt 797 EXIST::FUNCTION:DES 789DES_ofb64_encrypt 797 EXIST::FUNCTION:DES
790des_ofb_encrypt 798 EXIST::FUNCTION:DES 790DES_ofb_encrypt 798 EXIST::FUNCTION:DES
791des_options 799 EXIST::FUNCTION:DES 791DES_options 799 EXIST::FUNCTION:DES
792des_pcbc_encrypt 800 EXIST::FUNCTION:DES 792DES_pcbc_encrypt 800 EXIST::FUNCTION:DES
793des_quad_cksum 801 EXIST::FUNCTION:DES 793DES_quad_cksum 801 EXIST::FUNCTION:DES
794des_random_key 802 EXIST::FUNCTION:DES 794DES_random_key 802 EXIST::FUNCTION:DES
795des_random_seed 803 EXIST::FUNCTION:DES 795_ossl_old_des_random_seed 803 EXIST::FUNCTION:DES
796des_read_2passwords 804 EXIST::FUNCTION:DES 796_ossl_old_des_read_2passwords 804 EXIST::FUNCTION:DES
797des_read_password 805 EXIST::FUNCTION:DES 797_ossl_old_des_read_password 805 EXIST::FUNCTION:DES
798des_read_pw 806 EXIST::FUNCTION:DES 798_ossl_old_des_read_pw 806 EXIST::FUNCTION:
799des_read_pw_string 807 EXIST::FUNCTION:DES 799_ossl_old_des_read_pw_string 807 EXIST::FUNCTION:
800des_set_key 808 EXIST::FUNCTION:DES 800DES_set_key 808 EXIST::FUNCTION:DES
801des_set_odd_parity 809 EXIST::FUNCTION:DES 801DES_set_odd_parity 809 EXIST::FUNCTION:DES
802des_string_to_2keys 810 EXIST::FUNCTION:DES 802DES_string_to_2keys 810 EXIST::FUNCTION:DES
803des_string_to_key 811 EXIST::FUNCTION:DES 803DES_string_to_key 811 EXIST::FUNCTION:DES
804des_xcbc_encrypt 812 EXIST::FUNCTION:DES 804DES_xcbc_encrypt 812 EXIST::FUNCTION:DES
805des_xwhite_in2out 813 EXIST::FUNCTION:DES 805DES_xwhite_in2out 813 EXIST::FUNCTION:DES
806fcrypt_body 814 NOEXIST::FUNCTION: 806fcrypt_body 814 NOEXIST::FUNCTION:
807i2a_ASN1_INTEGER 815 EXIST::FUNCTION: 807i2a_ASN1_INTEGER 815 EXIST::FUNCTION:BIO
808i2a_ASN1_OBJECT 816 EXIST::FUNCTION: 808i2a_ASN1_OBJECT 816 EXIST::FUNCTION:BIO
809i2a_ASN1_STRING 817 EXIST::FUNCTION: 809i2a_ASN1_STRING 817 EXIST::FUNCTION:BIO
810i2d_ASN1_BIT_STRING 818 EXIST::FUNCTION: 810i2d_ASN1_BIT_STRING 818 EXIST::FUNCTION:
811i2d_ASN1_BOOLEAN 819 EXIST::FUNCTION: 811i2d_ASN1_BOOLEAN 819 EXIST::FUNCTION:
812i2d_ASN1_HEADER 820 EXIST::FUNCTION: 812i2d_ASN1_HEADER 820 EXIST::FUNCTION:
@@ -821,7 +821,7 @@ i2d_ASN1_UTCTIME 828 EXIST::FUNCTION:
821i2d_ASN1_bytes 829 EXIST::FUNCTION: 821i2d_ASN1_bytes 829 EXIST::FUNCTION:
822i2d_DHparams 830 EXIST::FUNCTION:DH 822i2d_DHparams 830 EXIST::FUNCTION:DH
823i2d_DSAPrivateKey 831 EXIST::FUNCTION:DSA 823i2d_DSAPrivateKey 831 EXIST::FUNCTION:DSA
824i2d_DSAPrivateKey_bio 832 EXIST::FUNCTION:DSA 824i2d_DSAPrivateKey_bio 832 EXIST::FUNCTION:BIO,DSA
825i2d_DSAPrivateKey_fp 833 EXIST::FUNCTION:DSA,FP_API 825i2d_DSAPrivateKey_fp 833 EXIST::FUNCTION:DSA,FP_API
826i2d_DSAPublicKey 834 EXIST::FUNCTION:DSA 826i2d_DSAPublicKey 834 EXIST::FUNCTION:DSA
827i2d_DSAparams 835 EXIST::FUNCTION:DSA 827i2d_DSAparams 835 EXIST::FUNCTION:DSA
@@ -843,8 +843,8 @@ i2d_PKCS7_fp 850 EXIST::FUNCTION:FP_API
843i2d_PrivateKey 851 EXIST::FUNCTION: 843i2d_PrivateKey 851 EXIST::FUNCTION:
844i2d_PublicKey 852 EXIST::FUNCTION: 844i2d_PublicKey 852 EXIST::FUNCTION:
845i2d_RSAPrivateKey 853 EXIST::FUNCTION:RSA 845i2d_RSAPrivateKey 853 EXIST::FUNCTION:RSA
846i2d_RSAPrivateKey_bio 854 EXIST::FUNCTION:RSA 846i2d_RSAPrivateKey_bio 854 EXIST::FUNCTION:BIO,RSA
847i2d_RSAPrivateKey_fp 855 EXIST::FUNCTION:RSA,FP_API 847i2d_RSAPrivateKey_fp 855 EXIST::FUNCTION:FP_API,RSA
848i2d_RSAPublicKey 856 EXIST::FUNCTION:RSA 848i2d_RSAPublicKey 856 EXIST::FUNCTION:RSA
849i2d_X509 857 EXIST::FUNCTION: 849i2d_X509 857 EXIST::FUNCTION:
850i2d_X509_ALGOR 858 EXIST::FUNCTION: 850i2d_X509_ALGOR 858 EXIST::FUNCTION:
@@ -852,7 +852,7 @@ i2d_X509_ATTRIBUTE 859 EXIST::FUNCTION:
852i2d_X509_CINF 860 EXIST::FUNCTION: 852i2d_X509_CINF 860 EXIST::FUNCTION:
853i2d_X509_CRL 861 EXIST::FUNCTION: 853i2d_X509_CRL 861 EXIST::FUNCTION:
854i2d_X509_CRL_INFO 862 EXIST::FUNCTION: 854i2d_X509_CRL_INFO 862 EXIST::FUNCTION:
855i2d_X509_CRL_bio 863 EXIST::FUNCTION: 855i2d_X509_CRL_bio 863 EXIST::FUNCTION:BIO
856i2d_X509_CRL_fp 864 EXIST::FUNCTION:FP_API 856i2d_X509_CRL_fp 864 EXIST::FUNCTION:FP_API
857i2d_X509_EXTENSION 865 EXIST::FUNCTION: 857i2d_X509_EXTENSION 865 EXIST::FUNCTION:
858i2d_X509_NAME 866 EXIST::FUNCTION: 858i2d_X509_NAME 866 EXIST::FUNCTION:
@@ -861,12 +861,12 @@ i2d_X509_PKEY 868 EXIST::FUNCTION:
861i2d_X509_PUBKEY 869 EXIST::FUNCTION: 861i2d_X509_PUBKEY 869 EXIST::FUNCTION:
862i2d_X509_REQ 870 EXIST::FUNCTION: 862i2d_X509_REQ 870 EXIST::FUNCTION:
863i2d_X509_REQ_INFO 871 EXIST::FUNCTION: 863i2d_X509_REQ_INFO 871 EXIST::FUNCTION:
864i2d_X509_REQ_bio 872 EXIST::FUNCTION: 864i2d_X509_REQ_bio 872 EXIST::FUNCTION:BIO
865i2d_X509_REQ_fp 873 EXIST::FUNCTION:FP_API 865i2d_X509_REQ_fp 873 EXIST::FUNCTION:FP_API
866i2d_X509_REVOKED 874 EXIST::FUNCTION: 866i2d_X509_REVOKED 874 EXIST::FUNCTION:
867i2d_X509_SIG 875 EXIST::FUNCTION: 867i2d_X509_SIG 875 EXIST::FUNCTION:
868i2d_X509_VAL 876 EXIST::FUNCTION: 868i2d_X509_VAL 876 EXIST::FUNCTION:
869i2d_X509_bio 877 EXIST::FUNCTION: 869i2d_X509_bio 877 EXIST::FUNCTION:BIO
870i2d_X509_fp 878 EXIST::FUNCTION:FP_API 870i2d_X509_fp 878 EXIST::FUNCTION:FP_API
871idea_cbc_encrypt 879 EXIST::FUNCTION:IDEA 871idea_cbc_encrypt 879 EXIST::FUNCTION:IDEA
872idea_cfb64_encrypt 880 EXIST::FUNCTION:IDEA 872idea_cfb64_encrypt 880 EXIST::FUNCTION:IDEA
@@ -883,12 +883,12 @@ lh_free 890 EXIST::FUNCTION:
883lh_insert 891 EXIST::FUNCTION: 883lh_insert 891 EXIST::FUNCTION:
884lh_new 892 EXIST::FUNCTION: 884lh_new 892 EXIST::FUNCTION:
885lh_node_stats 893 EXIST::FUNCTION:FP_API 885lh_node_stats 893 EXIST::FUNCTION:FP_API
886lh_node_stats_bio 894 EXIST::FUNCTION: 886lh_node_stats_bio 894 EXIST::FUNCTION:BIO
887lh_node_usage_stats 895 EXIST::FUNCTION:FP_API 887lh_node_usage_stats 895 EXIST::FUNCTION:FP_API
888lh_node_usage_stats_bio 896 EXIST::FUNCTION: 888lh_node_usage_stats_bio 896 EXIST::FUNCTION:BIO
889lh_retrieve 897 EXIST::FUNCTION: 889lh_retrieve 897 EXIST::FUNCTION:
890lh_stats 898 EXIST::FUNCTION:FP_API 890lh_stats 898 EXIST::FUNCTION:FP_API
891lh_stats_bio 899 EXIST::FUNCTION: 891lh_stats_bio 899 EXIST::FUNCTION:BIO
892lh_strhash 900 EXIST::FUNCTION: 892lh_strhash 900 EXIST::FUNCTION:
893sk_delete 901 EXIST::FUNCTION: 893sk_delete 901 EXIST::FUNCTION:
894sk_delete_ptr 902 EXIST::FUNCTION: 894sk_delete_ptr 902 EXIST::FUNCTION:
@@ -907,7 +907,7 @@ sk_zero 914 EXIST::FUNCTION:
907BIO_f_nbio_test 915 EXIST::FUNCTION: 907BIO_f_nbio_test 915 EXIST::FUNCTION:
908ASN1_TYPE_get 916 EXIST::FUNCTION: 908ASN1_TYPE_get 916 EXIST::FUNCTION:
909ASN1_TYPE_set 917 EXIST::FUNCTION: 909ASN1_TYPE_set 917 EXIST::FUNCTION:
910PKCS7_content_free 918 EXIST::FUNCTION: 910PKCS7_content_free 918 NOEXIST::FUNCTION:
911ERR_load_PKCS7_strings 919 EXIST::FUNCTION: 911ERR_load_PKCS7_strings 919 EXIST::FUNCTION:
912X509_find_by_issuer_and_serial 920 EXIST::FUNCTION: 912X509_find_by_issuer_and_serial 920 EXIST::FUNCTION:
913X509_find_by_subject 921 EXIST::FUNCTION: 913X509_find_by_subject 921 EXIST::FUNCTION:
@@ -929,16 +929,16 @@ EVP_delete_alias 941 NOEXIST::FUNCTION:
929EVP_mdc2 942 EXIST::FUNCTION:MDC2 929EVP_mdc2 942 EXIST::FUNCTION:MDC2
930PEM_read_bio_RSAPublicKey 943 EXIST::FUNCTION:RSA 930PEM_read_bio_RSAPublicKey 943 EXIST::FUNCTION:RSA
931PEM_write_bio_RSAPublicKey 944 EXIST::FUNCTION:RSA 931PEM_write_bio_RSAPublicKey 944 EXIST::FUNCTION:RSA
932d2i_RSAPublicKey_bio 945 EXIST::FUNCTION:RSA 932d2i_RSAPublicKey_bio 945 EXIST::FUNCTION:BIO,RSA
933i2d_RSAPublicKey_bio 946 EXIST::FUNCTION:RSA 933i2d_RSAPublicKey_bio 946 EXIST::FUNCTION:BIO,RSA
934PEM_read_RSAPublicKey 947 EXIST:!WIN16:FUNCTION:RSA 934PEM_read_RSAPublicKey 947 EXIST:!WIN16:FUNCTION:RSA
935PEM_write_RSAPublicKey 949 EXIST:!WIN16:FUNCTION:RSA 935PEM_write_RSAPublicKey 949 EXIST:!WIN16:FUNCTION:RSA
936d2i_RSAPublicKey_fp 952 EXIST::FUNCTION:RSA,FP_API 936d2i_RSAPublicKey_fp 952 EXIST::FUNCTION:FP_API,RSA
937i2d_RSAPublicKey_fp 954 EXIST::FUNCTION:RSA,FP_API 937i2d_RSAPublicKey_fp 954 EXIST::FUNCTION:FP_API,RSA
938BIO_copy_next_retry 955 EXIST::FUNCTION: 938BIO_copy_next_retry 955 EXIST::FUNCTION:
939RSA_flags 956 EXIST::FUNCTION:RSA 939RSA_flags 956 EXIST::FUNCTION:RSA
940X509_STORE_add_crl 957 EXIST::FUNCTION: 940X509_STORE_add_crl 957 EXIST::FUNCTION:
941X509_load_crl_file 958 EXIST::FUNCTION: 941X509_load_crl_file 958 EXIST::FUNCTION:STDIO
942EVP_rc2_40_cbc 959 EXIST::FUNCTION:RC2 942EVP_rc2_40_cbc 959 EXIST::FUNCTION:RC2
943EVP_rc4_40 960 EXIST::FUNCTION:RC4 943EVP_rc4_40 960 EXIST::FUNCTION:RC4
944EVP_CIPHER_CTX_init 961 EXIST::FUNCTION: 944EVP_CIPHER_CTX_init 961 EXIST::FUNCTION:
@@ -948,7 +948,7 @@ HMAC_Update 964 EXIST::FUNCTION:HMAC
948HMAC_Final 965 EXIST::FUNCTION:HMAC 948HMAC_Final 965 EXIST::FUNCTION:HMAC
949ERR_get_next_error_library 966 EXIST::FUNCTION: 949ERR_get_next_error_library 966 EXIST::FUNCTION:
950EVP_PKEY_cmp_parameters 967 EXIST::FUNCTION: 950EVP_PKEY_cmp_parameters 967 EXIST::FUNCTION:
951HMAC_cleanup 968 EXIST::FUNCTION:HMAC 951HMAC_cleanup 968 NOEXIST::FUNCTION:
952BIO_ptr_ctrl 969 EXIST::FUNCTION: 952BIO_ptr_ctrl 969 EXIST::FUNCTION:
953BIO_new_file_internal 970 EXIST:WIN16:FUNCTION:FP_API 953BIO_new_file_internal 970 EXIST:WIN16:FUNCTION:FP_API
954BIO_new_fp_internal 971 EXIST:WIN16:FUNCTION:FP_API 954BIO_new_fp_internal 971 EXIST:WIN16:FUNCTION:FP_API
@@ -984,12 +984,12 @@ BIO_ghbn_ctrl 1003 EXIST::FUNCTION:
984CRYPTO_free_ex_data 1004 EXIST::FUNCTION: 984CRYPTO_free_ex_data 1004 EXIST::FUNCTION:
985CRYPTO_get_ex_data 1005 EXIST::FUNCTION: 985CRYPTO_get_ex_data 1005 EXIST::FUNCTION:
986CRYPTO_set_ex_data 1007 EXIST::FUNCTION: 986CRYPTO_set_ex_data 1007 EXIST::FUNCTION:
987ERR_load_CRYPTO_strings 1009 EXIST:!WIN16,!VMS:FUNCTION: 987ERR_load_CRYPTO_strings 1009 EXIST:!VMS,!WIN16:FUNCTION:
988ERR_load_CRYPTOlib_strings 1009 EXIST:WIN16,VMS:FUNCTION: 988ERR_load_CRYPTOlib_strings 1009 EXIST:VMS,WIN16:FUNCTION:
989EVP_PKEY_bits 1010 EXIST::FUNCTION: 989EVP_PKEY_bits 1010 EXIST::FUNCTION:
990MD5_Transform 1011 EXIST::FUNCTION:MD5 990MD5_Transform 1011 EXIST::FUNCTION:MD5
991SHA1_Transform 1012 EXIST::FUNCTION:SHA 991SHA1_Transform 1012 EXIST::FUNCTION:SHA,SHA1
992SHA_Transform 1013 EXIST::FUNCTION:SHA 992SHA_Transform 1013 EXIST::FUNCTION:SHA,SHA0
993X509_STORE_CTX_get_chain 1014 EXIST::FUNCTION: 993X509_STORE_CTX_get_chain 1014 EXIST::FUNCTION:
994X509_STORE_CTX_get_current_cert 1015 EXIST::FUNCTION: 994X509_STORE_CTX_get_current_cert 1015 EXIST::FUNCTION:
995X509_STORE_CTX_get_error 1016 EXIST::FUNCTION: 995X509_STORE_CTX_get_error 1016 EXIST::FUNCTION:
@@ -1014,7 +1014,7 @@ RSA_padding_check_PKCS1_type_2 1036 EXIST::FUNCTION:RSA
1014RSA_padding_check_SSLv23 1037 EXIST::FUNCTION:RSA 1014RSA_padding_check_SSLv23 1037 EXIST::FUNCTION:RSA
1015RSA_padding_check_none 1038 EXIST::FUNCTION:RSA 1015RSA_padding_check_none 1038 EXIST::FUNCTION:RSA
1016bn_add_words 1039 EXIST::FUNCTION: 1016bn_add_words 1039 EXIST::FUNCTION:
1017d2i_Netscape_RSA_2 1040 EXIST::FUNCTION:RSA 1017d2i_Netscape_RSA_2 1040 NOEXIST::FUNCTION:
1018CRYPTO_get_ex_new_index 1041 EXIST::FUNCTION: 1018CRYPTO_get_ex_new_index 1041 EXIST::FUNCTION:
1019RIPEMD160_Init 1042 EXIST::FUNCTION:RIPEMD 1019RIPEMD160_Init 1042 EXIST::FUNCTION:RIPEMD
1020RIPEMD160_Update 1043 EXIST::FUNCTION:RIPEMD 1020RIPEMD160_Update 1043 EXIST::FUNCTION:RIPEMD
@@ -1050,7 +1050,7 @@ ASN1_TYPE_get_octetstring 1077 EXIST::FUNCTION:
1050ASN1_TYPE_set_int_octetstring 1078 EXIST::FUNCTION: 1050ASN1_TYPE_set_int_octetstring 1078 EXIST::FUNCTION:
1051ASN1_TYPE_set_octetstring 1079 EXIST::FUNCTION: 1051ASN1_TYPE_set_octetstring 1079 EXIST::FUNCTION:
1052ASN1_UTCTIME_set_string 1080 EXIST::FUNCTION: 1052ASN1_UTCTIME_set_string 1080 EXIST::FUNCTION:
1053ERR_add_error_data 1081 EXIST::FUNCTION: 1053ERR_add_error_data 1081 EXIST::FUNCTION:BIO
1054ERR_set_error_data 1082 EXIST::FUNCTION: 1054ERR_set_error_data 1082 EXIST::FUNCTION:
1055EVP_CIPHER_asn1_to_param 1083 EXIST::FUNCTION: 1055EVP_CIPHER_asn1_to_param 1083 EXIST::FUNCTION:
1056EVP_CIPHER_param_to_asn1 1084 EXIST::FUNCTION: 1056EVP_CIPHER_param_to_asn1 1084 EXIST::FUNCTION:
@@ -1127,20 +1127,24 @@ PKCS7_set_signed_attributes 1154 EXIST::FUNCTION:
1127X509_ATTRIBUTE_create 1155 EXIST::FUNCTION: 1127X509_ATTRIBUTE_create 1155 EXIST::FUNCTION:
1128X509_ATTRIBUTE_dup 1156 EXIST::FUNCTION: 1128X509_ATTRIBUTE_dup 1156 EXIST::FUNCTION:
1129ASN1_GENERALIZEDTIME_check 1157 EXIST::FUNCTION: 1129ASN1_GENERALIZEDTIME_check 1157 EXIST::FUNCTION:
1130ASN1_GENERALIZEDTIME_print 1158 EXIST::FUNCTION: 1130ASN1_GENERALIZEDTIME_print 1158 EXIST::FUNCTION:BIO
1131ASN1_GENERALIZEDTIME_set 1159 EXIST::FUNCTION: 1131ASN1_GENERALIZEDTIME_set 1159 EXIST::FUNCTION:
1132ASN1_GENERALIZEDTIME_set_string 1160 EXIST::FUNCTION: 1132ASN1_GENERALIZEDTIME_set_string 1160 EXIST::FUNCTION:
1133ASN1_TIME_print 1161 EXIST::FUNCTION: 1133ASN1_TIME_print 1161 EXIST::FUNCTION:BIO
1134BASIC_CONSTRAINTS_free 1162 EXIST::FUNCTION: 1134BASIC_CONSTRAINTS_free 1162 EXIST::FUNCTION:
1135BASIC_CONSTRAINTS_new 1163 EXIST::FUNCTION: 1135BASIC_CONSTRAINTS_new 1163 EXIST::FUNCTION:
1136ERR_load_X509V3_strings 1164 EXIST::FUNCTION: 1136ERR_load_X509V3_strings 1164 EXIST::FUNCTION:
1137NETSCAPE_CERT_SEQUENCE_free 1165 EXIST::FUNCTION: 1137NETSCAPE_CERT_SEQUENCE_free 1165 EXIST::FUNCTION:
1138NETSCAPE_CERT_SEQUENCE_new 1166 EXIST::FUNCTION: 1138NETSCAPE_CERT_SEQUENCE_new 1166 EXIST::FUNCTION:
1139OBJ_txt2obj 1167 EXIST::FUNCTION: 1139OBJ_txt2obj 1167 EXIST::FUNCTION:
1140PEM_read_NETSCAPE_CERT_SEQUENCE 1168 EXIST:!WIN16:FUNCTION: 1140PEM_read_NETSCAPE_CERT_SEQUENCE 1168 EXIST:!VMS,!WIN16:FUNCTION:
1141PEM_read_bio_NETSCAPE_CERT_SEQUENCE 1169 EXIST::FUNCTION: 1141PEM_read_NS_CERT_SEQ 1168 EXIST:VMS:FUNCTION:
1142PEM_write_NETSCAPE_CERT_SEQUENCE 1170 EXIST:!WIN16:FUNCTION: 1142PEM_read_bio_NETSCAPE_CERT_SEQUENCE 1169 EXIST:!VMS:FUNCTION:
1143PEM_write_bio_NETSCAPE_CERT_SEQUENCE 1171 EXIST::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:
1144X509V3_EXT_add 1172 EXIST::FUNCTION: 1148X509V3_EXT_add 1172 EXIST::FUNCTION:
1145X509V3_EXT_add_alias 1173 EXIST::FUNCTION: 1149X509V3_EXT_add_alias 1173 EXIST::FUNCTION:
1146X509V3_EXT_add_conf 1174 EXIST::FUNCTION: 1150X509V3_EXT_add_conf 1174 EXIST::FUNCTION:
@@ -1163,14 +1167,14 @@ d2i_ASN1_GENERALIZEDTIME 1190 EXIST::FUNCTION:
1163d2i_ASN1_TIME 1191 EXIST::FUNCTION: 1167d2i_ASN1_TIME 1191 EXIST::FUNCTION:
1164d2i_BASIC_CONSTRAINTS 1192 EXIST::FUNCTION: 1168d2i_BASIC_CONSTRAINTS 1192 EXIST::FUNCTION:
1165d2i_NETSCAPE_CERT_SEQUENCE 1193 EXIST::FUNCTION: 1169d2i_NETSCAPE_CERT_SEQUENCE 1193 EXIST::FUNCTION:
1166d2i_ext_ku 1194 EXIST::FUNCTION: 1170d2i_ext_ku 1194 NOEXIST::FUNCTION:
1167ext_ku_free 1195 EXIST::FUNCTION: 1171ext_ku_free 1195 NOEXIST::FUNCTION:
1168ext_ku_new 1196 EXIST::FUNCTION: 1172ext_ku_new 1196 NOEXIST::FUNCTION:
1169i2d_ASN1_GENERALIZEDTIME 1197 EXIST::FUNCTION: 1173i2d_ASN1_GENERALIZEDTIME 1197 EXIST::FUNCTION:
1170i2d_ASN1_TIME 1198 EXIST::FUNCTION: 1174i2d_ASN1_TIME 1198 EXIST::FUNCTION:
1171i2d_BASIC_CONSTRAINTS 1199 EXIST::FUNCTION: 1175i2d_BASIC_CONSTRAINTS 1199 EXIST::FUNCTION:
1172i2d_NETSCAPE_CERT_SEQUENCE 1200 EXIST::FUNCTION: 1176i2d_NETSCAPE_CERT_SEQUENCE 1200 EXIST::FUNCTION:
1173i2d_ext_ku 1201 EXIST::FUNCTION: 1177i2d_ext_ku 1201 NOEXIST::FUNCTION:
1174EVP_MD_CTX_copy 1202 EXIST::FUNCTION: 1178EVP_MD_CTX_copy 1202 EXIST::FUNCTION:
1175i2d_ASN1_ENUMERATED 1203 EXIST::FUNCTION: 1179i2d_ASN1_ENUMERATED 1203 EXIST::FUNCTION:
1176d2i_ASN1_ENUMERATED 1204 EXIST::FUNCTION: 1180d2i_ASN1_ENUMERATED 1204 EXIST::FUNCTION:
@@ -1178,8 +1182,8 @@ ASN1_ENUMERATED_set 1205 EXIST::FUNCTION:
1178ASN1_ENUMERATED_get 1206 EXIST::FUNCTION: 1182ASN1_ENUMERATED_get 1206 EXIST::FUNCTION:
1179BN_to_ASN1_ENUMERATED 1207 EXIST::FUNCTION: 1183BN_to_ASN1_ENUMERATED 1207 EXIST::FUNCTION:
1180ASN1_ENUMERATED_to_BN 1208 EXIST::FUNCTION: 1184ASN1_ENUMERATED_to_BN 1208 EXIST::FUNCTION:
1181i2a_ASN1_ENUMERATED 1209 EXIST::FUNCTION: 1185i2a_ASN1_ENUMERATED 1209 EXIST::FUNCTION:BIO
1182a2i_ASN1_ENUMERATED 1210 EXIST::FUNCTION: 1186a2i_ASN1_ENUMERATED 1210 EXIST::FUNCTION:BIO
1183i2d_GENERAL_NAME 1211 EXIST::FUNCTION: 1187i2d_GENERAL_NAME 1211 EXIST::FUNCTION:
1184d2i_GENERAL_NAME 1212 EXIST::FUNCTION: 1188d2i_GENERAL_NAME 1212 EXIST::FUNCTION:
1185GENERAL_NAME_new 1213 EXIST::FUNCTION: 1189GENERAL_NAME_new 1213 EXIST::FUNCTION:
@@ -1194,11 +1198,11 @@ s2i_ASN1_OCTET_STRING 1221 EXIST::FUNCTION:
1194X509V3_EXT_check_conf 1222 NOEXIST::FUNCTION: 1198X509V3_EXT_check_conf 1222 NOEXIST::FUNCTION:
1195hex_to_string 1223 EXIST::FUNCTION: 1199hex_to_string 1223 EXIST::FUNCTION:
1196string_to_hex 1224 EXIST::FUNCTION: 1200string_to_hex 1224 EXIST::FUNCTION:
1197des_ede3_cbcm_encrypt 1225 EXIST::FUNCTION:DES 1201DES_ede3_cbcm_encrypt 1225 EXIST::FUNCTION:DES
1198RSA_padding_add_PKCS1_OAEP 1226 EXIST::FUNCTION:RSA 1202RSA_padding_add_PKCS1_OAEP 1226 EXIST::FUNCTION:RSA
1199RSA_padding_check_PKCS1_OAEP 1227 EXIST::FUNCTION:RSA 1203RSA_padding_check_PKCS1_OAEP 1227 EXIST::FUNCTION:RSA
1200X509_CRL_print_fp 1228 EXIST::FUNCTION:FP_API 1204X509_CRL_print_fp 1228 EXIST::FUNCTION:FP_API
1201X509_CRL_print 1229 EXIST::FUNCTION: 1205X509_CRL_print 1229 EXIST::FUNCTION:BIO
1202i2v_GENERAL_NAME 1230 EXIST::FUNCTION: 1206i2v_GENERAL_NAME 1230 EXIST::FUNCTION:
1203v2i_GENERAL_NAME 1231 EXIST::FUNCTION: 1207v2i_GENERAL_NAME 1231 EXIST::FUNCTION:
1204i2d_PKEY_USAGE_PERIOD 1232 EXIST::FUNCTION: 1208i2d_PKEY_USAGE_PERIOD 1232 EXIST::FUNCTION:
@@ -1212,8 +1216,8 @@ name_cmp 1239 EXIST::FUNCTION:
1212str_dup 1240 NOEXIST::FUNCTION: 1216str_dup 1240 NOEXIST::FUNCTION:
1213i2s_ASN1_ENUMERATED 1241 EXIST::FUNCTION: 1217i2s_ASN1_ENUMERATED 1241 EXIST::FUNCTION:
1214i2s_ASN1_ENUMERATED_TABLE 1242 EXIST::FUNCTION: 1218i2s_ASN1_ENUMERATED_TABLE 1242 EXIST::FUNCTION:
1215BIO_s_log 1243 EXIST:!WIN32,!WIN16,!macintosh:FUNCTION: 1219BIO_s_log 1243 EXIST:!WIN16,!WIN32,!macintosh:FUNCTION:
1216BIO_f_reliable 1244 EXIST::FUNCTION: 1220BIO_f_reliable 1244 EXIST::FUNCTION:BIO
1217PKCS7_dataFinal 1245 EXIST::FUNCTION: 1221PKCS7_dataFinal 1245 EXIST::FUNCTION:
1218PKCS7_dataDecode 1246 EXIST::FUNCTION: 1222PKCS7_dataDecode 1246 EXIST::FUNCTION:
1219X509V3_EXT_CRL_add_conf 1247 EXIST::FUNCTION: 1223X509V3_EXT_CRL_add_conf 1247 EXIST::FUNCTION:
@@ -1231,7 +1235,7 @@ ASN1_seq_unpack 1258 EXIST::FUNCTION:
1231ASN1_seq_pack 1259 EXIST::FUNCTION: 1235ASN1_seq_pack 1259 EXIST::FUNCTION:
1232ASN1_unpack_string 1260 EXIST::FUNCTION: 1236ASN1_unpack_string 1260 EXIST::FUNCTION:
1233ASN1_pack_string 1261 EXIST::FUNCTION: 1237ASN1_pack_string 1261 EXIST::FUNCTION:
1234PKCS12_pack_safebag 1262 EXIST::FUNCTION: 1238PKCS12_pack_safebag 1262 NOEXIST::FUNCTION:
1235PKCS12_MAKE_KEYBAG 1263 EXIST::FUNCTION: 1239PKCS12_MAKE_KEYBAG 1263 EXIST::FUNCTION:
1236PKCS8_encrypt 1264 EXIST::FUNCTION: 1240PKCS8_encrypt 1264 EXIST::FUNCTION:
1237PKCS12_MAKE_SHKEYBAG 1265 EXIST::FUNCTION: 1241PKCS12_MAKE_SHKEYBAG 1265 EXIST::FUNCTION:
@@ -1242,8 +1246,8 @@ PKCS12_add_friendlyname_asc 1269 EXIST::FUNCTION:
1242PKCS12_add_friendlyname_uni 1270 EXIST::FUNCTION: 1246PKCS12_add_friendlyname_uni 1270 EXIST::FUNCTION:
1243PKCS12_get_friendlyname 1271 EXIST::FUNCTION: 1247PKCS12_get_friendlyname 1271 EXIST::FUNCTION:
1244PKCS12_pbe_crypt 1272 EXIST::FUNCTION: 1248PKCS12_pbe_crypt 1272 EXIST::FUNCTION:
1245PKCS12_decrypt_d2i 1273 EXIST::FUNCTION: 1249PKCS12_decrypt_d2i 1273 NOEXIST::FUNCTION:
1246PKCS12_i2d_encrypt 1274 EXIST::FUNCTION: 1250PKCS12_i2d_encrypt 1274 NOEXIST::FUNCTION:
1247PKCS12_init 1275 EXIST::FUNCTION: 1251PKCS12_init 1275 EXIST::FUNCTION:
1248PKCS12_key_gen_asc 1276 EXIST::FUNCTION: 1252PKCS12_key_gen_asc 1276 EXIST::FUNCTION:
1249PKCS12_key_gen_uni 1277 EXIST::FUNCTION: 1253PKCS12_key_gen_uni 1277 EXIST::FUNCTION:
@@ -1423,21 +1427,25 @@ d2i_ASN1_SET_OF_PKCS7_RECIP_INFO 1753 NOEXIST::FUNCTION:
1423PKCS5_PBE_add 1775 EXIST::FUNCTION: 1427PKCS5_PBE_add 1775 EXIST::FUNCTION:
1424PEM_write_bio_PKCS8 1776 EXIST::FUNCTION: 1428PEM_write_bio_PKCS8 1776 EXIST::FUNCTION:
1425i2d_PKCS8_fp 1777 EXIST::FUNCTION:FP_API 1429i2d_PKCS8_fp 1777 EXIST::FUNCTION:FP_API
1426PEM_read_bio_PKCS8_PRIV_KEY_INFO 1778 EXIST::FUNCTION: 1430PEM_read_bio_PKCS8_PRIV_KEY_INFO 1778 EXIST:!VMS:FUNCTION:
1427d2i_PKCS8_bio 1779 EXIST::FUNCTION: 1431PEM_read_bio_P8_PRIV_KEY_INFO 1778 EXIST:VMS:FUNCTION:
1432d2i_PKCS8_bio 1779 EXIST::FUNCTION:BIO
1428d2i_PKCS8_PRIV_KEY_INFO_fp 1780 EXIST::FUNCTION:FP_API 1433d2i_PKCS8_PRIV_KEY_INFO_fp 1780 EXIST::FUNCTION:FP_API
1429PEM_write_bio_PKCS8_PRIV_KEY_INFO 1781 EXIST::FUNCTION: 1434PEM_write_bio_PKCS8_PRIV_KEY_INFO 1781 EXIST:!VMS:FUNCTION:
1435PEM_write_bio_P8_PRIV_KEY_INFO 1781 EXIST:VMS:FUNCTION:
1430PEM_read_PKCS8 1782 EXIST:!WIN16:FUNCTION: 1436PEM_read_PKCS8 1782 EXIST:!WIN16:FUNCTION:
1431d2i_PKCS8_PRIV_KEY_INFO_bio 1783 EXIST::FUNCTION: 1437d2i_PKCS8_PRIV_KEY_INFO_bio 1783 EXIST::FUNCTION:BIO
1432d2i_PKCS8_fp 1784 EXIST::FUNCTION:FP_API 1438d2i_PKCS8_fp 1784 EXIST::FUNCTION:FP_API
1433PEM_write_PKCS8 1785 EXIST:!WIN16:FUNCTION: 1439PEM_write_PKCS8 1785 EXIST:!WIN16:FUNCTION:
1434PEM_read_PKCS8_PRIV_KEY_INFO 1786 EXIST:!WIN16:FUNCTION: 1440PEM_read_PKCS8_PRIV_KEY_INFO 1786 EXIST:!VMS,!WIN16:FUNCTION:
1441PEM_read_P8_PRIV_KEY_INFO 1786 EXIST:VMS:FUNCTION:
1435PEM_read_bio_PKCS8 1787 EXIST::FUNCTION: 1442PEM_read_bio_PKCS8 1787 EXIST::FUNCTION:
1436PEM_write_PKCS8_PRIV_KEY_INFO 1788 EXIST:!WIN16:FUNCTION: 1443PEM_write_PKCS8_PRIV_KEY_INFO 1788 EXIST:!VMS,!WIN16:FUNCTION:
1444PEM_write_P8_PRIV_KEY_INFO 1788 EXIST:VMS:FUNCTION:
1437PKCS5_PBE_keyivgen 1789 EXIST::FUNCTION: 1445PKCS5_PBE_keyivgen 1789 EXIST::FUNCTION:
1438i2d_PKCS8_bio 1790 EXIST::FUNCTION: 1446i2d_PKCS8_bio 1790 EXIST::FUNCTION:BIO
1439i2d_PKCS8_PRIV_KEY_INFO_fp 1791 EXIST::FUNCTION:FP_API 1447i2d_PKCS8_PRIV_KEY_INFO_fp 1791 EXIST::FUNCTION:FP_API
1440i2d_PKCS8_PRIV_KEY_INFO_bio 1792 EXIST::FUNCTION: 1448i2d_PKCS8_PRIV_KEY_INFO_bio 1792 EXIST::FUNCTION:BIO
1441BIO_s_bio 1793 EXIST::FUNCTION: 1449BIO_s_bio 1793 EXIST::FUNCTION:
1442PKCS5_pbe2_set 1794 EXIST::FUNCTION: 1450PKCS5_pbe2_set 1794 EXIST::FUNCTION:
1443PKCS5_PBKDF2_HMAC_SHA1 1795 EXIST::FUNCTION: 1451PKCS5_PBKDF2_HMAC_SHA1 1795 EXIST::FUNCTION:
@@ -1460,7 +1468,7 @@ RSA_get_method 1847 EXIST::FUNCTION:RSA
1460RSA_get_default_method 1848 EXIST::FUNCTION:RSA 1468RSA_get_default_method 1848 EXIST::FUNCTION:RSA
1461RSA_check_key 1869 EXIST::FUNCTION:RSA 1469RSA_check_key 1869 EXIST::FUNCTION:RSA
1462OBJ_obj2txt 1870 EXIST::FUNCTION: 1470OBJ_obj2txt 1870 EXIST::FUNCTION:
1463DSA_dup_DH 1871 EXIST::FUNCTION:DSA,DH 1471DSA_dup_DH 1871 EXIST::FUNCTION:DH,DSA
1464X509_REQ_get_extensions 1872 EXIST::FUNCTION: 1472X509_REQ_get_extensions 1872 EXIST::FUNCTION:
1465X509_REQ_set_extension_nids 1873 EXIST::FUNCTION: 1473X509_REQ_set_extension_nids 1873 EXIST::FUNCTION:
1466BIO_nwrite 1874 EXIST::FUNCTION: 1474BIO_nwrite 1874 EXIST::FUNCTION:
@@ -1486,11 +1494,11 @@ DSA_set_ex_data 1893 EXIST::FUNCTION:DSA
1486DH_set_default_method 1894 EXIST::FUNCTION:DH 1494DH_set_default_method 1894 EXIST::FUNCTION:DH
1487DSA_get_ex_data 1895 EXIST::FUNCTION:DSA 1495DSA_get_ex_data 1895 EXIST::FUNCTION:DSA
1488X509V3_EXT_REQ_add_conf 1896 EXIST::FUNCTION: 1496X509V3_EXT_REQ_add_conf 1896 EXIST::FUNCTION:
1489NETSCAPE_SPKI_print 1897 EXIST::FUNCTION: 1497NETSCAPE_SPKI_print 1897 EXIST::FUNCTION:EVP
1490NETSCAPE_SPKI_set_pubkey 1898 EXIST::FUNCTION: 1498NETSCAPE_SPKI_set_pubkey 1898 EXIST::FUNCTION:EVP
1491NETSCAPE_SPKI_b64_encode 1899 EXIST::FUNCTION: 1499NETSCAPE_SPKI_b64_encode 1899 EXIST::FUNCTION:EVP
1492NETSCAPE_SPKI_get_pubkey 1900 EXIST::FUNCTION: 1500NETSCAPE_SPKI_get_pubkey 1900 EXIST::FUNCTION:EVP
1493NETSCAPE_SPKI_b64_decode 1901 EXIST::FUNCTION: 1501NETSCAPE_SPKI_b64_decode 1901 EXIST::FUNCTION:EVP
1494UTF8_putc 1902 EXIST::FUNCTION: 1502UTF8_putc 1902 EXIST::FUNCTION:
1495UTF8_getc 1903 EXIST::FUNCTION: 1503UTF8_getc 1903 EXIST::FUNCTION:
1496RSA_null_method 1904 EXIST::FUNCTION:RSA 1504RSA_null_method 1904 EXIST::FUNCTION:RSA
@@ -1535,22 +1543,22 @@ ASN1_STRING_set_default_mask_asc 1960 EXIST:!VMS:FUNCTION:
1535ASN1_STRING_set_def_mask_asc 1960 EXIST:VMS:FUNCTION: 1543ASN1_STRING_set_def_mask_asc 1960 EXIST:VMS:FUNCTION:
1536PEM_write_bio_RSA_PUBKEY 1961 EXIST::FUNCTION:RSA 1544PEM_write_bio_RSA_PUBKEY 1961 EXIST::FUNCTION:RSA
1537ASN1_INTEGER_cmp 1963 EXIST::FUNCTION: 1545ASN1_INTEGER_cmp 1963 EXIST::FUNCTION:
1538d2i_RSA_PUBKEY_fp 1964 EXIST::FUNCTION:RSA,FP_API 1546d2i_RSA_PUBKEY_fp 1964 EXIST::FUNCTION:FP_API,RSA
1539X509_trust_set_bit_asc 1967 NOEXIST::FUNCTION: 1547X509_trust_set_bit_asc 1967 NOEXIST::FUNCTION:
1540PEM_write_bio_DSA_PUBKEY 1968 EXIST::FUNCTION: 1548PEM_write_bio_DSA_PUBKEY 1968 EXIST::FUNCTION:DSA
1541X509_STORE_CTX_free 1969 EXIST::FUNCTION: 1549X509_STORE_CTX_free 1969 EXIST::FUNCTION:
1542EVP_PKEY_set1_DSA 1970 EXIST::FUNCTION:DSA 1550EVP_PKEY_set1_DSA 1970 EXIST::FUNCTION:DSA
1543i2d_DSA_PUBKEY_fp 1971 EXIST::FUNCTION:DSA,FP_API 1551i2d_DSA_PUBKEY_fp 1971 EXIST::FUNCTION:DSA,FP_API
1544X509_load_cert_crl_file 1972 EXIST::FUNCTION: 1552X509_load_cert_crl_file 1972 EXIST::FUNCTION:STDIO
1545ASN1_TIME_new 1973 EXIST::FUNCTION: 1553ASN1_TIME_new 1973 EXIST::FUNCTION:
1546i2d_RSA_PUBKEY 1974 EXIST::FUNCTION:RSA 1554i2d_RSA_PUBKEY 1974 EXIST::FUNCTION:RSA
1547X509_STORE_CTX_purpose_inherit 1976 EXIST::FUNCTION: 1555X509_STORE_CTX_purpose_inherit 1976 EXIST::FUNCTION:
1548PEM_read_RSA_PUBKEY 1977 EXIST:!WIN16:FUNCTION:RSA 1556PEM_read_RSA_PUBKEY 1977 EXIST:!WIN16:FUNCTION:RSA
1549d2i_X509_AUX 1980 EXIST::FUNCTION: 1557d2i_X509_AUX 1980 EXIST::FUNCTION:
1550i2d_DSA_PUBKEY 1981 EXIST::FUNCTION:DSA 1558i2d_DSA_PUBKEY 1981 EXIST::FUNCTION:DSA
1551X509_CERT_AUX_print 1982 EXIST::FUNCTION: 1559X509_CERT_AUX_print 1982 EXIST::FUNCTION:BIO
1552PEM_read_DSA_PUBKEY 1984 EXIST:!WIN16:FUNCTION: 1560PEM_read_DSA_PUBKEY 1984 EXIST:!WIN16:FUNCTION:DSA
1553i2d_RSA_PUBKEY_bio 1985 EXIST::FUNCTION:RSA 1561i2d_RSA_PUBKEY_bio 1985 EXIST::FUNCTION:BIO,RSA
1554ASN1_BIT_STRING_num_asc 1986 EXIST::FUNCTION: 1562ASN1_BIT_STRING_num_asc 1986 EXIST::FUNCTION:
1555i2d_PUBKEY 1987 EXIST::FUNCTION: 1563i2d_PUBKEY 1987 EXIST::FUNCTION:
1556ASN1_UTCTIME_free 1988 EXIST::FUNCTION: 1564ASN1_UTCTIME_free 1988 EXIST::FUNCTION:
@@ -1568,7 +1576,7 @@ X509_NAME_add_entry_by_OBJ 2008 EXIST::FUNCTION:
1568X509_CRL_get_ext_d2i 2009 EXIST::FUNCTION: 1576X509_CRL_get_ext_d2i 2009 EXIST::FUNCTION:
1569X509_PURPOSE_get0_name 2011 EXIST::FUNCTION: 1577X509_PURPOSE_get0_name 2011 EXIST::FUNCTION:
1570PEM_read_PUBKEY 2012 EXIST:!WIN16:FUNCTION: 1578PEM_read_PUBKEY 2012 EXIST:!WIN16:FUNCTION:
1571i2d_DSA_PUBKEY_bio 2014 EXIST::FUNCTION:DSA 1579i2d_DSA_PUBKEY_bio 2014 EXIST::FUNCTION:BIO,DSA
1572i2d_OTHERNAME 2015 EXIST::FUNCTION: 1580i2d_OTHERNAME 2015 EXIST::FUNCTION:
1573ASN1_OCTET_STRING_free 2016 EXIST::FUNCTION: 1581ASN1_OCTET_STRING_free 2016 EXIST::FUNCTION:
1574ASN1_BIT_STRING_set_asc 2017 EXIST::FUNCTION: 1582ASN1_BIT_STRING_set_asc 2017 EXIST::FUNCTION:
@@ -1598,7 +1606,7 @@ ASN1_IA5STRING_new 2049 EXIST::FUNCTION:
1598d2i_DSA_PUBKEY 2050 EXIST::FUNCTION:DSA 1606d2i_DSA_PUBKEY 2050 EXIST::FUNCTION:DSA
1599X509_check_purpose 2051 EXIST::FUNCTION: 1607X509_check_purpose 2051 EXIST::FUNCTION:
1600ASN1_ENUMERATED_new 2052 EXIST::FUNCTION: 1608ASN1_ENUMERATED_new 2052 EXIST::FUNCTION:
1601d2i_RSA_PUBKEY_bio 2053 EXIST::FUNCTION:RSA 1609d2i_RSA_PUBKEY_bio 2053 EXIST::FUNCTION:BIO,RSA
1602d2i_PUBKEY 2054 EXIST::FUNCTION: 1610d2i_PUBKEY 2054 EXIST::FUNCTION:
1603X509_TRUST_get_trust 2055 EXIST::FUNCTION: 1611X509_TRUST_get_trust 2055 EXIST::FUNCTION:
1604X509_TRUST_get_flags 2056 EXIST::FUNCTION: 1612X509_TRUST_get_flags 2056 EXIST::FUNCTION:
@@ -1622,15 +1630,15 @@ ASN1_BIT_STRING_free 2080 EXIST::FUNCTION:
1622PEM_read_bio_RSA_PUBKEY 2081 EXIST::FUNCTION:RSA 1630PEM_read_bio_RSA_PUBKEY 2081 EXIST::FUNCTION:RSA
1623X509_add1_reject_object 2082 EXIST::FUNCTION: 1631X509_add1_reject_object 2082 EXIST::FUNCTION:
1624X509_check_trust 2083 EXIST::FUNCTION: 1632X509_check_trust 2083 EXIST::FUNCTION:
1625PEM_read_bio_DSA_PUBKEY 2088 EXIST::FUNCTION: 1633PEM_read_bio_DSA_PUBKEY 2088 EXIST::FUNCTION:DSA
1626X509_PURPOSE_add 2090 EXIST::FUNCTION: 1634X509_PURPOSE_add 2090 EXIST::FUNCTION:
1627ASN1_STRING_TABLE_get 2091 EXIST::FUNCTION: 1635ASN1_STRING_TABLE_get 2091 EXIST::FUNCTION:
1628ASN1_UTF8STRING_free 2092 EXIST::FUNCTION: 1636ASN1_UTF8STRING_free 2092 EXIST::FUNCTION:
1629d2i_DSA_PUBKEY_bio 2093 EXIST::FUNCTION:DSA 1637d2i_DSA_PUBKEY_bio 2093 EXIST::FUNCTION:BIO,DSA
1630PEM_write_RSA_PUBKEY 2095 EXIST:!WIN16:FUNCTION:RSA 1638PEM_write_RSA_PUBKEY 2095 EXIST:!WIN16:FUNCTION:RSA
1631d2i_OTHERNAME 2096 EXIST::FUNCTION: 1639d2i_OTHERNAME 2096 EXIST::FUNCTION:
1632X509_reject_set_bit 2098 NOEXIST::FUNCTION: 1640X509_reject_set_bit 2098 NOEXIST::FUNCTION:
1633PEM_write_DSA_PUBKEY 2101 EXIST:!WIN16:FUNCTION: 1641PEM_write_DSA_PUBKEY 2101 EXIST:!WIN16:FUNCTION:DSA
1634X509_PURPOSE_get0_sname 2105 EXIST::FUNCTION: 1642X509_PURPOSE_get0_sname 2105 EXIST::FUNCTION:
1635EVP_PKEY_set1_DH 2107 EXIST::FUNCTION:DH 1643EVP_PKEY_set1_DH 2107 EXIST::FUNCTION:DH
1636ASN1_OCTET_STRING_dup 2108 EXIST::FUNCTION: 1644ASN1_OCTET_STRING_dup 2108 EXIST::FUNCTION:
@@ -1638,7 +1646,7 @@ ASN1_BIT_STRING_set 2109 EXIST::FUNCTION:
1638X509_TRUST_get_count 2110 EXIST::FUNCTION: 1646X509_TRUST_get_count 2110 EXIST::FUNCTION:
1639ASN1_INTEGER_free 2111 EXIST::FUNCTION: 1647ASN1_INTEGER_free 2111 EXIST::FUNCTION:
1640OTHERNAME_free 2112 EXIST::FUNCTION: 1648OTHERNAME_free 2112 EXIST::FUNCTION:
1641i2d_RSA_PUBKEY_fp 2113 EXIST::FUNCTION:RSA,FP_API 1649i2d_RSA_PUBKEY_fp 2113 EXIST::FUNCTION:FP_API,RSA
1642ASN1_INTEGER_dup 2114 EXIST::FUNCTION: 1650ASN1_INTEGER_dup 2114 EXIST::FUNCTION:
1643d2i_X509_CERT_AUX 2115 EXIST::FUNCTION: 1651d2i_X509_CERT_AUX 2115 EXIST::FUNCTION:
1644PEM_write_bio_PUBKEY 2117 EXIST::FUNCTION: 1652PEM_write_bio_PUBKEY 2117 EXIST::FUNCTION:
@@ -1650,7 +1658,7 @@ EVP_PKEY_get1_DH 2128 EXIST::FUNCTION:DH
1650ASN1_OCTET_STRING_new 2130 EXIST::FUNCTION: 1658ASN1_OCTET_STRING_new 2130 EXIST::FUNCTION:
1651ASN1_INTEGER_new 2131 EXIST::FUNCTION: 1659ASN1_INTEGER_new 2131 EXIST::FUNCTION:
1652i2d_X509_AUX 2132 EXIST::FUNCTION: 1660i2d_X509_AUX 2132 EXIST::FUNCTION:
1653ASN1_BIT_STRING_name_print 2134 EXIST::FUNCTION: 1661ASN1_BIT_STRING_name_print 2134 EXIST::FUNCTION:BIO
1654X509_cmp 2135 EXIST::FUNCTION: 1662X509_cmp 2135 EXIST::FUNCTION:
1655ASN1_STRING_length_set 2136 EXIST::FUNCTION: 1663ASN1_STRING_length_set 2136 EXIST::FUNCTION:
1656DIRECTORYSTRING_new 2137 EXIST::FUNCTION: 1664DIRECTORYSTRING_new 2137 EXIST::FUNCTION:
@@ -1658,10 +1666,10 @@ X509_add1_trust_object 2140 EXIST::FUNCTION:
1658PKCS12_newpass 2141 EXIST::FUNCTION: 1666PKCS12_newpass 2141 EXIST::FUNCTION:
1659SMIME_write_PKCS7 2142 EXIST::FUNCTION: 1667SMIME_write_PKCS7 2142 EXIST::FUNCTION:
1660SMIME_read_PKCS7 2143 EXIST::FUNCTION: 1668SMIME_read_PKCS7 2143 EXIST::FUNCTION:
1661des_set_key_checked 2144 EXIST::FUNCTION:DES 1669DES_set_key_checked 2144 EXIST::FUNCTION:DES
1662PKCS7_verify 2145 EXIST::FUNCTION: 1670PKCS7_verify 2145 EXIST::FUNCTION:
1663PKCS7_encrypt 2146 EXIST::FUNCTION: 1671PKCS7_encrypt 2146 EXIST::FUNCTION:
1664des_set_key_unchecked 2147 EXIST::FUNCTION:DES 1672DES_set_key_unchecked 2147 EXIST::FUNCTION:DES
1665SMIME_crlf_copy 2148 EXIST::FUNCTION: 1673SMIME_crlf_copy 2148 EXIST::FUNCTION:
1666i2d_ASN1_PRINTABLESTRING 2149 EXIST::FUNCTION: 1674i2d_ASN1_PRINTABLESTRING 2149 EXIST::FUNCTION:
1667PKCS7_get0_signers 2150 EXIST::FUNCTION: 1675PKCS7_get0_signers 2150 EXIST::FUNCTION:
@@ -1693,12 +1701,12 @@ i2d_PKCS8PrivateKey_nid_fp 2174 EXIST::FUNCTION:
1693d2i_PKCS8PrivateKey_fp 2175 EXIST::FUNCTION: 1701d2i_PKCS8PrivateKey_fp 2175 EXIST::FUNCTION:
1694i2d_PKCS8PrivateKey_nid_bio 2176 EXIST::FUNCTION: 1702i2d_PKCS8PrivateKey_nid_bio 2176 EXIST::FUNCTION:
1695i2d_PKCS8PrivateKeyInfo_fp 2177 EXIST::FUNCTION:FP_API 1703i2d_PKCS8PrivateKeyInfo_fp 2177 EXIST::FUNCTION:FP_API
1696i2d_PKCS8PrivateKeyInfo_bio 2178 EXIST::FUNCTION: 1704i2d_PKCS8PrivateKeyInfo_bio 2178 EXIST::FUNCTION:BIO
1697PEM_cb 2179 NOEXIST::FUNCTION: 1705PEM_cb 2179 NOEXIST::FUNCTION:
1698i2d_PrivateKey_fp 2180 EXIST::FUNCTION:FP_API 1706i2d_PrivateKey_fp 2180 EXIST::FUNCTION:FP_API
1699d2i_PrivateKey_bio 2181 EXIST::FUNCTION: 1707d2i_PrivateKey_bio 2181 EXIST::FUNCTION:BIO
1700d2i_PrivateKey_fp 2182 EXIST::FUNCTION:FP_API 1708d2i_PrivateKey_fp 2182 EXIST::FUNCTION:FP_API
1701i2d_PrivateKey_bio 2183 EXIST::FUNCTION: 1709i2d_PrivateKey_bio 2183 EXIST::FUNCTION:BIO
1702X509_reject_clear 2184 EXIST::FUNCTION: 1710X509_reject_clear 2184 EXIST::FUNCTION:
1703X509_TRUST_set_default 2185 EXIST::FUNCTION: 1711X509_TRUST_set_default 2185 EXIST::FUNCTION:
1704d2i_AutoPrivateKey 2186 EXIST::FUNCTION: 1712d2i_AutoPrivateKey 2186 EXIST::FUNCTION:
@@ -1745,21 +1753,21 @@ ASN1_STRING_TABLE_add 2245 EXIST::FUNCTION:
1745CRYPTO_dbg_get_options 2246 EXIST::FUNCTION: 1753CRYPTO_dbg_get_options 2246 EXIST::FUNCTION:
1746AUTHORITY_INFO_ACCESS_new 2247 EXIST::FUNCTION: 1754AUTHORITY_INFO_ACCESS_new 2247 EXIST::FUNCTION:
1747CRYPTO_get_mem_debug_options 2248 EXIST::FUNCTION: 1755CRYPTO_get_mem_debug_options 2248 EXIST::FUNCTION:
1748des_crypt 2249 EXIST::FUNCTION:DES 1756DES_crypt 2249 EXIST::FUNCTION:DES
1749PEM_write_bio_X509_REQ_NEW 2250 EXIST::FUNCTION: 1757PEM_write_bio_X509_REQ_NEW 2250 EXIST::FUNCTION:
1750PEM_write_X509_REQ_NEW 2251 EXIST:!WIN16:FUNCTION: 1758PEM_write_X509_REQ_NEW 2251 EXIST:!WIN16:FUNCTION:
1751BIO_callback_ctrl 2252 EXIST::FUNCTION: 1759BIO_callback_ctrl 2252 EXIST::FUNCTION:
1752RAND_egd 2253 EXIST::FUNCTION: 1760RAND_egd 2253 EXIST::FUNCTION:
1753RAND_status 2254 EXIST::FUNCTION: 1761RAND_status 2254 EXIST::FUNCTION:
1754bn_dump1 2255 NOEXIST::FUNCTION: 1762bn_dump1 2255 NOEXIST::FUNCTION:
1755des_check_key_parity 2256 EXIST::FUNCTION:DES 1763DES_check_key_parity 2256 EXIST::FUNCTION:DES
1756lh_num_items 2257 EXIST::FUNCTION: 1764lh_num_items 2257 EXIST::FUNCTION:
1757RAND_event 2258 EXIST::FUNCTION: 1765RAND_event 2258 EXIST:WIN32:FUNCTION:
1758DSO_new 2259 EXIST::FUNCTION: 1766DSO_new 2259 EXIST::FUNCTION:
1759DSO_new_method 2260 EXIST::FUNCTION: 1767DSO_new_method 2260 EXIST::FUNCTION:
1760DSO_free 2261 EXIST::FUNCTION: 1768DSO_free 2261 EXIST::FUNCTION:
1761DSO_flags 2262 EXIST::FUNCTION: 1769DSO_flags 2262 EXIST::FUNCTION:
1762DSO_up 2263 EXIST::FUNCTION: 1770DSO_up 2263 NOEXIST::FUNCTION:
1763DSO_set_default_method 2264 EXIST::FUNCTION: 1771DSO_set_default_method 2264 EXIST::FUNCTION:
1764DSO_get_default_method 2265 EXIST::FUNCTION: 1772DSO_get_default_method 2265 EXIST::FUNCTION:
1765DSO_get_method 2266 EXIST::FUNCTION: 1773DSO_get_method 2266 EXIST::FUNCTION:
@@ -1777,7 +1785,7 @@ NCONF_load_fp 2278 EXIST::FUNCTION:FP_API
1777NCONF_new 2279 EXIST::FUNCTION: 1785NCONF_new 2279 EXIST::FUNCTION:
1778NCONF_get_string 2280 EXIST::FUNCTION: 1786NCONF_get_string 2280 EXIST::FUNCTION:
1779NCONF_free 2281 EXIST::FUNCTION: 1787NCONF_free 2281 EXIST::FUNCTION:
1780NCONF_get_number 2282 EXIST::FUNCTION: 1788NCONF_get_number 2282 NOEXIST::FUNCTION:
1781CONF_dump_fp 2283 EXIST::FUNCTION: 1789CONF_dump_fp 2283 EXIST::FUNCTION:
1782NCONF_load_bio 2284 EXIST::FUNCTION: 1790NCONF_load_bio 2284 EXIST::FUNCTION:
1783NCONF_dump_fp 2285 EXIST::FUNCTION: 1791NCONF_dump_fp 2285 EXIST::FUNCTION:
@@ -1795,9 +1803,9 @@ i2d_ASN1_SET_OF_PKCS7 2328 NOEXIST::FUNCTION:
1795BIO_vfree 2334 EXIST::FUNCTION: 1803BIO_vfree 2334 EXIST::FUNCTION:
1796d2i_ASN1_SET_OF_ASN1_INTEGER 2339 NOEXIST::FUNCTION: 1804d2i_ASN1_SET_OF_ASN1_INTEGER 2339 NOEXIST::FUNCTION:
1797d2i_ASN1_SET_OF_PKCS12_SAFEBAG 2341 NOEXIST::FUNCTION: 1805d2i_ASN1_SET_OF_PKCS12_SAFEBAG 2341 NOEXIST::FUNCTION:
1798ASN1_UTCTIME_get 2350 EXIST::FUNCTION: 1806ASN1_UTCTIME_get 2350 NOEXIST::FUNCTION:
1799X509_REQ_digest 2362 EXIST::FUNCTION: 1807X509_REQ_digest 2362 EXIST::FUNCTION:EVP
1800X509_CRL_digest 2391 EXIST::FUNCTION: 1808X509_CRL_digest 2391 EXIST::FUNCTION:EVP
1801d2i_ASN1_SET_OF_PKCS7 2397 NOEXIST::FUNCTION: 1809d2i_ASN1_SET_OF_PKCS7 2397 NOEXIST::FUNCTION:
1802EVP_CIPHER_CTX_set_key_length 2399 EXIST::FUNCTION: 1810EVP_CIPHER_CTX_set_key_length 2399 EXIST::FUNCTION:
1803EVP_CIPHER_CTX_ctrl 2400 EXIST::FUNCTION: 1811EVP_CIPHER_CTX_ctrl 2400 EXIST::FUNCTION:
@@ -1807,7 +1815,7 @@ X509_REQ_get1_email 2403 EXIST::FUNCTION:
1807X509_get1_email 2404 EXIST::FUNCTION: 1815X509_get1_email 2404 EXIST::FUNCTION:
1808X509_email_free 2405 EXIST::FUNCTION: 1816X509_email_free 2405 EXIST::FUNCTION:
1809i2d_RSA_NET 2406 EXIST::FUNCTION:RSA 1817i2d_RSA_NET 2406 EXIST::FUNCTION:RSA
1810d2i_RSA_NET_2 2407 EXIST::FUNCTION:RSA 1818d2i_RSA_NET_2 2407 NOEXIST::FUNCTION:
1811d2i_RSA_NET 2408 EXIST::FUNCTION:RSA 1819d2i_RSA_NET 2408 EXIST::FUNCTION:RSA
1812DSO_bind_func 2409 EXIST::FUNCTION: 1820DSO_bind_func 2409 EXIST::FUNCTION:
1813CRYPTO_get_new_dynlockid 2410 EXIST::FUNCTION: 1821CRYPTO_get_new_dynlockid 2410 EXIST::FUNCTION:
@@ -1833,21 +1841,21 @@ RAND_poll 2423 EXIST::FUNCTION:
1833c2i_ASN1_INTEGER 2424 EXIST::FUNCTION: 1841c2i_ASN1_INTEGER 2424 EXIST::FUNCTION:
1834i2c_ASN1_INTEGER 2425 EXIST::FUNCTION: 1842i2c_ASN1_INTEGER 2425 EXIST::FUNCTION:
1835BIO_dump_indent 2426 EXIST::FUNCTION: 1843BIO_dump_indent 2426 EXIST::FUNCTION:
1836ASN1_parse_dump 2427 EXIST::FUNCTION: 1844ASN1_parse_dump 2427 EXIST::FUNCTION:BIO
1837c2i_ASN1_OBJECT 2428 EXIST::FUNCTION: 1845c2i_ASN1_OBJECT 2428 EXIST::FUNCTION:
1838X509_NAME_print_ex_fp 2429 EXIST::FUNCTION:FP_API 1846X509_NAME_print_ex_fp 2429 EXIST::FUNCTION:FP_API
1839ASN1_STRING_print_ex_fp 2430 EXIST::FUNCTION:FP_API 1847ASN1_STRING_print_ex_fp 2430 EXIST::FUNCTION:FP_API
1840X509_NAME_print_ex 2431 EXIST::FUNCTION: 1848X509_NAME_print_ex 2431 EXIST::FUNCTION:BIO
1841ASN1_STRING_print_ex 2432 EXIST::FUNCTION: 1849ASN1_STRING_print_ex 2432 EXIST::FUNCTION:BIO
1842MD4 2433 EXIST::FUNCTION:MD4 1850MD4 2433 EXIST::FUNCTION:MD4
1843MD4_Transform 2434 EXIST::FUNCTION:MD4 1851MD4_Transform 2434 EXIST::FUNCTION:MD4
1844MD4_Final 2435 EXIST::FUNCTION:MD4 1852MD4_Final 2435 EXIST::FUNCTION:MD4
1845MD4_Update 2436 EXIST::FUNCTION:MD4 1853MD4_Update 2436 EXIST::FUNCTION:MD4
1846MD4_Init 2437 EXIST::FUNCTION:MD4 1854MD4_Init 2437 EXIST::FUNCTION:MD4
1847EVP_md4 2438 EXIST::FUNCTION:MD4 1855EVP_md4 2438 EXIST::FUNCTION:MD4
1848i2d_PUBKEY_bio 2439 EXIST::FUNCTION: 1856i2d_PUBKEY_bio 2439 EXIST::FUNCTION:BIO
1849i2d_PUBKEY_fp 2440 EXIST::FUNCTION:FP_API 1857i2d_PUBKEY_fp 2440 EXIST::FUNCTION:FP_API
1850d2i_PUBKEY_bio 2441 EXIST::FUNCTION: 1858d2i_PUBKEY_bio 2441 EXIST::FUNCTION:BIO
1851ASN1_STRING_to_UTF8 2442 EXIST::FUNCTION: 1859ASN1_STRING_to_UTF8 2442 EXIST::FUNCTION:
1852BIO_vprintf 2443 EXIST::FUNCTION: 1860BIO_vprintf 2443 EXIST::FUNCTION:
1853BIO_vsnprintf 2444 EXIST::FUNCTION: 1861BIO_vsnprintf 2444 EXIST::FUNCTION:
@@ -1862,10 +1870,10 @@ X509_STORE_CTX_trusted_stack 2452 EXIST::FUNCTION:
1862X509_time_adj 2453 EXIST::FUNCTION: 1870X509_time_adj 2453 EXIST::FUNCTION:
1863X509_check_issued 2454 EXIST::FUNCTION: 1871X509_check_issued 2454 EXIST::FUNCTION:
1864ASN1_UTCTIME_cmp_time_t 2455 EXIST::FUNCTION: 1872ASN1_UTCTIME_cmp_time_t 2455 EXIST::FUNCTION:
1865des_set_weak_key_flag 2456 EXIST::VARIABLE:DES 1873DES_set_weak_key_flag 2456 NOEXIST::FUNCTION:
1866des_check_key 2457 EXIST::VARIABLE:DES 1874DES_check_key 2457 NOEXIST::FUNCTION:
1867des_rw_mode 2458 EXIST::VARIABLE:DES 1875DES_rw_mode 2458 NOEXIST::FUNCTION:
1868RSA_PKCS1_RSAref 2459 EXIST:RSAREF:FUNCTION:RSA 1876RSA_PKCS1_RSAref 2459 NOEXIST::FUNCTION:
1869X509_keyid_set1 2460 EXIST::FUNCTION: 1877X509_keyid_set1 2460 EXIST::FUNCTION:
1870BIO_next 2461 EXIST::FUNCTION: 1878BIO_next 2461 EXIST::FUNCTION:
1871DSO_METHOD_vms 2462 EXIST::FUNCTION: 1879DSO_METHOD_vms 2462 EXIST::FUNCTION:
@@ -1877,14 +1885,14 @@ ERR_load_ENGINE_strings 2467 EXIST::FUNCTION:
1877ENGINE_set_DSA 2468 EXIST::FUNCTION: 1885ENGINE_set_DSA 2468 EXIST::FUNCTION:
1878ENGINE_get_finish_function 2469 EXIST::FUNCTION: 1886ENGINE_get_finish_function 2469 EXIST::FUNCTION:
1879ENGINE_get_default_RSA 2470 EXIST::FUNCTION: 1887ENGINE_get_default_RSA 2470 EXIST::FUNCTION:
1880ENGINE_get_BN_mod_exp 2471 EXIST::FUNCTION: 1888ENGINE_get_BN_mod_exp 2471 NOEXIST::FUNCTION:
1881DSA_get_default_openssl_method 2472 EXIST::FUNCTION:DSA 1889DSA_get_default_openssl_method 2472 NOEXIST::FUNCTION:
1882ENGINE_set_DH 2473 EXIST::FUNCTION: 1890ENGINE_set_DH 2473 EXIST::FUNCTION:
1883ENGINE_set_default_BN_mod_exp_crt 2474 EXIST:!VMS:FUNCTION: 1891ENGINE_set_def_BN_mod_exp_crt 2474 NOEXIST::FUNCTION:
1884ENGINE_set_def_BN_mod_exp_crt 2474 EXIST:VMS:FUNCTION: 1892ENGINE_set_default_BN_mod_exp_crt 2474 NOEXIST::FUNCTION:
1885ENGINE_init 2475 EXIST::FUNCTION: 1893ENGINE_init 2475 EXIST::FUNCTION:
1886DH_get_default_openssl_method 2476 EXIST::FUNCTION:DH 1894DH_get_default_openssl_method 2476 NOEXIST::FUNCTION:
1887RSA_set_default_openssl_method 2477 EXIST::FUNCTION:RSA 1895RSA_set_default_openssl_method 2477 NOEXIST::FUNCTION:
1888ENGINE_finish 2478 EXIST::FUNCTION: 1896ENGINE_finish 2478 EXIST::FUNCTION:
1889ENGINE_load_public_key 2479 EXIST::FUNCTION: 1897ENGINE_load_public_key 2479 EXIST::FUNCTION:
1890ENGINE_get_DH 2480 EXIST::FUNCTION: 1898ENGINE_get_DH 2480 EXIST::FUNCTION:
@@ -1902,32 +1910,867 @@ ENGINE_get_RAND 2491 EXIST::FUNCTION:
1902ENGINE_get_first 2492 EXIST::FUNCTION: 1910ENGINE_get_first 2492 EXIST::FUNCTION:
1903ENGINE_by_id 2493 EXIST::FUNCTION: 1911ENGINE_by_id 2493 EXIST::FUNCTION:
1904ENGINE_set_finish_function 2494 EXIST::FUNCTION: 1912ENGINE_set_finish_function 2494 EXIST::FUNCTION:
1905ENGINE_get_default_BN_mod_exp_crt 2495 EXIST:!VMS:FUNCTION: 1913ENGINE_get_def_BN_mod_exp_crt 2495 NOEXIST::FUNCTION:
1906ENGINE_get_def_BN_mod_exp_crt 2495 EXIST:VMS:FUNCTION: 1914ENGINE_get_default_BN_mod_exp_crt 2495 NOEXIST::FUNCTION:
1907RSA_get_default_openssl_method 2496 EXIST::FUNCTION:RSA 1915RSA_get_default_openssl_method 2496 NOEXIST::FUNCTION:
1908ENGINE_set_RSA 2497 EXIST::FUNCTION: 1916ENGINE_set_RSA 2497 EXIST::FUNCTION:
1909ENGINE_load_private_key 2498 EXIST::FUNCTION: 1917ENGINE_load_private_key 2498 EXIST::FUNCTION:
1910ENGINE_set_default_RAND 2499 EXIST::FUNCTION: 1918ENGINE_set_default_RAND 2499 EXIST::FUNCTION:
1911ENGINE_set_BN_mod_exp 2500 EXIST::FUNCTION: 1919ENGINE_set_BN_mod_exp 2500 NOEXIST::FUNCTION:
1912ENGINE_remove 2501 EXIST::FUNCTION: 1920ENGINE_remove 2501 EXIST::FUNCTION:
1913ENGINE_free 2502 EXIST::FUNCTION: 1921ENGINE_free 2502 EXIST::FUNCTION:
1914ENGINE_get_BN_mod_exp_crt 2503 EXIST::FUNCTION: 1922ENGINE_get_BN_mod_exp_crt 2503 NOEXIST::FUNCTION:
1915ENGINE_get_next 2504 EXIST::FUNCTION: 1923ENGINE_get_next 2504 EXIST::FUNCTION:
1916ENGINE_set_name 2505 EXIST::FUNCTION: 1924ENGINE_set_name 2505 EXIST::FUNCTION:
1917ENGINE_get_default_DSA 2506 EXIST::FUNCTION: 1925ENGINE_get_default_DSA 2506 EXIST::FUNCTION:
1918ENGINE_set_default_BN_mod_exp 2507 EXIST::FUNCTION: 1926ENGINE_set_default_BN_mod_exp 2507 NOEXIST::FUNCTION:
1919ENGINE_set_default_RSA 2508 EXIST::FUNCTION: 1927ENGINE_set_default_RSA 2508 EXIST::FUNCTION:
1920ENGINE_get_default_RAND 2509 EXIST::FUNCTION: 1928ENGINE_get_default_RAND 2509 EXIST::FUNCTION:
1921ENGINE_get_default_BN_mod_exp 2510 EXIST::FUNCTION: 1929ENGINE_get_default_BN_mod_exp 2510 NOEXIST::FUNCTION:
1922ENGINE_set_RAND 2511 EXIST::FUNCTION: 1930ENGINE_set_RAND 2511 EXIST::FUNCTION:
1923ENGINE_set_id 2512 EXIST::FUNCTION: 1931ENGINE_set_id 2512 EXIST::FUNCTION:
1924ENGINE_set_BN_mod_exp_crt 2513 EXIST::FUNCTION: 1932ENGINE_set_BN_mod_exp_crt 2513 NOEXIST::FUNCTION:
1925ENGINE_set_default_DH 2514 EXIST::FUNCTION: 1933ENGINE_set_default_DH 2514 EXIST::FUNCTION:
1926ENGINE_new 2515 EXIST::FUNCTION: 1934ENGINE_new 2515 EXIST::FUNCTION:
1927ENGINE_get_id 2516 EXIST::FUNCTION: 1935ENGINE_get_id 2516 EXIST::FUNCTION:
1928DSA_set_default_openssl_method 2517 EXIST::FUNCTION:DSA 1936DSA_set_default_openssl_method 2517 NOEXIST::FUNCTION:
1929ENGINE_add 2518 EXIST::FUNCTION: 1937ENGINE_add 2518 EXIST::FUNCTION:
1930DH_set_default_openssl_method 2519 EXIST::FUNCTION:DH 1938DH_set_default_openssl_method 2519 NOEXIST::FUNCTION:
1931ENGINE_get_DSA 2520 EXIST::FUNCTION: 1939ENGINE_get_DSA 2520 EXIST::FUNCTION:
1932ENGINE_get_ctrl_function 2521 EXIST::FUNCTION: 1940ENGINE_get_ctrl_function 2521 EXIST::FUNCTION:
1933ENGINE_set_ctrl_function 2522 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:!VMS,!WIN16:FUNCTION:
2736OCSP_crlID2_new 3181 EXIST: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
diff --git a/src/lib/libcrypto/util/mk1mf.pl b/src/lib/libcrypto/util/mk1mf.pl
index 46755fa287..8b6b2e668a 100644
--- a/src/lib/libcrypto/util/mk1mf.pl
+++ b/src/lib/libcrypto/util/mk1mf.pl
@@ -37,6 +37,7 @@ $infile="MINFO";
37 "linux-elf","Linux elf", 37 "linux-elf","Linux elf",
38 "ultrix-mips","DEC mips ultrix", 38 "ultrix-mips","DEC mips ultrix",
39 "FreeBSD","FreeBSD distribution", 39 "FreeBSD","FreeBSD distribution",
40 "OS2-EMX", "EMX GCC OS/2",
40 "default","cc under unix", 41 "default","cc under unix",
41 ); 42 );
42 43
@@ -54,12 +55,14 @@ foreach (@ARGV)
54and [options] can be one of 55and [options] can be one of
55 no-md2 no-md4 no-md5 no-sha no-mdc2 - Skip this digest 56 no-md2 no-md4 no-md5 no-sha no-mdc2 - Skip this digest
56 no-ripemd 57 no-ripemd
57 no-rc2 no-rc4 no-idea no-des no-bf no-cast - Skip this symetric cipher 58 no-rc2 no-rc4 no-rc5 no-idea no-des - Skip this symetric cipher
58 no-rc5 59 no-bf no-cast no-aes
59 no-rsa no-dsa no-dh - Skip this public key cipher 60 no-rsa no-dsa no-dh - Skip this public key cipher
60 no-ssl2 no-ssl3 - Skip this version of SSL 61 no-ssl2 no-ssl3 - Skip this version of SSL
61 just-ssl - remove all non-ssl keys/digest 62 just-ssl - remove all non-ssl keys/digest
62 no-asm - No x86 asm 63 no-asm - No x86 asm
64 no-krb5 - No KRB5
65 no-ec - No EC
63 nasm - Use NASM for x86 asm 66 nasm - Use NASM for x86 asm
64 gaswin - Use GNU as with Mingw32 67 gaswin - Use GNU as with Mingw32
65 no-socks - No socket code 68 no-socks - No socket code
@@ -68,7 +71,6 @@ and [options] can be one of
68 debug - Debug build 71 debug - Debug build
69 profile - Profiling build 72 profile - Profiling build
70 gcc - Use Gcc (unix) 73 gcc - Use Gcc (unix)
71 rsaref - Build to require RSAref
72 74
73Values that can be set 75Values that can be set
74TMP=tmpdir OUT=outdir SRC=srcdir BIN=binpath INC=header-outdir CC=C-compiler 76TMP=tmpdir OUT=outdir SRC=srcdir BIN=binpath INC=header-outdir CC=C-compiler
@@ -81,7 +83,7 @@ EOF
81 } 83 }
82 $platform=$_; 84 $platform=$_;
83 } 85 }
84foreach (split / /, $OPTIONS) 86foreach (grep(!/^$/, split(/ /, $OPTIONS)))
85 { 87 {
86 print STDERR "unknown option - $_\n" if !&read_options; 88 print STDERR "unknown option - $_\n" if !&read_options;
87 } 89 }
@@ -91,7 +93,7 @@ $no_mdc2=1 if ($no_des);
91$no_ssl3=1 if ($no_md5 || $no_sha); 93$no_ssl3=1 if ($no_md5 || $no_sha);
92$no_ssl3=1 if ($no_rsa && $no_dh); 94$no_ssl3=1 if ($no_rsa && $no_dh);
93 95
94$no_ssl2=1 if ($no_md5 || $no_rsa); 96$no_ssl2=1 if ($no_md5);
95$no_ssl2=1 if ($no_rsa); 97$no_ssl2=1 if ($no_rsa);
96 98
97$out_def="out"; 99$out_def="out";
@@ -101,7 +103,6 @@ $tmp_def="tmp";
101$mkdir="mkdir"; 103$mkdir="mkdir";
102 104
103($ssl,$crypto)=("ssl","crypto"); 105($ssl,$crypto)=("ssl","crypto");
104$RSAglue="RSAglue";
105$ranlib="echo ranlib"; 106$ranlib="echo ranlib";
106 107
107$cc=(defined($VARS{'CC'}))?$VARS{'CC'}:'cc'; 108$cc=(defined($VARS{'CC'}))?$VARS{'CC'}:'cc';
@@ -183,6 +184,11 @@ elsif ($platform eq "ultrix-mips")
183 require "ultrix.pl"; 184 require "ultrix.pl";
184 $unix=1; 185 $unix=1;
185 } 186 }
187elsif ($platform eq "OS2-EMX")
188 {
189 $wc=1;
190 require 'OS2-EMX.pl';
191 }
186else 192else
187 { 193 {
188 require "unix.pl"; 194 require "unix.pl";
@@ -197,28 +203,31 @@ $inc_dir=(defined($VARS{'INC'}))?$VARS{'INC'}:$inc_def;
197 203
198$bin_dir=$bin_dir.$o unless ((substr($bin_dir,-1,1) eq $o) || ($bin_dir eq '')); 204$bin_dir=$bin_dir.$o unless ((substr($bin_dir,-1,1) eq $o) || ($bin_dir eq ''));
199 205
200$cflags.=" -DNO_IDEA" if $no_idea; 206$cflags.=" -DOPENSSL_NO_IDEA" if $no_idea;
201$cflags.=" -DNO_RC2" if $no_rc2; 207$cflags.=" -DOPENSSL_NO_AES" if $no_aes;
202$cflags.=" -DNO_RC4" if $no_rc4; 208$cflags.=" -DOPENSSL_NO_RC2" if $no_rc2;
203$cflags.=" -DNO_RC5" if $no_rc5; 209$cflags.=" -DOPENSSL_NO_RC4" if $no_rc4;
204$cflags.=" -DNO_MD2" if $no_md2; 210$cflags.=" -DOPENSSL_NO_RC5" if $no_rc5;
205$cflags.=" -DNO_MD4" if $no_md4; 211$cflags.=" -DOPENSSL_NO_MD2" if $no_md2;
206$cflags.=" -DNO_MD5" if $no_md5; 212$cflags.=" -DOPENSSL_NO_MD4" if $no_md4;
207$cflags.=" -DNO_SHA" if $no_sha; 213$cflags.=" -DOPENSSL_NO_MD5" if $no_md5;
208$cflags.=" -DNO_SHA1" if $no_sha1; 214$cflags.=" -DOPENSSL_NO_SHA" if $no_sha;
209$cflags.=" -DNO_RIPEMD" if $no_rmd160; 215$cflags.=" -DOPENSSL_NO_SHA1" if $no_sha1;
210$cflags.=" -DNO_MDC2" if $no_mdc2; 216$cflags.=" -DOPENSSL_NO_RIPEMD" if $no_rmd160;
211$cflags.=" -DNO_BF" if $no_bf; 217$cflags.=" -DOPENSSL_NO_MDC2" if $no_mdc2;
212$cflags.=" -DNO_CAST" if $no_cast; 218$cflags.=" -DOPENSSL_NO_BF" if $no_bf;
213$cflags.=" -DNO_DES" if $no_des; 219$cflags.=" -DOPENSSL_NO_CAST" if $no_cast;
214$cflags.=" -DNO_RSA" if $no_rsa; 220$cflags.=" -DOPENSSL_NO_DES" if $no_des;
215$cflags.=" -DNO_DSA" if $no_dsa; 221$cflags.=" -DOPENSSL_NO_RSA" if $no_rsa;
216$cflags.=" -DNO_DH" if $no_dh; 222$cflags.=" -DOPENSSL_NO_DSA" if $no_dsa;
217$cflags.=" -DNO_SOCK" if $no_sock; 223$cflags.=" -DOPENSSL_NO_DH" if $no_dh;
218$cflags.=" -DNO_SSL2" if $no_ssl2; 224$cflags.=" -DOPENSSL_NO_SOCK" if $no_sock;
219$cflags.=" -DNO_SSL3" if $no_ssl3; 225$cflags.=" -DOPENSSL_NO_SSL2" if $no_ssl2;
220$cflags.=" -DNO_ERR" if $no_err; 226$cflags.=" -DOPENSSL_NO_SSL3" if $no_ssl3;
221$cflags.=" -DRSAref" if $rsaref ne ""; 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 "";
222 231
223## if ($unix) 232## if ($unix)
224## { $cflags="$c_flags" if ($c_flags ne ""); } 233## { $cflags="$c_flags" if ($c_flags ne ""); }
@@ -227,6 +236,9 @@ $cflags.=" -DRSAref" if $rsaref ne "";
227 236
228$ex_libs="$l_flags$ex_libs" if ($l_flags ne ""); 237$ex_libs="$l_flags$ex_libs" if ($l_flags ne "");
229 238
239%shlib_ex_cflags=("SSL" => " -DOPENSSL_BUILD_SHLIBSSL",
240 "CRYPTO" => " -DOPENSSL_BUILD_SHLIBCRYPTO");
241
230if ($msdos) 242if ($msdos)
231 { 243 {
232 $banner ="\t\@echo Make sure you have run 'perl Configure $platform' in the\n"; 244 $banner ="\t\@echo Make sure you have run 'perl Configure $platform' in the\n";
@@ -319,7 +331,6 @@ ASM=$bin_dir$asm
319E_EXE=openssl 331E_EXE=openssl
320SSL=$ssl 332SSL=$ssl
321CRYPTO=$crypto 333CRYPTO=$crypto
322RSAGLUE=$RSAglue
323 334
324# BIN_D - Binary output directory 335# BIN_D - Binary output directory
325# TEST_D - Binary test file output directory 336# TEST_D - Binary test file output directory
@@ -338,14 +349,12 @@ INCL_D=\$(TMP_D)
338 349
339O_SSL= \$(LIB_D)$o$plib\$(SSL)$shlibp 350O_SSL= \$(LIB_D)$o$plib\$(SSL)$shlibp
340O_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$shlibp 351O_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$shlibp
341O_RSAGLUE= \$(LIB_D)$o$plib\$(RSAGLUE)$libp
342SO_SSL= $plib\$(SSL)$so_shlibp 352SO_SSL= $plib\$(SSL)$so_shlibp
343SO_CRYPTO= $plib\$(CRYPTO)$so_shlibp 353SO_CRYPTO= $plib\$(CRYPTO)$so_shlibp
344L_SSL= \$(LIB_D)$o$plib\$(SSL)$libp 354L_SSL= \$(LIB_D)$o$plib\$(SSL)$libp
345L_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$libp 355L_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$libp
346 356
347L_LIBS= \$(L_SSL) \$(L_CRYPTO) 357L_LIBS= \$(L_SSL) \$(L_CRYPTO)
348#L_LIBS= \$(O_SSL) \$(O_RSAGLUE) -lrsaref \$(O_CRYPTO)
349 358
350###################################################### 359######################################################
351# Don't touch anything below this point 360# Don't touch anything below this point
@@ -355,7 +364,7 @@ INC=-I\$(INC_D) -I\$(INCL_D)
355APP_CFLAGS=\$(INC) \$(CFLAG) \$(APP_CFLAG) 364APP_CFLAGS=\$(INC) \$(CFLAG) \$(APP_CFLAG)
356LIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) 365LIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG)
357SHLIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) \$(SHLIB_CFLAG) 366SHLIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) \$(SHLIB_CFLAG)
358LIBS_DEP=\$(O_CRYPTO) \$(O_RSAGLUE) \$(O_SSL) 367LIBS_DEP=\$(O_CRYPTO) \$(O_SSL)
359 368
360############################################# 369#############################################
361EOF 370EOF
@@ -527,20 +536,12 @@ foreach (values %lib_nam)
527 $lib_obj=$lib_obj{$_}; 536 $lib_obj=$lib_obj{$_};
528 local($slib)=$shlib; 537 local($slib)=$shlib;
529 538
530 $slib=0 if ($_ eq "RSAGLUE");
531
532 if (($_ eq "SSL") && $no_ssl2 && $no_ssl3) 539 if (($_ eq "SSL") && $no_ssl2 && $no_ssl3)
533 { 540 {
534 $rules.="\$(O_SSL):\n\n"; 541 $rules.="\$(O_SSL):\n\n";
535 next; 542 next;
536 } 543 }
537 544
538 if (($_ eq "RSAGLUE") && $no_rsa)
539 {
540 $rules.="\$(O_RSAGLUE):\n\n";
541 next;
542 }
543
544 if (($bn_asm_obj ne "") && ($_ eq "CRYPTO")) 545 if (($bn_asm_obj ne "") && ($_ eq "CRYPTO"))
545 { 546 {
546 $lib_obj =~ s/\s\S*\/bn_asm\S*/ \$(BN_ASM_OBJ)/; 547 $lib_obj =~ s/\s\S*\/bn_asm\S*/ \$(BN_ASM_OBJ)/;
@@ -593,7 +594,7 @@ foreach (values %lib_nam)
593 $rules.=&do_asm_rule($rmd160_asm_obj,$rmd160_asm_src); 594 $rules.=&do_asm_rule($rmd160_asm_obj,$rmd160_asm_src);
594 } 595 }
595 $defs.=&do_defs(${_}."OBJ",$lib_obj,"\$(OBJ_D)",$obj); 596 $defs.=&do_defs(${_}."OBJ",$lib_obj,"\$(OBJ_D)",$obj);
596 $lib=($slib)?" \$(SHLIB_CFLAGS)":" \$(LIB_CFLAGS)"; 597 $lib=($slib)?" \$(SHLIB_CFLAGS)".$shlib_ex_cflags{$_}:" \$(LIB_CFLAGS)";
597 $rules.=&do_compile_rule("\$(OBJ_D)",$lib_obj{$_},$lib); 598 $rules.=&do_compile_rule("\$(OBJ_D)",$lib_obj{$_},$lib);
598 } 599 }
599 600
@@ -606,8 +607,6 @@ foreach (split(/\s+/,$test))
606 } 607 }
607 608
608$rules.= &do_lib_rule("\$(SSLOBJ)","\$(O_SSL)",$ssl,$shlib,"\$(SO_SSL)"); 609$rules.= &do_lib_rule("\$(SSLOBJ)","\$(O_SSL)",$ssl,$shlib,"\$(SO_SSL)");
609$rules.= &do_lib_rule("\$(RSAGLUEOBJ)","\$(O_RSAGLUE)",$RSAglue,0,"")
610 unless $no_rsa;
611$rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib,"\$(SO_CRYPTO)"); 610$rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib,"\$(SO_CRYPTO)");
612 611
613$rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)"); 612$rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)");
@@ -634,6 +633,7 @@ sub var_add
634 local(@a,$_,$ret); 633 local(@a,$_,$ret);
635 634
636 return("") if $no_idea && $dir =~ /\/idea/; 635 return("") if $no_idea && $dir =~ /\/idea/;
636 return("") if $no_aes && $dir =~ /\/aes/;
637 return("") if $no_rc2 && $dir =~ /\/rc2/; 637 return("") if $no_rc2 && $dir =~ /\/rc2/;
638 return("") if $no_rc4 && $dir =~ /\/rc4/; 638 return("") if $no_rc4 && $dir =~ /\/rc4/;
639 return("") if $no_rc5 && $dir =~ /\/rc5/; 639 return("") if $no_rc5 && $dir =~ /\/rc5/;
@@ -659,7 +659,8 @@ sub var_add
659 659
660 @a=grep(!/^e_.*_3d$/,@a) if $no_des; 660 @a=grep(!/^e_.*_3d$/,@a) if $no_des;
661 @a=grep(!/^e_.*_d$/,@a) if $no_des; 661 @a=grep(!/^e_.*_d$/,@a) if $no_des;
662 @a=grep(!/^e_.*_i$/,@a) if $no_idea; 662 @a=grep(!/^e_.*_ae$/,@a) if $no_idea;
663 @a=grep(!/^e_.*_i$/,@a) if $no_aes;
663 @a=grep(!/^e_.*_r2$/,@a) if $no_rc2; 664 @a=grep(!/^e_.*_r2$/,@a) if $no_rc2;
664 @a=grep(!/^e_.*_r5$/,@a) if $no_rc5; 665 @a=grep(!/^e_.*_r5$/,@a) if $no_rc5;
665 @a=grep(!/^e_.*_bf$/,@a) if $no_bf; 666 @a=grep(!/^e_.*_bf$/,@a) if $no_bf;
@@ -858,6 +859,7 @@ sub read_options
858 elsif (/^no-rc4$/) { $no_rc4=1; } 859 elsif (/^no-rc4$/) { $no_rc4=1; }
859 elsif (/^no-rc5$/) { $no_rc5=1; } 860 elsif (/^no-rc5$/) { $no_rc5=1; }
860 elsif (/^no-idea$/) { $no_idea=1; } 861 elsif (/^no-idea$/) { $no_idea=1; }
862 elsif (/^no-aes$/) { $no_aes=1; }
861 elsif (/^no-des$/) { $no_des=1; } 863 elsif (/^no-des$/) { $no_des=1; }
862 elsif (/^no-bf$/) { $no_bf=1; } 864 elsif (/^no-bf$/) { $no_bf=1; }
863 elsif (/^no-cast$/) { $no_cast=1; } 865 elsif (/^no-cast$/) { $no_cast=1; }
@@ -873,6 +875,7 @@ sub read_options
873 elsif (/^no-dsa$/) { $no_dsa=1; } 875 elsif (/^no-dsa$/) { $no_dsa=1; }
874 elsif (/^no-dh$/) { $no_dh=1; } 876 elsif (/^no-dh$/) { $no_dh=1; }
875 elsif (/^no-hmac$/) { $no_hmac=1; } 877 elsif (/^no-hmac$/) { $no_hmac=1; }
878 elsif (/^no-aes$/) { $no_aes=1; }
876 elsif (/^no-asm$/) { $no_asm=1; } 879 elsif (/^no-asm$/) { $no_asm=1; }
877 elsif (/^nasm$/) { $nasm=1; } 880 elsif (/^nasm$/) { $nasm=1; }
878 elsif (/^gaswin$/) { $gaswin=1; } 881 elsif (/^gaswin$/) { $gaswin=1; }
@@ -880,12 +883,15 @@ sub read_options
880 elsif (/^no-ssl3$/) { $no_ssl3=1; } 883 elsif (/^no-ssl3$/) { $no_ssl3=1; }
881 elsif (/^no-err$/) { $no_err=1; } 884 elsif (/^no-err$/) { $no_err=1; }
882 elsif (/^no-sock$/) { $no_sock=1; } 885 elsif (/^no-sock$/) { $no_sock=1; }
886 elsif (/^no-krb5$/) { $no_krb5=1; }
887 elsif (/^no-ec$/) { $no_ec=1; }
883 888
884 elsif (/^just-ssl$/) { $no_rc2=$no_idea=$no_des=$no_bf=$no_cast=1; 889 elsif (/^just-ssl$/) { $no_rc2=$no_idea=$no_des=$no_bf=$no_cast=1;
885 $no_md2=$no_sha=$no_mdc2=$no_dsa=$no_dh=1; 890 $no_md2=$no_sha=$no_mdc2=$no_dsa=$no_dh=1;
886 $no_ssl2=$no_err=$no_rmd160=$no_rc5=1; } 891 $no_ssl2=$no_err=$no_rmd160=$no_rc5=1;
892 $no_aes=1; }
887 893
888 elsif (/^rsaref$/) { $rsaref=1; } 894 elsif (/^rsaref$/) { }
889 elsif (/^gcc$/) { $gcc=1; } 895 elsif (/^gcc$/) { $gcc=1; }
890 elsif (/^debug$/) { $debug=1; } 896 elsif (/^debug$/) { $debug=1; }
891 elsif (/^profile$/) { $profile=1; } 897 elsif (/^profile$/) { $profile=1; }
diff --git a/src/lib/libcrypto/util/mkdef.pl b/src/lib/libcrypto/util/mkdef.pl
index ba453358cf..071036a6d2 100644
--- a/src/lib/libcrypto/util/mkdef.pl
+++ b/src/lib/libcrypto/util/mkdef.pl
@@ -37,34 +37,38 @@
37# - "platforms" is empty if it exists on all platforms, otherwise it contains 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 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 39# for those platforms, or prepended with a "!" if not. This helps resolve
40# symbol name replacements for platforms where the names are too long for the 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 41# compiler or linker, or if the systems is case insensitive and there is a
42# clash. This script assumes those redefinitions are place in the file 42# clash, or the symbol is implemented differently (see
43# crypto/symhacks.h. 43# EXPORT_VAR_AS_FUNCTION). This script assumes renaming of symbols is found
44# The semantics for the platforms list is a bit complicated. The rule of 44# in the file crypto/symhacks.h.
45# thumb is that the list is exclusive, but it seems to mean different things. 45# The semantics for the platforms is that every item is checked against the
46# So, if the list is all negatives (like "!VMS,!WIN16"), the symbol exists 46# enviroment. For the negative items ("!FOO"), if any of them is false
47# on all platforms except those listed. If the list is all positives (like 47# (i.e. "FOO" is true) in the enviroment, the corresponding symbol can't be
48# "VMS,WIN16"), the symbol exists only on those platforms and nowhere else. 48# used. For the positive itms, if all of them are false in the environment,
49# The combination of positives and negatives will act as if the positives 49# the corresponding symbol can't be used. Any combination of positive and
50# weren't there. 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. 51# - "kind" is "FUNCTION" or "VARIABLE". The meaning of that is obvious.
52# - "algorithms" is a comma-separated list of algorithm names. This helps 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 53# exclude symbols that are part of an algorithm that some user wants to
54# exclude. 54# exclude.
55# 55#
56 56
57my $debug=0;
58
57my $crypto_num= "util/libeay.num"; 59my $crypto_num= "util/libeay.num";
58my $ssl_num= "util/ssleay.num"; 60my $ssl_num= "util/ssleay.num";
59 61
60my $do_update = 0; 62my $do_update = 0;
61my $do_rewrite = 0; 63my $do_rewrite = 1;
62my $do_crypto = 0; 64my $do_crypto = 0;
63my $do_ssl = 0; 65my $do_ssl = 0;
64my $do_ctest = 0; 66my $do_ctest = 0;
65my $do_ctestall = 0; 67my $do_ctestall = 0;
66my $rsaref = 0; 68my $do_checkexist = 0;
67 69
70my $VMSVAX=0;
71my $VMSAlpha=0;
68my $VMS=0; 72my $VMS=0;
69my $W32=0; 73my $W32=0;
70my $W16=0; 74my $W16=0;
@@ -72,11 +76,20 @@ my $NT=0;
72# Set this to make typesafe STACK definitions appear in DEF 76# Set this to make typesafe STACK definitions appear in DEF
73my $safe_stack_def = 0; 77my $safe_stack_def = 0;
74 78
75my @known_platforms = ( "__FreeBSD__", "VMS", "WIN16", "WIN32", 79my @known_platforms = ( "__FreeBSD__", "PERL5", "NeXT",
76 "WINNT", "PERL5", "NeXT" ); 80 "EXPORT_VAR_AS_FUNCTION" );
81my @known_ossl_platforms = ( "VMS", "WIN16", "WIN32", "WINNT" );
77my @known_algorithms = ( "RC2", "RC4", "RC5", "IDEA", "DES", "BF", 82my @known_algorithms = ( "RC2", "RC4", "RC5", "IDEA", "DES", "BF",
78 "CAST", "MD2", "MD4", "MD5", "SHA", "RIPEMD", 83 "CAST", "MD2", "MD4", "MD5", "SHA", "SHA0", "SHA1",
79 "MDC2", "RSA", "DSA", "DH", "HMAC", "FP_API" ); 84 "RIPEMD",
85 "MDC2", "RSA", "DSA", "DH", "EC", "HMAC", "AES",
86 # Envelope "algorithms"
87 "EVP", "X509", "ASN1_TYPEDEFS",
88 # Helper "algorithms"
89 "BIO", "COMP", "BUFFER", "LHASH", "STACK", "ERR",
90 "LOCKING",
91 # External "algorithms"
92 "FP_API", "STDIO", "SOCK", "KRB5" );
80 93
81my $options=""; 94my $options="";
82open(IN,"<Makefile.ssl") || die "unable to open Makefile.ssl!\n"; 95open(IN,"<Makefile.ssl") || die "unable to open Makefile.ssl!\n";
@@ -91,19 +104,28 @@ close(IN);
91my $no_rc2; my $no_rc4; my $no_rc5; my $no_idea; my $no_des; my $no_bf; 104my $no_rc2; my $no_rc4; my $no_rc5; my $no_idea; my $no_des; my $no_bf;
92my $no_cast; 105my $no_cast;
93my $no_md2; my $no_md4; my $no_md5; my $no_sha; my $no_ripemd; my $no_mdc2; 106my $no_md2; my $no_md4; my $no_md5; my $no_sha; my $no_ripemd; my $no_mdc2;
94my $no_rsa; my $no_dsa; my $no_dh; my $no_hmac=0; 107my $no_rsa; my $no_dsa; my $no_dh; my $no_hmac=0; my $no_aes; my $no_krb5;
108my $no_ec;
95my $no_fp_api; 109my $no_fp_api;
96 110
97foreach (@ARGV, split(/ /, $options)) 111foreach (@ARGV, split(/ /, $options))
98 { 112 {
113 $debug=1 if $_ eq "debug";
99 $W32=1 if $_ eq "32"; 114 $W32=1 if $_ eq "32";
100 $W16=1 if $_ eq "16"; 115 $W16=1 if $_ eq "16";
101 if($_ eq "NT") { 116 if($_ eq "NT") {
102 $W32 = 1; 117 $W32 = 1;
103 $NT = 1; 118 $NT = 1;
104 } 119 }
120 if ($_ eq "VMS-VAX") {
121 $VMS=1;
122 $VMSVAX=1;
123 }
124 if ($_ eq "VMS-Alpha") {
125 $VMS=1;
126 $VMSAlpha=1;
127 }
105 $VMS=1 if $_ eq "VMS"; 128 $VMS=1 if $_ eq "VMS";
106 $rsaref=1 if $_ eq "rsaref";
107 129
108 $do_ssl=1 if $_ eq "ssleay"; 130 $do_ssl=1 if $_ eq "ssleay";
109 $do_ssl=1 if $_ eq "ssl"; 131 $do_ssl=1 if $_ eq "ssl";
@@ -113,6 +135,7 @@ foreach (@ARGV, split(/ /, $options))
113 $do_rewrite=1 if $_ eq "rewrite"; 135 $do_rewrite=1 if $_ eq "rewrite";
114 $do_ctest=1 if $_ eq "ctest"; 136 $do_ctest=1 if $_ eq "ctest";
115 $do_ctestall=1 if $_ eq "ctestall"; 137 $do_ctestall=1 if $_ eq "ctestall";
138 $do_checkexist=1 if $_ eq "exist";
116 #$safe_stack_def=1 if $_ eq "-DDEBUG_SAFESTACK"; 139 #$safe_stack_def=1 if $_ eq "-DDEBUG_SAFESTACK";
117 140
118 if (/^no-rc2$/) { $no_rc2=1; } 141 if (/^no-rc2$/) { $no_rc2=1; }
@@ -131,7 +154,19 @@ foreach (@ARGV, split(/ /, $options))
131 elsif (/^no-rsa$/) { $no_rsa=1; } 154 elsif (/^no-rsa$/) { $no_rsa=1; }
132 elsif (/^no-dsa$/) { $no_dsa=1; } 155 elsif (/^no-dsa$/) { $no_dsa=1; }
133 elsif (/^no-dh$/) { $no_dh=1; } 156 elsif (/^no-dh$/) { $no_dh=1; }
157 elsif (/^no-ec$/) { $no_ec=1; }
134 elsif (/^no-hmac$/) { $no_hmac=1; } 158 elsif (/^no-hmac$/) { $no_hmac=1; }
159 elsif (/^no-aes$/) { $no_aes=1; }
160 elsif (/^no-evp$/) { $no_evp=1; }
161 elsif (/^no-lhash$/) { $no_lhash=1; }
162 elsif (/^no-stack$/) { $no_stack=1; }
163 elsif (/^no-err$/) { $no_err=1; }
164 elsif (/^no-buffer$/) { $no_buffer=1; }
165 elsif (/^no-bio$/) { $no_bio=1; }
166 #elsif (/^no-locking$/) { $no_locking=1; }
167 elsif (/^no-comp$/) { $no_comp=1; }
168 elsif (/^no-dso$/) { $no_dso=1; }
169 elsif (/^no-krb5$/) { $no_krb5=1; }
135 } 170 }
136 171
137 172
@@ -147,7 +182,7 @@ if ($W16) {
147 182
148if (!$do_ssl && !$do_crypto) 183if (!$do_ssl && !$do_crypto)
149 { 184 {
150 print STDERR "usage: $0 ( ssl | crypto ) [ 16 | 32 | NT ] [rsaref]\n"; 185 print STDERR "usage: $0 ( ssl | crypto ) [ 16 | 32 | NT ]\n";
151 exit(1); 186 exit(1);
152 } 187 }
153 188
@@ -157,51 +192,58 @@ $max_ssl = $max_num;
157$max_crypto = $max_num; 192$max_crypto = $max_num;
158 193
159my $ssl="ssl/ssl.h"; 194my $ssl="ssl/ssl.h";
195$ssl.=" ssl/kssl.h";
160 196
161my $crypto ="crypto/crypto.h"; 197my $crypto ="crypto/crypto.h";
162$crypto.=" crypto/des/des.h" unless $no_des; 198$crypto.=" crypto/des/des.h crypto/des/des_old.h" ; # unless $no_des;
163$crypto.=" crypto/idea/idea.h" unless $no_idea; 199$crypto.=" crypto/idea/idea.h" ; # unless $no_idea;
164$crypto.=" crypto/rc4/rc4.h" unless $no_rc4; 200$crypto.=" crypto/rc4/rc4.h" ; # unless $no_rc4;
165$crypto.=" crypto/rc5/rc5.h" unless $no_rc5; 201$crypto.=" crypto/rc5/rc5.h" ; # unless $no_rc5;
166$crypto.=" crypto/rc2/rc2.h" unless $no_rc2; 202$crypto.=" crypto/rc2/rc2.h" ; # unless $no_rc2;
167$crypto.=" crypto/bf/blowfish.h" unless $no_bf; 203$crypto.=" crypto/bf/blowfish.h" ; # unless $no_bf;
168$crypto.=" crypto/cast/cast.h" unless $no_cast; 204$crypto.=" crypto/cast/cast.h" ; # unless $no_cast;
169$crypto.=" crypto/md2/md2.h" unless $no_md2; 205$crypto.=" crypto/md2/md2.h" ; # unless $no_md2;
170$crypto.=" crypto/md4/md4.h" unless $no_md4; 206$crypto.=" crypto/md4/md4.h" ; # unless $no_md4;
171$crypto.=" crypto/md5/md5.h" unless $no_md5; 207$crypto.=" crypto/md5/md5.h" ; # unless $no_md5;
172$crypto.=" crypto/mdc2/mdc2.h" unless $no_mdc2; 208$crypto.=" crypto/mdc2/mdc2.h" ; # unless $no_mdc2;
173$crypto.=" crypto/sha/sha.h" unless $no_sha; 209$crypto.=" crypto/sha/sha.h" ; # unless $no_sha;
174$crypto.=" crypto/ripemd/ripemd.h" unless $no_ripemd; 210$crypto.=" crypto/ripemd/ripemd.h" ; # unless $no_ripemd;
211$crypto.=" crypto/aes/aes.h" ; # unless $no_aes;
175 212
176$crypto.=" crypto/bn/bn.h"; 213$crypto.=" crypto/bn/bn.h";
177$crypto.=" crypto/rsa/rsa.h" unless $no_rsa; 214$crypto.=" crypto/rsa/rsa.h" ; # unless $no_rsa;
178$crypto.=" crypto/dsa/dsa.h" unless $no_dsa; 215$crypto.=" crypto/dsa/dsa.h" ; # unless $no_dsa;
179$crypto.=" crypto/dh/dh.h" unless $no_dh; 216$crypto.=" crypto/dh/dh.h" ; # unless $no_dh;
180$crypto.=" crypto/hmac/hmac.h" unless $no_hmac; 217$crypto.=" crypto/ec/ec.h" ; # unless $no_ec;
218$crypto.=" crypto/hmac/hmac.h" ; # unless $no_hmac;
181 219
182$crypto.=" crypto/engine/engine.h"; 220$crypto.=" crypto/engine/engine.h";
183$crypto.=" crypto/stack/stack.h"; 221$crypto.=" crypto/stack/stack.h" ; # unless $no_stack;
184$crypto.=" crypto/buffer/buffer.h"; 222$crypto.=" crypto/buffer/buffer.h" ; # unless $no_buffer;
185$crypto.=" crypto/bio/bio.h"; 223$crypto.=" crypto/bio/bio.h" ; # unless $no_bio;
186$crypto.=" crypto/dso/dso.h"; 224$crypto.=" crypto/dso/dso.h" ; # unless $no_dso;
187$crypto.=" crypto/lhash/lhash.h"; 225$crypto.=" crypto/lhash/lhash.h" ; # unless $no_lhash;
188$crypto.=" crypto/conf/conf.h"; 226$crypto.=" crypto/conf/conf.h";
189$crypto.=" crypto/txt_db/txt_db.h"; 227$crypto.=" crypto/txt_db/txt_db.h";
190 228
191$crypto.=" crypto/evp/evp.h"; 229$crypto.=" crypto/evp/evp.h" ; # unless $no_evp;
192$crypto.=" crypto/objects/objects.h"; 230$crypto.=" crypto/objects/objects.h";
193$crypto.=" crypto/pem/pem.h"; 231$crypto.=" crypto/pem/pem.h";
194#$crypto.=" crypto/meth/meth.h"; 232#$crypto.=" crypto/meth/meth.h";
195$crypto.=" crypto/asn1/asn1.h"; 233$crypto.=" crypto/asn1/asn1.h";
234$crypto.=" crypto/asn1/asn1t.h";
196$crypto.=" crypto/asn1/asn1_mac.h"; 235$crypto.=" crypto/asn1/asn1_mac.h";
197$crypto.=" crypto/err/err.h"; 236$crypto.=" crypto/err/err.h" ; # unless $no_err;
198$crypto.=" crypto/pkcs7/pkcs7.h"; 237$crypto.=" crypto/pkcs7/pkcs7.h";
199$crypto.=" crypto/pkcs12/pkcs12.h"; 238$crypto.=" crypto/pkcs12/pkcs12.h";
200$crypto.=" crypto/x509/x509.h"; 239$crypto.=" crypto/x509/x509.h";
201$crypto.=" crypto/x509/x509_vfy.h"; 240$crypto.=" crypto/x509/x509_vfy.h";
202$crypto.=" crypto/x509v3/x509v3.h"; 241$crypto.=" crypto/x509v3/x509v3.h";
203$crypto.=" crypto/rand/rand.h"; 242$crypto.=" crypto/rand/rand.h";
204$crypto.=" crypto/comp/comp.h"; 243$crypto.=" crypto/comp/comp.h" ; # unless $no_comp;
244$crypto.=" crypto/ocsp/ocsp.h";
245$crypto.=" crypto/ui/ui.h crypto/ui/ui_compat.h";
246$crypto.=" crypto/krb5/krb5_asn.h";
205$crypto.=" crypto/tmdiff.h"; 247$crypto.=" crypto/tmdiff.h";
206 248
207my $symhacks="crypto/symhacks.h"; 249my $symhacks="crypto/symhacks.h";
@@ -217,7 +259,6 @@ if ($do_ssl == 1) {
217 if ($do_rewrite == 1) { 259 if ($do_rewrite == 1) {
218 open(OUT, ">$ssl_num"); 260 open(OUT, ">$ssl_num");
219 &rewrite_numbers(*OUT,"SSLEAY",*ssl_list,@ssl_symbols); 261 &rewrite_numbers(*OUT,"SSLEAY",*ssl_list,@ssl_symbols);
220 close OUT;
221 } else { 262 } else {
222 open(OUT, ">>$ssl_num"); 263 open(OUT, ">>$ssl_num");
223 } 264 }
@@ -238,6 +279,11 @@ if($do_crypto == 1) {
238 close OUT; 279 close OUT;
239} 280}
240 281
282} elsif ($do_checkexist) {
283 &check_existing(*ssl_list, @ssl_symbols)
284 if $do_ssl == 1;
285 &check_existing(*crypto_list, @crypto_symbols)
286 if $do_crypto == 1;
241} elsif ($do_ctest || $do_ctestall) { 287} elsif ($do_ctest || $do_ctestall) {
242 288
243 print <<"EOF"; 289 print <<"EOF";
@@ -277,16 +323,21 @@ sub do_defs
277 my %platform; # For anything undefined, we assume "" 323 my %platform; # For anything undefined, we assume ""
278 my %kind; # For anything undefined, we assume "FUNCTION" 324 my %kind; # For anything undefined, we assume "FUNCTION"
279 my %algorithm; # For anything undefined, we assume "" 325 my %algorithm; # For anything undefined, we assume ""
280 my %rename; 326 my %variant;
327 my %variant_cnt; # To be able to allocate "name{n}" if "name"
328 # is the same name as the original.
281 my $cpp; 329 my $cpp;
330 my %unknown_algorithms = ();
282 331
283 foreach $file (split(/\s+/,$symhacksfile." ".$files)) 332 foreach $file (split(/\s+/,$symhacksfile." ".$files))
284 { 333 {
334 print STDERR "DEBUG: starting on $file:\n" if $debug;
285 open(IN,"<$file") || die "unable to open $file:$!\n"; 335 open(IN,"<$file") || die "unable to open $file:$!\n";
286 my $line = "", my $def= ""; 336 my $line = "", my $def= "";
287 my %tag = ( 337 my %tag = (
288 (map { $_ => 0 } @known_platforms), 338 (map { $_ => 0 } @known_platforms),
289 (map { "NO_".$_ => 0 } @known_algorithms), 339 (map { "OPENSSL_SYS_".$_ => 0 } @known_ossl_platforms),
340 (map { "OPENSSL_NO_".$_ => 0 } @known_algorithms),
290 NOPROTO => 0, 341 NOPROTO => 0,
291 PERL5 => 0, 342 PERL5 => 0,
292 _WINDLL => 0, 343 _WINDLL => 0,
@@ -294,14 +345,70 @@ sub do_defs
294 TRUE => 1, 345 TRUE => 1,
295 ); 346 );
296 my $symhacking = $file eq $symhacksfile; 347 my $symhacking = $file eq $symhacksfile;
348 my @current_platforms = ();
349 my @current_algorithms = ();
350
351 # params: symbol, alias, platforms, kind
352 # The reason to put this subroutine in a variable is that
353 # it will otherwise create it's own, unshared, version of
354 # %tag and %variant...
355 my $make_variant = sub
356 {
357 my ($s, $a, $p, $k) = @_;
358 my ($a1, $a2);
359
360 print STDERR "DEBUG: make_variant: Entered with ",$s,", ",$a,", ",(defined($p)?$p:""),", ",(defined($k)?$k:""),"\n" if $debug;
361 if (defined($p))
362 {
363 $a1 = join(",",$p,
364 grep(!/^$/,
365 map { $tag{$_} == 1 ? $_ : "" }
366 @known_platforms));
367 }
368 else
369 {
370 $a1 = join(",",
371 grep(!/^$/,
372 map { $tag{$_} == 1 ? $_ : "" }
373 @known_platforms));
374 }
375 $a2 = join(",",
376 grep(!/^$/,
377 map { $tag{"OPENSSL_SYS_".$_} == 1 ? $_ : "" }
378 @known_ossl_platforms));
379 print STDERR "DEBUG: make_variant: a1 = $a1; a2 = $a2\n" if $debug;
380 if ($a1 eq "") { $a1 = $a2; }
381 elsif ($a1 ne "" && $a2 ne "") { $a1 .= ",".$a2; }
382 if ($a eq $s)
383 {
384 if (!defined($variant_cnt{$s}))
385 {
386 $variant_cnt{$s} = 0;
387 }
388 $variant_cnt{$s}++;
389 $a .= "{$variant_cnt{$s}}";
390 }
391 my $toadd = $a.":".$a1.(defined($k)?":".$k:"");
392 my $togrep = $s.'(\{[0-9]+\})?:'.$a1.(defined($k)?":".$k:"");
393 if (!grep(/^$togrep$/,
394 split(/;/, defined($variant{$s})?$variant{$s}:""))) {
395 if (defined($variant{$s})) { $variant{$s} .= ";"; }
396 $variant{$s} .= $toadd;
397 }
398 print STDERR "DEBUG: make_variant: Exit with variant of ",$s," = ",$variant{$s},"\n" if $debug;
399 };
400
401 print STDERR "DEBUG: parsing ----------\n" if $debug;
297 while(<IN>) { 402 while(<IN>) {
298 last if (/BEGIN ERROR CODES/); 403 last if (/\/\* Error codes for the \w+ functions\. \*\//);
299 if ($line ne '') { 404 if ($line ne '') {
300 $_ = $line . $_; 405 $_ = $line . $_;
301 $line = ''; 406 $line = '';
302 } 407 }
303 408
304 if (/\\$/) { 409 if (/\\$/) {
410 chomp; # remove eol
411 chop; # remove ending backslash
305 $line = $_; 412 $line = $_;
306 next; 413 next;
307 } 414 }
@@ -314,134 +421,344 @@ sub do_defs
314 421
315 s/\/\*.*?\*\///gs; # ignore comments 422 s/\/\*.*?\*\///gs; # ignore comments
316 s/{[^{}]*}//gs; # ignore {} blocks 423 s/{[^{}]*}//gs; # ignore {} blocks
317 if (/^\#\s*ifndef (.*)/) { 424 print STDERR "DEBUG: \$_=\"$_\"\n" if $debug;
425 if (/^\#\s*ifndef\s+(.*)/) {
426 push(@tag,"-");
318 push(@tag,$1); 427 push(@tag,$1);
319 $tag{$1}=-1; 428 $tag{$1}=-1;
320 } elsif (/^\#\s*if !defined\(([^\)]+)\)/) { 429 print STDERR "DEBUG: $file: found tag $1 = -1\n" if $debug;
321 push(@tag,$1); 430 } elsif (/^\#\s*if\s+!defined\(([^\)]+)\)/) {
322 $tag{$1}=-1; 431 push(@tag,"-");
323 } elsif (/^\#\s*ifdef (.*)/) { 432 if (/^\#\s*if\s+(!defined\(([^\)]+)\)(\s+\&\&\s+!defined\(([^\)]+)\))*)$/) {
324 push(@tag,$1); 433 my $tmp_1 = $1;
325 $tag{$1}=1; 434 my $tmp_;
326 } elsif (/^\#\s*if defined\(([^\)]+)\)/) { 435 foreach $tmp_ (split '\&\&',$tmp_1) {
436 $tmp_ =~ /!defined\(([^\)]+)\)/;
437 print STDERR "DEBUG: $file: found tag $1 = -1\n" if $debug;
438 push(@tag,$1);
439 $tag{$1}=-1;
440 }
441 } else {
442 print STDERR "Warning: $file: complicated expression: $_" if $debug; # because it is O...
443 print STDERR "DEBUG: $file: found tag $1 = -1\n" if $debug;
444 push(@tag,$1);
445 $tag{$1}=-1;
446 }
447 } elsif (/^\#\s*ifdef\s+(.*)/) {
448 push(@tag,"-");
327 push(@tag,$1); 449 push(@tag,$1);
328 $tag{$1}=1; 450 $tag{$1}=1;
451 print STDERR "DEBUG: $file: found tag $1 = 1\n" if $debug;
452 } elsif (/^\#\s*if\s+defined\(([^\)]+)\)/) {
453 push(@tag,"-");
454 if (/^\#\s*if\s+(defined\(([^\)]+)\)(\s+\|\|\s+defined\(([^\)]+)\))*)$/) {
455 my $tmp_1 = $1;
456 my $tmp_;
457 foreach $tmp_ (split '\|\|',$tmp_1) {
458 $tmp_ =~ /defined\(([^\)]+)\)/;
459 print STDERR "DEBUG: $file: found tag $1 = 1\n" if $debug;
460 push(@tag,$1);
461 $tag{$1}=1;
462 }
463 } else {
464 print STDERR "Warning: $file: complicated expression: $_\n" if $debug; # because it is O...
465 print STDERR "DEBUG: $file: found tag $1 = 1\n" if $debug;
466 push(@tag,$1);
467 $tag{$1}=1;
468 }
329 } elsif (/^\#\s*error\s+(\w+) is disabled\./) { 469 } elsif (/^\#\s*error\s+(\w+) is disabled\./) {
330 if ($tag[$#tag] eq "NO_".$1) { 470 my $tag_i = $#tag;
331 $tag{$tag[$#tag]}=2; 471 while($tag[$tag_i] ne "-") {
472 if ($tag[$tag_i] eq "OPENSSL_NO_".$1) {
473 $tag{$tag[$tag_i]}=2;
474 print STDERR "DEBUG: $file: chaged tag $1 = 2\n" if $debug;
475 }
476 $tag_i--;
332 } 477 }
333 } elsif (/^\#\s*endif/) { 478 } elsif (/^\#\s*endif/) {
334 if ($tag{$tag[$#tag]}==2) { 479 my $tag_i = $#tag;
335 $tag{$tag[$#tag]}=-1; 480 while($tag[$tag_i] ne "-") {
336 } else { 481 my $t=$tag[$tag_i];
337 $tag{$tag[$#tag]}=0; 482 print STDERR "DEBUG: \$t=\"$t\"\n" if $debug;
483 if ($tag{$t}==2) {
484 $tag{$t}=-1;
485 } else {
486 $tag{$t}=0;
487 }
488 print STDERR "DEBUG: $file: changed tag ",$t," = ",$tag{$t},"\n" if $debug;
489 pop(@tag);
490 if ($t =~ /^OPENSSL_NO_([A-Z0-9_]+)$/) {
491 $t=$1;
492 } else {
493 $t="";
494 }
495 if ($t ne ""
496 && !grep(/^$t$/, @known_algorithms)) {
497 $unknown_algorithms{$t} = 1;
498 #print STDERR "DEBUG: Added as unknown algorithm: $t\n" if $debug;
499 }
500 $tag_i--;
338 } 501 }
339 pop(@tag); 502 pop(@tag);
340 } elsif (/^\#\s*else/) { 503 } elsif (/^\#\s*else/) {
341 my $t=$tag[$#tag]; 504 my $tag_i = $#tag;
342 $tag{$t}= -$tag{$t}; 505 while($tag[$tag_i] ne "-") {
506 my $t=$tag[$tag_i];
507 $tag{$t}= -$tag{$t};
508 print STDERR "DEBUG: $file: changed tag ",$t," = ",$tag{$t},"\n" if $debug;
509 $tag_i--;
510 }
343 } elsif (/^\#\s*if\s+1/) { 511 } elsif (/^\#\s*if\s+1/) {
512 push(@tag,"-");
344 # Dummy tag 513 # Dummy tag
345 push(@tag,"TRUE"); 514 push(@tag,"TRUE");
346 $tag{"TRUE"}=1; 515 $tag{"TRUE"}=1;
516 print STDERR "DEBUG: $file: found 1\n" if $debug;
347 } elsif (/^\#\s*if\s+0/) { 517 } elsif (/^\#\s*if\s+0/) {
518 push(@tag,"-");
348 # Dummy tag 519 # Dummy tag
349 push(@tag,"TRUE"); 520 push(@tag,"TRUE");
350 $tag{"TRUE"}=-1; 521 $tag{"TRUE"}=-1;
522 print STDERR "DEBUG: $file: found 0\n" if $debug;
351 } elsif (/^\#\s*define\s+(\w+)\s+(\w+)/ 523 } elsif (/^\#\s*define\s+(\w+)\s+(\w+)/
352 && $symhacking) { 524 && $symhacking && $tag{'TRUE'} != -1) {
353 my $s = $1; 525 # This is for aliasing. When we find an alias,
354 my $a = 526 # we have to invert
355 $2.":".join(",", grep(!/^$/, 527 &$make_variant($1,$2);
356 map { $tag{$_} == 1 ? 528 print STDERR "DEBUG: $file: defined $1 = $2\n" if $debug;
357 $_ : "" }
358 @known_platforms));
359 $rename{$s} = $a;
360 } 529 }
361 if (/^\#/) { 530 if (/^\#/) {
362 my @p = grep(!/^$/, 531 @current_platforms =
363 map { $tag{$_} == 1 ? $_ : 532 grep(!/^$/,
364 $tag{$_} == -1 ? "!".$_ : "" } 533 map { $tag{$_} == 1 ? $_ :
365 @known_platforms); 534 $tag{$_} == -1 ? "!".$_ : "" }
366 my @a = grep(!/^$/, 535 @known_platforms);
367 map { $tag{"NO_".$_} == -1 ? $_ : "" } 536 push @current_platforms
368 @known_algorithms); 537 , grep(!/^$/,
369 $def .= "#INFO:".join(',',@p).":".join(',',@a).";"; 538 map { $tag{"OPENSSL_SYS_".$_} == 1 ? $_ :
539 $tag{"OPENSSL_SYS_".$_} == -1 ? "!".$_ : "" }
540 @known_ossl_platforms);
541 @current_algorithms =
542 grep(!/^$/,
543 map { $tag{"OPENSSL_NO_".$_} == -1 ? $_ : "" }
544 @known_algorithms);
545 $def .=
546 "#INFO:"
547 .join(',',@current_platforms).":"
548 .join(',',@current_algorithms).";";
370 next; 549 next;
371 } 550 }
372 if (/^\s*DECLARE_STACK_OF\s*\(\s*(\w*)\s*\)/) { 551 if ($tag{'TRUE'} != -1) {
373 next; 552 if (/^\s*DECLARE_STACK_OF\s*\(\s*(\w*)\s*\)/) {
374 } elsif (/^\s*DECLARE_PKCS12_STACK_OF\s*\(\s*(\w*)\s*\)/) { 553 next;
375 next; 554 } elsif (/^\s*DECLARE_ASN1_ENCODE_FUNCTIONS\s*\(\s*(\w*)\s*,\s*(\w*)\s*,\s*(\w*)\s*\)/) {
376 } elsif (/^\s*DECLARE_ASN1_SET_OF\s*\(\s*(\w*)\s*\)/) { 555 $def .= "int d2i_$3(void);";
377 next; 556 $def .= "int i2d_$3(void);";
378 } elsif (/^DECLARE_PEM_rw\s*\(\s*(\w*)\s*,/ || 557 # Variant for platforms that do not
379 /^DECLARE_PEM_rw_cb\s*\(\s*(\w*)\s*,/ ) { 558 # have to access globale variables
380 # Things not in Win16 559 # in shared libraries through functions
381 $syms{"PEM_read_${1}"} = 1; 560 $def .=
382 $platform{"PEM_read_${1}"} = "!WIN16"; 561 "#INFO:"
383 $syms{"PEM_write_${1}"} = 1; 562 .join(',',"!EXPORT_VAR_AS_FUNCTION",@current_platforms).":"
384 $platform{"PEM_write_${1}"} = "!WIN16"; 563 .join(',',@current_algorithms).";";
385 # Things that are everywhere 564 $def .= "OPENSSL_EXTERN int $2_it;";
386 $syms{"PEM_read_bio_${1}"} = 1; 565 $def .=
387 $syms{"PEM_write_bio_${1}"} = 1; 566 "#INFO:"
388 if ($1 eq "RSAPrivateKey" || 567 .join(',',@current_platforms).":"
389 $1 eq "RSAPublicKey" || 568 .join(',',@current_algorithms).";";
390 $1 eq "RSA_PUBKEY") { 569 # Variant for platforms that have to
391 $algorithm{"PEM_read_${1}"} = "RSA"; 570 # access globale variables in shared
392 $algorithm{"PEM_write_${1}"} = "RSA"; 571 # libraries through functions
393 $algorithm{"PEM_read_bio_${1}"} = "RSA"; 572 &$make_variant("$2_it","$2_it",
394 $algorithm{"PEM_write_bio_${1}"} = "RSA"; 573 "EXPORT_VAR_AS_FUNCTION",
395 } 574 "FUNCTION");
396 elsif ($1 eq "DSAPrivateKey" || 575 next;
397 $1 eq "DSAparams" || 576 } elsif (/^\s*DECLARE_ASN1_FUNCTIONS_fname\s*\(\s*(\w*)\s*,\s*(\w*)\s*,\s*(\w*)\s*\)/) {
398 $1 eq "RSA_PUBKEY") { 577 $def .= "int d2i_$3(void);";
399 $algorithm{"PEM_read_${1}"} = "DSA"; 578 $def .= "int i2d_$3(void);";
400 $algorithm{"PEM_write_${1}"} = "DSA"; 579 $def .= "int $3_free(void);";
401 $algorithm{"PEM_read_bio_${1}"} = "DSA"; 580 $def .= "int $3_new(void);";
402 $algorithm{"PEM_write_bio_${1}"} = "DSA"; 581 # Variant for platforms that do not
403 } 582 # have to access globale variables
404 elsif ($1 eq "DHparams") { 583 # in shared libraries through functions
405 $algorithm{"PEM_read_${1}"} = "DH"; 584 $def .=
406 $algorithm{"PEM_write_${1}"} = "DH"; 585 "#INFO:"
407 $algorithm{"PEM_read_bio_${1}"} = "DH"; 586 .join(',',"!EXPORT_VAR_AS_FUNCTION",@current_platforms).":"
408 $algorithm{"PEM_write_bio_${1}"} = "DH"; 587 .join(',',@current_algorithms).";";
409 } 588 $def .= "OPENSSL_EXTERN int $2_it;";
410 } elsif (/^DECLARE_PEM_write\s*\(\s*(\w*)\s*,/ || 589 $def .=
411 /^DECLARE_PEM_write_cb\s*\(\s*(\w*)\s*,/ ) { 590 "#INFO:"
412 # Things not in Win16 591 .join(',',@current_platforms).":"
413 $syms{"PEM_write_${1}"} = 1; 592 .join(',',@current_algorithms).";";
414 $platform{"PEM_write_${1}"} .= ",!WIN16"; 593 # Variant for platforms that have to
415 # Things that are everywhere 594 # access globale variables in shared
416 $syms{"PEM_write_bio_${1}"} = 1; 595 # libraries through functions
417 if ($1 eq "RSAPrivateKey" || 596 &$make_variant("$2_it","$2_it",
418 $1 eq "RSAPublicKey" || 597 "EXPORT_VAR_AS_FUNCTION",
419 $1 eq "RSA_PUBKEY") { 598 "FUNCTION");
420 $algorithm{"PEM_write_${1}"} = "RSA"; 599 next;
421 $algorithm{"PEM_write_bio_${1}"} = "RSA"; 600 } elsif (/^\s*DECLARE_ASN1_FUNCTIONS\s*\(\s*(\w*)\s*\)/ ||
422 } 601 /^\s*DECLARE_ASN1_FUNCTIONS_const\s*\(\s*(\w*)\s*\)/) {
423 elsif ($1 eq "DSAPrivateKey" || 602 $def .= "int d2i_$1(void);";
424 $1 eq "DSAparams" || 603 $def .= "int i2d_$1(void);";
425 $1 eq "RSA_PUBKEY") { 604 $def .= "int $1_free(void);";
426 $algorithm{"PEM_write_${1}"} = "DSA"; 605 $def .= "int $1_new(void);";
427 $algorithm{"PEM_write_bio_${1}"} = "DSA"; 606 # Variant for platforms that do not
428 } 607 # have to access globale variables
429 elsif ($1 eq "DHparams") { 608 # in shared libraries through functions
430 $algorithm{"PEM_write_${1}"} = "DH"; 609 $def .=
431 $algorithm{"PEM_write_bio_${1}"} = "DH"; 610 "#INFO:"
432 } 611 .join(',',"!EXPORT_VAR_AS_FUNCTION",@current_platforms).":"
433 } elsif (/^DECLARE_PEM_read\s*\(\s*(\w*)\s*,/ || 612 .join(',',@current_algorithms).";";
434 /^DECLARE_PEM_read_cb\s*\(\s*(\w*)\s*,/ ) { 613 $def .= "OPENSSL_EXTERN int $1_it;";
435 # Things not in Win16 614 $def .=
436 $syms{"PEM_read_${1}"} = 1; 615 "#INFO:"
437 $platform{"PEM_read_${1}"} .= ",!WIN16"; 616 .join(',',@current_platforms).":"
438 # Things that are everywhere 617 .join(',',@current_algorithms).";";
439 $syms{"PEM_read_bio_${1}"} = 1; 618 # Variant for platforms that have to
440 } elsif ( 619 # access globale variables in shared
441 ($tag{'TRUE'} != -1) 620 # libraries through functions
442 && ($tag{'CONST_STRICT'} != 1) 621 &$make_variant("$1_it","$1_it",
443 ) 622 "EXPORT_VAR_AS_FUNCTION",
444 { 623 "FUNCTION");
624 next;
625 } elsif (/^\s*DECLARE_ASN1_ENCODE_FUNCTIONS_const\s*\(\s*(\w*)\s*,\s*(\w*)\s*\)/) {
626 $def .= "int d2i_$2(void);";
627 $def .= "int i2d_$2(void);";
628 # Variant for platforms that do not
629 # have to access globale variables
630 # in shared libraries through functions
631 $def .=
632 "#INFO:"
633 .join(',',"!EXPORT_VAR_AS_FUNCTION",@current_platforms).":"
634 .join(',',@current_algorithms).";";
635 $def .= "OPENSSL_EXTERN int $2_it;";
636 $def .=
637 "#INFO:"
638 .join(',',@current_platforms).":"
639 .join(',',@current_algorithms).";";
640 # Variant for platforms that have to
641 # access globale variables in shared
642 # libraries through functions
643 &$make_variant("$2_it","$2_it",
644 "EXPORT_VAR_AS_FUNCTION",
645 "FUNCTION");
646 next;
647 } elsif (/^\s*DECLARE_ASN1_FUNCTIONS_name\s*\(\s*(\w*)\s*,\s*(\w*)\s*\)/) {
648 $def .= "int d2i_$2(void);";
649 $def .= "int i2d_$2(void);";
650 $def .= "int $2_free(void);";
651 $def .= "int $2_new(void);";
652 # Variant for platforms that do not
653 # have to access globale variables
654 # in shared libraries through functions
655 $def .=
656 "#INFO:"
657 .join(',',"!EXPORT_VAR_AS_FUNCTION",@current_platforms).":"
658 .join(',',@current_algorithms).";";
659 $def .= "OPENSSL_EXTERN int $2_it;";
660 $def .=
661 "#INFO:"
662 .join(',',@current_platforms).":"
663 .join(',',@current_algorithms).";";
664 # Variant for platforms that have to
665 # access globale variables in shared
666 # libraries through functions
667 &$make_variant("$2_it","$2_it",
668 "EXPORT_VAR_AS_FUNCTION",
669 "FUNCTION");
670 next;
671 } elsif (/^\s*DECLARE_ASN1_ITEM\s*\(\s*(\w*)\s*\)/) {
672 # Variant for platforms that do not
673 # have to access globale variables
674 # in shared libraries through functions
675 $def .=
676 "#INFO:"
677 .join(',',"!EXPORT_VAR_AS_FUNCTION",@current_platforms).":"
678 .join(',',@current_algorithms).";";
679 $def .= "OPENSSL_EXTERN int $1_it;";
680 $def .=
681 "#INFO:"
682 .join(',',@current_platforms).":"
683 .join(',',@current_algorithms).";";
684 # Variant for platforms that have to
685 # access globale variables in shared
686 # libraries through functions
687 &$make_variant("$1_it","$1_it",
688 "EXPORT_VAR_AS_FUNCTION",
689 "FUNCTION");
690 next;
691 } elsif (/^\s*DECLARE_ASN1_SET_OF\s*\(\s*(\w*)\s*\)/) {
692 next;
693 } elsif (/^\s*DECLARE_PKCS12_STACK_OF\s*\(\s*(\w*)\s*\)/) {
694 next;
695 } elsif (/^DECLARE_PEM_rw\s*\(\s*(\w*)\s*,/ ||
696 /^DECLARE_PEM_rw_cb\s*\(\s*(\w*)\s*,/ ) {
697 # Things not in Win16
698 $def .=
699 "#INFO:"
700 .join(',',"!WIN16",@current_platforms).":"
701 .join(',',@current_algorithms).";";
702 $def .= "int PEM_read_$1(void);";
703 $def .= "int PEM_write_$1(void);";
704 $def .=
705 "#INFO:"
706 .join(',',@current_platforms).":"
707 .join(',',@current_algorithms).";";
708 # Things that are everywhere
709 $def .= "int PEM_read_bio_$1(void);";
710 $def .= "int PEM_write_bio_$1(void);";
711 next;
712 } elsif (/^DECLARE_PEM_write\s*\(\s*(\w*)\s*,/ ||
713 /^DECLARE_PEM_write_cb\s*\(\s*(\w*)\s*,/ ) {
714 # Things not in Win16
715 $def .=
716 "#INFO:"
717 .join(',',"!WIN16",@current_platforms).":"
718 .join(',',@current_algorithms).";";
719 $def .= "int PEM_write_$1(void);";
720 $def .=
721 "#INFO:"
722 .join(',',@current_platforms).":"
723 .join(',',@current_algorithms).";";
724 # Things that are everywhere
725 $def .= "int PEM_write_bio_$1(void);";
726 next;
727 } elsif (/^DECLARE_PEM_read\s*\(\s*(\w*)\s*,/ ||
728 /^DECLARE_PEM_read_cb\s*\(\s*(\w*)\s*,/ ) {
729 # Things not in Win16
730 $def .=
731 "#INFO:"
732 .join(',',"!WIN16",@current_platforms).":"
733 .join(',',@current_algorithms).";";
734 $def .= "int PEM_read_$1(void);";
735 $def .=
736 "#INFO:"
737 .join(',',@current_platforms).":"
738 .join(',',@current_algorithms).";";
739 # Things that are everywhere
740 $def .= "int PEM_read_bio_$1(void);";
741 next;
742 } elsif (/^OPENSSL_DECLARE_GLOBAL\s*\(\s*(\w*)\s*,\s*(\w*)\s*\)/) {
743 # Variant for platforms that do not
744 # have to access globale variables
745 # in shared libraries through functions
746 $def .=
747 "#INFO:"
748 .join(',',"!EXPORT_VAR_AS_FUNCTION",@current_platforms).":"
749 .join(',',@current_algorithms).";";
750 $def .= "OPENSSL_EXTERN int _shadow_$2;";
751 $def .=
752 "#INFO:"
753 .join(',',@current_platforms).":"
754 .join(',',@current_algorithms).";";
755 # Variant for platforms that have to
756 # access globale variables in shared
757 # libraries through functions
758 &$make_variant("_shadow_$2","_shadow_$2",
759 "EXPORT_VAR_AS_FUNCTION",
760 "FUNCTION");
761 } elsif ($tag{'CONST_STRICT'} != 1) {
445 if (/\{|\/\*|\([^\)]*$/) { 762 if (/\{|\/\*|\([^\)]*$/) {
446 $line = $_; 763 $line = $_;
447 } else { 764 } else {
@@ -449,11 +766,13 @@ sub do_defs
449 } 766 }
450 } 767 }
451 } 768 }
769 }
452 close(IN); 770 close(IN);
453 771
454 my $algs; 772 my $algs;
455 my $plays; 773 my $plays;
456 774
775 print STDERR "DEBUG: postprocessing ----------\n" if $debug;
457 foreach (split /;/, $def) { 776 foreach (split /;/, $def) {
458 my $s; my $k = "FUNCTION"; my $p; my $a; 777 my $s; my $k = "FUNCTION"; my $p; my $a;
459 s/^[\n\s]*//g; 778 s/^[\n\s]*//g;
@@ -462,26 +781,32 @@ sub do_defs
462 next if(/typedef\W/); 781 next if(/typedef\W/);
463 next if(/\#define/); 782 next if(/\#define/);
464 783
784 print STDERR "DEBUG: \$_ = \"$_\"\n" if $debug;
465 if (/^\#INFO:([^:]*):(.*)$/) { 785 if (/^\#INFO:([^:]*):(.*)$/) {
466 $plats = $1; 786 $plats = $1;
467 $algs = $2; 787 $algs = $2;
788 print STDERR "DEBUG: found info on platforms ($plats) and algorithms ($algs)\n" if $debug;
468 next; 789 next;
469 } elsif (/^\s*OPENSSL_EXTERN\s.*?(\w+)(\[[0-9]*\])*\s*$/) { 790 } elsif (/^\s*OPENSSL_EXTERN\s.*?(\w+(\{[0-9]+\})?)(\[[0-9]*\])*\s*$/) {
470 $s = $1; 791 $s = $1;
471 $k = "VARIABLE"; 792 $k = "VARIABLE";
472 } elsif (/\(\*(\w*)\([^\)]+/) { 793 print STDERR "DEBUG: found external variable $s\n" if $debug;
794 } elsif (/\(\*(\w*(\{[0-9]+\})?)\([^\)]+/) {
473 $s = $1; 795 $s = $1;
796 print STDERR "DEBUG: found ANSI C function $s\n" if $debug;
474 } elsif (/\w+\W+(\w+)\W*\(\s*\)$/s) { 797 } elsif (/\w+\W+(\w+)\W*\(\s*\)$/s) {
475 # K&R C 798 # K&R C
799 print STDERR "DEBUG: found K&R C function $s\n" if $debug;
476 next; 800 next;
477 } elsif (/\w+\W+\w+\W*\(.*\)$/s) { 801 } elsif (/\w+\W+\w+(\{[0-9]+\})?\W*\(.*\)$/s) {
478 while (not /\(\)$/s) { 802 while (not /\(\)$/s) {
479 s/[^\(\)]*\)$/\)/s; 803 s/[^\(\)]*\)$/\)/s;
480 s/\([^\(\)]*\)\)$/\)/s; 804 s/\([^\(\)]*\)\)$/\)/s;
481 } 805 }
482 s/\(void\)//; 806 s/\(void\)//;
483 /(\w+)\W*\(\)/s; 807 /(\w+(\{[0-9]+\})?)\W*\(\)/s;
484 $s = $1; 808 $s = $1;
809 print STDERR "DEBUG: found function $s\n" if $debug;
485 } elsif (/\(/ and not (/=/)) { 810 } elsif (/\(/ and not (/=/)) {
486 print STDERR "File $file: cannot parse: $_;\n"; 811 print STDERR "File $file: cannot parse: $_;\n";
487 next; 812 next;
@@ -512,67 +837,61 @@ sub do_defs
512 $a .= ",RSA" if($s =~ /RSAPrivateKey/); 837 $a .= ",RSA" if($s =~ /RSAPrivateKey/);
513 $a .= ",RSA" if($s =~ /SSLv23?_((client|server)_)?method/); 838 $a .= ",RSA" if($s =~ /SSLv23?_((client|server)_)?method/);
514 839
515 $platform{$s} .= ','.$p; 840 $platform{$s} =
841 &reduce_platforms((defined($platform{$s})?$platform{$s}.',':"").$p);
516 $algorithm{$s} .= ','.$a; 842 $algorithm{$s} .= ','.$a;
517 843
518 if (defined($rename{$s})) { 844 if (defined($variant{$s})) {
519 (my $r, my $p) = split(/:/,$rename{$s}); 845 foreach $v (split /;/,$variant{$s}) {
520 my @ip = map { /^!(.*)$/ ? $1 : "!".$_ } split /,/, $p; 846 (my $r, my $p, my $k) = split(/:/,$v);
521 $syms{$r} = 1; 847 my $ip = join ',',map({ /^!(.*)$/ ? $1 : "!".$_ } split /,/, $p);
522 $kind{$r} = $kind{$s}."(".$s.")"; 848 $syms{$r} = 1;
523 $algorithm{$r} = $algorithm{$s}; 849 if (!defined($k)) { $k = $kind{$s}; }
524 $platform{$r} = $platform{$s}.",".$p; 850 $kind{$r} = $k."(".$s.")";
525 $platform{$s} .= ','.join(',', @ip).','.join(',', @ip); 851 $algorithm{$r} = $algorithm{$s};
852 $platform{$r} = &reduce_platforms($platform{$s}.",".$p.",".$p);
853 $platform{$s} = &reduce_platforms($platform{$s}.','.$ip.','.$ip);
854 print STDERR "DEBUG: \$variant{\"$s\"} = ",$v,"; \$r = $r; \$p = ",$platform{$r},"; \$a = ",$algorithm{$r},"; \$kind = ",$kind{$r},"\n" if $debug;
855 }
526 } 856 }
857 print STDERR "DEBUG: \$s = $s; \$p = ",$platform{$s},"; \$a = ",$algorithm{$s},"; \$kind = ",$kind{$s},"\n" if $debug;
527 } 858 }
528 } 859 }
529 860
530 # Prune the returned symbols 861 # Prune the returned symbols
531 862
532 $platform{"crypt"} .= ",!PERL5,!__FreeBSD__,!NeXT";
533
534 delete $syms{"SSL_add_dir_cert_subjects_to_stack"};
535 delete $syms{"bn_dump1"}; 863 delete $syms{"bn_dump1"};
536
537 $platform{"BIO_s_file_internal"} .= ",WIN16";
538 $platform{"BIO_new_file_internal"} .= ",WIN16";
539 $platform{"BIO_new_fp_internal"} .= ",WIN16";
540
541 $platform{"BIO_s_file"} .= ",!WIN16";
542 $platform{"BIO_new_file"} .= ",!WIN16";
543 $platform{"BIO_new_fp"} .= ",!WIN16";
544
545 $platform{"BIO_s_log"} .= ",!WIN32,!WIN16,!macintosh"; 864 $platform{"BIO_s_log"} .= ",!WIN32,!WIN16,!macintosh";
546 865
547 if(exists $syms{"ERR_load_CRYPTO_strings"}) { 866 $platform{"PEM_read_NS_CERT_SEQ"} = "VMS";
548 $platform{"ERR_load_CRYPTO_strings"} .= ",!VMS,!WIN16"; 867 $platform{"PEM_write_NS_CERT_SEQ"} = "VMS";
549 $syms{"ERR_load_CRYPTOlib_strings"} = 1; 868 $platform{"PEM_read_P8_PRIV_KEY_INFO"} = "VMS";
550 $platform{"ERR_load_CRYPTOlib_strings"} .= ",VMS,WIN16"; 869 $platform{"PEM_write_P8_PRIV_KEY_INFO"} = "VMS";
551 }
552 870
553 # Info we know about 871 # Info we know about
554 872
555 $platform{"RSA_PKCS1_RSAref"} = "RSAREF";
556 $algorithm{"RSA_PKCS1_RSAref"} = "RSA";
557
558 push @ret, map { $_."\\".&info_string($_,"EXIST", 873 push @ret, map { $_."\\".&info_string($_,"EXIST",
559 $platform{$_}, 874 $platform{$_},
560 $kind{$_}, 875 $kind{$_},
561 $algorithm{$_}) } keys %syms; 876 $algorithm{$_}) } keys %syms;
562 877
878 if (keys %unknown_algorithms) {
879 print STDERR "WARNING: mkdef.pl doesn't know the following algorithms:\n";
880 print STDERR "\t",join("\n\t",keys %unknown_algorithms),"\n";
881 }
563 return(@ret); 882 return(@ret);
564} 883}
565 884
566sub info_string { 885# Param: string of comma-separated platform-specs.
567 (my $symbol, my $exist, my $platforms, my $kind, my $algorithms) = @_; 886sub reduce_platforms
568 887{
569 my %a = defined($algorithms) ? 888 my ($platforms) = @_;
570 map { $_ => 1 } split /,/, $algorithms : ();
571 my $pl = defined($platforms) ? $platforms : ""; 889 my $pl = defined($platforms) ? $platforms : "";
572 my %p = map { $_ => 0 } split /,/, $pl; 890 my %p = map { $_ => 0 } split /,/, $pl;
573 my $k = defined($kind) ? $kind : "FUNCTION";
574 my $ret; 891 my $ret;
575 892
893 print STDERR "DEBUG: Entered reduce_platforms with \"$platforms\"\n"
894 if $debug;
576 # We do this, because if there's code like the following, it really 895 # We do this, because if there's code like the following, it really
577 # means the function exists in all cases and should therefore be 896 # means the function exists in all cases and should therefore be
578 # everywhere. By increasing and decreasing, we may attain 0: 897 # everywhere. By increasing and decreasing, we may attain 0:
@@ -594,12 +913,28 @@ sub info_string {
594 } 913 }
595 914
596 delete $p{""}; 915 delete $p{""};
916
917 $ret = join(',',sort(map { $p{$_} < 0 ? "!".$_ : $_ } keys %p));
918 print STDERR "DEBUG: Exiting reduce_platforms with \"$ret\"\n"
919 if $debug;
920 return $ret;
921}
922
923sub info_string {
924 (my $symbol, my $exist, my $platforms, my $kind, my $algorithms) = @_;
925
926 my %a = defined($algorithms) ?
927 map { $_ => 1 } split /,/, $algorithms : ();
928 my $k = defined($kind) ? $kind : "FUNCTION";
929 my $ret;
930 my $p = &reduce_platforms($platforms);
931
597 delete $a{""}; 932 delete $a{""};
598 933
599 $ret = $exist; 934 $ret = $exist;
600 $ret .= ":".join(',',map { $p{$_} < 0 ? "!".$_ : $_ } keys %p); 935 $ret .= ":".$p;
601 $ret .= ":".$k; 936 $ret .= ":".$k;
602 $ret .= ":".join(',',keys %a); 937 $ret .= ":".join(',',sort keys %a);
603 return $ret; 938 return $ret;
604} 939}
605 940
@@ -607,19 +942,30 @@ sub maybe_add_info {
607 (my $name, *nums, my @symbols) = @_; 942 (my $name, *nums, my @symbols) = @_;
608 my $sym; 943 my $sym;
609 my $new_info = 0; 944 my $new_info = 0;
945 my %syms=();
610 946
611 print STDERR "Updating $name info\n"; 947 print STDERR "Updating $name info\n";
612 foreach $sym (@symbols) { 948 foreach $sym (@symbols) {
613 (my $s, my $i) = split /\\/, $sym; 949 (my $s, my $i) = split /\\/, $sym;
614 $i =~ s/^(.*?:.*?:\w+)(\(\w+\))?/$1/;
615 if (defined($nums{$s})) { 950 if (defined($nums{$s})) {
951 $i =~ s/^(.*?:.*?:\w+)(\(\w+\))?/$1/;
616 (my $n, my $dummy) = split /\\/, $nums{$s}; 952 (my $n, my $dummy) = split /\\/, $nums{$s};
617 if (!defined($dummy) || $i ne $dummy) { 953 if (!defined($dummy) || $i ne $dummy) {
618 $nums{$s} = $n."\\".$i; 954 $nums{$s} = $n."\\".$i;
619 $new_info++; 955 $new_info++;
620 #print STDERR "DEBUG: maybe_add_info for $s: \"$dummy\" => \"$i\"\n"; 956 print STDERR "DEBUG: maybe_add_info for $s: \"$dummy\" => \"$i\"\n" if $debug;
621 } 957 }
622 } 958 }
959 $syms{$s} = 1;
960 }
961
962 my @s=sort { &parse_number($nums{$a},"n") <=> &parse_number($nums{$b},"n") } keys %nums;
963 foreach $sym (@s) {
964 (my $n, my $i) = split /\\/, $nums{$sym};
965 if (!defined($syms{$sym}) && $i !~ /^NOEXIST:/) {
966 $new_info++;
967 print STDERR "DEBUG: maybe_add_info for $sym: -> undefined\n" if $debug;
968 }
623 } 969 }
624 if ($new_info) { 970 if ($new_info) {
625 print STDERR "$new_info old symbols got an info update\n"; 971 print STDERR "$new_info old symbols got an info update\n";
@@ -631,35 +977,121 @@ sub maybe_add_info {
631 } 977 }
632} 978}
633 979
980# Param: string of comma-separated keywords, each possibly prefixed with a "!"
981sub is_valid
982{
983 my ($keywords_txt,$platforms) = @_;
984 my (@keywords) = split /,/,$keywords_txt;
985 my ($falsesum, $truesum) = (0, !grep(/^[^!]/,@keywords));
986
987 # Param: one keyword
988 sub recognise
989 {
990 my ($keyword,$platforms) = @_;
991
992 if ($platforms) {
993 # platforms
994 if ($keyword eq "VMS" && $VMS) { return 1; }
995 if ($keyword eq "WIN32" && $W32) { return 1; }
996 if ($keyword eq "WIN16" && $W16) { return 1; }
997 if ($keyword eq "WINNT" && $NT) { return 1; }
998 # Special platforms:
999 # EXPORT_VAR_AS_FUNCTION means that global variables
1000 # will be represented as functions. This currently
1001 # only happens on VMS-VAX.
1002 if ($keyword eq "EXPORT_VAR_AS_FUNCTION" && ($VMSVAX || $W32 || $W16)) {
1003 return 1;
1004 }
1005 return 0;
1006 } else {
1007 # algorithms
1008 if ($keyword eq "RC2" && $no_rc2) { return 0; }
1009 if ($keyword eq "RC4" && $no_rc4) { return 0; }
1010 if ($keyword eq "RC5" && $no_rc5) { return 0; }
1011 if ($keyword eq "IDEA" && $no_idea) { return 0; }
1012 if ($keyword eq "DES" && $no_des) { return 0; }
1013 if ($keyword eq "BF" && $no_bf) { return 0; }
1014 if ($keyword eq "CAST" && $no_cast) { return 0; }
1015 if ($keyword eq "MD2" && $no_md2) { return 0; }
1016 if ($keyword eq "MD4" && $no_md4) { return 0; }
1017 if ($keyword eq "MD5" && $no_md5) { return 0; }
1018 if ($keyword eq "SHA" && $no_sha) { return 0; }
1019 if ($keyword eq "RIPEMD" && $no_ripemd) { return 0; }
1020 if ($keyword eq "MDC2" && $no_mdc2) { return 0; }
1021 if ($keyword eq "RSA" && $no_rsa) { return 0; }
1022 if ($keyword eq "DSA" && $no_dsa) { return 0; }
1023 if ($keyword eq "DH" && $no_dh) { return 0; }
1024 if ($keyword eq "EC" && $no_ec) { return 0; }
1025 if ($keyword eq "HMAC" && $no_hmac) { return 0; }
1026 if ($keyword eq "AES" && $no_aes) { return 0; }
1027 if ($keyword eq "EVP" && $no_evp) { return 0; }
1028 if ($keyword eq "LHASH" && $no_lhash) { return 0; }
1029 if ($keyword eq "STACK" && $no_stack) { return 0; }
1030 if ($keyword eq "ERR" && $no_err) { return 0; }
1031 if ($keyword eq "BUFFER" && $no_buffer) { return 0; }
1032 if ($keyword eq "BIO" && $no_bio) { return 0; }
1033 if ($keyword eq "COMP" && $no_comp) { return 0; }
1034 if ($keyword eq "DSO" && $no_dso) { return 0; }
1035 if ($keyword eq "KRB5" && $no_krb5) { return 0; }
1036 if ($keyword eq "FP_API" && $no_fp_api) { return 0; }
1037
1038 # Nothing recognise as true
1039 return 1;
1040 }
1041 }
1042
1043 foreach $k (@keywords) {
1044 if ($k =~ /^!(.*)$/) {
1045 $falsesum += &recognise($1,$platforms);
1046 } else {
1047 $truesum += &recognise($k,$platforms);
1048 }
1049 }
1050 print STDERR "DEBUG: [",$#keywords,",",$#keywords < 0,"] is_valid($keywords_txt) => (\!$falsesum) && $truesum = ",(!$falsesum) && $truesum,"\n" if $debug;
1051 return (!$falsesum) && $truesum;
1052}
1053
634sub print_test_file 1054sub print_test_file
635{ 1055{
636 (*OUT,my $name,*nums,my @symbols)=@_; 1056 (*OUT,my $name,*nums,my $testall,my @symbols)=@_;
637 my $n = 1; my @e; my @r; 1057 my $n = 1; my @e; my @r;
638 my $sym; my $prev = ""; my $prefSSLeay; 1058 my $sym; my $prev = ""; my $prefSSLeay;
639 1059
640 (@e)=grep(/^SSLeay\\.*?:.*?:FUNCTION/,@symbols); 1060 (@e)=grep(/^SSLeay(\{[0-9]+\})?\\.*?:.*?:.*/,@symbols);
641 (@r)=grep(/^\w+\\.*?:.*?:FUNCTION/ && !/^SSLeay\\.*?:.*?:FUNCTION/,@symbols); 1061 (@r)=grep(/^\w+(\{[0-9]+\})?\\.*?:.*?:.*/ && !/^SSLeay(\{[0-9]+\})?\\.*?:.*?:.*/,@symbols);
642 @symbols=((sort @e),(sort @r)); 1062 @symbols=((sort @e),(sort @r));
643 1063
644 foreach $sym (@symbols) { 1064 foreach $sym (@symbols) {
645 (my $s, my $i) = $sym =~ /^(.*?)\\(.*)$/; 1065 (my $s, my $i) = $sym =~ /^(.*?)\\(.*)$/;
646 if ($s ne $prev) { 1066 my $v = 0;
647 if (!defined($nums{$sym})) { 1067 $v = 1 if $i=~ /^.*?:.*?:VARIABLE/;
648 printf STDERR "Warning: $sym does not have a number assigned\n" 1068 my $p = ($i =~ /^[^:]*:([^:]*):/,$1);
649 if(!$do_update); 1069 my $a = ($i =~ /^[^:]*:[^:]*:[^:]*:([^:]*)/,$1);
1070 if (!defined($nums{$s})) {
1071 print STDERR "Warning: $s does not have a number assigned\n"
1072 if(!$do_update);
1073 } elsif (is_valid($p,1) && is_valid($a,0)) {
1074 my $s2 = ($s =~ /^(.*?)(\{[0-9]+\})?$/, $1);
1075 if ($prev eq $s2) {
1076 print OUT "\t/* The following has already appeared previously */\n";
1077 print STDERR "Warning: Symbol '",$s2,"' redefined. old=",($nums{$prev} =~ /^(.*?)\\/,$1),", new=",($nums{$s2} =~ /^(.*?)\\/,$1),"\n";
1078 }
1079 $prev = $s2; # To warn about duplicates...
1080
1081 ($nn,$ni)=($nums{$s2} =~ /^(.*?)\\(.*)$/);
1082 if ($v) {
1083 print OUT "\textern int $s2; /* type unknown */ /* $nn $ni */\n";
650 } else { 1084 } else {
651 $n=$nums{$s}; 1085 print OUT "\textern int $s2(); /* type unknown */ /* $nn $ni */\n";
652 print OUT "\t$s();\n";
653 } 1086 }
654 } 1087 }
655 $prev = $s; # To avoid duplicates...
656 } 1088 }
657} 1089}
658 1090
659sub print_def_file 1091sub print_def_file
660{ 1092{
661 (*OUT,my $name,*nums,my @symbols)=@_; 1093 (*OUT,my $name,*nums,my @symbols)=@_;
662 my $n = 1; my @e; my @r; 1094 my $n = 1; my @e; my @r; my @v; my $prev="";
663 1095
664 if ($W32) 1096 if ($W32)
665 { $name.="32"; } 1097 { $name.="32"; }
@@ -692,80 +1124,35 @@ EOF
692 1124
693 print "EXPORTS\n"; 1125 print "EXPORTS\n";
694 1126
695 (@e)=grep(/^SSLeay\\.*?:.*?:FUNCTION/,@symbols); 1127 (@e)=grep(/^SSLeay(\{[0-9]+\})?\\.*?:.*?:FUNCTION/,@symbols);
696 (@r)=grep(/^\w+\\.*?:.*?:FUNCTION/ && !/^SSLeay\\.*?:.*?:FUNCTION/,@symbols); 1128 (@r)=grep(/^\w+(\{[0-9]+\})?\\.*?:.*?:FUNCTION/ && !/^SSLeay(\{[0-9]+\})?\\.*?:.*?:FUNCTION/,@symbols);
697 @symbols=((sort @e),(sort @r)); 1129 (@v)=grep(/^\w+(\{[0-9]+\})?\\.*?:.*?:VARIABLE/,@symbols);
1130 @symbols=((sort @e),(sort @r), (sort @v));
698 1131
699 1132
700 foreach $sym (@symbols) { 1133 foreach $sym (@symbols) {
701 (my $s, my $i) = $sym =~ /^(.*?)\\(.*)$/; 1134 (my $s, my $i) = $sym =~ /^(.*?)\\(.*)$/;
1135 my $v = 0;
1136 $v = 1 if $i =~ /^.*?:.*?:VARIABLE/;
702 if (!defined($nums{$s})) { 1137 if (!defined($nums{$s})) {
703 printf STDERR "Warning: $s does not have a number assigned\n" 1138 printf STDERR "Warning: $s does not have a number assigned\n"
704 if(!$do_update); 1139 if(!$do_update);
705 } else { 1140 } else {
706 (my $n, my $i) = split /\\/, $nums{$s}; 1141 (my $n, my $dummy) = split /\\/, $nums{$s};
707 my %pf = (); 1142 my %pf = ();
708 my @p = split(/,/, ($i =~ /^[^:]*:([^:]*):/,$1)); 1143 my $p = ($i =~ /^[^:]*:([^:]*):/,$1);
709 my @a = split(/,/, ($i =~ /^[^:]*:[^:]*:[^:]*:([^:]*)/,$1)); 1144 my $a = ($i =~ /^[^:]*:[^:]*:[^:]*:([^:]*)/,$1);
710 # @p_purged must contain hardware platforms only 1145 if (is_valid($p,1) && is_valid($a,0)) {
711 my @p_purged = (); 1146 my $s2 = ($s =~ /^(.*?)(\{[0-9]+\})?$/, $1);
712 foreach $ptmp (@p) { 1147 if ($prev eq $s2) {
713 next if $ptmp =~ /^!?RSAREF$/; 1148 print STDERR "Warning: Symbol '",$s2,"' redefined. old=",($nums{$prev} =~ /^(.*?)\\/,$1),", new=",($nums{$s2} =~ /^(.*?)\\/,$1),"\n";
714 push @p_purged, $ptmp; 1149 }
715 } 1150 $prev = $s2; # To warn about duplicates...
716 my $negatives = !!grep(/^!/,@p); 1151 if($v) {
717 # It is very important to check NT before W32 1152 printf OUT " %s%-39s @%-8d DATA\n",($W32)?"":"_",$s2,$n;
718 if ((($NT && (!@p_purged 1153 } else {
719 || (!$negatives && grep(/^WINNT$/,@p)) 1154 printf OUT " %s%-39s @%d\n",($W32)?"":"_",$s2,$n;
720 || ($negatives && !grep(/^!WINNT$/,@p)))) 1155 }
721 || ($W32 && (!@p_purged
722 || (!$negatives && grep(/^WIN32$/,@p))
723 || ($negatives && !grep(/^!WIN32$/,@p))))
724 || ($W16 && (!@p_purged
725 || (!$negatives && grep(/^WIN16$/,@p))
726 || ($negatives && !grep(/^!WIN16$/,@p)))))
727 && (!@p
728 || (!$negatives
729 && ($rsaref || !grep(/^RSAREF$/,@p)))
730 || ($negatives
731 && (!$rsaref || !grep(/^!RSAREF$/,@p))))
732 && (!@a || (!$no_rc2 || !grep(/^RC2$/,@a)))
733 && (!@a || (!$no_rc4 || !grep(/^RC4$/,@a)))
734 && (!@a || (!$no_rc5 || !grep(/^RC5$/,@a)))
735 && (!@a || (!$no_idea || !grep(/^IDEA$/,@a)))
736 && (!@a || (!$no_des || !grep(/^DES$/,@a)))
737 && (!@a || (!$no_bf || !grep(/^BF$/,@a)))
738 && (!@a || (!$no_cast || !grep(/^CAST$/,@a)))
739 && (!@a || (!$no_md2 || !grep(/^MD2$/,@a)))
740 && (!@a || (!$no_md4 || !grep(/^MD4$/,@a)))
741 && (!@a || (!$no_md5 || !grep(/^MD5$/,@a)))
742 && (!@a || (!$no_sha || !grep(/^SHA$/,@a)))
743 && (!@a || (!$no_ripemd || !grep(/^RIPEMD$/,@a)))
744 && (!@a || (!$no_mdc2 || !grep(/^MDC2$/,@a)))
745 && (!@a || (!$no_rsa || !grep(/^RSA$/,@a)))
746 && (!@a || (!$no_dsa || !grep(/^DSA$/,@a)))
747 && (!@a || (!$no_dh || !grep(/^DH$/,@a)))
748 && (!@a || (!$no_hmac || !grep(/^HMAC$/,@a)))
749 && (!@a || (!$no_fp_api || !grep(/^FP_API$/,@a)))
750 ) {
751 printf OUT " %s%-40s@%d\n",($W32)?"":"_",$s,$n;
752# } else {
753# print STDERR "DEBUG: \"$sym\" (@p):",
754# " rsaref:", !!(!@p
755# || (!$negatives
756# && ($rsaref || !grep(/^RSAREF$/,@p)))
757# || ($negatives
758# && (!$rsaref || !grep(/^!RSAREF$/,@p))))?1:0,
759# " 16:", !!($W16 && (!@p_purged
760# || (!$negatives && grep(/^WIN16$/,@p))
761# || ($negatives && !grep(/^!WIN16$/,@p)))),
762# " 32:", !!($W32 && (!@p_purged
763# || (!$negatives && grep(/^WIN32$/,@p))
764# || ($negatives && !grep(/^!WIN32$/,@p)))),
765# " NT:", !!($NT && (!@p_purged
766# || (!$negatives && grep(/^WINNT$/,@p))
767# || ($negatives && !grep(/^!WINNT$/,@p)))),
768# "\n";
769 } 1156 }
770 } 1157 }
771 } 1158 }
@@ -780,6 +1167,7 @@ sub load_numbers
780 $max_num = 0; 1167 $max_num = 0;
781 $num_noinfo = 0; 1168 $num_noinfo = 0;
782 $prev = ""; 1169 $prev = "";
1170 $prev_cnt = 0;
783 1171
784 open(IN,"<$name") || die "unable to open $name:$!\n"; 1172 open(IN,"<$name") || die "unable to open $name:$!\n";
785 while (<IN>) { 1173 while (<IN>) {
@@ -788,14 +1176,22 @@ sub load_numbers
788 next if /^\s*$/; 1176 next if /^\s*$/;
789 @a=split; 1177 @a=split;
790 if (defined $ret{$a[0]}) { 1178 if (defined $ret{$a[0]}) {
791 print STDERR "Warning: Symbol '",$a[0],"' redefined. old=",$ret{$a[0]},", new=",$a[1],"\n"; 1179 # This is actually perfectly OK
1180 #print STDERR "Warning: Symbol '",$a[0],"' redefined. old=",$ret{$a[0]},", new=",$a[1],"\n";
792 } 1181 }
793 if ($max_num > $a[1]) { 1182 if ($max_num > $a[1]) {
794 print STDERR "Warning: Number decreased from ",$max_num," to ",$a[1],"\n"; 1183 print STDERR "Warning: Number decreased from ",$max_num," to ",$a[1],"\n";
795 } 1184 }
796 if ($max_num == $a[1]) { 1185 elsif ($max_num == $a[1]) {
797 # This is actually perfectly OK 1186 # This is actually perfectly OK
798 #print STDERR "Warning: Symbol ",$a[0]," has same number as previous ",$prev,": ",$a[1],"\n"; 1187 #print STDERR "Warning: Symbol ",$a[0]," has same number as previous ",$prev,": ",$a[1],"\n";
1188 if ($a[0] eq $prev) {
1189 $prev_cnt++;
1190 $a[0] .= "{$prev_cnt}";
1191 }
1192 }
1193 else {
1194 $prev_cnt = 0;
799 } 1195 }
800 if ($#a < 2) { 1196 if ($#a < 2) {
801 # Existence will be proven later, in do_defs 1197 # Existence will be proven later, in do_defs
@@ -837,7 +1233,7 @@ sub rewrite_numbers
837 1233
838 print STDERR "Rewriting $name\n"; 1234 print STDERR "Rewriting $name\n";
839 1235
840 my @r = grep(/^\w+\\.*?:.*?:\w+\(\w+\)/,@symbols); 1236 my @r = grep(/^\w+(\{[0-9]+\})?\\.*?:.*?:\w+\(\w+\)/,@symbols);
841 my $r; my %r; my %rsyms; 1237 my $r; my %r; my %rsyms;
842 foreach $r (@r) { 1238 foreach $r (@r) {
843 (my $s, my $i) = split /\\/, $r; 1239 (my $s, my $i) = split /\\/, $r;
@@ -847,16 +1243,31 @@ sub rewrite_numbers
847 $rsyms{$s} = 1; 1243 $rsyms{$s} = 1;
848 } 1244 }
849 1245
850 my @s=sort { &parse_number($nums{$a},"n") <=> &parse_number($nums{$b},"n") } keys %nums; 1246 my %syms = ();
1247 foreach $_ (@symbols) {
1248 (my $n, my $i) = split /\\/;
1249 $syms{$n} = 1;
1250 }
1251
1252 my @s=sort {
1253 &parse_number($nums{$a},"n") <=> &parse_number($nums{$b},"n")
1254 || $a cmp $b
1255 } keys %nums;
851 foreach $sym (@s) { 1256 foreach $sym (@s) {
852 (my $n, my $i) = split /\\/, $nums{$sym}; 1257 (my $n, my $i) = split /\\/, $nums{$sym};
853 next if defined($i) && $i =~ /^.*?:.*?:\w+\(\w+\)/; 1258 next if defined($i) && $i =~ /^.*?:.*?:\w+\(\w+\)/;
854 next if defined($rsyms{$sym}); 1259 next if defined($rsyms{$sym});
855 $i="NOEXIST::FUNCTION:" if !defined($i) || $i eq ""; 1260 print STDERR "DEBUG: rewrite_numbers for sym = ",$sym,": i = ",$i,", n = ",$n,", rsym{sym} = ",$rsyms{$sym},"syms{sym} = ",$syms{$sym},"\n" if $debug;
856 printf OUT "%s%-40s%d\t%s\n","",$sym,$n,$i; 1261 $i="NOEXIST::FUNCTION:"
1262 if !defined($i) || $i eq "" || !defined($syms{$sym});
1263 my $s2 = $sym;
1264 $s2 =~ s/\{[0-9]+\}$//;
1265 printf OUT "%s%-39s %d\t%s\n","",$s2,$n,$i;
857 if (exists $r{$sym}) { 1266 if (exists $r{$sym}) {
858 (my $s, $i) = split /\\/,$r{$sym}; 1267 (my $s, $i) = split /\\/,$r{$sym};
859 printf OUT "%s%-40s%d\t%s\n","",$s,$n,$i; 1268 my $s2 = $s;
1269 $s2 =~ s/\{[0-9]+\}$//;
1270 printf OUT "%s%-39s %d\t%s\n","",$s2,$n,$i;
860 } 1271 }
861 } 1272 }
862} 1273}
@@ -868,7 +1279,7 @@ sub update_numbers
868 1279
869 print STDERR "Updating $name numbers\n"; 1280 print STDERR "Updating $name numbers\n";
870 1281
871 my @r = grep(/^\w+\\.*?:.*?:\w+\(\w+\)/,@symbols); 1282 my @r = grep(/^\w+(\{[0-9]+\})?\\.*?:.*?:\w+\(\w+\)/,@symbols);
872 my $r; my %r; my %rsyms; 1283 my $r; my %r; my %rsyms;
873 foreach $r (@r) { 1284 foreach $r (@r) {
874 (my $s, my $i) = split /\\/, $r; 1285 (my $s, my $i) = split /\\/, $r;
@@ -886,10 +1297,13 @@ sub update_numbers
886 if $i eq ""; 1297 if $i eq "";
887 if (!exists $nums{$s}) { 1298 if (!exists $nums{$s}) {
888 $new_syms++; 1299 $new_syms++;
889 printf OUT "%s%-40s%d\t%s\n","",$s, ++$start_num,$i; 1300 my $s2 = $s;
1301 $s2 =~ s/\{[0-9]+\}$//;
1302 printf OUT "%s%-39s %d\t%s\n","",$s2, ++$start_num,$i;
890 if (exists $r{$s}) { 1303 if (exists $r{$s}) {
891 ($s, $i) = split /\\/,$r{$s}; 1304 ($s, $i) = split /\\/,$r{$s};
892 printf OUT "%s%-40s%d\t%s\n","",$s, $start_num,$i; 1305 $s =~ s/\{[0-9]+\}$//;
1306 printf OUT "%s%-39s %d\t%s\n","",$s, $start_num,$i;
893 } 1307 }
894 } 1308 }
895 } 1309 }
diff --git a/src/lib/libcrypto/util/mkerr.pl b/src/lib/libcrypto/util/mkerr.pl
index 7d98b5234d..6c2237d142 100644
--- a/src/lib/libcrypto/util/mkerr.pl
+++ b/src/lib/libcrypto/util/mkerr.pl
@@ -7,7 +7,7 @@ my $static = 1;
7my $recurse = 0; 7my $recurse = 0;
8my $reindex = 0; 8my $reindex = 0;
9my $dowrite = 0; 9my $dowrite = 0;
10 10my $staticloader = "";
11 11
12while (@ARGV) { 12while (@ARGV) {
13 my $arg = $ARGV[0]; 13 my $arg = $ARGV[0];
@@ -29,6 +29,9 @@ while (@ARGV) {
29 } elsif($arg eq "-nostatic") { 29 } elsif($arg eq "-nostatic") {
30 $static = 0; 30 $static = 0;
31 shift @ARGV; 31 shift @ARGV;
32 } elsif($arg eq "-staticloader") {
33 $staticloader = "static ";
34 shift @ARGV;
32 } elsif($arg eq "-write") { 35 } elsif($arg eq "-write") {
33 $dowrite = 1; 36 $dowrite = 1;
34 shift @ARGV; 37 shift @ARGV;
@@ -38,7 +41,7 @@ while (@ARGV) {
38} 41}
39 42
40if($recurse) { 43if($recurse) {
41 @source = (<crypto/*.c>, <crypto/*/*.c>, <rsaref/*.c>, <ssl/*.c>); 44 @source = (<crypto/*.c>, <crypto/*/*.c>, <ssl/*.c>);
42} else { 45} else {
43 @source = @ARGV; 46 @source = @ARGV;
44} 47}
@@ -53,6 +56,7 @@ while(<IN>)
53{ 56{
54 if(/^L\s+(\S+)\s+(\S+)\s+(\S+)/) { 57 if(/^L\s+(\S+)\s+(\S+)\s+(\S+)/) {
55 $hinc{$1} = $2; 58 $hinc{$1} = $2;
59 $libinc{$2} = $1;
56 $cskip{$3} = $1; 60 $cskip{$3} = $1;
57 if($3 ne "NONE") { 61 if($3 ne "NONE") {
58 $csrc{$1} = $3; 62 $csrc{$1} = $3;
@@ -74,42 +78,44 @@ close IN;
74# Scan each header file in turn and make a list of error codes 78# Scan each header file in turn and make a list of error codes
75# and function names 79# and function names
76 80
77while (($lib, $hdr) = each %hinc) 81while (($hdr, $lib) = each %libinc)
78{ 82{
79 next if($hdr eq "NONE"); 83 next if($hdr eq "NONE");
80 print STDERR "Scanning header file $hdr\n" if $debug; 84 print STDERR "Scanning header file $hdr\n" if $debug;
81 open(IN, "<$hdr") || die "Can't open Header file $hdr\n"; 85 my $line = "", $def= "", $linenr = 0, $gotfile = 0;
82 my $line = "", $def= "", $linenr = 0; 86 if (open(IN, "<$hdr")) {
83 while(<IN>) { 87 $gotfile = 1;
84 $linenr++; 88 while(<IN>) {
85 print STDERR "line: $linenr\r" if $debug; 89 $linenr++;
86 90 print STDERR "line: $linenr\r" if $debug;
87 last if(/BEGIN\s+ERROR\s+CODES/); 91
88 if ($line ne '') { 92 last if(/BEGIN\s+ERROR\s+CODES/);
89 $_ = $line . $_; 93 if ($line ne '') {
90 $line = ''; 94 $_ = $line . $_;
91 } 95 $line = '';
96 }
92 97
93 if (/\\$/) { 98 if (/\\$/) {
94 $line = $_; 99 $line = $_;
95 next; 100 next;
96 } 101 }
97 102
98 $cpp = 1 if /^#.*ifdef.*cplusplus/; # skip "C" declaration 103 $cpp = 1 if /^#.*ifdef.*cplusplus/; # skip "C" declaration
99 if ($cpp) { 104 if ($cpp) {
100 $cpp = 0 if /^#.*endif/; 105 $cpp = 0 if /^#.*endif/;
101 next; 106 next;
102 } 107 }
103 108
104 next if (/^#/); # skip preprocessor directives 109 next if (/^\#/); # skip preprocessor directives
105 110
106 s/\/\*.*?\*\///gs; # ignore comments 111 s/\/\*.*?\*\///gs; # ignore comments
107 s/{[^{}]*}//gs; # ignore {} blocks 112 s/{[^{}]*}//gs; # ignore {} blocks
108 113
109 if (/{|\/\*/) { # Add a } so editor works... 114 if (/\{|\/\*/) { # Add a } so editor works...
110 $line = $_; 115 $line = $_;
111 } else { 116 } else {
112 $def .= $_; 117 $def .= $_;
118 }
113 } 119 }
114 } 120 }
115 121
@@ -151,10 +157,12 @@ while (($lib, $hdr) = each %hinc)
151 # Scan function and reason codes and store them: keep a note of the 157 # Scan function and reason codes and store them: keep a note of the
152 # maximum code used. 158 # maximum code used.
153 159
154 while(<IN>) { 160 if ($gotfile) {
155 if(/^#define\s+(\S+)\s+(\S+)/) { 161 while(<IN>) {
162 if(/^\#define\s+(\S+)\s+(\S+)/) {
156 $name = $1; 163 $name = $1;
157 $code = $2; 164 $code = $2;
165 next if $name =~ /^${lib}err/;
158 unless($name =~ /^${lib}_([RF])_(\w+)$/) { 166 unless($name =~ /^${lib}_([RF])_(\w+)$/) {
159 print STDERR "Invalid error code $name\n"; 167 print STDERR "Invalid error code $name\n";
160 next; 168 next;
@@ -172,6 +180,7 @@ while (($lib, $hdr) = each %hinc)
172 $fcodes{$name} = $code; 180 $fcodes{$name} = $code;
173 } 181 }
174 } 182 }
183 }
175 } 184 }
176 close IN; 185 close IN;
177} 186}
@@ -188,9 +197,11 @@ while (($lib, $hdr) = each %hinc)
188# so all those unreferenced can be printed out. 197# so all those unreferenced can be printed out.
189 198
190 199
200print STDERR "Files loaded: " if $debug;
191foreach $file (@source) { 201foreach $file (@source) {
192 # Don't parse the error source file. 202 # Don't parse the error source file.
193 next if exists $cskip{$file}; 203 next if exists $cskip{$file};
204 print STDERR $file if $debug;
194 open(IN, "<$file") || die "Can't open source file $file\n"; 205 open(IN, "<$file") || die "Can't open source file $file\n";
195 while(<IN>) { 206 while(<IN>) {
196 if(/(([A-Z0-9]+)_F_([A-Z0-9_]+))/) { 207 if(/(([A-Z0-9]+)_F_([A-Z0-9_]+))/) {
@@ -214,6 +225,7 @@ foreach $file (@source) {
214 } 225 }
215 close IN; 226 close IN;
216} 227}
228print STDERR "\n" if $debug;
217 229
218# Now process each library in turn. 230# Now process each library in turn.
219 231
@@ -240,15 +252,74 @@ foreach $lib (keys %csrc)
240 252
241 # Rewrite the header file 253 # Rewrite the header file
242 254
243 open(IN, "<$hfile") || die "Can't Open Header File $hfile\n"; 255 if (open(IN, "<$hfile")) {
244 256 # Copy across the old file
245 # Copy across the old file 257 while(<IN>) {
246 while(<IN>) {
247 push @out, $_; 258 push @out, $_;
248 last if (/BEGIN ERROR CODES/); 259 last if (/BEGIN ERROR CODES/);
260 }
261 close IN;
262 } else {
263 push @out,
264"/* ====================================================================\n",
265" * Copyright (c) 2001 The OpenSSL Project. All rights reserved.\n",
266" *\n",
267" * Redistribution and use in source and binary forms, with or without\n",
268" * modification, are permitted provided that the following conditions\n",
269" * are met:\n",
270" *\n",
271" * 1. Redistributions of source code must retain the above copyright\n",
272" * notice, this list of conditions and the following disclaimer. \n",
273" *\n",
274" * 2. Redistributions in binary form must reproduce the above copyright\n",
275" * notice, this list of conditions and the following disclaimer in\n",
276" * the documentation and/or other materials provided with the\n",
277" * distribution.\n",
278" *\n",
279" * 3. All advertising materials mentioning features or use of this\n",
280" * software must display the following acknowledgment:\n",
281" * \"This product includes software developed by the OpenSSL Project\n",
282" * for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n",
283" *\n",
284" * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n",
285" * endorse or promote products derived from this software without\n",
286" * prior written permission. For written permission, please contact\n",
287" * openssl-core\@openssl.org.\n",
288" *\n",
289" * 5. Products derived from this software may not be called \"OpenSSL\"\n",
290" * nor may \"OpenSSL\" appear in their names without prior written\n",
291" * permission of the OpenSSL Project.\n",
292" *\n",
293" * 6. Redistributions of any form whatsoever must retain the following\n",
294" * acknowledgment:\n",
295" * \"This product includes software developed by the OpenSSL Project\n",
296" * for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n",
297" *\n",
298" * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n",
299" * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n",
300" * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n",
301" * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR\n",
302" * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n",
303" * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n",
304" * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n",
305" * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n",
306" * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n",
307" * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n",
308" * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n",
309" * OF THE POSSIBILITY OF SUCH DAMAGE.\n",
310" * ====================================================================\n",
311" *\n",
312" * This product includes cryptographic software written by Eric Young\n",
313" * (eay\@cryptsoft.com). This product includes software written by Tim\n",
314" * Hudson (tjh\@cryptsoft.com).\n",
315" *\n",
316" */\n",
317"\n",
318"#ifndef HEADER_${lib}_ERR_H\n",
319"#define HEADER_${lib}_ERR_H\n",
320"\n",
321"/* BEGIN ERROR CODES */\n";
249 } 322 }
250 close IN;
251
252 open (OUT, ">$hfile") || die "Can't Open File $hfile for writing\n"; 323 open (OUT, ">$hfile") || die "Can't Open File $hfile for writing\n";
253 324
254 print OUT @out; 325 print OUT @out;
@@ -257,7 +328,22 @@ foreach $lib (keys %csrc)
257/* The following lines are auto generated by the script mkerr.pl. Any changes 328/* The following lines are auto generated by the script mkerr.pl. Any changes
258 * made after this point may be overwritten when the script is next run. 329 * made after this point may be overwritten when the script is next run.
259 */ 330 */
331EOF
332 if($static) {
333 print OUT <<"EOF";
334${staticloader}void ERR_load_${lib}_strings(void);
335
336EOF
337 } else {
338 print OUT <<"EOF";
339${staticloader}void ERR_load_${lib}_strings(void);
340${staticloader}void ERR_unload_${lib}_strings(void);
341${staticloader}void ERR_${lib}_error(int function, int reason, char *file, int line);
342#define ${lib}err(f,r) ERR_${lib}_error((f),(r),__FILE__,__LINE__)
260 343
344EOF
345 }
346 print OUT <<"EOF";
261/* Error codes for the $lib functions. */ 347/* Error codes for the $lib functions. */
262 348
263/* Function codes. */ 349/* Function codes. */
@@ -288,7 +374,6 @@ EOF
288} 374}
289#endif 375#endif
290#endif 376#endif
291
292EOF 377EOF
293 close OUT; 378 close OUT;
294 379
@@ -382,7 +467,7 @@ EOF
382#include $hincf 467#include $hincf
383 468
384/* BEGIN ERROR CODES */ 469/* BEGIN ERROR CODES */
385#ifndef NO_ERR 470#ifndef OPENSSL_NO_ERR
386static ERR_STRING_DATA ${lib}_str_functs[]= 471static ERR_STRING_DATA ${lib}_str_functs[]=
387 { 472 {
388EOF 473EOF
@@ -425,14 +510,14 @@ if($static) {
425 510
426#endif 511#endif
427 512
428void ERR_load_${lib}_strings(void) 513${staticloader}void ERR_load_${lib}_strings(void)
429 { 514 {
430 static int init=1; 515 static int init=1;
431 516
432 if (init) 517 if (init)
433 { 518 {
434 init=0; 519 init=0;
435#ifndef NO_ERR 520#ifndef OPENSSL_NO_ERR
436 ERR_load_strings(ERR_LIB_${lib},${lib}_str_functs); 521 ERR_load_strings(ERR_LIB_${lib},${lib}_str_functs);
437 ERR_load_strings(ERR_LIB_${lib},${lib}_str_reasons); 522 ERR_load_strings(ERR_LIB_${lib},${lib}_str_reasons);
438#endif 523#endif
@@ -456,19 +541,18 @@ static ERR_STRING_DATA ${lib}_lib_name[]=
456#endif 541#endif
457 542
458 543
459int ${lib}_lib_error_code=0; 544static int ${lib}_lib_error_code=0;
545static int ${lib}_error_init=1;
460 546
461void ERR_load_${lib}_strings(void) 547${staticloader}void ERR_load_${lib}_strings(void)
462 { 548 {
463 static int init=1;
464
465 if (${lib}_lib_error_code == 0) 549 if (${lib}_lib_error_code == 0)
466 ${lib}_lib_error_code=ERR_get_next_error_library(); 550 ${lib}_lib_error_code=ERR_get_next_error_library();
467 551
468 if (init) 552 if (${lib}_error_init)
469 { 553 {
470 init=0; 554 ${lib}_error_init=0;
471#ifndef NO_ERR 555#ifndef OPENSSL_NO_ERR
472 ERR_load_strings(${lib}_lib_error_code,${lib}_str_functs); 556 ERR_load_strings(${lib}_lib_error_code,${lib}_str_functs);
473 ERR_load_strings(${lib}_lib_error_code,${lib}_str_reasons); 557 ERR_load_strings(${lib}_lib_error_code,${lib}_str_reasons);
474#endif 558#endif
@@ -480,7 +564,23 @@ void ERR_load_${lib}_strings(void)
480 } 564 }
481 } 565 }
482 566
483void ERR_${lib}_error(int function, int reason, char *file, int line) 567${staticloader}void ERR_unload_${lib}_strings(void)
568 {
569 if (${lib}_error_init == 0)
570 {
571#ifndef OPENSSL_NO_ERR
572 ERR_unload_strings(${lib}_lib_error_code,${lib}_str_functs);
573 ERR_unload_strings(${lib}_lib_error_code,${lib}_str_reasons);
574#endif
575
576#ifdef ${lib}_LIB_NAME
577 ERR_unload_strings(0,${lib}_lib_name);
578#endif
579 ${lib}_error_init=1;
580 }
581 }
582
583${staticloader}void ERR_${lib}_error(int function, int reason, char *file, int line)
484 { 584 {
485 if (${lib}_lib_error_code == 0) 585 if (${lib}_lib_error_code == 0)
486 ${lib}_lib_error_code=ERR_get_next_error_library(); 586 ${lib}_lib_error_code=ERR_get_next_error_library();
diff --git a/src/lib/libcrypto/util/mkfiles.pl b/src/lib/libcrypto/util/mkfiles.pl
index 470feea76f..29e1404c69 100644
--- a/src/lib/libcrypto/util/mkfiles.pl
+++ b/src/lib/libcrypto/util/mkfiles.pl
@@ -23,11 +23,13 @@ my @dirs = (
23"crypto/idea", 23"crypto/idea",
24"crypto/bf", 24"crypto/bf",
25"crypto/cast", 25"crypto/cast",
26"crypto/aes",
26"crypto/bn", 27"crypto/bn",
27"crypto/rsa", 28"crypto/rsa",
28"crypto/dsa", 29"crypto/dsa",
29"crypto/dso", 30"crypto/dso",
30"crypto/dh", 31"crypto/dh",
32"crypto/ec",
31"crypto/buffer", 33"crypto/buffer",
32"crypto/bio", 34"crypto/bio",
33"crypto/stack", 35"crypto/stack",
@@ -46,8 +48,10 @@ my @dirs = (
46"crypto/pkcs12", 48"crypto/pkcs12",
47"crypto/comp", 49"crypto/comp",
48"crypto/engine", 50"crypto/engine",
51"crypto/ocsp",
52"crypto/ui",
53"crypto/krb5",
49"ssl", 54"ssl",
50"rsaref",
51"apps", 55"apps",
52"test", 56"test",
53"tools" 57"tools"
diff --git a/src/lib/libcrypto/util/mkstack.pl b/src/lib/libcrypto/util/mkstack.pl
index 3ee13fe7c9..085c50f790 100644
--- a/src/lib/libcrypto/util/mkstack.pl
+++ b/src/lib/libcrypto/util/mkstack.pl
@@ -21,7 +21,7 @@ while (@ARGV) {
21} 21}
22 22
23 23
24@source = (<crypto/*.[ch]>, <crypto/*/*.[ch]>, <rsaref/*.[ch]>, <ssl/*.[ch]>); 24@source = (<crypto/*.[ch]>, <crypto/*/*.[ch]>, <ssl/*.[ch]>);
25foreach $file (@source) { 25foreach $file (@source) {
26 next if -l $file; 26 next if -l $file;
27 27
diff --git a/src/lib/libcrypto/util/pl/BC-16.pl b/src/lib/libcrypto/util/pl/BC-16.pl
index 6c6df4fe0b..2033f524ca 100644
--- a/src/lib/libcrypto/util/pl/BC-16.pl
+++ b/src/lib/libcrypto/util/pl/BC-16.pl
@@ -21,14 +21,14 @@ $lflags="$base_lflags";
21if ($win16) 21if ($win16)
22 { 22 {
23 $shlib=1; 23 $shlib=1;
24 $cflags.=" -DWINDOWS -DWIN16"; 24 $cflags.=" -DOPENSSL_SYSNAME_WIN16";
25 $app_cflag="-W"; 25 $app_cflag="-W";
26 $lib_cflag="-WD"; 26 $lib_cflag="-WD";
27 $lflags.="/Twe"; 27 $lflags.="/Twe";
28 } 28 }
29else 29else
30 { 30 {
31 $cflags.=" -DMSDOS"; 31 $cflags.=" -DOENSSL_SYSNAME_MSDOS";
32 $lflags.=" /Tde"; 32 $lflags.=" /Tde";
33 } 33 }
34 34
diff --git a/src/lib/libcrypto/util/pl/BC-32.pl b/src/lib/libcrypto/util/pl/BC-32.pl
index 20cb3a9c50..78d60616a6 100644
--- a/src/lib/libcrypto/util/pl/BC-32.pl
+++ b/src/lib/libcrypto/util/pl/BC-32.pl
@@ -4,7 +4,6 @@
4 4
5$ssl= "ssleay32"; 5$ssl= "ssleay32";
6$crypto="libeay32"; 6$crypto="libeay32";
7$RSAref="RSAref32";
8 7
9$o='\\'; 8$o='\\';
10$cp='copy'; 9$cp='copy';
@@ -19,7 +18,7 @@ $out_def="out32";
19$tmp_def="tmp32"; 18$tmp_def="tmp32";
20$inc_def="inc32"; 19$inc_def="inc32";
21#enable max error messages, disable most common warnings 20#enable max error messages, disable most common warnings
22$cflags="-DWIN32_LEAN_AND_MEAN -q -w-aus -w-par -w-inl -c -tWC -tWM -DWINDOWS -DWIN32 -DL_ENDIAN -DDSO_WIN32 "; 21$cflags="-DWIN32_LEAN_AND_MEAN -q -w-aus -w-par -w-inl -c -tWC -tWM -DOPENSSL_SYSNAME_WIN32 -DL_ENDIAN -DDSO_WIN32 ";
23if ($debug) 22if ($debug)
24{ 23{
25 $cflags.="-Od -y -v -vi- -D_DEBUG"; 24 $cflags.="-Od -y -v -vi- -D_DEBUG";
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..57180556ca
--- /dev/null
+++ b/src/lib/libcrypto/util/pl/OS2-EMX.pl
@@ -0,0 +1,96 @@
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 -Zmt -Wall ";
14
15if ($debug) {
16 $cflags.="-g ";
17}
18
19$obj='.o';
20$ofile='-o ';
21
22# EXE linking stuff
23$link='${CC}';
24$lflags='${CFLAGS} -Zbsd-signals';
25$efile='-o ';
26$exep='.exe';
27$ex_libs="-lsocket";
28
29# static library stuff
30$mklib='ar r';
31$mlflags='';
32$ranlib="ar s";
33$plib='lib';
34$libp=".a";
35$shlibp=".a";
36$lfile='';
37
38$asm='as';
39$afile='-o ';
40$bn_asm_obj="";
41$bn_asm_src="";
42$des_enc_obj="";
43$des_enc_src="";
44$bf_enc_obj="";
45$bf_enc_src="";
46
47if (!$no_asm)
48 {
49 $bn_asm_obj='crypto\bn\asm\bn-os2.o crypto\bn\asm\co-os2.o';
50 $bn_asm_src='crypto\bn\asm\bn-os2.asm crypto\bn\asm\co-os2.asm';
51 $des_enc_obj='crypto\des\asm\d-os2.o crypto\des\asm\y-os2.o';
52 $des_enc_src='crypto\des\asm\d-os2.asm crypto\des\asm\y-os2.asm';
53 $bf_enc_obj='crypto\bf\asm\b-os2.o';
54 $bf_enc_src='crypto\bf\asm\b-os2.asm';
55 $cast_enc_obj='crypto\cast\asm\c-os2.o';
56 $cast_enc_src='crypto\cast\asm\c-os2.asm';
57 $rc4_enc_obj='crypto\rc4\asm\r4-os2.o';
58 $rc4_enc_src='crypto\rc4\asm\r4-os2.asm';
59 $rc5_enc_obj='crypto\rc5\asm\r5-os2.o';
60 $rc5_enc_src='crypto\rc5\asm\r5-os2.asm';
61 $md5_asm_obj='crypto\md5\asm\m5-os2.o';
62 $md5_asm_src='crypto\md5\asm\m5-os2.asm';
63 $sha1_asm_obj='crypto\sha\asm\s1-os2.o';
64 $sha1_asm_src='crypto\sha\asm\s1-os2.asm';
65 $rmd160_asm_obj='crypto\ripemd\asm\rm-os2.o';
66 $rmd160_asm_src='crypto\ripemd\asm\rm-os2.asm';
67 }
68
69sub do_lib_rule
70 {
71 local($obj,$target,$name,$shlib)=@_;
72 local($ret,$_,$Name);
73
74 $target =~ s/\//$o/g if $o ne '/';
75 $target="$target";
76 ($Name=$name) =~ tr/a-z/A-Z/;
77
78 $ret.="$target: \$(${Name}OBJ)\n";
79 $ret.="\t\$(RM) $target\n";
80 $ret.="\t\$(MKLIB) $target \$(${Name}OBJ)\n";
81 $ret.="\t\$(RANLIB) $target\n\n";
82 }
83
84sub do_link_rule
85 {
86 local($target,$files,$dep_libs,$libs)=@_;
87 local($ret,$_);
88
89 $file =~ s/\//$o/g if $o ne '/';
90 $n=&bname($target);
91 $ret.="$target: $files $dep_libs\n";
92 $ret.="\t\$(LINK) ${efile}$target \$(LFLAGS) $files $libs\n\n";
93 return($ret);
94 }
95
961;
diff --git a/src/lib/libcrypto/util/pl/VC-16.pl b/src/lib/libcrypto/util/pl/VC-16.pl
index a5079d4ca7..7cda5e67a9 100644
--- a/src/lib/libcrypto/util/pl/VC-16.pl
+++ b/src/lib/libcrypto/util/pl/VC-16.pl
@@ -4,7 +4,6 @@
4 4
5$ssl= "ssleay16"; 5$ssl= "ssleay16";
6$crypto="libeay16"; 6$crypto="libeay16";
7$RSAref="RSAref16";
8 7
9$o='\\'; 8$o='\\';
10$cp='copy'; 9$cp='copy';
@@ -34,7 +33,7 @@ $lflags="$base_lflags /STACK:20000";
34 33
35if ($win16) 34if ($win16)
36 { 35 {
37 $cflags.=" -DWINDOWS -DWIN16"; 36 $cflags.=" -DOPENSSL_SYSNAME_WIN16";
38 $app_cflag="/Gw /FPi87"; 37 $app_cflag="/Gw /FPi87";
39 $lib_cflag="/Gw"; 38 $lib_cflag="/Gw";
40 $lib_cflag.=" -D_WINDLL -D_DLL" if $shlib; 39 $lib_cflag.=" -D_WINDLL -D_DLL" if $shlib;
diff --git a/src/lib/libcrypto/util/pl/VC-32.pl b/src/lib/libcrypto/util/pl/VC-32.pl
index 7c6674b971..50bfb34385 100644
--- a/src/lib/libcrypto/util/pl/VC-32.pl
+++ b/src/lib/libcrypto/util/pl/VC-32.pl
@@ -4,7 +4,6 @@
4 4
5$ssl= "ssleay32"; 5$ssl= "ssleay32";
6$crypto="libeay32"; 6$crypto="libeay32";
7$RSAref="RSAref32";
8 7
9$o='\\'; 8$o='\\';
10$cp='copy nul+'; # Timestamps get stuffed otherwise 9$cp='copy nul+'; # Timestamps get stuffed otherwise
@@ -12,7 +11,7 @@ $rm='del';
12 11
13# C compiler stuff 12# C compiler stuff
14$cc='cl'; 13$cc='cl';
15$cflags=' /MD /W3 /WX /G5 /Ox /O2 /Ob2 /Gs0 /GF /Gy /nologo -DWIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32'; 14$cflags=' /MD /W3 /WX /G5 /Ox /O2 /Ob2 /Gs0 /GF /Gy /nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32';
16$lflags="/nologo /subsystem:console /machine:I386 /opt:ref"; 15$lflags="/nologo /subsystem:console /machine:I386 /opt:ref";
17$mlflags=''; 16$mlflags='';
18 17
@@ -22,11 +21,11 @@ $inc_def="inc32";
22 21
23if ($debug) 22if ($debug)
24 { 23 {
25 $cflags=" /MDd /W3 /WX /Zi /Yd /Od /nologo -DWIN32 -D_DEBUG -DL_ENDIAN -DWIN32_LEAN_AND_MEAN -DDEBUG -DDSO_WIN32"; 24 $cflags=" /MDd /W3 /WX /Zi /Yd /Od /nologo -DOPENSSL_SYSNAME_WIN32 -D_DEBUG -DL_ENDIAN -DWIN32_LEAN_AND_MEAN -DDEBUG -DDSO_WIN32";
26 $lflags.=" /debug"; 25 $lflags.=" /debug";
27 $mlflags.=' /debug'; 26 $mlflags.=' /debug';
28 } 27 }
29$cflags .= " -DWINNT" if $NT == 1; 28$cflags .= " -DOPENSSL_SYSNAME_WINNT" if $NT == 1;
30 29
31$obj='.obj'; 30$obj='.obj';
32$ofile="/Fo"; 31$ofile="/Fo";
@@ -92,7 +91,7 @@ if ($shlib)
92 { 91 {
93 $mlflags.=" $lflags /dll"; 92 $mlflags.=" $lflags /dll";
94# $cflags =~ s| /MD| /MT|; 93# $cflags =~ s| /MD| /MT|;
95 $lib_cflag=" /GD -D_WINDLL -D_DLL"; 94 $lib_cflag=" -D_WINDLL -D_DLL";
96 $out_def="out32dll"; 95 $out_def="out32dll";
97 $tmp_def="tmp32dll"; 96 $tmp_def="tmp32dll";
98 } 97 }
diff --git a/src/lib/libcrypto/util/selftest.pl b/src/lib/libcrypto/util/selftest.pl
index eb50d52ff8..276b81183d 100644
--- a/src/lib/libcrypto/util/selftest.pl
+++ b/src/lib/libcrypto/util/selftest.pl
@@ -50,6 +50,7 @@ if (open(IN,"<Makefile.ssl")) {
50 50
51$cversion=`$cc -v 2>&1`; 51$cversion=`$cc -v 2>&1`;
52$cversion=`$cc -V 2>&1` if $cversion =~ "usage"; 52$cversion=`$cc -V 2>&1` if $cversion =~ "usage";
53$cversion=`$cc -V |head -1` if $cversion =~ "Error";
53$cversion=`$cc --version` if $cversion eq ""; 54$cversion=`$cc --version` if $cversion eq "";
54$cversion =~ s/Reading specs.*\n//; 55$cversion =~ s/Reading specs.*\n//;
55$cversion =~ s/usage.*\n//; 56$cversion =~ s/usage.*\n//;
@@ -57,7 +58,7 @@ chomp $cversion;
57 58
58if (open(IN,"<CHANGES")) { 59if (open(IN,"<CHANGES")) {
59 while(<IN>) { 60 while(<IN>) {
60 if (/\*\) (.{0,55})/) { 61 if (/\*\) (.{0,55})/ && !/applies to/) {
61 $last=$1; 62 $last=$1;
62 last; 63 last;
63 } 64 }
@@ -131,19 +132,14 @@ if (system("make 2>&1 | tee make.log") > 255) {
131 132
132$_=$options; 133$_=$options;
133s/no-asm//; 134s/no-asm//;
135s/no-shared//;
136s/no-krb5//;
134if (/no-/) 137if (/no-/)
135{ 138{
136 print OUT "Test skipped.\n"; 139 print OUT "Test skipped.\n";
137 goto err; 140 goto err;
138} 141}
139 142
140if (`echo 4+1 | bc` != 5)
141{
142 print OUT "Can't run bc! Test skipped.\n";
143 print OUT $not_our_fault;
144 goto err;
145}
146
147print "Running make test...\n"; 143print "Running make test...\n";
148if (system("make test 2>&1 | tee maketest.log") > 255) 144if (system("make test 2>&1 | tee maketest.log") > 255)
149 { 145 {
diff --git a/src/lib/libcrypto/util/ssleay.num b/src/lib/libcrypto/util/ssleay.num
index 561bac2ec9..fdea47205d 100644
--- a/src/lib/libcrypto/util/ssleay.num
+++ b/src/lib/libcrypto/util/ssleay.num
@@ -18,16 +18,16 @@ SSL_CTX_set_ssl_version 19 EXIST::FUNCTION:
18SSL_CTX_set_verify 21 EXIST::FUNCTION: 18SSL_CTX_set_verify 21 EXIST::FUNCTION:
19SSL_CTX_use_PrivateKey 22 EXIST::FUNCTION: 19SSL_CTX_use_PrivateKey 22 EXIST::FUNCTION:
20SSL_CTX_use_PrivateKey_ASN1 23 EXIST::FUNCTION: 20SSL_CTX_use_PrivateKey_ASN1 23 EXIST::FUNCTION:
21SSL_CTX_use_PrivateKey_file 24 EXIST::FUNCTION: 21SSL_CTX_use_PrivateKey_file 24 EXIST::FUNCTION:STDIO
22SSL_CTX_use_RSAPrivateKey 25 EXIST::FUNCTION:RSA 22SSL_CTX_use_RSAPrivateKey 25 EXIST::FUNCTION:RSA
23SSL_CTX_use_RSAPrivateKey_ASN1 26 EXIST::FUNCTION:RSA 23SSL_CTX_use_RSAPrivateKey_ASN1 26 EXIST::FUNCTION:RSA
24SSL_CTX_use_RSAPrivateKey_file 27 EXIST::FUNCTION:RSA 24SSL_CTX_use_RSAPrivateKey_file 27 EXIST::FUNCTION:RSA,STDIO
25SSL_CTX_use_certificate 28 EXIST::FUNCTION: 25SSL_CTX_use_certificate 28 EXIST::FUNCTION:
26SSL_CTX_use_certificate_ASN1 29 EXIST::FUNCTION: 26SSL_CTX_use_certificate_ASN1 29 EXIST::FUNCTION:
27SSL_CTX_use_certificate_file 30 EXIST::FUNCTION: 27SSL_CTX_use_certificate_file 30 EXIST::FUNCTION:STDIO
28SSL_SESSION_free 31 EXIST::FUNCTION: 28SSL_SESSION_free 31 EXIST::FUNCTION:
29SSL_SESSION_new 32 EXIST::FUNCTION: 29SSL_SESSION_new 32 EXIST::FUNCTION:
30SSL_SESSION_print 33 EXIST::FUNCTION: 30SSL_SESSION_print 33 EXIST::FUNCTION:BIO
31SSL_SESSION_print_fp 34 EXIST::FUNCTION:FP_API 31SSL_SESSION_print_fp 34 EXIST::FUNCTION:FP_API
32SSL_accept 35 EXIST::FUNCTION: 32SSL_accept 35 EXIST::FUNCTION:
33SSL_add_client_CA 36 EXIST::FUNCTION: 33SSL_add_client_CA 36 EXIST::FUNCTION:
@@ -52,15 +52,15 @@ SSL_get_error 58 EXIST::FUNCTION:
52SSL_get_fd 59 EXIST::FUNCTION: 52SSL_get_fd 59 EXIST::FUNCTION:
53SSL_get_peer_cert_chain 60 EXIST::FUNCTION: 53SSL_get_peer_cert_chain 60 EXIST::FUNCTION:
54SSL_get_peer_certificate 61 EXIST::FUNCTION: 54SSL_get_peer_certificate 61 EXIST::FUNCTION:
55SSL_get_rbio 63 EXIST::FUNCTION: 55SSL_get_rbio 63 EXIST::FUNCTION:BIO
56SSL_get_read_ahead 64 EXIST::FUNCTION: 56SSL_get_read_ahead 64 EXIST::FUNCTION:
57SSL_get_shared_ciphers 65 EXIST::FUNCTION: 57SSL_get_shared_ciphers 65 EXIST::FUNCTION:
58SSL_get_ssl_method 66 EXIST::FUNCTION: 58SSL_get_ssl_method 66 EXIST::FUNCTION:
59SSL_get_verify_callback 69 EXIST::FUNCTION: 59SSL_get_verify_callback 69 EXIST::FUNCTION:
60SSL_get_verify_mode 70 EXIST::FUNCTION: 60SSL_get_verify_mode 70 EXIST::FUNCTION:
61SSL_get_version 71 EXIST::FUNCTION: 61SSL_get_version 71 EXIST::FUNCTION:
62SSL_get_wbio 72 EXIST::FUNCTION: 62SSL_get_wbio 72 EXIST::FUNCTION:BIO
63SSL_load_client_CA_file 73 EXIST::FUNCTION: 63SSL_load_client_CA_file 73 EXIST::FUNCTION:STDIO
64SSL_load_error_strings 74 EXIST::FUNCTION: 64SSL_load_error_strings 74 EXIST::FUNCTION:
65SSL_new 75 EXIST::FUNCTION: 65SSL_new 75 EXIST::FUNCTION:
66SSL_peek 76 EXIST::FUNCTION: 66SSL_peek 76 EXIST::FUNCTION:
@@ -70,29 +70,29 @@ SSL_renegotiate 79 EXIST::FUNCTION:
70SSL_rstate_string 80 EXIST::FUNCTION: 70SSL_rstate_string 80 EXIST::FUNCTION:
71SSL_rstate_string_long 81 EXIST::FUNCTION: 71SSL_rstate_string_long 81 EXIST::FUNCTION:
72SSL_set_accept_state 82 EXIST::FUNCTION: 72SSL_set_accept_state 82 EXIST::FUNCTION:
73SSL_set_bio 83 EXIST::FUNCTION: 73SSL_set_bio 83 EXIST::FUNCTION:BIO
74SSL_set_cipher_list 84 EXIST::FUNCTION: 74SSL_set_cipher_list 84 EXIST::FUNCTION:
75SSL_set_client_CA_list 85 EXIST::FUNCTION: 75SSL_set_client_CA_list 85 EXIST::FUNCTION:
76SSL_set_connect_state 86 EXIST::FUNCTION: 76SSL_set_connect_state 86 EXIST::FUNCTION:
77SSL_set_fd 87 EXIST::FUNCTION: 77SSL_set_fd 87 EXIST::FUNCTION:SOCK
78SSL_set_read_ahead 88 EXIST::FUNCTION: 78SSL_set_read_ahead 88 EXIST::FUNCTION:
79SSL_set_rfd 89 EXIST::FUNCTION: 79SSL_set_rfd 89 EXIST::FUNCTION:SOCK
80SSL_set_session 90 EXIST::FUNCTION: 80SSL_set_session 90 EXIST::FUNCTION:
81SSL_set_ssl_method 91 EXIST::FUNCTION: 81SSL_set_ssl_method 91 EXIST::FUNCTION:
82SSL_set_verify 94 EXIST::FUNCTION: 82SSL_set_verify 94 EXIST::FUNCTION:
83SSL_set_wfd 95 EXIST::FUNCTION: 83SSL_set_wfd 95 EXIST::FUNCTION:SOCK
84SSL_shutdown 96 EXIST::FUNCTION: 84SSL_shutdown 96 EXIST::FUNCTION:
85SSL_state_string 97 EXIST::FUNCTION: 85SSL_state_string 97 EXIST::FUNCTION:
86SSL_state_string_long 98 EXIST::FUNCTION: 86SSL_state_string_long 98 EXIST::FUNCTION:
87SSL_use_PrivateKey 99 EXIST::FUNCTION: 87SSL_use_PrivateKey 99 EXIST::FUNCTION:
88SSL_use_PrivateKey_ASN1 100 EXIST::FUNCTION: 88SSL_use_PrivateKey_ASN1 100 EXIST::FUNCTION:
89SSL_use_PrivateKey_file 101 EXIST::FUNCTION: 89SSL_use_PrivateKey_file 101 EXIST::FUNCTION:STDIO
90SSL_use_RSAPrivateKey 102 EXIST::FUNCTION:RSA 90SSL_use_RSAPrivateKey 102 EXIST::FUNCTION:RSA
91SSL_use_RSAPrivateKey_ASN1 103 EXIST::FUNCTION:RSA 91SSL_use_RSAPrivateKey_ASN1 103 EXIST::FUNCTION:RSA
92SSL_use_RSAPrivateKey_file 104 EXIST::FUNCTION:RSA 92SSL_use_RSAPrivateKey_file 104 EXIST::FUNCTION:RSA,STDIO
93SSL_use_certificate 105 EXIST::FUNCTION: 93SSL_use_certificate 105 EXIST::FUNCTION:
94SSL_use_certificate_ASN1 106 EXIST::FUNCTION: 94SSL_use_certificate_ASN1 106 EXIST::FUNCTION:
95SSL_use_certificate_file 107 EXIST::FUNCTION: 95SSL_use_certificate_file 107 EXIST::FUNCTION:STDIO
96SSL_write 108 EXIST::FUNCTION: 96SSL_write 108 EXIST::FUNCTION:
97SSLeay_add_ssl_algorithms 109 NOEXIST::FUNCTION: 97SSLeay_add_ssl_algorithms 109 NOEXIST::FUNCTION:
98SSLv23_client_method 110 EXIST::FUNCTION:RSA 98SSLv23_client_method 110 EXIST::FUNCTION:RSA
@@ -106,17 +106,17 @@ SSLv3_method 117 EXIST::FUNCTION:
106SSLv3_server_method 118 EXIST::FUNCTION: 106SSLv3_server_method 118 EXIST::FUNCTION:
107d2i_SSL_SESSION 119 EXIST::FUNCTION: 107d2i_SSL_SESSION 119 EXIST::FUNCTION:
108i2d_SSL_SESSION 120 EXIST::FUNCTION: 108i2d_SSL_SESSION 120 EXIST::FUNCTION:
109BIO_f_ssl 121 EXIST::FUNCTION: 109BIO_f_ssl 121 EXIST::FUNCTION:BIO
110BIO_new_ssl 122 EXIST::FUNCTION: 110BIO_new_ssl 122 EXIST::FUNCTION:BIO
111BIO_proxy_ssl_copy_session_id 123 NOEXIST::FUNCTION: 111BIO_proxy_ssl_copy_session_id 123 NOEXIST::FUNCTION:
112BIO_ssl_copy_session_id 124 EXIST::FUNCTION: 112BIO_ssl_copy_session_id 124 EXIST::FUNCTION:BIO
113SSL_do_handshake 125 EXIST::FUNCTION: 113SSL_do_handshake 125 EXIST::FUNCTION:
114SSL_get_privatekey 126 EXIST::FUNCTION: 114SSL_get_privatekey 126 EXIST::FUNCTION:
115SSL_get_current_cipher 127 EXIST::FUNCTION: 115SSL_get_current_cipher 127 EXIST::FUNCTION:
116SSL_CIPHER_get_bits 128 EXIST::FUNCTION: 116SSL_CIPHER_get_bits 128 EXIST::FUNCTION:
117SSL_CIPHER_get_version 129 EXIST::FUNCTION: 117SSL_CIPHER_get_version 129 EXIST::FUNCTION:
118SSL_CIPHER_get_name 130 EXIST::FUNCTION: 118SSL_CIPHER_get_name 130 EXIST::FUNCTION:
119BIO_ssl_shutdown 131 EXIST::FUNCTION: 119BIO_ssl_shutdown 131 EXIST::FUNCTION:BIO
120SSL_SESSION_cmp 132 EXIST::FUNCTION: 120SSL_SESSION_cmp 132 EXIST::FUNCTION:
121SSL_SESSION_hash 133 EXIST::FUNCTION: 121SSL_SESSION_hash 133 EXIST::FUNCTION:
122SSL_SESSION_get_time 134 EXIST::FUNCTION: 122SSL_SESSION_get_time 134 EXIST::FUNCTION:
@@ -152,8 +152,8 @@ SSL_get_ex_new_index 169 EXIST::FUNCTION:
152TLSv1_method 170 EXIST::FUNCTION: 152TLSv1_method 170 EXIST::FUNCTION:
153TLSv1_server_method 171 EXIST::FUNCTION: 153TLSv1_server_method 171 EXIST::FUNCTION:
154TLSv1_client_method 172 EXIST::FUNCTION: 154TLSv1_client_method 172 EXIST::FUNCTION:
155BIO_new_buffer_ssl_connect 173 EXIST::FUNCTION: 155BIO_new_buffer_ssl_connect 173 EXIST::FUNCTION:BIO
156BIO_new_ssl_connect 174 EXIST::FUNCTION: 156BIO_new_ssl_connect 174 EXIST::FUNCTION:BIO
157SSL_get_ex_data_X509_STORE_CTX_idx 175 EXIST:!VMS:FUNCTION: 157SSL_get_ex_data_X509_STORE_CTX_idx 175 EXIST:!VMS:FUNCTION:
158SSL_get_ex_d_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 159SSL_CTX_set_tmp_dh_callback 176 EXIST::FUNCTION:DH
@@ -164,16 +164,16 @@ SSL_CTX_get_cert_store 180 EXIST::FUNCTION:
164SSL_CTX_set_cert_store 181 EXIST::FUNCTION: 164SSL_CTX_set_cert_store 181 EXIST::FUNCTION:
165SSL_want 182 EXIST::FUNCTION: 165SSL_want 182 EXIST::FUNCTION:
166SSL_library_init 183 EXIST::FUNCTION: 166SSL_library_init 183 EXIST::FUNCTION:
167SSL_COMP_add_compression_method 184 EXIST::FUNCTION: 167SSL_COMP_add_compression_method 184 EXIST::FUNCTION:COMP
168SSL_add_file_cert_subjects_to_stack 185 EXIST:!VMS:FUNCTION: 168SSL_add_file_cert_subjects_to_stack 185 EXIST:!VMS:FUNCTION:STDIO
169SSL_add_file_cert_subjs_to_stk 185 EXIST:VMS:FUNCTION: 169SSL_add_file_cert_subjs_to_stk 185 EXIST:VMS:FUNCTION:STDIO
170SSL_set_tmp_rsa_callback 186 EXIST::FUNCTION:RSA 170SSL_set_tmp_rsa_callback 186 EXIST::FUNCTION:RSA
171SSL_set_tmp_dh_callback 187 EXIST::FUNCTION:DH 171SSL_set_tmp_dh_callback 187 EXIST::FUNCTION:DH
172SSL_add_dir_cert_subjects_to_stack 188 NOEXIST::FUNCTION: 172SSL_add_dir_cert_subjects_to_stack 188 EXIST:!VMS,!WIN32:FUNCTION:STDIO
173SSL_add_dir_cert_subjs_to_stk 188 EXIST:VMS:FUNCTION: 173SSL_add_dir_cert_subjs_to_stk 188 NOEXIST::FUNCTION:
174SSL_set_session_id_context 189 EXIST::FUNCTION: 174SSL_set_session_id_context 189 EXIST::FUNCTION:
175SSL_CTX_use_certificate_chain_file 222 EXIST:!VMS:FUNCTION: 175SSL_CTX_use_certificate_chain_file 222 EXIST:!VMS:FUNCTION:STDIO
176SSL_CTX_use_cert_chain_file 222 EXIST:VMS:FUNCTION: 176SSL_CTX_use_cert_chain_file 222 EXIST:VMS:FUNCTION:STDIO
177SSL_CTX_set_verify_depth 225 EXIST::FUNCTION: 177SSL_CTX_set_verify_depth 225 EXIST::FUNCTION:
178SSL_set_verify_depth 226 EXIST::FUNCTION: 178SSL_set_verify_depth 226 EXIST::FUNCTION:
179SSL_CTX_get_verify_depth 228 EXIST::FUNCTION: 179SSL_CTX_get_verify_depth 228 EXIST::FUNCTION:
@@ -193,3 +193,25 @@ SSL_get1_session 242 EXIST::FUNCTION:
193SSL_CTX_callback_ctrl 243 EXIST::FUNCTION: 193SSL_CTX_callback_ctrl 243 EXIST::FUNCTION:
194SSL_callback_ctrl 244 EXIST::FUNCTION: 194SSL_callback_ctrl 244 EXIST::FUNCTION:
195SSL_CTX_sessions 245 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/x509/Makefile.ssl b/src/lib/libcrypto/x509/Makefile.ssl
index 79f09d4f71..62243ae812 100644
--- a/src/lib/libcrypto/x509/Makefile.ssl
+++ b/src/lib/libcrypto/x509/Makefile.ssl
@@ -5,13 +5,14 @@
5DIR= x509 5DIR= x509
6TOP= ../.. 6TOP= ../..
7CC= cc 7CC= cc
8INCLUDES= -I.. -I../../include 8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g 9CFLAG=-g
10INSTALL_PREFIX= 10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl 11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl 12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl 13MAKE= make -f Makefile.ssl
14MAKEDEPEND= $(TOP)/util/domd $(TOP) 14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
15MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
16AR= ar r 17AR= ar r
17 18
@@ -24,13 +25,13 @@ APPS=
24LIB=$(TOP)/libcrypto.a 25LIB=$(TOP)/libcrypto.a
25LIBSRC= x509_def.c x509_d2.c x509_r2x.c x509_cmp.c \ 26LIBSRC= x509_def.c x509_d2.c x509_r2x.c x509_cmp.c \
26 x509_obj.c x509_req.c x509spki.c x509_vfy.c \ 27 x509_obj.c x509_req.c x509spki.c x509_vfy.c \
27 x509_set.c x509rset.c x509_err.c \ 28 x509_set.c x509cset.c x509rset.c x509_err.c \
28 x509name.c x509_v3.c x509_ext.c x509_att.c \ 29 x509name.c x509_v3.c x509_ext.c x509_att.c \
29 x509type.c x509_lu.c x_all.c x509_txt.c \ 30 x509type.c x509_lu.c x_all.c x509_txt.c \
30 x509_trs.c by_file.c by_dir.c 31 x509_trs.c by_file.c by_dir.c
31LIBOBJ= x509_def.o x509_d2.o x509_r2x.o x509_cmp.o \ 32LIBOBJ= x509_def.o x509_d2.o x509_r2x.o x509_cmp.o \
32 x509_obj.o x509_req.o x509spki.o x509_vfy.o \ 33 x509_obj.o x509_req.o x509spki.o x509_vfy.o \
33 x509_set.o x509rset.o x509_err.o \ 34 x509_set.o x509cset.o x509rset.o x509_err.o \
34 x509name.o x509_v3.o x509_ext.o x509_att.o \ 35 x509name.o x509_v3.o x509_ext.o x509_att.o \
35 x509type.o x509_lu.o x_all.o x509_txt.o \ 36 x509type.o x509_lu.o x_all.o x509_txt.o \
36 x509_trs.o by_file.o by_dir.o 37 x509_trs.o by_file.o by_dir.o
@@ -49,8 +50,7 @@ all: lib
49 50
50lib: $(LIBOBJ) 51lib: $(LIBOBJ)
51 $(AR) $(LIB) $(LIBOBJ) 52 $(AR) $(LIB) $(LIBOBJ)
52 @echo You may get an error following this line. Please ignore. 53 $(RANLIB) $(LIB) || echo Never mind.
53 - $(RANLIB) $(LIB)
54 @touch lib 54 @touch lib
55 55
56files: 56files:
@@ -89,433 +89,322 @@ clean:
89 89
90# DO NOT DELETE THIS LINE -- make depend depends on it. 90# DO NOT DELETE THIS LINE -- make depend depends on it.
91 91
92by_dir.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 92by_dir.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
93by_dir.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 93by_dir.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
94by_dir.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 94by_dir.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
95by_dir.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 95by_dir.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
96by_dir.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
97by_dir.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
98by_dir.o: ../../include/openssl/err.h ../../include/openssl/evp.h 96by_dir.o: ../../include/openssl/err.h ../../include/openssl/evp.h
99by_dir.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 97by_dir.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
100by_dir.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 98by_dir.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
101by_dir.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 99by_dir.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
102by_dir.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 100by_dir.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
103by_dir.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
104by_dir.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
105by_dir.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
106by_dir.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
107by_dir.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 101by_dir.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
108by_dir.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 102by_dir.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
109by_dir.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 103by_dir.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
110by_dir.o: ../cryptlib.h 104by_dir.o: ../cryptlib.h by_dir.c
111by_file.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 105by_file.o: ../../e_os.h ../../include/openssl/asn1.h
112by_file.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 106by_file.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
113by_file.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 107by_file.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
114by_file.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
115by_file.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 108by_file.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
116by_file.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 109by_file.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
117by_file.o: ../../include/openssl/err.h ../../include/openssl/evp.h 110by_file.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
118by_file.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
119by_file.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
120by_file.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
121by_file.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 111by_file.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
122by_file.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 112by_file.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
123by_file.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h 113by_file.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h
124by_file.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h 114by_file.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h
125by_file.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 115by_file.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
126by_file.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 116by_file.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
127by_file.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 117by_file.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
128by_file.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 118by_file.o: ../../include/openssl/x509_vfy.h ../cryptlib.h by_file.c
129by_file.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 119x509_att.o: ../../e_os.h ../../include/openssl/asn1.h
130by_file.o: ../cryptlib.h 120x509_att.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
131x509_att.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 121x509_att.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
132x509_att.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 122x509_att.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
133x509_att.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 123x509_att.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
134x509_att.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
135x509_att.o: ../../include/openssl/des.h ../../include/openssl/dh.h
136x509_att.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
137x509_att.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
138x509_att.o: ../../include/openssl/err.h ../../include/openssl/evp.h 124x509_att.o: ../../include/openssl/err.h ../../include/openssl/evp.h
139x509_att.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 125x509_att.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
140x509_att.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 126x509_att.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
141x509_att.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 127x509_att.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
142x509_att.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 128x509_att.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
143x509_att.o: ../../include/openssl/opensslconf.h 129x509_att.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
144x509_att.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 130x509_att.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
145x509_att.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 131x509_att.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
146x509_att.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 132x509_att.o: ../../include/openssl/x509v3.h ../cryptlib.h x509_att.c
147x509_att.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 133x509_cmp.o: ../../e_os.h ../../include/openssl/asn1.h
148x509_att.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 134x509_cmp.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
149x509_att.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 135x509_cmp.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
150x509_att.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h 136x509_cmp.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
151x509_att.o: ../cryptlib.h 137x509_cmp.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
152x509_cmp.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
153x509_cmp.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
154x509_cmp.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
155x509_cmp.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
156x509_cmp.o: ../../include/openssl/des.h ../../include/openssl/dh.h
157x509_cmp.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
158x509_cmp.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
159x509_cmp.o: ../../include/openssl/err.h ../../include/openssl/evp.h 138x509_cmp.o: ../../include/openssl/err.h ../../include/openssl/evp.h
160x509_cmp.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 139x509_cmp.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
161x509_cmp.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 140x509_cmp.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
162x509_cmp.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 141x509_cmp.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
163x509_cmp.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 142x509_cmp.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
164x509_cmp.o: ../../include/openssl/opensslconf.h 143x509_cmp.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
165x509_cmp.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 144x509_cmp.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
166x509_cmp.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 145x509_cmp.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
167x509_cmp.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 146x509_cmp.o: ../../include/openssl/x509v3.h ../cryptlib.h x509_cmp.c
168x509_cmp.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 147x509_d2.o: ../../e_os.h ../../include/openssl/asn1.h
169x509_cmp.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 148x509_d2.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
170x509_cmp.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 149x509_d2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
171x509_cmp.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
172x509_cmp.o: ../cryptlib.h
173x509_d2.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
174x509_d2.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
175x509_d2.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
176x509_d2.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
177x509_d2.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 150x509_d2.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
178x509_d2.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 151x509_d2.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
179x509_d2.o: ../../include/openssl/err.h ../../include/openssl/evp.h 152x509_d2.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
180x509_d2.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
181x509_d2.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
182x509_d2.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
183x509_d2.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 153x509_d2.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
184x509_d2.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 154x509_d2.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
185x509_d2.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h 155x509_d2.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
186x509_d2.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 156x509_d2.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
187x509_d2.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 157x509_d2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
188x509_d2.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 158x509_d2.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
189x509_d2.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 159x509_d2.o: ../../include/openssl/x509_vfy.h ../cryptlib.h x509_d2.c
190x509_d2.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 160x509_def.o: ../../e_os.h ../../include/openssl/asn1.h
191x509_d2.o: ../cryptlib.h 161x509_def.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
192x509_def.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 162x509_def.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
193x509_def.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
194x509_def.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
195x509_def.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
196x509_def.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 163x509_def.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
197x509_def.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 164x509_def.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
198x509_def.o: ../../include/openssl/err.h ../../include/openssl/evp.h 165x509_def.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
199x509_def.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
200x509_def.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
201x509_def.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
202x509_def.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 166x509_def.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
203x509_def.o: ../../include/openssl/opensslconf.h 167x509_def.o: ../../include/openssl/opensslconf.h
204x509_def.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 168x509_def.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
205x509_def.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 169x509_def.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
206x509_def.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 170x509_def.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
207x509_def.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 171x509_def.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
208x509_def.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 172x509_def.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
209x509_def.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 173x509_def.o: ../cryptlib.h x509_def.c
210x509_def.o: ../../include/openssl/x509_vfy.h ../cryptlib.h
211x509_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 174x509_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
212x509_err.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 175x509_err.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
213x509_err.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 176x509_err.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
214x509_err.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 177x509_err.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
215x509_err.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 178x509_err.o: ../../include/openssl/err.h ../../include/openssl/evp.h
216x509_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 179x509_err.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
217x509_err.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
218x509_err.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
219x509_err.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
220x509_err.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
221x509_err.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 180x509_err.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
222x509_err.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 181x509_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
223x509_err.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 182x509_err.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
224x509_err.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 183x509_err.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
225x509_err.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 184x509_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
226x509_err.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 185x509_err.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
227x509_err.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 186x509_err.o: x509_err.c
228x509_err.o: ../../include/openssl/x509_vfy.h 187x509_ext.o: ../../e_os.h ../../include/openssl/asn1.h
229x509_ext.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 188x509_ext.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
230x509_ext.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 189x509_ext.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
231x509_ext.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 190x509_ext.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
232x509_ext.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h 191x509_ext.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
233x509_ext.o: ../../include/openssl/des.h ../../include/openssl/dh.h
234x509_ext.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
235x509_ext.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
236x509_ext.o: ../../include/openssl/err.h ../../include/openssl/evp.h 192x509_ext.o: ../../include/openssl/err.h ../../include/openssl/evp.h
237x509_ext.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 193x509_ext.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
238x509_ext.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 194x509_ext.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
239x509_ext.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 195x509_ext.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
240x509_ext.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 196x509_ext.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
241x509_ext.o: ../../include/openssl/opensslconf.h 197x509_ext.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
242x509_ext.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 198x509_ext.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
243x509_ext.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 199x509_ext.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
244x509_ext.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 200x509_ext.o: ../../include/openssl/x509v3.h ../cryptlib.h x509_ext.c
245x509_ext.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 201x509_lu.o: ../../e_os.h ../../include/openssl/asn1.h
246x509_ext.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 202x509_lu.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
247x509_ext.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 203x509_lu.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
248x509_ext.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h 204x509_lu.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
249x509_ext.o: ../cryptlib.h 205x509_lu.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
250x509_lu.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
251x509_lu.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
252x509_lu.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
253x509_lu.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
254x509_lu.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
255x509_lu.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
256x509_lu.o: ../../include/openssl/err.h ../../include/openssl/evp.h 206x509_lu.o: ../../include/openssl/err.h ../../include/openssl/evp.h
257x509_lu.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 207x509_lu.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
258x509_lu.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 208x509_lu.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
259x509_lu.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 209x509_lu.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
260x509_lu.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 210x509_lu.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
261x509_lu.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
262x509_lu.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
263x509_lu.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
264x509_lu.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
265x509_lu.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 211x509_lu.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
266x509_lu.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 212x509_lu.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
267x509_lu.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 213x509_lu.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
268x509_lu.o: ../cryptlib.h 214x509_lu.o: ../../include/openssl/x509v3.h ../cryptlib.h x509_lu.c
269x509_obj.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 215x509_obj.o: ../../e_os.h ../../include/openssl/asn1.h
270x509_obj.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 216x509_obj.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
271x509_obj.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 217x509_obj.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
272x509_obj.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
273x509_obj.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 218x509_obj.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
274x509_obj.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 219x509_obj.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
275x509_obj.o: ../../include/openssl/err.h ../../include/openssl/evp.h 220x509_obj.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
276x509_obj.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
277x509_obj.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
278x509_obj.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
279x509_obj.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 221x509_obj.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
280x509_obj.o: ../../include/openssl/opensslconf.h 222x509_obj.o: ../../include/openssl/opensslconf.h
281x509_obj.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 223x509_obj.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
282x509_obj.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 224x509_obj.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
283x509_obj.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 225x509_obj.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
284x509_obj.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 226x509_obj.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
285x509_obj.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 227x509_obj.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
286x509_obj.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 228x509_obj.o: ../cryptlib.h x509_obj.c
287x509_obj.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 229x509_r2x.o: ../../e_os.h ../../include/openssl/asn1.h
288x509_r2x.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 230x509_r2x.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
289x509_r2x.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 231x509_r2x.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
290x509_r2x.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
291x509_r2x.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
292x509_r2x.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 232x509_r2x.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
293x509_r2x.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 233x509_r2x.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
294x509_r2x.o: ../../include/openssl/err.h ../../include/openssl/evp.h 234x509_r2x.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
295x509_r2x.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
296x509_r2x.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
297x509_r2x.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
298x509_r2x.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 235x509_r2x.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
299x509_r2x.o: ../../include/openssl/opensslconf.h 236x509_r2x.o: ../../include/openssl/opensslconf.h
300x509_r2x.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 237x509_r2x.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
301x509_r2x.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 238x509_r2x.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
302x509_r2x.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 239x509_r2x.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
303x509_r2x.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 240x509_r2x.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
304x509_r2x.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 241x509_r2x.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
305x509_r2x.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 242x509_r2x.o: ../cryptlib.h x509_r2x.c
306x509_r2x.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 243x509_req.o: ../../e_os.h ../../include/openssl/asn1.h
307x509_req.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 244x509_req.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
308x509_req.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 245x509_req.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
309x509_req.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
310x509_req.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
311x509_req.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 246x509_req.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
312x509_req.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 247x509_req.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
313x509_req.o: ../../include/openssl/err.h ../../include/openssl/evp.h 248x509_req.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
314x509_req.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
315x509_req.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
316x509_req.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
317x509_req.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 249x509_req.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
318x509_req.o: ../../include/openssl/opensslconf.h 250x509_req.o: ../../include/openssl/opensslconf.h
319x509_req.o: ../../include/openssl/opensslv.h ../../include/openssl/pem.h 251x509_req.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
320x509_req.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h 252x509_req.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
321x509_req.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 253x509_req.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
322x509_req.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 254x509_req.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
323x509_req.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 255x509_req.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
324x509_req.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 256x509_req.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
325x509_req.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 257x509_req.o: ../cryptlib.h x509_req.c
326x509_req.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 258x509_set.o: ../../e_os.h ../../include/openssl/asn1.h
327x509_set.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 259x509_set.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
328x509_set.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 260x509_set.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
329x509_set.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
330x509_set.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
331x509_set.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 261x509_set.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
332x509_set.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 262x509_set.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
333x509_set.o: ../../include/openssl/err.h ../../include/openssl/evp.h 263x509_set.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
334x509_set.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
335x509_set.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
336x509_set.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
337x509_set.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 264x509_set.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
338x509_set.o: ../../include/openssl/opensslconf.h 265x509_set.o: ../../include/openssl/opensslconf.h
339x509_set.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 266x509_set.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
340x509_set.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 267x509_set.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
341x509_set.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 268x509_set.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
342x509_set.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 269x509_set.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
343x509_set.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 270x509_set.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
344x509_set.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 271x509_set.o: ../cryptlib.h x509_set.c
345x509_set.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 272x509_trs.o: ../../e_os.h ../../include/openssl/asn1.h
346x509_trs.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 273x509_trs.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
347x509_trs.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 274x509_trs.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
348x509_trs.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 275x509_trs.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
349x509_trs.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h 276x509_trs.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
350x509_trs.o: ../../include/openssl/des.h ../../include/openssl/dh.h
351x509_trs.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
352x509_trs.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
353x509_trs.o: ../../include/openssl/err.h ../../include/openssl/evp.h 277x509_trs.o: ../../include/openssl/err.h ../../include/openssl/evp.h
354x509_trs.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 278x509_trs.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
355x509_trs.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 279x509_trs.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
356x509_trs.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 280x509_trs.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
357x509_trs.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 281x509_trs.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
358x509_trs.o: ../../include/openssl/opensslconf.h 282x509_trs.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
359x509_trs.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 283x509_trs.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
360x509_trs.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 284x509_trs.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
361x509_trs.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 285x509_trs.o: ../../include/openssl/x509v3.h ../cryptlib.h x509_trs.c
362x509_trs.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 286x509_txt.o: ../../e_os.h ../../include/openssl/asn1.h
363x509_trs.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 287x509_txt.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
364x509_trs.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 288x509_txt.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
365x509_trs.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
366x509_trs.o: ../cryptlib.h
367x509_txt.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
368x509_txt.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
369x509_txt.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
370x509_txt.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
371x509_txt.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 289x509_txt.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
372x509_txt.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 290x509_txt.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
373x509_txt.o: ../../include/openssl/err.h ../../include/openssl/evp.h 291x509_txt.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
374x509_txt.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
375x509_txt.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
376x509_txt.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
377x509_txt.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 292x509_txt.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
378x509_txt.o: ../../include/openssl/opensslconf.h 293x509_txt.o: ../../include/openssl/opensslconf.h
379x509_txt.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 294x509_txt.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
380x509_txt.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 295x509_txt.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
381x509_txt.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 296x509_txt.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
382x509_txt.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 297x509_txt.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
383x509_txt.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 298x509_txt.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
384x509_txt.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 299x509_txt.o: ../cryptlib.h x509_txt.c
385x509_txt.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 300x509_v3.o: ../../e_os.h ../../include/openssl/asn1.h
386x509_v3.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 301x509_v3.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
387x509_v3.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 302x509_v3.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
388x509_v3.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 303x509_v3.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
389x509_v3.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h 304x509_v3.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
390x509_v3.o: ../../include/openssl/des.h ../../include/openssl/dh.h
391x509_v3.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
392x509_v3.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
393x509_v3.o: ../../include/openssl/err.h ../../include/openssl/evp.h 305x509_v3.o: ../../include/openssl/err.h ../../include/openssl/evp.h
394x509_v3.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 306x509_v3.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
395x509_v3.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 307x509_v3.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
396x509_v3.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 308x509_v3.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
397x509_v3.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 309x509_v3.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
398x509_v3.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
399x509_v3.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
400x509_v3.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
401x509_v3.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
402x509_v3.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 310x509_v3.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
403x509_v3.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 311x509_v3.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
404x509_v3.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 312x509_v3.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
405x509_v3.o: ../../include/openssl/x509v3.h ../cryptlib.h 313x509_v3.o: ../../include/openssl/x509v3.h ../cryptlib.h x509_v3.c
406x509_vfy.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 314x509_vfy.o: ../../e_os.h ../../include/openssl/asn1.h
407x509_vfy.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 315x509_vfy.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
408x509_vfy.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 316x509_vfy.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
409x509_vfy.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h 317x509_vfy.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
410x509_vfy.o: ../../include/openssl/des.h ../../include/openssl/dh.h 318x509_vfy.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
411x509_vfy.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
412x509_vfy.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
413x509_vfy.o: ../../include/openssl/err.h ../../include/openssl/evp.h 319x509_vfy.o: ../../include/openssl/err.h ../../include/openssl/evp.h
414x509_vfy.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 320x509_vfy.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
415x509_vfy.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 321x509_vfy.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
416x509_vfy.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 322x509_vfy.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
417x509_vfy.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 323x509_vfy.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
418x509_vfy.o: ../../include/openssl/opensslconf.h 324x509_vfy.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
419x509_vfy.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 325x509_vfy.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
420x509_vfy.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 326x509_vfy.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
421x509_vfy.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 327x509_vfy.o: ../../include/openssl/x509v3.h ../cryptlib.h x509_vfy.c
422x509_vfy.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 328x509cset.o: ../../e_os.h ../../include/openssl/asn1.h
423x509_vfy.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 329x509cset.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
424x509_vfy.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 330x509cset.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
425x509_vfy.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h 331x509cset.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
426x509_vfy.o: ../cryptlib.h 332x509cset.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
427x509name.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 333x509cset.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
428x509name.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 334x509cset.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
429x509name.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 335x509cset.o: ../../include/openssl/opensslconf.h
430x509name.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 336x509cset.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
337x509cset.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
338x509cset.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
339x509cset.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
340x509cset.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
341x509cset.o: ../cryptlib.h x509cset.c
342x509name.o: ../../e_os.h ../../include/openssl/asn1.h
343x509name.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
344x509name.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
431x509name.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 345x509name.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
432x509name.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 346x509name.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
433x509name.o: ../../include/openssl/err.h ../../include/openssl/evp.h 347x509name.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
434x509name.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
435x509name.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
436x509name.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
437x509name.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 348x509name.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
438x509name.o: ../../include/openssl/opensslconf.h 349x509name.o: ../../include/openssl/opensslconf.h
439x509name.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 350x509name.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
440x509name.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 351x509name.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
441x509name.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 352x509name.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
442x509name.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 353x509name.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
443x509name.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 354x509name.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
444x509name.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 355x509name.o: ../cryptlib.h x509name.c
445x509name.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 356x509rset.o: ../../e_os.h ../../include/openssl/asn1.h
446x509rset.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 357x509rset.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
447x509rset.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 358x509rset.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
448x509rset.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
449x509rset.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
450x509rset.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 359x509rset.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
451x509rset.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 360x509rset.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
452x509rset.o: ../../include/openssl/err.h ../../include/openssl/evp.h 361x509rset.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
453x509rset.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
454x509rset.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
455x509rset.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
456x509rset.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 362x509rset.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
457x509rset.o: ../../include/openssl/opensslconf.h 363x509rset.o: ../../include/openssl/opensslconf.h
458x509rset.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 364x509rset.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
459x509rset.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 365x509rset.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
460x509rset.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 366x509rset.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
461x509rset.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 367x509rset.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
462x509rset.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 368x509rset.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
463x509rset.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 369x509rset.o: ../cryptlib.h x509rset.c
464x509rset.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 370x509spki.o: ../../e_os.h ../../include/openssl/asn1.h
465x509spki.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 371x509spki.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
466x509spki.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h 372x509spki.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
467x509spki.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 373x509spki.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
468x509spki.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
469x509spki.o: ../../include/openssl/des.h ../../include/openssl/dh.h
470x509spki.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
471x509spki.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 374x509spki.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
472x509spki.o: ../../include/openssl/evp.h ../../include/openssl/idea.h 375x509spki.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
473x509spki.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h 376x509spki.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
474x509spki.o: ../../include/openssl/md4.h ../../include/openssl/md5.h 377x509spki.o: ../../include/openssl/opensslconf.h
475x509spki.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h 378x509spki.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
476x509spki.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 379x509spki.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
477x509spki.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 380x509spki.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
478x509spki.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 381x509spki.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
479x509spki.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 382x509spki.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
480x509spki.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 383x509spki.o: ../cryptlib.h x509spki.c
481x509spki.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 384x509type.o: ../../e_os.h ../../include/openssl/asn1.h
482x509spki.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 385x509type.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
483x509spki.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 386x509type.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
484x509type.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
485x509type.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
486x509type.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
487x509type.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
488x509type.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 387x509type.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
489x509type.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 388x509type.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
490x509type.o: ../../include/openssl/err.h ../../include/openssl/evp.h 389x509type.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
491x509type.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
492x509type.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
493x509type.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
494x509type.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 390x509type.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
495x509type.o: ../../include/openssl/opensslconf.h 391x509type.o: ../../include/openssl/opensslconf.h
496x509type.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 392x509type.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
497x509type.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 393x509type.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
498x509type.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 394x509type.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
499x509type.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 395x509type.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
500x509type.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 396x509type.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
501x509type.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 397x509type.o: ../cryptlib.h x509type.c
502x509type.o: ../../include/openssl/x509_vfy.h ../cryptlib.h 398x_all.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
503x_all.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 399x_all.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
504x_all.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 400x_all.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
505x_all.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 401x_all.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
506x_all.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
507x_all.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
508x_all.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
509x_all.o: ../../include/openssl/err.h ../../include/openssl/evp.h 402x_all.o: ../../include/openssl/err.h ../../include/openssl/evp.h
510x_all.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 403x_all.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
511x_all.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 404x_all.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
512x_all.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 405x_all.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
513x_all.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 406x_all.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
514x_all.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
515x_all.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
516x_all.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
517x_all.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
518x_all.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 407x_all.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
519x_all.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 408x_all.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
520x_all.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 409x_all.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
521x_all.o: ../cryptlib.h 410x_all.o: ../cryptlib.h x_all.c
diff --git a/src/lib/libcrypto/x509/by_file.c b/src/lib/libcrypto/x509/by_file.c
index 78e9240a8d..92e00d2d73 100644
--- a/src/lib/libcrypto/x509/by_file.c
+++ b/src/lib/libcrypto/x509/by_file.c
@@ -66,7 +66,7 @@
66#include <openssl/x509.h> 66#include <openssl/x509.h>
67#include <openssl/pem.h> 67#include <openssl/pem.h>
68 68
69#ifndef NO_STDIO 69#ifndef OPENSSL_NO_STDIO
70 70
71static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, 71static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc,
72 long argl, char **ret); 72 long argl, char **ret);
@@ -294,5 +294,5 @@ int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type)
294} 294}
295 295
296 296
297#endif /* NO_STDIO */ 297#endif /* OPENSSL_NO_STDIO */
298 298
diff --git a/src/lib/libcrypto/x509/x509.h b/src/lib/libcrypto/x509/x509.h
index 813c8adffd..c75aa0c717 100644
--- a/src/lib/libcrypto/x509/x509.h
+++ b/src/lib/libcrypto/x509/x509.h
@@ -60,47 +60,46 @@
60#define HEADER_X509_H 60#define HEADER_X509_H
61 61
62#include <openssl/symhacks.h> 62#include <openssl/symhacks.h>
63#ifndef NO_BUFFER 63#ifndef OPENSSL_NO_BUFFER
64#include <openssl/buffer.h> 64#include <openssl/buffer.h>
65#endif 65#endif
66#ifndef NO_EVP 66#ifndef OPENSSL_NO_EVP
67#include <openssl/evp.h> 67#include <openssl/evp.h>
68#endif 68#endif
69#ifndef NO_BIO 69#ifndef OPENSSL_NO_BIO
70#include <openssl/bio.h> 70#include <openssl/bio.h>
71#endif 71#endif
72#include <openssl/stack.h> 72#include <openssl/stack.h>
73#include <openssl/asn1.h> 73#include <openssl/asn1.h>
74#include <openssl/safestack.h> 74#include <openssl/safestack.h>
75 75
76#ifndef NO_RSA 76#ifndef OPENSSL_NO_RSA
77#include <openssl/rsa.h> 77#include <openssl/rsa.h>
78#endif 78#endif
79 79
80#ifndef NO_DSA 80#ifndef OPENSSL_NO_DSA
81#include <openssl/dsa.h> 81#include <openssl/dsa.h>
82#endif 82#endif
83 83
84#ifndef NO_DH 84#ifndef OPENSSL_NO_DH
85#include <openssl/dh.h> 85#include <openssl/dh.h>
86#endif 86#endif
87 87#ifndef OPENSSL_NO_SHA
88#include <openssl/sha.h>
89#endif
88#include <openssl/evp.h> 90#include <openssl/evp.h>
89 91#include <openssl/e_os2.h>
92#include <openssl/ossl_typ.h>
90 93
91#ifdef __cplusplus 94#ifdef __cplusplus
92extern "C" { 95extern "C" {
93#endif 96#endif
94 97
95#ifdef WIN32 98#ifdef OPENSSL_SYS_WIN32
96/* Under Win32 this is defined in wincrypt.h */ 99/* Under Win32 this is defined in wincrypt.h */
97#undef X509_NAME 100#undef X509_NAME
98#endif 101#endif
99 102
100 /* If placed in pkcs12.h, we end up with a circular depency with pkcs7.h */
101#define DECLARE_PKCS12_STACK_OF(type) /* Nothing */
102#define IMPLEMENT_PKCS12_STACK_OF(type) /* Nothing */
103
104#define X509_FILETYPE_PEM 1 103#define X509_FILETYPE_PEM 1
105#define X509_FILETYPE_ASN1 2 104#define X509_FILETYPE_ASN1 2
106#define X509_FILETYPE_DEFAULT 3 105#define X509_FILETYPE_DEFAULT 3
@@ -123,11 +122,11 @@ typedef struct X509_objects_st
123 int (*i2a)(); 122 int (*i2a)();
124 } X509_OBJECTS; 123 } X509_OBJECTS;
125 124
126typedef struct X509_algor_st 125struct X509_algor_st
127 { 126 {
128 ASN1_OBJECT *algorithm; 127 ASN1_OBJECT *algorithm;
129 ASN1_TYPE *parameter; 128 ASN1_TYPE *parameter;
130 } X509_ALGOR; 129 } /* X509_ALGOR */;
131 130
132DECLARE_STACK_OF(X509_ALGOR) 131DECLARE_STACK_OF(X509_ALGOR)
133DECLARE_ASN1_SET_OF(X509_ALGOR) 132DECLARE_ASN1_SET_OF(X509_ALGOR)
@@ -163,17 +162,17 @@ DECLARE_STACK_OF(X509_NAME_ENTRY)
163DECLARE_ASN1_SET_OF(X509_NAME_ENTRY) 162DECLARE_ASN1_SET_OF(X509_NAME_ENTRY)
164 163
165/* we always keep X509_NAMEs in 2 forms. */ 164/* we always keep X509_NAMEs in 2 forms. */
166typedef struct X509_name_st 165struct X509_name_st
167 { 166 {
168 STACK_OF(X509_NAME_ENTRY) *entries; 167 STACK_OF(X509_NAME_ENTRY) *entries;
169 int modified; /* true if 'bytes' needs to be built */ 168 int modified; /* true if 'bytes' needs to be built */
170#ifndef NO_BUFFER 169#ifndef OPENSSL_NO_BUFFER
171 BUF_MEM *bytes; 170 BUF_MEM *bytes;
172#else 171#else
173 char *bytes; 172 char *bytes;
174#endif 173#endif
175 unsigned long hash; /* Keep the hash around for lookups */ 174 unsigned long hash; /* Keep the hash around for lookups */
176 } X509_NAME; 175 } /* X509_NAME */;
177 176
178DECLARE_STACK_OF(X509_NAME) 177DECLARE_STACK_OF(X509_NAME)
179 178
@@ -182,11 +181,8 @@ DECLARE_STACK_OF(X509_NAME)
182typedef struct X509_extension_st 181typedef struct X509_extension_st
183 { 182 {
184 ASN1_OBJECT *object; 183 ASN1_OBJECT *object;
185 short critical; 184 ASN1_BOOLEAN critical;
186 short netscape_hack;
187 ASN1_OCTET_STRING *value; 185 ASN1_OCTET_STRING *value;
188 struct v3_ext_method *method; /* V3 method to use */
189 void *ext_val; /* extension value */
190 } X509_EXTENSION; 186 } X509_EXTENSION;
191 187
192DECLARE_STACK_OF(X509_EXTENSION) 188DECLARE_STACK_OF(X509_EXTENSION)
@@ -196,27 +192,26 @@ DECLARE_ASN1_SET_OF(X509_EXTENSION)
196typedef struct x509_attributes_st 192typedef struct x509_attributes_st
197 { 193 {
198 ASN1_OBJECT *object; 194 ASN1_OBJECT *object;
199 int set; /* 1 for a set, 0 for a single item (which is wrong) */ 195 int single; /* 0 for a set, 1 for a single item (which is wrong) */
200 union { 196 union {
201 char *ptr; 197 char *ptr;
202/* 1 */ STACK_OF(ASN1_TYPE) *set; 198/* 0 */ STACK_OF(ASN1_TYPE) *set;
203/* 0 */ ASN1_TYPE *single; 199/* 1 */ ASN1_TYPE *single;
204 } value; 200 } value;
205 } X509_ATTRIBUTE; 201 } X509_ATTRIBUTE;
206 202
207DECLARE_STACK_OF(X509_ATTRIBUTE) 203DECLARE_STACK_OF(X509_ATTRIBUTE)
208DECLARE_ASN1_SET_OF(X509_ATTRIBUTE) 204DECLARE_ASN1_SET_OF(X509_ATTRIBUTE)
209 205
206
210typedef struct X509_req_info_st 207typedef struct X509_req_info_st
211 { 208 {
212 unsigned char *asn1; 209 ASN1_ENCODING enc;
213 int length;
214 ASN1_INTEGER *version; 210 ASN1_INTEGER *version;
215 X509_NAME *subject; 211 X509_NAME *subject;
216 X509_PUBKEY *pubkey; 212 X509_PUBKEY *pubkey;
217 /* d=2 hl=2 l= 0 cons: cont: 00 */ 213 /* d=2 hl=2 l= 0 cons: cont: 00 */
218 STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */ 214 STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */
219 int req_kludge;
220 } X509_REQ_INFO; 215 } X509_REQ_INFO;
221 216
222typedef struct X509_req_st 217typedef struct X509_req_st
@@ -256,7 +251,7 @@ typedef struct x509_cert_aux_st
256 STACK_OF(X509_ALGOR) *other; /* other unspecified info */ 251 STACK_OF(X509_ALGOR) *other; /* other unspecified info */
257 } X509_CERT_AUX; 252 } X509_CERT_AUX;
258 253
259typedef struct x509_st 254struct x509_st
260 { 255 {
261 X509_CINF *cert_info; 256 X509_CINF *cert_info;
262 X509_ALGOR *sig_alg; 257 X509_ALGOR *sig_alg;
@@ -273,11 +268,11 @@ typedef struct x509_st
273 unsigned long ex_nscert; 268 unsigned long ex_nscert;
274 ASN1_OCTET_STRING *skid; 269 ASN1_OCTET_STRING *skid;
275 struct AUTHORITY_KEYID_st *akid; 270 struct AUTHORITY_KEYID_st *akid;
276#ifndef NO_SHA 271#ifndef OPENSSL_NO_SHA
277 unsigned char sha1_hash[SHA_DIGEST_LENGTH]; 272 unsigned char sha1_hash[SHA_DIGEST_LENGTH];
278#endif 273#endif
279 X509_CERT_AUX *aux; 274 X509_CERT_AUX *aux;
280 } X509; 275 } /* X509 */;
281 276
282DECLARE_STACK_OF(X509) 277DECLARE_STACK_OF(X509)
283DECLARE_ASN1_SET_OF(X509) 278DECLARE_ASN1_SET_OF(X509)
@@ -304,10 +299,12 @@ DECLARE_STACK_OF(X509_TRUST)
304#define X509_TRUST_SSL_SERVER 3 299#define X509_TRUST_SSL_SERVER 3
305#define X509_TRUST_EMAIL 4 300#define X509_TRUST_EMAIL 4
306#define X509_TRUST_OBJECT_SIGN 5 301#define X509_TRUST_OBJECT_SIGN 5
302#define X509_TRUST_OCSP_SIGN 6
303#define X509_TRUST_OCSP_REQUEST 7
307 304
308/* Keep these up to date! */ 305/* Keep these up to date! */
309#define X509_TRUST_MIN 1 306#define X509_TRUST_MIN 1
310#define X509_TRUST_MAX 5 307#define X509_TRUST_MAX 7
311 308
312 309
313/* trust_flags values */ 310/* trust_flags values */
@@ -320,6 +317,21 @@ DECLARE_STACK_OF(X509_TRUST)
320#define X509_TRUST_REJECTED 2 317#define X509_TRUST_REJECTED 2
321#define X509_TRUST_UNTRUSTED 3 318#define X509_TRUST_UNTRUSTED 3
322 319
320/* Flags for X509_print_ex() */
321
322#define X509_FLAG_COMPAT 0
323#define X509_FLAG_NO_HEADER 1L
324#define X509_FLAG_NO_VERSION (1L << 1)
325#define X509_FLAG_NO_SERIAL (1L << 2)
326#define X509_FLAG_NO_SIGNAME (1L << 3)
327#define X509_FLAG_NO_ISSUER (1L << 4)
328#define X509_FLAG_NO_VALIDITY (1L << 5)
329#define X509_FLAG_NO_SUBJECT (1L << 6)
330#define X509_FLAG_NO_PUBKEY (1L << 7)
331#define X509_FLAG_NO_EXTENSIONS (1L << 8)
332#define X509_FLAG_NO_SIGDUMP (1L << 9)
333#define X509_FLAG_NO_AUX (1L << 10)
334
323/* Flags specific to X509_NAME_print_ex() */ 335/* Flags specific to X509_NAME_print_ex() */
324 336
325/* The field separator information */ 337/* The field separator information */
@@ -351,6 +363,8 @@ DECLARE_STACK_OF(X509_TRUST)
351 363
352#define XN_FLAG_DUMP_UNKNOWN_FIELDS (1 << 24) 364#define XN_FLAG_DUMP_UNKNOWN_FIELDS (1 << 24)
353 365
366#define XN_FLAG_FN_ALIGN (1 << 25) /* Align field names to 20 characters */
367
354/* Complete set of RFC2253 flags */ 368/* Complete set of RFC2253 flags */
355 369
356#define XN_FLAG_RFC2253 (ASN1_STRFLGS_RFC2253 | \ 370#define XN_FLAG_RFC2253 (ASN1_STRFLGS_RFC2253 | \
@@ -373,7 +387,8 @@ DECLARE_STACK_OF(X509_TRUST)
373 ASN1_STRFLGS_ESC_MSB | \ 387 ASN1_STRFLGS_ESC_MSB | \
374 XN_FLAG_SEP_MULTILINE | \ 388 XN_FLAG_SEP_MULTILINE | \
375 XN_FLAG_SPC_EQ | \ 389 XN_FLAG_SPC_EQ | \
376 XN_FLAG_FN_LN) 390 XN_FLAG_FN_LN | \
391 XN_FLAG_FN_ALIGN)
377 392
378typedef struct X509_revoked_st 393typedef struct X509_revoked_st
379 { 394 {
@@ -397,14 +412,14 @@ typedef struct X509_crl_info_st
397 STACK_OF(X509_EXTENSION) /* [0] */ *extensions; 412 STACK_OF(X509_EXTENSION) /* [0] */ *extensions;
398 } X509_CRL_INFO; 413 } X509_CRL_INFO;
399 414
400typedef struct X509_crl_st 415struct X509_crl_st
401 { 416 {
402 /* actual signature */ 417 /* actual signature */
403 X509_CRL_INFO *crl; 418 X509_CRL_INFO *crl;
404 X509_ALGOR *sig_alg; 419 X509_ALGOR *sig_alg;
405 ASN1_BIT_STRING *signature; 420 ASN1_BIT_STRING *signature;
406 int references; 421 int references;
407 } X509_CRL; 422 } /* X509_CRL */;
408 423
409DECLARE_STACK_OF(X509_CRL) 424DECLARE_STACK_OF(X509_CRL)
410DECLARE_ASN1_SET_OF(X509_CRL) 425DECLARE_ASN1_SET_OF(X509_CRL)
@@ -430,7 +445,7 @@ typedef struct private_key_st
430 int references; 445 int references;
431 } X509_PKEY; 446 } X509_PKEY;
432 447
433#ifndef NO_EVP 448#ifndef OPENSSL_NO_EVP
434typedef struct X509_info_st 449typedef struct X509_info_st
435 { 450 {
436 X509 *x509; 451 X509 *x509;
@@ -686,7 +701,7 @@ extern "C" {
686const char *X509_verify_cert_error_string(long n); 701const char *X509_verify_cert_error_string(long n);
687 702
688#ifndef SSLEAY_MACROS 703#ifndef SSLEAY_MACROS
689#ifndef NO_EVP 704#ifndef OPENSSL_NO_EVP
690int X509_verify(X509 *a, EVP_PKEY *r); 705int X509_verify(X509 *a, EVP_PKEY *r);
691 706
692int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r); 707int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r);
@@ -700,11 +715,15 @@ int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey);
700 715
701int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki); 716int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki);
702 717
718int X509_signature_print(BIO *bp,X509_ALGOR *alg, ASN1_STRING *sig);
719
703int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md); 720int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);
704int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md); 721int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md);
705int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md); 722int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md);
706int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md); 723int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md);
707 724
725int X509_pubkey_digest(const X509 *data,const EVP_MD *type,
726 unsigned char *md, unsigned int *len);
708int X509_digest(const X509 *data,const EVP_MD *type, 727int X509_digest(const X509 *data,const EVP_MD *type,
709 unsigned char *md, unsigned int *len); 728 unsigned char *md, unsigned int *len);
710int X509_CRL_digest(const X509_CRL *data,const EVP_MD *type, 729int X509_CRL_digest(const X509_CRL *data,const EVP_MD *type,
@@ -715,14 +734,14 @@ int X509_NAME_digest(const X509_NAME *data,const EVP_MD *type,
715 unsigned char *md, unsigned int *len); 734 unsigned char *md, unsigned int *len);
716#endif 735#endif
717 736
718#ifndef NO_FP_API 737#ifndef OPENSSL_NO_FP_API
719X509 *d2i_X509_fp(FILE *fp, X509 **x509); 738X509 *d2i_X509_fp(FILE *fp, X509 **x509);
720int i2d_X509_fp(FILE *fp,X509 *x509); 739int i2d_X509_fp(FILE *fp,X509 *x509);
721X509_CRL *d2i_X509_CRL_fp(FILE *fp,X509_CRL **crl); 740X509_CRL *d2i_X509_CRL_fp(FILE *fp,X509_CRL **crl);
722int i2d_X509_CRL_fp(FILE *fp,X509_CRL *crl); 741int i2d_X509_CRL_fp(FILE *fp,X509_CRL *crl);
723X509_REQ *d2i_X509_REQ_fp(FILE *fp,X509_REQ **req); 742X509_REQ *d2i_X509_REQ_fp(FILE *fp,X509_REQ **req);
724int i2d_X509_REQ_fp(FILE *fp,X509_REQ *req); 743int i2d_X509_REQ_fp(FILE *fp,X509_REQ *req);
725#ifndef NO_RSA 744#ifndef OPENSSL_NO_RSA
726RSA *d2i_RSAPrivateKey_fp(FILE *fp,RSA **rsa); 745RSA *d2i_RSAPrivateKey_fp(FILE *fp,RSA **rsa);
727int i2d_RSAPrivateKey_fp(FILE *fp,RSA *rsa); 746int i2d_RSAPrivateKey_fp(FILE *fp,RSA *rsa);
728RSA *d2i_RSAPublicKey_fp(FILE *fp,RSA **rsa); 747RSA *d2i_RSAPublicKey_fp(FILE *fp,RSA **rsa);
@@ -730,7 +749,7 @@ int i2d_RSAPublicKey_fp(FILE *fp,RSA *rsa);
730RSA *d2i_RSA_PUBKEY_fp(FILE *fp,RSA **rsa); 749RSA *d2i_RSA_PUBKEY_fp(FILE *fp,RSA **rsa);
731int i2d_RSA_PUBKEY_fp(FILE *fp,RSA *rsa); 750int i2d_RSA_PUBKEY_fp(FILE *fp,RSA *rsa);
732#endif 751#endif
733#ifndef NO_DSA 752#ifndef OPENSSL_NO_DSA
734DSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa); 753DSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa);
735int i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa); 754int i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa);
736DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa); 755DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa);
@@ -748,14 +767,14 @@ int i2d_PUBKEY_fp(FILE *fp, EVP_PKEY *pkey);
748EVP_PKEY *d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **a); 767EVP_PKEY *d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **a);
749#endif 768#endif
750 769
751#ifndef NO_BIO 770#ifndef OPENSSL_NO_BIO
752X509 *d2i_X509_bio(BIO *bp,X509 **x509); 771X509 *d2i_X509_bio(BIO *bp,X509 **x509);
753int i2d_X509_bio(BIO *bp,X509 *x509); 772int i2d_X509_bio(BIO *bp,X509 *x509);
754X509_CRL *d2i_X509_CRL_bio(BIO *bp,X509_CRL **crl); 773X509_CRL *d2i_X509_CRL_bio(BIO *bp,X509_CRL **crl);
755int i2d_X509_CRL_bio(BIO *bp,X509_CRL *crl); 774int i2d_X509_CRL_bio(BIO *bp,X509_CRL *crl);
756X509_REQ *d2i_X509_REQ_bio(BIO *bp,X509_REQ **req); 775X509_REQ *d2i_X509_REQ_bio(BIO *bp,X509_REQ **req);
757int i2d_X509_REQ_bio(BIO *bp,X509_REQ *req); 776int i2d_X509_REQ_bio(BIO *bp,X509_REQ *req);
758#ifndef NO_RSA 777#ifndef OPENSSL_NO_RSA
759RSA *d2i_RSAPrivateKey_bio(BIO *bp,RSA **rsa); 778RSA *d2i_RSAPrivateKey_bio(BIO *bp,RSA **rsa);
760int i2d_RSAPrivateKey_bio(BIO *bp,RSA *rsa); 779int i2d_RSAPrivateKey_bio(BIO *bp,RSA *rsa);
761RSA *d2i_RSAPublicKey_bio(BIO *bp,RSA **rsa); 780RSA *d2i_RSAPublicKey_bio(BIO *bp,RSA **rsa);
@@ -763,7 +782,7 @@ int i2d_RSAPublicKey_bio(BIO *bp,RSA *rsa);
763RSA *d2i_RSA_PUBKEY_bio(BIO *bp,RSA **rsa); 782RSA *d2i_RSA_PUBKEY_bio(BIO *bp,RSA **rsa);
764int i2d_RSA_PUBKEY_bio(BIO *bp,RSA *rsa); 783int i2d_RSA_PUBKEY_bio(BIO *bp,RSA *rsa);
765#endif 784#endif
766#ifndef NO_DSA 785#ifndef OPENSSL_NO_DSA
767DSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa); 786DSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa);
768int i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa); 787int i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa);
769DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa); 788DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa);
@@ -789,7 +808,7 @@ X509_REQ *X509_REQ_dup(X509_REQ *req);
789X509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn); 808X509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn);
790X509_NAME *X509_NAME_dup(X509_NAME *xn); 809X509_NAME *X509_NAME_dup(X509_NAME *xn);
791X509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne); 810X509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne);
792#ifndef NO_RSA 811#ifndef OPENSSL_NO_RSA
793RSA *RSAPublicKey_dup(RSA *rsa); 812RSA *RSAPublicKey_dup(RSA *rsa);
794RSA *RSAPrivateKey_dup(RSA *rsa); 813RSA *RSAPrivateKey_dup(RSA *rsa);
795#endif 814#endif
@@ -810,25 +829,12 @@ const char * X509_get_default_private_dir(void );
810 829
811X509_REQ * X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md); 830X509_REQ * X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);
812X509 * X509_REQ_to_X509(X509_REQ *r, int days,EVP_PKEY *pkey); 831X509 * X509_REQ_to_X509(X509_REQ *r, int days,EVP_PKEY *pkey);
813void ERR_load_X509_strings(void );
814 832
815X509_ALGOR * X509_ALGOR_new(void ); 833DECLARE_ASN1_FUNCTIONS(X509_ALGOR)
816void X509_ALGOR_free(X509_ALGOR *a); 834DECLARE_ASN1_FUNCTIONS(X509_VAL)
817int i2d_X509_ALGOR(X509_ALGOR *a,unsigned char **pp);
818X509_ALGOR * d2i_X509_ALGOR(X509_ALGOR **a,unsigned char **pp,
819 long length);
820 835
821X509_VAL * X509_VAL_new(void ); 836DECLARE_ASN1_FUNCTIONS(X509_PUBKEY)
822void X509_VAL_free(X509_VAL *a);
823int i2d_X509_VAL(X509_VAL *a,unsigned char **pp);
824X509_VAL * d2i_X509_VAL(X509_VAL **a,unsigned char **pp,
825 long length);
826 837
827X509_PUBKEY * X509_PUBKEY_new(void );
828void X509_PUBKEY_free(X509_PUBKEY *a);
829int i2d_X509_PUBKEY(X509_PUBKEY *a,unsigned char **pp);
830X509_PUBKEY * d2i_X509_PUBKEY(X509_PUBKEY **a,unsigned char **pp,
831 long length);
832int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey); 838int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey);
833EVP_PKEY * X509_PUBKEY_get(X509_PUBKEY *key); 839EVP_PKEY * X509_PUBKEY_get(X509_PUBKEY *key);
834int X509_get_pubkey_parameters(EVP_PKEY *pkey, 840int X509_get_pubkey_parameters(EVP_PKEY *pkey,
@@ -836,69 +842,37 @@ int X509_get_pubkey_parameters(EVP_PKEY *pkey,
836int i2d_PUBKEY(EVP_PKEY *a,unsigned char **pp); 842int i2d_PUBKEY(EVP_PKEY *a,unsigned char **pp);
837EVP_PKEY * d2i_PUBKEY(EVP_PKEY **a,unsigned char **pp, 843EVP_PKEY * d2i_PUBKEY(EVP_PKEY **a,unsigned char **pp,
838 long length); 844 long length);
839#ifndef NO_RSA 845#ifndef OPENSSL_NO_RSA
840int i2d_RSA_PUBKEY(RSA *a,unsigned char **pp); 846int i2d_RSA_PUBKEY(RSA *a,unsigned char **pp);
841RSA * d2i_RSA_PUBKEY(RSA **a,unsigned char **pp, 847RSA * d2i_RSA_PUBKEY(RSA **a,unsigned char **pp,
842 long length); 848 long length);
843#endif 849#endif
844#ifndef NO_DSA 850#ifndef OPENSSL_NO_DSA
845int i2d_DSA_PUBKEY(DSA *a,unsigned char **pp); 851int i2d_DSA_PUBKEY(DSA *a,unsigned char **pp);
846DSA * d2i_DSA_PUBKEY(DSA **a,unsigned char **pp, 852DSA * d2i_DSA_PUBKEY(DSA **a,unsigned char **pp,
847 long length); 853 long length);
848#endif 854#endif
849 855
850X509_SIG * X509_SIG_new(void ); 856DECLARE_ASN1_FUNCTIONS(X509_SIG)
851void X509_SIG_free(X509_SIG *a); 857DECLARE_ASN1_FUNCTIONS(X509_REQ_INFO)
852int i2d_X509_SIG(X509_SIG *a,unsigned char **pp); 858DECLARE_ASN1_FUNCTIONS(X509_REQ)
853X509_SIG * d2i_X509_SIG(X509_SIG **a,unsigned char **pp,long length);
854
855X509_REQ_INFO *X509_REQ_INFO_new(void);
856void X509_REQ_INFO_free(X509_REQ_INFO *a);
857int i2d_X509_REQ_INFO(X509_REQ_INFO *a,unsigned char **pp);
858X509_REQ_INFO *d2i_X509_REQ_INFO(X509_REQ_INFO **a,unsigned char **pp,
859 long length);
860 859
861X509_REQ * X509_REQ_new(void); 860DECLARE_ASN1_FUNCTIONS(X509_ATTRIBUTE)
862void X509_REQ_free(X509_REQ *a);
863int i2d_X509_REQ(X509_REQ *a,unsigned char **pp);
864X509_REQ * d2i_X509_REQ(X509_REQ **a,unsigned char **pp,long length);
865
866X509_ATTRIBUTE *X509_ATTRIBUTE_new(void );
867void X509_ATTRIBUTE_free(X509_ATTRIBUTE *a);
868int i2d_X509_ATTRIBUTE(X509_ATTRIBUTE *a,unsigned char **pp);
869X509_ATTRIBUTE *d2i_X509_ATTRIBUTE(X509_ATTRIBUTE **a,unsigned char **pp,
870 long length);
871X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value); 861X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value);
872 862
863DECLARE_ASN1_FUNCTIONS(X509_EXTENSION)
873 864
874X509_EXTENSION *X509_EXTENSION_new(void ); 865DECLARE_ASN1_FUNCTIONS(X509_NAME_ENTRY)
875void X509_EXTENSION_free(X509_EXTENSION *a);
876int i2d_X509_EXTENSION(X509_EXTENSION *a,unsigned char **pp);
877X509_EXTENSION *d2i_X509_EXTENSION(X509_EXTENSION **a,unsigned char **pp,
878 long length);
879 866
880X509_NAME_ENTRY *X509_NAME_ENTRY_new(void); 867DECLARE_ASN1_FUNCTIONS(X509_NAME)
881void X509_NAME_ENTRY_free(X509_NAME_ENTRY *a);
882int i2d_X509_NAME_ENTRY(X509_NAME_ENTRY *a,unsigned char **pp);
883X509_NAME_ENTRY *d2i_X509_NAME_ENTRY(X509_NAME_ENTRY **a,unsigned char **pp,
884 long length);
885 868
886X509_NAME * X509_NAME_new(void);
887void X509_NAME_free(X509_NAME *a);
888int i2d_X509_NAME(X509_NAME *a,unsigned char **pp);
889X509_NAME * d2i_X509_NAME(X509_NAME **a,unsigned char **pp,long length);
890int X509_NAME_set(X509_NAME **xn, X509_NAME *name); 869int X509_NAME_set(X509_NAME **xn, X509_NAME *name);
891 870
871DECLARE_ASN1_FUNCTIONS(X509_CINF)
892 872
893X509_CINF * X509_CINF_new(void); 873DECLARE_ASN1_FUNCTIONS(X509)
894void X509_CINF_free(X509_CINF *a); 874DECLARE_ASN1_FUNCTIONS(X509_CERT_AUX)
895int i2d_X509_CINF(X509_CINF *a,unsigned char **pp);
896X509_CINF * d2i_X509_CINF(X509_CINF **a,unsigned char **pp,long length);
897 875
898X509 * X509_new(void);
899void X509_free(X509 *a);
900int i2d_X509(X509 *a,unsigned char **pp);
901X509 * d2i_X509(X509 **a,unsigned char **pp,long length);
902int X509_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, 876int X509_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
903 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); 877 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
904int X509_set_ex_data(X509 *r, int idx, void *arg); 878int X509_set_ex_data(X509 *r, int idx, void *arg);
@@ -906,60 +880,32 @@ void *X509_get_ex_data(X509 *r, int idx);
906int i2d_X509_AUX(X509 *a,unsigned char **pp); 880int i2d_X509_AUX(X509 *a,unsigned char **pp);
907X509 * d2i_X509_AUX(X509 **a,unsigned char **pp,long length); 881X509 * d2i_X509_AUX(X509 **a,unsigned char **pp,long length);
908 882
909X509_CERT_AUX * X509_CERT_AUX_new(void);
910void X509_CERT_AUX_free(X509_CERT_AUX *a);
911int i2d_X509_CERT_AUX(X509_CERT_AUX *a,unsigned char **pp);
912X509_CERT_AUX * d2i_X509_CERT_AUX(X509_CERT_AUX **a,unsigned char **pp,
913 long length);
914int X509_alias_set1(X509 *x, unsigned char *name, int len); 883int X509_alias_set1(X509 *x, unsigned char *name, int len);
915int X509_keyid_set1(X509 *x, unsigned char *id, int len); 884int X509_keyid_set1(X509 *x, unsigned char *id, int len);
916unsigned char * X509_alias_get0(X509 *x, int *len); 885unsigned char * X509_alias_get0(X509 *x, int *len);
917int (*X509_TRUST_set_default(int (*trust)(int , X509 *, int)))(int, X509 *, int); 886int (*X509_TRUST_set_default(int (*trust)(int , X509 *, int)))(int, X509 *, int);
887int X509_TRUST_set(int *t, int trust);
918int X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj); 888int X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj);
919int X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj); 889int X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj);
920void X509_trust_clear(X509 *x); 890void X509_trust_clear(X509 *x);
921void X509_reject_clear(X509 *x); 891void X509_reject_clear(X509 *x);
922 892
923X509_REVOKED * X509_REVOKED_new(void); 893DECLARE_ASN1_FUNCTIONS(X509_REVOKED)
924void X509_REVOKED_free(X509_REVOKED *a); 894DECLARE_ASN1_FUNCTIONS(X509_CRL_INFO)
925int i2d_X509_REVOKED(X509_REVOKED *a,unsigned char **pp); 895DECLARE_ASN1_FUNCTIONS(X509_CRL)
926X509_REVOKED * d2i_X509_REVOKED(X509_REVOKED **a,unsigned char **pp,long length);
927 896
928X509_CRL_INFO *X509_CRL_INFO_new(void); 897int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev);
929void X509_CRL_INFO_free(X509_CRL_INFO *a);
930int i2d_X509_CRL_INFO(X509_CRL_INFO *a,unsigned char **pp);
931X509_CRL_INFO *d2i_X509_CRL_INFO(X509_CRL_INFO **a,unsigned char **pp,
932 long length);
933
934X509_CRL * X509_CRL_new(void);
935void X509_CRL_free(X509_CRL *a);
936int i2d_X509_CRL(X509_CRL *a,unsigned char **pp);
937X509_CRL * d2i_X509_CRL(X509_CRL **a,unsigned char **pp,long length);
938 898
939X509_PKEY * X509_PKEY_new(void ); 899X509_PKEY * X509_PKEY_new(void );
940void X509_PKEY_free(X509_PKEY *a); 900void X509_PKEY_free(X509_PKEY *a);
941int i2d_X509_PKEY(X509_PKEY *a,unsigned char **pp); 901int i2d_X509_PKEY(X509_PKEY *a,unsigned char **pp);
942X509_PKEY * d2i_X509_PKEY(X509_PKEY **a,unsigned char **pp,long length); 902X509_PKEY * d2i_X509_PKEY(X509_PKEY **a,unsigned char **pp,long length);
943 903
944NETSCAPE_SPKI * NETSCAPE_SPKI_new(void ); 904DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKI)
945void NETSCAPE_SPKI_free(NETSCAPE_SPKI *a); 905DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKAC)
946int i2d_NETSCAPE_SPKI(NETSCAPE_SPKI *a,unsigned char **pp); 906DECLARE_ASN1_FUNCTIONS(NETSCAPE_CERT_SEQUENCE)
947NETSCAPE_SPKI * d2i_NETSCAPE_SPKI(NETSCAPE_SPKI **a,unsigned char **pp,
948 long length);
949 907
950NETSCAPE_SPKAC *NETSCAPE_SPKAC_new(void ); 908#ifndef OPENSSL_NO_EVP
951void NETSCAPE_SPKAC_free(NETSCAPE_SPKAC *a);
952int i2d_NETSCAPE_SPKAC(NETSCAPE_SPKAC *a,unsigned char **pp);
953NETSCAPE_SPKAC *d2i_NETSCAPE_SPKAC(NETSCAPE_SPKAC **a,unsigned char **pp,
954 long length);
955
956
957int i2d_NETSCAPE_CERT_SEQUENCE(NETSCAPE_CERT_SEQUENCE *a, unsigned char **pp);
958NETSCAPE_CERT_SEQUENCE *NETSCAPE_CERT_SEQUENCE_new(void);
959NETSCAPE_CERT_SEQUENCE *d2i_NETSCAPE_CERT_SEQUENCE(NETSCAPE_CERT_SEQUENCE **a, unsigned char **pp, long length);
960void NETSCAPE_CERT_SEQUENCE_free(NETSCAPE_CERT_SEQUENCE *a);
961
962#ifndef NO_EVP
963X509_INFO * X509_INFO_new(void); 909X509_INFO * X509_INFO_new(void);
964void X509_INFO_free(X509_INFO *a); 910void X509_INFO_free(X509_INFO *a);
965char * X509_NAME_oneline(X509_NAME *a,char *buf,int size); 911char * X509_NAME_oneline(X509_NAME *a,char *buf,int size);
@@ -973,6 +919,16 @@ int ASN1_digest(int (*i2d)(),const EVP_MD *type,char *data,
973int ASN1_sign(int (*i2d)(), X509_ALGOR *algor1, X509_ALGOR *algor2, 919int ASN1_sign(int (*i2d)(), X509_ALGOR *algor1, X509_ALGOR *algor2,
974 ASN1_BIT_STRING *signature, 920 ASN1_BIT_STRING *signature,
975 char *data,EVP_PKEY *pkey, const EVP_MD *type); 921 char *data,EVP_PKEY *pkey, const EVP_MD *type);
922
923int ASN1_item_digest(const ASN1_ITEM *it,const EVP_MD *type,void *data,
924 unsigned char *md,unsigned int *len);
925
926int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *algor1,
927 ASN1_BIT_STRING *signature,void *data,EVP_PKEY *pkey);
928
929int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2,
930 ASN1_BIT_STRING *signature,
931 void *data, EVP_PKEY *pkey, const EVP_MD *type);
976#endif 932#endif
977 933
978int X509_set_version(X509 *x,long version); 934int X509_set_version(X509 *x,long version);
@@ -986,6 +942,7 @@ int X509_set_notBefore(X509 *x, ASN1_TIME *tm);
986int X509_set_notAfter(X509 *x, ASN1_TIME *tm); 942int X509_set_notAfter(X509 *x, ASN1_TIME *tm);
987int X509_set_pubkey(X509 *x, EVP_PKEY *pkey); 943int X509_set_pubkey(X509 *x, EVP_PKEY *pkey);
988EVP_PKEY * X509_get_pubkey(X509 *x); 944EVP_PKEY * X509_get_pubkey(X509 *x);
945ASN1_BIT_STRING * X509_get0_pubkey_bitstr(const X509 *x);
989int X509_certificate_type(X509 *x,EVP_PKEY *pubkey /* optional */); 946int X509_certificate_type(X509 *x,EVP_PKEY *pubkey /* optional */);
990 947
991int X509_REQ_set_version(X509_REQ *x,long version); 948int X509_REQ_set_version(X509_REQ *x,long version);
@@ -1008,14 +965,23 @@ X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc);
1008X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc); 965X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc);
1009int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr); 966int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr);
1010int X509_REQ_add1_attr_by_OBJ(X509_REQ *req, 967int X509_REQ_add1_attr_by_OBJ(X509_REQ *req,
1011 ASN1_OBJECT *obj, int type, 968 const ASN1_OBJECT *obj, int type,
1012 unsigned char *bytes, int len); 969 const unsigned char *bytes, int len);
1013int X509_REQ_add1_attr_by_NID(X509_REQ *req, 970int X509_REQ_add1_attr_by_NID(X509_REQ *req,
1014 int nid, int type, 971 int nid, int type,
1015 unsigned char *bytes, int len); 972 const unsigned char *bytes, int len);
1016int X509_REQ_add1_attr_by_txt(X509_REQ *req, 973int X509_REQ_add1_attr_by_txt(X509_REQ *req,
1017 char *attrname, int type, 974 const char *attrname, int type,
1018 unsigned char *bytes, int len); 975 const unsigned char *bytes, int len);
976
977int X509_CRL_set_version(X509_CRL *x, long version);
978int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name);
979int X509_CRL_set_lastUpdate(X509_CRL *x, ASN1_TIME *tm);
980int X509_CRL_set_nextUpdate(X509_CRL *x, ASN1_TIME *tm);
981int X509_CRL_sort(X509_CRL *crl);
982
983int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial);
984int X509_REVOKED_set_revocationDate(X509_REVOKED *r, ASN1_TIME *tm);
1019 985
1020int X509_check_private_key(X509 *x509,EVP_PKEY *pkey); 986int X509_check_private_key(X509 *x509,EVP_PKEY *pkey);
1021 987
@@ -1033,17 +999,20 @@ int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b);
1033unsigned long X509_NAME_hash(X509_NAME *x); 999unsigned long X509_NAME_hash(X509_NAME *x);
1034 1000
1035int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b); 1001int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b);
1036#ifndef NO_FP_API 1002#ifndef OPENSSL_NO_FP_API
1003int X509_print_ex_fp(FILE *bp,X509 *x, unsigned long nmflag, unsigned long cflag);
1037int X509_print_fp(FILE *bp,X509 *x); 1004int X509_print_fp(FILE *bp,X509 *x);
1038int X509_CRL_print_fp(FILE *bp,X509_CRL *x); 1005int X509_CRL_print_fp(FILE *bp,X509_CRL *x);
1039int X509_REQ_print_fp(FILE *bp,X509_REQ *req); 1006int X509_REQ_print_fp(FILE *bp,X509_REQ *req);
1040int X509_NAME_print_ex_fp(FILE *fp, X509_NAME *nm, int indent, unsigned long flags); 1007int X509_NAME_print_ex_fp(FILE *fp, X509_NAME *nm, int indent, unsigned long flags);
1041#endif 1008#endif
1042 1009
1043#ifndef NO_BIO 1010#ifndef OPENSSL_NO_BIO
1044int X509_NAME_print(BIO *bp, X509_NAME *name, int obase); 1011int X509_NAME_print(BIO *bp, X509_NAME *name, int obase);
1045int X509_NAME_print_ex(BIO *out, X509_NAME *nm, int indent, unsigned long flags); 1012int X509_NAME_print_ex(BIO *out, X509_NAME *nm, int indent, unsigned long flags);
1013int X509_print_ex(BIO *bp,X509 *x, unsigned long nmflag, unsigned long cflag);
1046int X509_print(BIO *bp,X509 *x); 1014int X509_print(BIO *bp,X509 *x);
1015int X509_ocspid_print(BIO *bp,X509 *x);
1047int X509_CERT_AUX_print(BIO *bp,X509_CERT_AUX *x, int indent); 1016int X509_CERT_AUX_print(BIO *bp,X509_CERT_AUX *x, int indent);
1048int X509_CRL_print(BIO *bp,X509_CRL *x); 1017int X509_CRL_print(BIO *bp,X509_CRL *x);
1049int X509_REQ_print(BIO *bp,X509_REQ *req); 1018int X509_REQ_print(BIO *bp,X509_REQ *req);
@@ -1104,6 +1073,8 @@ X509_EXTENSION *X509_get_ext(X509 *x, int loc);
1104X509_EXTENSION *X509_delete_ext(X509 *x, int loc); 1073X509_EXTENSION *X509_delete_ext(X509 *x, int loc);
1105int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc); 1074int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc);
1106void * X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx); 1075void * X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx);
1076int X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit,
1077 unsigned long flags);
1107 1078
1108int X509_CRL_get_ext_count(X509_CRL *x); 1079int X509_CRL_get_ext_count(X509_CRL *x);
1109int X509_CRL_get_ext_by_NID(X509_CRL *x, int nid, int lastpos); 1080int X509_CRL_get_ext_by_NID(X509_CRL *x, int nid, int lastpos);
@@ -1113,6 +1084,8 @@ X509_EXTENSION *X509_CRL_get_ext(X509_CRL *x, int loc);
1113X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc); 1084X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc);
1114int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc); 1085int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc);
1115void * X509_CRL_get_ext_d2i(X509_CRL *x, int nid, int *crit, int *idx); 1086void * X509_CRL_get_ext_d2i(X509_CRL *x, int nid, int *crit, int *idx);
1087int X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit,
1088 unsigned long flags);
1116 1089
1117int X509_REVOKED_get_ext_count(X509_REVOKED *x); 1090int X509_REVOKED_get_ext_count(X509_REVOKED *x);
1118int X509_REVOKED_get_ext_by_NID(X509_REVOKED *x, int nid, int lastpos); 1091int X509_REVOKED_get_ext_by_NID(X509_REVOKED *x, int nid, int lastpos);
@@ -1122,6 +1095,8 @@ X509_EXTENSION *X509_REVOKED_get_ext(X509_REVOKED *x, int loc);
1122X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc); 1095X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc);
1123int X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc); 1096int X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc);
1124void * X509_REVOKED_get_ext_d2i(X509_REVOKED *x, int nid, int *crit, int *idx); 1097void * X509_REVOKED_get_ext_d2i(X509_REVOKED *x, int nid, int *crit, int *idx);
1098int X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit,
1099 unsigned long flags);
1125 1100
1126X509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex, 1101X509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex,
1127 int nid, int crit, ASN1_OCTET_STRING *data); 1102 int nid, int crit, ASN1_OCTET_STRING *data);
@@ -1145,22 +1120,22 @@ X509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc);
1145STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x, 1120STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x,
1146 X509_ATTRIBUTE *attr); 1121 X509_ATTRIBUTE *attr);
1147STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE) **x, 1122STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE) **x,
1148 ASN1_OBJECT *obj, int type, 1123 const ASN1_OBJECT *obj, int type,
1149 unsigned char *bytes, int len); 1124 const unsigned char *bytes, int len);
1150STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE) **x, 1125STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE) **x,
1151 int nid, int type, 1126 int nid, int type,
1152 unsigned char *bytes, int len); 1127 const unsigned char *bytes, int len);
1153STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) **x, 1128STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) **x,
1154 char *attrname, int type, 1129 const char *attrname, int type,
1155 unsigned char *bytes, int len); 1130 const unsigned char *bytes, int len);
1156X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid, 1131X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid,
1157 int atrtype, void *data, int len); 1132 int atrtype, const void *data, int len);
1158X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr, 1133X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr,
1159 ASN1_OBJECT *obj, int atrtype, void *data, int len); 1134 const ASN1_OBJECT *obj, int atrtype, const void *data, int len);
1160X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr, 1135X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr,
1161 char *atrname, int type, unsigned char *bytes, int len); 1136 const char *atrname, int type, const unsigned char *bytes, int len);
1162int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, ASN1_OBJECT *obj); 1137int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj);
1163int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, void *data, int len); 1138int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *data, int len);
1164void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx, 1139void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx,
1165 int atrtype, void *data); 1140 int atrtype, void *data);
1166int X509_ATTRIBUTE_count(X509_ATTRIBUTE *attr); 1141int X509_ATTRIBUTE_count(X509_ATTRIBUTE *attr);
@@ -1174,31 +1149,17 @@ X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk,X509_NAME *name,
1174 ASN1_INTEGER *serial); 1149 ASN1_INTEGER *serial);
1175X509 *X509_find_by_subject(STACK_OF(X509) *sk,X509_NAME *name); 1150X509 *X509_find_by_subject(STACK_OF(X509) *sk,X509_NAME *name);
1176 1151
1177int i2d_PBEPARAM(PBEPARAM *a, unsigned char **pp); 1152DECLARE_ASN1_FUNCTIONS(PBEPARAM)
1178PBEPARAM *PBEPARAM_new(void); 1153DECLARE_ASN1_FUNCTIONS(PBE2PARAM)
1179PBEPARAM *d2i_PBEPARAM(PBEPARAM **a, unsigned char **pp, long length); 1154DECLARE_ASN1_FUNCTIONS(PBKDF2PARAM)
1180void PBEPARAM_free(PBEPARAM *a); 1155
1181X509_ALGOR *PKCS5_pbe_set(int alg, int iter, unsigned char *salt, int saltlen); 1156X509_ALGOR *PKCS5_pbe_set(int alg, int iter, unsigned char *salt, int saltlen);
1182X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter, 1157X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
1183 unsigned char *salt, int saltlen); 1158 unsigned char *salt, int saltlen);
1184 1159
1185int i2d_PBKDF2PARAM(PBKDF2PARAM *a, unsigned char **pp);
1186PBKDF2PARAM *PBKDF2PARAM_new(void);
1187PBKDF2PARAM *d2i_PBKDF2PARAM(PBKDF2PARAM **a, unsigned char **pp, long length);
1188void PBKDF2PARAM_free(PBKDF2PARAM *a);
1189
1190int i2d_PBE2PARAM(PBE2PARAM *a, unsigned char **pp);
1191PBE2PARAM *PBE2PARAM_new(void);
1192PBE2PARAM *d2i_PBE2PARAM(PBE2PARAM **a, unsigned char **pp, long length);
1193void PBE2PARAM_free(PBE2PARAM *a);
1194
1195/* PKCS#8 utilities */ 1160/* PKCS#8 utilities */
1196 1161
1197int i2d_PKCS8_PRIV_KEY_INFO(PKCS8_PRIV_KEY_INFO *a, unsigned char **pp); 1162DECLARE_ASN1_FUNCTIONS(PKCS8_PRIV_KEY_INFO)
1198PKCS8_PRIV_KEY_INFO *PKCS8_PRIV_KEY_INFO_new(void);
1199PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO(PKCS8_PRIV_KEY_INFO **a,
1200 unsigned char **pp, long length);
1201void PKCS8_PRIV_KEY_INFO_free(PKCS8_PRIV_KEY_INFO *a);
1202 1163
1203EVP_PKEY *EVP_PKCS82PKEY(PKCS8_PRIV_KEY_INFO *p8); 1164EVP_PKEY *EVP_PKCS82PKEY(PKCS8_PRIV_KEY_INFO *p8);
1204PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey); 1165PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey);
@@ -1220,6 +1181,7 @@ int X509_TRUST_get_trust(X509_TRUST *xp);
1220/* The following lines are auto generated by the script mkerr.pl. Any changes 1181/* The following lines are auto generated by the script mkerr.pl. Any changes
1221 * made after this point may be overwritten when the script is next run. 1182 * made after this point may be overwritten when the script is next run.
1222 */ 1183 */
1184void ERR_load_X509_strings(void);
1223 1185
1224/* Error codes for the X509 functions. */ 1186/* Error codes for the X509 functions. */
1225 1187
@@ -1258,9 +1220,12 @@ int X509_TRUST_get_trust(X509_TRUST *xp);
1258#define X509_F_X509_REQ_TO_X509 123 1220#define X509_F_X509_REQ_TO_X509 123
1259#define X509_F_X509_STORE_ADD_CERT 124 1221#define X509_F_X509_STORE_ADD_CERT 124
1260#define X509_F_X509_STORE_ADD_CRL 125 1222#define X509_F_X509_STORE_ADD_CRL 125
1223#define X509_F_X509_STORE_CTX_INIT 143
1224#define X509_F_X509_STORE_CTX_NEW 142
1261#define X509_F_X509_STORE_CTX_PURPOSE_INHERIT 134 1225#define X509_F_X509_STORE_CTX_PURPOSE_INHERIT 134
1262#define X509_F_X509_TO_X509_REQ 126 1226#define X509_F_X509_TO_X509_REQ 126
1263#define X509_F_X509_TRUST_ADD 133 1227#define X509_F_X509_TRUST_ADD 133
1228#define X509_F_X509_TRUST_SET 141
1264#define X509_F_X509_VERIFY_CERT 127 1229#define X509_F_X509_VERIFY_CERT 127
1265 1230
1266/* Reason codes. */ 1231/* Reason codes. */
@@ -1271,6 +1236,7 @@ int X509_TRUST_get_trust(X509_TRUST *xp);
1271#define X509_R_ERR_ASN1_LIB 102 1236#define X509_R_ERR_ASN1_LIB 102
1272#define X509_R_INVALID_DIRECTORY 113 1237#define X509_R_INVALID_DIRECTORY 113
1273#define X509_R_INVALID_FIELD_NAME 119 1238#define X509_R_INVALID_FIELD_NAME 119
1239#define X509_R_INVALID_TRUST 123
1274#define X509_R_KEY_TYPE_MISMATCH 115 1240#define X509_R_KEY_TYPE_MISMATCH 115
1275#define X509_R_KEY_VALUES_MISMATCH 116 1241#define X509_R_KEY_VALUES_MISMATCH 116
1276#define X509_R_LOADING_CERT_DIR 103 1242#define X509_R_LOADING_CERT_DIR 103
@@ -1291,4 +1257,3 @@ int X509_TRUST_get_trust(X509_TRUST *xp);
1291} 1257}
1292#endif 1258#endif
1293#endif 1259#endif
1294
diff --git a/src/lib/libcrypto/x509/x509_att.c b/src/lib/libcrypto/x509/x509_att.c
index caafde658f..0bae3d32a1 100644
--- a/src/lib/libcrypto/x509/x509_att.c
+++ b/src/lib/libcrypto/x509/x509_att.c
@@ -149,8 +149,8 @@ err2:
149} 149}
150 150
151STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE) **x, 151STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE) **x,
152 ASN1_OBJECT *obj, int type, 152 const ASN1_OBJECT *obj, int type,
153 unsigned char *bytes, int len) 153 const unsigned char *bytes, int len)
154{ 154{
155 X509_ATTRIBUTE *attr; 155 X509_ATTRIBUTE *attr;
156 STACK_OF(X509_ATTRIBUTE) *ret; 156 STACK_OF(X509_ATTRIBUTE) *ret;
@@ -163,7 +163,7 @@ STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE) **x,
163 163
164STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE) **x, 164STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE) **x,
165 int nid, int type, 165 int nid, int type,
166 unsigned char *bytes, int len) 166 const unsigned char *bytes, int len)
167{ 167{
168 X509_ATTRIBUTE *attr; 168 X509_ATTRIBUTE *attr;
169 STACK_OF(X509_ATTRIBUTE) *ret; 169 STACK_OF(X509_ATTRIBUTE) *ret;
@@ -175,8 +175,8 @@ STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE) **x,
175} 175}
176 176
177STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) **x, 177STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) **x,
178 char *attrname, int type, 178 const char *attrname, int type,
179 unsigned char *bytes, int len) 179 const unsigned char *bytes, int len)
180{ 180{
181 X509_ATTRIBUTE *attr; 181 X509_ATTRIBUTE *attr;
182 STACK_OF(X509_ATTRIBUTE) *ret; 182 STACK_OF(X509_ATTRIBUTE) *ret;
@@ -188,7 +188,7 @@ STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) **x,
188} 188}
189 189
190X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid, 190X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid,
191 int atrtype, void *data, int len) 191 int atrtype, const void *data, int len)
192{ 192{
193 ASN1_OBJECT *obj; 193 ASN1_OBJECT *obj;
194 X509_ATTRIBUTE *ret; 194 X509_ATTRIBUTE *ret;
@@ -205,7 +205,7 @@ X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid,
205} 205}
206 206
207X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr, 207X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr,
208 ASN1_OBJECT *obj, int atrtype, void *data, int len) 208 const ASN1_OBJECT *obj, int atrtype, const void *data, int len)
209{ 209{
210 X509_ATTRIBUTE *ret; 210 X509_ATTRIBUTE *ret;
211 211
@@ -234,7 +234,7 @@ err:
234} 234}
235 235
236X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr, 236X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr,
237 char *atrname, int type, unsigned char *bytes, int len) 237 const char *atrname, int type, const unsigned char *bytes, int len)
238 { 238 {
239 ASN1_OBJECT *obj; 239 ASN1_OBJECT *obj;
240 X509_ATTRIBUTE *nattr; 240 X509_ATTRIBUTE *nattr;
@@ -252,7 +252,7 @@ X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr,
252 return nattr; 252 return nattr;
253 } 253 }
254 254
255int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, ASN1_OBJECT *obj) 255int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj)
256{ 256{
257 if ((attr == NULL) || (obj == NULL)) 257 if ((attr == NULL) || (obj == NULL))
258 return(0); 258 return(0);
@@ -261,7 +261,7 @@ int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, ASN1_OBJECT *obj)
261 return(1); 261 return(1);
262} 262}
263 263
264int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, void *data, int len) 264int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *data, int len)
265{ 265{
266 ASN1_TYPE *ttmp; 266 ASN1_TYPE *ttmp;
267 ASN1_STRING *stmp; 267 ASN1_STRING *stmp;
@@ -283,7 +283,7 @@ int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, void *data, int
283 if(!(attr->value.set = sk_ASN1_TYPE_new_null())) goto err; 283 if(!(attr->value.set = sk_ASN1_TYPE_new_null())) goto err;
284 if(!(ttmp = ASN1_TYPE_new())) goto err; 284 if(!(ttmp = ASN1_TYPE_new())) goto err;
285 if(!sk_ASN1_TYPE_push(attr->value.set, ttmp)) goto err; 285 if(!sk_ASN1_TYPE_push(attr->value.set, ttmp)) goto err;
286 attr->set = 1; 286 attr->single = 0;
287 ASN1_TYPE_set(ttmp, atype, stmp); 287 ASN1_TYPE_set(ttmp, atype, stmp);
288 return 1; 288 return 1;
289 err: 289 err:
@@ -293,7 +293,7 @@ int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, void *data, int
293 293
294int X509_ATTRIBUTE_count(X509_ATTRIBUTE *attr) 294int X509_ATTRIBUTE_count(X509_ATTRIBUTE *attr)
295{ 295{
296 if(attr->set) return sk_ASN1_TYPE_num(attr->value.set); 296 if(!attr->single) return sk_ASN1_TYPE_num(attr->value.set);
297 if(attr->value.single) return 1; 297 if(attr->value.single) return 1;
298 return 0; 298 return 0;
299} 299}
@@ -321,6 +321,6 @@ ASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx)
321{ 321{
322 if (attr == NULL) return(NULL); 322 if (attr == NULL) return(NULL);
323 if(idx >= X509_ATTRIBUTE_count(attr)) return NULL; 323 if(idx >= X509_ATTRIBUTE_count(attr)) return NULL;
324 if(attr->set) return sk_ASN1_TYPE_value(attr->value.set, idx); 324 if(!attr->single) return sk_ASN1_TYPE_value(attr->value.set, idx);
325 else return attr->value.single; 325 else return attr->value.single;
326} 326}
diff --git a/src/lib/libcrypto/x509/x509_cmp.c b/src/lib/libcrypto/x509/x509_cmp.c
index 3f9f9b3d47..cd20b6d66f 100644
--- a/src/lib/libcrypto/x509/x509_cmp.c
+++ b/src/lib/libcrypto/x509/x509_cmp.c
@@ -75,24 +75,26 @@ int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b)
75 return(X509_NAME_cmp(ai->issuer,bi->issuer)); 75 return(X509_NAME_cmp(ai->issuer,bi->issuer));
76 } 76 }
77 77
78#ifndef NO_MD5 78#ifndef OPENSSL_NO_MD5
79unsigned long X509_issuer_and_serial_hash(X509 *a) 79unsigned long X509_issuer_and_serial_hash(X509 *a)
80 { 80 {
81 unsigned long ret=0; 81 unsigned long ret=0;
82 MD5_CTX ctx; 82 EVP_MD_CTX ctx;
83 unsigned char md[16]; 83 unsigned char md[16];
84 char str[256]; 84 char str[256];
85 85
86 EVP_MD_CTX_init(&ctx);
86 X509_NAME_oneline(a->cert_info->issuer,str,256); 87 X509_NAME_oneline(a->cert_info->issuer,str,256);
87 ret=strlen(str); 88 ret=strlen(str);
88 MD5_Init(&ctx); 89 EVP_DigestInit_ex(&ctx, EVP_md5(), NULL);
89 MD5_Update(&ctx,(unsigned char *)str,ret); 90 EVP_DigestUpdate(&ctx,(unsigned char *)str,ret);
90 MD5_Update(&ctx,(unsigned char *)a->cert_info->serialNumber->data, 91 EVP_DigestUpdate(&ctx,(unsigned char *)a->cert_info->serialNumber->data,
91 (unsigned long)a->cert_info->serialNumber->length); 92 (unsigned long)a->cert_info->serialNumber->length);
92 MD5_Final(&(md[0]),&ctx); 93 EVP_DigestFinal_ex(&ctx,&(md[0]),NULL);
93 ret=( ((unsigned long)md[0] )|((unsigned long)md[1]<<8L)| 94 ret=( ((unsigned long)md[0] )|((unsigned long)md[1]<<8L)|
94 ((unsigned long)md[2]<<16L)|((unsigned long)md[3]<<24L) 95 ((unsigned long)md[2]<<16L)|((unsigned long)md[3]<<24L)
95 )&0xffffffffL; 96 )&0xffffffffL;
97 EVP_MD_CTX_cleanup(&ctx);
96 return(ret); 98 return(ret);
97 } 99 }
98#endif 100#endif
@@ -137,7 +139,7 @@ unsigned long X509_subject_name_hash(X509 *x)
137 return(X509_NAME_hash(x->cert_info->subject)); 139 return(X509_NAME_hash(x->cert_info->subject));
138 } 140 }
139 141
140#ifndef NO_SHA 142#ifndef OPENSSL_NO_SHA
141/* Compare two certificates: they must be identical for 143/* Compare two certificates: they must be identical for
142 * this to work. NB: Although "cmp" operations are generally 144 * this to work. NB: Although "cmp" operations are generally
143 * prototyped to take "const" arguments (eg. for use in 145 * prototyped to take "const" arguments (eg. for use in
@@ -192,7 +194,7 @@ int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b)
192 return(0); 194 return(0);
193 } 195 }
194 196
195#ifndef NO_MD5 197#ifndef OPENSSL_NO_MD5
196/* I now DER encode the name and hash it. Since I cache the DER encoding, 198/* I now DER encode the name and hash it. Since I cache the DER encoding,
197 * this is reasonably efficient. */ 199 * this is reasonably efficient. */
198unsigned long X509_NAME_hash(X509_NAME *x) 200unsigned long X509_NAME_hash(X509_NAME *x)
@@ -200,12 +202,9 @@ unsigned long X509_NAME_hash(X509_NAME *x)
200 unsigned long ret=0; 202 unsigned long ret=0;
201 unsigned char md[16]; 203 unsigned char md[16];
202 204
203 /* Ensure cached version is up to date */ 205 /* Make sure X509_NAME structure contains valid cached encoding */
204 i2d_X509_NAME(x,NULL); 206 i2d_X509_NAME(x,NULL);
205 /* Use cached encoding directly rather than copying: this should 207 EVP_Digest(x->bytes->data, x->bytes->length, md, NULL, EVP_md5(), NULL);
206 * keep libsafe happy.
207 */
208 MD5((unsigned char *)x->bytes->data,x->bytes->length,&(md[0]));
209 208
210 ret=( ((unsigned long)md[0] )|((unsigned long)md[1]<<8L)| 209 ret=( ((unsigned long)md[0] )|((unsigned long)md[1]<<8L)|
211 ((unsigned long)md[2]<<16L)|((unsigned long)md[3]<<24L) 210 ((unsigned long)md[2]<<16L)|((unsigned long)md[3]<<24L)
@@ -258,6 +257,12 @@ EVP_PKEY *X509_get_pubkey(X509 *x)
258 return(X509_PUBKEY_get(x->cert_info->key)); 257 return(X509_PUBKEY_get(x->cert_info->key));
259 } 258 }
260 259
260ASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x)
261 {
262 if(!x) return NULL;
263 return x->cert_info->key->public_key;
264 }
265
261int X509_check_private_key(X509 *x, EVP_PKEY *k) 266int X509_check_private_key(X509 *x, EVP_PKEY *k)
262 { 267 {
263 EVP_PKEY *xk=NULL; 268 EVP_PKEY *xk=NULL;
@@ -271,7 +276,7 @@ int X509_check_private_key(X509 *x, EVP_PKEY *k)
271 } 276 }
272 switch (k->type) 277 switch (k->type)
273 { 278 {
274#ifndef NO_RSA 279#ifndef OPENSSL_NO_RSA
275 case EVP_PKEY_RSA: 280 case EVP_PKEY_RSA:
276 if (BN_cmp(xk->pkey.rsa->n,k->pkey.rsa->n) != 0 281 if (BN_cmp(xk->pkey.rsa->n,k->pkey.rsa->n) != 0
277 || BN_cmp(xk->pkey.rsa->e,k->pkey.rsa->e) != 0) 282 || BN_cmp(xk->pkey.rsa->e,k->pkey.rsa->e) != 0)
@@ -281,7 +286,7 @@ int X509_check_private_key(X509 *x, EVP_PKEY *k)
281 } 286 }
282 break; 287 break;
283#endif 288#endif
284#ifndef NO_DSA 289#ifndef OPENSSL_NO_DSA
285 case EVP_PKEY_DSA: 290 case EVP_PKEY_DSA:
286 if (BN_cmp(xk->pkey.dsa->pub_key,k->pkey.dsa->pub_key) != 0) 291 if (BN_cmp(xk->pkey.dsa->pub_key,k->pkey.dsa->pub_key) != 0)
287 { 292 {
@@ -290,7 +295,7 @@ int X509_check_private_key(X509 *x, EVP_PKEY *k)
290 } 295 }
291 break; 296 break;
292#endif 297#endif
293#ifndef NO_DH 298#ifndef OPENSSL_NO_DH
294 case EVP_PKEY_DH: 299 case EVP_PKEY_DH:
295 /* No idea */ 300 /* No idea */
296 X509err(X509_F_X509_CHECK_PRIVATE_KEY,X509_R_CANT_CHECK_DH_KEY); 301 X509err(X509_F_X509_CHECK_PRIVATE_KEY,X509_R_CANT_CHECK_DH_KEY);
diff --git a/src/lib/libcrypto/x509/x509_d2.c b/src/lib/libcrypto/x509/x509_d2.c
index 753d53eb43..51410cfd1a 100644
--- a/src/lib/libcrypto/x509/x509_d2.c
+++ b/src/lib/libcrypto/x509/x509_d2.c
@@ -61,7 +61,7 @@
61#include <openssl/crypto.h> 61#include <openssl/crypto.h>
62#include <openssl/x509.h> 62#include <openssl/x509.h>
63 63
64#ifndef NO_STDIO 64#ifndef OPENSSL_NO_STDIO
65int X509_STORE_set_default_paths(X509_STORE *ctx) 65int X509_STORE_set_default_paths(X509_STORE *ctx)
66 { 66 {
67 X509_LOOKUP *lookup; 67 X509_LOOKUP *lookup;
diff --git a/src/lib/libcrypto/x509/x509_err.c b/src/lib/libcrypto/x509/x509_err.c
index 848add56e9..5bbf4acf76 100644
--- a/src/lib/libcrypto/x509/x509_err.c
+++ b/src/lib/libcrypto/x509/x509_err.c
@@ -63,7 +63,7 @@
63#include <openssl/x509.h> 63#include <openssl/x509.h>
64 64
65/* BEGIN ERROR CODES */ 65/* BEGIN ERROR CODES */
66#ifndef NO_ERR 66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA X509_str_functs[]= 67static ERR_STRING_DATA X509_str_functs[]=
68 { 68 {
69{ERR_PACK(0,X509_F_ADD_CERT_DIR,0), "ADD_CERT_DIR"}, 69{ERR_PACK(0,X509_F_ADD_CERT_DIR,0), "ADD_CERT_DIR"},
@@ -100,9 +100,12 @@ static ERR_STRING_DATA X509_str_functs[]=
100{ERR_PACK(0,X509_F_X509_REQ_TO_X509,0), "X509_REQ_to_X509"}, 100{ERR_PACK(0,X509_F_X509_REQ_TO_X509,0), "X509_REQ_to_X509"},
101{ERR_PACK(0,X509_F_X509_STORE_ADD_CERT,0), "X509_STORE_add_cert"}, 101{ERR_PACK(0,X509_F_X509_STORE_ADD_CERT,0), "X509_STORE_add_cert"},
102{ERR_PACK(0,X509_F_X509_STORE_ADD_CRL,0), "X509_STORE_add_crl"}, 102{ERR_PACK(0,X509_F_X509_STORE_ADD_CRL,0), "X509_STORE_add_crl"},
103{ERR_PACK(0,X509_F_X509_STORE_CTX_INIT,0), "X509_STORE_CTX_init"},
104{ERR_PACK(0,X509_F_X509_STORE_CTX_NEW,0), "X509_STORE_CTX_new"},
103{ERR_PACK(0,X509_F_X509_STORE_CTX_PURPOSE_INHERIT,0), "X509_STORE_CTX_purpose_inherit"}, 105{ERR_PACK(0,X509_F_X509_STORE_CTX_PURPOSE_INHERIT,0), "X509_STORE_CTX_purpose_inherit"},
104{ERR_PACK(0,X509_F_X509_TO_X509_REQ,0), "X509_to_X509_REQ"}, 106{ERR_PACK(0,X509_F_X509_TO_X509_REQ,0), "X509_to_X509_REQ"},
105{ERR_PACK(0,X509_F_X509_TRUST_ADD,0), "X509_TRUST_add"}, 107{ERR_PACK(0,X509_F_X509_TRUST_ADD,0), "X509_TRUST_add"},
108{ERR_PACK(0,X509_F_X509_TRUST_SET,0), "X509_TRUST_set"},
106{ERR_PACK(0,X509_F_X509_VERIFY_CERT,0), "X509_verify_cert"}, 109{ERR_PACK(0,X509_F_X509_VERIFY_CERT,0), "X509_verify_cert"},
107{0,NULL} 110{0,NULL}
108 }; 111 };
@@ -116,6 +119,7 @@ static ERR_STRING_DATA X509_str_reasons[]=
116{X509_R_ERR_ASN1_LIB ,"err asn1 lib"}, 119{X509_R_ERR_ASN1_LIB ,"err asn1 lib"},
117{X509_R_INVALID_DIRECTORY ,"invalid directory"}, 120{X509_R_INVALID_DIRECTORY ,"invalid directory"},
118{X509_R_INVALID_FIELD_NAME ,"invalid field name"}, 121{X509_R_INVALID_FIELD_NAME ,"invalid field name"},
122{X509_R_INVALID_TRUST ,"invalid trust"},
119{X509_R_KEY_TYPE_MISMATCH ,"key type mismatch"}, 123{X509_R_KEY_TYPE_MISMATCH ,"key type mismatch"},
120{X509_R_KEY_VALUES_MISMATCH ,"key values mismatch"}, 124{X509_R_KEY_VALUES_MISMATCH ,"key values mismatch"},
121{X509_R_LOADING_CERT_DIR ,"loading cert dir"}, 125{X509_R_LOADING_CERT_DIR ,"loading cert dir"},
@@ -143,7 +147,7 @@ void ERR_load_X509_strings(void)
143 if (init) 147 if (init)
144 { 148 {
145 init=0; 149 init=0;
146#ifndef NO_ERR 150#ifndef OPENSSL_NO_ERR
147 ERR_load_strings(ERR_LIB_X509,X509_str_functs); 151 ERR_load_strings(ERR_LIB_X509,X509_str_functs);
148 ERR_load_strings(ERR_LIB_X509,X509_str_reasons); 152 ERR_load_strings(ERR_LIB_X509,X509_str_reasons);
149#endif 153#endif
diff --git a/src/lib/libcrypto/x509/x509_ext.c b/src/lib/libcrypto/x509/x509_ext.c
index 2955989807..e7fdacb5e4 100644
--- a/src/lib/libcrypto/x509/x509_ext.c
+++ b/src/lib/libcrypto/x509/x509_ext.c
@@ -101,6 +101,12 @@ void *X509_CRL_get_ext_d2i(X509_CRL *x, int nid, int *crit, int *idx)
101 return X509V3_get_d2i(x->crl->extensions, nid, crit, idx); 101 return X509V3_get_d2i(x->crl->extensions, nid, crit, idx);
102} 102}
103 103
104int X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit,
105 unsigned long flags)
106{
107 return X509V3_add1_i2d(&x->crl->extensions, nid, value, crit, flags);
108}
109
104int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc) 110int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc)
105 { 111 {
106 return(X509v3_add_ext(&(x->crl->extensions),ex,loc) != NULL); 112 return(X509v3_add_ext(&(x->crl->extensions),ex,loc) != NULL);
@@ -146,6 +152,13 @@ void *X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx)
146 return X509V3_get_d2i(x->cert_info->extensions, nid, crit, idx); 152 return X509V3_get_d2i(x->cert_info->extensions, nid, crit, idx);
147} 153}
148 154
155int X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit,
156 unsigned long flags)
157{
158 return X509V3_add1_i2d(&x->cert_info->extensions, nid, value, crit,
159 flags);
160}
161
149int X509_REVOKED_get_ext_count(X509_REVOKED *x) 162int X509_REVOKED_get_ext_count(X509_REVOKED *x)
150 { 163 {
151 return(X509v3_get_ext_count(x->extensions)); 164 return(X509v3_get_ext_count(x->extensions));
@@ -187,5 +200,11 @@ void *X509_REVOKED_get_ext_d2i(X509_REVOKED *x, int nid, int *crit, int *idx)
187 return X509V3_get_d2i(x->extensions, nid, crit, idx); 200 return X509V3_get_d2i(x->extensions, nid, crit, idx);
188} 201}
189 202
203int X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit,
204 unsigned long flags)
205{
206 return X509V3_add1_i2d(&x->extensions, nid, value, crit, flags);
207}
208
190IMPLEMENT_STACK_OF(X509_EXTENSION) 209IMPLEMENT_STACK_OF(X509_EXTENSION)
191IMPLEMENT_ASN1_SET_OF(X509_EXTENSION) 210IMPLEMENT_ASN1_SET_OF(X509_EXTENSION)
diff --git a/src/lib/libcrypto/x509/x509_lu.c b/src/lib/libcrypto/x509/x509_lu.c
index 863c738cad..b780dae5e2 100644
--- a/src/lib/libcrypto/x509/x509_lu.c
+++ b/src/lib/libcrypto/x509/x509_lu.c
@@ -60,8 +60,7 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/lhash.h> 61#include <openssl/lhash.h>
62#include <openssl/x509.h> 62#include <openssl/x509.h>
63 63#include <openssl/x509v3.h>
64static STACK_OF(CRYPTO_EX_DATA_FUNCS) *x509_store_meth=NULL;
65 64
66X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method) 65X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method)
67 { 66 {
@@ -185,9 +184,23 @@ X509_STORE *X509_STORE_new(void)
185 ret->objs = sk_X509_OBJECT_new(x509_object_cmp); 184 ret->objs = sk_X509_OBJECT_new(x509_object_cmp);
186 ret->cache=1; 185 ret->cache=1;
187 ret->get_cert_methods=sk_X509_LOOKUP_new_null(); 186 ret->get_cert_methods=sk_X509_LOOKUP_new_null();
188 ret->verify=NULL; 187 ret->verify=0;
189 ret->verify_cb=NULL; 188 ret->verify_cb=0;
190 memset(&ret->ex_data,0,sizeof(CRYPTO_EX_DATA)); 189
190 ret->purpose = 0;
191 ret->trust = 0;
192
193 ret->flags = 0;
194
195 ret->get_issuer = 0;
196 ret->check_issued = 0;
197 ret->check_revocation = 0;
198 ret->get_crl = 0;
199 ret->check_crl = 0;
200 ret->cert_crl = 0;
201 ret->cleanup = 0;
202
203 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_X509_STORE, ret, &ret->ex_data);
191 ret->references=1; 204 ret->references=1;
192 ret->depth=0; 205 ret->depth=0;
193 return ret; 206 return ret;
@@ -230,7 +243,7 @@ void X509_STORE_free(X509_STORE *vfy)
230 sk_X509_LOOKUP_free(sk); 243 sk_X509_LOOKUP_free(sk);
231 sk_X509_OBJECT_pop_free(vfy->objs, cleanup); 244 sk_X509_OBJECT_pop_free(vfy->objs, cleanup);
232 245
233 CRYPTO_free_ex_data(x509_store_meth,vfy,&vfy->ex_data); 246 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_X509_STORE, vfy, &vfy->ex_data);
234 OPENSSL_free(vfy); 247 OPENSSL_free(vfy);
235 } 248 }
236 249
@@ -525,5 +538,20 @@ int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x)
525 return 0; 538 return 0;
526} 539}
527 540
541void X509_STORE_set_flags(X509_STORE *ctx, long flags)
542 {
543 ctx->flags |= flags;
544 }
545
546int X509_STORE_set_purpose(X509_STORE *ctx, int purpose)
547 {
548 return X509_PURPOSE_set(&ctx->purpose, purpose);
549 }
550
551int X509_STORE_set_trust(X509_STORE *ctx, int trust)
552 {
553 return X509_TRUST_set(&ctx->trust, trust);
554 }
555
528IMPLEMENT_STACK_OF(X509_LOOKUP) 556IMPLEMENT_STACK_OF(X509_LOOKUP)
529IMPLEMENT_STACK_OF(X509_OBJECT) 557IMPLEMENT_STACK_OF(X509_OBJECT)
diff --git a/src/lib/libcrypto/x509/x509_obj.c b/src/lib/libcrypto/x509/x509_obj.c
index f0271fdfa1..1e718f76eb 100644
--- a/src/lib/libcrypto/x509/x509_obj.c
+++ b/src/lib/libcrypto/x509/x509_obj.c
@@ -94,6 +94,7 @@ int i;
94 OPENSSL_free(b); 94 OPENSSL_free(b);
95 } 95 }
96 strncpy(buf,"NO X509_NAME",len); 96 strncpy(buf,"NO X509_NAME",len);
97 buf[len-1]='\0';
97 return buf; 98 return buf;
98 } 99 }
99 100
diff --git a/src/lib/libcrypto/x509/x509_req.c b/src/lib/libcrypto/x509/x509_req.c
index 7eca1bd57a..0affa3bf30 100644
--- a/src/lib/libcrypto/x509/x509_req.c
+++ b/src/lib/libcrypto/x509/x509_req.c
@@ -156,9 +156,9 @@ STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req)
156 for(i = 0; i < sk_X509_ATTRIBUTE_num(sk); i++) { 156 for(i = 0; i < sk_X509_ATTRIBUTE_num(sk); i++) {
157 attr = sk_X509_ATTRIBUTE_value(sk, i); 157 attr = sk_X509_ATTRIBUTE_value(sk, i);
158 if(X509_REQ_extension_nid(OBJ_obj2nid(attr->object))) { 158 if(X509_REQ_extension_nid(OBJ_obj2nid(attr->object))) {
159 if(attr->set && sk_ASN1_TYPE_num(attr->value.set)) 159 if(attr->single) ext = attr->value.single;
160 else if(sk_ASN1_TYPE_num(attr->value.set))
160 ext = sk_ASN1_TYPE_value(attr->value.set, 0); 161 ext = sk_ASN1_TYPE_value(attr->value.set, 0);
161 else ext = attr->value.single;
162 break; 162 break;
163 } 163 }
164 } 164 }
@@ -199,7 +199,7 @@ int X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts,
199 if(!(attr->value.set = sk_ASN1_TYPE_new_null())) goto err; 199 if(!(attr->value.set = sk_ASN1_TYPE_new_null())) goto err;
200 if(!sk_ASN1_TYPE_push(attr->value.set, at)) goto err; 200 if(!sk_ASN1_TYPE_push(attr->value.set, at)) goto err;
201 at = NULL; 201 at = NULL;
202 attr->set = 1; 202 attr->single = 0;
203 attr->object = OBJ_nid2obj(nid); 203 attr->object = OBJ_nid2obj(nid);
204 if(!sk_X509_ATTRIBUTE_push(req->req_info->attributes, attr)) goto err; 204 if(!sk_X509_ATTRIBUTE_push(req->req_info->attributes, attr)) goto err;
205 return 1; 205 return 1;
@@ -251,8 +251,8 @@ int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr)
251} 251}
252 252
253int X509_REQ_add1_attr_by_OBJ(X509_REQ *req, 253int X509_REQ_add1_attr_by_OBJ(X509_REQ *req,
254 ASN1_OBJECT *obj, int type, 254 const ASN1_OBJECT *obj, int type,
255 unsigned char *bytes, int len) 255 const unsigned char *bytes, int len)
256{ 256{
257 if(X509at_add1_attr_by_OBJ(&req->req_info->attributes, obj, 257 if(X509at_add1_attr_by_OBJ(&req->req_info->attributes, obj,
258 type, bytes, len)) return 1; 258 type, bytes, len)) return 1;
@@ -261,7 +261,7 @@ int X509_REQ_add1_attr_by_OBJ(X509_REQ *req,
261 261
262int X509_REQ_add1_attr_by_NID(X509_REQ *req, 262int X509_REQ_add1_attr_by_NID(X509_REQ *req,
263 int nid, int type, 263 int nid, int type,
264 unsigned char *bytes, int len) 264 const unsigned char *bytes, int len)
265{ 265{
266 if(X509at_add1_attr_by_NID(&req->req_info->attributes, nid, 266 if(X509at_add1_attr_by_NID(&req->req_info->attributes, nid,
267 type, bytes, len)) return 1; 267 type, bytes, len)) return 1;
@@ -269,8 +269,8 @@ int X509_REQ_add1_attr_by_NID(X509_REQ *req,
269} 269}
270 270
271int X509_REQ_add1_attr_by_txt(X509_REQ *req, 271int X509_REQ_add1_attr_by_txt(X509_REQ *req,
272 char *attrname, int type, 272 const char *attrname, int type,
273 unsigned char *bytes, int len) 273 const unsigned char *bytes, int len)
274{ 274{
275 if(X509at_add1_attr_by_txt(&req->req_info->attributes, attrname, 275 if(X509at_add1_attr_by_txt(&req->req_info->attributes, attrname,
276 type, bytes, len)) return 1; 276 type, bytes, len)) return 1;
diff --git a/src/lib/libcrypto/x509/x509_trs.c b/src/lib/libcrypto/x509/x509_trs.c
index 86b3b79dcc..17d69ac005 100644
--- a/src/lib/libcrypto/x509/x509_trs.c
+++ b/src/lib/libcrypto/x509/x509_trs.c
@@ -66,6 +66,7 @@ static int tr_cmp(const X509_TRUST * const *a,
66static void trtable_free(X509_TRUST *p); 66static void trtable_free(X509_TRUST *p);
67 67
68static int trust_1oidany(X509_TRUST *trust, X509 *x, int flags); 68static int trust_1oidany(X509_TRUST *trust, X509 *x, int flags);
69static int trust_1oid(X509_TRUST *trust, X509 *x, int flags);
69static int trust_compat(X509_TRUST *trust, X509 *x, int flags); 70static int trust_compat(X509_TRUST *trust, X509 *x, int flags);
70 71
71static int obj_trust(int id, X509 *x, int flags); 72static int obj_trust(int id, X509 *x, int flags);
@@ -79,8 +80,10 @@ static int (*default_trust)(int id, X509 *x, int flags) = obj_trust;
79static X509_TRUST trstandard[] = { 80static X509_TRUST trstandard[] = {
80{X509_TRUST_COMPAT, 0, trust_compat, "compatible", 0, NULL}, 81{X509_TRUST_COMPAT, 0, trust_compat, "compatible", 0, NULL},
81{X509_TRUST_SSL_CLIENT, 0, trust_1oidany, "SSL Client", NID_client_auth, NULL}, 82{X509_TRUST_SSL_CLIENT, 0, trust_1oidany, "SSL Client", NID_client_auth, NULL},
82{X509_TRUST_SSL_SERVER, 0, trust_1oidany, "SSL Client", NID_server_auth, NULL}, 83{X509_TRUST_SSL_SERVER, 0, trust_1oidany, "SSL Server", NID_server_auth, NULL},
83{X509_TRUST_EMAIL, 0, trust_1oidany, "S/MIME email", NID_email_protect, NULL}, 84{X509_TRUST_EMAIL, 0, trust_1oidany, "S/MIME email", NID_email_protect, NULL},
85{X509_TRUST_OCSP_SIGN, 0, trust_1oid, "OCSP responder", NID_OCSP_sign, NULL},
86{X509_TRUST_OCSP_REQUEST, 0, trust_1oid, "OCSP request", NID_ad_OCSP, NULL}
84}; 87};
85 88
86#define X509_TRUST_COUNT (sizeof(trstandard)/sizeof(X509_TRUST)) 89#define X509_TRUST_COUNT (sizeof(trstandard)/sizeof(X509_TRUST))
@@ -97,10 +100,10 @@ static int tr_cmp(const X509_TRUST * const *a,
97 100
98int (*X509_TRUST_set_default(int (*trust)(int , X509 *, int)))(int, X509 *, int) 101int (*X509_TRUST_set_default(int (*trust)(int , X509 *, int)))(int, X509 *, int)
99{ 102{
100int (*oldtrust)(int , X509 *, int); 103 int (*oldtrust)(int , X509 *, int);
101oldtrust = default_trust; 104 oldtrust = default_trust;
102default_trust = trust; 105 default_trust = trust;
103return oldtrust; 106 return oldtrust;
104} 107}
105 108
106 109
@@ -141,6 +144,16 @@ int X509_TRUST_get_by_id(int id)
141 return idx + X509_TRUST_COUNT; 144 return idx + X509_TRUST_COUNT;
142} 145}
143 146
147int X509_TRUST_set(int *t, int trust)
148{
149 if(X509_TRUST_get_by_id(trust) == -1) {
150 X509err(X509_F_X509_TRUST_SET, X509_R_INVALID_TRUST);
151 return 0;
152 }
153 *t = trust;
154 return 1;
155}
156
144int X509_TRUST_add(int id, int flags, int (*ck)(X509_TRUST *, X509 *, int), 157int X509_TRUST_add(int id, int flags, int (*ck)(X509_TRUST *, X509 *, int),
145 char *name, int arg1, void *arg2) 158 char *name, int arg1, void *arg2)
146{ 159{
@@ -236,6 +249,12 @@ static int trust_1oidany(X509_TRUST *trust, X509 *x, int flags)
236 return trust_compat(trust, x, flags); 249 return trust_compat(trust, x, flags);
237} 250}
238 251
252static int trust_1oid(X509_TRUST *trust, X509 *x, int flags)
253{
254 if(x->aux) return obj_trust(trust->arg1, x, flags);
255 return X509_TRUST_UNTRUSTED;
256}
257
239static int trust_compat(X509_TRUST *trust, X509 *x, int flags) 258static int trust_compat(X509_TRUST *trust, X509 *x, int flags)
240{ 259{
241 X509_check_purpose(x, -1, 0); 260 X509_check_purpose(x, -1, 0);
diff --git a/src/lib/libcrypto/x509/x509_txt.c b/src/lib/libcrypto/x509/x509_txt.c
index cfb478d4bc..4f83db8ba2 100644
--- a/src/lib/libcrypto/x509/x509_txt.c
+++ b/src/lib/libcrypto/x509/x509_txt.c
@@ -83,7 +83,7 @@ const char *X509_verify_cert_error_string(long n)
83 case X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE: 83 case X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE:
84 return("unable to decrypt certificate's signature"); 84 return("unable to decrypt certificate's signature");
85 case X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE: 85 case X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE:
86 return("unable to decrypt CRL's's signature"); 86 return("unable to decrypt CRL's signature");
87 case X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY: 87 case X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY:
88 return("unable to decode issuer public key"); 88 return("unable to decode issuer public key");
89 case X509_V_ERR_CERT_SIGNATURE_FAILURE: 89 case X509_V_ERR_CERT_SIGNATURE_FAILURE:
@@ -95,7 +95,7 @@ const char *X509_verify_cert_error_string(long n)
95 case X509_V_ERR_CRL_NOT_YET_VALID: 95 case X509_V_ERR_CRL_NOT_YET_VALID:
96 return("CRL is not yet valid"); 96 return("CRL is not yet valid");
97 case X509_V_ERR_CERT_HAS_EXPIRED: 97 case X509_V_ERR_CERT_HAS_EXPIRED:
98 return("Certificate has expired"); 98 return("certificate has expired");
99 case X509_V_ERR_CRL_HAS_EXPIRED: 99 case X509_V_ERR_CRL_HAS_EXPIRED:
100 return("CRL has expired"); 100 return("CRL has expired");
101 case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD: 101 case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD:
@@ -141,6 +141,12 @@ const char *X509_verify_cert_error_string(long n)
141 case X509_V_ERR_KEYUSAGE_NO_CERTSIGN: 141 case X509_V_ERR_KEYUSAGE_NO_CERTSIGN:
142 return("key usage does not include certificate signing"); 142 return("key usage does not include certificate signing");
143 143
144 case X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER:
145 return("unable to get CRL issuer certificate");
146
147 case X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION:
148 return("unhandled critical extension");
149
144 default: 150 default:
145 sprintf(buf,"error number %ld",n); 151 sprintf(buf,"error number %ld",n);
146 return(buf); 152 return(buf);
diff --git a/src/lib/libcrypto/x509/x509_v3.c b/src/lib/libcrypto/x509/x509_v3.c
index 52887986fe..b5f7daa2e5 100644
--- a/src/lib/libcrypto/x509/x509_v3.c
+++ b/src/lib/libcrypto/x509/x509_v3.c
@@ -115,8 +115,8 @@ int X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *sk, int crit,
115 for ( ; lastpos < n; lastpos++) 115 for ( ; lastpos < n; lastpos++)
116 { 116 {
117 ex=sk_X509_EXTENSION_value(sk,lastpos); 117 ex=sk_X509_EXTENSION_value(sk,lastpos);
118 if ( (ex->critical && crit) || 118 if ( ((ex->critical > 0) && crit) ||
119 (!ex->critical && !crit)) 119 (!(ex->critical <= 0) && !crit))
120 return(lastpos); 120 return(lastpos);
121 } 121 }
122 return(-1); 122 return(-1);
@@ -234,7 +234,7 @@ int X509_EXTENSION_set_object(X509_EXTENSION *ex, ASN1_OBJECT *obj)
234int X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit) 234int X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit)
235 { 235 {
236 if (ex == NULL) return(0); 236 if (ex == NULL) return(0);
237 ex->critical=(crit)?0xFF:0; 237 ex->critical=(crit)?0xFF:-1;
238 return(1); 238 return(1);
239 } 239 }
240 240
@@ -263,5 +263,6 @@ ASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ex)
263int X509_EXTENSION_get_critical(X509_EXTENSION *ex) 263int X509_EXTENSION_get_critical(X509_EXTENSION *ex)
264 { 264 {
265 if (ex == NULL) return(0); 265 if (ex == NULL) return(0);
266 return(ex->critical); 266 if(ex->critical > 0) return 1;
267 return 0;
267 } 268 }
diff --git a/src/lib/libcrypto/x509/x509_vfy.c b/src/lib/libcrypto/x509/x509_vfy.c
index 0f4110cc64..db12f7bd35 100644
--- a/src/lib/libcrypto/x509/x509_vfy.c
+++ b/src/lib/libcrypto/x509/x509_vfy.c
@@ -75,15 +75,11 @@ static int check_issued(X509_STORE_CTX *ctx, X509 *x, X509 *issuer);
75static X509 *find_issuer(X509_STORE_CTX *ctx, STACK_OF(X509) *sk, X509 *x); 75static X509 *find_issuer(X509_STORE_CTX *ctx, STACK_OF(X509) *sk, X509 *x);
76static int check_chain_purpose(X509_STORE_CTX *ctx); 76static int check_chain_purpose(X509_STORE_CTX *ctx);
77static int check_trust(X509_STORE_CTX *ctx); 77static int check_trust(X509_STORE_CTX *ctx);
78static int check_revocation(X509_STORE_CTX *ctx);
79static int check_cert(X509_STORE_CTX *ctx);
78static int internal_verify(X509_STORE_CTX *ctx); 80static int internal_verify(X509_STORE_CTX *ctx);
79const char *X509_version="X.509" OPENSSL_VERSION_PTEXT; 81const char *X509_version="X.509" OPENSSL_VERSION_PTEXT;
80 82
81static STACK_OF(CRYPTO_EX_DATA_FUNCS) *x509_store_ctx_method=NULL;
82static int x509_store_ctx_num=0;
83#if 0
84static int x509_store_num=1;
85static STACK *x509_store_method=NULL;
86#endif
87 83
88static int null_callback(int ok, X509_STORE_CTX *e) 84static int null_callback(int ok, X509_STORE_CTX *e)
89 { 85 {
@@ -113,7 +109,6 @@ int X509_verify_cert(X509_STORE_CTX *ctx)
113 } 109 }
114 110
115 cb=ctx->verify_cb; 111 cb=ctx->verify_cb;
116 if (cb == NULL) cb=null_callback;
117 112
118 /* first we make sure the chain we are going to build is 113 /* first we make sure the chain we are going to build is
119 * present and that the first entry is in place */ 114 * present and that the first entry is in place */
@@ -299,6 +294,13 @@ int X509_verify_cert(X509_STORE_CTX *ctx)
299 /* We may as well copy down any DSA parameters that are required */ 294 /* We may as well copy down any DSA parameters that are required */
300 X509_get_pubkey_parameters(NULL,ctx->chain); 295 X509_get_pubkey_parameters(NULL,ctx->chain);
301 296
297 /* Check revocation status: we do this after copying parameters
298 * because they may be needed for CRL signature verification.
299 */
300
301 ok = ctx->check_revocation(ctx);
302 if(!ok) goto end;
303
302 /* At this point, we have a chain and just need to verify it */ 304 /* At this point, we have a chain and just need to verify it */
303 if (ctx->verify != NULL) 305 if (ctx->verify != NULL)
304 ok=ctx->verify(ctx); 306 ok=ctx->verify(ctx);
@@ -346,8 +348,7 @@ static int check_issued(X509_STORE_CTX *ctx, X509 *x, X509 *issuer)
346 ctx->error = ret; 348 ctx->error = ret;
347 ctx->current_cert = x; 349 ctx->current_cert = x;
348 ctx->current_issuer = issuer; 350 ctx->current_issuer = issuer;
349 if (ctx->verify_cb) 351 return ctx->verify_cb(0, ctx);
350 return ctx->verify_cb(0, ctx);
351 return 0; 352 return 0;
352} 353}
353 354
@@ -372,18 +373,26 @@ static int get_issuer_sk(X509 **issuer, X509_STORE_CTX *ctx, X509 *x)
372 373
373static int check_chain_purpose(X509_STORE_CTX *ctx) 374static int check_chain_purpose(X509_STORE_CTX *ctx)
374{ 375{
375#ifdef NO_CHAIN_VERIFY 376#ifdef OPENSSL_NO_CHAIN_VERIFY
376 return 1; 377 return 1;
377#else 378#else
378 int i, ok=0; 379 int i, ok=0;
379 X509 *x; 380 X509 *x;
380 int (*cb)(); 381 int (*cb)();
381 cb=ctx->verify_cb; 382 cb=ctx->verify_cb;
382 if (cb == NULL) cb=null_callback;
383 /* Check all untrusted certificates */ 383 /* Check all untrusted certificates */
384 for (i = 0; i < ctx->last_untrusted; i++) 384 for (i = 0; i < ctx->last_untrusted; i++)
385 { 385 {
386 x = sk_X509_value(ctx->chain, i); 386 x = sk_X509_value(ctx->chain, i);
387 if (!(ctx->flags & X509_V_FLAG_IGNORE_CRITICAL)
388 && (x->ex_flags & EXFLAG_CRITICAL))
389 {
390 ctx->error = X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION;
391 ctx->error_depth = i;
392 ctx->current_cert = x;
393 ok=cb(0,ctx);
394 if (!ok) goto end;
395 }
387 if (!X509_check_purpose(x, ctx->purpose, i)) 396 if (!X509_check_purpose(x, ctx->purpose, i))
388 { 397 {
389 if (i) 398 if (i)
@@ -414,21 +423,20 @@ static int check_chain_purpose(X509_STORE_CTX *ctx)
414 423
415static int check_trust(X509_STORE_CTX *ctx) 424static int check_trust(X509_STORE_CTX *ctx)
416{ 425{
417#ifdef NO_CHAIN_VERIFY 426#ifdef OPENSSL_NO_CHAIN_VERIFY
418 return 1; 427 return 1;
419#else 428#else
420 int i, ok; 429 int i, ok;
421 X509 *x; 430 X509 *x;
422 int (*cb)(); 431 int (*cb)();
423 cb=ctx->verify_cb; 432 cb=ctx->verify_cb;
424 if (cb == NULL) cb=null_callback;
425/* For now just check the last certificate in the chain */ 433/* For now just check the last certificate in the chain */
426 i = sk_X509_num(ctx->chain) - 1; 434 i = sk_X509_num(ctx->chain) - 1;
427 x = sk_X509_value(ctx->chain, i); 435 x = sk_X509_value(ctx->chain, i);
428 ok = X509_check_trust(x, ctx->trust, 0); 436 ok = X509_check_trust(x, ctx->trust, 0);
429 if (ok == X509_TRUST_TRUSTED) 437 if (ok == X509_TRUST_TRUSTED)
430 return 1; 438 return 1;
431 ctx->error_depth = sk_X509_num(ctx->chain) - 1; 439 ctx->error_depth = i;
432 ctx->current_cert = x; 440 ctx->current_cert = x;
433 if (ok == X509_TRUST_REJECTED) 441 if (ok == X509_TRUST_REJECTED)
434 ctx->error = X509_V_ERR_CERT_REJECTED; 442 ctx->error = X509_V_ERR_CERT_REJECTED;
@@ -439,6 +447,183 @@ static int check_trust(X509_STORE_CTX *ctx)
439#endif 447#endif
440} 448}
441 449
450static int check_revocation(X509_STORE_CTX *ctx)
451 {
452 int i, last, ok;
453 if (!(ctx->flags & X509_V_FLAG_CRL_CHECK))
454 return 1;
455 if (ctx->flags & X509_V_FLAG_CRL_CHECK_ALL)
456 last = 0;
457 else
458 last = sk_X509_num(ctx->chain) - 1;
459 for(i = 0; i <= last; i++)
460 {
461 ctx->error_depth = i;
462 ok = check_cert(ctx);
463 if (!ok) return ok;
464 }
465 return 1;
466 }
467
468static int check_cert(X509_STORE_CTX *ctx)
469 {
470 X509_CRL *crl = NULL;
471 X509 *x;
472 int ok, cnum;
473 cnum = ctx->error_depth;
474 x = sk_X509_value(ctx->chain, cnum);
475 ctx->current_cert = x;
476 /* Try to retrieve relevant CRL */
477 ok = ctx->get_crl(ctx, &crl, x);
478 /* If error looking up CRL, nothing we can do except
479 * notify callback
480 */
481 if(!ok)
482 {
483 ctx->error = X509_V_ERR_UNABLE_TO_GET_CRL;
484 ok = ctx->verify_cb(0, ctx);
485 goto err;
486 }
487 ctx->current_crl = crl;
488 ok = ctx->check_crl(ctx, crl);
489 if (!ok) goto err;
490 ok = ctx->cert_crl(ctx, crl, x);
491 err:
492 ctx->current_crl = NULL;
493 X509_CRL_free(crl);
494 return ok;
495
496 }
497
498/* Retrieve CRL corresponding to certificate: currently just a
499 * subject lookup: maybe use AKID later...
500 * Also might look up any included CRLs too (e.g PKCS#7 signedData).
501 */
502static int get_crl(X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x)
503 {
504 int ok;
505 X509_OBJECT xobj;
506 ok = X509_STORE_get_by_subject(ctx, X509_LU_CRL, X509_get_issuer_name(x), &xobj);
507 if (!ok) return 0;
508 *crl = xobj.data.crl;
509 return 1;
510 }
511
512/* Check CRL validity */
513static int check_crl(X509_STORE_CTX *ctx, X509_CRL *crl)
514 {
515 X509 *issuer = NULL;
516 EVP_PKEY *ikey = NULL;
517 int ok = 0, chnum, cnum, i;
518 time_t *ptime;
519 cnum = ctx->error_depth;
520 chnum = sk_X509_num(ctx->chain) - 1;
521 /* Find CRL issuer: if not last certificate then issuer
522 * is next certificate in chain.
523 */
524 if(cnum < chnum)
525 issuer = sk_X509_value(ctx->chain, cnum + 1);
526 else
527 {
528 issuer = sk_X509_value(ctx->chain, chnum);
529 /* If not self signed, can't check signature */
530 if(!ctx->check_issued(ctx, issuer, issuer))
531 {
532 ctx->error = X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER;
533 ok = ctx->verify_cb(0, ctx);
534 if(!ok) goto err;
535 }
536 }
537
538 if(issuer)
539 {
540
541 /* Attempt to get issuer certificate public key */
542 ikey = X509_get_pubkey(issuer);
543
544 if(!ikey)
545 {
546 ctx->error=X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY;
547 ok = ctx->verify_cb(0, ctx);
548 if (!ok) goto err;
549 }
550 else
551 {
552 /* Verify CRL signature */
553 if(X509_CRL_verify(crl, ikey) <= 0)
554 {
555 ctx->error=X509_V_ERR_CRL_SIGNATURE_FAILURE;
556 ok = ctx->verify_cb(0, ctx);
557 if (!ok) goto err;
558 }
559 }
560 }
561
562 /* OK, CRL signature valid check times */
563 if (ctx->flags & X509_V_FLAG_USE_CHECK_TIME)
564 ptime = &ctx->check_time;
565 else
566 ptime = NULL;
567
568 i=X509_cmp_time(X509_CRL_get_lastUpdate(crl), ptime);
569 if (i == 0)
570 {
571 ctx->error=X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD;
572 ok = ctx->verify_cb(0, ctx);
573 if (!ok) goto err;
574 }
575
576 if (i > 0)
577 {
578 ctx->error=X509_V_ERR_CRL_NOT_YET_VALID;
579 ok = ctx->verify_cb(0, ctx);
580 if (!ok) goto err;
581 }
582
583 if(X509_CRL_get_nextUpdate(crl))
584 {
585 i=X509_cmp_time(X509_CRL_get_nextUpdate(crl), ptime);
586
587 if (i == 0)
588 {
589 ctx->error=X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD;
590 ok = ctx->verify_cb(0, ctx);
591 if (!ok) goto err;
592 }
593
594 if (i < 0)
595 {
596 ctx->error=X509_V_ERR_CRL_HAS_EXPIRED;
597 ok = ctx->verify_cb(0, ctx);
598 if (!ok) goto err;
599 }
600 }
601
602 ok = 1;
603
604 err:
605 EVP_PKEY_free(ikey);
606 return ok;
607 }
608
609/* Check certificate against CRL */
610static int cert_crl(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x)
611 {
612 int idx, ok;
613 X509_REVOKED rtmp;
614 /* Look for serial number of certificate in CRL */
615 rtmp.serialNumber = X509_get_serialNumber(x);
616 idx = sk_X509_REVOKED_find(crl->crl->revoked, &rtmp);
617 /* Not found: OK */
618 if(idx == -1) return 1;
619 /* Otherwise revoked: want something cleverer than
620 * this to handle entry extensions in V2 CRLs.
621 */
622 ctx->error = X509_V_ERR_CERT_REVOKED;
623 ok = ctx->verify_cb(0, ctx);
624 return ok;
625 }
626
442static int internal_verify(X509_STORE_CTX *ctx) 627static int internal_verify(X509_STORE_CTX *ctx)
443 { 628 {
444 int i,ok=0,n; 629 int i,ok=0,n;
@@ -448,7 +633,6 @@ static int internal_verify(X509_STORE_CTX *ctx)
448 int (*cb)(); 633 int (*cb)();
449 634
450 cb=ctx->verify_cb; 635 cb=ctx->verify_cb;
451 if (cb == NULL) cb=null_callback;
452 636
453 n=sk_X509_num(ctx->chain); 637 n=sk_X509_num(ctx->chain);
454 ctx->error_depth=n-1; 638 ctx->error_depth=n-1;
@@ -491,6 +675,13 @@ static int internal_verify(X509_STORE_CTX *ctx)
491 if (!ok) goto end; 675 if (!ok) goto end;
492 } 676 }
493 if (X509_verify(xs,pkey) <= 0) 677 if (X509_verify(xs,pkey) <= 0)
678 /* XXX For the final trusted self-signed cert,
679 * this is a waste of time. That check should
680 * optional so that e.g. 'openssl x509' can be
681 * used to detect invalid self-signatures, but
682 * we don't verify again and again in SSL
683 * handshakes and the like once the cert has
684 * been declared trusted. */
494 { 685 {
495 ctx->error=X509_V_ERR_CERT_SIGNATURE_FAILURE; 686 ctx->error=X509_V_ERR_CERT_SIGNATURE_FAILURE;
496 ctx->current_cert=xs; 687 ctx->current_cert=xs;
@@ -539,8 +730,6 @@ static int internal_verify(X509_STORE_CTX *ctx)
539 if (!ok) goto end; 730 if (!ok) goto end;
540 } 731 }
541 732
542 /* CRL CHECK */
543
544 /* The last error (if any) is still in the error value */ 733 /* The last error (if any) is still in the error value */
545 ctx->current_cert=xs; 734 ctx->current_cert=xs;
546 ok=(*cb)(1,ctx); 735 ok=(*cb)(1,ctx);
@@ -648,14 +837,16 @@ ASN1_TIME *X509_gmtime_adj(ASN1_TIME *s, long adj)
648ASN1_TIME *X509_time_adj(ASN1_TIME *s, long adj, time_t *in_tm) 837ASN1_TIME *X509_time_adj(ASN1_TIME *s, long adj, time_t *in_tm)
649 { 838 {
650 time_t t; 839 time_t t;
840 int type = -1;
651 841
652 if (in_tm) t = *in_tm; 842 if (in_tm) t = *in_tm;
653 else time(&t); 843 else time(&t);
654 844
655 t+=adj; 845 t+=adj;
656 if (!s) return ASN1_TIME_set(s, t); 846 if (s) type = s->type;
657 if (s->type == V_ASN1_UTCTIME) return ASN1_UTCTIME_set(s,t); 847 if (type == V_ASN1_UTCTIME) return ASN1_UTCTIME_set(s,t);
658 return ASN1_GENERALIZEDTIME_set(s, t); 848 if (type == V_ASN1_GENERALIZEDTIME) return ASN1_GENERALIZEDTIME_set(s, t);
849 return ASN1_TIME_set(s, t);
659 } 850 }
660 851
661int X509_get_pubkey_parameters(EVP_PKEY *pkey, STACK_OF(X509) *chain) 852int X509_get_pubkey_parameters(EVP_PKEY *pkey, STACK_OF(X509) *chain)
@@ -702,12 +893,12 @@ int X509_get_pubkey_parameters(EVP_PKEY *pkey, STACK_OF(X509) *chain)
702 893
703int X509_STORE_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, 894int X509_STORE_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
704 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) 895 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
705 { 896 {
706 x509_store_ctx_num++; 897 /* This function is (usually) called only once, by
707 return CRYPTO_get_ex_new_index(x509_store_ctx_num-1, 898 * SSL_get_ex_data_X509_STORE_CTX_idx (ssl/ssl_cert.c). */
708 &x509_store_ctx_method, 899 return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509_STORE_CTX, argl, argp,
709 argl,argp,new_func,dup_func,free_func); 900 new_func, dup_func, free_func);
710 } 901 }
711 902
712int X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx, int idx, void *data) 903int X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx, int idx, void *data)
713 { 904 {
@@ -831,8 +1022,8 @@ int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose,
831 } 1022 }
832 } 1023 }
833 1024
834 if (purpose) ctx->purpose = purpose; 1025 if (purpose && !ctx->purpose) ctx->purpose = purpose;
835 if (trust) ctx->trust = trust; 1026 if (trust && !ctx->trust) ctx->trust = trust;
836 return 1; 1027 return 1;
837} 1028}
838 1029
@@ -840,7 +1031,12 @@ X509_STORE_CTX *X509_STORE_CTX_new(void)
840{ 1031{
841 X509_STORE_CTX *ctx; 1032 X509_STORE_CTX *ctx;
842 ctx = (X509_STORE_CTX *)OPENSSL_malloc(sizeof(X509_STORE_CTX)); 1033 ctx = (X509_STORE_CTX *)OPENSSL_malloc(sizeof(X509_STORE_CTX));
843 if (ctx) memset(ctx, 0, sizeof(X509_STORE_CTX)); 1034 if (!ctx)
1035 {
1036 X509err(X509_F_X509_STORE_CTX_NEW,ERR_R_MALLOC_FAILURE);
1037 return NULL;
1038 }
1039 memset(ctx, 0, sizeof(X509_STORE_CTX));
844 return ctx; 1040 return ctx;
845} 1041}
846 1042
@@ -850,7 +1046,7 @@ void X509_STORE_CTX_free(X509_STORE_CTX *ctx)
850 OPENSSL_free(ctx); 1046 OPENSSL_free(ctx);
851} 1047}
852 1048
853void X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, X509 *x509, 1049int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, X509 *x509,
854 STACK_OF(X509) *chain) 1050 STACK_OF(X509) *chain)
855 { 1051 {
856 ctx->ctx=store; 1052 ctx->ctx=store;
@@ -858,10 +1054,7 @@ void X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, X509 *x509,
858 ctx->cert=x509; 1054 ctx->cert=x509;
859 ctx->untrusted=chain; 1055 ctx->untrusted=chain;
860 ctx->last_untrusted=0; 1056 ctx->last_untrusted=0;
861 ctx->purpose=0;
862 ctx->trust=0;
863 ctx->check_time=0; 1057 ctx->check_time=0;
864 ctx->flags=0;
865 ctx->other_ctx=NULL; 1058 ctx->other_ctx=NULL;
866 ctx->valid=0; 1059 ctx->valid=0;
867 ctx->chain=NULL; 1060 ctx->chain=NULL;
@@ -870,12 +1063,80 @@ void X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, X509 *x509,
870 ctx->error_depth=0; 1063 ctx->error_depth=0;
871 ctx->current_cert=NULL; 1064 ctx->current_cert=NULL;
872 ctx->current_issuer=NULL; 1065 ctx->current_issuer=NULL;
873 ctx->check_issued = check_issued; 1066
874 ctx->get_issuer = X509_STORE_CTX_get1_issuer; 1067 /* Inherit callbacks and flags from X509_STORE if not set
875 ctx->verify_cb = store->verify_cb; 1068 * use defaults.
876 ctx->verify = store->verify; 1069 */
877 ctx->cleanup = 0; 1070
878 memset(&(ctx->ex_data),0,sizeof(CRYPTO_EX_DATA)); 1071
1072 if (store)
1073 {
1074 ctx->purpose=store->purpose;
1075 ctx->trust=store->trust;
1076 ctx->flags = store->flags;
1077 ctx->cleanup = store->cleanup;
1078 }
1079 else
1080 {
1081 ctx->purpose = 0;
1082 ctx->trust = 0;
1083 ctx->flags = 0;
1084 ctx->cleanup = 0;
1085 }
1086
1087 if (store && store->check_issued)
1088 ctx->check_issued = store->check_issued;
1089 else
1090 ctx->check_issued = check_issued;
1091
1092 if (store && store->get_issuer)
1093 ctx->get_issuer = store->get_issuer;
1094 else
1095 ctx->get_issuer = X509_STORE_CTX_get1_issuer;
1096
1097 if (store && store->verify_cb)
1098 ctx->verify_cb = store->verify_cb;
1099 else
1100 ctx->verify_cb = null_callback;
1101
1102 if (store && store->verify)
1103 ctx->verify = store->verify;
1104 else
1105 ctx->verify = internal_verify;
1106
1107 if (store && store->check_revocation)
1108 ctx->check_revocation = store->check_revocation;
1109 else
1110 ctx->check_revocation = check_revocation;
1111
1112 if (store && store->get_crl)
1113 ctx->get_crl = store->get_crl;
1114 else
1115 ctx->get_crl = get_crl;
1116
1117 if (store && store->check_crl)
1118 ctx->check_crl = store->check_crl;
1119 else
1120 ctx->check_crl = check_crl;
1121
1122 if (store && store->cert_crl)
1123 ctx->cert_crl = store->cert_crl;
1124 else
1125 ctx->cert_crl = cert_crl;
1126
1127
1128 /* This memset() can't make any sense anyway, so it's removed. As
1129 * X509_STORE_CTX_cleanup does a proper "free" on the ex_data, we put a
1130 * corresponding "new" here and remove this bogus initialisation. */
1131 /* memset(&(ctx->ex_data),0,sizeof(CRYPTO_EX_DATA)); */
1132 if(!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_X509_STORE_CTX, ctx,
1133 &(ctx->ex_data)))
1134 {
1135 OPENSSL_free(ctx);
1136 X509err(X509_F_X509_STORE_CTX_INIT,ERR_R_MALLOC_FAILURE);
1137 return 0;
1138 }
1139 return 1;
879 } 1140 }
880 1141
881/* Set alternative lookup method: just a STACK of trusted certificates. 1142/* Set alternative lookup method: just a STACK of trusted certificates.
@@ -896,7 +1157,7 @@ void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx)
896 sk_X509_pop_free(ctx->chain,X509_free); 1157 sk_X509_pop_free(ctx->chain,X509_free);
897 ctx->chain=NULL; 1158 ctx->chain=NULL;
898 } 1159 }
899 CRYPTO_free_ex_data(x509_store_ctx_method,ctx,&(ctx->ex_data)); 1160 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_X509_STORE_CTX, ctx, &(ctx->ex_data));
900 memset(&ctx->ex_data,0,sizeof(CRYPTO_EX_DATA)); 1161 memset(&ctx->ex_data,0,sizeof(CRYPTO_EX_DATA));
901 } 1162 }
902 1163
@@ -911,6 +1172,12 @@ void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, long flags, time_t t)
911 ctx->flags |= X509_V_FLAG_USE_CHECK_TIME; 1172 ctx->flags |= X509_V_FLAG_USE_CHECK_TIME;
912 } 1173 }
913 1174
1175void X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx,
1176 int (*verify_cb)(int, X509_STORE_CTX *))
1177 {
1178 ctx->verify_cb=verify_cb;
1179 }
1180
914IMPLEMENT_STACK_OF(X509) 1181IMPLEMENT_STACK_OF(X509)
915IMPLEMENT_ASN1_SET_OF(X509) 1182IMPLEMENT_ASN1_SET_OF(X509)
916 1183
diff --git a/src/lib/libcrypto/x509/x509_vfy.h b/src/lib/libcrypto/x509/x509_vfy.h
index e289d5309a..f0be21f452 100644
--- a/src/lib/libcrypto/x509/x509_vfy.h
+++ b/src/lib/libcrypto/x509/x509_vfy.h
@@ -65,11 +65,12 @@
65#ifndef HEADER_X509_VFY_H 65#ifndef HEADER_X509_VFY_H
66#define HEADER_X509_VFY_H 66#define HEADER_X509_VFY_H
67 67
68#ifndef NO_LHASH 68#ifndef OPENSSL_NO_LHASH
69#include <openssl/lhash.h> 69#include <openssl/lhash.h>
70#endif 70#endif
71#include <openssl/bio.h> 71#include <openssl/bio.h>
72#include <openssl/crypto.h> 72#include <openssl/crypto.h>
73#include <openssl/symhacks.h>
73 74
74#ifdef __cplusplus 75#ifdef __cplusplus
75extern "C" { 76extern "C" {
@@ -154,12 +155,10 @@ typedef struct x509_lookup_method_st
154 X509_OBJECT *ret); 155 X509_OBJECT *ret);
155 } X509_LOOKUP_METHOD; 156 } X509_LOOKUP_METHOD;
156 157
157typedef struct x509_store_ctx_st X509_STORE_CTX;
158
159/* This is used to hold everything. It is used for all certificate 158/* This is used to hold everything. It is used for all certificate
160 * validation. Once we have a certificate chain, the 'verify' 159 * validation. Once we have a certificate chain, the 'verify'
161 * function is then called to actually check the cert chain. */ 160 * function is then called to actually check the cert chain. */
162typedef struct x509_store_st 161struct x509_store_st
163 { 162 {
164 /* The following is a cache of trusted certs */ 163 /* The following is a cache of trusted certs */
165 int cache; /* if true, stash any hits */ 164 int cache; /* if true, stash any hits */
@@ -167,13 +166,29 @@ typedef struct x509_store_st
167 166
168 /* These are external lookup methods */ 167 /* These are external lookup methods */
169 STACK_OF(X509_LOOKUP) *get_cert_methods; 168 STACK_OF(X509_LOOKUP) *get_cert_methods;
169
170 /* The following fields are not used by X509_STORE but are
171 * inherited by X509_STORE_CTX when it is initialised.
172 */
173
174 unsigned long flags; /* Various verify flags */
175 int purpose;
176 int trust;
177 /* Callbacks for various operations */
170 int (*verify)(X509_STORE_CTX *ctx); /* called to verify a certificate */ 178 int (*verify)(X509_STORE_CTX *ctx); /* called to verify a certificate */
171 int (*verify_cb)(int ok,X509_STORE_CTX *ctx); /* error callback */ 179 int (*verify_cb)(int ok,X509_STORE_CTX *ctx); /* error callback */
180 int (*get_issuer)(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); /* get issuers cert from ctx */
181 int (*check_issued)(X509_STORE_CTX *ctx, X509 *x, X509 *issuer); /* check issued */
182 int (*check_revocation)(X509_STORE_CTX *ctx); /* Check revocation status of chain */
183 int (*get_crl)(X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); /* retrieve CRL */
184 int (*check_crl)(X509_STORE_CTX *ctx, X509_CRL *crl); /* Check CRL validity */
185 int (*cert_crl)(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); /* Check certificate against CRL */
186 int (*cleanup)(X509_STORE_CTX *ctx);
172 187
173 CRYPTO_EX_DATA ex_data; 188 CRYPTO_EX_DATA ex_data;
174 int references; 189 int references;
175 int depth; /* how deep to look (still unused -- X509_STORE_CTX's depth is used) */ 190 int depth; /* how deep to look (still unused -- X509_STORE_CTX's depth is used) */
176 } X509_STORE; 191 } /* X509_STORE */;
177 192
178#define X509_STORE_set_depth(ctx,d) ((ctx)->depth=(d)) 193#define X509_STORE_set_depth(ctx,d) ((ctx)->depth=(d))
179 194
@@ -189,7 +204,7 @@ struct x509_lookup_st
189 char *method_data; /* method data */ 204 char *method_data; /* method data */
190 205
191 X509_STORE *store_ctx; /* who owns us */ 206 X509_STORE *store_ctx; /* who owns us */
192 }; 207 } /* X509_LOOKUP */;
193 208
194/* This is a used when verifying cert chains. Since the 209/* This is a used when verifying cert chains. Since the
195 * gathering of the cert chain can take some time (and have to be 210 * gathering of the cert chain can take some time (and have to be
@@ -213,6 +228,10 @@ struct x509_store_ctx_st /* X509_STORE_CTX */
213 int (*verify_cb)(int ok,X509_STORE_CTX *ctx); /* error callback */ 228 int (*verify_cb)(int ok,X509_STORE_CTX *ctx); /* error callback */
214 int (*get_issuer)(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); /* get issuers cert from ctx */ 229 int (*get_issuer)(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); /* get issuers cert from ctx */
215 int (*check_issued)(X509_STORE_CTX *ctx, X509 *x, X509 *issuer); /* check issued */ 230 int (*check_issued)(X509_STORE_CTX *ctx, X509 *x, X509 *issuer); /* check issued */
231 int (*check_revocation)(X509_STORE_CTX *ctx); /* Check revocation status of chain */
232 int (*get_crl)(X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); /* retrieve CRL */
233 int (*check_crl)(X509_STORE_CTX *ctx, X509_CRL *crl); /* Check CRL validity */
234 int (*cert_crl)(X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); /* Check certificate against CRL */
216 int (*cleanup)(X509_STORE_CTX *ctx); 235 int (*cleanup)(X509_STORE_CTX *ctx);
217 236
218 /* The following is built up */ 237 /* The following is built up */
@@ -226,9 +245,10 @@ struct x509_store_ctx_st /* X509_STORE_CTX */
226 int error; 245 int error;
227 X509 *current_cert; 246 X509 *current_cert;
228 X509 *current_issuer; /* cert currently being tested as valid issuer */ 247 X509 *current_issuer; /* cert currently being tested as valid issuer */
248 X509_CRL *current_crl; /* current CRL */
229 249
230 CRYPTO_EX_DATA ex_data; 250 CRYPTO_EX_DATA ex_data;
231 }; 251 } /* X509_STORE_CTX */;
232 252
233#define X509_STORE_CTX_set_depth(ctx,d) ((ctx)->depth=(d)) 253#define X509_STORE_CTX_set_depth(ctx,d) ((ctx)->depth=(d))
234 254
@@ -282,6 +302,9 @@ struct x509_store_ctx_st /* X509_STORE_CTX */
282#define X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH 31 302#define X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH 31
283#define X509_V_ERR_KEYUSAGE_NO_CERTSIGN 32 303#define X509_V_ERR_KEYUSAGE_NO_CERTSIGN 32
284 304
305#define X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER 33
306#define X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION 34
307
285/* The application is not happy */ 308/* The application is not happy */
286#define X509_V_ERR_APPLICATION_VERIFICATION 50 309#define X509_V_ERR_APPLICATION_VERIFICATION 50
287 310
@@ -289,21 +312,9 @@ struct x509_store_ctx_st /* X509_STORE_CTX */
289 312
290#define X509_V_FLAG_CB_ISSUER_CHECK 0x1 /* Send issuer+subject checks to verify_cb */ 313#define X509_V_FLAG_CB_ISSUER_CHECK 0x1 /* Send issuer+subject checks to verify_cb */
291#define X509_V_FLAG_USE_CHECK_TIME 0x2 /* Use check time instead of current time */ 314#define X509_V_FLAG_USE_CHECK_TIME 0x2 /* Use check time instead of current time */
292 315#define X509_V_FLAG_CRL_CHECK 0x4 /* Lookup CRLs */
293 /* These functions are being redefined in another directory, 316#define X509_V_FLAG_CRL_CHECK_ALL 0x8 /* Lookup CRLs for whole chain */
294 and clash when the linker is case-insensitive, so let's 317#define X509_V_FLAG_IGNORE_CRITICAL 0x10 /* Ignore unhandled critical extensions */
295 hide them a little, by giving them an extra 'o' at the
296 beginning of the name... */
297#ifdef VMS
298#undef X509v3_cleanup_extensions
299#define X509v3_cleanup_extensions oX509v3_cleanup_extensions
300#undef X509v3_add_extension
301#define X509v3_add_extension oX509v3_add_extension
302#undef X509v3_add_netscape_extensions
303#define X509v3_add_netscape_extensions oX509v3_add_netscape_extensions
304#undef X509v3_add_standard_extensions
305#define X509v3_add_standard_extensions oX509v3_add_standard_extensions
306#endif
307 318
308int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type, 319int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type,
309 X509_NAME *name); 320 X509_NAME *name);
@@ -314,12 +325,16 @@ void X509_OBJECT_free_contents(X509_OBJECT *a);
314X509_STORE *X509_STORE_new(void ); 325X509_STORE *X509_STORE_new(void );
315void X509_STORE_free(X509_STORE *v); 326void X509_STORE_free(X509_STORE *v);
316 327
328void X509_STORE_set_flags(X509_STORE *ctx, long flags);
329int X509_STORE_set_purpose(X509_STORE *ctx, int purpose);
330int X509_STORE_set_trust(X509_STORE *ctx, int trust);
331
317X509_STORE_CTX *X509_STORE_CTX_new(void); 332X509_STORE_CTX *X509_STORE_CTX_new(void);
318 333
319int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); 334int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x);
320 335
321void X509_STORE_CTX_free(X509_STORE_CTX *ctx); 336void X509_STORE_CTX_free(X509_STORE_CTX *ctx);
322void X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, 337int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store,
323 X509 *x509, STACK_OF(X509) *chain); 338 X509 *x509, STACK_OF(X509) *chain);
324void X509_STORE_CTX_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk); 339void X509_STORE_CTX_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk);
325void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx); 340void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx);
@@ -338,7 +353,7 @@ int X509_STORE_get_by_subject(X509_STORE_CTX *vs,int type,X509_NAME *name,
338int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, 353int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc,
339 long argl, char **ret); 354 long argl, char **ret);
340 355
341#ifndef NO_STDIO 356#ifndef OPENSSL_NO_STDIO
342int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type); 357int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type);
343int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type); 358int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type);
344int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type); 359int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type);
@@ -358,7 +373,7 @@ int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, int type, char *str,
358 int len, X509_OBJECT *ret); 373 int len, X509_OBJECT *ret);
359int X509_LOOKUP_shutdown(X509_LOOKUP *ctx); 374int X509_LOOKUP_shutdown(X509_LOOKUP *ctx);
360 375
361#ifndef NO_STDIO 376#ifndef OPENSSL_NO_STDIO
362int X509_STORE_load_locations (X509_STORE *ctx, 377int X509_STORE_load_locations (X509_STORE *ctx,
363 const char *file, const char *dir); 378 const char *file, const char *dir);
364int X509_STORE_set_default_paths(X509_STORE *ctx); 379int X509_STORE_set_default_paths(X509_STORE *ctx);
@@ -382,6 +397,8 @@ int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose,
382 int purpose, int trust); 397 int purpose, int trust);
383void X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, long flags); 398void X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, long flags);
384void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, long flags, time_t t); 399void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, long flags, time_t t);
400void X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx,
401 int (*verify_cb)(int, X509_STORE_CTX *));
385 402
386#ifdef __cplusplus 403#ifdef __cplusplus
387} 404}
diff --git a/src/lib/libcrypto/x509/x509cset.c b/src/lib/libcrypto/x509/x509cset.c
new file mode 100644
index 0000000000..6cac440ea9
--- /dev/null
+++ b/src/lib/libcrypto/x509/x509cset.c
@@ -0,0 +1,169 @@
1/* crypto/x509/x509cset.c */
2/* Written by Dr Stephen N 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 <stdio.h>
60#include "cryptlib.h"
61#include <openssl/asn1.h>
62#include <openssl/objects.h>
63#include <openssl/evp.h>
64#include <openssl/x509.h>
65
66int X509_CRL_set_version(X509_CRL *x, long version)
67 {
68 if (x == NULL) return(0);
69 if (x->crl->version == NULL)
70 {
71 if ((x->crl->version=M_ASN1_INTEGER_new()) == NULL)
72 return(0);
73 }
74 return(ASN1_INTEGER_set(x->crl->version,version));
75 }
76
77int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name)
78 {
79 if ((x == NULL) || (x->crl == NULL)) return(0);
80 return(X509_NAME_set(&x->crl->issuer,name));
81 }
82
83
84int X509_CRL_set_lastUpdate(X509_CRL *x, ASN1_TIME *tm)
85 {
86 ASN1_TIME *in;
87
88 if (x == NULL) return(0);
89 in=x->crl->lastUpdate;
90 if (in != tm)
91 {
92 in=M_ASN1_TIME_dup(tm);
93 if (in != NULL)
94 {
95 M_ASN1_TIME_free(x->crl->lastUpdate);
96 x->crl->lastUpdate=in;
97 }
98 }
99 return(in != NULL);
100 }
101
102int X509_CRL_set_nextUpdate(X509_CRL *x, ASN1_TIME *tm)
103 {
104 ASN1_TIME *in;
105
106 if (x == NULL) return(0);
107 in=x->crl->nextUpdate;
108 if (in != tm)
109 {
110 in=M_ASN1_TIME_dup(tm);
111 if (in != NULL)
112 {
113 M_ASN1_TIME_free(x->crl->nextUpdate);
114 x->crl->nextUpdate=in;
115 }
116 }
117 return(in != NULL);
118 }
119
120int X509_CRL_sort(X509_CRL *c)
121 {
122 int i;
123 X509_REVOKED *r;
124 /* sort the data so it will be written in serial
125 * number order */
126 sk_X509_REVOKED_sort(c->crl->revoked);
127 for (i=0; i<sk_X509_REVOKED_num(c->crl->revoked); i++)
128 {
129 r=sk_X509_REVOKED_value(c->crl->revoked,i);
130 r->sequence=i;
131 }
132 return 1;
133 }
134
135int X509_REVOKED_set_revocationDate(X509_REVOKED *x, ASN1_TIME *tm)
136 {
137 ASN1_TIME *in;
138
139 if (x == NULL) return(0);
140 in=x->revocationDate;
141 if (in != tm)
142 {
143 in=M_ASN1_TIME_dup(tm);
144 if (in != NULL)
145 {
146 M_ASN1_TIME_free(x->revocationDate);
147 x->revocationDate=in;
148 }
149 }
150 return(in != NULL);
151 }
152
153int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial)
154 {
155 ASN1_INTEGER *in;
156
157 if (x == NULL) return(0);
158 in=x->serialNumber;
159 if (in != serial)
160 {
161 in=M_ASN1_INTEGER_dup(serial);
162 if (in != NULL)
163 {
164 M_ASN1_INTEGER_free(x->serialNumber);
165 x->serialNumber=in;
166 }
167 }
168 return(in != NULL);
169 }
diff --git a/src/lib/libcrypto/x509/x509spki.c b/src/lib/libcrypto/x509/x509spki.c
index fd0a534d88..4c3af946ec 100644
--- a/src/lib/libcrypto/x509/x509spki.c
+++ b/src/lib/libcrypto/x509/x509spki.c
@@ -59,7 +59,6 @@
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/x509.h> 61#include <openssl/x509.h>
62#include <openssl/asn1_mac.h>
63 62
64int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey) 63int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey)
65{ 64{
diff --git a/src/lib/libcrypto/x509/x_all.c b/src/lib/libcrypto/x509/x_all.c
index 9bd6e2a39b..fb5015cd4d 100644
--- a/src/lib/libcrypto/x509/x_all.c
+++ b/src/lib/libcrypto/x509/x_all.c
@@ -67,224 +67,159 @@
67 67
68int X509_verify(X509 *a, EVP_PKEY *r) 68int X509_verify(X509 *a, EVP_PKEY *r)
69 { 69 {
70 return(ASN1_verify((int (*)())i2d_X509_CINF,a->sig_alg, 70 return(ASN1_item_verify(ASN1_ITEM_rptr(X509_CINF),a->sig_alg,
71 a->signature,(char *)a->cert_info,r)); 71 a->signature,a->cert_info,r));
72 } 72 }
73 73
74int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r) 74int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r)
75 { 75 {
76 return( ASN1_verify((int (*)())i2d_X509_REQ_INFO, 76 return( ASN1_item_verify(ASN1_ITEM_rptr(X509_REQ_INFO),
77 a->sig_alg,a->signature,(char *)a->req_info,r)); 77 a->sig_alg,a->signature,a->req_info,r));
78 } 78 }
79 79
80int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r) 80int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r)
81 { 81 {
82 return(ASN1_verify((int (*)())i2d_X509_CRL_INFO, 82 return(ASN1_item_verify(ASN1_ITEM_rptr(X509_CRL_INFO),
83 a->sig_alg, a->signature,(char *)a->crl,r)); 83 a->sig_alg, a->signature,a->crl,r));
84 } 84 }
85 85
86int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r) 86int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r)
87 { 87 {
88 return(ASN1_verify((int (*)())i2d_NETSCAPE_SPKAC, 88 return(ASN1_item_verify(ASN1_ITEM_rptr(NETSCAPE_SPKAC),
89 a->sig_algor,a->signature, (char *)a->spkac,r)); 89 a->sig_algor,a->signature,a->spkac,r));
90 } 90 }
91 91
92int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md) 92int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md)
93 { 93 {
94 return(ASN1_sign((int (*)())i2d_X509_CINF, x->cert_info->signature, 94 return(ASN1_item_sign(ASN1_ITEM_rptr(X509_CINF), x->cert_info->signature,
95 x->sig_alg, x->signature, (char *)x->cert_info,pkey,md)); 95 x->sig_alg, x->signature, x->cert_info,pkey,md));
96 } 96 }
97 97
98int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md) 98int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md)
99 { 99 {
100 return(ASN1_sign((int (*)())i2d_X509_REQ_INFO,x->sig_alg, NULL, 100 return(ASN1_item_sign(ASN1_ITEM_rptr(X509_REQ_INFO),x->sig_alg, NULL,
101 x->signature, (char *)x->req_info,pkey,md)); 101 x->signature, x->req_info,pkey,md));
102 } 102 }
103 103
104int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md) 104int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md)
105 { 105 {
106 return(ASN1_sign((int (*)())i2d_X509_CRL_INFO,x->crl->sig_alg, 106 return(ASN1_item_sign(ASN1_ITEM_rptr(X509_CRL_INFO),x->crl->sig_alg,
107 x->sig_alg, x->signature, (char *)x->crl,pkey,md)); 107 x->sig_alg, x->signature, x->crl,pkey,md));
108 } 108 }
109 109
110int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md) 110int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md)
111 { 111 {
112 return(ASN1_sign((int (*)())i2d_NETSCAPE_SPKAC, x->sig_algor,NULL, 112 return(ASN1_item_sign(ASN1_ITEM_rptr(NETSCAPE_SPKAC), x->sig_algor,NULL,
113 x->signature, (char *)x->spkac,pkey,md)); 113 x->signature, x->spkac,pkey,md));
114 } 114 }
115 115
116X509_ATTRIBUTE *X509_ATTRIBUTE_dup(X509_ATTRIBUTE *xa) 116#ifndef OPENSSL_NO_FP_API
117 {
118 return((X509_ATTRIBUTE *)ASN1_dup((int (*)())i2d_X509_ATTRIBUTE,
119 (char *(*)())d2i_X509_ATTRIBUTE,(char *)xa));
120 }
121
122X509 *X509_dup(X509 *x509)
123 {
124 return((X509 *)ASN1_dup((int (*)())i2d_X509,
125 (char *(*)())d2i_X509,(char *)x509));
126 }
127
128X509_EXTENSION *X509_EXTENSION_dup(X509_EXTENSION *ex)
129 {
130 return((X509_EXTENSION *)ASN1_dup(
131 (int (*)())i2d_X509_EXTENSION,
132 (char *(*)())d2i_X509_EXTENSION,(char *)ex));
133 }
134
135#ifndef NO_FP_API
136X509 *d2i_X509_fp(FILE *fp, X509 **x509) 117X509 *d2i_X509_fp(FILE *fp, X509 **x509)
137 { 118 {
138 return((X509 *)ASN1_d2i_fp((char *(*)())X509_new, 119 return ASN1_item_d2i_fp(ASN1_ITEM_rptr(X509), fp, x509);
139 (char *(*)())d2i_X509, (fp),(unsigned char **)(x509)));
140 } 120 }
141 121
142int i2d_X509_fp(FILE *fp, X509 *x509) 122int i2d_X509_fp(FILE *fp, X509 *x509)
143 { 123 {
144 return(ASN1_i2d_fp(i2d_X509,fp,(unsigned char *)x509)); 124 return ASN1_item_i2d_fp(ASN1_ITEM_rptr(X509), fp, x509);
145 } 125 }
146#endif 126#endif
147 127
148X509 *d2i_X509_bio(BIO *bp, X509 **x509) 128X509 *d2i_X509_bio(BIO *bp, X509 **x509)
149 { 129 {
150 return((X509 *)ASN1_d2i_bio((char *(*)())X509_new, 130 return ASN1_item_d2i_bio(ASN1_ITEM_rptr(X509), bp, x509);
151 (char *(*)())d2i_X509, (bp),(unsigned char **)(x509)));
152 } 131 }
153 132
154int i2d_X509_bio(BIO *bp, X509 *x509) 133int i2d_X509_bio(BIO *bp, X509 *x509)
155 { 134 {
156 return(ASN1_i2d_bio(i2d_X509,bp,(unsigned char *)x509)); 135 return ASN1_item_i2d_bio(ASN1_ITEM_rptr(X509), bp, x509);
157 }
158
159X509_CRL *X509_CRL_dup(X509_CRL *crl)
160 {
161 return((X509_CRL *)ASN1_dup((int (*)())i2d_X509_CRL,
162 (char *(*)())d2i_X509_CRL,(char *)crl));
163 } 136 }
164 137
165#ifndef NO_FP_API 138#ifndef OPENSSL_NO_FP_API
166X509_CRL *d2i_X509_CRL_fp(FILE *fp, X509_CRL **crl) 139X509_CRL *d2i_X509_CRL_fp(FILE *fp, X509_CRL **crl)
167 { 140 {
168 return((X509_CRL *)ASN1_d2i_fp((char *(*)()) 141 return ASN1_item_d2i_fp(ASN1_ITEM_rptr(X509_CRL), fp, crl);
169 X509_CRL_new,(char *(*)())d2i_X509_CRL, (fp),
170 (unsigned char **)(crl)));
171 } 142 }
172 143
173int i2d_X509_CRL_fp(FILE *fp, X509_CRL *crl) 144int i2d_X509_CRL_fp(FILE *fp, X509_CRL *crl)
174 { 145 {
175 return(ASN1_i2d_fp(i2d_X509_CRL,fp,(unsigned char *)crl)); 146 return ASN1_item_i2d_fp(ASN1_ITEM_rptr(X509_CRL), fp, crl);
176 } 147 }
177#endif 148#endif
178 149
179X509_CRL *d2i_X509_CRL_bio(BIO *bp, X509_CRL **crl) 150X509_CRL *d2i_X509_CRL_bio(BIO *bp, X509_CRL **crl)
180 { 151 {
181 return((X509_CRL *)ASN1_d2i_bio((char *(*)()) 152 return ASN1_item_d2i_bio(ASN1_ITEM_rptr(X509_CRL), bp, crl);
182 X509_CRL_new,(char *(*)())d2i_X509_CRL, (bp),
183 (unsigned char **)(crl)));
184 } 153 }
185 154
186int i2d_X509_CRL_bio(BIO *bp, X509_CRL *crl) 155int i2d_X509_CRL_bio(BIO *bp, X509_CRL *crl)
187 { 156 {
188 return(ASN1_i2d_bio(i2d_X509_CRL,bp,(unsigned char *)crl)); 157 return ASN1_item_i2d_bio(ASN1_ITEM_rptr(X509_CRL), bp, crl);
189 }
190
191PKCS7 *PKCS7_dup(PKCS7 *p7)
192 {
193 return((PKCS7 *)ASN1_dup((int (*)())i2d_PKCS7,
194 (char *(*)())d2i_PKCS7,(char *)p7));
195 } 158 }
196 159
197#ifndef NO_FP_API 160#ifndef OPENSSL_NO_FP_API
198PKCS7 *d2i_PKCS7_fp(FILE *fp, PKCS7 **p7) 161PKCS7 *d2i_PKCS7_fp(FILE *fp, PKCS7 **p7)
199 { 162 {
200 return((PKCS7 *)ASN1_d2i_fp((char *(*)()) 163 return ASN1_item_d2i_fp(ASN1_ITEM_rptr(PKCS7), fp, p7);
201 PKCS7_new,(char *(*)())d2i_PKCS7, (fp),
202 (unsigned char **)(p7)));
203 } 164 }
204 165
205int i2d_PKCS7_fp(FILE *fp, PKCS7 *p7) 166int i2d_PKCS7_fp(FILE *fp, PKCS7 *p7)
206 { 167 {
207 return(ASN1_i2d_fp(i2d_PKCS7,fp,(unsigned char *)p7)); 168 return ASN1_item_i2d_fp(ASN1_ITEM_rptr(PKCS7), fp, p7);
208 } 169 }
209#endif 170#endif
210 171
211PKCS7 *d2i_PKCS7_bio(BIO *bp, PKCS7 **p7) 172PKCS7 *d2i_PKCS7_bio(BIO *bp, PKCS7 **p7)
212 { 173 {
213 return((PKCS7 *)ASN1_d2i_bio((char *(*)()) 174 return ASN1_item_d2i_bio(ASN1_ITEM_rptr(PKCS7), bp, p7);
214 PKCS7_new,(char *(*)())d2i_PKCS7, (bp),
215 (unsigned char **)(p7)));
216 } 175 }
217 176
218int i2d_PKCS7_bio(BIO *bp, PKCS7 *p7) 177int i2d_PKCS7_bio(BIO *bp, PKCS7 *p7)
219 { 178 {
220 return(ASN1_i2d_bio(i2d_PKCS7,bp,(unsigned char *)p7)); 179 return ASN1_item_i2d_bio(ASN1_ITEM_rptr(PKCS7), bp, p7);
221 } 180 }
222 181
223X509_REQ *X509_REQ_dup(X509_REQ *req) 182#ifndef OPENSSL_NO_FP_API
224 {
225 return((X509_REQ *)ASN1_dup((int (*)())i2d_X509_REQ,
226 (char *(*)())d2i_X509_REQ,(char *)req));
227 }
228
229#ifndef NO_FP_API
230X509_REQ *d2i_X509_REQ_fp(FILE *fp, X509_REQ **req) 183X509_REQ *d2i_X509_REQ_fp(FILE *fp, X509_REQ **req)
231 { 184 {
232 return((X509_REQ *)ASN1_d2i_fp((char *(*)()) 185 return ASN1_item_d2i_fp(ASN1_ITEM_rptr(X509_REQ), fp, req);
233 X509_REQ_new, (char *(*)())d2i_X509_REQ, (fp),
234 (unsigned char **)(req)));
235 } 186 }
236 187
237int i2d_X509_REQ_fp(FILE *fp, X509_REQ *req) 188int i2d_X509_REQ_fp(FILE *fp, X509_REQ *req)
238 { 189 {
239 return(ASN1_i2d_fp(i2d_X509_REQ,fp,(unsigned char *)req)); 190 return ASN1_item_i2d_fp(ASN1_ITEM_rptr(X509_REQ), fp, req);
240 } 191 }
241#endif 192#endif
242 193
243X509_REQ *d2i_X509_REQ_bio(BIO *bp, X509_REQ **req) 194X509_REQ *d2i_X509_REQ_bio(BIO *bp, X509_REQ **req)
244 { 195 {
245 return((X509_REQ *)ASN1_d2i_bio((char *(*)()) 196 return ASN1_item_d2i_bio(ASN1_ITEM_rptr(X509_REQ), bp, req);
246 X509_REQ_new, (char *(*)())d2i_X509_REQ, (bp),
247 (unsigned char **)(req)));
248 } 197 }
249 198
250int i2d_X509_REQ_bio(BIO *bp, X509_REQ *req) 199int i2d_X509_REQ_bio(BIO *bp, X509_REQ *req)
251 { 200 {
252 return(ASN1_i2d_bio(i2d_X509_REQ,bp,(unsigned char *)req)); 201 return ASN1_item_i2d_bio(ASN1_ITEM_rptr(X509_REQ), bp, req);
253 }
254
255#ifndef NO_RSA
256RSA *RSAPublicKey_dup(RSA *rsa)
257 {
258 return((RSA *)ASN1_dup((int (*)())i2d_RSAPublicKey,
259 (char *(*)())d2i_RSAPublicKey,(char *)rsa));
260 } 202 }
261 203
262RSA *RSAPrivateKey_dup(RSA *rsa) 204#ifndef OPENSSL_NO_RSA
263 {
264 return((RSA *)ASN1_dup((int (*)())i2d_RSAPrivateKey,
265 (char *(*)())d2i_RSAPrivateKey,(char *)rsa));
266 }
267 205
268#ifndef NO_FP_API 206#ifndef OPENSSL_NO_FP_API
269RSA *d2i_RSAPrivateKey_fp(FILE *fp, RSA **rsa) 207RSA *d2i_RSAPrivateKey_fp(FILE *fp, RSA **rsa)
270 { 208 {
271 return((RSA *)ASN1_d2i_fp((char *(*)()) 209 return ASN1_item_d2i_fp(ASN1_ITEM_rptr(RSAPrivateKey), fp, rsa);
272 RSA_new,(char *(*)())d2i_RSAPrivateKey, (fp),
273 (unsigned char **)(rsa)));
274 } 210 }
275 211
276int i2d_RSAPrivateKey_fp(FILE *fp, RSA *rsa) 212int i2d_RSAPrivateKey_fp(FILE *fp, RSA *rsa)
277 { 213 {
278 return(ASN1_i2d_fp(i2d_RSAPrivateKey,fp,(unsigned char *)rsa)); 214 return ASN1_item_i2d_fp(ASN1_ITEM_rptr(RSAPrivateKey), fp, rsa);
279 } 215 }
280 216
281RSA *d2i_RSAPublicKey_fp(FILE *fp, RSA **rsa) 217RSA *d2i_RSAPublicKey_fp(FILE *fp, RSA **rsa)
282 { 218 {
283 return((RSA *)ASN1_d2i_fp((char *(*)()) 219 return ASN1_item_d2i_fp(ASN1_ITEM_rptr(RSAPublicKey), fp, rsa);
284 RSA_new,(char *(*)())d2i_RSAPublicKey, (fp),
285 (unsigned char **)(rsa)));
286 } 220 }
287 221
222
288RSA *d2i_RSA_PUBKEY_fp(FILE *fp, RSA **rsa) 223RSA *d2i_RSA_PUBKEY_fp(FILE *fp, RSA **rsa)
289 { 224 {
290 return((RSA *)ASN1_d2i_fp((char *(*)()) 225 return((RSA *)ASN1_d2i_fp((char *(*)())
@@ -294,7 +229,7 @@ RSA *d2i_RSA_PUBKEY_fp(FILE *fp, RSA **rsa)
294 229
295int i2d_RSAPublicKey_fp(FILE *fp, RSA *rsa) 230int i2d_RSAPublicKey_fp(FILE *fp, RSA *rsa)
296 { 231 {
297 return(ASN1_i2d_fp(i2d_RSAPublicKey,fp,(unsigned char *)rsa)); 232 return ASN1_item_i2d_fp(ASN1_ITEM_rptr(RSAPublicKey), fp, rsa);
298 } 233 }
299 234
300int i2d_RSA_PUBKEY_fp(FILE *fp, RSA *rsa) 235int i2d_RSA_PUBKEY_fp(FILE *fp, RSA *rsa)
@@ -305,23 +240,20 @@ int i2d_RSA_PUBKEY_fp(FILE *fp, RSA *rsa)
305 240
306RSA *d2i_RSAPrivateKey_bio(BIO *bp, RSA **rsa) 241RSA *d2i_RSAPrivateKey_bio(BIO *bp, RSA **rsa)
307 { 242 {
308 return((RSA *)ASN1_d2i_bio((char *(*)()) 243 return ASN1_item_d2i_bio(ASN1_ITEM_rptr(RSAPrivateKey), bp, rsa);
309 RSA_new,(char *(*)())d2i_RSAPrivateKey, (bp),
310 (unsigned char **)(rsa)));
311 } 244 }
312 245
313int i2d_RSAPrivateKey_bio(BIO *bp, RSA *rsa) 246int i2d_RSAPrivateKey_bio(BIO *bp, RSA *rsa)
314 { 247 {
315 return(ASN1_i2d_bio(i2d_RSAPrivateKey,bp,(unsigned char *)rsa)); 248 return ASN1_item_i2d_bio(ASN1_ITEM_rptr(RSAPrivateKey), bp, rsa);
316 } 249 }
317 250
318RSA *d2i_RSAPublicKey_bio(BIO *bp, RSA **rsa) 251RSA *d2i_RSAPublicKey_bio(BIO *bp, RSA **rsa)
319 { 252 {
320 return((RSA *)ASN1_d2i_bio((char *(*)()) 253 return ASN1_item_d2i_bio(ASN1_ITEM_rptr(RSAPublicKey), bp, rsa);
321 RSA_new,(char *(*)())d2i_RSAPublicKey, (bp),
322 (unsigned char **)(rsa)));
323 } 254 }
324 255
256
325RSA *d2i_RSA_PUBKEY_bio(BIO *bp, RSA **rsa) 257RSA *d2i_RSA_PUBKEY_bio(BIO *bp, RSA **rsa)
326 { 258 {
327 return((RSA *)ASN1_d2i_bio((char *(*)()) 259 return((RSA *)ASN1_d2i_bio((char *(*)())
@@ -331,7 +263,7 @@ RSA *d2i_RSA_PUBKEY_bio(BIO *bp, RSA **rsa)
331 263
332int i2d_RSAPublicKey_bio(BIO *bp, RSA *rsa) 264int i2d_RSAPublicKey_bio(BIO *bp, RSA *rsa)
333 { 265 {
334 return(ASN1_i2d_bio(i2d_RSAPublicKey,bp,(unsigned char *)rsa)); 266 return ASN1_item_i2d_bio(ASN1_ITEM_rptr(RSAPublicKey), bp, rsa);
335 } 267 }
336 268
337int i2d_RSA_PUBKEY_bio(BIO *bp, RSA *rsa) 269int i2d_RSA_PUBKEY_bio(BIO *bp, RSA *rsa)
@@ -340,8 +272,8 @@ int i2d_RSA_PUBKEY_bio(BIO *bp, RSA *rsa)
340 } 272 }
341#endif 273#endif
342 274
343#ifndef NO_DSA 275#ifndef OPENSSL_NO_DSA
344#ifndef NO_FP_API 276#ifndef OPENSSL_NO_FP_API
345DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa) 277DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa)
346 { 278 {
347 return((DSA *)ASN1_d2i_fp((char *(*)()) 279 return((DSA *)ASN1_d2i_fp((char *(*)())
@@ -393,57 +325,48 @@ int i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa)
393 325
394#endif 326#endif
395 327
396X509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn) 328int X509_pubkey_digest(const X509 *data, const EVP_MD *type, unsigned char *md,
397 { 329 unsigned int *len)
398 return((X509_ALGOR *)ASN1_dup((int (*)())i2d_X509_ALGOR,
399 (char *(*)())d2i_X509_ALGOR,(char *)xn));
400 }
401
402X509_NAME *X509_NAME_dup(X509_NAME *xn)
403 {
404 return((X509_NAME *)ASN1_dup((int (*)())i2d_X509_NAME,
405 (char *(*)())d2i_X509_NAME,(char *)xn));
406 }
407
408X509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne)
409 { 330 {
410 return((X509_NAME_ENTRY *)ASN1_dup((int (*)())i2d_X509_NAME_ENTRY, 331 ASN1_BIT_STRING *key;
411 (char *(*)())d2i_X509_NAME_ENTRY,(char *)ne)); 332 key = X509_get0_pubkey_bitstr(data);
333 if(!key) return 0;
334 return EVP_Digest(key->data, key->length, md, len, type, NULL);
412 } 335 }
413 336
414int X509_digest(const X509 *data, const EVP_MD *type, unsigned char *md, 337int X509_digest(const X509 *data, const EVP_MD *type, unsigned char *md,
415 unsigned int *len) 338 unsigned int *len)
416 { 339 {
417 return(ASN1_digest((int (*)())i2d_X509,type,(char *)data,md,len)); 340 return(ASN1_item_digest(ASN1_ITEM_rptr(X509),type,(char *)data,md,len));
418 } 341 }
419 342
420int X509_CRL_digest(const X509_CRL *data, const EVP_MD *type, unsigned char *md, 343int X509_CRL_digest(const X509_CRL *data, const EVP_MD *type, unsigned char *md,
421 unsigned int *len) 344 unsigned int *len)
422 { 345 {
423 return(ASN1_digest((int (*)())i2d_X509_CRL,type,(char *)data,md,len)); 346 return(ASN1_item_digest(ASN1_ITEM_rptr(X509_CRL),type,(char *)data,md,len));
424 } 347 }
425 348
426int X509_REQ_digest(const X509_REQ *data, const EVP_MD *type, unsigned char *md, 349int X509_REQ_digest(const X509_REQ *data, const EVP_MD *type, unsigned char *md,
427 unsigned int *len) 350 unsigned int *len)
428 { 351 {
429 return(ASN1_digest((int (*)())i2d_X509_REQ,type,(char *)data,md,len)); 352 return(ASN1_item_digest(ASN1_ITEM_rptr(X509_REQ),type,(char *)data,md,len));
430 } 353 }
431 354
432int X509_NAME_digest(const X509_NAME *data, const EVP_MD *type, unsigned char *md, 355int X509_NAME_digest(const X509_NAME *data, const EVP_MD *type, unsigned char *md,
433 unsigned int *len) 356 unsigned int *len)
434 { 357 {
435 return(ASN1_digest((int (*)())i2d_X509_NAME,type,(char *)data,md,len)); 358 return(ASN1_item_digest(ASN1_ITEM_rptr(X509_NAME),type,(char *)data,md,len));
436 } 359 }
437 360
438int PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data, const EVP_MD *type, 361int PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data, const EVP_MD *type,
439 unsigned char *md, unsigned int *len) 362 unsigned char *md, unsigned int *len)
440 { 363 {
441 return(ASN1_digest((int (*)())i2d_PKCS7_ISSUER_AND_SERIAL,type, 364 return(ASN1_item_digest(ASN1_ITEM_rptr(PKCS7_ISSUER_AND_SERIAL),type,
442 (char *)data,md,len)); 365 (char *)data,md,len));
443 } 366 }
444 367
445 368
446#ifndef NO_FP_API 369#ifndef OPENSSL_NO_FP_API
447X509_SIG *d2i_PKCS8_fp(FILE *fp, X509_SIG **p8) 370X509_SIG *d2i_PKCS8_fp(FILE *fp, X509_SIG **p8)
448 { 371 {
449 return((X509_SIG *)ASN1_d2i_fp((char *(*)())X509_SIG_new, 372 return((X509_SIG *)ASN1_d2i_fp((char *(*)())X509_SIG_new,
@@ -467,7 +390,7 @@ int i2d_PKCS8_bio(BIO *bp, X509_SIG *p8)
467 return(ASN1_i2d_bio(i2d_X509_SIG,bp,(unsigned char *)p8)); 390 return(ASN1_i2d_bio(i2d_X509_SIG,bp,(unsigned char *)p8));
468 } 391 }
469 392
470#ifndef NO_FP_API 393#ifndef OPENSSL_NO_FP_API
471PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, 394PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,
472 PKCS8_PRIV_KEY_INFO **p8inf) 395 PKCS8_PRIV_KEY_INFO **p8inf)
473 { 396 {
diff --git a/src/lib/libcrypto/x509v3/Makefile.ssl b/src/lib/libcrypto/x509v3/Makefile.ssl
index 236e13af4e..8620992280 100644
--- a/src/lib/libcrypto/x509v3/Makefile.ssl
+++ b/src/lib/libcrypto/x509v3/Makefile.ssl
@@ -5,13 +5,14 @@
5DIR= x509v3 5DIR= x509v3
6TOP= ../.. 6TOP= ../..
7CC= cc 7CC= cc
8INCLUDES= -I.. -I../../include 8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g 9CFLAG=-g
10INSTALL_PREFIX= 10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl 11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl 12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl 13MAKE= make -f Makefile.ssl
14MAKEDEPEND= $(TOP)/util/domd $(TOP) 14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
15MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
16AR= ar r 17AR= ar r
17 18
@@ -22,12 +23,14 @@ TEST=
22APPS= 23APPS=
23 24
24LIB=$(TOP)/libcrypto.a 25LIB=$(TOP)/libcrypto.a
25LIBSRC= v3_bcons.c v3_bitst.c v3_conf.c v3_extku.c v3_ia5.c \ 26LIBSRC= v3_bcons.c v3_bitst.c v3_conf.c v3_extku.c v3_ia5.c v3_lib.c \
26v3_lib.c v3_prn.c v3_utl.c v3err.c v3_genn.c v3_alt.c v3_skey.c v3_akey.c \ 27v3_prn.c v3_utl.c v3err.c v3_genn.c v3_alt.c v3_skey.c v3_akey.c v3_pku.c \
27v3_pku.c v3_int.c v3_enum.c v3_sxnet.c v3_cpols.c v3_crld.c v3_purp.c v3_info.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
28LIBOBJ= v3_bcons.o v3_bitst.o v3_conf.o v3_extku.o v3_ia5.o v3_lib.o \ 30LIBOBJ= v3_bcons.o v3_bitst.o v3_conf.o v3_extku.o v3_ia5.o v3_lib.o \
29v3_prn.o v3_utl.o v3err.o v3_genn.o v3_alt.o v3_skey.o v3_akey.o v3_pku.o \ 31v3_prn.o v3_utl.o v3err.o v3_genn.o v3_alt.o v3_skey.o v3_akey.o v3_pku.o \
30v3_int.o v3_enum.o v3_sxnet.o v3_cpols.o v3_crld.o v3_purp.o v3_info.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
31 34
32SRC= $(LIBSRC) 35SRC= $(LIBSRC)
33 36
@@ -43,8 +46,7 @@ all: lib
43 46
44lib: $(LIBOBJ) 47lib: $(LIBOBJ)
45 $(AR) $(LIB) $(LIBOBJ) 48 $(AR) $(LIB) $(LIBOBJ)
46 @echo You may get an error following this line. Please ignore. 49 $(RANLIB) $(LIB) || echo Never mind.
47 - $(RANLIB) $(LIB)
48 @touch lib 50 @touch lib
49 51
50files: 52files:
@@ -83,432 +85,336 @@ clean:
83 85
84# DO NOT DELETE THIS LINE -- make depend depends on it. 86# DO NOT DELETE THIS LINE -- make depend depends on it.
85 87
86v3_akey.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 88v3_akey.o: ../../e_os.h ../../include/openssl/asn1.h
87v3_akey.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h 89v3_akey.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
88v3_akey.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 90v3_akey.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
89v3_akey.o: ../../include/openssl/cast.h ../../include/openssl/conf.h 91v3_akey.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
90v3_akey.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
91v3_akey.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 92v3_akey.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
92v3_akey.o: ../../include/openssl/e_os.h ../../include/openssl/e_os.h
93v3_akey.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 93v3_akey.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
94v3_akey.o: ../../include/openssl/evp.h ../../include/openssl/idea.h 94v3_akey.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
95v3_akey.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h 95v3_akey.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
96v3_akey.o: ../../include/openssl/md4.h ../../include/openssl/md5.h 96v3_akey.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
97v3_akey.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h 97v3_akey.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
98v3_akey.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
99v3_akey.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
100v3_akey.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
101v3_akey.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
102v3_akey.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 98v3_akey.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
103v3_akey.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 99v3_akey.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
104v3_akey.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 100v3_akey.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
105v3_akey.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h 101v3_akey.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
106v3_akey.o: ../cryptlib.h 102v3_akey.o: ../cryptlib.h v3_akey.c
107v3_alt.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 103v3_akeya.o: ../../e_os.h ../../include/openssl/asn1.h
108v3_alt.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 104v3_akeya.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
109v3_alt.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 105v3_akeya.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
106v3_akeya.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
107v3_akeya.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
108v3_akeya.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
109v3_akeya.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
110v3_akeya.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
111v3_akeya.o: ../../include/openssl/opensslconf.h
112v3_akeya.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
113v3_akeya.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
114v3_akeya.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
115v3_akeya.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
116v3_akeya.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
117v3_akeya.o: ../../include/openssl/x509v3.h ../cryptlib.h v3_akeya.c
118v3_alt.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
119v3_alt.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
110v3_alt.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h 120v3_alt.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
111v3_alt.o: ../../include/openssl/des.h ../../include/openssl/dh.h 121v3_alt.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
112v3_alt.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h 122v3_alt.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
113v3_alt.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 123v3_alt.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
114v3_alt.o: ../../include/openssl/err.h ../../include/openssl/evp.h
115v3_alt.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
116v3_alt.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
117v3_alt.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
118v3_alt.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 124v3_alt.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
119v3_alt.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 125v3_alt.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
120v3_alt.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h 126v3_alt.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
121v3_alt.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 127v3_alt.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
122v3_alt.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 128v3_alt.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
123v3_alt.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 129v3_alt.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
124v3_alt.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 130v3_alt.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
125v3_alt.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 131v3_alt.o: ../cryptlib.h v3_alt.c
126v3_alt.o: ../../include/openssl/x509v3.h ../cryptlib.h 132v3_bcons.o: ../../e_os.h ../../include/openssl/asn1.h
127v3_bcons.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 133v3_bcons.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
128v3_bcons.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
129v3_bcons.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 134v3_bcons.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
130v3_bcons.o: ../../include/openssl/cast.h ../../include/openssl/conf.h 135v3_bcons.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
131v3_bcons.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
132v3_bcons.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 136v3_bcons.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
133v3_bcons.o: ../../include/openssl/e_os.h ../../include/openssl/e_os.h
134v3_bcons.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 137v3_bcons.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
135v3_bcons.o: ../../include/openssl/evp.h ../../include/openssl/idea.h 138v3_bcons.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
136v3_bcons.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h 139v3_bcons.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
137v3_bcons.o: ../../include/openssl/md4.h ../../include/openssl/md5.h 140v3_bcons.o: ../../include/openssl/opensslconf.h
138v3_bcons.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h 141v3_bcons.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
139v3_bcons.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 142v3_bcons.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
140v3_bcons.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 143v3_bcons.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
141v3_bcons.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 144v3_bcons.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
142v3_bcons.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 145v3_bcons.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
143v3_bcons.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 146v3_bcons.o: ../../include/openssl/x509v3.h ../cryptlib.h v3_bcons.c
144v3_bcons.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 147v3_bitst.o: ../../e_os.h ../../include/openssl/asn1.h
145v3_bcons.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 148v3_bitst.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
146v3_bcons.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h 149v3_bitst.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
147v3_bcons.o: ../cryptlib.h 150v3_bitst.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
148v3_bitst.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 151v3_bitst.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
149v3_bitst.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
150v3_bitst.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
151v3_bitst.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
152v3_bitst.o: ../../include/openssl/des.h ../../include/openssl/dh.h
153v3_bitst.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
154v3_bitst.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
155v3_bitst.o: ../../include/openssl/err.h ../../include/openssl/evp.h 152v3_bitst.o: ../../include/openssl/err.h ../../include/openssl/evp.h
156v3_bitst.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 153v3_bitst.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
157v3_bitst.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 154v3_bitst.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
158v3_bitst.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 155v3_bitst.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
159v3_bitst.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 156v3_bitst.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
160v3_bitst.o: ../../include/openssl/opensslconf.h 157v3_bitst.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
161v3_bitst.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 158v3_bitst.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
162v3_bitst.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 159v3_bitst.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
163v3_bitst.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 160v3_bitst.o: ../../include/openssl/x509v3.h ../cryptlib.h v3_bitst.c
164v3_bitst.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 161v3_conf.o: ../../e_os.h ../../include/openssl/asn1.h
165v3_bitst.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 162v3_conf.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
166v3_bitst.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 163v3_conf.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
167v3_bitst.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h 164v3_conf.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
168v3_bitst.o: ../cryptlib.h 165v3_conf.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
169v3_conf.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
170v3_conf.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
171v3_conf.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
172v3_conf.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
173v3_conf.o: ../../include/openssl/des.h ../../include/openssl/dh.h
174v3_conf.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
175v3_conf.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
176v3_conf.o: ../../include/openssl/err.h ../../include/openssl/evp.h 166v3_conf.o: ../../include/openssl/err.h ../../include/openssl/evp.h
177v3_conf.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 167v3_conf.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
178v3_conf.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 168v3_conf.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
179v3_conf.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 169v3_conf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
180v3_conf.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 170v3_conf.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
181v3_conf.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
182v3_conf.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
183v3_conf.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
184v3_conf.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
185v3_conf.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 171v3_conf.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
186v3_conf.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 172v3_conf.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
187v3_conf.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 173v3_conf.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
188v3_conf.o: ../../include/openssl/x509v3.h ../cryptlib.h 174v3_conf.o: ../../include/openssl/x509v3.h ../cryptlib.h v3_conf.c
189v3_cpols.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 175v3_cpols.o: ../../e_os.h ../../include/openssl/asn1.h
190v3_cpols.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h 176v3_cpols.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
191v3_cpols.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 177v3_cpols.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
192v3_cpols.o: ../../include/openssl/cast.h ../../include/openssl/conf.h 178v3_cpols.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
193v3_cpols.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
194v3_cpols.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 179v3_cpols.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
195v3_cpols.o: ../../include/openssl/e_os.h ../../include/openssl/e_os.h
196v3_cpols.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 180v3_cpols.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
197v3_cpols.o: ../../include/openssl/evp.h ../../include/openssl/idea.h 181v3_cpols.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
198v3_cpols.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h 182v3_cpols.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
199v3_cpols.o: ../../include/openssl/md4.h ../../include/openssl/md5.h 183v3_cpols.o: ../../include/openssl/opensslconf.h
200v3_cpols.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h 184v3_cpols.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
201v3_cpols.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 185v3_cpols.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
202v3_cpols.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 186v3_cpols.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
203v3_cpols.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 187v3_cpols.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
204v3_cpols.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 188v3_cpols.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
205v3_cpols.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 189v3_cpols.o: ../../include/openssl/x509v3.h ../cryptlib.h v3_cpols.c
206v3_cpols.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 190v3_crld.o: ../../e_os.h ../../include/openssl/asn1.h
207v3_cpols.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 191v3_crld.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
208v3_cpols.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
209v3_cpols.o: ../cryptlib.h
210v3_crld.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
211v3_crld.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
212v3_crld.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 192v3_crld.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
213v3_crld.o: ../../include/openssl/cast.h ../../include/openssl/conf.h 193v3_crld.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
214v3_crld.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
215v3_crld.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 194v3_crld.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
216v3_crld.o: ../../include/openssl/e_os.h ../../include/openssl/e_os.h
217v3_crld.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 195v3_crld.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
218v3_crld.o: ../../include/openssl/evp.h ../../include/openssl/idea.h 196v3_crld.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
219v3_crld.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h 197v3_crld.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
220v3_crld.o: ../../include/openssl/md4.h ../../include/openssl/md5.h 198v3_crld.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
221v3_crld.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h 199v3_crld.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
222v3_crld.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
223v3_crld.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
224v3_crld.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
225v3_crld.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
226v3_crld.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 200v3_crld.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
227v3_crld.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 201v3_crld.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
228v3_crld.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 202v3_crld.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
229v3_crld.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h 203v3_crld.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
230v3_crld.o: ../cryptlib.h 204v3_crld.o: ../cryptlib.h v3_crld.c
231v3_enum.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 205v3_enum.o: ../../e_os.h ../../include/openssl/asn1.h
232v3_enum.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 206v3_enum.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
233v3_enum.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 207v3_enum.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
234v3_enum.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h 208v3_enum.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
235v3_enum.o: ../../include/openssl/des.h ../../include/openssl/dh.h 209v3_enum.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
236v3_enum.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
237v3_enum.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
238v3_enum.o: ../../include/openssl/err.h ../../include/openssl/evp.h 210v3_enum.o: ../../include/openssl/err.h ../../include/openssl/evp.h
239v3_enum.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 211v3_enum.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
240v3_enum.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 212v3_enum.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
241v3_enum.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 213v3_enum.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
242v3_enum.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 214v3_enum.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
243v3_enum.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
244v3_enum.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
245v3_enum.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
246v3_enum.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
247v3_enum.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 215v3_enum.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
248v3_enum.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 216v3_enum.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
249v3_enum.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 217v3_enum.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
250v3_enum.o: ../../include/openssl/x509v3.h ../cryptlib.h 218v3_enum.o: ../../include/openssl/x509v3.h ../cryptlib.h v3_enum.c
251v3_extku.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 219v3_extku.o: ../../e_os.h ../../include/openssl/asn1.h
252v3_extku.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 220v3_extku.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
253v3_extku.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 221v3_extku.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
254v3_extku.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h 222v3_extku.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
255v3_extku.o: ../../include/openssl/des.h ../../include/openssl/dh.h 223v3_extku.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
256v3_extku.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h 224v3_extku.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
257v3_extku.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 225v3_extku.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
258v3_extku.o: ../../include/openssl/err.h ../../include/openssl/evp.h
259v3_extku.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
260v3_extku.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
261v3_extku.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
262v3_extku.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 226v3_extku.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
263v3_extku.o: ../../include/openssl/opensslconf.h 227v3_extku.o: ../../include/openssl/opensslconf.h
264v3_extku.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 228v3_extku.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
265v3_extku.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 229v3_extku.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
266v3_extku.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 230v3_extku.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
267v3_extku.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 231v3_extku.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
268v3_extku.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 232v3_extku.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
269v3_extku.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 233v3_extku.o: ../../include/openssl/x509v3.h ../cryptlib.h v3_extku.c
270v3_extku.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h 234v3_genn.o: ../../e_os.h ../../include/openssl/asn1.h
271v3_extku.o: ../cryptlib.h 235v3_genn.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
272v3_genn.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h
273v3_genn.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
274v3_genn.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 236v3_genn.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
275v3_genn.o: ../../include/openssl/cast.h ../../include/openssl/conf.h 237v3_genn.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
276v3_genn.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
277v3_genn.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 238v3_genn.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
278v3_genn.o: ../../include/openssl/e_os.h ../../include/openssl/e_os.h
279v3_genn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 239v3_genn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
280v3_genn.o: ../../include/openssl/evp.h ../../include/openssl/idea.h 240v3_genn.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
281v3_genn.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h 241v3_genn.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
282v3_genn.o: ../../include/openssl/md4.h ../../include/openssl/md5.h 242v3_genn.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
283v3_genn.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h 243v3_genn.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
284v3_genn.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
285v3_genn.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
286v3_genn.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
287v3_genn.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
288v3_genn.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 244v3_genn.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
289v3_genn.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 245v3_genn.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
290v3_genn.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 246v3_genn.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
291v3_genn.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h 247v3_genn.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
292v3_genn.o: ../cryptlib.h 248v3_genn.o: ../cryptlib.h v3_genn.c
293v3_ia5.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 249v3_ia5.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
294v3_ia5.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 250v3_ia5.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
295v3_ia5.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
296v3_ia5.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h 251v3_ia5.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
297v3_ia5.o: ../../include/openssl/des.h ../../include/openssl/dh.h 252v3_ia5.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
298v3_ia5.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h 253v3_ia5.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
299v3_ia5.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 254v3_ia5.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
300v3_ia5.o: ../../include/openssl/err.h ../../include/openssl/evp.h
301v3_ia5.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
302v3_ia5.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
303v3_ia5.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
304v3_ia5.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 255v3_ia5.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
305v3_ia5.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 256v3_ia5.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
306v3_ia5.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h 257v3_ia5.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
307v3_ia5.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 258v3_ia5.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
308v3_ia5.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 259v3_ia5.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
309v3_ia5.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 260v3_ia5.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
310v3_ia5.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 261v3_ia5.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
311v3_ia5.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 262v3_ia5.o: ../cryptlib.h v3_ia5.c
312v3_ia5.o: ../../include/openssl/x509v3.h ../cryptlib.h 263v3_info.o: ../../e_os.h ../../include/openssl/asn1.h
313v3_info.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 264v3_info.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
314v3_info.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h
315v3_info.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 265v3_info.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
316v3_info.o: ../../include/openssl/cast.h ../../include/openssl/conf.h 266v3_info.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
317v3_info.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
318v3_info.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 267v3_info.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
319v3_info.o: ../../include/openssl/e_os.h ../../include/openssl/e_os.h
320v3_info.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 268v3_info.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
321v3_info.o: ../../include/openssl/evp.h ../../include/openssl/idea.h 269v3_info.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
322v3_info.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h 270v3_info.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
323v3_info.o: ../../include/openssl/md4.h ../../include/openssl/md5.h 271v3_info.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
324v3_info.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h 272v3_info.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
325v3_info.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
326v3_info.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
327v3_info.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
328v3_info.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
329v3_info.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 273v3_info.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
330v3_info.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 274v3_info.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
331v3_info.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 275v3_info.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
332v3_info.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h 276v3_info.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
333v3_info.o: ../cryptlib.h 277v3_info.o: ../cryptlib.h v3_info.c
334v3_int.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 278v3_int.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
335v3_int.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 279v3_int.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
336v3_int.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
337v3_int.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h 280v3_int.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
338v3_int.o: ../../include/openssl/des.h ../../include/openssl/dh.h 281v3_int.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
339v3_int.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h 282v3_int.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
340v3_int.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 283v3_int.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
341v3_int.o: ../../include/openssl/err.h ../../include/openssl/evp.h
342v3_int.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
343v3_int.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
344v3_int.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
345v3_int.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 284v3_int.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
346v3_int.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 285v3_int.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
347v3_int.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h 286v3_int.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
348v3_int.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 287v3_int.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
349v3_int.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 288v3_int.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
350v3_int.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 289v3_int.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
351v3_int.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 290v3_int.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
352v3_int.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 291v3_int.o: ../cryptlib.h v3_int.c
353v3_int.o: ../../include/openssl/x509v3.h ../cryptlib.h 292v3_lib.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
354v3_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 293v3_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
355v3_lib.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
356v3_lib.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
357v3_lib.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h 294v3_lib.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
358v3_lib.o: ../../include/openssl/des.h ../../include/openssl/dh.h 295v3_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
359v3_lib.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h 296v3_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
360v3_lib.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 297v3_lib.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
361v3_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h
362v3_lib.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
363v3_lib.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
364v3_lib.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
365v3_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 298v3_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
366v3_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 299v3_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
367v3_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h 300v3_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
368v3_lib.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 301v3_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
369v3_lib.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 302v3_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
370v3_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 303v3_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
371v3_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 304v3_lib.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
372v3_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 305v3_lib.o: ../cryptlib.h ext_dat.h v3_lib.c
373v3_lib.o: ../../include/openssl/x509v3.h ../cryptlib.h ext_dat.h 306v3_ocsp.o: ../../e_os.h ../../include/openssl/asn1.h
374v3_pku.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 307v3_ocsp.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
375v3_pku.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h 308v3_ocsp.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
309v3_ocsp.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
310v3_ocsp.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
311v3_ocsp.o: ../../include/openssl/err.h ../../include/openssl/evp.h
312v3_ocsp.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
313v3_ocsp.o: ../../include/openssl/objects.h ../../include/openssl/ocsp.h
314v3_ocsp.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
315v3_ocsp.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
316v3_ocsp.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
317v3_ocsp.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
318v3_ocsp.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
319v3_ocsp.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
320v3_ocsp.o: ../cryptlib.h v3_ocsp.c
321v3_pku.o: ../../e_os.h ../../include/openssl/asn1.h
322v3_pku.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
376v3_pku.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 323v3_pku.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
377v3_pku.o: ../../include/openssl/cast.h ../../include/openssl/conf.h 324v3_pku.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
378v3_pku.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
379v3_pku.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 325v3_pku.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
380v3_pku.o: ../../include/openssl/e_os.h ../../include/openssl/e_os.h
381v3_pku.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 326v3_pku.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
382v3_pku.o: ../../include/openssl/evp.h ../../include/openssl/idea.h 327v3_pku.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
383v3_pku.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h 328v3_pku.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
384v3_pku.o: ../../include/openssl/md4.h ../../include/openssl/md5.h 329v3_pku.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
385v3_pku.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h 330v3_pku.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
386v3_pku.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
387v3_pku.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
388v3_pku.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
389v3_pku.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
390v3_pku.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 331v3_pku.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
391v3_pku.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 332v3_pku.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
392v3_pku.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 333v3_pku.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
393v3_pku.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h 334v3_pku.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
394v3_pku.o: ../cryptlib.h 335v3_pku.o: ../cryptlib.h v3_pku.c
395v3_prn.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 336v3_prn.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
396v3_prn.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 337v3_prn.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
397v3_prn.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
398v3_prn.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h 338v3_prn.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
399v3_prn.o: ../../include/openssl/des.h ../../include/openssl/dh.h 339v3_prn.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
400v3_prn.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h 340v3_prn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
401v3_prn.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 341v3_prn.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
402v3_prn.o: ../../include/openssl/err.h ../../include/openssl/evp.h
403v3_prn.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
404v3_prn.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
405v3_prn.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
406v3_prn.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 342v3_prn.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
407v3_prn.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 343v3_prn.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
408v3_prn.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h 344v3_prn.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
409v3_prn.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 345v3_prn.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
410v3_prn.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 346v3_prn.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
411v3_prn.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 347v3_prn.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
412v3_prn.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 348v3_prn.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
413v3_prn.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 349v3_prn.o: ../cryptlib.h v3_prn.c
414v3_prn.o: ../../include/openssl/x509v3.h ../cryptlib.h 350v3_purp.o: ../../e_os.h ../../include/openssl/asn1.h
415v3_purp.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 351v3_purp.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
416v3_purp.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 352v3_purp.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
417v3_purp.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 353v3_purp.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
418v3_purp.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h 354v3_purp.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
419v3_purp.o: ../../include/openssl/des.h ../../include/openssl/dh.h
420v3_purp.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
421v3_purp.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
422v3_purp.o: ../../include/openssl/err.h ../../include/openssl/evp.h 355v3_purp.o: ../../include/openssl/err.h ../../include/openssl/evp.h
423v3_purp.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 356v3_purp.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
424v3_purp.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 357v3_purp.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
425v3_purp.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 358v3_purp.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
426v3_purp.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 359v3_purp.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
427v3_purp.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
428v3_purp.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
429v3_purp.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
430v3_purp.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
431v3_purp.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 360v3_purp.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
432v3_purp.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 361v3_purp.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
433v3_purp.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 362v3_purp.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
434v3_purp.o: ../../include/openssl/x509v3.h ../cryptlib.h 363v3_purp.o: ../../include/openssl/x509v3.h ../cryptlib.h v3_purp.c
435v3_skey.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 364v3_skey.o: ../../e_os.h ../../include/openssl/asn1.h
436v3_skey.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 365v3_skey.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
437v3_skey.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h 366v3_skey.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
438v3_skey.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h 367v3_skey.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
439v3_skey.o: ../../include/openssl/des.h ../../include/openssl/dh.h 368v3_skey.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
440v3_skey.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
441v3_skey.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h
442v3_skey.o: ../../include/openssl/err.h ../../include/openssl/evp.h 369v3_skey.o: ../../include/openssl/err.h ../../include/openssl/evp.h
443v3_skey.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h 370v3_skey.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
444v3_skey.o: ../../include/openssl/md2.h ../../include/openssl/md4.h 371v3_skey.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
445v3_skey.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h 372v3_skey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
446v3_skey.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 373v3_skey.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
447v3_skey.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
448v3_skey.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h
449v3_skey.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
450v3_skey.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
451v3_skey.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 374v3_skey.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
452v3_skey.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 375v3_skey.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
453v3_skey.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 376v3_skey.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
454v3_skey.o: ../../include/openssl/x509v3.h ../cryptlib.h 377v3_skey.o: ../../include/openssl/x509v3.h ../cryptlib.h v3_skey.c
455v3_sxnet.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h 378v3_sxnet.o: ../../e_os.h ../../include/openssl/asn1.h
456v3_sxnet.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h 379v3_sxnet.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
457v3_sxnet.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 380v3_sxnet.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
458v3_sxnet.o: ../../include/openssl/cast.h ../../include/openssl/conf.h 381v3_sxnet.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
459v3_sxnet.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
460v3_sxnet.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 382v3_sxnet.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
461v3_sxnet.o: ../../include/openssl/e_os.h ../../include/openssl/e_os.h
462v3_sxnet.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 383v3_sxnet.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
463v3_sxnet.o: ../../include/openssl/evp.h ../../include/openssl/idea.h 384v3_sxnet.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
464v3_sxnet.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h 385v3_sxnet.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
465v3_sxnet.o: ../../include/openssl/md4.h ../../include/openssl/md5.h 386v3_sxnet.o: ../../include/openssl/opensslconf.h
466v3_sxnet.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h 387v3_sxnet.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
467v3_sxnet.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 388v3_sxnet.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
468v3_sxnet.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h 389v3_sxnet.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
469v3_sxnet.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h 390v3_sxnet.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
470v3_sxnet.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h 391v3_sxnet.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
471v3_sxnet.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 392v3_sxnet.o: ../../include/openssl/x509v3.h ../cryptlib.h v3_sxnet.c
472v3_sxnet.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 393v3_utl.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
473v3_sxnet.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 394v3_utl.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
474v3_sxnet.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
475v3_sxnet.o: ../cryptlib.h
476v3_utl.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
477v3_utl.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
478v3_utl.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
479v3_utl.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h 395v3_utl.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
480v3_utl.o: ../../include/openssl/des.h ../../include/openssl/dh.h 396v3_utl.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
481v3_utl.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h 397v3_utl.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
482v3_utl.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h 398v3_utl.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
483v3_utl.o: ../../include/openssl/err.h ../../include/openssl/evp.h
484v3_utl.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
485v3_utl.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
486v3_utl.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
487v3_utl.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 399v3_utl.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
488v3_utl.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 400v3_utl.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
489v3_utl.o: ../../include/openssl/pkcs7.h ../../include/openssl/rc2.h 401v3_utl.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
490v3_utl.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h 402v3_utl.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
491v3_utl.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h 403v3_utl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
492v3_utl.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 404v3_utl.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
493v3_utl.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 405v3_utl.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
494v3_utl.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 406v3_utl.o: ../cryptlib.h v3_utl.c
495v3_utl.o: ../../include/openssl/x509v3.h ../cryptlib.h
496v3err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h 407v3err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
497v3err.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h 408v3err.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
498v3err.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
499v3err.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h 409v3err.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
500v3err.o: ../../include/openssl/des.h ../../include/openssl/dh.h 410v3err.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
501v3err.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h
502v3err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 411v3err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
503v3err.o: ../../include/openssl/evp.h ../../include/openssl/idea.h 412v3err.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
504v3err.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h 413v3err.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
505v3err.o: ../../include/openssl/md4.h ../../include/openssl/md5.h 414v3err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
506v3err.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h 415v3err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
507v3err.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
508v3err.o: ../../include/openssl/opensslv.h ../../include/openssl/pkcs7.h
509v3err.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
510v3err.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
511v3err.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h 416v3err.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
512v3err.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 417v3err.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
513v3err.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h 418v3err.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
514v3err.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h 419v3err.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
420v3err.o: v3err.c
diff --git a/src/lib/libcrypto/x509v3/ext_dat.h b/src/lib/libcrypto/x509v3/ext_dat.h
index 801a585a52..586f116db5 100644
--- a/src/lib/libcrypto/x509v3/ext_dat.h
+++ b/src/lib/libcrypto/x509v3/ext_dat.h
@@ -58,9 +58,12 @@
58/* This file contains a table of "standard" extensions */ 58/* This file contains a table of "standard" extensions */
59 59
60extern X509V3_EXT_METHOD v3_bcons, v3_nscert, v3_key_usage, v3_ext_ku; 60extern X509V3_EXT_METHOD v3_bcons, v3_nscert, v3_key_usage, v3_ext_ku;
61extern X509V3_EXT_METHOD v3_pkey_usage_period, v3_sxnet, v3_info; 61extern X509V3_EXT_METHOD v3_pkey_usage_period, v3_sxnet, v3_info, v3_sinfo;
62extern X509V3_EXT_METHOD v3_ns_ia5_list[], v3_alt[], v3_skey_id, v3_akey_id; 62extern X509V3_EXT_METHOD v3_ns_ia5_list[], v3_alt[], v3_skey_id, v3_akey_id;
63extern X509V3_EXT_METHOD v3_crl_num, v3_crl_reason, v3_cpols, v3_crld; 63extern X509V3_EXT_METHOD v3_crl_num, v3_crl_reason, v3_crl_invdate, v3_cpols, v3_crld;
64extern X509V3_EXT_METHOD v3_ocsp_nonce, v3_ocsp_accresp, v3_ocsp_acutoff;
65extern X509V3_EXT_METHOD v3_ocsp_crlid, v3_ocsp_nocheck, v3_ocsp_serviceloc;
66extern X509V3_EXT_METHOD v3_crl_hold;
64 67
65/* This table will be searched using OBJ_bsearch so it *must* kept in 68/* This table will be searched using OBJ_bsearch so it *must* kept in
66 * order of the ext_nid values. 69 * order of the ext_nid values.
@@ -87,8 +90,17 @@ static X509V3_EXT_METHOD *standard_exts[] = {
87&v3_crld, 90&v3_crld,
88&v3_ext_ku, 91&v3_ext_ku,
89&v3_crl_reason, 92&v3_crl_reason,
93&v3_crl_invdate,
90&v3_sxnet, 94&v3_sxnet,
91&v3_info, 95&v3_info,
96&v3_ocsp_nonce,
97&v3_ocsp_crlid,
98&v3_ocsp_accresp,
99&v3_ocsp_nocheck,
100&v3_ocsp_acutoff,
101&v3_ocsp_serviceloc,
102&v3_crl_hold,
103&v3_sinfo
92}; 104};
93 105
94/* Number of standard extensions */ 106/* Number of standard extensions */
diff --git a/src/lib/libcrypto/x509v3/v3_akey.c b/src/lib/libcrypto/x509v3/v3_akey.c
index 0889a18993..97e686f97a 100644
--- a/src/lib/libcrypto/x509v3/v3_akey.c
+++ b/src/lib/libcrypto/x509v3/v3_akey.c
@@ -60,7 +60,7 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/conf.h> 61#include <openssl/conf.h>
62#include <openssl/asn1.h> 62#include <openssl/asn1.h>
63#include <openssl/asn1_mac.h> 63#include <openssl/asn1t.h>
64#include <openssl/x509v3.h> 64#include <openssl/x509v3.h>
65 65
66static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_KEYID(X509V3_EXT_METHOD *method, 66static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_KEYID(X509V3_EXT_METHOD *method,
@@ -69,72 +69,15 @@ static AUTHORITY_KEYID *v2i_AUTHORITY_KEYID(X509V3_EXT_METHOD *method,
69 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *values); 69 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *values);
70 70
71X509V3_EXT_METHOD v3_akey_id = { 71X509V3_EXT_METHOD v3_akey_id = {
72NID_authority_key_identifier, X509V3_EXT_MULTILINE, 72NID_authority_key_identifier, X509V3_EXT_MULTILINE, ASN1_ITEM_ref(AUTHORITY_KEYID),
73(X509V3_EXT_NEW)AUTHORITY_KEYID_new, 730,0,0,0,
74(X509V3_EXT_FREE)AUTHORITY_KEYID_free, 740,0,
75(X509V3_EXT_D2I)d2i_AUTHORITY_KEYID,
76(X509V3_EXT_I2D)i2d_AUTHORITY_KEYID,
77NULL, NULL,
78(X509V3_EXT_I2V)i2v_AUTHORITY_KEYID, 75(X509V3_EXT_I2V)i2v_AUTHORITY_KEYID,
79(X509V3_EXT_V2I)v2i_AUTHORITY_KEYID, 76(X509V3_EXT_V2I)v2i_AUTHORITY_KEYID,
80NULL,NULL, 770,0,
81NULL 78NULL
82}; 79};
83 80
84
85int i2d_AUTHORITY_KEYID(AUTHORITY_KEYID *a, unsigned char **pp)
86{
87 M_ASN1_I2D_vars(a);
88
89 M_ASN1_I2D_len_IMP_opt (a->keyid, i2d_ASN1_OCTET_STRING);
90 M_ASN1_I2D_len_IMP_opt (a->issuer, i2d_GENERAL_NAMES);
91 M_ASN1_I2D_len_IMP_opt (a->serial, i2d_ASN1_INTEGER);
92
93 M_ASN1_I2D_seq_total();
94
95 M_ASN1_I2D_put_IMP_opt (a->keyid, i2d_ASN1_OCTET_STRING, 0);
96 M_ASN1_I2D_put_IMP_opt (a->issuer, i2d_GENERAL_NAMES, 1);
97 M_ASN1_I2D_put_IMP_opt (a->serial, i2d_ASN1_INTEGER, 2);
98
99 M_ASN1_I2D_finish();
100}
101
102AUTHORITY_KEYID *AUTHORITY_KEYID_new(void)
103{
104 AUTHORITY_KEYID *ret=NULL;
105 ASN1_CTX c;
106 M_ASN1_New_Malloc(ret, AUTHORITY_KEYID);
107 ret->keyid = NULL;
108 ret->issuer = NULL;
109 ret->serial = NULL;
110 return (ret);
111 M_ASN1_New_Error(ASN1_F_AUTHORITY_KEYID_NEW);
112}
113
114AUTHORITY_KEYID *d2i_AUTHORITY_KEYID(AUTHORITY_KEYID **a, unsigned char **pp,
115 long length)
116{
117 M_ASN1_D2I_vars(a,AUTHORITY_KEYID *,AUTHORITY_KEYID_new);
118 M_ASN1_D2I_Init();
119 M_ASN1_D2I_start_sequence();
120 M_ASN1_D2I_get_IMP_opt (ret->keyid, d2i_ASN1_OCTET_STRING, 0,
121 V_ASN1_OCTET_STRING);
122 M_ASN1_D2I_get_IMP_opt (ret->issuer, d2i_GENERAL_NAMES, 1,
123 V_ASN1_SEQUENCE);
124 M_ASN1_D2I_get_IMP_opt (ret->serial, d2i_ASN1_INTEGER, 2,
125 V_ASN1_INTEGER);
126 M_ASN1_D2I_Finish(a, AUTHORITY_KEYID_free, ASN1_F_D2I_AUTHORITY_KEYID);
127}
128
129void AUTHORITY_KEYID_free(AUTHORITY_KEYID *a)
130{
131 if (a == NULL) return;
132 M_ASN1_OCTET_STRING_free(a->keyid);
133 sk_GENERAL_NAME_pop_free(a->issuer, GENERAL_NAME_free);
134 M_ASN1_INTEGER_free (a->serial);
135 OPENSSL_free (a);
136}
137
138static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_KEYID(X509V3_EXT_METHOD *method, 81static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_KEYID(X509V3_EXT_METHOD *method,
139 AUTHORITY_KEYID *akeyid, STACK_OF(CONF_VALUE) *extlist) 82 AUTHORITY_KEYID *akeyid, STACK_OF(CONF_VALUE) *extlist)
140{ 83{
@@ -171,7 +114,7 @@ int i;
171CONF_VALUE *cnf; 114CONF_VALUE *cnf;
172ASN1_OCTET_STRING *ikeyid = NULL; 115ASN1_OCTET_STRING *ikeyid = NULL;
173X509_NAME *isname = NULL; 116X509_NAME *isname = NULL;
174STACK_OF(GENERAL_NAME) * gens = NULL; 117GENERAL_NAMES * gens = NULL;
175GENERAL_NAME *gen = NULL; 118GENERAL_NAME *gen = NULL;
176ASN1_INTEGER *serial = NULL; 119ASN1_INTEGER *serial = NULL;
177X509_EXTENSION *ext; 120X509_EXTENSION *ext;
@@ -192,8 +135,6 @@ for(i = 0; i < sk_CONF_VALUE_num(values); i++) {
192 } 135 }
193} 136}
194 137
195
196
197if(!ctx || !ctx->issuer_cert) { 138if(!ctx || !ctx->issuer_cert) {
198 if(ctx && (ctx->flags==CTX_TEST)) return AUTHORITY_KEYID_new(); 139 if(ctx && (ctx->flags==CTX_TEST)) return AUTHORITY_KEYID_new();
199 X509V3err(X509V3_F_V2I_AUTHORITY_KEYID,X509V3_R_NO_ISSUER_CERTIFICATE); 140 X509V3err(X509V3_F_V2I_AUTHORITY_KEYID,X509V3_R_NO_ISSUER_CERTIFICATE);
diff --git a/src/lib/libcrypto/x509v3/v3_akeya.c b/src/lib/libcrypto/x509v3/v3_akeya.c
new file mode 100644
index 0000000000..2aafa26ba7
--- /dev/null
+++ b/src/lib/libcrypto/x509v3/v3_akeya.c
@@ -0,0 +1,72 @@
1/* v3_akey_asn1.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/conf.h>
62#include <openssl/asn1.h>
63#include <openssl/asn1t.h>
64#include <openssl/x509v3.h>
65
66ASN1_SEQUENCE(AUTHORITY_KEYID) = {
67 ASN1_IMP_OPT(AUTHORITY_KEYID, keyid, ASN1_OCTET_STRING, 0),
68 ASN1_IMP_SEQUENCE_OF_OPT(AUTHORITY_KEYID, issuer, GENERAL_NAME, 1),
69 ASN1_IMP_OPT(AUTHORITY_KEYID, serial, ASN1_INTEGER, 2)
70} ASN1_SEQUENCE_END(AUTHORITY_KEYID)
71
72IMPLEMENT_ASN1_FUNCTIONS(AUTHORITY_KEYID)
diff --git a/src/lib/libcrypto/x509v3/v3_alt.c b/src/lib/libcrypto/x509v3/v3_alt.c
index 94bebcd448..0e9e7dcb4f 100644
--- a/src/lib/libcrypto/x509v3/v3_alt.c
+++ b/src/lib/libcrypto/x509v3/v3_alt.c
@@ -61,33 +61,28 @@
61#include <openssl/conf.h> 61#include <openssl/conf.h>
62#include <openssl/x509v3.h> 62#include <openssl/x509v3.h>
63 63
64static STACK_OF(GENERAL_NAME) *v2i_subject_alt(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); 64static GENERAL_NAMES *v2i_subject_alt(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval);
65static STACK_OF(GENERAL_NAME) *v2i_issuer_alt(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); 65static GENERAL_NAMES *v2i_issuer_alt(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval);
66static int copy_email(X509V3_CTX *ctx, STACK_OF(GENERAL_NAME) *gens); 66static int copy_email(X509V3_CTX *ctx, GENERAL_NAMES *gens, int move_p);
67static int copy_issuer(X509V3_CTX *ctx, STACK_OF(GENERAL_NAME) *gens); 67static int copy_issuer(X509V3_CTX *ctx, GENERAL_NAMES *gens);
68X509V3_EXT_METHOD v3_alt[] = { 68X509V3_EXT_METHOD v3_alt[] = {
69{ NID_subject_alt_name, 0, 69{ NID_subject_alt_name, 0, ASN1_ITEM_ref(GENERAL_NAMES),
70(X509V3_EXT_NEW)GENERAL_NAMES_new, 700,0,0,0,
71(X509V3_EXT_FREE)GENERAL_NAMES_free, 710,0,
72(X509V3_EXT_D2I)d2i_GENERAL_NAMES,
73(X509V3_EXT_I2D)i2d_GENERAL_NAMES,
74NULL, NULL,
75(X509V3_EXT_I2V)i2v_GENERAL_NAMES, 72(X509V3_EXT_I2V)i2v_GENERAL_NAMES,
76(X509V3_EXT_V2I)v2i_subject_alt, 73(X509V3_EXT_V2I)v2i_subject_alt,
77NULL, NULL, NULL}, 74NULL, NULL, NULL},
78{ NID_issuer_alt_name, 0, 75
79(X509V3_EXT_NEW)GENERAL_NAMES_new, 76{ NID_issuer_alt_name, 0, ASN1_ITEM_ref(GENERAL_NAMES),
80(X509V3_EXT_FREE)GENERAL_NAMES_free, 770,0,0,0,
81(X509V3_EXT_D2I)d2i_GENERAL_NAMES, 780,0,
82(X509V3_EXT_I2D)i2d_GENERAL_NAMES,
83NULL, NULL,
84(X509V3_EXT_I2V)i2v_GENERAL_NAMES, 79(X509V3_EXT_I2V)i2v_GENERAL_NAMES,
85(X509V3_EXT_V2I)v2i_issuer_alt, 80(X509V3_EXT_V2I)v2i_issuer_alt,
86NULL, NULL, NULL}, 81NULL, NULL, NULL},
87}; 82};
88 83
89STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method, 84STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method,
90 STACK_OF(GENERAL_NAME) *gens, STACK_OF(CONF_VALUE) *ret) 85 GENERAL_NAMES *gens, STACK_OF(CONF_VALUE) *ret)
91{ 86{
92 int i; 87 int i;
93 GENERAL_NAME *gen; 88 GENERAL_NAME *gen;
@@ -102,8 +97,8 @@ STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method,
102STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method, 97STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method,
103 GENERAL_NAME *gen, STACK_OF(CONF_VALUE) *ret) 98 GENERAL_NAME *gen, STACK_OF(CONF_VALUE) *ret)
104{ 99{
105 char oline[256];
106 unsigned char *p; 100 unsigned char *p;
101 char oline[256];
107 switch (gen->type) 102 switch (gen->type)
108 { 103 {
109 case GEN_OTHERNAME: 104 case GEN_OTHERNAME:
@@ -154,10 +149,63 @@ STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method,
154 return ret; 149 return ret;
155} 150}
156 151
157static STACK_OF(GENERAL_NAME) *v2i_issuer_alt(X509V3_EXT_METHOD *method, 152int GENERAL_NAME_print(BIO *out, GENERAL_NAME *gen)
153{
154 unsigned char *p;
155 switch (gen->type)
156 {
157 case GEN_OTHERNAME:
158 BIO_printf(out, "othername:<unsupported>");
159 break;
160
161 case GEN_X400:
162 BIO_printf(out, "X400Name:<unsupported>");
163 break;
164
165 case GEN_EDIPARTY:
166 /* Maybe fix this: it is supported now */
167 BIO_printf(out, "EdiPartyName:<unsupported>");
168 break;
169
170 case GEN_EMAIL:
171 BIO_printf(out, "email:%s",gen->d.ia5->data);
172 break;
173
174 case GEN_DNS:
175 BIO_printf(out, "DNS:%s",gen->d.ia5->data);
176 break;
177
178 case GEN_URI:
179 BIO_printf(out, "URI:%s",gen->d.ia5->data);
180 break;
181
182 case GEN_DIRNAME:
183 BIO_printf(out, "DirName: ");
184 X509_NAME_print_ex(out, gen->d.dirn, 0, XN_FLAG_ONELINE);
185 break;
186
187 case GEN_IPADD:
188 p = gen->d.ip->data;
189 /* BUG: doesn't support IPV6 */
190 if(gen->d.ip->length != 4) {
191 BIO_printf(out,"IP Address:<invalid>");
192 break;
193 }
194 BIO_printf(out, "IP Address:%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
195 break;
196
197 case GEN_RID:
198 BIO_printf(out, "Registered ID");
199 i2a_ASN1_OBJECT(out, gen->d.rid);
200 break;
201 }
202 return 1;
203}
204
205static GENERAL_NAMES *v2i_issuer_alt(X509V3_EXT_METHOD *method,
158 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) 206 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval)
159{ 207{
160 STACK_OF(GENERAL_NAME) *gens = NULL; 208 GENERAL_NAMES *gens = NULL;
161 CONF_VALUE *cnf; 209 CONF_VALUE *cnf;
162 int i; 210 int i;
163 if(!(gens = sk_GENERAL_NAME_new_null())) { 211 if(!(gens = sk_GENERAL_NAME_new_null())) {
@@ -184,9 +232,9 @@ static STACK_OF(GENERAL_NAME) *v2i_issuer_alt(X509V3_EXT_METHOD *method,
184 232
185/* Append subject altname of issuer to issuer alt name of subject */ 233/* Append subject altname of issuer to issuer alt name of subject */
186 234
187static int copy_issuer(X509V3_CTX *ctx, STACK_OF(GENERAL_NAME) *gens) 235static int copy_issuer(X509V3_CTX *ctx, GENERAL_NAMES *gens)
188{ 236{
189 STACK_OF(GENERAL_NAME) *ialt; 237 GENERAL_NAMES *ialt;
190 GENERAL_NAME *gen; 238 GENERAL_NAME *gen;
191 X509_EXTENSION *ext; 239 X509_EXTENSION *ext;
192 int i; 240 int i;
@@ -219,10 +267,10 @@ static int copy_issuer(X509V3_CTX *ctx, STACK_OF(GENERAL_NAME) *gens)
219 267
220} 268}
221 269
222static STACK_OF(GENERAL_NAME) *v2i_subject_alt(X509V3_EXT_METHOD *method, 270static GENERAL_NAMES *v2i_subject_alt(X509V3_EXT_METHOD *method,
223 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) 271 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval)
224{ 272{
225 STACK_OF(GENERAL_NAME) *gens = NULL; 273 GENERAL_NAMES *gens = NULL;
226 CONF_VALUE *cnf; 274 CONF_VALUE *cnf;
227 int i; 275 int i;
228 if(!(gens = sk_GENERAL_NAME_new_null())) { 276 if(!(gens = sk_GENERAL_NAME_new_null())) {
@@ -233,7 +281,10 @@ static STACK_OF(GENERAL_NAME) *v2i_subject_alt(X509V3_EXT_METHOD *method,
233 cnf = sk_CONF_VALUE_value(nval, i); 281 cnf = sk_CONF_VALUE_value(nval, i);
234 if(!name_cmp(cnf->name, "email") && cnf->value && 282 if(!name_cmp(cnf->name, "email") && cnf->value &&
235 !strcmp(cnf->value, "copy")) { 283 !strcmp(cnf->value, "copy")) {
236 if(!copy_email(ctx, gens)) goto err; 284 if(!copy_email(ctx, gens, 0)) goto err;
285 } else if(!name_cmp(cnf->name, "email") && cnf->value &&
286 !strcmp(cnf->value, "move")) {
287 if(!copy_email(ctx, gens, 1)) goto err;
237 } else { 288 } else {
238 GENERAL_NAME *gen; 289 GENERAL_NAME *gen;
239 if(!(gen = v2i_GENERAL_NAME(method, ctx, cnf))) 290 if(!(gen = v2i_GENERAL_NAME(method, ctx, cnf)))
@@ -251,7 +302,7 @@ static STACK_OF(GENERAL_NAME) *v2i_subject_alt(X509V3_EXT_METHOD *method,
251 * GENERAL_NAMES 302 * GENERAL_NAMES
252 */ 303 */
253 304
254static int copy_email(X509V3_CTX *ctx, STACK_OF(GENERAL_NAME) *gens) 305static int copy_email(X509V3_CTX *ctx, GENERAL_NAMES *gens, int move_p)
255{ 306{
256 X509_NAME *nm; 307 X509_NAME *nm;
257 ASN1_IA5STRING *email = NULL; 308 ASN1_IA5STRING *email = NULL;
@@ -273,6 +324,11 @@ static int copy_email(X509V3_CTX *ctx, STACK_OF(GENERAL_NAME) *gens)
273 NID_pkcs9_emailAddress, i)) >= 0) { 324 NID_pkcs9_emailAddress, i)) >= 0) {
274 ne = X509_NAME_get_entry(nm, i); 325 ne = X509_NAME_get_entry(nm, i);
275 email = M_ASN1_IA5STRING_dup(X509_NAME_ENTRY_get_data(ne)); 326 email = M_ASN1_IA5STRING_dup(X509_NAME_ENTRY_get_data(ne));
327 if (move_p)
328 {
329 X509_NAME_delete_entry(nm, i);
330 i--;
331 }
276 if(!email || !(gen = GENERAL_NAME_new())) { 332 if(!email || !(gen = GENERAL_NAME_new())) {
277 X509V3err(X509V3_F_COPY_EMAIL,ERR_R_MALLOC_FAILURE); 333 X509V3err(X509V3_F_COPY_EMAIL,ERR_R_MALLOC_FAILURE);
278 goto err; 334 goto err;
@@ -297,11 +353,11 @@ static int copy_email(X509V3_CTX *ctx, STACK_OF(GENERAL_NAME) *gens)
297 353
298} 354}
299 355
300STACK_OF(GENERAL_NAME) *v2i_GENERAL_NAMES(X509V3_EXT_METHOD *method, 356GENERAL_NAMES *v2i_GENERAL_NAMES(X509V3_EXT_METHOD *method,
301 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) 357 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval)
302{ 358{
303 GENERAL_NAME *gen; 359 GENERAL_NAME *gen;
304 STACK_OF(GENERAL_NAME) *gens = NULL; 360 GENERAL_NAMES *gens = NULL;
305 CONF_VALUE *cnf; 361 CONF_VALUE *cnf;
306 int i; 362 int i;
307 if(!(gens = sk_GENERAL_NAME_new_null())) { 363 if(!(gens = sk_GENERAL_NAME_new_null())) {
diff --git a/src/lib/libcrypto/x509v3/v3_bcons.c b/src/lib/libcrypto/x509v3/v3_bcons.c
index c576b8e955..cbb012715e 100644
--- a/src/lib/libcrypto/x509v3/v3_bcons.c
+++ b/src/lib/libcrypto/x509v3/v3_bcons.c
@@ -60,7 +60,7 @@
60#include <stdio.h> 60#include <stdio.h>
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/asn1.h> 62#include <openssl/asn1.h>
63#include <openssl/asn1_mac.h> 63#include <openssl/asn1t.h>
64#include <openssl/conf.h> 64#include <openssl/conf.h>
65#include <openssl/x509v3.h> 65#include <openssl/x509v3.h>
66 66
@@ -69,62 +69,22 @@ static BASIC_CONSTRAINTS *v2i_BASIC_CONSTRAINTS(X509V3_EXT_METHOD *method, X509V
69 69
70X509V3_EXT_METHOD v3_bcons = { 70X509V3_EXT_METHOD v3_bcons = {
71NID_basic_constraints, 0, 71NID_basic_constraints, 0,
72(X509V3_EXT_NEW)BASIC_CONSTRAINTS_new, 72ASN1_ITEM_ref(BASIC_CONSTRAINTS),
73(X509V3_EXT_FREE)BASIC_CONSTRAINTS_free, 730,0,0,0,
74(X509V3_EXT_D2I)d2i_BASIC_CONSTRAINTS, 740,0,
75(X509V3_EXT_I2D)i2d_BASIC_CONSTRAINTS,
76NULL, NULL,
77(X509V3_EXT_I2V)i2v_BASIC_CONSTRAINTS, 75(X509V3_EXT_I2V)i2v_BASIC_CONSTRAINTS,
78(X509V3_EXT_V2I)v2i_BASIC_CONSTRAINTS, 76(X509V3_EXT_V2I)v2i_BASIC_CONSTRAINTS,
79NULL,NULL, 77NULL,NULL,
80NULL 78NULL
81}; 79};
82 80
81ASN1_SEQUENCE(BASIC_CONSTRAINTS) = {
82 ASN1_OPT(BASIC_CONSTRAINTS, ca, ASN1_FBOOLEAN),
83 ASN1_OPT(BASIC_CONSTRAINTS, pathlen, ASN1_INTEGER)
84} ASN1_SEQUENCE_END(BASIC_CONSTRAINTS)
83 85
84int i2d_BASIC_CONSTRAINTS(BASIC_CONSTRAINTS *a, unsigned char **pp) 86IMPLEMENT_ASN1_FUNCTIONS(BASIC_CONSTRAINTS)
85{
86 M_ASN1_I2D_vars(a);
87 if(a->ca) M_ASN1_I2D_len (a->ca, i2d_ASN1_BOOLEAN);
88 M_ASN1_I2D_len (a->pathlen, i2d_ASN1_INTEGER);
89
90 M_ASN1_I2D_seq_total();
91
92 if (a->ca) M_ASN1_I2D_put (a->ca, i2d_ASN1_BOOLEAN);
93 M_ASN1_I2D_put (a->pathlen, i2d_ASN1_INTEGER);
94 M_ASN1_I2D_finish();
95}
96
97BASIC_CONSTRAINTS *BASIC_CONSTRAINTS_new(void)
98{
99 BASIC_CONSTRAINTS *ret=NULL;
100 ASN1_CTX c;
101 M_ASN1_New_Malloc(ret, BASIC_CONSTRAINTS);
102 ret->ca = 0;
103 ret->pathlen = NULL;
104 return (ret);
105 M_ASN1_New_Error(ASN1_F_BASIC_CONSTRAINTS_NEW);
106}
107 87
108BASIC_CONSTRAINTS *d2i_BASIC_CONSTRAINTS(BASIC_CONSTRAINTS **a,
109 unsigned char **pp, long length)
110{
111 M_ASN1_D2I_vars(a,BASIC_CONSTRAINTS *,BASIC_CONSTRAINTS_new);
112 M_ASN1_D2I_Init();
113 M_ASN1_D2I_start_sequence();
114 if((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) ==
115 (V_ASN1_UNIVERSAL|V_ASN1_BOOLEAN) ) {
116 M_ASN1_D2I_get_int (ret->ca, d2i_ASN1_BOOLEAN);
117 }
118 M_ASN1_D2I_get_opt (ret->pathlen, d2i_ASN1_INTEGER, V_ASN1_INTEGER);
119 M_ASN1_D2I_Finish(a, BASIC_CONSTRAINTS_free, ASN1_F_D2I_BASIC_CONSTRAINTS);
120}
121
122void BASIC_CONSTRAINTS_free(BASIC_CONSTRAINTS *a)
123{
124 if (a == NULL) return;
125 M_ASN1_INTEGER_free (a->pathlen);
126 OPENSSL_free (a);
127}
128 88
129static STACK_OF(CONF_VALUE) *i2v_BASIC_CONSTRAINTS(X509V3_EXT_METHOD *method, 89static STACK_OF(CONF_VALUE) *i2v_BASIC_CONSTRAINTS(X509V3_EXT_METHOD *method,
130 BASIC_CONSTRAINTS *bcons, STACK_OF(CONF_VALUE) *extlist) 90 BASIC_CONSTRAINTS *bcons, STACK_OF(CONF_VALUE) *extlist)
diff --git a/src/lib/libcrypto/x509v3/v3_bitst.c b/src/lib/libcrypto/x509v3/v3_bitst.c
index 0e1167d05c..16cf125562 100644
--- a/src/lib/libcrypto/x509v3/v3_bitst.c
+++ b/src/lib/libcrypto/x509v3/v3_bitst.c
@@ -66,6 +66,7 @@ static ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,
66static STACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, 66static STACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,
67 ASN1_BIT_STRING *bits, 67 ASN1_BIT_STRING *bits,
68 STACK_OF(CONF_VALUE) *extlist); 68 STACK_OF(CONF_VALUE) *extlist);
69
69static BIT_STRING_BITNAME ns_cert_type_table[] = { 70static BIT_STRING_BITNAME ns_cert_type_table[] = {
70{0, "SSL Client", "client"}, 71{0, "SSL Client", "client"},
71{1, "SSL Server", "server"}, 72{1, "SSL Server", "server"},
diff --git a/src/lib/libcrypto/x509v3/v3_conf.c b/src/lib/libcrypto/x509v3/v3_conf.c
index bdc9c1cbc1..1a3448e121 100644
--- a/src/lib/libcrypto/x509v3/v3_conf.c
+++ b/src/lib/libcrypto/x509v3/v3_conf.c
@@ -68,114 +68,137 @@
68 68
69static int v3_check_critical(char **value); 69static int v3_check_critical(char **value);
70static int v3_check_generic(char **value); 70static int v3_check_generic(char **value);
71static X509_EXTENSION *do_ext_conf(LHASH *conf, X509V3_CTX *ctx, int ext_nid, int crit, char *value); 71static X509_EXTENSION *do_ext_nconf(CONF *conf, X509V3_CTX *ctx, int ext_nid, int crit, char *value);
72static X509_EXTENSION *v3_generic_extension(const char *ext, char *value, int crit, int type); 72static X509_EXTENSION *v3_generic_extension(const char *ext, char *value, int crit, int type);
73static char *conf_lhash_get_string(void *db, char *section, char *value); 73static char *conf_lhash_get_string(void *db, char *section, char *value);
74static STACK_OF(CONF_VALUE) *conf_lhash_get_section(void *db, char *section); 74static STACK_OF(CONF_VALUE) *conf_lhash_get_section(void *db, char *section);
75static X509_EXTENSION *do_ext_i2d(X509V3_EXT_METHOD *method, int ext_nid, 75static X509_EXTENSION *do_ext_i2d(X509V3_EXT_METHOD *method, int ext_nid,
76 int crit, void *ext_struc); 76 int crit, void *ext_struc);
77/* LHASH *conf: Config file */ 77/* CONF *conf: Config file */
78/* char *name: Name */ 78/* char *name: Name */
79/* char *value: Value */ 79/* char *value: Value */
80X509_EXTENSION *X509V3_EXT_conf(LHASH *conf, X509V3_CTX *ctx, char *name, 80X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, char *name,
81 char *value) 81 char *value)
82{ 82 {
83 int crit; 83 int crit;
84 int ext_type; 84 int ext_type;
85 X509_EXTENSION *ret; 85 X509_EXTENSION *ret;
86 crit = v3_check_critical(&value); 86 crit = v3_check_critical(&value);
87 if((ext_type = v3_check_generic(&value))) 87 if ((ext_type = v3_check_generic(&value)))
88 return v3_generic_extension(name, value, crit, ext_type); 88 return v3_generic_extension(name, value, crit, ext_type);
89 ret = do_ext_conf(conf, ctx, OBJ_sn2nid(name), crit, value); 89 ret = do_ext_nconf(conf, ctx, OBJ_sn2nid(name), crit, value);
90 if(!ret) { 90 if (!ret)
91 {
91 X509V3err(X509V3_F_X509V3_EXT_CONF,X509V3_R_ERROR_IN_EXTENSION); 92 X509V3err(X509V3_F_X509V3_EXT_CONF,X509V3_R_ERROR_IN_EXTENSION);
92 ERR_add_error_data(4,"name=", name, ", value=", value); 93 ERR_add_error_data(4,"name=", name, ", value=", value);
93 } 94 }
94 return ret; 95 return ret;
95} 96 }
96 97
97/* LHASH *conf: Config file */ 98/* CONF *conf: Config file */
98/* char *value: Value */ 99/* char *value: Value */
99X509_EXTENSION *X509V3_EXT_conf_nid(LHASH *conf, X509V3_CTX *ctx, int ext_nid, 100X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid,
100 char *value) 101 char *value)
101{ 102 {
102 int crit; 103 int crit;
103 int ext_type; 104 int ext_type;
104 crit = v3_check_critical(&value); 105 crit = v3_check_critical(&value);
105 if((ext_type = v3_check_generic(&value))) 106 if ((ext_type = v3_check_generic(&value)))
106 return v3_generic_extension(OBJ_nid2sn(ext_nid), 107 return v3_generic_extension(OBJ_nid2sn(ext_nid),
107 value, crit, ext_type); 108 value, crit, ext_type);
108 return do_ext_conf(conf, ctx, ext_nid, crit, value); 109 return do_ext_nconf(conf, ctx, ext_nid, crit, value);
109} 110 }
110 111
111/* LHASH *conf: Config file */ 112/* CONF *conf: Config file */
112/* char *value: Value */ 113/* char *value: Value */
113static X509_EXTENSION *do_ext_conf(LHASH *conf, X509V3_CTX *ctx, int ext_nid, 114static X509_EXTENSION *do_ext_nconf(CONF *conf, X509V3_CTX *ctx, int ext_nid,
114 int crit, char *value) 115 int crit, char *value)
115{ 116 {
116 X509V3_EXT_METHOD *method; 117 X509V3_EXT_METHOD *method;
117 X509_EXTENSION *ext; 118 X509_EXTENSION *ext;
118 STACK_OF(CONF_VALUE) *nval; 119 STACK_OF(CONF_VALUE) *nval;
119 void *ext_struc; 120 void *ext_struc;
120 if(ext_nid == NID_undef) { 121 if (ext_nid == NID_undef)
122 {
121 X509V3err(X509V3_F_DO_EXT_CONF,X509V3_R_UNKNOWN_EXTENSION_NAME); 123 X509V3err(X509V3_F_DO_EXT_CONF,X509V3_R_UNKNOWN_EXTENSION_NAME);
122 return NULL; 124 return NULL;
123 } 125 }
124 if(!(method = X509V3_EXT_get_nid(ext_nid))) { 126 if (!(method = X509V3_EXT_get_nid(ext_nid)))
127 {
125 X509V3err(X509V3_F_DO_EXT_CONF,X509V3_R_UNKNOWN_EXTENSION); 128 X509V3err(X509V3_F_DO_EXT_CONF,X509V3_R_UNKNOWN_EXTENSION);
126 return NULL; 129 return NULL;
127 } 130 }
128 /* Now get internal extension representation based on type */ 131 /* Now get internal extension representation based on type */
129 if(method->v2i) { 132 if (method->v2i)
130 if(*value == '@') nval = CONF_get_section(conf, value + 1); 133 {
134 if(*value == '@') nval = NCONF_get_section(conf, value + 1);
131 else nval = X509V3_parse_list(value); 135 else nval = X509V3_parse_list(value);
132 if(!nval) { 136 if(!nval)
137 {
133 X509V3err(X509V3_F_X509V3_EXT_CONF,X509V3_R_INVALID_EXTENSION_STRING); 138 X509V3err(X509V3_F_X509V3_EXT_CONF,X509V3_R_INVALID_EXTENSION_STRING);
134 ERR_add_error_data(4, "name=", OBJ_nid2sn(ext_nid), ",section=", value); 139 ERR_add_error_data(4, "name=", OBJ_nid2sn(ext_nid), ",section=", value);
135 return NULL; 140 return NULL;
136 } 141 }
137 ext_struc = method->v2i(method, ctx, nval); 142 ext_struc = method->v2i(method, ctx, nval);
138 if(*value != '@') sk_CONF_VALUE_pop_free(nval, 143 if(*value != '@') sk_CONF_VALUE_pop_free(nval,
139 X509V3_conf_free); 144 X509V3_conf_free);
140 if(!ext_struc) return NULL; 145 if(!ext_struc) return NULL;
141 } else if(method->s2i) { 146 }
147 else if(method->s2i)
148 {
142 if(!(ext_struc = method->s2i(method, ctx, value))) return NULL; 149 if(!(ext_struc = method->s2i(method, ctx, value))) return NULL;
143 } else if(method->r2i) { 150 }
144 if(!ctx->db) { 151 else if(method->r2i)
152 {
153 if(!ctx->db)
154 {
145 X509V3err(X509V3_F_X509V3_EXT_CONF,X509V3_R_NO_CONFIG_DATABASE); 155 X509V3err(X509V3_F_X509V3_EXT_CONF,X509V3_R_NO_CONFIG_DATABASE);
146 return NULL; 156 return NULL;
147 } 157 }
148 if(!(ext_struc = method->r2i(method, ctx, value))) return NULL; 158 if(!(ext_struc = method->r2i(method, ctx, value))) return NULL;
149 } else { 159 }
160 else
161 {
150 X509V3err(X509V3_F_X509V3_EXT_CONF,X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED); 162 X509V3err(X509V3_F_X509V3_EXT_CONF,X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED);
151 ERR_add_error_data(2, "name=", OBJ_nid2sn(ext_nid)); 163 ERR_add_error_data(2, "name=", OBJ_nid2sn(ext_nid));
152 return NULL; 164 return NULL;
153 } 165 }
154 166
155 ext = do_ext_i2d(method, ext_nid, crit, ext_struc); 167 ext = do_ext_i2d(method, ext_nid, crit, ext_struc);
156 method->ext_free(ext_struc); 168 if(method->it) ASN1_item_free(ext_struc, ASN1_ITEM_ptr(method->it));
169 else method->ext_free(ext_struc);
157 return ext; 170 return ext;
158 171
159} 172 }
160 173
161static X509_EXTENSION *do_ext_i2d(X509V3_EXT_METHOD *method, int ext_nid, 174static X509_EXTENSION *do_ext_i2d(X509V3_EXT_METHOD *method, int ext_nid,
162 int crit, void *ext_struc) 175 int crit, void *ext_struc)
163{ 176 {
164 unsigned char *ext_der, *p; 177 unsigned char *ext_der;
165 int ext_len; 178 int ext_len;
166 ASN1_OCTET_STRING *ext_oct; 179 ASN1_OCTET_STRING *ext_oct;
167 X509_EXTENSION *ext; 180 X509_EXTENSION *ext;
168 /* Convert internal representation to DER */ 181 /* Convert internal representation to DER */
169 ext_len = method->i2d(ext_struc, NULL); 182 if (method->it)
170 if(!(ext_der = OPENSSL_malloc(ext_len))) goto merr; 183 {
171 p = ext_der; 184 ext_der = NULL;
172 method->i2d(ext_struc, &p); 185 ext_len = ASN1_item_i2d(ext_struc, &ext_der, ASN1_ITEM_ptr(method->it));
173 if(!(ext_oct = M_ASN1_OCTET_STRING_new())) goto merr; 186 if (ext_len < 0) goto merr;
187 }
188 else
189 {
190 unsigned char *p;
191 ext_len = method->i2d(ext_struc, NULL);
192 if(!(ext_der = OPENSSL_malloc(ext_len))) goto merr;
193 p = ext_der;
194 method->i2d(ext_struc, &p);
195 }
196 if (!(ext_oct = M_ASN1_OCTET_STRING_new())) goto merr;
174 ext_oct->data = ext_der; 197 ext_oct->data = ext_der;
175 ext_oct->length = ext_len; 198 ext_oct->length = ext_len;
176 199
177 ext = X509_EXTENSION_create_by_NID(NULL, ext_nid, crit, ext_oct); 200 ext = X509_EXTENSION_create_by_NID(NULL, ext_nid, crit, ext_oct);
178 if(!ext) goto merr; 201 if (!ext) goto merr;
179 M_ASN1_OCTET_STRING_free(ext_oct); 202 M_ASN1_OCTET_STRING_free(ext_oct);
180 203
181 return ext; 204 return ext;
@@ -184,14 +207,14 @@ static X509_EXTENSION *do_ext_i2d(X509V3_EXT_METHOD *method, int ext_nid,
184 X509V3err(X509V3_F_DO_EXT_I2D,ERR_R_MALLOC_FAILURE); 207 X509V3err(X509V3_F_DO_EXT_I2D,ERR_R_MALLOC_FAILURE);
185 return NULL; 208 return NULL;
186 209
187} 210 }
188 211
189/* Given an internal structure, nid and critical flag create an extension */ 212/* Given an internal structure, nid and critical flag create an extension */
190 213
191X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc) 214X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc)
192{ 215 {
193 X509V3_EXT_METHOD *method; 216 X509V3_EXT_METHOD *method;
194 if(!(method = X509V3_EXT_get_nid(ext_nid))) { 217 if (!(method = X509V3_EXT_get_nid(ext_nid))) {
195 X509V3err(X509V3_F_X509V3_EXT_I2D,X509V3_R_UNKNOWN_EXTENSION); 218 X509V3err(X509V3_F_X509V3_EXT_I2D,X509V3_R_UNKNOWN_EXTENSION);
196 return NULL; 219 return NULL;
197 } 220 }
@@ -202,7 +225,7 @@ X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc)
202static int v3_check_critical(char **value) 225static int v3_check_critical(char **value)
203{ 226{
204 char *p = *value; 227 char *p = *value;
205 if((strlen(p) < 9) || strncmp(p, "critical,", 9)) return 0; 228 if ((strlen(p) < 9) || strncmp(p, "critical,", 9)) return 0;
206 p+=9; 229 p+=9;
207 while(isspace((unsigned char)*p)) p++; 230 while(isspace((unsigned char)*p)) p++;
208 *value = p; 231 *value = p;
@@ -213,9 +236,9 @@ static int v3_check_critical(char **value)
213static int v3_check_generic(char **value) 236static int v3_check_generic(char **value)
214{ 237{
215 char *p = *value; 238 char *p = *value;
216 if((strlen(p) < 4) || strncmp(p, "DER:,", 4)) return 0; 239 if ((strlen(p) < 4) || strncmp(p, "DER:,", 4)) return 0;
217 p+=4; 240 p+=4;
218 while(isspace((unsigned char)*p)) p++; 241 while (isspace((unsigned char)*p)) p++;
219 *value = p; 242 *value = p;
220 return 1; 243 return 1;
221} 244}
@@ -223,148 +246,202 @@ static int v3_check_generic(char **value)
223/* Create a generic extension: for now just handle DER type */ 246/* Create a generic extension: for now just handle DER type */
224static X509_EXTENSION *v3_generic_extension(const char *ext, char *value, 247static X509_EXTENSION *v3_generic_extension(const char *ext, char *value,
225 int crit, int type) 248 int crit, int type)
226{ 249 {
227unsigned char *ext_der=NULL; 250 unsigned char *ext_der=NULL;
228long ext_len; 251 long ext_len;
229ASN1_OBJECT *obj=NULL; 252 ASN1_OBJECT *obj=NULL;
230ASN1_OCTET_STRING *oct=NULL; 253 ASN1_OCTET_STRING *oct=NULL;
231X509_EXTENSION *extension=NULL; 254 X509_EXTENSION *extension=NULL;
232if(!(obj = OBJ_txt2obj(ext, 0))) { 255 if (!(obj = OBJ_txt2obj(ext, 0)))
233 X509V3err(X509V3_F_V3_GENERIC_EXTENSION,X509V3_R_EXTENSION_NAME_ERROR); 256 {
234 ERR_add_error_data(2, "name=", ext); 257 X509V3err(X509V3_F_V3_GENERIC_EXTENSION,X509V3_R_EXTENSION_NAME_ERROR);
235 goto err; 258 ERR_add_error_data(2, "name=", ext);
236} 259 goto err;
260 }
237 261
238if(!(ext_der = string_to_hex(value, &ext_len))) { 262 if (!(ext_der = string_to_hex(value, &ext_len)))
239 X509V3err(X509V3_F_V3_GENERIC_EXTENSION,X509V3_R_EXTENSION_VALUE_ERROR); 263 {
240 ERR_add_error_data(2, "value=", value); 264 X509V3err(X509V3_F_V3_GENERIC_EXTENSION,X509V3_R_EXTENSION_VALUE_ERROR);
241 goto err; 265 ERR_add_error_data(2, "value=", value);
242} 266 goto err;
267 }
243 268
244if(!(oct = M_ASN1_OCTET_STRING_new())) { 269 if (!(oct = M_ASN1_OCTET_STRING_new()))
245 X509V3err(X509V3_F_V3_GENERIC_EXTENSION,ERR_R_MALLOC_FAILURE); 270 {
246 goto err; 271 X509V3err(X509V3_F_V3_GENERIC_EXTENSION,ERR_R_MALLOC_FAILURE);
247} 272 goto err;
273 }
248 274
249oct->data = ext_der; 275 oct->data = ext_der;
250oct->length = ext_len; 276 oct->length = ext_len;
251ext_der = NULL; 277 ext_der = NULL;
252 278
253extension = X509_EXTENSION_create_by_OBJ(NULL, obj, crit, oct); 279 extension = X509_EXTENSION_create_by_OBJ(NULL, obj, crit, oct);
254 280
255err: 281 err:
256ASN1_OBJECT_free(obj); 282 ASN1_OBJECT_free(obj);
257M_ASN1_OCTET_STRING_free(oct); 283 M_ASN1_OCTET_STRING_free(oct);
258if(ext_der) OPENSSL_free(ext_der); 284 if(ext_der) OPENSSL_free(ext_der);
259return extension; 285 return extension;
260} 286
287 }
261 288
262 289
263/* This is the main function: add a bunch of extensions based on a config file 290/* This is the main function: add a bunch of extensions based on a config file
264 * section 291 * section to an extension STACK.
265 */ 292 */
266 293
267int X509V3_EXT_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, 294
268 X509 *cert) 295int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, char *section,
269{ 296 STACK_OF(X509_EXTENSION) **sk)
297 {
270 X509_EXTENSION *ext; 298 X509_EXTENSION *ext;
271 STACK_OF(CONF_VALUE) *nval; 299 STACK_OF(CONF_VALUE) *nval;
272 CONF_VALUE *val; 300 CONF_VALUE *val;
273 int i; 301 int i;
274 if(!(nval = CONF_get_section(conf, section))) return 0; 302 if (!(nval = NCONF_get_section(conf, section))) return 0;
275 for(i = 0; i < sk_CONF_VALUE_num(nval); i++) { 303 for (i = 0; i < sk_CONF_VALUE_num(nval); i++)
304 {
276 val = sk_CONF_VALUE_value(nval, i); 305 val = sk_CONF_VALUE_value(nval, i);
277 if(!(ext = X509V3_EXT_conf(conf, ctx, val->name, val->value))) 306 if (!(ext = X509V3_EXT_nconf(conf, ctx, val->name, val->value)))
278 return 0; 307 return 0;
279 if(cert) X509_add_ext(cert, ext, -1); 308 if (sk) X509v3_add_ext(sk, ext, -1);
280 X509_EXTENSION_free(ext); 309 X509_EXTENSION_free(ext);
281 } 310 }
282 return 1; 311 return 1;
283} 312 }
313
314/* Convenience functions to add extensions to a certificate, CRL and request */
315
316int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section,
317 X509 *cert)
318 {
319 STACK_OF(X509_EXTENSION) **sk = NULL;
320 if (cert)
321 sk = &cert->cert_info->extensions;
322 return X509V3_EXT_add_nconf_sk(conf, ctx, section, sk);
323 }
284 324
285/* Same as above but for a CRL */ 325/* Same as above but for a CRL */
286 326
287int X509V3_EXT_CRL_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, 327int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section,
288 X509_CRL *crl) 328 X509_CRL *crl)
289{ 329 {
290 X509_EXTENSION *ext; 330 STACK_OF(X509_EXTENSION) **sk = NULL;
291 STACK_OF(CONF_VALUE) *nval; 331 if (crl)
292 CONF_VALUE *val; 332 sk = &crl->crl->extensions;
293 int i; 333 return X509V3_EXT_add_nconf_sk(conf, ctx, section, sk);
294 if(!(nval = CONF_get_section(conf, section))) return 0;
295 for(i = 0; i < sk_CONF_VALUE_num(nval); i++) {
296 val = sk_CONF_VALUE_value(nval, i);
297 if(!(ext = X509V3_EXT_conf(conf, ctx, val->name, val->value)))
298 return 0;
299 if(crl) X509_CRL_add_ext(crl, ext, -1);
300 X509_EXTENSION_free(ext);
301 } 334 }
302 return 1;
303}
304 335
305/* Add extensions to certificate request */ 336/* Add extensions to certificate request */
306 337
307int X509V3_EXT_REQ_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, 338int X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section,
308 X509_REQ *req) 339 X509_REQ *req)
309{ 340 {
310 X509_EXTENSION *ext; 341 STACK_OF(X509_EXTENSION) *extlist = NULL, **sk = NULL;
311 STACK_OF(X509_EXTENSION) *extlist = NULL;
312 STACK_OF(CONF_VALUE) *nval;
313 CONF_VALUE *val;
314 int i; 342 int i;
315 if(!(nval = CONF_get_section(conf, section))) return 0; 343 if (req)
316 for(i = 0; i < sk_CONF_VALUE_num(nval); i++) { 344 sk = &extlist;
317 val = sk_CONF_VALUE_value(nval, i); 345 i = X509V3_EXT_add_nconf_sk(conf, ctx, section, sk);
318 if(!(ext = X509V3_EXT_conf(conf, ctx, val->name, val->value))) 346 if (!i || !sk)
319 return 0; 347 return i;
320 if(!extlist) extlist = sk_X509_EXTENSION_new_null(); 348 i = X509_REQ_add_extensions(req, extlist);
321 sk_X509_EXTENSION_push(extlist, ext);
322 }
323 if(req) i = X509_REQ_add_extensions(req, extlist);
324 else i = 1;
325 sk_X509_EXTENSION_pop_free(extlist, X509_EXTENSION_free); 349 sk_X509_EXTENSION_pop_free(extlist, X509_EXTENSION_free);
326 return i; 350 return i;
327} 351 }
328 352
329/* Config database functions */ 353/* Config database functions */
330 354
331char * X509V3_get_string(X509V3_CTX *ctx, char *name, char *section) 355char * X509V3_get_string(X509V3_CTX *ctx, char *name, char *section)
332{ 356 {
333 if(ctx->db_meth->get_string) 357 if (ctx->db_meth->get_string)
334 return ctx->db_meth->get_string(ctx->db, name, section); 358 return ctx->db_meth->get_string(ctx->db, name, section);
335 return NULL; 359 return NULL;
336} 360 }
337 361
338STACK_OF(CONF_VALUE) * X509V3_get_section(X509V3_CTX *ctx, char *section) 362STACK_OF(CONF_VALUE) * X509V3_get_section(X509V3_CTX *ctx, char *section)
339{ 363 {
340 if(ctx->db_meth->get_section) 364 if (ctx->db_meth->get_section)
341 return ctx->db_meth->get_section(ctx->db, section); 365 return ctx->db_meth->get_section(ctx->db, section);
342 return NULL; 366 return NULL;
343} 367 }
344 368
345void X509V3_string_free(X509V3_CTX *ctx, char *str) 369void X509V3_string_free(X509V3_CTX *ctx, char *str)
346{ 370 {
347 if(!str) return; 371 if (!str) return;
348 if(ctx->db_meth->free_string) 372 if (ctx->db_meth->free_string)
349 ctx->db_meth->free_string(ctx->db, str); 373 ctx->db_meth->free_string(ctx->db, str);
350} 374 }
351 375
352void X509V3_section_free(X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section) 376void X509V3_section_free(X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section)
353{ 377 {
354 if(!section) return; 378 if (!section) return;
355 if(ctx->db_meth->free_section) 379 if (ctx->db_meth->free_section)
356 ctx->db_meth->free_section(ctx->db, section); 380 ctx->db_meth->free_section(ctx->db, section);
357} 381 }
382
383static char *nconf_get_string(void *db, char *section, char *value)
384 {
385 return NCONF_get_string(db, section, value);
386 }
387
388static STACK_OF(CONF_VALUE) *nconf_get_section(void *db, char *section)
389 {
390 return NCONF_get_section(db, section);
391 }
392
393static X509V3_CONF_METHOD nconf_method = {
394nconf_get_string,
395nconf_get_section,
396NULL,
397NULL
398};
399
400void X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf)
401 {
402 ctx->db_meth = &nconf_method;
403 ctx->db = conf;
404 }
405
406void X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subj, X509_REQ *req,
407 X509_CRL *crl, int flags)
408 {
409 ctx->issuer_cert = issuer;
410 ctx->subject_cert = subj;
411 ctx->crl = crl;
412 ctx->subject_req = req;
413 ctx->flags = flags;
414 }
415
416/* Old conf compatibility functions */
417
418X509_EXTENSION *X509V3_EXT_conf(LHASH *conf, X509V3_CTX *ctx, char *name,
419 char *value)
420 {
421 CONF ctmp;
422 CONF_set_nconf(&ctmp, conf);
423 return X509V3_EXT_nconf(&ctmp, ctx, name, value);
424 }
425
426/* LHASH *conf: Config file */
427/* char *value: Value */
428X509_EXTENSION *X509V3_EXT_conf_nid(LHASH *conf, X509V3_CTX *ctx, int ext_nid,
429 char *value)
430 {
431 CONF ctmp;
432 CONF_set_nconf(&ctmp, conf);
433 return X509V3_EXT_nconf_nid(&ctmp, ctx, ext_nid, value);
434 }
358 435
359static char *conf_lhash_get_string(void *db, char *section, char *value) 436static char *conf_lhash_get_string(void *db, char *section, char *value)
360{ 437 {
361 return CONF_get_string(db, section, value); 438 return CONF_get_string(db, section, value);
362} 439 }
363 440
364static STACK_OF(CONF_VALUE) *conf_lhash_get_section(void *db, char *section) 441static STACK_OF(CONF_VALUE) *conf_lhash_get_section(void *db, char *section)
365{ 442 {
366 return CONF_get_section(db, section); 443 return CONF_get_section(db, section);
367} 444 }
368 445
369static X509V3_CONF_METHOD conf_lhash_method = { 446static X509V3_CONF_METHOD conf_lhash_method = {
370conf_lhash_get_string, 447conf_lhash_get_string,
@@ -374,17 +451,35 @@ NULL
374}; 451};
375 452
376void X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH *lhash) 453void X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH *lhash)
377{ 454 {
378 ctx->db_meth = &conf_lhash_method; 455 ctx->db_meth = &conf_lhash_method;
379 ctx->db = lhash; 456 ctx->db = lhash;
380} 457 }
381 458
382void X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subj, X509_REQ *req, 459int X509V3_EXT_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section,
383 X509_CRL *crl, int flags) 460 X509 *cert)
384{ 461 {
385 ctx->issuer_cert = issuer; 462 CONF ctmp;
386 ctx->subject_cert = subj; 463 CONF_set_nconf(&ctmp, conf);
387 ctx->crl = crl; 464 return X509V3_EXT_add_nconf(&ctmp, ctx, section, cert);
388 ctx->subject_req = req; 465 }
389 ctx->flags = flags; 466
390} 467/* Same as above but for a CRL */
468
469int X509V3_EXT_CRL_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section,
470 X509_CRL *crl)
471 {
472 CONF ctmp;
473 CONF_set_nconf(&ctmp, conf);
474 return X509V3_EXT_CRL_add_nconf(&ctmp, ctx, section, crl);
475 }
476
477/* Add extensions to certificate request */
478
479int X509V3_EXT_REQ_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section,
480 X509_REQ *req)
481 {
482 CONF ctmp;
483 CONF_set_nconf(&ctmp, conf);
484 return X509V3_EXT_REQ_add_nconf(&ctmp, ctx, section, req);
485 }
diff --git a/src/lib/libcrypto/x509v3/v3_cpols.c b/src/lib/libcrypto/x509v3/v3_cpols.c
index 8203ed7571..0d4ab1f680 100644
--- a/src/lib/libcrypto/x509v3/v3_cpols.c
+++ b/src/lib/libcrypto/x509v3/v3_cpols.c
@@ -60,7 +60,7 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/conf.h> 61#include <openssl/conf.h>
62#include <openssl/asn1.h> 62#include <openssl/asn1.h>
63#include <openssl/asn1_mac.h> 63#include <openssl/asn1t.h>
64#include <openssl/x509v3.h> 64#include <openssl/x509v3.h>
65 65
66/* Certificate policies extension support: this one is a bit complex... */ 66/* Certificate policies extension support: this one is a bit complex... */
@@ -76,18 +76,55 @@ static POLICYQUALINFO *notice_section(X509V3_CTX *ctx,
76static STACK_OF(ASN1_INTEGER) *nref_nos(STACK_OF(CONF_VALUE) *nos); 76static STACK_OF(ASN1_INTEGER) *nref_nos(STACK_OF(CONF_VALUE) *nos);
77 77
78X509V3_EXT_METHOD v3_cpols = { 78X509V3_EXT_METHOD v3_cpols = {
79NID_certificate_policies, 0, 79NID_certificate_policies, 0,ASN1_ITEM_ref(CERTIFICATEPOLICIES),
80(X509V3_EXT_NEW)CERTIFICATEPOLICIES_new, 800,0,0,0,
81(X509V3_EXT_FREE)CERTIFICATEPOLICIES_free, 810,0,
82(X509V3_EXT_D2I)d2i_CERTIFICATEPOLICIES, 820,0,
83(X509V3_EXT_I2D)i2d_CERTIFICATEPOLICIES,
84NULL, NULL,
85NULL, NULL,
86(X509V3_EXT_I2R)i2r_certpol, 83(X509V3_EXT_I2R)i2r_certpol,
87(X509V3_EXT_R2I)r2i_certpol, 84(X509V3_EXT_R2I)r2i_certpol,
88NULL 85NULL
89}; 86};
90 87
88ASN1_ITEM_TEMPLATE(CERTIFICATEPOLICIES) =
89 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, CERTIFICATEPOLICIES, POLICYINFO)
90ASN1_ITEM_TEMPLATE_END(CERTIFICATEPOLICIES)
91
92IMPLEMENT_ASN1_FUNCTIONS(CERTIFICATEPOLICIES)
93
94ASN1_SEQUENCE(POLICYINFO) = {
95 ASN1_SIMPLE(POLICYINFO, policyid, ASN1_OBJECT),
96 ASN1_SEQUENCE_OF_OPT(POLICYINFO, qualifiers, POLICYQUALINFO)
97} ASN1_SEQUENCE_END(POLICYINFO)
98
99IMPLEMENT_ASN1_FUNCTIONS(POLICYINFO)
100
101ASN1_ADB_TEMPLATE(policydefault) = ASN1_SIMPLE(POLICYQUALINFO, d.other, ASN1_ANY);
102
103ASN1_ADB(POLICYQUALINFO) = {
104 ADB_ENTRY(NID_id_qt_cps, ASN1_SIMPLE(POLICYQUALINFO, d.cpsuri, ASN1_IA5STRING)),
105 ADB_ENTRY(NID_id_qt_unotice, ASN1_SIMPLE(POLICYQUALINFO, d.usernotice, USERNOTICE))
106} ASN1_ADB_END(POLICYQUALINFO, 0, pqualid, 0, &policydefault_tt, NULL);
107
108ASN1_SEQUENCE(POLICYQUALINFO) = {
109 ASN1_SIMPLE(POLICYQUALINFO, pqualid, ASN1_OBJECT),
110 ASN1_ADB_OBJECT(POLICYQUALINFO)
111} ASN1_SEQUENCE_END(POLICYQUALINFO)
112
113IMPLEMENT_ASN1_FUNCTIONS(POLICYQUALINFO)
114
115ASN1_SEQUENCE(USERNOTICE) = {
116 ASN1_OPT(USERNOTICE, noticeref, NOTICEREF),
117 ASN1_OPT(USERNOTICE, exptext, DISPLAYTEXT)
118} ASN1_SEQUENCE_END(USERNOTICE)
119
120IMPLEMENT_ASN1_FUNCTIONS(USERNOTICE)
121
122ASN1_SEQUENCE(NOTICEREF) = {
123 ASN1_SIMPLE(NOTICEREF, organization, DISPLAYTEXT),
124 ASN1_SEQUENCE_OF(NOTICEREF, noticenos, ASN1_INTEGER)
125} ASN1_SEQUENCE_END(NOTICEREF)
126
127IMPLEMENT_ASN1_FUNCTIONS(NOTICEREF)
91 128
92static STACK_OF(POLICYINFO) *r2i_certpol(X509V3_EXT_METHOD *method, 129static STACK_OF(POLICYINFO) *r2i_certpol(X509V3_EXT_METHOD *method,
93 X509V3_CTX *ctx, char *value) 130 X509V3_CTX *ctx, char *value)
@@ -327,83 +364,6 @@ static int i2r_certpol(X509V3_EXT_METHOD *method, STACK_OF(POLICYINFO) *pol,
327 return 1; 364 return 1;
328} 365}
329 366
330
331int i2d_CERTIFICATEPOLICIES(STACK_OF(POLICYINFO) *a, unsigned char **pp)
332{
333
334return i2d_ASN1_SET_OF_POLICYINFO(a, pp, i2d_POLICYINFO, V_ASN1_SEQUENCE,
335 V_ASN1_UNIVERSAL, IS_SEQUENCE);}
336
337STACK_OF(POLICYINFO) *CERTIFICATEPOLICIES_new(void)
338{
339 return sk_POLICYINFO_new_null();
340}
341
342void CERTIFICATEPOLICIES_free(STACK_OF(POLICYINFO) *a)
343{
344 sk_POLICYINFO_pop_free(a, POLICYINFO_free);
345}
346
347STACK_OF(POLICYINFO) *d2i_CERTIFICATEPOLICIES(STACK_OF(POLICYINFO) **a,
348 unsigned char **pp,long length)
349{
350return d2i_ASN1_SET_OF_POLICYINFO(a, pp, length, d2i_POLICYINFO,
351 POLICYINFO_free, V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL);
352
353}
354
355IMPLEMENT_STACK_OF(POLICYINFO)
356IMPLEMENT_ASN1_SET_OF(POLICYINFO)
357
358int i2d_POLICYINFO(POLICYINFO *a, unsigned char **pp)
359{
360 M_ASN1_I2D_vars(a);
361
362 M_ASN1_I2D_len (a->policyid, i2d_ASN1_OBJECT);
363 M_ASN1_I2D_len_SEQUENCE_type(POLICYQUALINFO, a->qualifiers,
364 i2d_POLICYQUALINFO);
365
366 M_ASN1_I2D_seq_total();
367
368 M_ASN1_I2D_put (a->policyid, i2d_ASN1_OBJECT);
369 M_ASN1_I2D_put_SEQUENCE_type(POLICYQUALINFO, a->qualifiers,
370 i2d_POLICYQUALINFO);
371
372 M_ASN1_I2D_finish();
373}
374
375POLICYINFO *POLICYINFO_new(void)
376{
377 POLICYINFO *ret=NULL;
378 ASN1_CTX c;
379 M_ASN1_New_Malloc(ret, POLICYINFO);
380 ret->policyid = NULL;
381 ret->qualifiers = NULL;
382 return (ret);
383 M_ASN1_New_Error(ASN1_F_POLICYINFO_NEW);
384}
385
386POLICYINFO *d2i_POLICYINFO(POLICYINFO **a, unsigned char **pp,long length)
387{
388 M_ASN1_D2I_vars(a,POLICYINFO *,POLICYINFO_new);
389 M_ASN1_D2I_Init();
390 M_ASN1_D2I_start_sequence();
391 M_ASN1_D2I_get(ret->policyid, d2i_ASN1_OBJECT);
392 if(!M_ASN1_D2I_end_sequence()) {
393 M_ASN1_D2I_get_seq_type (POLICYQUALINFO, ret->qualifiers,
394 d2i_POLICYQUALINFO, POLICYQUALINFO_free);
395 }
396 M_ASN1_D2I_Finish(a, POLICYINFO_free, ASN1_F_D2I_POLICYINFO);
397}
398
399void POLICYINFO_free(POLICYINFO *a)
400{
401 if (a == NULL) return;
402 ASN1_OBJECT_free(a->policyid);
403 sk_POLICYQUALINFO_pop_free(a->qualifiers, POLICYQUALINFO_free);
404 OPENSSL_free (a);
405}
406
407static void print_qualifiers(BIO *out, STACK_OF(POLICYQUALINFO) *quals, 367static void print_qualifiers(BIO *out, STACK_OF(POLICYQUALINFO) *quals,
408 int indent) 368 int indent)
409{ 369{
@@ -459,202 +419,4 @@ static void print_notice(BIO *out, USERNOTICE *notice, int indent)
459 BIO_printf(out, "%*sExplicit Text: %s\n", indent, "", 419 BIO_printf(out, "%*sExplicit Text: %s\n", indent, "",
460 notice->exptext->data); 420 notice->exptext->data);
461} 421}
462
463
464
465int i2d_POLICYQUALINFO(POLICYQUALINFO *a, unsigned char **pp)
466{
467 M_ASN1_I2D_vars(a);
468
469 M_ASN1_I2D_len (a->pqualid, i2d_ASN1_OBJECT);
470 switch(OBJ_obj2nid(a->pqualid)) {
471 case NID_id_qt_cps:
472 M_ASN1_I2D_len(a->d.cpsuri, i2d_ASN1_IA5STRING);
473 break;
474
475 case NID_id_qt_unotice:
476 M_ASN1_I2D_len(a->d.usernotice, i2d_USERNOTICE);
477 break;
478
479 default:
480 M_ASN1_I2D_len(a->d.other, i2d_ASN1_TYPE);
481 break;
482 }
483
484 M_ASN1_I2D_seq_total();
485
486 M_ASN1_I2D_put (a->pqualid, i2d_ASN1_OBJECT);
487 switch(OBJ_obj2nid(a->pqualid)) {
488 case NID_id_qt_cps:
489 M_ASN1_I2D_put(a->d.cpsuri, i2d_ASN1_IA5STRING);
490 break;
491
492 case NID_id_qt_unotice:
493 M_ASN1_I2D_put(a->d.usernotice, i2d_USERNOTICE);
494 break;
495
496 default:
497 M_ASN1_I2D_put(a->d.other, i2d_ASN1_TYPE);
498 break;
499 }
500
501 M_ASN1_I2D_finish();
502}
503
504POLICYQUALINFO *POLICYQUALINFO_new(void)
505{
506 POLICYQUALINFO *ret=NULL;
507 ASN1_CTX c;
508 M_ASN1_New_Malloc(ret, POLICYQUALINFO);
509 ret->pqualid = NULL;
510 ret->d.other = NULL;
511 return (ret);
512 M_ASN1_New_Error(ASN1_F_POLICYQUALINFO_NEW);
513}
514
515POLICYQUALINFO *d2i_POLICYQUALINFO(POLICYQUALINFO **a, unsigned char **pp,
516 long length)
517{
518 M_ASN1_D2I_vars(a,POLICYQUALINFO *,POLICYQUALINFO_new);
519 M_ASN1_D2I_Init();
520 M_ASN1_D2I_start_sequence();
521 M_ASN1_D2I_get (ret->pqualid, d2i_ASN1_OBJECT);
522 switch(OBJ_obj2nid(ret->pqualid)) {
523 case NID_id_qt_cps:
524 M_ASN1_D2I_get(ret->d.cpsuri, d2i_ASN1_IA5STRING);
525 break;
526
527 case NID_id_qt_unotice:
528 M_ASN1_D2I_get(ret->d.usernotice, d2i_USERNOTICE);
529 break;
530
531 default:
532 M_ASN1_D2I_get(ret->d.other, d2i_ASN1_TYPE);
533 break;
534 }
535 M_ASN1_D2I_Finish(a, POLICYQUALINFO_free, ASN1_F_D2I_POLICYQUALINFO);
536}
537
538void POLICYQUALINFO_free(POLICYQUALINFO *a)
539{
540 if (a == NULL) return;
541 switch(OBJ_obj2nid(a->pqualid)) {
542 case NID_id_qt_cps:
543 M_ASN1_IA5STRING_free(a->d.cpsuri);
544 break;
545
546 case NID_id_qt_unotice:
547 USERNOTICE_free(a->d.usernotice);
548 break;
549
550 default:
551 ASN1_TYPE_free(a->d.other);
552 break;
553 }
554
555 ASN1_OBJECT_free(a->pqualid);
556 OPENSSL_free (a);
557}
558
559int i2d_USERNOTICE(USERNOTICE *a, unsigned char **pp)
560{
561 M_ASN1_I2D_vars(a);
562
563 M_ASN1_I2D_len (a->noticeref, i2d_NOTICEREF);
564 M_ASN1_I2D_len (a->exptext, i2d_DISPLAYTEXT);
565
566 M_ASN1_I2D_seq_total();
567
568 M_ASN1_I2D_put (a->noticeref, i2d_NOTICEREF);
569 M_ASN1_I2D_put (a->exptext, i2d_DISPLAYTEXT);
570
571 M_ASN1_I2D_finish();
572}
573
574USERNOTICE *USERNOTICE_new(void)
575{
576 USERNOTICE *ret=NULL;
577 ASN1_CTX c;
578 M_ASN1_New_Malloc(ret, USERNOTICE);
579 ret->noticeref = NULL;
580 ret->exptext = NULL;
581 return (ret);
582 M_ASN1_New_Error(ASN1_F_USERNOTICE_NEW);
583}
584
585USERNOTICE *d2i_USERNOTICE(USERNOTICE **a, unsigned char **pp,long length)
586{
587 M_ASN1_D2I_vars(a,USERNOTICE *,USERNOTICE_new);
588 M_ASN1_D2I_Init();
589 M_ASN1_D2I_start_sequence();
590 M_ASN1_D2I_get_opt(ret->noticeref, d2i_NOTICEREF, V_ASN1_SEQUENCE);
591 if (!M_ASN1_D2I_end_sequence()) {
592 M_ASN1_D2I_get(ret->exptext, d2i_DISPLAYTEXT);
593 }
594 M_ASN1_D2I_Finish(a, USERNOTICE_free, ASN1_F_D2I_USERNOTICE);
595}
596
597void USERNOTICE_free(USERNOTICE *a)
598{
599 if (a == NULL) return;
600 NOTICEREF_free(a->noticeref);
601 M_DISPLAYTEXT_free(a->exptext);
602 OPENSSL_free (a);
603}
604
605int i2d_NOTICEREF(NOTICEREF *a, unsigned char **pp)
606{
607 M_ASN1_I2D_vars(a);
608
609 M_ASN1_I2D_len (a->organization, i2d_DISPLAYTEXT);
610 M_ASN1_I2D_len_SEQUENCE_type(ASN1_INTEGER, a->noticenos,
611 i2d_ASN1_INTEGER);
612
613 M_ASN1_I2D_seq_total();
614
615 M_ASN1_I2D_put (a->organization, i2d_DISPLAYTEXT);
616 M_ASN1_I2D_put_SEQUENCE_type(ASN1_INTEGER, a->noticenos,
617 i2d_ASN1_INTEGER);
618
619 M_ASN1_I2D_finish();
620}
621
622NOTICEREF *NOTICEREF_new(void)
623{
624 NOTICEREF *ret=NULL;
625 ASN1_CTX c;
626 M_ASN1_New_Malloc(ret, NOTICEREF);
627 ret->organization = NULL;
628 ret->noticenos = NULL;
629 return (ret);
630 M_ASN1_New_Error(ASN1_F_NOTICEREF_NEW);
631}
632
633NOTICEREF *d2i_NOTICEREF(NOTICEREF **a, unsigned char **pp,long length)
634{
635 M_ASN1_D2I_vars(a,NOTICEREF *,NOTICEREF_new);
636 M_ASN1_D2I_Init();
637 M_ASN1_D2I_start_sequence();
638 /* This is to cope with some broken encodings that use IA5STRING for
639 * the organization field
640 */
641 M_ASN1_D2I_get_opt(ret->organization, d2i_ASN1_IA5STRING,
642 V_ASN1_IA5STRING);
643 if(!ret->organization) {
644 M_ASN1_D2I_get(ret->organization, d2i_DISPLAYTEXT);
645 }
646 M_ASN1_D2I_get_seq_type(ASN1_INTEGER, ret->noticenos, d2i_ASN1_INTEGER,
647 ASN1_STRING_free);
648 M_ASN1_D2I_Finish(a, NOTICEREF_free, ASN1_F_D2I_NOTICEREF);
649}
650
651void NOTICEREF_free(NOTICEREF *a)
652{
653 if (a == NULL) return;
654 M_DISPLAYTEXT_free(a->organization);
655 sk_ASN1_INTEGER_pop_free(a->noticenos, ASN1_STRING_free);
656 OPENSSL_free (a);
657}
658 422
659IMPLEMENT_STACK_OF(POLICYQUALINFO)
660IMPLEMENT_ASN1_SET_OF(POLICYQUALINFO)
diff --git a/src/lib/libcrypto/x509v3/v3_crld.c b/src/lib/libcrypto/x509v3/v3_crld.c
index 67feea4017..894a8b94d8 100644
--- a/src/lib/libcrypto/x509v3/v3_crld.c
+++ b/src/lib/libcrypto/x509v3/v3_crld.c
@@ -60,7 +60,7 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/conf.h> 61#include <openssl/conf.h>
62#include <openssl/asn1.h> 62#include <openssl/asn1.h>
63#include <openssl/asn1_mac.h> 63#include <openssl/asn1t.h>
64#include <openssl/x509v3.h> 64#include <openssl/x509v3.h>
65 65
66static STACK_OF(CONF_VALUE) *i2v_crld(X509V3_EXT_METHOD *method, 66static STACK_OF(CONF_VALUE) *i2v_crld(X509V3_EXT_METHOD *method,
@@ -69,15 +69,13 @@ static STACK_OF(DIST_POINT) *v2i_crld(X509V3_EXT_METHOD *method,
69 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); 69 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval);
70 70
71X509V3_EXT_METHOD v3_crld = { 71X509V3_EXT_METHOD v3_crld = {
72NID_crl_distribution_points, X509V3_EXT_MULTILINE, 72NID_crl_distribution_points, X509V3_EXT_MULTILINE, ASN1_ITEM_ref(CRL_DIST_POINTS),
73(X509V3_EXT_NEW)CRL_DIST_POINTS_new, 730,0,0,0,
74(X509V3_EXT_FREE)CRL_DIST_POINTS_free, 740,0,
75(X509V3_EXT_D2I)d2i_CRL_DIST_POINTS,
76(X509V3_EXT_I2D)i2d_CRL_DIST_POINTS,
77NULL, NULL,
78(X509V3_EXT_I2V)i2v_crld, 75(X509V3_EXT_I2V)i2v_crld,
79(X509V3_EXT_V2I)v2i_crld, 76(X509V3_EXT_V2I)v2i_crld,
80NULL, NULL, NULL 770,0,
78NULL
81}; 79};
82 80
83static STACK_OF(CONF_VALUE) *i2v_crld(X509V3_EXT_METHOD *method, 81static STACK_OF(CONF_VALUE) *i2v_crld(X509V3_EXT_METHOD *method,
@@ -87,16 +85,16 @@ static STACK_OF(CONF_VALUE) *i2v_crld(X509V3_EXT_METHOD *method,
87 int i; 85 int i;
88 for(i = 0; i < sk_DIST_POINT_num(crld); i++) { 86 for(i = 0; i < sk_DIST_POINT_num(crld); i++) {
89 point = sk_DIST_POINT_value(crld, i); 87 point = sk_DIST_POINT_value(crld, i);
90 if(point->distpoint && point->distpoint->fullname) { 88 if(point->distpoint) {
91 exts = i2v_GENERAL_NAMES(NULL, 89 if(point->distpoint->type == 0)
92 point->distpoint->fullname, exts); 90 exts = i2v_GENERAL_NAMES(NULL,
91 point->distpoint->name.fullname, exts);
92 else X509V3_add_value("RelativeName","<UNSUPPORTED>", &exts);
93 } 93 }
94 if(point->reasons) 94 if(point->reasons)
95 X509V3_add_value("reasons","<UNSUPPORTED>", &exts); 95 X509V3_add_value("reasons","<UNSUPPORTED>", &exts);
96 if(point->CRLissuer) 96 if(point->CRLissuer)
97 X509V3_add_value("CRLissuer","<UNSUPPORTED>", &exts); 97 X509V3_add_value("CRLissuer","<UNSUPPORTED>", &exts);
98 if(point->distpoint && point->distpoint->relativename)
99 X509V3_add_value("RelativeName","<UNSUPPORTED>", &exts);
100 } 98 }
101 return exts; 99 return exts;
102} 100}
@@ -105,7 +103,7 @@ static STACK_OF(DIST_POINT) *v2i_crld(X509V3_EXT_METHOD *method,
105 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) 103 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval)
106{ 104{
107 STACK_OF(DIST_POINT) *crld = NULL; 105 STACK_OF(DIST_POINT) *crld = NULL;
108 STACK_OF(GENERAL_NAME) *gens = NULL; 106 GENERAL_NAMES *gens = NULL;
109 GENERAL_NAME *gen = NULL; 107 GENERAL_NAME *gen = NULL;
110 CONF_VALUE *cnf; 108 CONF_VALUE *cnf;
111 int i; 109 int i;
@@ -123,7 +121,8 @@ static STACK_OF(DIST_POINT) *v2i_crld(X509V3_EXT_METHOD *method,
123 goto merr; 121 goto merr;
124 } 122 }
125 if(!(point->distpoint = DIST_POINT_NAME_new())) goto merr; 123 if(!(point->distpoint = DIST_POINT_NAME_new())) goto merr;
126 point->distpoint->fullname = gens; 124 point->distpoint->name.fullname = gens;
125 point->distpoint->type = 0;
127 gens = NULL; 126 gens = NULL;
128 } 127 }
129 return crld; 128 return crld;
@@ -137,149 +136,27 @@ static STACK_OF(DIST_POINT) *v2i_crld(X509V3_EXT_METHOD *method,
137 return NULL; 136 return NULL;
138} 137}
139 138
140int i2d_CRL_DIST_POINTS(STACK_OF(DIST_POINT) *a, unsigned char **pp)
141{
142
143return i2d_ASN1_SET_OF_DIST_POINT(a, pp, i2d_DIST_POINT, V_ASN1_SEQUENCE,
144 V_ASN1_UNIVERSAL, IS_SEQUENCE);}
145
146STACK_OF(DIST_POINT) *CRL_DIST_POINTS_new(void)
147{
148 return sk_DIST_POINT_new_null();
149}
150
151void CRL_DIST_POINTS_free(STACK_OF(DIST_POINT) *a)
152{
153 sk_DIST_POINT_pop_free(a, DIST_POINT_free);
154}
155
156STACK_OF(DIST_POINT) *d2i_CRL_DIST_POINTS(STACK_OF(DIST_POINT) **a,
157 unsigned char **pp,long length)
158{
159return d2i_ASN1_SET_OF_DIST_POINT(a, pp, length, d2i_DIST_POINT,
160 DIST_POINT_free, V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL);
161
162}
163
164IMPLEMENT_STACK_OF(DIST_POINT) 139IMPLEMENT_STACK_OF(DIST_POINT)
165IMPLEMENT_ASN1_SET_OF(DIST_POINT) 140IMPLEMENT_ASN1_SET_OF(DIST_POINT)
166 141
167int i2d_DIST_POINT(DIST_POINT *a, unsigned char **pp)
168{
169 int v = 0;
170 M_ASN1_I2D_vars(a);
171 /* NB: underlying type is a CHOICE so need EXPLICIT tagging */
172 M_ASN1_I2D_len_EXP_opt (a->distpoint, i2d_DIST_POINT_NAME, 0, v);
173 M_ASN1_I2D_len_IMP_opt (a->reasons, i2d_ASN1_BIT_STRING);
174 M_ASN1_I2D_len_IMP_opt (a->CRLissuer, i2d_GENERAL_NAMES);
175 142
176 M_ASN1_I2D_seq_total(); 143ASN1_CHOICE(DIST_POINT_NAME) = {
144 ASN1_IMP_SEQUENCE_OF(DIST_POINT_NAME, name.fullname, GENERAL_NAME, 0),
145 ASN1_IMP_SET_OF(DIST_POINT_NAME, name.relativename, X509_NAME_ENTRY, 1)
146} ASN1_CHOICE_END(DIST_POINT_NAME)
177 147
178 M_ASN1_I2D_put_EXP_opt (a->distpoint, i2d_DIST_POINT_NAME, 0, v); 148IMPLEMENT_ASN1_FUNCTIONS(DIST_POINT_NAME)
179 M_ASN1_I2D_put_IMP_opt (a->reasons, i2d_ASN1_BIT_STRING, 1);
180 M_ASN1_I2D_put_IMP_opt (a->CRLissuer, i2d_GENERAL_NAMES, 2);
181 149
182 M_ASN1_I2D_finish(); 150ASN1_SEQUENCE(DIST_POINT) = {
183} 151 ASN1_EXP_OPT(DIST_POINT, distpoint, DIST_POINT_NAME, 0),
152 ASN1_IMP_OPT(DIST_POINT, reasons, ASN1_BIT_STRING, 1),
153 ASN1_IMP_SEQUENCE_OF_OPT(DIST_POINT, CRLissuer, GENERAL_NAME, 2)
154} ASN1_SEQUENCE_END(DIST_POINT)
184 155
185DIST_POINT *DIST_POINT_new(void) 156IMPLEMENT_ASN1_FUNCTIONS(DIST_POINT)
186{
187 DIST_POINT *ret=NULL;
188 ASN1_CTX c;
189 M_ASN1_New_Malloc(ret, DIST_POINT);
190 ret->distpoint = NULL;
191 ret->reasons = NULL;
192 ret->CRLissuer = NULL;
193 return (ret);
194 M_ASN1_New_Error(ASN1_F_DIST_POINT_NEW);
195}
196 157
197DIST_POINT *d2i_DIST_POINT(DIST_POINT **a, unsigned char **pp, long length) 158ASN1_ITEM_TEMPLATE(CRL_DIST_POINTS) =
198{ 159 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, DIST_POINT, DIST_POINT)
199 M_ASN1_D2I_vars(a,DIST_POINT *,DIST_POINT_new); 160ASN1_ITEM_TEMPLATE_END(CRL_DIST_POINTS)
200 M_ASN1_D2I_Init();
201 M_ASN1_D2I_start_sequence();
202 M_ASN1_D2I_get_EXP_opt (ret->distpoint, d2i_DIST_POINT_NAME, 0);
203 M_ASN1_D2I_get_IMP_opt (ret->reasons, d2i_ASN1_BIT_STRING, 1,
204 V_ASN1_BIT_STRING);
205 M_ASN1_D2I_get_IMP_opt (ret->CRLissuer, d2i_GENERAL_NAMES, 2,
206 V_ASN1_SEQUENCE);
207 M_ASN1_D2I_Finish(a, DIST_POINT_free, ASN1_F_D2I_DIST_POINT);
208}
209 161
210void DIST_POINT_free(DIST_POINT *a) 162IMPLEMENT_ASN1_FUNCTIONS(CRL_DIST_POINTS)
211{
212 if (a == NULL) return;
213 DIST_POINT_NAME_free(a->distpoint);
214 M_ASN1_BIT_STRING_free(a->reasons);
215 sk_GENERAL_NAME_pop_free(a->CRLissuer, GENERAL_NAME_free);
216 OPENSSL_free (a);
217}
218
219int i2d_DIST_POINT_NAME(DIST_POINT_NAME *a, unsigned char **pp)
220{
221 M_ASN1_I2D_vars(a);
222
223 if(a->fullname) {
224 M_ASN1_I2D_len_IMP_opt (a->fullname, i2d_GENERAL_NAMES);
225 } else {
226 M_ASN1_I2D_len_IMP_SET_opt_type(X509_NAME_ENTRY,
227 a->relativename, i2d_X509_NAME_ENTRY, 1);
228 }
229
230 /* Don't want a SEQUENCE so... */
231 if(pp == NULL) return ret;
232 p = *pp;
233
234 if(a->fullname) {
235 M_ASN1_I2D_put_IMP_opt (a->fullname, i2d_GENERAL_NAMES, 0);
236 } else {
237 M_ASN1_I2D_put_IMP_SET_opt_type(X509_NAME_ENTRY,
238 a->relativename, i2d_X509_NAME_ENTRY, 1);
239 }
240 M_ASN1_I2D_finish();
241}
242
243DIST_POINT_NAME *DIST_POINT_NAME_new(void)
244{
245 DIST_POINT_NAME *ret=NULL;
246 ASN1_CTX c;
247 M_ASN1_New_Malloc(ret, DIST_POINT_NAME);
248 ret->fullname = NULL;
249 ret->relativename = NULL;
250 return (ret);
251 M_ASN1_New_Error(ASN1_F_DIST_POINT_NAME_NEW);
252}
253
254void DIST_POINT_NAME_free(DIST_POINT_NAME *a)
255{
256 if (a == NULL) return;
257 sk_X509_NAME_ENTRY_pop_free(a->relativename, X509_NAME_ENTRY_free);
258 sk_GENERAL_NAME_pop_free(a->fullname, GENERAL_NAME_free);
259 OPENSSL_free (a);
260}
261
262DIST_POINT_NAME *d2i_DIST_POINT_NAME(DIST_POINT_NAME **a, unsigned char **pp,
263 long length)
264{
265 unsigned char _tmp, tag;
266 M_ASN1_D2I_vars(a,DIST_POINT_NAME *,DIST_POINT_NAME_new);
267 M_ASN1_D2I_Init();
268 c.slen = length;
269
270 _tmp = M_ASN1_next;
271 tag = _tmp & ~V_ASN1_CONSTRUCTED;
272
273 if(tag == (0|V_ASN1_CONTEXT_SPECIFIC)) {
274 M_ASN1_D2I_get_imp(ret->fullname, d2i_GENERAL_NAMES,
275 V_ASN1_SEQUENCE);
276 } else if (tag == (1|V_ASN1_CONTEXT_SPECIFIC)) {
277 M_ASN1_D2I_get_IMP_set_opt_type (X509_NAME_ENTRY,
278 ret->relativename, d2i_X509_NAME_ENTRY, X509_NAME_ENTRY_free, 1);
279 } else {
280 c.error = ASN1_R_BAD_TAG;
281 goto err;
282 }
283
284 M_ASN1_D2I_Finish(a, DIST_POINT_NAME_free, ASN1_F_D2I_DIST_POINT_NAME);
285}
diff --git a/src/lib/libcrypto/x509v3/v3_enum.c b/src/lib/libcrypto/x509v3/v3_enum.c
index aecfdc87f8..010c9d6260 100644
--- a/src/lib/libcrypto/x509v3/v3_enum.c
+++ b/src/lib/libcrypto/x509v3/v3_enum.c
@@ -73,14 +73,12 @@ static ENUMERATED_NAMES crl_reasons[] = {
73}; 73};
74 74
75X509V3_EXT_METHOD v3_crl_reason = { 75X509V3_EXT_METHOD v3_crl_reason = {
76NID_crl_reason, 0, 76NID_crl_reason, 0, ASN1_ITEM_ref(ASN1_ENUMERATED),
77(X509V3_EXT_NEW)ASN1_ENUMERATED_new, 770,0,0,0,
78(X509V3_EXT_FREE)ASN1_ENUMERATED_free,
79(X509V3_EXT_D2I)d2i_ASN1_ENUMERATED,
80(X509V3_EXT_I2D)i2d_ASN1_ENUMERATED,
81(X509V3_EXT_I2S)i2s_ASN1_ENUMERATED_TABLE, 78(X509V3_EXT_I2S)i2s_ASN1_ENUMERATED_TABLE,
82(X509V3_EXT_S2I)0, 790,
83NULL, NULL, NULL, NULL, crl_reasons}; 800,0,0,0,
81crl_reasons};
84 82
85 83
86char *i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *method, 84char *i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *method,
diff --git a/src/lib/libcrypto/x509v3/v3_extku.c b/src/lib/libcrypto/x509v3/v3_extku.c
index 53ec40a027..b1cfaba1aa 100644
--- a/src/lib/libcrypto/x509v3/v3_extku.c
+++ b/src/lib/libcrypto/x509v3/v3_extku.c
@@ -59,92 +59,84 @@
59 59
60#include <stdio.h> 60#include <stdio.h>
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/asn1.h> 62#include <openssl/asn1t.h>
63#include <openssl/conf.h> 63#include <openssl/conf.h>
64#include <openssl/x509v3.h> 64#include <openssl/x509v3.h>
65 65
66static STACK_OF(ASN1_OBJECT) *v2i_ext_ku(X509V3_EXT_METHOD *method, 66static void *v2i_EXTENDED_KEY_USAGE(X509V3_EXT_METHOD *method,
67 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); 67 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval);
68static STACK_OF(CONF_VALUE) *i2v_ext_ku(X509V3_EXT_METHOD *method, 68static STACK_OF(CONF_VALUE) *i2v_EXTENDED_KEY_USAGE(X509V3_EXT_METHOD *method,
69 STACK_OF(ASN1_OBJECT) *eku, STACK_OF(CONF_VALUE) *extlist); 69 void *eku, STACK_OF(CONF_VALUE) *extlist);
70
70X509V3_EXT_METHOD v3_ext_ku = { 71X509V3_EXT_METHOD v3_ext_ku = {
71NID_ext_key_usage, 0, 72 NID_ext_key_usage, 0,
72(X509V3_EXT_NEW)ext_ku_new, 73 ASN1_ITEM_ref(EXTENDED_KEY_USAGE),
73(X509V3_EXT_FREE)ext_ku_free, 74 0,0,0,0,
74(X509V3_EXT_D2I)d2i_ext_ku, 75 0,0,
75(X509V3_EXT_I2D)i2d_ext_ku, 76 i2v_EXTENDED_KEY_USAGE,
76NULL, NULL, 77 v2i_EXTENDED_KEY_USAGE,
77(X509V3_EXT_I2V)i2v_ext_ku, 78 0,0,
78(X509V3_EXT_V2I)v2i_ext_ku, 79 NULL
79NULL,NULL,
80NULL
81}; 80};
82 81
83STACK_OF(ASN1_OBJECT) *ext_ku_new(void) 82/* NB OCSP acceptable responses also is a SEQUENCE OF OBJECT */
84{ 83X509V3_EXT_METHOD v3_ocsp_accresp = {
85 return sk_ASN1_OBJECT_new_null(); 84 NID_id_pkix_OCSP_acceptableResponses, 0,
86} 85 ASN1_ITEM_ref(EXTENDED_KEY_USAGE),
87 86 0,0,0,0,
88void ext_ku_free(STACK_OF(ASN1_OBJECT) *eku) 87 0,0,
89{ 88 i2v_EXTENDED_KEY_USAGE,
90 sk_ASN1_OBJECT_pop_free(eku, ASN1_OBJECT_free); 89 v2i_EXTENDED_KEY_USAGE,
91 return; 90 0,0,
92} 91 NULL
93 92};
94int i2d_ext_ku(STACK_OF(ASN1_OBJECT) *a, unsigned char **pp)
95{
96 return i2d_ASN1_SET_OF_ASN1_OBJECT(a, pp, i2d_ASN1_OBJECT,
97 V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL, IS_SEQUENCE);
98}
99
100STACK_OF(ASN1_OBJECT) *d2i_ext_ku(STACK_OF(ASN1_OBJECT) **a,
101 unsigned char **pp, long length)
102{
103 return d2i_ASN1_SET_OF_ASN1_OBJECT(a, pp, length, d2i_ASN1_OBJECT,
104 ASN1_OBJECT_free, V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL);
105}
106 93
94ASN1_ITEM_TEMPLATE(EXTENDED_KEY_USAGE) =
95 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, EXTENDED_KEY_USAGE, ASN1_OBJECT)
96ASN1_ITEM_TEMPLATE_END(EXTENDED_KEY_USAGE)
107 97
98IMPLEMENT_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE)
108 99
109static STACK_OF(CONF_VALUE) *i2v_ext_ku(X509V3_EXT_METHOD *method, 100static STACK_OF(CONF_VALUE) *i2v_EXTENDED_KEY_USAGE(X509V3_EXT_METHOD *method,
110 STACK_OF(ASN1_OBJECT) *eku, STACK_OF(CONF_VALUE) *ext_list) 101 void *a, STACK_OF(CONF_VALUE) *ext_list)
111{ 102{
112int i; 103 EXTENDED_KEY_USAGE *eku = a;
113ASN1_OBJECT *obj; 104 int i;
114char obj_tmp[80]; 105 ASN1_OBJECT *obj;
115for(i = 0; i < sk_ASN1_OBJECT_num(eku); i++) { 106 char obj_tmp[80];
116 obj = sk_ASN1_OBJECT_value(eku, i); 107 for(i = 0; i < sk_ASN1_OBJECT_num(eku); i++) {
117 i2t_ASN1_OBJECT(obj_tmp, 80, obj); 108 obj = sk_ASN1_OBJECT_value(eku, i);
118 X509V3_add_value(NULL, obj_tmp, &ext_list); 109 i2t_ASN1_OBJECT(obj_tmp, 80, obj);
119} 110 X509V3_add_value(NULL, obj_tmp, &ext_list);
120return ext_list; 111 }
112 return ext_list;
121} 113}
122 114
123static STACK_OF(ASN1_OBJECT) *v2i_ext_ku(X509V3_EXT_METHOD *method, 115static void *v2i_EXTENDED_KEY_USAGE(X509V3_EXT_METHOD *method,
124 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) 116 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval)
125{ 117{
126STACK_OF(ASN1_OBJECT) *extku; 118 EXTENDED_KEY_USAGE *extku;
127char *extval; 119 char *extval;
128ASN1_OBJECT *objtmp; 120 ASN1_OBJECT *objtmp;
129CONF_VALUE *val; 121 CONF_VALUE *val;
130int i; 122 int i;
131 123
132if(!(extku = sk_ASN1_OBJECT_new_null())) { 124 if(!(extku = sk_ASN1_OBJECT_new_null())) {
133 X509V3err(X509V3_F_V2I_EXT_KU,ERR_R_MALLOC_FAILURE); 125 X509V3err(X509V3_F_V2I_EXT_KU,ERR_R_MALLOC_FAILURE);
134 return NULL;
135}
136
137for(i = 0; i < sk_CONF_VALUE_num(nval); i++) {
138 val = sk_CONF_VALUE_value(nval, i);
139 if(val->value) extval = val->value;
140 else extval = val->name;
141 if(!(objtmp = OBJ_txt2obj(extval, 0))) {
142 sk_ASN1_OBJECT_pop_free(extku, ASN1_OBJECT_free);
143 X509V3err(X509V3_F_V2I_EXT_KU,X509V3_R_INVALID_OBJECT_IDENTIFIER);
144 X509V3_conf_err(val);
145 return NULL; 126 return NULL;
146 } 127 }
147 sk_ASN1_OBJECT_push(extku, objtmp); 128
148} 129 for(i = 0; i < sk_CONF_VALUE_num(nval); i++) {
149return extku; 130 val = sk_CONF_VALUE_value(nval, i);
131 if(val->value) extval = val->value;
132 else extval = val->name;
133 if(!(objtmp = OBJ_txt2obj(extval, 0))) {
134 sk_ASN1_OBJECT_pop_free(extku, ASN1_OBJECT_free);
135 X509V3err(X509V3_F_V2I_EXT_KU,X509V3_R_INVALID_OBJECT_IDENTIFIER);
136 X509V3_conf_err(val);
137 return NULL;
138 }
139 sk_ASN1_OBJECT_push(extku, objtmp);
140 }
141 return extku;
150} 142}
diff --git a/src/lib/libcrypto/x509v3/v3_genn.c b/src/lib/libcrypto/x509v3/v3_genn.c
index d44751458e..650b510980 100644
--- a/src/lib/libcrypto/x509v3/v3_genn.c
+++ b/src/lib/libcrypto/x509v3/v3_genn.c
@@ -59,233 +59,43 @@
59 59
60#include <stdio.h> 60#include <stdio.h>
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/asn1.h> 62#include <openssl/asn1t.h>
63#include <openssl/asn1_mac.h>
64#include <openssl/conf.h> 63#include <openssl/conf.h>
65#include <openssl/x509v3.h> 64#include <openssl/x509v3.h>
66 65
67int i2d_GENERAL_NAME(GENERAL_NAME *a, unsigned char **pp) 66ASN1_SEQUENCE(OTHERNAME) = {
68{ 67 ASN1_SIMPLE(OTHERNAME, type_id, ASN1_OBJECT),
69 unsigned char *p; 68 /* Maybe have a true ANY DEFINED BY later */
70 int ret; 69 ASN1_EXP(OTHERNAME, value, ASN1_ANY, 0)
71 70} ASN1_SEQUENCE_END(OTHERNAME)
72 ret = 0; 71
73 72IMPLEMENT_ASN1_FUNCTIONS(OTHERNAME)
74 /* Save the location of initial TAG */ 73
75 if(pp) p = *pp; 74ASN1_SEQUENCE(EDIPARTYNAME) = {
76 else p = NULL; 75 ASN1_IMP_OPT(EDIPARTYNAME, nameAssigner, DIRECTORYSTRING, 0),
77 76 ASN1_IMP_OPT(EDIPARTYNAME, partyName, DIRECTORYSTRING, 1)
78 /* GEN_DNAME needs special treatment because of EXPLICIT tag */ 77} ASN1_SEQUENCE_END(EDIPARTYNAME)
79 78
80 if(a->type == GEN_DIRNAME) { 79IMPLEMENT_ASN1_FUNCTIONS(EDIPARTYNAME)
81 int v = 0; 80
82 M_ASN1_I2D_len_EXP_opt(a->d.dirn, i2d_X509_NAME, 4, v); 81ASN1_CHOICE(GENERAL_NAME) = {
83 if(!p) return ret; 82 ASN1_IMP(GENERAL_NAME, d.otherName, OTHERNAME, GEN_OTHERNAME),
84 M_ASN1_I2D_put_EXP_opt(a->d.dirn, i2d_X509_NAME, 4, v); 83 ASN1_IMP(GENERAL_NAME, d.rfc822Name, ASN1_IA5STRING, GEN_EMAIL),
85 *pp = p; 84 ASN1_IMP(GENERAL_NAME, d.dNSName, ASN1_IA5STRING, GEN_DNS),
86 return ret; 85 /* Don't decode this */
87 } 86 ASN1_IMP(GENERAL_NAME, d.x400Address, ASN1_SEQUENCE, GEN_X400),
88 87 /* X509_NAME is a CHOICE type so use EXPLICIT */
89 switch(a->type) { 88 ASN1_EXP(GENERAL_NAME, d.directoryName, X509_NAME, GEN_DIRNAME),
90 89 ASN1_IMP(GENERAL_NAME, d.ediPartyName, EDIPARTYNAME, GEN_EDIPARTY),
91 case GEN_X400: 90 ASN1_IMP(GENERAL_NAME, d.uniformResourceIdentifier, ASN1_IA5STRING, GEN_URI),
92 case GEN_EDIPARTY: 91 ASN1_IMP(GENERAL_NAME, d.iPAddress, ASN1_OCTET_STRING, GEN_IPADD),
93 ret = i2d_ASN1_TYPE(a->d.other, pp); 92 ASN1_IMP(GENERAL_NAME, d.registeredID, ASN1_OBJECT, GEN_RID)
94 break; 93} ASN1_CHOICE_END(GENERAL_NAME)
95 94
96 case GEN_OTHERNAME: 95IMPLEMENT_ASN1_FUNCTIONS(GENERAL_NAME)
97 ret = i2d_OTHERNAME(a->d.otherName, pp); 96
98 break; 97ASN1_ITEM_TEMPLATE(GENERAL_NAMES) =
99 98 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, GeneralNames, GENERAL_NAME)
100 case GEN_EMAIL: 99ASN1_ITEM_TEMPLATE_END(GENERAL_NAMES)
101 case GEN_DNS: 100
102 case GEN_URI: 101IMPLEMENT_ASN1_FUNCTIONS(GENERAL_NAMES)
103 ret = i2d_ASN1_IA5STRING(a->d.ia5, pp);
104 break;
105
106 case GEN_IPADD:
107 ret = i2d_ASN1_OCTET_STRING(a->d.ip, pp);
108 break;
109
110 case GEN_RID:
111 ret = i2d_ASN1_OBJECT(a->d.rid, pp);
112 break;
113 }
114 /* Replace TAG with IMPLICIT value */
115 if(p) *p = (*p & V_ASN1_CONSTRUCTED) | a->type;
116 return ret;
117}
118
119GENERAL_NAME *GENERAL_NAME_new()
120{
121 GENERAL_NAME *ret=NULL;
122 ASN1_CTX c;
123 M_ASN1_New_Malloc(ret, GENERAL_NAME);
124 ret->type = -1;
125 ret->d.ptr = NULL;
126 return (ret);
127 M_ASN1_New_Error(ASN1_F_GENERAL_NAME_NEW);
128}
129
130GENERAL_NAME *d2i_GENERAL_NAME(GENERAL_NAME **a, unsigned char **pp,
131 long length)
132{
133 unsigned char _tmp;
134 M_ASN1_D2I_vars(a,GENERAL_NAME *,GENERAL_NAME_new);
135 M_ASN1_D2I_Init();
136 c.slen = length;
137
138 _tmp = M_ASN1_next;
139 ret->type = _tmp & ~V_ASN1_CONSTRUCTED;
140
141 switch(ret->type) {
142 /* Just put these in a "blob" for now */
143 case GEN_X400:
144 case GEN_EDIPARTY:
145 M_ASN1_D2I_get_imp(ret->d.other, d2i_ASN1_TYPE,V_ASN1_SEQUENCE);
146 break;
147
148 case GEN_OTHERNAME:
149 M_ASN1_D2I_get_imp(ret->d.otherName, d2i_OTHERNAME,V_ASN1_SEQUENCE);
150 break;
151
152 case GEN_EMAIL:
153 case GEN_DNS:
154 case GEN_URI:
155 M_ASN1_D2I_get_imp(ret->d.ia5, d2i_ASN1_IA5STRING,
156 V_ASN1_IA5STRING);
157 break;
158
159 case GEN_DIRNAME:
160 M_ASN1_D2I_get_EXP_opt(ret->d.dirn, d2i_X509_NAME, 4);
161 break;
162
163 case GEN_IPADD:
164 M_ASN1_D2I_get_imp(ret->d.ip, d2i_ASN1_OCTET_STRING,
165 V_ASN1_OCTET_STRING);
166 break;
167
168 case GEN_RID:
169 M_ASN1_D2I_get_imp(ret->d.rid, d2i_ASN1_OBJECT,V_ASN1_OBJECT);
170 break;
171
172 default:
173 c.error = ASN1_R_BAD_TAG;
174 goto err;
175 }
176
177 c.slen = 0;
178 M_ASN1_D2I_Finish(a, GENERAL_NAME_free, ASN1_F_D2I_GENERAL_NAME);
179}
180
181void GENERAL_NAME_free(GENERAL_NAME *a)
182{
183 if (a == NULL) return;
184 switch(a->type) {
185 case GEN_X400:
186 case GEN_EDIPARTY:
187 ASN1_TYPE_free(a->d.other);
188 break;
189
190 case GEN_OTHERNAME:
191 OTHERNAME_free(a->d.otherName);
192 break;
193
194 case GEN_EMAIL:
195 case GEN_DNS:
196 case GEN_URI:
197
198 M_ASN1_IA5STRING_free(a->d.ia5);
199 break;
200
201 case GEN_DIRNAME:
202 X509_NAME_free(a->d.dirn);
203 break;
204
205 case GEN_IPADD:
206 M_ASN1_OCTET_STRING_free(a->d.ip);
207 break;
208
209 case GEN_RID:
210 ASN1_OBJECT_free(a->d.rid);
211 break;
212
213 }
214 OPENSSL_free (a);
215}
216
217/* Now the GeneralNames versions: a SEQUENCE OF GeneralName. These are needed as
218 * explicit functions.
219 */
220
221STACK_OF(GENERAL_NAME) *GENERAL_NAMES_new()
222{
223 return sk_GENERAL_NAME_new_null();
224}
225
226void GENERAL_NAMES_free(STACK_OF(GENERAL_NAME) *a)
227{
228 sk_GENERAL_NAME_pop_free(a, GENERAL_NAME_free);
229}
230
231STACK_OF(GENERAL_NAME) *d2i_GENERAL_NAMES(STACK_OF(GENERAL_NAME) **a,
232 unsigned char **pp, long length)
233{
234return d2i_ASN1_SET_OF_GENERAL_NAME(a, pp, length, d2i_GENERAL_NAME,
235 GENERAL_NAME_free, V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL);
236}
237
238int i2d_GENERAL_NAMES(STACK_OF(GENERAL_NAME) *a, unsigned char **pp)
239{
240return i2d_ASN1_SET_OF_GENERAL_NAME(a, pp, i2d_GENERAL_NAME, V_ASN1_SEQUENCE,
241 V_ASN1_UNIVERSAL, IS_SEQUENCE);
242}
243
244IMPLEMENT_STACK_OF(GENERAL_NAME)
245IMPLEMENT_ASN1_SET_OF(GENERAL_NAME)
246
247int i2d_OTHERNAME(OTHERNAME *a, unsigned char **pp)
248{
249 int v = 0;
250 M_ASN1_I2D_vars(a);
251
252 M_ASN1_I2D_len(a->type_id, i2d_ASN1_OBJECT);
253 M_ASN1_I2D_len_EXP_opt(a->value, i2d_ASN1_TYPE, 0, v);
254
255 M_ASN1_I2D_seq_total();
256
257 M_ASN1_I2D_put(a->type_id, i2d_ASN1_OBJECT);
258 M_ASN1_I2D_put_EXP_opt(a->value, i2d_ASN1_TYPE, 0, v);
259
260 M_ASN1_I2D_finish();
261}
262
263OTHERNAME *OTHERNAME_new(void)
264{
265 OTHERNAME *ret=NULL;
266 ASN1_CTX c;
267 M_ASN1_New_Malloc(ret, OTHERNAME);
268 ret->type_id = OBJ_nid2obj(NID_undef);
269 M_ASN1_New(ret->value, ASN1_TYPE_new);
270 return (ret);
271 M_ASN1_New_Error(ASN1_F_OTHERNAME_NEW);
272}
273
274OTHERNAME *d2i_OTHERNAME(OTHERNAME **a, unsigned char **pp, long length)
275{
276 M_ASN1_D2I_vars(a,OTHERNAME *,OTHERNAME_new);
277 M_ASN1_D2I_Init();
278 M_ASN1_D2I_start_sequence();
279 M_ASN1_D2I_get(ret->type_id, d2i_ASN1_OBJECT);
280 M_ASN1_D2I_get_EXP_opt(ret->value, d2i_ASN1_TYPE, 0);
281 M_ASN1_D2I_Finish(a, OTHERNAME_free, ASN1_F_D2I_OTHERNAME);
282}
283
284void OTHERNAME_free(OTHERNAME *a)
285{
286 if (a == NULL) return;
287 ASN1_OBJECT_free(a->type_id);
288 ASN1_TYPE_free(a->value);
289 OPENSSL_free (a);
290}
291
diff --git a/src/lib/libcrypto/x509v3/v3_info.c b/src/lib/libcrypto/x509v3/v3_info.c
index a045a629ee..7f17f3231d 100644
--- a/src/lib/libcrypto/x509v3/v3_info.c
+++ b/src/lib/libcrypto/x509v3/v3_info.c
@@ -60,28 +60,48 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/conf.h> 61#include <openssl/conf.h>
62#include <openssl/asn1.h> 62#include <openssl/asn1.h>
63#include <openssl/asn1_mac.h> 63#include <openssl/asn1t.h>
64#include <openssl/x509v3.h> 64#include <openssl/x509v3.h>
65 65
66static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *method, 66static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *method,
67 STACK_OF(ACCESS_DESCRIPTION) *ainfo, 67 AUTHORITY_INFO_ACCESS *ainfo,
68 STACK_OF(CONF_VALUE) *ret); 68 STACK_OF(CONF_VALUE) *ret);
69static STACK_OF(ACCESS_DESCRIPTION) *v2i_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *method, 69static AUTHORITY_INFO_ACCESS *v2i_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *method,
70 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); 70 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval);
71 71
72X509V3_EXT_METHOD v3_info = 72X509V3_EXT_METHOD v3_info =
73{ NID_info_access, X509V3_EXT_MULTILINE, 73{ NID_info_access, X509V3_EXT_MULTILINE, ASN1_ITEM_ref(AUTHORITY_INFO_ACCESS),
74(X509V3_EXT_NEW)AUTHORITY_INFO_ACCESS_new, 740,0,0,0,
75(X509V3_EXT_FREE)AUTHORITY_INFO_ACCESS_free, 750,0,
76(X509V3_EXT_D2I)d2i_AUTHORITY_INFO_ACCESS,
77(X509V3_EXT_I2D)i2d_AUTHORITY_INFO_ACCESS,
78NULL, NULL,
79(X509V3_EXT_I2V)i2v_AUTHORITY_INFO_ACCESS, 76(X509V3_EXT_I2V)i2v_AUTHORITY_INFO_ACCESS,
80(X509V3_EXT_V2I)v2i_AUTHORITY_INFO_ACCESS, 77(X509V3_EXT_V2I)v2i_AUTHORITY_INFO_ACCESS,
81NULL, NULL, NULL}; 780,0,
79NULL};
80
81X509V3_EXT_METHOD v3_sinfo =
82{ NID_sinfo_access, X509V3_EXT_MULTILINE, ASN1_ITEM_ref(AUTHORITY_INFO_ACCESS),
830,0,0,0,
840,0,
85(X509V3_EXT_I2V)i2v_AUTHORITY_INFO_ACCESS,
86(X509V3_EXT_V2I)v2i_AUTHORITY_INFO_ACCESS,
870,0,
88NULL};
89
90ASN1_SEQUENCE(ACCESS_DESCRIPTION) = {
91 ASN1_SIMPLE(ACCESS_DESCRIPTION, method, ASN1_OBJECT),
92 ASN1_SIMPLE(ACCESS_DESCRIPTION, location, GENERAL_NAME)
93} ASN1_SEQUENCE_END(ACCESS_DESCRIPTION)
94
95IMPLEMENT_ASN1_FUNCTIONS(ACCESS_DESCRIPTION)
96
97ASN1_ITEM_TEMPLATE(AUTHORITY_INFO_ACCESS) =
98 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, GeneralNames, ACCESS_DESCRIPTION)
99ASN1_ITEM_TEMPLATE_END(AUTHORITY_INFO_ACCESS)
100
101IMPLEMENT_ASN1_FUNCTIONS(AUTHORITY_INFO_ACCESS)
82 102
83static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *method, 103static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *method,
84 STACK_OF(ACCESS_DESCRIPTION) *ainfo, 104 AUTHORITY_INFO_ACCESS *ainfo,
85 STACK_OF(CONF_VALUE) *ret) 105 STACK_OF(CONF_VALUE) *ret)
86{ 106{
87 ACCESS_DESCRIPTION *desc; 107 ACCESS_DESCRIPTION *desc;
@@ -111,10 +131,10 @@ static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *method
111 return ret; 131 return ret;
112} 132}
113 133
114static STACK_OF(ACCESS_DESCRIPTION) *v2i_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *method, 134static AUTHORITY_INFO_ACCESS *v2i_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *method,
115 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) 135 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval)
116{ 136{
117 STACK_OF(ACCESS_DESCRIPTION) *ainfo = NULL; 137 AUTHORITY_INFO_ACCESS *ainfo = NULL;
118 CONF_VALUE *cnf, ctmp; 138 CONF_VALUE *cnf, ctmp;
119 ACCESS_DESCRIPTION *acc; 139 ACCESS_DESCRIPTION *acc;
120 int i, objlen; 140 int i, objlen;
@@ -162,75 +182,11 @@ static STACK_OF(ACCESS_DESCRIPTION) *v2i_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD
162 return NULL; 182 return NULL;
163} 183}
164 184
165int i2d_ACCESS_DESCRIPTION(ACCESS_DESCRIPTION *a, unsigned char **pp) 185int i2a_ACCESS_DESCRIPTION(BIO *bp, ACCESS_DESCRIPTION* a)
166{ 186 {
167 M_ASN1_I2D_vars(a); 187 i2a_ASN1_OBJECT(bp, a->method);
168 188#ifdef UNDEF
169 M_ASN1_I2D_len(a->method, i2d_ASN1_OBJECT); 189 i2a_GENERAL_NAME(bp, a->location);
170 M_ASN1_I2D_len(a->location, i2d_GENERAL_NAME); 190#endif
171 191 return 2;
172 M_ASN1_I2D_seq_total(); 192 }
173
174 M_ASN1_I2D_put(a->method, i2d_ASN1_OBJECT);
175 M_ASN1_I2D_put(a->location, i2d_GENERAL_NAME);
176
177 M_ASN1_I2D_finish();
178}
179
180ACCESS_DESCRIPTION *ACCESS_DESCRIPTION_new(void)
181{
182 ACCESS_DESCRIPTION *ret=NULL;
183 ASN1_CTX c;
184 M_ASN1_New_Malloc(ret, ACCESS_DESCRIPTION);
185 ret->method = OBJ_nid2obj(NID_undef);
186 ret->location = NULL;
187 return (ret);
188 M_ASN1_New_Error(ASN1_F_ACCESS_DESCRIPTION_NEW);
189}
190
191ACCESS_DESCRIPTION *d2i_ACCESS_DESCRIPTION(ACCESS_DESCRIPTION **a, unsigned char **pp,
192 long length)
193{
194 M_ASN1_D2I_vars(a,ACCESS_DESCRIPTION *,ACCESS_DESCRIPTION_new);
195 M_ASN1_D2I_Init();
196 M_ASN1_D2I_start_sequence();
197 M_ASN1_D2I_get(ret->method, d2i_ASN1_OBJECT);
198 M_ASN1_D2I_get(ret->location, d2i_GENERAL_NAME);
199 M_ASN1_D2I_Finish(a, ACCESS_DESCRIPTION_free, ASN1_F_D2I_ACCESS_DESCRIPTION);
200}
201
202void ACCESS_DESCRIPTION_free(ACCESS_DESCRIPTION *a)
203{
204 if (a == NULL) return;
205 ASN1_OBJECT_free(a->method);
206 GENERAL_NAME_free(a->location);
207 OPENSSL_free (a);
208}
209
210STACK_OF(ACCESS_DESCRIPTION) *AUTHORITY_INFO_ACCESS_new(void)
211{
212 return sk_ACCESS_DESCRIPTION_new_null();
213}
214
215void AUTHORITY_INFO_ACCESS_free(STACK_OF(ACCESS_DESCRIPTION) *a)
216{
217 sk_ACCESS_DESCRIPTION_pop_free(a, ACCESS_DESCRIPTION_free);
218}
219
220STACK_OF(ACCESS_DESCRIPTION) *d2i_AUTHORITY_INFO_ACCESS(STACK_OF(ACCESS_DESCRIPTION) **a,
221 unsigned char **pp, long length)
222{
223return d2i_ASN1_SET_OF_ACCESS_DESCRIPTION(a, pp, length, d2i_ACCESS_DESCRIPTION,
224 ACCESS_DESCRIPTION_free, V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL);
225}
226
227int i2d_AUTHORITY_INFO_ACCESS(STACK_OF(ACCESS_DESCRIPTION) *a, unsigned char **pp)
228{
229return i2d_ASN1_SET_OF_ACCESS_DESCRIPTION(a, pp, i2d_ACCESS_DESCRIPTION, V_ASN1_SEQUENCE,
230 V_ASN1_UNIVERSAL, IS_SEQUENCE);
231}
232
233IMPLEMENT_STACK_OF(ACCESS_DESCRIPTION)
234IMPLEMENT_ASN1_SET_OF(ACCESS_DESCRIPTION)
235
236
diff --git a/src/lib/libcrypto/x509v3/v3_int.c b/src/lib/libcrypto/x509v3/v3_int.c
index 63c201e5f4..f34cbfb731 100644
--- a/src/lib/libcrypto/x509v3/v3_int.c
+++ b/src/lib/libcrypto/x509v3/v3_int.c
@@ -61,12 +61,9 @@
61#include <openssl/x509v3.h> 61#include <openssl/x509v3.h>
62 62
63X509V3_EXT_METHOD v3_crl_num = { 63X509V3_EXT_METHOD v3_crl_num = {
64NID_crl_number, 0, 64NID_crl_number, 0, ASN1_ITEM_ref(ASN1_INTEGER),
65(X509V3_EXT_NEW)ASN1_INTEGER_new, 650,0,0,0,
66(X509V3_EXT_FREE)ASN1_INTEGER_free,
67(X509V3_EXT_D2I)d2i_ASN1_INTEGER,
68(X509V3_EXT_I2D)i2d_ASN1_INTEGER,
69(X509V3_EXT_I2S)i2s_ASN1_INTEGER, 66(X509V3_EXT_I2S)i2s_ASN1_INTEGER,
70(X509V3_EXT_S2I)0, 670,
71NULL, NULL, NULL, NULL, NULL}; 680,0,0,0, NULL};
72 69
diff --git a/src/lib/libcrypto/x509v3/v3_lib.c b/src/lib/libcrypto/x509v3/v3_lib.c
index ea86b9ebb9..482ca8ccf5 100644
--- a/src/lib/libcrypto/x509v3/v3_lib.c
+++ b/src/lib/libcrypto/x509v3/v3_lib.c
@@ -163,8 +163,9 @@ void *X509V3_EXT_d2i(X509_EXTENSION *ext)
163{ 163{
164 X509V3_EXT_METHOD *method; 164 X509V3_EXT_METHOD *method;
165 unsigned char *p; 165 unsigned char *p;
166 if(!(method = X509V3_EXT_get(ext)) || !method->d2i) return NULL; 166 if(!(method = X509V3_EXT_get(ext))) return NULL;
167 p = ext->value->data; 167 p = ext->value->data;
168 if(method->it) return ASN1_item_d2i(NULL, &p, ext->value->length, ASN1_ITEM_ptr(method->it));
168 return method->d2i(NULL, &p, ext->value->length); 169 return method->d2i(NULL, &p, ext->value->length);
169} 170}
170 171
@@ -212,7 +213,7 @@ void *X509V3_get_d2i(STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx)
212 } 213 }
213 if(found_ex) { 214 if(found_ex) {
214 /* Found it */ 215 /* Found it */
215 if(crit) *crit = found_ex->critical; 216 if(crit) *crit = X509_EXTENSION_get_critical(found_ex);
216 return X509V3_EXT_d2i(found_ex); 217 return X509V3_EXT_d2i(found_ex);
217 } 218 }
218 219
@@ -222,4 +223,79 @@ void *X509V3_get_d2i(STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx)
222 return NULL; 223 return NULL;
223} 224}
224 225
226/* This function is a general extension append, replace and delete utility.
227 * The precise operation is governed by the 'flags' value. The 'crit' and
228 * 'value' arguments (if relevant) are the extensions internal structure.
229 */
230
231int X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value,
232 int crit, unsigned long flags)
233{
234 int extidx = -1;
235 int errcode;
236 X509_EXTENSION *ext, *extmp;
237 unsigned long ext_op = flags & X509V3_ADD_OP_MASK;
238
239 /* If appending we don't care if it exists, otherwise
240 * look for existing extension.
241 */
242 if(ext_op != X509V3_ADD_APPEND)
243 extidx = X509v3_get_ext_by_NID(*x, nid, -1);
244
245 /* See if extension exists */
246 if(extidx >= 0) {
247 /* If keep existing, nothing to do */
248 if(ext_op == X509V3_ADD_KEEP_EXISTING)
249 return 1;
250 /* If default then its an error */
251 if(ext_op == X509V3_ADD_DEFAULT) {
252 errcode = X509V3_R_EXTENSION_EXISTS;
253 goto err;
254 }
255 /* If delete, just delete it */
256 if(ext_op == X509V3_ADD_DELETE) {
257 if(!sk_X509_EXTENSION_delete(*x, extidx)) return -1;
258 return 1;
259 }
260 } else {
261 /* If replace existing or delete, error since
262 * extension must exist
263 */
264 if((ext_op == X509V3_ADD_REPLACE_EXISTING) ||
265 (ext_op == X509V3_ADD_DELETE)) {
266 errcode = X509V3_R_EXTENSION_NOT_FOUND;
267 goto err;
268 }
269 }
270
271 /* If we get this far then we have to create an extension:
272 * could have some flags for alternative encoding schemes...
273 */
274
275 ext = X509V3_EXT_i2d(nid, crit, value);
276
277 if(!ext) {
278 X509V3err(X509V3_F_X509V3_ADD_I2D, X509V3_R_ERROR_CREATING_EXTENSION);
279 return 0;
280 }
281
282 /* If extension exists replace it.. */
283 if(extidx >= 0) {
284 extmp = sk_X509_EXTENSION_value(*x, extidx);
285 X509_EXTENSION_free(extmp);
286 if(!sk_X509_EXTENSION_set(*x, extidx, ext)) return -1;
287 return 1;
288 }
289
290 if(!*x && !(*x = sk_X509_EXTENSION_new_null())) return -1;
291 if(!sk_X509_EXTENSION_push(*x, ext)) return -1;
292
293 return 1;
294
295 err:
296 if(!(flags & X509V3_ADD_SILENT))
297 X509V3err(X509V3_F_X509V3_ADD_I2D, errcode);
298 return 0;
299}
300
225IMPLEMENT_STACK_OF(X509V3_EXT_METHOD) 301IMPLEMENT_STACK_OF(X509V3_EXT_METHOD)
diff --git a/src/lib/libcrypto/x509v3/v3_ocsp.c b/src/lib/libcrypto/x509v3/v3_ocsp.c
new file mode 100644
index 0000000000..083112314e
--- /dev/null
+++ b/src/lib/libcrypto/x509v3/v3_ocsp.c
@@ -0,0 +1,272 @@
1/* v3_ocsp.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/conf.h>
62#include <openssl/asn1.h>
63#include <openssl/ocsp.h>
64#include <openssl/x509v3.h>
65
66/* OCSP extensions and a couple of CRL entry extensions
67 */
68
69static int i2r_ocsp_crlid(X509V3_EXT_METHOD *method, void *nonce, BIO *out, int indent);
70static int i2r_ocsp_acutoff(X509V3_EXT_METHOD *method, void *nonce, BIO *out, int indent);
71static int i2r_object(X509V3_EXT_METHOD *method, void *obj, BIO *out, int indent);
72
73static void *ocsp_nonce_new(void);
74static int i2d_ocsp_nonce(void *a, unsigned char **pp);
75static void *d2i_ocsp_nonce(void *a, unsigned char **pp, long length);
76static void ocsp_nonce_free(void *a);
77static int i2r_ocsp_nonce(X509V3_EXT_METHOD *method, void *nonce, BIO *out, int indent);
78
79static int i2r_ocsp_nocheck(X509V3_EXT_METHOD *method, void *nocheck, BIO *out, int indent);
80static void *s2i_ocsp_nocheck(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str);
81static int i2r_ocsp_serviceloc(X509V3_EXT_METHOD *method, void *in, BIO *bp, int ind);
82
83X509V3_EXT_METHOD v3_ocsp_crlid = {
84 NID_id_pkix_OCSP_CrlID, 0, ASN1_ITEM_ref(OCSP_CRLID),
85 0,0,0,0,
86 0,0,
87 0,0,
88 i2r_ocsp_crlid,0,
89 NULL
90};
91
92X509V3_EXT_METHOD v3_ocsp_acutoff = {
93 NID_id_pkix_OCSP_archiveCutoff, 0, ASN1_ITEM_ref(ASN1_GENERALIZEDTIME),
94 0,0,0,0,
95 0,0,
96 0,0,
97 i2r_ocsp_acutoff,0,
98 NULL
99};
100
101X509V3_EXT_METHOD v3_crl_invdate = {
102 NID_invalidity_date, 0, ASN1_ITEM_ref(ASN1_GENERALIZEDTIME),
103 0,0,0,0,
104 0,0,
105 0,0,
106 i2r_ocsp_acutoff,0,
107 NULL
108};
109
110X509V3_EXT_METHOD v3_crl_hold = {
111 NID_hold_instruction_code, 0, ASN1_ITEM_ref(ASN1_OBJECT),
112 0,0,0,0,
113 0,0,
114 0,0,
115 i2r_object,0,
116 NULL
117};
118
119X509V3_EXT_METHOD v3_ocsp_nonce = {
120 NID_id_pkix_OCSP_Nonce, 0, NULL,
121 ocsp_nonce_new,
122 ocsp_nonce_free,
123 d2i_ocsp_nonce,
124 i2d_ocsp_nonce,
125 0,0,
126 0,0,
127 i2r_ocsp_nonce,0,
128 NULL
129};
130
131X509V3_EXT_METHOD v3_ocsp_nocheck = {
132 NID_id_pkix_OCSP_noCheck, 0, ASN1_ITEM_ref(ASN1_NULL),
133 0,0,0,0,
134 0,s2i_ocsp_nocheck,
135 0,0,
136 i2r_ocsp_nocheck,0,
137 NULL
138};
139
140X509V3_EXT_METHOD v3_ocsp_serviceloc = {
141 NID_id_pkix_OCSP_serviceLocator, 0, ASN1_ITEM_ref(OCSP_SERVICELOC),
142 0,0,0,0,
143 0,0,
144 0,0,
145 i2r_ocsp_serviceloc,0,
146 NULL
147};
148
149static int i2r_ocsp_crlid(X509V3_EXT_METHOD *method, void *in, BIO *bp, int ind)
150{
151 OCSP_CRLID *a = in;
152 if (a->crlUrl)
153 {
154 if (!BIO_printf(bp, "%*scrlUrl: ", ind, "")) goto err;
155 if (!ASN1_STRING_print(bp, (ASN1_STRING*)a->crlUrl)) goto err;
156 if (!BIO_write(bp, "\n", 1)) goto err;
157 }
158 if (a->crlNum)
159 {
160 if (!BIO_printf(bp, "%*scrlNum: ", ind, "")) goto err;
161 if (!i2a_ASN1_INTEGER(bp, a->crlNum)) goto err;
162 if (!BIO_write(bp, "\n", 1)) goto err;
163 }
164 if (a->crlTime)
165 {
166 if (!BIO_printf(bp, "%*scrlTime: ", ind, "")) goto err;
167 if (!ASN1_GENERALIZEDTIME_print(bp, a->crlTime)) goto err;
168 if (!BIO_write(bp, "\n", 1)) goto err;
169 }
170 return 1;
171 err:
172 return 0;
173}
174
175static int i2r_ocsp_acutoff(X509V3_EXT_METHOD *method, void *cutoff, BIO *bp, int ind)
176{
177 if (!BIO_printf(bp, "%*s", ind, "")) return 0;
178 if(!ASN1_GENERALIZEDTIME_print(bp, cutoff)) return 0;
179 return 1;
180}
181
182
183static int i2r_object(X509V3_EXT_METHOD *method, void *oid, BIO *bp, int ind)
184{
185 if (!BIO_printf(bp, "%*s", ind, "")) return 0;
186 if(!i2a_ASN1_OBJECT(bp, oid)) return 0;
187 return 1;
188}
189
190/* OCSP nonce. This is needs special treatment because it doesn't have
191 * an ASN1 encoding at all: it just contains arbitrary data.
192 */
193
194static void *ocsp_nonce_new(void)
195{
196 return ASN1_OCTET_STRING_new();
197}
198
199static int i2d_ocsp_nonce(void *a, unsigned char **pp)
200{
201 ASN1_OCTET_STRING *os = a;
202 if(pp) {
203 memcpy(*pp, os->data, os->length);
204 *pp += os->length;
205 }
206 return os->length;
207}
208
209static void *d2i_ocsp_nonce(void *a, unsigned char **pp, long length)
210{
211 ASN1_OCTET_STRING *os, **pos;
212 pos = a;
213 if(!pos || !*pos) os = ASN1_OCTET_STRING_new();
214 else os = *pos;
215 if(!ASN1_OCTET_STRING_set(os, *pp, length)) goto err;
216
217 *pp += length;
218
219 if(pos) *pos = os;
220 return os;
221
222 err:
223 if(os && (!pos || (*pos != os))) M_ASN1_OCTET_STRING_free(os);
224 OCSPerr(OCSP_F_D2I_OCSP_NONCE, ERR_R_MALLOC_FAILURE);
225 return NULL;
226}
227
228static void ocsp_nonce_free(void *a)
229{
230 M_ASN1_OCTET_STRING_free(a);
231}
232
233static int i2r_ocsp_nonce(X509V3_EXT_METHOD *method, void *nonce, BIO *out, int indent)
234{
235 if(BIO_printf(out, "%*s", indent, "") <= 0) return 0;
236 if(i2a_ASN1_STRING(out, nonce, V_ASN1_OCTET_STRING) <= 0) return 0;
237 return 1;
238}
239
240/* Nocheck is just a single NULL. Don't print anything and always set it */
241
242static int i2r_ocsp_nocheck(X509V3_EXT_METHOD *method, void *nocheck, BIO *out, int indent)
243{
244 return 1;
245}
246
247static void *s2i_ocsp_nocheck(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str)
248{
249 return ASN1_NULL_new();
250}
251
252static int i2r_ocsp_serviceloc(X509V3_EXT_METHOD *method, void *in, BIO *bp, int ind)
253 {
254 int i;
255 OCSP_SERVICELOC *a = in;
256 ACCESS_DESCRIPTION *ad;
257
258 if (BIO_printf(bp, "%*sIssuer: ", ind, "") <= 0) goto err;
259 if (X509_NAME_print_ex(bp, a->issuer, 0, XN_FLAG_ONELINE) <= 0) goto err;
260 for (i = 0; i < sk_ACCESS_DESCRIPTION_num(a->locator); i++)
261 {
262 ad = sk_ACCESS_DESCRIPTION_value(a->locator,i);
263 if (BIO_printf(bp, "\n%*s", (2*ind), "") <= 0)
264 goto err;
265 if(i2a_ASN1_OBJECT(bp, ad->method) <= 0) goto err;
266 if(BIO_puts(bp, " - ") <= 0) goto err;
267 if(GENERAL_NAME_print(bp, ad->location) <= 0) goto err;
268 }
269 return 1;
270err:
271 return 0;
272 }
diff --git a/src/lib/libcrypto/x509v3/v3_pku.c b/src/lib/libcrypto/x509v3/v3_pku.c
index 47f9e8f123..49a2e4697a 100644
--- a/src/lib/libcrypto/x509v3/v3_pku.c
+++ b/src/lib/libcrypto/x509v3/v3_pku.c
@@ -59,7 +59,7 @@
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/asn1.h> 61#include <openssl/asn1.h>
62#include <openssl/asn1_mac.h> 62#include <openssl/asn1t.h>
63#include <openssl/x509v3.h> 63#include <openssl/x509v3.h>
64 64
65static int i2r_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method, PKEY_USAGE_PERIOD *usage, BIO *out, int indent); 65static int i2r_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method, PKEY_USAGE_PERIOD *usage, BIO *out, int indent);
@@ -67,62 +67,19 @@ static int i2r_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method, PKEY_USAGE_PERIOD *u
67static PKEY_USAGE_PERIOD *v2i_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *values); 67static PKEY_USAGE_PERIOD *v2i_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *values);
68*/ 68*/
69X509V3_EXT_METHOD v3_pkey_usage_period = { 69X509V3_EXT_METHOD v3_pkey_usage_period = {
70NID_private_key_usage_period, 0, 70NID_private_key_usage_period, 0, ASN1_ITEM_ref(PKEY_USAGE_PERIOD),
71(X509V3_EXT_NEW)PKEY_USAGE_PERIOD_new, 710,0,0,0,
72(X509V3_EXT_FREE)PKEY_USAGE_PERIOD_free, 720,0,0,0,
73(X509V3_EXT_D2I)d2i_PKEY_USAGE_PERIOD,
74(X509V3_EXT_I2D)i2d_PKEY_USAGE_PERIOD,
75NULL, NULL, NULL, NULL,
76(X509V3_EXT_I2R)i2r_PKEY_USAGE_PERIOD, NULL, 73(X509V3_EXT_I2R)i2r_PKEY_USAGE_PERIOD, NULL,
77NULL 74NULL
78}; 75};
79 76
80int i2d_PKEY_USAGE_PERIOD(PKEY_USAGE_PERIOD *a, unsigned char **pp) 77ASN1_SEQUENCE(PKEY_USAGE_PERIOD) = {
81{ 78 ASN1_IMP_OPT(PKEY_USAGE_PERIOD, notBefore, ASN1_GENERALIZEDTIME, 0),
82 M_ASN1_I2D_vars(a); 79 ASN1_IMP_OPT(PKEY_USAGE_PERIOD, notAfter, ASN1_GENERALIZEDTIME, 1)
83 80} ASN1_SEQUENCE_END(PKEY_USAGE_PERIOD)
84 M_ASN1_I2D_len_IMP_opt (a->notBefore, i2d_ASN1_GENERALIZEDTIME);
85 M_ASN1_I2D_len_IMP_opt (a->notAfter, i2d_ASN1_GENERALIZEDTIME);
86
87 M_ASN1_I2D_seq_total();
88
89 M_ASN1_I2D_put_IMP_opt (a->notBefore, i2d_ASN1_GENERALIZEDTIME, 0);
90 M_ASN1_I2D_put_IMP_opt (a->notAfter, i2d_ASN1_GENERALIZEDTIME, 1);
91
92 M_ASN1_I2D_finish();
93}
94
95PKEY_USAGE_PERIOD *PKEY_USAGE_PERIOD_new(void)
96{
97 PKEY_USAGE_PERIOD *ret=NULL;
98 ASN1_CTX c;
99 M_ASN1_New_Malloc(ret, PKEY_USAGE_PERIOD);
100 ret->notBefore = NULL;
101 ret->notAfter = NULL;
102 return (ret);
103 M_ASN1_New_Error(ASN1_F_PKEY_USAGE_PERIOD_NEW);
104}
105 81
106PKEY_USAGE_PERIOD *d2i_PKEY_USAGE_PERIOD(PKEY_USAGE_PERIOD **a, 82IMPLEMENT_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD)
107 unsigned char **pp, long length)
108{
109 M_ASN1_D2I_vars(a,PKEY_USAGE_PERIOD *,PKEY_USAGE_PERIOD_new);
110 M_ASN1_D2I_Init();
111 M_ASN1_D2I_start_sequence();
112 M_ASN1_D2I_get_IMP_opt (ret->notBefore, d2i_ASN1_GENERALIZEDTIME, 0,
113 V_ASN1_GENERALIZEDTIME);
114 M_ASN1_D2I_get_IMP_opt (ret->notAfter, d2i_ASN1_GENERALIZEDTIME, 1,
115 V_ASN1_GENERALIZEDTIME);
116 M_ASN1_D2I_Finish(a, PKEY_USAGE_PERIOD_free, ASN1_F_D2I_PKEY_USAGE_PERIOD);
117}
118
119void PKEY_USAGE_PERIOD_free(PKEY_USAGE_PERIOD *a)
120{
121 if (a == NULL) return;
122 M_ASN1_GENERALIZEDTIME_free(a->notBefore);
123 M_ASN1_GENERALIZEDTIME_free(a->notAfter);
124 OPENSSL_free (a);
125}
126 83
127static int i2r_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method, 84static int i2r_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method,
128 PKEY_USAGE_PERIOD *usage, BIO *out, int indent) 85 PKEY_USAGE_PERIOD *usage, BIO *out, int indent)
diff --git a/src/lib/libcrypto/x509v3/v3_prn.c b/src/lib/libcrypto/x509v3/v3_prn.c
index 14b804c4ad..aeaf6170fe 100644
--- a/src/lib/libcrypto/x509v3/v3_prn.c
+++ b/src/lib/libcrypto/x509v3/v3_prn.c
@@ -64,6 +64,8 @@
64 64
65/* Extension printing routines */ 65/* Extension printing routines */
66 66
67static int unknown_ext_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, int indent, int supported);
68
67/* Print out a name+value stack */ 69/* Print out a name+value stack */
68 70
69void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent, int ml) 71void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent, int ml)
@@ -103,16 +105,22 @@ void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent, int ml)
103 105
104/* Main routine: print out a general extension */ 106/* Main routine: print out a general extension */
105 107
106int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, int flag, int indent) 108int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, int indent)
107{ 109{
108 char *ext_str = NULL, *value = NULL; 110 void *ext_str = NULL;
111 char *value = NULL;
109 unsigned char *p; 112 unsigned char *p;
110 X509V3_EXT_METHOD *method; 113 X509V3_EXT_METHOD *method;
111 STACK_OF(CONF_VALUE) *nval = NULL; 114 STACK_OF(CONF_VALUE) *nval = NULL;
112 int ok = 1; 115 int ok = 1;
113 if(!(method = X509V3_EXT_get(ext))) return 0; 116 if(!(method = X509V3_EXT_get(ext)))
117 return unknown_ext_print(out, ext, flag, indent, 0);
114 p = ext->value->data; 118 p = ext->value->data;
115 if(!(ext_str = method->d2i(NULL, &p, ext->value->length))) return 0; 119 if(method->it) ext_str = ASN1_item_d2i(NULL, &p, ext->value->length, ASN1_ITEM_ptr(method->it));
120 else ext_str = method->d2i(NULL, &p, ext->value->length);
121
122 if(!ext_str) return unknown_ext_print(out, ext, flag, indent, 1);
123
116 if(method->i2s) { 124 if(method->i2s) {
117 if(!(value = method->i2s(method, ext_str))) { 125 if(!(value = method->i2s(method, ext_str))) {
118 ok = 0; 126 ok = 0;
@@ -148,11 +156,71 @@ int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, int flag, int indent)
148 err: 156 err:
149 sk_CONF_VALUE_pop_free(nval, X509V3_conf_free); 157 sk_CONF_VALUE_pop_free(nval, X509V3_conf_free);
150 if(value) OPENSSL_free(value); 158 if(value) OPENSSL_free(value);
151 method->ext_free(ext_str); 159 if(method->it) ASN1_item_free(ext_str, ASN1_ITEM_ptr(method->it));
160 else method->ext_free(ext_str);
152 return ok; 161 return ok;
153} 162}
154 163
155#ifndef NO_FP_API 164int X509V3_extensions_print(BIO *bp, char *title, STACK_OF(X509_EXTENSION) *exts, unsigned long flag, int indent)
165{
166 int i, j;
167
168 if(sk_X509_EXTENSION_num(exts) <= 0) return 1;
169
170 if(title)
171 {
172 BIO_printf(bp,"%*s%s:\n",indent, "", title);
173 indent += 4;
174 }
175
176 for (i=0; i<sk_X509_EXTENSION_num(exts); i++)
177 {
178 ASN1_OBJECT *obj;
179 X509_EXTENSION *ex;
180 ex=sk_X509_EXTENSION_value(exts, i);
181 if (BIO_printf(bp,"%*s",indent, "") <= 0) return 0;
182 obj=X509_EXTENSION_get_object(ex);
183 i2a_ASN1_OBJECT(bp,obj);
184 j=X509_EXTENSION_get_critical(ex);
185 if (BIO_printf(bp,": %s\n",j?"critical":"","") <= 0)
186 return 0;
187 if(!X509V3_EXT_print(bp, ex, flag, 12))
188 {
189 BIO_printf(bp, "%*s", indent + 4, "");
190 M_ASN1_OCTET_STRING_print(bp,ex->value);
191 }
192 if (BIO_write(bp,"\n",1) <= 0) return 0;
193 }
194 return 1;
195}
196
197static int unknown_ext_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, int indent, int supported)
198{
199 switch(flag & X509V3_EXT_UNKNOWN_MASK) {
200
201 case X509V3_EXT_DEFAULT:
202 return 0;
203
204 case X509V3_EXT_ERROR_UNKNOWN:
205 if(supported)
206 BIO_printf(out, "%*s<Parse Error>", indent, "");
207 else
208 BIO_printf(out, "%*s<Not Supported>", indent, "");
209 return 1;
210
211 case X509V3_EXT_PARSE_UNKNOWN:
212 return ASN1_parse_dump(out,
213 ext->value->data, ext->value->length, indent, -1);
214 case X509V3_EXT_DUMP_UNKNOWN:
215 return BIO_dump_indent(out, (char *)ext->value->data, ext->value->length, indent);
216
217 default:
218 return 1;
219 }
220}
221
222
223#ifndef OPENSSL_NO_FP_API
156int X509V3_EXT_print_fp(FILE *fp, X509_EXTENSION *ext, int flag, int indent) 224int X509V3_EXT_print_fp(FILE *fp, X509_EXTENSION *ext, int flag, int indent)
157{ 225{
158 BIO *bio_tmp; 226 BIO *bio_tmp;
diff --git a/src/lib/libcrypto/x509v3/v3_purp.c b/src/lib/libcrypto/x509v3/v3_purp.c
index 8aecd00e63..b739e4fd83 100644
--- a/src/lib/libcrypto/x509v3/v3_purp.c
+++ b/src/lib/libcrypto/x509v3/v3_purp.c
@@ -1,9 +1,9 @@
1/* v3_purp.c */ 1/* v3_purp.c */
2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL 2/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
3 * project 1999. 3 * project 2001.
4 */ 4 */
5/* ==================================================================== 5/* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. 6 * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
@@ -61,7 +61,6 @@
61#include <openssl/x509v3.h> 61#include <openssl/x509v3.h>
62#include <openssl/x509_vfy.h> 62#include <openssl/x509_vfy.h>
63 63
64
65static void x509v3_cache_extensions(X509 *x); 64static void x509v3_cache_extensions(X509 *x);
66 65
67static int ca_check(const X509 *x); 66static int ca_check(const X509 *x);
@@ -74,6 +73,7 @@ static int check_purpose_smime_sign(const X509_PURPOSE *xp, const X509 *x, int c
74static int check_purpose_smime_encrypt(const X509_PURPOSE *xp, const X509 *x, int ca); 73static int check_purpose_smime_encrypt(const X509_PURPOSE *xp, const X509 *x, int ca);
75static int check_purpose_crl_sign(const X509_PURPOSE *xp, const X509 *x, int ca); 74static int check_purpose_crl_sign(const X509_PURPOSE *xp, const X509 *x, int ca);
76static int no_check(const X509_PURPOSE *xp, const X509 *x, int ca); 75static int no_check(const X509_PURPOSE *xp, const X509 *x, int ca);
76static int ocsp_helper(const X509_PURPOSE *xp, const X509 *x, int ca);
77 77
78static int xp_cmp(const X509_PURPOSE * const *a, 78static int xp_cmp(const X509_PURPOSE * const *a,
79 const X509_PURPOSE * const *b); 79 const X509_PURPOSE * const *b);
@@ -87,6 +87,7 @@ static X509_PURPOSE xstandard[] = {
87 {X509_PURPOSE_SMIME_ENCRYPT, X509_TRUST_EMAIL, 0, check_purpose_smime_encrypt, "S/MIME encryption", "smimeencrypt", NULL}, 87 {X509_PURPOSE_SMIME_ENCRYPT, X509_TRUST_EMAIL, 0, check_purpose_smime_encrypt, "S/MIME encryption", "smimeencrypt", NULL},
88 {X509_PURPOSE_CRL_SIGN, X509_TRUST_COMPAT, 0, check_purpose_crl_sign, "CRL signing", "crlsign", NULL}, 88 {X509_PURPOSE_CRL_SIGN, X509_TRUST_COMPAT, 0, check_purpose_crl_sign, "CRL signing", "crlsign", NULL},
89 {X509_PURPOSE_ANY, X509_TRUST_DEFAULT, 0, no_check, "Any Purpose", "any", NULL}, 89 {X509_PURPOSE_ANY, X509_TRUST_DEFAULT, 0, no_check, "Any Purpose", "any", NULL},
90 {X509_PURPOSE_OCSP_HELPER, X509_TRUST_COMPAT, 0, ocsp_helper, "OCSP helper", "ocsphelper", NULL},
90}; 91};
91 92
92#define X509_PURPOSE_COUNT (sizeof(xstandard)/sizeof(X509_PURPOSE)) 93#define X509_PURPOSE_COUNT (sizeof(xstandard)/sizeof(X509_PURPOSE))
@@ -120,6 +121,16 @@ int X509_check_purpose(X509 *x, int id, int ca)
120 return pt->check_purpose(pt, x, ca); 121 return pt->check_purpose(pt, x, ca);
121} 122}
122 123
124int X509_PURPOSE_set(int *p, int purpose)
125{
126 if(X509_PURPOSE_get_by_id(purpose) == -1) {
127 X509V3err(X509V3_F_X509_PURPOSE_SET, X509V3_R_INVALID_PURPOSE);
128 return 0;
129 }
130 *p = purpose;
131 return 1;
132}
133
123int X509_PURPOSE_get_count(void) 134int X509_PURPOSE_get_count(void)
124{ 135{
125 if(!xptable) return X509_PURPOSE_COUNT; 136 if(!xptable) return X509_PURPOSE_COUNT;
@@ -144,7 +155,6 @@ int X509_PURPOSE_get_by_sname(char *sname)
144 return -1; 155 return -1;
145} 156}
146 157
147
148int X509_PURPOSE_get_by_id(int purpose) 158int X509_PURPOSE_get_by_id(int purpose)
149{ 159{
150 X509_PURPOSE tmp; 160 X509_PURPOSE tmp;
@@ -256,16 +266,55 @@ int X509_PURPOSE_get_trust(X509_PURPOSE *xp)
256 return xp->trust; 266 return xp->trust;
257} 267}
258 268
269static int nid_cmp(int *a, int *b)
270 {
271 return *a - *b;
272 }
273
274int X509_supported_extension(X509_EXTENSION *ex)
275 {
276 /* This table is a list of the NIDs of supported extensions:
277 * that is those which are used by the verify process. If
278 * an extension is critical and doesn't appear in this list
279 * then the verify process will normally reject the certificate.
280 * The list must be kept in numerical order because it will be
281 * searched using bsearch.
282 */
283
284 static int supported_nids[] = {
285 NID_netscape_cert_type, /* 71 */
286 NID_key_usage, /* 83 */
287 NID_subject_alt_name, /* 85 */
288 NID_basic_constraints, /* 87 */
289 NID_ext_key_usage /* 126 */
290 };
291
292 int ex_nid;
293
294 ex_nid = OBJ_obj2nid(X509_EXTENSION_get_object(ex));
295
296 if (ex_nid == NID_undef)
297 return 0;
298
299 if (OBJ_bsearch((char *)&ex_nid, (char *)supported_nids,
300 sizeof(supported_nids)/sizeof(int), sizeof(int),
301 (int (*)(const void *, const void *))nid_cmp))
302 return 1;
303 return 0;
304 }
305
306
259static void x509v3_cache_extensions(X509 *x) 307static void x509v3_cache_extensions(X509 *x)
260{ 308{
261 BASIC_CONSTRAINTS *bs; 309 BASIC_CONSTRAINTS *bs;
262 ASN1_BIT_STRING *usage; 310 ASN1_BIT_STRING *usage;
263 ASN1_BIT_STRING *ns; 311 ASN1_BIT_STRING *ns;
264 STACK_OF(ASN1_OBJECT) *extusage; 312 EXTENDED_KEY_USAGE *extusage;
313 X509_EXTENSION *ex;
265 314
266 int i; 315 int i;
267 if(x->ex_flags & EXFLAG_SET) return; 316 if(x->ex_flags & EXFLAG_SET) return;
268#ifndef NO_SHA 317#ifndef OPENSSL_NO_SHA
269 X509_digest(x, EVP_sha1(), x->sha1_hash, NULL); 318 X509_digest(x, EVP_sha1(), x->sha1_hash, NULL);
270#endif 319#endif
271 /* Does subject name match issuer ? */ 320 /* Does subject name match issuer ? */
@@ -320,6 +369,15 @@ static void x509v3_cache_extensions(X509 *x)
320 case NID_ms_sgc: 369 case NID_ms_sgc:
321 case NID_ns_sgc: 370 case NID_ns_sgc:
322 x->ex_xkusage |= XKU_SGC; 371 x->ex_xkusage |= XKU_SGC;
372 break;
373
374 case NID_OCSP_sign:
375 x->ex_xkusage |= XKU_OCSP_SIGN;
376 break;
377
378 case NID_time_stamp:
379 x->ex_xkusage |= XKU_TIMESTAMP;
380 break;
323 } 381 }
324 } 382 }
325 sk_ASN1_OBJECT_pop_free(extusage, ASN1_OBJECT_free); 383 sk_ASN1_OBJECT_pop_free(extusage, ASN1_OBJECT_free);
@@ -333,6 +391,17 @@ static void x509v3_cache_extensions(X509 *x)
333 } 391 }
334 x->skid =X509_get_ext_d2i(x, NID_subject_key_identifier, NULL, NULL); 392 x->skid =X509_get_ext_d2i(x, NID_subject_key_identifier, NULL, NULL);
335 x->akid =X509_get_ext_d2i(x, NID_authority_key_identifier, NULL, NULL); 393 x->akid =X509_get_ext_d2i(x, NID_authority_key_identifier, NULL, NULL);
394 for (i = 0; i < X509_get_ext_count(x); i++)
395 {
396 ex = X509_get_ext(x, i);
397 if (!X509_EXTENSION_get_critical(ex))
398 continue;
399 if (!X509_supported_extension(ex))
400 {
401 x->ex_flags |= EXFLAG_CRITICAL;
402 break;
403 }
404 }
336 x->ex_flags |= EXFLAG_SET; 405 x->ex_flags |= EXFLAG_SET;
337} 406}
338 407
@@ -472,6 +541,27 @@ static int check_purpose_crl_sign(const X509_PURPOSE *xp, const X509 *x, int ca)
472 return 1; 541 return 1;
473} 542}
474 543
544/* OCSP helper: this is *not* a full OCSP check. It just checks that
545 * each CA is valid. Additional checks must be made on the chain.
546 */
547
548static int ocsp_helper(const X509_PURPOSE *xp, const X509 *x, int ca)
549{
550 /* Must be a valid CA */
551 if(ca) {
552 int ca_ret;
553 ca_ret = ca_check(x);
554 if(ca_ret != 2) return ca_ret;
555 if(x->ex_flags & EXFLAG_NSCERT) {
556 if(x->ex_nscert & NS_ANY_CA) return ca_ret;
557 return 0;
558 }
559 return 0;
560 }
561 /* leaf certificate is checked in OCSP_verify() */
562 return 1;
563}
564
475static int no_check(const X509_PURPOSE *xp, const X509 *x, int ca) 565static int no_check(const X509_PURPOSE *xp, const X509 *x, int ca)
476{ 566{
477 return 1; 567 return 1;
@@ -513,7 +603,7 @@ int X509_check_issued(X509 *issuer, X509 *subject)
513 * There may be more than one but we only take any 603 * There may be more than one but we only take any
514 * notice of the first. 604 * notice of the first.
515 */ 605 */
516 STACK_OF(GENERAL_NAME) *gens; 606 GENERAL_NAMES *gens;
517 GENERAL_NAME *gen; 607 GENERAL_NAME *gen;
518 X509_NAME *nm = NULL; 608 X509_NAME *nm = NULL;
519 int i; 609 int i;
diff --git a/src/lib/libcrypto/x509v3/v3_skey.c b/src/lib/libcrypto/x509v3/v3_skey.c
index 939845fa8f..c0f044ac1b 100644
--- a/src/lib/libcrypto/x509v3/v3_skey.c
+++ b/src/lib/libcrypto/x509v3/v3_skey.c
@@ -63,14 +63,12 @@
63 63
64static ASN1_OCTET_STRING *s2i_skey_id(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str); 64static ASN1_OCTET_STRING *s2i_skey_id(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str);
65X509V3_EXT_METHOD v3_skey_id = { 65X509V3_EXT_METHOD v3_skey_id = {
66NID_subject_key_identifier, 0, 66NID_subject_key_identifier, 0, ASN1_ITEM_ref(ASN1_OCTET_STRING),
67(X509V3_EXT_NEW)ASN1_OCTET_STRING_new, 670,0,0,0,
68(X509V3_EXT_FREE)ASN1_OCTET_STRING_free,
69(X509V3_EXT_D2I)d2i_ASN1_OCTET_STRING,
70(X509V3_EXT_I2D)i2d_ASN1_OCTET_STRING,
71(X509V3_EXT_I2S)i2s_ASN1_OCTET_STRING, 68(X509V3_EXT_I2S)i2s_ASN1_OCTET_STRING,
72(X509V3_EXT_S2I)s2i_skey_id, 69(X509V3_EXT_S2I)s2i_skey_id,
73NULL, NULL, NULL, NULL, NULL}; 700,0,0,0,
71NULL};
74 72
75char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, 73char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method,
76 ASN1_OCTET_STRING *oct) 74 ASN1_OCTET_STRING *oct)
@@ -106,7 +104,6 @@ static ASN1_OCTET_STRING *s2i_skey_id(X509V3_EXT_METHOD *method,
106 ASN1_OCTET_STRING *oct; 104 ASN1_OCTET_STRING *oct;
107 ASN1_BIT_STRING *pk; 105 ASN1_BIT_STRING *pk;
108 unsigned char pkey_dig[EVP_MAX_MD_SIZE]; 106 unsigned char pkey_dig[EVP_MAX_MD_SIZE];
109 EVP_MD_CTX md;
110 unsigned int diglen; 107 unsigned int diglen;
111 108
112 if(strcmp(str, "hash")) return s2i_ASN1_OCTET_STRING(method, ctx, str); 109 if(strcmp(str, "hash")) return s2i_ASN1_OCTET_STRING(method, ctx, str);
@@ -132,9 +129,7 @@ static ASN1_OCTET_STRING *s2i_skey_id(X509V3_EXT_METHOD *method,
132 goto err; 129 goto err;
133 } 130 }
134 131
135 EVP_DigestInit(&md, EVP_sha1()); 132 EVP_Digest(pk->data, pk->length, pkey_dig, &diglen, EVP_sha1(), NULL);
136 EVP_DigestUpdate(&md, pk->data, pk->length);
137 EVP_DigestFinal(&md, pkey_dig, &diglen);
138 133
139 if(!M_ASN1_OCTET_STRING_set(oct, pkey_dig, diglen)) { 134 if(!M_ASN1_OCTET_STRING_set(oct, pkey_dig, diglen)) {
140 X509V3err(X509V3_F_S2I_S2I_SKEY_ID,ERR_R_MALLOC_FAILURE); 135 X509V3err(X509V3_F_S2I_S2I_SKEY_ID,ERR_R_MALLOC_FAILURE);
diff --git a/src/lib/libcrypto/x509v3/v3_sxnet.c b/src/lib/libcrypto/x509v3/v3_sxnet.c
index bfecacd336..d3f4ba3a72 100644
--- a/src/lib/libcrypto/x509v3/v3_sxnet.c
+++ b/src/lib/libcrypto/x509v3/v3_sxnet.c
@@ -60,7 +60,7 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/conf.h> 61#include <openssl/conf.h>
62#include <openssl/asn1.h> 62#include <openssl/asn1.h>
63#include <openssl/asn1_mac.h> 63#include <openssl/asn1t.h>
64#include <openssl/x509v3.h> 64#include <openssl/x509v3.h>
65 65
66/* Support for Thawte strong extranet extension */ 66/* Support for Thawte strong extranet extension */
@@ -73,111 +73,33 @@ static SXNET * sxnet_v2i(X509V3_EXT_METHOD *method, X509V3_CTX *ctx,
73 STACK_OF(CONF_VALUE) *nval); 73 STACK_OF(CONF_VALUE) *nval);
74#endif 74#endif
75X509V3_EXT_METHOD v3_sxnet = { 75X509V3_EXT_METHOD v3_sxnet = {
76NID_sxnet, X509V3_EXT_MULTILINE, 76NID_sxnet, X509V3_EXT_MULTILINE, ASN1_ITEM_ref(SXNET),
77(X509V3_EXT_NEW)SXNET_new, 770,0,0,0,
78(X509V3_EXT_FREE)SXNET_free, 780,0,
79(X509V3_EXT_D2I)d2i_SXNET, 790,
80(X509V3_EXT_I2D)i2d_SXNET,
81NULL, NULL,
82NULL,
83#ifdef SXNET_TEST 80#ifdef SXNET_TEST
84(X509V3_EXT_V2I)sxnet_v2i, 81(X509V3_EXT_V2I)sxnet_v2i,
85#else 82#else
86NULL, 830,
87#endif 84#endif
88(X509V3_EXT_I2R)sxnet_i2r, 85(X509V3_EXT_I2R)sxnet_i2r,
89NULL, 860,
90NULL 87NULL
91}; 88};
92 89
90ASN1_SEQUENCE(SXNETID) = {
91 ASN1_SIMPLE(SXNETID, zone, ASN1_INTEGER),
92 ASN1_SIMPLE(SXNETID, user, ASN1_OCTET_STRING)
93} ASN1_SEQUENCE_END(SXNETID)
93 94
94int i2d_SXNET(SXNET *a, unsigned char **pp) 95IMPLEMENT_ASN1_FUNCTIONS(SXNETID)
95{
96 M_ASN1_I2D_vars(a);
97
98 M_ASN1_I2D_len (a->version, i2d_ASN1_INTEGER);
99 M_ASN1_I2D_len_SEQUENCE_type (SXNETID, a->ids, i2d_SXNETID);
100
101 M_ASN1_I2D_seq_total();
102
103 M_ASN1_I2D_put (a->version, i2d_ASN1_INTEGER);
104 M_ASN1_I2D_put_SEQUENCE_type (SXNETID, a->ids, i2d_SXNETID);
105 96
106 M_ASN1_I2D_finish(); 97ASN1_SEQUENCE(SXNET) = {
107} 98 ASN1_SIMPLE(SXNET, version, ASN1_INTEGER),
108 99 ASN1_SEQUENCE_OF(SXNET, ids, SXNETID)
109SXNET *SXNET_new(void) 100} ASN1_SEQUENCE_END(SXNET)
110{
111 SXNET *ret=NULL;
112 ASN1_CTX c;
113 M_ASN1_New_Malloc(ret, SXNET);
114 M_ASN1_New(ret->version,M_ASN1_INTEGER_new);
115 M_ASN1_New(ret->ids,sk_SXNETID_new_null);
116 return (ret);
117 M_ASN1_New_Error(ASN1_F_SXNET_NEW);
118}
119 101
120SXNET *d2i_SXNET(SXNET **a, unsigned char **pp, long length) 102IMPLEMENT_ASN1_FUNCTIONS(SXNET)
121{
122 M_ASN1_D2I_vars(a,SXNET *,SXNET_new);
123 M_ASN1_D2I_Init();
124 M_ASN1_D2I_start_sequence();
125 M_ASN1_D2I_get (ret->version, d2i_ASN1_INTEGER);
126 M_ASN1_D2I_get_seq_type (SXNETID, ret->ids, d2i_SXNETID, SXNETID_free);
127 M_ASN1_D2I_Finish(a, SXNET_free, ASN1_F_D2I_SXNET);
128}
129
130void SXNET_free(SXNET *a)
131{
132 if (a == NULL) return;
133 M_ASN1_INTEGER_free(a->version);
134 sk_SXNETID_pop_free(a->ids, SXNETID_free);
135 OPENSSL_free (a);
136}
137
138int i2d_SXNETID(SXNETID *a, unsigned char **pp)
139{
140 M_ASN1_I2D_vars(a);
141
142 M_ASN1_I2D_len (a->zone, i2d_ASN1_INTEGER);
143 M_ASN1_I2D_len (a->user, i2d_ASN1_OCTET_STRING);
144
145 M_ASN1_I2D_seq_total();
146
147 M_ASN1_I2D_put (a->zone, i2d_ASN1_INTEGER);
148 M_ASN1_I2D_put (a->user, i2d_ASN1_OCTET_STRING);
149
150 M_ASN1_I2D_finish();
151}
152
153SXNETID *SXNETID_new(void)
154{
155 SXNETID *ret=NULL;
156 ASN1_CTX c;
157 M_ASN1_New_Malloc(ret, SXNETID);
158 ret->zone = NULL;
159 M_ASN1_New(ret->user,M_ASN1_OCTET_STRING_new);
160 return (ret);
161 M_ASN1_New_Error(ASN1_F_SXNETID_NEW);
162}
163
164SXNETID *d2i_SXNETID(SXNETID **a, unsigned char **pp, long length)
165{
166 M_ASN1_D2I_vars(a,SXNETID *,SXNETID_new);
167 M_ASN1_D2I_Init();
168 M_ASN1_D2I_start_sequence();
169 M_ASN1_D2I_get(ret->zone, d2i_ASN1_INTEGER);
170 M_ASN1_D2I_get(ret->user, d2i_ASN1_OCTET_STRING);
171 M_ASN1_D2I_Finish(a, SXNETID_free, ASN1_F_D2I_SXNETID);
172}
173
174void SXNETID_free(SXNETID *a)
175{
176 if (a == NULL) return;
177 M_ASN1_INTEGER_free(a->zone);
178 M_ASN1_OCTET_STRING_free(a->user);
179 OPENSSL_free (a);
180}
181 103
182static int sxnet_i2r(X509V3_EXT_METHOD *method, SXNET *sx, BIO *out, 104static int sxnet_i2r(X509V3_EXT_METHOD *method, SXNET *sx, BIO *out,
183 int indent) 105 int indent)
diff --git a/src/lib/libcrypto/x509v3/v3_utl.c b/src/lib/libcrypto/x509v3/v3_utl.c
index 619f161b58..283e943e46 100644
--- a/src/lib/libcrypto/x509v3/v3_utl.c
+++ b/src/lib/libcrypto/x509v3/v3_utl.c
@@ -66,7 +66,7 @@
66 66
67static char *strip_spaces(char *name); 67static char *strip_spaces(char *name);
68static int sk_strcmp(const char * const *a, const char * const *b); 68static int sk_strcmp(const char * const *a, const char * const *b);
69static STACK *get_email(X509_NAME *name, STACK_OF(GENERAL_NAME) *gens); 69static STACK *get_email(X509_NAME *name, GENERAL_NAMES *gens);
70static void str_free(void *str); 70static void str_free(void *str);
71static int append_ia5(STACK **sk, ASN1_IA5STRING *email); 71static int append_ia5(STACK **sk, ASN1_IA5STRING *email);
72 72
@@ -154,21 +154,40 @@ ASN1_INTEGER *s2i_ASN1_INTEGER(X509V3_EXT_METHOD *method, char *value)
154{ 154{
155 BIGNUM *bn = NULL; 155 BIGNUM *bn = NULL;
156 ASN1_INTEGER *aint; 156 ASN1_INTEGER *aint;
157 int isneg, ishex;
158 int ret;
157 bn = BN_new(); 159 bn = BN_new();
158 if(!value) { 160 if (!value) {
159 X509V3err(X509V3_F_S2I_ASN1_INTEGER,X509V3_R_INVALID_NULL_VALUE); 161 X509V3err(X509V3_F_S2I_ASN1_INTEGER,X509V3_R_INVALID_NULL_VALUE);
160 return 0; 162 return 0;
161 } 163 }
162 if(!BN_dec2bn(&bn, value)) { 164 if (value[0] == '-') {
165 value++;
166 isneg = 1;
167 } else isneg = 0;
168
169 if (value[0] == '0' && ((value[1] == 'x') || (value[1] == 'X'))) {
170 value += 2;
171 ishex = 1;
172 } else ishex = 0;
173
174 if (ishex) ret = BN_hex2bn(&bn, value);
175 else ret = BN_dec2bn(&bn, value);
176
177 if (!ret) {
163 X509V3err(X509V3_F_S2I_ASN1_INTEGER,X509V3_R_BN_DEC2BN_ERROR); 178 X509V3err(X509V3_F_S2I_ASN1_INTEGER,X509V3_R_BN_DEC2BN_ERROR);
164 return 0; 179 return 0;
165 } 180 }
166 181
167 if(!(aint = BN_to_ASN1_INTEGER(bn, NULL))) { 182 if (isneg && BN_is_zero(bn)) isneg = 0;
183
184 aint = BN_to_ASN1_INTEGER(bn, NULL);
185 BN_free(bn);
186 if (!aint) {
168 X509V3err(X509V3_F_S2I_ASN1_INTEGER,X509V3_R_BN_TO_ASN1_INTEGER_ERROR); 187 X509V3err(X509V3_F_S2I_ASN1_INTEGER,X509V3_R_BN_TO_ASN1_INTEGER_ERROR);
169 return 0; 188 return 0;
170 } 189 }
171 BN_free(bn); 190 if (isneg) aint->type |= V_ASN1_NEG;
172 return aint; 191 return aint;
173} 192}
174 193
@@ -221,7 +240,7 @@ int X509V3_get_value_int(CONF_VALUE *value, ASN1_INTEGER **aint)
221 240
222/*#define DEBUG*/ 241/*#define DEBUG*/
223 242
224STACK_OF(CONF_VALUE) *X509V3_parse_list(char *line) 243STACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line)
225{ 244{
226 char *p, *q, c; 245 char *p, *q, c;
227 char *ntmp, *vtmp; 246 char *ntmp, *vtmp;
@@ -250,7 +269,7 @@ STACK_OF(CONF_VALUE) *X509V3_parse_list(char *line)
250 *p = 0; 269 *p = 0;
251 ntmp = strip_spaces(q); 270 ntmp = strip_spaces(q);
252 q = p + 1; 271 q = p + 1;
253#ifdef DEBUG 272#if 0
254 printf("%s\n", ntmp); 273 printf("%s\n", ntmp);
255#endif 274#endif
256 if(!ntmp) { 275 if(!ntmp) {
@@ -266,7 +285,7 @@ STACK_OF(CONF_VALUE) *X509V3_parse_list(char *line)
266 state = HDR_NAME; 285 state = HDR_NAME;
267 *p = 0; 286 *p = 0;
268 vtmp = strip_spaces(q); 287 vtmp = strip_spaces(q);
269#ifdef DEBUG 288#if 0
270 printf("%s\n", ntmp); 289 printf("%s\n", ntmp);
271#endif 290#endif
272 if(!vtmp) { 291 if(!vtmp) {
@@ -283,7 +302,7 @@ STACK_OF(CONF_VALUE) *X509V3_parse_list(char *line)
283 302
284 if(state == HDR_VALUE) { 303 if(state == HDR_VALUE) {
285 vtmp = strip_spaces(q); 304 vtmp = strip_spaces(q);
286#ifdef DEBUG 305#if 0
287 printf("%s=%s\n", ntmp, vtmp); 306 printf("%s=%s\n", ntmp, vtmp);
288#endif 307#endif
289 if(!vtmp) { 308 if(!vtmp) {
@@ -293,7 +312,7 @@ STACK_OF(CONF_VALUE) *X509V3_parse_list(char *line)
293 X509V3_add_value(ntmp, vtmp, &values); 312 X509V3_add_value(ntmp, vtmp, &values);
294 } else { 313 } else {
295 ntmp = strip_spaces(q); 314 ntmp = strip_spaces(q);
296#ifdef DEBUG 315#if 0
297 printf("%s\n", ntmp); 316 printf("%s\n", ntmp);
298#endif 317#endif
299 if(!ntmp) { 318 if(!ntmp) {
@@ -439,7 +458,7 @@ static int sk_strcmp(const char * const *a, const char * const *b)
439 458
440STACK *X509_get1_email(X509 *x) 459STACK *X509_get1_email(X509 *x)
441{ 460{
442 STACK_OF(GENERAL_NAME) *gens; 461 GENERAL_NAMES *gens;
443 STACK *ret; 462 STACK *ret;
444 gens = X509_get_ext_d2i(x, NID_subject_alt_name, NULL, NULL); 463 gens = X509_get_ext_d2i(x, NID_subject_alt_name, NULL, NULL);
445 ret = get_email(X509_get_subject_name(x), gens); 464 ret = get_email(X509_get_subject_name(x), gens);
@@ -449,7 +468,7 @@ STACK *X509_get1_email(X509 *x)
449 468
450STACK *X509_REQ_get1_email(X509_REQ *x) 469STACK *X509_REQ_get1_email(X509_REQ *x)
451{ 470{
452 STACK_OF(GENERAL_NAME) *gens; 471 GENERAL_NAMES *gens;
453 STACK_OF(X509_EXTENSION) *exts; 472 STACK_OF(X509_EXTENSION) *exts;
454 STACK *ret; 473 STACK *ret;
455 exts = X509_REQ_get_extensions(x); 474 exts = X509_REQ_get_extensions(x);
@@ -461,7 +480,7 @@ STACK *X509_REQ_get1_email(X509_REQ *x)
461} 480}
462 481
463 482
464static STACK *get_email(X509_NAME *name, STACK_OF(GENERAL_NAME) *gens) 483static STACK *get_email(X509_NAME *name, GENERAL_NAMES *gens)
465{ 484{
466 STACK *ret = NULL; 485 STACK *ret = NULL;
467 X509_NAME_ENTRY *ne; 486 X509_NAME_ENTRY *ne;
diff --git a/src/lib/libcrypto/x509v3/v3conf.c b/src/lib/libcrypto/x509v3/v3conf.c
index 21cf746f45..67ee14f334 100644
--- a/src/lib/libcrypto/x509v3/v3conf.c
+++ b/src/lib/libcrypto/x509v3/v3conf.c
@@ -60,7 +60,6 @@
60#include <stdio.h> 60#include <stdio.h>
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/asn1.h> 62#include <openssl/asn1.h>
63#include <openssl/asn1_mac.h>
64#include <openssl/conf.h> 63#include <openssl/conf.h>
65#include <openssl/x509.h> 64#include <openssl/x509.h>
66#include <openssl/x509v3.h> 65#include <openssl/x509v3.h>
diff --git a/src/lib/libcrypto/x509v3/v3err.c b/src/lib/libcrypto/x509v3/v3err.c
index aa4a605dc4..6458e95bb9 100644
--- a/src/lib/libcrypto/x509v3/v3err.c
+++ b/src/lib/libcrypto/x509v3/v3err.c
@@ -63,7 +63,7 @@
63#include <openssl/x509v3.h> 63#include <openssl/x509v3.h>
64 64
65/* BEGIN ERROR CODES */ 65/* BEGIN ERROR CODES */
66#ifndef NO_ERR 66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA X509V3_str_functs[]= 67static ERR_STRING_DATA X509V3_str_functs[]=
68 { 68 {
69{ERR_PACK(0,X509V3_F_COPY_EMAIL,0), "COPY_EMAIL"}, 69{ERR_PACK(0,X509V3_F_COPY_EMAIL,0), "COPY_EMAIL"},
@@ -98,6 +98,7 @@ static ERR_STRING_DATA X509V3_str_functs[]=
98{ERR_PACK(0,X509V3_F_V2I_GENERAL_NAME,0), "v2i_GENERAL_NAME"}, 98{ERR_PACK(0,X509V3_F_V2I_GENERAL_NAME,0), "v2i_GENERAL_NAME"},
99{ERR_PACK(0,X509V3_F_V2I_GENERAL_NAMES,0), "v2i_GENERAL_NAMES"}, 99{ERR_PACK(0,X509V3_F_V2I_GENERAL_NAMES,0), "v2i_GENERAL_NAMES"},
100{ERR_PACK(0,X509V3_F_V3_GENERIC_EXTENSION,0), "V3_GENERIC_EXTENSION"}, 100{ERR_PACK(0,X509V3_F_V3_GENERIC_EXTENSION,0), "V3_GENERIC_EXTENSION"},
101{ERR_PACK(0,X509V3_F_X509V3_ADD_I2D,0), "X509V3_ADD_I2D"},
101{ERR_PACK(0,X509V3_F_X509V3_ADD_VALUE,0), "X509V3_add_value"}, 102{ERR_PACK(0,X509V3_F_X509V3_ADD_VALUE,0), "X509V3_add_value"},
102{ERR_PACK(0,X509V3_F_X509V3_EXT_ADD,0), "X509V3_EXT_add"}, 103{ERR_PACK(0,X509V3_F_X509V3_EXT_ADD,0), "X509V3_EXT_add"},
103{ERR_PACK(0,X509V3_F_X509V3_EXT_ADD_ALIAS,0), "X509V3_EXT_add_alias"}, 104{ERR_PACK(0,X509V3_F_X509V3_EXT_ADD_ALIAS,0), "X509V3_EXT_add_alias"},
@@ -106,6 +107,7 @@ static ERR_STRING_DATA X509V3_str_functs[]=
106{ERR_PACK(0,X509V3_F_X509V3_GET_VALUE_BOOL,0), "X509V3_get_value_bool"}, 107{ERR_PACK(0,X509V3_F_X509V3_GET_VALUE_BOOL,0), "X509V3_get_value_bool"},
107{ERR_PACK(0,X509V3_F_X509V3_PARSE_LIST,0), "X509V3_parse_list"}, 108{ERR_PACK(0,X509V3_F_X509V3_PARSE_LIST,0), "X509V3_parse_list"},
108{ERR_PACK(0,X509V3_F_X509_PURPOSE_ADD,0), "X509_PURPOSE_add"}, 109{ERR_PACK(0,X509V3_F_X509_PURPOSE_ADD,0), "X509_PURPOSE_add"},
110{ERR_PACK(0,X509V3_F_X509_PURPOSE_SET,0), "X509_PURPOSE_set"},
109{0,NULL} 111{0,NULL}
110 }; 112 };
111 113
@@ -117,8 +119,10 @@ static ERR_STRING_DATA X509V3_str_reasons[]=
117{X509V3_R_BN_TO_ASN1_INTEGER_ERROR ,"bn to asn1 integer error"}, 119{X509V3_R_BN_TO_ASN1_INTEGER_ERROR ,"bn to asn1 integer error"},
118{X509V3_R_DUPLICATE_ZONE_ID ,"duplicate zone id"}, 120{X509V3_R_DUPLICATE_ZONE_ID ,"duplicate zone id"},
119{X509V3_R_ERROR_CONVERTING_ZONE ,"error converting zone"}, 121{X509V3_R_ERROR_CONVERTING_ZONE ,"error converting zone"},
122{X509V3_R_ERROR_CREATING_EXTENSION ,"error creating extension"},
120{X509V3_R_ERROR_IN_EXTENSION ,"error in extension"}, 123{X509V3_R_ERROR_IN_EXTENSION ,"error in extension"},
121{X509V3_R_EXPECTED_A_SECTION_NAME ,"expected a section name"}, 124{X509V3_R_EXPECTED_A_SECTION_NAME ,"expected a section name"},
125{X509V3_R_EXTENSION_EXISTS ,"extension exists"},
122{X509V3_R_EXTENSION_NAME_ERROR ,"extension name error"}, 126{X509V3_R_EXTENSION_NAME_ERROR ,"extension name error"},
123{X509V3_R_EXTENSION_NOT_FOUND ,"extension not found"}, 127{X509V3_R_EXTENSION_NOT_FOUND ,"extension not found"},
124{X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED,"extension setting not supported"}, 128{X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED,"extension setting not supported"},
@@ -135,6 +139,7 @@ static ERR_STRING_DATA X509V3_str_reasons[]=
135{X509V3_R_INVALID_OBJECT_IDENTIFIER ,"invalid object identifier"}, 139{X509V3_R_INVALID_OBJECT_IDENTIFIER ,"invalid object identifier"},
136{X509V3_R_INVALID_OPTION ,"invalid option"}, 140{X509V3_R_INVALID_OPTION ,"invalid option"},
137{X509V3_R_INVALID_POLICY_IDENTIFIER ,"invalid policy identifier"}, 141{X509V3_R_INVALID_POLICY_IDENTIFIER ,"invalid policy identifier"},
142{X509V3_R_INVALID_PURPOSE ,"invalid purpose"},
138{X509V3_R_INVALID_SECTION ,"invalid section"}, 143{X509V3_R_INVALID_SECTION ,"invalid section"},
139{X509V3_R_INVALID_SYNTAX ,"invalid syntax"}, 144{X509V3_R_INVALID_SYNTAX ,"invalid syntax"},
140{X509V3_R_ISSUER_DECODE_ERROR ,"issuer decode error"}, 145{X509V3_R_ISSUER_DECODE_ERROR ,"issuer decode error"},
@@ -167,7 +172,7 @@ void ERR_load_X509V3_strings(void)
167 if (init) 172 if (init)
168 { 173 {
169 init=0; 174 init=0;
170#ifndef NO_ERR 175#ifndef OPENSSL_NO_ERR
171 ERR_load_strings(ERR_LIB_X509V3,X509V3_str_functs); 176 ERR_load_strings(ERR_LIB_X509V3,X509V3_str_functs);
172 ERR_load_strings(ERR_LIB_X509V3,X509V3_str_reasons); 177 ERR_load_strings(ERR_LIB_X509V3,X509V3_str_reasons);
173#endif 178#endif
diff --git a/src/lib/libcrypto/x509v3/v3prin.c b/src/lib/libcrypto/x509v3/v3prin.c
index ee798859f0..b529814319 100644
--- a/src/lib/libcrypto/x509v3/v3prin.c
+++ b/src/lib/libcrypto/x509v3/v3prin.c
@@ -59,9 +59,7 @@
59 59
60 60
61#include <stdio.h> 61#include <stdio.h>
62#include "cryptlib.h"
63#include <openssl/asn1.h> 62#include <openssl/asn1.h>
64#include <openssl/asn1_mac.h>
65#include <openssl/conf.h> 63#include <openssl/conf.h>
66#include <openssl/x509.h> 64#include <openssl/x509.h>
67#include <openssl/x509v3.h> 65#include <openssl/x509v3.h>
diff --git a/src/lib/libcrypto/x509v3/x509v3.h b/src/lib/libcrypto/x509v3/x509v3.h
index 0453b12d63..daecc55271 100644
--- a/src/lib/libcrypto/x509v3/x509v3.h
+++ b/src/lib/libcrypto/x509v3/x509v3.h
@@ -88,6 +88,9 @@ typedef void * (*X509V3_EXT_R2I)(struct v3_ext_method *method, struct v3_ext_ctx
88struct v3_ext_method { 88struct v3_ext_method {
89int ext_nid; 89int ext_nid;
90int ext_flags; 90int ext_flags;
91/* If this is set the following four fields are ignored */
92ASN1_ITEM_EXP *it;
93/* Old style ASN1 calls */
91X509V3_EXT_NEW ext_new; 94X509V3_EXT_NEW ext_new;
92X509V3_EXT_FREE ext_free; 95X509V3_EXT_FREE ext_free;
93X509V3_EXT_D2I d2i; 96X509V3_EXT_D2I d2i;
@@ -156,35 +159,56 @@ ASN1_OBJECT *type_id;
156ASN1_TYPE *value; 159ASN1_TYPE *value;
157} OTHERNAME; 160} OTHERNAME;
158 161
162typedef struct EDIPartyName_st {
163 ASN1_STRING *nameAssigner;
164 ASN1_STRING *partyName;
165} EDIPARTYNAME;
166
159typedef struct GENERAL_NAME_st { 167typedef struct GENERAL_NAME_st {
160 168
161#define GEN_OTHERNAME (0|V_ASN1_CONTEXT_SPECIFIC) 169#define GEN_OTHERNAME 0
162#define GEN_EMAIL (1|V_ASN1_CONTEXT_SPECIFIC) 170#define GEN_EMAIL 1
163#define GEN_DNS (2|V_ASN1_CONTEXT_SPECIFIC) 171#define GEN_DNS 2
164#define GEN_X400 (3|V_ASN1_CONTEXT_SPECIFIC) 172#define GEN_X400 3
165#define GEN_DIRNAME (4|V_ASN1_CONTEXT_SPECIFIC) 173#define GEN_DIRNAME 4
166#define GEN_EDIPARTY (5|V_ASN1_CONTEXT_SPECIFIC) 174#define GEN_EDIPARTY 5
167#define GEN_URI (6|V_ASN1_CONTEXT_SPECIFIC) 175#define GEN_URI 6
168#define GEN_IPADD (7|V_ASN1_CONTEXT_SPECIFIC) 176#define GEN_IPADD 7
169#define GEN_RID (8|V_ASN1_CONTEXT_SPECIFIC) 177#define GEN_RID 8
170 178
171int type; 179int type;
172union { 180union {
173 char *ptr; 181 char *ptr;
174 ASN1_IA5STRING *ia5;/* rfc822Name, dNSName, uniformResourceIdentifier */ 182 OTHERNAME *otherName; /* otherName */
183 ASN1_IA5STRING *rfc822Name;
184 ASN1_IA5STRING *dNSName;
185 ASN1_TYPE *x400Address;
186 X509_NAME *directoryName;
187 EDIPARTYNAME *ediPartyName;
188 ASN1_IA5STRING *uniformResourceIdentifier;
189 ASN1_OCTET_STRING *iPAddress;
190 ASN1_OBJECT *registeredID;
191
192 /* Old names */
175 ASN1_OCTET_STRING *ip; /* iPAddress */ 193 ASN1_OCTET_STRING *ip; /* iPAddress */
176 X509_NAME *dirn; /* dirn */ 194 X509_NAME *dirn; /* dirn */
195 ASN1_IA5STRING *ia5;/* rfc822Name, dNSName, uniformResourceIdentifier */
177 ASN1_OBJECT *rid; /* registeredID */ 196 ASN1_OBJECT *rid; /* registeredID */
178 OTHERNAME *otherName; /* otherName */ 197 ASN1_TYPE *other; /* x400Address */
179 ASN1_TYPE *other; /* ediPartyName, x400Address */
180} d; 198} d;
181} GENERAL_NAME; 199} GENERAL_NAME;
182 200
201typedef STACK_OF(GENERAL_NAME) GENERAL_NAMES;
202
183typedef struct ACCESS_DESCRIPTION_st { 203typedef struct ACCESS_DESCRIPTION_st {
184 ASN1_OBJECT *method; 204 ASN1_OBJECT *method;
185 GENERAL_NAME *location; 205 GENERAL_NAME *location;
186} ACCESS_DESCRIPTION; 206} ACCESS_DESCRIPTION;
187 207
208typedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS;
209
210typedef STACK_OF(ASN1_OBJECT) EXTENDED_KEY_USAGE;
211
188DECLARE_STACK_OF(GENERAL_NAME) 212DECLARE_STACK_OF(GENERAL_NAME)
189DECLARE_ASN1_SET_OF(GENERAL_NAME) 213DECLARE_ASN1_SET_OF(GENERAL_NAME)
190 214
@@ -192,23 +216,27 @@ DECLARE_STACK_OF(ACCESS_DESCRIPTION)
192DECLARE_ASN1_SET_OF(ACCESS_DESCRIPTION) 216DECLARE_ASN1_SET_OF(ACCESS_DESCRIPTION)
193 217
194typedef struct DIST_POINT_NAME_st { 218typedef struct DIST_POINT_NAME_st {
195/* NB: this is a CHOICE type and only one of these should be set */ 219int type;
196STACK_OF(GENERAL_NAME) *fullname; 220union {
197STACK_OF(X509_NAME_ENTRY) *relativename; 221 GENERAL_NAMES *fullname;
222 STACK_OF(X509_NAME_ENTRY) *relativename;
223} name;
198} DIST_POINT_NAME; 224} DIST_POINT_NAME;
199 225
200typedef struct DIST_POINT_st { 226typedef struct DIST_POINT_st {
201DIST_POINT_NAME *distpoint; 227DIST_POINT_NAME *distpoint;
202ASN1_BIT_STRING *reasons; 228ASN1_BIT_STRING *reasons;
203STACK_OF(GENERAL_NAME) *CRLissuer; 229GENERAL_NAMES *CRLissuer;
204} DIST_POINT; 230} DIST_POINT;
205 231
232typedef STACK_OF(DIST_POINT) CRL_DIST_POINTS;
233
206DECLARE_STACK_OF(DIST_POINT) 234DECLARE_STACK_OF(DIST_POINT)
207DECLARE_ASN1_SET_OF(DIST_POINT) 235DECLARE_ASN1_SET_OF(DIST_POINT)
208 236
209typedef struct AUTHORITY_KEYID_st { 237typedef struct AUTHORITY_KEYID_st {
210ASN1_OCTET_STRING *keyid; 238ASN1_OCTET_STRING *keyid;
211STACK_OF(GENERAL_NAME) *issuer; 239GENERAL_NAMES *issuer;
212ASN1_INTEGER *serial; 240ASN1_INTEGER *serial;
213} AUTHORITY_KEYID; 241} AUTHORITY_KEYID;
214 242
@@ -254,6 +282,8 @@ typedef struct POLICYINFO_st {
254 STACK_OF(POLICYQUALINFO) *qualifiers; 282 STACK_OF(POLICYQUALINFO) *qualifiers;
255} POLICYINFO; 283} POLICYINFO;
256 284
285typedef STACK_OF(POLICYINFO) CERTIFICATEPOLICIES;
286
257DECLARE_STACK_OF(POLICYINFO) 287DECLARE_STACK_OF(POLICYINFO)
258DECLARE_ASN1_SET_OF(POLICYINFO) 288DECLARE_ASN1_SET_OF(POLICYINFO)
259 289
@@ -262,32 +292,24 @@ DECLARE_ASN1_SET_OF(POLICYINFO)
262 292
263#define X509V3_set_ctx_test(ctx) \ 293#define X509V3_set_ctx_test(ctx) \
264 X509V3_set_ctx(ctx, NULL, NULL, NULL, NULL, CTX_TEST) 294 X509V3_set_ctx(ctx, NULL, NULL, NULL, NULL, CTX_TEST)
265#define X509V3_set_ctx_nodb(ctx) ctx->db = NULL; 295#define X509V3_set_ctx_nodb(ctx) (ctx)->db = NULL;
266 296
267#define EXT_BITSTRING(nid, table) { nid, 0, \ 297#define EXT_BITSTRING(nid, table) { nid, 0, ASN1_ITEM_ref(ASN1_BIT_STRING), \
268 (X509V3_EXT_NEW)ASN1_BIT_STRING_new, \ 298 0,0,0,0, \
269 (X509V3_EXT_FREE)ASN1_BIT_STRING_free, \ 299 0,0, \
270 (X509V3_EXT_D2I)d2i_ASN1_BIT_STRING, \
271 (X509V3_EXT_I2D)i2d_ASN1_BIT_STRING, \
272 NULL, NULL, \
273 (X509V3_EXT_I2V)i2v_ASN1_BIT_STRING, \ 300 (X509V3_EXT_I2V)i2v_ASN1_BIT_STRING, \
274 (X509V3_EXT_V2I)v2i_ASN1_BIT_STRING, \ 301 (X509V3_EXT_V2I)v2i_ASN1_BIT_STRING, \
275 NULL, NULL, \ 302 NULL, NULL, \
276 (char *)table} 303 table}
277 304
278#define EXT_IA5STRING(nid) { nid, 0, \ 305#define EXT_IA5STRING(nid) { nid, 0, ASN1_ITEM_ref(ASN1_IA5STRING), \
279 (X509V3_EXT_NEW)ASN1_IA5STRING_new, \ 306 0,0,0,0, \
280 (X509V3_EXT_FREE)ASN1_IA5STRING_free, \
281 (X509V3_EXT_D2I)d2i_ASN1_IA5STRING, \
282 (X509V3_EXT_I2D)i2d_ASN1_IA5STRING, \
283 (X509V3_EXT_I2S)i2s_ASN1_IA5STRING, \ 307 (X509V3_EXT_I2S)i2s_ASN1_IA5STRING, \
284 (X509V3_EXT_S2I)s2i_ASN1_IA5STRING, \ 308 (X509V3_EXT_S2I)s2i_ASN1_IA5STRING, \
285 NULL, NULL, NULL, NULL, \ 309 0,0,0,0, \
286 NULL} 310 NULL}
287 311
288#define EXT_END { -1, 0, NULL, NULL, NULL, NULL, NULL, NULL, \ 312#define EXT_END { -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
289 NULL, NULL, NULL, NULL, \
290 NULL}
291 313
292 314
293/* X509_PURPOSE stuff */ 315/* X509_PURPOSE stuff */
@@ -302,6 +324,7 @@ DECLARE_ASN1_SET_OF(POLICYINFO)
302#define EXFLAG_V1 0x40 324#define EXFLAG_V1 0x40
303#define EXFLAG_INVALID 0x80 325#define EXFLAG_INVALID 0x80
304#define EXFLAG_SET 0x100 326#define EXFLAG_SET 0x100
327#define EXFLAG_CRITICAL 0x200
305 328
306#define KU_DIGITAL_SIGNATURE 0x0080 329#define KU_DIGITAL_SIGNATURE 0x0080
307#define KU_NON_REPUDIATION 0x0040 330#define KU_NON_REPUDIATION 0x0040
@@ -320,12 +343,15 @@ DECLARE_ASN1_SET_OF(POLICYINFO)
320#define NS_SSL_CA 0x04 343#define NS_SSL_CA 0x04
321#define NS_SMIME_CA 0x02 344#define NS_SMIME_CA 0x02
322#define NS_OBJSIGN_CA 0x01 345#define NS_OBJSIGN_CA 0x01
346#define NS_ANY_CA (NS_SSL_CA|NS_SMIME_CA|NS_OBJSIGN_CA)
323 347
324#define XKU_SSL_SERVER 0x1 348#define XKU_SSL_SERVER 0x1
325#define XKU_SSL_CLIENT 0x2 349#define XKU_SSL_CLIENT 0x2
326#define XKU_SMIME 0x4 350#define XKU_SMIME 0x4
327#define XKU_CODE_SIGN 0x8 351#define XKU_CODE_SIGN 0x8
328#define XKU_SGC 0x10 352#define XKU_SGC 0x10
353#define XKU_OCSP_SIGN 0x20
354#define XKU_TIMESTAMP 0x40
329 355
330#define X509_PURPOSE_DYNAMIC 0x1 356#define X509_PURPOSE_DYNAMIC 0x1
331#define X509_PURPOSE_DYNAMIC_NAME 0x2 357#define X509_PURPOSE_DYNAMIC_NAME 0x2
@@ -348,33 +374,40 @@ typedef struct x509_purpose_st {
348#define X509_PURPOSE_SMIME_ENCRYPT 5 374#define X509_PURPOSE_SMIME_ENCRYPT 5
349#define X509_PURPOSE_CRL_SIGN 6 375#define X509_PURPOSE_CRL_SIGN 6
350#define X509_PURPOSE_ANY 7 376#define X509_PURPOSE_ANY 7
377#define X509_PURPOSE_OCSP_HELPER 8
351 378
352#define X509_PURPOSE_MIN 1 379#define X509_PURPOSE_MIN 1
353#define X509_PURPOSE_MAX 7 380#define X509_PURPOSE_MAX 8
381
382/* Flags for X509V3_EXT_print() */
383
384#define X509V3_EXT_UNKNOWN_MASK (0xfL << 16)
385/* Return error for unknown extensions */
386#define X509V3_EXT_DEFAULT 0
387/* Print error for unknown extensions */
388#define X509V3_EXT_ERROR_UNKNOWN (1L << 16)
389/* ASN1 parse unknown extensions */
390#define X509V3_EXT_PARSE_UNKNOWN (2L << 16)
391/* BIO_dump unknown extensions */
392#define X509V3_EXT_DUMP_UNKNOWN (3L << 16)
393
394/* Flags for X509V3_add1_i2d */
395
396#define X509V3_ADD_OP_MASK 0xfL
397#define X509V3_ADD_DEFAULT 0L
398#define X509V3_ADD_APPEND 1L
399#define X509V3_ADD_REPLACE 2L
400#define X509V3_ADD_REPLACE_EXISTING 3L
401#define X509V3_ADD_KEEP_EXISTING 4L
402#define X509V3_ADD_DELETE 5L
403#define X509V3_ADD_SILENT 0x10
354 404
355DECLARE_STACK_OF(X509_PURPOSE) 405DECLARE_STACK_OF(X509_PURPOSE)
356 406
357void ERR_load_X509V3_strings(void); 407DECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS)
358int i2d_BASIC_CONSTRAINTS(BASIC_CONSTRAINTS *a, unsigned char **pp);
359BASIC_CONSTRAINTS *d2i_BASIC_CONSTRAINTS(BASIC_CONSTRAINTS **a, unsigned char **pp, long length);
360BASIC_CONSTRAINTS *BASIC_CONSTRAINTS_new(void);
361void BASIC_CONSTRAINTS_free(BASIC_CONSTRAINTS *a);
362
363int i2d_GENERAL_NAME(GENERAL_NAME *a, unsigned char **pp);
364GENERAL_NAME *d2i_GENERAL_NAME(GENERAL_NAME **a, unsigned char **pp, long length);
365GENERAL_NAME *GENERAL_NAME_new(void);
366void GENERAL_NAME_free(GENERAL_NAME *a);
367STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method, GENERAL_NAME *gen, STACK_OF(CONF_VALUE) *ret);
368
369int i2d_SXNET(SXNET *a, unsigned char **pp);
370SXNET *d2i_SXNET(SXNET **a, unsigned char **pp, long length);
371SXNET *SXNET_new(void);
372void SXNET_free(SXNET *a);
373 408
374int i2d_SXNETID(SXNETID *a, unsigned char **pp); 409DECLARE_ASN1_FUNCTIONS(SXNET)
375SXNETID *d2i_SXNETID(SXNETID **a, unsigned char **pp, long length); 410DECLARE_ASN1_FUNCTIONS(SXNETID)
376SXNETID *SXNETID_new(void);
377void SXNETID_free(SXNETID *a);
378 411
379int SXNET_add_id_asc(SXNET **psx, char *zone, char *user, int userlen); 412int SXNET_add_id_asc(SXNET **psx, char *zone, char *user, int userlen);
380int SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, char *user, int userlen); 413int SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, char *user, int userlen);
@@ -384,108 +417,66 @@ ASN1_OCTET_STRING *SXNET_get_id_asc(SXNET *sx, char *zone);
384ASN1_OCTET_STRING *SXNET_get_id_ulong(SXNET *sx, unsigned long lzone); 417ASN1_OCTET_STRING *SXNET_get_id_ulong(SXNET *sx, unsigned long lzone);
385ASN1_OCTET_STRING *SXNET_get_id_INTEGER(SXNET *sx, ASN1_INTEGER *zone); 418ASN1_OCTET_STRING *SXNET_get_id_INTEGER(SXNET *sx, ASN1_INTEGER *zone);
386 419
387int i2d_AUTHORITY_KEYID(AUTHORITY_KEYID *a, unsigned char **pp); 420DECLARE_ASN1_FUNCTIONS(AUTHORITY_KEYID)
388AUTHORITY_KEYID *d2i_AUTHORITY_KEYID(AUTHORITY_KEYID **a, unsigned char **pp, long length);
389AUTHORITY_KEYID *AUTHORITY_KEYID_new(void);
390void AUTHORITY_KEYID_free(AUTHORITY_KEYID *a);
391 421
392int i2d_PKEY_USAGE_PERIOD(PKEY_USAGE_PERIOD *a, unsigned char **pp); 422DECLARE_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD)
393PKEY_USAGE_PERIOD *d2i_PKEY_USAGE_PERIOD(PKEY_USAGE_PERIOD **a, unsigned char **pp, long length); 423
394PKEY_USAGE_PERIOD *PKEY_USAGE_PERIOD_new(void); 424DECLARE_ASN1_FUNCTIONS(GENERAL_NAME)
395void PKEY_USAGE_PERIOD_free(PKEY_USAGE_PERIOD *a); 425
426STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method, GENERAL_NAME *gen, STACK_OF(CONF_VALUE) *ret);
427int GENERAL_NAME_print(BIO *out, GENERAL_NAME *gen);
428
429DECLARE_ASN1_FUNCTIONS(GENERAL_NAMES)
396 430
397STACK_OF(GENERAL_NAME) *GENERAL_NAMES_new(void);
398void GENERAL_NAMES_free(STACK_OF(GENERAL_NAME) *a);
399STACK_OF(GENERAL_NAME) *d2i_GENERAL_NAMES(STACK_OF(GENERAL_NAME) **a, unsigned char **pp, long length);
400int i2d_GENERAL_NAMES(STACK_OF(GENERAL_NAME) *a, unsigned char **pp);
401STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method, 431STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method,
402 STACK_OF(GENERAL_NAME) *gen, STACK_OF(CONF_VALUE) *extlist); 432 GENERAL_NAMES *gen, STACK_OF(CONF_VALUE) *extlist);
403STACK_OF(GENERAL_NAME) *v2i_GENERAL_NAMES(X509V3_EXT_METHOD *method, 433GENERAL_NAMES *v2i_GENERAL_NAMES(X509V3_EXT_METHOD *method,
404 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); 434 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval);
405 435
406int i2d_OTHERNAME(OTHERNAME *a, unsigned char **pp); 436DECLARE_ASN1_FUNCTIONS(OTHERNAME)
407OTHERNAME *OTHERNAME_new(void); 437DECLARE_ASN1_FUNCTIONS(EDIPARTYNAME)
408OTHERNAME *d2i_OTHERNAME(OTHERNAME **a, unsigned char **pp, long length);
409void OTHERNAME_free(OTHERNAME *a);
410 438
411char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, ASN1_OCTET_STRING *ia5); 439char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, ASN1_OCTET_STRING *ia5);
412ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str); 440ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str);
413 441
414int i2d_ext_ku(STACK_OF(ASN1_OBJECT) *a, unsigned char **pp); 442DECLARE_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE)
415STACK_OF(ASN1_OBJECT) *d2i_ext_ku(STACK_OF(ASN1_OBJECT) **a, 443int i2a_ACCESS_DESCRIPTION(BIO *bp, ACCESS_DESCRIPTION* a);
416 unsigned char **pp, long length); 444
417void ext_ku_free(STACK_OF(ASN1_OBJECT) *a); 445DECLARE_ASN1_FUNCTIONS(CERTIFICATEPOLICIES)
418STACK_OF(ASN1_OBJECT) *ext_ku_new(void); 446DECLARE_ASN1_FUNCTIONS(POLICYINFO)
419 447DECLARE_ASN1_FUNCTIONS(POLICYQUALINFO)
420int i2d_CERTIFICATEPOLICIES(STACK_OF(POLICYINFO) *a, unsigned char **pp); 448DECLARE_ASN1_FUNCTIONS(USERNOTICE)
421STACK_OF(POLICYINFO) *CERTIFICATEPOLICIES_new(void); 449DECLARE_ASN1_FUNCTIONS(NOTICEREF)
422void CERTIFICATEPOLICIES_free(STACK_OF(POLICYINFO) *a);
423STACK_OF(POLICYINFO) *d2i_CERTIFICATEPOLICIES(STACK_OF(POLICYINFO) **a, unsigned char **pp, long length);
424
425int i2d_POLICYINFO(POLICYINFO *a, unsigned char **pp);
426POLICYINFO *POLICYINFO_new(void);
427POLICYINFO *d2i_POLICYINFO(POLICYINFO **a, unsigned char **pp, long length);
428void POLICYINFO_free(POLICYINFO *a);
429
430int i2d_POLICYQUALINFO(POLICYQUALINFO *a, unsigned char **pp);
431POLICYQUALINFO *POLICYQUALINFO_new(void);
432POLICYQUALINFO *d2i_POLICYQUALINFO(POLICYQUALINFO **a, unsigned char **pp,
433 long length);
434void POLICYQUALINFO_free(POLICYQUALINFO *a);
435
436int i2d_USERNOTICE(USERNOTICE *a, unsigned char **pp);
437USERNOTICE *USERNOTICE_new(void);
438USERNOTICE *d2i_USERNOTICE(USERNOTICE **a, unsigned char **pp, long length);
439void USERNOTICE_free(USERNOTICE *a);
440
441int i2d_NOTICEREF(NOTICEREF *a, unsigned char **pp);
442NOTICEREF *NOTICEREF_new(void);
443NOTICEREF *d2i_NOTICEREF(NOTICEREF **a, unsigned char **pp, long length);
444void NOTICEREF_free(NOTICEREF *a);
445
446int i2d_CRL_DIST_POINTS(STACK_OF(DIST_POINT) *a, unsigned char **pp);
447STACK_OF(DIST_POINT) *CRL_DIST_POINTS_new(void);
448void CRL_DIST_POINTS_free(STACK_OF(DIST_POINT) *a);
449STACK_OF(DIST_POINT) *d2i_CRL_DIST_POINTS(STACK_OF(DIST_POINT) **a,
450 unsigned char **pp,long length);
451
452int i2d_DIST_POINT(DIST_POINT *a, unsigned char **pp);
453DIST_POINT *DIST_POINT_new(void);
454DIST_POINT *d2i_DIST_POINT(DIST_POINT **a, unsigned char **pp, long length);
455void DIST_POINT_free(DIST_POINT *a);
456
457int i2d_DIST_POINT_NAME(DIST_POINT_NAME *a, unsigned char **pp);
458DIST_POINT_NAME *DIST_POINT_NAME_new(void);
459void DIST_POINT_NAME_free(DIST_POINT_NAME *a);
460DIST_POINT_NAME *d2i_DIST_POINT_NAME(DIST_POINT_NAME **a, unsigned char **pp,
461 long length);
462
463int i2d_ACCESS_DESCRIPTION(ACCESS_DESCRIPTION *a, unsigned char **pp);
464ACCESS_DESCRIPTION *ACCESS_DESCRIPTION_new(void);
465void ACCESS_DESCRIPTION_free(ACCESS_DESCRIPTION *a);
466ACCESS_DESCRIPTION *d2i_ACCESS_DESCRIPTION(ACCESS_DESCRIPTION **a, unsigned char **pp,
467 long length);
468
469STACK_OF(ACCESS_DESCRIPTION) *AUTHORITY_INFO_ACCESS_new(void);
470void AUTHORITY_INFO_ACCESS_free(STACK_OF(ACCESS_DESCRIPTION) *a);
471STACK_OF(ACCESS_DESCRIPTION) *d2i_AUTHORITY_INFO_ACCESS(STACK_OF(ACCESS_DESCRIPTION) **a,
472 unsigned char **pp, long length);
473int i2d_AUTHORITY_INFO_ACCESS(STACK_OF(ACCESS_DESCRIPTION) *a, unsigned char **pp);
474 450
451DECLARE_ASN1_FUNCTIONS(CRL_DIST_POINTS)
452DECLARE_ASN1_FUNCTIONS(DIST_POINT)
453DECLARE_ASN1_FUNCTIONS(DIST_POINT_NAME)
475 454
455DECLARE_ASN1_FUNCTIONS(ACCESS_DESCRIPTION)
456DECLARE_ASN1_FUNCTIONS(AUTHORITY_INFO_ACCESS)
476 457
477#ifdef HEADER_CONF_H 458#ifdef HEADER_CONF_H
478GENERAL_NAME *v2i_GENERAL_NAME(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, CONF_VALUE *cnf); 459GENERAL_NAME *v2i_GENERAL_NAME(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, CONF_VALUE *cnf);
479void X509V3_conf_free(CONF_VALUE *val); 460void X509V3_conf_free(CONF_VALUE *val);
461
462X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid, char *value);
463X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, char *name, char *value);
464int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, char *section, STACK_OF(X509_EXTENSION) **sk);
465int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509 *cert);
466int X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_REQ *req);
467int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section, X509_CRL *crl);
468
480X509_EXTENSION *X509V3_EXT_conf_nid(LHASH *conf, X509V3_CTX *ctx, int ext_nid, char *value); 469X509_EXTENSION *X509V3_EXT_conf_nid(LHASH *conf, X509V3_CTX *ctx, int ext_nid, char *value);
481X509_EXTENSION *X509V3_EXT_conf(LHASH *conf, X509V3_CTX *ctx, char *name, char *value); 470X509_EXTENSION *X509V3_EXT_conf(LHASH *conf, X509V3_CTX *ctx, char *name, char *value);
482int X509V3_EXT_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509 *cert); 471int X509V3_EXT_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509 *cert);
483int X509V3_EXT_REQ_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509_REQ *req); 472int X509V3_EXT_REQ_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509_REQ *req);
484int X509V3_EXT_CRL_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509_CRL *crl); 473int X509V3_EXT_CRL_add_conf(LHASH *conf, X509V3_CTX *ctx, char *section, X509_CRL *crl);
474
485int X509V3_add_value_bool_nf(char *name, int asn1_bool, 475int X509V3_add_value_bool_nf(char *name, int asn1_bool,
486 STACK_OF(CONF_VALUE) **extlist); 476 STACK_OF(CONF_VALUE) **extlist);
487int X509V3_get_value_bool(CONF_VALUE *value, int *asn1_bool); 477int X509V3_get_value_bool(CONF_VALUE *value, int *asn1_bool);
488int X509V3_get_value_int(CONF_VALUE *value, ASN1_INTEGER **aint); 478int X509V3_get_value_int(CONF_VALUE *value, ASN1_INTEGER **aint);
479void X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf);
489void X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH *lhash); 480void X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH *lhash);
490#endif 481#endif
491 482
@@ -516,11 +507,13 @@ void X509V3_EXT_cleanup(void);
516X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext); 507X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext);
517X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid); 508X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid);
518int X509V3_add_standard_extensions(void); 509int X509V3_add_standard_extensions(void);
519STACK_OF(CONF_VALUE) *X509V3_parse_list(char *line); 510STACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line);
520void *X509V3_EXT_d2i(X509_EXTENSION *ext); 511void *X509V3_EXT_d2i(X509_EXTENSION *ext);
521void *X509V3_get_d2i(STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx); 512void *X509V3_get_d2i(STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx);
522 513
514
523X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc); 515X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc);
516int X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value, int crit, unsigned long flags);
524 517
525char *hex_to_string(unsigned char *buffer, long len); 518char *hex_to_string(unsigned char *buffer, long len);
526unsigned char *string_to_hex(char *str, long *len); 519unsigned char *string_to_hex(char *str, long *len);
@@ -528,10 +521,14 @@ int name_cmp(const char *name, const char *cmp);
528 521
529void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent, 522void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent,
530 int ml); 523 int ml);
531int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, int flag, int indent); 524int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, int indent);
532int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent); 525int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent);
533 526
527int X509V3_extensions_print(BIO *out, char *title, STACK_OF(X509_EXTENSION) *exts, unsigned long flag, int indent);
528
534int X509_check_purpose(X509 *x, int id, int ca); 529int X509_check_purpose(X509 *x, int id, int ca);
530int X509_supported_extension(X509_EXTENSION *ex);
531int X509_PURPOSE_set(int *p, int purpose);
535int X509_check_issued(X509 *issuer, X509 *subject); 532int X509_check_issued(X509 *issuer, X509 *subject);
536int X509_PURPOSE_get_count(void); 533int X509_PURPOSE_get_count(void);
537X509_PURPOSE * X509_PURPOSE_get0(int idx); 534X509_PURPOSE * X509_PURPOSE_get0(int idx);
@@ -555,6 +552,7 @@ void X509_email_free(STACK *sk);
555/* The following lines are auto generated by the script mkerr.pl. Any changes 552/* The following lines are auto generated by the script mkerr.pl. Any changes
556 * made after this point may be overwritten when the script is next run. 553 * made after this point may be overwritten when the script is next run.
557 */ 554 */
555void ERR_load_X509V3_strings(void);
558 556
559/* Error codes for the X509V3 functions. */ 557/* Error codes for the X509V3 functions. */
560 558
@@ -591,6 +589,7 @@ void X509_email_free(STACK *sk);
591#define X509V3_F_V2I_GENERAL_NAME 117 589#define X509V3_F_V2I_GENERAL_NAME 117
592#define X509V3_F_V2I_GENERAL_NAMES 118 590#define X509V3_F_V2I_GENERAL_NAMES 118
593#define X509V3_F_V3_GENERIC_EXTENSION 116 591#define X509V3_F_V3_GENERIC_EXTENSION 116
592#define X509V3_F_X509V3_ADD_I2D 140
594#define X509V3_F_X509V3_ADD_VALUE 105 593#define X509V3_F_X509V3_ADD_VALUE 105
595#define X509V3_F_X509V3_EXT_ADD 104 594#define X509V3_F_X509V3_EXT_ADD 104
596#define X509V3_F_X509V3_EXT_ADD_ALIAS 106 595#define X509V3_F_X509V3_EXT_ADD_ALIAS 106
@@ -599,6 +598,7 @@ void X509_email_free(STACK *sk);
599#define X509V3_F_X509V3_GET_VALUE_BOOL 110 598#define X509V3_F_X509V3_GET_VALUE_BOOL 110
600#define X509V3_F_X509V3_PARSE_LIST 109 599#define X509V3_F_X509V3_PARSE_LIST 109
601#define X509V3_F_X509_PURPOSE_ADD 137 600#define X509V3_F_X509_PURPOSE_ADD 137
601#define X509V3_F_X509_PURPOSE_SET 141
602 602
603/* Reason codes. */ 603/* Reason codes. */
604#define X509V3_R_BAD_IP_ADDRESS 118 604#define X509V3_R_BAD_IP_ADDRESS 118
@@ -607,8 +607,10 @@ void X509_email_free(STACK *sk);
607#define X509V3_R_BN_TO_ASN1_INTEGER_ERROR 101 607#define X509V3_R_BN_TO_ASN1_INTEGER_ERROR 101
608#define X509V3_R_DUPLICATE_ZONE_ID 133 608#define X509V3_R_DUPLICATE_ZONE_ID 133
609#define X509V3_R_ERROR_CONVERTING_ZONE 131 609#define X509V3_R_ERROR_CONVERTING_ZONE 131
610#define X509V3_R_ERROR_CREATING_EXTENSION 144
610#define X509V3_R_ERROR_IN_EXTENSION 128 611#define X509V3_R_ERROR_IN_EXTENSION 128
611#define X509V3_R_EXPECTED_A_SECTION_NAME 137 612#define X509V3_R_EXPECTED_A_SECTION_NAME 137
613#define X509V3_R_EXTENSION_EXISTS 145
612#define X509V3_R_EXTENSION_NAME_ERROR 115 614#define X509V3_R_EXTENSION_NAME_ERROR 115
613#define X509V3_R_EXTENSION_NOT_FOUND 102 615#define X509V3_R_EXTENSION_NOT_FOUND 102
614#define X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED 103 616#define X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED 103
@@ -625,6 +627,7 @@ void X509_email_free(STACK *sk);
625#define X509V3_R_INVALID_OBJECT_IDENTIFIER 110 627#define X509V3_R_INVALID_OBJECT_IDENTIFIER 110
626#define X509V3_R_INVALID_OPTION 138 628#define X509V3_R_INVALID_OPTION 138
627#define X509V3_R_INVALID_POLICY_IDENTIFIER 134 629#define X509V3_R_INVALID_POLICY_IDENTIFIER 134
630#define X509V3_R_INVALID_PURPOSE 146
628#define X509V3_R_INVALID_SECTION 135 631#define X509V3_R_INVALID_SECTION 135
629#define X509V3_R_INVALID_SYNTAX 143 632#define X509V3_R_INVALID_SYNTAX 143
630#define X509V3_R_ISSUER_DECODE_ERROR 126 633#define X509V3_R_ISSUER_DECODE_ERROR 126
@@ -650,4 +653,3 @@ void X509_email_free(STACK *sk);
650} 653}
651#endif 654#endif
652#endif 655#endif
653